Author: sveinung
Date: Tue Oct 27 16:54:25 2015
New Revision: 30237

URL: http://svn.gna.org/viewcvs/freeciv?rev=30237&view=rev
Log:
Introduce a heavy scenario rule setting class

The player is normally allowed to change rule settings before the game
starts. This is true both for completely new games and for games that take
place on an unpopulated scenario. Doing it for a new game that uses a heavy
scenario, one that comes pre populated with players, cities and units, has
been forbidden.

Allowing the player to change all rule settings of heavy scenarios can lead
to illegal situations. A changed citymindist can result in two pre placed
cities being illegaly close. A changed trademindist can make an existing
trade route illegal. There are other rule settings should be safe to change
as long as it is done before the game starts.

Introduce the new setting class SSET_RULES_SCENARIO. Settings in this class
can be changed before game start on a heavy scenario. Outside this corner
case they should behave like SSET_RULES. Changing them once the game has
started should still be illegal.

See patch #6481

Modified:
    branches/S2_6/server/settings.c

Modified: branches/S2_6/server/settings.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/settings.c?rev=30237&r1=30236&r2=30237&view=diff
==============================================================================
--- branches/S2_6/server/settings.c     (original)
+++ branches/S2_6/server/settings.c     Tue Oct 27 16:54:25 2015
@@ -54,6 +54,7 @@
   SSET_PLAYERS,
   SSET_GAME_INIT,
   SSET_RULES,
+  SSET_RULES_SCENARIO,
   SSET_RULES_FLEXIBLE,
   SSET_META
 };
@@ -2773,6 +2774,24 @@
                       _("The setting '%s' can't be modified after the map "
                         "is fixed."), setting_name(pset));
     return FALSE;
+
+  case SSET_RULES_SCENARIO:
+    /* Like SSET_RULES except that it can be changed before the game starts
+     * for heavy scenarios. A heavy scenario comes with players. It can
+     * include cities, units, diplomatic relations and other complex
+     * state. Make sure that changing a setting can't make the state of a
+     * heavy scenario illegal if you want to change it from SSET_RULES to
+     * SSET_RULES_SCENARIO. */
+
+    if (game.scenario.is_scenario && game.scenario.players
+        && server_state() == S_S_INITIAL) {
+      /* Special case detected. */
+      return TRUE;
+    }
+
+    /* The special case didn't make it legal to change the setting. Don't
+     * give up. It could still be legal. Fall through so the non special
+     * cases are checked too. */
 
   case SSET_MAP_ADD:
   case SSET_PLAYERS:


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to