From 715d0af24dac5b87f6cb474a9500b6fa4b60684b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 9 Sep 2022 23:02:16 +0300 Subject: [PATCH 40/40] Count units lost due to shield upkeep to score.units_lost Reported by ihnatus See osdn #44887 Signed-off-by: Marko Lindqvist --- server/cityturn.c | 2 +- server/unittools.c | 7 ++++- server/unittools.h | 75 ++++++++++++++++++++++++---------------------- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/server/cityturn.c b/server/cityturn.c index 72bf112a6a..0792852a71 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -2277,7 +2277,7 @@ static bool city_distribute_surplus_shields(struct player *pplayer, /* TODO: Should the unit try to help cities on adjacent tiles? That * would be a rules change. (This action is performed by the game * it self) */ - if (upkeep_kill_unit(punit, O_SHIELD, ULR_DISBANDED, + if (upkeep_kill_unit(punit, O_SHIELD, ULR_UPKEEP, game.info.muuk_shield_wipe)) { notify_player(pplayer, city_tile(pcity), E_UNIT_LOST_MISC, ftc_server, diff --git a/server/unittools.c b/server/unittools.c index fd41f1b0c5..5eea8d2cbc 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -1875,8 +1875,12 @@ static void server_remove_unit_full(struct unit *punit, bool transported, player_status_add(unit_owner(punit), PSTATUS_DYING); } + /* Have to pass new ULR_UPKEEP as ULR_DISBAND for compatibility reasons. + * Changes in freeciv-3.2 */ script_server_signal_emit("unit_lost", punit, unit_owner(punit), - unit_loss_reason_name(reason)); + unit_loss_reason_name((reason == ULR_UPKEEP) + ? ULR_DISBANDED + : reason)); script_server_remove_exported_object(punit); game_remove_unit(&wld, punit); @@ -2115,6 +2119,7 @@ static void wipe_unit_full(struct unit *punit, bool transported, case ULR_BARB_UNLEASH: case ULR_CITY_LOST: case ULR_STARVED: + case ULR_UPKEEP: case ULR_NONNATIVE_TERR: case ULR_ARMISTICE: case ULR_HP_LOSS: diff --git a/server/unittools.h b/server/unittools.h index e0c3b232e0..a451e31177 100644 --- a/server/unittools.h +++ b/server/unittools.h @@ -33,42 +33,45 @@ #define SPECENUM_VALUE5NAME "starved" #define SPECENUM_VALUE6 ULR_SOLD #define SPECENUM_VALUE6NAME "sold" -#define SPECENUM_VALUE7 ULR_USED -#define SPECENUM_VALUE7NAME "used" -#define SPECENUM_VALUE8 ULR_EXECUTED -#define SPECENUM_VALUE8NAME "executed" -#define SPECENUM_VALUE9 ULR_ELIMINATED -#define SPECENUM_VALUE9NAME "eliminated" -#define SPECENUM_VALUE10 ULR_EDITOR -#define SPECENUM_VALUE10NAME "editor" -#define SPECENUM_VALUE11 ULR_NONNATIVE_TERR -#define SPECENUM_VALUE11NAME "nonnative_terr" -#define SPECENUM_VALUE12 ULR_PLAYER_DIED -#define SPECENUM_VALUE12NAME "player_died" -#define SPECENUM_VALUE13 ULR_ARMISTICE -#define SPECENUM_VALUE13NAME "armistice" -#define SPECENUM_VALUE14 ULR_SDI -#define SPECENUM_VALUE14NAME "sdi" -#define SPECENUM_VALUE15 ULR_DETONATED -#define SPECENUM_VALUE15NAME "detonated" -#define SPECENUM_VALUE16 ULR_MISSILE -#define SPECENUM_VALUE16NAME "missile" -#define SPECENUM_VALUE17 ULR_NUKE -#define SPECENUM_VALUE17NAME "nuke" -#define SPECENUM_VALUE18 ULR_HP_LOSS -#define SPECENUM_VALUE18NAME "hp_loss" -#define SPECENUM_VALUE19 ULR_FUEL -#define SPECENUM_VALUE19NAME "fuel" -#define SPECENUM_VALUE20 ULR_STACK_CONFLICT -#define SPECENUM_VALUE20NAME "stack_conflict" -#define SPECENUM_VALUE21 ULR_BRIBED -#define SPECENUM_VALUE21NAME "bribed" -#define SPECENUM_VALUE22 ULR_CAPTURED -#define SPECENUM_VALUE22NAME "captured" -#define SPECENUM_VALUE23 ULR_CAUGHT -#define SPECENUM_VALUE23NAME "caught" -#define SPECENUM_VALUE24 ULR_TRANSPORT_LOST -#define SPECENUM_VALUE24NAME "transport_lost" +/* Upkeep other than one of the above ones */ +#define SPECENUM_VALUE7 ULR_UPKEEP +#define SPECENUM_VALUE7NAME "upkeep" +#define SPECENUM_VALUE8 ULR_USED +#define SPECENUM_VALUE8NAME "used" +#define SPECENUM_VALUE9 ULR_EXECUTED +#define SPECENUM_VALUE9NAME "executed" +#define SPECENUM_VALUE10 ULR_ELIMINATED +#define SPECENUM_VALUE10NAME "eliminated" +#define SPECENUM_VALUE11 ULR_EDITOR +#define SPECENUM_VALUE11NAME "editor" +#define SPECENUM_VALUE12 ULR_NONNATIVE_TERR +#define SPECENUM_VALUE12NAME "nonnative_terr" +#define SPECENUM_VALUE13 ULR_PLAYER_DIED +#define SPECENUM_VALUE13NAME "player_died" +#define SPECENUM_VALUE14 ULR_ARMISTICE +#define SPECENUM_VALUE14NAME "armistice" +#define SPECENUM_VALUE15 ULR_SDI +#define SPECENUM_VALUE15NAME "sdi" +#define SPECENUM_VALUE16 ULR_DETONATED +#define SPECENUM_VALUE16NAME "detonated" +#define SPECENUM_VALUE17 ULR_MISSILE +#define SPECENUM_VALUE17NAME "missile" +#define SPECENUM_VALUE18 ULR_NUKE +#define SPECENUM_VALUE18NAME "nuke" +#define SPECENUM_VALUE19 ULR_HP_LOSS +#define SPECENUM_VALUE19NAME "hp_loss" +#define SPECENUM_VALUE20 ULR_FUEL +#define SPECENUM_VALUE20NAME "fuel" +#define SPECENUM_VALUE21 ULR_STACK_CONFLICT +#define SPECENUM_VALUE21NAME "stack_conflict" +#define SPECENUM_VALUE22 ULR_BRIBED +#define SPECENUM_VALUE22NAME "bribed" +#define SPECENUM_VALUE23 ULR_CAPTURED +#define SPECENUM_VALUE23NAME "captured" +#define SPECENUM_VALUE24 ULR_CAUGHT +#define SPECENUM_VALUE24NAME "caught" +#define SPECENUM_VALUE25 ULR_TRANSPORT_LOST +#define SPECENUM_VALUE25NAME "transport_lost" #include "specenum_gen.h" /* battle related */ -- 2.35.1