Skip to content

Commit

Permalink
Validate selected Titan loadout index better (#762)
Browse files Browse the repository at this point in the history
Seemingly there are cases where mods can set an invalid Titan loadout index, which then causes the progression checks to attempt to set the player's Titan model to an invalid index.

This commit adds a check to ensure that it is within the bounds of the titan loadout array.
  • Loading branch information
ASpoonPlaysGames authored Apr 11, 2024
1 parent a8c0653 commit 11787b3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ void function ValidateEquippedItems( entity player )
}

// titan loadouts
int selectedTitanLoadoutIndex = player.GetPersistentVarAsInt( "titanSpawnLoadout.index" )
for ( int titanLoadoutIndex = 0; titanLoadoutIndex < NUM_PERSISTENT_TITAN_LOADOUTS; titanLoadoutIndex++ )
{
printt( "- VALIDATING TITAN LOADOUT: " + titanLoadoutIndex )

bool isSelected = titanLoadoutIndex == player.GetPersistentVarAsInt( "titanSpawnLoadout.index" )
bool isSelected = titanLoadoutIndex == selectedTitanLoadoutIndex
TitanLoadoutDef loadout = GetTitanLoadout( player, titanLoadoutIndex )
TitanLoadoutDef defaultLoadout = shGlobal.defaultTitanLoadouts[titanLoadoutIndex]

Expand Down Expand Up @@ -446,11 +447,18 @@ void function ValidateEquippedItems( entity player )
{
printt( " - SELECTED TITAN CLASS IS LOCKED, RESETTING" )
player.SetPersistentVar( "titanSpawnLoadout.index", 0 )
Remote_CallFunction_NonReplay( player, "ServerCallback_UpdateTitanModel", 0 )
selectedTitanLoadoutIndex = 0
}
}

Remote_CallFunction_NonReplay( player, "ServerCallback_UpdateTitanModel", player.GetPersistentVarAsInt( "titanSpawnLoadout.index" ) )
if ( selectedTitanLoadoutIndex < 0 || selectedTitanLoadoutIndex >= NUM_PERSISTENT_TITAN_LOADOUTS )
{
printt( "- SELECTED TITAN CLASS IS INVALID, RESETTING" )
player.SetPersistentVar( "titanSpawnLoadout.index", 0 )
selectedTitanLoadoutIndex = 0
}

Remote_CallFunction_NonReplay( player, "ServerCallback_UpdateTitanModel", selectedTitanLoadoutIndex )

// pilot loadouts
for ( int pilotLoadoutIndex = 0; pilotLoadoutIndex < NUM_PERSISTENT_PILOT_LOADOUTS; pilotLoadoutIndex++ )
Expand Down

0 comments on commit 11787b3

Please sign in to comment.