Clearing terrain edits for a base
hbouma opened this issue · 0 comments
Okay, per nmsmods.com, it would be great if you can clear the terrain edits for a base location for when we've ran out of available edits. It shouldn't be that hard. Most of the data is pretty easy to follow having worked on video games for over 12 years lol. I don't know JSON terms, but TerrainEditData has 5 arrays in it, where when you start editing the terrain in a new location, it gets added to the GalacticAddresses array and that is the same offset into all of the other arrays but Edits.
Each time you edit terrain, the changes go into the end of the Edits array. The number of changes you've made gets tracked in the buffersize entry. The anchor point for the edits is in bufferanchors. Therefore, If for example, you edit terrain at one location, go to another location, edit there, and come back, and edit it again, you'll have three entries in the tables in order to track the list of changes in the Edits table. The bufferages tracks how long ago you edited the terrain [see below]
By adding up the previous buffersize entries in the table, you know your starting point in Edits. Also, the Terrain Edit's galactic addresses match your base's galactic addresses so all you need to do is walk the GalacticAddress list and remove the matching ones from the tables and its corresponding entries in the edits list . that should clear out the terrain for the base - possibly the whole planet too. You can then save out the reduced table to retain the other location edits.
In my case, I ran out of edits so I cleared out my last two bases which was like 8 location entries at the end of the arrays. I cleared out the galacticaddress/anchorpoint/buffersize entries. I added up their buffersize totals and removed that number (about 26,000) from the Edits list. I took a risk by not replacing the rest of the list with default values but it seemed to work okay. My last two bases had their original terrain back and I was able edit the terrain again at the other bases.
Anyway, that is the still simple but more difficult way of solving this. It might also possible [and far easier] to clear out the entries through setting its bufferages to a particular value - i.e. expired so the game thinks its time to clear them out. That way you only have to change a single value rather than resize tables. The age setting is there so that changes you make while exploring about are eventually discarded as you're unlikely to go back. I haven't experimented yet to find out what that value needs to be or if its enforced on bases, but that could be another route to take. I can try to see if this method works on a base tonight.
Hal