Nortmar
Greenhorn
Hey. I've been working on a tool in the fashion of Stardew Checkup/Predictor where you have to work on top of a save file.
Accidentally, I formatted my game save file XML content using VSCode, so instead of the minified versions, the tags were in different lines and with whitespace.
Before realizing that, I tried opening my game and it just crashed with errors like this:
I was able to fix it by running a simple JS script on top of my save file, to remove whitespace:
This is just to report that, at least for some of the tags, the game is not parsing whitespace between tags. So this is my suggestion that when loading a game, it should trim the XML tag contents.
Accidentally, I formatted my game save file XML content using VSCode, so instead of the minified versions, the tags were in different lines and with whitespace.
Before realizing that, I tried opening my game and it just crashed with errors like this:
Code:
Message: There is an error in XML document (11174, 9).
InnerException: System.InvalidOperationException: There is an error in XML document (11174, 9).
---> System.ArgumentException:
winter
at StardewValley.WorldDate.set_Season(String value) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\WorldDate.cs:line 60
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderFriendship.Read2_WorldDate(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderFriendship.Read4_Friendship(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderFriendship.Read5_Friendship()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at StardewValley.SerializableDictionary`2.ReadXml(XmlReader reader) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\SerializableDictionary.cs:line 113
at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny)
at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSaveGame.Read148_Farmer(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSaveGame.Read237_SaveGame(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSaveGame.Read238_SaveGame()
Stack Trace: at StardewValley.SaveGame.getLoadEnumerator(String file)+MoveNext() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\SaveGame.cs:line 1510
at StardewValley.Game1.UpdateTitleScreen(GameTime time) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 6307
at StardewValley.Game1._update(GameTime gameTime) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 4906
at StardewValley.Game1.Update(GameTime gameTime) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 3974
at StardewValley.GameRunner.Update(GameTime gameTime) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\LocalMultiplayer.cs:line 1067
at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 814
at Microsoft.Xna.Framework.Game.Tick() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 567
at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Platform\SDL\SDLGamePlatform.cs:line 91
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 481
at StardewValley.Program.Main(String[] args) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Program.cs:line 175
JavaScript:
const fs = require('fs')
var content = fs.readFileSync('MyFile', 'utf8')
content = content.replace(/>\s*/g, '>');
content = content.replace(/\s*</g, '<');
console.log(content)