Remove rpg, ui, editor and scene subfolders; split scripts by platform
Delete src/dusk/rpg, src/dusk/ui, the animation/keyframe modules, the scene subfolders, the chunk asset loader and ./editor, and strip the dependent save slot, scene type, engine and test code so the main binary and tests build again. Add scene/node.c/.h skeleton and move build scripts into scripts/<platform>/. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
3948607b1e
commit
31ee7989de
464 files changed
+70
-33009
No files matched your search
@@ -10,9 +10,6 @@
|
||||
|
||||
#include "savetestfixture.h"
|
||||
#include "assert/assert.h"
|
||||
#include "asset/asset.h"
|
||||
#include "asset/loader/assetloader.h"
|
||||
#include "asset/loader/assetentry.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include <ftw.h>
|
||||
@@ -25,51 +22,6 @@ static char_t SAVE_TEST_FIXTURE_HOME[PATH_MAX];
|
||||
static char_t SAVE_TEST_FIXTURE_REAL_HOME[PATH_MAX];
|
||||
static bool_t SAVE_TEST_FIXTURE_HAD_REAL_HOME;
|
||||
|
||||
static const char_t *SAVE_TEST_FIXTURE_PARTY_JSON =
|
||||
"{\"members\":{\"hero\":{"
|
||||
"\"attack\":10,\"defense\":5,\"magic\":0,\"speed\":10,\"luck\":0,"
|
||||
"\"healthMax\":30,\"mpMax\":10"
|
||||
"}}}";
|
||||
|
||||
static yyjson_doc *SAVE_TEST_FIXTURE_PARTY_DOC = NULL;
|
||||
|
||||
errorret_t saveTestFixturePartyJsonLoadSyncStub(assetloading_t *loading) {
|
||||
loading->entry->data.json = SAVE_TEST_FIXTURE_PARTY_DOC;
|
||||
loading->entry->state = ASSET_ENTRY_STATE_LOADED;
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t saveTestFixturePartyJsonDisposeStub(assetentry_t *entry) {
|
||||
errorOk();
|
||||
}
|
||||
|
||||
void saveTestFixtureStubPartyAsset(void) {
|
||||
memoryZero(&ASSET, sizeof(ASSET));
|
||||
for(size_t i = 0; i < ASSET_LOADING_COUNT_MAX; i++) {
|
||||
threadMutexInit(&ASSET.loading[i].mutex);
|
||||
}
|
||||
|
||||
if(SAVE_TEST_FIXTURE_PARTY_DOC == NULL) {
|
||||
SAVE_TEST_FIXTURE_PARTY_DOC = yyjson_read(
|
||||
SAVE_TEST_FIXTURE_PARTY_JSON, strlen(SAVE_TEST_FIXTURE_PARTY_JSON), 0
|
||||
);
|
||||
assertNotNull(
|
||||
SAVE_TEST_FIXTURE_PARTY_DOC, "Failed to parse party JSON fixture"
|
||||
);
|
||||
}
|
||||
|
||||
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_JSON].loadSync =
|
||||
saveTestFixturePartyJsonLoadSyncStub;
|
||||
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_JSON].dispose =
|
||||
saveTestFixturePartyJsonDisposeStub;
|
||||
}
|
||||
|
||||
void saveTestFixtureUnstubPartyAsset(void) {
|
||||
if(SAVE_TEST_FIXTURE_PARTY_DOC == NULL) return;
|
||||
yyjson_doc_free(SAVE_TEST_FIXTURE_PARTY_DOC);
|
||||
SAVE_TEST_FIXTURE_PARTY_DOC = NULL;
|
||||
}
|
||||
|
||||
static int_t saveTestFixtureRemoveEntry(
|
||||
const char *path,
|
||||
const struct stat *statBuffer,
|
||||
@@ -97,8 +49,6 @@ int saveTestFixtureSetup(void **state) {
|
||||
|
||||
assertTrue(setenv("HOME", SAVE_TEST_FIXTURE_HOME, 1) == 0, "setenv failed");
|
||||
|
||||
saveTestFixtureStubPartyAsset();
|
||||
|
||||
errorret_t ret = saveInit();
|
||||
assertTrue(errorIsOk(ret), "saveInit failed in test fixture");
|
||||
|
||||
@@ -106,7 +56,6 @@ int saveTestFixtureSetup(void **state) {
|
||||
}
|
||||
|
||||
int saveTestFixtureTeardown(void **state) {
|
||||
saveTestFixtureUnstubPartyAsset();
|
||||
|
||||
nftw(
|
||||
SAVE_TEST_FIXTURE_HOME, saveTestFixtureRemoveEntry, 16,
|
||||
|
||||
@@ -36,20 +36,3 @@ int saveTestFixtureTeardown(void **state);
|
||||
*/
|
||||
void saveTestFixtureBlockSaveDirectory(void);
|
||||
|
||||
/**
|
||||
* Stubs the JSON asset loader's sync callback to hand back a small
|
||||
* in-memory party.jsonc-shaped doc instead of doing a real file/zip read -
|
||||
* saveInit()/saveSlotInit() seed the party roster via partyInit(), which
|
||||
* loads party.jsonc through the real asset system, and there's no real
|
||||
* asset bundle available under the test harness. No thread, no real I/O.
|
||||
* Resets ASSET to a fresh, otherwise-empty state each call, so it's safe
|
||||
* to call once per test. Called automatically by saveTestFixtureSetup.
|
||||
*/
|
||||
void saveTestFixtureStubPartyAsset(void);
|
||||
|
||||
/**
|
||||
* Frees the in-memory doc created by saveTestFixtureStubPartyAsset. Safe
|
||||
* to call even if that function was never called. Called automatically
|
||||
* by saveTestFixtureTeardown.
|
||||
*/
|
||||
void saveTestFixtureUnstubPartyAsset(void);
|
||||
@@ -15,19 +15,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// saveSlotInit() seeds the party roster via partyInit(), which loads
|
||||
// party.jsonc through the real asset system - stub it out (see
|
||||
// savetestfixture.h) rather than needing a real asset bundle here.
|
||||
static int assetGroupSetup(void **state) {
|
||||
saveTestFixtureStubPartyAsset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int assetGroupTeardown(void **state) {
|
||||
saveTestFixtureUnstubPartyAsset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Helpers - wrap the writeInit/readInit macros (which can only be used
|
||||
// inside a function returning errorret_t) so tests can call them plainly.
|
||||
@@ -156,12 +143,6 @@ static void test_saveSlotReadJSON_roundTrip(void **state) {
|
||||
SAVE.slot.cachedData.name, "Hero", sizeof(SAVE.slot.cachedData.name)
|
||||
);
|
||||
SAVE.slot.cachedData.playerLevel = 42;
|
||||
// An in-use slot (non-empty name) requires a non-empty map name too -
|
||||
// see saveSlotNewGame/requireStrMin("mapName", 1) in saveSlotVer1ReadJSON.
|
||||
stringCopy(
|
||||
SAVE.slot.cachedData.mapName, "overworld",
|
||||
sizeof(SAVE.slot.cachedData.mapName)
|
||||
);
|
||||
|
||||
char_t *json;
|
||||
size_t len;
|
||||
@@ -178,7 +159,6 @@ static void test_saveSlotReadJSON_roundTrip(void **state) {
|
||||
|
||||
assert_true(stringEquals(read.cachedData.name, "Hero"));
|
||||
assert_int_equal(read.cachedData.playerLevel, 42);
|
||||
assert_true(stringEquals(read.cachedData.mapName, "overworld"));
|
||||
assert_true(read.cachedData.time.time == writtenTime.time);
|
||||
|
||||
// version/dataType are struct-only bookkeeping, never serialized - the
|
||||
@@ -199,33 +179,18 @@ static void test_saveSlotReadJSON_blankSlot_shortCircuits(void **state) {
|
||||
|
||||
// No "name" key (or an empty one) means a blank/never-used slot (see
|
||||
// saveSlotInUse) - the reader returns right after reading that, without
|
||||
// needing or validating time/mapName/partyMembers/partyOrder at all, so
|
||||
// needing or validating time at all, so
|
||||
// this succeeds despite omitting fields that would otherwise be required.
|
||||
errorret_t ret = slotFromJSON(&slot, "{\"version\":1}");
|
||||
assert_true(errorIsOk(ret));
|
||||
|
||||
assert_int_equal(slot.cachedData.name[0], '\0');
|
||||
assert_int_equal(slot.cachedData.mapName[0], '\0');
|
||||
// Not readInt32's own default of 1 - the early return happens before
|
||||
// playerLevel is ever read, leaving the zero-init saveSlotCurrentReadJSON
|
||||
// seeds ver1 with (see the memoryZero in saveSlotCurrentReadJSON).
|
||||
assert_int_equal(slot.cachedData.playerLevel, 0);
|
||||
}
|
||||
|
||||
static void test_saveSlotReadJSON_inUseMissingMapName_errors(void **state) {
|
||||
saveslot_t slot;
|
||||
|
||||
// "name" is present (in use) but "mapName" is missing - a real save
|
||||
// (via saveSlotNewGame) always has both, so this is corrupt.
|
||||
errorret_t ret = slotFromJSON(
|
||||
&slot,
|
||||
"{\"version\":1,\"name\":\"Hero\","
|
||||
"\"time\":{\"time\":1.0,\"timeZone\":0.0,\"offsetTime\":0.0}}"
|
||||
);
|
||||
assert_true(errorIsNotOk(ret));
|
||||
errorCatch(ret);
|
||||
}
|
||||
|
||||
static void test_saveSlotReadJSON_missingTimeKey_errors(void **state) {
|
||||
saveslot_t slot;
|
||||
|
||||
@@ -302,7 +267,6 @@ int main(void) {
|
||||
cmocka_unit_test(test_saveSlotReadJSON_nullAsserts),
|
||||
cmocka_unit_test(test_saveSlotReadJSON_roundTrip),
|
||||
cmocka_unit_test(test_saveSlotReadJSON_blankSlot_shortCircuits),
|
||||
cmocka_unit_test(test_saveSlotReadJSON_inUseMissingMapName_errors),
|
||||
cmocka_unit_test(test_saveSlotReadJSON_missingTimeKey_errors),
|
||||
cmocka_unit_test(test_saveSlotReadJSON_nameTooLong_errors),
|
||||
cmocka_unit_test(test_saveSlotReadJSON_nonObjectRoot_errors),
|
||||
@@ -310,5 +274,5 @@ int main(void) {
|
||||
cmocka_unit_test(test_saveSlotReadJSON_versionMismatch_errors),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, assetGroupSetup, assetGroupTeardown);
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
Reference in new issue
Block a user