Replace ke::LinkedList with std::list.
This commit is contained in:
parent
d5d4d78023
commit
80acff8d7d
@ -45,7 +45,7 @@ using namespace ke;
|
||||
|
||||
ConCmdManager g_ConCmds;
|
||||
|
||||
typedef ke::LinkedList<CmdHook *> PluginHookList;
|
||||
typedef std::list<CmdHook *> PluginHookList;
|
||||
void RegisterInPlugin(CmdHook *hook);
|
||||
|
||||
ConCmdManager::ConCmdManager()
|
||||
@ -381,7 +381,7 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
|
||||
pHook->admin->eflags = pHook->admin->flags;
|
||||
pInfo->eflags = pHook->admin->eflags;
|
||||
|
||||
cmdgroup->hooks.append(pHook);
|
||||
cmdgroup->hooks.push_back(pHook);
|
||||
pInfo->hooks.append(pHook);
|
||||
RegisterInPlugin(pHook);
|
||||
return true;
|
||||
@ -426,13 +426,13 @@ void RegisterInPlugin(CmdHook *hook)
|
||||
const char *cmd = (*iter)->info->pCmd->GetName();
|
||||
if (strcmp(orig, cmd) < 0)
|
||||
{
|
||||
pList->insertBefore(iter, hook);
|
||||
pList->emplace(iter, hook);
|
||||
return;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
pList->append(hook);
|
||||
pList->emplace_back(hook);
|
||||
}
|
||||
|
||||
void ConCmdManager::AddToCmdList(ConCmdInfo *info)
|
||||
|
@ -32,8 +32,14 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
|
||||
#define _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include <am-inlinelist.h>
|
||||
#include <am-refcounting.h>
|
||||
#include <am-utility.h>
|
||||
#include <sm_stringhashmap.h>
|
||||
|
||||
#include "sm_globals.h"
|
||||
#include "sourcemm_api.h"
|
||||
#include <IForwardSys.h>
|
||||
@ -43,11 +49,6 @@
|
||||
#include <IAdminSystem.h>
|
||||
#include "concmd_cleaner.h"
|
||||
#include "GameHooks.h"
|
||||
#include <sm_stringhashmap.h>
|
||||
#include <am-utility.h>
|
||||
#include <am-inlinelist.h>
|
||||
#include <am-linkedlist.h>
|
||||
#include <am-refcounting.h>
|
||||
|
||||
using namespace SourceHook;
|
||||
|
||||
@ -56,7 +57,7 @@ struct ConCmdInfo;
|
||||
|
||||
struct CommandGroup : public ke::Refcounted<CommandGroup>
|
||||
{
|
||||
ke::LinkedList<CmdHook *> hooks;
|
||||
std::list<CmdHook *> hooks;
|
||||
};
|
||||
|
||||
struct AdminCmdInfo
|
||||
|
@ -61,7 +61,7 @@ IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned
|
||||
{
|
||||
scripts->AddFunctionsToForward(name, fwd);
|
||||
|
||||
m_managed.append(fwd);
|
||||
m_managed.push_back(fwd);
|
||||
}
|
||||
|
||||
return fwd;
|
||||
@ -78,7 +78,7 @@ IChangeableForward *CForwardManager::CreateForwardEx(const char *name, ExecType
|
||||
|
||||
if (fwd)
|
||||
{
|
||||
m_unmanaged.append(fwd);
|
||||
m_unmanaged.push_back(fwd);
|
||||
}
|
||||
|
||||
return fwd;
|
||||
@ -751,9 +751,9 @@ bool CForward::AddFunction(IPluginFunction *func)
|
||||
return false;
|
||||
|
||||
if (func->IsRunnable())
|
||||
m_functions.append(func);
|
||||
m_functions.push_back(func);
|
||||
else
|
||||
m_paused.append(func);
|
||||
m_paused.push_back(func);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -780,7 +780,7 @@ const char *CForward::GetForwardName()
|
||||
|
||||
unsigned int CForward::GetFunctionCount()
|
||||
{
|
||||
return m_functions.length();
|
||||
return m_functions.size();
|
||||
}
|
||||
|
||||
ExecType CForward::GetExecType()
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include <sp_vm_types.h>
|
||||
#include <sh_list.h>
|
||||
#include <am-linkedlist.h>
|
||||
#include <am-vector.h>
|
||||
#include "common_logic.h"
|
||||
#include "Native.h"
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "Logger.h"
|
||||
#include "frame_tasks.h"
|
||||
#include <amtl/am-string.h>
|
||||
#include <amtl/am-linkedlist.h>
|
||||
#include <bridge/include/IVEngineServerBridge.h>
|
||||
#include <bridge/include/CoreProvider.h>
|
||||
|
||||
@ -790,7 +789,7 @@ void CPlugin::BindFakeNativesTo(CPlugin *other)
|
||||
CPluginManager::CPluginIterator::CPluginIterator(ReentrantList<CPlugin *>& in)
|
||||
{
|
||||
for (PluginIter iter(in); !iter.done(); iter.next())
|
||||
mylist.append(*iter);
|
||||
mylist.push_back(*iter);
|
||||
current = mylist.begin();
|
||||
g_PluginSys.AddPluginsListener(this);
|
||||
}
|
||||
@ -1033,7 +1032,7 @@ void CPluginManager::LoadAutoPlugin(const char *plugin)
|
||||
|
||||
void CPluginManager::AddPlugin(CPlugin *pPlugin)
|
||||
{
|
||||
m_plugins.append(pPlugin);
|
||||
m_plugins.push_back(pPlugin);
|
||||
m_LoadLookup.insert(pPlugin->GetFilename(), pPlugin);
|
||||
|
||||
pPlugin->SetRegistered();
|
||||
@ -1536,12 +1535,12 @@ CPlugin *CPluginManager::GetPluginByCtx(const sp_context_t *ctx)
|
||||
|
||||
unsigned int CPluginManager::GetPluginCount()
|
||||
{
|
||||
return m_plugins.length();
|
||||
return m_plugins.size();
|
||||
}
|
||||
|
||||
void CPluginManager::AddPluginsListener(IPluginsListener *listener)
|
||||
{
|
||||
m_listeners.append(listener);
|
||||
m_listeners.push_back(listener);
|
||||
}
|
||||
|
||||
void CPluginManager::RemovePluginsListener(IPluginsListener *listener)
|
||||
@ -1715,7 +1714,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
|
||||
rootmenu->ConsolePrint("[SM] Listing %d plugin%s:", plnum, (plnum > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
ke::LinkedList<CPlugin *> fail_list;
|
||||
std::list<CPlugin *> fail_list;
|
||||
|
||||
for (PluginIter iter(m_plugins); !iter.done(); iter.next(), id++) {
|
||||
CPlugin *pl = (*iter);
|
||||
@ -1727,7 +1726,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
|
||||
len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d <%s>", plpadding, id, GetStatusText(pl->GetDisplayStatus()));
|
||||
|
||||
/* Plugin has failed to load. */
|
||||
fail_list.append(pl);
|
||||
fail_list.push_back(pl);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2351,7 +2350,7 @@ public:
|
||||
{
|
||||
ke::RefPtr<PluginsListenerV1Wrapper> wrapper = new PluginsListenerV1Wrapper(listener);
|
||||
|
||||
v1_wrappers_.append(wrapper);
|
||||
v1_wrappers_.push_back(wrapper);
|
||||
g_PluginSys.AddPluginsListener(wrapper);
|
||||
}
|
||||
|
||||
|
@ -320,8 +320,8 @@ public:
|
||||
void Release();
|
||||
void OnPluginDestroyed(IPlugin *plugin) override;
|
||||
private:
|
||||
ke::LinkedList<CPlugin *> mylist;
|
||||
ke::LinkedList<CPlugin *>::iterator current;
|
||||
std::list<CPlugin *> mylist;
|
||||
std::list<CPlugin *>::iterator current;
|
||||
};
|
||||
friend class CPluginManager::CPluginIterator;
|
||||
public: //IScriptManager
|
||||
@ -476,7 +476,7 @@ private:
|
||||
private:
|
||||
ReentrantList<IPluginsListener *> m_listeners;
|
||||
ReentrantList<CPlugin *> m_plugins;
|
||||
ke::LinkedList<CPluginIterator *> m_iterators;
|
||||
std::list<CPluginIterator *> m_iterators;
|
||||
|
||||
typedef decltype(m_listeners)::iterator ListenerIter;
|
||||
typedef decltype(m_plugins)::iterator PluginIter;
|
||||
|
@ -27,14 +27,15 @@
|
||||
#ifndef _include_sourcemod_reentrant_iterator_h_
|
||||
#define _include_sourcemod_reentrant_iterator_h_
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#include <amtl/am-linkedlist.h>
|
||||
#include <amtl/am-function.h>
|
||||
|
||||
namespace SourceMod {
|
||||
|
||||
// ReentrantList is a wrapper around a LinkedList, with special attention twoard
|
||||
// ReentrantList is a wrapper around a std::list, with special attention twoard
|
||||
// reentrancy. The list may be mutated during iteration as long as its iterator
|
||||
// protocol is obeyed: iterators may only be used on the stack in a LIFO manner,
|
||||
// and it is illegal to request access to an iterator's item after the list has
|
||||
@ -43,16 +44,15 @@ namespace SourceMod {
|
||||
// We guard against this using assertions. If an item in a list is removed, and
|
||||
// this affects any active iterators, those iterators cannot be used until their
|
||||
// next() function is called.
|
||||
template <typename T, class AllocPolicy = ke::SystemAllocatorPolicy>
|
||||
class ReentrantList : public ke::LinkedList<T, AllocPolicy>
|
||||
template <typename T>
|
||||
class ReentrantList : public std::list<T>
|
||||
{
|
||||
typedef typename ke::LinkedList<T> BaseType;
|
||||
typedef typename ke::LinkedList<T>::iterator BaseTypeIter;
|
||||
typedef typename std::list<T> BaseType;
|
||||
typedef typename std::list<T>::iterator BaseTypeIter;
|
||||
|
||||
public:
|
||||
ReentrantList(AllocPolicy ap = AllocPolicy())
|
||||
: ke::LinkedList<T, AllocPolicy>(ap),
|
||||
top_(nullptr)
|
||||
ReentrantList()
|
||||
: top_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -150,12 +150,12 @@ public:
|
||||
|
||||
template <typename U>
|
||||
void insertBefore(iterator& where, U &&obj) {
|
||||
BaseType::insertBefore(where.impl_, std::forward<U>(obj));
|
||||
BaseType::insert(where.impl_, std::forward<U>(obj));
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool contains(const U &obj) {
|
||||
return BaseType::find(obj) != BaseType::end();
|
||||
return std::find(BaseType::begin(), BaseType::end(), obj) != BaseType::end();
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user