From f2e670bd32fc291dbb6a4b45c08cb8f2d94a6bc8 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Fri, 2 Sep 2022 00:38:07 +0200 Subject: [PATCH] Refactor cleanup (some formatting fixes) (#257) * Fix some formatting * More formatting fixes --- NorthstarDLL/bansystem.cpp | 2 +- NorthstarDLL/clientruihooks.cpp | 2 +- NorthstarDLL/convar.h | 2 +- NorthstarDLL/cvar.h | 2 +- NorthstarDLL/dedicated.cpp | 5 +- NorthstarDLL/dllmain.cpp | 2 +- NorthstarDLL/exploitfixes.cpp | 2 +- NorthstarDLL/exploitfixes_lzss.cpp | 2 +- NorthstarDLL/hooks.cpp | 1 - NorthstarDLL/host.cpp | 2 +- NorthstarDLL/hoststate.cpp | 2 +- NorthstarDLL/localchatwriter.cpp | 4 +- NorthstarDLL/masterserver.cpp | 8 ++-- NorthstarDLL/maxplayers.cpp | 2 +- NorthstarDLL/maxplayers.h | 2 +- NorthstarDLL/memory.cpp | 16 +++---- NorthstarDLL/memory.h | 9 ++-- NorthstarDLL/misccommands.cpp | 6 +-- NorthstarDLL/miscserverscript.cpp | 2 +- NorthstarDLL/modmanager.cpp | 3 +- NorthstarDLL/modmanager.h | 2 +- NorthstarDLL/playlist.cpp | 11 ++--- NorthstarDLL/plugins.cpp | 2 +- NorthstarDLL/printcommands.cpp | 11 +++-- NorthstarDLL/printmaps.cpp | 9 ++-- NorthstarDLL/r2client.h | 2 +- NorthstarDLL/r2engine.cpp | 2 +- NorthstarDLL/r2server.cpp | 2 +- NorthstarDLL/rpakfilesystem.cpp | 8 ++-- NorthstarDLL/rpakfilesystem.h | 2 +- NorthstarDLL/scriptdatatables.cpp | 68 ++++++++++++--------------- NorthstarDLL/scriptjson.cpp | 2 - NorthstarDLL/scriptmodmenu.cpp | 3 +- NorthstarDLL/scriptserverbrowser.cpp | 28 +++++------ NorthstarDLL/scriptutility.cpp | 2 +- NorthstarDLL/serverauthentication.cpp | 14 +++--- NorthstarDLL/serverpresence.cpp | 8 ++-- NorthstarDLL/squirrel.cpp | 64 ++++++++++--------------- NorthstarDLL/squirrel.h | 2 +- NorthstarLauncher/main.cpp | 12 +++-- 40 files changed, 150 insertions(+), 180 deletions(-) diff --git a/NorthstarDLL/bansystem.cpp b/NorthstarDLL/bansystem.cpp index 922077d5b..25c0e6bff 100644 --- a/NorthstarDLL/bansystem.cpp +++ b/NorthstarDLL/bansystem.cpp @@ -100,7 +100,7 @@ void ServerBanSystem::UnbanUID(uint64_t uid) return; m_vBannedUids.erase(findResult); - + std::vector banlistText; std::ifstream fs_readBanlist(GetNorthstarPrefix() + "/banlist.txt"); diff --git a/NorthstarDLL/clientruihooks.cpp b/NorthstarDLL/clientruihooks.cpp index 080957c92..9d6562d24 100644 --- a/NorthstarDLL/clientruihooks.cpp +++ b/NorthstarDLL/clientruihooks.cpp @@ -10,7 +10,7 @@ bool,, (void* a1, float* a2)) { if (!Cvar_rui_drawEnable->GetBool()) return 0; - + return DrawRUIFunc(a1, a2); } diff --git a/NorthstarDLL/convar.h b/NorthstarDLL/convar.h index e7fb5397f..5a9aa4ebf 100644 --- a/NorthstarDLL/convar.h +++ b/NorthstarDLL/convar.h @@ -107,7 +107,7 @@ const std::multimap g_PrintCommandFlags = { {FCVAR_ARCHIVE_PLAYERPROFILE, "ARCHIVE_PLAYERPROFILE"}, {FCVAR_SERVER_CAN_EXECUTE, "SERVER_CAN_EXECUTE"}, {FCVAR_SERVER_CANNOT_QUERY, "SERVER_CANNOT_QUERY"}, - {FCVAR_CLIENTCMD_CAN_EXECUTE, "UNKNOWN"}, + {FCVAR_CLIENTCMD_CAN_EXECUTE, "UNKNOWN"}, {FCVAR_ACCESSIBLE_FROM_THREADS, "ACCESSIBLE_FROM_THREADS"} }; diff --git a/NorthstarDLL/cvar.h b/NorthstarDLL/cvar.h index ead30d3eb..e65e5145e 100644 --- a/NorthstarDLL/cvar.h +++ b/NorthstarDLL/cvar.h @@ -36,7 +36,7 @@ class CCvar }; // use the R2 namespace for game funcs -namespace R2 +namespace R2 { extern SourceInterface* g_pCVarInterface; extern CCvar* g_pCVar; diff --git a/NorthstarDLL/dedicated.cpp b/NorthstarDLL/dedicated.cpp index d8e2992ed..42af9456b 100644 --- a/NorthstarDLL/dedicated.cpp +++ b/NorthstarDLL/dedicated.cpp @@ -144,7 +144,6 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul // 00 => 01 base.Offset(7).Patch("01"); } - // Some init that i'm not sure of that crashes // nop the call to it @@ -198,7 +197,6 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul // nop call to ShowWindow module.Offset(0x1CD146).NOP(5); - CDedicatedExports* dedicatedExports = new CDedicatedExports; dedicatedExports->vtable = dedicatedExports; dedicatedExports->Sys_Printf = Sys_Printf; @@ -222,7 +220,7 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul Tier0::CommandLine()->AppendParm("-nomessagebox", 0); Tier0::CommandLine()->AppendParm("+host_preload_shaders", "0"); Tier0::CommandLine()->AppendParm("+net_usesocketsforloopback", "1"); - + // use presence reporter for console title DedicatedConsoleServerPresence* presenceReporter = new DedicatedConsoleServerPresence; g_pServerPresence->AddPresenceReporter(presenceReporter); @@ -285,6 +283,5 @@ ON_DLL_LOAD_DEDI("server.dll", DedicatedServerGameDLL, (CModule module)) module.Offset(0x6BA300).Patch( "B8 C8 00 00 00 C3"); // return 200 as the number of skins from server.dll + 6BA300, this is the normal value read from // skins.rson and should be updated when we need it more modular - } } diff --git a/NorthstarDLL/dllmain.cpp b/NorthstarDLL/dllmain.cpp index aa808bf5b..600fb339d 100644 --- a/NorthstarDLL/dllmain.cpp +++ b/NorthstarDLL/dllmain.cpp @@ -18,7 +18,7 @@ #include namespace fs = std::filesystem; - typedef void (*initPluginFuncPtr)(void* (*getPluginObject)(PluginObject)); +typedef void (*initPluginFuncPtr)(void* (*getPluginObject)(PluginObject)); BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { diff --git a/NorthstarDLL/exploitfixes.cpp b/NorthstarDLL/exploitfixes.cpp index 4ce9f3519..3a9a504fc 100644 --- a/NorthstarDLL/exploitfixes.cpp +++ b/NorthstarDLL/exploitfixes.cpp @@ -397,7 +397,7 @@ ON_DLL_LOAD("engine.dll", EngineExploitFixes, (CModule module)) { AUTOHOOK_DISPATCH_MODULE(engine.dll) - CCommand__Tokenize = module.Offset(0x418380).As(); + CCommand__Tokenize = module.Offset(0x418380).As(); // allow client/ui to run clientcommands despite restricting servercommands module.Offset(0x4FB65).Patch("EB 11"); diff --git a/NorthstarDLL/exploitfixes_lzss.cpp b/NorthstarDLL/exploitfixes_lzss.cpp index cc95246f8..87d2868de 100644 --- a/NorthstarDLL/exploitfixes_lzss.cpp +++ b/NorthstarDLL/exploitfixes_lzss.cpp @@ -30,7 +30,7 @@ unsigned int,, (void* self, const unsigned char* pInput, unsigned char* pOutput, { if (!getCmdByte) cmdByte = *pInput++; - + getCmdByte = (getCmdByte + 1) & 0x07; if (cmdByte & 0x01) diff --git a/NorthstarDLL/hooks.cpp b/NorthstarDLL/hooks.cpp index ce4bbcec7..08050be60 100644 --- a/NorthstarDLL/hooks.cpp +++ b/NorthstarDLL/hooks.cpp @@ -276,7 +276,6 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress) } } - if (bShouldContinue) continue; diff --git a/NorthstarDLL/host.cpp b/NorthstarDLL/host.cpp index dc09cf48d..74dad7854 100644 --- a/NorthstarDLL/host.cpp +++ b/NorthstarDLL/host.cpp @@ -66,6 +66,6 @@ void,, (bool bDedicated)) } ON_DLL_LOAD("engine.dll", Host_Init, (CModule module)) -{ +{ AUTOHOOK_DISPATCH() } diff --git a/NorthstarDLL/hoststate.cpp b/NorthstarDLL/hoststate.cpp index c0d6b3b9a..6008a0f2f 100644 --- a/NorthstarDLL/hoststate.cpp +++ b/NorthstarDLL/hoststate.cpp @@ -19,7 +19,7 @@ namespace R2 ConVar* Cvar_hostport; -void ServerStartingOrChangingMap() +void ServerStartingOrChangingMap() { // net_data_block_enabled is required for sp, force it if we're on an sp map // sucks for security but just how it be diff --git a/NorthstarDLL/localchatwriter.cpp b/NorthstarDLL/localchatwriter.cpp index 14f369998..2c661feb2 100644 --- a/NorthstarDLL/localchatwriter.cpp +++ b/NorthstarDLL/localchatwriter.cpp @@ -41,8 +41,7 @@ class vgui_BaseRichText_vtable void(__fastcall* InsertIndentChange)(vgui_BaseRichText* self, int pixelsIndent); void(__fastcall* InsertClickableTextStart)(vgui_BaseRichText* self, const char* pchClickAction); void(__fastcall* InsertClickableTextEnd)(vgui_BaseRichText* self); - void(__fastcall* InsertPossibleURLString)( - vgui_BaseRichText* self, const char* text, Color URLTextColor, Color normalTextColor); + void(__fastcall* InsertPossibleURLString)(vgui_BaseRichText* self, const char* text, Color URLTextColor, Color normalTextColor); void(__fastcall* InsertFade)(vgui_BaseRichText* self, float flSustain, float flLength); void(__fastcall* ResetAllFades)(vgui_BaseRichText* self, bool bHold, bool bOnlyExpired, float flNewSustain); void(__fastcall* SetToFullHeight)(vgui_BaseRichText* self); @@ -374,7 +373,6 @@ static Color GetHudSwatchColor(CHudChat* hud, LocalChatWriter::SwatchColor swatc case LocalChatWriter::NetworkNameColor: return hud->m_networkNameColor; - } return Color(0, 0, 0, 0); diff --git a/NorthstarDLL/masterserver.cpp b/NorthstarDLL/masterserver.cpp index 04656b332..ef23c919d 100644 --- a/NorthstarDLL/masterserver.cpp +++ b/NorthstarDLL/masterserver.cpp @@ -40,8 +40,8 @@ RemoteServerInfo::RemoteServerInfo( description = std::string(newDescription); - strncpy_s((char*)map, sizeof(map) , newMap, sizeof(map) - 1); - strncpy_s((char*)playlist, sizeof(playlist) , newPlaylist, sizeof(playlist) - 1); + strncpy_s((char*)map, sizeof(map), newMap, sizeof(map) - 1); + strncpy_s((char*)playlist, sizeof(playlist), newPlaylist, sizeof(playlist) - 1); playerCount = newPlayerCount; maxPlayers = newMaxPlayers; @@ -755,7 +755,7 @@ class MasterServerPresenceReporter : public ServerPresenceReporter double m_bShouldTryRegisterServer; int m_nNumRegistrationAttempts; - void CreatePresence(const ServerPresence* pServerPresence) override + void CreatePresence(const ServerPresence* pServerPresence) override { m_bShouldTryRegisterServer = true; m_nNumRegistrationAttempts = 0; @@ -764,7 +764,7 @@ class MasterServerPresenceReporter : public ServerPresenceReporter void ReportPresence(const ServerPresence* pServerPresence) override { // make a copy of presence for multithreading purposes - + ServerPresence threadedPresence(pServerPresence); if (!*g_pMasterServerManager->m_sOwnServerId || m_bShouldTryRegisterServer) diff --git a/NorthstarDLL/maxplayers.cpp b/NorthstarDLL/maxplayers.cpp index ba165beea..bc7fce320 100644 --- a/NorthstarDLL/maxplayers.cpp +++ b/NorthstarDLL/maxplayers.cpp @@ -56,7 +56,7 @@ bool MaxPlayersIncreaseEnabled() // should we use R2 for this? not sure namespace R2 // use R2 namespace for game funcs { - int GetMaxPlayers() + int GetMaxPlayers() { if (MaxPlayersIncreaseEnabled()) return NEW_MAX_PLAYERS; diff --git a/NorthstarDLL/maxplayers.h b/NorthstarDLL/maxplayers.h index 9c104f5c2..b251f6a68 100644 --- a/NorthstarDLL/maxplayers.h +++ b/NorthstarDLL/maxplayers.h @@ -1,6 +1,6 @@ #pragma once -// should we use R2 for this? not sure +// should we use R2 for this? not sure namespace R2 // use R2 namespace for game funcs { int GetMaxPlayers(); diff --git a/NorthstarDLL/memory.cpp b/NorthstarDLL/memory.cpp index d93b736e5..8b7694bd4 100644 --- a/NorthstarDLL/memory.cpp +++ b/NorthstarDLL/memory.cpp @@ -11,7 +11,7 @@ MemoryAddress::operator uintptr_t() const return m_nAddress; } -MemoryAddress::operator void* () const +MemoryAddress::operator void*() const { return reinterpret_cast(m_nAddress); } @@ -41,12 +41,12 @@ bool MemoryAddress::operator!=(const uintptr_t& addr) const return m_nAddress != addr; } -MemoryAddress MemoryAddress::operator+(const MemoryAddress& other) const +MemoryAddress MemoryAddress::operator+(const MemoryAddress& other) const { return Offset(other.m_nAddress); } -MemoryAddress MemoryAddress::operator-(const MemoryAddress& other) const +MemoryAddress MemoryAddress::operator-(const MemoryAddress& other) const { return MemoryAddress(m_nAddress - other.m_nAddress); } @@ -110,7 +110,7 @@ inline std::vector HexBytesToString(const char* pHexString) // If this is a space character, ignore it if (isspace(pHexString[i])) continue; - + if (i < size - 1) { BYTE result = 0; @@ -159,7 +159,7 @@ void MemoryAddress::NOP(const size_t nSize) memset(pBytes, 0x90, nSize); Patch(pBytes, nSize); - + delete[] pBytes; } @@ -176,9 +176,7 @@ bool MemoryAddress::IsMemoryReadable(const size_t nSize) return memInfo.RegionSize >= nSize && memInfo.State & MEM_COMMIT && !(memInfo.Protect & PAGE_NOACCESS); } - - -CModule::CModule(const HMODULE pModule) +CModule::CModule(const HMODULE pModule) { MODULEINFO mInfo {0}; @@ -343,7 +341,7 @@ inline std::pair, std::string> MaskedBytesFromPattern(const return std::make_pair(vRet, sMask); } -MemoryAddress CModule::FindPattern(const char* pPattern) +MemoryAddress CModule::FindPattern(const char* pPattern) { const auto pattern = MaskedBytesFromPattern(pPattern); return FindPattern(pattern.first.data(), pattern.second.c_str()); diff --git a/NorthstarDLL/memory.h b/NorthstarDLL/memory.h index b69979d05..38c76cb3b 100644 --- a/NorthstarDLL/memory.h +++ b/NorthstarDLL/memory.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once class MemoryAddress { @@ -10,7 +10,7 @@ class MemoryAddress MemoryAddress(const uintptr_t nAddress); MemoryAddress(const void* pAddress); - //operators + // operators operator uintptr_t() const; operator void*() const; operator bool() const; @@ -26,7 +26,10 @@ class MemoryAddress MemoryAddress operator-(const uintptr_t& other) const; MemoryAddress operator*() const; - template T As() { return reinterpret_cast(m_nAddress); } + template T As() + { + return reinterpret_cast(m_nAddress); + } // traversal MemoryAddress Offset(const uintptr_t nOffset) const; diff --git a/NorthstarDLL/misccommands.cpp b/NorthstarDLL/misccommands.cpp index c61f13ecd..e745752fc 100644 --- a/NorthstarDLL/misccommands.cpp +++ b/NorthstarDLL/misccommands.cpp @@ -9,7 +9,7 @@ #include "serverauthentication.h" #include "squirrel.h" -void ConCommand_force_newgame(const CCommand& arg) +void ConCommand_force_newgame(const CCommand& arg) { if (arg.ArgC() < 2) return; @@ -18,14 +18,14 @@ void ConCommand_force_newgame(const CCommand& arg) strncpy(R2::g_pHostState->m_levelName, arg.Arg(1), sizeof(R2::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(R2::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) { R2::Cbuf_AddText( R2::Cbuf_GetCurrentPlayer(), diff --git a/NorthstarDLL/miscserverscript.cpp b/NorthstarDLL/miscserverscript.cpp index 5089d9e80..3b30dd236 100644 --- a/NorthstarDLL/miscserverscript.cpp +++ b/NorthstarDLL/miscserverscript.cpp @@ -2,7 +2,7 @@ #include "squirrel.h" #include "masterserver.h" #include "serverauthentication.h" -#include "dedicated.h" +#include "dedicated.h" #include "r2client.h" #include "r2server.h" diff --git a/NorthstarDLL/modmanager.cpp b/NorthstarDLL/modmanager.cpp index 8ba883a3d..c9dfcdbb0 100644 --- a/NorthstarDLL/modmanager.cpp +++ b/NorthstarDLL/modmanager.cpp @@ -320,7 +320,6 @@ void ModManager::LoadMods() Mod mod(modDir, (char*)jsonStringStream.str().c_str()); - for (auto& pair : mod.DependencyConstants) { if (m_DependencyConstants.find(pair.first) != m_DependencyConstants.end() && m_DependencyConstants[pair.first] != pair.second) @@ -366,7 +365,7 @@ void ModManager::LoadMods() // causes us to leak memory on reload, but not much, potentially find a way to not do this at some point for (ModConVar* convar : mod.ConVars) if (!R2::g_pCVar->FindVar(convar->Name.c_str())) // make sure convar isn't registered yet, unsure if necessary but idk what - // behaviour is for defining same convar multiple times + // behaviour is for defining same convar multiple times new ConVar(convar->Name.c_str(), convar->DefaultValue.c_str(), convar->Flags, convar->HelpString.c_str()); // read vpk paths diff --git a/NorthstarDLL/modmanager.h b/NorthstarDLL/modmanager.h index 336ef8044..621df76fe 100644 --- a/NorthstarDLL/modmanager.h +++ b/NorthstarDLL/modmanager.h @@ -103,7 +103,7 @@ class Mod std::unordered_map RpakAliases; // paks we alias to other rpaks, e.g. to load sp_crashsite paks on the map mp_crashsite - std::unordered_map DependencyConstants; + std::unordered_map DependencyConstants; public: Mod(fs::path modPath, char* jsonBuf); diff --git a/NorthstarDLL/playlist.cpp b/NorthstarDLL/playlist.cpp index 87847fc14..7cf9e41ea 100644 --- a/NorthstarDLL/playlist.cpp +++ b/NorthstarDLL/playlist.cpp @@ -33,7 +33,7 @@ AUTOHOOK(SetCurrentPlaylist, engine.dll + 0x18EB20, bool, __fastcall, (const char* pPlaylistName)) { bool bSuccess = SetCurrentPlaylist(pPlaylistName); - + if (bSuccess) { spdlog::info("Set playlist to {}", R2::GetCurrentPlaylistName()); @@ -72,7 +72,6 @@ int,, ()) return iMaxPlayers; } - void ConCommand_playlist(const CCommand& args) { if (args.ArgC() < 2) @@ -94,10 +93,10 @@ ON_DLL_LOAD_RELIESON("engine.dll", PlaylistHooks, (ConCommand, ConVar), (CModule { AUTOHOOK_DISPATCH() - R2::GetCurrentPlaylistName = module.Offset(0x18C640).As(); - R2::SetCurrentPlaylist = module.Offset(0x18EB20).As (); - R2::SetPlaylistVarOverride = module.Offset(0x18ED00).As(); - R2::GetCurrentPlaylistVar = module.Offset(0x18C680).As(); + R2::GetCurrentPlaylistName = module.Offset(0x18C640).As(); + R2::SetCurrentPlaylist = module.Offset(0x18EB20).As(); + R2::SetPlaylistVarOverride = module.Offset(0x18ED00).As(); + R2::GetCurrentPlaylistVar = module.Offset(0x18C680).As(); // playlist is the name of the command on respawn servers, but we already use setplaylist so can't get rid of it RegisterConCommand("playlist", ConCommand_playlist, "Sets the current playlist", FCVAR_NONE); diff --git a/NorthstarDLL/plugins.cpp b/NorthstarDLL/plugins.cpp index e6089f3bf..790439d1d 100644 --- a/NorthstarDLL/plugins.cpp +++ b/NorthstarDLL/plugins.cpp @@ -195,7 +195,7 @@ SQRESULT SQ_UpdateListenServer(HSquirrelVM* sqvm) { AcquireSRWLockExclusive(&serverInfoLock); serverInfo.id = g_pMasterServerManager->m_sOwnServerId; - serverInfo.password = "";// g_pServerPresence->Cvar_ns_server_password->GetString(); todo this fr + serverInfo.password = ""; // g_pServerPresence->Cvar_ns_server_password->GetString(); todo this fr ReleaseSRWLockExclusive(&serverInfoLock); return SQRESULT_NOTNULL; } diff --git a/NorthstarDLL/printcommands.cpp b/NorthstarDLL/printcommands.cpp index 605f7dceb..90af15751 100644 --- a/NorthstarDLL/printcommands.cpp +++ b/NorthstarDLL/printcommands.cpp @@ -24,14 +24,15 @@ void PrintCommandHelpDialogue(const ConCommandBase* command, const char* name) { if (command->GetFlags() & flagPair.first) { - // special case, slightly hacky: PRINTABLEONLY is for commands, GAMEDLL_FOR_REMOTE_CLIENTS is for concommands, both have the same value + // special case, slightly hacky: PRINTABLEONLY is for commands, GAMEDLL_FOR_REMOTE_CLIENTS is for concommands, both have the + // same value if (flagPair.first == FCVAR_PRINTABLEONLY) { if (cvar && !strcmp(flagPair.second, "GAMEDLL_FOR_REMOTE_CLIENTS")) continue; if (!cvar && !strcmp(flagPair.second, "PRINTABLEONLY")) - continue; + continue; } flagString += flagPair.second; @@ -121,7 +122,7 @@ void ConCommand_find(const CCommand& arg) } } -void ConCommand_findflags(const CCommand& arg) +void ConCommand_findflags(const CCommand& arg) { if (arg.ArgC() < 2) { @@ -146,7 +147,7 @@ void ConCommand_findflags(const CCommand& arg) if (!strcmp(flagPair.second, upperFlag)) { resolvedFlag |= flagPair.first; - break; + break; } } @@ -160,7 +161,7 @@ void ConCommand_findflags(const CCommand& arg) delete[] upperFlag; } -void InitialiseCommandPrint() +void InitialiseCommandPrint() { RegisterConCommand("find", ConCommand_find, "Find concommands with the specified string in their name/help text.", FCVAR_NONE); RegisterConCommand("findflags", ConCommand_findflags, "Find concommands by flags.", FCVAR_NONE); diff --git a/NorthstarDLL/printmaps.cpp b/NorthstarDLL/printmaps.cpp index 7a12b1fe8..82ba8d5ec 100644 --- a/NorthstarDLL/printmaps.cpp +++ b/NorthstarDLL/printmaps.cpp @@ -19,9 +19,9 @@ enum class MapSource_t }; const std::unordered_map PrintMapSource = { - {MapSource_t::VPK, "VPK"}, + {MapSource_t::VPK, "VPK"}, {MapSource_t::MOD, "MOD"}, - {MapSource_t::GAMEDIR, "R2"} + {MapSource_t::GAMEDIR, "R2"} }; struct MapVPKInfo @@ -34,7 +34,7 @@ struct MapVPKInfo // our current list of maps in the game std::vector vMapList; -void RefreshMapList() +void RefreshMapList() { vMapList.clear(); @@ -144,8 +144,7 @@ int, __fastcall, (const char const* cmdname, const char const* partial, char com return numMaps; } - -void ConCommand_maps(const CCommand& args) +void ConCommand_maps(const CCommand& args) { if (args.ArgC() < 2) { diff --git a/NorthstarDLL/r2client.h b/NorthstarDLL/r2client.h index 48ac049aa..64ed6c616 100644 --- a/NorthstarDLL/r2client.h +++ b/NorthstarDLL/r2client.h @@ -5,7 +5,7 @@ namespace R2 { extern char* g_pLocalPlayerUserID; extern char* g_pLocalPlayerOriginToken; - + typedef void* (*GetBaseLocalClientType)(); extern GetBaseLocalClientType GetBaseLocalClient; } // namespace R2 diff --git a/NorthstarDLL/r2engine.cpp b/NorthstarDLL/r2engine.cpp index 5a5568c14..4807a1742 100644 --- a/NorthstarDLL/r2engine.cpp +++ b/NorthstarDLL/r2engine.cpp @@ -28,7 +28,7 @@ ON_DLL_LOAD("engine.dll", R2Engine, (CModule module)) g_pEngine = module.Offset(0x7D70C8).Deref().As(); // new - CBaseClient__Disconnect = module.Offset(0x1012C0).As(); + CBaseClient__Disconnect = module.Offset(0x1012C0).As(); g_pClientArray = module.Offset(0x12A53F90).As(); g_pServerState = module.Offset(0x12A53D48).As(); diff --git a/NorthstarDLL/r2server.cpp b/NorthstarDLL/r2server.cpp index 7144f93c8..50cfa2393 100644 --- a/NorthstarDLL/r2server.cpp +++ b/NorthstarDLL/r2server.cpp @@ -12,6 +12,6 @@ namespace R2 ON_DLL_LOAD("server.dll", R2GameServer, (CModule module)) { - Server_GetEntityByIndex = module.Offset(0xFB820).As(); + Server_GetEntityByIndex = module.Offset(0xFB820).As(); UTIL_PlayerByIndex = module.Offset(0x26AA10).As(); } diff --git a/NorthstarDLL/rpakfilesystem.cpp b/NorthstarDLL/rpakfilesystem.cpp index 895cfd79a..d5cff26c0 100644 --- a/NorthstarDLL/rpakfilesystem.cpp +++ b/NorthstarDLL/rpakfilesystem.cpp @@ -14,7 +14,7 @@ struct PakLoadFuncs void* unk1[2]; void* (*UnloadPak)(int iPakHandle, void* callback); void* unk2[6]; - void* (*LoadFile)(const char* path);//unsure + void* (*LoadFile)(const char* path); // unsure void* unk3[10]; void* (*ReadFileAsync)(const char* pPath, void* a2); }; @@ -173,8 +173,7 @@ void LoadCustomMapPaks(char** pakName, bool* bNeedToFreePakName) } } -HOOK(LoadPakAsyncHook, LoadPakAsync, -int,, (char* pPath, void* unknownSingleton, int flags, void* pCallback0, void* pCallback1)) +HOOK(LoadPakAsyncHook, LoadPakAsync, int, , (char* pPath, void* unknownSingleton, int flags, void* pCallback0, void* pCallback1)) { HandlePakAliases(&pPath); @@ -207,7 +206,7 @@ int,, (char* pPath, void* unknownSingleton, int flags, void* pCallback0, void* p delete[] pPath; spdlog::info("Not loading pak {} for dedicated server", originalPath); - return -1; + return -1; } } @@ -273,7 +272,6 @@ void*, , (const char* pPath, void* pCallback)) return ret; } - ON_DLL_LOAD("engine.dll", RpakFilesystem, (CModule module)) { AUTOHOOK_DISPATCH(); diff --git a/NorthstarDLL/rpakfilesystem.h b/NorthstarDLL/rpakfilesystem.h index 888116862..3f608dba8 100644 --- a/NorthstarDLL/rpakfilesystem.h +++ b/NorthstarDLL/rpakfilesystem.h @@ -25,7 +25,7 @@ class PakLoadManager int LoadPakAsync(const char* pPath, const ePakLoadSource nLoadSource); void UnloadPak(const int nPakHandle); void UnloadMapPaks(); - void* LoadFile(const char* path); //this is a guess + void* LoadFile(const char* path); // this is a guess LoadedPak* TrackLoadedPak(ePakLoadSource nLoadSource, int nPakHandle, size_t nPakNameHash); void RemoveLoadedPak(int nPakHandle); diff --git a/NorthstarDLL/scriptdatatables.cpp b/NorthstarDLL/scriptdatatables.cpp index 053933bd4..40bb6a397 100644 --- a/NorthstarDLL/scriptdatatables.cpp +++ b/NorthstarDLL/scriptdatatables.cpp @@ -80,9 +80,9 @@ template SQRESULT GetDatatable(HSquirrelVM* sqvm) { spdlog::error("Asset \"{}\" doesn't start with \"datatable/\"", assetName); } - else if ((!Cvar_ns_prefer_datatable_from_disk->GetBool()) && g_pPakLoadManager->LoadFile(assetName) ) + else if ((!Cvar_ns_prefer_datatable_from_disk->GetBool()) && g_pPakLoadManager->LoadFile(assetName)) { - //spdlog::info("Load Datatable {} from rpak", assetName); + // spdlog::info("Load Datatable {} from rpak", assetName); result = g_pSquirrel->m_funcOriginals["GetDataTable"](sqvm); } else @@ -91,7 +91,7 @@ template SQRESULT GetDatatable(HSquirrelVM* sqvm) snprintf(assetPath, 250, "scripts/%s", assetName); if (cacheMap.count(assetName)) { - //spdlog::info("Loaded custom Datatable {} from cache", assetName); + // spdlog::info("Loaded custom Datatable {} from cache", assetName); csvData** dataPointer = (csvData**)g_pSquirrel->createuserdata(sqvm, sizeof(csvData*)); *dataPointer = cacheMap[assetName]; g_pSquirrel->setuserdatatypeid(sqvm, -1, customDatatableTypeId); @@ -217,11 +217,11 @@ template SQRESULT GetDatatable(HSquirrelVM* sqvm) *dataPointer = data; // vm->_stack[vm->_top -1]._VAL.asUserdata->releaseHook = datatableReleaseHook; cacheMap[assetName] = data; - //spdlog::info("Loaded custom Datatable from file at {} with pointer {}", assetPath, (void*)data); + // spdlog::info("Loaded custom Datatable from file at {} with pointer {}", assetPath, (void*)data); result = SQRESULT_NOTNULL; } - else if (Cvar_ns_prefer_datatable_from_disk->GetBool()&&g_pPakLoadManager->LoadFile(assetName)) + else if (Cvar_ns_prefer_datatable_from_disk->GetBool() && g_pPakLoadManager->LoadFile(assetName)) { result = g_pSquirrel->m_funcOriginals["GetDataTable"](sqvm); } @@ -235,7 +235,7 @@ template SQRESULT GetDatatable(HSquirrelVM* sqvm) template SQRESULT GetDatatabeColumnByName(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableColumnByName"); + // spdlog::info("start getDatatableColumnByName"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -249,7 +249,7 @@ template SQRESULT GetDatatabeColumnByName(HSquirrelVM* s { return SQRESULT_ERROR; } - //spdlog::info("GetColumnByName form datatable with pointer {}",(void*)data); + // spdlog::info("GetColumnByName form datatable with pointer {}",(void*)data); const char* searchName = g_pSquirrel->getstring(sqvm, 2); int col = 0; for (auto colName : data->columnNames) @@ -261,14 +261,14 @@ template SQRESULT GetDatatabeColumnByName(HSquirrelVM* s } if (col == data->columnNames.size()) col = -1; - //spdlog::info("Datatable CoulumnName {} in column {}", std::string(searchName), col); + // spdlog::info("Datatable CoulumnName {} in column {}", std::string(searchName), col); g_pSquirrel->pushinteger(sqvm, col); return SQRESULT_NOTNULL; } template SQRESULT GetDatatabeRowCount(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableRowCount"); + // spdlog::info("start getDatatableRowCount"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -289,7 +289,7 @@ template SQRESULT GetDatatabeRowCount(HSquirrelVM* sqvm) template SQRESULT GetDataTableString(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableString"); + // spdlog::info("start getDatatableString"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -307,7 +307,7 @@ template SQRESULT GetDataTableString(HSquirrelVM* sqvm) int col = g_pSquirrel->getinteger(sqvm, 3); if (row >= data->dataPointers.size() || col >= data->dataPointers[row].size()) { - spdlog::info( "row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); + spdlog::info("row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); return SQRESULT_ERROR; } @@ -317,7 +317,7 @@ template SQRESULT GetDataTableString(HSquirrelVM* sqvm) template SQRESULT GetDataTableAsset(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableAsset"); + // spdlog::info("start getDatatableAsset"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -335,7 +335,7 @@ template SQRESULT GetDataTableAsset(HSquirrelVM* sqvm) int col = g_pSquirrel->getinteger(sqvm, 3); if (row >= data->dataPointers.size() || col >= data->dataPointers[row].size()) { - spdlog::info( "row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); + spdlog::info("row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); return SQRESULT_ERROR; } char* asset = data->dataPointers[row][col]; @@ -362,7 +362,7 @@ template SQRESULT GetDataTableInt(HSquirrelVM* sqvm) int col = g_pSquirrel->getinteger(sqvm, 3); if (row >= data->dataPointers.size() || col >= data->dataPointers[row].size()) { - spdlog::info( "row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); + spdlog::info("row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); return SQRESULT_ERROR; } g_pSquirrel->pushinteger(sqvm, std::stoi(data->dataPointers[row][col])); @@ -371,7 +371,7 @@ template SQRESULT GetDataTableInt(HSquirrelVM* sqvm) template SQRESULT GetDataTableFloat(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableFloat"); + // spdlog::info("start getDatatableFloat"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -389,7 +389,7 @@ template SQRESULT GetDataTableFloat(HSquirrelVM* sqvm) int col = g_pSquirrel->getinteger(sqvm, 3); if (row >= data->dataPointers.size() || col >= data->dataPointers[row].size()) { - spdlog::info( "row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); + spdlog::info("row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); return SQRESULT_ERROR; } g_pSquirrel->pushfloat(sqvm, std::stof(data->dataPointers[row][col])); @@ -398,7 +398,7 @@ template SQRESULT GetDataTableFloat(HSquirrelVM* sqvm) template SQRESULT GetDataTableBool(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableBool"); + // spdlog::info("start getDatatableBool"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -416,7 +416,7 @@ template SQRESULT GetDataTableBool(HSquirrelVM* sqvm) int col = g_pSquirrel->getinteger(sqvm, 3); if (row >= data->dataPointers.size() || col >= data->dataPointers[row].size()) { - spdlog::info( "row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); + spdlog::info("row {} and col {} are outside of range row {} and col {}", row, col, data->dataPointers.size(), data->columnNames.size()); return SQRESULT_ERROR; } g_pSquirrel->pushbool(sqvm, std::stoi(data->dataPointers[row][col])); @@ -425,7 +425,7 @@ template SQRESULT GetDataTableBool(HSquirrelVM* sqvm) template SQRESULT GetDataTableVector(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableVector"); + // spdlog::info("start getDatatableVector"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -489,7 +489,7 @@ template SQRESULT GetDataTableRowMatchingStringValue(HSq template SQRESULT GetDataTableRowMatchingAssetValue(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableRowMatchingAsset"); + // spdlog::info("start getDatatableRowMatchingAsset"); csvData** dataPointer; long long typeId; g_pSquirrel->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -733,8 +733,8 @@ template SQRESULT GetDataTableRowMatchingVectorValue(HSq for (int i = 0; i < data->dataPointers.size(); i++) { - float dataTableVector[3]; - StringToVector(data->dataPointers[i][col],dataTableVector); + float dataTableVector[3]; + StringToVector(data->dataPointers[i][col], dataTableVector); if ((dataTableVector[0] == compareValue[0]) && (dataTableVector[1] == compareValue[1]) && (dataTableVector[2] == compareValue[2])) { g_pSquirrel->pushinteger(sqvm, i); @@ -755,8 +755,8 @@ template SQRESULT DumpDataTable(HSquirrelVM* sqvm) g_pSquirrel->pushinteger(sqvm, 1); return SQRESULT_NOTNULL; } - //spdlog::info("Datatable size row = {} col = {}", datatable->rowAmount, datatable->columnAmount); - // std::string header = std::string(datatable->columnInfo[0].name); + // spdlog::info("Datatable size row = {} col = {}", datatable->rowAmount, datatable->columnAmount); + // std::string header = std::string(datatable->columnInfo[0].name); spdlog::info(DataTableToString(datatable)); @@ -772,7 +772,7 @@ template SQRESULT DumpDataTableToFile(HSquirrelVM* sqvm) g_pSquirrel->pushinteger(sqvm, 1); return SQRESULT_NOTNULL; } - //spdlog::info("Datatable size row = {} col = {}", datatable->rowAmount, datatable->columnAmount); + // spdlog::info("Datatable size row = {} col = {}", datatable->rowAmount, datatable->columnAmount); // std::string header = std::string(datatable->columnInfo[0].name); const char* pathName = g_pSquirrel->getstring(sqvm, 2); std::ofstream ofs(pathName); @@ -861,8 +861,7 @@ void datatableReleaseHook(void* d, int size) delete data; } - -template void RegisterDataTableFunctions() +template void RegisterDataTableFunctions() { g_pSquirrel->AddFuncOverride("GetDataTable", GetDatatable); g_pSquirrel->AddFuncOverride("GetDataTableColumnByName", GetDatatabeColumnByName); @@ -876,7 +875,7 @@ template void RegisterDataTableFunctions() g_pSquirrel->AddFuncOverride("GetDataTableRowMatchingStringValue", GetDataTableRowMatchingStringValue); g_pSquirrel->AddFuncOverride("GetDataTableRowMatchingAssetValue", GetDataTableRowMatchingAssetValue); g_pSquirrel->AddFuncOverride("GetDataTableRowMatchingFloatValue", GetDataTableRowMatchingFloatValue); - g_pSquirrel->AddFuncOverride("GetDataTableRowMatchingIntValue", GetDataTableRowMatchingIntValue < context>); + g_pSquirrel->AddFuncOverride("GetDataTableRowMatchingIntValue", GetDataTableRowMatchingIntValue); g_pSquirrel->AddFuncOverride("GetDataTableRowMatchingVectorValue", GetDataTableRowMatchingVectorValue); g_pSquirrel->AddFuncOverride( "GetDataTableRowLessThanOrEqualToFloatValue", GetDataTableRowLessThanOrEqualToFloatValue); @@ -885,8 +884,6 @@ template void RegisterDataTableFunctions() g_pSquirrel->AddFuncOverride("GetDataTableRowLessThanOrEqualToIntValue", GetDataTableRowLessThanOrEqualToIntValue); g_pSquirrel->AddFuncOverride( "GetDataTableRowGreaterThanOrEqualToFloatValue", GetDataTableRowGreaterThanOrEqualToIntValue); - - } ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CModule module)) @@ -894,15 +891,12 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CMod RegisterDataTableFunctions(); g_pSquirrel->AddFuncRegistration( "void", "DumpDataTable", "var", "Dumps rpak datatable contents to console", DumpDataTable); - // g_pSquirrel->AddFuncRegistration( "void", "DumpDataTableToFile", "var,string", "Dumps datatable contents to console", - // DumpDataTableToFile); - - + // g_pSquirrel->AddFuncRegistration( "void", "DumpDataTableToFile", "var,string", "Dumps datatable contents to + // console", DumpDataTableToFile); getDataTableStructure = module.Offset(0x1250f0).As(); } - ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CModule module)) { @@ -910,7 +904,7 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CMod RegisterDataTableFunctions(); } -ON_DLL_LOAD_RELIESON("engine.dll", GeneralScriptDataTables, ConCommand, (CModule module)) +ON_DLL_LOAD_RELIESON("engine.dll", GeneralScriptDataTables, ConCommand, (CModule module)) { Cvar_ns_prefer_datatable_from_disk = new ConVar("ns_prefer_datatable_from_disk", "0", FCVAR_NONE, "whether datatables from disk overwrite rpak datatables"); @@ -918,6 +912,4 @@ ON_DLL_LOAD_RELIESON("engine.dll", GeneralScriptDataTables, ConCommand, (CModule { Cvar_ns_prefer_datatable_from_disk->SetValue(true); } - - } \ No newline at end of file diff --git a/NorthstarDLL/scriptjson.cpp b/NorthstarDLL/scriptjson.cpp index dff5800e7..620745877 100644 --- a/NorthstarDLL/scriptjson.cpp +++ b/NorthstarDLL/scriptjson.cpp @@ -206,7 +206,6 @@ template void EncodeJSONArray( } } - // table function DecodeJSON( string json, bool fatalParseErrors = false ) template SQRESULT SQ_DecodeJSON(HSquirrelVM* sqvm) { @@ -235,7 +234,6 @@ template SQRESULT SQ_DecodeJSON(HSquirrelVM* sqvm) DecodeJsonTable(sqvm, (rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>*)&doc); } - // string function EncodeJSON( table data ) template SQRESULT SQ_EncodeJSON(HSquirrelVM* sqvm) { diff --git a/NorthstarDLL/scriptmodmenu.cpp b/NorthstarDLL/scriptmodmenu.cpp index fcd740242..d2f352856 100644 --- a/NorthstarDLL/scriptmodmenu.cpp +++ b/NorthstarDLL/scriptmodmenu.cpp @@ -176,7 +176,8 @@ SQRESULT SQ_ReloadMods(HSquirrelVM* sqvm) ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ScriptModMenu, ClientSquirrel, (CModule module)) { - g_pSquirrel->AddFuncRegistration("array", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames); + g_pSquirrel->AddFuncRegistration( + "array", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames); g_pSquirrel->AddFuncRegistration( "bool", "NSIsModEnabled", "string modName", "Returns whether a given mod is enabled", SQ_IsModEnabled); g_pSquirrel->AddFuncRegistration( diff --git a/NorthstarDLL/scriptserverbrowser.cpp b/NorthstarDLL/scriptserverbrowser.cpp index bf63e35ab..ba5b17e20 100644 --- a/NorthstarDLL/scriptserverbrowser.cpp +++ b/NorthstarDLL/scriptserverbrowser.cpp @@ -50,7 +50,7 @@ SQRESULT SQ_GetServerName(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get name of server index {} when only {} servers are available", serverIndex, @@ -71,7 +71,7 @@ SQRESULT SQ_GetServerDescription(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get description of server index {} when only {} servers are available", serverIndex, @@ -92,7 +92,7 @@ SQRESULT SQ_GetServerMap(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get map of server index {} when only {} servers are available", serverIndex, @@ -113,7 +113,7 @@ SQRESULT SQ_GetServerPlaylist(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get playlist of server index {} when only {} servers are available", serverIndex, @@ -134,7 +134,7 @@ SQRESULT SQ_GetServerPlayerCount(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get playercount of server index {} when only {} servers are available", serverIndex, @@ -155,7 +155,7 @@ SQRESULT SQ_GetServerMaxPlayerCount(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get max playercount of server index {} when only {} servers are available", serverIndex, @@ -176,7 +176,7 @@ SQRESULT SQ_GetServerID(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get id of server index {} when only {} servers are available", serverIndex, @@ -197,7 +197,7 @@ SQRESULT SQ_ServerRequiresPassword(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get hasPassword of server index {} when only {} servers are available", serverIndex, @@ -218,7 +218,7 @@ SQRESULT SQ_GetServerRequiredModsCount(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get required mods count of server index {} when only {} servers are available", serverIndex, @@ -240,7 +240,7 @@ SQRESULT SQ_GetServerRequiredModName(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get hasPassword of server index {} when only {} servers are available", serverIndex, @@ -252,7 +252,7 @@ SQRESULT SQ_GetServerRequiredModName(HSquirrelVM* sqvm) if (modIndex >= g_pMasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get required mod name of mod index {} when only {} mod are available", modIndex, @@ -274,7 +274,7 @@ SQRESULT SQ_GetServerRequiredModVersion(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get required mod version of server index {} when only {} servers are available", serverIndex, @@ -286,7 +286,7 @@ SQRESULT SQ_GetServerRequiredModVersion(HSquirrelVM* sqvm) if (modIndex >= g_pMasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to get required mod version of mod index {} when only {} mod are available", modIndex, @@ -317,7 +317,7 @@ SQRESULT SQ_TryAuthWithServer(HSquirrelVM* sqvm) if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size()) { g_pSquirrel->raiseerror( - sqvm, + sqvm, fmt::format( "Tried to auth with server index {} when only {} servers are available", serverIndex, diff --git a/NorthstarDLL/scriptutility.cpp b/NorthstarDLL/scriptutility.cpp index db26cf31c..7a1936cf3 100644 --- a/NorthstarDLL/scriptutility.cpp +++ b/NorthstarDLL/scriptutility.cpp @@ -16,7 +16,7 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientSharedScriptUtility, ClientSquir "asset", "StringToAsset", "string assetName", "converts a given string to an asset", SQ_StringToAsset); } -ON_DLL_LOAD_RELIESON("server.dll", ServerSharedScriptUtility, ServerSquirrel, (CModule module)) +ON_DLL_LOAD_RELIESON("server.dll", ServerSharedScriptUtility, ServerSquirrel, (CModule module)) { g_pSquirrel->AddFuncRegistration( "asset", "StringToAsset", "string assetName", "converts a given string to an asset", SQ_StringToAsset); diff --git a/NorthstarDLL/serverauthentication.cpp b/NorthstarDLL/serverauthentication.cpp index e7a7ff001..366a391aa 100644 --- a/NorthstarDLL/serverauthentication.cpp +++ b/NorthstarDLL/serverauthentication.cpp @@ -101,7 +101,7 @@ void ServerAuthenticationManager::StopPlayerAuthServer() m_PlayerAuthServer.stop(); } -void ServerAuthenticationManager::AddPlayerData(R2::CBaseClient* player, const char* pToken) +void ServerAuthenticationManager::AddPlayerData(R2::CBaseClient* player, const char* pToken) { PlayerAuthenticationData additionalData; additionalData.pdataSize = m_RemoteAuthenticationData[pToken].pdataSize; @@ -129,7 +129,7 @@ void ServerAuthenticationManager::VerifyPlayerName(R2::CBaseClient* player, char } } -bool ServerAuthenticationManager::CheckDuplicateAccounts(R2::CBaseClient* player) +bool ServerAuthenticationManager::CheckDuplicateAccounts(R2::CBaseClient* player) { if (m_bAllowDuplicateAccounts) return true; @@ -284,7 +284,7 @@ bool,, (R2::CBaseClient* self, char* name, void* netchan_ptr_arg, char b_fake_pl if (strlen(name) >= 64) // fix for name overflow bug R2::CBaseClient__Disconnect(self, 1, "Invalid name"); - else if (!g_pServerAuthentication->AuthenticatePlayer(self, iNextPlayerUid, pNextPlayerToken) && + else if (!g_pServerAuthentication->AuthenticatePlayer(self, iNextPlayerUid, pNextPlayerToken) && g_pServerAuthentication->m_bRequireClientAuth) R2::CBaseClient__Disconnect(self, 1, "Authentication Failed"); @@ -368,17 +368,17 @@ ON_DLL_LOAD_RELIESON("engine.dll", ServerAuthentication, (ConCommand, ConVar), ( "ns_auth_allow_insecure_write", "0", FCVAR_GAMEDLL, - "Whether the pdata of unauthenticated clients will be written to disk when changed"); + "Whether the pdata of unauthenticated clients will be written to disk when changed"); RegisterConCommand( "ns_resetpersistence", ConCommand_ns_resetpersistence, "resets your pdata when you next enter the lobby", FCVAR_NONE); - + // patch to disable kicking based on incorrect serverfilter in connectclient, since we repurpose it for use as an auth token module.Offset(0x114655).Patch("EB"); - + // patch to disable fairfight marking players as cheaters and kicking them module.Offset(0x101012).Patch("E9 90 00"); - + if (Tier0::CommandLine()->CheckParm("-allowdupeaccounts")) { // patch to allow same of multiple account diff --git a/NorthstarDLL/serverpresence.cpp b/NorthstarDLL/serverpresence.cpp index cfc1c2135..9338cd9c2 100644 --- a/NorthstarDLL/serverpresence.cpp +++ b/NorthstarDLL/serverpresence.cpp @@ -68,7 +68,7 @@ std::string UnescapeUnicode(const std::string& str) return str; else result.append(last_match.suffix()); - + return result; } @@ -79,7 +79,7 @@ ServerPresenceManager::ServerPresenceManager() "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 description", false, 0, false, 0, [](ConVar* cvar, const char* pOldValue, float flOldValue) { - g_pServerPresence->SetName(UnescapeUnicode(g_pServerPresence->Cvar_ns_server_name->GetString())); + 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()); @@ -111,7 +111,7 @@ void ServerPresenceManager::CreatePresence() m_ServerPresence.m_iPlayerCount = 0; // this should actually be 0 at this point, so shouldn't need updating later m_ServerPresence.m_iMaxPlayers = 0; - + memset(m_ServerPresence.m_MapName, 0, sizeof(m_ServerPresence.m_MapName)); memset(m_ServerPresence.m_PlaylistName, 0, sizeof(m_ServerPresence.m_PlaylistName)); m_ServerPresence.m_bIsSingleplayerServer = false; @@ -171,7 +171,7 @@ void ServerPresenceManager::SetAuthPort(const int iAuthPort) m_ServerPresence.m_iAuthPort = iAuthPort; } -void ServerPresenceManager::SetName(const std::string sServerNameUnicode) +void ServerPresenceManager::SetName(const std::string sServerNameUnicode) { // update name m_ServerPresence.m_sServerName = sServerNameUnicode; diff --git a/NorthstarDLL/squirrel.cpp b/NorthstarDLL/squirrel.cpp index 7cf46f4f7..056fe4010 100644 --- a/NorthstarDLL/squirrel.cpp +++ b/NorthstarDLL/squirrel.cpp @@ -39,7 +39,7 @@ eSQReturnType SQReturnTypeFromString(const char* pReturnType) return sqReturnTypeNameToString.at(pReturnType); else return eSQReturnType::Default; // previous default value -} +} // needed to define implementations for squirrelmanager outside of squirrel.h without compiler errors template class SquirrelManager; @@ -129,7 +129,7 @@ template void SquirrelManager::AddFuncRegistrat m_funcRegistrations.push_back(reg); } -template SQRESULT SquirrelManager::setupfunc(const SQChar* funcname) +template SQRESULT SquirrelManager::setupfunc(const SQChar* funcname) { pushroottable(sqvm); pushstring(sqvm, funcname, -1); @@ -143,7 +143,7 @@ template SQRESULT SquirrelManager::setupfunc(co template void SquirrelManager::AddFuncOverride(std::string name, SQFunction func) { m_funcOverrides[name] = func; -} +} // hooks template void* (*sq_compiler_create)(HSquirrelVM* sqvm, void* a2, void* a3, SQBool bShouldThrowError); @@ -239,21 +239,18 @@ template void ScriptCompileErrorHook(void* sqvm, const c // likely temp: show console so user can see any errors, as error message wont display if ui is dead // maybe we could disable all mods other than the coremods and try a reload before doing this? // could also maybe do some vgui bullshit to show something visually rather than console - if (realContext == ScriptContext::UI) - R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "showconsole", R2::cmd_source_t::kCommandSrcCode); + if (realContext == ScriptContext::UI) + R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "showconsole", R2::cmd_source_t::kCommandSrcCode); } } // dont call the original function since it kills game lol } - - - -template int64_t(*RegisterSquirrelFunction)(CSquirrelVM* sqvm, SQFuncRegistration* funcReg, char unknown); +template int64_t (*RegisterSquirrelFunction)(CSquirrelVM* sqvm, SQFuncRegistration* funcReg, char unknown); template int64_t RegisterSquirrelFunctionHook(CSquirrelVM* sqvm, SQFuncRegistration* funcReg, char unknown) { - + if (context == ScriptContext::CLIENT && sqvm == g_pSquirrel->SquirrelVM) { if (g_pSquirrel->m_funcOverrides.count(funcReg->squirrelFuncName)) @@ -361,9 +358,9 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel = new SquirrelManager; g_pSquirrel = new SquirrelManager; - - //g_pSquirrel->RegisterSquirrelFunc = module.Offset(0x108E0).As(); - //g_pSquirrel->RegisterSquirrelFunc = g_pSquirrel->RegisterSquirrelFunc; + + // g_pSquirrel->RegisterSquirrelFunc = module.Offset(0x108E0).As(); + // g_pSquirrel->RegisterSquirrelFunc = g_pSquirrel->RegisterSquirrelFunc; g_pSquirrel->__sq_defconst = module.Offset(0x12120).As(); g_pSquirrel->__sq_defconst = g_pSquirrel->__sq_defconst; @@ -399,7 +396,6 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel->__sq_pushvector = g_pSquirrel->__sq_pushvector; g_pSquirrel->__sq_pushasset = g_pSquirrel->__sq_pushasset; g_pSquirrel->__sq_raiseerror = g_pSquirrel->__sq_raiseerror; - g_pSquirrel->__sq_getstring = module.Offset(0x60C0).As(); g_pSquirrel->__sq_getinteger = module.Offset(0x60E0).As(); @@ -426,26 +422,21 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) // uiscript_reset concommand: don't loop forever if compilation fails module.Offset(0x3C6E4C).NOP(6); - MAKEHOOK(module.Offset(0x8AD0), - &sq_compiler_createHook, - &sq_compiler_create); + MAKEHOOK(module.Offset(0x8AD0), &sq_compiler_createHook, &sq_compiler_create); MAKEHOOK(module.Offset(0x12B00), &SQPrintHook, &SQPrint); MAKEHOOK(module.Offset(0x12BA0), &SQPrintHook, &SQPrint); MAKEHOOK(module.Offset(0x26130), &CreateNewVMHook, &CreateNewVM); MAKEHOOK(module.Offset(0x26E70), &DestroyVMHook, &DestroyVM); - MAKEHOOK( - module.Offset(0x79A50), - &ScriptCompileErrorHook, - &SQCompileError); + MAKEHOOK(module.Offset(0x79A50), &ScriptCompileErrorHook, &SQCompileError); - MAKEHOOK( - module.Offset(0x10190), - &CallScriptInitCallbackHook, - &CallScriptInitCallback); + MAKEHOOK(module.Offset(0x10190), &CallScriptInitCallbackHook, &CallScriptInitCallback); - MAKEHOOK(module.Offset(0x108E0), &RegisterSquirrelFunctionHook, &g_pSquirrel->RegisterSquirrelFunc); + MAKEHOOK( + module.Offset(0x108E0), + &RegisterSquirrelFunctionHook, + &g_pSquirrel->RegisterSquirrelFunc); g_pSquirrel->RegisterSquirrelFunc = g_pSquirrel->RegisterSquirrelFunc; @@ -473,7 +464,7 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module)) g_pSquirrel = new SquirrelManager; - //g_pSquirrel->RegisterSquirrelFunc = module.Offset(0x1DD10).As(); + // g_pSquirrel->RegisterSquirrelFunc = module.Offset(0x1DD10).As(); g_pSquirrel->__sq_defconst = module.Offset(0x1F550).As(); g_pSquirrel->__sq_compilebuffer = module.Offset(0x3110).As(); @@ -506,23 +497,18 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module)) g_pSquirrel->__sq_createuserdata = module.Offset(0x38D0).As(); g_pSquirrel->__sq_setuserdatatypeid = module.Offset(0x6470).As(); - MAKEHOOK(module.Offset(0x8AA0), - &sq_compiler_createHook, - &sq_compiler_create); + MAKEHOOK(module.Offset(0x8AA0), &sq_compiler_createHook, &sq_compiler_create); MAKEHOOK(module.Offset(0x1FE90), &SQPrintHook, &SQPrint); MAKEHOOK(module.Offset(0x260E0), &CreateNewVMHook, &CreateNewVM); MAKEHOOK(module.Offset(0x26E20), &DestroyVMHook, &DestroyVM); - MAKEHOOK( - module.Offset(0x799E0), - &ScriptCompileErrorHook, - &SQCompileError); - MAKEHOOK( - module.Offset(0x1D5C0), - &CallScriptInitCallbackHook, - &CallScriptInitCallback); + MAKEHOOK(module.Offset(0x799E0), &ScriptCompileErrorHook, &SQCompileError); + MAKEHOOK(module.Offset(0x1D5C0), &CallScriptInitCallbackHook, &CallScriptInitCallback); - MAKEHOOK(module.Offset(0x1DD10), &RegisterSquirrelFunctionHook, &g_pSquirrel->RegisterSquirrelFunc); + MAKEHOOK( + module.Offset(0x1DD10), + &RegisterSquirrelFunctionHook, + &g_pSquirrel->RegisterSquirrelFunc); // FCVAR_CHEAT and FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS allows clients to execute this, but since it's unsafe we only allow it when cheats // are enabled for script_client and script_ui, we don't use cheats, so clients can execute them on themselves all they want diff --git a/NorthstarDLL/squirrel.h b/NorthstarDLL/squirrel.h index f29ff05d1..fc7273570 100644 --- a/NorthstarDLL/squirrel.h +++ b/NorthstarDLL/squirrel.h @@ -259,7 +259,7 @@ template class SquirrelManager { __sq_pushasset(sqvm, sVal, length); } - inline void pushvector(HSquirrelVM* sqvm, const SQFloat* pVal) + inline void pushvector(HSquirrelVM* sqvm, const SQFloat* pVal) { __sq_pushvector(sqvm, pVal); } diff --git a/NorthstarLauncher/main.cpp b/NorthstarLauncher/main.cpp index 0471b9d1a..078cbc4a4 100644 --- a/NorthstarLauncher/main.cpp +++ b/NorthstarLauncher/main.cpp @@ -147,7 +147,7 @@ void AwaitOriginStartup() std::cout << "LSX: connect()" << std::endl; connect(sock, (struct sockaddr*)&lsxAddr, sizeof(lsxAddr)); - + char buf[4096]; memset(buf, 0, sizeof(buf)); @@ -298,7 +298,7 @@ bool LoadNorthstar() LoadPlugins = GetProcAddress(hHookModule, "LoadPlugins"); if (!hHookModule || LoadPlugins == nullptr) { - std::cout << "Failed to get function pointer to LoadPlugins of Northstar.dll" << std::endl; + std::cout << "Failed to get function pointer to LoadPlugins of Northstar.dll" << std::endl; LibraryLoadError(GetLastError(), L"Northstar.dll", buffer); return false; } @@ -365,8 +365,9 @@ int main(int argc, char* argv[]) { if ((!gssao || FreeLibrary(gssao)) && (!gtxaa || FreeLibrary(gtxaa)) && (!d3d11 || FreeLibrary(d3d11))) { - std::cout <<"[*] WARNING: Failed to load d3d11/gfsdk stubs from bin/x64_dedi. " - "The stubs have been unloaded and the original libraries will be used instead" << std::endl; + std::cout << "[*] WARNING: Failed to load d3d11/gfsdk stubs from bin/x64_dedi. " + "The stubs have been unloaded and the original libraries will be used instead" + << std::endl; } else { @@ -385,7 +386,8 @@ int main(int argc, char* argv[]) { // this should never happen std::cout << "[*] WARNING: Failed to load stubs because conflicting modules are already loaded, so those will be used instead " - "(did Northstar initialize too late?)." << std::endl; + "(did Northstar initialize too late?)." + << std::endl; } }