Fix garbage characters in hardware game names
Store game names and descriptions in persistent LuaGameFactoryData structure instead of local stack variables to prevent dangling pointers. Same fix as emulator version.
This commit is contained in:
@@ -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<LuaGameFactoryData*> 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);
|
||||
|
||||
Reference in New Issue
Block a user