Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8801) scenarios with too many players
Home

[Freeciv-Dev] (PR#8801) scenarios with too many players

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8801) scenarios with too many players
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 May 2004 21:50:40 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8801 >

Mike asked why extra players were cut when the number of players 
exceeded those provided by the scenario.

It's pretty hard to get this to happen accidentally.  If it does happen, 
it's because you changed the max_players yourself.  So we may want to 
allocate all-new start positions in this case.  (It's not possible to 
keep the existing start positions and add new ones to them, but it *is* 
possible to reallocate them from scratch.)

This patch does this.  It is untested.  I'm not even sure it's better 
than what's done now (although it is a bit simpler).

jason

Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.160
diff -u -r1.160 srv_main.c
--- server/srv_main.c   2 May 2004 14:47:12 -0000       1.160
+++ server/srv_main.c   22 May 2004 04:49:33 -0000
@@ -1666,9 +1666,10 @@
     } players_iterate_end;
     game.max_players = game.nplayers;
 
-    /* we don't want random start positions in a scenario which already
-       provides them. -- Gudy */
-    if(map.num_start_positions == 0) {
+    /* We don't want random start positions in a scenario which already
+     * provides them - unless there aren't enough start positions in the
+     * scenario. */
+    if (map.num_start_positions < game.nplayers) {
       create_start_positions();
     }
   }
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.317
diff -u -r1.317 stdinhand.c
--- server/stdinhand.c  17 May 2004 05:34:53 -0000      1.317
+++ server/stdinhand.c  22 May 2004 04:49:34 -0000
@@ -4466,30 +4466,9 @@
 {
   switch (server_state) {
   case PRE_GAME_STATE:
-    /* Sanity check scenario */
-    if (game.is_new_game && !check) {
-      if (map.fixed_start_positions
-         && game.max_players > map.num_start_positions) {
-       freelog(LOG_VERBOSE, "Reduced maxplayers from %i to %i to fit "
-               "to the number of start positions.",
-               game.max_players, map.num_start_positions);
-       game.max_players = map.num_start_positions;
-      }
-
-      if (game.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) {
-         server_remove_player(get_player(game.max_players));
-        }
-
-       freelog(LOG_VERBOSE,
-               "Had to cut down the number of players to the "
-               "number of map start positions, there must be "
-               "something wrong with the savegame or you "
-               "adjusted the maxplayers value.");
-      }
-    }
+    /* We used to cut players here if there were too many for the scenario.
+     * Now we let them through; this causes the start positions to be
+     * reallocated later. */
 
     /* check min_players */
     if (game.nplayers < game.min_players) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8801) scenarios with too many players, Jason Short <=