Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
September 2005: [Freeciv-Dev] (PR#13961) remove wipe_unit_spec_safe |
![]() |
[Freeciv-Dev] (PR#13961) remove wipe_unit_spec_safe[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13961 > This patch removes wipe_unit_spec_safe. Now there is just wipe_unit. The "spec_safe" part of the function name is a historical anomaly; this function isn't any safer than wipe_unit. There is one difference however: this function takes a wipe_cargo parameter. With the change the cargo is always wiped. The non-wiping form was only used in 3 places and changing it shouldn't make any substantial differences here. This is a minor cleanup that should be a first step toward other cleanups: - wipe_unit should be cleaned up internally to make use of gen-movement. - many callers should be adjusted; for instance nuke_unit will give one message for each wiped unit (under the change it will often not give messages for wiped cargo). -jason Index: server/maphand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v retrieving revision 1.176 diff -p -u -r1.176 maphand.c --- server/maphand.c 5 Sep 2005 15:55:46 -0000 1.176 +++ server/maphand.c 14 Sep 2005 02:55:09 -0000 @@ -1491,7 +1491,7 @@ static void bounce_units_on_terrain_chan punit->tile, E_UNIT_LOST, _("Disbanded your %s due to changing terrain."), unit_name(punit->type)); - wipe_unit_spec_safe(punit, FALSE); + wipe_unit(punit); } } } unit_list_iterate_safe_end; Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.385 diff -p -u -r1.385 unittools.c --- server/unittools.c 8 Sep 2005 19:47:38 -0000 1.385 +++ server/unittools.c 14 Sep 2005 02:55:10 -0000 @@ -1503,8 +1503,9 @@ static void server_remove_unit(struct un Remove the unit, and passengers if it is a carrying any. Remove the _minimum_ number, eg there could be another boat on the square. **************************************************************************/ -void wipe_unit_spec_safe(struct unit *punit, bool wipe_cargo) +void wipe_unit(struct unit *punit) { + bool wipe_cargo = TRUE; /* This used to be a function parameter. */ struct tile *ptile = punit->tile; struct player *pplayer = unit_owner(punit); struct unit_type *ptype = unit_type(punit); @@ -1608,14 +1609,6 @@ void wipe_unit_spec_safe(struct unit *pu } /************************************************************************** -... -**************************************************************************/ -void wipe_unit(struct unit *punit) -{ - wipe_unit_spec_safe(punit, TRUE); -} - -/************************************************************************** this is a highlevel routine the unit has been killed in combat => all other units on the tile dies unless ... @@ -1746,13 +1739,12 @@ void kill_unit(struct unit *pkiller, str } /* remove the units */ - unit_list_iterate(punit->tile->units, punit2) { + unit_list_iterate_safe(punit->tile->units, punit2) { if (pplayers_at_war(unit_owner(pkiller), unit_owner(punit2))) { gamelog(GAMELOG_UNITLOSS, punit2, destroyer); - wipe_unit_spec_safe(punit2, FALSE); + wipe_unit(punit2); } - } - unit_list_iterate_end; + } unit_list_iterate_safe_end; } } @@ -1982,7 +1974,7 @@ static void do_nuke_tile(struct player * { struct city *pcity = tile_get_city(ptile); - unit_list_iterate(ptile->units, punit) { + unit_list_iterate_safe(ptile->units, punit) { notify_player(unit_owner(punit), ptile, E_UNIT_LOST, _("Your %s was nuked by %s."), unit_name(punit->type), @@ -1994,8 +1986,8 @@ static void do_nuke_tile(struct player * unit_owner(punit)->name, unit_name(punit->type)); } - wipe_unit_spec_safe(punit, FALSE); - } unit_list_iterate_end; + wipe_unit(punit); + } unit_list_iterate_safe_end; if (pcity) { notify_player(city_owner(pcity), Index: server/unittools.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.h,v retrieving revision 1.75 diff -p -u -r1.75 unittools.h --- server/unittools.h 22 Jul 2005 16:18:08 -0000 1.75 +++ server/unittools.h 14 Sep 2005 02:55:10 -0000 @@ -62,7 +62,6 @@ struct unit *create_unit_full(struct pla int homecity_id, int moves_left, int hp_left, struct unit *ptrans); void wipe_unit(struct unit *punit); -void wipe_unit_spec_safe(struct unit *punit, bool wipe_cargo); void kill_unit(struct unit *pkiller, struct unit *punit); /* sending to client */
|