Author: cazfi
Date: Thu Jan  1 23:59:10 2015
New Revision: 27481

URL: http://svn.gna.org/viewcvs/freeciv?rev=27481&view=rev
Log:
Added flag to ruleset loading telling if compatibility mode to allow loading
rulesets from the previous version should be used.
Outside the compatibility mode, using 'name' instead of 'type' in effect 
definitions
is no longer accepted.

See patch #5308

Modified:
    trunk/server/ruleset.c
    trunk/server/ruleset.h
    trunk/server/savegame.c
    trunk/server/savegame2.c
    trunk/server/savegame3.c
    trunk/server/srv_main.c
    trunk/server/stdinhand.c
    trunk/tools/civmanual.c
    trunk/tools/ruledit/ruledit_qt.cpp

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Thu Jan  1 23:59:10 2015
@@ -116,7 +116,8 @@
 static char *base_sections = NULL;
 static char *road_sections = NULL;
 
-static bool load_rulesetdir(const char *rsdir, bool act, bool save_script);
+static bool load_rulesetdir(const char *rsdir, bool compat_mode,
+                            bool act, bool save_script);
 static struct section_file *openload_ruleset_file(const char *whichset,
                                                   const char *rsdir);
 static const char *check_ruleset_capabilities(struct section_file *file,
@@ -145,7 +146,7 @@
 static bool load_ruleset_terrain(struct section_file *file);
 static bool load_ruleset_styles(struct section_file *file);
 static bool load_ruleset_cities(struct section_file *file);
-static bool load_ruleset_effects(struct section_file *file);
+static bool load_ruleset_effects(struct section_file *file, bool compat_mode);
 
 static bool load_ruleset_game(struct section_file *file, bool act);
 
@@ -4582,7 +4583,7 @@
 /**************************************************************************
 Load effects.ruleset file
 **************************************************************************/
-static bool load_ruleset_effects(struct section_file *file)
+static bool load_ruleset_effects(struct section_file *file, bool compat_mode)
 {
   struct section_list *sec;
   const char *type;
@@ -4607,12 +4608,12 @@
     struct requirement_vector *reqs;
 
     type = secfile_lookup_str(file, "%s.type", sec_name);
-    if (type == NULL) {
+    if (type == NULL && compat_mode) {
       /* Backward compatibility. Field used to be named "name" */
       type = secfile_lookup_str(file, "%s.name", sec_name);
     }
     if (type == NULL) {
-      ruleset_error(LOG_ERROR, "\"%s\" [%s] missing effect name.", filename, 
sec_name);
+      ruleset_error(LOG_ERROR, "\"%s\" [%s] missing effect type.", filename, 
sec_name);
       ok = FALSE;
       break;
     }
@@ -6525,15 +6526,16 @@
 /**************************************************************************
   Loads the rulesets.
 **************************************************************************/
-bool load_rulesets(const char *restore, bool act, bool save_script)
-{
-  if (load_rulesetdir(game.server.rulesetdir, act, save_script)) {
+bool load_rulesets(const char *restore, bool compat_mode,
+                   bool act, bool save_script)
+{
+  if (load_rulesetdir(game.server.rulesetdir, compat_mode, act, save_script)) {
     return TRUE;
   }
 
   /* Fallback to previous one. */
   if (restore != NULL) {
-    if (load_rulesetdir(restore, act, save_script)) {
+    if (load_rulesetdir(restore, compat_mode, act, save_script)) {
       sz_strlcpy(game.server.rulesetdir, restore);
 
       notify_ruleset_fallback(_("Ruleset couldn't be loaded. Keeping previous 
one."));
@@ -6548,7 +6550,7 @@
   /* Fallback to default one, but not if that's what we tried already */
   if (strcmp(GAME_DEFAULT_RULESETDIR, game.server.rulesetdir)
       && (restore == NULL || strcmp(GAME_DEFAULT_RULESETDIR, restore))) {
-    if (load_rulesetdir(GAME_DEFAULT_RULESETDIR, act, save_script)) {
+    if (load_rulesetdir(GAME_DEFAULT_RULESETDIR, FALSE, act, save_script)) {
       /* We're in sane state as fallback ruleset loading succeeded,
        * but return failure to indicate that this is not what caller
        * wanted. */
@@ -6583,7 +6585,8 @@
   Loads the rulesets from directory.
   This may be called more than once and it will free any stale data.
 **************************************************************************/
-static bool load_rulesetdir(const char *rsdir, bool act, bool save_script)
+static bool load_rulesetdir(const char *rsdir, bool compat_mode,
+                            bool act, bool save_script)
 {
   struct section_file *techfile, *unitfile, *buildfile, *govfile, *terrfile;
   struct section_file *stylefile, *cityfile, *nationfile, *effectfile, 
*gamefile;
@@ -6664,7 +6667,7 @@
     ok = load_ruleset_nations(nationfile);
   }
   if (ok) {
-    ok = load_ruleset_effects(effectfile);
+    ok = load_ruleset_effects(effectfile, compat_mode);
   }
   if (ok) {
     ok = load_ruleset_game(gamefile, act);

Modified: trunk/server/ruleset.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.h?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/ruleset.h      (original)
+++ trunk/server/ruleset.h      Thu Jan  1 23:59:10 2015
@@ -31,7 +31,8 @@
 struct conn_list;
 
 /* functions */
-bool load_rulesets(const char *restore, bool act, bool save_script);
+bool load_rulesets(const char *restore, bool compat_mode,
+                   bool act, bool save_script);
 bool reload_rulesets_settings(void);
 void send_rulesets(struct conn_list *dest);
 

Modified: trunk/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/savegame.c     (original)
+++ trunk/server/savegame.c     Thu Jan  1 23:59:10 2015
@@ -3109,7 +3109,7 @@
   }
 
   /* load rulesets */
-  if (!load_rulesets(NULL, TRUE, FALSE)) {
+  if (!load_rulesets(NULL, FALSE, TRUE, FALSE)) {
     /* Failed to load correct ruleset */
     exit(EXIT_FAILURE);
   }

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Thu Jan  1 23:59:10 2015
@@ -1051,7 +1051,7 @@
   if (!strcmp("default", game.server.rulesetdir)) {
     sz_strlcpy(game.server.rulesetdir, "classic");
   }
-  if (!load_rulesets(NULL, TRUE, FALSE)) {
+  if (!load_rulesets(NULL, FALSE, TRUE, FALSE)) {
     /* Failed to load correct ruleset */
     sg_failure_ret(TRUE, "Failed to load ruleset");
   }

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Thu Jan  1 23:59:10 2015
@@ -1479,7 +1479,7 @@
   if (!strcmp("default", game.server.rulesetdir)) {
     sz_strlcpy(game.server.rulesetdir, "classic");
   }
-  if (!load_rulesets(NULL, TRUE, FALSE)) {
+  if (!load_rulesets(NULL, FALSE, TRUE, FALSE)) {
     /* Failed to load correct ruleset */
     sg_failure_ret(TRUE, "Failed to load ruleset");
   }

Modified: trunk/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/srv_main.c     (original)
+++ trunk/server/srv_main.c     Thu Jan  1 23:59:10 2015
@@ -2591,7 +2591,7 @@
    || !load_command(NULL, srvarg.load_filename, FALSE)) {
     /* Rulesets are loaded on game initialization, but may be changed later
      * if /load or /rulesetdir is done. */
-    load_rulesets(NULL, TRUE, FALSE);
+    load_rulesets(NULL, FALSE, TRUE, FALSE);
   }
 
   maybe_automatic_meta_message(default_meta_message_string());
@@ -3007,7 +3007,7 @@
     server_game_free();
     server_game_init();
     mapimg_reset();
-    load_rulesets(NULL, TRUE, FALSE);
+    load_rulesets(NULL, FALSE, TRUE, FALSE);
     game.info.is_new_game = TRUE;
   } while (TRUE);
 

Modified: trunk/server/stdinhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/stdinhand.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/server/stdinhand.c    (original)
+++ trunk/server/stdinhand.c    Thu Jan  1 23:59:10 2015
@@ -3754,7 +3754,7 @@
 
     /* load the ruleset (and game settings defined in the ruleset) */
     player_info_freeze();
-    if (!load_rulesets(old, TRUE, FALSE)) {
+    if (!load_rulesets(old, FALSE, TRUE, FALSE)) {
       success = FALSE;
 
       /* While loading of the requested ruleset failed, we might

Modified: trunk/tools/civmanual.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/civmanual.c?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/tools/civmanual.c     (original)
+++ trunk/tools/civmanual.c     Thu Jan  1 23:59:10 2015
@@ -162,7 +162,7 @@
   /* Reset aifill to zero */
   game.info.aifill = 0;
 
-  if (!load_rulesets(NULL, FALSE, FALSE)) {
+  if (!load_rulesets(NULL, FALSE, FALSE, FALSE)) {
     /* Failed to load correct ruleset */
     return FALSE;
   }

Modified: trunk/tools/ruledit/ruledit_qt.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/ruledit_qt.cpp?rev=27481&r1=27480&r2=27481&view=diff
==============================================================================
--- trunk/tools/ruledit/ruledit_qt.cpp  (original)
+++ trunk/tools/ruledit/ruledit_qt.cpp  Thu Jan  1 23:59:10 2015
@@ -191,7 +191,7 @@
 {
   sz_strlcpy(game.server.rulesetdir, ruleset_select->text().toUtf8().data());
 
-  if (load_rulesets(NULL, FALSE, TRUE)) {
+  if (load_rulesets(NULL, TRUE, FALSE, TRUE)) {
     display_msg(R__("Ruleset loaded"));
 
     /* Make freeable copy */


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

Reply via email to