[Freeciv-Dev] Re: Reproducable core dump (PR#1051)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
> Index: server/gotohand.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
> retrieving revision 1.122
> diff -u -r1.122 gotohand.c
> --- server/gotohand.c 2001/10/08 12:11:17 1.122
> +++ server/gotohand.c 2001/11/30 20:12:27
> @@ -38,6 +38,15 @@
> /* These are used for airplane GOTOs with waypoints */
> #define MAXFUEL 100
>
> +/* These should be either true or false. They are used for finding routes
> + for airplanes - the airplane doesn't want to fly through occupied
> + territory, but most territory will be either fogged or unknown entirely.
> + See airspace_looks_usable(). Note that this is currently only used
> + by the move-counting function air_can_move_between(), not by
> + the path-finding function (whatever that may be). */
This comment's format looks odd. But never mind ;-).
> +#define AIR_ASSUMES_UNKNOWN_SAFE TRUE
> +#define AIR_ASSUMES_FOGGED_SAFE TRUE
> +
> enum refuel_type {
> FUEL_START = 0, FUEL_GOAL, FUEL_CITY, FUEL_AIRBASE
> };
> @@ -1429,6 +1438,38 @@
> }
>
> /**************************************************************************
> + Returns true if the given map position has airspace that _looks_
> + usable to the player. The airspace is unusable if the player
> + believes there is an enemy unit on it. This is tricky, since we have to
> + consider what the player knows/doesn't know.
> +**************************************************************************/
> +int airspace_looks_usable(int x, int y, struct player *pplayer)
> +{
> + struct tile * ptile = map_get_tile(x, y);
> +
> + /* If the tile's unknown, we (may) assume it's empty. */
> + if (ai_handicap(pplayer, H_MAP) &&
This is odd. If pplayer is not AI, ai_handicap() will return -1, which is
nonzero so it will always return AIR_ASSUMES_UNKNOWN_SAFE for human players.
If it's an intent, it should be stated some comment clearly, otherwise you
should first test if the player is AI-controlled.
> + !map_get_known(x, y, pplayer)) {
> + return AIR_ASSUMES_UNKNOWN_SAFE;
> + }
> +
> + /* This is bad: there could be a city there that the player doesn't
> + know about. How can we check that? */
> + if (is_non_allied_city_tile(ptile, pplayer)) {
> + return 0;
> + }
> +
> + /* If the tile's fogged we again (may) assume it's empty. */
> + if (ai_handicap(pplayer, H_FOG) &&
Again.
> + !map_get_known_and_seen(x, y, pplayer)) {
> + return AIR_ASSUMES_FOGGED_SAFE;
> + }
> +
> + /* Finally, we check to see if there's an enemy unit on the tile. */
> + return !is_non_allied_unit_tile(ptile, pplayer);
> +}
> +
> +/**************************************************************************
> Returns #moves left when player playerid is moving a unit from src_x,src_y
> to
> dest_x,dest_y in moves moves. [Kero]
> If there was no way to move between returns -1.
--
Petr "Pasky" Baudis
UN*X programmer, UN*X administrator, hobbies = IPv6, IRC, FreeCiv hacking
.
"A common mistake that people make, when trying to design
something completely foolproof is to underestimate the
ingenuity of complete fools."
-- Douglas Adams in Mostly Harmless
.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/
- [Freeciv-Dev] Re: Reproducable core dump (PR#1051), (continued)
[Freeciv-Dev] Re: Reproducable core dump (PR#1051), Raimar Falke, 2001/11/30
[Freeciv-Dev] Re: Reproducable core dump (PR#1051), jdorje, 2001/11/30
[Freeciv-Dev] Re: Reproducable core dump (PR#1051), jdorje, 2001/11/30
|
|