<URL: http://bugs.freeciv.org/Ticket/Display.html?id=34377 >
New unit class flag "AlwaysSafe". Units with this flag are safe from
unsafe terrains. Previously that was hardcoded property of AIR_MOVING
and HELI_MOVING units. This also fixes the problem that amphibious
units were safe from unsafe terrain.
- ML
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c 2007-01-22 17:18:36.000000000 +0200
+++ freeciv/common/unit.c 2007-01-23 16:44:13.000000000 +0200
@@ -1198,8 +1198,8 @@
}
}
- /* All units may be lost on unsafe terrain. (Actually air units are
- * exempt; see base_unsafe_terrain_loss_pct.) */
+ /* All units may be lost on unsafe terrain. (Actually units with
+ * class flag UCF_ALWAYS_SAFE are exempt; see base_unsafe_terrain_loss_pct.) */
if (terrain_has_flag(tile_get_terrain(ptile), TER_UNSAFE)) {
return loss_pct + base_unsafe_terrain_loss_pct(pplayer, punit);
}
@@ -1226,12 +1226,14 @@
}
/**************************************************************************
- All units except air units have a flat 15% chance of being lost.
+ All units without unit class flag UCF_ALWAYS_SAFE have a flat 15% chance
+ of being lost.
**************************************************************************/
int base_unsafe_terrain_loss_pct(const struct player *pplayer,
const struct unit *punit)
{
- return (is_air_unit(punit) || is_heli_unit(punit)) ? 0 : 15;
+ return unit_class_flag(get_unit_class(unit_type(punit)), UCF_ALWAYS_SAFE)
+ ? 0 : 15;
}
/**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c 2007-01-23 16:05:15.000000000 +0200
+++ freeciv/common/unittype.c 2007-01-23 16:35:00.000000000 +0200
@@ -41,7 +41,7 @@
static const char *unit_class_flag_names[] = {
"TerrainSpeed", "DamageSlows", "CanOccupy", "Missile",
- "RoadNative", "BuildAnywhere", "Unreachable"
+ "RoadNative", "BuildAnywhere", "Unreachable", "AlwaysSafe"
};
static const char *flag_names[] = {
"TradeRoute" ,"HelpWonder", "IgZOC", "NonMil", "IgTer",
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h 2007-01-23 16:05:15.000000000 +0200
+++ freeciv/common/unittype.h 2007-01-23 16:34:43.000000000 +0200
@@ -33,6 +33,7 @@
UCF_ROAD_NATIVE,
UCF_BUILD_ANYWHERE,
UCF_UNREACHABLE,
+ UCF_ALWAYS_SAFE,
UCF_LAST
};
diff -Nurd -X.diff_ignore freeciv/data/civ1/units.ruleset freeciv/data/civ1/units.ruleset
--- freeciv/data/civ1/units.ruleset 2007-01-23 16:05:14.000000000 +0200
+++ freeciv/data/civ1/units.ruleset 2007-01-23 16:36:51.000000000 +0200
@@ -67,6 +67,7 @@
; "BuildAnywhere" = Unit can be built even in the middle of non-native terrain
; "Unreachable" = Unit can be attacked only by units with "AttackAny" flag or on
; city or airbase
+; "AlwaysSafe" = Unit is safe even on unsafe terrain
[unitclass_land]
name = _("Land")
@@ -87,14 +88,14 @@
move_type = "Air"
min_speed = 1
hp_loss_pct = 0
-flags = "Unreachable"
+flags = "Unreachable", "AlwaysSafe"
[unitclass_missile]
name = _("Missile")
move_type = "Air"
min_speed = 1
hp_loss_pct = 0
-flags = "Missile", "Unreachable"
+flags = "Missile", "Unreachable", "AlwaysSafe"
; Below: The individual units, one per section.
;
diff -Nurd -X.diff_ignore freeciv/data/civ2/units.ruleset freeciv/data/civ2/units.ruleset
--- freeciv/data/civ2/units.ruleset 2007-01-23 16:05:15.000000000 +0200
+++ freeciv/data/civ2/units.ruleset 2007-01-23 16:36:30.000000000 +0200
@@ -67,13 +67,14 @@
; "BuildAnywhere" = Unit can be built even in the middle of non-native terrain
; "Unreachable" = Unit can be attacked only by units with "AttackAny" flag or on
; city or airbase
+; "AlwaysSafe" = Unit is safe even on unsafe terrain
[unitclass_missile]
name = _("Missile")
move_type = "Air"
min_speed = 1
hp_loss_pct = 0
-flags = "Missile", "Unreachable"
+flags = "Missile", "Unreachable", "AlwaysSafe"
[unitclass_land]
name = _("Land")
@@ -94,14 +95,14 @@
move_type = "Both"
min_speed = 1
hp_loss_pct = 10
-flags = "CanOccupy"
+flags = "CanOccupy", "AlwaysSafe"
[unitclass_air]
name = _("Air")
move_type = "Air"
min_speed = 1
hp_loss_pct = 0
-flags = "Unreachable"
+flags = "Unreachable", "AlwaysSafe"
; Below: The individual units, one per section.
;
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset 2007-01-23 16:05:15.000000000 +0200
+++ freeciv/data/default/units.ruleset 2007-01-23 16:35:57.000000000 +0200
@@ -73,13 +73,14 @@
; "BuildAnywhere" = Unit can be built even in the middle of non-native terrain
; "Unreachable" = Unit can be attacked only by units with "AttackAny" flag or on
; city or airbase
+; "AlwaysSafe" = Unit is safe even on unsafe terrain
[unitclass_missile]
name = _("Missile")
move_type = "Air"
min_speed = 1
hp_loss_pct = 0
-flags = "Missile", "Unreachable"
+flags = "Missile", "Unreachable", "AlwaysSafe"
[unitclass_land]
name = _("Land")
@@ -100,14 +101,14 @@
move_type = "Both"
min_speed = 1
hp_loss_pct = 10
-flags = "CanOccupy"
+flags = "CanOccupy", "AlwaysSafe"
[unitclass_air]
name = _("Air")
move_type = "Air"
min_speed = 1
hp_loss_pct = 0
-flags = "Unreachable"
+flags = "Unreachable", "AlwaysSafe"
; Below: The individual units, one per section.
;
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c 2007-01-22 22:06:23.000000000 +0200
+++ freeciv/server/unittools.c 2007-01-23 16:39:39.000000000 +0200
@@ -370,11 +370,11 @@
unit_name(punit->type));
}
}
- } else if (!(is_air_unit(punit) || is_heli_unit(punit))
+ } else if (!unit_class_flag(get_unit_class(unit_type(punit)), UCF_ALWAYS_SAFE)
&& (myrand(100) < unit_loss_pct(pplayer,
punit->tile, punit))) {
- /* All units may have a chance of dying if they are on TER_UNSAFE
- * terrain. */
+ /* Units without unit class flag UCF_ALWAYS_SAFE have a chance of
+ * dying if they are on TER_UNSAFE terrain. */
notify_player(pplayer, punit->tile, E_UNIT_LOST,
_("Your %s has been lost on unsafe terrain."),
unit_name(punit->type));
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev