mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-26 19:54:14 +01:00
fixed bugs related to vsplistener and vsp loading mechanism
--HG-- branch : sourcemm-1.4.3 extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.3%40599
This commit is contained in:
parent
bcc08f184b
commit
90fb451242
@ -12,6 +12,7 @@
|
||||
#include "CSmmAPI.h"
|
||||
#include "sourcemm.h"
|
||||
#include "concommands.h"
|
||||
#include "vsp_listener.h"
|
||||
|
||||
/**
|
||||
* @brief Implements functions from CPlugin.h
|
||||
@ -22,14 +23,14 @@ using namespace SourceMM;
|
||||
|
||||
#define ITER_PLEVENT(evn, plid) \
|
||||
CPluginManager::CPlugin *_Xpl; \
|
||||
SourceHook::List<IMetamodListener *>::iterator event; \
|
||||
SourceHook::List<CPluginEventHandler>::iterator event; \
|
||||
IMetamodListener *api; \
|
||||
for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++) { \
|
||||
_Xpl = (*iter); \
|
||||
if (_Xpl->m_Id == plid) \
|
||||
continue; \
|
||||
for (event=_Xpl->m_Events.begin(); event!=_Xpl->m_Events.end(); event++) { \
|
||||
api = (*event); \
|
||||
api = (*event).event; \
|
||||
api->evn(plid); \
|
||||
} \
|
||||
}
|
||||
@ -182,6 +183,38 @@ void CPluginManager::SetAllLoaded()
|
||||
}
|
||||
}
|
||||
|
||||
void CPluginManager::SetVSPAsLoaded()
|
||||
{
|
||||
PluginIter i;
|
||||
CPlugin *pPlugin;
|
||||
SourceHook::List<CPluginEventHandler>::iterator event;
|
||||
|
||||
for (i = m_Plugins.begin(); i != m_Plugins.end(); i++)
|
||||
{
|
||||
pPlugin = (*i);
|
||||
if (pPlugin->m_Status < Pl_Paused)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* Only valid for plugins >= 10 (v1:5, SourceMM 1.4) */
|
||||
if (pPlugin->m_API->GetApiVersion() < 10)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (event = pPlugin->m_Events.begin();
|
||||
event != pPlugin->m_Events.end();
|
||||
event++)
|
||||
{
|
||||
if (!(*event).got_vsp)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(*event).got_vsp = true;
|
||||
(*event).event->OnVSPListening(&g_VspListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CPluginManager::Pause(PluginId id, char *error, size_t maxlen)
|
||||
{
|
||||
CPlugin *pl = FindById(id);
|
||||
@ -373,6 +406,21 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
|
||||
//if (pl->m_API->GetApiVersion() >= 4)
|
||||
pl->m_API->AllPluginsLoaded();
|
||||
}
|
||||
if (g_VspListener.IsRootLoadMethod())
|
||||
{
|
||||
SourceHook::List<CPluginEventHandler>::iterator event;
|
||||
for (event = pl->m_Events.begin();
|
||||
event != pl->m_Events.end();
|
||||
event++)
|
||||
{
|
||||
if ((*event).got_vsp)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(*event).got_vsp = true;
|
||||
(*event).event->OnVSPListening(&g_VspListener);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pl->m_Status = Pl_Refused;
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ namespace SourceMM
|
||||
SourceHook::String alias;
|
||||
SourceHook::String value;
|
||||
};
|
||||
|
||||
struct CPluginEventHandler
|
||||
{
|
||||
bool got_vsp;
|
||||
IMetamodListener *event;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Implements Plugin Manager API
|
||||
*/
|
||||
@ -72,7 +79,7 @@ namespace SourceMM
|
||||
HINSTANCE m_Lib;
|
||||
SourceHook::List<ConCommandBase *> m_Cvars;
|
||||
SourceHook::List<ConCommandBase *> m_Cmds;
|
||||
SourceHook::List<IMetamodListener *> m_Events;
|
||||
SourceHook::List<CPluginEventHandler> m_Events;
|
||||
};
|
||||
public:
|
||||
CPluginManager();
|
||||
@ -123,6 +130,8 @@ namespace SourceMM
|
||||
//Internal iterators
|
||||
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _begin();
|
||||
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _end();
|
||||
|
||||
void SetVSPAsLoaded();
|
||||
private:
|
||||
//These are identical internal functions for the wrappers above.
|
||||
CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
|
||||
|
@ -141,8 +141,12 @@ void CSmmAPI::ConPrintf(const char *fmt, ...)
|
||||
void CSmmAPI::AddListener(ISmmPlugin *plugin, IMetamodListener *pListener)
|
||||
{
|
||||
CPluginManager::CPlugin *pl = g_PluginMngr.FindByAPI(plugin);
|
||||
CPluginEventHandler cpeh;
|
||||
|
||||
pl->m_Events.push_back(pListener);
|
||||
cpeh.event = pListener;
|
||||
cpeh.got_vsp = false;
|
||||
|
||||
pl->m_Events.push_back(cpeh);
|
||||
}
|
||||
|
||||
void *CSmmAPI::MetaFactory(const char *iface, int *_ret, PluginId *id)
|
||||
@ -174,7 +178,7 @@ void *CSmmAPI::MetaFactory(const char *iface, int *_ret, PluginId *id)
|
||||
}
|
||||
|
||||
CPluginManager::CPlugin *pl;
|
||||
SourceHook::List<IMetamodListener *>::iterator event;
|
||||
SourceHook::List<CPluginEventHandler>::iterator event;
|
||||
IMetamodListener *api;
|
||||
int ret = 0;
|
||||
void *val = NULL;
|
||||
@ -184,7 +188,7 @@ void *CSmmAPI::MetaFactory(const char *iface, int *_ret, PluginId *id)
|
||||
pl = (*iter);
|
||||
for (event=pl->m_Events.begin(); event!=pl->m_Events.end(); event++)
|
||||
{
|
||||
api = (*event);
|
||||
api = (*event).event;
|
||||
ret = IFACE_FAILED;
|
||||
if ( (val=api->OnMetamodQuery(iface, &ret)) != NULL )
|
||||
{
|
||||
|
@ -73,14 +73,14 @@ void ClearGamedllList();
|
||||
/* Helper Macro */
|
||||
#define IFACE_MACRO(orig,nam) \
|
||||
CPluginManager::CPlugin *pl; \
|
||||
SourceHook::List<IMetamodListener *>::iterator event; \
|
||||
SourceHook::List<CPluginEventHandler>::iterator event; \
|
||||
IMetamodListener *api; \
|
||||
int mret = 0; \
|
||||
void *val = NULL; \
|
||||
for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++) { \
|
||||
pl = (*iter); \
|
||||
for (event=pl->m_Events.begin(); event!=pl->m_Events.end(); event++) { \
|
||||
api = (*event); \
|
||||
api = (*event).event; \
|
||||
mret = IFACE_FAILED; \
|
||||
if ( (val=api->On##nam##Query(iface, &mret)) != NULL ) { \
|
||||
if (ret) *ret = mret; \
|
||||
@ -92,12 +92,12 @@ void ClearGamedllList();
|
||||
|
||||
#define ITER_EVENT(evn, args) \
|
||||
CPluginManager::CPlugin *pl; \
|
||||
SourceHook::List<IMetamodListener *>::iterator event; \
|
||||
SourceHook::List<CPluginEventHandler>::iterator event; \
|
||||
IMetamodListener *api; \
|
||||
for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++) { \
|
||||
pl = (*iter); \
|
||||
for (event=pl->m_Events.begin(); event!=pl->m_Events.end(); event++) { \
|
||||
api = (*event); \
|
||||
api = (*event).event; \
|
||||
api->evn args; \
|
||||
} \
|
||||
}
|
||||
@ -308,6 +308,7 @@ bool GameInit_handler()
|
||||
if (g_VspListener.IsRootLoadMethod())
|
||||
{
|
||||
DoInitialPluginLoads();
|
||||
//gaben
|
||||
}
|
||||
|
||||
bGameInit = true;
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
#define SVN_PRODUCT_VERSION "1.4.3"
|
||||
|
||||
#define SVN_REVISION 590
|
||||
#define SVN_REVISION_STRING "590"
|
||||
#define SVN_FILE_VERSION 1,4,3,590
|
||||
#define SVN_FILE_VERSION_STRING "1.4.3.590"
|
||||
#define SVN_REVISION 599
|
||||
#define SVN_REVISION_STRING "599"
|
||||
#define SVN_FILE_VERSION 1,4,3,599
|
||||
#define SVN_FILE_VERSION_STRING "1.4.3.599"
|
||||
|
||||
#endif //_INCLUDE_SVN_VERSION_H_
|
||||
|
@ -178,29 +178,9 @@ bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gam
|
||||
m_Loaded = true;
|
||||
SetLoadable(false);
|
||||
|
||||
PluginIter iter;
|
||||
CPluginManager::CPlugin *pPlugin;
|
||||
SourceHook::List<IMetamodListener *>::iterator event;
|
||||
IMetamodListener *pML;
|
||||
for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++)
|
||||
if (!m_bIsRootLoadMethod)
|
||||
{
|
||||
pPlugin = (*iter);
|
||||
if (pPlugin->m_Status < Pl_Paused)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* Only valid for plugins >= 10 (v1:5, SourceMM 1.4) */
|
||||
if (pPlugin->m_API->GetApiVersion() < 10)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (event=pPlugin->m_Events.begin();
|
||||
event!=pPlugin->m_Events.end();
|
||||
event++)
|
||||
{
|
||||
pML = (*event);
|
||||
pML->OnVSPListening(this);
|
||||
}
|
||||
g_PluginMngr.SetVSPAsLoaded();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user