Skip to content

Commit

Permalink
fix(tolk): fix tolk not working since october 16 2024 update.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiao921 committed Oct 17, 2024
1 parent ad216e9 commit 9e1d3f9
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/lua_extensions/bindings/tolk/tolk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ namespace lua::tolk
}
}

static void* sgg_world_ptr = nullptr;

namespace sgg
{
// These offsets can easily be found again
Expand Down Expand Up @@ -168,16 +166,26 @@ namespace lua::tolk
{
std::vector<std::string> res;

static auto world_ptr = big::hades2_symbol_to_address["sgg::world"].as<void**>();
if (!world_ptr)
{
return res;
}

static auto get_active_thing = big::hades2_symbol_to_address["sgg::World::GetActiveThing"].as_func<sgg::Thing*(void* this_, int id)>();
sgg::Thing* active_thing = get_active_thing(sgg_world_ptr, thing_id);
if (active_thing && active_thing->pText)

sgg::Thing* active_thing = get_active_thing(*world_ptr, thing_id);

if (!active_thing || !active_thing->pText)
{
return res;
}

for (auto i = active_thing->pText->mTextBoxes.begin(); i != active_thing->pText->mTextBoxes.end(); i++)
{
for (auto i = active_thing->pText->mTextBoxes.begin(); i != active_thing->pText->mTextBoxes.end(); i++)
for (auto j = (*i)->mLines.mpBegin; j < (*i)->mLines.mpEnd; j++)
{
for (auto j = (*i)->mLines.mpBegin; j < (*i)->mLines.mpEnd; j++)
{
res.push_back(j->mText.c_str());
}
res.push_back(j->mText.c_str());
}
}

Expand Down Expand Up @@ -207,15 +215,6 @@ namespace lua::tolk
}
}

static void* hook_GetActiveThing(void* this_, int thing_id)
{
sgg_world_ptr = this_;

const auto res = big::g_hooking->get_original<hook_GetActiveThing>()(this_, thing_id);

return res;
}

void bind(sol::table& state)
{
if (!Tolk_IsLoaded())
Expand All @@ -241,9 +240,6 @@ namespace lua::tolk
ns.set_function("output", output);
ns.set_function("on_button_hover", on_button_hover);

static auto GetActiveThing_hook_obj =
big::hooking::detour_hook_helper::add_now<hook_GetActiveThing>("hook_GetActiveThing", big::hades2_symbol_to_address["GetActiveThing"]);

ns.set_function("get_lines_from_thing", get_lines_from_thing);
}
} // namespace lua::tolk

0 comments on commit 9e1d3f9

Please sign in to comment.