From e03827880e2c7b69ae23eab752d6955442ee5458 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Thu, 13 Feb 2025 10:06:18 +0100 Subject: [PATCH] Fix crash when giving items --- P3D/HelperClasses/Localization.vb | 6 ++++++ P3D/Screens/Inventory/NewInventoryScreen.vb | 4 ++-- P3D/Screens/Pokemon/PartyScreen.vb | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/P3D/HelperClasses/Localization.vb b/P3D/HelperClasses/Localization.vb index c7c372437..726cb7792 100644 --- a/P3D/HelperClasses/Localization.vb +++ b/P3D/HelperClasses/Localization.vb @@ -117,6 +117,12 @@ If result.Contains("") Then result = result.Replace("", "//POKEMONNAME//") End If + If result.Contains("") Then + result = result.Replace("", "//NEWITEM//") + End If + If result.Contains("") Then + result = result.Replace("", "//OLDITEM//") + End If If result.Contains("<") Then result = CStr(ScriptVersion2.ScriptComparer.EvaluateConstruct(result)) End If diff --git a/P3D/Screens/Inventory/NewInventoryScreen.vb b/P3D/Screens/Inventory/NewInventoryScreen.vb index 4bae68f24..e55306e95 100644 --- a/P3D/Screens/Inventory/NewInventoryScreen.vb +++ b/P3D/Screens/Inventory/NewInventoryScreen.vb @@ -1083,12 +1083,12 @@ Public Class NewInventoryScreen If reItem Is Nothing Then 'JSON Stuff 'ShowMessage(_translation.MESSAGE_GIVE_ITEM(Pokemon.GetDisplayName(), cItem.Name)) - Dim giveString As String = Localization.GetString("inventory_screen_GiveItem_Give", "Gave the .").Replace("", Pokemon.GetDisplayName()).Replace("", cItem.OneLineName()) + Dim giveString As String = Localization.GetString("inventory_screen_GiveItem_Give", "Gave the .").Replace("//POKEMONNAME//", Pokemon.GetDisplayName()).Replace("//NEWITEM//", cItem.OneLineName()) ShowMessage(giveString) Else 'JSON Stuff 'ShowMessage(_translation.MESSAGE_SWITCH_ITEM(Pokemon.GetDisplayName(), reItem.Name, cItem.Name)) - Dim switchString As String = Localization.GetString("inventory_screen_GiveItem_Switch", "Switched 's with the .").Replace("", Pokemon.GetDisplayName()).Replace("", reItem.OneLineName()).Replace("", cItem.OneLineName()) + Dim switchString As String = Localization.GetString("inventory_screen_GiveItem_Switch", "Switched 's with the .").Replace("//POKEMONNAME//", Pokemon.GetDisplayName()).Replace("//OLDITEM//", reItem.OneLineName()).Replace("//NEWITEM//", cItem.OneLineName()) ShowMessage(switchString) End If diff --git a/P3D/Screens/Pokemon/PartyScreen.vb b/P3D/Screens/Pokemon/PartyScreen.vb index 82e18ea85..593384a37 100644 --- a/P3D/Screens/Pokemon/PartyScreen.vb +++ b/P3D/Screens/Pokemon/PartyScreen.vb @@ -850,7 +850,7 @@ Public Class PartyScreen If reItem.IsMail And reItem.AdditionalData <> "" Then Core.Player.Mails.Add(Items.MailItem.GetMailDataFromString(reItem.AdditionalData)) - message = Localization.GetString("inventory_screen_GiveItem_TakeMail", "Gave to and took the Mail to the PC.").Replace("", i.OneLineName()).Replace("", p.GetDisplayName()) + message = Localization.GetString("inventory_screen_GiveItem_TakeMail", "Gave to and took the Mail to the PC.").Replace("//NEWITEM//", i.OneLineName()).Replace("//POKEMONNAME//", p.GetDisplayName()) Else Dim ReItemID As String If reItem.IsGameModeItem Then @@ -860,17 +860,17 @@ Public Class PartyScreen End If Core.Player.Inventory.AddItem(ReItemID, 1) - message = Localization.GetString("inventory_screen_GiveItem_Switch", "Switched 's with the .").Replace("", i.OneLineName()).Replace("", reItem.OneLineName()).Replace("", p.GetDisplayName()) + message = Localization.GetString("inventory_screen_GiveItem_Switch", "Switched 's with the .").Replace("//NEWITEM//", i.OneLineName()).Replace("//OLDITEM//", reItem.OneLineName()).Replace("//POKEMONNAME//", p.GetDisplayName()) End If Else - message = Localization.GetString("inventory_screen_GiveItem_Give", "Gave the .").Replace("", p.GetDisplayName()).Replace("", i.OneLineName()) + message = Localization.GetString("inventory_screen_GiveItem_Give", "Gave the .").Replace("//POKEMONNAME//", p.GetDisplayName()).Replace("//NEWITEM//", i.OneLineName()) End If p.Item = i ShowMessage(message) Else - ShowMessage(Localization.GetString("inventory_screen_CannotGiveToPokemon", " cannot be given to a Pokémon.").Replace("", i.OneLineName())) + ShowMessage(Localization.GetString("inventory_screen_CannotGiveToPokemon", " cannot be given to a Pokémon.").Replace("//NEWITEM//", i.OneLineName())) End If End Sub