Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18625) [Patch] Better error msg for unit_type <-> unit
Home

[Freeciv-Dev] (PR#18625) [Patch] Better error msg for unit_type <-> unit

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18625) [Patch] Better error msg for unit_type <-> unit_class flags
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Sat, 15 Jul 2006 16:20:39 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  I guess separate unit_type and unit_class flags can be a bit 
confusing. This patch adds more informative error message if modpack 
author tries to use unit_type flag as unit_class flag or the other way 
around.


  Side note: We could allow all flags to be used for unit_class.


  - ML


diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2006-07-15 23:27:54.031250000 +0300
+++ freeciv/server/ruleset.c    2006-07-15 23:36:06.265625000 +0300
@@ -1070,8 +1070,13 @@
       if (ival == UCF_LAST) {
        freelog(LOG_ERROR, "for unit_class \"%s\": bad flag name \"%s\" (%s)",
                 ut->name, sval, filename);
+        ival = unit_flag_from_str(sval);
+        if (ival != F_LAST) {
+          freelog(LOG_ERROR, "it's unit_type flag!");
+        }
+      } else {
+        BV_SET(ut->flags, ival);
       }
-      BV_SET(ut->flags, ival);
     }
     free(slist);
 
@@ -1194,12 +1199,17 @@
       if(strcmp(sval,"")==0) {
        continue;
       }
-       ival = unit_flag_from_str(sval);
+      ival = unit_flag_from_str(sval);
       if (ival==F_LAST) {
        freelog(LOG_ERROR, "for unit_type \"%s\": bad flag name \"%s\" (%s)",
             u->name, sval, filename);
+        ival = unit_class_flag_from_str(sval);
+        if (ival != UCF_LAST) {
+          freelog(LOG_ERROR, "it's unit_class flag!");
+        }
+      } else {
+        BV_SET(u->flags, ival);
       }
-      BV_SET(u->flags, ival);
       assert(unit_type_flag(u, ival));
     }
     free(slist);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18625) [Patch] Better error msg for unit_type <-> unit_class flags, Marko Lindqvist <=