From 5d94f0bea863ad6bee71ddc829c32af296cc0f8b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 30 May 2020 23:06:29 -0700 Subject: [PATCH] Replace ke::Vector with std::vector. --- core/ChatTriggers.cpp | 16 +- core/ChatTriggers.h | 2 +- core/GameHooks.cpp | 2 +- core/GameHooks.h | 4 +- core/MenuStyle_Base.cpp | 20 +- core/MenuStyle_Base.h | 2 +- core/logic/CDataPack.cpp | 32 +- core/logic/CDataPack.h | 4 +- core/logic/Database.cpp | 2 +- core/logic/DatabaseConfBuilder.cpp | 2 +- core/logic/DatabaseConfBuilder.h | 6 +- core/logic/DebugReporter.cpp | 14 +- core/logic/DebugReporter.h | 2 +- core/logic/FrameIterator.cpp | 4 +- core/logic/FrameIterator.h | 2 +- core/logic/NativeOwner.cpp | 6 +- core/logic/NativeOwner.h | 4 +- core/logic/PluginSys.cpp | 6 +- core/logic/PluginSys.h | 2 +- core/logic/ProfileTools.cpp | 8 +- core/logic/ProfileTools.h | 4 +- core/logic/frame_tasks.cpp | 10 +- core/logic/smn_core.cpp | 1874 +++++++++++++------------- core/logic/smn_database.cpp | 42 +- core/logic_bridge.cpp | 2 +- core/provider.h | 2 +- extensions/clientprefs/cookie.cpp | 20 +- extensions/clientprefs/cookie.h | 4 +- extensions/clientprefs/extension.cpp | 8 +- extensions/clientprefs/extension.h | 2 +- extensions/clientprefs/natives.cpp | 14 +- extensions/cstrike/RegNatives.cpp | 4 +- extensions/cstrike/RegNatives.h | 2 +- extensions/sdkhooks/extension.cpp | 174 +-- extensions/sdkhooks/extension.h | 4 +- extensions/sdktools/hooks.cpp | 26 +- extensions/sdktools/hooks.h | 6 +- extensions/tf2/RegNatives.cpp | 4 +- extensions/tf2/RegNatives.h | 2 +- public/amtl | 2 +- sourcepawn | 2 +- 41 files changed, 1174 insertions(+), 1174 deletions(-) diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 60366cbf..f04a376b 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -137,26 +137,26 @@ void ChatTriggers::OnSourceModGameInitialized() }; if (ConCommand *say = FindCommand("say")) { - hooks_.append(sCoreProviderImpl.AddCommandHook(say, pre_hook)); - hooks_.append(sCoreProviderImpl.AddPostCommandHook(say, post_hook)); + hooks_.push_back(sCoreProviderImpl.AddCommandHook(say, pre_hook)); + hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say, post_hook)); } if (ConCommand *say_team = FindCommand("say_team")) { - hooks_.append(sCoreProviderImpl.AddCommandHook(say_team, pre_hook)); - hooks_.append(sCoreProviderImpl.AddPostCommandHook(say_team, post_hook)); + hooks_.push_back(sCoreProviderImpl.AddCommandHook(say_team, pre_hook)); + hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say_team, post_hook)); } #if SOURCE_ENGINE == SE_EPISODEONE m_bIsINS = (strcmp(g_SourceMod.GetGameFolderName(), "insurgency") == 0); if (m_bIsINS) { if (ConCommand *say2 = FindCommand("say2")) { - hooks_.append(sCoreProviderImpl.AddCommandHook(say2, pre_hook)); - hooks_.append(sCoreProviderImpl.AddPostCommandHook(say2, post_hook)); + hooks_.push_back(sCoreProviderImpl.AddCommandHook(say2, pre_hook)); + hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say2, post_hook)); } } #elif SOURCE_ENGINE == SE_NUCLEARDAWN if (ConCommand *say_squad = FindCommand("say_squad")) { - hooks_.append(sCoreProviderImpl.AddCommandHook(say_squad, pre_hook)); - hooks_.append(sCoreProviderImpl.AddPostCommandHook(say_squad, post_hook)); + hooks_.push_back(sCoreProviderImpl.AddCommandHook(say_squad, pre_hook)); + hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say_squad, post_hook)); } #endif } diff --git a/core/ChatTriggers.h b/core/ChatTriggers.h index e309858f..de9620f9 100644 --- a/core/ChatTriggers.h +++ b/core/ChatTriggers.h @@ -73,7 +73,7 @@ private: bool ClientIsFlooding(int client); cell_t CallOnClientSayCommand(int client); private: - ke::Vector> hooks_; + std::vector> hooks_; std::string m_PubTrigger; std::string m_PrivTrigger; bool m_bWillProcessInPost; diff --git a/core/GameHooks.cpp b/core/GameHooks.cpp index 5606932e..db50b03d 100644 --- a/core/GameHooks.cpp +++ b/core/GameHooks.cpp @@ -91,7 +91,7 @@ void GameHooks::OnVSPReceived() void GameHooks::Shutdown() { - for (size_t i = 0; i < hooks_.length(); i++) + for (size_t i = 0; i < hooks_.size(); i++) SH_REMOVE_HOOK_ID(hooks_[i]); hooks_.clear(); diff --git a/core/GameHooks.h b/core/GameHooks.h index c73d84ac..83c8ad70 100644 --- a/core/GameHooks.h +++ b/core/GameHooks.h @@ -114,11 +114,11 @@ private: void SetCommandClient(int client); private: - class HookList : public ke::Vector + class HookList : public std::vector { public: HookList &operator += (int hook_id) { - this->append(hook_id); + this->push_back(hook_id); return *this; } }; diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index 884260c9..4392a1ae 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -628,7 +628,7 @@ Handle_t CBaseMenu::GetHandle() bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw) { if (m_Pagination == (unsigned)MENU_NO_PAGINATION - && m_items.length() >= m_pStyle->GetMaxPageItems()) + && m_items.size() >= m_pStyle->GetMaxPageItems()) { return false; } @@ -640,19 +640,19 @@ bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw) item.display = std::make_unique(draw.display); item.style = draw.style; - m_items.append(std::move(item)); + m_items.push_back(std::move(item)); return true; } bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw) { if (m_Pagination == (unsigned)MENU_NO_PAGINATION && - m_items.length() >= m_pStyle->GetMaxPageItems()) + m_items.size() >= m_pStyle->GetMaxPageItems()) { return false; } - if (position >= m_items.length()) + if (position >= m_items.size()) return false; CItem item; @@ -661,16 +661,16 @@ bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDr item.display = std::make_unique(draw.display); item.style = draw.style; - m_items.insert(position, std::move(item)); + ke::InsertAt(&m_items, position, std::move(item)); return true; } bool CBaseMenu::RemoveItem(unsigned int position) { - if (position >= m_items.length()) + if (position >= m_items.size()) return false; - m_items.remove(position); + ke::RemoveAt(&m_items, position); return true; } @@ -681,7 +681,7 @@ void CBaseMenu::RemoveAllItems() const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =NULL */) { - if (position >= m_items.length()) + if (position >= m_items.size()) return NULL; if (draw) @@ -695,7 +695,7 @@ const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* = unsigned int CBaseMenu::GetItemCount() { - return m_items.length(); + return m_items.size(); } bool CBaseMenu::SetPagination(unsigned int itemsPerPage) @@ -825,5 +825,5 @@ IMenuHandler *CBaseMenu::GetHandler() unsigned int CBaseMenu::GetBaseMemUsage() { - return m_Title.length() + (m_items.length() * sizeof(CItem)); + return m_Title.size() + (m_items.size() * sizeof(CItem)); } diff --git a/core/MenuStyle_Base.h b/core/MenuStyle_Base.h index d81e4b07..ac2e5cb9 100644 --- a/core/MenuStyle_Base.h +++ b/core/MenuStyle_Base.h @@ -161,7 +161,7 @@ protected: std::string m_Title; IMenuStyle *m_pStyle; unsigned int m_Pagination; - ke::Vector m_items; + std::vector m_items; bool m_bShouldDelete; bool m_bCancelling; IdentityToken_t *m_pOwner; diff --git a/core/logic/CDataPack.cpp b/core/logic/CDataPack.cpp index e70f4300..afd313e8 100644 --- a/core/logic/CDataPack.cpp +++ b/core/logic/CDataPack.cpp @@ -46,7 +46,7 @@ CDataPack::~CDataPack() Initialize(); } -static ke::Vector> sDataPackCache; +static std::vector> sDataPackCache; CDataPack *CDataPack::New() { @@ -54,7 +54,7 @@ CDataPack *CDataPack::New() return new CDataPack(); CDataPack *pack = sDataPackCache.back().release(); - sDataPackCache.pop(); + sDataPackCache.pop_back(); pack->Initialize(); return pack; } @@ -62,7 +62,7 @@ CDataPack *CDataPack::New() void CDataPack::Free(CDataPack *pack) { - sDataPackCache.append(static_cast(pack)); + sDataPackCache.emplace_back(pack); } void CDataPack::Initialize() @@ -87,7 +87,7 @@ size_t CDataPack::CreateMemory(size_t size, void **addr) val.type = CDataPackType::Raw; val.pData.vval = new uint8_t[size + sizeof(size)]; reinterpret_cast(val.pData.vval)[0] = size; - elements.insert(position, val); + ke::InsertAt(&elements, position, val); return position++; } @@ -97,7 +97,7 @@ void CDataPack::PackCell(cell_t cell) InternalPack val; val.type = CDataPackType::Cell; val.pData.cval = cell; - elements.insert(position++, val); + ke::InsertAt(&elements, position++, val); } void CDataPack::PackFunction(cell_t function) @@ -105,7 +105,7 @@ void CDataPack::PackFunction(cell_t function) InternalPack val; val.type = CDataPackType::Function; val.pData.cval = function; - elements.insert(position++, val); + ke::InsertAt(&elements, position++, val); } void CDataPack::PackFloat(float floatval) @@ -113,7 +113,7 @@ void CDataPack::PackFloat(float floatval) InternalPack val; val.type = CDataPackType::Float; val.pData.fval = floatval; - elements.insert(position++, val); + ke::InsertAt(&elements, position++, val); } void CDataPack::PackString(const char *string) @@ -122,7 +122,7 @@ void CDataPack::PackString(const char *string) val.type = CDataPackType::String; std::string *sval = new std::string(string); val.pData.sval = sval; - elements.insert(position++, val); + ke::InsertAt(&elements, position++, val); } void CDataPack::PackCellArray(cell_t const *vals, cell_t count) @@ -133,7 +133,7 @@ void CDataPack::PackCellArray(cell_t const *vals, cell_t count) val.pData.aval = new cell_t [count + 1]; memcpy(&val.pData.aval[1], vals, sizeof(cell_t) * (count + 1)); val.pData.aval[0] = count; - elements.insert(position++, val); + ke::InsertAt(&elements, position++, val); } void CDataPack::PackFloatArray(cell_t const *vals, cell_t count) @@ -144,7 +144,7 @@ void CDataPack::PackFloatArray(cell_t const *vals, cell_t count) val.pData.aval = new cell_t [count + 1]; memcpy(&val.pData.aval[1], vals, sizeof(cell_t) * (count + 1)); val.pData.aval[0] = count; - elements.insert(position++, val); + ke::InsertAt(&elements, position++, val); } void CDataPack::Reset() const @@ -159,7 +159,7 @@ size_t CDataPack::GetPosition() const bool CDataPack::SetPosition(size_t pos) const { - if (pos > elements.length()) + if (pos > elements.size()) return false; position = pos; @@ -192,7 +192,7 @@ float CDataPack::ReadFloat() const bool CDataPack::IsReadable(size_t bytes) const { - return (position < elements.length()); + return (position < elements.size()); } const char *CDataPack::ReadString(size_t *len) const @@ -207,7 +207,7 @@ const char *CDataPack::ReadString(size_t *len) const const std::string &val = *elements[position++].pData.sval; if (len) - *len = val.length(); + *len = val.size(); return val.c_str(); } @@ -270,7 +270,7 @@ void *CDataPack::ReadMemory(size_t *size) const bool CDataPack::RemoveItem(size_t pos) { - if (!elements.length()) + if (!elements.size()) { return false; } @@ -280,7 +280,7 @@ bool CDataPack::RemoveItem(size_t pos) pos = position; } - if (pos >= elements.length()) + if (pos >= elements.size()) { return false; } @@ -312,6 +312,6 @@ bool CDataPack::RemoveItem(size_t pos) } } - elements.remove(pos); + ke::RemoveAt(&elements, pos); return true; } diff --git a/core/logic/CDataPack.h b/core/logic/CDataPack.h index fe7ba7a1..f8966f52 100644 --- a/core/logic/CDataPack.h +++ b/core/logic/CDataPack.h @@ -204,7 +204,7 @@ public: // Originally IDataPack public: void Initialize(); - inline size_t GetCapacity() const { return this->elements.length(); }; + inline size_t GetCapacity() const { return this->elements.size(); }; inline CDataPackType GetCurrentType(void) const { return this->elements[this->position].type; }; bool RemoveItem(size_t pos = -1); @@ -222,7 +222,7 @@ private: CDataPackType type; } InternalPack; - ke::Vector elements; + std::vector elements; mutable size_t position; }; diff --git a/core/logic/Database.cpp b/core/logic/Database.cpp index a4f9282b..5d3601e1 100644 --- a/core/logic/Database.cpp +++ b/core/logic/Database.cpp @@ -210,7 +210,7 @@ void DBManager::RemoveDriver(IDBDriver *pDriver) } ConfDbInfoList *list = m_Builder.GetConfigList(); - for (size_t i = 0; i < list->length(); i++) + for (size_t i = 0; i < list->size(); i++) { ke::RefPtr current = list->at(i); if (current->realDriver == pDriver) diff --git a/core/logic/DatabaseConfBuilder.cpp b/core/logic/DatabaseConfBuilder.cpp index 5d2bdfad..c28a5107 100644 --- a/core/logic/DatabaseConfBuilder.cpp +++ b/core/logic/DatabaseConfBuilder.cpp @@ -161,7 +161,7 @@ SMCResult DatabaseConfBuilder::ReadSMC_LeavingSection(const SMCStates *states) /* Save it.. */ m_ParseCurrent->AddRef(); - m_ParseList->append(m_ParseCurrent); + m_ParseList->push_back(m_ParseCurrent); m_ParseCurrent = nullptr; /* Go up one level */ diff --git a/core/logic/DatabaseConfBuilder.h b/core/logic/DatabaseConfBuilder.h index 4482c389..9d41b926 100644 --- a/core/logic/DatabaseConfBuilder.h +++ b/core/logic/DatabaseConfBuilder.h @@ -56,7 +56,7 @@ public: DatabaseInfo info; }; -class ConfDbInfoList : public ke::Vector +class ConfDbInfoList : public std::vector { /* Allow internal usage of ConfDbInfoList */ friend class DBManager; @@ -67,7 +67,7 @@ private: } ConfDbInfo *GetDatabaseConf(const char *name) { - for (size_t i = 0; i < this->length(); i++) + for (size_t i = 0; i < this->size(); i++) { ConfDbInfo *current = this->at(i); /* If we run into the default configuration, then we'll save it @@ -90,7 +90,7 @@ private: m_DefDriver = std::string(input); } void ReleaseMembers() { - for (size_t i = 0; i < this->length(); i++) { + for (size_t i = 0; i < this->size(); i++) { ConfDbInfo *current = this->at(i); current->Release(); } diff --git a/core/logic/DebugReporter.cpp b/core/logic/DebugReporter.cpp index 55bbf0c4..5c5be839 100644 --- a/core/logic/DebugReporter.cpp +++ b/core/logic/DebugReporter.cpp @@ -194,22 +194,22 @@ void DebugReport::ReportError(const IErrorReport &report, IFrameIterator &iter) g_Logger.LogError("[SM] Blaming: %s", blame); } - ke::Vector arr = GetStackTrace(&iter); - for (size_t i = 0; i < arr.length(); i++) + std::vector arr = GetStackTrace(&iter); + for (size_t i = 0; i < arr.size(); i++) { g_Logger.LogError("%s", arr[i].c_str()); } } -ke::Vector DebugReport::GetStackTrace(IFrameIterator *iter) +std::vector DebugReport::GetStackTrace(IFrameIterator *iter) { char temp[3072]; - ke::Vector trace; + std::vector trace; iter->Reset(); if (!iter->Done()) { - trace.append("[SM] Call stack trace:"); + trace.push_back("[SM] Call stack trace:"); for (int index = 0; !iter->Done(); iter->Next(), index++) { @@ -221,7 +221,7 @@ ke::Vector DebugReport::GetStackTrace(IFrameIterator *iter) if (iter->IsNativeFrame()) { g_pSM->Format(temp, sizeof(temp), "[SM] [%d] %s", index, fn); - trace.append(temp); + trace.push_back(temp); continue; } if (iter->IsScriptedFrame()) @@ -237,7 +237,7 @@ ke::Vector DebugReport::GetStackTrace(IFrameIterator *iter) file, fn); - trace.append(temp); + trace.push_back(temp); } } } diff --git a/core/logic/DebugReporter.h b/core/logic/DebugReporter.h index b8e7be60..27b54a9b 100644 --- a/core/logic/DebugReporter.h +++ b/core/logic/DebugReporter.h @@ -50,7 +50,7 @@ public: void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...); void GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap); void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...); - ke::Vector GetStackTrace(IFrameIterator *iter); + std::vector GetStackTrace(IFrameIterator *iter); private: int _GetPluginIndex(IPluginContext *ctx); }; diff --git a/core/logic/FrameIterator.cpp b/core/logic/FrameIterator.cpp index dd10fc33..39115d05 100644 --- a/core/logic/FrameIterator.cpp +++ b/core/logic/FrameIterator.cpp @@ -36,7 +36,7 @@ SafeFrameIterator::SafeFrameIterator(IFrameIterator *it) while (!it->Done()) { FrameInfo info = FrameInfo(it); - frames.append(info); + frames.push_back(info); it->Next(); } @@ -46,7 +46,7 @@ SafeFrameIterator::SafeFrameIterator(IFrameIterator *it) bool SafeFrameIterator::Done() const { - return current >= frames.length(); + return current >= frames.size(); } bool SafeFrameIterator::Next() diff --git a/core/logic/FrameIterator.h b/core/logic/FrameIterator.h index a4ffe37e..9b9e02f1 100644 --- a/core/logic/FrameIterator.h +++ b/core/logic/FrameIterator.h @@ -73,5 +73,5 @@ public: private: size_t current; - ke::Vector frames; + std::vector frames; }; diff --git a/core/logic/NativeOwner.cpp b/core/logic/NativeOwner.cpp index 85ea6df3..bdb415f8 100644 --- a/core/logic/NativeOwner.cpp +++ b/core/logic/NativeOwner.cpp @@ -62,7 +62,7 @@ void CNativeOwner::AddNatives(const sp_nativeinfo_t *natives) for (const sp_nativeinfo_t *native = natives; native->func && native->name; native++) g_ShareSys.AddNativeToCache(this, native); - m_natives.append(natives); + m_natives.push_back(natives); } void CNativeOwner::UnbindWeakRef(const WeakNative &ref) @@ -90,14 +90,14 @@ void CNativeOwner::DropEverything() } /* Strip all of our natives from the cache */ - for (size_t i = 0; i < m_natives.length(); i++) { + for (size_t i = 0; i < m_natives.size(); i++) { const sp_nativeinfo_t *natives = m_natives[i]; for (const sp_nativeinfo_t *native = natives; native->func && native->name; native++) g_ShareSys.ClearNativeFromCache(this, native->name); } m_natives.clear(); - for (size_t i = 0; i < m_fakes.length(); i++) + for (size_t i = 0; i < m_fakes.size(); i++) g_ShareSys.ClearNativeFromCache(this, m_fakes[i]->name()); m_fakes.clear(); } diff --git a/core/logic/NativeOwner.h b/core/logic/NativeOwner.h index b09350cd..ac7876da 100644 --- a/core/logic/NativeOwner.h +++ b/core/logic/NativeOwner.h @@ -80,8 +80,8 @@ protected: List m_Dependents; unsigned int m_nMarkSerial; List m_WeakRefs; - ke::Vector m_natives; - ke::Vector > m_fakes; + std::vector m_natives; + std::vector > m_fakes; }; extern CNativeOwner g_CoreNatives; diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index aa2d8b78..8a71953b 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -674,7 +674,7 @@ void CPlugin::DependencyDropped(CPlugin *pOwner) } unsigned int unbound = 0; - for (size_t i = 0; i < pOwner->m_fakes.length(); i++) + for (size_t i = 0; i < pOwner->m_fakes.size(); i++) { ke::RefPtr entry(pOwner->m_fakes[i]); @@ -773,13 +773,13 @@ bool CPlugin::AddFakeNative(IPluginFunction *pFunc, const char *name, SPVM_FAKEN if (!entry) return false; - m_fakes.append(entry); + m_fakes.push_back(entry); return true; } void CPlugin::BindFakeNativesTo(CPlugin *other) { - for (size_t i = 0; i < m_fakes.length(); i++) + for (size_t i = 0; i < m_fakes.size(); i++) g_ShareSys.BindNativeToPlugin(other, m_fakes[i]); } diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index a1d40340..8ced63da 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -227,7 +227,7 @@ public: return m_LibraryMissing; } bool HasFakeNatives() const { - return m_fakes.length() > 0; + return m_fakes.size() > 0; } // True if we got far enough into the second pass to call OnPluginLoaded diff --git a/core/logic/ProfileTools.cpp b/core/logic/ProfileTools.cpp index 0305ec9d..3d3246d6 100644 --- a/core/logic/ProfileTools.cpp +++ b/core/logic/ProfileTools.cpp @@ -52,7 +52,7 @@ ProfileToolManager::OnSourceModShutdown() IProfilingTool * ProfileToolManager::FindToolByName(const char *name) { - for (size_t i = 0; i < tools_.length(); i++) { + for (size_t i = 0; i < tools_.size(); i++) { if (strcmp(tools_[i]->Name(), name) == 0) return tools_[i]; } @@ -97,7 +97,7 @@ ProfileToolManager::StartFromConsole(IProfilingTool *tool) void ProfileToolManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *args) { - if (tools_.length() == 0) { + if (tools_.size() == 0) { rootmenu->ConsolePrint("No profiling tools are enabled."); return; } @@ -107,7 +107,7 @@ ProfileToolManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs if (strcmp(cmdname, "list") == 0) { rootmenu->ConsolePrint("Profiling tools:"); - for (size_t i = 0; i < tools_.length(); i++) { + for (size_t i = 0; i < tools_.size(); i++) { rootmenu->DrawGenericOption(tools_[i]->Name(), tools_[i]->Description()); } return; @@ -135,7 +135,7 @@ ProfileToolManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs if (strcmp(cmdname, "start") == 0) { if (!default_) { default_ = FindToolByName("vprof"); - if (!default_ && tools_.length() > 0) + if (!default_ && tools_.size() > 0) default_ = tools_[0]; if (!default_) { rootmenu->ConsolePrint("Could not find any profiler to use."); diff --git a/core/logic/ProfileTools.h b/core/logic/ProfileTools.h index 824fd1fd..f0447f67 100644 --- a/core/logic/ProfileTools.h +++ b/core/logic/ProfileTools.h @@ -51,7 +51,7 @@ public: void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *args) override; void RegisterTool(IProfilingTool *tool) { - tools_.append(tool); + tools_.push_back(tool); } bool IsActive() const { @@ -76,7 +76,7 @@ private: void StartFromConsole(IProfilingTool *tool); private: - ke::Vector tools_; + std::vector tools_; IProfilingTool *active_; IProfilingTool *default_; bool enabled_; diff --git a/core/logic/frame_tasks.cpp b/core/logic/frame_tasks.cpp index 18d7ea96..74f767d8 100644 --- a/core/logic/frame_tasks.cpp +++ b/core/logic/frame_tasks.cpp @@ -30,13 +30,13 @@ using namespace SourceMod; -ke::Vector> sNextTasks; -ke::Vector> sWorkTasks; +std::vector> sNextTasks; +std::vector> sWorkTasks; void SourceMod::ScheduleTaskForNextFrame(ke::Function&& task) { - sNextTasks.append(std::forward(task)); + sNextTasks.push_back(std::forward(task)); } void @@ -46,11 +46,11 @@ SourceMod::RunScheduledFrameTasks(bool simulating) return; // Swap. - ke::Vector> temp(std::move(sNextTasks)); + std::vector> temp(std::move(sNextTasks)); sNextTasks = std::move(sWorkTasks); sWorkTasks = std::move(temp); - for (size_t i = 0; i < sWorkTasks.length(); i++) + for (size_t i = 0; i < sWorkTasks.size(); i++) sWorkTasks[i](); sWorkTasks.clear(); } diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index 9364eb1a..2394612e 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -1,55 +1,55 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet : - * ============================================================================= - * SourceMod - * Copyright (C) 2004-2017 AlliedModders LLC. All rights reserved. - * ============================================================================= - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 3.0, as published by the - * Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - * - * As a special exception, AlliedModders LLC gives you permission to link the - * code of this program (as well as its derivative works) to "Half-Life 2," the - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software - * by the Valve Corporation. You must obey the GNU General Public License in - * all respects for all other code used. Additionally, AlliedModders LLC grants - * this exception to all derivative works. AlliedModders LLC defines further - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), - * or . - * - * Version: $Id$ - */ - -#include -#include -#include -#include "common_logic.h" -#include "Logger.h" - -#include -#include -#include -#include - -#include -#include - -#if defined PLATFORM_WINDOWS -#include -#elif defined PLATFORM_POSIX -#include -#include -#include -#endif +/** + * vim: set ts=4 sw=4 tw=99 noet : + * ============================================================================= + * SourceMod + * Copyright (C) 2004-2017 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#include +#include +#include +#include "common_logic.h" +#include "Logger.h" + +#include +#include +#include +#include + +#include +#include + +#if defined PLATFORM_WINDOWS +#include +#elif defined PLATFORM_POSIX +#include +#include +#include +#endif #include #include #include @@ -59,623 +59,623 @@ using namespace SourceMod; using namespace SourcePawn; - -HandleType_t g_PlIter; -HandleType_t g_FrameIter; - -IForward *g_OnLogAction = NULL; - -static ConVar *sm_datetime_format = NULL; - -class CoreNativeHelpers : - public SMGlobalClass, - public IHandleTypeDispatch -{ -public: - void OnSourceModAllInitialized() - { - HandleAccess hacc; - handlesys->InitAccessDefaults(NULL, &hacc); - hacc.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER; - - g_PlIter = handlesys->CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL); - g_FrameIter = handlesys->CreateType("FrameIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL); - - g_OnLogAction = forwardsys->CreateForward("OnLogAction", - ET_Hook, - 5, - NULL, - Param_Cell, - Param_Cell, - Param_Cell, - Param_Cell, - Param_String); - - sm_datetime_format = bridge->FindConVar("sm_datetime_format"); - } - void OnHandleDestroy(HandleType_t type, void *object) - { - if (type == g_FrameIter) - { - delete (SafeFrameIterator *) object; - } - else if (type == g_PlIter) - { - IPluginIterator *iter = (IPluginIterator *)object; - iter->Release(); - } - } - void OnSourceModShutdown() - { - forwardsys->ReleaseForward(g_OnLogAction); - handlesys->RemoveType(g_PlIter, g_pCoreIdent); - handlesys->RemoveType(g_FrameIter, g_pCoreIdent); - } -} g_CoreNativeHelpers; - -void LogAction(Handle_t hndl, int type, int client, int target, const char *message) -{ - if (g_OnLogAction->GetFunctionCount()) - { - cell_t result = 0; - g_OnLogAction->PushCell(hndl); - g_OnLogAction->PushCell(type); - g_OnLogAction->PushCell(client); - g_OnLogAction->PushCell(target); - g_OnLogAction->PushString(message); - g_OnLogAction->Execute(&result); - - if (result >= (ResultType)Pl_Handled) - { - return; - } - } - - const char *logtag = "SM"; - if (type == 2) - { - HandleError err; - IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err); - if (pPlugin) - { - logtag = pPlugin->GetFilename(); - } - } - - g_Logger.LogMessage("[%s] %s", logtag, message); -} - - static cell_t ThrowError(IPluginContext *pContext, const cell_t *params) -{ - char buffer[512]; - - g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - + +HandleType_t g_PlIter; +HandleType_t g_FrameIter; + +IForward *g_OnLogAction = NULL; + +static ConVar *sm_datetime_format = NULL; + +class CoreNativeHelpers : + public SMGlobalClass, + public IHandleTypeDispatch +{ +public: + void OnSourceModAllInitialized() + { + HandleAccess hacc; + handlesys->InitAccessDefaults(NULL, &hacc); + hacc.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER; + + g_PlIter = handlesys->CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL); + g_FrameIter = handlesys->CreateType("FrameIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL); + + g_OnLogAction = forwardsys->CreateForward("OnLogAction", + ET_Hook, + 5, + NULL, + Param_Cell, + Param_Cell, + Param_Cell, + Param_Cell, + Param_String); + + sm_datetime_format = bridge->FindConVar("sm_datetime_format"); + } + void OnHandleDestroy(HandleType_t type, void *object) + { + if (type == g_FrameIter) + { + delete (SafeFrameIterator *) object; + } + else if (type == g_PlIter) + { + IPluginIterator *iter = (IPluginIterator *)object; + iter->Release(); + } + } + void OnSourceModShutdown() + { + forwardsys->ReleaseForward(g_OnLogAction); + handlesys->RemoveType(g_PlIter, g_pCoreIdent); + handlesys->RemoveType(g_FrameIter, g_pCoreIdent); + } +} g_CoreNativeHelpers; + +void LogAction(Handle_t hndl, int type, int client, int target, const char *message) +{ + if (g_OnLogAction->GetFunctionCount()) + { + cell_t result = 0; + g_OnLogAction->PushCell(hndl); + g_OnLogAction->PushCell(type); + g_OnLogAction->PushCell(client); + g_OnLogAction->PushCell(target); + g_OnLogAction->PushString(message); + g_OnLogAction->Execute(&result); + + if (result >= (ResultType)Pl_Handled) + { + return; + } + } + + const char *logtag = "SM"; + if (type == 2) + { + HandleError err; + IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err); + if (pPlugin) + { + logtag = pPlugin->GetFilename(); + } + } + + g_Logger.LogMessage("[%s] %s", logtag, message); +} + + static cell_t ThrowError(IPluginContext *pContext, const cell_t *params) +{ + char buffer[512]; + + g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + { DetectExceptions eh(pContext); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); if (eh.HasException()) return 0; } - + pContext->ReportError("%s", buffer); - return 0; -} - -static cell_t GetTime(IPluginContext *pContext, const cell_t *params) -{ - time_t t = g_pSM->GetAdjustedTime(); - cell_t *addr; - pContext->LocalToPhysAddr(params[1], &addr); - - *(time_t *)addr = t; - - return static_cast(t); -} - -#if defined SUBPLATFORM_SECURECRT -void _ignore_invalid_parameter( - const wchar_t * expression, - const wchar_t * function, - const wchar_t * file, - unsigned int line, - uintptr_t pReserved - ) -{ - /* Wow we don't care, thanks Microsoft. */ -} -#endif - -static cell_t FormatTime(IPluginContext *pContext, const cell_t *params) -{ - char *format, *buffer; - pContext->LocalToString(params[1], &buffer); - pContext->LocalToStringNULL(params[3], &format); - - if (format == NULL) - { - format = const_cast(bridge->GetCvarString(sm_datetime_format)); - } - -#if defined SUBPLATFORM_SECURECRT - _invalid_parameter_handler handler = _set_invalid_parameter_handler(_ignore_invalid_parameter); -#endif - - time_t t = (params[4] == -1) ? g_pSM->GetAdjustedTime() : (time_t)params[4]; - size_t written = strftime(buffer, params[2], format, localtime(&t)); - -#if defined SUBPLATFORM_SECURECRT - _set_invalid_parameter_handler(handler); -#endif - - if (params[2] && format[0] != '\0' && !written) - { - pContext->ThrowNativeError("Invalid time format or buffer too small"); - return 0; - } - - return 1; -} - -static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params) -{ - IPluginIterator *iter = scripts->GetPluginIterator(); - - Handle_t hndl = handlesys->CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL); - - if (hndl == BAD_HANDLE) - { - iter->Release(); - } - - return hndl; -} - -static cell_t MorePlugins(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - IPluginIterator *pIter; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - return pIter->MorePlugins() ? 1 : 0; -} - -static cell_t ReadPlugin(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - IPluginIterator *pIter; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - IPlugin *pPlugin = pIter->GetPlugin(); - if (!pPlugin) - { - return BAD_HANDLE; - } - - pIter->NextPlugin(); - - return pPlugin->GetMyHandle(); -} - -IPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl) -{ - if (hndl == BAD_HANDLE) - { - return scripts->FindPluginByContext(pContext->GetContext()); - } else { - HandleError err; - IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err); - if (!pPlugin) - { - pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - return pPlugin; - } -} - -static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params) -{ - IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); - if (!pPlugin) - { - return 0; - } - - return pPlugin->GetStatus(); -} - -static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params) -{ - IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); - if (!pPlugin) - { - return 0; - } - - pContext->StringToLocalUTF8(params[2], params[3], pPlugin->GetFilename(), NULL); - - return 1; -} - -static cell_t IsPluginDebugging(IPluginContext *pContext, const cell_t *params) -{ - IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); - if (!pPlugin) - { - return 0; - } - - return pPlugin->IsDebugging() ? 1 : 0; -} - -/* Local to plugins only */ -enum PluginInfo -{ - PlInfo_Name, /**< Plugin name */ - PlInfo_Author, /**< Plugin author */ - PlInfo_Description, /**< Plugin description */ - PlInfo_Version, /**< Plugin verison */ - PlInfo_URL, /**< Plugin URL */ -}; - -static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params) -{ - IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); - if (!pPlugin) - { - return 0; - } - - const sm_plugininfo_t *info = pPlugin->GetPublicInfo(); - - if (!info) - { - return 0; - } - - const char *str = NULL; - - switch ((PluginInfo)params[2]) - { - case PlInfo_Name: - { - str = info->name; - break; - } - case PlInfo_Author: - { - str = info->author; - break; - } - case PlInfo_Description: - { - str = info->description; - break; - } - case PlInfo_Version: - { - str = info->version; - break; - } - case PlInfo_URL: - { - str = info->url; - break; - } - } - - if (!str || str[0] == '\0') - { - return 0; - } - - pContext->StringToLocalUTF8(params[3], params[4], str, NULL); - - return 1; -} - -static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) -{ - char *str; - SMPlugin *pPlugin; - - pContext->LocalToString(params[1], &str); - pPlugin = scripts->FindPluginByContext(pContext->GetContext()); - - if (params[0] == 1) - { - pPlugin->EvictWithError(Plugin_Failed, "%s", str); - - return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); - } - else - { - char buffer[2048]; - + return 0; +} + +static cell_t GetTime(IPluginContext *pContext, const cell_t *params) +{ + time_t t = g_pSM->GetAdjustedTime(); + cell_t *addr; + pContext->LocalToPhysAddr(params[1], &addr); + + *(time_t *)addr = t; + + return static_cast(t); +} + +#if defined SUBPLATFORM_SECURECRT +void _ignore_invalid_parameter( + const wchar_t * expression, + const wchar_t * function, + const wchar_t * file, + unsigned int line, + uintptr_t pReserved + ) +{ + /* Wow we don't care, thanks Microsoft. */ +} +#endif + +static cell_t FormatTime(IPluginContext *pContext, const cell_t *params) +{ + char *format, *buffer; + pContext->LocalToString(params[1], &buffer); + pContext->LocalToStringNULL(params[3], &format); + + if (format == NULL) + { + format = const_cast(bridge->GetCvarString(sm_datetime_format)); + } + +#if defined SUBPLATFORM_SECURECRT + _invalid_parameter_handler handler = _set_invalid_parameter_handler(_ignore_invalid_parameter); +#endif + + time_t t = (params[4] == -1) ? g_pSM->GetAdjustedTime() : (time_t)params[4]; + size_t written = strftime(buffer, params[2], format, localtime(&t)); + +#if defined SUBPLATFORM_SECURECRT + _set_invalid_parameter_handler(handler); +#endif + + if (params[2] && format[0] != '\0' && !written) + { + pContext->ThrowNativeError("Invalid time format or buffer too small"); + return 0; + } + + return 1; +} + +static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params) +{ + IPluginIterator *iter = scripts->GetPluginIterator(); + + Handle_t hndl = handlesys->CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL); + + if (hndl == BAD_HANDLE) + { + iter->Release(); + } + + return hndl; +} + +static cell_t MorePlugins(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + IPluginIterator *pIter; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + return pIter->MorePlugins() ? 1 : 0; +} + +static cell_t ReadPlugin(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + IPluginIterator *pIter; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + IPlugin *pPlugin = pIter->GetPlugin(); + if (!pPlugin) + { + return BAD_HANDLE; + } + + pIter->NextPlugin(); + + return pPlugin->GetMyHandle(); +} + +IPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl) +{ + if (hndl == BAD_HANDLE) + { + return scripts->FindPluginByContext(pContext->GetContext()); + } else { + HandleError err; + IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err); + if (!pPlugin) + { + pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + return pPlugin; + } +} + +static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params) +{ + IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); + if (!pPlugin) + { + return 0; + } + + return pPlugin->GetStatus(); +} + +static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params) +{ + IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); + if (!pPlugin) + { + return 0; + } + + pContext->StringToLocalUTF8(params[2], params[3], pPlugin->GetFilename(), NULL); + + return 1; +} + +static cell_t IsPluginDebugging(IPluginContext *pContext, const cell_t *params) +{ + IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); + if (!pPlugin) + { + return 0; + } + + return pPlugin->IsDebugging() ? 1 : 0; +} + +/* Local to plugins only */ +enum PluginInfo +{ + PlInfo_Name, /**< Plugin name */ + PlInfo_Author, /**< Plugin author */ + PlInfo_Description, /**< Plugin description */ + PlInfo_Version, /**< Plugin verison */ + PlInfo_URL, /**< Plugin URL */ +}; + +static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params) +{ + IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); + if (!pPlugin) + { + return 0; + } + + const sm_plugininfo_t *info = pPlugin->GetPublicInfo(); + + if (!info) + { + return 0; + } + + const char *str = NULL; + + switch ((PluginInfo)params[2]) + { + case PlInfo_Name: + { + str = info->name; + break; + } + case PlInfo_Author: + { + str = info->author; + break; + } + case PlInfo_Description: + { + str = info->description; + break; + } + case PlInfo_Version: + { + str = info->version; + break; + } + case PlInfo_URL: + { + str = info->url; + break; + } + } + + if (!str || str[0] == '\0') + { + return 0; + } + + pContext->StringToLocalUTF8(params[3], params[4], str, NULL); + + return 1; +} + +static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) +{ + char *str; + SMPlugin *pPlugin; + + pContext->LocalToString(params[1], &str); + pPlugin = scripts->FindPluginByContext(pContext->GetContext()); + + if (params[0] == 1) + { + pPlugin->EvictWithError(Plugin_Failed, "%s", str); + + return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); + } + else + { + char buffer[2048]; + { DetectExceptions eh(pContext); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); if (eh.HasException()) { - pPlugin->EvictWithError(Plugin_Failed, "%s", str); + pPlugin->EvictWithError(Plugin_Failed, "%s", str); return 0; } - pPlugin->EvictWithError(Plugin_Failed, "%s", buffer); - pContext->ReportFatalError("%s", buffer); + pPlugin->EvictWithError(Plugin_Failed, "%s", buffer); + pContext->ReportFatalError("%s", buffer); return 0; - } - } - - return 0; -} - -static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params) -{ -#if defined PLATFORM_WINDOWS - return (cell_t)GetTickCount(); -#elif defined PLATFORM_POSIX - tms tm; - clock_t ticks = times(&tm); - long ticks_per_sec = sysconf(_SC_CLK_TCK); - double fticks = (double)ticks / (double)ticks_per_sec; - fticks *= 1000.0f; - if (fticks > INT_MAX) - { - double r = (int)(fticks / INT_MAX) * (double)INT_MAX; - fticks -= r; - } - return (cell_t)fticks; -#endif -} - -static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params) -{ - SMPlugin *plugin = scripts->FindPluginByContext(pContext->GetContext()); - - char *cfg, *folder; - pContext->LocalToString(params[2], &cfg); - pContext->LocalToString(params[3], &folder); - - if (cfg[0] == '\0') - { - static char temp_str[255]; - static char temp_file[PLATFORM_MAX_PATH]; - char *ptr; - - libsys->GetFileFromPath(temp_str, sizeof(temp_str), plugin->GetFilename()); - if ((ptr = strstr(temp_str, ".smx")) != NULL) - { - *ptr = '\0'; - } - - /* We have the raw filename! */ - g_pSM->Format(temp_file, sizeof(temp_file), "plugin.%s", temp_str); - cfg = temp_file; - } - - plugin->AddConfig(params[1] ? true : false, cfg, folder); - - return 1; -} - -static cell_t MarkNativeAsOptional(IPluginContext *pContext, const cell_t *params) -{ - char *name; - uint32_t idx; - - pContext->LocalToString(params[1], &name); - if (pContext->FindNativeByName(name, &idx) != SP_ERROR_NONE) - { - /* Oops! This HAS to silently fail! */ - return 0; - } - + } + } + + return 0; +} + +static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params) +{ +#if defined PLATFORM_WINDOWS + return (cell_t)GetTickCount(); +#elif defined PLATFORM_POSIX + tms tm; + clock_t ticks = times(&tm); + long ticks_per_sec = sysconf(_SC_CLK_TCK); + double fticks = (double)ticks / (double)ticks_per_sec; + fticks *= 1000.0f; + if (fticks > INT_MAX) + { + double r = (int)(fticks / INT_MAX) * (double)INT_MAX; + fticks -= r; + } + return (cell_t)fticks; +#endif +} + +static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params) +{ + SMPlugin *plugin = scripts->FindPluginByContext(pContext->GetContext()); + + char *cfg, *folder; + pContext->LocalToString(params[2], &cfg); + pContext->LocalToString(params[3], &folder); + + if (cfg[0] == '\0') + { + static char temp_str[255]; + static char temp_file[PLATFORM_MAX_PATH]; + char *ptr; + + libsys->GetFileFromPath(temp_str, sizeof(temp_str), plugin->GetFilename()); + if ((ptr = strstr(temp_str, ".smx")) != NULL) + { + *ptr = '\0'; + } + + /* We have the raw filename! */ + g_pSM->Format(temp_file, sizeof(temp_file), "plugin.%s", temp_str); + cfg = temp_file; + } + + plugin->AddConfig(params[1] ? true : false, cfg, folder); + + return 1; +} + +static cell_t MarkNativeAsOptional(IPluginContext *pContext, const cell_t *params) +{ + char *name; + uint32_t idx; + + pContext->LocalToString(params[1], &name); + if (pContext->FindNativeByName(name, &idx) != SP_ERROR_NONE) + { + /* Oops! This HAS to silently fail! */ + return 0; + } + pContext->GetRuntime()->UpdateNativeBinding(idx, nullptr, SP_NTVFLAG_OPTIONAL, nullptr); - return 1; -} - -static cell_t RegPluginLibrary(IPluginContext *pContext, const cell_t *params) -{ - char *name; - SMPlugin *pl = scripts->FindPluginByContext(pContext->GetContext()); - - pContext->LocalToString(params[1], &name); - - pl->AddLibrary(name); - return 1; -} - -static cell_t LibraryExists(IPluginContext *pContext, const cell_t *params) -{ - char *str; - pContext->LocalToString(params[1], &str); - - if (strcmp(str, "__CanTestFeatures__") == 0) - { - return 1; - } - - if (scripts->LibraryExists(str)) - { - return 1; - } - - if (extsys->LibraryExists(str)) - { - return 1; - } - - return 0; -} - -static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params) -{ - char buffer[2048]; - g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + return 1; +} + +static cell_t RegPluginLibrary(IPluginContext *pContext, const cell_t *params) +{ + char *name; + SMPlugin *pl = scripts->FindPluginByContext(pContext->GetContext()); + + pContext->LocalToString(params[1], &name); + + pl->AddLibrary(name); + return 1; +} + +static cell_t LibraryExists(IPluginContext *pContext, const cell_t *params) +{ + char *str; + pContext->LocalToString(params[1], &str); + + if (strcmp(str, "__CanTestFeatures__") == 0) + { + return 1; + } + + if (scripts->LibraryExists(str)) + { + return 1; + } + + if (extsys->LibraryExists(str)) + { + return 1; + } + + return 0; +} + +static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params) +{ + char buffer[2048]; + g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); { DetectExceptions eh(pContext); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); if (eh.HasException()) return 0; } - - IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); - - LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer); - - return 1; -} - -static cell_t LogToFile(IPluginContext *pContext, const cell_t *params) -{ - char *file; - pContext->LocalToString(params[1], &file); - - char path[PLATFORM_MAX_PATH]; - g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file); - - FILE *fp = fopen(path, "at"); - if (!fp) - { - return pContext->ThrowNativeError("Could not open file \"%s\"", path); - } - - char buffer[2048]; + + IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); + + LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer); + + return 1; +} + +static cell_t LogToFile(IPluginContext *pContext, const cell_t *params) +{ + char *file; + pContext->LocalToString(params[1], &file); + + char path[PLATFORM_MAX_PATH]; + g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file); + + FILE *fp = fopen(path, "at"); + if (!fp) + { + return pContext->ThrowNativeError("Could not open file \"%s\"", path); + } + + char buffer[2048]; { DetectExceptions eh(pContext); - g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); if (eh.HasException()) { fclose(fp); return 0; } } - - IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); - - g_Logger.LogToOpenFile(fp, "[%s] %s", pPlugin->GetFilename(), buffer); - - fclose(fp); - - return 1; -} - -static cell_t LogToFileEx(IPluginContext *pContext, const cell_t *params) -{ - char *file; - pContext->LocalToString(params[1], &file); - - char path[PLATFORM_MAX_PATH]; - g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file); - - FILE *fp = fopen(path, "at"); - if (!fp) - { - return pContext->ThrowNativeError("Could not open file \"%s\"", path); - } - - char buffer[2048]; + + IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); + + g_Logger.LogToOpenFile(fp, "[%s] %s", pPlugin->GetFilename(), buffer); + + fclose(fp); + + return 1; +} + +static cell_t LogToFileEx(IPluginContext *pContext, const cell_t *params) +{ + char *file; + pContext->LocalToString(params[1], &file); + + char path[PLATFORM_MAX_PATH]; + g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file); + + FILE *fp = fopen(path, "at"); + if (!fp) + { + return pContext->ThrowNativeError("Could not open file \"%s\"", path); + } + + char buffer[2048]; { DetectExceptions eh(pContext); - g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); if (eh.HasException()) { fclose(fp); return 0; } } - - g_Logger.LogToOpenFile(fp, "%s", buffer); - - fclose(fp); - - return 1; -} - -static cell_t GetExtensionFileStatus(IPluginContext *pContext, const cell_t *params) -{ - char *str; - pContext->LocalToString(params[1], &str); - - IExtension *pExtension = extsys->FindExtensionByFile(str); - - if (!pExtension) - { - return -2; - } - - if (!pExtension->IsLoaded()) - { - return -1; - } - - char *error; - pContext->LocalToString(params[2], &error); - if (!pExtension->IsRunning(error, params[3])) - { - return 0; - } - - return 1; -} - -static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params) -{ - IPlugin *pPlugin = scripts->FindPluginByOrder(params[1]); - - if (pPlugin == NULL) - { - return BAD_HANDLE; - } - - return pPlugin->GetMyHandle(); -} - -static cell_t VerifyCoreVersion(IPluginContext *pContext, const cell_t *params) -{ - return 4; -} - -static cell_t GetFeatureStatus(IPluginContext *pContext, const cell_t *params) -{ - FeatureType type = (FeatureType)params[1]; - char *name; - - pContext->LocalToString(params[2], &name); - - return sharesys->TestFeature(pContext->GetRuntime(), type, name); -} - -static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params) -{ - FeatureType type = (FeatureType)params[1]; - char *name; - - pContext->LocalToString(params[2], &name); - - if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available) - { + + g_Logger.LogToOpenFile(fp, "%s", buffer); + + fclose(fp); + + return 1; +} + +static cell_t GetExtensionFileStatus(IPluginContext *pContext, const cell_t *params) +{ + char *str; + pContext->LocalToString(params[1], &str); + + IExtension *pExtension = extsys->FindExtensionByFile(str); + + if (!pExtension) + { + return -2; + } + + if (!pExtension->IsLoaded()) + { + return -1; + } + + char *error; + pContext->LocalToString(params[2], &error); + if (!pExtension->IsRunning(error, params[3])) + { + return 0; + } + + return 1; +} + +static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params) +{ + IPlugin *pPlugin = scripts->FindPluginByOrder(params[1]); + + if (pPlugin == NULL) + { + return BAD_HANDLE; + } + + return pPlugin->GetMyHandle(); +} + +static cell_t VerifyCoreVersion(IPluginContext *pContext, const cell_t *params) +{ + return 4; +} + +static cell_t GetFeatureStatus(IPluginContext *pContext, const cell_t *params) +{ + FeatureType type = (FeatureType)params[1]; + char *name; + + pContext->LocalToString(params[2], &name); + + return sharesys->TestFeature(pContext->GetRuntime(), type, name); +} + +static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params) +{ + FeatureType type = (FeatureType)params[1]; + char *name; + + pContext->LocalToString(params[2], &name); + + if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available) + { char buffer[255]; char *msg = buffer; char default_message[255]; - SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); + SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); DetectExceptions eh(pContext); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); @@ -693,307 +693,307 @@ static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params) return 0; } - return 1; -} - -enum NumberType -{ - NumberType_Int8, - NumberType_Int16, - NumberType_Int32 -}; - -//memory addresses below 0x10000 are automatically considered invalid for dereferencing -#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000 - -static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params) -{ -#ifdef PLATFORM_X86 - void *addr = reinterpret_cast(params[1]); -#else - void *addr = pseudoAddr.FromPseudoAddress(params[1]); -#endif - - if (addr == NULL) - { - return pContext->ThrowNativeError("Address cannot be null"); - } - else if (reinterpret_cast(addr) < VALID_MINIMUM_MEMORY_ADDRESS) - { - return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr); - } - NumberType size = static_cast(params[2]); - - switch(size) - { - case NumberType_Int8: - return *reinterpret_cast(addr); - case NumberType_Int16: - return *reinterpret_cast(addr); - case NumberType_Int32: - return *reinterpret_cast(addr); - default: - return pContext->ThrowNativeError("Invalid number types %d", size); - } -} - - -static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params) -{ -#ifdef PLATFORM_X86 - void *addr = reinterpret_cast(params[1]); -#else - void *addr = pseudoAddr.FromPseudoAddress(params[1]); -#endif - - if (addr == NULL) - { - return pContext->ThrowNativeError("Address cannot be null"); - } - else if (reinterpret_cast(addr) < VALID_MINIMUM_MEMORY_ADDRESS) - { - return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr); - } - cell_t data = params[2]; - - NumberType size = static_cast(params[3]); - - switch(size) - { - case NumberType_Int8: - SourceHook::SetMemAccess(addr, sizeof(uint8_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); - *reinterpret_cast(addr) = data; - break; - case NumberType_Int16: - SourceHook::SetMemAccess(addr, sizeof(uint16_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); - *reinterpret_cast(addr) = data; - break; - case NumberType_Int32: - SourceHook::SetMemAccess(addr, sizeof(uint32_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); - *reinterpret_cast(addr) = data; - break; - default: - return pContext->ThrowNativeError("Invalid number types %d", size); - } - - return 0; -} - -static cell_t IsNullVector(IPluginContext *pContext, const cell_t *params) -{ - cell_t *pNullVec = pContext->GetNullRef(SP_NULL_VECTOR); - if (!pNullVec) - return 0; - - cell_t *addr; - pContext->LocalToPhysAddr(params[1], &addr); - - return addr == pNullVec; -} - -static cell_t IsNullString(IPluginContext *pContext, const cell_t *params) -{ - char *str; - if (pContext->LocalToStringNULL(params[1], &str) != SP_ERROR_NONE) - return 0; - - return str == nullptr; -} - -static cell_t FrameIterator_Create(IPluginContext *pContext, const cell_t *params) -{ - IFrameIterator *it = pContext->CreateFrameIterator(); - - SafeFrameIterator *iterator = new SafeFrameIterator(it); - - pContext->DestroyFrameIterator(it); - - Handle_t handle = handlesys->CreateHandle(g_FrameIter, iterator, pContext->GetIdentity(), g_pCoreIdent, NULL); - if (handle == BAD_HANDLE) - { - delete iterator; - return BAD_HANDLE; - } - - return handle; -} - -static cell_t FrameIterator_Next(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - SafeFrameIterator *iterator; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - return iterator->Next(); -} - -static cell_t FrameIterator_Reset(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - SafeFrameIterator *iterator; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - iterator->Reset(); - return 0; -} - -static cell_t FrameIterator_LineNumber(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - SafeFrameIterator *iterator; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - int lineNum = iterator->LineNumber(); - if (lineNum < 0) - { - return pContext->ThrowNativeError("Iterator out of bounds. Check return value of FrameIterator.Next"); - } - - return lineNum; -} - -static cell_t FrameIterator_GetFunctionName(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - SafeFrameIterator *iterator; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - const char* functionName = iterator->FunctionName(); - if (!functionName) - { - return pContext->ThrowNativeError("Iterator out of bounds. Check return value of FrameIterator.Next"); - } - - char* buffer; - pContext->LocalToString(params[2], &buffer); - size_t size = static_cast(params[3]); - - ke::SafeStrcpy(buffer, size, functionName); - return 0; -} - -static cell_t FrameIterator_GetFilePath(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = (Handle_t)params[1]; - HandleError err; - SafeFrameIterator *iterator; - - HandleSecurity sec; - sec.pIdentity = g_pCoreIdent; - sec.pOwner = pContext->GetIdentity(); - - if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) - { - return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); - } - - const char* filePath = iterator->FilePath(); - if (!filePath) - { - return pContext->ThrowNativeError("Iterator out of bounds. Check return value of FrameIterator.Next"); - } - - char* buffer; - pContext->LocalToString(params[2], &buffer); - size_t size = static_cast(params[3]); - - ke::SafeStrcpy(buffer, size, filePath); - return 0; -} - -static cell_t LogStackTrace(IPluginContext *pContext, const cell_t *params) -{ - char buffer[512]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); - - IFrameIterator *it = pContext->CreateFrameIterator(); - ke::Vector arr = g_DbgReporter.GetStackTrace(it); - pContext->DestroyFrameIterator(it); - - IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); - - g_Logger.LogError("[SM] Stack trace requested: %s", buffer); - g_Logger.LogError("[SM] Called from: %s", pPlugin->GetFilename()); - for (size_t i = 0; i < arr.length(); ++i) - { - g_Logger.LogError("%s", arr[i].c_str()); - } - return 0; -} - -REGISTER_NATIVES(coreNatives) -{ - {"ThrowError", ThrowError}, - {"GetTime", GetTime}, - {"FormatTime", FormatTime}, - {"GetPluginIterator", GetPluginIterator}, - {"MorePlugins", MorePlugins}, - {"ReadPlugin", ReadPlugin}, - {"GetPluginStatus", GetPluginStatus}, - {"GetPluginFilename", GetPluginFilename}, - {"IsPluginDebugging", IsPluginDebugging}, - {"GetPluginInfo", GetPluginInfo}, - {"SetFailState", SetFailState}, - {"GetSysTickCount", GetSysTickCount}, - {"AutoExecConfig", AutoExecConfig}, - {"MarkNativeAsOptional", MarkNativeAsOptional}, - {"RegPluginLibrary", RegPluginLibrary}, - {"LibraryExists", LibraryExists}, - {"LogAction", sm_LogAction}, - {"LogToFile", LogToFile}, - {"LogToFileEx", LogToFileEx}, - {"GetExtensionFileStatus", GetExtensionFileStatus}, - {"FindPluginByNumber", FindPluginByNumber}, - {"VerifyCoreVersion", VerifyCoreVersion}, - {"GetFeatureStatus", GetFeatureStatus}, - {"RequireFeature", RequireFeature}, - {"LoadFromAddress", LoadFromAddress}, - {"StoreToAddress", StoreToAddress}, - {"IsNullVector", IsNullVector}, - {"IsNullString", IsNullString}, - {"LogStackTrace", LogStackTrace}, - - {"FrameIterator.FrameIterator", FrameIterator_Create}, - {"FrameIterator.Next", FrameIterator_Next}, - {"FrameIterator.Reset", FrameIterator_Reset}, - {"FrameIterator.LineNumber.get", FrameIterator_LineNumber}, - {"FrameIterator.GetFunctionName", FrameIterator_GetFunctionName}, - {"FrameIterator.GetFilePath", FrameIterator_GetFilePath}, - {NULL, NULL}, + return 1; +} + +enum NumberType +{ + NumberType_Int8, + NumberType_Int16, + NumberType_Int32 +}; + +//memory addresses below 0x10000 are automatically considered invalid for dereferencing +#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000 + +static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params) +{ +#ifdef PLATFORM_X86 + void *addr = reinterpret_cast(params[1]); +#else + void *addr = pseudoAddr.FromPseudoAddress(params[1]); +#endif + + if (addr == NULL) + { + return pContext->ThrowNativeError("Address cannot be null"); + } + else if (reinterpret_cast(addr) < VALID_MINIMUM_MEMORY_ADDRESS) + { + return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr); + } + NumberType size = static_cast(params[2]); + + switch(size) + { + case NumberType_Int8: + return *reinterpret_cast(addr); + case NumberType_Int16: + return *reinterpret_cast(addr); + case NumberType_Int32: + return *reinterpret_cast(addr); + default: + return pContext->ThrowNativeError("Invalid number types %d", size); + } +} + + +static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params) +{ +#ifdef PLATFORM_X86 + void *addr = reinterpret_cast(params[1]); +#else + void *addr = pseudoAddr.FromPseudoAddress(params[1]); +#endif + + if (addr == NULL) + { + return pContext->ThrowNativeError("Address cannot be null"); + } + else if (reinterpret_cast(addr) < VALID_MINIMUM_MEMORY_ADDRESS) + { + return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr); + } + cell_t data = params[2]; + + NumberType size = static_cast(params[3]); + + switch(size) + { + case NumberType_Int8: + SourceHook::SetMemAccess(addr, sizeof(uint8_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + *reinterpret_cast(addr) = data; + break; + case NumberType_Int16: + SourceHook::SetMemAccess(addr, sizeof(uint16_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + *reinterpret_cast(addr) = data; + break; + case NumberType_Int32: + SourceHook::SetMemAccess(addr, sizeof(uint32_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + *reinterpret_cast(addr) = data; + break; + default: + return pContext->ThrowNativeError("Invalid number types %d", size); + } + + return 0; +} + +static cell_t IsNullVector(IPluginContext *pContext, const cell_t *params) +{ + cell_t *pNullVec = pContext->GetNullRef(SP_NULL_VECTOR); + if (!pNullVec) + return 0; + + cell_t *addr; + pContext->LocalToPhysAddr(params[1], &addr); + + return addr == pNullVec; +} + +static cell_t IsNullString(IPluginContext *pContext, const cell_t *params) +{ + char *str; + if (pContext->LocalToStringNULL(params[1], &str) != SP_ERROR_NONE) + return 0; + + return str == nullptr; +} + +static cell_t FrameIterator_Create(IPluginContext *pContext, const cell_t *params) +{ + IFrameIterator *it = pContext->CreateFrameIterator(); + + SafeFrameIterator *iterator = new SafeFrameIterator(it); + + pContext->DestroyFrameIterator(it); + + Handle_t handle = handlesys->CreateHandle(g_FrameIter, iterator, pContext->GetIdentity(), g_pCoreIdent, NULL); + if (handle == BAD_HANDLE) + { + delete iterator; + return BAD_HANDLE; + } + + return handle; +} + +static cell_t FrameIterator_Next(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + SafeFrameIterator *iterator; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + return iterator->Next(); +} + +static cell_t FrameIterator_Reset(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + SafeFrameIterator *iterator; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + iterator->Reset(); + return 0; +} + +static cell_t FrameIterator_LineNumber(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + SafeFrameIterator *iterator; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + int lineNum = iterator->LineNumber(); + if (lineNum < 0) + { + return pContext->ThrowNativeError("Iterator out of bounds. Check return value of FrameIterator.Next"); + } + + return lineNum; +} + +static cell_t FrameIterator_GetFunctionName(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + SafeFrameIterator *iterator; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + const char* functionName = iterator->FunctionName(); + if (!functionName) + { + return pContext->ThrowNativeError("Iterator out of bounds. Check return value of FrameIterator.Next"); + } + + char* buffer; + pContext->LocalToString(params[2], &buffer); + size_t size = static_cast(params[3]); + + ke::SafeStrcpy(buffer, size, functionName); + return 0; +} + +static cell_t FrameIterator_GetFilePath(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = (Handle_t)params[1]; + HandleError err; + SafeFrameIterator *iterator; + + HandleSecurity sec; + sec.pIdentity = g_pCoreIdent; + sec.pOwner = pContext->GetIdentity(); + + if ((err=handlesys->ReadHandle(hndl, g_FrameIter, &sec, (void **)&iterator)) != HandleError_None) + { + return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); + } + + const char* filePath = iterator->FilePath(); + if (!filePath) + { + return pContext->ThrowNativeError("Iterator out of bounds. Check return value of FrameIterator.Next"); + } + + char* buffer; + pContext->LocalToString(params[2], &buffer); + size_t size = static_cast(params[3]); + + ke::SafeStrcpy(buffer, size, filePath); + return 0; +} + +static cell_t LogStackTrace(IPluginContext *pContext, const cell_t *params) +{ + char buffer[512]; + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + + IFrameIterator *it = pContext->CreateFrameIterator(); + std::vector arr = g_DbgReporter.GetStackTrace(it); + pContext->DestroyFrameIterator(it); + + IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); + + g_Logger.LogError("[SM] Stack trace requested: %s", buffer); + g_Logger.LogError("[SM] Called from: %s", pPlugin->GetFilename()); + for (size_t i = 0; i < arr.size(); ++i) + { + g_Logger.LogError("%s", arr[i].c_str()); + } + return 0; +} + +REGISTER_NATIVES(coreNatives) +{ + {"ThrowError", ThrowError}, + {"GetTime", GetTime}, + {"FormatTime", FormatTime}, + {"GetPluginIterator", GetPluginIterator}, + {"MorePlugins", MorePlugins}, + {"ReadPlugin", ReadPlugin}, + {"GetPluginStatus", GetPluginStatus}, + {"GetPluginFilename", GetPluginFilename}, + {"IsPluginDebugging", IsPluginDebugging}, + {"GetPluginInfo", GetPluginInfo}, + {"SetFailState", SetFailState}, + {"GetSysTickCount", GetSysTickCount}, + {"AutoExecConfig", AutoExecConfig}, + {"MarkNativeAsOptional", MarkNativeAsOptional}, + {"RegPluginLibrary", RegPluginLibrary}, + {"LibraryExists", LibraryExists}, + {"LogAction", sm_LogAction}, + {"LogToFile", LogToFile}, + {"LogToFileEx", LogToFileEx}, + {"GetExtensionFileStatus", GetExtensionFileStatus}, + {"FindPluginByNumber", FindPluginByNumber}, + {"VerifyCoreVersion", VerifyCoreVersion}, + {"GetFeatureStatus", GetFeatureStatus}, + {"RequireFeature", RequireFeature}, + {"LoadFromAddress", LoadFromAddress}, + {"StoreToAddress", StoreToAddress}, + {"IsNullVector", IsNullVector}, + {"IsNullString", IsNullString}, + {"LogStackTrace", LogStackTrace}, + + {"FrameIterator.FrameIterator", FrameIterator_Create}, + {"FrameIterator.Next", FrameIterator_Next}, + {"FrameIterator.Reset", FrameIterator_Reset}, + {"FrameIterator.LineNumber.get", FrameIterator_LineNumber}, + {"FrameIterator.GetFunctionName", FrameIterator_GetFunctionName}, + {"FrameIterator.GetFilePath", FrameIterator_GetFilePath}, + {NULL, NULL}, }; diff --git a/core/logic/smn_database.cpp b/core/logic/smn_database.cpp index 5f8809da..af03261b 100644 --- a/core/logic/smn_database.cpp +++ b/core/logic/smn_database.cpp @@ -68,7 +68,7 @@ struct Transaction cell_t data; }; - ke::Vector entries; + std::vector entries; }; class DatabaseHelpers : @@ -1540,9 +1540,9 @@ static cell_t SQL_AddQuery(IPluginContext *pContext, const cell_t *params) Transaction::Entry entry; entry.query = query; entry.data = params[3]; - txn->entries.append(std::move(entry)); + txn->entries.push_back(std::move(entry)); - return cell_t(txn->entries.length() - 1); + return cell_t(txn->entries.size() - 1); } class TTransactOp : public IDBThreadOperation @@ -1564,7 +1564,7 @@ public: ~TTransactOp() { - for (size_t i = 0; i < results_.length(); i++) + for (size_t i = 0; i < results_.size(); i++) results_[i]->Destroy(); results_.clear(); } @@ -1585,7 +1585,7 @@ public: private: bool Succeeded() const { - return error_.length() == 0; + return error_.size() == 0; } void SetDbError() @@ -1617,7 +1617,7 @@ private: return; } - for (size_t i = 0; i < txn_->entries.length(); i++) + for (size_t i = 0; i < txn_->entries.size(); i++) { Transaction::Entry &entry = txn_->entries[i]; IQuery *result = Exec(entry.query.c_str()); @@ -1626,7 +1626,7 @@ private: failIndex_ = (cell_t)i; return; } - results_.append(result); + results_.push_back(result); } if (!db_->DoSimpleQuery("COMMIT")) @@ -1667,11 +1667,11 @@ private: // Add an extra refcount for the handle. db_->AddRef(); - assert(results_.length() == txn_->entries.length()); + assert(results_.size() == txn_->entries.size()); - 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++) + std::unique_ptr data = std::make_unique(results_.size()); + std::unique_ptr handles = std::make_unique(results_.size()); + for (size_t i = 0; i < results_.size(); i++) { CombinedQuery *obj = new CombinedQuery(results_[i], db_); Handle_t rh = CreateLocalHandle(hCombinedQueryType, obj, &sec); @@ -1682,7 +1682,7 @@ private: delete obj; for (size_t iter = 0; iter < i; iter++) handlesys->FreeHandle(handles[iter], &sec); - for (size_t iter = i; iter < results_.length(); iter++) + for (size_t iter = i; iter < results_.size(); iter++) results_[iter]->Destroy(); handlesys->FreeHandle(dbh, &sec); results_.clear(); @@ -1698,15 +1698,15 @@ private: { success_->PushCell(dbh); success_->PushCell(data_); - success_->PushCell(txn_->entries.length()); - success_->PushArray(handles.get(), results_.length()); - success_->PushArray(data.get(), results_.length()); + success_->PushCell(txn_->entries.size()); + success_->PushArray(handles.get(), results_.size()); + success_->PushArray(data.get(), results_.size()); success_->Execute(NULL); } // Cleanup. Note we clear results_, since freeing their handles will // call Destroy(), and we don't want to double-free in ~TTransactOp. - for (size_t i = 0; i < results_.length(); i++) + for (size_t i = 0; i < results_.size(); i++) handlesys->FreeHandle(handles[i], &sec); handlesys->FreeHandle(dbh, &sec); results_.clear(); @@ -1730,8 +1730,8 @@ public: { HandleSecurity sec(ident_, g_pCoreIdent); - std::unique_ptr data = std::make_unique(txn_->entries.length()); - for (size_t i = 0; i < txn_->entries.length(); i++) + std::unique_ptr data = std::make_unique(txn_->entries.size()); + for (size_t i = 0; i < txn_->entries.size(); i++) data[i] = txn_->entries[i].data; Handle_t dbh = CreateLocalHandle(g_DBMan.GetDatabaseType(), db_, &sec); @@ -1745,10 +1745,10 @@ public: { failure_->PushCell(dbh); failure_->PushCell(data_); - failure_->PushCell(txn_->entries.length()); + failure_->PushCell(txn_->entries.size()); failure_->PushString(error_.c_str()); failure_->PushCell(failIndex_); - failure_->PushArray(data.get(), txn_->entries.length()); + failure_->PushArray(data.get(), txn_->entries.size()); failure_->Execute(NULL); } @@ -1765,7 +1765,7 @@ private: cell_t data_; AutoHandleRooter autoHandle_; std::string error_; - ke::Vector results_; + std::vector results_; cell_t failIndex_; }; diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index c8fe82c6..8f0b5432 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -768,7 +768,7 @@ CoreProviderImpl::DefineCommand(const char *name, const char *help, const Comman ke::RefPtr hook = AddCommandHook(cmd, callback); ke::RefPtr impl = new CommandImpl(cmd, hook); - commands_.append(impl); + commands_.push_back(impl); } void CoreProviderImpl::InitializeHooks() diff --git a/core/provider.h b/core/provider.h index ff5d670e..d281ccdc 100644 --- a/core/provider.h +++ b/core/provider.h @@ -91,7 +91,7 @@ private: ConCommand *cmd_; ke::RefPtr hook_; }; - ke::Vector> commands_; + std::vector> commands_; }; extern CoreProviderImpl sCoreProviderImpl; diff --git a/extensions/clientprefs/cookie.cpp b/extensions/clientprefs/cookie.cpp index 7ab605e0..6c04fef5 100644 --- a/extensions/clientprefs/cookie.cpp +++ b/extensions/clientprefs/cookie.cpp @@ -59,7 +59,7 @@ void CookieManager::Unload() } /* Find all cookies and delete them */ - for (size_t iter = 0; iter < cookieList.length(); ++iter) + for (size_t iter = 0; iter < cookieList.size(); ++iter) delete cookieList[iter]; cookieList.clear(); @@ -95,7 +95,7 @@ Cookie *CookieManager::CreateCookie(const char *name, const char *description, C op->m_params.cookie = pCookie; cookieFinder.insert(name, pCookie); - cookieList.append(pCookie); + cookieList.push_back(pCookie); g_ClientPrefs.AddQueryToQueue(op); @@ -111,7 +111,7 @@ bool CookieManager::GetCookieValue(Cookie *pCookie, int client, char **value) { data = new CookieData(""); data->parent = pCookie; - clientData[client].append(data); + clientData[client].push_back(data); pCookie->data[client] = data; data->changed = false; data->timestamp = 0; @@ -130,7 +130,7 @@ bool CookieManager::SetCookieValue(Cookie *pCookie, int client, const char *valu { data = new CookieData(value); data->parent = pCookie; - clientData[client].append(data); + clientData[client].push_back(data); pCookie->data[client] = data; } else @@ -185,8 +185,8 @@ void CookieManager::OnClientDisconnecting(int client) g_ClientPrefs.ClearQueryCache(player->GetSerial()); } - ke::Vector &clientvec = clientData[client]; - for (size_t iter = 0; iter < clientvec.length(); ++iter) + std::vector &clientvec = clientData[client]; + for (size_t iter = 0; iter < clientvec.size(); ++iter) { current = clientvec[iter]; dbId = current->parent->dbid; @@ -263,7 +263,7 @@ void CookieManager::ClientConnectCallback(int serial, IQuery *data) pData->parent = parent; parent->data[client] = pData; - clientData[client].append(pData); + clientData[client].push_back(pData); } statsLoaded[client] = true; @@ -317,18 +317,18 @@ bool CookieManager::AreClientCookiesPending(int client) void CookieManager::OnPluginDestroyed(IPlugin *plugin) { - ke::Vector *pList; + std::vector *pList; if (plugin->GetProperty("SettingsMenuItems", (void **)&pList, true)) { - ke::Vector &menuitems = (*pList); + std::vector &menuitems = (*pList); char *name; ItemDrawInfo draw; const char *info; AutoMenuData * data; unsigned itemcount; - for (size_t p_iter = 0; p_iter < menuitems.length(); ++p_iter) + for (size_t p_iter = 0; p_iter < menuitems.size(); ++p_iter) { name = menuitems[p_iter]; itemcount = clientMenu->GetItemCount(); diff --git a/extensions/clientprefs/cookie.h b/extensions/clientprefs/cookie.h index 31b59f35..10c9df3c 100644 --- a/extensions/clientprefs/cookie.h +++ b/extensions/clientprefs/cookie.h @@ -132,12 +132,12 @@ public: public: IForward *cookieDataLoadedForward; - ke::Vector cookieList; + std::vector cookieList; IBaseMenu *clientMenu; private: NameHashSet cookieFinder; - ke::Vector clientData[SM_MAXPLAYERS+1]; + std::vector clientData[SM_MAXPLAYERS+1]; bool connected[SM_MAXPLAYERS+1]; bool statsLoaded[SM_MAXPLAYERS+1]; diff --git a/extensions/clientprefs/extension.cpp b/extensions/clientprefs/extension.cpp index e995f38a..e0e12e28 100644 --- a/extensions/clientprefs/extension.cpp +++ b/extensions/clientprefs/extension.cpp @@ -313,7 +313,7 @@ bool ClientPrefs::AddQueryToQueue(TQueryOp *query) std::lock_guard lock(queryLock); if (!Database) { - cachedQueries.append(query); + cachedQueries.push_back(query); return false; } @@ -331,7 +331,7 @@ void ClientPrefs::ProcessQueryCache() if (!Database) return; - for (size_t iter = 0; iter < cachedQueries.length(); ++iter) + for (size_t iter = 0; iter < cachedQueries.size(); ++iter) { TQueryOp *op = cachedQueries[iter]; op->SetDatabase(Database); @@ -373,13 +373,13 @@ void ClientPrefs::ClearQueryCache(int serial) { std::lock_guard lock(queryLock); - for (size_t iter = 0; iter < cachedQueries.length(); ++iter) + for (size_t iter = 0; iter < cachedQueries.size(); ++iter) { TQueryOp *op = cachedQueries[iter]; if (op && op->PullQueryType() == Query_SelectData && op->PullQuerySerial() == serial) { op->Destroy(); - cachedQueries.remove(iter--); + ke::RemoveAt(&cachedQueries, iter--); } } } diff --git a/extensions/clientprefs/extension.h b/extensions/clientprefs/extension.h index dde6d290..b14cc453 100644 --- a/extensions/clientprefs/extension.h +++ b/extensions/clientprefs/extension.h @@ -158,7 +158,7 @@ public: bool databaseLoading; private: - ke::Vector cachedQueries; + std::vector cachedQueries; std::mutex queryLock; IdentityToken_t *identity; }; diff --git a/extensions/clientprefs/natives.cpp b/extensions/clientprefs/natives.cpp index adffe6f1..a7b92799 100644 --- a/extensions/clientprefs/natives.cpp +++ b/extensions/clientprefs/natives.cpp @@ -299,7 +299,7 @@ static cell_t ReadCookieIterator(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Cookie iterator handle %x (error %d)", hndl, err); } - if (*iter >= g_CookieManager.cookieList.length()) + if (*iter >= g_CookieManager.cookieList.size()) { return 0; } @@ -356,18 +356,18 @@ cell_t AddSettingsMenuItem(IPluginContext *pContext, const cell_t *params) /* Track this in case the plugin unloads */ IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext()); - ke::Vector *pList = NULL; + std::vector *pList = NULL; if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList) { - pList = new ke::Vector; + pList = new std::vector; pPlugin->SetProperty("SettingsMenuItems", pList); } char *copyarray = new char[strlen(display)+1]; g_pSM->Format(copyarray, strlen(display)+1, "%s", display); - pList->append(copyarray); + pList->push_back(copyarray); return 0; } @@ -426,18 +426,18 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params) /* Track this in case the plugin unloads */ IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext()); - ke::Vector *pList = NULL; + std::vector *pList = NULL; if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList) { - pList = new ke::Vector; + pList = new std::vector; pPlugin->SetProperty("SettingsMenuItems", pList); } char *copyarray = new char[strlen(display)+1]; g_pSM->Format(copyarray, strlen(display)+1, "%s", display); - pList->append(copyarray); + pList->push_back(copyarray); return 0; } diff --git a/extensions/cstrike/RegNatives.cpp b/extensions/cstrike/RegNatives.cpp index 29e98ca5..0e88e663 100644 --- a/extensions/cstrike/RegNatives.cpp +++ b/extensions/cstrike/RegNatives.cpp @@ -36,12 +36,12 @@ RegNatives g_RegNatives; void RegNatives::Register(ICallWrapper *pWrapper) { - m_Natives.append(pWrapper); + m_Natives.push_back(pWrapper); } void RegNatives::UnregisterAll() { - for (size_t iter = 0; iter < m_Natives.length(); ++iter) + for (size_t iter = 0; iter < m_Natives.size(); ++iter) { m_Natives[iter]->Destroy(); } diff --git a/extensions/cstrike/RegNatives.h b/extensions/cstrike/RegNatives.h index 5042c5a5..b6bcb933 100644 --- a/extensions/cstrike/RegNatives.h +++ b/extensions/cstrike/RegNatives.h @@ -40,7 +40,7 @@ public: void Register(ICallWrapper *pWrapper); void UnregisterAll(); private: - ke::Vector m_Natives; + std::vector m_Natives; }; extern RegNatives g_RegNatives; diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index d7f08e25..f6386463 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -101,7 +101,7 @@ SDKHooks g_Interface; SMEXT_LINK(&g_Interface); CGlobalVars *gpGlobals; -ke::Vector g_HookList[SDKHook_MAXHOOKS]; +std::vector g_HookList[SDKHook_MAXHOOKS]; IBinTools *g_pBinTools = NULL; ICvar *icvar = NULL; @@ -454,17 +454,17 @@ FeatureStatus SDKHooks::GetFeatureStatus(FeatureType type, const char *name) * Functions */ -static void PopulateCallbackList(const ke::Vector &source, ke::Vector &destination, int entity) +static void PopulateCallbackList(const std::vector &source, std::vector &destination, int entity) { - destination.ensure(8); /* Skip trivial allocations as AMTL uses length<<1. */ - for (size_t iter = 0; iter < source.length(); ++iter) + destination.reserve(8); + for (size_t iter = 0; iter < source.size(); ++iter) { if (source[iter].entity != entity) { continue; } - destination.append(source[iter].callback); + destination.push_back(source[iter].callback); } } @@ -483,8 +483,8 @@ cell_t SDKHooks::Call(CBaseEntity *pEnt, SDKHookType type, CBaseEntity *pOther) cell_t ret = Pl_Continue; CVTableHook vhook(pEnt); - ke::Vector &vtablehooklist = g_HookList[type]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[type]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -494,9 +494,9 @@ cell_t SDKHooks::Call(CBaseEntity *pEnt, SDKHookType type, CBaseEntity *pOther) int entity = gamehelpers->EntityToBCompatRef(pEnt); int other = gamehelpers->EntityToBCompatRef(pOther); - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -584,8 +584,8 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac size_t entry; CVTableHook vhook(pEnt); - ke::Vector &vtablehooklist = g_HookList[type]; - for (entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[type]; + for (entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook == vtablehooklist[entry]->vtablehook) { @@ -593,7 +593,7 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac } } - if (entry == vtablehooklist.length()) + if (entry == vtablehooklist.size()) { int hookid = 0; switch(type) @@ -738,14 +738,14 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac CVTableList *vtablelist = new CVTableList; vtablelist->vtablehook = new CVTableHook(vhook); - vtablehooklist.append(vtablelist); + vtablehooklist.push_back(vtablelist); } // Add hook to hook list HookList hook; hook.entity = gamehelpers->EntityToBCompatRef(pEnt); hook.callback = callback; - vtablehooklist[entry]->hooks.append(hook); + vtablehooklist[entry]->hooks.push_back(hook); return HookRet_Successful; } @@ -760,24 +760,24 @@ void SDKHooks::Unhook(CBaseEntity *pEntity) int entity = gamehelpers->EntityToBCompatRef(pEntity); for (size_t type = 0; type < SDKHook_MAXHOOKS; ++type) { - ke::Vector &vtablehooklist = g_HookList[type]; - for (size_t listentry = 0; listentry < vtablehooklist.length(); ++listentry) + std::vector &vtablehooklist = g_HookList[type]; + for (size_t listentry = 0; listentry < vtablehooklist.size(); ++listentry) { - ke::Vector &pawnhooks = vtablehooklist[listentry]->hooks; - for (size_t entry = 0; entry < pawnhooks.length(); ++entry) + std::vector &pawnhooks = vtablehooklist[listentry]->hooks; + for (size_t entry = 0; entry < pawnhooks.size(); ++entry) { if (entity != pawnhooks[entry].entity) { continue; } - pawnhooks.remove(entry--); + ke::RemoveAt(&pawnhooks, entry--); } - if (pawnhooks.length() == 0) + if (pawnhooks.size() == 0) { delete vtablehooklist[listentry]; - vtablehooklist.remove(listentry--); + ke::RemoveAt(&vtablehooklist, listentry--); } } } @@ -787,24 +787,24 @@ void SDKHooks::Unhook(IPluginContext *pContext) { for (size_t type = 0; type < SDKHook_MAXHOOKS; ++type) { - ke::Vector &vtablehooklist = g_HookList[type]; - for (size_t listentry = 0; listentry < vtablehooklist.length(); ++listentry) + std::vector &vtablehooklist = g_HookList[type]; + for (size_t listentry = 0; listentry < vtablehooklist.size(); ++listentry) { - ke::Vector &pawnhooks = vtablehooklist[listentry]->hooks; - for (size_t entry = 0; entry < pawnhooks.length(); ++entry) + std::vector &pawnhooks = vtablehooklist[listentry]->hooks; + for (size_t entry = 0; entry < pawnhooks.size(); ++entry) { if (pContext != NULL && pContext != pawnhooks[entry].callback->GetParentRuntime()->GetDefaultContext()) { continue; } - pawnhooks.remove(entry--); + ke::RemoveAt(&pawnhooks, entry--); } - if (pawnhooks.length() == 0) + if (pawnhooks.size() == 0) { delete vtablehooklist[listentry]; - vtablehooklist.remove(listentry--); + ke::RemoveAt(&vtablehooklist, listentry--); } } } @@ -819,8 +819,8 @@ void SDKHooks::Unhook(int entity, SDKHookType type, IPluginFunction *pCallback) } CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[type]; - for (size_t listentry = 0; listentry < vtablehooklist.length(); ++listentry) + std::vector &vtablehooklist = g_HookList[type]; + for (size_t listentry = 0; listentry < vtablehooklist.size(); ++listentry) { if (vhook != vtablehooklist[listentry]->vtablehook) { @@ -829,8 +829,8 @@ void SDKHooks::Unhook(int entity, SDKHookType type, IPluginFunction *pCallback) entity = gamehelpers->EntityToBCompatRef(pEntity); - ke::Vector &pawnhooks = vtablehooklist[listentry]->hooks; - for (size_t entry = 0; entry < pawnhooks.length(); ++entry) + std::vector &pawnhooks = vtablehooklist[listentry]->hooks; + for (size_t entry = 0; entry < pawnhooks.size(); ++entry) { HookList &hookentry = pawnhooks[entry]; if (entity != hookentry.entity || pCallback != hookentry.callback) @@ -838,13 +838,13 @@ void SDKHooks::Unhook(int entity, SDKHookType type, IPluginFunction *pCallback) continue; } - pawnhooks.remove(entry--); + ke::RemoveAt(&pawnhooks, entry--); } - if (pawnhooks.length() == 0) + if (pawnhooks.size() == 0) { delete vtablehooklist[listentry]; - vtablehooklist.remove(listentry); + ke::RemoveAt(&vtablehooklist, listentry); } break; @@ -932,8 +932,8 @@ bool SDKHooks::Hook_CanBeAutobalanced() CBaseEntity *pPlayer = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pPlayer); - ke::Vector &vtablehooklist = g_HookList[SDKHook_CanBeAutobalanced]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_CanBeAutobalanced]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -945,9 +945,9 @@ bool SDKHooks::Hook_CanBeAutobalanced() bool origRet = SH_MCALL(pPlayer, CanBeAutobalanced)(); bool newRet = origRet; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { cell_t res = origRet; IPluginFunction *callback = callbackList[entry]; @@ -1000,8 +1000,8 @@ void SDKHooks::Hook_FireBulletsPost(const FireBulletsInfo_t &info) RETURN_META(MRES_IGNORED); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_FireBulletsPost]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_FireBulletsPost]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1010,9 +1010,9 @@ void SDKHooks::Hook_FireBulletsPost(const FireBulletsInfo_t &info) const char *weapon = pInfo->GetWeaponName(); - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1034,8 +1034,8 @@ int SDKHooks::Hook_GetMaxHealth() int original_max = SH_MCALL(pEntity, GetMaxHealth)(); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_GetMaxHealth]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_GetMaxHealth]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1048,9 +1048,9 @@ int SDKHooks::Hook_GetMaxHealth() cell_t res = Pl_Continue; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1078,8 +1078,8 @@ int SDKHooks::HandleOnTakeDamageHook(CTakeDamageInfoHack &info, SDKHookType hook CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[hookType]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[hookType]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1101,9 +1101,9 @@ int SDKHooks::HandleOnTakeDamageHook(CTakeDamageInfoHack &info, SDKHookType hook cell_t res, ret = Pl_Continue; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1169,8 +1169,8 @@ int SDKHooks::HandleOnTakeDamageHookPost(CTakeDamageInfoHack &info, SDKHookType CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[hookType]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[hookType]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1179,9 +1179,9 @@ int SDKHooks::HandleOnTakeDamageHookPost(CTakeDamageInfoHack &info, SDKHookType int entity = gamehelpers->EntityToBCompatRef(pEntity); - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1257,8 +1257,8 @@ bool SDKHooks::Hook_Reload() CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_Reload]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_Reload]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1268,9 +1268,9 @@ bool SDKHooks::Hook_Reload() int entity = gamehelpers->EntityToBCompatRef(pEntity); cell_t res = Pl_Continue; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1291,8 +1291,8 @@ bool SDKHooks::Hook_ReloadPost() CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_ReloadPost]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_ReloadPost]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1302,9 +1302,9 @@ bool SDKHooks::Hook_ReloadPost() int entity = gamehelpers->EntityToBCompatRef(pEntity); cell_t origreturn = META_RESULT_ORIG_RET(bool) ? 1 : 0; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1333,8 +1333,8 @@ bool SDKHooks::Hook_ShouldCollide(int collisionGroup, int contentsMask) CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_ShouldCollide]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_ShouldCollide]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1345,9 +1345,9 @@ bool SDKHooks::Hook_ShouldCollide(int collisionGroup, int contentsMask) cell_t origRet = ((META_RESULT_STATUS >= MRES_OVERRIDE)?(META_RESULT_OVERRIDE_RET(bool)):(META_RESULT_ORIG_RET(bool))) ? 1 : 0; cell_t res = 0; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1374,8 +1374,8 @@ void SDKHooks::Hook_Spawn() CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_Spawn]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_Spawn]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1385,9 +1385,9 @@ void SDKHooks::Hook_Spawn() int entity = gamehelpers->EntityToBCompatRef(pEntity); cell_t res = Pl_Continue; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1460,8 +1460,8 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_TraceAttack]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_TraceAttack]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1476,9 +1476,9 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, int ammotype = info.GetAmmoType(); cell_t res, ret = Pl_Continue; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1541,8 +1541,8 @@ void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vec CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_TraceAttackPost]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_TraceAttackPost]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1551,9 +1551,9 @@ void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vec int entity = gamehelpers->EntityToBCompatRef(pEntity); - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1578,8 +1578,8 @@ void SDKHooks::Hook_Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_Use]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_Use]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1591,9 +1591,9 @@ void SDKHooks::Hook_Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE int caller = gamehelpers->EntityToBCompatRef(pCaller); cell_t ret = Pl_Continue; - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); @@ -1618,8 +1618,8 @@ void SDKHooks::Hook_UsePost(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); CVTableHook vhook(pEntity); - ke::Vector &vtablehooklist = g_HookList[SDKHook_UsePost]; - for (size_t entry = 0; entry < vtablehooklist.length(); ++entry) + std::vector &vtablehooklist = g_HookList[SDKHook_UsePost]; + for (size_t entry = 0; entry < vtablehooklist.size(); ++entry) { if (vhook != vtablehooklist[entry]->vtablehook) { @@ -1630,9 +1630,9 @@ void SDKHooks::Hook_UsePost(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T int activator = gamehelpers->EntityToBCompatRef(pActivator); int caller = gamehelpers->EntityToBCompatRef(pCaller); - ke::Vector callbackList; + std::vector callbackList; PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity); - for (entry = 0; entry < callbackList.length(); ++entry) + for (entry = 0; entry < callbackList.size(); ++entry) { IPluginFunction *callback = callbackList[entry]; callback->PushCell(entity); diff --git a/extensions/sdkhooks/extension.h b/extensions/sdkhooks/extension.h index 580be1d8..419a9dd8 100644 --- a/extensions/sdkhooks/extension.h +++ b/extensions/sdkhooks/extension.h @@ -127,7 +127,7 @@ public: }; public: CVTableHook *vtablehook; - ke::Vector hooks; + std::vector hooks; }; class IEntityListener @@ -344,7 +344,7 @@ private: }; extern CGlobalVars *gpGlobals; -extern ke::Vector g_HookList[SDKHook_MAXHOOKS]; +extern std::vector g_HookList[SDKHook_MAXHOOKS]; extern ICvar *icvar; diff --git a/extensions/sdktools/hooks.cpp b/extensions/sdktools/hooks.cpp index 3ef57985..2371489a 100644 --- a/extensions/sdktools/hooks.cpp +++ b/extensions/sdktools/hooks.cpp @@ -169,9 +169,9 @@ void CHookManager::PlayerRunCmdHook(int client, bool post) return; } - ke::Vector &runUserCmdHookVec = post ? m_runUserCmdPostHooks : m_runUserCmdHooks; + std::vector &runUserCmdHookVec = post ? m_runUserCmdPostHooks : m_runUserCmdHooks; CVTableHook hook(pEntity); - for (size_t i = 0; i < runUserCmdHookVec.length(); ++i) + for (size_t i = 0; i < runUserCmdHookVec.size(); ++i) { if (hook == runUserCmdHookVec[i]) { @@ -186,7 +186,7 @@ void CHookManager::PlayerRunCmdHook(int client, bool post) hookid = SH_ADD_MANUALVPHOOK(PlayerRunCmdHook, pEntity, SH_MEMBER(this, &CHookManager::PlayerRunCmd), false); hook.SetHookID(hookid); - runUserCmdHookVec.append(new CVTableHook(hook)); + runUserCmdHookVec.push_back(new CVTableHook(hook)); } void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) @@ -332,16 +332,16 @@ void CHookManager::NetChannelHook(int client) } else #endif - if (!m_netChannelHooks.length()) + if (!m_netChannelHooks.size()) { CVTableHook filehook(basefilesystem); int hookid = SH_ADD_VPHOOK(IBaseFileSystem, FileExists, basefilesystem, SH_MEMBER(this, &CHookManager::FileExists), false); filehook.SetHookID(hookid); - m_netChannelHooks.append(new CVTableHook(filehook)); + m_netChannelHooks.push_back(new CVTableHook(filehook)); } - for (iter = 0; iter < m_netChannelHooks.length(); ++iter) + for (iter = 0; iter < m_netChannelHooks.size(); ++iter) { if (nethook == m_netChannelHooks[iter]) { @@ -349,19 +349,19 @@ void CHookManager::NetChannelHook(int client) } } - if (iter == m_netChannelHooks.length()) + if (iter == m_netChannelHooks.size()) { int hookid = SH_ADD_VPHOOK(INetChannel, SendFile, pNetChannel, SH_MEMBER(this, &CHookManager::SendFile), false); nethook.SetHookID(hookid); - m_netChannelHooks.append(new CVTableHook(nethook)); + m_netChannelHooks.push_back(new CVTableHook(nethook)); hookid = SH_ADD_VPHOOK(INetChannel, ProcessPacket, pNetChannel, SH_MEMBER(this, &CHookManager::ProcessPacket), false); nethook.SetHookID(hookid); - m_netChannelHooks.append(new CVTableHook(nethook)); + m_netChannelHooks.push_back(new CVTableHook(nethook)); hookid = SH_ADD_VPHOOK(INetChannel, ProcessPacket, pNetChannel, SH_MEMBER(this, &CHookManager::ProcessPacket_Post), true); nethook.SetHookID(hookid); - m_netChannelHooks.append(new CVTableHook(nethook)); + m_netChannelHooks.push_back(new CVTableHook(nethook)); } } } @@ -508,7 +508,7 @@ void CHookManager::OnPluginUnloaded(IPlugin *plugin) { if (PRCH_used && !m_usercmdsFwd->GetFunctionCount()) { - for (size_t i = 0; i < m_runUserCmdHooks.length(); ++i) + for (size_t i = 0; i < m_runUserCmdHooks.size(); ++i) { delete m_runUserCmdHooks[i]; } @@ -519,7 +519,7 @@ void CHookManager::OnPluginUnloaded(IPlugin *plugin) if (PRCHPost_used && !m_usercmdsPostFwd->GetFunctionCount()) { - for (size_t i = 0; i < m_runUserCmdPostHooks.length(); ++i) + for (size_t i = 0; i < m_runUserCmdPostHooks.size(); ++i) { delete m_runUserCmdPostHooks[i]; } @@ -530,7 +530,7 @@ void CHookManager::OnPluginUnloaded(IPlugin *plugin) if (FILE_used && !m_netFileSendFwd->GetFunctionCount() && !m_netFileReceiveFwd->GetFunctionCount()) { - for (size_t i = 0; i < m_netChannelHooks.length(); ++i) + for (size_t i = 0; i < m_netChannelHooks.size(); ++i) { delete m_netChannelHooks[i]; } diff --git a/extensions/sdktools/hooks.h b/extensions/sdktools/hooks.h index f536753b..40011422 100644 --- a/extensions/sdktools/hooks.h +++ b/extensions/sdktools/hooks.h @@ -75,9 +75,9 @@ private: IForward *m_usercmdsPostFwd; IForward *m_netFileSendFwd; IForward *m_netFileReceiveFwd; - ke::Vector m_runUserCmdHooks; - ke::Vector m_runUserCmdPostHooks; - ke::Vector m_netChannelHooks; + std::vector m_runUserCmdHooks; + std::vector m_runUserCmdPostHooks; + std::vector m_netChannelHooks; INetChannel *m_pActiveNetChannel; bool m_bFSTranHookWarned = false; bool m_bReplayEnabled = false; diff --git a/extensions/tf2/RegNatives.cpp b/extensions/tf2/RegNatives.cpp index 19c0aff2..1ba8f687 100644 --- a/extensions/tf2/RegNatives.cpp +++ b/extensions/tf2/RegNatives.cpp @@ -36,12 +36,12 @@ RegNatives g_RegNatives; void RegNatives::Register(ICallWrapper *pWrapper) { - m_Natives.append(pWrapper); + m_Natives.push_back(pWrapper); } void RegNatives::UnregisterAll() { - for (size_t iter = 0; iter < m_Natives.length(); ++iter) + for (size_t iter = 0; iter < m_Natives.size(); ++iter) { m_Natives[iter]->Destroy(); } diff --git a/extensions/tf2/RegNatives.h b/extensions/tf2/RegNatives.h index 2ecd3c4b..b3e27aee 100644 --- a/extensions/tf2/RegNatives.h +++ b/extensions/tf2/RegNatives.h @@ -40,7 +40,7 @@ public: void Register(ICallWrapper *pWrapper); void UnregisterAll(); private: - ke::Vector m_Natives; + std::vector m_Natives; }; extern RegNatives g_RegNatives; diff --git a/public/amtl b/public/amtl index 0d11efc7..abb3b74a 160000 --- a/public/amtl +++ b/public/amtl @@ -1 +1 @@ -Subproject commit 0d11efc79bcfcb9640e73d5c9e6516314218372a +Subproject commit abb3b74a1a58803fcf43f24936c3f595c2faf081 diff --git a/sourcepawn b/sourcepawn index 71016c40..7db5de57 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit 71016c40cfee83ff3f7e9c2b5c10e2e5a77952b9 +Subproject commit 7db5de576c3e7cbadc854a6d34b40ac659216e6b