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

I am not sure about it, but I think that the packet game_info is
received before the packet remove_player. This causes a invalid set of
game.nplayers:

game.nplayers = 1
game_info: set game.nplayers to 0
remove_player: renumbers players and decrease game.nplayers (then -1).

With the attached patch, I don't get the bug anymore.
Index: common/game.c
===================================================================
--- common/game.c	(révision 14865)
+++ common/game.c	(copie de travail)
@@ -494,10 +494,12 @@
     game.player_ptr=&game.players[game.player_idx];
   }
 
-  game.nplayers--;
+  if (game.nplayers > 0) {
+    game.nplayers--;
 
-  /* Reset player structure. */
-  player_init(&game.players[game.nplayers]);
+    /* reinit former last player*/
+    player_init(&game.players[game.nplayers]);
+  }
 }
 
 /**************************************************************************
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to