From 515151e2d12a107a7dc306d649a27d48b85f786b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 26 Apr 2023 21:05:22 +0300 Subject: [PATCH 38/38] Add support for units that can always defend transported Requested by Sveinung Kvilhaugsvik See osdn #43541 Signed-off-by: Marko Lindqvist --- common/fc_types.h | 2 ++ common/movement.c | 7 ++++--- data/alien/units.ruleset | 1 + data/civ1/units.ruleset | 1 + data/civ2/units.ruleset | 1 + data/civ2civ3/units.ruleset | 1 + data/classic/units.ruleset | 1 + data/goldkeep/units.ruleset | 1 + data/granularity/units.ruleset | 1 + data/multiplayer/units.ruleset | 1 + data/ruledit/comments-3.3.txt | 5 +++-- data/sandbox/units.ruleset | 1 + data/stub/units.ruleset | 1 + data/webperimental/units.ruleset | 1 + 14 files changed, 20 insertions(+), 5 deletions(-) diff --git a/common/fc_types.h b/common/fc_types.h index 3c989db16e..b1aeadc070 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -1362,6 +1362,8 @@ typedef float adv_want; #define SPECENUM_VALUE0NAME "Alight" #define SPECENUM_VALUE1 TDT_BLOCKED #define SPECENUM_VALUE1NAME "Blocked" +#define SPECENUM_VALUE2 TDT_ALWAYS +#define SPECENUM_VALUE2NAME "Always" #include "specenum_gen.h" #ifdef __cplusplus diff --git a/common/movement.c b/common/movement.c index e81e0f45e2..d37deac332 100644 --- a/common/movement.c +++ b/common/movement.c @@ -166,10 +166,9 @@ int utype_unknown_move_cost(const struct unit_type *utype) return move_cost; } - /************************************************************************//** - Return TRUE iff the unit can be a defender at its current location. This - should be checked when looking for a defender - not all units on the + Return TRUE iff the unit can be a defender at its current location. + This should be checked when looking for a defender - not all units on the tile are valid defenders. ****************************************************************************/ bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit) @@ -188,6 +187,8 @@ bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit) case TDT_ALIGHT: return can_unit_exist_at_tile(nmap, punit, unit_tile(punit)) && can_unit_deboard_or_be_unloaded(punit, ptrans); + case TDT_ALWAYS: + return TRUE; } fc_assert(FALSE); diff --git a/data/alien/units.ruleset b/data/alien/units.ruleset index bbcde45fe8..711ddf5d75 100644 --- a/data/alien/units.ruleset +++ b/data/alien/units.ruleset @@ -244,6 +244,7 @@ flags = "Missile", "DoesntOccupyTile" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/civ1/units.ruleset b/data/civ1/units.ruleset index 8cef493931..4622e0d2df 100644 --- a/data/civ1/units.ruleset +++ b/data/civ1/units.ruleset @@ -219,6 +219,7 @@ flags = "Missile", "Unreachable", "HutNothing" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/civ2/units.ruleset b/data/civ2/units.ruleset index 217481e157..630f1a26f1 100644 --- a/data/civ2/units.ruleset +++ b/data/civ2/units.ruleset @@ -237,6 +237,7 @@ flags = "Unreachable", "DoesntOccupyTile", "HutFrighten" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/civ2civ3/units.ruleset b/data/civ2civ3/units.ruleset index d040e74459..280f7737a1 100644 --- a/data/civ2civ3/units.ruleset +++ b/data/civ2civ3/units.ruleset @@ -278,6 +278,7 @@ flags = "Unreachable", "DoesntOccupyTile", "CanPillage", ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/classic/units.ruleset b/data/classic/units.ruleset index 8be62a75f2..d25e593955 100644 --- a/data/classic/units.ruleset +++ b/data/classic/units.ruleset @@ -248,6 +248,7 @@ flags = "Unreachable", "DoesntOccupyTile", "HutFrighten" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/goldkeep/units.ruleset b/data/goldkeep/units.ruleset index 5c6e865b14..0e81adf278 100644 --- a/data/goldkeep/units.ruleset +++ b/data/goldkeep/units.ruleset @@ -260,6 +260,7 @@ flags = "Unreachable", "DoesntOccupyTile", "HutFrighten" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/granularity/units.ruleset b/data/granularity/units.ruleset index 8a40542f0f..84dd98b91e 100644 --- a/data/granularity/units.ruleset +++ b/data/granularity/units.ruleset @@ -195,6 +195,7 @@ flags = "TerrainSpeed" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/multiplayer/units.ruleset b/data/multiplayer/units.ruleset index 29bc0b030b..4cddf462ad 100644 --- a/data/multiplayer/units.ruleset +++ b/data/multiplayer/units.ruleset @@ -248,6 +248,7 @@ flags = "Unreachable", "DoesntOccupyTile", "HutFrighten" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/ruledit/comments-3.3.txt b/data/ruledit/comments-3.3.txt index f1db299dfd..c2159f633c 100644 --- a/data/ruledit/comments-3.3.txt +++ b/data/ruledit/comments-3.3.txt @@ -360,8 +360,9 @@ utypes = "\ ; (but \'Join City\' uses pop_cost)\n\ ; tp_defense = Method to decide if unit can be selected as a defender when\n\ ; transported.\n\ -; \"Blocked\" - Can't defend when transported\n\ -; \"Alight\" - Can defend if can alight or unload (current default)\n\ +; \"Blocked\" - Can\'t defend when transported\n\ +; \"Alight\" - Can defend if can alight or unload (current default)\n\ +; \"Always\" - Can defend even when transported\n\ ; targets = list of unit classes this unit can attack against even\n\ ; if they have Unreachable unit class flag\n\ ; embarks = list of unit classes this unit may load into while not in\n\ diff --git a/data/sandbox/units.ruleset b/data/sandbox/units.ruleset index daf48e8671..7a39718ffc 100644 --- a/data/sandbox/units.ruleset +++ b/data/sandbox/units.ruleset @@ -291,6 +291,7 @@ flags = "Unreachable", "DoesntOccupyTile", "CanPillage", ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/stub/units.ruleset b/data/stub/units.ruleset index 46f0c32f0e..50766ba012 100644 --- a/data/stub/units.ruleset +++ b/data/stub/units.ruleset @@ -177,6 +177,7 @@ flags = "" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in diff --git a/data/webperimental/units.ruleset b/data/webperimental/units.ruleset index 1cdef54c30..815f5e5a37 100644 --- a/data/webperimental/units.ruleset +++ b/data/webperimental/units.ruleset @@ -252,6 +252,7 @@ flags = "Unreachable", "DoesntOccupyTile", "HutFrighten" ; transported. ; "Blocked" - Can't defend when transported ; "Alight" - Can defend if can alight or unload (current default) +; "Always" - Can defend even when transported ; targets = list of unit classes this unit can attack against even ; if they have Unreachable unit class flag ; embarks = list of unit classes this unit may load into while not in -- 2.39.2