Skip to content

Commit

Permalink
change bombarding message system
Browse files Browse the repository at this point in the history
So the bombarder does not reveal the units bombarded.
  • Loading branch information
hugomflavio committed Sep 8, 2024
1 parent 08b407f commit e83dbd1
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
8 changes: 5 additions & 3 deletions client/packhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,11 @@ void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
struct unit *punit1 = game_unit_by_number(packet->defender_unit_id);

if (punit0 && punit1) {
popup_combat_info(packet->attacker_unit_id, packet->defender_unit_id,
packet->attacker_hp, packet->defender_hp,
packet->make_att_veteran, packet->make_def_veteran);
if (!packet->bombard) {
popup_combat_info(packet->attacker_unit_id, packet->defender_unit_id,
packet->attacker_hp, packet->defender_hp,
packet->make_att_veteran, packet->make_def_veteran);
}
if (tile_visible_mapcanvas(unit_tile(punit0))
&& tile_visible_mapcanvas(unit_tile(punit1))) {
show_combat = true;
Expand Down
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
1 change: 1 addition & 0 deletions common/networking/packets.def
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ PACKET_UNIT_COMBAT_INFO = 65; sc, lsend
HP defender_hp;
BOOL make_att_veteran;
BOOL make_def_veteran;
BOOL bombard;
end

PACKET_UNIT_BOMBARD_INFO = 66; sc, lsend, cap(bombard-info)
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
39 changes: 23 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,24 @@ 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 in [tile] have been bombarded by the French
Bomber.*/
_("Your units in %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 Bomber bombarded [coords?].*/
_("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

0 comments on commit e83dbd1

Please sign in to comment.