diff --git a/games/lua_game_loader.cpp b/games/lua_game_loader.cpp index ee6126c..d76c206 100644 --- a/games/lua_game_loader.cpp +++ b/games/lua_game_loader.cpp @@ -16,6 +16,8 @@ extern "C" { // Structure to hold script path for factory closure struct LuaGameFactoryData { char script_path[256]; + char name[64]; + char description[128]; }; static std::vector factory_data_list; @@ -131,23 +133,22 @@ int LuaGameLoader::register_all_games(GameLauncher* launcher) { char script_path[256]; snprintf(script_path, sizeof(script_path), "/games/%s", fno.fname); - // Parse metadata - char name[64]; - char description[128]; - parse_metadata(script_path, name, description); - - printf("LuaGameLoader: Found %s - '%s'\n", fno.fname, name); - // Create factory data (persistent for game lifetime) LuaGameFactoryData* data = new LuaGameFactoryData(); strncpy(data->script_path, script_path, sizeof(data->script_path) - 1); data->script_path[sizeof(data->script_path) - 1] = '\0'; + + // Parse metadata directly into persistent storage + parse_metadata(script_path, data->name, data->description); + + printf("LuaGameLoader: Found %s - '%s'\n", fno.fname, data->name); + factory_data_list.push_back(data); // Register with launcher - using lambda factory pattern launcher->register_game( - name, - description[0] ? description : "Lua Script", + data->name, + data->description[0] ? data->description : "Lua Script", [data](uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager) -> Game* { return new LuaGame(data->script_path, width, height, renderer, gui, input_manager);