<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39370 >
Committed trunk revision 13093. Adopted some of Per's syntax, with my ruleset option, attached for posterity.
Index: server/citytools.c =================================================================== --- server/citytools.c (revision 13092) +++ server/citytools.c (working copy) @@ -801,7 +801,8 @@ give_citymap_from_player_to_player(pcity, pgiver, ptaker); old_vision = pcity->server.vision; - pcity->server.vision = vision_new(ptaker, pcity->tile, FALSE); + pcity->server.vision = vision_new(ptaker, pcity->tile); + vision_reveal_tiles(pcity->server.vision, game.info.city_reveal_tiles); vision_layer_iterate(v) { vision_change_sight(pcity->server.vision, v, vision_get_sight(old_vision, v)); @@ -985,7 +986,8 @@ } /* Before arranging workers to show unknown land */ - pcity->server.vision = vision_new(pplayer, ptile, FALSE); + pcity->server.vision = vision_new(pplayer, ptile); + vision_reveal_tiles(pcity->server.vision, game.info.city_reveal_tiles); city_refresh_vision(pcity); tile_set_city(ptile, pcity); Index: server/ruleset.c =================================================================== --- server/ruleset.c (revision 13092) +++ server/ruleset.c (working copy) @@ -2684,6 +2684,10 @@ exit(EXIT_FAILURE); } + /* civ1 & 2 didn't reveal tiles */ + game.info.city_reveal_tiles = + secfile_lookup_bool_default(file, FALSE, "parameters.vision_reveal_tiles"); + /* City Styles ... */ styles = secfile_get_secnames_prefix(file, CITYSTYLE_SECTION_PREFIX, &nval); Index: server/maphand.c =================================================================== --- server/maphand.c (revision 13092) +++ server/maphand.c (working copy) @@ -1713,14 +1713,13 @@ See documentation in maphand.h. ****************************************************************************/ -struct vision *vision_new(struct player *pplayer, struct tile *ptile, - bool can_reveal_tiles) +struct vision *vision_new(struct player *pplayer, struct tile *ptile) { struct vision *vision = fc_malloc(sizeof(*vision)); vision->player = pplayer; vision->tile = ptile; - vision->can_reveal_tiles = can_reveal_tiles; + vision->can_reveal_tiles = TRUE; vision_layer_iterate(v) { vision->radius_sq[v] = -1; } vision_layer_iterate_end; @@ -1729,6 +1728,20 @@ } /**************************************************************************** + Sets the can_reveal_tiles flag. + Returns the old flag. + + See documentation in maphand.h. +****************************************************************************/ +bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles) +{ + bool was = vision->can_reveal_tiles; + + vision->can_reveal_tiles = reveal_tiles; + return was; +} + +/**************************************************************************** Returns the sight points (radius_sq) that this vision source has. See documentation in maphand.h. Index: server/maphand.h =================================================================== --- server/maphand.h (revision 13092) +++ server/maphand.h (working copy) @@ -120,9 +120,9 @@ only rarely be necessary since all fogging and unfogging operations are taken care of internally. - The can_reveal_tiles parameter controls whether the vision source can - discover new (unknown) tiles or simply maintain vision on already-known - tiles. Currently cities should pass FALSE for this since they cannot + vision_reveal_tiles() controls whether the vision source can discover + new (unknown) tiles or simply maintain vision on already-known tiles. + By default, cities should pass FALSE for this since they cannot discover new tiles. ***** IMPORTANT ***** @@ -137,7 +137,7 @@ visible. For instance to move a unit: old_vision = punit->server.vision; - punit->server.vision = vision_new(punit->owner, dest_tile, TRUE); + punit->server.vision = vision_new(punit->owner, dest_tile); vision_change_sight(punit->server.vision, get_unit_vision_at(punit, dest_tile)); @@ -151,8 +151,8 @@ a unit or city between players, etc. ****************************************************************************/ struct vision; -struct vision *vision_new(struct player *pplayer, struct tile *ptile, - bool can_reveal_tiles); +struct vision *vision_new(struct player *pplayer, struct tile *ptile); +bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles); int vision_get_sight(const struct vision *vision, enum vision_layer vlayer); void vision_change_sight(struct vision *vision, enum vision_layer vlayer, int radius_sq); Index: server/unittools.c =================================================================== --- server/unittools.c (revision 13092) +++ server/unittools.c (working copy) @@ -1378,7 +1378,7 @@ send_city_info(pplayer, pcity); } - punit->server.vision = vision_new(pplayer, ptile, TRUE); + punit->server.vision = vision_new(pplayer, ptile); unit_refresh_vision(punit); send_unit_info(NULL, punit); @@ -2792,7 +2792,7 @@ unit_list_iterate(cargo_units, pcargo) { struct vision *old_vision = pcargo->server.vision; - pcargo->server.vision = vision_new(pcargo->owner, pdesttile, TRUE); + pcargo->server.vision = vision_new(pcargo->owner, pdesttile); vision_layer_iterate(v) { vision_change_sight(pcargo->server.vision, v, get_unit_vision_at(pcargo, pdesttile, v)); @@ -2823,7 +2823,7 @@ move */ /* Enhance vision if unit steps into a fortress */ - punit->server.vision = vision_new(punit->owner, pdesttile, TRUE); + punit->server.vision = vision_new(punit->owner, pdesttile); vision_layer_iterate(v) { vision_change_sight(punit->server.vision, v, get_unit_vision_at(punit, pdesttile, v)); Index: server/unithand.c =================================================================== --- server/unithand.c (revision 13092) +++ server/unithand.c (working copy) @@ -292,7 +292,7 @@ unit_list_prepend(new_owner->units, punit); punit->owner = new_owner; - punit->server.vision = vision_new(new_owner, punit->tile, TRUE); + punit->server.vision = vision_new(new_owner, punit->tile); unit_refresh_vision(punit); } Index: server/savegame.c =================================================================== --- server/savegame.c (revision 13092) +++ server/savegame.c (working copy) @@ -1858,7 +1858,7 @@ } /* allocate the unit's contribution to fog of war */ - punit->server.vision = vision_new(punit->owner, punit->tile, TRUE); + punit->server.vision = vision_new(punit->owner, punit->tile); unit_refresh_vision(punit); /* NOTE: There used to be some map_set_known calls here. These were * unneeded since unfogging the tile when the unit sees it will @@ -2434,7 +2434,8 @@ } /* adding the cities contribution to fog-of-war */ - pcity->server.vision = vision_new(pcity->owner, pcity->tile, FALSE); + pcity->server.vision = vision_new(pcity->owner, pcity->tile); + vision_reveal_tiles(pcity->server.vision, game.info.city_reveal_tiles); city_refresh_vision(pcity); pcity->units_supported = unit_list_new(); Index: data/default/cities.ruleset =================================================================== --- data/default/cities.ruleset (revision 13092) +++ data/default/cities.ruleset (working copy) @@ -53,13 +53,14 @@ add_to_size_limit = 8 ; cities >= this cannot be added to. angry_citizens = 1 ; set to zero to disable angry citizens celebrate_size_limit = 3 ; cities >= can celebrate - changable_tax = 1 ; set to zero to disallow changing of tax rates ;forced_science = 0 ; set these fields when changeable_tax is turned off ;forced_luxury = 100 ;forced_gold = 0 +vision_reveal_tiles = 1 ; civ1 & 2 default zero + ; ; City styles define the way cities are drawn ; Index: common/packets.def =================================================================== --- common/packets.def (revision 13092) +++ common/packets.def (working copy) @@ -429,6 +429,7 @@ UINT8 forced_science; UINT8 forced_luxury; UINT8 forced_gold; + BOOL city_reveal_tiles; UINT8 min_city_center_output[O_MAX]; UINT8 min_dist_bw_cities; UINT8 init_vis_radius_sq;
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev