Author: sveinung
Date: Wed Apr 12 15:55:08 2017
New Revision: 35237

URL: http://svn.gna.org/viewcvs/freeciv?rev=35237&view=rev
Log:
Count the number of server setting types.

See hrm Feature #651514

Modified:
    branches/S3_0/common/server_settings.h
    branches/S3_0/server/settings.c
    branches/S3_0/server/stdinhand.c
    branches/S3_0/tools/civmanual.c
    branches/S3_0/tools/ruleutil/rulesave.c

Modified: branches/S3_0/common/server_settings.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/server_settings.h?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- branches/S3_0/common/server_settings.h      (original)
+++ branches/S3_0/common/server_settings.h      Wed Apr 12 15:55:08 2017
@@ -25,6 +25,7 @@
 #define SPECENUM_VALUE2 SST_STRING
 #define SPECENUM_VALUE3 SST_ENUM
 #define SPECENUM_VALUE4 SST_BITWISE
+#define SPECENUM_COUNT  SST_COUNT
 #include "specenum_gen.h"
 
 #ifdef __cplusplus

Modified: branches/S3_0/server/settings.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/settings.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- branches/S3_0/server/settings.c     (original)
+++ branches/S3_0/server/settings.c     Wed Apr 12 15:55:08 2017
@@ -3872,6 +3872,9 @@
   case SST_BITWISE:
     return setting_bitwise_to_str(pset, *pset->bitwise.pvalue,
                                   pretty, buf, buf_len);
+  case SST_COUNT:
+    /* Error logged below. */
+    break;
   }
 
   log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
@@ -3905,6 +3908,9 @@
   case SST_BITWISE:
     return setting_bitwise_to_str(pset, pset->bitwise.default_value,
                                   pretty, buf, buf_len);
+  case SST_COUNT:
+    /* Error logged below. */
+    break;
   }
 
   log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
@@ -3933,6 +3939,9 @@
     break;
   case SST_BITWISE:
     (*pset->bitwise.pvalue) = pset->bitwise.default_value;
+    break;
+  case SST_COUNT:
+    fc_assert(pset->stype != SST_COUNT);
     break;
   }
 
@@ -4138,6 +4147,10 @@
       }
     }
     break;
+
+  case SST_COUNT:
+    fc_assert(pset->stype != SST_COUNT);
+    break;
   }
 
   pset->setdef = SETDEF_RULESET;
@@ -4171,6 +4184,9 @@
     return (read_enum_value(pset) != pset->enumerator.default_value);
   case SST_BITWISE:
     return (*pset->bitwise.pvalue != pset->bitwise.default_value);
+  case SST_COUNT:
+    /* Error logged below. */
+    break;
   }
 
   log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
@@ -4225,6 +4241,10 @@
   case SST_BITWISE:
     pset->bitwise.game_value = *pset->bitwise.pvalue;
     break;
+
+  case SST_COUNT:
+    fc_assert(setting_type(pset) != SST_COUNT);
+    break;
   }
 }
 
@@ -4282,6 +4302,10 @@
                                           FALSE, buf, sizeof(buf))
            && setting_bitwise_set(pset, buf, NULL, reject_msg,
                                   sizeof(reject_msg)));
+    break;
+
+  case SST_COUNT:
+    res = NULL;
     break;
   }
 
@@ -4356,6 +4380,13 @@
                                  setting_bitwise_secfile_str, pset,
                                  "%s.set%d.gamestart", section, set_count);
         break;
+      case SST_COUNT:
+        fc_assert(setting_type(pset) != SST_COUNT);
+        secfile_insert_str(file, "Unknown setting type",
+                           "%s.set%d.value", section, set_count);
+        secfile_insert_str(file, "Unknown setting type",
+                           "%s.set%d.gamestart", section, set_count);
+        break;
       }
       set_count++;
     }
@@ -4561,6 +4592,10 @@
           }
         }
         break;
+
+      case SST_COUNT:
+        fc_assert(pset->stype != SST_COUNT);
+        break;
       }
 
       if (game.server.settings_gamestart_valid) {
@@ -4598,6 +4633,10 @@
               secfile_lookup_enum_default_data(file,
                   *pset->bitwise.pvalue, TRUE, setting_bitwise_secfile_str,
                   pset, "%s.set%d.gamestart", section, i);
+          break;
+
+        case SST_COUNT:
+          fc_assert(pset->stype != SST_COUNT);
           break;
         }
 
@@ -4810,6 +4849,10 @@
         send_packet_server_setting_bitwise(pconn, &packet);
       } conn_list_iterate_end;
     }
+    break;
+
+  case SST_COUNT:
+    fc_assert(setting_type(pset) != SST_COUNT);
     break;
   }
 

Modified: branches/S3_0/server/stdinhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/stdinhand.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- branches/S3_0/server/stdinhand.c    (original)
+++ branches/S3_0/server/stdinhand.c    Wed Apr 12 15:55:08 2017
@@ -1762,6 +1762,9 @@
                   _("Default:"), def_buf);
       }
       break;
+    case SST_COUNT:
+      fc_assert(setting_type(pset) != SST_COUNT);
+      break;
     }
   }
 }
@@ -3000,6 +3003,11 @@
       cmd_reply(CMD_SET, caller, C_FAIL, "%s", reject_msg);
       goto cleanup;
     }
+    break;
+
+  case SST_COUNT:
+    fc_assert(setting_type(pset) != SST_COUNT);
+    goto cleanup;
     break;
   }
 

Modified: branches/S3_0/tools/civmanual.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/civmanual.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- branches/S3_0/tools/civmanual.c     (original)
+++ branches/S3_0/tools/civmanual.c     Wed Apr 12 15:55:08 2017
@@ -315,6 +315,9 @@
           break;
         case SST_BOOL:
         case SST_STRING:
+          break;
+        case SST_COUNT:
+          fc_assert(setting_type(pset) != SST_COUNT);
           break;
         }
         if (SST_INT != setting_type(pset)) {

Modified: branches/S3_0/tools/ruleutil/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/ruleutil/rulesave.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- branches/S3_0/tools/ruleutil/rulesave.c     (original)
+++ branches/S3_0/tools/ruleutil/rulesave.c     Wed Apr 12 15:55:08 2017
@@ -1393,6 +1393,11 @@
                                  setting_bitwise_secfile_str, pset,
                                  "settings.set%d.value", set_count);
         break;
+      case SST_COUNT:
+        fc_assert(setting_type(pset) != SST_COUNT);
+        secfile_insert_str(sfile, "Unknown setting type",
+                           "settings.set%d.value", set_count);
+        break;
       }
 
       if (locks) {


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

Reply via email to