From bbe0e48d23d5983177b7c312539433759a8c26ba Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sat, 6 Jun 2026 16:42:12 -0500 Subject: [PATCH] Builds again? --- src/dusk/engine/engine.c | 1 - src/dusk/scene/scene.c | 95 ---------------------------------------- src/dusk/scene/scene.h | 44 +------------------ 3 files changed, 1 insertion(+), 139 deletions(-) diff --git a/src/dusk/engine/engine.c b/src/dusk/engine/engine.c index cef6f1dc..16fdfa74 100644 --- a/src/dusk/engine/engine.c +++ b/src/dusk/engine/engine.c @@ -59,7 +59,6 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) { consolePrint("Engine initialized"); errorChain(scriptExecFile("init.js")); - errorChain(sceneSet("testscene.js")); errorOk(); } diff --git a/src/dusk/scene/scene.c b/src/dusk/scene/scene.c index ac8f4b8c..c07eb40e 100644 --- a/src/dusk/scene/scene.c +++ b/src/dusk/scene/scene.c @@ -27,20 +27,6 @@ errorret_t sceneInit(void) { } void sceneUpdate(void) { - if((SCENE.state & SCENE_STATE_LOADED) == 0) return; - - if((SCENE.state & SCENE_STATE_INITIALIZED) == 0) { - errorret_t ret = sceneCallScriptMethod(SCENE.jsInit, "init"); - if(errorIsNotOk(ret)) { - errorCatch(errorPrint(ret)); - errorCatch(errorPrint(sceneDispose())); - return; - } - - SCENE.state |= SCENE_STATE_INITIALIZED; - } - - errorCatch(errorPrint(sceneCallScriptMethod(SCENE.jsUpdate, "update"))); } errorret_t sceneRender(void) { @@ -78,87 +64,6 @@ errorret_t sceneRender(void) { errorOk(); } -errorret_t sceneSet(const char_t *jsFile) { - assertStrLenMin(jsFile, 1, "jsFile cannot be empty"); - - // Dispose any active scene before switching. - errorChain(sceneDispose()); - - // // Lock the asset - // assetloaderinput_t input; - // memoryZero(&input, sizeof(input)); - // assetentry_t *entry = assetLock(jsFile, ASSET_LOADER_TYPE_SCRIPT, &input); - // if(!entry) errorThrow("sceneSet: failed to lock '%s'", jsFile); - - // // Wait for loaded. - // errorret_t err = assetRequireLoaded(entry); - // if(errorIsNotOk(err)) { - // assetUnlockEntry(entry); - // errorChain(err); - // } - - // // Any export? - // if(entry->data.script.exportedModule == 0) { - // assetUnlockEntry(entry); - // errorThrow("sceneSet: '%s' produced no exports", jsFile); - // } - - // // Copy the exports reference before unlocking (entry may be reaped). - // jerry_value_t exports = jerry_value_copy(entry->data.script.exportedModule); - // assetUnlockEntry(entry); - - // // Extract the three lifecycle callbacks. - // SCENE.jsInit = sceneExtractFn(exports, "init"); - // SCENE.jsUpdate = sceneExtractFn(exports, "update"); - // SCENE.jsDispose = sceneExtractFn(exports, "dispose"); - // jerry_value_free(exports); - - SCENE.state |= SCENE_STATE_LOADED; - - errorOk(); -} - -errorret_t sceneCallScriptMethod(jerry_value_t fn, const char_t *name) { - assertStrLenMin(name, 1, "name cannot be empty"); - - if(!jerry_value_is_function(fn)) { - errorOk(); - } - - jerry_value_t ret = jerry_call(fn, jerry_undefined(), NULL, 0); - if(jerry_value_is_exception(ret)) { - char_t buf[256]; - moduleBaseExceptionMessage(ret, buf, sizeof(buf)); - errorThrow("Scene script exception in %s: %s", name, buf); - } - jerry_value_free(ret); - errorOk(); -} - -jerry_value_t sceneExtractFn(jerry_value_t obj, const char_t *name) { - jerry_value_t val = moduleBaseGetProp(obj, name); - if(jerry_value_is_function(val)) return val; - jerry_value_free(val); - return jerry_undefined(); -} - errorret_t sceneDispose(void) { - if((SCENE.state & SCENE_STATE_LOADED) == 0) { - errorOk(); - } - - if((SCENE.state & SCENE_STATE_INITIALIZED) != 0) { - errorChain(sceneCallScriptMethod(SCENE.jsDispose, "dispose")); - } - - jerry_value_free(SCENE.jsDispose); - jerry_value_free(SCENE.jsInit); - jerry_value_free(SCENE.jsUpdate); - - SCENE.jsDispose = jerry_undefined(); - SCENE.jsInit = jerry_undefined(); - SCENE.jsUpdate = jerry_undefined(); - - SCENE.state = 0; errorOk(); } diff --git a/src/dusk/scene/scene.h b/src/dusk/scene/scene.h index f639762b..a9101a9a 100644 --- a/src/dusk/scene/scene.h +++ b/src/dusk/scene/scene.h @@ -7,16 +7,9 @@ #pragma once #include "error/error.h" -#include - -#define SCENE_STATE_LOADED 0x01 -#define SCENE_STATE_INITIALIZED 0x02 typedef struct { - jerry_value_t jsInit; - jerry_value_t jsUpdate; - jerry_value_t jsDispose; - uint8_t state; + void *nothing; } scene_t; extern scene_t SCENE; @@ -37,41 +30,6 @@ void sceneUpdate(void); */ errorret_t sceneRender(void); -/** - * Requests a scene transition. The pending script scene (set via - * scriptSceneSetPending) will be activated at the start of the next - * sceneUpdate call. - */ -// void sceneSet(void); - -/** - * Loads a JS file as a module, extracts the .init / .update / .dispose - * callbacks from its exports, and stores them ready for the scene loop. - * Disposes any previously active scene first. - * - * @param jsFile Asset path of the script (e.g. "testscene.js"). - */ -errorret_t sceneSet(const char_t *jsFile); - -/** - * Calls a scene script method and logs any exception. - * - * @param fn The function to call. If not a function, this is a no-op. - * @param name The name of the method (for logging purposes). - * @return Error state (if any). - */ -errorret_t sceneCallScriptMethod(jerry_value_t fn, const char_t *name); - -/** - * Extracts a function from a scene module export. If the property doesn't - * exist or isn't a function, returns undefined. - * - * @param obj The module exports object. - * @param name The name of the property to extract. - * @return The extracted function, or undefined. - */ -jerry_value_t sceneExtractFn(jerry_value_t obj, const char_t *name); - /** * Disposes the active scene immediately. */