Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2518) ai reading from raw memory?
Home

[Freeciv-Dev] (PR#2518) ai reading from raw memory?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2518) ai reading from raw memory?
From: "Mike Kaufman via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 8 Dec 2002 14:41:54 -0800
Reply-to: rt@xxxxxxxxxxxxxx

while testing my general effects patch, I noticed that I was getting
diverging savegames. Because I am fairly sure I wasn't touching any code
that would cause such a thing, I did a bit of investigation (but not too
much, otherwise you guys wouldn't get to have any fun...)

it seems that somewhere, the ai is looking at raw memory and making
calculations based on this.

Procedure:

1. compile two trees with debugging
2. apply this diff to one tree:

diff -Nur -Xsnap/diff_ignore snap/server/srv_main.c
snap-aitest/server/srv_main.c
--- snap/server/srv_main.c      Thu Nov 14 22:21:45 2002
+++ snap-aitest/server/srv_main.c       Sun Dec  8 16:26:38 2002
@@ -427,6 +427,11 @@
   for (i = 0; i < game.nplayers; i++) {
     struct player *pplayer = shuffled_player(i);
     if (pplayer->ai.control) {
+
+     impr_type_iterate(impr) {
+       int i = improvement_exists(impr);
+     } impr_type_iterate_end;
+
       ai_do_first_activities(pplayer);
       flush_packets();                 /* AIs can be such spammers... */
     }

this _ought_ to be a noop, wouldn't you agree?

run the attached savegame like so:
ser -d 4 -f civgame+1000.sav.gz 1> output.err.sav
st

here's a taste:

-4: Engineers 266(25, 17) wants city at (135266592, -1073742952) with want
0, distance 0 moves
+4: Engineers 266(25, 17) wants city at (135266624, -1073742968) with want
0, distance 0 moves
 >
 4: adding cost:0 at 25,17
 >
@@ -166005,7 +166005,7 @@
 >
 4: City value (26, 30) = 2088, harbour = 1, cfood = 48
 >
-4: Engineers 231(37, 20) wants city at (135266592, -1073742952) with want
0, distance 0 moves
+4: Engineers 231(37, 20) wants city at (135266624, -1073742968) with want
0, distance 0 moves
 
this should be fairly easy to track down given the debugging message I
would think.

diff -Nur -Xsnap/diff_ignore snap/server/srv_main.c 
snap-aitest/server/srv_main.c
--- snap/server/srv_main.c      Thu Nov 14 22:21:45 2002
+++ snap-aitest/server/srv_main.c       Sun Dec  8 16:26:38 2002
@@ -427,6 +427,11 @@
   for (i = 0; i < game.nplayers; i++) {
     struct player *pplayer = shuffled_player(i);
     if (pplayer->ai.control) {
+
+     impr_type_iterate(impr) {
+       int i = improvement_exists(impr);
+     } impr_type_iterate_end;
+
       ai_do_first_activities(pplayer);
       flush_packets();                 /* AIs can be such spammers... */
     }

Attachment: memread-diff.diff.gz
Description: memread-diff.diff.gz

Attachment: civgame+1000.sav.gz
Description: civgame+1000.sav.gz


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