[Freeciv-Dev] (PR#13299) aifill/team crash
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13299 >
civserver: team.c:103: team_remove_player: Assertion
`pplayer->team->players >= 0' failed.
To reproduce:
* Start client and server.
* Set aifill 7 in server.
* Connect with client.
* Set aifill 1 in server.
* Set aifill 7 in server.
* Boom.
The attached patch fixes this. However I think this is symptomatic of a
significant bug in game_renumber_players. It should either use
player_init on the "removed" player at the end or it should copy the
"removed" player from the middle to the end.
Also included is some logging code.
-jason
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.219
diff -u -r1.219 game.c
--- common/game.c 14 Jun 2005 18:49:08 -0000 1.219
+++ common/game.c 20 Jun 2005 22:42:03 -0000
@@ -488,6 +488,7 @@
game.players[game.info.nplayers].ai.control = FALSE;
sz_strlcpy(game.players[game.info.nplayers].name, ANON_PLAYER_NAME);
sz_strlcpy(game.players[game.info.nplayers].username, ANON_USER_NAME);
+ game.players[game.info.nplayers].team = NULL;
}
/**************************************************************************
Index: common/team.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/team.c,v
retrieving revision 1.4
diff -u -r1.4 team.c
--- common/team.c 4 Jun 2005 16:28:19 -0000 1.4
+++ common/team.c 20 Jun 2005 22:42:03 -0000
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "fcintl.h"
+#include "log.h"
#include "shared.h"
#include "support.h"
@@ -74,6 +75,10 @@
assert(pplayer != NULL);
assert(!pteam || &teams[pteam->index] == pteam);
+ freelog(LOG_DEBUG, "Adding player %d/%s to team %s.",
+ pplayer->player_no, pplayer->username,
+ pteam ? pteam->name : "(none)");
+
/* Remove the player from the old team, if any. The player's team should
* only be NULL for a few instants after the player was created; after
* that they should automatically be put on a team. So although we
@@ -99,6 +104,10 @@
void team_remove_player(struct player *pplayer)
{
if (pplayer->team) {
+ freelog(LOG_DEBUG, "Removing player %d/%s from team %s (%d)",
+ pplayer->player_no, pplayer->username,
+ pplayer->team ? pplayer->team->name : "(none)",
+ pplayer->team ? pplayer->team->players : 0);
pplayer->team->players--;
assert(pplayer->team->players >= 0);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13299) aifill/team crash,
Jason Short <=
|
|