Fix the build after archiving rpg/ui/scene: drop their last live dependents

rpg/ui/scene moved to archive/ earlier left a handful of otherwise-generic
systems with dead references into them:
- asset/loader/chunk existed solely to load rpg overworld map chunks
  (tile_t, worldpos_t) - deleted outright, along with its
  ASSET_LOADER_TYPE_CHUNK entry in assetloader.c/h.
- save/slot wrapped party_t/storyflagval_t/map-name/cutscene-path, which is
  100% rpg save data - deleted outright (save.c/h, savedevice.c/h and the
  Linux save backend keep their generic settings/device-discovery logic,
  just lose the slot read/write pieces that only existed for it).
- locale/localemanager.c and test/CMakeLists.txt/test/save/* had a few
  stray includes and test cases that only existed for the now-gone code.

Also restores assets/locale/en_US.po (copied back from archive/assets/) -
locale init still needs a real locale file to boot into, even with the
asset-moving/archiving done separately.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
YourWishesandClaude Sonnet 5 committed 2026-10-15 09:08:02 -05:00
1 parent f6b884bf7f
commit fdfdfa3a66
31 files changed
+292 -1994

No files matched your search

-221
View File
@@ -8,7 +8,6 @@
#include "dusktest.h"
#include "savetestfixture.h"
#include "save/save.h"
#include "save/savedevicelinux.h"
#include "util/memory.h"
#include "util/string.h"
#include <stdio.h>
@@ -54,16 +53,10 @@ static void test_saveInit_setsDefaults(void **state) {
// saveTestFixtureSetup already called the real saveInit() - just assert
// on the state it left behind.
assert_int_equal(SAVE.deviceCurrent, 0xFF);
assert_int_equal(SAVE.slotCurrent, 0xFF);
assert_false(SAVE.findingAvailableDevice);
assert_false(SAVE.noAvailableDeviceFound);
assert_true(SAVE.settings.audioMasterVolume == 1.0f);
assert_int_equal(SAVE.devices[0].state, SAVE_DEVICE_STATE_UNKNOWN);
for(uint8_t i = 0; i < SAVE_SLOT_COUNT; i++) {
assert_int_equal(SAVE.caches[i].name[0], '\0');
assert_int_equal(SAVE.caches[i].playerLevel, 0);
}
}
// ============================================================
@@ -281,180 +274,6 @@ static void test_saveLoadSettings_readsAndClearsDirtyFlag(void **state) {
assert_false(SAVE.settingsDirty);
}
// ============================================================
// saveSaveSlot / saveLoadSlot
// ============================================================
static void test_saveSaveSlot_noCurrentDeviceAsserts(void **state) {
expect_assert_failure(saveSaveSlot());
}
static void test_saveSaveSlot_invalidSlotIndexAsserts(void **state) {
makeDeviceAvailable();
// slotCurrent is still 0xFF (unset) from saveInit().
expect_assert_failure(saveSaveSlot());
}
static void test_saveSaveSlot_success(void **state) {
makeDeviceAvailable();
SAVE.slotCurrent = 1;
saveSlotInit(&SAVE.slot);
stringCopy(
SAVE.slot.cachedData.name, "Hero", sizeof(SAVE.slot.cachedData.name)
);
SAVE.slot.cachedData.playerLevel = 12;
SAVE.slotDirty = true;
errorret_t ret = saveSaveSlot();
assert_true(errorIsOk(ret));
assert_false(SAVE.slotDirty);
assert_true(stringEquals(SAVE.caches[1].name, "Hero"));
assert_int_equal(SAVE.caches[1].playerLevel, 12);
// No pre-init needed - saveSlotReadJSON() (via saveDeviceSlotRead) fully
// resets/overwrites its destination struct regardless of prior content.
saveslot_t onDisk;
errorret_t readRet = saveDeviceSlotRead(&SAVE.devices[0], &onDisk, 1);
assert_true(errorIsOk(readRet));
assert_true(stringEquals(onDisk.cachedData.name, "Hero"));
assert_int_equal(onDisk.cachedData.playerLevel, 12);
}
static void test_saveLoadSlot_noCurrentDeviceAsserts(void **state) {
expect_assert_failure(saveLoadSlot());
}
static void test_saveLoadSlot_invalidSlotIndexAsserts(void **state) {
makeDeviceAvailable();
expect_assert_failure(saveLoadSlot());
}
static void test_saveLoadSlot_success(void **state) {
makeDeviceAvailable();
// Write slot 2's on-disk file via SAVE.slot itself (saveSlotInit() only
// ever operates on SAVE.slot now), then reset it again below - the
// write and the load-under-test don't overlap in time.
SAVE.slotCurrent = 2;
saveSlotInit(&SAVE.slot);
stringCopy(
SAVE.slot.cachedData.name, "Zelda", sizeof(SAVE.slot.cachedData.name)
);
SAVE.slot.cachedData.playerLevel = 30;
errorret_t writeRet = saveDeviceSlotWrite(&SAVE.devices[0], &SAVE.slot, 2);
assert_true(errorIsOk(writeRet));
SAVE.slotCurrent = 2;
saveSlotInit(&SAVE.slot);
SAVE.slotDirty = true;
errorret_t ret = saveLoadSlot();
assert_true(errorIsOk(ret));
assert_false(SAVE.slotDirty);
assert_true(stringEquals(SAVE.slot.cachedData.name, "Zelda"));
assert_int_equal(SAVE.slot.cachedData.playerLevel, 30);
assert_true(stringEquals(SAVE.caches[2].name, "Zelda"));
assert_int_equal(SAVE.caches[2].playerLevel, 30);
}
static void test_saveLoadSlot_deviceReadFails_cacheStaysStale(void **state) {
makeDeviceAvailable();
char_t slotPath[512];
errorret_t pathRet = saveDeviceLinuxGetSlotPath(
slotPath, sizeof(slotPath), 0
);
assert_true(errorIsOk(pathRet));
FILE *file = fopen(slotPath, "w");
assert_non_null(file);
fprintf(file, "not valid json {{{");
fclose(file);
SAVE.slotCurrent = 0;
saveSlotInit(&SAVE.slot);
SAVE.caches[0].playerLevel = 77;// sentinel
errorret_t ret = saveLoadSlot();
assert_true(errorIsNotOk(ret));
errorCatch(ret);
// The device read failed before the cache-sync line ever ran.
assert_int_equal(SAVE.caches[0].playerLevel, 77);
}
// ============================================================
// saveLoadAllSlots
// ============================================================
static void test_saveLoadAllSlots_loadsAllAndEndsAtLastIndex(void **state) {
makeDeviceAvailable();
for(uint8_t i = 0; i < SAVE_SLOT_COUNT; i++) {
SAVE.slotCurrent = i;
saveSlotInit(&SAVE.slot);
SAVE.slot.cachedData.playerLevel = (int32_t)(i + 1);
errorret_t saveRet = saveSaveSlot();
assert_true(errorIsOk(saveRet));
}
errorret_t ret = saveLoadAllSlots();
assert_true(errorIsOk(ret));
assert_int_equal(SAVE.slotCurrent, SAVE_SLOT_COUNT - 1);
for(uint8_t i = 0; i < SAVE_SLOT_COUNT; i++) {
assert_int_equal(SAVE.caches[i].playerLevel, (int32_t)(i + 1));
}
}
static void test_saveLoadAllSlots_missingFileLeavesInitDefaults(void **state) {
makeDeviceAvailable();
SAVE.slotCurrent = 0;
saveSlotInit(&SAVE.slot);
SAVE.slot.cachedData.playerLevel = 5;
errorret_t saveRet = saveSaveSlot();
assert_true(errorIsOk(saveRet));
// Slots 1 and 2 are never written - no file exists for them.
errorret_t ret = saveLoadAllSlots();
assert_true(errorIsOk(ret));
assert_int_equal(SAVE.caches[0].playerLevel, 5);
// Missing-file slots fall back to saveSlotInit()'s default (0), not the
// JSON-missing-field default of 1 that a corrupt-but-present file with no
// playerLevel key would produce - these are two different defaults.
assert_int_equal(SAVE.caches[1].playerLevel, 0);
assert_int_equal(SAVE.caches[2].playerLevel, 0);
}
static void test_saveLoadAllSlots_middleSlotCorrupt_stopsAtFailingIndex(
void **state
) {
makeDeviceAvailable();
SAVE.slotCurrent = 0;
saveSlotInit(&SAVE.slot);
errorret_t saveRet = saveSaveSlot();
assert_true(errorIsOk(saveRet));
char_t slotPath[512];
errorret_t pathRet = saveDeviceLinuxGetSlotPath(
slotPath, sizeof(slotPath), 1
);
assert_true(errorIsOk(pathRet));
FILE *file = fopen(slotPath, "w");
assert_non_null(file);
fprintf(file, "not valid json {{{");
fclose(file);
errorret_t ret = saveLoadAllSlots();
assert_true(errorIsNotOk(ret));
errorCatch(ret);
// The loop bails out as soon as slot 1 fails - it never reaches slot 2.
assert_int_equal(SAVE.slotCurrent, 1);
}
// ============================================================
// saveDispose
// ============================================================
@@ -566,46 +385,6 @@ int main(void) {
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveSaveSlot_noCurrentDeviceAsserts,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveSaveSlot_invalidSlotIndexAsserts,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveSaveSlot_success, saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadSlot_noCurrentDeviceAsserts,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadSlot_invalidSlotIndexAsserts,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadSlot_success, saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadSlot_deviceReadFails_cacheStaysStale,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadAllSlots_loadsAllAndEndsAtLastIndex,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadAllSlots_missingFileLeavesInitDefaults,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveLoadAllSlots_middleSlotCorrupt_stopsAtFailingIndex,
saveTestFixtureSetup, saveTestFixtureTeardown
),
cmocka_unit_test_setup_teardown(
test_saveDispose_succeeds, saveTestFixtureSetup, saveTestFixtureTeardown
),