Author: cazfi
Date: Mon Aug 22 12:45:19 2016
New Revision: 33667

URL: http://svn.gna.org/viewcvs/freeciv?rev=33667&view=rev
Log:
Added value editing for Terrain, Nation, and Unit type requirement types.

See patch #7638

Modified:
    trunk/common/terrain.c
    trunk/common/terrain.h
    trunk/tools/ruledit/tab_misc.cpp
    trunk/tools/ruledit/univ_value.c

Modified: trunk/common/terrain.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/terrain.c?rev=33667&r1=33666&r2=33667&view=diff
==============================================================================
--- trunk/common/terrain.c      (original)
+++ trunk/common/terrain.c      Mon Aug 22 12:45:19 2016
@@ -46,6 +46,7 @@
   for (i = 0; i < ARRAY_SIZE(civ_terrains); i++) {
     /* Can't use terrain_by_number here because it does a bounds check. */
     civ_terrains[i].item_number = i;
+    civ_terrains[i].disabled = FALSE;
     civ_terrains[i].rgb = NULL;
     civ_terrains[i].animal = NULL;
   }

Modified: trunk/common/terrain.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/terrain.h?rev=33667&r1=33666&r2=33667&view=diff
==============================================================================
--- trunk/common/terrain.h      (original)
+++ trunk/common/terrain.h      Mon Aug 22 12:45:19 2016
@@ -175,6 +175,7 @@
 struct terrain {
   int item_number;
   struct name_translation name;
+  bool disabled; /* Does not really exist - hole in terrain array */
   char graphic_str[MAX_LEN_NAME];      /* add tile_ prefix */
   char graphic_alt[MAX_LEN_NAME];
 
@@ -349,6 +350,14 @@
   }                                                                    \
 }
 
+#define terrain_active_iterate(_p)                         \
+  terrain_type_iterate(_p) {                               \
+    if (!_p->disabled) {
+
+#define terrain_active_iterate_end                         \
+    }                                                      \
+  } terrain_type_iterate_end;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/tools/ruledit/tab_misc.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/tab_misc.cpp?rev=33667&r1=33666&r2=33667&view=diff
==============================================================================
--- trunk/tools/ruledit/tab_misc.cpp    (original)
+++ trunk/tools/ruledit/tab_misc.cpp    Mon Aug 22 12:45:19 2016
@@ -237,7 +237,12 @@
   int row = 0;
   int count;
 
-  stats->item(row++, 1)->setText(QString::number(game.control.terrain_count));
+  count = 0;
+  terrain_active_iterate(pterr) {
+    count++;
+  } terrain_active_iterate_end;
+  stats->item(row++, 1)->setText(QString::number(count));
+
   stats->item(row++, 
1)->setText(QString::number(game.control.num_resource_types));
 
   count = 0;

Modified: trunk/tools/ruledit/univ_value.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/univ_value.c?rev=33667&r1=33666&r2=33667&view=diff
==============================================================================
--- trunk/tools/ruledit/univ_value.c    (original)
+++ trunk/tools/ruledit/univ_value.c    Mon Aug 22 12:45:19 2016
@@ -227,8 +227,20 @@
     } improvement_active_iterate_end;
     break;
   case VUT_TERRAIN:
+    terrain_active_iterate(pterr) {
+      cb(terrain_rule_name(pterr), univ->value.terrain == pterr, data);
+    } terrain_active_iterate_end;
+    break;
   case VUT_NATION:
+    nations_iterate(pnat) {
+      cb(nation_rule_name(pnat), univ->value.nation == pnat, data);
+    } nations_iterate_end;
+    break;
   case VUT_UTYPE:
+    unit_active_type_iterate(putype) {
+      cb(utype_rule_name(putype), univ->value.utype == putype, data);
+    } unit_active_type_iterate_end;
+    break;
   case VUT_UTFLAG:
   case VUT_UCLASS:
   case VUT_UCFLAG:


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

Reply via email to