From ce48ab55ec38b7373634039946c2369702a9f9a5 Mon Sep 17 00:00:00 2001 From: Dregu Date: Sun, 5 Nov 2023 04:37:54 +0200 Subject: [PATCH] make get_raw_input function --- src/game_api/game_manager.cpp | 6 ++++++ src/game_api/game_manager.hpp | 1 + src/game_api/script/usertypes/game_manager_lua.cpp | 8 ++------ src/injected/ui.cpp | 3 +++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/game_api/game_manager.cpp b/src/game_api/game_manager.cpp index a7848320b..746a5a618 100644 --- a/src/game_api/game_manager.cpp +++ b/src/game_api/game_manager.cpp @@ -9,3 +9,9 @@ GameManager* get_game_manager() static GameManager** gm = (GameManager**)get_address("game_manager"sv); return *gm; } + +RawInput* get_raw_input() +{ + static auto offset = get_address("input_table"); + return reinterpret_cast(offset); +} diff --git a/src/game_api/game_manager.hpp b/src/game_api/game_manager.hpp index 0f6a94a73..34d4521dd 100644 --- a/src/game_api/game_manager.hpp +++ b/src/game_api/game_manager.hpp @@ -195,3 +195,4 @@ struct GameManager }; GameManager* get_game_manager(); +RawInput* get_raw_input(); diff --git a/src/game_api/script/usertypes/game_manager_lua.cpp b/src/game_api/script/usertypes/game_manager_lua.cpp index dcb8be9a2..9bf46d21d 100644 --- a/src/game_api/script/usertypes/game_manager_lua.cpp +++ b/src/game_api/script/usertypes/game_manager_lua.cpp @@ -144,11 +144,7 @@ void register_usertypes(sol::state& lua) "pressed", &ControllerButton::pressed); - lua["get_raw_input"] = []() -> RawInput* - { - // TODO:temp, move to rpc or something - static auto offset = get_address("input_table"); - return reinterpret_cast(offset); - }; + /// Returns RawInput, a game structure for raw keyboard and controller state + lua["get_raw_input"] = get_raw_input; } }; // namespace NGM diff --git a/src/injected/ui.cpp b/src/injected/ui.cpp index 7191178fc..569739eea 100644 --- a/src/injected/ui.cpp +++ b/src/injected/ui.cpp @@ -1913,6 +1913,9 @@ void quick_start(uint8_t screen, uint8_t world, uint8_t level, uint8_t theme) g_game_manager->main_menu_music->kill(false); g_game_manager->main_menu_music = nullptr; } + + // TODO: this doesn't quite work, loads intro after character selection + g_state->screen_character_select->available_mine_entrances = 4; } std::string get_clipboard()