diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 3c1dc111..430c88e7 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -29,6 +29,8 @@ * Version: $Id$ */ +#include + #include #include "ChatTriggers.h" #include "sm_stringutil.h" @@ -64,7 +66,7 @@ ChatTriggers::~ChatTriggers() void ChatTriggers::SetChatTrigger(ChatTriggerType type, const char *value) { - ke::AutoPtr filtered(new char[strlen(value) + 1]); + std::unique_ptr filtered(new char[strlen(value) + 1]); const char *src = value; char *dest = filtered.get(); diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index a3c266c0..a5da1ca7 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -30,15 +30,16 @@ */ #include "ConCmdManager.h" -#include "sm_stringutil.h" -#include "PlayerManager.h" -#include "HalfLife2.h" -#include "ChatTriggers.h" -#include "logic_bridge.h" -#include "sourcemod.h" -#include "provider.h" -#include "command_args.h" + #include +#include "ChatTriggers.h" +#include "HalfLife2.h" +#include "PlayerManager.h" +#include "command_args.h" +#include "logic_bridge.h" +#include "provider.h" +#include "sm_stringutil.h" +#include "sourcemod.h" using namespace ke; @@ -181,7 +182,7 @@ ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int if (hook->type == CmdHook::Server || !hook->pf->IsRunnable()) continue; - if (hook->admin && !CheckAccess(client, cmd, hook->admin)) + if (hook->admin && !CheckAccess(client, cmd, hook->admin.get())) { if (result < Pl_Handled) result = Pl_Handled; @@ -271,7 +272,7 @@ bool ConCmdManager::InternalDispatch(int client, const ICommandArgs *args) } else { // Check admin rights if needed. realClient isn't needed since we // should bypass admin checks if client == 0 anyway. - if (client && hook->admin && !CheckAccess(client, cmd, hook->admin)) + if (client && hook->admin && !CheckAccess(client, cmd, hook->admin.get())) { if (result < Pl_Handled) result = Pl_Handled; @@ -360,7 +361,7 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction, RefPtr cmdgroup = i->value; CmdHook *pHook = new CmdHook(CmdHook::Client, pInfo, pFunction, description); - pHook->admin = new AdminCmdInfo(cmdgroup, adminflags); + pHook->admin = std::make_unique(cmdgroup, adminflags); /* First get the command group override, if any */ bool override = adminsys->GetCommandOverride(group, diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index 64d84e13..6c805898 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -32,6 +32,8 @@ #ifndef _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_ #define _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_ +#include + #include "sm_globals.h" #include "sourcemm_api.h" #include @@ -41,7 +43,6 @@ #include #include "concmd_cleaner.h" #include "GameHooks.h" -#include #include #include #include @@ -90,7 +91,7 @@ struct CmdHook : public ke::InlineListNode ConCmdInfo *info; IPluginFunction *pf; /* function hook */ ke::AString helptext; /* help text */ - ke::AutoPtr admin; /* admin requirements, if any */ + std::unique_ptr admin; /* admin requirements, if any */ }; typedef ke::InlineList CmdHookList; diff --git a/core/ConsoleDetours.cpp b/core/ConsoleDetours.cpp index 1e445458..69badc43 100644 --- a/core/ConsoleDetours.cpp +++ b/core/ConsoleDetours.cpp @@ -307,7 +307,7 @@ bool ConsoleDetours::AddListener(IPluginFunction *fun, const char *command) } else { - ke::AutoPtr str(UTIL_ToLowerCase(command)); + std::unique_ptr str(UTIL_ToLowerCase(command)); IChangeableForward *forward; if (!m_Listeners.retrieve(str.get(), &forward)) { @@ -329,7 +329,7 @@ bool ConsoleDetours::RemoveListener(IPluginFunction *fun, const char *command) } else { - ke::AutoPtr str(UTIL_ToLowerCase(command)); + std::unique_ptr str(UTIL_ToLowerCase(command)); IChangeableForward *forward; if (!m_Listeners.retrieve(str.get(), &forward)) return false; diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index 415029c1..398c2e0a 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -637,7 +637,7 @@ bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw) item.info = info; if (draw.display) - item.display = new ke::AString(draw.display); + item.display = std::make_unique(draw.display); item.style = draw.style; m_items.append(ke::Move(item)); @@ -658,7 +658,7 @@ bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDr CItem item; item.info = info; if (draw.display) - item.display = new ke::AString(draw.display); + item.display = std::make_unique(draw.display); item.style = draw.style; m_items.insert(position, ke::Move(item)); diff --git a/core/MenuStyle_Base.h b/core/MenuStyle_Base.h index e9d83ebf..ea431de8 100644 --- a/core/MenuStyle_Base.h +++ b/core/MenuStyle_Base.h @@ -32,9 +32,10 @@ #ifndef _INCLUDE_MENUSTYLE_BASE_H #define _INCLUDE_MENUSTYLE_BASE_H +#include + #include #include -#include #include #include #include "sm_fastlink.h" @@ -67,7 +68,7 @@ public: public: ke::AString info; - ke::AutoPtr display; + std::unique_ptr display; unsigned int style; unsigned int access; diff --git a/core/logic/CDataPack.cpp b/core/logic/CDataPack.cpp index af53c52d..65666b39 100644 --- a/core/logic/CDataPack.cpp +++ b/core/logic/CDataPack.cpp @@ -31,8 +31,10 @@ #include #include + +#include + #include "CDataPack.h" -#include CDataPack::CDataPack() { @@ -44,14 +46,14 @@ CDataPack::~CDataPack() Initialize(); } -static ke::Vector> sDataPackCache; +static ke::Vector> sDataPackCache; CDataPack *CDataPack::New() { if (sDataPackCache.empty()) return new CDataPack(); - CDataPack *pack = sDataPackCache.back().take(); + CDataPack *pack = sDataPackCache.back().release(); sDataPackCache.pop(); pack->Initialize(); return pack; diff --git a/core/logic/ExtensionSys.cpp b/core/logic/ExtensionSys.cpp index 7559172c..8f3f05d7 100644 --- a/core/logic/ExtensionSys.cpp +++ b/core/logic/ExtensionSys.cpp @@ -30,6 +30,9 @@ */ #include + +#include + #include "ExtensionSys.h" #include #include @@ -496,7 +499,7 @@ void CExtensionManager::TryAutoload() g_pSM->BuildPath(Path_SM, path, sizeof(path), "extensions"); - ke::AutoPtr pDir(libsys->OpenDirectory(path)); + std::unique_ptr pDir(libsys->OpenDirectory(path)); if (!pDir) return; diff --git a/core/logic/HandleSys.cpp b/core/logic/HandleSys.cpp index 10c9791c..594bcbf9 100644 --- a/core/logic/HandleSys.cpp +++ b/core/logic/HandleSys.cpp @@ -206,7 +206,7 @@ HandleType_t HandleSystem::CreateType(const char *name, pType->dispatch = dispatch; if (name && name[0] != '\0') { - pType->name = new ke::AString(name); + pType->name = std::make_unique(name); m_TypeLookup.insert(name, pType); } diff --git a/core/logic/HandleSys.h b/core/logic/HandleSys.h index 4aace757..c4480c3b 100644 --- a/core/logic/HandleSys.h +++ b/core/logic/HandleSys.h @@ -32,12 +32,14 @@ #ifndef _INCLUDE_SOURCEMOD_HANDLESYSTEM_H_ #define _INCLUDE_SOURCEMOD_HANDLESYSTEM_H_ -#include #include -#include -#include + +#include + #include #include +#include +#include #include "common_logic.h" #define HANDLESYS_MAX_HANDLES (1<<15) @@ -105,7 +107,7 @@ struct QHandleType TypeAccess typeSec; HandleAccess hndlSec; unsigned int opened; - ke::AutoPtr name; + std::unique_ptr name; static inline bool matches(const char *key, const QHandleType *type) { diff --git a/core/logic/Native.h b/core/logic/Native.h index 6c7ff188..11076f65 100644 --- a/core/logic/Native.h +++ b/core/logic/Native.h @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -64,19 +63,19 @@ struct Native : public ke::Refcounted Native(CNativeOwner *owner, const sp_nativeinfo_t *native) : owner(owner), native(native), - fake(NULL) + fake(nullptr) { } Native(CNativeOwner *owner, FakeNative *fake) : owner(owner), - native(NULL), + native(nullptr), fake(fake) { } CNativeOwner *owner; const sp_nativeinfo_t *native; - ke::AutoPtr fake; + std::unique_ptr fake; SPVM_NATIVE_FUNC func() const { diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 9569c5b3..b432824e 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -79,7 +79,7 @@ CPlugin::CPlugin(const char *file) memset(&m_info, 0, sizeof(m_info)); - m_pPhrases = g_Translator.CreatePhraseCollection(); + m_pPhrases.reset(g_Translator.CreatePhraseCollection()); } CPlugin::~CPlugin() @@ -227,7 +227,7 @@ bool CPlugin::SetProperty(const char *prop, void *ptr) IPluginRuntime *CPlugin::GetRuntime() { - return m_pRuntime; + return m_pRuntime.get(); } void CPlugin::EvictWithError(PluginStatus status, const char *error_fmt, ...) @@ -483,7 +483,7 @@ bool CPlugin::TryCompile() g_pSM->BuildPath(Path_SM, fullpath, sizeof(fullpath), "plugins/%s", m_filename); char loadmsg[255]; - m_pRuntime = g_pSourcePawn2->LoadBinaryFromFile(fullpath, loadmsg, sizeof(loadmsg)); + m_pRuntime.reset(g_pSourcePawn2->LoadBinaryFromFile(fullpath, loadmsg, sizeof(loadmsg))); if (!m_pRuntime) { EvictWithError(Plugin_BadLoad, "Unable to load plugin (%s)", loadmsg); return false; @@ -658,7 +658,7 @@ time_t CPlugin::GetFileTimeStamp() IPhraseCollection *CPlugin::GetPhrases() { - return m_pPhrases; + return m_pPhrases.get(); } void CPlugin::DependencyDropped(CPlugin *pOwner) diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index 7087ced9..dfd8eca0 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -32,9 +32,12 @@ #ifndef _INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_ #define _INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_ -#include #include #include +#include + +#include + #include #include #include @@ -267,8 +270,8 @@ private: char m_errormsg[256]; // Internal properties that must by reset if the runtime is evicted. - ke::AutoPtr m_pRuntime; - ke::AutoPtr m_pPhrases; + std::unique_ptr m_pRuntime; + std::unique_ptr m_pPhrases; IPluginContext *m_pContext; sp_pubvar_t *m_MaxClientsVar; StringHashMap m_Props; diff --git a/core/logic/ShareSys.cpp b/core/logic/ShareSys.cpp index 3b4d4589..4fd0e8da 100644 --- a/core/logic/ShareSys.cpp +++ b/core/logic/ShareSys.cpp @@ -29,13 +29,16 @@ * Version: $Id$ */ +#include + +#include + #include "ShareSys.h" #include "ExtensionSys.h" #include #include "common_logic.h" #include "PluginSys.h" #include "HandleSys.h" -#include using namespace ke; @@ -406,15 +409,15 @@ AlreadyRefed ShareSystem::AddFakeNative(IPluginFunction *pFunc, const ch if (entry) return nullptr; - AutoPtr fake(new FakeNative(name, pFunc)); + std::unique_ptr fake(new FakeNative(name, pFunc)); - fake->gate = g_pSourcePawn2->CreateFakeNative(func, fake); + fake->gate = g_pSourcePawn2->CreateFakeNative(func, fake.get()); if (!fake->gate) return nullptr; CNativeOwner *owner = g_PluginSys.GetPluginByCtx(fake->ctx->GetContext()); - entry = new Native(owner, fake.take()); + entry = new Native(owner, fake.release()); m_NtvCache.insert(name, entry); return entry.forget(); diff --git a/core/logic/smn_adt_trie.cpp b/core/logic/smn_adt_trie.cpp index 4bac0208..9c4afe16 100644 --- a/core/logic/smn_adt_trie.cpp +++ b/core/logic/smn_adt_trie.cpp @@ -30,8 +30,10 @@ */ #include + +#include + #include "common_logic.h" -#include #include #include #include @@ -182,7 +184,7 @@ struct TrieSnapshot } size_t length; - ke::AutoPtr keys; + std::unique_ptr keys; BaseStringTable strings; }; @@ -557,7 +559,7 @@ static cell_t CreateTrieSnapshot(IPluginContext *pContext, const cell_t *params) TrieSnapshot *snapshot = new TrieSnapshot; snapshot->length = pTrie->map.elements(); - snapshot->keys = ke::MakeUnique(snapshot->length); + snapshot->keys = std::make_unique(snapshot->length); size_t i = 0; for (StringHashMap::iterator iter = pTrie->map.iter(); !iter.empty(); iter.next(), i++) snapshot->keys[i] = snapshot->strings.AddString(iter->key.chars(), iter->key.length()); diff --git a/core/logic/smn_database.cpp b/core/logic/smn_database.cpp index f4e97c48..834ec864 100644 --- a/core/logic/smn_database.cpp +++ b/core/logic/smn_database.cpp @@ -29,6 +29,8 @@ * Version: $Id$ */ +#include + #include "common_logic.h" #include "Database.h" #include "ExtensionSys.h" @@ -1667,8 +1669,8 @@ private: assert(results_.length() == txn_->entries.length()); - ke::AutoPtr data = ke::MakeUnique(results_.length()); - ke::AutoPtr handles = ke::MakeUnique(results_.length()); + std::unique_ptr data = std::make_unique(results_.length()); + std::unique_ptr handles = std::make_unique(results_.length()); for (size_t i = 0; i < results_.length(); i++) { CombinedQuery *obj = new CombinedQuery(results_[i], db_); @@ -1728,7 +1730,7 @@ public: { HandleSecurity sec(ident_, g_pCoreIdent); - ke::AutoPtr data = ke::MakeUnique(txn_->entries.length()); + std::unique_ptr data = std::make_unique(txn_->entries.length()); for (size_t i = 0; i < txn_->entries.length(); i++) data[i] = txn_->entries[i].data; diff --git a/core/logic/smn_functions.cpp b/core/logic/smn_functions.cpp index 606b7855..ec8dc2c3 100644 --- a/core/logic/smn_functions.cpp +++ b/core/logic/smn_functions.cpp @@ -29,12 +29,13 @@ * Version: $Id$ */ +#include + #include "common_logic.h" #include #include #include #include -#include HandleType_t g_GlobalFwdType = 0; HandleType_t g_PrivateFwdType = 0; @@ -686,7 +687,7 @@ struct SMFrameActionData static void PawnFrameAction(void *pData) { - ke::AutoPtr frame(reinterpret_cast(pData)); + std::unique_ptr frame(reinterpret_cast(pData)); IPlugin *pPlugin = pluginsys->PluginFromHandle(frame->ownerhandle, NULL); if (!pPlugin) { diff --git a/public/amtl b/public/amtl index 8a59372d..bf8516fd 160000 --- a/public/amtl +++ b/public/amtl @@ -1 +1 @@ -Subproject commit 8a59372d1f8333ad455e03866b2aec7769cfb51a +Subproject commit bf8516fd43dd1f498e89e579ebd3b70a9041df09 diff --git a/public/sm_namehashset.h b/public/sm_namehashset.h index 26507353..0b7d0613 100644 --- a/public/sm_namehashset.h +++ b/public/sm_namehashset.h @@ -29,8 +29,6 @@ * Version: $Id$ */ -#include - #ifndef _include_sourcemod_namehashset_h_ #define _include_sourcemod_namehashset_h_ @@ -124,7 +122,7 @@ public: template bool add(Insert &i, U &&value) { - return table_.add(i, ke::Forward(value)); + return table_.add(i, std::forward(value)); } bool retrieve(const char *aKey, T *value) @@ -144,7 +142,7 @@ public: Insert i = table_.findForAdd(key); if (i.found()) return false; - return table_.add(i, ke::Forward(value)); + return table_.add(i, std::forward(value)); } bool contains(const char *aKey) diff --git a/sourcepawn b/sourcepawn index ee2b9baa..20756050 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit ee2b9baac39f1e3d1e4c81600beb6b4e1f81323e +Subproject commit 2075605089d674d70a437469800eb47a916e3c91