Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#10249) Save AI target
Home

[Freeciv-Dev] (PR#10249) Save AI target

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10249) Save AI target
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Tue, 21 Sep 2004 16:18:20 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10249 >

AI diplomacy target isn't saved.
This patch fixes it.
--
mateusz
Index: savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.192
diff -u -r1.192 savegame.c
--- savegame.c  21 Sep 2004 22:10:21 -0000      1.192
+++ savegame.c  21 Sep 2004 23:16:01 -0000
@@ -1427,6 +1427,7 @@
   struct ai_data *ai;
   struct government *gov;
   int id;
+  int target_no;
 
   server_player_init(plr, TRUE);
   ai = ai_data_get(plr);
@@ -1564,6 +1565,10 @@
     ai->diplomacy.player_intel[i].asked_about_ceasefire
          = secfile_lookup_int_default(file, 0, "player%d.ai%d.ask_ceasefire", 
plrno, i);
   }
+  /* Diplomacy target is saved as player number or -1 if none */ 
+  target_no = secfile_lookup_int_default(file, -1,
+                                         "player%d.ai.target", plrno);
+  ai->diplomacy.target = target_no == -1 ? NULL : &game.players[target_no];
   plr->ai.tech_goal = load_technology(file, "player%d.ai.tech_goal", plrno);
   if (plr->ai.tech_goal == A_NONE) {
     /* Old servers (1.14.1) saved both A_UNSET and A_NONE by 0
@@ -2284,6 +2289,10 @@
     secfile_insert_int(file, 
ai->diplomacy.player_intel[i].asked_about_ceasefire, 
                        "player%d.ai%d.ask_ceasefire", plrno, i);
   }
+  secfile_insert_int(file,
+                     ai->diplomacy.target == NULL ? 
+                      -1 : ai->diplomacy.target->player_no,
+                    "player%d.ai.target", plrno);
   save_technology(file, "player%d.ai.tech_goal", plrno, plr->ai.tech_goal);
   secfile_insert_int(file, plr->ai.skill_level,
                     "player%d.ai.skill_level", plrno);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#10249) Save AI target, Mateusz Stefek <=