Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12017) observer start game, cvs head crash
Home

[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]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#12017) observer start game, cvs head crash
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 1 Feb 2005 23:06:17 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [kauf - Sat Jan 29 21:09:28 2005]:
> 
> On Tue, Jan 25, 2005 at 03:45:44PM -0800, Per I. Mathisen wrote:
> > 
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12017 >
> > 
> > Bug 1: You can start a game with only an observer as a player. I believe
> > this to be a bug.
> 
> agree. here's a patch.

The patch is an improvement but it is incomplete.  Say we have
minplayers 2, with 1 human and 1 observer player.  The game should not
start.  Here is a better patch I think (untested).

-jason

? diff
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.381
diff -u -r1.381 stdinhand.c
--- server/stdinhand.c  22 Jan 2005 20:22:23 -0000      1.381
+++ server/stdinhand.c  2 Feb 2005 07:06:10 -0000
@@ -3578,6 +3578,8 @@
   case PRE_GAME_STATE:
     /* Sanity check scenario */
     if (game.is_new_game && !check) {
+      int nplayers = 0;
+
       if (map.num_start_positions > 0
          && game.max_players > map.num_start_positions) {
        /* If we load a pre-generated map (i.e., a scenario) it is possible
@@ -3590,7 +3592,14 @@
        game.max_players = map.num_start_positions;
       }
 
-      if (game.nplayers > game.max_players) {
+      /* Find the number of non-observer players in the game. */
+      players_iterate(pplayer) {
+       if (!pplayer->is_observer) {
+         nplayers++;
+       }
+      } players_iterate_end;
+
+      if (nplayers > game.max_players) {
        /* Because of the way player ids are renumbered during
           server_remove_player() this is correct */
         while (game.nplayers > game.max_players) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12017) observer start game, cvs head crash, Jason Short <=