diff options
author | Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> | 2024-04-12 00:50:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 01:50:38 +0200 |
commit | 11787b3896b8242ac8f7e583d72cabf68f9161a9 (patch) | |
tree | 59d5d1d9719254b3a6e44081f9ba1f0f0e35588e | |
parent | a8c0653b25616a4b3b5cf224ae7eddc856fad7cc (diff) | |
download | NorthstarMods-11787b3896b8242ac8f7e583d72cabf68f9161a9.tar.gz NorthstarMods-11787b3896b8242ac8f7e583d72cabf68f9161a9.zip |
Validate selected Titan loadout index better (#762)
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.
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut b/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut index 5098dd32..3297643e 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut @@ -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] @@ -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++ ) |