mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-30 19:52:17 +01:00
Merge.
This commit is contained in:
commit
071c1877cb
@ -38,6 +38,26 @@ using namespace SourceMM;
|
||||
|
||||
CPluginManager g_PluginMngr;
|
||||
|
||||
void NotifyConCommandBaseDrop(PluginId id, ConCommandBase *base)
|
||||
{
|
||||
CPluginManager::CPlugin *pl;
|
||||
SourceHook::List<CPluginEventHandler>::iterator event;
|
||||
IMetamodListener *api;
|
||||
for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++)
|
||||
{
|
||||
pl = (*iter);
|
||||
if (pl->m_Status < Pl_Paused)
|
||||
continue;
|
||||
if (pl->m_API->GetApiVersion() < 11)
|
||||
continue;
|
||||
for (event = pl->m_Events.begin(); event != pl->m_Events.end(); event++)
|
||||
{
|
||||
api = (*event).event;
|
||||
api->OnUnlinkConCommandBase(id, base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPluginManager::CPluginManager()
|
||||
{
|
||||
m_LastId = Pl_MinId;
|
||||
@ -654,13 +674,19 @@ void CPluginManager::UnregAllConCmds(CPlugin *pl)
|
||||
{
|
||||
SourceHook::List<ConCommandBase *>::iterator i;
|
||||
|
||||
for (i=pl->m_Cvars.begin(); i!=pl->m_Cvars.end(); i++)
|
||||
g_SMConVarAccessor.Unregister( (*i) );
|
||||
for (i = pl->m_Cvars.begin(); i != pl->m_Cvars.end(); i++)
|
||||
{
|
||||
NotifyConCommandBaseDrop(pl->m_Id, (*i));
|
||||
g_SMConVarAccessor.Unregister((*i));
|
||||
}
|
||||
|
||||
pl->m_Cvars.clear();
|
||||
|
||||
for (i=pl->m_Cmds.begin(); i!=pl->m_Cmds.end(); i++)
|
||||
g_SMConVarAccessor.Unregister( (*i) );
|
||||
for (i = pl->m_Cmds.begin(); i != pl->m_Cmds.end(); i++)
|
||||
{
|
||||
NotifyConCommandBaseDrop(pl->m_Id, (*i));
|
||||
g_SMConVarAccessor.Unregister((*i));
|
||||
}
|
||||
|
||||
pl->m_Cmds.clear();
|
||||
}
|
||||
|
@ -149,6 +149,8 @@ namespace SourceMM
|
||||
};
|
||||
};
|
||||
|
||||
void NotifyConCommandBaseDrop(PluginId id, ConCommandBase *base);
|
||||
|
||||
typedef SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIter;
|
||||
|
||||
/** @brief Singleton for plugin manager */
|
||||
|
@ -119,6 +119,11 @@ void CSmmAPI::UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand)
|
||||
g_PluginMngr.RemovePluginCvar(plugin, pCommand);
|
||||
}
|
||||
|
||||
CPluginManager::CPlugin *pPlugin = g_PluginMngr.FindByAPI(plugin);
|
||||
PluginId id = (pPlugin != NULL) ? pPlugin->m_Id : Pl_BadLoad;
|
||||
|
||||
NotifyConCommandBaseDrop(id, pCommand);
|
||||
|
||||
g_SMConVarAccessor.Unregister(pCommand);
|
||||
}
|
||||
|
||||
@ -633,3 +638,16 @@ const char *CSmmAPI::GetUserMessage(int index, int *size)
|
||||
|
||||
return msg->name;
|
||||
}
|
||||
|
||||
IServerPluginCallbacks *CSmmAPI::GetVSPInfo(int *pVersion)
|
||||
{
|
||||
if (pVersion != NULL)
|
||||
*pVersion = g_vsp_version;
|
||||
|
||||
return g_pRealVspCallbacks;
|
||||
}
|
||||
|
||||
int CSmmAPI::GetSourceEngineBuild()
|
||||
{
|
||||
return g_Engine.original ? SOURCE_ENGINE_ORIGINAL : SOURCE_ENGINE_EPISODEONE;
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ namespace SourceMM
|
||||
virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
|
||||
virtual const char *GetBaseDir();
|
||||
virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
|
||||
virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion);
|
||||
void ClientConPrintf(edict_t *client, const char *fmt, ...);
|
||||
void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
|
||||
void EnableVSPListener();
|
||||
@ -70,6 +71,7 @@ namespace SourceMM
|
||||
int GetUserMessageCount();
|
||||
int FindUserMessage(const char *name, int *size=NULL);
|
||||
const char *GetUserMessage(int index, int *size=NULL);
|
||||
int GetSourceEngineBuild();
|
||||
public:
|
||||
bool CacheCmds();
|
||||
bool CmdCacheSuccessful();
|
||||
|
@ -35,6 +35,10 @@ class ISmmPlugin;
|
||||
#define MMIFACE_PLMANAGER "IPluginManager" /**< SourceMM Plugin Functions */
|
||||
#define IFACE_MAXNUM 999
|
||||
|
||||
#define SOURCE_ENGINE_UNKNOWN 0 /**< Could not determine the engine version */
|
||||
#define SOURCE_ENGINE_ORIGINAL 1 /**< Original Source Engine (used by The Ship) */
|
||||
#define SOURCE_ENGINE_EPISODEONE 2 /**< Episode 1 Source Engine (second major SDK) */
|
||||
|
||||
class ISmmAPI
|
||||
{
|
||||
public:
|
||||
@ -303,6 +307,30 @@ public: // Added in 1.4 (1:5)
|
||||
* @return Message name, or NULL on failure.
|
||||
*/
|
||||
virtual const char *GetUserMessage(int index, int *size=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the VSP listener loaded.
|
||||
*
|
||||
* This is useful for late-loading plugins which need to decide whether
|
||||
* to add a listener or not (or need to get the pointer at all).
|
||||
*
|
||||
* @param pVersion Optional pointer to store the VSP version.
|
||||
* @return IServerPluginCallbacks pointer, or NULL if an
|
||||
* IMetamodListener event has yet to occur for
|
||||
* EnableVSPListener().
|
||||
*/
|
||||
virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the engine interface that MM:S is using as a backend.
|
||||
*
|
||||
* The values will be one of the SOURCE_ENGINE_* constants from the top
|
||||
* of this file.
|
||||
*
|
||||
* @return A SOURCE_ENGINE_* constant value.
|
||||
*/
|
||||
virtual int GetSourceEngineBuild() =0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -315,7 +343,7 @@ public: // Added in 1.4 (1:5)
|
||||
* 1.2.2 Added API for printing to client console (with string formatting).
|
||||
* 1.3 Added new interface search API.
|
||||
* 1.4 Added VSP listener and user message API.
|
||||
* 1.8 Added VP hooks to SH-legacy.
|
||||
* 1.8 Backported SH VP hooks and various "new API" calls.
|
||||
*/
|
||||
|
||||
#endif //_INCLUDE_ISMM_API_H
|
||||
|
@ -316,6 +316,20 @@ public:
|
||||
virtual void OnVSPListening(IServerPluginCallbacks *iface)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod:Source knows that a specific ConCommandBase is
|
||||
* about to be unregistered. This is only called for ConCommandBases
|
||||
* registered by Metamod:Source plugins.
|
||||
*
|
||||
* This is only invoked on Metamod:Source 1.8 or higher (PLAPI_VERSION >= 11).
|
||||
*
|
||||
* @param plugin Plugin owning the ConCommandBase.
|
||||
* @param base ConCommandBase that is being unlinked.
|
||||
*/
|
||||
virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *base)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#define PL_EXPOSURE CreateInterface
|
||||
|
@ -67,6 +67,7 @@ static const char GAMEINFO_PATH[] = "|gameinfo_path|";
|
||||
IFileSystem *baseFs = NULL;
|
||||
bool g_bLevelChanged = false;
|
||||
IServerPluginCallbacks *g_pRealVspCallbacks = &g_VspListener;
|
||||
unsigned int g_vsp_version = 0;
|
||||
|
||||
#define ITER_EVENT(evn, args) \
|
||||
CPluginManager::CPlugin *pl; \
|
||||
@ -148,6 +149,8 @@ CreateInterface(const char *iface, int *ret)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_vsp_version = vsp_version;
|
||||
|
||||
return g_pRealVspCallbacks;
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,8 @@ extern int g_GameDllVersion;
|
||||
extern bool g_bGameInit;
|
||||
extern bool g_bLevelChanged;
|
||||
|
||||
extern unsigned int g_vsp_version;
|
||||
|
||||
void UnloadMetamod(bool shutting_down);
|
||||
|
||||
void LoadAsGameDLL(const gamedll_bridge_info *info);
|
||||
|
@ -84,6 +84,7 @@ class VspBridge : public IVspBridge
|
||||
|
||||
g_bIsBridgedAsVsp = true;
|
||||
g_pRealVspCallbacks = info->vsp_callbacks;
|
||||
g_vsp_version = info->vsp_version;
|
||||
|
||||
g_PluginMngr.SetVSPAsLoaded();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user