aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-10-12 01:29:31 +0100
committerGitHub <noreply@github.com>2023-10-12 02:29:31 +0200
commit407c5ce39c3124658a869c387e4308e6b72e4c23 (patch)
treeaa022e2dd9a64ddfe0cee8b0d68bfc7b8588be65 /Northstar.Client/mod
parentc2716db187ce1e896031ac75e097f96754dc92cf (diff)
downloadNorthstarMods-1.19.8-rc1.tar.gz
NorthstarMods-1.19.8-rc1.zip
Fix INVALID_REF errors caused by mods (#657)v1.19.8-rc1v1.19.8v1.19.7-rc1v1.19.7
`INVALID_REF` errors were being caused by trying to get the item image for weapon skins. If a mod (e.g. moreskins) added new skins, the client equipped one, and then the mod is disabled, the client now has bad persistence. This is mostly handled fine by the game, except for weapon skins. This PR prevents the crash, and resets the bad persistence to default.
Diffstat (limited to 'Northstar.Client/mod')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_edit_pilot_loadouts.nut5
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_pilot_loadouts_shared.nut22
2 files changed, 24 insertions, 3 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_edit_pilot_loadouts.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_edit_pilot_loadouts.nut
index e785b067..89479a76 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_edit_pilot_loadouts.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_edit_pilot_loadouts.nut
@@ -82,6 +82,11 @@ void function OnLoadoutButton_Focused( var button )
{
int index = expect int( button.s.rowIndex )
+ // update the editingLoadoutIndex on focus so that it always matches
+ // with the pilot loadout panel
+ uiGlobal.editingLoadoutIndex = index
+ uiGlobal.editingLoadoutType = "pilot"
+
UpdatePilotLoadout( index )
string pilotLoadoutRef = "pilot_loadout_" + ( index + 1 )
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_pilot_loadouts_shared.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_pilot_loadouts_shared.nut
index 122403a3..f0139e04 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_pilot_loadouts_shared.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_pilot_loadouts_shared.nut
@@ -86,7 +86,7 @@ void function UpdatePilotLoadoutPanel( var loadoutPanel, PilotLoadoutDef loadout
else if ( loadout.primarySkinIndex == 1 ) // camo
primaryAppearanceImage = CamoSkin_GetImage( CamoSkins_GetByIndex( loadout.primaryCamoIndex ) )
else // warpaint skin
- primaryAppearanceImage = GetItemImage( GetSkinRefFromWeaponRefAndPersistenceValue( loadout.primary, loadout.primarySkinIndex ) )
+ primaryAppearanceImage = GetItemImageFromWeaponRefAndPersistenceValue( loadout.primary, loadout.primarySkinIndex, "primarySkinIndex" )
asset secondaryAppearanceImage
if ( loadout.secondarySkinIndex == 0 ) // default skin
@@ -94,7 +94,7 @@ void function UpdatePilotLoadoutPanel( var loadoutPanel, PilotLoadoutDef loadout
else if ( loadout.secondarySkinIndex == 1 ) // camo
secondaryAppearanceImage = CamoSkin_GetImage( CamoSkins_GetByIndex( loadout.secondaryCamoIndex ) )
else // warpaint skin
- secondaryAppearanceImage = GetItemImage( GetSkinRefFromWeaponRefAndPersistenceValue( loadout.secondary, loadout.secondarySkinIndex ) )
+ secondaryAppearanceImage = GetItemImageFromWeaponRefAndPersistenceValue( loadout.secondary, loadout.secondarySkinIndex, "secondarySkinIndex" )
asset weapon3AppearanceImage
if ( loadout.weapon3SkinIndex == 0 ) // default skin
@@ -102,7 +102,7 @@ void function UpdatePilotLoadoutPanel( var loadoutPanel, PilotLoadoutDef loadout
else if ( loadout.weapon3SkinIndex == 1 ) // camo
weapon3AppearanceImage = CamoSkin_GetImage( CamoSkins_GetByIndex( loadout.weapon3CamoIndex ) )
else // warpaint skin
- weapon3AppearanceImage = GetItemImage( GetSkinRefFromWeaponRefAndPersistenceValue( loadout.weapon3, loadout.weapon3SkinIndex ) )
+ weapon3AppearanceImage = GetItemImageFromWeaponRefAndPersistenceValue( loadout.weapon3, loadout.weapon3SkinIndex, "weapon3SkinIndex" )
RuiSetImage( Hud_GetRui( Hud_GetChild( loadoutPanel, "ButtonPilotCamo" ) ), "camoImage", pilotAppearanceImage )
RuiSetImage( Hud_GetRui( Hud_GetChild( loadoutPanel, "ButtonPrimarySkin" ) ), "camoImage", primaryAppearanceImage )
@@ -282,3 +282,19 @@ void function UpdatePilotLoadoutPanelBinds( var loadoutPanel )
//SetLabelRuiText( Hud_GetChild( loadoutPanel, "TacticalBind" ), Localize( "%offhand1%" ) )
//SetLabelRuiText( Hud_GetChild( loadoutPanel, "OrdnanceBind" ), Localize( "%offhand0%" ) )
}
+
+asset function GetItemImageFromWeaponRefAndPersistenceValue(string weaponRef, int persistenceValue, string loadoutProperty)
+{
+ string skinRef = GetSkinRefFromWeaponRefAndPersistenceValue( weaponRef, persistenceValue )
+ if (!IsRefValid(skinRef))
+ {
+ if (uiGlobal.editingLoadoutIndex != -1)
+ {
+ printt( "Resetting invalid " + loadoutProperty + " for weapon " + weaponRef )
+ SetCachedLoadoutValue(GetUIPlayer(), "pilot", uiGlobal.editingLoadoutIndex, loadoutProperty, "0")
+ }
+ return $"rui/menu/common/appearance_button_swatch"
+ }
+
+ return GetItemImage( skinRef )
+}