Skip to content

Commit

Permalink
fix for callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Oct 11, 2024
1 parent 721d627 commit 3ee416a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions includes/callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class CallbackHandler
{
std::function<void()> fn;
std::optional<hook::pattern> pattern;
bool executed;
};

static inline auto& GetOnModuleLoadCallbackList()
Expand Down Expand Up @@ -321,15 +322,24 @@ class CallbackHandler
{
auto& threadParams = GetCallbackParamsList();

static std::mutex threadParamsMutex;
std::lock_guard<std::mutex> lock(threadParamsMutex);

for (auto& it : threadParams)
{
if (!it.pattern.has_value() || !it.pattern.value().clear().empty())
it.fn();
if (!it.executed)
{
if (!it.pattern.has_value() || !it.pattern.value().clear().empty())
{
it.executed = true;
it.fn();
}
}
}

shGetSystemTimeAsFileTime.stdcall<ReturnType<decltype(GetSystemTimeAsFileTime)>>(lpSystemTimeAsFileTime);

if (threadParams.empty())
if (std::all_of(threadParams.begin(), threadParams.end(), [](const auto& params) { return params.executed; }))
shGetSystemTimeAsFileTime = {};
}

Expand Down
2 changes: 1 addition & 1 deletion source/ResidentEvil2.RE3.Dolphin.FusionMod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void PluginThread(std::future<void> futureObj)
if (Dolphin::MemoryValid())
{
auto gameVersion = GameVersion::UNDEFINED;
if (Dolphin::GameID() == "GHAE08" || Dolphin::GameID() == "GHAP08")
if (Dolphin::GameID() == "GHAE08" || Dolphin::GameID() == "GHAP08" || Dolphin::GameID() == "GHAJ08")
gameVersion = GameVersion::RE2;
else if (Dolphin::GameID() == "GLEE08" || Dolphin::GameID() == "GLEJ08" || Dolphin::GameID() == "GLEP08")
gameVersion = GameVersion::RE3;
Expand Down

0 comments on commit 3ee416a

Please sign in to comment.