[Freeciv-Dev] (PR#9934) variable number of terrains
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9934 >
This patch adds a new variable game.terrain_count which gives the number
of terrains. The number of terrains is therefore not a fixed value.
This allows adding new terrains.
Note that the terrain enumeration is still in place for now. Reducing
the number of terrains, or reordering them, will break mapgen. And if
you add new terrains onto the end mapgen will not know about them.
Nonetheless you can use scenarios with your custom terrains if you like.
jason
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 4 Sep 2004 17:01:34 -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/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.183
diff -u -r1.183 capstr.c
--- common/capstr.c 3 Sep 2004 03:56:58 -0000 1.183
+++ common/capstr.c 4 Sep 2004 17:01:36 -0000
@@ -73,7 +73,7 @@
* are not directly related to the capability strings discussed here.)
*/
-#define CAPABILITY "+Freeciv.Devel.2004.Sep.2"
+#define CAPABILITY "+Freeciv.Devel.2004.Sep.4"
void init_our_capability(void)
{
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 4 Sep 2004 17:01:36 -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 4 Sep 2004 17:01:36 -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 4 Sep 2004 17:01:37 -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.25
diff -u -r1.25 terrain.h
--- common/terrain.h 4 Sep 2004 16:53:39 -0000 1.25
+++ common/terrain.h 4 Sep 2004 17:01:37 -0000
@@ -73,11 +73,11 @@
/* 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/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 4 Sep 2004 17:01:39 -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);
- }
+ if (nval == 0) {
+ /* TRANS: Obscure ruleset error. "%s" is a filename. */
+ freelog(LOG_FATAL, _("Ruleset doesn't have any terrains (%s)"),
+ filename);
+ exit(EXIT_FAILURE);
+ }
+ game.terrain_count = nval;
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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9934) variable number of terrains,
Jason Short <=
|
|