Persist the current map name in the save slot

mapSetMap() now keeps SAVE.slot.cachedData.mapName in sync with the
active map, so whichever map is loaded gets written out next time the
slot is actually saved.
This commit is contained in:
2026-09-08 12:49:13 -05:00
parent 8139a0ea54
commit 178d78ef72
+5
View File
@@ -15,6 +15,7 @@
#include "rpg/entity/global/entityglobal.h" #include "rpg/entity/global/entityglobal.h"
#include "rpg/entity/item/entityitem.h" #include "rpg/entity/item/entityitem.h"
#include "rpg/overworld/maparea.h" #include "rpg/overworld/maparea.h"
#include "save/save.h"
map_t MAP; map_t MAP;
@@ -48,6 +49,10 @@ errorret_t mapSetMap(const char_t *map) {
memoryZero(&MAP, sizeof(map_t)); memoryZero(&MAP, sizeof(map_t));
stringCopy(MAP.name, map, MAP_NAME_MAX); stringCopy(MAP.name, map, MAP_NAME_MAX);
// Keep the current save slot's cached map name in sync so whichever map
// is active gets persisted next time the slot is actually saved.
stringCopy(SAVE.slot.cachedData.mapName, MAP.name, MAP_NAME_MAX);
chunkindex_t i = 0; chunkindex_t i = 0;
for(chunkunit_t z = 0; z < MAP_CHUNK_DEPTH; z++) { for(chunkunit_t z = 0; z < MAP_CHUNK_DEPTH; z++) {
for(chunkunit_t y = 0; y < MAP_CHUNK_HEIGHT; y++) { for(chunkunit_t y = 0; y < MAP_CHUNK_HEIGHT; y++) {