Author: sveinung
Date: Tue Mar 10 12:50:17 2015
New Revision: 28483

URL: http://svn.gna.org/viewcvs/freeciv?rev=28483&view=rev
Log:
Make citytile_type a specenum.

See patch #5921

Modified:
    branches/S2_6/common/city.c
    branches/S2_6/common/city.h
    branches/S2_6/common/fc_types.h
    branches/S2_6/common/requirements.c

Modified: branches/S2_6/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/city.c?rev=28483&r1=28482&r2=28483&view=diff
==============================================================================
--- branches/S2_6/common/city.c (original)
+++ branches/S2_6/common/city.c Tue Mar 10 12:50:17 2015
@@ -3181,18 +3181,6 @@
 }
 
 /**************************************************************************
-  Return citytile type for a given rule name
-**************************************************************************/
-enum citytile_type citytile_by_rule_name(const char *name)
-{
-  if (!fc_strcasecmp(name, "Center")) {
-    return CITYT_CENTER;
-  }
-
-  return CITYT_LAST;
-}
-
-/**************************************************************************
   Return pointer to ai data of given city and ai type.
 **************************************************************************/
 void *city_ai_data(const struct city *pcity, const struct ai_type *ai)

Modified: branches/S2_6/common/city.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/city.h?rev=28483&r1=28482&r2=28483&view=diff
==============================================================================
--- branches/S2_6/common/city.h (original)
+++ branches/S2_6/common/city.h Tue Mar 10 12:50:17 2015
@@ -743,8 +743,6 @@
   (CITY_MAP_CENTER_TILE_INDEX == city_tile_index)
 #define FREE_WORKED_TILES (1)
 
-enum citytile_type citytile_by_rule_name(const char *name);
-
 void *city_ai_data(const struct city *pcity, const struct ai_type *ai);
 void city_set_ai_data(struct city *pcity, const struct ai_type *ai,
                       void *data);

Modified: branches/S2_6/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=28483&r1=28482&r2=28483&view=diff
==============================================================================
--- branches/S2_6/common/fc_types.h     (original)
+++ branches/S2_6/common/fc_types.h     Tue Mar 10 12:50:17 2015
@@ -266,10 +266,11 @@
  *
  * Used in the network protocol
  */
-enum citytile_type {
-  CITYT_CENTER,
-  CITYT_LAST
-};
+#define SPECENUM_NAME citytile_type
+#define SPECENUM_VALUE0 CITYT_CENTER
+#define SPECENUM_VALUE0NAME "Center"
+#define SPECENUM_COUNT CITYT_LAST
+#include "specenum_gen.h"
 
 /*
  * UnitState requirement property types.

Modified: branches/S2_6/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/requirements.c?rev=28483&r1=28482&r2=28483&view=diff
==============================================================================
--- branches/S2_6/common/requirements.c (original)
+++ branches/S2_6/common/requirements.c Tue Mar 10 12:50:17 2015
@@ -275,7 +275,7 @@
     }
     break;
   case VUT_CITYTILE:
-    source.value.citytile = citytile_by_rule_name(value);
+    source.value.citytile = citytile_type_by_name(value, fc_strcasecmp);
     if (source.value.citytile != CITYT_LAST) {
       return source;
     }
@@ -2908,11 +2908,7 @@
   case VUT_NONE:
     return "(none)";
   case VUT_CITYTILE:
-    if (psource->value.citytile == CITYT_CENTER) {
-      return "Center";
-    } else {
-      return "(none)";
-    }
+    return citytile_type_name(psource->value.citytile);
   case VUT_MINYEAR:
     fc_snprintf(buffer, sizeof(buffer), "%d", psource->value.minyear);
 


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

Reply via email to