Author: cazfi
Date: Tue Jun 28 07:40:28 2016
New Revision: 33074

URL: http://svn.gna.org/viewcvs/freeciv?rev=33074&view=rev
Log:
Added active_iterate macros about ruleset objects that can be disabled.

See bug #24793

Modified:
    trunk/common/improvement.h
    trunk/common/tech.h
    trunk/common/traderoutes.h
    trunk/common/unittype.h
    trunk/tools/ruledit/tab_misc.cpp

Modified: trunk/common/improvement.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/improvement.h?rev=33074&r1=33073&r2=33074&view=diff
==============================================================================
--- trunk/common/improvement.h  (original)
+++ trunk/common/improvement.h  Tue Jun 28 07:40:28 2016
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -203,6 +203,14 @@
   }                                                                    \
 }
 
+#define improvement_active_iterate(_p)                                  \
+  improvement_iterate(_p) {                                             \
+    if (!_p->disabled) {
+
+#define improvement_active_iterate_end                                  \
+    }                                                                   \
+  } improvement_iterate_end;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/tech.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/tech.h?rev=33074&r1=33073&r2=33074&view=diff
==============================================================================
--- trunk/common/tech.h (original)
+++ trunk/common/tech.h Tue Jun 28 07:40:28 2016
@@ -214,6 +214,15 @@
   }                                                                    \
 }
 
+#define advance_active_iterate(_p)                                      \
+  advance_iterate(A_FIRST, _p) {                                         \
+    if (_p->require[AR_ONE] != A_NEVER) {
+
+#define advance_active_iterate_end                                      \
+    }                                                                   \
+  } advance_iterate_end;
+
+
 /* Advance requirements iterator. */
 struct advance_req_iter;
 

Modified: trunk/common/traderoutes.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/traderoutes.h?rev=33074&r1=33073&r2=33074&view=diff
==============================================================================
--- trunk/common/traderoutes.h  (original)
+++ trunk/common/traderoutes.h  Tue Jun 28 07:40:28 2016
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -188,6 +188,14 @@
   }                                                  \
 }
 
+#define goods_active_type_iterate(_p)                         \
+  goods_type_iterate(_p) {                                    \
+    if (!_p->disabled) {
+
+#define goods_active_type_iterate_end                         \
+    }                                                         \
+  } goods_type_iterate_end;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/unittype.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.h?rev=33074&r1=33073&r2=33074&view=diff
==============================================================================
--- trunk/common/unittype.h     (original)
+++ trunk/common/unittype.h     Tue Jun 28 07:40:28 2016
@@ -751,6 +751,15 @@
   }                                                                    \
 }
 
+#define unit_active_type_iterate(_p)                                    \
+  unit_type_iterate(_p) {                                               \
+    if (!_p->disabled) {
+
+#define unit_active_type_iterate_end                                    \
+    }                                                                   \
+  } unit_type_iterate_end;
+
+
 void *utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai);
 void utype_set_ai_data(struct unit_type *ptype, const struct ai_type *ai,
                        void *data);

Modified: trunk/tools/ruledit/tab_misc.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/tab_misc.cpp?rev=33074&r1=33073&r2=33074&view=diff
==============================================================================
--- trunk/tools/ruledit/tab_misc.cpp    (original)
+++ trunk/tools/ruledit/tab_misc.cpp    Tue Jun 28 07:40:28 2016
@@ -236,29 +236,23 @@
   stats->item(row++, 
1)->setText(QString::number(game.control.num_resource_types));
 
   count = 0;
-  advance_iterate(A_FIRST, padv) {
-    if (padv->require[AR_ONE] != A_NEVER) {
-      count++;
-    }
-  } advance_iterate_end;
+  advance_active_iterate(padv) {
+    count++;
+  } advance_active_iterate_end;
   stats->item(row++, 1)->setText(QString::number(count));
 
   stats->item(row++, 
1)->setText(QString::number(game.control.num_unit_classes));
 
   count = 0;
-  unit_type_iterate(ptype) {
-    if (!ptype->disabled) {
-      count++;
-    }
-  } unit_type_iterate_end;
+  unit_active_type_iterate(ptype) {
+    count++;
+  } unit_active_type_iterate_end;
   stats->item(row++, 1)->setText(QString::number(count));
 
   count = 0;
-  improvement_iterate(pimpr) {
-    if (!pimpr->disabled) {
-      count++;
-    }
-  } improvement_iterate_end;
+  improvement_active_iterate(pimpr) {
+    count++;
+  } improvement_active_iterate_end;
   stats->item(row++, 1)->setText(QString::number(count));
 
   // Second column
@@ -275,7 +269,11 @@
   stats->item(row++, 
7)->setText(QString::number(game.control.num_extra_types));
   stats->item(row++, 7)->setText(QString::number(game.control.num_base_types));
   stats->item(row++, 7)->setText(QString::number(game.control.num_road_types));
-  stats->item(row++, 
7)->setText(QString::number(game.control.num_goods_types));
+  count = 0;
+  goods_active_type_iterate(pg) {
+    count++;
+  } goods_active_type_iterate_end;
+  stats->item(row++, 7)->setText(QString::number(count));
 
   stats->resizeColumnsToContents();
 }


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

Reply via email to