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

 These fix Unknown activity warnings from can_unit_do_activity_targeted_at().


 - ML

diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c	2007-08-06 16:41:57.000000000 +0300
+++ freeciv/common/unit.c	2007-08-06 23:09:12.000000000 +0300
@@ -492,6 +492,19 @@
 }
 
 /**************************************************************************
+  Return if given activity really is in game. For savegame compatibility
+  activity enum cannot be reordered and there is holes in it.
+**************************************************************************/
+bool is_real_activity(enum unit_activity activity)
+{
+  /* ACTIVITY_FORTRESS and ACTIVITY_AIRBASE are deprecated */
+  return activity != ACTIVITY_FORTRESS
+    && activity != ACTIVITY_AIRBASE
+    && activity != ACTIVITY_UNKNOWN
+    && activity != ACTIVITY_PATROL_UNUSED;
+}
+
+/**************************************************************************
   Return the name of the activity in a static buffer.
 **************************************************************************/
 const char *get_activity_text(enum unit_activity activity)
diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h
--- freeciv/common/unit.h	2007-08-06 16:41:57.000000000 +0300
+++ freeciv/common/unit.h	2007-08-06 23:09:12.000000000 +0300
@@ -183,14 +183,18 @@
 #define MOVE_COST_RAIL 0
 #define MOVE_COST_ROAD 1
 
+bool is_real_activity(enum unit_activity activity);
+
 /* Iterates over the types of unit activity. */
 #define activity_type_iterate(act)					    \
 {									    \
   Activity_type_id act;			         			    \
 									    \
-  for (act = 0; act < ACTIVITY_LAST; act++) {
+  for (act = 0; act < ACTIVITY_LAST; act++) {				    \
+    if (is_real_activity(act)) {
 
 #define activity_type_iterate_end     					    \
+    }									    \
   }									    \
 }
 
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c	2007-08-06 16:42:13.000000000 +0300
+++ freeciv/common/unit.c	2007-08-06 23:30:29.000000000 +0300
@@ -526,6 +526,16 @@
 }
 
 /**************************************************************************
+  Return if given activity really is in game. For savegame compatibility
+  activity enum cannot be reordered and there is holes in it.
+**************************************************************************/
+bool is_real_activity(enum unit_activity activity)
+{
+  return activity != ACTIVITY_UNKNOWN
+    && activity != ACTIVITY_PATROL_UNUSED;
+}
+
+/**************************************************************************
   Return the name of the activity in a static buffer.
 **************************************************************************/
 const char *get_activity_text(enum unit_activity activity)
diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h
--- freeciv/common/unit.h	2007-08-06 16:42:13.000000000 +0300
+++ freeciv/common/unit.h	2007-08-06 23:30:07.000000000 +0300
@@ -193,14 +193,18 @@
 #define MOVE_COST_RAIL 0
 #define MOVE_COST_ROAD 1
 
+bool is_real_activity(enum unit_activity activity);
+
 /* Iterates over the types of unit activity. */
 #define activity_type_iterate(act)					    \
 {									    \
   Activity_type_id act;			         			    \
 									    \
-  for (act = 0; act < ACTIVITY_LAST; act++) {
+  for (act = 0; act < ACTIVITY_LAST; act++) {				    \
+    if (is_real_activity(act)) {
 
 #define activity_type_iterate_end     					    \
+    }									    \
   }									    \
 }
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to