Don't allocate/delete across static CRTs (no bug, irc r=fyren+psychonic).
This commit is contained in:
parent
4a0a509dd8
commit
9b5ca124ab
@ -545,11 +545,10 @@ void SM_ExecuteAllConfigs()
|
|||||||
|
|
||||||
engine->ServerCommand("exec sourcemod/sourcemod.cfg\n");
|
engine->ServerCommand("exec sourcemod/sourcemod.cfg\n");
|
||||||
|
|
||||||
CVector<SMPlugin *> plugins;
|
AutoPluginList plugins(scripts);
|
||||||
scripts->ListPlugins(&plugins);
|
for (size_t i = 0; i < plugins->size(); i++)
|
||||||
for (size_t i = 0; i < plugins.size(); i++)
|
|
||||||
{
|
{
|
||||||
SMPlugin *plugin = plugins[i];
|
SMPlugin *plugin = plugins->at(i);
|
||||||
unsigned int num = plugin->GetConfigCount();
|
unsigned int num = plugin->GetConfigCount();
|
||||||
bool can_create = true;
|
bool can_create = true;
|
||||||
for (unsigned int i=0; i<num; i++)
|
for (unsigned int i=0; i<num; i++)
|
||||||
|
@ -783,10 +783,8 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
|||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
unsigned int start = 0;
|
unsigned int start = 0;
|
||||||
|
|
||||||
CVector<IExtension *> extensions;
|
AutoExtensionList extensions(extsys);
|
||||||
extsys->ListExtensions(&extensions);
|
if (!extensions->size())
|
||||||
|
|
||||||
if (!extensions.size())
|
|
||||||
{
|
{
|
||||||
ClientConsolePrint(player->GetEdict(), "[SM] No extensions found.");
|
ClientConsolePrint(player->GetEdict(), "[SM] No extensions found.");
|
||||||
return;
|
return;
|
||||||
@ -797,13 +795,10 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
|||||||
start = atoi(args.Arg(2));
|
start = atoi(args.Arg(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceHook::CVector<IExtension *>::iterator iter;
|
size_t i = 0;
|
||||||
|
for (; i < extensions->size(); i++)
|
||||||
for (iter = extensions.begin();
|
|
||||||
iter != extensions.end();
|
|
||||||
iter++)
|
|
||||||
{
|
{
|
||||||
IExtension *ext = (*iter);
|
IExtension *ext = extensions->at(i);
|
||||||
|
|
||||||
char error[255];
|
char error[255];
|
||||||
if (!ext->IsRunning(error, sizeof(error)))
|
if (!ext->IsRunning(error, sizeof(error)))
|
||||||
@ -850,16 +845,16 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
|||||||
ClientConsolePrint(player->GetEdict(), "%s", buffer);
|
ClientConsolePrint(player->GetEdict(), "%s", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; iter != extensions.end(); iter++)
|
for (; i < extensions->size(); i++)
|
||||||
{
|
{
|
||||||
char error[255];
|
char error[255];
|
||||||
if ((*iter)->IsRunning(error, sizeof(error)))
|
if (extensions->at(i)->IsRunning(error, sizeof(error)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iter != extensions.end())
|
if (i < extensions->size())
|
||||||
{
|
{
|
||||||
ClientConsolePrint(player->GetEdict(), "To see more, type \"sm exts %d\"", id);
|
ClientConsolePrint(player->GetEdict(), "To see more, type \"sm exts %d\"", id);
|
||||||
}
|
}
|
||||||
@ -872,10 +867,8 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
|||||||
edict_t *e = player->GetEdict();
|
edict_t *e = player->GetEdict();
|
||||||
unsigned int start = 0;
|
unsigned int start = 0;
|
||||||
|
|
||||||
CVector<SMPlugin *> plugins;
|
AutoPluginList plugins(scripts);
|
||||||
scripts->ListPlugins(&plugins);
|
if (!plugins->size())
|
||||||
|
|
||||||
if (!plugins.size())
|
|
||||||
{
|
{
|
||||||
ClientConsolePrint(e, "[SM] No plugins found.");
|
ClientConsolePrint(e, "[SM] No plugins found.");
|
||||||
return;
|
return;
|
||||||
@ -888,10 +881,10 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
|||||||
|
|
||||||
SourceHook::List<SMPlugin *> m_FailList;
|
SourceHook::List<SMPlugin *> m_FailList;
|
||||||
|
|
||||||
CVector<SMPlugin *>::iterator iter = plugins.begin();
|
size_t i = 0;
|
||||||
for (; iter != plugins.end(); iter++)
|
for (; i < plugins->size(); i++)
|
||||||
{
|
{
|
||||||
SMPlugin *pl = *iter;
|
SMPlugin *pl = plugins->at(i);
|
||||||
|
|
||||||
if (pl->GetStatus() != Plugin_Running)
|
if (pl->GetStatus() != Plugin_Running)
|
||||||
{
|
{
|
||||||
@ -929,16 +922,16 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* See if we can get more plugins */
|
/* See if we can get more plugins */
|
||||||
for (; iter != plugins.end(); iter++)
|
for (; i < plugins->size(); i++)
|
||||||
{
|
{
|
||||||
if ((*iter)->GetStatus() == Plugin_Running)
|
if (plugins->at(i)->GetStatus() == Plugin_Running)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do we actually have more plugins? */
|
/* Do we actually have more plugins? */
|
||||||
if (iter != plugins.end())
|
if (i < plugins->size())
|
||||||
{
|
{
|
||||||
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
|
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
|
||||||
}
|
}
|
||||||
|
@ -1361,12 +1361,17 @@ void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CExtensionManager::ListExtensions(CVector<IExtension *> *list)
|
const CVector<IExtension *> *CExtensionManager::ListExtensions()
|
||||||
{
|
{
|
||||||
|
CVector<IExtension *> *list = new CVector<IExtension *>();
|
||||||
for (List<CExtension *>::iterator iter = m_Libs.begin(); iter != m_Libs.end(); iter++)
|
for (List<CExtension *>::iterator iter = m_Libs.begin(); iter != m_Libs.end(); iter++)
|
||||||
{
|
|
||||||
list->push_back(*iter);
|
list->push_back(*iter);
|
||||||
}
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CExtensionManager::FreeExtensionList(const CVector<IExtension *> *list)
|
||||||
|
{
|
||||||
|
delete const_cast<CVector<IExtension *> *>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLocalExtension::IsSameFile(const char *file)
|
bool CLocalExtension::IsSameFile(const char *file)
|
||||||
|
@ -174,7 +174,8 @@ public:
|
|||||||
bool LibraryExists(const char *library);
|
bool LibraryExists(const char *library);
|
||||||
void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
|
void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface);
|
void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface);
|
||||||
void ListExtensions(CVector<IExtension *> *list);
|
const CVector<IExtension *> *ListExtensions();
|
||||||
|
void FreeExtensionList(const CVector<IExtension *> *list);
|
||||||
public:
|
public:
|
||||||
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
@ -2627,14 +2627,19 @@ void CPluginManager::SyncMaxClients(int max_clients)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginManager::ListPlugins(CVector<SMPlugin *> *list)
|
const CVector<SMPlugin *> *CPluginManager::ListPlugins()
|
||||||
{
|
{
|
||||||
List<CPlugin *>::iterator iter;
|
CVector<SMPlugin *> *list = new CVector<SMPlugin *>();
|
||||||
|
|
||||||
for (iter = m_plugins.begin(); iter != m_plugins.end(); iter++)
|
for (List<CPlugin *>::iterator iter = m_plugins.begin(); iter != m_plugins.end(); iter++)
|
||||||
{
|
|
||||||
list->push_back((*iter));
|
list->push_back((*iter));
|
||||||
}
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPluginManager::FreePluginList(const CVector<SMPlugin *> *list)
|
||||||
|
{
|
||||||
|
delete const_cast<CVector<SMPlugin *> *>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
class OldPluginAPI : public IPluginManager
|
class OldPluginAPI : public IPluginManager
|
||||||
|
@ -325,7 +325,8 @@ public: //IScriptManager
|
|||||||
SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) {
|
SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) {
|
||||||
return static_cast<SMPlugin *>(PluginFromHandle(hndl, errp));
|
return static_cast<SMPlugin *>(PluginFromHandle(hndl, errp));
|
||||||
}
|
}
|
||||||
void ListPlugins(CVector<SMPlugin *> *plugins);
|
const CVector<SMPlugin *> *ListPlugins();
|
||||||
|
void FreePluginList(const CVector<SMPlugin *> *plugins);
|
||||||
public: //SMGlobalClass
|
public: //SMGlobalClass
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModShutdown();
|
void OnSourceModShutdown();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet:
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
@ -49,7 +49,7 @@ using namespace SourceHook;
|
|||||||
* Add 1 to the RHS of this expression to bump the intercom file
|
* Add 1 to the RHS of this expression to bump the intercom file
|
||||||
* This is to prevent mismatching core/logic binaries
|
* This is to prevent mismatching core/logic binaries
|
||||||
*/
|
*/
|
||||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 19)
|
#define SM_LOGIC_MAGIC (0x0F47C0DE - 20)
|
||||||
|
|
||||||
#if defined SM_LOGIC
|
#if defined SM_LOGIC
|
||||||
class IVEngineServer
|
class IVEngineServer
|
||||||
@ -141,7 +141,8 @@ public:
|
|||||||
virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
|
virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
|
||||||
virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0;
|
virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0;
|
||||||
virtual bool UnloadPlugin(IPlugin *plugin) = 0;
|
virtual bool UnloadPlugin(IPlugin *plugin) = 0;
|
||||||
virtual void ListPlugins(CVector<SMPlugin *> *plugins) = 0;
|
virtual const CVector<SMPlugin *> *ListPlugins() = 0;
|
||||||
|
virtual void FreePluginList(const CVector<SMPlugin *> *list) = 0;
|
||||||
virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0;
|
virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,7 +158,48 @@ public:
|
|||||||
virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
|
virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
|
||||||
virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0;
|
virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0;
|
||||||
virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0;
|
virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0;
|
||||||
virtual void ListExtensions(CVector<IExtension *> *list) = 0;
|
virtual const CVector<IExtension *> *ListExtensions() = 0;
|
||||||
|
virtual void FreeExtensionList(const CVector<IExtension *> *list) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AutoPluginList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoPluginList(IScriptManager *scripts)
|
||||||
|
: scripts_(scripts), list_(scripts->ListPlugins())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~AutoPluginList()
|
||||||
|
{
|
||||||
|
scripts_->FreePluginList(list_);
|
||||||
|
}
|
||||||
|
const CVector<SMPlugin *> *operator ->()
|
||||||
|
{
|
||||||
|
return list_;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
IScriptManager *scripts_;
|
||||||
|
const CVector<SMPlugin *> *list_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AutoExtensionList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoExtensionList(IExtensionSys *extensions)
|
||||||
|
: extensions_(extensions), list_(extensions_->ListExtensions())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~AutoExtensionList()
|
||||||
|
{
|
||||||
|
extensions_->FreeExtensionList(list_);
|
||||||
|
}
|
||||||
|
const CVector<IExtension *> *operator ->()
|
||||||
|
{
|
||||||
|
return list_;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
IExtensionSys *extensions_;
|
||||||
|
const CVector<IExtension *> *list_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCommand;
|
class CCommand;
|
||||||
|
Loading…
Reference in New Issue
Block a user