mcdungeon
mcdungeon copied to clipboard
Cache freshness not checked on delete
(Split out from #256 into its own issue as it is separate)
There is a problem with the delete function not checking for cache freshness, and so changes ot the world (possibly invalidating some chunks in the chunk cache) before a delete are not registered.
This is the sequence of events to duplicate the issue I mentioned.
- Treasure hunts get added to world. Chunk cache is written with mtime A
- User builds some structures on previously good chunks and lights them with torches at time B
- Treasure hunt is deleted from world. The chunks containing the landmarks are deleted. The chunk cache is updated, with the deleted chunks missing(?). This sets mtime to be C
- A dungeon is added to the world. Since B<C, the code at mcdungeon.py around line 1446 assumes the chunks are cached correctly, and does not realise that the chunks with structures should no longer be in the good chunks list.
- The new dungeon erroneously overwrites the chunk built on at step (2).
Things seem to come down to the delete action updating the chunk cache (and hence setting the mtime to 'now') but not making sure that every other chunk is correct at the same time.
Suggested solution -- have the chunk scan moved into a separate function, and call it before any action that updates the cache -- adding or deleting, instead of just on add as now. Alternatively, the scan for expired cache items could be added to the load_cache function.
Not sure I'm following this one...
When you delete the hunts in step 3, the cache is refreshed and the chunks that were build on will be scanned and marked as player structures.
That is what I would have expected; however I had several examples where a new dungeon was built over the top of new construction that had been built before some deletions had been done. Maybe in previous versions of MCD the chunk scan was not redone at delete time? It might take a bit of time to try and reliably duplicate this