Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10554) Reproduceable crash in civserver
Home

[Freeciv-Dev] (PR#10554) Reproduceable crash in civserver

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: sam@xxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10554) Reproduceable crash in civserver
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 17 Oct 2004 19:51:37 -0700
Reply-to: rt@xxxxxxxxxxx

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

I reproduced the bug from the original savegame, and it was easy to see
the problem.  This patch fixes it, with enough added comments to explain
the possible pitfalls.  Please test.

jason

Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.330.2.1
diff -u -r1.330.2.1 plrhand.c
--- server/plrhand.c    12 Oct 2004 16:35:58 -0000      1.330.2.1
+++ server/plrhand.c    18 Oct 2004 02:51:24 -0000
@@ -803,20 +803,26 @@
 }
 
 /**************************************************************************
-...
+  Set the player to be researching the given tech.
+
+  If there are enough accumulated research points, the tech may be
+  acquired immediately.
 **************************************************************************/
 void handle_player_research(struct player *pplayer, int tech)
 {
   choose_tech(pplayer, tech);
   send_player_info(pplayer, pplayer);
 
-  /* Notify Team members */
+  /* Notify Team members.  Note that the the player may not necessarily
+   * be researching the tech that has been set: if there were enough
+   * research points then research will finish immediately and the
+   * player will start researching the "next" tech (probably A_NONE). */
   players_iterate(aplayer) {
     if (pplayer != aplayer
-       && aplayer->research.researching != tech
+       && aplayer->research.researching != pplayer->research.researching
        && pplayer->diplstates[aplayer->player_no].type == DS_TEAM
        && aplayer->is_alive) {
-      handle_player_research(aplayer, tech);
+      handle_player_research(aplayer, pplayer->research.researching);
     }
   } players_iterate_end;
 }

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