Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] Re: (PR#13302) Show changed
Home

[Freeciv-Dev] Re: (PR#13302) Show changed

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#13302) Show changed
From: "Thomas Müller" <mail@xxxxxxxxxxx>
Date: Wed, 29 Jun 2005 04:01:58 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13302 >

Ok, now i was tought how to create good patches i reformatted the patch for 
better Style and changed is_changed to bool.

Plus, this time i dont forget to send the patch, hehe ;)

Index: stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.423
diff -u -r1.423 stdinhand.c
--- stdinhand.c 27 Jun 2005 14:13:44 -0000      1.423
+++ stdinhand.c 29 Jun 2005 10:56:13 -0000
@@ -1431,7 +1431,7 @@
 {
   enum sset_level i;
 
-  for (i = SSET_ALL; i <= SSET_RARE; i++) {
+  for (i = SSET_ALL; i <= SSET_CHANGED; i++) {
     if (0 == mystrcasecmp(name, sset_level_names[i])) {
       return i;
     }
@@ -1872,6 +1872,7 @@
 {
   char buf[MAX_LEN_CONSOLE_LINE];
   char command[MAX_LEN_CONSOLE_LINE], *cptr_s, *cptr_d;
+  bool is_changed;
   int cmd,i,len1;
   enum sset_level level = SSET_VITAL;
   size_t clen = 0;
@@ -1923,6 +1924,9 @@
   switch(level) {
     case SSET_NONE:
       break;
+    case SSET_CHANGED:
+      cmd_reply_show(_("All options with non-default values"));
+      break;
     case SSET_ALL:
       cmd_reply_show(_("All options"));
       break;
@@ -1950,25 +1954,34 @@
   buf[0] = '\0';
 
   for (i = 0; settings[i].name; i++) {
-    if (may_view_option(caller, i)
-       && (cmd == -1 || cmd == -3 || cmd == i
-           || (cmd == -2
-               && mystrncasecmp(settings[i].name, command, clen) == 0))) {
+   is_changed = FALSE;
+   if (may_view_option(caller, i)
+       && (cmd == -1 || cmd == -3 || level == SSET_CHANGED || cmd == i 
+       || (cmd == -2 && mystrncasecmp(settings[i].name, command, clen) == 0))) 
{
       /* in the cmd==i case, this loop is inefficient. never mind - rp */
       struct settings_s *op = &settings[i];
       int len = 0;
 
-      if (level == SSET_ALL || op->level == level || cmd >= 0) {
-        switch (op->type) {
-        case SSET_BOOL:
+ 
+   if ((level == SSET_ALL || op->level == level || cmd >= 0 
+     || level == SSET_CHANGED))  {
+   switch (op->type) {
+        case SSET_BOOL: 
+         if (*op->bool_value != op->bool_default_value) {
+           is_changed = TRUE;
+         }
          len = my_snprintf(buf, sizeof(buf),
                            "%-*s %c%c%-5d (0,1)", OPTION_NAME_SPACE, op->name,
                            may_set_option_now(caller, i) ? '+' : ' ',
                            ((*op->bool_value == op->bool_default_value) ?
                             '=' : ' '), (*op->bool_value) ? 1 : 0);
+
          break;
 
-        case SSET_INT:
+        case SSET_INT: 
+         if (*op->int_value != op->int_default_value) {
+           is_changed = TRUE;
+         }
          len = my_snprintf(buf, sizeof(buf),
                            "%-*s %c%c%-5d (%d,%d)", OPTION_NAME_SPACE,
                            op->name, may_set_option_now(caller,
@@ -1976,16 +1989,19 @@
                            ((*op->int_value == op->int_default_value) ?
                             '=' : ' '),
                            *op->int_value, op->int_min_value,
-                           op->int_max_value);
+                           op->int_max_value); 
          break;
 
         case SSET_STRING:
+         if (strcmp(op->string_value, op->string_default_value) != 0) {
+           is_changed = TRUE; 
+         }
          len = my_snprintf(buf, sizeof(buf),
                            "%-*s %c%c\"%s\"", OPTION_NAME_SPACE, op->name,
                            may_set_option_now(caller, i) ? '+' : ' ',
                            ((strcmp(op->string_value,
                                     op->string_default_value) == 0) ?
-                            '=' : ' '), op->string_value);
+                            '=' : ' '), op->string_value); 
          break;
         }
         if (len == -1) {
@@ -1998,7 +2014,9 @@
           sz_strlcat(buf, " ");
         }
         sz_strlcat(buf, _(op->short_help));
-        cmd_reply_show(buf);
+        if ((is_changed) || (level != SSET_CHANGED)) {
+         cmd_reply_show(buf);
+       }
       }
     }
   }
Index: settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.27
diff -u -r1.27 settings.c
--- settings.c  14 Jun 2005 18:49:09 -0000      1.27
+++ settings.c  29 Jun 2005 10:56:14 -0000
@@ -41,7 +41,8 @@
                                  N_("All"),
                                  N_("Vital"),
                                  N_("Situational"),
-                                 N_("Rare")};
+                                 N_("Rare"),
+                                 N_("Changed")};
 const int OLEVELS_NUM = ARRAY_SIZE(sset_level_names);
 
 
Index: settings.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.h,v
retrieving revision 1.4
diff -u -r1.4 settings.h
--- settings.h  29 Apr 2005 17:49:27 -0000      1.4
+++ settings.h  29 Jun 2005 10:56:14 -0000
@@ -68,7 +68,8 @@
   SSET_ALL,
   SSET_VITAL,
   SSET_SITUATIONAL,
-  SSET_RARE
+  SSET_RARE,
+  SSET_CHANGED
 };
 
 extern const char *sset_level_names[];

[Prev in Thread] Current Thread [Next in Thread]