Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11556) spurious warnings when loading effects
Home

[Freeciv-Dev] (PR#11556) spurious warnings when loading effects

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11556) spurious warnings when loading effects
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Dec 2004 13:32:51 -0800
Reply-to: bugs@xxxxxxxxxxx

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

If you run the server now you get lots of error messages when loading 
effect reqs.  These are spurious - they're caused because the callers is 
passing in "" to mean REQ_NONE but the function expects "None".

Rather than have the caller know that the right name is "None" I just 
added a special case for NULL, which always means REQ_NONE.

-jason

Index: common/requirements.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/requirements.c,v
retrieving revision 1.1
diff -u -r1.1 requirements.c
--- common/requirements.c       15 Dec 2004 19:28:44 -0000      1.1
+++ common/requirements.c       16 Dec 2004 21:30:44 -0000
@@ -34,7 +34,8 @@
 
 /****************************************************************************
   Parse a requirement type and value string into a requrement structure.
-  Returns REQ_LAST on error.
+  Returns REQ_LAST on error.  Passing in a NULL type be considered REQ_NONE
+  (not an error).
 
   Pass this some values like "Building", "Factory".
 ****************************************************************************/
@@ -45,10 +46,14 @@
 
   assert(ARRAY_SIZE(req_type_names) == REQ_LAST);
 
-  for (req.type = 0; req.type < ARRAY_SIZE(req_type_names); req.type++) {
-    if (0 == mystrcasecmp(req_type_names[req.type], type)) {
-      break;
+  if (type) {
+    for (req.type = 0; req.type < ARRAY_SIZE(req_type_names); req.type++) {
+      if (0 == mystrcasecmp(req_type_names[req.type], type)) {
+       break;
+      }
     }
+  } else {
+    req.type = REQ_NONE;
   }
 
   switch (req.type) {
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.218
diff -u -r1.218 ruleset.c
--- server/ruleset.c    16 Dec 2004 20:37:49 -0000      1.218
+++ server/ruleset.c    16 Dec 2004 21:30:45 -0000
@@ -1383,7 +1383,8 @@
        }
 
        /* Sometimes the ruleset will have to list "" here. */
-       req_type = secfile_lookup_str_default(file, "", "%s.effect%d.req_type",
+       req_type = secfile_lookup_str_default(file, NULL,
+                                             "%s.effect%d.req_type",
                                              sec[i], j);
        req_value = secfile_lookup_str_default(file, "", "%s.effect%d.req",
                                               sec[i], j);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11556) spurious warnings when loading effects, Jason Short <=