Author: cazfi
Date: Tue Jan 20 23:17:16 2015
New Revision: 27748

URL: http://svn.gna.org/viewcvs/freeciv?rev=27748&view=rev
Log:
Track which settings have not changed at all, and which are explicitly set even 
if the value happens
to be same as default.

See patch #5714

Modified:
    trunk/server/savegame.c
    trunk/server/settings.c
    trunk/server/settings.h
    trunk/server/stdinhand.c
    trunk/tools/civmanual.c

Modified: trunk/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame.c?rev=27748&r1=27747&r2=27748&view=diff
==============================================================================
--- trunk/server/savegame.c     (original)
+++ trunk/server/savegame.c     Tue Jan 20 23:17:16 2015
@@ -3826,6 +3826,8 @@
                                sizeof(server.game_identifier));
   }
 
+  settings_consider_all_changed();
+
   map_load(file, tmp_server_state, savefile_options,
            special_order, num_special_types,
            base_order, num_base_types);

Modified: trunk/server/settings.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/settings.c?rev=27748&r1=27747&r2=27748&view=diff
==============================================================================
--- trunk/server/settings.c     (original)
+++ trunk/server/settings.c     Tue Jan 20 23:17:16 2015
@@ -157,6 +157,9 @@
 
   /* ruleset lock for game settings */
   bool locked;
+
+  /* It's not "default", even if value is the same as default */
+  bool changed;
 };
 
 static struct {
@@ -3481,6 +3484,8 @@
     (*pset->bitwise.pvalue) = pset->bitwise.default_value;
     break;
   }
+
+  pset->changed = FALSE;
 }
 
 /********************************************************************
@@ -3696,9 +3701,9 @@
 }
 
 /**************************************************************************
-  Returns whether the setting has been changed (is not default).
+  Returns whether the setting has non-default value.
 **************************************************************************/
-bool setting_changed(const struct setting *pset)
+bool setting_non_default(const struct setting *pset)
 {
   switch (setting_type(pset)) {
   case SSET_BOOL:
@@ -4097,6 +4102,8 @@
                   pset, "%s.set%d.gamestart", section, i);
           break;
         }
+
+        pset->changed = TRUE;
       }
     } settings_iterate_end;
   }
@@ -4443,7 +4450,7 @@
 
   /* Refill them. */
   for (i = 0; (pset = setting_by_number(i)); i++) {
-    if (setting_changed(pset)) {
+    if (setting_non_default(pset)) {
       setting_list_append(setting_sorted.level[SSET_CHANGED], pset);
     }
     if (setting_locked(pset)) {
@@ -4497,3 +4504,23 @@
 
   setting_sorted.init = FALSE;
 }
+
+/*****************************************************************************
+  Mark setting changed
+*****************************************************************************/
+void setting_changed(struct setting *pset)
+{
+  pset->changed = TRUE;
+}
+
+/*****************************************************************************
+  Compatibility function. In the very old times there was no concept of
+  'default' value outside setting initialization, all values were handled
+  like we now want to handle non-default ones.
+*****************************************************************************/
+void settings_consider_all_changed(void)
+{
+  settings_iterate(SSET_ALL, pset) {
+    pset->changed = TRUE;
+  } settings_iterate_end;
+}

Modified: trunk/server/settings.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/settings.h?rev=27748&r1=27747&r2=27748&view=diff
==============================================================================
--- trunk/server/settings.h     (original)
+++ trunk/server/settings.h     Tue Jan 20 23:17:16 2015
@@ -159,7 +159,7 @@
 
 void setting_action(const struct setting *pset);
 
-bool setting_changed(const struct setting *pset);
+bool setting_non_default(const struct setting *pset);
 bool setting_locked(const struct setting *pset);
 void setting_lock_set(struct setting *pset, bool lock);
 
@@ -207,6 +207,9 @@
 void send_server_hack_level_settings(struct conn_list *dest);
 void send_server_setting_control(struct connection *pconn);
 
+void setting_changed(struct setting *pset);
+void settings_consider_all_changed(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/server/stdinhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/stdinhand.c?rev=27748&r1=27747&r2=27748&view=diff
==============================================================================
--- trunk/server/stdinhand.c    (original)
+++ trunk/server/stdinhand.c    Tue Jan 20 23:17:16 2015
@@ -2204,7 +2204,7 @@
 
   fc_assert_ret(pset != NULL);
 
-  is_changed = setting_changed(pset);
+  is_changed = setting_non_default(pset);
   setting_value_name(pset, TRUE, value, sizeof(value));
 
   /* Wrap long option values, such as bitwise options */
@@ -2947,6 +2947,7 @@
     /* Notify the console. */
     con_write(C_OK, "%s", packet.message);
 
+    setting_changed(pset);
     setting_action(pset);
     send_server_setting(NULL, pset);
     /* 

Modified: trunk/tools/civmanual.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/civmanual.c?rev=27748&r1=27747&r2=27748&view=diff
==============================================================================
--- trunk/tools/civmanual.c     (original)
+++ trunk/tools/civmanual.c     Tue Jan 20 23:17:16 2015
@@ -256,7 +256,7 @@
           fprintf(doc, "<p class=\"bounds\">%s %s</p>\n\n",
                   _("Default:"), buf);
         }
-        if (setting_changed(pset)) {
+        if (setting_non_default(pset)) {
           fprintf(doc, _("<p class=\"changed\">Value set to %s</p>\n\n"),
                   setting_value_name(pset, TRUE, buf, sizeof(buf)));
         }


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

Reply via email to