[Freeciv-Dev] Re: (PR#12950) Failed sanity check in latest cvs.
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12950 >
Per I. Mathisen wrote:
...
> The attached patch should fix all the problems, including fogging.
...
> void real_unit_change_homecity(struct unit *punit, struct city *new_pcity)
...
> + if (old_owner != new_owner) {
> + remove_unit_sight_points(punit);
> +
> + unit_list_unlink(old_owner->units, punit);
> + unit_list_prepend(new_owner->units, punit);
> + punit->owner = new_owner->player_no;
> +
> + if (tile_has_special(punit->tile, S_FORTRESS)
> + && unit_profits_of_watchtower(punit)) {
> + unfog_area(new_owner, punit->tile, get_watchtower_vision(punit));
> + } else {
> + unfog_area(new_owner, punit->tile, unit_type(punit)->vision_range);
> + }
> +
> + conceal_hidden_units(old_owner, punit->tile);
> + reveal_hidden_units(new_owner, punit->tile);
> + }
...
I'd say that was crying out for a function called add_unit_sight_points.
I did a bit more work on the problem between my previous post and yours,
producing the following:
server/maphand.c:
/**************************************************************************
+For adding a unit.
+**************************************************************************/
+void add_unit_sight_points(struct unit *punit)
+{
+ struct tile *ptile = punit->tile;
+ struct player *pplayer = unit_owner(punit);
+
+ freelog(LOG_DEBUG, "Adding unit sight points at %i,%i",
+ TILE_XY(punit->tile));
+
+ if (tile_has_special(punit->tile, S_FORTRESS)
+ && unit_profits_of_watchtower(punit))
+ unfog_area(pplayer, ptile, get_watchtower_vision(punit));
+ else
+ unfog_area(pplayer, ptile, unit_type(punit)->vision_range);
+}
+
|
|