Skip to content

Enable /WX for msvc + Fix the various new warnings that appear for x64 compilation #2118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -325,6 +323,7 @@ class SMConfig(object):
]
cxx.cflags += [
'/W3',
'/WX'
]
cxx.cxxflags += [
'/EHsc',
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions bridge/include/IFileSystemBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion bridge/include/LogicProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
Expand Down
2 changes: 1 addition & 1 deletion core/CellRecipientFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/ConVarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions core/ConVarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions core/CoreConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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++)
{
Expand Down
8 changes: 4 additions & 4 deletions core/HalfLife2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 13 additions & 13 deletions core/MenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/MenuManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 16 additions & 11 deletions core/MenuStyle_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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())
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 ...
Expand All @@ -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];
Expand Down Expand Up @@ -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())
{
Expand All @@ -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();
}
Expand Down Expand Up @@ -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));
}
Loading