marcrobledo / acnl-editor

An Animal Crossing: New Leaf savegame editor made in HTML5
https://www.marcrobledo.com/acnl-editor/
MIT License
154 stars 32 forks source link

How to add/remove buildings correctly #60

Open Slattz opened 5 years ago

Slattz commented 5 years ago

Hey, so there's currently an issue with adding and removing PWPs that can end up breaking peoples saves due to invalid building amounts. The game assume there's 58 town PWP Slots where there's actually 56 Town PWP Slots and 2 Event PWP Slots (i.e. ones on the town plaza). The Event PWP Slots should not be used and should be kept free. Or it should be implemented correctly so that only Event PWPs can go in those slots and it uses the Event PWPs amount byte.

As seen here in my WIP save structure, the Town PWPs and Event PWPs each have their own byte for the amount of them currently in the save.

Also, it'd probably be a good idea to recalculate how many buildings the user has (i.e. how many of the buildings aren't 0xFC) upon saving, or instead of reading the value, just calculate how many they have when loading the save rather than reading from the save. It'll fix saves that might have been previously broken and prevent this very common issue.

marcrobledo commented 5 years ago

Indeed, the editor always try to add buildings from slot 56 backwards (leaving 57 and 58 for events). I coded the editor some years ago and I could not remember this, but after checking the code lately, the limit was already there, so I did something well after all :-D

The building counter was also there, but broken somehow. Your contribution is appreciated, this is going to fix those building problems that some user get randomly, I hope this is once and for all.

I implemented an automatic fix when opening the glitched savegame in 916f432292400bb55b35d985e4eaa0c305bbe31e along with other fixes aswell.

And I'm gonna toy with building removing now that the counter works correctly.