fix: hook registration fixes
This commit is contained in:
@@ -30,8 +30,8 @@ namespace fxn
|
|||||||
void RegisterNativeHandler(const NativeHash hash, const NativeHandler handler);
|
void RegisterNativeHandler(const NativeHash hash, const NativeHandler handler);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void RegisterNativeHook(const NativeHash hash, const NativeHook& hook);
|
size_t RegisterNativeHook(const NativeHash hash, const NativeHook& hook);
|
||||||
void UnregisterNativeHook(const NativeHash hash);
|
void UnregisterNativeHook(const NativeHash hash, size_t index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Invoke(fxn::NativeContext* context);
|
bool Invoke(fxn::NativeContext* context);
|
||||||
|
|||||||
@@ -105,14 +105,24 @@ namespace fxn
|
|||||||
m_NativeHandlers[hash] = handler;
|
m_NativeHandlers[hash] = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterNativeHook(const NativeHash hash, const NativeHook& hook)
|
size_t RegisterNativeHook(const NativeHash hash, const NativeHook& hook)
|
||||||
{
|
{
|
||||||
m_NativeHooks[hash].push_back(hook);
|
m_NativeHooks[hash].push_back(hook);
|
||||||
|
|
||||||
|
return m_NativeHooks[hash].size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterNativeHook(const NativeHash hash)
|
void UnregisterNativeHook(const NativeHash hash, std::size_t index)
|
||||||
{
|
{
|
||||||
m_NativeHooks.erase(hash);
|
auto it = m_NativeHooks.find(hash);
|
||||||
|
if (it != m_NativeHooks.end())
|
||||||
|
{
|
||||||
|
auto& hooks = it->second;
|
||||||
|
if (index < hooks.size())
|
||||||
|
{
|
||||||
|
hooks.erase(hooks.begin() + index);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DispatchNative(fxn::NativeContext* context, NativeHash hash)
|
void DispatchNative(fxn::NativeContext* context, NativeHash hash)
|
||||||
@@ -216,14 +226,14 @@ namespace fxn
|
|||||||
m_Impl->RegisterNativeHandler(hash, handler);
|
m_Impl->RegisterNativeHandler(hash, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FxnManager::RegisterNativeHook(const NativeHash hash, const NativeHook& hook)
|
size_t FxnManager::RegisterNativeHook(const NativeHash hash, const NativeHook& hook)
|
||||||
{
|
{
|
||||||
m_Impl->RegisterNativeHook(hash, hook);
|
return m_Impl->RegisterNativeHook(hash, hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FxnManager::UnregisterNativeHook(const NativeHash hash)
|
void FxnManager::UnregisterNativeHook(const NativeHash hash, size_t index)
|
||||||
{
|
{
|
||||||
m_Impl->UnregisterNativeHook(hash);
|
m_Impl->UnregisterNativeHook(hash, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FxnManager::Invoke(fxn::NativeContext* context)
|
bool FxnManager::Invoke(fxn::NativeContext* context)
|
||||||
|
|||||||
Reference in New Issue
Block a user