[Freeciv-Dev] (PR#12017) observer start game, cvs head 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=12017 >
This patch I believe fixes the problem entirely. When making
minplayers/maxplayers comparisons we always use the number of
non-observer players.
-jason
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.386
diff -u -r1.386 stdinhand.c
--- server/stdinhand.c 23 Feb 2005 03:34:06 -0000 1.386
+++ server/stdinhand.c 3 Mar 2005 04:32:55 -0000
@@ -830,6 +830,23 @@
return TRUE;
}
+/****************************************************************************
+ Return the number of non-observer players. game.nplayers includes
+ observers so in some places this function should be called instead.
+****************************************************************************/
+static int get_num_nonobserver_players(void)
+{
+ int nplayers = 0;
+
+ players_iterate(pplayer) {
+ if (!pplayer->is_observer) {
+ nplayers++;
+ }
+ } players_iterate_end;
+
+ return nplayers;
+}
+
/**************************************************************************
...
**************************************************************************/
@@ -845,8 +862,10 @@
return FALSE;
}
- if (game.nplayers >= game.max_players)
- {
+ /* game.max_players is a limit on the number of non-observer players.
+ * MAX_NUM_PLAYERS is a limit on all players. */
+ if (get_num_nonobserver_players() >= game.max_players
+ || game.nplayers >= MAX_NUM_PLAYERS) {
cmd_reply(CMD_CREATE, caller, C_FAIL,
_("Can't add more players, server is full."));
return FALSE;
@@ -3592,10 +3611,12 @@
game.max_players = map.num_start_positions;
}
- if (game.nplayers > game.max_players) {
+ if (get_num_nonobserver_players() > game.max_players) {
/* Because of the way player ids are renumbered during
server_remove_player() this is correct */
- while (game.nplayers > game.max_players) {
+ while (get_num_nonobserver_players() > game.max_players) {
+ /* This may erronously remove observer players sometimes. This
+ * is a bug but non-fatal. */
server_remove_player(get_player(game.max_players));
}
@@ -3608,7 +3629,7 @@
}
/* check min_players */
- if (game.nplayers < game.min_players) {
+ if (get_num_nonobserver_players() < game.min_players) {
cmd_reply(CMD_START_GAME, caller, C_FAIL,
_("Not enough players, game will not start."));
return FALSE;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12017) observer start game, cvs head crash,
Jason Short <=
|
|