mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 08:14:38 +01:00
Improve chat subscription
This commit is contained in:
@@ -87,6 +87,12 @@ void HookEngine::UnsubscribeAll()
|
||||
}
|
||||
}
|
||||
|
||||
bool HookEngine::HasSubscriptions(HOOK_TYPE type) const
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
return !hookList.Hooks.empty();
|
||||
}
|
||||
|
||||
void HookEngine::Call(HOOK_TYPE type)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
@@ -101,6 +107,23 @@ void HookEngine::Call(HOOK_TYPE type)
|
||||
}
|
||||
}
|
||||
|
||||
void HookEngine::Call(HOOK_TYPE type, DukValue args)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
for (auto& hook : hookList.Hooks)
|
||||
{
|
||||
ScriptExecutionInfo::PluginScope scope(_execInfo, hook.Owner);
|
||||
|
||||
const auto& function = hook.Function;
|
||||
auto ctx = function.context();
|
||||
function.push();
|
||||
|
||||
args.push();
|
||||
duk_pcall(ctx, 1);
|
||||
duk_pop(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void HookEngine::Call(HOOK_TYPE type, const std::initializer_list<std::pair<std::string_view, std::any>>& args)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
@@ -141,3 +164,9 @@ HookList& HookEngine::GetHookList(HOOK_TYPE type)
|
||||
auto index = static_cast<size_t>(type);
|
||||
return _hookMap[index];
|
||||
}
|
||||
|
||||
const HookList& HookEngine::GetHookList(HOOK_TYPE type) const
|
||||
{
|
||||
auto index = static_cast<size_t>(type);
|
||||
return _hookMap[index];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user