From b37e9f5d527fdb5704de1043ca6690a3dbf6b507 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 10 Apr 2021 02:09:02 +0300 Subject: [PATCH 51/52] Notify players when nuke destroyes a city completely See osdn #41912 Signed-off-by: Marko Lindqvist --- server/unittools.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/server/unittools.c b/server/unittools.c index 0fc7c82fb4..ada9e1299c 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -2721,23 +2721,38 @@ static void do_nuke_tile(struct player *pplayer, struct tile *ptile) if (pcity) { - notify_player(city_owner(pcity), ptile, E_CITY_NUKED, ftc_server, + struct player *owner = city_owner(pcity); + char city_name[MAX_LEN_LINK]; + + sz_strlcpy(city_name, city_link(pcity)); + + notify_player(owner, ptile, E_CITY_NUKED, ftc_server, _("%s was nuked by %s."), - city_link(pcity), - pplayer == city_owner(pcity) + city_name, + pplayer == owner ? _("yourself") : nation_plural_for_player(pplayer)); - if (city_owner(pcity) != pplayer) { + if (owner != pplayer) { notify_player(pplayer, ptile, E_CITY_NUKED, ftc_server, _("You nuked %s."), - city_link(pcity)); + city_name); } pop_loss = round((game.info.nuke_pop_loss_pct * city_size_get(pcity)) / 100.0); if (city_reduce_size(pcity, pop_loss, pplayer, "nuke")) { /* Send city size reduction to everyone seeing it */ send_city_info(NULL, pcity); + } else { + /* City was destroyed */ + notify_player(owner, ptile, E_CITY_NUKED, ftc_server, + _("%s was destroyed by the nuke."), + city_name); + if (owner != pplayer) { + notify_player(pplayer, ptile, E_CITY_NUKED, ftc_server, + _("Your nuke destroyed %s."), + city_name); + } } } -- 2.30.2