Author: cazfi
Date: Thu Feb  5 03:16:20 2015
New Revision: 27996

URL: http://svn.gna.org/viewcvs/freeciv?rev=27996&view=rev
Log:
Track settings defaultness level (internal / ruleset / not-at-all) instead of 
just whether they are
internal default.

See patch #5781

Modified:
    branches/S2_6/server/settings.c
    branches/S2_6/server/settings.h
    branches/S2_6/server/stdinhand.c
    branches/S2_6/tools/ruledit/rulesave.c

Modified: branches/S2_6/server/settings.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/settings.c?rev=27996&r1=27995&r2=27996&view=diff
==============================================================================
--- branches/S2_6/server/settings.c     (original)
+++ branches/S2_6/server/settings.c     Thu Feb  5 03:16:20 2015
@@ -159,7 +159,7 @@
   bool locked;
 
   /* It's not "default", even if value is the same as default */
-  bool changed;
+  enum setting_default_level setdef;
 };
 
 static struct {
@@ -3526,7 +3526,7 @@
     break;
   }
 
-  pset->changed = FALSE;
+  pset->setdef = SETDEF_INTERNAL;
 }
 
 /********************************************************************
@@ -3728,6 +3728,8 @@
     break;
   }
 
+  pset->setdef = SETDEF_RULESET;
+
   /* set lock */
   lock = secfile_lookup_bool_default(file, FALSE, "%s.lock", path);
 
@@ -3904,7 +3906,7 @@
     if ( /* Normal save always has all settings saved */
         !scenario
          /* It's explicitly set to some value to save */
-        || setting_is_changed(pset)
+        || setting_get_setdef(pset) == SETDEF_CHANGED
          /* It must be same at loading time as it was saving time, even if
           * freeciv's default has changed. */
         || !setting_is_changeable(pset, NULL, errbuf, sizeof(errbuf))) {
@@ -4155,7 +4157,7 @@
           break;
         }
 
-        pset->changed = TRUE;
+        pset->setdef = SETDEF_CHANGED;
       }
     } settings_iterate_end;
   }
@@ -4562,15 +4564,15 @@
 *****************************************************************************/
 void setting_changed(struct setting *pset)
 {
-  pset->changed = TRUE;
+  pset->setdef = SETDEF_CHANGED;
 }
 
 /*****************************************************************************
   Is the setting in changed state, or the default
 *****************************************************************************/
-bool setting_is_changed(struct setting *pset)
-{
-  return pset->changed;
+enum setting_default_level setting_get_setdef(struct setting *pset)
+{
+  return pset->setdef;
 }
 
 /*****************************************************************************
@@ -4581,6 +4583,6 @@
 void settings_consider_all_changed(void)
 {
   settings_iterate(SSET_ALL, pset) {
-    pset->changed = TRUE;
+    pset->setdef = SETDEF_CHANGED;
   } settings_iterate_end;
 }

Modified: branches/S2_6/server/settings.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/settings.h?rev=27996&r1=27995&r2=27996&view=diff
==============================================================================
--- branches/S2_6/server/settings.h     (original)
+++ branches/S2_6/server/settings.h     Thu Feb  5 03:16:20 2015
@@ -86,6 +86,8 @@
 #define SPECENUM_VALUE4 SSET_BITWISE
 #include "specenum_gen.h"
 
+enum setting_default_level { SETDEF_INTERNAL, SETDEF_RULESET, SETDEF_CHANGED };
+
 /* forward declaration */
 struct setting;
 
@@ -219,7 +221,7 @@
 void send_server_setting_control(struct connection *pconn);
 
 void setting_changed(struct setting *pset);
-bool setting_is_changed(struct setting *pset);
+enum setting_default_level setting_get_setdef(struct setting *pset);
 void settings_consider_all_changed(void);
 
 #ifdef __cplusplus

Modified: branches/S2_6/server/stdinhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/stdinhand.c?rev=27996&r1=27995&r2=27996&view=diff
==============================================================================
--- branches/S2_6/server/stdinhand.c    (original)
+++ branches/S2_6/server/stdinhand.c    Thu Feb  5 03:16:20 2015
@@ -2244,7 +2244,7 @@
                  setting_int_min(pset), setting_int_max(pset));
   }
 
-  if (!setting_is_changed(pset)) {
+  if (setting_get_setdef(pset) == SETDEF_INTERNAL) {
     defaultness = '~';
   } else if (is_changed) {
     defaultness = ' ';

Modified: branches/S2_6/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/rulesave.c?rev=27996&r1=27995&r2=27996&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/rulesave.c      (original)
+++ branches/S2_6/tools/ruledit/rulesave.c      Thu Feb  5 03:16:20 2015
@@ -996,9 +996,7 @@
 
   set_count = 0;
   settings_iterate(SSET_ALL, pset) {
-    /* TODO: Save also those that should get the same value at loading time
-     * even if it's current default, and default is different at loading time. 
*/
-    if (setting_non_default(pset) || setting_locked(pset)) {
+    if (setting_get_setdef(pset) == SETDEF_RULESET || setting_locked(pset)) {
       secfile_insert_str(sfile, setting_name(pset), "settings.name%d", 
set_count);
       switch (setting_type(pset)) {
       case SSET_BOOL:


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

Reply via email to