<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40194 >
On 07/04/2008, Marko Lindqvist wrote: > > start_game() is called from two distinct places. > > 1) Command /start > 2) All human players indicate that they are ready by using Start -button > > There is some functionality in first that is never executed for case > two. Number of players is not checked against minplayers setting > (making it totally useless), there's no scenario sanity checking. Patch - ML
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c --- freeciv/server/srv_main.c 2008-04-01 22:40:44.000000000 +0300 +++ freeciv/server/srv_main.c 2008-04-07 01:41:47.000000000 +0300 @@ -1578,9 +1578,8 @@ "are ready to start."), num_ready, num_ready + num_unready); } else { - notify_conn(NULL, NULL, E_SETTING, - _("All players are ready; starting game.")); - start_game(); + /* Check minplayers etc. and then start */ + start_command(NULL, FALSE, TRUE); } } } diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c --- freeciv/server/stdinhand.c 2008-04-06 11:24:53.000000000 +0300 +++ freeciv/server/stdinhand.c 2008-04-07 01:42:08.000000000 +0300 @@ -93,7 +93,6 @@ static bool observe_command(struct connection *caller, char *name, bool check); static bool take_command(struct connection *caller, char *name, bool check); static bool detach_command(struct connection *caller, char *name, bool check); -static bool start_command(struct connection *caller, char *name, bool check); static bool end_command(struct connection *caller, char *str, bool check); static bool surrender_command(struct connection *caller, char *str, bool check); @@ -3695,7 +3694,7 @@ case CMD_TIMEOUT: return timeout_command(caller, allargs, check); case CMD_START_GAME: - return start_command(caller, arg, check); + return start_command(caller, check, FALSE); case CMD_END_GAME: return end_command(caller, arg, check); case CMD_SURRENDER: @@ -3756,9 +3755,9 @@ } /************************************************************************** -... + Handle start command. Notify all players about errors if notify set. **************************************************************************/ -static bool start_command(struct connection *caller, char *name, bool check) +bool start_command(struct connection *caller, bool check, bool notify) { switch (server_state()) { case S_S_INITIAL: @@ -3797,16 +3796,26 @@ if (game.info.nplayers < game.info.min_players) { cmd_reply(CMD_START_GAME, caller, C_FAIL, _("Not enough players, game will not start.")); + if (notify) { + notify_conn(NULL, NULL, E_SETTING, + _("Not enough players, game will not start.")); + } return FALSE; } else if (check) { return TRUE; } else if (!caller) { + if (notify) { + notify_conn(NULL, NULL, E_SETTING, + _("All players are ready; starting game.")); + } start_game(); return TRUE; } else if (NULL == caller->playing || !caller->playing->is_connected) { /* A detached or observer player can't do /start. */ return TRUE; } else { + /* This might trigger recursive call to start_command() if this is + * last player who gets ready. In that case caller is NULL. */ handle_player_ready(caller->playing, player_number(caller->playing), TRUE); return TRUE; } diff -Nurd -X.diff_ignore freeciv/server/stdinhand.h freeciv/server/stdinhand.h --- freeciv/server/stdinhand.h 2007-09-14 14:44:25.000000000 +0300 +++ freeciv/server/stdinhand.h 2008-04-07 01:28:38.000000000 +0300 @@ -33,7 +33,7 @@ void show_players(struct connection *caller); bool load_command(struct connection *caller, char *arg, bool check); - +bool start_command(struct connection *caller, bool check, bool notify); void toggle_ai_player_direct(struct connection *caller, struct player *pplayer);
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev