Skip to content

Commit

Permalink
Merge pull request scp-fs2open#5938 from MjnMixael/unload_pilot_scpui
Browse files Browse the repository at this point in the history
Fix SCPUI overwriting campaign data
  • Loading branch information
The-E committed Jan 15, 2024
2 parents 2bb1c10 + 3bfc371 commit 292f7d3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions code/scripting/api/libs/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,23 @@ ADE_FUNC(
return ade_set_args(L, "b", player_create_new_pilot(callsign, is_multi, copy_from));
}

ADE_FUNC(unloadPilot,
l_UserInterface_PilotSelect,
nullptr,
"Unloads a player file & associated campaign file. Can not be used outside of pilot select!",
"boolean",
"Returns true if successful, false otherwise")
{
if (gameseq_get_state() == GS_STATE_INITIAL_PLAYER_SELECT) {
Player = nullptr;
Campaign.filename[0] = '\0';

return ADE_RETURN_TRUE;
}

return ADE_RETURN_FALSE;
}

ADE_FUNC(isAutoselect, l_UserInterface_PilotSelect, nullptr,
"Determines if the pilot selection screen should automatically select the default user.", "boolean",
"true if autoselect is enabled, false otherwise")
Expand Down

0 comments on commit 292f7d3

Please sign in to comment.