1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Use shared_ptr for Plugin

This commit is contained in:
Ted John
2018-03-23 22:39:12 +00:00
parent a6bb9a9b64
commit f54b3efe9e
7 changed files with 25 additions and 39 deletions

View File

@@ -35,7 +35,7 @@ HookEngine::HookEngine(ScriptExecutionInfo& execInfo) :
}
}
uint32 HookEngine::Subscribe(HOOK_TYPE type, Plugin& owner, const DukValue &function)
uint32 HookEngine::Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, const DukValue &function)
{
auto& hookList = GetHookList(type);
auto cookie = _nextCookie++;
@@ -58,14 +58,14 @@ void HookEngine::Unsubscribe(HOOK_TYPE type, uint32 cookie)
}
}
void HookEngine::UnsubscribeAll(const Plugin& owner)
void HookEngine::UnsubscribeAll(std::shared_ptr<const Plugin> owner)
{
for (auto& hookList : _hookMap)
{
auto& hooks = hookList.Hooks;
for (auto it = hooks.begin(); it != hooks.end();)
{
if (it->Owner == &owner)
if (it->Owner == owner)
{
it = hooks.erase(it);
}