Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a player with Deprecated items in inventory with globalitem data corrupts player #4195

Open
JavidPack opened this issue May 3, 2024 · 0 comments
Assignees
Labels
Requestor-Modders Issues or PRs adding or fixing TML modder API

Comments

@JavidPack
Copy link
Collaborator

Version

Latest 1.4.4-stable

OS

Windows

Platform

Steam

This bug affects...

Mod capability as a Modder

Description

The player has StardustHammer in inventory somehow, and enters a world with a mod with a GlobalItem class. That class saves data on the StardustHammer when leaving the world. Attempting to load the player on the player select screen results in the following:

[01:40:38.125] [Main Thread/WARN] [tML]: Silently Caught Exception: 
System.Collections.Generic.KeyNotFoundException: Terraria.ModLoader.Default.UnloadedGlobalItem
   at Terraria.Item.GetGlobalItem[T]() in tModLoader\Terraria\Item.TML.cs:line 30
   at Terraria.ModLoader.IO.ItemIO.LoadGlobals(Item item, IList`1 list) in tModLoader\Terraria\ModLoader\IO\ItemIO.cs:line 166
   at Terraria.ModLoader.IO.ItemIO.Load(Item item, TagCompound tag) in tModLoader\Terraria\ModLoader\IO\ItemIO.cs:line 113
   at Terraria.ModLoader.IO.ItemIO.Load(TagCompound tag) in tModLoader\Terraria\ModLoader\IO\ItemIO.cs:line 119
   at Terraria.ModLoader.IO.PlayerIO.LoadInventory(Item[] inv, IList`1 list) in tModLoader\Terraria\ModLoader\IO\PlayerIO.cs:line 121
   at Terraria.ModLoader.IO.PlayerIO.Load(Player player, TagCompound tag) in tModLoader\Terraria\ModLoader\IO\PlayerIO.cs:line 74
   at Terraria.Player.Deserialize(PlayerFileData data, Player newPlayer, BinaryReader fileIO, Byte[] tplrData, Int32 release, Boolean& gotToReadName) in tModLoader\Terraria\Player.cs:line 45095
   at Terraria.Player.LoadPlayerFromStream(PlayerFileData playerFileData, Byte[] plrData, Byte[] tplrData) in tModLoader\Terraria\Player.cs:line 45037
   at Terraria.Player.LoadPlayer(String playerPath, Boolean cloudSave) in tModLoader\Terraria\Player.cs:line 45002
   at Terraria.Player.GetFileData(String file, Boolean cloudSave) in tModLoader\Terraria\Player.cs:line 45702
   at Terraria.Main.LoadPlayers() in tModLoader\Terraria\Main.cs:line 3418
   at Terraria.GameContent.UI.States.UICharacterSelect.OnActivate() in tModLoader\Terraria\GameContent\UI\States\UICharacterSelect.cs:line 133
   at Terraria.UI.UIElement.Activate() in tModLoader\Terraria\UI\UIElement.cs:line 452
   at Terraria.UI.UserInterface.SetState(UIState state) in tModLoader\Terraria\UI\UserInterface.cs:line 262
   at Terraria.Main.OpenCharacterSelectUI() in tModLoader\Terraria\Main.cs:line 44935
   at Terraria.Main.DrawMenu(GameTime gameTime) in tModLoader\Terraria\Main.cs:line 41957
   at DMD<System.Void Terraria.Main:DoDraw(Microsoft.Xna.Framework.GameTime)>(Main this, GameTime gameTime)
   at SyncProxy<System.Void Terraria.Main:DoDraw(Microsoft.Xna.Framework.GameTime)>(Main , GameTime )
   at Terraria.Main.Draw_Inner(GameTime gameTime)
   at Terraria.Main.Draw(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.Tick()
   at Microsoft.Xna.Framework.Game.RunLoop()
   at Microsoft.Xna.Framework.Game.Run()
   at Terraria.Program.RunGame()
   at Terraria.Program.LaunchGame_(Boolean isServer)
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
   at Terraria.MonoLaunch.Main_End(String[] args)
   at Terraria.MonoLaunch.<>c__DisplayClass1_0.<Main>b__1()

Player file.
deprecatedglobalitemissue.zip

The issue can be bypassed by manually editing the tplr and removing the globaldata:
image

I thought deprecated items weren't supposed to load in with a player the first place, so something is up. The exception is caused by Item._globals being set to null in ItemIO.Load->Item.SetDefaults.

Will need to verify vanilla behavior and fix this accordingly.

Log File

No response

Steps to reproduce

No response

Expected Behavior

No response

Actual Behavior

No response

Reproduction frequency

No response

Additional Information

No response

@JavidPack JavidPack added the NEW ISSUE Flags an Issue as new. To be removed once issue is assessed. label May 3, 2024
@github-actions github-actions bot added the Requestor-Modders Issues or PRs adding or fixing TML modder API label May 3, 2024
@JavidPack JavidPack removed the NEW ISSUE Flags an Issue as new. To be removed once issue is assessed. label May 6, 2024
@JavidPack JavidPack self-assigned this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requestor-Modders Issues or PRs adding or fixing TML modder API
Projects
None yet
Development

No branches or pull requests

1 participant