Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2004:
[freeciv-ai] Re: aiair uses set_unit_activity() directly

[freeciv-ai] Re: aiair uses set_unit_activity() directly

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: aiair uses set_unit_activity() directly
From: Jason Dorje Short <jdorje@xxxxxxxxxxxx>
Date: Mon, 30 Aug 2004 19:10:19 -0400

Per Inge Mathisen wrote:
We should whenever possible gate all our server calls through the
appropriate handle_*() functions, instead of doing direct changes to the
server state.

One problem is the handle_* functions generally fail silently if they are given invalid input. Obviously when getting data from a network this is correct. But when an AI is involved we'd usually like an assertion instead.

One idea is to change code in the handle_* functions from

  if (!normalize_map_pos(&x, &y)) return;


  if (!normalize_map_pos(&x, &y)) {
    assert(pplayer->conn != NULL);

which will get the assertions to happen for AI players only (but not for autosettlers of human players). This is a bit ugly but not very hard. Another idea is to have wrappers like ai_handle_* to do the work. Yet another idea is to have the handle_* functions be the wrappers that do sanity checking only and then call an internal function base_handle_* to do the real work, with assertions. Yet another idea is just to ignore the problem - but this can give bizarre errors (like the one where handle_unit_load() was failing silently, causing ferry code to crash obscurely).


[Prev in Thread] Current Thread [Next in Thread]