Delay unloading of plugins until it is absolutely safe (
bug 5034, r=ds).
1 /* ======== SourceHook ========
2 * Copyright (C) 2004-2010 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): Pavol "PM OnoTo" Marko
8 * Contributors: Scott "Damaged Soul" Ehlert
9 * ============================
12 #include "sourcehook_impl.h"
18 CHookManager::CHookManager(Plugin ownerPlugin, HookManagerPubFunc pubFunc)
19 : m_OwnerPlugin(ownerPlugin), m_PubFunc(pubFunc), m_Version(-1)
22 // -> Should call SetInfo and set all the other variables!
23 if (m_PubFunc(false, this) != 0)
30 void CHookManager::SetInfo(int hookman_version, int vtbloffs, int vtblidx,
31 ProtoInfo *proto, void *hookfunc_vfnptr)
33 m_Version = hookman_version;
34 m_VtblOffs = vtbloffs;
37 m_HookfuncVfnptr = hookfunc_vfnptr;
40 void CHookManager::Register()
42 m_PubFunc(true, this);
45 void CHookManager::Unregister()
47 m_PubFunc(true, NULL);
50 void CHookManager::IncrRef(CVfnPtr *pVfnPtr)
52 m_VfnPtrs.push_back(pVfnPtr);
53 if (m_VfnPtrs.size() == 1)
57 void CHookManager::DecrRef(CVfnPtr *pVfnPtr)
59 m_VfnPtrs.remove(pVfnPtr);
60 if (m_VfnPtrs.empty())
64 CHookManager *CHookManList::GetHookMan(Plugin plug, HookManagerPubFunc pubFunc)
66 CHookManager hm(plug, pubFunc);
67 return GetHookMan(hm);
70 CHookManager *CHookManList::GetHookMan(CHookManager &hm)
72 iterator iter = find(hm);