Set player name in Players[] at single-player game start

Single player games relied on the quirk that the pilot's name was always
kept in Players[], even outside a game.  Commit 0c7de10512 removed
that quirk, which had the unintended consequence that single player
games are now played by the anonymous pilot.  Set the player's callsign
during game setup so that the high score entry can be attributed
correctly.

Fixes: 0c7de10512 ("Track chosen pilot name outside Players[]")
Reported-by: Neurochild247 <https://github.com/dxx-rebirth/dxx-rebirth/issues/443>
Bisected-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/443#issuecomment-523827234>
This commit is contained in:
Kp 2019-08-25 17:53:57 +00:00
parent e7275f8a8c
commit 0b8f32d744
2 changed files with 5 additions and 2 deletions

View file

@ -1088,7 +1088,9 @@ void StartNewGame(const int start_level)
#endif
StartNewLevel(start_level);
get_local_player().starting_level = start_level; // Mark where they started
auto &plr = get_local_player();
plr.starting_level = start_level; // Mark where they started
plr.callsign = InterfaceUniqueState.PilotName;
game_disable_cheats();
#if defined(DXX_BUILD_DESCENT_II)

View file

@ -323,7 +323,8 @@ static void scores_draw_item(grs_canvas &canvas, const grs_font &cv_font, const
const auto &&fspacx = FSPACX();
const auto &&fspacx66 = fspacx(66);
const auto &&fspacy_y = FSPACY(y);
if (strlen(stats->name)==0) {
if (!stats->name[0])
{
gr_string(canvas, cv_font, fspacx66, fspacy_y, TXT_EMPTY);
return;
}