Skip to content

Commit

Permalink
Show both name and callsign in escort list.
Browse files Browse the repository at this point in the history
In #5477, I made the escort list respect hidden names by copying the behavior from `message_queue_process()`, which already checked those flags; however, this resulted in some dramatic behavioral changes for mods using callsigns for escort ships, and while making the behavior optional was a possibility, feedback suggested everyone would rather it just behaved like the target box and displayed both. So I replaced the code with similar logic from hudtargetbox.cpp, except with the "replace hidden name with ship class" code taking priority.
  • Loading branch information
MageKing17 committed Sep 26, 2023
1 parent 4ba6191 commit 305a7f6
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions code/hud/hudescort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ void HudGaugeEscort::renderIcon(int x, int y, int index)
float shields, integrity;
int screen_integrity, offset, objnum = -1;
char buf[255];
const player *pl = nullptr;

auto eship = get_escort_entry_from_index(index);

Expand All @@ -312,8 +311,7 @@ void HudGaugeEscort::renderIcon(int x, int y, int index)
int np_index = find_player_index(eship->np_id);

if (np_index >= 0) {
pl = Net_players[np_index].m_player;
objnum = pl->objnum;
objnum = Net_players[np_index].m_player->objnum;

// this can occassionally happen in multi when a player still needs to respawn.
if (objnum < 0 || Objects[objnum].type != OBJ_SHIP){
Expand Down Expand Up @@ -350,15 +348,9 @@ void HudGaugeEscort::renderIcon(int x, int y, int index)
}

// print out ship name
// behavior largely taken from message_queue_process() in missionmessage.cpp,
// but with the multiplayer callsign behavior kept in accordance with #1674.
if (sp->callsign_index >= 0 && !pl)
{
// Without the !pl, this would just stuff short_callsign anyway, so may
// as well use the ship name and append it instead.
hud_stuff_ship_callsign(buf, sp);
}
else if (((Iff_info[sp->team].flags & IFFF_WING_NAME_HIDDEN) && (sp->wingnum != -1)) || (sp->flags[Ship::Ship_Flags::Hide_ship_name]))
// original behavior replaced with similar logic to hudtargetbox.cpp, except
// if the name is hidden, it's replaced with the class name.
if (((Iff_info[sp->team].flags & IFFF_WING_NAME_HIDDEN) && (sp->wingnum != -1)) || (sp->flags[Ship::Ship_Flags::Hide_ship_name]))
{
// If we're hiding the ship name, we probably shouldn't append the callsign either
hud_stuff_ship_class(buf, sp);
Expand All @@ -367,17 +359,19 @@ void HudGaugeEscort::renderIcon(int x, int y, int index)
{
hud_stuff_ship_name(buf, sp);

// maybe add callsign if multi and player ship
if (pl) {
SCP_string callsign;

callsign.reserve(32);

callsign += " (";
callsign += pl->short_callsign;
callsign += ")";
// maybe concatenate the callsign
if (*buf)
{
char callsign[NAME_LENGTH];

strcat_s(buf, callsign.c_str());
hud_stuff_ship_callsign(callsign, sp);
if (*callsign)
sprintf(&buf[strlen(buf)], " (%s)", callsign);
}
// maybe substitute the callsign
else
{
hud_stuff_ship_callsign(buf, sp);
}
}

Expand Down

0 comments on commit 305a7f6

Please sign in to comment.