[KKS][MainGameOptimizations] Avoid error when saving more than 2 GB in the main game #63
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
IllusionMods/IllusionFixes!63
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "large-save"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When saving saved data in the main game, there was a problem with not being able to save the data when there were many characters and the size exceeded 2 GB. If it looks good, merge it.
If the maximum number of characters is set and the number of costumes is increased continuously, 2 GB is reached.
Fixed to bypass the process via MemoryStream and write directly to the file.
This problem only occurs with KKS.
KK does not go through MemoryStream.
This modification was made at the request of a commission from BitMagnet.
This seems fairly fragile, wouldn't it make more sense to fix the mentioned hook inside ExtendedSave instead? When I wrote it I assumed that save data would never be larger than a few hundred MB at worst so it is not optimized at all.
The proper fix would be to patch the save lambda with a transplier and write extended data there, like it's done for character data.
Is this?
IllusionMods/BepisPlugins@abee07b239/src/KKS_ExtensibleSaveFormat/KKS.ExtendedSave.SaveData.Hooks.cs (L61)I get an exception on MemoryStream in GetBytes, I can't call GetBytes.
I thought it was awesome when I heard that his saved data exceeded 2GB.
Is this the lambda of the save?

Maybe you haven't seen the KK version?

Is this?
Patching GetBytes? Rewrite MemoryStream to FileStream?
IllusionMods/BepisPlugins@abee07b239/src/Core_ExtensibleSaveFormat/Core.ExtendedSave.Hooks.cs (L300)Delete the current ExtendedSave.SaveDataSaveHook patch and add a transpiler to add extended save data behind WorldData.cs:272 in KKS?
Yes, that would be the best way to do it I think. The issue I had was that different versions of the game (with or without EX) have different names for this lambda (
<Save>b__140_0and<Save>b__144_0), so there has to be some additional code to find and patch the right one.Edit: Something like this could be used to see what method is called by
SaveIllusionMods/IllusionFixes@df5a3f0eaa/src/KKS_Fix_ShowerAccessories/KKS_ShowerAccessories.cs (L27-L46)No, that method may not extend the data size limit.
I tried it with 500MB of data at hand, and the data stored in the added area was quite small, probably mostly heroine's data.
If I leave GetBytes() as it is, the heroine's data alone reaches 2GB, subject to the MemoryStream-derived 2GB limit.
I think we need to expand the GetBytes() Write code directly into Save() without using the transpiler (GetBytes), what do you think?
Oh, you're right, the data is added to the characters and not to the save file itself.
In this case there's no way to use
GetBytesby patching it I think, it has to be rewritten insideSaveas you've suggested.I believe no other plugins other than ExtendedSave patch or use the
GetBytesmethod, so it should be safe to not use it at all and make it throw an exception (to make sure that no one tries using it since the data it returns is no longer valid).How's that?
https://github.com/IllusionMods/BepisPlugins/pull/197
Pull request closed