From 85a2fb9c56c1942958c09c8aeafd14ddefb6e0c3 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Mon, 4 Mar 2024 00:12:05 +0000 Subject: Address C4100 compiler warnings (unused var) (#648) Adds and uses a macro to avoid the warning --- primedev/core/convar/convar.cpp | 1 + primedev/dedicated/dedicated.cpp | 5 +++++ primedev/dedicated/dedicatedlogtoclient.cpp | 1 + primedev/dllmain.cpp | 2 ++ primedev/logging/logging.cpp | 1 + primedev/logging/logging.h | 1 + primedev/logging/loghooks.cpp | 5 +++++ primedev/logging/sourceconsole.cpp | 4 ++++ primedev/masterserver/masterserver.cpp | 5 +++++ primedev/mods/autodownload/moddownloader.cpp | 2 ++ primedev/mods/modmanager.cpp | 1 + primedev/pch.h | 2 ++ primedev/scripts/client/scriptmainmenupromos.cpp | 1 + primedev/scripts/client/scriptmodmenu.cpp | 1 + primedev/scripts/client/scriptserverbrowser.cpp | 4 ++++ primedev/scripts/scriptdatatables.cpp | 1 + primedev/server/auth/bansystem.cpp | 1 + primedev/server/auth/serverauthentication.cpp | 1 + primedev/server/serverpresence.cpp | 9 +++++++++ primedev/server/serverpresence.h | 8 ++++---- primedev/shared/exploit_fixes/exploitfixes.cpp | 2 ++ primedev/shared/exploit_fixes/exploitfixes_lzss.cpp | 1 + primedev/shared/exploit_fixes/ns_limits.cpp | 1 + primedev/shared/misccommands.cpp | 2 ++ primedev/squirrel/squirrel.cpp | 3 +++ primedev/util/printcommands.cpp | 2 ++ 26 files changed, 63 insertions(+), 4 deletions(-) diff --git a/primedev/core/convar/convar.cpp b/primedev/core/convar/convar.cpp index 767961ed..87a1e159 100644 --- a/primedev/core/convar/convar.cpp +++ b/primedev/core/convar/convar.cpp @@ -363,6 +363,7 @@ void ConVar::SetValue(Color clValue) //----------------------------------------------------------------------------- void ConVar::ChangeStringValue(const char* pszTempVal, float flOldValue) { + NOTE_UNUSED(flOldValue); assert(!(m_ConCommandBase.m_nFlags & FCVAR_NEVER_AS_STRING)); char* pszOldValue = (char*)_malloca(m_Value.m_iStringLength); diff --git a/primedev/dedicated/dedicated.cpp b/primedev/dedicated/dedicated.cpp index 5c679b76..eca9b9f1 100644 --- a/primedev/dedicated/dedicated.cpp +++ b/primedev/dedicated/dedicated.cpp @@ -35,11 +35,14 @@ struct CDedicatedExports void Sys_Printf(CDedicatedExports* dedicated, const char* msg) { + NOTE_UNUSED(dedicated); spdlog::info("[DEDICATED SERVER] {}", msg); } void RunServer(CDedicatedExports* dedicated) { + NOTE_UNUSED(dedicated); + spdlog::info("CDedicatedExports::RunServer(): starting"); spdlog::info(CommandLine()->GetCmdLine()); @@ -86,6 +89,8 @@ class DedicatedConsoleServerPresence : public ServerPresenceReporter HANDLE consoleInputThreadHandle = NULL; DWORD WINAPI ConsoleInputThread(PVOID pThreadParameter) { + NOTE_UNUSED(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 bf2cf77a..48954d34 100644 --- a/primedev/dedicated/dedicatedlogtoclient.cpp +++ b/primedev/dedicated/dedicatedlogtoclient.cpp @@ -37,6 +37,7 @@ void DedicatedServerLogToClientSink::custom_sink_it_(const custom_log_msg& msg) void DedicatedServerLogToClientSink::sink_it_(const spdlog::details::log_msg& msg) { + NOTE_UNUSED(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 c87c8bae..1191307f 100644 --- a/primedev/dllmain.cpp +++ b/primedev/dllmain.cpp @@ -20,6 +20,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + NOTE_UNUSED(hModule); + NOTE_UNUSED(lpReserved); switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: diff --git a/primedev/logging/logging.cpp b/primedev/logging/logging.cpp index ef9a6737..72171e25 100644 --- a/primedev/logging/logging.cpp +++ b/primedev/logging/logging.cpp @@ -70,6 +70,7 @@ void CreateLogFiles() void ExternalConsoleSink::sink_it_(const spdlog::details::log_msg& msg) { + NOTE_UNUSED(msg); throw std::runtime_error("sink_it_ called on SourceConsoleSink with pure log_msg. This is an error!"); } diff --git a/primedev/logging/logging.h b/primedev/logging/logging.h index 5056af27..be41cb39 100644 --- a/primedev/logging/logging.h +++ b/primedev/logging/logging.h @@ -25,6 +25,7 @@ public: void custom_log(const custom_log_msg& msg); virtual void custom_sink_it_(const custom_log_msg& msg) { + NOTE_UNUSED(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 7efb5b99..dcd9b85a 100644 --- a/primedev/logging/loghooks.cpp +++ b/primedev/logging/loghooks.cpp @@ -108,6 +108,8 @@ AUTOHOOK(Hook_fprintf, engine.dll + 0x51B1F0, int,, (void* const stream, const char* const format, ...)) // clang-format on { + NOTE_UNUSED(stream); + va_list va; va_start(va, format); @@ -139,6 +141,7 @@ AUTOHOOK(EngineSpewFunc, engine.dll + 0x11CA80, void, __fastcall, (void* pEngineServer, SpewType_t type, const char* format, va_list args)) // clang-format on { + NOTE_UNUSED(pEngineServer); if (!Cvar_spewlog_enable->GetBool()) return; @@ -235,6 +238,8 @@ AUTOHOOK(CClientState_ProcessPrint, engine.dll + 0x1A1530, bool,, (void* thisptr, uintptr_t msg)) // clang-format on { + NOTE_UNUSED(thisptr); + char* text = *(char**)(msg + 0x20); auto endpos = strlen(text); diff --git a/primedev/logging/sourceconsole.cpp b/primedev/logging/sourceconsole.cpp index e436d1d4..55be4723 100644 --- a/primedev/logging/sourceconsole.cpp +++ b/primedev/logging/sourceconsole.cpp @@ -8,6 +8,7 @@ SourceInterface* g_pSourceGameConsole; void ConCommand_toggleconsole(const CCommand& arg) { + NOTE_UNUSED(arg); if ((*g_pSourceGameConsole)->IsConsoleVisible()) (*g_pSourceGameConsole)->Hide(); else @@ -16,11 +17,13 @@ void ConCommand_toggleconsole(const CCommand& arg) void ConCommand_showconsole(const CCommand& arg) { + NOTE_UNUSED(arg); (*g_pSourceGameConsole)->Activate(); } void ConCommand_hideconsole(const CCommand& arg) { + NOTE_UNUSED(arg); (*g_pSourceGameConsole)->Hide(); } @@ -47,6 +50,7 @@ void SourceConsoleSink::custom_sink_it_(const custom_log_msg& msg) void SourceConsoleSink::sink_it_(const spdlog::details::log_msg& msg) { + NOTE_UNUSED(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 a2d9f00e..e7bb1132 100644 --- a/primedev/masterserver/masterserver.cpp +++ b/primedev/masterserver/masterserver.cpp @@ -988,6 +988,7 @@ void MasterServerManager::ProcessConnectionlessPacketSigreq1(std::string data) void ConCommand_ns_fetchservers(const CCommand& args) { + NOTE_UNUSED(args); g_pMasterServerManager->RequestServerList(); } @@ -1008,6 +1009,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", MasterServer, (ConCommand, ServerPresence), ( void MasterServerPresenceReporter::CreatePresence(const ServerPresence* pServerPresence) { + NOTE_UNUSED(pServerPresence); m_nNumRegistrationAttempts = 0; } @@ -1051,6 +1053,7 @@ void MasterServerPresenceReporter::ReportPresence(const ServerPresence* pServerP void MasterServerPresenceReporter::DestroyPresence(const ServerPresence* pServerPresence) { + NOTE_UNUSED(pServerPresence); // Don't call this if we don't have a server id. if (!*g_pMasterServerManager->m_sOwnServerId) { @@ -1086,6 +1089,8 @@ void MasterServerPresenceReporter::DestroyPresence(const ServerPresence* pServer void MasterServerPresenceReporter::RunFrame(double flCurrentTime, const ServerPresence* pServerPresence) { + NOTE_UNUSED(flCurrentTime); + NOTE_UNUSED(pServerPresence); // Check if we're already running an InternalAddServer() call in the background. // If so, grab the result if it's ready. if (addServerFuture.valid()) diff --git a/primedev/mods/autodownload/moddownloader.cpp b/primedev/mods/autodownload/moddownloader.cpp index 960f435a..3a946263 100644 --- a/primedev/mods/autodownload/moddownloader.cpp +++ b/primedev/mods/autodownload/moddownloader.cpp @@ -126,6 +126,8 @@ 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) { + NOTE_UNUSED(totalToUpload); + NOTE_UNUSED(nowUploaded); if (totalDownloadSize != 0 && finishedDownloadSize != 0) { ModDownloader* instance = static_cast(ptr); diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp index e1077922..268a65a5 100644 --- a/primedev/mods/modmanager.cpp +++ b/primedev/mods/modmanager.cpp @@ -1121,6 +1121,7 @@ void ModManager::CompileAssetsForFile(const char* filename) void ConCommand_reload_mods(const CCommand& args) { + NOTE_UNUSED(args); g_pModManager->LoadMods(); } diff --git a/primedev/pch.h b/primedev/pch.h index 141995c7..577f803c 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(var) do { (void)var; } while(false) + #include "core/macros.h" #include "core/math/color.h" diff --git a/primedev/scripts/client/scriptmainmenupromos.cpp b/primedev/scripts/client/scriptmainmenupromos.cpp index ecb47af7..91bc3002 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 a88478fb..2e877db4 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 21324535..b946f7a9 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()) diff --git a/primedev/scripts/scriptdatatables.cpp b/primedev/scripts/scriptdatatables.cpp index 47c3a0f1..5e685b48 100644 --- a/primedev/scripts/scriptdatatables.cpp +++ b/primedev/scripts/scriptdatatables.cpp @@ -781,6 +781,7 @@ void ConCommand_dump_datatable(const CCommand& args) void ConCommand_dump_datatables(const CCommand& args) { + NOTE_UNUSED(args); // likely not a comprehensive list, might be missing a couple? static const std::vector VANILLA_DATATABLE_PATHS = { "datatable/burn_meter_rewards.rpak", diff --git a/primedev/server/auth/bansystem.cpp b/primedev/server/auth/bansystem.cpp index 59bb6067..20c07844 100644 --- a/primedev/server/auth/bansystem.cpp +++ b/primedev/server/auth/bansystem.cpp @@ -213,6 +213,7 @@ void ConCommand_unban(const CCommand& args) void ConCommand_clearbanlist(const CCommand& args) { + NOTE_UNUSED(args); g_pBanSystem->ClearBanlist(); } diff --git a/primedev/server/auth/serverauthentication.cpp b/primedev/server/auth/serverauthentication.cpp index 7d656820..d0d4c698 100644 --- a/primedev/server/auth/serverauthentication.cpp +++ b/primedev/server/auth/serverauthentication.cpp @@ -333,6 +333,7 @@ void,, (CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...) void ConCommand_ns_resetpersistence(const CCommand& args) { + NOTE_UNUSED(args); if (*g_pServerState == server_state_t::ss_active) { spdlog::error("ns_resetpersistence must be entered from the main menu"); diff --git a/primedev/server/serverpresence.cpp b/primedev/server/serverpresence.cpp index 159b9f30..509243f0 100644 --- a/primedev/server/serverpresence.cpp +++ b/primedev/server/serverpresence.cpp @@ -79,6 +79,9 @@ void ServerPresenceManager::CreateConVars() "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) { + NOTE_UNUSED(cvar); + NOTE_UNUSED(pOldValue); + NOTE_UNUSED(flOldValue); g_pServerPresence->SetName(UnescapeUnicode(g_pServerPresence->Cvar_ns_server_name->GetString())); // update engine hostname cvar @@ -86,10 +89,16 @@ void ServerPresenceManager::CreateConVars() }); 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) { + NOTE_UNUSED(cvar); + NOTE_UNUSED(pOldValue); + NOTE_UNUSED(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) { + NOTE_UNUSED(cvar); + NOTE_UNUSED(pOldValue); + NOTE_UNUSED(flOldValue); g_pServerPresence->SetPassword(g_pServerPresence->Cvar_ns_server_password->GetString()); }); diff --git a/primedev/server/serverpresence.h b/primedev/server/serverpresence.h index c644cc37..94ecfe6a 100644 --- a/primedev/server/serverpresence.h +++ b/primedev/server/serverpresence.h @@ -45,10 +45,10 @@ public: 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 7850f7b0..d96bc41e 100644 --- a/primedev/shared/exploit_fixes/exploitfixes.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes.cpp @@ -55,6 +55,8 @@ 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 // clang-format on { + NOTE_UNUSED(thisptr); + NOTE_UNUSED(buffer); return false; } diff --git a/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp b/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp index ccb6ac18..9a9a5691 100644 --- a/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp @@ -16,6 +16,7 @@ AUTOHOOK(CLZSS__SafeDecompress, engine.dll + 0x432A10, unsigned int, __fastcall, (void* self, const unsigned char* pInput, unsigned char* pOutput, unsigned int unBufSize)) // clang-format on { + NOTE_UNUSED(self); unsigned int totalBytes = 0; int getCmdByte = 0; int cmdByte = 0; diff --git a/primedev/shared/exploit_fixes/ns_limits.cpp b/primedev/shared/exploit_fixes/ns_limits.cpp index bd855ee4..63abbf69 100644 --- a/primedev/shared/exploit_fixes/ns_limits.cpp +++ b/primedev/shared/exploit_fixes/ns_limits.cpp @@ -16,6 +16,7 @@ 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) { + NOTE_UNUSED(flCurrentTime); if (Cvar_sv_antispeedhack_enable->GetBool()) { // for each player, set their usercmd processing budget for the frame to the last frametime for the server diff --git a/primedev/shared/misccommands.cpp b/primedev/shared/misccommands.cpp index 648525b9..29d92d2d 100644 --- a/primedev/shared/misccommands.cpp +++ b/primedev/shared/misccommands.cpp @@ -21,6 +21,7 @@ void ConCommand_force_newgame(const CCommand& arg) void ConCommand_ns_start_reauth_and_leave_to_lobby(const CCommand& arg) { + NOTE_UNUSED(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); @@ -28,6 +29,7 @@ void ConCommand_ns_start_reauth_and_leave_to_lobby(const CCommand& arg) void ConCommand_ns_end_reauth_and_leave_to_lobby(const CCommand& arg) { + NOTE_UNUSED(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 259d0f43..41a6a782 100644 --- a/primedev/squirrel/squirrel.cpp +++ b/primedev/squirrel/squirrel.cpp @@ -316,6 +316,7 @@ template void SquirrelManager::AddFuncOverride( // hooks bool IsUIVM(ScriptContext context, HSquirrelVM* pSqvm) { + NOTE_UNUSED(context); return ScriptContext(pSqvm->sharedState->cSquirrelVM->vmContext) == ScriptContext::UI; } @@ -334,6 +335,8 @@ 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); diff --git a/primedev/util/printcommands.cpp b/primedev/util/printcommands.cpp index 20ebfffc..03ccce5e 100644 --- a/primedev/util/printcommands.cpp +++ b/primedev/util/printcommands.cpp @@ -188,6 +188,7 @@ void ConCommand_findflags(const CCommand& arg) void ConCommand_list(const CCommand& arg) { + NOTE_UNUSED(arg); ConCommandBase* var; CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator(); std::map sorted; @@ -210,6 +211,7 @@ void ConCommand_list(const CCommand& arg) void ConCommand_differences(const CCommand& arg) { + NOTE_UNUSED(arg); CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator(); std::map sorted; -- cgit v1.2.3