Author: sveinung Date: Tue Mar 10 12:49:49 2015 New Revision: 28482 URL: http://svn.gna.org/viewcvs/freeciv?rev=28482&view=rev Log: Make citytile_type a specenum.
See patch #5921 Modified: trunk/common/city.c trunk/common/city.h trunk/common/fc_types.h trunk/common/requirements.c Modified: trunk/common/city.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/city.c?rev=28482&r1=28481&r2=28482&view=diff ============================================================================== --- trunk/common/city.c (original) +++ trunk/common/city.c Tue Mar 10 12:49:49 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: trunk/common/city.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/city.h?rev=28482&r1=28481&r2=28482&view=diff ============================================================================== --- trunk/common/city.h (original) +++ trunk/common/city.h Tue Mar 10 12:49:49 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: trunk/common/fc_types.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=28482&r1=28481&r2=28482&view=diff ============================================================================== --- trunk/common/fc_types.h (original) +++ trunk/common/fc_types.h Tue Mar 10 12:49:49 2015 @@ -268,10 +268,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: trunk/common/requirements.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.c?rev=28482&r1=28481&r2=28482&view=diff ============================================================================== --- trunk/common/requirements.c (original) +++ trunk/common/requirements.c Tue Mar 10 12:49:49 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