diff --git a/primedev/Launcher.cmake b/primedev/Launcher.cmake index c04fc70b1..f6408a0de 100644 --- a/primedev/Launcher.cmake +++ b/primedev/Launcher.cmake @@ -26,3 +26,15 @@ set_target_properties( NorthstarLauncher PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${NS_BINARY_DIR} LINK_FLAGS "/MANIFEST:NO /DEBUG /STACK:8000000" ) + +if(MSVC) + target_compile_options(NorthstarLauncher PRIVATE /W4 /WX) +else() + target_compile_options( + NorthstarLauncher + PRIVATE -Wall + -Wextra + -Wpedantic + -Werror + ) +endif() diff --git a/primedev/Northstar.cmake b/primedev/Northstar.cmake index 6b9c2380e..7d4268558 100644 --- a/primedev/Northstar.cmake +++ b/primedev/Northstar.cmake @@ -201,3 +201,15 @@ set_target_properties( OUTPUT_NAME Northstar LINK_FLAGS "/MANIFEST:NO /DEBUG" ) + +if(MSVC) + target_compile_options(NorthstarDLL PRIVATE /W4 /WX) +else() + target_compile_options( + NorthstarDLL + PRIVATE -Wall + -Wextra + -Wpedantic + -Werror + ) +endif() diff --git a/primedev/WSockProxy.cmake b/primedev/WSockProxy.cmake index 017e358a1..2a4db6a05 100644 --- a/primedev/WSockProxy.cmake +++ b/primedev/WSockProxy.cmake @@ -47,3 +47,16 @@ set_target_properties( OUTPUT_NAME wsock32 LINK_FLAGS "/MANIFEST:NO /DEBUG" ) + +# COMPILE_LANGUAGE is used here because of the ASM file +if(MSVC) + target_compile_options(loader_wsock32_proxy PRIVATE $<$:/W4 /WX>) +else() + target_compile_options( + loader_wsock32_proxy + PRIVATE $<$:-Wall + -Wextra + -Wpedantic + -Werror> + ) +endif() diff --git a/primedev/client/audio.cpp b/primedev/client/audio.cpp index 099fdcee5..52b2715ac 100644 --- a/primedev/client/audio.cpp +++ b/primedev/client/audio.cpp @@ -207,14 +207,14 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa // Allocate enough memory for the file. // blank out the memory for now, then read it later - uint8_t* data = new uint8_t[fileSize]; - memcpy(data, EMPTY_WAVE, sizeof(EMPTY_WAVE)); - Samples.push_back({fileSize, std::unique_ptr(data)}); + uint8_t* fileData = new uint8_t[fileSize]; + memcpy(fileData, EMPTY_WAVE, sizeof(EMPTY_WAVE)); + Samples.push_back({fileSize, std::unique_ptr(fileData)}); // thread off the file read // should we spawn one thread per read? or should there be a cap to the number of reads at once? std::thread readThread( - [pathString, fileSize, data] + [pathString, fileSize, fileData] { std::shared_lock lock(g_CustomAudioManager.m_loadingMutex); std::ifstream wavStream(pathString, std::ios::binary); @@ -228,7 +228,7 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa // read from after the header first to preserve the empty header, then read the header last wavStream.seekg(0, std::ios::beg); - wavStream.read(reinterpret_cast(data), fileSize); + wavStream.read(reinterpret_cast(fileData), fileSize); wavStream.close(); spdlog::info("Finished async read of audio sample {}", pathString); @@ -328,7 +328,7 @@ void CustomAudioManager::ClearAudioOverrides() template Iter select_randomly(Iter start, Iter end, RandomGenerator& g) { - std::uniform_int_distribution<> dis(0, std::distance(start, end) - 1); + std::uniform_int_distribution<__int64> dis(0, std::distance(start, end) - 1); std::advance(start, dis(g)); return start; } diff --git a/primedev/client/debugoverlay.cpp b/primedev/client/debugoverlay.cpp index a67b8355c..05c08b499 100644 --- a/primedev/client/debugoverlay.cpp +++ b/primedev/client/debugoverlay.cpp @@ -231,7 +231,7 @@ void, __fastcall, (bool bRender)) OverlayBase_t* pPrevOverlay = nullptr; // rsi OverlayBase_t* pNextOverlay = nullptr; // rdi - int m_nCreationTick; // eax + // int m_nCreationTick; // eax bool bShouldDraw; // zf int m_pUnk; // eax @@ -256,7 +256,7 @@ void, __fastcall, (bool bRender)) { if (pCurrOverlay->m_nCreationTick == -1) { - m_pUnk = pCurrOverlay->m_pUnk; + m_pUnk = (int)pCurrOverlay->m_pUnk; if (m_pUnk == -1) { diff --git a/primedev/client/languagehooks.cpp b/primedev/client/languagehooks.cpp index 35ca5659f..9ce4e1df4 100644 --- a/primedev/client/languagehooks.cpp +++ b/primedev/client/languagehooks.cpp @@ -100,9 +100,9 @@ char*, __fastcall, ()) { spdlog::warn("Caution, audio for this language does NOT exist. You might want to override your game language with -language " "command line option."); - auto lang = GetAnyInstalledAudioLanguage(); - spdlog::warn("Falling back to the first installed audio language: {}", lang.c_str()); - strncpy(ingameLang1, lang.c_str(), 256); + auto installedLang = GetAnyInstalledAudioLanguage(); + spdlog::warn("Falling back to the first installed audio language: {}", installedLang.c_str()); + strncpy(ingameLang1, installedLang.c_str(), 256); return ingameLang1; } diff --git a/primedev/client/latencyflex.cpp b/primedev/client/latencyflex.cpp index 25e38c7a4..e4f952138 100644 --- a/primedev/client/latencyflex.cpp +++ b/primedev/client/latencyflex.cpp @@ -24,10 +24,10 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module)) // https://ishitatsuyuki.github.io/post/latencyflex/ HMODULE pLfxModule; - if (pLfxModule = LoadLibraryA("latencyflex_layer.dll")) + if ((pLfxModule = LoadLibraryA("latencyflex_layer.dll")) != NULL) m_winelfx_WaitAndBeginFrame = reinterpret_cast(reinterpret_cast(GetProcAddress(pLfxModule, "lfx_WaitAndBeginFrame"))); - else if (pLfxModule = LoadLibraryA("latencyflex_wine.dll")) + else if ((pLfxModule = LoadLibraryA("latencyflex_wine.dll")) != NULL) m_winelfx_WaitAndBeginFrame = reinterpret_cast(reinterpret_cast(GetProcAddress(pLfxModule, "winelfx_WaitAndBeginFrame"))); else diff --git a/primedev/client/localchatwriter.cpp b/primedev/client/localchatwriter.cpp index 35cc065f4..e8ea1e060 100644 --- a/primedev/client/localchatwriter.cpp +++ b/primedev/client/localchatwriter.cpp @@ -213,7 +213,7 @@ class AnsiEscapeParser } else if (val < 232) { - unsigned char code = val - 16; + unsigned char code = (unsigned char)(val - 16); unsigned char blue = code % 6; unsigned char green = ((code - blue) / 6) % 6; unsigned char red = (code - blue - (green * 6)) / 36; @@ -221,7 +221,7 @@ class AnsiEscapeParser } else if (val < UCHAR_MAX) { - unsigned char brightness = (val - 232) * 10 + 8; + unsigned char brightness = (unsigned char)(val - 232) * 10 + 8; m_writer->InsertColorChange(Color {brightness, brightness, brightness, 255}); } diff --git a/primedev/core/convar/convar.cpp b/primedev/core/convar/convar.cpp index 767961edc..985558c89 100644 --- a/primedev/core/convar/convar.cpp +++ b/primedev/core/convar/convar.cpp @@ -361,7 +361,7 @@ void ConVar::SetValue(Color clValue) // Purpose: changes the ConVar string value. // Input : *pszTempVal - flOldValue //----------------------------------------------------------------------------- -void ConVar::ChangeStringValue(const char* pszTempVal, float flOldValue) +void ConVar::ChangeStringValue(const char* pszTempVal, float /*flOldValue*/) { assert(!(m_ConCommandBase.m_nFlags & FCVAR_NEVER_AS_STRING)); @@ -403,8 +403,8 @@ bool ConVar::SetColorFromString(const char* pszValue) bool bColor = false; // Try pulling RGBA color values out of the string. - int nRGBA[4] {}; - int nParamsRead = sscanf_s(pszValue, "%i %i %i %i", &(nRGBA[0]), &(nRGBA[1]), &(nRGBA[2]), &(nRGBA[3])); + unsigned char nRGBA[4] {}; + int nParamsRead = sscanf_s(pszValue, "%hhu %hhu %hhu %hhu", &(nRGBA[0]), &(nRGBA[1]), &(nRGBA[2]), &(nRGBA[3])); if (nParamsRead >= 3) { diff --git a/primedev/core/convar/convar.h b/primedev/core/convar/convar.h index f0366b466..aa0c9b4f3 100644 --- a/primedev/core/convar/convar.h +++ b/primedev/core/convar/convar.h @@ -175,7 +175,7 @@ class ConVar struct CVValue_t { const char* m_pszString; - int64_t m_iStringLength; + uint64_t m_iStringLength; float m_fValue; int m_nValue; }; diff --git a/primedev/core/convar/cvar.h b/primedev/core/convar/cvar.h index beaa84f47..a0a60a800 100644 --- a/primedev/core/convar/cvar.h +++ b/primedev/core/convar/cvar.h @@ -18,6 +18,8 @@ class CCVarIteratorInternal // Fully reversed table, just look at the virtual fu virtual void Next(void) = 0; // 1 virtual bool IsValid(void) = 0; // 2 virtual ConCommandBase* Get(void) = 0; // 3 + + virtual ~CCVarIteratorInternal() {} }; //----------------------------------------------------------------------------- diff --git a/primedev/core/filesystem/filesystem.cpp b/primedev/core/filesystem/filesystem.cpp index b39939e45..acbac905b 100644 --- a/primedev/core/filesystem/filesystem.cpp +++ b/primedev/core/filesystem/filesystem.cpp @@ -117,7 +117,7 @@ FileHandle_t, __fastcall, (VPKData* vpkInfo, uint64_t* b, char* filename)) // don't compile here because this is only ever called from OpenEx, which already compiles if (TryReplaceFile(filename, false)) { - *b = -1; + *b = (uint64_t)-1; return b; } diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp index 20f0cbef1..a58b6aed0 100644 --- a/primedev/core/hooks.cpp +++ b/primedev/core/hooks.cpp @@ -141,7 +141,6 @@ uintptr_t ParseDLLOffsetString(const char* pAddrString) uintptr_t iOffset = 0; int iOffsetBegin = iDllNameEnd; - size_t iOffsetEnd = strlen(pAddrString); // seek until we hit the start of the number offset for (; !(pAddrString[iOffsetBegin] >= '0' && pAddrString[iOffsetBegin] <= '9') && pAddrString[iOffsetBegin]; iOffsetBegin++) @@ -407,8 +406,6 @@ HMODULE, WINAPI, (LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)) { MessageBoxA(0, "Could not find XInput9_1_0.dll", "Northstar", MB_ICONERROR); exit(EXIT_FAILURE); - - return nullptr; } } else diff --git a/primedev/core/math/bitbuf.h b/primedev/core/math/bitbuf.h index a06dab17f..6992362b8 100644 --- a/primedev/core/math/bitbuf.h +++ b/primedev/core/math/bitbuf.h @@ -188,7 +188,7 @@ class BFRead : public BitBufferBase return ret; } - INLINE u32 ReadUBitLong(i32 numBits) + INLINE u32 ReadUBitLong(u32 numBits) { if (m_CachedBitsLeft >= numBits) { @@ -432,7 +432,7 @@ class BFRead : public BitBufferBase float shift = (float)(GetBitForBitnum(numBits)); i32 i = ReadUBitLong(numBits); - float fReturn = (float)i * (360.0 / shift); + float fReturn = (float)i * (360.0f / shift); return fReturn; } @@ -531,14 +531,14 @@ class BFRead : public BitBufferBase // read remaining bytes while (bitsLeft >= 8) { - *out = ReadUBitLong(8); + *out = (u8)ReadUBitLong(8); ++out; bitsLeft -= 8; } // read remaining bits if (bitsLeft) - *out = ReadUBitLong(bitsLeft); + *out = (u8)ReadUBitLong(bitsLeft); } INLINE bool ReadBytes(uptr outData, u32 byteLength) @@ -554,7 +554,7 @@ class BFRead : public BitBufferBase while (1) { - char val = ReadChar(); + char val = (char)ReadChar(); if (val == 0) break; @@ -594,7 +594,7 @@ class BFRead : public BitBufferBase // Now copy into the output and return it; char* ret = new char[chars + 1]; - for (u32 i = 0; i <= chars; i++) + for (int i = 0; i <= chars; i++) ret[i] = str[i]; return ret; @@ -745,7 +745,7 @@ class BFWrite : public BitBufferBase INLINE int GetNumBitsLeft() { - return m_OutBitsLeft + (32 * (m_DataEnd - m_DataOut - 1)); + return (int)(m_OutBitsLeft + (32 * (m_DataEnd - m_DataOut - 1))); } INLINE void Reset() @@ -826,7 +826,7 @@ class BFWrite : public BitBufferBase Flush(); } - INLINE void WriteUBitLong(u32 data, i32 numBits, bool checkRange = true) + INLINE void WriteUBitLong(u32 data, u32 numBits, bool checkRange = true) { if (numBits <= m_OutBitsLeft) { @@ -918,7 +918,7 @@ class BFWrite : public BitBufferBase INLINE i32 GetNumBitsWritten() { - return (32 - m_OutBitsLeft) + (32 * (m_DataOut - m_Data)); + return (i32)((32 - m_OutBitsLeft) + (32 * (m_DataOut - m_Data))); } INLINE i32 GetNumBytesWritten() diff --git a/primedev/core/memalloc.cpp b/primedev/core/memalloc.cpp index 0a75bc2bd..984b46c6c 100644 --- a/primedev/core/memalloc.cpp +++ b/primedev/core/memalloc.cpp @@ -1,6 +1,9 @@ #include "core/memalloc.h" #include "core/tier0.h" +// TODO: refactor this entire thing to not cause the suppressed warnings +#pragma warning(push) +#pragma warning(disable : 4273 4565) // TODO: rename to malloc and free after removing statically compiled .libs extern "C" void* _malloc_base(size_t n) @@ -69,3 +72,5 @@ void operator delete(void* p) noexcept { _free_base(p); } // /FORCE:MULTIPLE + +#pragma warning(pop) diff --git a/primedev/core/memalloc.h b/primedev/core/memalloc.h index 2f3833350..e054257f4 100644 --- a/primedev/core/memalloc.h +++ b/primedev/core/memalloc.h @@ -3,12 +3,14 @@ #include "rapidjson/document.h" // #include "include/rapidjson/allocators.h" +#pragma warning(push) +#pragma warning(disable : 4273 4565) extern "C" void* _malloc_base(size_t size); extern "C" void* _calloc_base(size_t const count, size_t const size); extern "C" void* _realloc_base(void* block, size_t size); -extern "C" void* _recalloc_base(void* const block, size_t const count, size_t const size); extern "C" void _free_base(void* const block); extern "C" char* _strdup_base(const char* src); +#pragma warning(pop) void* operator new(size_t n); void operator delete(void* p) noexcept; diff --git a/primedev/core/memory.cpp b/primedev/core/memory.cpp index 41110aee3..29614df5e 100644 --- a/primedev/core/memory.cpp +++ b/primedev/core/memory.cpp @@ -104,7 +104,7 @@ inline std::vector HexBytesToString(const char* pHexString) std::vector ret; size_t size = strlen(pHexString); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { // If this is a space character, ignore it if (isspace(pHexString[i])) @@ -115,7 +115,7 @@ inline std::vector HexBytesToString(const char* pHexString) BYTE result = 0; for (int j = 0; j < 2; j++) { - int val = 0; + BYTE val = 0; char c = *(pHexString + i + j); if (c >= 'a') { @@ -132,7 +132,7 @@ inline std::vector HexBytesToString(const char* pHexString) else { assert_msg(false, "Failed to parse invalid hex string."); - val = -1; + val = 0xFF; // -1 } result += (j == 0) ? val * 16 : val; @@ -244,7 +244,7 @@ CMemoryAddress CModule::FindPattern(const uint8_t* pPattern, const char* pMask) { if (pMask[i * 16 + j] == 'x') { - _bittestandset(reinterpret_cast(&nMasks[i]), j); + _bittestandset(reinterpret_cast(&nMasks[i]), (long)j); } } } @@ -290,7 +290,7 @@ inline std::pair, std::string> MaskedBytesFromPattern(const std::string sMask; size_t size = strlen(pPatternString); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { // If this is a space character, ignore it if (isspace(pPatternString[i])) @@ -307,7 +307,7 @@ inline std::pair, std::string> MaskedBytesFromPattern(const BYTE result = 0; for (int j = 0; j < 2; j++) { - int val = 0; + BYTE val = 0; char c = *(pPatternString + i + j); if (c >= 'a') { @@ -324,7 +324,7 @@ inline std::pair, std::string> MaskedBytesFromPattern(const else { assert_msg(false, "Failed to parse invalid pattern string."); - val = -1; + val = 0xFF; // -1 } result += (j == 0) ? val * 16 : val; diff --git a/primedev/dedicated/dedicated.cpp b/primedev/dedicated/dedicated.cpp index df6e5787e..857fecd38 100644 --- a/primedev/dedicated/dedicated.cpp +++ b/primedev/dedicated/dedicated.cpp @@ -33,12 +33,12 @@ struct CDedicatedExports DedicatedRunServerType RunServer; }; -void Sys_Printf(CDedicatedExports* dedicated, const char* msg) +void Sys_Printf(CDedicatedExports* /*dedicated*/, const char* msg) { spdlog::info("[DEDICATED SERVER] {}", msg); } -void RunServer(CDedicatedExports* dedicated) +void RunServer(CDedicatedExports* /*dedicated*/) { spdlog::info("CDedicatedExports::RunServer(): starting"); spdlog::info(CommandLine()->GetCmdLine()); @@ -56,7 +56,6 @@ void RunServer(CDedicatedExports* dedicated) Cbuf_Execute(); // main loop - double frameTitle = 0; while (g_pEngine->m_nQuitting == EngineQuitState::QUIT_NOTQUITTING) { double frameStart = Plat_FloatTime(); @@ -84,7 +83,7 @@ class DedicatedConsoleServerPresence : public ServerPresenceReporter }; HANDLE consoleInputThreadHandle = NULL; -DWORD WINAPI ConsoleInputThread(PVOID pThreadParameter) +DWORD WINAPI ConsoleInputThread(PVOID /*pThreadParameter*/) { while (!g_pEngine || !g_pHostState || g_pHostState->m_iCurrentState != HostState_t::HS_RUN) Sleep(1000); diff --git a/primedev/dedicated/dedicatedlogtoclient.cpp b/primedev/dedicated/dedicatedlogtoclient.cpp index bf2cf77a0..3188f42cd 100644 --- a/primedev/dedicated/dedicatedlogtoclient.cpp +++ b/primedev/dedicated/dedicatedlogtoclient.cpp @@ -35,7 +35,7 @@ void DedicatedServerLogToClientSink::custom_sink_it_(const custom_log_msg& msg) } } -void DedicatedServerLogToClientSink::sink_it_(const spdlog::details::log_msg& msg) +void DedicatedServerLogToClientSink::sink_it_(const spdlog::details::log_msg& /*msg*/) { throw std::runtime_error("sink_it_ called on DedicatedServerLogToClientSink with pure log_msg. This is an error!"); } diff --git a/primedev/dllmain.cpp b/primedev/dllmain.cpp index c87c8baec..797d7c602 100644 --- a/primedev/dllmain.cpp +++ b/primedev/dllmain.cpp @@ -18,7 +18,7 @@ #include #include -BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpReserved*/) { switch (ul_reason_for_call) { diff --git a/primedev/logging/crashhandler.cpp b/primedev/logging/crashhandler.cpp index 75ca85442..5cef1c916 100644 --- a/primedev/logging/crashhandler.cpp +++ b/primedev/logging/crashhandler.cpp @@ -89,7 +89,6 @@ BOOL WINAPI ConsoleCtrlRoutine(DWORD dwCtrlType) delete g_pCrashHandler; g_pCrashHandler = nullptr; std::exit(EXIT_SUCCESS); - return TRUE; } return FALSE; diff --git a/primedev/logging/logging.cpp b/primedev/logging/logging.cpp index ef9a67376..ea8a6d5c9 100644 --- a/primedev/logging/logging.cpp +++ b/primedev/logging/logging.cpp @@ -68,7 +68,7 @@ void CreateLogFiles() } } -void ExternalConsoleSink::sink_it_(const spdlog::details::log_msg& msg) +void ExternalConsoleSink::sink_it_(const spdlog::details::log_msg& /*msg*/) { throw std::runtime_error("sink_it_ called on SourceConsoleSink with pure log_msg. This is an error!"); } @@ -281,9 +281,6 @@ void StartupLog() } else { - // We are real Windows (hopefully) - const char* win_ver = "Unknown"; - RTL_OSVERSIONINFOW osvi; osvi.dwOSVersionInfoSize = sizeof(osvi); diff --git a/primedev/logging/logging.h b/primedev/logging/logging.h index 5056af27b..198915786 100644 --- a/primedev/logging/logging.h +++ b/primedev/logging/logging.h @@ -23,7 +23,7 @@ class CustomSink : public spdlog::sinks::base_sink { public: void custom_log(const custom_log_msg& msg); - virtual void custom_sink_it_(const custom_log_msg& msg) + virtual void custom_sink_it_(const custom_log_msg&) { throw std::runtime_error("Pure virtual call to CustomSink::custom_sink_it_"); } diff --git a/primedev/logging/loghooks.cpp b/primedev/logging/loghooks.cpp index 7efb5b995..436436f05 100644 --- a/primedev/logging/loghooks.cpp +++ b/primedev/logging/loghooks.cpp @@ -105,7 +105,7 @@ void,, (BFRead* msg)) // clang-format off AUTOHOOK(Hook_fprintf, engine.dll + 0x51B1F0, -int,, (void* const stream, const char* const format, ...)) +int,, (void* const /*stream*/, const char* const format, ...)) // clang-format on { va_list va; @@ -136,7 +136,7 @@ void,, (const CCommand& arg)) // clang-format off AUTOHOOK(EngineSpewFunc, engine.dll + 0x11CA80, -void, __fastcall, (void* pEngineServer, SpewType_t type, const char* format, va_list args)) +void, __fastcall, (void* /*pEngineServer*/, SpewType_t type, const char* format, va_list args)) // clang-format on { if (!Cvar_spewlog_enable->GetBool()) @@ -232,7 +232,7 @@ void,, (const char* text, ...)) // clang-format off AUTOHOOK(CClientState_ProcessPrint, engine.dll + 0x1A1530, -bool,, (void* thisptr, uintptr_t msg)) +bool,, (void* /*thisptr*/, uintptr_t msg)) // clang-format on { char* text = *(char**)(msg + 0x20); diff --git a/primedev/logging/sourceconsole.cpp b/primedev/logging/sourceconsole.cpp index e436d1d42..13ecbf23c 100644 --- a/primedev/logging/sourceconsole.cpp +++ b/primedev/logging/sourceconsole.cpp @@ -6,7 +6,7 @@ SourceInterface* g_pSourceGameConsole; -void ConCommand_toggleconsole(const CCommand& arg) +void ConCommand_toggleconsole(const CCommand& /*arg*/) { if ((*g_pSourceGameConsole)->IsConsoleVisible()) (*g_pSourceGameConsole)->Hide(); @@ -14,12 +14,12 @@ void ConCommand_toggleconsole(const CCommand& arg) (*g_pSourceGameConsole)->Activate(); } -void ConCommand_showconsole(const CCommand& arg) +void ConCommand_showconsole(const CCommand& /*arg*/) { (*g_pSourceGameConsole)->Activate(); } -void ConCommand_hideconsole(const CCommand& arg) +void ConCommand_hideconsole(const CCommand& /*arg*/) { (*g_pSourceGameConsole)->Hide(); } @@ -45,7 +45,7 @@ void SourceConsoleSink::custom_sink_it_(const custom_log_msg& msg) (*g_pSourceGameConsole)->m_pConsole->m_pConsolePanel->Print(fmt::to_string(formatted).c_str()); } -void SourceConsoleSink::sink_it_(const spdlog::details::log_msg& msg) +void SourceConsoleSink::sink_it_(const spdlog::details::log_msg& /*msg*/) { throw std::runtime_error("sink_it_ called on SourceConsoleSink with pure log_msg. This is an error!"); } diff --git a/primedev/masterserver/masterserver.cpp b/primedev/masterserver/masterserver.cpp index a2d9f00e8..4c1663fe6 100644 --- a/primedev/masterserver/masterserver.cpp +++ b/primedev/masterserver/masterserver.cpp @@ -618,7 +618,7 @@ void MasterServerManager::AuthenticateWithServer(const char* uid, const char* pl std::string passwordStr(password); std::thread requestThread( - [this, uidStr, tokenStr, serverIdStr, passwordStr, server]() + [&]() { // esnure that any persistence saving is done, so we know masterserver has newest while (m_bSavingPersistentData) @@ -734,6 +734,8 @@ void MasterServerManager::AuthenticateWithServer(const char* uid, const char* pl m_bSuccessfullyAuthenticatedWithGameServer = false; m_bScriptAuthenticatingWithGameServer = false; } + + return; }); requestThread.detach(); @@ -880,16 +882,16 @@ void MasterServerManager::ProcessConnectionlessPacketSigreq1(std::string data) if (respStatus != 200) { - rapidjson_document obj; - obj.Parse(pdata.c_str()); + rapidjson_document doc; + doc.Parse(pdata.c_str()); - if (!obj.HasParseError() && obj.HasMember("error") && obj["error"].IsObject()) + if (!doc.HasParseError() && doc.HasMember("error") && doc["error"].IsObject()) spdlog::error( "failed to make Atlas connect pdata request {}: response status {}, error: {} ({})", token, respStatus, - ((obj["error"].HasMember("enum") && obj["error"]["enum"].IsString()) ? obj["error"]["enum"].GetString() : ""), - ((obj["error"].HasMember("msg") && obj["error"]["msg"].IsString()) ? obj["error"]["msg"].GetString() : "")); + ((doc["error"].HasMember("enum") && doc["error"]["enum"].IsString()) ? doc["error"]["enum"].GetString() : ""), + ((doc["error"].HasMember("msg") && doc["error"]["msg"].IsString()) ? doc["error"]["msg"].GetString() : "")); else spdlog::error("failed to make Atlas connect pdata request {}: response status {}", token, respStatus); return; @@ -964,16 +966,16 @@ void MasterServerManager::ProcessConnectionlessPacketSigreq1(std::string data) if (respStatus != 200) { - rapidjson_document obj; - obj.Parse(buf.c_str()); + rapidjson_document req; + req.Parse(buf.c_str()); - if (!obj.HasParseError() && obj.HasMember("error") && obj["error"].IsObject()) + if (!req.HasParseError() && req.HasMember("error") && req["error"].IsObject()) spdlog::error( "failed to respond to Atlas connect request {}: response status {}, error: {} ({})", token, respStatus, - ((obj["error"].HasMember("enum") && obj["error"]["enum"].IsString()) ? obj["error"]["enum"].GetString() : ""), - ((obj["error"].HasMember("msg") && obj["error"]["msg"].IsString()) ? obj["error"]["msg"].GetString() : "")); + ((req["error"].HasMember("enum") && req["error"]["enum"].IsString()) ? req["error"]["enum"].GetString() : ""), + ((req["error"].HasMember("msg") && req["error"]["msg"].IsString()) ? req["error"]["msg"].GetString() : "")); else spdlog::error("failed to respond to Atlas connect request {}: response status {}", token, respStatus); return; @@ -986,7 +988,7 @@ void MasterServerManager::ProcessConnectionlessPacketSigreq1(std::string data) spdlog::error("invalid Atlas connectionless packet request: unknown type {}", type); } -void ConCommand_ns_fetchservers(const CCommand& args) +void ConCommand_ns_fetchservers(const CCommand& /*args*/) { g_pMasterServerManager->RequestServerList(); } @@ -1006,7 +1008,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", MasterServer, (ConCommand, ServerPresence), ( g_pServerPresence->AddPresenceReporter(presenceReporter); } -void MasterServerPresenceReporter::CreatePresence(const ServerPresence* pServerPresence) +void MasterServerPresenceReporter::CreatePresence(const ServerPresence* /*pServerPresence*/) { m_nNumRegistrationAttempts = 0; } @@ -1049,7 +1051,7 @@ void MasterServerPresenceReporter::ReportPresence(const ServerPresence* pServerP } } -void MasterServerPresenceReporter::DestroyPresence(const ServerPresence* pServerPresence) +void MasterServerPresenceReporter::DestroyPresence(const ServerPresence* /*pServerPresence*/) { // Don't call this if we don't have a server id. if (!*g_pMasterServerManager->m_sOwnServerId) @@ -1077,14 +1079,14 @@ void MasterServerPresenceReporter::DestroyPresence(const ServerPresence* pServer "{}/server/remove_server?id={}", Cvar_ns_masterserver_hostname->GetString(), g_pMasterServerManager->m_sOwnServerId) .c_str()); - CURLcode result = curl_easy_perform(curl); + curl_easy_perform(curl); curl_easy_cleanup(curl); }); requestThread.detach(); } -void MasterServerPresenceReporter::RunFrame(double flCurrentTime, const ServerPresence* pServerPresence) +void MasterServerPresenceReporter::RunFrame(double /*flCurrentTime*/, const ServerPresence* /*pServerPresence*/) { // Check if we're already running an InternalAddServer() call in the background. // If so, grab the result if it's ready. diff --git a/primedev/mods/autodownload/moddownloader.cpp b/primedev/mods/autodownload/moddownloader.cpp index 960f435a2..821e2d942 100644 --- a/primedev/mods/autodownload/moddownloader.cpp +++ b/primedev/mods/autodownload/moddownloader.cpp @@ -38,12 +38,12 @@ ModDownloader::ModDownloader() url = cla.substr(quote1 + 1, quote2); } spdlog::info("Found custom verified mods URL in command line argument: {}", url); - modsListUrl = strdup(url.c_str()); + modsListUrl = _strdup(url.c_str()); } else { spdlog::info("Custom verified mods URL not found in command line arguments, using default URL."); - modsListUrl = strdup(DEFAULT_MODS_LIST_URL); + modsListUrl = _strdup(DEFAULT_MODS_LIST_URL); } } @@ -124,14 +124,14 @@ size_t WriteData(void* ptr, size_t size, size_t nmemb, FILE* stream) } int ModDownloader::ModFetchingProgressCallback( - void* ptr, curl_off_t totalDownloadSize, curl_off_t finishedDownloadSize, curl_off_t totalToUpload, curl_off_t nowUploaded) + void* ptr, curl_off_t totalDownloadSize, curl_off_t finishedDownloadSize, curl_off_t /*totalToUpload*/, curl_off_t /*nowUploaded*/) { if (totalDownloadSize != 0 && finishedDownloadSize != 0) { ModDownloader* instance = static_cast(ptr); auto currentDownloadProgress = roundf(static_cast(finishedDownloadSize) / totalDownloadSize * 100); - instance->modState.progress = finishedDownloadSize; - instance->modState.total = totalDownloadSize; + instance->modState.progress = (int)finishedDownloadSize; + instance->modState.total = (int)totalDownloadSize; instance->modState.ratio = currentDownloadProgress; } @@ -155,7 +155,6 @@ std::optional ModDownloader::FetchModFromDistantStore(std::string_view modState.state = DOWNLOADING; // Download the actual archive - bool failed = false; FILE* fp = fopen(downloadPath.generic_string().c_str(), "wb"); CURLcode result; CURL* easyhandle; @@ -288,7 +287,7 @@ bool ModDownloader::IsModLegit(fs::path modPath, std::string_view expectedChecks std::streamsize bytesRead = fp.gcount(); if (bytesRead > 0) { - status = BCryptHashData(hashHandle, (PBYTE)buffer.data(), bytesRead, 0); + status = BCryptHashData(hashHandle, (PUCHAR)buffer.data(), (ULONG)bytesRead, 0); if (!NT_SUCCESS(status)) { modState.state = MOD_CORRUPTED; @@ -313,7 +312,7 @@ bool ModDownloader::IsModLegit(fs::path modPath, std::string_view expectedChecks // Convert hash to string using bytes raw values ss << std::hex << std::setfill('0'); - for (int i = 0; i < hashLength; i++) + for (unsigned int i = 0; i < hashLength; i++) { ss << std::hex << std::setw(2) << static_cast(hash.data()[i]); } @@ -340,9 +339,9 @@ bool ModDownloader::IsModAuthorized(std::string_view modName, std::string_view m return versions.count(modVersion.data()) != 0; } -int GetModArchiveSize(unzFile file, unz_global_info64 info) +uint64_t GetModArchiveSize(unzFile file, unz_global_info64 info) { - int totalSize = 0; + uint64_t totalSize = 0; for (int i = 0; i < info.number_entry; i++) { @@ -399,7 +398,7 @@ void ModDownloader::ExtractMod(fs::path modPath) // Update state modState.state = EXTRACTING; - modState.total = GetModArchiveSize(file, gi); + modState.total = (int)GetModArchiveSize(file, gi); modState.progress = 0; // Mod directory name (removing the ".zip" fom the archive name) diff --git a/primedev/mods/compiled/modkeyvalues.cpp b/primedev/mods/compiled/modkeyvalues.cpp index e44a81d31..5db70cb75 100644 --- a/primedev/mods/compiled/modkeyvalues.cpp +++ b/primedev/mods/compiled/modkeyvalues.cpp @@ -79,7 +79,6 @@ void ModManager::TryBuildKeyValues(const char* filename) i++; } - int j = 0; for (int j = 0; originalFile[i] >= 65 && originalFile[i] <= 122; j++) rootName[j] = originalFile[i++]; diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp index e10779226..9c4047374 100644 --- a/primedev/mods/modmanager.cpp +++ b/primedev/mods/modmanager.cpp @@ -1119,7 +1119,7 @@ void ModManager::CompileAssetsForFile(const char* filename) } } -void ConCommand_reload_mods(const CCommand& args) +void ConCommand_reload_mods(const CCommand& /*args*/) { g_pModManager->LoadMods(); } diff --git a/primedev/mods/modsavefiles.cpp b/primedev/mods/modsavefiles.cpp index 68e33864b..779069050 100644 --- a/primedev/mods/modsavefiles.cpp +++ b/primedev/mods/modsavefiles.cpp @@ -34,7 +34,7 @@ uintmax_t GetSizeOfFolderContentsMinusFile(fs::path dir, std::string file) { result += fs::file_size(entry.path()); } - catch (fs::filesystem_error& e) + catch (fs::filesystem_error&) { if (entry.is_directory()) { @@ -56,7 +56,7 @@ uintmax_t GetSizeOfFolder(fs::path dir) { result += fs::file_size(entry.path()); } - catch (fs::filesystem_error& e) + catch (fs::filesystem_error&) { if (entry.is_directory()) { @@ -530,7 +530,7 @@ ADD_SQFUNC("int", NSGetTotalSpaceRemaining, "", "", ScriptContext::CLIENT | Scri { Mod* mod = g_pSquirrel->getcallingmod(sqvm); fs::path dir = savePath / fs::path(mod->m_ModDirectory).filename(); - g_pSquirrel->pushinteger(sqvm, (MAX_FOLDER_SIZE - GetSizeOfFolder(dir)) / 1024); + g_pSquirrel->pushinteger(sqvm, (MAX_FOLDER_SIZE - (int)GetSizeOfFolder(dir)) / 1024); return SQRESULT_NOTNULL; } diff --git a/primedev/pch.h b/primedev/pch.h index 8a03b857c..5be26b593 100644 --- a/primedev/pch.h +++ b/primedev/pch.h @@ -29,6 +29,8 @@ typedef void (*callable_v)(void* v); #define assert_msg(exp, msg) assert((exp, msg)) //clang-format on +#define NOTE_UNUSED(unusedVar) (void)unusedVar; + #include "core/macros.h" #include "core/math/color.h" diff --git a/primedev/plugins/pluginmanager.cpp b/primedev/plugins/pluginmanager.cpp index 718e69568..b86a4c97a 100644 --- a/primedev/plugins/pluginmanager.cpp +++ b/primedev/plugins/pluginmanager.cpp @@ -175,6 +175,7 @@ void PluginManager::RunFrame() const void ConCommand_reload_plugins(const CCommand& args) { + NOTE_UNUSED(args) g_pPluginManager->ReloadPlugins(); } diff --git a/primedev/primelauncher/main.cpp b/primedev/primelauncher/main.cpp index 96c96c047..1b2c1c0a2 100644 --- a/primedev/primelauncher/main.cpp +++ b/primedev/primelauncher/main.cpp @@ -382,11 +382,11 @@ int main(int argc, char* argv[]) { std::cout << "[*] Loading stubs" << std::endl; HMODULE gssao, gtxaa, d3d11; - if (!(gssao = GetModuleHandleA("GFSDK_SSAO.win64.dll")) && !(gtxaa = GetModuleHandleA("GFSDK_TXAA.win64.dll")) && - !(d3d11 = GetModuleHandleA("d3d11.dll"))) + if ((gssao = GetModuleHandleA("GFSDK_SSAO.win64.dll")) != NULL && (gtxaa = GetModuleHandleA("GFSDK_TXAA.win64.dll")) != NULL && + (d3d11 = GetModuleHandleA("d3d11.dll")) != NULL) { - if (!(gssao = LoadDediStub("GFSDK_SSAO.win64.dll")) || !(gtxaa = LoadDediStub("GFSDK_TXAA.win64.dll")) || - !(d3d11 = LoadDediStub("d3d11.dll"))) + if ((gssao = LoadDediStub("GFSDK_SSAO.win64.dll")) != NULL || (gtxaa = LoadDediStub("GFSDK_TXAA.win64.dll")) != NULL || + (d3d11 = LoadDediStub("d3d11.dll")) != NULL) { if ((!gssao || FreeLibrary(gssao)) && (!gtxaa || FreeLibrary(gtxaa)) && (!d3d11 || FreeLibrary(d3d11))) { diff --git a/primedev/scripts/client/clientchathooks.cpp b/primedev/scripts/client/clientchathooks.cpp index e084f47e9..d1fcd4fd4 100644 --- a/primedev/scripts/client/clientchathooks.cpp +++ b/primedev/scripts/client/clientchathooks.cpp @@ -32,8 +32,8 @@ void, __fastcall, (void* self, const char* message, int inboxId, bool isTeam, bo RemoveAsciiControlSequences(const_cast(message), true); - SQRESULT result = g_pSquirrel->Call( - "CHudChat_ProcessMessageStartThread", static_cast(senderId) - 1, payload, isTeam, isDead, type); + SQRESULT result = + g_pSquirrel->Call("CHudChat_ProcessMessageStartThread", senderId - 1, payload, isTeam, isDead, type); if (result == SQRESULT_ERROR) for (CHudChat* hud = *CHudChat::allHuds; hud != NULL; hud = hud->next) CHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead); diff --git a/primedev/scripts/client/scriptmainmenupromos.cpp b/primedev/scripts/client/scriptmainmenupromos.cpp index ecb47af77..61b932773 100644 --- a/primedev/scripts/client/scriptmainmenupromos.cpp +++ b/primedev/scripts/client/scriptmainmenupromos.cpp @@ -23,6 +23,7 @@ enum eMainMenuPromoDataProperty }; ADD_SQFUNC("void", NSRequestCustomMainMenuPromos, "", "", ScriptContext::UI) { + NOTE_UNUSED(sqvm) g_pMasterServerManager->RequestMainMenuPromos(); return SQRESULT_NULL; } diff --git a/primedev/scripts/client/scriptmodmenu.cpp b/primedev/scripts/client/scriptmodmenu.cpp index a88478fb7..844197716 100644 --- a/primedev/scripts/client/scriptmodmenu.cpp +++ b/primedev/scripts/client/scriptmodmenu.cpp @@ -160,6 +160,7 @@ ADD_SQFUNC( ADD_SQFUNC("void", NSReloadMods, "", "", ScriptContext::UI) { + NOTE_UNUSED(sqvm) g_pModManager->LoadMods(); return SQRESULT_NULL; } diff --git a/primedev/scripts/client/scriptserverbrowser.cpp b/primedev/scripts/client/scriptserverbrowser.cpp index 21324535c..93faa5802 100644 --- a/primedev/scripts/client/scriptserverbrowser.cpp +++ b/primedev/scripts/client/scriptserverbrowser.cpp @@ -8,6 +8,7 @@ ADD_SQFUNC("void", NSRequestServerList, "", "", ScriptContext::UI) { + NOTE_UNUSED(sqvm) g_pMasterServerManager->RequestServerList(); return SQRESULT_NULL; } @@ -32,6 +33,7 @@ ADD_SQFUNC("int", NSGetServerCount, "", "", ScriptContext::UI) ADD_SQFUNC("void", NSClearRecievedServerList, "", "", ScriptContext::UI) { + NOTE_UNUSED(sqvm) g_pMasterServerManager->ClearServerList(); return SQRESULT_NULL; } @@ -114,6 +116,7 @@ ADD_SQFUNC("void", NSConnectToAuthedServer, "", "", ScriptContext::UI) ADD_SQFUNC("void", NSTryAuthWithLocalServer, "", "", ScriptContext::UI) { + NOTE_UNUSED(sqvm) // do auth request g_pMasterServerManager->AuthenticateWithOwnServer(g_pLocalPlayerUserID, g_pMasterServerManager->m_sOwnClientAuthToken); @@ -122,6 +125,7 @@ ADD_SQFUNC("void", NSTryAuthWithLocalServer, "", "", ScriptContext::UI) ADD_SQFUNC("void", NSCompleteAuthWithLocalServer, "", "", ScriptContext::UI) { + NOTE_UNUSED(sqvm) // literally just set serverfilter // note: this assumes we have no authdata other than our own if (g_pServerAuthentication->m_RemoteAuthenticationData.size()) @@ -139,7 +143,7 @@ ADD_SQFUNC("string", NSGetAuthFailReason, "", "", ScriptContext::UI) ADD_SQFUNC("array", NSGetGameServers, "", "", ScriptContext::UI) { g_pSquirrel->newarray(sqvm, 0); - for (size_t i = 0; i < g_pMasterServerManager->m_vRemoteServers.size(); i++) + for (SQInteger i = 0; i < (SQInteger)g_pMasterServerManager->m_vRemoteServers.size(); i++) { const RemoteServerInfo& remoteServer = g_pMasterServerManager->m_vRemoteServers[i]; diff --git a/primedev/scripts/scriptdatatables.cpp b/primedev/scripts/scriptdatatables.cpp index 47c3a0f11..1bf50609e 100644 --- a/primedev/scripts/scriptdatatables.cpp +++ b/primedev/scripts/scriptdatatables.cpp @@ -696,7 +696,7 @@ std::string DataTableToString(Datatable* datatable) { sCSVString += '\n'; - bool bShouldComma = false; + bShouldComma = false; for (int col = 0; col < datatable->numColumns; col++) { if (bShouldComma) @@ -779,7 +779,7 @@ void ConCommand_dump_datatable(const CCommand& args) DumpDatatable(args.Arg(1)); } -void ConCommand_dump_datatables(const CCommand& args) +void ConCommand_dump_datatables(const CCommand& /*args*/) { // likely not a comprehensive list, might be missing a couple? static const std::vector VANILLA_DATATABLE_PATHS = { diff --git a/primedev/server/auth/bansystem.cpp b/primedev/server/auth/bansystem.cpp index 59bb60675..54e76e1c6 100644 --- a/primedev/server/auth/bansystem.cpp +++ b/primedev/server/auth/bansystem.cpp @@ -211,7 +211,7 @@ void ConCommand_unban(const CCommand& args) g_pBanSystem->UnbanUID(strtoull(args.Arg(1), nullptr, 10)); } -void ConCommand_clearbanlist(const CCommand& args) +void ConCommand_clearbanlist(const CCommand& /*args*/) { g_pBanSystem->ClearBanlist(); } diff --git a/primedev/server/auth/serverauthentication.cpp b/primedev/server/auth/serverauthentication.cpp index 7d656820b..27052131f 100644 --- a/primedev/server/auth/serverauthentication.cpp +++ b/primedev/server/auth/serverauthentication.cpp @@ -93,7 +93,6 @@ bool ServerAuthenticationManager::IsDuplicateAccount(CBaseClient* pPlayer, const if (m_bAllowDuplicateAccounts) return false; - bool bHasUidPlayer = false; for (int i = 0; i < g_pGlobals->m_nMaxClients; i++) if (&g_pClientArray[i] != pPlayer && !strcmp(pPlayerUid, g_pClientArray[i].m_UID)) return true; @@ -331,7 +330,7 @@ void,, (CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...) _CBaseClient__Disconnect(self, unknownButAlways1, buf); } -void ConCommand_ns_resetpersistence(const CCommand& args) +void ConCommand_ns_resetpersistence(const CCommand& /*args*/) { if (*g_pServerState == server_state_t::ss_active) { diff --git a/primedev/server/servernethooks.cpp b/primedev/server/servernethooks.cpp index 148b735fa..189d145bb 100644 --- a/primedev/server/servernethooks.cpp +++ b/primedev/server/servernethooks.cpp @@ -7,6 +7,8 @@ #include #include +#define STATUS_SUCCESS 0 // taken from ntstatus.h but redefinition errors + AUTOHOOK_INIT() static ConVar* Cvar_net_debug_atlas_packet; @@ -21,13 +23,14 @@ static bool InitHMACSHA256() DWORD hashLength = 0; ULONG hashLengthSz = 0; - if ((status = BCryptOpenAlgorithmProvider(&HMACSHA256, BCRYPT_SHA256_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG))) + if ((status = BCryptOpenAlgorithmProvider(&HMACSHA256, BCRYPT_SHA256_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG)) != STATUS_SUCCESS) { spdlog::error("failed to initialize HMAC-SHA256: BCryptOpenAlgorithmProvider: error 0x{:08X}", (ULONG)status); return false; } - if ((status = BCryptGetProperty(HMACSHA256, BCRYPT_HASH_LENGTH, (PUCHAR)&hashLength, sizeof(hashLength), &hashLengthSz, 0))) + if ((status = BCryptGetProperty(HMACSHA256, BCRYPT_HASH_LENGTH, (PUCHAR)&hashLength, sizeof(hashLength), &hashLengthSz, 0)) != + STATUS_SUCCESS) { spdlog::error("failed to initialize HMAC-SHA256: BCryptGetProperty(BCRYPT_HASH_LENGTH): error 0x{:08X}", (ULONG)status); return false; @@ -51,19 +54,19 @@ static bool VerifyHMACSHA256(std::string key, std::string sig, std::string data) NTSTATUS status; BCRYPT_HASH_HANDLE h = NULL; - if ((status = BCryptCreateHash(HMACSHA256, &h, NULL, 0, (PUCHAR)key.c_str(), (ULONG)key.length(), 0))) + if ((status = BCryptCreateHash(HMACSHA256, &h, NULL, 0, (PUCHAR)key.c_str(), (ULONG)key.length(), 0)) != STATUS_SUCCESS) { spdlog::error("failed to verify HMAC-SHA256: BCryptCreateHash: error 0x{:08X}", (ULONG)status); goto cleanup; } - if ((status = BCryptHashData(h, (PUCHAR)data.c_str(), (ULONG)data.length(), 0))) + if ((status = BCryptHashData(h, (PUCHAR)data.c_str(), (ULONG)data.length(), 0)) != STATUS_SUCCESS) { spdlog::error("failed to verify HMAC-SHA256: BCryptHashData: error 0x{:08X}", (ULONG)status); goto cleanup; } - if ((status = BCryptFinishHash(h, (PUCHAR)&hash, (ULONG)sizeof(hash), 0))) + if ((status = BCryptFinishHash(h, (PUCHAR)&hash, (ULONG)sizeof(hash), 0)) != STATUS_SUCCESS) { spdlog::error("failed to verify HMAC-SHA256: BCryptFinishHash: error 0x{:08X}", (ULONG)status); goto cleanup; diff --git a/primedev/server/serverpresence.cpp b/primedev/server/serverpresence.cpp index 159b9f30a..b9e367f79 100644 --- a/primedev/server/serverpresence.cpp +++ b/primedev/server/serverpresence.cpp @@ -41,25 +41,25 @@ std::string UnescapeUnicode(const std::string& str) last_match = *i; result.append(last_match.prefix()); unsigned int cp = 0; - for (int i = 2; i <= 5; ++i) + for (int j = 2; j <= 5; ++j) { cp *= 16; - cp += hctod(last_match.str()[i]); + cp += hctod(last_match.str()[j]); } if (cp <= 0x7F) { - result.push_back(cp); + result.push_back((char)cp); } else if (cp <= 0x7FF) { - result.push_back((cp >> 6) | 0b11000000 & (~(1 << 5))); - result.push_back(cp & ((1 << 6) - 1) | 0b10000000 & (~(1 << 6))); + result.push_back((char)((cp >> 6) | 0b11000000 & (~(1 << 5)))); + result.push_back((char)(cp & ((1 << 6) - 1) | 0b10000000 & (~(1 << 6)))); } else if (cp <= 0xFFFF) { - result.push_back((cp >> 12) | 0b11100000 & (~(1 << 4))); - result.push_back((cp >> 6) & ((1 << 6) - 1) | 0b10000000 & (~(1 << 6))); - result.push_back(cp & ((1 << 6) - 1) | 0b10000000 & (~(1 << 6))); + result.push_back((char)((cp >> 12) | 0b11100000 & (~(1 << 4)))); + result.push_back((char)((cp >> 6) & ((1 << 6) - 1) | 0b10000000 & (~(1 << 6)))); + result.push_back((char)(cp & ((1 << 6) - 1) | 0b10000000 & (~(1 << 6)))); } } @@ -78,18 +78,18 @@ void ServerPresenceManager::CreateConVars() Cvar_ns_server_presence_update_rate = new ConVar( "ns_server_presence_update_rate", "5000", FCVAR_GAMEDLL, "How often we update our server's presence on server lists in ms"); - Cvar_ns_server_name = new ConVar("ns_server_name", "Unnamed Northstar Server", FCVAR_GAMEDLL, "This server's name", false, 0, false, 0, [](ConVar* cvar, const char* pOldValue, float flOldValue) { + Cvar_ns_server_name = new ConVar("ns_server_name", "Unnamed Northstar Server", FCVAR_GAMEDLL, "This server's name", false, 0, false, 0, [](ConVar* /*cvar*/, const char* /*pOldValue*/, float /*flOldValue*/) { g_pServerPresence->SetName(UnescapeUnicode(g_pServerPresence->Cvar_ns_server_name->GetString())); // update engine hostname cvar Cvar_hostname->SetValue(g_pServerPresence->Cvar_ns_server_name->GetString()); }); - Cvar_ns_server_desc = new ConVar("ns_server_desc", "Default server description", FCVAR_GAMEDLL, "This server's description", false, 0, false, 0, [](ConVar* cvar, const char* pOldValue, float flOldValue) { + Cvar_ns_server_desc = new ConVar("ns_server_desc", "Default server description", FCVAR_GAMEDLL, "This server's description", false, 0, false, 0, [](ConVar* /*cvar*/, const char* /*pOldValue*/, float /*flOldValue*/) { g_pServerPresence->SetDescription(UnescapeUnicode(g_pServerPresence->Cvar_ns_server_desc->GetString())); }); - Cvar_ns_server_password = new ConVar("ns_server_password", "", FCVAR_GAMEDLL, "This server's password", false, 0, false, 0, [](ConVar* cvar, const char* pOldValue, float flOldValue) { + Cvar_ns_server_password = new ConVar("ns_server_password", "", FCVAR_GAMEDLL, "This server's password", false, 0, false, 0, [](ConVar* /*cvar*/, const char* /*pOldValue*/, float /*flOldValue*/) { g_pServerPresence->SetPassword(g_pServerPresence->Cvar_ns_server_password->GetString()); }); diff --git a/primedev/server/serverpresence.h b/primedev/server/serverpresence.h index c644cc377..94ecfe6a0 100644 --- a/primedev/server/serverpresence.h +++ b/primedev/server/serverpresence.h @@ -45,10 +45,10 @@ struct ServerPresence class ServerPresenceReporter { public: - virtual void CreatePresence(const ServerPresence* pServerPresence) {} - virtual void ReportPresence(const ServerPresence* pServerPresence) {} - virtual void DestroyPresence(const ServerPresence* pServerPresence) {} - virtual void RunFrame(double flCurrentTime, const ServerPresence* pServerPresence) {} + virtual void CreatePresence(const ServerPresence* /*pServerPresence*/) {} + virtual void ReportPresence(const ServerPresence* /*pServerPresence*/) {} + virtual void DestroyPresence(const ServerPresence* /*pServerPresence*/) {} + virtual void RunFrame(double /*flCurrentTime*/, const ServerPresence* /*pServerPresence*/) {} }; class ServerPresenceManager diff --git a/primedev/shared/exploit_fixes/exploitfixes.cpp b/primedev/shared/exploit_fixes/exploitfixes.cpp index cade40843..d322511d0 100644 --- a/primedev/shared/exploit_fixes/exploitfixes.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes.cpp @@ -52,7 +52,7 @@ bool, __fastcall, (void* thisptr, void* buffer)) // 48 89 5C 24 ? 48 89 6C 24 ? // This is unused ingame and a big client=>server=>client exploit vector // clang-format off AUTOHOOK(Base_CmdKeyValues_ReadFromBuffer, engine.dll + 0x220040, -bool, __fastcall, (void* thisptr, void* buffer)) // 40 55 48 81 EC ? ? ? ? 48 8D 6C 24 ? 48 89 5D 70 +bool, __fastcall, (void* /*thisptr*/, void* /*buffer*/)) // 40 55 48 81 EC ? ? ? ? 48 8D 6C 24 ? 48 89 5D 70 // clang-format on { return false; @@ -107,11 +107,11 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10 { // Find null terminators bool nameValid = false, valValid = false; - for (int i = 0; i < ENTRY_STR_LEN; i++) + for (int j = 0; j < ENTRY_STR_LEN; j++) { - if (!entry->name[i]) + if (!entry->name[j]) nameValid = true; - if (!entry->val[i]) + if (!entry->val[j]) valValid = true; } @@ -255,9 +255,14 @@ void, __fastcall, (void* buf, void* pCmd_move, void* pCmd_from)) // 4C 89 44 24 // Fix any gameplay-affecting cmd properties // NOTE: Currently tickcount/frametime is set to 0, this ~shouldn't~ cause any problems - cmd->worldViewAngles = cmd->localViewAngles = cmd->attackangles = cmd->cameraAngles = {0, 0, 0}; - cmd->tick_count = cmd->frameTime = 0; - cmd->move = cmd->cameraPos = {0, 0, 0}; + cmd->worldViewAngles = {0, 0, 0}; + cmd->localViewAngles = {0, 0, 0}; + cmd->attackangles = {0, 0, 0}; + cmd->cameraAngles = {0, 0, 0}; + cmd->tick_count = 0; + cmd->frameTime = 0.0f; + cmd->move = {0, 0, 0}; + cmd->cameraPos = {0, 0, 0}; cmd->buttons = 0; cmd->meleetarget = 0; } @@ -333,7 +338,6 @@ bool, __fastcall, (CBaseClient* self, uint32_t unknown, const char* pCommandStri size_t iCmdLength = strlen(tempCommand.Arg(0)); - bool bIsBadCommand = false; for (auto& blockedCommand : blockedCommands) { if (iCmdLength != strlen(blockedCommand)) diff --git a/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp b/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp index ccb6ac18f..4083050d1 100644 --- a/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp @@ -13,7 +13,7 @@ struct lzss_header_t // out of the bounds of the output buffer. // clang-format off AUTOHOOK(CLZSS__SafeDecompress, engine.dll + 0x432A10, -unsigned int, __fastcall, (void* self, const unsigned char* pInput, unsigned char* pOutput, unsigned int unBufSize)) +unsigned int, __fastcall, (void* /*self*/, const unsigned char* pInput, unsigned char* pOutput, unsigned int unBufSize)) // clang-format on { unsigned int totalBytes = 0; @@ -36,7 +36,7 @@ unsigned int, __fastcall, (void* self, const unsigned char* pInput, unsigned cha if (cmdByte & 0x01) { - int position = *pInput++ << LZSS_LOOKSHIFT; + unsigned int position = *pInput++ << LZSS_LOOKSHIFT; position |= (*pInput >> LZSS_LOOKSHIFT); position += 1; int count = (*pInput++ & 0x0F) + 1; diff --git a/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp b/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp index 3d97f7501..fe5249574 100644 --- a/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp @@ -42,17 +42,17 @@ bool __fastcall CheckUTF8Valid(INT64* a1, DWORD* a2, char* strData) int v39; // eax int v40; // er10 DWORD v41; // er10 - INT64 v43; // r8 - INT64 v44; // rdx - INT64 v45; // rcx - INT64 v46; // rax - INT64 v47; // rax - char v48; // al - INT64 v49; // r8 - INT64 v50; // rdx - INT64 v51; // rcx - INT64 v52; // rax - INT64 v53; // rax + // INT64 v43; // r8 + // INT64 v44; // rdx + // INT64 v45; // rcx + // INT64 v46; // rax + // INT64 v47; // rax + // char v48; // al + // INT64 v49; // r8 + // INT64 v50; // rdx + // INT64 v51; // rcx + // INT64 v52; // rax + // INT64 v53; // rax v3 = a2[2]; v4 = (char*)(a1[1] + *a2); diff --git a/primedev/shared/exploit_fixes/ns_limits.cpp b/primedev/shared/exploit_fixes/ns_limits.cpp index bd855ee45..52c760c03 100644 --- a/primedev/shared/exploit_fixes/ns_limits.cpp +++ b/primedev/shared/exploit_fixes/ns_limits.cpp @@ -14,7 +14,7 @@ ServerLimitsManager* g_pServerLimits; float (*CEngineServer__GetTimescale)(); // todo: make this work on higher timescales, also possibly disable when sv_cheats is set -void ServerLimitsManager::RunFrame(double flCurrentTime, float flFrameTime) +void ServerLimitsManager::RunFrame(double /*flCurrentTime*/, float flFrameTime) { if (Cvar_sv_antispeedhack_enable->GetBool()) { @@ -243,9 +243,9 @@ void, __fastcall, (void* self, CBasePlayer* player, SV_CUserCmd* pUserCmd, uint6 { PlayerLimitData* pLimitData = &g_pServerLimits->m_PlayerLimitData[pClient]; - pLimitData->flFrameUserCmdBudget = fmax(0.0, pLimitData->flFrameUserCmdBudget - pUserCmd->frameTime); + pLimitData->flFrameUserCmdBudget = fmax(0.0f, pLimitData->flFrameUserCmdBudget - pUserCmd->frameTime); - if (pLimitData->flFrameUserCmdBudget <= 0.0) + if (pLimitData->flFrameUserCmdBudget <= 0.0f) { spdlog::warn("player {} went over usercmd budget ({})", pClient->m_Name, pLimitData->flFrameUserCmdBudget); return; diff --git a/primedev/shared/maxplayers.cpp b/primedev/shared/maxplayers.cpp index 711193d4a..40533c04c 100644 --- a/primedev/shared/maxplayers.cpp +++ b/primedev/shared/maxplayers.cpp @@ -138,11 +138,11 @@ void,, (bool a1, float a2)) // clang-format on { unsigned char v3; // bl - int v5; // er14 - int i; // edi + unsigned int v5; // er14 + unsigned int i; // edi __int64 v7; // rax DWORD* v8; // rbx - int v9; // edi + unsigned int v9; // edi __int64* v10; // rsi __int64 v11; // rax int v12; // er12 @@ -153,7 +153,7 @@ void,, (bool a1, float a2)) int v17; // edx char v18; // r15 char v19; // bp - int v20; // esi + unsigned int v20; // esi __int64* v21; // rdi __int64 v22; // rcx bool v23; // al @@ -221,7 +221,7 @@ void,, (bool a1, float a2)) v14 = *(DWORD*)(globals + 52); do { - v15 = RandomIntZeroMax(); + v15 = (int)RandomIntZeroMax(); v16 = v25[v13--]; v17 = v15 % v14--; v25[v13 + 1] = v25[v17]; diff --git a/primedev/shared/misccommands.cpp b/primedev/shared/misccommands.cpp index 648525b97..f87cc5749 100644 --- a/primedev/shared/misccommands.cpp +++ b/primedev/shared/misccommands.cpp @@ -19,14 +19,14 @@ void ConCommand_force_newgame(const CCommand& arg) strncpy(g_pHostState->m_levelName, arg.Arg(1), sizeof(g_pHostState->m_levelName)); } -void ConCommand_ns_start_reauth_and_leave_to_lobby(const CCommand& arg) +void ConCommand_ns_start_reauth_and_leave_to_lobby(const CCommand& /*arg*/) { // hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect g_pMasterServerManager->m_bNewgameAfterSelfAuth = true; g_pMasterServerManager->AuthenticateWithOwnServer(g_pLocalPlayerUserID, g_pMasterServerManager->m_sOwnClientAuthToken); } -void ConCommand_ns_end_reauth_and_leave_to_lobby(const CCommand& arg) +void ConCommand_ns_end_reauth_and_leave_to_lobby(const CCommand& /*arg*/) { if (g_pServerAuthentication->m_RemoteAuthenticationData.size()) g_pCVar->FindVar("serverfilter")->SetValue(g_pServerAuthentication->m_RemoteAuthenticationData.begin()->first.c_str()); diff --git a/primedev/squirrel/squirrel.cpp b/primedev/squirrel/squirrel.cpp index 70dedcb87..b101b971c 100644 --- a/primedev/squirrel/squirrel.cpp +++ b/primedev/squirrel/squirrel.cpp @@ -27,7 +27,6 @@ std::shared_ptr getSquirrelLoggerByContext(ScriptContext context) return NS::log::SCRIPT_SV; default: throw std::runtime_error("getSquirrelLoggerByContext called with invalid context"); - return nullptr; } } @@ -314,7 +313,7 @@ template void SquirrelManager::AddFuncOverride( } // hooks -bool IsUIVM(ScriptContext context, HSquirrelVM* pSqvm) +bool IsUIVM(ScriptContext /*context*/, HSquirrelVM* pSqvm) { return ScriptContext(pSqvm->sharedState->cSquirrelVM->vmContext) == ScriptContext::UI; } @@ -334,6 +333,7 @@ template void* __fastcall sq_compiler_createHook(HSquirr template SQInteger (*SQPrint)(HSquirrelVM* sqvm, const char* fmt); template SQInteger SQPrintHook(HSquirrelVM* sqvm, const char* fmt, ...) { + NOTE_UNUSED(sqvm) va_list va; va_start(va, fmt); @@ -480,14 +480,14 @@ template bool __fastcall CallScriptInitCallbackHook(void ScriptContext realContext = context; bool bShouldCallCustomCallbacks = true; - if (context == ScriptContext::CLIENT) + if constexpr (context == ScriptContext::CLIENT) { if (!strcmp(callback, "UICodeCallback_UIInit")) realContext = ScriptContext::UI; else if (strcmp(callback, "ClientCodeCallback_MapSpawn")) bShouldCallCustomCallbacks = false; } - else if (context == ScriptContext::SERVER) + else if constexpr (context == ScriptContext::SERVER) bShouldCallCustomCallbacks = !strcmp(callback, "CodeCallback_MapSpawn"); if (bShouldCallCustomCallbacks) diff --git a/primedev/util/printcommands.cpp b/primedev/util/printcommands.cpp index 20ebfffc9..67c0c7877 100644 --- a/primedev/util/printcommands.cpp +++ b/primedev/util/printcommands.cpp @@ -117,11 +117,11 @@ void ConCommand_find(const CCommand& arg) strncpy_s(pTempName, sizeof(pTempName), map.second->m_pszName, sizeof(pTempName) - 1); strncpy_s(pTempSearchTerm, sizeof(pTempSearchTerm), arg.Arg(i + 1), sizeof(pTempSearchTerm) - 1); - for (int i = 0; pTempName[i]; i++) - pTempName[i] = tolower(pTempName[i]); + for (int j = 0; pTempName[j]; j++) + pTempName[j] = (char)tolower(pTempName[j]); - for (int i = 0; pTempSearchTerm[i]; i++) - pTempSearchTerm[i] = tolower(pTempSearchTerm[i]); + for (int j = 0; pTempSearchTerm[j]; j++) + pTempSearchTerm[j] = (char)tolower(pTempSearchTerm[j]); if (!strstr(pTempName, pTempSearchTerm)) { @@ -151,7 +151,7 @@ void ConCommand_findflags(const CCommand& arg) strcpy(upperFlag, arg.Arg(1)); for (int i = 0; upperFlag[i]; i++) - upperFlag[i] = toupper(upperFlag[i]); + upperFlag[i] = (char)toupper(upperFlag[i]); // resolve flag name => int flags int resolvedFlag = FCVAR_NONE; @@ -186,7 +186,7 @@ void ConCommand_findflags(const CCommand& arg) delete[] upperFlag; } -void ConCommand_list(const CCommand& arg) +void ConCommand_list(const CCommand& /*arg*/) { ConCommandBase* var; CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator(); @@ -208,7 +208,7 @@ void ConCommand_list(const CCommand& arg) spdlog::info("{} total convars/concommands", sorted.size()); } -void ConCommand_differences(const CCommand& arg) +void ConCommand_differences(const CCommand& /*arg*/) { CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator(); std::map sorted; diff --git a/primedev/util/utils.cpp b/primedev/util/utils.cpp index c3f90cfa9..53c2b30f6 100644 --- a/primedev/util/utils.cpp +++ b/primedev/util/utils.cpp @@ -22,8 +22,9 @@ bool skip_valid_ansi_csi_sgr(char*& str) void RemoveAsciiControlSequences(char* str, bool allow_color_codes) { - for (char *pc = str, c = *pc; c = *pc; pc++) + for (char* pc = str; *pc != 0x00; pc++) { + char c = *pc; // skip UTF-8 characters int bytesToSkip = 0; if ((c & 0xE0) == 0xC0)