Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8843) Check gives_shared_vision in savegame
Home

[Freeciv-Dev] (PR#8843) Check gives_shared_vision in savegame

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mstefek@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#8843) Check gives_shared_vision in savegame
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 27 May 2004 19:34:54 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [mstefek@xxxxxxxxx - Wed May 26 13:27:45 2004]:
> 
> I manually edited savagame and it took me a long time to find what was
> wrong with it.
> Attached patch checks if someone gives vision to non-existing player.
> (When barbarians are created, AI removes shared vision, and everything
> crashes)

I think it's better to instead limit the iterator to only look at real
players.

jason

? diff
? ferries
? flags
? data/flags
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.155
diff -u -r1.155 savegame.c
--- server/savegame.c   27 May 2004 22:14:19 -0000      1.155
+++ server/savegame.c   28 May 2004 02:34:23 -0000
@@ -2342,10 +2342,13 @@
       int plrno = pplayer->player_no;
       vision = secfile_lookup_str_default(file, NULL, 
"player%d.gives_shared_vision",
                                          plrno);
-      if (vision)
-       for (i=0; i < MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS; i++)
-         if (vision[i] == '1')
-           give_shared_vision(pplayer, get_player(i));
+      if (vision) {
+       players_iterate(pplayer2) {
+         if (vision[pplayer2->player_no] == '1') {
+           give_shared_vision(pplayer, pplayer2);
+         }
+       } players_iterate_end;
+      }
     } players_iterate_end;
 
     initialize_globals();

[Prev in Thread] Current Thread [Next in Thread]