diff --git a/AMBuildScript b/AMBuildScript index 50af518b5a..54249cab87 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -267,8 +267,6 @@ class SMConfig(object): cxx.cxxflags += ['-Wno-inconsistent-missing-override'] if cxx.version >= 'clang-2.9' or cxx.version >= 'apple-clang-3.0': cxx.cxxflags += ['-Wno-null-dereference'] - if have_clang or (cxx.version >= 'gcc-4.6'): - cxx.cflags += ['-Wno-narrowing'] if have_clang or (cxx.version >= 'gcc-4.7'): cxx.cxxflags += ['-Wno-delete-non-virtual-dtor'] if cxx.version >= 'gcc-4.8': @@ -325,6 +323,7 @@ class SMConfig(object): ] cxx.cflags += [ '/W3', + '/WX' ] cxx.cxxflags += [ '/EHsc', @@ -401,7 +400,7 @@ class SMConfig(object): cxx.cxxflags += ['-stdlib=libc++'] def configure_windows(self, cxx): - cxx.defines += ['WIN32', '_WINDOWS'] + cxx.defines += ['WIN32', '_WINDOWS', '_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING'] def add_libamtl(self): # Add libamtl. diff --git a/bridge/include/IFileSystemBridge.h b/bridge/include/IFileSystemBridge.h index 73fdec8d60..a0f9e2ce0c 100644 --- a/bridge/include/IFileSystemBridge.h +++ b/bridge/include/IFileSystemBridge.h @@ -44,9 +44,9 @@ class IFileSystemBridge virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0; virtual bool EndOfFile(FileHandle_t file) = 0; virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0; - virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0; - virtual int Read(void* pOutput, int size, FileHandle_t file) = 0; - virtual int Write(void const* pInput, int size, FileHandle_t file) = 0; + virtual size_t Size(const char *pFileName, const char *pPathID = 0) = 0; + virtual size_t Read(void* pOutput, size_t size, FileHandle_t file) = 0; + virtual size_t Write(void const* pInput, size_t size, FileHandle_t file) = 0; virtual void Seek(FileHandle_t file, int post, int seekType) = 0; virtual unsigned int Tell(FileHandle_t file) = 0; virtual int FPrint(FileHandle_t file, const char *pData) = 0; diff --git a/bridge/include/LogicProvider.h b/bridge/include/LogicProvider.h index 7c01a0f21c..f665fd875d 100644 --- a/bridge/include/LogicProvider.h +++ b/bridge/include/LogicProvider.h @@ -61,7 +61,7 @@ struct sm_logic_t size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *); bool (*CoreTranslate)(char *, size_t, const char *, unsigned int, size_t *, ...); void (*AddCorePhraseFile)(const char *filename); - unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool); + size_t (*ReplaceAll)(char*, size_t, const char *, const char *, bool); char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool); size_t (*DecodeHexString)(unsigned char *, size_t, const char *); IGameConfig * (*GetCoreGameConfig)(); diff --git a/core/CellRecipientFilter.h b/core/CellRecipientFilter.h index 082d6cdbb3..a6c16acf50 100644 --- a/core/CellRecipientFilter.h +++ b/core/CellRecipientFilter.h @@ -76,7 +76,7 @@ inline bool CellRecipientFilter::IsInitMessage() const inline int CellRecipientFilter::GetRecipientCount() const { - return m_Size; + return (int)m_Size; } inline int CellRecipientFilter::GetRecipientIndex(int slot) const diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index dcd5d8ed0a..d93bf68434 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -276,7 +276,7 @@ void ConVarManager::OnHandleDestroy(HandleType_t type, void *object) { } -bool ConVarManager::GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) +bool ConVarManager::GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) { *pSize = sizeof(ConVar) + sizeof(ConVarInfo); return true; diff --git a/core/ConVarManager.h b/core/ConVarManager.h index b541baf9cb..a8958c7a8b 100644 --- a/core/ConVarManager.h +++ b/core/ConVarManager.h @@ -108,20 +108,20 @@ class ConVarManager : ConVarManager(); ~ConVarManager(); public: // SMGlobalClass - void OnSourceModStartup(bool late); - void OnSourceModAllInitialized(); - void OnSourceModShutdown(); + void OnSourceModStartup(bool late) override; + void OnSourceModAllInitialized() override; + void OnSourceModShutdown() override; public: // IHandleTypeDispatch - void OnHandleDestroy(HandleType_t type, void *object); - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize); + void OnHandleDestroy(HandleType_t type, void *object) override; + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override; public: // IPluginsListener - void OnPluginUnloaded(IPlugin *plugin); + void OnPluginUnloaded(IPlugin *plugin) override; public: //IRootConsoleCommand void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override; public: //IConCommandTracker void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) override; public: //IClientListener - void OnClientDisconnected(int client); + void OnClientDisconnected(int client) override; public: /** * Create a convar and return a handle to it. diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index f2b32f72b9..c75b1d5bab 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -516,7 +516,7 @@ void SM_ExecuteForPlugin(IPluginContext *ctx) { SMPlugin *plugin = scripts->FindPluginByContext(ctx->GetContext()); - unsigned int num = plugin->GetConfigCount(); + size_t num = plugin->GetConfigCount(); if (!num) { SM_DoSingleExecFwds(ctx); @@ -547,7 +547,7 @@ void SM_ExecuteAllConfigs() for (size_t i = 0; i < plugins->size(); i++) { SMPlugin *plugin = plugins->at(i); - unsigned int num = plugin->GetConfigCount(); + size_t num = plugin->GetConfigCount(); bool can_create = true; for (unsigned int i=0; i<num; i++) { diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 53af3dc891..13ca4ee8e7 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -1181,8 +1181,8 @@ const char *CHalfLife2::GetEntityClassname(edict_t * pEdict) const char *CHalfLife2::GetEntityClassname(CBaseEntity *pEntity) { - static int offset = -1; - if (offset == -1) + static size_t offset = INVALID_OFFSET; + if (offset == INVALID_OFFSET) { CBaseEntity *pGetterEnt = ReferenceToEntity(0); if (pGetterEnt == NULL) @@ -1468,8 +1468,8 @@ string_t CHalfLife2::AllocPooledString(const char *pszValue) auto *pDataMap = GetDataMap(pEntity); assert(pDataMap); - static int iNameOffset = -1; - if (iNameOffset == -1) + static size_t iNameOffset = INVALID_OFFSET; + if (iNameOffset == INVALID_OFFSET) { sm_datatable_info_t info; bool found = FindDataMapInfo(pDataMap, "m_iName", &info); diff --git a/core/MenuManager.cpp b/core/MenuManager.cpp index 68dd2bb288..b37404080c 100644 --- a/core/MenuManager.cpp +++ b/core/MenuManager.cpp @@ -111,7 +111,7 @@ void MenuManager::OnHandleDestroy(HandleType_t type, void *object) } } -bool MenuManager::GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) +bool MenuManager::GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) { if (type == m_MenuType) { @@ -244,14 +244,14 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord struct { - unsigned int position; + size_t position; ItemDrawInfo draw; } drawItems[10]; /* Figure out how many items to draw */ IMenuStyle *style = menu->GetDrawStyle(); unsigned int pgn = menu->GetPagination(); - unsigned int maxItems = style->GetMaxPageItems(); + size_t maxItems = style->GetMaxPageItems(); bool exitButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT; bool novoteButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_NOVOTE) == MENUFLAG_BUTTON_NOVOTE; @@ -275,8 +275,8 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord return NULL; } - unsigned int totalItems = menu->GetItemCount(); - unsigned int startItem = 0; + size_t totalItems = menu->GetItemCount(); + size_t startItem = 0; /* For pagination, find the starting point. */ if (pgn != MENU_NO_PAGINATION) @@ -313,7 +313,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord IMenuPanel *panel = menu->CreatePanel(); IMenuHandler *mh = md.mh; bool foundExtra = false; - unsigned int extraItem = 0; + size_t extraItem = 0; if (panel == NULL) { @@ -326,8 +326,8 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord * 2) We reach one OVER the maximum number of slot items * 3) We have reached maxItems and pagination is MENU_NO_PAGINATION */ - unsigned int i = startItem; - unsigned int foundItems = 0; + size_t i = startItem; + size_t foundItems = 0; while (totalItems) { ItemDrawInfo &dr = drawItems[foundItems].draw; @@ -410,7 +410,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord } } - unsigned int lastItem = 0; + size_t lastItem = 0; ItemDrawInfo dr; /* Find the last feasible item to search from. */ if (order == ItemOrder_Descending) @@ -463,7 +463,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord /* Draw the item according to the order */ menu_slots_t *slots = md.slots; - unsigned int position = 0; /* Keep track of the last position */ + size_t position = 0; /* Keep track of the last position */ if (novoteButton) { @@ -504,7 +504,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord } else if (order == ItemOrder_Descending) { - unsigned int i = foundItems; + size_t i = foundItems; /* NOTE: There will always be at least one item because * of the check earlier. */ @@ -545,7 +545,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord } /* Calculate how many items we are allowed for control stuff */ - unsigned int padding = style->GetMaxPageItems() - maxItems; + size_t padding = style->GetMaxPageItems() - maxItems; /* Add the number of available slots */ padding += (maxItems - foundItems); @@ -701,7 +701,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord } /* Lastly, fill in any slots we could have missed */ - for (unsigned int i = position + 1; i < 10; i++) + for (size_t i = position + 1; i < 10; i++) { slots[i].type = ItemSel_None; } diff --git a/core/MenuManager.h b/core/MenuManager.h index 3c75347ef7..16d6b1a7eb 100644 --- a/core/MenuManager.h +++ b/core/MenuManager.h @@ -89,7 +89,7 @@ class MenuManager : bool RedrawClientVoteMenu2(int client, bool revote); public: //IHandleTypeDispatch void OnHandleDestroy(HandleType_t type, void *object); - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize); + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize); public: HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu); HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style); diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index b35142fce8..960737ef6e 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -280,7 +280,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press) } bool cancel = false; - unsigned int item = 0; + size_t item = 0; MenuCancelReason reason = MenuCancel_Exit; MenuEndReason end_reason = MenuEnd_Selected; menu_states_t &states = player->states; @@ -289,7 +289,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press) IMenuHandler *mh = states.mh; IBaseMenu *menu = states.menu; - unsigned int item_on_page = states.item_on_page; + size_t item_on_page = states.item_on_page; assert(mh != NULL); @@ -470,7 +470,7 @@ bool BaseMenuStyle::DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, bool BaseMenuStyle::DoClientMenu(int client, CBaseMenu *menu, - unsigned int first_item, + size_t first_item, IMenuHandler *mh, unsigned int time) { @@ -644,7 +644,7 @@ bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw) return true; } -bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw) +bool CBaseMenu::InsertItem(size_t position, const char *info, const ItemDrawInfo &draw) { if (m_Pagination == (unsigned)MENU_NO_PAGINATION && m_items.size() >= m_pStyle->GetMaxPageItems()) @@ -665,7 +665,7 @@ bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDr return true; } -bool CBaseMenu::RemoveItem(unsigned int position) +bool CBaseMenu::RemoveItem(size_t position) { if (position >= m_items.size()) return false; @@ -679,7 +679,7 @@ void CBaseMenu::RemoveAllItems() m_items.clear(); } -const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =NULL */, int client/* =0 */) +const char *CBaseMenu::GetItemInfo(size_t position, ItemDrawInfo *draw/* =NULL */, int client/* =0 */) { if (position >= m_items.size()) return NULL; @@ -701,10 +701,15 @@ const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* = void CBaseMenu::ShufflePerClient(int start, int stop) { // limit map len to 255 items since it's using uint8 - int length = MIN(GetItemCount(), 255); + size_t length = MIN(GetItemCount(), 255); if (stop >= 0) length = MIN(length, stop); + if (length == 0) + { + return; + } + for (int i = 1; i <= SM_MAXPLAYERS; i++) { // populate per-client map ... @@ -713,7 +718,7 @@ void CBaseMenu::ShufflePerClient(int start, int stop) m_RandomMaps[i][j] = j; // ... and random shuffle it - for (int j = length - 1; j > start; j--) + for (size_t j = length - 1; j > start; j--) { int x = rand() % (j - start + 1) + start; uint8_t tmp = m_RandomMaps[i][x]; @@ -743,7 +748,7 @@ bool CBaseMenu::IsPerClientShuffled() return false; } -unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position) +size_t CBaseMenu::GetRealItemIndex(int client, size_t position) { if (client > 0 && position < m_RandomMaps[client].size()) { @@ -754,7 +759,7 @@ unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position) return position; } -unsigned int CBaseMenu::GetItemCount() +size_t CBaseMenu::GetItemCount() { return m_items.size(); } @@ -884,7 +889,7 @@ IMenuHandler *CBaseMenu::GetHandler() return m_pHandler; } -unsigned int CBaseMenu::GetBaseMemUsage() +size_t CBaseMenu::GetBaseMemUsage() { return m_Title.size() + (m_items.size() * sizeof(CItem)); } diff --git a/core/MenuStyle_Base.h b/core/MenuStyle_Base.h index 43ae0e6339..88a635a152 100644 --- a/core/MenuStyle_Base.h +++ b/core/MenuStyle_Base.h @@ -46,7 +46,7 @@ using namespace SourceMod; class CItem { public: - CItem(unsigned int index) + CItem(size_t index) { this->index = index; style = 0; @@ -71,7 +71,7 @@ class CItem } public: - unsigned int index; + size_t index; std::string info; std::unique_ptr<std::string> display; unsigned int style; @@ -116,7 +116,7 @@ class BaseMenuStyle : public: //what derived may implement virtual bool DoClientMenu(int client, CBaseMenu *menu, - unsigned int first_item, + size_t first_item, IMenuHandler *mh, unsigned int time); virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time); @@ -141,11 +141,11 @@ class CBaseMenu : public IBaseMenu virtual ~CBaseMenu(); public: virtual bool AppendItem(const char *info, const ItemDrawInfo &draw); - virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw); - virtual bool RemoveItem(unsigned int position); + virtual bool InsertItem(size_t position, const char *info, const ItemDrawInfo &draw); + virtual bool RemoveItem(size_t position); virtual void RemoveAllItems(); - virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL, int client=0); - virtual unsigned int GetItemCount(); + virtual const char *GetItemInfo(size_t position, ItemDrawInfo *draw=NULL, int client=0); + virtual size_t GetItemCount(); virtual bool SetPagination(unsigned int itemsPerPage); virtual unsigned int GetPagination(); virtual IMenuStyle *GetDrawStyle(); @@ -161,8 +161,8 @@ class CBaseMenu : public IBaseMenu virtual void ShufflePerClient(int start, int stop); virtual void SetClientMapping(int client, int *array, int length); virtual bool IsPerClientShuffled(); - virtual unsigned int GetRealItemIndex(int client, unsigned int position); - unsigned int GetBaseMemUsage(); + virtual size_t GetRealItemIndex(int client, size_t position); + size_t GetBaseMemUsage(); private: void InternalDelete(); protected: diff --git a/core/MenuStyle_Radio.cpp b/core/MenuStyle_Radio.cpp index 035219e322..b8800d6777 100644 --- a/core/MenuStyle_Radio.cpp +++ b/core/MenuStyle_Radio.cpp @@ -68,7 +68,7 @@ static bool s_RadioClosesOnInvalidSlot = false; CRadioStyle::CRadioStyle() { m_players = new CRadioMenuPlayer[256+1]; - for (size_t i = 0; i < 256+1; i++) + for (unsigned int i = 0; i < 256+1; i++) { m_players[i].Radio_SetIndex(i); } @@ -237,7 +237,7 @@ IBaseMenu *CRadioStyle::CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwn return new CRadioMenu(pHandler, pOwner); } -unsigned int CRadioStyle::GetMaxPageItems() +size_t CRadioStyle::GetMaxPageItems() { return s_RadioMaxPageItems; } @@ -304,7 +304,7 @@ void CRadioStyle::ProcessWatchList() } } -unsigned int CRadioStyle::GetApproxMemUsage() +size_t CRadioStyle::GetApproxMemUsage() { return sizeof(CRadioStyle) + (sizeof(CRadioMenuPlayer) * 257); } @@ -565,7 +565,7 @@ bool CRadioDisplay::SetSelectableKeys(unsigned int keymap) return true; } -unsigned int CRadioDisplay::GetApproxMemUsage() +size_t CRadioDisplay::GetApproxMemUsage() { return sizeof(CRadioDisplay) + m_BufferText.size() @@ -595,7 +595,7 @@ bool CRadioMenu::Display(int client, unsigned int time, IMenuHandler *alt_handle bool CRadioMenu::DisplayAtItem(int client, unsigned int time, - unsigned int start_item, + size_t start_item, IMenuHandler *alt_handler) { #if defined MENU_DEBUG @@ -633,7 +633,7 @@ void CRadioMenu::Cancel_Finally() g_RadioMenuStyle.CancelMenu(this); } -unsigned int CRadioMenu::GetApproxMemUsage() +size_t CRadioMenu::GetApproxMemUsage() { return sizeof(CRadioMenu) + GetBaseMemUsage(); } diff --git a/core/MenuStyle_Radio.h b/core/MenuStyle_Radio.h index afb356ef01..d863c7df14 100644 --- a/core/MenuStyle_Radio.h +++ b/core/MenuStyle_Radio.h @@ -88,8 +88,8 @@ class CRadioStyle : const char *GetStyleName(); IMenuPanel *CreatePanel(); IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner); - unsigned int GetMaxPageItems(); - unsigned int GetApproxMemUsage(); + size_t GetMaxPageItems(); + size_t GetApproxMemUsage(); public: //IUserMessageListener #ifdef USE_PROTOBUF_USERMESSAGES void OnUserMessage(int msg_id, protobuf::Message &msg, IRecipientFilter *pFilter); @@ -130,7 +130,7 @@ class CRadioDisplay : public IMenuPanel unsigned int GetCurrentKey(); bool SetCurrentKey(unsigned int key); int GetAmountRemaining(); - unsigned int GetApproxMemUsage(); + size_t GetApproxMemUsage(); bool DirectSet(const char *str); private: String m_BufferText; @@ -149,11 +149,11 @@ class CRadioMenu : public CBaseMenu bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL); bool DisplayAtItem(int client, unsigned int time, - unsigned int start_item, + size_t start_item, IMenuHandler *alt_handler/* =NULL */); bool SetPagination(unsigned int itemsPerPage); void Cancel_Finally(); - unsigned int GetApproxMemUsage(); + size_t GetApproxMemUsage(); }; extern CRadioStyle g_RadioMenuStyle; diff --git a/core/MenuStyle_Valve.cpp b/core/MenuStyle_Valve.cpp index 892720984c..4fffdc7b5c 100644 --- a/core/MenuStyle_Valve.cpp +++ b/core/MenuStyle_Valve.cpp @@ -127,7 +127,7 @@ const char *ValveMenuStyle::GetStyleName() return "valve"; } -unsigned int ValveMenuStyle::GetMaxPageItems() +size_t ValveMenuStyle::GetMaxPageItems() { return 8; } @@ -149,7 +149,7 @@ bool ValveMenuStyle::DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh return BaseMenuStyle::DoClientMenu(client, menu, mh, time); } -bool ValveMenuStyle::DoClientMenu(int client, CBaseMenu *menu, unsigned int first_item, IMenuHandler *mh, unsigned int time) +bool ValveMenuStyle::DoClientMenu(int client, CBaseMenu *menu, size_t first_item, IMenuHandler *mh, unsigned int time) { if (vsp_interface == NULL) { @@ -162,7 +162,7 @@ bool ValveMenuStyle::DoClientMenu(int client, CBaseMenu *menu, unsigned int firs return BaseMenuStyle::DoClientMenu(client, menu, first_item, mh, time); } -unsigned int ValveMenuStyle::GetApproxMemUsage() +size_t ValveMenuStyle::GetApproxMemUsage() { return sizeof(ValveMenuStyle) + (sizeof(CValveMenuPlayer) * 257); } @@ -346,7 +346,7 @@ int CValveMenuDisplay::GetAmountRemaining() return -1; } -unsigned int CValveMenuDisplay::GetApproxMemUsage() +size_t CValveMenuDisplay::GetApproxMemUsage() { return sizeof(CValveMenuDisplay) + (sizeof(KeyValues) * m_NextPos * 10); } @@ -396,7 +396,7 @@ bool CValveMenu::Display(int client, unsigned int time, IMenuHandler *alt_handle bool CValveMenu::DisplayAtItem(int client, unsigned int time, - unsigned int start_item, + size_t start_item, IMenuHandler *alt_handler/* =NULL */) { if (m_bCancelling) @@ -419,7 +419,7 @@ void CValveMenu::SetMenuOptionFlags(unsigned int flags) CBaseMenu::SetMenuOptionFlags(flags); } -unsigned int CValveMenu::GetApproxMemUsage() +size_t CValveMenu::GetApproxMemUsage() { return sizeof(CValveMenu) + GetBaseMemUsage(); } diff --git a/core/MenuStyle_Valve.h b/core/MenuStyle_Valve.h index 03fa1226fd..3b222bffce 100644 --- a/core/MenuStyle_Valve.h +++ b/core/MenuStyle_Valve.h @@ -66,7 +66,7 @@ class ValveMenuStyle : public: //BaseMenuStyle CBaseMenuPlayer *GetMenuPlayer(int client); void SendDisplay(int client, IMenuPanel *display); - bool DoClientMenu(int client, CBaseMenu *menu, unsigned int first_item, IMenuHandler *mh, unsigned int time); + bool DoClientMenu(int client, CBaseMenu *menu, size_t first_item, IMenuHandler *mh, unsigned int time); bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time); public: //SMGlobalClass void OnSourceModAllInitialized(); @@ -75,8 +75,8 @@ class ValveMenuStyle : const char *GetStyleName(); IMenuPanel *CreatePanel(); IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner); - unsigned int GetMaxPageItems(); - unsigned int GetApproxMemUsage(); + size_t GetMaxPageItems(); + size_t GetApproxMemUsage(); bool IsSupported() { return true; } private: void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin); @@ -107,7 +107,7 @@ class CValveMenuDisplay : public IMenuPanel unsigned int GetCurrentKey(); bool SetCurrentKey(unsigned int key); int GetAmountRemaining(); - unsigned int GetApproxMemUsage(); + size_t GetApproxMemUsage(); bool DirectSet(const char *str) { return false; } private: KeyValues *m_pKv; @@ -129,10 +129,10 @@ class CValveMenu : public CBaseMenu bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL); bool DisplayAtItem(int client, unsigned int time, - unsigned int start_item, + size_t start_item, IMenuHandler *alt_handler/* =NULL */); void SetMenuOptionFlags(unsigned int flags); - unsigned int GetApproxMemUsage(); + size_t GetApproxMemUsage(); public: //CBaseMenu void Cancel_Finally(); private: diff --git a/core/MenuVoting.cpp b/core/MenuVoting.cpp index 93925c6bfe..cc4e30486b 100644 --- a/core/MenuVoting.cpp +++ b/core/MenuVoting.cpp @@ -163,12 +163,12 @@ void VoteMenuHandler::OnClientDisconnected(int client) /* Wipe out their vote if they had one. We have to make sure the the the * newly connected client is not allowed to vote. */ - int item; - if ((item = m_ClientVotes[client]) >= VOTE_PENDING) + size_t item = m_ClientVotes[client]; + if (m_ClientVotes[client] != VOTE_NOT_VOTING) { - if (item >= 0) + if (item != VOTE_PENDING) { - assert((unsigned)item < m_Items); + assert(item < m_Items); assert(m_Votes[item] > 0); m_Votes[item]--; } @@ -239,7 +239,7 @@ bool VoteMenuHandler::IsClientInVotePool(int client) return (m_ClientVotes[client] > VOTE_NOT_VOTING); } -bool VoteMenuHandler::GetClientVoteChoice(int client, unsigned int *pItem) +bool VoteMenuHandler::GetClientVoteChoice(int client, size_t *pItem) { if (!IsClientInVotePool(client) || m_ClientVotes[client] == VOTE_PENDING) @@ -514,7 +514,7 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite /* Check by our item count, NOT the vote array size */ if (item < m_Items) { - unsigned int index = menu->GetRealItemIndex(client, item); + size_t index = menu->GetRealItemIndex(client, item); m_ClientVotes[client] = index; m_Votes[index]++; m_NumVotes++; @@ -679,7 +679,7 @@ void VoteMenuHandler::BuildVoteLeaders() SortVoteItems); /* Take the top 3 (if applicable) and draw them */ - int len = 0; + size_t len = 0; for (unsigned int i=0; i<vote.num_items && i<3; i++) { int curItem = vote.item_list[i].item; diff --git a/core/MenuVoting.h b/core/MenuVoting.h index 7660b29430..2d487f597e 100644 --- a/core/MenuVoting.h +++ b/core/MenuVoting.h @@ -78,7 +78,7 @@ class VoteMenuHandler : bool IsCancelling(); unsigned int GetRemainingVoteDelay(); bool IsClientInVotePool(int client); - bool GetClientVoteChoice(int client, unsigned int *pItem); + bool GetClientVoteChoice(int client, size_t *pItem); bool RedrawToClient(int client, bool revote); private: void Reset(IMenuHandler *mh); @@ -96,7 +96,7 @@ class VoteMenuHandler : IMenuHandler *m_pHandler; unsigned int m_Clients; unsigned int m_TotalClients; - unsigned int m_Items; + size_t m_Items; CVector<unsigned int> m_Votes; IBaseMenu *m_pCurMenu; bool m_bStarted; @@ -106,7 +106,7 @@ class VoteMenuHandler : unsigned int m_VoteFlags; float m_fStartTime; unsigned int m_nMenuTime; - int m_ClientVotes[256+1]; + size_t m_ClientVotes[256+1]; bool m_Revoting[256+1]; char m_leaderList[1024]; ITimer *m_displayTimer; diff --git a/core/NextMap.cpp b/core/NextMap.cpp index 16b6b25a3d..a8f4ace9af 100644 --- a/core/NextMap.cpp +++ b/core/NextMap.cpp @@ -177,13 +177,13 @@ void NextMapManager::OnSourceModLevelChange( const char *mapName ) m_mapHistory.push_back(new MapChangeData(lastMap, newReason, m_tempChangeInfo.startTime)); } - int historydiff = sm_maphistory_size.GetInt(); + long historydiff = sm_maphistory_size.GetInt(); if (historydiff > 0) { - historydiff -= m_mapHistory.size(); + historydiff -= (long)m_mapHistory.size(); } else if (historydiff < 0) { - historydiff = (m_mapHistory.size() * -1); + historydiff = (long)(m_mapHistory.size() * -1); } for (SourceHook::List<MapChangeData *>::iterator iter = m_mapHistory.begin(); historydiff++ < 0; iter = m_mapHistory.erase(iter)) diff --git a/core/UserMessages.cpp b/core/UserMessages.cpp index 413ae7853b..ac277b2196 100644 --- a/core/UserMessages.cpp +++ b/core/UserMessages.cpp @@ -170,7 +170,7 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con if (m_FallbackSearch) { int size; - return gamedll->GetUserMessageInfo(msgid, buffer, maxlength, size); + return gamedll->GetUserMessageInfo(msgid, buffer, (int)maxlength, size); } const char *msg = g_SMAPI->GetUserMessage(msgid); diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index 6cf9ac38bb..05ff3bb5bb 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -1080,7 +1080,7 @@ bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index) */ bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t maxlen) { - int len = strlen(ident); + size_t len = strlen(ident); if (!strcmp(ident, "BOT")) { // Bots diff --git a/core/logic/DebugReporter.cpp b/core/logic/DebugReporter.cpp index 4d733b5f1e..1c67e2cb4b 100644 --- a/core/logic/DebugReporter.cpp +++ b/core/logic/DebugReporter.cpp @@ -133,7 +133,7 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr } } -int DebugReport::_GetPluginIndex(IPluginContext *ctx) +size_t DebugReport::_GetPluginIndex(IPluginContext *ctx) { int id = 1; IPluginIterator *iter = pluginsys->GetPluginIterator(); diff --git a/core/logic/DebugReporter.h b/core/logic/DebugReporter.h index e79b893230..f2ab225531 100644 --- a/core/logic/DebugReporter.h +++ b/core/logic/DebugReporter.h @@ -54,7 +54,7 @@ class DebugReport : void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...); std::vector<std::string> GetStackTrace(IFrameIterator *iter); private: - int _GetPluginIndex(IPluginContext *ctx); + size_t _GetPluginIndex(IPluginContext *ctx); }; extern DebugReport g_DbgReporter; diff --git a/core/logic/ForwardSys.cpp b/core/logic/ForwardSys.cpp index e85cf3a600..c5e38f3bff 100644 --- a/core/logic/ForwardSys.cpp +++ b/core/logic/ForwardSys.cpp @@ -518,7 +518,7 @@ int CForward::PushFloatByRef(float *num, int flags) return SP_ERROR_NONE; } -void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags) +void CForward::_Int_PushArray(cell_t *inarray, size_t cells, int flags) { m_params[m_curparam].byref.cells = cells; m_params[m_curparam].byref.flags = flags; @@ -526,7 +526,7 @@ void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags) m_params[m_curparam].isnull = false; } -int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags) +int CForward::PushArray(cell_t *inarray, size_t cells, int flags) { /* Push a reference to the NULL_VECTOR pubvar if NULL was passed. */ if (!inarray) @@ -564,7 +564,7 @@ int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags) return SP_ERROR_NONE; } -void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags) +void CForward::_Int_PushString(cell_t *inarray, size_t cells, int sz_flags, int cp_flags) { m_params[m_curparam].byref.cells = cells; /* Notice this contains the char count not cell count */ m_params[m_curparam].byref.flags = cp_flags; @@ -778,7 +778,7 @@ const char *CForward::GetForwardName() return m_name; } -unsigned int CForward::GetFunctionCount() +size_t CForward::GetFunctionCount() { return m_functions.size(); } diff --git a/core/logic/ForwardSys.h b/core/logic/ForwardSys.h index cd1b3b82cd..1cda239542 100644 --- a/core/logic/ForwardSys.h +++ b/core/logic/ForwardSys.h @@ -46,13 +46,13 @@ class CForward : public IChangeableForward virtual int PushCellByRef(cell_t *cell, int flags); virtual int PushFloat(float number); virtual int PushFloatByRef(float *number, int flags); - virtual int PushArray(cell_t *inarray, unsigned int cells, int flags); + virtual int PushArray(cell_t *inarray, size_t cells, int flags); virtual int PushString(const char *string); virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags); virtual void Cancel(); public: //IForward virtual const char *GetForwardName(); - virtual unsigned int GetFunctionCount(); + virtual size_t GetFunctionCount(); virtual ExecType GetExecType(); virtual int Execute(cell_t *result, IForwardFilter *filter); public: //IChangeableForward @@ -75,8 +75,8 @@ class CForward : public IChangeableForward int PushNullString(); int PushNullVector(); int _ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param); - void _Int_PushArray(cell_t *inarray, unsigned int cells, int flags); - void _Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags); + void _Int_PushArray(cell_t *inarray, size_t cells, int flags); + void _Int_PushString(cell_t *inarray, size_t cells, int sz_flags, int cp_flags); inline int SetError(int err) { m_errstate = err; diff --git a/core/logic/GameConfigs.cpp b/core/logic/GameConfigs.cpp index bf7b249704..99c3bcf00f 100644 --- a/core/logic/GameConfigs.cpp +++ b/core/logic/GameConfigs.cpp @@ -915,7 +915,7 @@ bool CGameConfig::Reparse(char *error, size_t maxlength) const char *curFile = customDir->GetEntryName(); /* Only allow .txt files */ - int len = strlen(curFile); + size_t len = strlen(curFile); if (len > 4 && strcmp(&curFile[len-4], ".txt") != 0) { customDir->NextEntry(); diff --git a/core/logic/HandleSys.cpp b/core/logic/HandleSys.cpp index c1c1b9300c..4e12a8fc07 100644 --- a/core/logic/HandleSys.cpp +++ b/core/logic/HandleSys.cpp @@ -253,7 +253,7 @@ bool HandleSystem::FindHandleType(const char *name, HandleType_t *aResult) return false; if (aResult) - *aResult = type - m_Types; + *aResult = (int32_t)(type - m_Types); return true; } @@ -1046,7 +1046,7 @@ bool HandleSystem::TryAndFreeSomeHandles() HANDLE_LOG_VERY_BAD("--------------------------------------------------------------------------"); const IdentityToken_t *pIdentity = highest_owner->GetIdentity(); - unsigned int total = 0, highest_index = 0, total_size = 0, size; + size_t total = 0, highest_index = 0, total_size = 0, size; unsigned int * pCount = new unsigned int[HANDLESYS_TYPEARRAY_SIZE+1]; memset(pCount, 0, ((HANDLESYS_TYPEARRAY_SIZE + 1) * sizeof(unsigned int))); @@ -1153,7 +1153,7 @@ static void rep(const HandleReporter &fn, const char *fmt, ...) void HandleSystem::Dump(const HandleReporter &fn) { - unsigned int total_size = 0; + size_t total_size = 0; rep(fn, "%-10.10s\t%-20.20s\t%-20.20s\t%-10.10s\t%-30.30s", "Handle", "Owner", "Type", "Memory", "Time Created"); rep(fn, "---------------------------------------------------------------------------------------------"); @@ -1202,7 +1202,7 @@ void HandleSystem::Dump(const HandleReporter &fn) } const char *type = "ANON"; QHandleType *pType = &m_Types[m_Handles[i].type]; - unsigned int size = 0; + size_t size = 0; unsigned int parentIdx; bool bresult; if (pType->name) @@ -1248,7 +1248,7 @@ void HandleSystem::Dump(const HandleReporter &fn) else { char buffer[32]; - ke::SafeSprintf(buffer, sizeof(buffer), "%d", size); + ke::SafeSprintf(buffer, sizeof(buffer), "%zu", size); rep(fn, "0x%08x\t%-20.20s\t%-20.20s\t%-10.10s\t%-30.30s", index, owner, type, buffer, date); total_size += size; } diff --git a/core/logic/LibrarySys.cpp b/core/logic/LibrarySys.cpp index 39d2700be2..ea8d057ae0 100644 --- a/core/logic/LibrarySys.cpp +++ b/core/logic/LibrarySys.cpp @@ -221,7 +221,7 @@ void LibrarySystem::GetPlatformErrorEx(int code, char *error, size_t maxlength) (DWORD)code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)error, - maxlength, + (DWORD)maxlength, NULL) == 0) { ke::SafeSprintf(error, maxlength, "error code %08x", code); diff --git a/core/logic/MemoryUtils.cpp b/core/logic/MemoryUtils.cpp index 62a236bebb..ce50b5a84c 100644 --- a/core/logic/MemoryUtils.cpp +++ b/core/logic/MemoryUtils.cpp @@ -94,7 +94,7 @@ void *MemoryUtils::FindPattern(const void *libPtr, const char *pattern, size_t l while (ptr < end) { found = true; - for (register size_t i = 0; i < len; i++) + for (size_t i = 0; i < len; i++) { if (pattern[i] != '\x2A' && pattern[i] != ptr[i]) { diff --git a/core/logic/MersenneTwister.h b/core/logic/MersenneTwister.h index 72eb7a92e1..7cb2e48ead 100644 --- a/core/logic/MersenneTwister.h +++ b/core/logic/MersenneTwister.h @@ -64,7 +64,9 @@ #include <stdio.h> #include <time.h> #include <math.h> - +#if defined(_WINDOWS) +#pragma warning(disable:4146) +#endif class MTRand { // Data public: @@ -180,7 +182,7 @@ inline MTRand::uint32 MTRand::randInt() if( left == 0 ) reload(); --left; - register uint32 s1; + uint32 s1; s1 = *pNext++; s1 ^= (s1 >> 11); s1 ^= (s1 << 7) & 0x9d2c5680UL; @@ -225,9 +227,9 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength ) // in each element are discarded. // Just call seed() if you want to get array from /dev/urandom initialize(19650218UL); - register int i = 1; - register uint32 j = 0; - register int k = ( N > seedLength ? N : seedLength ); + int i = 1; + uint32 j = 0; + int k = ( N > seedLength ? N : seedLength ); for( ; k; --k ) { state[i] = @@ -262,9 +264,9 @@ inline void MTRand::seed() if( urandom ) { uint32 bigSeed[N]; - register uint32 *s = bigSeed; - register int i = N; - register bool success = true; + uint32 *s = bigSeed; + int i = N; + bool success = true; while( success && i-- ) success = fread( s++, sizeof(uint32), 1, urandom ); fclose(urandom); @@ -282,9 +284,9 @@ inline void MTRand::initialize( const uint32 seed ) // See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. // In previous versions, most significant bits (MSBs) of the seed affect // only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. - register uint32 *s = state; - register uint32 *r = state; - register int i = 1; + uint32 *s = state; + uint32 *r = state; + int i = 1; *s++ = seed & 0xffffffffUL; for( ; i < N; ++i ) { @@ -298,8 +300,8 @@ inline void MTRand::reload() { // Generate N new values in state // Made clearer and faster by Matthew Bellew (matthew.bellew@home.com) - register uint32 *p = state; - register int i; + uint32 *p = state; + int i; for( i = N - M; i--; ++p ) *p = twist( p[M], p[0], p[1] ); for( i = M; --i; ++p ) @@ -338,9 +340,9 @@ inline MTRand::uint32 MTRand::hash( time_t t, clock_t c ) inline void MTRand::save( uint32* saveArray ) const { - register uint32 *sa = saveArray; - register const uint32 *s = state; - register int i = N; + uint32 *sa = saveArray; + const uint32 *s = state; + int i = N; for( ; i--; *sa++ = *s++ ) {} *sa = left; } @@ -348,9 +350,9 @@ inline void MTRand::save( uint32* saveArray ) const inline void MTRand::load( uint32 *const loadArray ) { - register uint32 *s = state; - register uint32 *la = loadArray; - register int i = N; + uint32 *s = state; + uint32 *la = loadArray; + int i = N; for( ; i--; *s++ = *la++ ) {} left = *la; pNext = &state[N-left]; diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 33f1c3af33..1406d24d2a 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -160,15 +160,15 @@ void CPlugin::FinishEviction() m_FileVersion = 0; } -unsigned int CPlugin::CalcMemUsage() +size_t CPlugin::CalcMemUsage() { - unsigned int base_size = + size_t base_size = sizeof(CPlugin) + sizeof(IdentityToken_t) + (m_configs.size() * (sizeof(AutoConfig *) + sizeof(AutoConfig))) + m_Props.mem_usage(); - for (unsigned int i = 0; i < m_configs.size(); i++) { + for (size_t i = 0; i < m_configs.size(); i++) { base_size += m_configs[i]->autocfg.size(); base_size += m_configs[i]->folder.size(); } @@ -1548,7 +1548,7 @@ CPlugin *CPluginManager::GetPluginByCtx(const sp_context_t *ctx) return (CPlugin *)FindPluginByContext(ctx); } -unsigned int CPluginManager::GetPluginCount() +size_t CPluginManager::GetPluginCount() { return m_plugins.size(); } @@ -1636,7 +1636,7 @@ void CPluginManager::OnHandleDestroy(HandleType_t type, void *object) /* We don't care about the internal object, actually */ } -bool CPluginManager::GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) +bool CPluginManager::GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) { *pSize = ((CPlugin *)object)->CalcMemUsage(); return true; @@ -1716,10 +1716,10 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg { char buffer[256]; unsigned int id = 1; - int plnum = GetPluginCount(); + size_t plnum = GetPluginCount(); char plstr[10]; - ke::SafeSprintf(plstr, sizeof(plstr), "%d", plnum); - int plpadding = strlen(plstr); + ke::SafeSprintf(plstr, sizeof(plstr), "%zu", plnum); + size_t plpadding = strlen(plstr); if (!plnum) { @@ -1736,18 +1736,18 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg for (PluginIter iter(m_plugins); !iter.done(); iter.next(), id++) { CPlugin *pl = (*iter); assert(pl->GetStatus() != Plugin_Created); - int len = 0; + size_t len = 0; const sm_plugininfo_t *info = pl->GetPublicInfo(); if (pl->GetStatus() != Plugin_Running && !pl->IsSilentlyFailed()) { - len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d <%s>", plpadding, id, GetStatusText(pl->GetDisplayStatus())); + len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d <%s>", (int)plpadding, id, GetStatusText(pl->GetDisplayStatus())); /* Plugin has failed to load. */ fail_list.push_back(pl); } else { - len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d", plpadding, id); + len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d", (int)plpadding, id); } if (pl->GetStatus() < Plugin_Created || pl->GetStatus() == Plugin_Evicted) { @@ -2353,7 +2353,7 @@ class OldPluginAPI final : public IPluginManager return g_PluginSys.FindPluginByContext(ctx); } - unsigned int GetPluginCount() override + size_t GetPluginCount() override { return g_PluginSys.GetPluginCount(); } diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index 047a6e1356..50f64a07fd 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -116,7 +116,7 @@ class CPlugin : bool SetPauseState(bool paused); unsigned int GetSerial(); IdentityToken_t *GetIdentity(); - unsigned int CalcMemUsage(); + size_t CalcMemUsage(); bool SetProperty(const char *prop, void *ptr); bool GetProperty(const char *prop, void **ptr, bool remove=false); void DropEverything(); @@ -325,47 +325,39 @@ class CPluginManager : }; friend class CPluginManager::CPluginIterator; public: //IScriptManager - IPlugin *LoadPlugin(const char *path, - bool debug, - PluginType type, - char error[], - size_t maxlength, - bool *wasloaded); - bool UnloadPlugin(IPlugin *plugin); - IPlugin *FindPluginByContext(const sp_context_t *ctx); - unsigned int GetPluginCount(); - IPluginIterator *GetPluginIterator(); - void AddPluginsListener(IPluginsListener *listener); - void RemovePluginsListener(IPluginsListener *listener); - void LoadAll(const char *config_path, const char *plugins_path); - void RefreshAll(); - SMPlugin *FindPluginByOrder(unsigned num) { + bool UnloadPlugin(IPlugin *plugin) override; + IPluginIterator *GetPluginIterator() override; + void AddPluginsListener(IPluginsListener *listener) override; + void RemovePluginsListener(IPluginsListener *listener) override; + void LoadAll(const char *config_path, const char *plugins_path) override; + void RefreshAll() override; + SMPlugin *FindPluginByOrder(unsigned num) override { return GetPluginByOrder(num); } - SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) { + SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) override { return GetPluginFromIdentity(ident); } - SMPlugin *FindPluginByContext(IPluginContext *ctx) { + SMPlugin *FindPluginByContext(IPluginContext *ctx) override { return GetPluginByCtx(ctx->GetContext()); } - SMPlugin *FindPluginByContext(sp_context_t *ctx) { + SMPlugin *FindPluginByContext(sp_context_t *ctx) override { return GetPluginByCtx(ctx); } - SMPlugin *FindPluginByConsoleArg(const char *text); - SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) { + SMPlugin *FindPluginByConsoleArg(const char *text) override; + SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) override { return static_cast<SMPlugin *>(PluginFromHandle(hndl, errp)); } - const CVector<SMPlugin *> *ListPlugins(); - void FreePluginList(const CVector<SMPlugin *> *plugins); + const CVector<SMPlugin *> *ListPlugins() override; + void FreePluginList(const CVector<SMPlugin *> *plugins) override; public: //SMGlobalClass - void OnSourceModAllInitialized(); - void OnSourceModShutdown(); - ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength); - void OnSourceModMaxPlayersChanged(int newvalue); + void OnSourceModAllInitialized() override; + void OnSourceModShutdown() override; + ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength) override; + void OnSourceModMaxPlayersChanged(int newvalue) override; public: //IHandleTypeDispatch - void OnHandleDestroy(HandleType_t type, void *object); - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize); + void OnHandleDestroy(HandleType_t type, void *object) override; + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override; public: //IRootConsoleCommand void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override; public: @@ -437,8 +429,21 @@ class CPluginManager : void ForEachPlugin(ke::Function<void(CPlugin *)> callback); private: + friend class OldPluginAPI; + + IPlugin *FindPluginByContext(const sp_context_t *ctx); + + IPlugin *LoadPlugin(const char *path, + bool debug, + PluginType type, + char error[], + size_t maxlength, + bool *wasloaded); + LoadRes LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type); + size_t GetPluginCount(); + void LoadAutoPlugin(const char *plugin); /** diff --git a/core/logic/PseudoAddrManager.cpp b/core/logic/PseudoAddrManager.cpp index 2979b1ab09..8d9691b9c0 100644 --- a/core/logic/PseudoAddrManager.cpp +++ b/core/logic/PseudoAddrManager.cpp @@ -91,7 +91,7 @@ uint32_t PseudoAddressManager::ToPseudoAddress(void *addr) if (diff > (UINT32_MAX >> PSEUDO_INDEX_BITS)) return 0; - return (index << PSEUDO_OFFSET_BITS) | diff; + return (uint32_t)((index << PSEUDO_OFFSET_BITS) | diff); #else return 0; #endif diff --git a/core/logic/TextParsers.cpp b/core/logic/TextParsers.cpp index 318cc4f0dc..765d7d0ea8 100644 --- a/core/logic/TextParsers.cpp +++ b/core/logic/TextParsers.cpp @@ -82,7 +82,7 @@ unsigned int TextParsers::GetUTF8CharBytes(const char *stream) * File streams */ -bool FileStreamReader(void *stream, char *buffer, size_t maxlength, unsigned int *read) +bool FileStreamReader(void *stream, char *buffer, size_t maxlength, size_t *read) { size_t num = fread(buffer, 1, maxlength, (FILE *)stream); @@ -156,7 +156,7 @@ struct RawStream size_t pos; }; -bool RawStreamReader(void *stream, char *buffer, size_t maxlength, unsigned int *read) +bool RawStreamReader(void *stream, char *buffer, size_t maxlength, size_t *read) { RawStream *rs = (RawStream *)stream; @@ -297,7 +297,7 @@ void scrap(StringInfo info[3]) info[0] = StringInfo(); } -void reloc(StringInfo &data, unsigned int bytes) +void reloc(StringInfo &data, size_t bytes) { if (data.ptr) { @@ -331,7 +331,7 @@ SMCError TextParsers::ParseStream_SMC(void *stream, char in_buf[4096]; char *parse_point = in_buf; char *line_begin = in_buf; - unsigned int read; + size_t read; unsigned int curlevel = 0; bool in_quote = false; bool ignoring = false; @@ -707,7 +707,7 @@ SMCError TextParsers::ParseStream_SMC(void *stream, { stage = line_begin; } - unsigned int bytes = read - (stage - parse_point); + size_t bytes = read - (stage - parse_point); /* It is now safe to delete everything before the staged point */ memmove(in_buf, stage, bytes); @@ -773,11 +773,11 @@ SMCError TextParsers::ParseStream_SMC(void *stream, * INI parser */ -bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listener, unsigned int *line, unsigned int *col) +bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listener, size_t *line, size_t *col) { FILE *fp = fopen(file, "rt"); unsigned int curline = 0; - unsigned int curtok; + size_t curtok; size_t len; if (!fp) diff --git a/core/logic/TextParsers.h b/core/logic/TextParsers.h index 99cecff7c9..d9f8c00cb8 100644 --- a/core/logic/TextParsers.h +++ b/core/logic/TextParsers.h @@ -44,7 +44,7 @@ using namespace SourceMod; * @param unsigned int * OUT: Number of bytes read (0 = end of stream) * @return True on success, false on failure */ -typedef bool (*STREAMREADER)(void *, char *, size_t, unsigned int *); +typedef bool (*STREAMREADER)(void *, char *, size_t, size_t *); class TextParsers : public ITextParsers, @@ -57,8 +57,8 @@ class TextParsers : public: bool ParseFile_INI(const char *file, ITextListener_INI *ini_listener, - unsigned int *line, - unsigned int *col); + size_t *line, + size_t *col); SMCError ParseFile_SMC(const char *file, ITextListener_SMC *smc_listener, diff --git a/core/logic/Translator.cpp b/core/logic/Translator.cpp index 7513ee93f5..7f5a69768a 100644 --- a/core/logic/Translator.cpp +++ b/core/logic/Translator.cpp @@ -61,7 +61,7 @@ struct phrase_t { int fmt_list; unsigned int fmt_count; - unsigned int fmt_bytes; + size_t fmt_bytes; int trans_tbl; unsigned int translations; }; @@ -937,8 +937,13 @@ bool Translator::AddLanguage(const char *langcode, const char *description) unsigned int idx; if (!m_LCodeLookup.retrieve(langcode, &idx)) { + size_t len = m_Languages.size(); + if (len == UINT_MAX) + { + return false; + } + idx = (unsigned int)len; Language *pLanguage = new Language; - idx = m_Languages.size(); ke::SafeStrcpy(pLanguage->m_code2, sizeof(pLanguage->m_code2), langcode); pLanguage->m_CanonicalName = m_pStringTab->AddString(lower); diff --git a/core/logic/smn_admin.cpp b/core/logic/smn_admin.cpp index cac4f96bab..a7790b06ac 100644 --- a/core/logic/smn_admin.cpp +++ b/core/logic/smn_admin.cpp @@ -239,7 +239,7 @@ static cell_t GetAdminUsername(IPluginContext *pContext, const cell_t *params) pContext->StringToLocalUTF8(params[2], params[3], name, &written); - return written; + return (cell_t)written; } static cell_t BindAdminIdentity(IPluginContext *pContext, const cell_t *params) @@ -534,7 +534,7 @@ static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params) const char *end = flag; FlagBits bits = adminsys->ReadFlagString(flag, &end); - *addr = end - flag; + *addr = (cell_t)(end - flag); return bits; } diff --git a/core/logic/smn_adt_array.cpp b/core/logic/smn_adt_array.cpp index fd85743fac..28a38956c9 100644 --- a/core/logic/smn_adt_array.cpp +++ b/core/logic/smn_adt_array.cpp @@ -42,21 +42,21 @@ class CellArrayHelpers : public IHandleTypeDispatch { public: //SMGlobalClass - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { htCellArray = handlesys->CreateType("CellArray", this, 0, NULL, NULL, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(htCellArray, g_pCoreIdent); } public: //IHandleTypeDispatch - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { CellArray *array = (CellArray *)object; delete array; } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { CellArray *pArray = (CellArray *)object; *pSize = sizeof(CellArray) + pArray->mem_usage(); @@ -298,7 +298,7 @@ static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params) pContext->StringToLocalUTF8(params[3], params[4], (char *)blk, &numWritten); - return numWritten; + return (cell_t)numWritten; } static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params) @@ -343,7 +343,7 @@ static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params) memcpy(addr, blk, sizeof(cell_t) * indexes); - return indexes; + return (cell_t)indexes; } static cell_t SetArrayCell(IPluginContext *pContext, const cell_t *params) @@ -426,7 +426,7 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params) maxlength = (size_t)params[4]; } - return strncopy((char*)blk, str, maxlength); + return (cell_t)strncopy((char*)blk, str, maxlength); } static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params) @@ -471,7 +471,7 @@ static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params) memcpy(blk, addr, sizeof(cell_t) * indexes); - return indexes; + return (cell_t)indexes; } static cell_t ShiftArrayUp(IPluginContext *pContext, const cell_t *params) @@ -662,7 +662,7 @@ static cell_t GetArrayBlockSize(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } - return array->blocksize(); + return (cell_t)array->blocksize(); } REGISTER_NATIVES(cellArrayNatives) diff --git a/core/logic/smn_adt_stack.cpp b/core/logic/smn_adt_stack.cpp index 4b13baaede..7b877400a3 100644 --- a/core/logic/smn_adt_stack.cpp +++ b/core/logic/smn_adt_stack.cpp @@ -43,21 +43,21 @@ class CellStackHelpers : public IHandleTypeDispatch { public: //SMGlobalClass - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { htCellStack = handlesys->CreateType("CellStack", this, 0, NULL, NULL, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(htCellStack, g_pCoreIdent); } public: //IHandleTypeDispatch - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { CellArray *array = (CellArray *)object; delete array; } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { CellArray *pArray = (CellArray *)object; *pSize = sizeof(CellArray) + pArray->mem_usage(); @@ -315,7 +315,7 @@ static cell_t PopStackArray(IPluginContext *pContext, const cell_t *params) memcpy(addr, blk, sizeof(cell_t) * indexes); array->remove(idx); - return indexes; + return (cell_t)indexes; } static cell_t IsStackEmpty(IPluginContext *pContext, const cell_t *params) @@ -493,7 +493,7 @@ static cell_t GetStackBlockSize(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } - return array->blocksize(); + return (cell_t)array->blocksize(); } static cell_t GetStackSize(IPluginContext *pContext, const cell_t *params) @@ -508,7 +508,7 @@ static cell_t GetStackSize(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } - return array->size(); + return (cell_t)array->size(); } REGISTER_NATIVES(cellStackNatives) diff --git a/core/logic/smn_adt_trie.cpp b/core/logic/smn_adt_trie.cpp index 8d1f7d6f45..aba97209cd 100644 --- a/core/logic/smn_adt_trie.cpp +++ b/core/logic/smn_adt_trie.cpp @@ -192,18 +192,18 @@ class TrieHelpers : public IHandleTypeDispatch { public: //SMGlobalClass - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { htCellTrie = handlesys->CreateType("Trie", this, 0, NULL, NULL, g_pCoreIdent, NULL); htSnapshot = handlesys->CreateType("TrieSnapshot", this, 0, NULL, NULL, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(htSnapshot, g_pCoreIdent); handlesys->RemoveType(htCellTrie, g_pCoreIdent); } public: //IHandleTypeDispatch - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { if (type == htCellTrie) { @@ -213,7 +213,7 @@ class TrieHelpers : delete snapshot; } } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { if (type == htCellTrie) { @@ -503,7 +503,7 @@ static cell_t GetTrieArray(IPluginContext *pContext, const cell_t *params) if (length > size_t(params[4])) *pSize = params[4]; else - *pSize = length; + *pSize = (cell_t)length; memcpy(pValue, base, sizeof(cell_t) * pSize[0]); return 1; @@ -560,7 +560,7 @@ static cell_t GetTrieSize(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); } - return pTrie->map.elements(); + return (cell_t)pTrie->map.elements(); } static cell_t CreateTrieSnapshot(IPluginContext *pContext, const cell_t *params) @@ -609,7 +609,7 @@ static cell_t TrieSnapshotLength(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err); } - return snapshot->length; + return (cell_t)snapshot->length; } static cell_t TrieSnapshotKeyBufferSize(IPluginContext *pContext, const cell_t *params) @@ -630,7 +630,7 @@ static cell_t TrieSnapshotKeyBufferSize(IPluginContext *pContext, const cell_t * if (index >= snapshot->length) return pContext->ThrowNativeError("Invalid index %d", index); - return strlen(snapshot->strings.GetString(snapshot->keys[index])) + 1; + return (cell_t)strlen(snapshot->strings.GetString(snapshot->keys[index])) + 1; } static cell_t GetTrieSnapshotKey(IPluginContext *pContext, const cell_t *params) @@ -654,7 +654,7 @@ static cell_t GetTrieSnapshotKey(IPluginContext *pContext, const cell_t *params) size_t written; const char *str = snapshot->strings.GetString(snapshot->keys[index]); pContext->StringToLocalUTF8(params[3], params[4], str, &written); - return written; + return (cell_t)written; } static cell_t CloneTrie(IPluginContext *pContext, const cell_t *params) diff --git a/core/logic/smn_console.cpp b/core/logic/smn_console.cpp index d25c4de244..c6717aae4e 100644 --- a/core/logic/smn_console.cpp +++ b/core/logic/smn_console.cpp @@ -218,7 +218,6 @@ static cell_t sm_ClientCommand(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(params[1]); char buffer[256]; - size_t len; { DetectExceptions eh(pContext); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index 8e90d40310..fc2a966ce9 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -310,9 +310,9 @@ static int ParseTime(IPluginContext *pContext, const cell_t *params) } #if defined PLATFORM_WINDOWS - return _mkgmtime(&t); + return (int)_mkgmtime(&t); #elif defined PLATFORM_LINUX || defined PLATFORM_APPLE - return timegm(&t); + return (int)timegm(&t); #else return pContext->ThrowNativeError("Platform has no implemented UTC conversion for std::tm to std::time_t"); #endif diff --git a/core/logic/smn_database.cpp b/core/logic/smn_database.cpp index 505cb6d695..d0525446d5 100644 --- a/core/logic/smn_database.cpp +++ b/core/logic/smn_database.cpp @@ -1297,7 +1297,7 @@ static cell_t SQL_FetchSize(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid field index %d", params[2]); } - return row->GetDataSize(params[2]); + return (cell_t)row->GetDataSize(params[2]); } static cell_t SQL_BindParamInt(IPluginContext *pContext, const cell_t *params) @@ -1698,7 +1698,7 @@ class TTransactOp : public IDBThreadOperation { success_->PushCell(dbh); success_->PushCell(data_); - success_->PushCell(txn_->entries.size()); + success_->PushCell((cell_t)txn_->entries.size()); success_->PushArray(handles.get(), results_.size()); success_->PushArray(data.get(), results_.size()); success_->Execute(NULL); @@ -1745,7 +1745,7 @@ class TTransactOp : public IDBThreadOperation { failure_->PushCell(dbh); failure_->PushCell(data_); - failure_->PushCell(txn_->entries.size()); + failure_->PushCell((cell_t)txn_->entries.size()); failure_->PushString(error_.c_str()); failure_->PushCell(failIndex_); failure_->PushArray(data.get(), txn_->entries.size()); diff --git a/core/logic/smn_datapacks.cpp b/core/logic/smn_datapacks.cpp index 3276c30086..eb498a9642 100644 --- a/core/logic/smn_datapacks.cpp +++ b/core/logic/smn_datapacks.cpp @@ -41,7 +41,7 @@ class DataPackNatives : public IHandleTypeDispatch { public: - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { HandleAccess hacc; TypeAccess tacc; @@ -54,16 +54,16 @@ class DataPackNatives : g_DataPackType = handlesys->CreateType("DataPack", this, 0, &tacc, &hacc, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(g_DataPackType, g_pCoreIdent); g_DataPackType = 0; } - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { delete reinterpret_cast<CDataPack *>(object); } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { CDataPack *pack = reinterpret_cast<CDataPack *>(object); *pSize = sizeof(CDataPack) + pack->GetCapacity(); diff --git a/core/logic/smn_entitylump.cpp b/core/logic/smn_entitylump.cpp index ee923235c1..decf6293a4 100644 --- a/core/logic/smn_entitylump.cpp +++ b/core/logic/smn_entitylump.cpp @@ -114,11 +114,11 @@ cell_t sm_LumpManagerAppend(IPluginContext *pContext, const cell_t *params) { if (!g_bLumpAvailableForWriting) { return pContext->ThrowNativeError("Cannot use EntityLump.Append() outside of OnMapInit"); } - return lumpmanager->Append(); + return (cell_t)lumpmanager->Append(); } cell_t sm_LumpManagerLength(IPluginContext *pContext, const cell_t *params) { - return lumpmanager->Length(); + return (cell_t)lumpmanager->Length(); } cell_t sm_LumpEntryGet(IPluginContext *pContext, const cell_t *params) { @@ -325,7 +325,7 @@ cell_t sm_LumpEntryFindKey(IPluginContext *pContext, const cell_t *params) { if (result == entry->end()) { return -1; } - return std::distance(entry->begin(), result); + return (cell_t)std::distance(entry->begin(), result); } cell_t sm_LumpEntryLength(IPluginContext *pContext, const cell_t *params) { @@ -344,7 +344,7 @@ cell_t sm_LumpEntryLength(IPluginContext *pContext, const cell_t *params) { } auto entry = entryref->lock(); - return entry->size(); + return (cell_t)entry->size(); } REGISTER_NATIVES(entityLumpNatives) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 032f951e60..8b33f8a507 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -73,9 +73,9 @@ class FileObject public: virtual ~FileObject() {} - virtual size_t Read(void *pOut, int size) = 0; + virtual size_t Read(void *pOut, size_t size) = 0; virtual char *ReadLine(char *pOut, int size) = 0; - virtual size_t Write(const void *pData, int size) = 0; + virtual size_t Write(const void *pData, size_t size) = 0; virtual bool Seek(int pos, int seek_type) = 0; virtual int Tell() = 0; virtual bool Flush() = 0; @@ -119,14 +119,14 @@ class ValveFile : public FileObject return true; } - size_t Read(void *pOut, int size) override { - return (size_t)bridge->filesystem->Read(pOut, size, handle_); + size_t Read(void *pOut, size_t size) override { + return bridge->filesystem->Read(pOut, size, handle_); } char *ReadLine(char *pOut, int size) override { return bridge->filesystem->ReadLine(pOut, size, handle_); } - size_t Write(const void *pData, int size) override { - return (size_t)bridge->filesystem->Write(pData, size, handle_); + size_t Write(const void *pData, size_t size) override { + return bridge->filesystem->Write(pData, size, handle_); } bool Seek(int pos, int seek_type) override { bridge->filesystem->Seek(handle_, pos, seek_type); @@ -183,13 +183,13 @@ class SystemFile : public FileObject return unlink(path) == 0; } - size_t Read(void *pOut, int size) override { + size_t Read(void *pOut, size_t size) override { return fread(pOut, 1, size, fp_); } char *ReadLine(char *pOut, int size) override { return fgets(pOut, size, fp_); } - size_t Write(const void *pData, int size) override { + size_t Write(const void *pData, size_t size) override { return fwrite(pData, 1, size, fp_); } bool Seek(int pos, int seek_type) override { @@ -675,7 +675,7 @@ static cell_t sm_FileSize(IPluginContext *pContext, const cell_t *params) if (!bridge->filesystem->FileExists(name, pathID)) return -1; - return bridge->filesystem->Size(name, pathID); + return (cell_t)bridge->filesystem->Size(name, pathID); } char realpath[PLATFORM_MAX_PATH]; @@ -817,7 +817,7 @@ static cell_t sm_BuildPath(IPluginContext *pContext, const cell_t *params) return 0; } - return g_pSM->BuildPath(Path_SM_Rel, buffer, params[3], "%s", path); + return (cell_t)g_pSM->BuildPath(Path_SM_Rel, buffer, params[3], "%s", path); } static cell_t sm_LogToGame(IPluginContext *pContext, const cell_t *params) @@ -995,7 +995,7 @@ static cell_t sm_ReadFile(IPluginContext *pContext, const cell_t *params) if ((read != size_t(params[3] * params[4])) && file->HasError()) return -1; - return read / params[4]; + return (cell_t)read / params[4]; } static cell_t sm_ReadFileString(IPluginContext *pContext, const cell_t *params) diff --git a/core/logic/smn_functions.cpp b/core/logic/smn_functions.cpp index ea1acaba78..97c98c6dcd 100644 --- a/core/logic/smn_functions.cpp +++ b/core/logic/smn_functions.cpp @@ -50,7 +50,7 @@ class ForwardNativeHelpers : public IHandleTypeDispatch { public: - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { HandleAccess sec; @@ -69,20 +69,20 @@ class ForwardNativeHelpers : g_PrivateFwdType = handlesys->CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(g_PrivateFwdType, g_pCoreIdent); handlesys->RemoveType(g_GlobalFwdType, g_pCoreIdent); } - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { IForward *pForward = static_cast<IForward *>(object); forwardsys->ReleaseForward(pForward); } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { *pSize = sizeof(IForward*) + (((IForward *)object)->GetFunctionCount() * 12); return true; @@ -198,7 +198,7 @@ static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err); } - return pForward->GetFunctionCount(); + return (cell_t)pForward->GetFunctionCount(); } static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params) diff --git a/core/logic/smn_menus.cpp b/core/logic/smn_menus.cpp index 152215ebeb..e9a4bd962b 100644 --- a/core/logic/smn_menus.cpp +++ b/core/logic/smn_menus.cpp @@ -160,14 +160,14 @@ class MenuNativeHelpers : public IPluginsListener { public: - virtual void OnSourceModAllInitialized() + virtual void OnSourceModAllInitialized() override { m_PanelType = handlesys->CreateType("IMenuPanel", this, 0, NULL, NULL, g_pCoreIdent, NULL); m_TempPanelType = handlesys->CreateType("TempIMenuPanel", this, m_PanelType, NULL, NULL, g_pCoreIdent, NULL); scripts->AddPluginsListener(this); } - virtual void OnSourceModShutdown() + virtual void OnSourceModShutdown() override { scripts->RemovePluginsListener(this); handlesys->RemoveType(m_TempPanelType, g_pCoreIdent); @@ -186,7 +186,7 @@ class MenuNativeHelpers : } } - virtual void OnHandleDestroy(HandleType_t type, void *object) + virtual void OnHandleDestroy(HandleType_t type, void *object) override { if (type == m_TempPanelType) { @@ -197,7 +197,7 @@ class MenuNativeHelpers : panel->DeleteThis(); } - virtual bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + virtual bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { *pSize = ((IMenuPanel *)object)->GetApproxMemUsage(); return true; @@ -211,7 +211,7 @@ class MenuNativeHelpers : * ones), but when push comes to shove, we have to scan them all * in case any of them are active. */ - virtual void OnPluginUnloaded(IPlugin *plugin) + virtual void OnPluginUnloaded(IPlugin *plugin) override { for (size_t i = 0; i < m_PanelHandlers.size(); i++) { @@ -504,7 +504,7 @@ void CMenuHandler::OnMenuVoteResults(IBaseMenu *menu, const menu_vote_result_t * auto init = std::make_unique<cell_t[]>(client_array_size); for (unsigned int i = 0; i < results->num_clients; i++) { init[i * 2] = results->client_list[i].client; - init[i * 2 + 1] = results->client_list[i].item; + init[i * 2 + 1] = (cell_t)results->client_list[i].item; } if (!pContext->HeapAlloc2dArray(results->num_clients, 2, &client_array_address, init.get())) { @@ -875,7 +875,7 @@ static cell_t GetMenuItemCount(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err); } - return menu->GetItemCount(); + return (cell_t)menu->GetItemCount(); } static cell_t SetMenuTitle(IPluginContext *pContext, const cell_t *params) @@ -1205,7 +1205,7 @@ static cell_t GetMaxPageItems(IPluginContext *pContext, const cell_t *params) style = menus->GetDefaultStyle(); } - return style->GetMaxPageItems(); + return (cell_t)style->GetMaxPageItems(); } static cell_t GetPanelStyle(IPluginContext *pContext, const cell_t *params) diff --git a/core/logic/smn_sorting.cpp b/core/logic/smn_sorting.cpp index 82ad19589a..dcf3ed4cd7 100644 --- a/core/logic/smn_sorting.cpp +++ b/core/logic/smn_sorting.cpp @@ -265,7 +265,7 @@ static cell_t sm_SortStrings_Legacy(IPluginContext *pContext, const cell_t *para /* Compute the final address of the old array and subtract the new location. * This is the fixed up distance. */ - array[i] = ((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i]; + array[i] = (cell_t)(((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i]); } pContext->HeapPop(amx_addr); @@ -473,7 +473,7 @@ static cell_t sm_SortCustom2D_Legacy(IPluginContext *pContext, const cell_t *par /* Compute the final address of the old array and subtract the new location. * This is the fixed up distance. */ - array[i] = ((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i]; + array[i] = (cell_t)(((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i]); } pContext->HeapPop(amx_addr); @@ -552,8 +552,11 @@ int sort_adtarray_strings_desc(const void *str1, const void *str2) void sort_adt_random(CellArray *cArray) { size_t arraysize = cArray->size(); + if (arraysize == 0) { + return; + } - for (int i = arraysize-1; i > 0; i--) + for (size_t i = arraysize-1; i > 0; i--) { int n = rand() % (i + 1); diff --git a/core/logic/smn_string.cpp b/core/logic/smn_string.cpp index be7488dcd6..e25fd01efe 100644 --- a/core/logic/smn_string.cpp +++ b/core/logic/smn_string.cpp @@ -58,7 +58,7 @@ static cell_t sm_strlen(IPluginContext *pCtx, const cell_t *params) char *str; pCtx->LocalToString(params[1], &str); - return strlen(str); + return (cell_t)strlen(str); } static cell_t sm_contain(IPluginContext *pCtx, const cell_t *params) @@ -74,7 +74,7 @@ static cell_t sm_contain(IPluginContext *pCtx, const cell_t *params) const char *pos = func(str, substr); if (pos) { - return (pos - str); + return (cell_t)(pos - str); } return -1; @@ -116,7 +116,7 @@ static cell_t sm_strcopy(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[1], &dest); pCtx->LocalToString(params[3], &src); - return strncopy(dest, src, params[2]); + return (cell_t)strncopy(dest, src, params[2]); } static cell_t sm_strconvint(IPluginContext *pCtx, const cell_t *params) @@ -136,7 +136,7 @@ static cell_t StringToIntEx(IPluginContext *pCtx, const cell_t *params) *addr = static_cast<cell_t>(strtoul(str, &dummy, params[3])); - return dummy - str; + return (cell_t)(dummy - str); } static cell_t StringToInt64(IPluginContext *pCtx, const cell_t *params) @@ -152,7 +152,7 @@ static cell_t StringToInt64(IPluginContext *pCtx, const cell_t *params) addr[0] = (cell_t)(number & 0xFFFFFFFFull); addr[1] = (cell_t)(number >> 32ull); - return dummy - str; + return (cell_t)(dummy - str); } static cell_t sm_numtostr(IPluginContext *pCtx, const cell_t *params) @@ -196,7 +196,7 @@ static cell_t StringToFloatEx(IPluginContext *pCtx, const cell_t *params) *addr = sp_ftoc(val); - return dummy - str; + return (cell_t)(dummy - str); } static cell_t sm_floattostr(IPluginContext *pCtx, const cell_t *params) @@ -275,7 +275,7 @@ static cell_t sm_vformat(IPluginContext *pContext, const cell_t *params) pContext->StringToLocal(params[1], maxlen, g_vformatbuf); } - return total; + return (cell_t)total; } /* :TODO: make this UTF8 safe */ @@ -364,7 +364,7 @@ static cell_t BreakString(IPluginContext *pContext, const cell_t *params) return -1; } - return inptr - input; + return (cell_t)(inptr - input); } static cell_t GetCharBytes(IPluginContext *pContext, const cell_t *params) @@ -474,7 +474,7 @@ static cell_t ReplaceString(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Cannot replace searches of empty strings"); } - return UTIL_ReplaceAll(text, maxlength, search, replace, caseSensitive); + return (cell_t)UTIL_ReplaceAll(text, maxlength, search, replace, caseSensitive); } static cell_t ReplaceStringEx(IPluginContext *pContext, const cell_t *params) @@ -513,7 +513,7 @@ static cell_t ReplaceStringEx(IPluginContext *pContext, const cell_t *params) return -1; } - return ptr - text; + return (cell_t)(ptr - text); } static cell_t TrimString(IPluginContext *pContext, const cell_t *params) @@ -548,7 +548,7 @@ static cell_t TrimString(IPluginContext *pContext, const cell_t *params) size_t bytes; pContext->StringToLocalUTF8(params[1], chars + 1, str, &bytes); - return bytes; + return (cell_t)bytes; } static cell_t SplitString(IPluginContext *pContext, const cell_t *params) diff --git a/core/logic/smn_textparse.cpp b/core/logic/smn_textparse.cpp index 09b919fbd5..271c083a8b 100644 --- a/core/logic/smn_textparse.cpp +++ b/core/logic/smn_textparse.cpp @@ -148,7 +148,7 @@ class TextParseGlobals : public IHandleTypeDispatch { public: - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { HandleAccess sec; @@ -162,18 +162,18 @@ class TextParseGlobals : g_TypeSMC = handlesys->CreateType("SMCParser", this, 0, NULL, &sec, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(g_TypeSMC, g_pCoreIdent); } - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { ParseInfo *parse = (ParseInfo *)object; delete parse; } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { *pSize = sizeof(ParseInfo); return true; diff --git a/core/logic/smn_timers.cpp b/core/logic/smn_timers.cpp index 631d4d41f8..68ba5dc071 100644 --- a/core/logic/smn_timers.cpp +++ b/core/logic/smn_timers.cpp @@ -291,7 +291,7 @@ static cell_t smn_TriggerTimer(IPluginContext *pCtx, const cell_t *params) static cell_t smn_GetTickedTime(IPluginContext *pContext, const cell_t *params) { - return sp_ftoc(*serverGlobals.universalTime); + return sp_ftoc((float)*serverGlobals.universalTime); } static cell_t smn_GetMapTimeLeft(IPluginContext *pContext, const cell_t *params) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index 93736318e8..1ac24b0537 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -150,9 +150,9 @@ size_t Translate(char *buffer, return 0; } -bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int prec, int flags) +bool AddString(char **buf_p, size_t &maxlen, const char *string, size_t width, size_t prec, size_t flags) { - int size = 0; + size_t size = 0; char *buf; static char nlstr[] = {'(','n','u','l','l',')','\0'}; @@ -181,7 +181,7 @@ bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int size--; } - if (size > (int)maxlen) + if (size > maxlen) { size = maxlen; } diff --git a/core/logic/stringutil.cpp b/core/logic/stringutil.cpp index d79e7771df..47ceff2464 100644 --- a/core/logic/stringutil.cpp +++ b/core/logic/stringutil.cpp @@ -75,18 +75,18 @@ const char *stristr(const char *str, const char *substr) return NULL; } -unsigned int strncopy(char *dest, const char *src, size_t count) +size_t strncopy(char *dest, const char *src, size_t count) { return ke::SafeStrcpy(dest, count, src); } -unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive) +size_t UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive) { size_t searchLen = strlen(search); size_t replaceLen = strlen(replace); char *newptr, *ptr = subject; - unsigned int total = 0; + size_t total = 0; while ((newptr = UTIL_ReplaceEx(ptr, maxlength, search, searchLen, replace, replaceLen, caseSensitive)) != NULL) { total++; @@ -304,13 +304,13 @@ size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char #define PATHSEPARATOR(c) ((c) == '\\' || (c) == '/') -void UTIL_StripExtension(const char *in, char *out, int outSize) +void UTIL_StripExtension(const char *in, char *out, size_t outSize) { // Find the last dot. If it's followed by a dot or a slash, then it's part of a // directory specifier like ../../somedir/./blah. // scan backward for '.' - int end = strlen(in) - 1; + size_t end = strlen(in) - 1; while (end > 0 && in[end] != '.' && !PATHSEPARATOR(in[end])) { --end; @@ -318,7 +318,7 @@ void UTIL_StripExtension(const char *in, char *out, int outSize) if (end > 0 && !PATHSEPARATOR(in[end]) && end < outSize) { - int nChars = MIN(end, outSize-1); + size_t nChars = MIN(end, outSize-1); if (out != in) { memcpy(out, in, nChars); @@ -408,7 +408,7 @@ cell_t InternalFormat(IPluginContext *pCtx, const cell_t *params, int start) maxlen = static_cast<size_t>(params[start + 2]); start_addr = params[start + 1]; - end_addr = params[start + 1] + maxlen; + end_addr = params[start + 1] + (cell_t)maxlen; maxparam = params[0]; for (cell_t i = (start + 3); i <= maxparam; i++) diff --git a/core/logic/stringutil.h b/core/logic/stringutil.h index 94b3a688fe..b48f010f81 100644 --- a/core/logic/stringutil.h +++ b/core/logic/stringutil.h @@ -33,14 +33,14 @@ #define _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_ const char *stristr(const char *str, const char *substr); -unsigned int strncopy(char *dest, const char *src, size_t count); -unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, +size_t strncopy(char *dest, const char *src, size_t count); +size_t UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive = true); char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen, bool caseSensitive = true); size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char *hexstr); -void UTIL_StripExtension(const char *in, char *out, int outSize); +void UTIL_StripExtension(const char *in, char *out, size_t outSize); char *UTIL_TrimWhitespace(char *str, size_t &len); // Internal copying Format helper, expects (char[] buffer, int maxlength, const char[] format, any ...) starting at |start| diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index a718c32345..d60d874783 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -138,17 +138,17 @@ class VFileSystem_Logic : public IFileSystemBridge { return filesystem->FileExists(pFileName, pPathID); } - unsigned int Size(const char *pFileName, const char *pPathID = 0) override + size_t Size(const char *pFileName, const char *pPathID = 0) override { return filesystem->Size(pFileName, pPathID); } - int Read(void* pOutput, int size, FileHandle_t file) override + size_t Read(void* pOutput, size_t size, FileHandle_t file) override { - return filesystem->Read(pOutput, size, file); + return filesystem->Read(pOutput, (int)size, file); } - int Write(void const* pInput, int size, FileHandle_t file) override + size_t Write(void const* pInput, size_t size, FileHandle_t file) override { - return filesystem->Write(pInput, size, file); + return filesystem->Write(pInput, (int)size, file); } void Seek(FileHandle_t file, int pos, int seekType) override { diff --git a/core/smn_console.cpp b/core/smn_console.cpp index dc03668412..a87a13bd5e 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -87,7 +87,7 @@ class ConsoleHelpers : public IHandleTypeDispatch { public: - virtual void OnSourceModAllInitialized() + virtual void OnSourceModAllInitialized() override { HandleAccess access; @@ -99,7 +99,7 @@ class ConsoleHelpers : hCmdIterType = handlesys->CreateType("CmdIter", this, 0, NULL, &access, g_pCoreIdent, NULL); } - virtual void OnHandleDestroy(HandleType_t type, void *object) + virtual void OnHandleDestroy(HandleType_t type, void *object) override { if (type == hCmdIterType) { @@ -112,7 +112,7 @@ class ConsoleHelpers : delete iter; } } - virtual bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + virtual bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { if (type == htConCmdIter) { @@ -535,7 +535,7 @@ static cell_t GetConVarDefault(IPluginContext *pContext, const cell_t *params) size_t bytes; pContext->StringToLocalUTF8(params[2], params[3], pConVar->GetDefault(), &bytes); - return bytes; + return (cell_t)bytes; } static cell_t sm_GetConVarFlags(IPluginContext *pContext, const cell_t *params) diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index 139da9cc1d..327dbe4b76 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -919,7 +919,7 @@ static cell_t FindSendPropInfo(IPluginContext *pContext, const cell_t *params) } SendProp *pProp = info.prop; - unsigned int actual_offset = info.actual_offset; + size_t actual_offset = info.actual_offset; // SendPropArray / SendPropArray2 if (pProp->GetType() == DPT_Array && pProp->GetArrayProp()) @@ -982,7 +982,7 @@ static cell_t FindSendPropInfo(IPluginContext *pContext, const cell_t *params) *pBits = pProp->m_nBits; - return actual_offset; + return (cell_t)actual_offset; } static void GuessDataPropTypes(typedescription_t *td, cell_t * pSize, cell_t * pType) @@ -1154,7 +1154,7 @@ static cell_t FindDataMapInfo(IPluginContext *pContext, const cell_t *params) } } - return info.actual_offset; + return (cell_t)info.actual_offset; } static cell_t GetEntDataString(IPluginContext *pContext, const cell_t *params) @@ -1176,7 +1176,7 @@ static cell_t GetEntDataString(IPluginContext *pContext, const cell_t *params) char *src = (char *)((uint8_t *)pEntity + offset); pContext->StringToLocalUTF8(params[3], params[4], src, &len); - return len; + return (cell_t)len; } static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params) @@ -1206,7 +1206,7 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params) g_HL2.SetEdictStateChanged(pEdict, offset); } - return len; + return (cell_t)len; } #define FIND_PROP_DATA(td) \ @@ -1470,7 +1470,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; edict_t *pEdict; int bit_count; bool is_unsigned = false; @@ -1584,7 +1584,7 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; edict_t *pEdict; int bit_count; @@ -1685,7 +1685,7 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params) if (params[2] == Prop_Send && (pEdict != NULL)) { - g_HL2.SetEdictStateChanged(pEdict, offset); + g_HL2.SetEdictStateChanged(pEdict, (unsigned short)offset); } return 0; @@ -1695,7 +1695,7 @@ static cell_t GetEntPropFloat(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; @@ -1758,7 +1758,7 @@ static cell_t SetEntPropFloat(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; @@ -1820,7 +1820,7 @@ static cell_t SetEntPropFloat(IPluginContext *pContext, const cell_t *params) if (params[2] == Prop_Send && (pEdict != NULL)) { - g_HL2.SetEdictStateChanged(pEdict, offset); + g_HL2.SetEdictStateChanged(pEdict, (unsigned short)offset); } return 1; @@ -1839,7 +1839,7 @@ static cell_t GetEntPropEnt(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; PropEntType type = PropEnt_Unknown; @@ -1954,7 +1954,7 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; PropEntType type = PropEnt_Unknown; @@ -2052,7 +2052,7 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) if (params[2] == Prop_Send && (pEdict != NULL)) { - g_HL2.SetEdictStateChanged(pEdict, offset); + g_HL2.SetEdictStateChanged(pEdict, (unsigned short)offset); } } @@ -2094,7 +2094,7 @@ static cell_t GetEntPropVector(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; @@ -2171,7 +2171,7 @@ static cell_t SetEntPropVector(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; @@ -2243,7 +2243,7 @@ static cell_t SetEntPropVector(IPluginContext *pContext, const cell_t *params) if (params[2] == Prop_Send && (pEdict != NULL)) { - g_HL2.SetEdictStateChanged(pEdict, offset); + g_HL2.SetEdictStateChanged(pEdict, (unsigned short)offset); } return 1; @@ -2253,7 +2253,7 @@ static cell_t GetEntPropString(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int bit_count; edict_t *pEdict; @@ -2358,7 +2358,7 @@ static cell_t GetEntPropString(IPluginContext *pContext, const cell_t *params) { size_t len; pContext->StringToLocalUTF8(params[4], params[5], src, &len); - return len; + return (cell_t)len; } pContext->StringToLocal(params[4], params[5], ""); @@ -2369,7 +2369,7 @@ static cell_t SetEntPropString(IPluginContext *pContext, const cell_t *params) { CBaseEntity *pEntity; char *prop; - int offset; + size_t offset; int maxlen; int bit_count; edict_t *pEdict; @@ -2502,10 +2502,10 @@ static cell_t SetEntPropString(IPluginContext *pContext, const cell_t *params) if (params[2] == Prop_Send && (pEdict != NULL)) { - g_HL2.SetEdictStateChanged(pEdict, offset); + g_HL2.SetEdictStateChanged(pEdict, (unsigned short)offset); } - return len; + return (cell_t)len; } static int32_t SDKEntFlagToSMEntFlag(int flag) @@ -2695,7 +2695,7 @@ static cell_t GetEntityFlags(IPluginContext *pContext, const cell_t *params) params[1]); } - int offset = info.actual_offset; + size_t offset = info.actual_offset; int32_t actual_flags = *(int32_t *)((uint8_t *)pEntity + offset); int32_t sm_flags = 0; @@ -2741,7 +2741,7 @@ static cell_t SetEntityFlags(IPluginContext *pContext, const cell_t *params) params[1]); } - int offset = info.actual_offset; + size_t offset = info.actual_offset; int32_t sm_flags = params[2]; int32_t actual_flags = 0; diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index f72b719608..1f1accf101 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -188,7 +188,7 @@ static cell_t GetGameDescription(IPluginContext *pContext, const cell_t *params) pContext->StringToLocalUTF8(params[1], params[2], description, &numBytes); - return numBytes; + return (cell_t)numBytes; } static cell_t GetGameFolderName(IPluginContext *pContext, const cell_t *params) @@ -198,7 +198,7 @@ static cell_t GetGameFolderName(IPluginContext *pContext, const cell_t *params) pContext->StringToLocalUTF8(params[1], params[2], name, &numBytes); - return numBytes; + return (cell_t)numBytes; } /* Useless comment to bump the build */ @@ -206,7 +206,7 @@ static cell_t GetCurrentMap(IPluginContext *pContext, const cell_t *params) { size_t bytes; pContext->StringToLocalUTF8(params[1], params[2], STRING(gpGlobals->mapname), &bytes); - return bytes; + return (cell_t)bytes; } static cell_t PrecacheModel(IPluginContext *pContext, const cell_t *params) diff --git a/core/smn_hudtext.cpp b/core/smn_hudtext.cpp index 88621d94b6..9e9ee117af 100644 --- a/core/smn_hudtext.cpp +++ b/core/smn_hudtext.cpp @@ -86,7 +86,7 @@ class HudMsgHelpers : return (g_HudMsgNum != -1); } - virtual void OnSourceModAllInitialized_Post() + virtual void OnSourceModAllInitialized_Post() override { const char *key; @@ -109,7 +109,7 @@ class HudMsgHelpers : g_Players.AddClientListener(this); } - virtual void OnSourceModShutdown() + virtual void OnSourceModShutdown() override { if (!IsSupported()) { @@ -122,20 +122,20 @@ class HudMsgHelpers : g_Players.RemoveClientListener(this); } - virtual void OnHandleDestroy(HandleType_t type, void *object) + virtual void OnHandleDestroy(HandleType_t type, void *object) override { hud_syncobj_t *obj = (hud_syncobj_t *)object; delete obj; } - virtual bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + virtual bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { *pSize = sizeof(unsigned int) * g_Players.GetMaxClients(); return true; } - virtual void OnClientConnected(int client) + virtual void OnClientConnected(int client) override { player_chaninfo_t *player; diff --git a/core/smn_keyvalues.cpp b/core/smn_keyvalues.cpp index c6eddc36aa..a1ff138fe6 100644 --- a/core/smn_keyvalues.cpp +++ b/core/smn_keyvalues.cpp @@ -46,16 +46,16 @@ class KeyValueNatives : public IHandleTypeDispatch { public: - void OnSourceModAllInitialized() + void OnSourceModAllInitialized() override { g_KeyValueType = handlesys->CreateType("KeyValues", this, 0, NULL, NULL, g_pCoreIdent, NULL); } - void OnSourceModShutdown() + void OnSourceModShutdown() override { handlesys->RemoveType(g_KeyValueType, g_pCoreIdent); g_KeyValueType = 0; } - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { KeyValueStack *pStk = reinterpret_cast<KeyValueStack *>(object); if (pStk->m_bDeleteOnDestroy) @@ -77,10 +77,10 @@ class KeyValueNatives : return size; } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { KeyValueStack *pStk = (KeyValueStack *)object; - unsigned int size = sizeof(KeyValueStack) + (pStk->pCurRoot.size() * sizeof(KeyValues *)); + size_t size = sizeof(KeyValueStack) + (pStk->pCurRoot.size() * sizeof(KeyValues *)); /* Check how much memory the actual thing takes up */ size += CalcKVSizeR(pStk->pBase); @@ -872,7 +872,7 @@ static cell_t smn_KvNodesInStack(IPluginContext *pCtx, const cell_t *params) return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); } - return pStk->pCurRoot.size() - 1; + return (cell_t)pStk->pCurRoot.size() - 1; } static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params) @@ -1151,8 +1151,8 @@ static cell_t smn_KeyValuesToString(IPluginContext *pContext, const cell_t *para pContext->LocalToString(params[2], &outStr); size_t maxlen = static_cast<size_t>(params[3]); - buffer.GetString(outStr, maxlen); - return buffer.TellPut(); + buffer.GetString(outStr, (int)maxlen); + return (cell_t)buffer.TellPut(); } static cell_t smn_KeyValuesExportLength(IPluginContext *pContext, const cell_t *params) diff --git a/core/smn_nextmap.cpp b/core/smn_nextmap.cpp index ef6f4ab28c..0b7c55d97c 100644 --- a/core/smn_nextmap.cpp +++ b/core/smn_nextmap.cpp @@ -69,7 +69,7 @@ static cell_t sm_ForceChangeLevel(IPluginContext *pCtx, const cell_t *params) static cell_t sm_GetMapHistorySize(IPluginContext *pCtx, const cell_t *params) { - return g_NextMap.m_mapHistory.size(); + return (cell_t)g_NextMap.m_mapHistory.size(); } static cell_t sm_GetMapHistory(IPluginContext *pCtx, const cell_t *params) diff --git a/core/smn_usermsgs.cpp b/core/smn_usermsgs.cpp index 72c5f055a7..9850f8ae89 100644 --- a/core/smn_usermsgs.cpp +++ b/core/smn_usermsgs.cpp @@ -62,11 +62,11 @@ class UsrMessageNatives : public: ~UsrMessageNatives(); public: //SMGlobalClass, IHandleTypeDispatch, IPluginListener - void OnSourceModAllInitialized(); - void OnSourceModShutdown(); - void OnHandleDestroy(HandleType_t type, void *object); - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize); - void OnPluginUnloaded(IPlugin *plugin); + void OnSourceModAllInitialized() override; + void OnSourceModShutdown() override; + void OnHandleDestroy(HandleType_t type, void *object) override; + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override; + void OnPluginUnloaded(IPlugin *plugin) override; public: MsgListenerWrapper *CreateListener(IPluginContext *pCtx); bool FindListener(int msgid, IPluginContext *pCtx, IPluginFunction *pHook, bool intercept, MsgWrapperIter *iter); @@ -131,7 +131,7 @@ void UsrMessageNatives::OnHandleDestroy(HandleType_t type, void *object) #endif } -bool UsrMessageNatives::GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) +bool UsrMessageNatives::GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) { #ifdef USE_PROTOBUF_USERMESSAGES // Different messages have different sizes, but this works as an approximate @@ -267,7 +267,7 @@ size_t MsgListenerWrapper::_FillInPlayers(int *pl_array, IRecipientFilter *pFilt { size_t size = static_cast<size_t>(pFilter->GetRecipientCount()); - for (size_t i=0; i<size; i++) + for (int i=0; i<size; i++) { pl_array[i] = pFilter->GetRecipientIndex(i); } @@ -320,7 +320,7 @@ void MsgListenerWrapper::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilte m_Hook->PushCell(msg_id); m_Hook->PushCell(hndl); m_Hook->PushArray(g_MsgPlayers, size); - m_Hook->PushCell(size); + m_Hook->PushCell((cell_t)size); m_Hook->PushCell(pFilter->IsReliable()); m_Hook->PushCell(pFilter->IsInitMessage()); m_Hook->Execute(&res); @@ -352,7 +352,7 @@ ResultType MsgListenerWrapper::InterceptUserMessage(int msg_id, bf_write *bf, IR m_Intercept->PushCell(msg_id); m_Intercept->PushCell(hndl); m_Intercept->PushArray(g_MsgPlayers, size); - m_Intercept->PushCell(size); + m_Intercept->PushCell((cell_t)size); m_Intercept->PushCell(pFilter->IsReliable()); m_Intercept->PushCell(pFilter->IsInitMessage()); m_Intercept->Execute(&res); diff --git a/extensions/bintools/CallWrapper.cpp b/extensions/bintools/CallWrapper.cpp index 513b540ea9..d82c53bd58 100644 --- a/extensions/bintools/CallWrapper.cpp +++ b/extensions/bintools/CallWrapper.cpp @@ -201,7 +201,7 @@ const SourceHook::PassInfo * CallWrapper::GetSHParamInfo(unsigned int num) return &(m_Info.paramsPassInfo[num+1]); } -unsigned int CallWrapper::GetParamOffset(unsigned int num) +size_t CallWrapper::GetParamOffset(unsigned int num) { assert(num < GetParamCount() && num >= 0); diff --git a/extensions/bintools/CallWrapper.h b/extensions/bintools/CallWrapper.h index 38c65a21e3..b21c94c60b 100644 --- a/extensions/bintools/CallWrapper.h +++ b/extensions/bintools/CallWrapper.h @@ -60,7 +60,7 @@ class CallWrapper : public ICallWrapper const SourceHook::PassInfo *GetSHReturnInfo(); SourceHook::ProtoInfo::CallConvention GetSHCallConvention(); const SourceHook::PassInfo *GetSHParamInfo(unsigned int num); - unsigned int GetParamOffset(unsigned int num); + size_t GetParamOffset(unsigned int num); unsigned int GetFunctionFlags(); public: void SetCalleeAddr(void *addr); diff --git a/extensions/bintools/jit_call_x64.cpp b/extensions/bintools/jit_call_x64.cpp index a2a47fad02..69899af5cb 100644 --- a/extensions/bintools/jit_call_x64.cpp +++ b/extensions/bintools/jit_call_x64.cpp @@ -273,7 +273,7 @@ inline void Write_Function_Epilogue(JitWriter *jit, bool is_void, bool has_param X64_Return(jit); } -inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *info, unsigned int offset) +inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *info, size_t offset) { bool needStack = false; jit_uint8_t reg = NextPODReg(info->size); @@ -297,7 +297,7 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf else if (offset < SCHAR_MAX) X64_Movzx_Reg64_Rm8_Disp8(jit, reg, kREG_RBX, (jit_int8_t)offset); else - X64_Movzx_Reg64_Rm8_Disp32(jit, reg, kREG_RBX, offset); + X64_Movzx_Reg64_Rm8_Disp32(jit, reg, kREG_RBX, (jit_int32_t)offset); break; } @@ -309,7 +309,7 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf else if (offset < SCHAR_MAX) X64_Movzx_Reg64_Rm16_Disp8(jit, reg, kREG_RBX, (jit_int8_t)offset); else - X64_Movzx_Reg64_Rm16_Disp32(jit, reg, kREG_RBX, offset); + X64_Movzx_Reg64_Rm16_Disp32(jit, reg, kREG_RBX, (jit_int32_t)offset); break; } @@ -321,7 +321,7 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf else if (offset < SCHAR_MAX) X64_Mov_Reg32_Rm_Disp8(jit, reg, kREG_EBX, (jit_int8_t)offset); else - X64_Mov_Reg32_Rm_Disp32(jit, reg, kREG_RBX, offset); + X64_Mov_Reg32_Rm_Disp32(jit, reg, kREG_RBX, (jit_int32_t)offset); break; } @@ -333,7 +333,7 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf else if (offset < SCHAR_MAX) X64_Mov_Reg_Rm_Disp8(jit, reg, kREG_EBX, (jit_int8_t)offset); else - X64_Mov_Reg_Rm_Disp32(jit, reg, kREG_RBX, offset); + X64_Mov_Reg_Rm_Disp32(jit, reg, kREG_RBX, (jit_int32_t)offset); break; } @@ -348,12 +348,12 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf else if (offset < SCHAR_MAX) X64_Mov_Reg_Rm_Disp8(jit, reg, kREG_RBX, (jit_int8_t)offset); else - X64_Mov_Reg_Rm_Disp32(jit, reg, kREG_RBX, offset); + X64_Mov_Reg_Rm_Disp32(jit, reg, kREG_RBX, (jit_int32_t)offset); if (offset+8 < SCHAR_MAX) X64_Mov_Reg_Rm_Disp8(jit, reg2, kREG_RBX, (jit_int8_t)(offset+8)); else - X64_Mov_Reg_Rm_Disp32(jit, reg2, kREG_RBX, offset+8); + X64_Mov_Reg_Rm_Disp32(jit, reg2, kREG_RBX, (jit_int32_t)(offset+8)); break; } @@ -365,7 +365,7 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf else if (offset < SCHAR_MAX) X64_Lea_DispRegImm8(jit, reg, kREG_RBX, (jit_int8_t)offset); else - X64_Lea_DispRegImm32(jit, reg, kREG_RBX, offset); + X64_Lea_DispRegImm32(jit, reg, kREG_RBX, (jit_int32_t)offset); } if (needStack) @@ -399,7 +399,7 @@ inline jit_uint8_t Write_PushPOD(JitWriter *jit, const SourceHook::PassInfo *inf return reg; } -inline void Write_PushFloat(JitWriter *jit, const SourceHook::PassInfo *info, unsigned int offset, uint8_t *floatRegs) +inline void Write_PushFloat(JitWriter *jit, const SourceHook::PassInfo *info, size_t offset, uint8_t *floatRegs) { bool needStack = false; jit_uint8_t floatReg = NextFloatReg(info->size); @@ -430,9 +430,9 @@ inline void Write_PushFloat(JitWriter *jit, const SourceHook::PassInfo *info, un X64_Movups_Rm_Disp8(jit, floatReg, kREG_EBX, (jit_int8_t)offset); } else { if (offset % 16 == 0) - X64_Movaps_Rm_Disp32(jit, floatReg, kREG_EBX, offset); + X64_Movaps_Rm_Disp32(jit, floatReg, kREG_EBX, (jit_int32_t)offset); else - X64_Movups_Rm_Disp32(jit, floatReg, kREG_EBX, offset); + X64_Movups_Rm_Disp32(jit, floatReg, kREG_EBX, (jit_int32_t)offset); } break; } @@ -451,9 +451,9 @@ inline void Write_PushFloat(JitWriter *jit, const SourceHook::PassInfo *info, un X64_Movupd_Rm_Disp8(jit, floatReg, kREG_EBX, (jit_int8_t)offset); } else { if (offset % 16 == 0) - X64_Movapd_Rm_Disp32(jit, floatReg, kREG_EBX, offset); + X64_Movapd_Rm_Disp32(jit, floatReg, kREG_EBX, (jit_int32_t)offset); else - X64_Movupd_Rm_Disp32(jit, floatReg, kREG_EBX, offset); + X64_Movupd_Rm_Disp32(jit, floatReg, kREG_EBX, (jit_int32_t)offset); } break; } @@ -470,25 +470,25 @@ inline void Write_PushFloat(JitWriter *jit, const SourceHook::PassInfo *info, un if (!offset) { X64_Movaps_Rm(jit, floatReg, kREG_EBX); - X64_Movups_Rm_Disp8(jit, floatReg2, kREG_EBX, offset+8); + X64_Movups_Rm_Disp8(jit, floatReg2, kREG_EBX, (jit_int8_t)(offset+8)); } else if (offset < SCHAR_MAX) { if (offset % 16 == 0) X64_Movaps_Rm_Disp8(jit, floatReg, kREG_EBX, (jit_int8_t)offset); else X64_Movups_Rm_Disp8(jit, floatReg, kREG_EBX, (jit_int8_t)offset); if ((offset + 8) % 16 == 0) - X64_Movaps_Rm_Disp8(jit, floatReg2, kREG_EBX, (jit_int8_t)offset+8); + X64_Movaps_Rm_Disp8(jit, floatReg2, kREG_EBX, (jit_int8_t)(offset+8)); else - X64_Movups_Rm_Disp8(jit, floatReg2, kREG_EBX, (jit_int8_t)offset+8); + X64_Movups_Rm_Disp8(jit, floatReg2, kREG_EBX, (jit_int8_t)(offset+8)); } else { if (offset % 16 == 0) - X64_Movaps_Rm_Disp32(jit, floatReg, kREG_EBX, offset); + X64_Movaps_Rm_Disp32(jit, floatReg, kREG_EBX, (jit_int32_t)offset); else - X64_Movups_Rm_Disp32(jit, floatReg, kREG_EBX, offset); + X64_Movups_Rm_Disp32(jit, floatReg, kREG_EBX, (jit_int32_t)offset); if ((offset + 8) % 16 == 0) - X64_Movaps_Rm_Disp32(jit, floatReg2, kREG_EBX, offset+8); + X64_Movaps_Rm_Disp32(jit, floatReg2, kREG_EBX, (jit_int32_t)(offset+8)); else - X64_Movups_Rm_Disp32(jit, floatReg2, kREG_EBX, offset+8); + X64_Movups_Rm_Disp32(jit, floatReg2, kREG_EBX, (jit_int32_t)(offset+8)); } } } else if (info->flags & PASSFLAG_BYREF) { @@ -716,7 +716,7 @@ inline int ClassifyObject(const PassInfo *info, ObjectClass *classes) return numWords; } -inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, unsigned int offset, +inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, size_t offset, const PassInfo *smInfo) { if (info->flags & PASSFLAG_BYVAL) @@ -800,7 +800,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u return; #endif - jit_uint32_t qwords = info->size >> 3; + jit_uint32_t qwords = (jit_uint32_t)(info->size >> 3); jit_uint32_t bytes = info->size & 0x7; //sub rsp, <size> @@ -837,7 +837,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u else if (offset < SCHAR_MAX) X64_Lea_DispRegImm8(jit, kREG_RSI, kREG_RBX, (jit_int8_t)offset); else - X64_Lea_DispRegImm32(jit, kREG_RSI, kREG_RBX, offset); + X64_Lea_DispRegImm32(jit, kREG_RSI, kREG_RBX, (jit_int32_t)offset); if (qwords) { @@ -854,7 +854,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u X64_Pop_Reg(jit, kREG_RSI); X64_Pop_Reg(jit, kREG_RDI); - g_StackUsage += info->size; + g_StackUsage += (jit_uint32_t)info->size; } else if (info->flags & PASSFLAG_BYREF) { push_byref: //lea reg, [ebx+<offset>] @@ -1044,7 +1044,7 @@ void *JIT_CallCompile(CallWrapper *pWrapper, FuncAddrMethod method) JitWriter writer; JitWriter *jit = &writer; - jit_uint32_t CodeSize = 0; + size_t CodeSize = 0; bool Needs_Retbuf = false; CallConvention Convention = pWrapper->GetCallConvention(); jit_uint32_t ParamCount = pWrapper->GetParamCount(); @@ -1110,7 +1110,7 @@ void *JIT_CallCompile(CallWrapper *pWrapper, FuncAddrMethod method) /* Write parameter push code */ for (jit_uint32_t i = 0; i < ParamCount; i++) { - unsigned int offset = pWrapper->GetParamOffset(i); + size_t offset = pWrapper->GetParamOffset(i); const SourceHook::PassInfo *info = pWrapper->GetSHParamInfo(i); assert(info != NULL); diff --git a/extensions/clientprefs/cookie.cpp b/extensions/clientprefs/cookie.cpp index 6c04fef52d..2c30e23a2a 100644 --- a/extensions/clientprefs/cookie.cpp +++ b/extensions/clientprefs/cookie.cpp @@ -326,7 +326,7 @@ void CookieManager::OnPluginDestroyed(IPlugin *plugin) ItemDrawInfo draw; const char *info; AutoMenuData * data; - unsigned itemcount; + size_t itemcount; for (size_t p_iter = 0; p_iter < menuitems.size(); ++p_iter) { @@ -344,8 +344,11 @@ void CookieManager::OnPluginDestroyed(IPlugin *plugin) if (strcmp(draw.display, name) == 0) { +#if defined(PLATFORM_X86) data = (AutoMenuData *)strtoul(info, NULL, 16); - +#elif defined(PLATFORM_X64) + data = (AutoMenuData *)strtoull(info, NULL, 16); +#endif if (data->handler->forward != NULL) { forwards->ReleaseForward(data->handler->forward); diff --git a/extensions/clientprefs/menus.cpp b/extensions/clientprefs/menus.cpp index 571781892c..7fc763d5e0 100644 --- a/extensions/clientprefs/menus.cpp +++ b/extensions/clientprefs/menus.cpp @@ -40,7 +40,11 @@ void ClientMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int i const char *info = menu->GetItemInfo(item, &draw); +#if defined(PLATFORM_X86) AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16); +#elif defined(PLATFORM_X64) + AutoMenuData *data = (AutoMenuData *)strtoull(info, NULL, 16); +#endif if (data->handler->forward != NULL) { @@ -94,7 +98,11 @@ unsigned int ClientMenuHandler::OnMenuDisplayItem(IBaseMenu *menu, const char *info = menu->GetItemInfo(item, &draw); +#if defined(PLATFORM_X86) AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16); +#elif defined(PLATFORM_X64) + AutoMenuData *data = (AutoMenuData *)strtoull(info, NULL, 16); +#endif if (data->handler->forward != NULL) { @@ -123,7 +131,11 @@ void AutoMenuHandler::OnMenuSelect(SourceMod::IBaseMenu *menu, int client, unsig const char *info = menu->GetItemInfo(item, &draw); +#if defined(PLATFORM_X86) AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16); +#elif defined(PLATFORM_X64) + AutoMenuData *data = (AutoMenuData *)strtoull(info, NULL, 16); +#endif g_CookieManager.SetCookieValue(data->pCookie, client, settings[data->type][item]); diff --git a/extensions/clientprefs/natives.cpp b/extensions/clientprefs/natives.cpp index fc4e470538..9017667c98 100644 --- a/extensions/clientprefs/natives.cpp +++ b/extensions/clientprefs/natives.cpp @@ -83,10 +83,9 @@ cell_t FindClientPrefCookie(IPluginContext *pContext, const cell_t *params) NULL); } -size_t IsAuthIdConnected(char *authID) +int IsAuthIdConnected(char *authID) { IGamePlayer *player; - const char *authString; for (int playerIndex = playerhelpers->GetMaxClients()+1; --playerIndex > 0;) { @@ -468,7 +467,7 @@ cell_t GetClientCookieTime(IPluginContext *pContext, const cell_t *params) return 0; } - return value; + return (cell_t)value; } static cell_t Cookie_Set(IPluginContext *pContext, const cell_t *params) diff --git a/extensions/curl/curl-src/lib/AMBuilder b/extensions/curl/curl-src/lib/AMBuilder index e4ea990789..ca59fce9c8 100644 --- a/extensions/curl/curl-src/lib/AMBuilder +++ b/extensions/curl/curl-src/lib/AMBuilder @@ -21,6 +21,7 @@ for cxx in builder.targets: 'BUILDING_LIBCURL', 'CURL_STATICLIB', 'CURL_DISABLE_LDAP', + '_WINSOCK_DEPRECATED_NO_WARNINGS' ] elif binary.compiler.target.platform == 'linux': binary.compiler.defines += ['_GNU_SOURCE'] diff --git a/extensions/curl/curl-src/lib/connect.c b/extensions/curl/curl-src/lib/connect.c index 8cbb38320c..b58368cdd1 100644 --- a/extensions/curl/curl-src/lib/connect.c +++ b/extensions/curl/curl-src/lib/connect.c @@ -1015,7 +1015,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ * The socket 'long' will be -1 in case of failure! */ CURLcode Curl_getconnectinfo(struct SessionHandle *data, - long *param_longp, + curl_socket_t *param_longp, struct connectdata **connp) { if((data->state.lastconnect != -1) && diff --git a/extensions/curl/curl-src/lib/connect.h b/extensions/curl/curl-src/lib/connect.h index defea5e6fd..e481647235 100644 --- a/extensions/curl/curl-src/lib/connect.h +++ b/extensions/curl/curl-src/lib/connect.h @@ -52,6 +52,6 @@ long Curl_timeleft(struct connectdata *conn, * The socket 'long' will be -1 in case of failure! */ CURLcode Curl_getconnectinfo(struct SessionHandle *data, - long *param_longp, + curl_socket_t *param_longp, struct connectdata **connp); #endif diff --git a/extensions/curl/curl-src/lib/curl_addrinfo.c b/extensions/curl/curl-src/lib/curl_addrinfo.c index c6d43d53ed..47c532f193 100644 --- a/extensions/curl/curl-src/lib/curl_addrinfo.c +++ b/extensions/curl/curl-src/lib/curl_addrinfo.c @@ -146,7 +146,7 @@ Curl_getaddrinfo_ex(const char *nodename, ca->ai_next = NULL; if((ai->ai_addrlen > 0) && (ai->ai_addr != NULL)) { - ca->ai_addrlen = ai->ai_addrlen; + ca->ai_addrlen = (socklen_t)ai->ai_addrlen; if((ca->ai_addr = malloc(ca->ai_addrlen)) == NULL) { error = EAI_MEMORY; free(ca); diff --git a/extensions/curl/curl-src/lib/easy.c b/extensions/curl/curl-src/lib/easy.c index 831ee787ad..d72b33ef24 100644 --- a/extensions/curl/curl-src/lib/easy.c +++ b/extensions/curl/curl-src/lib/easy.c @@ -1084,7 +1084,7 @@ static CURLcode easy_connection(struct SessionHandle *data, struct connectdata **connp) { CURLcode ret; - long sockfd; + curl_socket_t sockfd; if(data == NULL) return CURLE_BAD_FUNCTION_ARGUMENT; @@ -1104,8 +1104,8 @@ static CURLcode easy_connection(struct SessionHandle *data, return CURLE_UNSUPPORTED_PROTOCOL; } - *sfd = (curl_socket_t)sockfd; /* we know that this is actually a socket - descriptor so the typecast is fine here */ + *sfd = sockfd; /* we know that this is actually a socket + descriptor so the typecast is fine here */ return CURLE_OK; } diff --git a/extensions/curl/curl-src/lib/file.c b/extensions/curl/curl-src/lib/file.c index 023496ec76..6f2573e2ef 100644 --- a/extensions/curl/curl-src/lib/file.c +++ b/extensions/curl/curl-src/lib/file.c @@ -429,7 +429,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done) curl_off_t expected_size=0; bool fstated=FALSE; ssize_t nread; - size_t bytestoread; + unsigned int bytestoread; struct SessionHandle *data = conn->data; char *buf = data->state.buffer; curl_off_t bytecount = 0; @@ -541,7 +541,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done) while(res == CURLE_OK) { /* Don't fill a whole buffer if we want less than all data */ - bytestoread = (expected_size < BUFSIZE-1)?(size_t)expected_size:BUFSIZE-1; + bytestoread = (expected_size < BUFSIZE-1)?(unsigned int)expected_size:BUFSIZE-1; nread = read(fd, buf, bytestoread); if( nread > 0) diff --git a/extensions/curl/curl-src/lib/ftp.c b/extensions/curl/curl-src/lib/ftp.c index c10f3a29c6..b928f35480 100644 --- a/extensions/curl/curl-src/lib/ftp.c +++ b/extensions/curl/curl-src/lib/ftp.c @@ -460,7 +460,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd, ssize_t clipamount = 0; bool restart = FALSE; - data->req.headerbytecount += gotbytes; + data->req.headerbytecount += (long)gotbytes; ftpc->nread_resp += gotbytes; for(i = 0; i < gotbytes; ptr++, i++) { @@ -4018,7 +4018,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) return CURLE_OUT_OF_MEMORY; } - dlen -= ftpc->file?strlen(ftpc->file):0; + dlen -= (int)(ftpc->file?strlen(ftpc->file):0); if((dlen == (int)strlen(ftpc->prevpath)) && strnequal(path, ftpc->prevpath, dlen)) { infof(data, "Request has same path as previous transfer\n"); diff --git a/extensions/curl/curl-src/lib/getinfo.c b/extensions/curl/curl-src/lib/getinfo.c index 7d538d74e7..0079192f13 100644 --- a/extensions/curl/curl-src/lib/getinfo.c +++ b/extensions/curl/curl-src/lib/getinfo.c @@ -211,7 +211,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) *param_charp = data->state.most_recent_ftp_entrypath; break; case CURLINFO_LASTSOCKET: - (void)Curl_getconnectinfo(data, param_longp, NULL); + (void)Curl_getconnectinfo(data, (curl_socket_t*)param_longp, NULL); break; case CURLINFO_REDIRECT_URL: /* Return the URL this request would have been redirected to if that diff --git a/extensions/curl/curl-src/lib/http.c b/extensions/curl/curl-src/lib/http.c index eef3eeb772..44d69a0b62 100644 --- a/extensions/curl/curl-src/lib/http.c +++ b/extensions/curl/curl-src/lib/http.c @@ -1062,7 +1062,7 @@ CURLcode add_buffer_send(send_buffer *in, accordingly */ http->writebytecount += bodylen; - *bytes_written += amount; + *bytes_written += (long)amount; if(http) { if((size_t)amount != size) { diff --git a/extensions/curl/curl-src/lib/setup_once.h b/extensions/curl/curl-src/lib/setup_once.h index f67e3214b2..de7b2251f9 100644 --- a/extensions/curl/curl-src/lib/setup_once.h +++ b/extensions/curl/curl-src/lib/setup_once.h @@ -370,38 +370,68 @@ typedef int sig_atomic_t; #define EINTR WSAEINTR #undef EINVAL /* override definition in errno.h */ #define EINVAL WSAEINVAL +#undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK +#undef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS +#undef EALREADY #define EALREADY WSAEALREADY +#undef ENOTSOCK #define ENOTSOCK WSAENOTSOCK +#undef EDESTADDRREQ #define EDESTADDRREQ WSAEDESTADDRREQ +#undef EMSGSIZE #define EMSGSIZE WSAEMSGSIZE +#undef EPROTOTYPE #define EPROTOTYPE WSAEPROTOTYPE +#undef ENOPROTOOPT #define ENOPROTOOPT WSAENOPROTOOPT +#undef EPROTONOSUPPORT #define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#undef ESOCKTNOSUPPORT #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#undef EOPNOTSUPP #define EOPNOTSUPP WSAEOPNOTSUPP +#undef EPFNOSUPPORT #define EPFNOSUPPORT WSAEPFNOSUPPORT +#undef EAFNOSUPPORT #define EAFNOSUPPORT WSAEAFNOSUPPORT +#undef EADDRINUSE #define EADDRINUSE WSAEADDRINUSE +#undef EADDRNOTAVAIL #define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#undef ENETDOWN #define ENETDOWN WSAENETDOWN +#undef ENETUNREACH #define ENETUNREACH WSAENETUNREACH +#undef ENETRESET #define ENETRESET WSAENETRESET +#undef ECONNABORTED #define ECONNABORTED WSAECONNABORTED +#undef ECONNRESET #define ECONNRESET WSAECONNRESET +#undef ENOBUFS #define ENOBUFS WSAENOBUFS +#undef EISCONN #define EISCONN WSAEISCONN +#undef ENOTCONN #define ENOTCONN WSAENOTCONN +#undef ESHUTDOWN #define ESHUTDOWN WSAESHUTDOWN +#undef ETOOMANYREFS #define ETOOMANYREFS WSAETOOMANYREFS +#undef ETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT +#undef ECONNREFUSED #define ECONNREFUSED WSAECONNREFUSED +#undef ELOOP #define ELOOP WSAELOOP #ifndef ENAMETOOLONG /* possible previous definition in errno.h */ #define ENAMETOOLONG WSAENAMETOOLONG #endif +#undef EHOSTDOWN #define EHOSTDOWN WSAEHOSTDOWN +#undef EHOSTUNREACH #define EHOSTUNREACH WSAEHOSTUNREACH #ifndef ENOTEMPTY /* possible previous definition in errno.h */ #define ENOTEMPTY WSAENOTEMPTY diff --git a/extensions/curl/curl-src/lib/socks.c b/extensions/curl/curl-src/lib/socks.c index e7419dfb90..52626d2efd 100644 --- a/extensions/curl/curl-src/lib/socks.c +++ b/extensions/curl/curl-src/lib/socks.c @@ -479,7 +479,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, else if(socksreq[1] == 2) { /* Needs user name and password */ size_t userlen, pwlen; - int len; + size_t len; if(proxy_name && proxy_password) { userlen = strlen(proxy_name); pwlen = strlen(proxy_password); diff --git a/extensions/curl/curl-src/lib/tftp.c b/extensions/curl/curl-src/lib/tftp.c index b59fbae902..075b3754d4 100644 --- a/extensions/curl/curl-src/lib/tftp.c +++ b/extensions/curl/curl-src/lib/tftp.c @@ -132,8 +132,8 @@ typedef struct tftp_state_data { struct connectdata *conn; curl_socket_t sockfd; int retries; - int retry_time; - int retry_max; + time_t retry_time; + time_t retry_max; time_t start_time; time_t max_time; unsigned short block; @@ -744,7 +744,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done) /* Wait until ready to read or timeout occurs */ rc=Curl_socket_ready(state->sockfd, CURL_SOCKET_BAD, - state->retry_time * 1000); + (int)state->retry_time * 1000); if(rc == -1) { /* bail out */ diff --git a/extensions/curl/curl-src/lib/url.c b/extensions/curl/curl-src/lib/url.c index 2befc85deb..ddcaaf68ed 100644 --- a/extensions/curl/curl-src/lib/url.c +++ b/extensions/curl/curl-src/lib/url.c @@ -537,7 +537,7 @@ struct conncache *Curl_mk_connc(int type, return NULL; if((size_t)(default_amount) > ((size_t)-1) / sizeof(struct connectdata *)) - default_amount = ((size_t)-1) / sizeof(struct connectdata *); + default_amount = (long)(((size_t)-1) / sizeof(struct connectdata *)); c->connects = calloc(sizeof(struct connectdata *), (size_t)default_amount); if(!c->connects) { diff --git a/extensions/geoip/extension.cpp b/extensions/geoip/extension.cpp index 2b86986335..1e97287bde 100644 --- a/extensions/geoip/extension.cpp +++ b/extensions/geoip/extension.cpp @@ -380,7 +380,7 @@ static cell_t sm_Geoip_Latitude(IPluginContext *pCtx, const cell_t *params) StripPort(ip); const char *path[] = {"location", "latitude", NULL}; - double latitude = lookupDouble(ip, path); + float latitude = (float)lookupDouble(ip, path); return sp_ftoc(latitude); } @@ -392,19 +392,19 @@ static cell_t sm_Geoip_Longitude(IPluginContext *pCtx, const cell_t *params) StripPort(ip); const char *path[] = {"location", "longitude", NULL}; - double longitude = lookupDouble(ip, path); + float longitude = (float)lookupDouble(ip, path); return sp_ftoc(longitude); } static cell_t sm_Geoip_Distance(IPluginContext *pCtx, const cell_t *params) { - float earthRadius = params[5] ? 3958.0 : 6370.997; // miles / km + float earthRadius = params[5] ? 3958.0f : 6370.997f; // miles / km - float lat1 = sp_ctof(params[1]) * (M_PI / 180); - float lon1 = sp_ctof(params[2]) * (M_PI / 180); - float lat2 = sp_ctof(params[3]) * (M_PI / 180); - float lon2 = sp_ctof(params[4]) * (M_PI / 180); + float lat1 = sp_ctof(params[1]) * ((float)M_PI / 180); + float lon1 = sp_ctof(params[2]) * ((float)M_PI / 180); + float lat2 = sp_ctof(params[3]) * ((float)M_PI / 180); + float lon2 = sp_ctof(params[4]) * ((float)M_PI / 180); return sp_ftoc(earthRadius * acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1))); } diff --git a/extensions/pgsql/pgsql/PgDriver.cpp b/extensions/pgsql/pgsql/PgDriver.cpp index cda7aceb14..34dd893b9f 100644 --- a/extensions/pgsql/pgsql/PgDriver.cpp +++ b/extensions/pgsql/pgsql/PgDriver.cpp @@ -220,7 +220,7 @@ void PgDriver::ShutdownThreadSafety() return; } -unsigned int strncopy(char *dest, const char *src, size_t count) +size_t strncopy(char *dest, const char *src, size_t count) { if (!count) { diff --git a/extensions/pgsql/pgsql/PgDriver.h b/extensions/pgsql/pgsql/PgDriver.h index 5a59fe012a..17f8b77d75 100644 --- a/extensions/pgsql/pgsql/PgDriver.h +++ b/extensions/pgsql/pgsql/PgDriver.h @@ -77,6 +77,6 @@ class PgDriver : public IDBDriver extern PgDriver g_PgDriver; -unsigned int strncopy(char *dest, const char *src, size_t count); +size_t strncopy(char *dest, const char *src, size_t count); #endif //_INCLUDE_SM_PGSQL_DRIVER_H_ diff --git a/extensions/pgsql/pgsql/PgStatement.cpp b/extensions/pgsql/pgsql/PgStatement.cpp index 0c920207d5..62f8c81ad8 100644 --- a/extensions/pgsql/pgsql/PgStatement.cpp +++ b/extensions/pgsql/pgsql/PgStatement.cpp @@ -243,14 +243,14 @@ bool PgStatement::Execute() case DBType_String: { paramValues[i] = (char *)m_pushinfo[i].blob; - paramLengths[i] = m_pushinfo[i].length; + paramLengths[i] = (int)m_pushinfo[i].length; paramFormats[i] = 0; break; } case DBType_Blob: { paramValues[i] = (char *)m_pushinfo[i].blob; - paramLengths[i] = m_pushinfo[i].length; + paramLengths[i] = (int)m_pushinfo[i].length; paramFormats[i] = 1; break; } diff --git a/extensions/regex/CRegEx.cpp b/extensions/regex/CRegEx.cpp index 06a50dca7a..be80963255 100644 --- a/extensions/regex/CRegEx.cpp +++ b/extensions/regex/CRegEx.cpp @@ -94,7 +94,7 @@ int RegEx::Compile(const char *pattern, int iFlags) return 1; } -int RegEx::Match(const char *const str, const size_t offset) +int RegEx::Match(const char *const str, const int offset) { int rc = 0; @@ -106,7 +106,7 @@ int RegEx::Match(const char *const str, const size_t offset) //save str subject = strdup(str); - rc = pcre_exec(re, nullptr, subject, strlen(subject), offset, 0, mMatches[0].mVector, MAX_CAPTURES); + rc = pcre_exec(re, nullptr, subject, (int)strlen(subject), offset, 0, mMatches[0].mVector, MAX_CAPTURES); if (rc < 0) { @@ -138,10 +138,10 @@ int RegEx::MatchAll(const char *str) subject = strdup(str); size_t len = strlen(subject); - size_t offset = 0; + int offset = 0; unsigned int matches = 0; - while (matches < MAX_MATCHES && offset < len && (rc = pcre_exec(re, 0, subject, len, offset, 0, mMatches[matches].mVector, MAX_CAPTURES)) >= 0) + while (matches < MAX_MATCHES && offset < len && (rc = pcre_exec(re, 0, subject, (int)len, offset, 0, mMatches[matches].mVector, MAX_CAPTURES)) >= 0) { offset = mMatches[matches].mVector[1]; mMatches[matches].mSubStringCount = rc; diff --git a/extensions/regex/CRegEx.h b/extensions/regex/CRegEx.h index 8a0885759d..7e403567a8 100644 --- a/extensions/regex/CRegEx.h +++ b/extensions/regex/CRegEx.h @@ -51,7 +51,7 @@ class RegEx void Clear(); int Compile(const char *pattern, int iFlags); - int Match(const char *const str, const size_t offset); + int Match(const char *const str, const int offset); int MatchAll(const char *str); void ClearMatch(); bool GetSubstring(int s, char buffer[], int max, int match); diff --git a/extensions/regex/extension.cpp b/extensions/regex/extension.cpp index 0483dba5b3..d79275e4b5 100644 --- a/extensions/regex/extension.cpp +++ b/extensions/regex/extension.cpp @@ -125,10 +125,10 @@ static cell_t MatchRegex(IPluginContext *pCtx, const cell_t *params) return 0; } - size_t offset = 0; + int offset = 0; if (params[0] >= 4) { - offset = static_cast<size_t>(params[4]); + offset = params[4]; } char *str; diff --git a/extensions/sdktools/CellRecipientFilter.h b/extensions/sdktools/CellRecipientFilter.h index 213443a573..0c710ad1e4 100644 --- a/extensions/sdktools/CellRecipientFilter.h +++ b/extensions/sdktools/CellRecipientFilter.h @@ -76,7 +76,7 @@ inline bool CellRecipientFilter::IsInitMessage() const inline int CellRecipientFilter::GetRecipientCount() const { - return m_Size; + return (int)m_Size; } inline int CellRecipientFilter::GetRecipientIndex(int slot) const diff --git a/extensions/sdktools/gamerulesnatives.cpp b/extensions/sdktools/gamerulesnatives.cpp index 07f4477a71..a1986978b2 100644 --- a/extensions/sdktools/gamerulesnatives.cpp +++ b/extensions/sdktools/gamerulesnatives.cpp @@ -195,7 +195,7 @@ static cell_t GameRules_GetProp(IPluginContext *pContext, const cell_t *params) { char *prop; int element = params[3]; - int offset; + size_t offset; int bit_count; bool is_unsigned; @@ -264,7 +264,7 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params) { char *prop; int element = params[4]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -320,7 +320,7 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params) edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)); if (proxyEdict != NULL) - gamehelpers->SetEdictStateChanged(proxyEdict, offset); + gamehelpers->SetEdictStateChanged(proxyEdict, (unsigned short)offset); return 0; } @@ -329,7 +329,7 @@ static cell_t GameRules_GetPropFloat(IPluginContext *pContext, const cell_t *par { char *prop; int element = params[2]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -350,7 +350,7 @@ static cell_t GameRules_SetPropFloat(IPluginContext *pContext, const cell_t *par { char *prop; int element = params[3]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -379,7 +379,7 @@ static cell_t GameRules_SetPropFloat(IPluginContext *pContext, const cell_t *par edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)); if (proxyEdict != NULL) - gamehelpers->SetEdictStateChanged(proxyEdict, offset); + gamehelpers->SetEdictStateChanged(proxyEdict, (unsigned short)offset); return 0; } @@ -388,7 +388,7 @@ static cell_t GameRules_GetPropEnt(IPluginContext *pContext, const cell_t *param { char *prop; int element = params[2]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -415,7 +415,7 @@ static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *param { char *prop; int element = params[3]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -460,7 +460,7 @@ static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *param edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)); if (proxyEdict != NULL) - gamehelpers->SetEdictStateChanged(proxyEdict, offset); + gamehelpers->SetEdictStateChanged(proxyEdict, (unsigned short)offset); return 0; } @@ -469,7 +469,7 @@ static cell_t GameRules_GetPropVector(IPluginContext *pContext, const cell_t *pa { char *prop; int element = params[3]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -497,7 +497,7 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa { char *prop; int element = params[3]; - int offset; + size_t offset; int bit_count; void *pGameRules = GameRules(); @@ -531,7 +531,7 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)); if (proxyEdict != NULL) - gamehelpers->SetEdictStateChanged(proxyEdict, offset); + gamehelpers->SetEdictStateChanged(proxyEdict, (unsigned short)offset); return 1; } @@ -539,7 +539,7 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa static cell_t GameRules_GetPropString(IPluginContext *pContext, const cell_t *params) { char *prop; - int offset; + size_t offset; int bit_count; int element = 0; @@ -573,7 +573,7 @@ static cell_t GameRules_GetPropString(IPluginContext *pContext, const cell_t *pa { size_t len; pContext->StringToLocalUTF8(params[2], params[3], src, &len); - return len; + return (cell_t)len; } pContext->StringToLocal(params[2], params[3], ""); @@ -583,7 +583,7 @@ static cell_t GameRules_GetPropString(IPluginContext *pContext, const cell_t *pa static cell_t GameRules_SetPropString(IPluginContext *pContext, const cell_t *params) { char *prop; - int offset; + size_t offset; int maxlen; int bit_count; @@ -647,9 +647,9 @@ static cell_t GameRules_SetPropString(IPluginContext *pContext, const cell_t *pa edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)); if (proxyEdict != NULL) - gamehelpers->SetEdictStateChanged(proxyEdict, offset); + gamehelpers->SetEdictStateChanged(proxyEdict, (unsigned short)offset); - return len; + return (cell_t)len; } sp_nativeinfo_t g_GameRulesNatives[] = diff --git a/extensions/sdktools/teamnatives.cpp b/extensions/sdktools/teamnatives.cpp index 6334ca5e48..6005999bac 100644 --- a/extensions/sdktools/teamnatives.cpp +++ b/extensions/sdktools/teamnatives.cpp @@ -86,7 +86,7 @@ void InitTeamNatives() static cell_t GetTeamCount(IPluginContext *pContext, const cell_t *params) { - return g_Teams.size(); + return (cell_t)g_Teams.size(); } static int g_teamname_offset = -1; diff --git a/extensions/sdktools/tempents.cpp b/extensions/sdktools/tempents.cpp index e71d652fd8..7b03aeb689 100644 --- a/extensions/sdktools/tempents.cpp +++ b/extensions/sdktools/tempents.cpp @@ -115,14 +115,14 @@ bool TempEntityInfo::IsValidProp(const char *name) return (g_pGameHelpers->FindInSendTable(m_Sc->GetName(), name)) ? true : false; } -int TempEntityInfo::_FindOffset(const char *name, int *size) +size_t TempEntityInfo::_FindOffset(const char *name, int *size) { - int offset; + size_t offset; sm_sendprop_info_t info; if (!g_pGameHelpers->FindSendPropInfo(m_Sc->GetName(), name, &info)) { - return -1; + return INVALID_OFFSET; } offset = info.actual_offset; @@ -138,9 +138,9 @@ bool TempEntityInfo::TE_SetEntData(const char *name, int value) { /* Search for our offset */ int size; - int offset = _FindOffset(name, &size); + size_t offset = _FindOffset(name, &size); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -163,9 +163,9 @@ bool TempEntityInfo::TE_GetEntData(const char *name, int *value) { /* Search for our offset */ int size; - int offset = _FindOffset(name, &size); + size_t offset = _FindOffset(name, &size); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -187,9 +187,9 @@ bool TempEntityInfo::TE_GetEntData(const char *name, int *value) bool TempEntityInfo::TE_SetEntDataEnt(const char *name, IHandleEntity *value) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -204,9 +204,9 @@ bool TempEntityInfo::TE_SetEntDataEnt(const char *name, IHandleEntity *value) bool TempEntityInfo::TE_GetEntDataEnt(const char *name, IHandleEntity **value) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -224,9 +224,9 @@ bool TempEntityInfo::TE_GetEntDataEnt(const char *name, IHandleEntity **value) bool TempEntityInfo::TE_SetEntDataFloat(const char *name, float value) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -239,9 +239,9 @@ bool TempEntityInfo::TE_SetEntDataFloat(const char *name, float value) bool TempEntityInfo::TE_GetEntDataFloat(const char *name, float *value) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -254,9 +254,9 @@ bool TempEntityInfo::TE_GetEntDataFloat(const char *name, float *value) bool TempEntityInfo::TE_SetEntDataVector(const char *name, float vector[3]) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -272,9 +272,9 @@ bool TempEntityInfo::TE_SetEntDataVector(const char *name, float vector[3]) bool TempEntityInfo::TE_GetEntDataVector(const char *name, float vector[3]) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } @@ -290,9 +290,9 @@ bool TempEntityInfo::TE_GetEntDataVector(const char *name, float vector[3]) bool TempEntityInfo::TE_SetEntDataFloatArray(const char *name, cell_t *array, int size) { /* Search for our offset */ - int offset = _FindOffset(name); + size_t offset = _FindOffset(name); - if (offset < 0) + if (offset == INVALID_OFFSET) { return false; } diff --git a/extensions/sdktools/tempents.h b/extensions/sdktools/tempents.h index fddb86144c..612fb62bf2 100644 --- a/extensions/sdktools/tempents.h +++ b/extensions/sdktools/tempents.h @@ -57,7 +57,7 @@ class TempEntityInfo bool TE_GetEntDataVector(const char *name, float vector[3]); void Send(IRecipientFilter &filter, float delay); private: - int _FindOffset(const char *name, int *size=NULL); + size_t _FindOffset(const char *name, int *size=NULL); private: void *m_Me; ServerClass *m_Sc; @@ -107,7 +107,7 @@ class TempEntHooks : public IPluginsListener private: void _IncRefCounter(); void _DecRefCounter(); - size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); + int _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); private: IBasicTrie *m_TEHooks; SourceHook::List<TEHookInfo *> m_HookInfo; diff --git a/extensions/sdktools/tenatives.cpp b/extensions/sdktools/tenatives.cpp index 014538aea5..0ed7b6235e 100644 --- a/extensions/sdktools/tenatives.cpp +++ b/extensions/sdktools/tenatives.cpp @@ -132,11 +132,11 @@ void TempEntHooks::_DecRefCounter() } } -size_t TempEntHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter) +int TempEntHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter) { - size_t size = static_cast<size_t>(pFilter->GetRecipientCount()); + int size = pFilter->GetRecipientCount(); - for (size_t i=0; i<size; i++) + for (int i=0; i<size; i++) { pl_array[i] = pFilter->GetRecipientIndex(i); } @@ -207,7 +207,7 @@ void TempEntHooks::OnPlaybackTempEntity(IRecipientFilter &filter, float delay, c { SourceHook::List<IPluginFunction *>::iterator iter; IPluginFunction *pFunc; - size_t size; + int size; cell_t res = static_cast<ResultType>(Pl_Continue); TempEntityInfo *oldinfo = g_CurrentTE; diff --git a/extensions/sdktools/vcaller.cpp b/extensions/sdktools/vcaller.cpp index 3cabcc40ae..2bb9f9013e 100644 --- a/extensions/sdktools/vcaller.cpp +++ b/extensions/sdktools/vcaller.cpp @@ -396,7 +396,9 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params) //note: varargs pawn args are passed by-ref cell_t *cell; pContext->LocalToPhysAddr(params[startparam], &cell); - void *thisptr = reinterpret_cast<void*>(*cell); + // To-Do: this really needs to be addressed for 64bits, a cell_t cannot hold an address + // void *thisptr = reinterpret_cast<void*>(*cell); + void *thisptr = *(void**)cell; if (thisptr == nullptr) { diff --git a/extensions/sdktools/vhelpers.cpp b/extensions/sdktools/vhelpers.cpp index 7d5c5545d0..cd0dc5d90f 100644 --- a/extensions/sdktools/vhelpers.cpp +++ b/extensions/sdktools/vhelpers.cpp @@ -322,7 +322,7 @@ bool CollisionRulesChanged(CBaseEntity *pEntity) // In order to keep consitent behaviour across all entities, including CNodeEnt and potential source games that have entity classes overriding this function. // We are going to fetch the world entity, which doesn't have this function overriden (on all source games hopefully), and obtain the function address static void *func = nullptr; - static int offsethOwnerEntity = -1; + static size_t offsethOwnerEntity = INVALID_OFFSET; if (func == nullptr) { int offset = -1; @@ -354,7 +354,7 @@ bool CollisionRulesChanged(CBaseEntity *pEntity) offsethOwnerEntity = offset_data_info.actual_offset; } - if (offsethOwnerEntity == -1) + if (offsethOwnerEntity == INVALID_OFFSET) { // Well... return false; @@ -482,7 +482,7 @@ char *UTIL_SendFlagsToString(int flags, int type) } #endif - int len = strlen(str) - 1; + size_t len = strlen(str) - 1; if (len > 0) { str[len] = 0; // Strip the final '|' @@ -886,7 +886,7 @@ char *UTIL_DataFlagsToString(int flags) strcat(str, "Override|"); } - int len = strlen(str) - 1; + size_t len = strlen(str) - 1; if (len > 0) { str[len] = 0; // Strip the final '|' @@ -1006,7 +1006,7 @@ CON_COMMAND(sm_dump_datamaps, "Dumps the data map list as a text file") fprintf(fp, "//\n\n"); - static int offsEFlags = -1; + static size_t offsEFlags = INVALID_OFFSET; for ( int i = dict->m_Factories.First(); i != dict->m_Factories.InvalidIndex(); i = dict->m_Factories.Next( i ) ) { IServerNetworkable *entity = dict->Create(dict->m_Factories.GetElementName(i)); @@ -1017,7 +1017,7 @@ CON_COMMAND(sm_dump_datamaps, "Dumps the data map list as a text file") UTIL_DrawDataTable(fp, pMap, 0); - if (offsEFlags == -1) + if (offsEFlags == INVALID_OFFSET) { sm_datatable_info_t info; if (!gamehelpers->FindDataMapInfo(pMap, "m_iEFlags", &info)) @@ -1154,7 +1154,7 @@ CON_COMMAND(sm_dump_datamaps_xml, "Dumps the data map list as an XML file") fprintf(fp, "<datamaps>\n"); - static int offsEFlags = -1; + static size_t offsEFlags = INVALID_OFFSET; for (int i = dict->m_Factories.First(); i != dict->m_Factories.InvalidIndex(); i = dict->m_Factories.Next(i)) { IServerNetworkable *entity = dict->Create(dict->m_Factories.GetElementName(i)); @@ -1167,7 +1167,7 @@ CON_COMMAND(sm_dump_datamaps_xml, "Dumps the data map list as an XML file") fprintf(fp, " </serverclass>\n"); - if (offsEFlags == -1) + if (offsEFlags == INVALID_OFFSET) { sm_datatable_info_t info; if (!gamehelpers->FindDataMapInfo(pMap, "m_iEFlags", &info)) diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index be41f65e05..2a557eb3a5 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -646,7 +646,7 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params) static ICallWrapper *s_teleport = NULL; static int s_health_offs = 0; static int s_sound_count = 0; - static int s_frag_offs = 0; + static size_t s_frag_offs = 0; if (!s_slap_setup) { @@ -900,10 +900,10 @@ static cell_t NativeFindEntityByClassname(IPluginContext *pContext, const cell_t pContext->LocalToString(params[2], &searchname); const char *classname; - int lastletterpos; + size_t lastletterpos; - static int offset = -1; - if (offset == -1) + static size_t offset = INVALID_OFFSET; + if (offset == INVALID_OFFSET) { sm_datatable_info_t info; if (!gamehelpers->FindDataMapInfo(gamehelpers->GetDataMap(pEntity), "m_iClassname", &info)) @@ -1615,7 +1615,7 @@ static cell_t SetEntityCollisionGroup(IPluginContext *pContext, const cell_t *pa CBaseEntity *pEntity; ENTINDEX_TO_CBASEENTITY(params[1], pEntity); - int offsetCollisionGroup = -1; + size_t offsetCollisionGroup = INVALID_OFFSET; // Retrieve m_hOwnerEntity offset sm_datatable_info_t offset_data_info; datamap_t *offsetMap = gamehelpers->GetDataMap(pEntity); diff --git a/extensions/sdktools/voice.cpp b/extensions/sdktools/voice.cpp index d872b8f7e0..97172d8eea 100644 --- a/extensions/sdktools/voice.cpp +++ b/extensions/sdktools/voice.cpp @@ -51,7 +51,7 @@ enum ListenOverride Listen_Yes, /**< Can hear */ }; -size_t g_VoiceFlags[SM_MAXPLAYERS+1]; +unsigned int g_VoiceFlags[SM_MAXPLAYERS+1]; size_t g_VoiceHookCount = 0; ListenOverride g_VoiceMap[SM_MAXPLAYERS+1][SM_MAXPLAYERS+1]; bool g_ClientMutes[SM_MAXPLAYERS+1][SM_MAXPLAYERS+1]; diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index 52a131da62..a418f5793d 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -67,11 +67,11 @@ cell_t SoundReferenceToIndex(cell_t ref) return gamehelpers->ReferenceToIndex(ref); } -size_t SoundHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter) +int SoundHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter) { - size_t size = static_cast<size_t>(pFilter->GetRecipientCount()); + int size = pFilter->GetRecipientCount(); - for (size_t i=0; i<size; i++) + for (int i=0; i<size; i++) { pl_array[i] = pFilter->GetRecipientIndex(i); } diff --git a/extensions/sdktools/vsound.h b/extensions/sdktools/vsound.h index 11f277aa81..35e5fffd86 100644 --- a/extensions/sdktools/vsound.h +++ b/extensions/sdktools/vsound.h @@ -95,7 +95,7 @@ class SoundHooks : public IPluginsListener #endif // SOURCE_ENGINE == SE_CSS, SE_HL2DM, SE_DODS, SE_SDK2013, SE_BMS, SE_TF2, SE_PVKII #endif // SOURCE_ENGINE >= SE_PORTAL2 private: - size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); + int _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); void _IncRefCounter(int type); void _DecRefCounter(int type); private: diff --git a/extensions/sdktools/vstringtable.cpp b/extensions/sdktools/vstringtable.cpp index 8827bf43e8..c55dd2a160 100644 --- a/extensions/sdktools/vstringtable.cpp +++ b/extensions/sdktools/vstringtable.cpp @@ -97,7 +97,7 @@ static cell_t GetStringTableName(IPluginContext *pContext, const cell_t *params) pContext->StringToLocalUTF8(params[2], params[3], pTable->GetTableName(), &numBytes); - return numBytes; + return (cell_t)numBytes; } static cell_t FindStringIndex(IPluginContext *pContext, const cell_t *params) @@ -121,7 +121,7 @@ static cell_t FindStringIndex(IPluginContext *pContext, const cell_t *params) return -1; } - return strindex; + return (cell_t)strindex; } static cell_t ReadStringTable(IPluginContext *pContext, const cell_t *params) @@ -147,7 +147,7 @@ static cell_t ReadStringTable(IPluginContext *pContext, const cell_t *params) pContext->StringToLocalUTF8(params[3], params[4], value, &numBytes); - return numBytes; + return (cell_t)numBytes; } static cell_t GetStringTableDataLength(IPluginContext *pContext, const cell_t *params) @@ -215,7 +215,7 @@ static cell_t GetStringTableData(IPluginContext *pContext, const cell_t *params) numBytes = 0; } - return numBytes; + return (cell_t)numBytes; } static cell_t SetStringTableData(IPluginContext *pContext, const cell_t *params) diff --git a/extensions/sqlite/driver/SqDatabase.cpp b/extensions/sqlite/driver/SqDatabase.cpp index 52df8b3999..75436bd3ee 100644 --- a/extensions/sqlite/driver/SqDatabase.cpp +++ b/extensions/sqlite/driver/SqDatabase.cpp @@ -208,7 +208,7 @@ IPreparedQuery *SqDatabase::PrepareQueryEx(const char *query, int *errCode/* =NULL */) { sqlite3_stmt *stmt = NULL; - if ((m_LastErrorCode = sqlite3_prepare_v2(m_sq3, query, len, &stmt, NULL)) != SQLITE_OK + if ((m_LastErrorCode = sqlite3_prepare_v2(m_sq3, query, (int)len, &stmt, NULL)) != SQLITE_OK || !stmt) { const char *msg; diff --git a/extensions/sqlite/driver/SqDriver.cpp b/extensions/sqlite/driver/SqDriver.cpp index 3b4ffbaff7..7363626eb7 100644 --- a/extensions/sqlite/driver/SqDriver.cpp +++ b/extensions/sqlite/driver/SqDriver.cpp @@ -37,7 +37,7 @@ SqDriver g_SqDriver; -unsigned int strncopy(char *dest, const char *src, size_t count) +size_t strncopy(char *dest, const char *src, size_t count) { if (!count) { diff --git a/extensions/sqlite/driver/SqDriver.h b/extensions/sqlite/driver/SqDriver.h index e41c9e7028..778e18b303 100644 --- a/extensions/sqlite/driver/SqDriver.h +++ b/extensions/sqlite/driver/SqDriver.h @@ -80,6 +80,6 @@ class SqDriver : public IDBDriver extern SqDriver g_SqDriver; -unsigned int strncopy(char *dest, const char *src, size_t count); +size_t strncopy(char *dest, const char *src, size_t count); #endif //_INCLUDE_SQLITE_SOURCEMOD_DRIVER_H_ diff --git a/extensions/sqlite/driver/SqQuery.cpp b/extensions/sqlite/driver/SqQuery.cpp index 063d395a02..b44b01ba23 100644 --- a/extensions/sqlite/driver/SqQuery.cpp +++ b/extensions/sqlite/driver/SqQuery.cpp @@ -122,7 +122,7 @@ bool SqQuery::BindParamBlob(unsigned int param, const void *data, size_t length, return false; } - return (sqlite3_bind_blob(m_pStmt, param, data, length, copy ? SQLITE_TRANSIENT : SQLITE_STATIC) == SQLITE_OK); + return (sqlite3_bind_blob(m_pStmt, param, data, (int)length, copy ? SQLITE_TRANSIENT : SQLITE_STATIC) == SQLITE_OK); } sqlite3_stmt *SqQuery::GetStmt() diff --git a/extensions/tf2/conditions.h b/extensions/tf2/conditions.h index 24404509d8..7fdf41a6d0 100644 --- a/extensions/tf2/conditions.h +++ b/extensions/tf2/conditions.h @@ -60,7 +60,7 @@ class PlayerConditionsMgr : public IClientListener void OnConVarChange(CondVar var, const SendProp *pProp, const void *pStructBase, const void *pData, DVariant *pOut, int iElement, int objectID); void ProcessCondChange(CondChangeData_t *pCondData); private: - inline unsigned int GetPropOffs(CondVar var) + inline size_t GetPropOffs(CondVar var) { return m_CondVarProps[var].actual_offset; } diff --git a/extensions/tf2/criticals.cpp b/extensions/tf2/criticals.cpp index dac519cbe1..34445c1d50 100644 --- a/extensions/tf2/criticals.cpp +++ b/extensions/tf2/criticals.cpp @@ -73,7 +73,7 @@ bool CritManager::TryEnable() m_hooksSetup = true; } - for (size_t i = playerhelpers->GetMaxClients() + 1; i < MAX_EDICTS; ++i) + for (int i = playerhelpers->GetMaxClients() + 1; i < MAX_EDICTS; ++i) { CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i); if (pEntity == NULL) diff --git a/extensions/topmenus/TopMenu.cpp b/extensions/topmenus/TopMenu.cpp index 28a173913e..81f7e96500 100644 --- a/extensions/topmenus/TopMenu.cpp +++ b/extensions/topmenus/TopMenu.cpp @@ -40,7 +40,6 @@ struct obj_by_name_t }; int _SortObjectNamesDescending(const void *ptr1, const void *ptr2); -unsigned int strncopy(char *dest, const char *src, size_t count); size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...); TopMenu::TopMenu(ITopMenuObjectCallbacks *callbacks) @@ -91,9 +90,9 @@ TopMenu::~TopMenu() } } -unsigned int TopMenu::CalcMemUsage() +size_t TopMenu::CalcMemUsage() { - unsigned int size = sizeof(TopMenu); + size_t size = sizeof(TopMenu); size += m_Config.strings.GetMemTable()->GetMemUsage(); size += (m_Config.cats.size() * sizeof(int)); @@ -519,7 +518,7 @@ bool TopMenu::FindCategoryByObject(unsigned int obj_id, size_t *index) return false; } -bool TopMenu::DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position) +bool TopMenu::DisplayCategory(int client, size_t category, unsigned int hold_time, bool last_position) { UpdateClientCategory(client, category); @@ -797,7 +796,7 @@ void TopMenu::UpdateClientRoot(int client, IGamePlayer *pGamePlayer) pClient->last_root_pos = 0; } -void TopMenu::UpdateClientCategory(int client, unsigned int category, bool bSkipRootCheck) +void TopMenu::UpdateClientCategory(int client, size_t category, bool bSkipRootCheck) { bool has_access = false; @@ -919,7 +918,7 @@ void TopMenu::UpdateClientCategory(int client, unsigned int category, bool bSkip player_cat->serial = cat->serial; } -void TopMenu::SortCategoryIfNeeded(unsigned int category) +void TopMenu::SortCategoryIfNeeded(size_t category) { topmenu_category_t *cat = m_Categories[category]; if (!cat->reorder) @@ -936,7 +935,7 @@ void TopMenu::SortCategoryIfNeeded(unsigned int category) return; } - CVector<unsigned int> to_sort; + CVector<size_t> to_sort; for (size_t i = 0; i < cat->obj_list.size(); i++) { to_sort.push_back(i); @@ -1251,7 +1250,7 @@ int _SortObjectNamesDescending(const void *ptr1, const void *ptr2) return strcmp(obj1->name, obj2->name); } -unsigned int strncopy(char *dest, const char *src, size_t count) +size_t strncopy(char *dest, const char *src, size_t count) { if (!count) { diff --git a/extensions/topmenus/TopMenu.h b/extensions/topmenus/TopMenu.h index 298c7f58a4..5dcbceb28d 100644 --- a/extensions/topmenus/TopMenu.h +++ b/extensions/topmenus/TopMenu.h @@ -71,7 +71,7 @@ struct topmenu_object_t TopMenuObjectType type; /** Object Type */ bool is_free; /** Free or not? */ char info[255]; /** Info string */ - unsigned int cat_id; /** Set if a category */ + size_t cat_id; /** Set if a category */ static inline bool matches(const char *name, const topmenu_object_t *topmenu) { @@ -106,7 +106,7 @@ struct topmenu_player_t IBaseMenu *root; /** root menu display */ topmenu_player_category_t *cats; /** category display */ unsigned int cat_count; /** number of categories */ - unsigned int last_category; /** last category they selected */ + size_t last_category; /** last category they selected */ unsigned int last_position; /** last position in that category */ unsigned int last_root_pos; /** last page in the root menu */ }; @@ -159,17 +159,17 @@ class TopMenu : SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value); SMCResult ReadSMC_LeavingSection(const SMCStates *states); public: - unsigned int CalcMemUsage(); + size_t CalcMemUsage(); void SetTitleCaching(bool cache_titles); bool DisplayMenuAtCategory(int client, unsigned int object_id); private: void SortCategoriesIfNeeded(); - void SortCategoryIfNeeded(unsigned int category); + void SortCategoryIfNeeded(size_t category); private: - bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position); + bool DisplayCategory(int client, size_t category, unsigned int hold_time, bool last_position); void CreatePlayers(int max_clients); void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL); - void UpdateClientCategory(int client, unsigned int category, bool bSkipRootCheck=false); + void UpdateClientCategory(int client, size_t category, bool bSkipRootCheck=false); void TearDownClient(topmenu_player_t *player); bool FindCategoryByObject(unsigned int obj_id, size_t *index); private: @@ -193,6 +193,6 @@ class TopMenu : bool m_bCacheTitles; /* True if the categorie titles should be cached */ }; -unsigned int strncopy(char *dest, const char *src, size_t count); +size_t strncopy(char *dest, const char *src, size_t count); #endif //_INCLUDE_SOURCEMOD_TOP_MENU_H_ diff --git a/extensions/topmenus/smn_topmenus.cpp b/extensions/topmenus/smn_topmenus.cpp index 3dc0e38034..a63340f571 100644 --- a/extensions/topmenus/smn_topmenus.cpp +++ b/extensions/topmenus/smn_topmenus.cpp @@ -38,14 +38,14 @@ HandleType_t hTopMenuType; class TopMenuHandle : public IHandleTypeDispatch { public: - void OnHandleDestroy(HandleType_t type, void *object) + void OnHandleDestroy(HandleType_t type, void *object) override { ITopMenu *pTopMenu = (ITopMenu *)object; g_TopMenus.DestroyTopMenu(pTopMenu); } - bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) override { - *pSize = ((TopMenu *)object)->CalcMemUsage(); + *pSize = (((TopMenu *)object)->CalcMemUsage()); return true; } } s_TopMenuHandle; @@ -108,7 +108,7 @@ class TopMenuCallbacks : public ITopMenuObjectCallbacks m_pFunction->PushCell(object_id); m_pFunction->PushCell(client); m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK); - m_pFunction->PushCell(maxlength); + m_pFunction->PushCell((cell_t)maxlength); m_pFunction->Execute(NULL); } @@ -123,7 +123,7 @@ class TopMenuCallbacks : public ITopMenuObjectCallbacks m_pFunction->PushCell(object_id); m_pFunction->PushCell(client); m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK); - m_pFunction->PushCell(maxlength); + m_pFunction->PushCell((cell_t)maxlength); m_pFunction->Execute(NULL); } @@ -373,7 +373,7 @@ static cell_t GetTopMenuInfoString(IPluginContext *pContext, const cell_t *param char *buffer; pContext->LocalToString(params[3], &buffer); - return strncopy(buffer, str, params[4]); + return (cell_t)strncopy(buffer, str, params[4]); } static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params) @@ -397,7 +397,7 @@ static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params) char *buffer; pContext->LocalToString(params[3], &buffer); - return strncopy(buffer, str, params[4]); + return (cell_t)strncopy(buffer, str, params[4]); } static cell_t SetTopMenuTitleCaching(IPluginContext *pContext, const cell_t *params) diff --git a/extensions/updater/Updater.cpp b/extensions/updater/Updater.cpp index ba18ff4e20..e46f12ef20 100644 --- a/extensions/updater/Updater.cpp +++ b/extensions/updater/Updater.cpp @@ -216,7 +216,7 @@ void UpdateReader::HandleFile() return; } - md5.update((unsigned char *)mdl.GetBuffer(), mdl.GetSize()); + md5.update((unsigned char *)mdl.GetBuffer(), (unsigned int)mdl.GetSize()); md5.finalize(); md5.hex_digest(real_checksum); diff --git a/extensions/updater/md5.cpp b/extensions/updater/md5.cpp index c891c5c535..c5d2bbfdd4 100644 --- a/extensions/updater/md5.cpp +++ b/extensions/updater/md5.cpp @@ -109,10 +109,10 @@ void MD5::update (uint1 *input, uint4 input_length) { void MD5::update(FILE *file){ unsigned char buffer[1024]; - int len; + size_t len; while ((len=fread(buffer, 1, 1024, file))) - update(buffer, len); + update(buffer, (unsigned int)len); fclose (file); diff --git a/hl2sdk-manifests b/hl2sdk-manifests index 22f699a941..64a49c0032 160000 --- a/hl2sdk-manifests +++ b/hl2sdk-manifests @@ -1 +1 @@ -Subproject commit 22f699a941093d9d68c1f647c7c545ec346d0ee3 +Subproject commit 64a49c00327e6cf03451ee20e51ddd4a4f58c2d2 diff --git a/public/CDetour/detours.cpp b/public/CDetour/detours.cpp index 822bba3c18..8dd2a940d8 100644 --- a/public/CDetour/detours.cpp +++ b/public/CDetour/detours.cpp @@ -203,7 +203,7 @@ bool CDetour::CreateDetour() } #if defined(_WIN64) || defined(__x86_64__) - int shortBytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE); + size_t shortBytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE); detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, X64_ABS_SIZE); #else detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE); @@ -211,7 +211,7 @@ bool CDetour::CreateDetour() JitWriter wr; JitWriter *jit = ≀ - jit_uint32_t CodeSize = 0; + size_t CodeSize = 0; wr.outbase = NULL; wr.outptr = NULL; diff --git a/public/IForwardSys.h b/public/IForwardSys.h index cbd59abb29..c1628db09e 100644 --- a/public/IForwardSys.h +++ b/public/IForwardSys.h @@ -50,7 +50,7 @@ using namespace SourcePawn; #define SMINTERFACE_FORWARDMANAGER_NAME "IForwardManager" -#define SMINTERFACE_FORWARDMANAGER_VERSION 4 +#define SMINTERFACE_FORWARDMANAGER_VERSION 5 /* * There is some very important documentation at the bottom of this file. @@ -107,7 +107,7 @@ namespace SourceMod struct ByrefInfo { - unsigned int cells; + size_t cells; cell_t *orig_addr; int flags; int sz_flags; @@ -156,7 +156,7 @@ namespace SourceMod * * @return Number of functions in forward. */ - virtual unsigned int GetFunctionCount() =0; + virtual size_t GetFunctionCount() =0; /** * @brief Returns the method of multi-calling this forward has. @@ -184,7 +184,7 @@ namespace SourceMod * @param flags Whether or not changes should be copied back to the input array. * @return Error code, if any. */ - virtual int PushArray(cell_t *inarray, unsigned int cells, int flags=0) =0; + virtual int PushArray(cell_t *inarray, size_t cells, int flags=0) =0; /** * @brief Pushes a string onto the current call. diff --git a/public/IGameHelpers.h b/public/IGameHelpers.h index b05c98d403..f019b87806 100644 --- a/public/IGameHelpers.h +++ b/public/IGameHelpers.h @@ -33,6 +33,7 @@ #define _INCLUDE_SOURCEMOD_GAMEHELPERS_H_ #include <IShareSys.h> +#include <limits> /** * @file IGameHelpers.h @@ -40,7 +41,7 @@ */ #define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers" -#define SMINTERFACE_GAMEHELPERS_VERSION 11 +#define SMINTERFACE_GAMEHELPERS_VERSION 13 class CBaseEntity; class CBaseHandle; @@ -56,21 +57,31 @@ struct typedescription_t; #define TEXTMSG_DEST_CHAT 3 #define TEXTMSG_DEST_CENTER 4 +// Macros can messup the call to std::numeric_limits<T>::max(); +#ifdef max +#undef max +#endif + namespace SourceMod { + /** + * @brief Constant to refer to an invalid offset, useful to default initiliase an offset variable. + */ + constexpr const size_t INVALID_OFFSET = std::numeric_limits<size_t>::max(); + /** * @brief Maps the heirarchy of a SendProp. */ struct sm_sendprop_info_t { - SendProp *prop; /**< Property instance. */ - unsigned int actual_offset; /**< Actual computed offset. */ + SendProp *prop; /**< Property instance. */ + size_t actual_offset; /**< Actual computed offset. */ }; struct sm_datatable_info_t { - typedescription_t *prop; /**< Property instance. */ - unsigned int actual_offset; /**< Actual computed offset. */ + typedescription_t *prop; /**< Property instance. */ + size_t actual_offset; /**< Actual computed offset. */ }; class IGameHelpers : public SMInterface @@ -354,4 +365,9 @@ namespace SourceMod }; } +#ifdef old_max +#define max old_max +#undef old_max +#endif + #endif //_INCLUDE_SOURCEMOD_GAMEHELPERS_H_ diff --git a/public/IHandleSys.h b/public/IHandleSys.h index e2387b5835..d2d4f28e1f 100644 --- a/public/IHandleSys.h +++ b/public/IHandleSys.h @@ -52,7 +52,7 @@ #include <sp_vm_types.h> #define SMINTERFACE_HANDLESYSTEM_NAME "IHandleSys" -#define SMINTERFACE_HANDLESYSTEM_VERSION 5 +#define SMINTERFACE_HANDLESYSTEM_VERSION 6 /** Specifies no Identity */ #define DEFAULT_IDENTITY NULL @@ -210,7 +210,7 @@ namespace SourceMod * @param pSize Pointer to store the approximate memory usage in bytes. * @return True on success, false if not implemented. */ - virtual bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) + virtual bool GetHandleApproxSize(HandleType_t type, void *object, size_t *pSize) { return false; } diff --git a/public/IMenuManager.h b/public/IMenuManager.h index 9b0978b6ef..13c83788c7 100644 --- a/public/IMenuManager.h +++ b/public/IMenuManager.h @@ -34,9 +34,15 @@ #include <IShareSys.h> #include <IHandleSys.h> +#include <limits> #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager" -#define SMINTERFACE_MENUMANAGER_VERSION 17 +#define SMINTERFACE_MENUMANAGER_VERSION 18 + +// Macros can messup the call to std::numeric_limits<T>::max(); +#ifdef max +#undef max +#endif /** * @file IMenuManager.h @@ -72,8 +78,8 @@ namespace SourceMod */ struct menu_slots_t { - ItemSelection type; /**< Item selection type */ - unsigned int item; /**< Item position, if applicable */ + ItemSelection type; /**< Item selection type */ + size_t item; /**< Item position, if applicable */ }; class IBaseMenu; @@ -88,9 +94,9 @@ namespace SourceMod unsigned int apiVers; /**< Must be filled with the API version */ IBaseMenu *menu; /**< Menu pointer, or NULL if there is only a display */ IMenuHandler *mh; /**< Menu callbacks handler */ - unsigned int firstItem; /**< MENU ONLY: First item displayed on the last page */ - unsigned int lastItem; /**< MENU ONLY: Last item displayed on the last page */ - unsigned int item_on_page; /**< MENU ONLY: First item on page */ + size_t firstItem; /**< MENU ONLY: First item displayed on the last page */ + size_t lastItem; /**< MENU ONLY: Last item displayed on the last page */ + size_t item_on_page; /**< MENU ONLY: First item on page */ menu_slots_t slots[11]; /**< MENU ONLY: Item selection table (first index is 1) */ }; @@ -116,6 +122,9 @@ namespace SourceMod unsigned int style; /**< ITEMDRAW style flags */ }; + constexpr const size_t VOTE_PENDING = std::numeric_limits<size_t>::max(); + constexpr const size_t VOTE_NOT_VOTING = std::numeric_limits<size_t>::max() - 1; + /** * @brief Contains information about a vote result. */ @@ -126,7 +135,7 @@ namespace SourceMod struct menu_client_vote_t { int client; /**< Client index */ - int item; /**< Item # (or -1 for none) */ + size_t item; /**< Item # (or VOTE_PENDING/VOTE_NOT_VOTING for none) */ } *client_list; /**< Array of size num_clients */ unsigned int num_items; /**< Number of items voted for */ struct menu_item_vote_t @@ -332,7 +341,7 @@ namespace SourceMod * * @return Approximate number of bytes being used. */ - virtual unsigned int GetApproxMemUsage() =0; + virtual size_t GetApproxMemUsage() =0; /** * @brief Sets panel content directly @@ -396,7 +405,7 @@ namespace SourceMod * * @return Number of items per page. */ - virtual unsigned int GetMaxPageItems() =0; + virtual size_t GetMaxPageItems() =0; /** * @brief Returns whether or not a client is viewing a menu. @@ -430,7 +439,7 @@ namespace SourceMod * * @return Approximate number of bytes being used. */ - virtual unsigned int GetApproxMemUsage() =0; + virtual size_t GetApproxMemUsage() =0; /** * @brief Returns whether or not this style is supported by the current game. @@ -465,7 +474,7 @@ namespace SourceMod * @param draw Default item draw info. * @return True on success, false on invalid menu position */ - virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw) =0; + virtual bool InsertItem(size_t position, const char *info, const ItemDrawInfo &draw) =0; /** * @brief Removes an item from the menu. @@ -473,7 +482,7 @@ namespace SourceMod * @param position Position, starting from 0. * @return True on success, false on invalid menu position. */ - virtual bool RemoveItem(unsigned int position) =0; + virtual bool RemoveItem(size_t position) =0; /** * @brief Removes all items from the menu. @@ -488,14 +497,14 @@ namespace SourceMod * @param client Client index. (Important for randomized menus.) * @return Info string pointer, or NULL if position was invalid. */ - virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw, int client=0) =0; + virtual const char *GetItemInfo(size_t position, ItemDrawInfo *draw, int client=0) =0; /** * @brief Returns the number of items. * * @return Number of items in the menu. */ - virtual unsigned int GetItemCount() =0; + virtual size_t GetItemCount() =0; /** * @brief Sets the menu's pagination,. @@ -628,7 +637,7 @@ namespace SourceMod */ virtual bool DisplayAtItem(int client, unsigned int time, - unsigned int start_item, + size_t start_item, IMenuHandler *alt_handler=NULL) =0; /** @@ -636,7 +645,7 @@ namespace SourceMod * * @return Approximate number of bytes being used. */ - virtual unsigned int GetApproxMemUsage() =0; + virtual size_t GetApproxMemUsage() =0; /** * @brief Generates a per-client random mapping for the current vote options. @@ -665,7 +674,7 @@ namespace SourceMod * @param position Position, starting from 0. * @return Actual item index in menu. */ - virtual unsigned int GetRealItemIndex(int client, unsigned int position) =0; + virtual size_t GetRealItemIndex(int client, size_t position) =0; }; /** @@ -712,7 +721,7 @@ namespace SourceMod * @param client Client that selected the item. * @param item Item number. */ - virtual void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item) + virtual void OnMenuSelect(IBaseMenu *menu, int client, size_t item) { } @@ -754,7 +763,7 @@ namespace SourceMod * @param item Item number in the menu. * @param style ITEMSTYLE flags, by reference for modification. */ - virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style) + virtual void OnMenuDrawItem(IBaseMenu *menu, int client, size_t item, unsigned int &style) { } @@ -772,7 +781,7 @@ namespace SourceMod virtual unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, - unsigned int item, + size_t item, const ItemDrawInfo &dr) { return 0; @@ -841,8 +850,8 @@ namespace SourceMod */ virtual void OnMenuSelect2(IBaseMenu *menu, int client, - unsigned int item, - unsigned int item_on_page) + size_t item, + size_t item_on_page) { } }; @@ -974,5 +983,4 @@ namespace SourceMod }; } -#endif //_INCLUDE_SOURCEMOD_MENU_SYSTEM_H_ - +#endif //_INCLUDE_SOURCEMOD_MENU_SYSTEM_H_ \ No newline at end of file diff --git a/public/IPluginSys.h b/public/IPluginSys.h index 03c48878fa..efe45f9b58 100644 --- a/public/IPluginSys.h +++ b/public/IPluginSys.h @@ -38,7 +38,7 @@ #include <sp_vm_api.h> #define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager" -#define SMINTERFACE_PLUGINSYSTEM_VERSION 8 +#define SMINTERFACE_PLUGINSYSTEM_VERSION 9 /** Context user slot 3 is used Core for holding an IPluginContext pointer. */ #define SM_CONTEXTVAR_USER 3 @@ -398,7 +398,7 @@ namespace SourceMod * * @return The number of internally cached plugins. */ - virtual unsigned int GetPluginCount() =0; + virtual size_t GetPluginCount() =0; /** * @brief Returns a pointer that can be used to iterate through plugins. diff --git a/public/ITextParsers.h b/public/ITextParsers.h index 7df0997b28..db0ac0b139 100644 --- a/public/ITextParsers.h +++ b/public/ITextParsers.h @@ -113,7 +113,7 @@ namespace SourceMod bool invalid_tokens, bool close_bracket, bool extra_tokens, - unsigned int *curtok) + size_t *curtok) { return true; } @@ -135,7 +135,7 @@ namespace SourceMod bool invalid_tokens, bool equal_token, bool quotes, - unsigned int *curtok) + size_t *curtok) { return true; } @@ -147,7 +147,7 @@ namespace SourceMod * @param curtok Pointer to optionally store failed position in string. * @return True to keep parsing, false otherwise. */ - virtual bool ReadINI_RawLine(const char *line, unsigned int *curtok) + virtual bool ReadINI_RawLine(const char *line, size_t *curtok) { return true; } @@ -346,8 +346,8 @@ namespace SourceMod */ virtual bool ParseFile_INI(const char *file, ITextListener_INI *ini_listener, - unsigned int *line, - unsigned int *col) =0; + size_t *line, + size_t *col) =0; /** * @brief Parses an SMC-format text file. diff --git a/public/amtl b/public/amtl index 285b4f853c..2e87aabd69 160000 --- a/public/amtl +++ b/public/amtl @@ -1 +1 @@ -Subproject commit 285b4f853c0003023838140113e3ec066bd800c6 +Subproject commit 2e87aabd69333ea836caaf2d728d7aa8776d152f diff --git a/public/asm/asm.c b/public/asm/asm.c index 44337f7e3a..972afb9691 100644 --- a/public/asm/asm.c +++ b/public/asm/asm.c @@ -89,7 +89,7 @@ void check_thunks(unsigned char *dest, unsigned char *pc) #endif } -int copy_bytes(unsigned char *func, unsigned char *dest, unsigned int required_len) +size_t copy_bytes(unsigned char *func, unsigned char *dest, size_t required_len) { ud_t ud_obj; ud_init(&ud_obj); @@ -101,11 +101,11 @@ int copy_bytes(unsigned char *func, unsigned char *dest, unsigned int required_l #endif ud_set_input_buffer(&ud_obj, func, 20); - unsigned int bytecount = 0; + size_t bytecount = 0; while (bytecount < required_len && ud_disassemble(&ud_obj)) { - unsigned int insn_len = ud_insn_len(&ud_obj); + size_t insn_len = ud_insn_len(&ud_obj); bytecount += insn_len; if (dest) @@ -117,13 +117,13 @@ int copy_bytes(unsigned char *func, unsigned char *dest, unsigned int required_l dest++; func++; if (ud_insn_opr(&ud_obj, 0)->size == 32) { - *(int32_t *)dest = func + *(int32_t *)func - dest; + *(int32_t *)dest = (int32_t)(func + *(int32_t *)func - dest); check_thunks(dest+4, func+4); dest += sizeof(int32_t); } else { - *(int16_t *)dest = func + *(int16_t *)func - dest; + *(int16_t *)dest = (int16_t)(func + *(int16_t *)func - dest); dest += sizeof(int16_t); } func--; diff --git a/public/asm/asm.h b/public/asm/asm.h index d61ff30f24..7f078349cf 100644 --- a/public/asm/asm.h +++ b/public/asm/asm.h @@ -1,5 +1,7 @@ #pragma once +#include <stddef.h> + #define OP_JMP 0xE9 #define OP_JMP_SIZE 5 #define X64_ABS_SIZE 14 @@ -22,7 +24,7 @@ void check_thunks(unsigned char *dest, unsigned char *pc); //if dest is NULL, returns minimum number of bytes needed to be copied //if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs //http://www.devmaster.net/forums/showthread.php?t=2311 -int copy_bytes(unsigned char *func, unsigned char* dest, unsigned int required_len); +size_t copy_bytes(unsigned char *func, unsigned char* dest, size_t required_len); //insert a specific JMP instruction at the given location void inject_jmp(void* src, void* dest); diff --git a/public/jit/jit_helpers.h b/public/jit/jit_helpers.h index 61ee263227..5f2f8acb86 100644 --- a/public/jit/jit_helpers.h +++ b/public/jit/jit_helpers.h @@ -53,7 +53,7 @@ typedef unsigned __int64 jit_uint64_t; #endif typedef char * jitcode_t; -typedef unsigned int jitoffs_t; +typedef size_t jitoffs_t; typedef signed int jitrel_t; class JitWriter diff --git a/public/jit/x86/x86_macros.h b/public/jit/x86/x86_macros.h index 01561d6033..1e3ae09fdd 100644 --- a/public/jit/x86/x86_macros.h +++ b/public/jit/x86/x86_macros.h @@ -302,10 +302,10 @@ inline void IA32_Write_Jump32_Abs(JitWriter *jit, jitoffs_t jmp, void *target) //save old ptr jitcode_t oldptr = jit->outptr; //get relative difference - long diff = ((long)target - ((long)jit->outbase + jmp + 4)); + intptr_t diff = ((intptr_t)target - ((intptr_t)jit->outbase + jmp + 4)); //overwrite old value jit->outptr = jit->outbase + jmp; - jit->write_int32(diff); + jit->write_int32((int)diff); //restore old ptr jit->outptr = oldptr; } diff --git a/public/libudis86/decode.c b/public/libudis86/decode.c index afe044a694..fc8325d637 100644 --- a/public/libudis86/decode.c +++ b/public/libudis86/decode.c @@ -440,7 +440,7 @@ decode_imm(struct ud* u, unsigned int size, struct ud_operand *op) * Decode mem address displacement. */ static void -decode_mem_disp(struct ud* u, unsigned int size, struct ud_operand *op) +decode_mem_disp(struct ud* u, size_t size, struct ud_operand *op) { switch (size) { case 8: @@ -1073,7 +1073,7 @@ decode_opcode(struct ud *u) * ud_decode() - Instruction decoder. Returns the number of bytes decoded. * ============================================================================= */ -unsigned int +size_t ud_decode(struct ud *u) { inp_start(u); diff --git a/public/libudis86/extern.h b/public/libudis86/extern.h index ae9f82f225..5afd1d5c99 100644 --- a/public/libudis86/extern.h +++ b/public/libudis86/extern.h @@ -72,7 +72,7 @@ extern uint64_t ud_insn_off(const struct ud*); extern const char* ud_insn_hex(struct ud*); -extern unsigned int ud_insn_len(const struct ud* u); +extern size_t ud_insn_len(const struct ud* u); extern const struct ud_operand* ud_insn_opr(const struct ud *u, unsigned int n); diff --git a/public/libudis86/syn.c b/public/libudis86/syn.c index 5c54cfbeb1..a3605448fd 100644 --- a/public/libudis86/syn.c +++ b/public/libudis86/syn.c @@ -108,7 +108,7 @@ int ud_asmprintf(struct ud *u, const char *fmt, ...) { int ret; - int avail; + size_t avail; va_list ap; va_start(ap, fmt); avail = u->asm_buf_size - u->asm_buf_fill - 1 /* nullchar */; diff --git a/public/libudis86/udis86.c b/public/libudis86/udis86.c index d62af1f3df..38969dc785 100644 --- a/public/libudis86/udis86.c +++ b/public/libudis86/udis86.c @@ -197,7 +197,7 @@ ud_insn_ptr(const struct ud* u) * Returns the count of bytes disassembled. * ============================================================================= */ -extern unsigned int +extern size_t ud_insn_len(const struct ud* u) { return u->inp_ctr; diff --git a/public/sm_memtable.h b/public/sm_memtable.h index 3926b2bc8c..edc9ccce22 100644 --- a/public/sm_memtable.h +++ b/public/sm_memtable.h @@ -38,7 +38,7 @@ class BaseMemTable { public: - BaseMemTable(unsigned int init_size) + BaseMemTable(size_t init_size) { membase = (unsigned char *)malloc(init_size); size = init_size; @@ -55,7 +55,7 @@ class BaseMemTable * Optionally outputs the address through 'addr'. * Returns an index >= 0 on success, < 0 on failure. */ - int CreateMem(unsigned int addsize, void **addr) + int CreateMem(size_t addsize, void **addr) { int idx = (int)tail; @@ -92,20 +92,20 @@ class BaseMemTable tail = 0; } - inline unsigned int GetMemUsage() + inline size_t GetMemUsage() { return size; } - inline unsigned int GetActualMemUsed() + inline size_t GetActualMemUsed() { return tail; } private: unsigned char *membase; - unsigned int size; - unsigned int tail; + size_t size; + size_t tail; }; class BaseStringTable diff --git a/public/sm_trie_tpl.h b/public/sm_trie_tpl.h index 79098e9c1d..2a3ce86780 100644 --- a/public/sm_trie_tpl.h +++ b/public/sm_trie_tpl.h @@ -159,13 +159,13 @@ class KTrie */ bool insert(const char *key, const K & obj) { - unsigned int lastidx = 1; /* the last node index */ - unsigned int curidx; /* current node index */ + size_t lastidx = 1; /* the last node index */ + size_t curidx; /* current node index */ const char *keyptr = key; /* input stream at current token */ KTrieNode *node = NULL; /* current node being processed */ KTrieNode *basenode = NULL; /* current base node being processed */ - unsigned int q; /* temporary var for x_check results */ - unsigned int curoffs; /* current offset */ + size_t q; /* temporary var for x_check results */ + size_t curoffs; /* current offset */ /** * Empty strings are a special case, since there are no productions. We could @@ -253,18 +253,18 @@ class KTrie * The arcs leaving A will be C and D, but our current node is B -> *. * Thus, we use the last index (A) to find the base for arcs leaving A. */ - unsigned int outgoing_base = m_base[lastidx].idx; - unsigned int outgoing_list[256]; - unsigned int outgoing_count = 0; /* count the current index here */ + size_t outgoing_base = m_base[lastidx].idx; + size_t outgoing_list[256]; + size_t outgoing_count = 0; /* count the current index here */ cur = &m_base[outgoing_base] + 1; - unsigned int outgoing_limit = 255; + size_t outgoing_limit = 255; if (outgoing_base + outgoing_limit > m_baseSize) { outgoing_limit = m_baseSize - outgoing_base; } - for (unsigned int i=1; i<=outgoing_limit; i++,cur++) + for (size_t i=1; i<=outgoing_limit; i++,cur++) { if (cur->mode == Node_Unused || cur->parent != lastidx) { @@ -278,10 +278,10 @@ class KTrie * Note: the inconsistency is the base of our parent. */ assert(m_base[node->parent].mode == Node_Arc); - unsigned int incoming_list[256]; - unsigned int incoming_base = m_base[node->parent].idx; - unsigned int incoming_count = 0; - unsigned int incoming_limit = 255; + size_t incoming_list[256]; + size_t incoming_base = m_base[node->parent].idx; + size_t incoming_count = 0; + size_t incoming_limit = 255; cur = &m_base[incoming_base] + 1; if (incoming_base + incoming_limit > m_baseSize) @@ -291,7 +291,7 @@ class KTrie assert(incoming_limit > 0 && incoming_limit <= 255); - for (unsigned int i=1; i<=incoming_limit; i++,cur++) + for (size_t i=1; i<=incoming_limit; i++,cur++) { if (cur->mode == Node_Arc || cur->mode == Node_Term) { @@ -304,7 +304,7 @@ class KTrie if (incoming_count < outgoing_count + 1) { - unsigned int q = x_check_multi(incoming_list, incoming_count); + size_t q = x_check_multi(incoming_list, incoming_count); node = &m_base[curidx]; @@ -314,8 +314,8 @@ class KTrie /* For each node in the "to move" list, * Relocate the node's info to the new position. */ - unsigned int idx, newidx, oldidx; - for (unsigned int i=0; i<incoming_count; i++) + size_t idx, newidx, oldidx; + for (size_t i=0; i<incoming_count; i++) { idx = incoming_list[i]; newidx = q + idx; @@ -356,7 +356,7 @@ class KTrie } else { - unsigned int q = x_check_multi(outgoing_list, outgoing_count); + size_t q = x_check_multi(outgoing_list, outgoing_count); node = &m_base[curidx]; @@ -371,8 +371,8 @@ class KTrie /* For each node in the "to move" list, * Relocate the node's info to the new position. */ - unsigned int idx, newidx, oldidx; - for (unsigned int i=0; i<outgoing_count; i++) + size_t idx, newidx, oldidx; + for (size_t i=0; i<outgoing_count; i++) { idx = outgoing_list[i]; newidx = q + idx; @@ -401,7 +401,7 @@ class KTrie { outgoing_limit = 255; } - for (unsigned int j=1; j<=outgoing_limit; j++, check_base++) + for (size_t j=1; j<=outgoing_limit; j++, check_base++) { if (check_base->parent == oldidx) { @@ -701,10 +701,10 @@ class KTrie size_t buf_pos, void *data, void (*func)(KTrie *, const char *, K & obj, void *data), - unsigned int root) + size_t root) { char *term; - unsigned int idx, limit, start; + size_t idx, limit, start; limit = 255; start = m_base[root].idx; @@ -824,14 +824,14 @@ class KTrie * I.e. to jump from this arc to character C, it will be at base[idx+C]. * For Node_Term, this is an index into the string table. */ - unsigned int idx; + size_t idx; /** * This contains the prior arc that we must have come from. * For example, if arc 63 has a base jump of index 12, and we want to see if * there is a valid character C, the parent of 12+C must be 63. */ - unsigned int parent; + size_t parent; K value; /* Value associated with this node */ NodeType mode; /* Current usage type of the node */ bool valset; /* Whether or not a value is set */ @@ -839,8 +839,8 @@ class KTrie private: KTrieNode *internal_retrieve(const char *key) { - unsigned int lastidx = 1; /* the last node index */ - unsigned int curidx; /* current node index */ + size_t lastidx = 1; /* the last node index */ + size_t curidx; /* current node index */ const char *keyptr = key; /* input stream at current token */ KTrieNode *node = NULL; /* current node being processed */ @@ -884,8 +884,8 @@ class KTrie bool grow() { /* The current # of nodes in the tree is trie->baseSize + 1 */ - unsigned int cur_size = m_baseSize; - unsigned int new_size = cur_size * 2; + size_t cur_size = m_baseSize; + size_t new_size = cur_size * 2; KTrieNode *new_base = (KTrieNode *)malloc((new_size + 1) * sizeof(KTrieNode)); if (!new_base) @@ -939,7 +939,7 @@ class KTrie } } } - unsigned int x_addstring(const char *ptr) + size_t x_addstring(const char *ptr) { size_t len = strlen(ptr) + 1; @@ -952,17 +952,17 @@ class KTrie m_stringtab = (char *)realloc(m_stringtab,m_stSize); } - unsigned int tail = m_tail; + size_t tail = m_tail; strcpy(&m_stringtab[tail], ptr); m_tail += len; return tail; } - unsigned int x_check(char c, unsigned int start=1) + size_t x_check(char c, size_t start=1) { unsigned char _c = charval(c); - unsigned int to_check = m_baseSize - _c; - for (unsigned int i=start; i<=to_check; i++) + size_t to_check = m_baseSize - _c; + for (size_t i=start; i<=to_check; i++) { if (m_base[i+_c].mode == Node_Unused) { @@ -974,12 +974,12 @@ class KTrie return x_check(c, to_check+1); } - unsigned int x_check2(char c1, char c2, unsigned int start=1) + size_t x_check2(char c1, char c2, size_t start=1) { unsigned char _c1 = charval(c1); unsigned char _c2 = charval(c2); - unsigned int to_check = m_baseSize - (_c1 > _c2 ? _c1 : _c2); - for (unsigned int i=start; i<=to_check; i++) + size_t to_check = m_baseSize - (_c1 > _c2 ? _c1 : _c2); + for (size_t i=start; i<=to_check; i++) { if (m_base[i+_c1].mode == Node_Unused && m_base[i+_c2].mode == Node_Unused) @@ -992,16 +992,16 @@ class KTrie return x_check2(c1, c2, to_check+1); } - unsigned int x_check_multi( - unsigned int offsets[], - unsigned int count, - unsigned int start=1) + size_t x_check_multi( + size_t offsets[], + size_t count, + size_t start=1) { KTrieNode *cur; - unsigned int to_check = m_baseSize; - unsigned int highest = 0; + size_t to_check = m_baseSize; + size_t highest = 0; - for (unsigned int i=0; i<count; i++) + for (size_t i=0; i<count; i++) { if (offsets[i] > highest) { @@ -1011,10 +1011,10 @@ class KTrie to_check -= highest; - for (unsigned int i=start; i<=to_check; i++) + for (size_t i=start; i<=to_check; i++) { bool okay = true; - for (unsigned int j=0; j<count; j++) + for (size_t j=0; j<count; j++) { cur = &m_base[i+offsets[j]]; if (cur->mode != Node_Unused) @@ -1048,9 +1048,9 @@ class KTrie KTrieNode *m_base; /* Base array for the sparse tables */ KTrieNode *m_empty; /* Special case for empty strings */ char *m_stringtab; /* String table pointer */ - unsigned int m_baseSize; /* Size of the base array, in members */ - unsigned int m_stSize; /* Size of the string table, in bytes */ - unsigned int m_tail; /* Current unused offset into the string table */ + size_t m_baseSize; /* Size of the base array, in members */ + size_t m_stSize; /* Size of the string table, in bytes */ + size_t m_tail; /* Current unused offset into the string table */ size_t m_numElements; /* Number of elements in use */ }; diff --git a/sourcepawn b/sourcepawn index d59a51b574..ac4be0d3dd 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit d59a51b5741823903ecbe8c014632ee1f8aad65d +Subproject commit ac4be0d3dd195bc80a6514e5fa1fda12e91138fd