diff -Nur -X/mnt/data/freeciv-dev/freeciv/diff_ignore freeciv/server/citytools.c codeciv/server/citytools.c --- freeciv/server/citytools.c Sat Dec 29 14:12:43 2001 +++ codeciv/server/citytools.c Sun Dec 30 20:56:36 2001 @@ -519,8 +519,8 @@ /********************************************************************* Note: the old unit is not wiped here. ***********************************************************************/ -static void transfer_unit(struct unit *punit, struct city *tocity, - int verbose) +static void transfer_unit_to_city(struct unit *punit, struct city *tocity, + int verbose) { struct player *from_player = unit_owner(punit); struct player *to_player = city_owner(tocity); @@ -535,20 +535,20 @@ } else { struct city *in_city = map_get_city(punit->x, punit->y); if (in_city) { - freelog(LOG_VERBOSE, "Transfered %s in %s from %s to %s", + freelog(LOG_VERBOSE, "Transferred %s in %s from %s to %s", unit_name(punit->type), in_city->name, from_player->name, to_player->name); if (verbose) { - notify_player(from_player, _("Game: Transfered %s in %s from %s to %s."), + notify_player(from_player, _("Game: Transferred %s in %s from %s to %s."), unit_name(punit->type), in_city->name, from_player->name, to_player->name); } } else { - freelog(LOG_VERBOSE, "Transfered %s from %s to %s", + freelog(LOG_VERBOSE, "Transferred %s from %s to %s", unit_name(punit->type), from_player->name, to_player->name); if (verbose) { - notify_player(from_player, _("Game: Transfered %s from %s to %s."), + notify_player(from_player, _("Game: Transferred %s from %s to %s."), unit_name(punit->type), from_player->name, to_player->name); } @@ -592,7 +592,7 @@ unit_list_iterate(map_get_tile(x, y)->units, vunit) { /* Don't transfer units already owned by new city-owner --wegge */ if (unit_owner(vunit) == pvictim) { - transfer_unit(vunit, pcity, verbose); + transfer_unit_to_city(vunit, pcity, verbose); wipe_unit_safe(vunit, &myiter); unit_list_unlink(units, vunit); } @@ -606,11 +606,11 @@ if (new_home_city && new_home_city != exclude_city) { /* unit is in another city: make that the new homecity, unless that city is actually the same city (happens if disbanding) */ - transfer_unit(vunit, new_home_city, verbose); + transfer_unit_to_city(vunit, new_home_city, verbose); } else if (kill_outside == -1 || real_map_distance(vunit->x, vunit->y, x, y) <= kill_outside) { /* else transfer to specified city. */ - transfer_unit(vunit, pcity, verbose); + transfer_unit_to_city(vunit, pcity, verbose); } /* not deleting cargo as it may be carried by units transfered later. diff -Nur -X/mnt/data/freeciv-dev/freeciv/diff_ignore freeciv/server/unittools.c codeciv/server/unittools.c --- freeciv/server/unittools.c Sat Dec 29 14:12:48 2001 +++ codeciv/server/unittools.c Sun Dec 30 21:09:43 2001 @@ -1512,26 +1512,18 @@ } } /* end while */ - /* There is only one allied units left on this square. If there is not - enough transporter capacity left send surplus to the closest friendly - city. */ - punit = unit_list_get(&(ptile->units), 0); - + /* There are only allied units left on this square. If there is not + enough transporter capacity left then disband the rest */ if (ptile->terrain == T_OCEAN) { + /* We restart the iteration each time to avoid the possibility of + genlist corruption. I don't think it could happen in the current + rules, but it is easier to be safe than proving that it couldn't :). */ START: unit_list_iterate(ptile->units, vunit) { - if (ground_unit_transporter_capacity(x, y, unit_owner(punit)) < 0) { - unit_list_iterate(ptile->units, wunit) { - if (is_ground_unit(wunit) && wunit->owner == vunit->owner) { - struct city *wcity = - find_closest_owned_city(unit_owner(wunit), x, y, 0, NULL); - if (wcity) - teleport_unit_to_city(wunit, wcity, 0, verbose); - else - disband_stack_conflict_unit(wunit, verbose); - goto START; - } - } unit_list_iterate_end; /* End of find a unit from that player to disband*/ + if (is_ground_unit(vunit) + && ground_unit_transporter_capacity(x, y, unit_owner(vunit)) < 0) { + disband_stack_conflict_unit(vunit, verbose); + goto START; } } unit_list_iterate_end; /* End of find a player */ }