<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39485 >

On 04/08/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  S2_1 and earlier assigned same barbarian nation to both barbarian
> players. When loading such savegame to trunk, it will assert due to
> inconsistent nation assignments.

 Fix


 - ML

diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2007-08-06 16:41:57.000000000 +0300
+++ freeciv/server/savegame.c	2007-08-07 15:00:43.000000000 +0300
@@ -1918,7 +1918,18 @@
   pnation = find_nation_by_rule_name(p);
 
   if (pnation != NO_NATION_SELECTED) {
-    player_set_nation(plr, pnation);
+
+    /* 2.1 and earlier savegames have same nation for both barbarian players.
+     * Reassign correct nations for such barbarians. */
+    enum barbarian_type nat_barb_type = nation_barbarian_type(pnation);
+
+    if ((!is_land_barbarian(plr) && nat_barb_type != SEA_BARBARIAN)
+        || (is_land_barbarian(plr) && nat_barb_type != LAND_BARBARIAN)) {
+      freelog(LOG_ERROR, "Reassigning barbarian nation for %s", plr->name);
+      plr->nation = NO_NATION_SELECTED;
+    } else {
+      player_set_nation(plr, pnation);
+    }
   } else {
     plr->nation = NO_NATION_SELECTED;
   }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to