Skip to content

Commit 292f7d3

Browse files
authored
Merge pull request #5938 from MjnMixael/unload_pilot_scpui
Fix SCPUI overwriting campaign data
2 parents 2bb1c10 + 3bfc371 commit 292f7d3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

code/scripting/api/libs/ui.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,23 @@ ADE_FUNC(
393393
return ade_set_args(L, "b", player_create_new_pilot(callsign, is_multi, copy_from));
394394
}
395395

396+
ADE_FUNC(unloadPilot,
397+
l_UserInterface_PilotSelect,
398+
nullptr,
399+
"Unloads a player file & associated campaign file. Can not be used outside of pilot select!",
400+
"boolean",
401+
"Returns true if successful, false otherwise")
402+
{
403+
if (gameseq_get_state() == GS_STATE_INITIAL_PLAYER_SELECT) {
404+
Player = nullptr;
405+
Campaign.filename[0] = '\0';
406+
407+
return ADE_RETURN_TRUE;
408+
}
409+
410+
return ADE_RETURN_FALSE;
411+
}
412+
396413
ADE_FUNC(isAutoselect, l_UserInterface_PilotSelect, nullptr,
397414
"Determines if the pilot selection screen should automatically select the default user.", "boolean",
398415
"true if autoselect is enabled, false otherwise")

0 commit comments

Comments
 (0)