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

[Freeciv-Dev] Re: (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] Re: (PR#8801) scenarios with too many players
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 May 2004 23:24:44 -0700
Reply-to: rt@xxxxxxxxxxx

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

Raimar Falke wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8801 >
> 
> On Fri, May 21, 2004 at 09:50:40PM -0700, Jason Short wrote:
> 
>><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.)
> 
> Can we catch this case and print an error message?

How about this?

jason

? convert.sh
? eff
? flags
? spec.diff
? data/flags
? data/scenario/files
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 06:24:03 -0000
@@ -1666,9 +1666,16 @@
     } 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) {
+      if (map.num_start_positions != 0) {
+       freelog(LOG_NORMAL,
+               _("There are more players than available start positions\n"
+                 "for this scenario.  A new set of starting positions\n"
+                 "will be randomly generated."));
+      }
       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 06:24:04 -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]