[Freeciv-Dev] (PR#13337) [Patch] Read native terrains from ruleset
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13337 >
Read information about native terrains for unit classes from
terrain.ruleset.
Currently changing ruleset values will break great many places, so
this patch is unlikely to get committed any time soon.
- ML
diff -Nurd -X.diff_ignore freeciv/common/capstr.c freeciv/common/capstr.c
--- freeciv/common/capstr.c 2005-06-26 12:32:45.625000000 +0300
+++ freeciv/common/capstr.c 2005-06-26 13:08:05.046875000 +0300
@@ -82,7 +82,7 @@
* as long as possible. We want to maintain network compatibility with
* the stable branch for as long as possible.
*/
-#define CAPABILITY "+Freeciv.Devel.2005.Jun.23"
+#define CAPABILITY "+Freeciv.Devel.2005.Jun.26"
void init_our_capability(void)
{
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c 2005-06-26 12:45:42.531250000 +0300
+++ freeciv/common/movement.c 2005-06-26 13:26:07.984375000 +0300
@@ -185,14 +185,9 @@
bool is_native_terrain(const struct unit *punit,
const struct tile *ptile)
{
- switch (unit_types[punit->type].move_type) {
- case LAND_MOVING:
- return !is_ocean(ptile->terrain);
- case SEA_MOVING:
- return is_ocean(ptile->terrain);
- default:
- return TRUE;
- }
+ Unit_Class_id class = get_unit_class(punit->type)->id;
+
+ return BV_ISSET(get_tile_type(tile_get_terrain(ptile))->native_to, class);
}
/****************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def 2005-06-26 12:32:46.968750000 +0300
+++ freeciv/common/packets.def 2005-06-26 13:07:39.515625000 +0300
@@ -1195,6 +1195,7 @@
TERRAIN id;
bitvector(bv_terrain_flags) flags;
+ bitvector(bv_unit_classes) native_to;
STRING terrain_name[MAX_LEN_NAME];
STRING graphic_str[MAX_LEN_NAME];
diff -Nurd -X.diff_ignore freeciv/common/terrain.h freeciv/common/terrain.h
--- freeciv/common/terrain.h 2005-06-26 12:32:47.359375000 +0300
+++ freeciv/common/terrain.h 2005-06-26 13:19:09.093750000 +0300
@@ -17,6 +17,9 @@
#include "fc_types.h"
+#include "unittype.h"
+
+
enum special_river_move {
RMV_NORMAL=0, RMV_FAST_STRICT=1, RMV_FAST_RELAXED=2, RMV_FAST_ALWAYS=3
};
@@ -154,6 +157,8 @@
* then 70% of 'mountainous' tiles will be given mountains. */
int property[MG_LAST];
+ bv_unit_classes native_to;
+
bv_terrain_flags flags;
char *helptext;
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h 2005-06-26 12:45:42.546875000 +0300
+++ freeciv/common/unittype.h 2005-06-26 13:17:46.156250000 +0300
@@ -47,6 +47,8 @@
to hold full number of unit types.
*/
+BV_DEFINE(bv_unit_classes, UCL_LAST);
+
struct move_params {
bool terrain_affects;
bool damage_slows;
diff -Nurd -X.diff_ignore freeciv/data/civ1/terrain.ruleset
freeciv/data/civ1/terrain.ruleset
--- freeciv/data/civ1/terrain.ruleset 2005-06-26 12:32:47.812500000 +0300
+++ freeciv/data/civ1/terrain.ruleset 2005-06-26 13:35:12.250000000 +0300
@@ -143,6 +143,7 @@
; see warmer_wetter_result
; cooler_drier_result = result of nuclear winter for dry terrains;
; see warmer_wetter_result
+; native_to = List of unit classes this is native terrain to
; flags = General flags for this terrain:
; - NoBarbs = Barbarians will not be spawned here.
; - NoPollution = Pollution will not be put on this terrain type.
@@ -197,6 +198,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "NoBarbs"
property_frozen = 100
helptext = _("\
@@ -284,6 +286,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter"
property_temperate = 50
property_foliage = 50
@@ -328,6 +331,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_temperate = 50
property_green = 50
@@ -371,6 +375,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter"
property_mountainous = 30
property_green = 10
@@ -500,6 +505,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Sea", "Air", "Missile", "Nuclear"
flags = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
helptext = _("\
Oceans cover much of the world, and only sea units (Triremes and\
@@ -544,6 +550,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter"
property_temperate = 50
property_green = 50
@@ -631,6 +638,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Arctic"
cooler_drier_result = "Arctic"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "NoBarbs"
property_cold = 50
helptext = _("\
diff -Nurd -X.diff_ignore freeciv/data/civ2/terrain.ruleset
freeciv/data/civ2/terrain.ruleset
--- freeciv/data/civ2/terrain.ruleset 2005-06-26 12:32:48.484375000 +0300
+++ freeciv/data/civ2/terrain.ruleset 2005-06-26 13:34:15.046875000 +0300
@@ -151,6 +151,7 @@
; see warmer_wetter_result
; cooler_drier_result = result of nuclear winter for dry terrains;
; see warmer_wetter_result
+; native_to = List of unit classes this is native terrain to
; flags = General flags for this terrain:
; - NoBarbs = Barbarians will not be spawned here.
; - NoPollution = Pollution will not be put on this terrain type.
@@ -205,6 +206,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "NoBarbs", "CanHaveRiver"
property_frozen = 100
helptext = _("\
@@ -249,6 +251,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_dry = 100
property_tropical = 50
@@ -293,6 +296,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_temperate = 50
property_foliage = 50
@@ -337,6 +341,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_temperate = 50
property_green = 50
@@ -380,6 +385,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_green = 50
property_mountainous = 30
@@ -424,7 +430,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
-flags = "CanHaveRiver"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_tropical = 50
property_foliage = 50
@@ -470,6 +476,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_mountainous = 70
helptext = _("\
@@ -513,6 +520,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Sea", "Air", "Missile", "Nuclear"
flags = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
helptext = _("\
Oceans cover much of the world, and only sea units (Triremes and\
@@ -557,6 +565,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_green = 50
property_temperate = 50
@@ -601,6 +610,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_wet = 100
property_foliage = 10
@@ -645,6 +655,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Glacier"
cooler_drier_result = "Glacier"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "NoBarbs", "CanHaveRiver"
property_cold = 50
helptext = _("\
diff -Nurd -X.diff_ignore freeciv/data/default/terrain.ruleset
freeciv/data/default/terrain.ruleset
--- freeciv/data/default/terrain.ruleset 2005-06-26 12:32:49.140625000
+0300
+++ freeciv/data/default/terrain.ruleset 2005-06-26 12:54:04.843750000
+0300
@@ -157,6 +157,7 @@
; see warmer_wetter_result
; cooler_drier_result = result of nuclear winter for dry terrains;
; see warmer_wetter_result
+; native_to = List of unit classes this is native terrain to
; flags = General flags for this terrain:
; - NoBarbs = Barbarians will not be spawned here.
; - NoPollution = Pollution will not be put on this terrain type.
@@ -233,6 +234,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "NoBarbs", "CanHaveRiver", "UnsafeCoast", "Unsafe"
property_frozen = 100
helptext = _("\
@@ -282,6 +284,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_dry = 100
property_tropical = 50
@@ -331,6 +334,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter","CanHaveRiver"
property_temperate = 50
property_foliage = 50
@@ -380,6 +384,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_temperate = 50
property_green = 50
@@ -428,6 +433,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_green = 50
property_mountainous = 30
@@ -477,6 +483,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_tropical = 50
property_foliage = 50
@@ -527,6 +534,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_mountainous = 70
helptext = _("\
@@ -575,6 +583,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Sea", "Air", "Missile", "Nuclear"
flags = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
property_ocean_depth = 10
helptext = _("\
@@ -625,6 +634,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_green = 50
property_temperate = 50
@@ -674,6 +684,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_wet = 100
property_foliage = 10
@@ -723,6 +734,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Glacier"
cooler_drier_result = "Glacier"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "NoBarbs", "CanHaveRiver"
property_cold = 50
helptext = _("\
diff -Nurd -X.diff_ignore freeciv/data/history/terrain.ruleset
freeciv/data/history/terrain.ruleset
--- freeciv/data/history/terrain.ruleset 2005-06-26 12:32:53.781250000
+0300
+++ freeciv/data/history/terrain.ruleset 2005-06-26 13:36:10.671875000
+0300
@@ -210,6 +210,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "NoBarbs", "CanHaveRiver", "UnsafeCoast", "Unsafe"
property_frozen = 100
helptext = _("\
@@ -259,6 +260,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_dry = 100
property_tropical = 50
@@ -308,6 +310,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_temperate = 50
property_foliage = 50
@@ -357,6 +360,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_temperate = 50
property_green = 50
@@ -405,6 +409,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_mountainous = 30
helptext = _("\
@@ -453,6 +458,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_tropical = 50
property_foliage = 50
@@ -503,6 +509,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_mountainous = 70
helptext = _("\
@@ -551,6 +558,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "no"
cooler_drier_result = "no"
+native_to = "Sea", "Air", "Missile", "Nuclear"
flags = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
helptext = _("\
Oceans cover much of the world, and only sea units (Triremes and\
@@ -600,6 +608,7 @@
warmer_drier_result = "Desert"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "Starter", "CanHaveRiver"
property_green = 50
property_temperate = 50
@@ -649,6 +658,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Desert"
cooler_drier_result = "Tundra"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "CanHaveRiver"
property_wet = 100
property_foliage = 10
@@ -698,6 +708,7 @@
warmer_drier_result = "no"
cooler_wetter_result = "Glacier"
cooler_drier_result = "Glacier"
+native_to = "Land", "Air", "Missile", "Nuclear"
flags = "NoBarbs", "CanHaveRiver"
property_cold = 50
helptext = _("\
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c 2005-06-26 12:45:42.593750000 +0300
+++ freeciv/server/ruleset.c 2005-06-26 13:05:51.953125000 +0300
@@ -1620,6 +1620,21 @@
"%s.property_%s",
sec[i], mg_names[j]);
}
+
+ slist = secfile_lookup_str_vec(file, &nval, "%s.native_to", sec[i]);
+ BV_CLR_ALL(t->native_to);
+ for (j = 0; j < nval; j++) {
+ Unit_Class_id class = unit_class_from_str(slist[j]);
+
+ if(class == UCL_LAST) {
+ /* TRANS: message for an obscure ruleset error. */
+ freelog(LOG_FATAL, _("Terrain %s is native to unknown unit class %s"),
+ t->terrain_name, slist[j]);
+ exit(EXIT_FAILURE);
+ } else {
+ BV_SET(t->native_to, class);
+ }
+ }
t->helptext = lookup_helptext(file, sec[i]);
} terrain_type_iterate_end;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13337) [Patch] Read native terrains from ruleset,
Marko Lindqvist <=
|
|