Author: cazfi
Date: Sun Sep 11 16:30:26 2016
New Revision: 33778

URL: http://svn.gna.org/viewcvs/freeciv?rev=33778&view=rev
Log:
Added value editing for AI Level, Specialist, and Terrain Class requirement 
types.

See patch #7679

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

Modified: trunk/common/specialist.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/specialist.c?rev=33778&r1=33777&r2=33778&view=diff
==============================================================================
--- trunk/common/specialist.c   (original)
+++ trunk/common/specialist.c   Sun Sep 11 16:30:26 2016
@@ -41,6 +41,7 @@
     struct specialist *p = &specialists[i];
 
     p->item_number = i;
+    p->disabled = FALSE;
 
     requirement_vector_init(&p->reqs);
   }

Modified: trunk/common/specialist.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/specialist.h?rev=33778&r1=33777&r2=33778&view=diff
==============================================================================
--- trunk/common/specialist.h   (original)
+++ trunk/common/specialist.h   Sun Sep 11 16:30:26 2016
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 2005 - The Freeciv Project
    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
@@ -30,6 +30,7 @@
   int item_number;
   struct name_translation name;
   struct name_translation abbreviation;
+  bool disabled;
 
   char graphic_alt[MAX_LEN_NAME];
 
@@ -61,7 +62,7 @@
 const char *specialists_string(const citizens *specialist_list);
 
 int get_specialist_output(const struct city *pcity,
-                         Specialist_type_id sp, Output_type_id otype);
+                          Specialist_type_id sp, Output_type_id otype);
 
 /* Initialization and iteration */
 void specialists_init(void);
@@ -78,6 +79,15 @@
   }                                                                         \
 }
 
+#define specialist_active_type_iterate(_p)                                  \
+  specialist_type_iterate(_p##_) {                                          \
+    struct specialist *_p = specialist_by_number(_p##_);                    \
+    if (!_p->disabled) {
+
+#define specialist_active_type_iterate_end                                  \
+    }                                                                       \
+  } specialist_type_iterate_end;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/terrain.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/terrain.h?rev=33778&r1=33777&r2=33778&view=diff
==============================================================================
--- trunk/common/terrain.h      (original)
+++ trunk/common/terrain.h      Sun Sep 11 16:30:26 2016
@@ -74,6 +74,7 @@
 #define SPECENUM_VALUE1 TC_OCEAN
 /* TRANS: terrain class: used adjectivally */
 #define SPECENUM_VALUE1NAME N_("Oceanic")
+#define SPECENUM_COUNT  TC_COUNT
 #include "specenum_gen.h"
 
 /* Types of alterations available to terrain.

Modified: trunk/tools/ruledit/tab_misc.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/tab_misc.cpp?rev=33778&r1=33777&r2=33778&view=diff
==============================================================================
--- trunk/tools/ruledit/tab_misc.cpp    (original)
+++ trunk/tools/ruledit/tab_misc.cpp    Sun Sep 11 16:30:26 2016
@@ -32,6 +32,7 @@
 // common
 #include "game.h"
 #include "government.h"
+#include "specialist.h"
 
 // server
 #include "rssanity.h"
@@ -287,7 +288,11 @@
   } styles_active_iterate_end;
   stats->item(row++, 4)->setText(QString::number(count));
 
-  stats->item(row++, 
4)->setText(QString::number(game.control.num_specialist_types));
+  count = 0;
+  specialist_active_type_iterate(pspe) {
+    count++;
+  } specialist_active_type_iterate_end;
+  stats->item(row++, 4)->setText(QString::number(count));
 
   count = 0;
   governments_active_iterate(pgov) {

Modified: trunk/tools/ruledit/univ_value.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/univ_value.c?rev=33778&r1=33777&r2=33778&view=diff
==============================================================================
--- trunk/tools/ruledit/univ_value.c    (original)
+++ trunk/tools/ruledit/univ_value.c    Sun Sep 11 16:30:26 2016
@@ -208,6 +208,8 @@
 void universal_kind_values(struct universal *univ,
                            univ_kind_values_cb cb, void *data)
 {
+  int i;
+
   switch (univ->kind) {
   case VUT_NONE:
     break;
@@ -271,11 +273,23 @@
       cb(style_rule_name(pstyle), univ->value.style == pstyle, data);
     } styles_active_iterate_end;
     break;
+  case VUT_AI_LEVEL:
+    for (i = 0; i < AI_LEVEL_COUNT; i++) {
+      cb(ai_level_name(i), univ->value.ai_level == i, data);
+    }
+    break;
+  case VUT_SPECIALIST:
+    specialist_active_type_iterate(pspe) {
+      cb(specialist_rule_name(pspe), univ->value.specialist == pspe, data);
+    } specialist_active_type_iterate_end;
+    break;
+  case VUT_TERRAINCLASS:
+    for (i = 0; i < TC_COUNT; i++) {
+      cb(terrain_class_name(i), univ->value.terrainclass == i, data);
+    }
+    break;
   case VUT_UTFLAG:
   case VUT_UCFLAG:
-  case VUT_SPECIALIST:
-  case VUT_AI_LEVEL:
-  case VUT_TERRAINCLASS:
   case VUT_TERRAINALTER:
   case VUT_CITYTILE:
   case VUT_TERRFLAG:


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

Reply via email to