Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] Re: (PR#12838) RFC: new behavior of start command
Home

[Freeciv-Dev] Re: (PR#12838) RFC: new behavior of start command

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#12838) RFC: new behavior of start command
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Apr 2005 18:35:36 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12838 >
> 
> See also PR#12642.
> 
> Currently in a multi-player game where everyone has commandlevel INFO:
> 
> * A player presses start (or types "/start").
> * Every other player cannot press start, but must instead do "/vote yes".
> 
> This is incredibly counter-intuitive.  A pubserver game with all newbie
> players would probably _never_ start.  This is a major problem that
> warrants fixing for 2.0.
> 
> Fortunately we can fix it!

And look, here's a patch!

This patch is designed for 2.0.  In fact it's intended to be committed
to S2_0 (meaning it'll be propogated into pubservers real fast and will
be a part of any 2.0.1 release).  It's quite simple and simply fixes the
biggest part of the problem.

Anyone who's interest in this should look it over ASAP (Per and Vasco,
this means you).  I'd like to put this into pubserver ASAP.

-jason

Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.157.2.4
diff -u -r1.157.2.4 player.c
--- common/player.c     6 Mar 2005 11:57:02 -0000       1.157.2.4
+++ common/player.c     19 Apr 2005 01:33:38 -0000
@@ -94,6 +94,7 @@
   plr->government=game.default_government;
   plr->nation = NO_NATION_SELECTED;
   plr->team = TEAM_NONE;
+  plr->is_started = FALSE;
   plr->revolution_finishes = -1;
   plr->capital = FALSE;
   unit_list_init(&plr->units);
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.130.2.3
diff -u -r1.130.2.3 player.h
--- common/player.h     22 Feb 2005 00:00:32 -0000      1.130.2.3
+++ common/player.h     19 Apr 2005 01:33:38 -0000
@@ -186,6 +186,7 @@
   int target_government;
   Nation_Type_id nation;
   Team_Type_id team;
+  bool is_started; /* Did the player click "start" yet? */
   bool turn_done;
   int nturns_idle;
   bool is_alive;
Index: server/commands.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.c,v
retrieving revision 1.2.2.5
diff -u -r1.2.2.5 commands.c
--- server/commands.c   19 Jan 2005 05:40:04 -0000      1.2.2.5
+++ server/commands.c   19 Apr 2005 01:33:38 -0000
@@ -23,7 +23,7 @@
 
 /* Commands must match the values in enum command_id. */
 const struct command commands[] = {
-  {"start",    ALLOW_CTRL, ALLOW_CTRL,
+  {"start",    ALLOW_INFO, ALLOW_INFO,
    "start",
    N_("Start the game, or restart after loading a savegame."),
    N_("This command starts the game.  When starting a new game, "
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.354.2.30
diff -u -r1.354.2.30 stdinhand.c
--- server/stdinhand.c  13 Apr 2005 03:48:32 -0000      1.354.2.30
+++ server/stdinhand.c  19 Apr 2005 01:33:39 -0000
@@ -3628,6 +3628,32 @@
     } else if (check) {
       return TRUE;
     } else {
+      int started = 0, notstarted = 0;
+      const int percent_required = 100;
+
+      /* Note this is called even if the player has pressed /start once
+       * before.  This is a good thing given that no other code supports
+       * is_started yet.  For instance if a player leaves everyone left
+       * might have pressed /start already but the start won't happen
+       * until someone presses it again.  Also you can press start more
+       * than once to remind other people to start (which is a good thing
+       * until somebody does it too much and it gets labeled as spam). */
+      caller->player->is_started = TRUE;
+      players_iterate(pplayer) {
+       if (pplayer->is_connected) {
+         if (pplayer->is_started) {
+           started++;
+         } else {
+           notstarted++;
+         }
+       }
+      } players_iterate_end;
+      if (started * 100 < (started + notstarted) * percent_required) {
+       notify_player(NULL, _("Waiting to start game: %d out of %d players "
+                             "are ready to start."),
+                     started, started + notstarted);
+       return TRUE;
+      }
       start_game();
       return TRUE;
     }

[Prev in Thread] Current Thread [Next in Thread]