From f453503a0cfc007473ce7d78f0234c45b8a04258 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 19 Dec 2021 13:37:00 +0200 Subject: [PATCH 37/38] Move "out of fuel" message to default.lua Requested by nef See osdn #43341 Signed-off-by: Marko Lindqvist --- data/default/default.lua | 16 ++++++++++++++++ server/unittools.c | 10 +--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/data/default/default.lua b/data/default/default.lua index 11e6010b2e..03d4c5779e 100644 --- a/data/default/default.lua +++ b/data/default/default.lua @@ -228,3 +228,19 @@ function _deflua_harmless_disaster_message(disaster, city, had_internal_effect) end signal.connect("disaster_occurred", "_deflua_harmless_disaster_message") + +function unit_loss_messages(unit, player, reason) + if reason == "fuel" then + if unit.utype:has_flag('Coast') then + notify.event(player, unit.tile, E.UNIT_LOST_MISC, + _("Your %s has run out of supplies."), + unit:tile_link_text()) + else + notify.event(player, unit.tile, E.UNIT_LOST_MISC, + _("Your %s has run out of fuel."), + unit:tile_link_text()) + end + end +end + +signal.connect("unit_lost", "unit_loss_messages") diff --git a/server/unittools.c b/server/unittools.c index a0bc846e2a..369f331397 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -597,15 +597,7 @@ void player_restore_units(struct player *pplayer) const struct unit_type *utype = unit_type_get(punit); if (punit->fuel <= 0 && utype_fuel(utype)) { - if (utype_has_flag(utype, UTYF_COAST)) { - notify_player(pplayer, unit_tile(punit), E_UNIT_LOST_MISC, ftc_server, - _("Your %s has run out of supplies."), - unit_tile_link(punit)); - } else { - notify_player(pplayer, unit_tile(punit), E_UNIT_LOST_MISC, ftc_server, - _("Your %s has run out of fuel."), - unit_tile_link(punit)); - } + /* Notifications sent from the lua script when unit wiped. */ wipe_unit(punit, ULR_FUEL, NULL); } } unit_list_iterate_safe_end; -- 2.34.1