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");
|
||||
|
||||
CVector<SMPlugin *> plugins;
|
||||
scripts->ListPlugins(&plugins);
|
||||
for (size_t i = 0; i < plugins.size(); i++)
|
||||
AutoPluginList plugins(scripts);
|
||||
for (size_t i = 0; i < plugins->size(); i++)
|
||||
{
|
||||
SMPlugin *plugin = plugins[i];
|
||||
SMPlugin *plugin = plugins->at(i);
|
||||
unsigned int num = plugin->GetConfigCount();
|
||||
bool can_create = true;
|
||||
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 start = 0;
|
||||
|
||||
CVector<IExtension *> extensions;
|
||||
extsys->ListExtensions(&extensions);
|
||||
|
||||
if (!extensions.size())
|
||||
AutoExtensionList extensions(extsys);
|
||||
if (!extensions->size())
|
||||
{
|
||||
ClientConsolePrint(player->GetEdict(), "[SM] No extensions found.");
|
||||
return;
|
||||
@ -797,13 +795,10 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||
start = atoi(args.Arg(2));
|
||||
}
|
||||
|
||||
SourceHook::CVector<IExtension *>::iterator iter;
|
||||
|
||||
for (iter = extensions.begin();
|
||||
iter != extensions.end();
|
||||
iter++)
|
||||
size_t i = 0;
|
||||
for (; i < extensions->size(); i++)
|
||||
{
|
||||
IExtension *ext = (*iter);
|
||||
IExtension *ext = extensions->at(i);
|
||||
|
||||
char error[255];
|
||||
if (!ext->IsRunning(error, sizeof(error)))
|
||||
@ -850,16 +845,16 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||
ClientConsolePrint(player->GetEdict(), "%s", buffer);
|
||||
}
|
||||
|
||||
for (; iter != extensions.end(); iter++)
|
||||
for (; i < extensions->size(); i++)
|
||||
{
|
||||
char error[255];
|
||||
if ((*iter)->IsRunning(error, sizeof(error)))
|
||||
if (extensions->at(i)->IsRunning(error, sizeof(error)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iter != extensions.end())
|
||||
if (i < extensions->size())
|
||||
{
|
||||
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();
|
||||
unsigned int start = 0;
|
||||
|
||||
CVector<SMPlugin *> plugins;
|
||||
scripts->ListPlugins(&plugins);
|
||||
|
||||
if (!plugins.size())
|
||||
AutoPluginList plugins(scripts);
|
||||
if (!plugins->size())
|
||||
{
|
||||
ClientConsolePrint(e, "[SM] No plugins found.");
|
||||
return;
|
||||
@ -888,10 +881,10 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
||||
|
||||
SourceHook::List<SMPlugin *> m_FailList;
|
||||
|
||||
CVector<SMPlugin *>::iterator iter = plugins.begin();
|
||||
for (; iter != plugins.end(); iter++)
|
||||
size_t i = 0;
|
||||
for (; i < plugins->size(); i++)
|
||||
{
|
||||
SMPlugin *pl = *iter;
|
||||
SMPlugin *pl = plugins->at(i);
|
||||
|
||||
if (pl->GetStatus() != Plugin_Running)
|
||||
{
|
||||
@ -929,16 +922,16 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we actually have more plugins? */
|
||||
if (iter != plugins.end())
|
||||
if (i < plugins->size())
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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)
|
||||
|
@ -174,7 +174,8 @@ public:
|
||||
bool LibraryExists(const char *library);
|
||||
void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
|
||||
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:
|
||||
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
||||
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));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void CPluginManager::FreePluginList(const CVector<SMPlugin *> *list)
|
||||
{
|
||||
delete const_cast<CVector<SMPlugin *> *>(list);
|
||||
}
|
||||
|
||||
class OldPluginAPI : public IPluginManager
|
||||
|
@ -325,7 +325,8 @@ public: //IScriptManager
|
||||
SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *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
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModShutdown();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* vim: set ts=4 sw=4 tw=99 noet:
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* 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
|
||||
* This is to prevent mismatching core/logic binaries
|
||||
*/
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 19)
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 20)
|
||||
|
||||
#if defined SM_LOGIC
|
||||
class IVEngineServer
|
||||
@ -141,7 +141,8 @@ public:
|
||||
virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
|
||||
virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 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;
|
||||
};
|
||||
|
||||
@ -157,7 +158,48 @@ public:
|
||||
virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
|
||||
virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 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;
|
||||
|
Loading…
Reference in New Issue
Block a user