1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 14:59:25 +08:00

add: more config when loading lua resources

This commit is contained in:
0O0o0oOoO00
2025-11-15 21:24:04 +08:00
parent 91c0dcf4a4
commit 2f78d7352d

View File

@@ -60,7 +60,11 @@ static fnset_TimeScaleT get_Time_set_timeScale() {
#endif #endif
Cracker::Cracker() Cracker::Cracker()
: m_state(lua_newthread(Utils::get_lua_state())) { : m_state([]() -> lua_State* {
auto new_tr = lua_newthread(Utils::get_lua_state());
SPDLOG_INFO("new lua_State: {}", (void*)new_tr);
return new_tr;
}()) {
try { try {
load_lua_resources(); load_lua_resources();
hook_all_lua_functions(); hook_all_lua_functions();
@@ -477,6 +481,9 @@ void Cracker::print_value(std::vector<std::string>& path) {
} }
void Cracker::load_lua_resources() { void Cracker::load_lua_resources() {
SPDLOG_INFO("Load lua resources");
SPDLOG_INFO("Load data proxies");
Lua::Table proxies = m_state["pg"]["proxyRegister"]["data"]; Lua::Table proxies = m_state["pg"]["proxyRegister"]["data"];
for (int i = 1; i <= proxies.size(); ++i) { for (int i = 1; i <= proxies.size(); ++i) {
Lua::Table proxy = proxies[i]; Lua::Table proxy = proxies[i];
@@ -490,6 +497,8 @@ void Cracker::load_lua_resources() {
m_data_proxy.world = proxy["facade"]["model"]["proxyMap"]["WorldProxy"]; m_data_proxy.world = proxy["facade"]["model"]["proxyMap"]["WorldProxy"];
} }
} }
SPDLOG_INFO("Load lua res");
m_lua_res.Clone = m_state["Clone"]; m_lua_res.Clone = m_state["Clone"];
m_lua_res.Ship_getIntimacyLevel = m_state["Ship"]["getIntimacyLevel"]; m_lua_res.Ship_getIntimacyLevel = m_state["Ship"]["getIntimacyLevel"];
m_lua_res.pg_intimacy_template = m_state["pg"]["intimacy_template"]; m_lua_res.pg_intimacy_template = m_state["pg"]["intimacy_template"];
@@ -507,6 +516,7 @@ void Cracker::load_lua_resources() {
.Dodge = AttributeType.get<std::string>("Dodge"), .Dodge = AttributeType.get<std::string>("Dodge"),
}; };
SPDLOG_INFO("Load lua functions");
m_original.GetBattleCheckResult = m_state["GetBattleCheckResult"]; m_original.GetBattleCheckResult = m_state["GetBattleCheckResult"];
m_original.FinishStageCommand_GeneralPackage = m_state["FinishStageCommand"]["GeneralPackage"]; m_original.FinishStageCommand_GeneralPackage = m_state["FinishStageCommand"]["GeneralPackage"];
m_original.Ship_intimacyAdditions = m_state["Ship"]["intimacyAdditions"]; m_original.Ship_intimacyAdditions = m_state["Ship"]["intimacyAdditions"];
@@ -537,6 +547,8 @@ void Cracker::load_lua_resources() {
} }
void Cracker::hook_all_lua_functions() { void Cracker::hook_all_lua_functions() {
SPDLOG_INFO("Hook lua functions");
// opsi_force_auto // opsi_force_auto
m_state["WorldMap"]["CanAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) -> bool { m_state["WorldMap"]["CanAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) -> bool {
if (!IS_ENABLED(OPSI_FORCE_AUTO)) { if (!IS_ENABLED(OPSI_FORCE_AUTO)) {