Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/bombard info #2362

Merged
merged 4 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ static struct {
GEN_EV(E_UNIT_LOST_ATT, E_S_UNIT, N_("Attack Failed")),
GEN_EV(E_UNIT_TIE_ATT, E_S_UNIT, N_("Attack Tied")),
GEN_EV(E_UNIT_WIN_ATT, E_S_UNIT, N_("Attack Succeeded")),
GEN_EV(E_UNIT_BOMB_ATT, E_S_UNIT, N_("Attacker Bombarding")),
GEN_EV(E_UNIT_BUY, E_S_UNIT, N_("Bought")),
GEN_EV(E_UNIT_BUILT, E_S_UNIT, N_("Built")),
GEN_EV(E_UNIT_LOST_DEF, E_S_UNIT, N_("Defender Destroyed")),
GEN_EV(E_UNIT_TIE_DEF, E_S_UNIT, N_("Defender Tied")),
GEN_EV(E_UNIT_WIN_DEF, E_S_UNIT, N_("Defender Survived")),
GEN_EV(E_UNIT_BOMB_DEF, E_S_UNIT, N_("Defender Bombarded")),
GEN_EV(E_UNIT_BECAME_VET, E_S_UNIT, N_("Promoted to Veteran")),
GEN_EV(E_UNIT_LOST_MISC, E_S_UNIT, N_("Lost Outside Battle")),
GEN_EV(E_UNIT_UPGRADED, E_S_UNIT, N_("Production Upgraded")),
Expand Down
3 changes: 3 additions & 0 deletions common/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
// Combat without winner (Combat_Rounds)
#define SPECENUM_VALUE136 E_UNIT_TIE_ATT
#define SPECENUM_VALUE137 E_UNIT_TIE_DEF
// bombarding
#define SPECENUM_VALUE138 E_UNIT_BOMB_ATT
#define SPECENUM_VALUE139 E_UNIT_BOMB_DEF

/*
* Note: If you add a new event, make sure you make a similar change
Expand Down
Binary file modified data/misc/events.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions data/misc/events.spec
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ tiles = { "row", "column", "tag"
4, 9, "e_my_spy_nuke"
4, 10, "e_my_spy_steal_map"
; 4, 11, "e_embassy_was_expelled"
4, 12, "e_unit_bomb_att"
4, 13, "e_unit_bomb_def"

; 5, 0, "e_enemy_diplomat_escape" ; base sprite for enemy diplomats
5, 1, "e_enemy_diplomat_bribe"
Expand Down
2 changes: 2 additions & 0 deletions data/stdsounds.soundspec
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ e_log_fatal = "stdsounds/LrgExpl.ogg" ; [warzone]
;e_unit_upgraded = ""
;e_unit_tie_def = ""
;e_unit_win_def = ""
;e_unit_bomb_def = ""
;e_unit_tie_att = ""
;e_unit_bomb_att = ""
;e_unit_win_att = ""
;e_unit_did_expel = ""
;e_unit_was_expelled = ""
Expand Down
40 changes: 24 additions & 16 deletions server/unithand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <cstdlib>
#include <cstring>
#include <set>

// utility
#include "astring.h"
Expand Down Expand Up @@ -3692,6 +3693,7 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile,
{
struct player *pplayer = unit_owner(punit);
struct city *pcity = tile_city(ptile);
std::set<struct player *> players_to_notify;

// Sanity check: The actor still exists.
fc_assert_ret_val(pplayer, false);
Expand Down Expand Up @@ -3733,20 +3735,7 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile,

unit_bombs_unit(punit, pdefender, &att_hp, &def_hp);

notify_player(pplayer, ptile, E_UNIT_WIN_ATT, ftc_server,
/* TRANS: Your Bomber bombards the English Rifleman.*/
_("Your %s bombards the %s %s."),
unit_name_translation(punit),
nation_adjective_for_player(unit_owner(pdefender)),
unit_name_translation(pdefender));

notify_player(
unit_owner(pdefender), ptile, E_UNIT_WIN_DEF, ftc_server,
/* TRANS: Your Rifleman is bombarded by the French Bomber.*/
_("Your %s is bombarded by the %s %s."),
unit_name_translation(pdefender),
nation_adjective_for_player(pplayer),
unit_name_translation(punit));
players_to_notify.insert(unit_owner(pdefender));

punit->hp = att_hp;
pdefender->hp = def_hp;
Expand All @@ -3759,11 +3748,11 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile,
}
unit_list_iterate_safe_end;

// Notify the client
// Notify the client (triggers explosion on tile)
see_combat_unit(punit);
send_bombardment(punit, ptile);

// Send units about affected units
// Send updates about affected units
unit_list_iterate_safe(ptile->units, pdefender)
{
if (is_unit_reachable_at(pdefender, punit, ptile)) {
Expand All @@ -3772,6 +3761,25 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile,
}
unit_list_iterate_safe_end;

// Notify the players hit by the bombardment
for (auto player_to_notify : players_to_notify) {
notify_player(
player_to_notify, ptile, E_UNIT_BOMB_DEF, ftc_server,
/* TRANS: Your units at (x, y) have been bombarded by the French
green Bomber [id:123].*/
_("Your units at %s were bombarded by a %s %s %s [id:%d]."),
tile_link(ptile), nation_adjective_for_player(pplayer),
unit_veteran_level_string(punit), unit_name_translation(punit),
punit->id);
}
// Notify the player that bombarded
notify_player(
pplayer, ptile, E_UNIT_BOMB_ATT, ftc_server,
/* TRANS: Your green Bomber [id:123] bombarded the units at (x, y).*/
_("Your %s %s [id:%d] bombarded the units at %s."),
unit_veteran_level_string(punit), unit_name_translation(punit),
punit->id, tile_link(ptile));

unit_did_action(punit);
unit_forget_last_activity(punit);
unit_attack_civilian_casualties(punit, pcity, paction, "bombard");
Expand Down
Loading