Author: sveinung Date: Wed Apr 5 16:24:34 2017 New Revision: 35206 URL: http://svn.gna.org/viewcvs/freeciv?rev=35206&view=rev Log: Make it possible to check if 0 units is certain.
Allow checking if a player can reason that a tile without any reported units really has no units on it. The presence of units is reported by the units them self or by an occupied city. See hrm Feature #649819 Modified: branches/S3_0/common/player.c branches/S3_0/common/player.h Modified: branches/S3_0/common/player.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/player.c?rev=35206&r1=35205&r2=35206&view=diff ============================================================================== --- branches/S3_0/common/player.c (original) +++ branches/S3_0/common/player.c Wed Apr 5 16:24:34 2017 @@ -897,24 +897,17 @@ } /************************************************************************* - Check if pplayer could see all units on ptile if it had units. + Returns TRUE iff pplayer can trust that ptile really has no units when + it looks empty. A tile looks empty if the player can't see any units on + it and it doesn't contain anything marked as occupied by a unit. See can_player_see_unit_at() for rules about when an unit is visible. **************************************************************************/ -bool can_player_see_hypotetic_units_at(const struct player *pplayer, - const struct tile *ptile) -{ - struct city *pcity; - +bool player_can_trust_tile_has_no_units(const struct player *pplayer, + const struct tile *ptile) +{ /* Can't see invisible units. */ if (!fc_funcs->player_tile_vision_get(ptile, pplayer, V_INVIS)) { - return FALSE; - } - - /* Can't see city units. */ - pcity = tile_city(ptile); - if (pcity && !can_player_see_units_in_city(pplayer, pcity) - && unit_list_size(ptile->units) > 0) { return FALSE; } @@ -925,6 +918,31 @@ return FALSE; } } extra_type_list_iterate_end; + } + + return TRUE; +} + +/************************************************************************* + Check if pplayer could see all units on ptile if it had units. + + See can_player_see_unit_at() for rules about when an unit is visible. +**************************************************************************/ +bool can_player_see_hypotetic_units_at(const struct player *pplayer, + const struct tile *ptile) +{ + struct city *pcity; + + if (!player_can_trust_tile_has_no_units(pplayer, ptile)) { + /* The existance of any units at all is hidden from the player. */ + return FALSE; + } + + /* Can't see city units. */ + pcity = tile_city(ptile); + if (pcity && !can_player_see_units_in_city(pplayer, pcity) + && unit_list_size(ptile->units) > 0) { + return FALSE; } /* Can't see non allied units in transports. */ Modified: branches/S3_0/common/player.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/player.h?rev=35206&r1=35205&r2=35206&view=diff ============================================================================== --- branches/S3_0/common/player.h (original) +++ branches/S3_0/common/player.h Wed Apr 5 16:24:34 2017 @@ -400,8 +400,10 @@ int player_age(const struct player *pplayer); +bool player_can_trust_tile_has_no_units(const struct player *pplayer, + const struct tile *ptile); bool can_player_see_hypotetic_units_at(const struct player *pplayer, - const struct tile *ptile); + const struct tile *ptile); bool can_player_see_unit(const struct player *pplayer, const struct unit *punit); bool can_player_see_unit_at(const struct player *pplayer, _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits