<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40319 >
> [EMAIL PROTECTED] - Wed Jun 25 17:28:11 2008]: > > No. In fact it appears there is no game_info being received in pregame. > Right for 2.0. It appears too that there is no player_info being received in pregame. So game.nplayers stays to 0 while the whole pregame. So it is wrong to receive a such packet in pregame. The attached patch should correct this plus the client side if the client connects an old server. P.S.: I didn't check if the same problem occurs in the other branches. P.S.2: I am trying to use git, I hope this patch will be usable.
>From dacf079355328d657aad8c231dba79e8ae0de172 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Pepeto?= <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 11:04:25 +0200 Subject: [PATCH] test --- common/game.c | 8 ++++++++ server/plrhand.c | 15 +++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/common/game.c b/common/game.c index 4667e7e..0d1e34c 100644 --- a/common/game.c +++ b/common/game.c @@ -481,6 +481,13 @@ void game_renumber_players(int plrno) { int i; + if (game.nplayers == 0) { + /* This could happen in pregame, when our client connects to an old + * server. N.B.: nplayers in not set in client side in pregame. + * See PR#40319. */ + return; + } + for (i = plrno; i < game.nplayers - 1; i++) { game.players[i]=game.players[i+1]; game.players[i].player_no=i; @@ -495,6 +502,7 @@ void game_renumber_players(int plrno) } game.nplayers--; + assert(game.nplayers >= 0); /* Reset player structure. */ player_init(&game.players[game.nplayers]); diff --git a/server/plrhand.c b/server/plrhand.c index 2d68356..616f6a1 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -1801,14 +1801,19 @@ void server_player_init(struct player *pplayer, bool initmap) } /********************************************************************** - This function does _not_ close any connections attached to this player. - cut_connection is used for that. + This function does _not_ close any connections attached to this player. + cut_connection is used for that. + + N.B.: It is wrong to send the packet_player_remove because no packet + packet players are sent to the client while the pregame, and the select + race state (except all player_info at the very end of select + race state). ***********************************************************************/ void server_remove_player(struct player *pplayer) { /* Not allowed after a game has started */ - if (!(game.is_new_game && (server_state==PRE_GAME_STATE || - server_state==SELECT_RACES_STATE))) { + if (!(game.is_new_game && (server_state == PRE_GAME_STATE || + server_state == SELECT_RACES_STATE))) { die("You can't remove players after the game has started!"); } @@ -1818,8 +1823,6 @@ void server_remove_player(struct player *pplayer) notify_conn(&game.est_connections, _("Game: %s has been removed from the game."), pplayer->name); - dlsend_packet_player_remove(&game.game_connections, pplayer->player_no); - /* Note it is ok to remove the _current_ item in a list_iterate. */ conn_list_iterate(pplayer->connections, pconn) { if (!unattach_connection_from_player(pconn)) { -- 1.5.4.3
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev