Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
September 2004: [Freeciv-Dev] (PR#9787) RFC: generalized terrain |
![]() |
[Freeciv-Dev] (PR#9787) RFC: generalized terrain[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9787 > Here's an updated patch. Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.400 diff -u -r1.400 packhand.c --- client/packhand.c 31 Aug 2004 04:40:48 -0000 1.400 +++ client/packhand.c 3 Sep 2004 20:19:50 -0000 @@ -2190,6 +2190,8 @@ city_styles_alloc(packet->style_count); tilespec_alloc_city_tiles(game.styles_count); + game.terrain_count = packet->terrain_count; + for(i = 0; i < MAX_NUM_TEAMS; i++) { mystrlcpy(team_get_by_id(i)->name, packet->team_name[i], MAX_LEN_NAME); Index: common/fc_types.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v retrieving revision 1.5 diff -u -r1.5 fc_types.h --- common/fc_types.h 3 Sep 2004 04:22:37 -0000 1.5 +++ common/fc_types.h 3 Sep 2004 20:19:50 -0000 @@ -19,7 +19,7 @@ * definition in another file */ typedef signed short Continent_id; -typedef enum tile_terrain_type Terrain_type_id; +typedef int Terrain_type_id; /* TODO: Remove this enum and make this an integer when gen-eff is done. */ typedef enum { Index: common/game.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/game.h,v retrieving revision 1.149 diff -u -r1.149 game.h --- common/game.h 3 Sep 2004 04:22:37 -0000 1.149 +++ common/game.h 3 Sep 2004 20:19:50 -0000 @@ -156,6 +156,8 @@ int playable_nation_count; int styles_count; + int terrain_count; + int watchtower_extra_vision; int watchtower_vision; int allowed_city_names; Index: common/nation.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/nation.h,v retrieving revision 1.30 diff -u -r1.30 nation.h --- common/nation.h 3 Sep 2004 04:22:37 -0000 1.30 +++ common/nation.h 3 Sep 2004 20:19:50 -0000 @@ -57,7 +57,7 @@ struct city_name { char* name; ternary river; - ternary terrain[T_COUNT]; + ternary terrain[MAX_NUM_TERRAINS]; }; struct leader { Index: common/packets.def =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v retrieving revision 1.45 diff -u -r1.45 packets.def --- common/packets.def 3 Sep 2004 03:56:58 -0000 1.45 +++ common/packets.def 3 Sep 2004 20:19:50 -0000 @@ -1240,6 +1240,7 @@ UINT8 nation_count; UINT8 playable_nation_count; UINT8 style_count; + UINT8 terrain_count; UINT8 borders; BOOL happyborders; BOOL slow_invasions; Index: common/terrain.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v retrieving revision 1.24 diff -u -r1.24 terrain.h --- common/terrain.h 3 Sep 2004 15:12:26 -0000 1.24 +++ common/terrain.h 3 Sep 2004 20:19:50 -0000 @@ -62,22 +62,17 @@ | S_FORTRESS \ | S_AIRBASE) -/* Changing this breaks savegame and network compatability. */ -enum tile_terrain_type { - T_NONE = -3, /* A special flag meaning no terrain. */ - T_ANY = -2, /* A special flag that matches "any" terrain type. */ - T_UNKNOWN = -1, /* A special flag meaning unknown terrain. */ - T_ARCTIC, T_DESERT, T_FOREST, T_GRASSLAND, T_HILLS, T_JUNGLE, - T_MOUNTAINS, T_OCEAN, T_PLAINS, T_UNUSED, T_SWAMP, T_TUNDRA -}; +#define T_NONE (-3) /* A special flag meaning no terrain type. */ +#define T_ANY (-2) /* A special flag that matches "any" terrain type. */ +#define T_UNKNOWN (-1) /* An unknown terrain. */ /* The first terrain value and number of base terrains. This is used in * loops. T_COUNT may eventually be turned into a variable. */ -#define T_FIRST (T_ARCTIC) -#define T_COUNT (T_TUNDRA + 1) +#define T_FIRST (0) +#define T_COUNT (game.terrain_count) /* A hard limit on the number of terrains; useful for static arrays. */ -#define MAX_NUM_TERRAINS (T_COUNT) +#define MAX_NUM_TERRAINS (MAX_NUM_ITEMS) /* Must match with terrain_flag_from_str in terrain.c. */ enum terrain_flag_id { Index: server/mapgen.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v retrieving revision 1.154 diff -u -r1.154 mapgen.c --- server/mapgen.c 3 Sep 2004 15:12:26 -0000 1.154 +++ server/mapgen.c 3 Sep 2004 20:19:52 -0000 @@ -33,6 +33,12 @@ #include "mapgen.h" +/* Old-style terrain enumeration: deprecated. */ +enum { + T_ARCTIC, T_DESERT, T_FOREST, T_GRASSLAND, T_HILLS, T_JUNGLE, + T_MOUNTAINS, T_OCEAN, T_PLAINS, T_UNUSED, T_SWAMP, T_TUNDRA, +}; + /* Provide a block to convert from native to map coordinates. For instance * do_in_map_pos(mx, my, xn, yn) { * map_set_terrain(mx, my, T_OCEAN); Index: server/ruleset.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v retrieving revision 1.192 diff -u -r1.192 ruleset.c --- server/ruleset.c 31 Aug 2004 04:40:50 -0000 1.192 +++ server/ruleset.c 3 Sep 2004 20:19:52 -0000 @@ -1508,12 +1508,13 @@ /* terrain names */ sec = secfile_get_secnames_prefix(file, "terrain_", &nval); - if (nval != (T_COUNT - T_FIRST)) - { - /* sometime this restriction should be removed */ - freelog(LOG_FATAL, "Bad number of terrains %d (%s)", nval, filename); - exit(EXIT_FAILURE); - } + game.terrain_count = nval; + if (nval == 0) { + /* TRANS: "%s" is filename */ + freelog(LOG_FATAL, _("Ruleset doesn't have any terrains (%s)"), + filename); + exit(EXIT_FAILURE); + } terrain_type_iterate(i) { char *name = secfile_lookup_str(file, "%s.terrain_name", sec[i]); @@ -1999,6 +2000,7 @@ packet.nation_count = game.nation_count; packet.playable_nation_count = game.playable_nation_count; packet.style_count = game.styles_count; + packet.terrain_count = game.terrain_count; for(i = 0; i < MAX_NUM_TEAMS; i++) { sz_strlcpy(packet.team_name[i], team_get_by_id(i)->name);
|