En/na Matthias Pfafferodt ha escrit:
Follow-up Comment #4, bug #14017 (project freeciv):
good question - I never played a game with a
gameloss unit. Should the unit teleported to
a random place? try the next city? the capital?
I did not resolve the issue with the gameloss unit...
But, at least, it does not crash the server...
I divided the list of units in two packs, the sea units and the
others...
Hope it helps...
Index: server/cityturn.c
===================================================================
--- server/cityturn.c (revision 15866)
+++ server/cityturn.c (working copy)
@@ -32,6 +32,7 @@
#include "game.h"
#include "government.h"
#include "map.h"
+#include "movement.h"
#include "player.h"
#include "specialist.h"
#include "tech.h"
@@ -2328,7 +2329,7 @@
struct tile *ptile_from, *ptile_to;
const char *name_from, *name_to, *nation_from, *nation_to;
char saved_name_from[MAX_LEN_NAME];
- struct city *rcity = NULL;
+ struct city *rcity = NULL, *rseacity = NULL;
if (!pcity_from || !pcity_to) {
return FALSE;
@@ -2409,17 +2410,64 @@
/* find closest city other of the same player than pcity_from */
rcity = find_closest_owned_city(pplayer_from, ptile_from,
FALSE, pcity_from);
+ /* find closest city near sea */
+ rseacity = find_closest_owned_city(pplayer_from, ptile_from,
+ TRUE, pcity_from);
- if (rcity) {
- /* transfer all units to the closest city */
- transfer_city_units(pplayer_from, pplayer_from,
- pcity_from->units_supported, rcity, pcity_from,
- -1, TRUE);
- remove_city(pcity_from);
+ if (rcity || rseacity) {
+ if (rcity == rseacity) {
- notify_player(pplayer_from, ptile_from, E_CITY_LOST,
- _("%s was disbanded by its citizens."),
- saved_name_from);
+ /* transfer all units to the closest city */
+ transfer_city_units(pplayer_from, pplayer_from,
+ pcity_from->units_supported, rcity, pcity_from,
+ -1, TRUE);
+ }
+ else {
+ /* split the unit list in sea and non-sea units */
+
+ struct unit_list *non_sea_units = unit_list_new();
+ struct unit_list *sea_units = unit_list_new();
+
+ unit_list_iterate_safe(pcity_from->units_supported, punit)
+ if (is_sailing_unit(punit)) {
+ unit_list_append(sea_units, punit);
+ }
+ else {
+ unit_list_append(non_sea_units, punit);
+ }
+ unit_list_iterate_safe_end;
+
+ /* transfer non-sea units to the closest city */
+ if ((unit_list_size(non_sea_units) > 0) && (rcity != NULL)) {
+ transfer_city_units(pplayer_from, pplayer_from,
+ non_sea_units, rcity, pcity_from,
+ -1, TRUE);
+ } else {
+ unit_list_iterate_safe(non_sea_units, punit)
+ wipe_unit(punit);
+ unit_list_iterate_safe_end;
+ }
+
+ /* transfer sea units to the closest sea city */
+ if ((unit_list_size(sea_units) > 0) && (rseacity != NULL)) {
+ transfer_city_units(pplayer_from, pplayer_from,
+ sea_units, rseacity, pcity_from,
+ -1, TRUE);
+ } else {
+ unit_list_iterate_safe(sea_units, punit)
+ wipe_unit(punit);
+ unit_list_iterate_safe_end;
+ }
+
+ }
+
+ /* remove the city */
+ remove_city(pcity_from);
+
+ notify_player(pplayer_from, ptile_from, E_CITY_LOST,
+ _("%s was disbanded by its citizens."),
+ saved_name_from);
+
} else {
/* it's the only city of the nation */
return FALSE;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev