diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2022-09-02 00:38:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-02 00:38:07 +0200 |
commit | f2e670bd32fc291dbb6a4b45c08cb8f2d94a6bc8 (patch) | |
tree | eb23e0d5ebfc8f796b7bde55179ae3dc0ae46d3f /NorthstarDLL | |
parent | 80673fb5cfa32d3ff75d54c4c4173d32905fda30 (diff) | |
download | NorthstarLauncher-f2e670bd32fc291dbb6a4b45c08cb8f2d94a6bc8.tar.gz NorthstarLauncher-f2e670bd32fc291dbb6a4b45c08cb8f2d94a6bc8.zip |
Refactor cleanup (some formatting fixes) (#257)
* Fix some formatting
* More formatting fixes
Diffstat (limited to 'NorthstarDLL')
39 files changed, 143 insertions, 175 deletions
diff --git a/NorthstarDLL/bansystem.cpp b/NorthstarDLL/bansystem.cpp index 922077d5..25c0e6bf 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<std::string> banlistText; std::ifstream fs_readBanlist(GetNorthstarPrefix() + "/banlist.txt"); diff --git a/NorthstarDLL/clientruihooks.cpp b/NorthstarDLL/clientruihooks.cpp index 080957c9..9d6562d2 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 e7fb5397..5a9aa4eb 100644 --- a/NorthstarDLL/convar.h +++ b/NorthstarDLL/convar.h @@ -107,7 +107,7 @@ const std::multimap<int, const char*> 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 ead30d3e..e65e5145 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<CCvar>* g_pCVarInterface; extern CCvar* g_pCVar; diff --git a/NorthstarDLL/dedicated.cpp b/NorthstarDLL/dedicated.cpp index d8e2992e..42af9456 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 aa808bf5..600fb339 100644 --- a/NorthstarDLL/dllmain.cpp +++ b/NorthstarDLL/dllmain.cpp @@ -18,7 +18,7 @@ #include <filesystem> 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 4ce9f351..3a9a504f 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<bool(*)(CCommand&, const char*, R2::cmd_source_t)>(); + CCommand__Tokenize = module.Offset(0x418380).As<bool (*)(CCommand&, const char*, R2::cmd_source_t)>(); // 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 cc95246f..87d2868d 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 ce4bbcec..08050be6 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 dc09cf48..74dad785 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 c0d6b3b9..6008a0f2 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 14f36999..2c661feb 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 04656b33..ef23c919 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 ba165bee..bc7fce32 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 9c104f5c..b251f6a6 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 d93b736e..8b7694bd 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<void*>(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<uint8_t> 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::vector<uint8_t>, 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 b69979d0..38c76cb3 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 <typename T> T As() { return reinterpret_cast<T>(m_nAddress); } + template <typename T> T As() + { + return reinterpret_cast<T>(m_nAddress); + } // traversal MemoryAddress Offset(const uintptr_t nOffset) const; diff --git a/NorthstarDLL/misccommands.cpp b/NorthstarDLL/misccommands.cpp index c61f13ec..e745752f 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 5089d9e8..3b30dd23 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 8ba883a3..c9dfcdbb 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 336ef804..621df76f 100644 --- a/NorthstarDLL/modmanager.h +++ b/NorthstarDLL/modmanager.h @@ -103,7 +103,7 @@ class Mod std::unordered_map<std::string, std::string> RpakAliases; // paks we alias to other rpaks, e.g. to load sp_crashsite paks on the map mp_crashsite - std::unordered_map<std::string, std::string> DependencyConstants; + std::unordered_map<std::string, std::string> DependencyConstants; public: Mod(fs::path modPath, char* jsonBuf); diff --git a/NorthstarDLL/playlist.cpp b/NorthstarDLL/playlist.cpp index 87847fc1..7cf9e41e 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<const char*(*)()>(); - R2::SetCurrentPlaylist = module.Offset(0x18EB20).As <void(*)(const char*)>(); - R2::SetPlaylistVarOverride = module.Offset(0x18ED00).As<void(*)(const char*, const char*)>(); - R2::GetCurrentPlaylistVar = module.Offset(0x18C680).As<const char*(*)(const char*, bool)>(); + R2::GetCurrentPlaylistName = module.Offset(0x18C640).As<const char* (*)()>(); + R2::SetCurrentPlaylist = module.Offset(0x18EB20).As<void (*)(const char*)>(); + R2::SetPlaylistVarOverride = module.Offset(0x18ED00).As<void (*)(const char*, const char*)>(); + R2::GetCurrentPlaylistVar = module.Offset(0x18C680).As<const char* (*)(const char*, bool)>(); // 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 e6089f3b..790439d1 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 605f7dce..90af1575 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 7a12b1fe..82ba8d5e 100644 --- a/NorthstarDLL/printmaps.cpp +++ b/NorthstarDLL/printmaps.cpp @@ -19,9 +19,9 @@ enum class MapSource_t }; const std::unordered_map<MapSource_t, const char*> 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<MapVPKInfo> 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 48ac049a..64ed6c61 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 5a5568c1..4807a174 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<CEngine*>(); // new - CBaseClient__Disconnect = module.Offset(0x1012C0).As<void(*)(void*, uint32_t, const char*, ...)>(); + CBaseClient__Disconnect = module.Offset(0x1012C0).As<void (*)(void*, uint32_t, const char*, ...)>(); g_pClientArray = module.Offset(0x12A53F90).As<CBaseClient*>(); g_pServerState = module.Offset(0x12A53D48).As<server_state_t*>(); diff --git a/NorthstarDLL/r2server.cpp b/NorthstarDLL/r2server.cpp index 7144f93c..50cfa239 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<CBaseEntity*(*)(int)>(); + Server_GetEntityByIndex = module.Offset(0xFB820).As<CBaseEntity* (*)(int)>(); UTIL_PlayerByIndex = module.Offset(0x26AA10).As<CBasePlayer*(__fastcall*)(int)>(); } diff --git a/NorthstarDLL/rpakfilesystem.cpp b/NorthstarDLL/rpakfilesystem.cpp index 895cfd79..d5cff26c 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 88811686..3f608dba 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 053933bd..40bb6a39 100644 --- a/NorthstarDLL/scriptdatatables.cpp +++ b/NorthstarDLL/scriptdatatables.cpp @@ -80,9 +80,9 @@ template <ScriptContext context> 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<context>->m_funcOriginals["GetDataTable"](sqvm); } else @@ -91,7 +91,7 @@ template <ScriptContext context> 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<context>->createuserdata(sqvm, sizeof(csvData*)); *dataPointer = cacheMap[assetName]; g_pSquirrel<context>->setuserdatatypeid(sqvm, -1, customDatatableTypeId); @@ -217,11 +217,11 @@ template <ScriptContext context> 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<context>->m_funcOriginals["GetDataTable"](sqvm); } @@ -235,7 +235,7 @@ template <ScriptContext context> SQRESULT GetDatatable(HSquirrelVM* sqvm) template <ScriptContext context> SQRESULT GetDatatabeColumnByName(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableColumnByName"); + // spdlog::info("start getDatatableColumnByName"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -249,7 +249,7 @@ template <ScriptContext context> 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<context>->getstring(sqvm, 2); int col = 0; for (auto colName : data->columnNames) @@ -261,14 +261,14 @@ template <ScriptContext context> 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<context>->pushinteger(sqvm, col); return SQRESULT_NOTNULL; } template <ScriptContext context> SQRESULT GetDatatabeRowCount(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableRowCount"); + // spdlog::info("start getDatatableRowCount"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -289,7 +289,7 @@ template <ScriptContext context> SQRESULT GetDatatabeRowCount(HSquirrelVM* sqvm) template <ScriptContext context> SQRESULT GetDataTableString(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableString"); + // spdlog::info("start getDatatableString"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -307,7 +307,7 @@ template <ScriptContext context> SQRESULT GetDataTableString(HSquirrelVM* sqvm) int col = g_pSquirrel<context>->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 <ScriptContext context> SQRESULT GetDataTableString(HSquirrelVM* sqvm) template <ScriptContext context> SQRESULT GetDataTableAsset(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableAsset"); + // spdlog::info("start getDatatableAsset"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -335,7 +335,7 @@ template <ScriptContext context> SQRESULT GetDataTableAsset(HSquirrelVM* sqvm) int col = g_pSquirrel<context>->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 <ScriptContext context> SQRESULT GetDataTableInt(HSquirrelVM* sqvm) int col = g_pSquirrel<context>->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<context>->pushinteger(sqvm, std::stoi(data->dataPointers[row][col])); @@ -371,7 +371,7 @@ template <ScriptContext context> SQRESULT GetDataTableInt(HSquirrelVM* sqvm) template <ScriptContext context> SQRESULT GetDataTableFloat(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableFloat"); + // spdlog::info("start getDatatableFloat"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -389,7 +389,7 @@ template <ScriptContext context> SQRESULT GetDataTableFloat(HSquirrelVM* sqvm) int col = g_pSquirrel<context>->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<context>->pushfloat(sqvm, std::stof(data->dataPointers[row][col])); @@ -398,7 +398,7 @@ template <ScriptContext context> SQRESULT GetDataTableFloat(HSquirrelVM* sqvm) template <ScriptContext context> SQRESULT GetDataTableBool(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableBool"); + // spdlog::info("start getDatatableBool"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -416,7 +416,7 @@ template <ScriptContext context> SQRESULT GetDataTableBool(HSquirrelVM* sqvm) int col = g_pSquirrel<context>->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<context>->pushbool(sqvm, std::stoi(data->dataPointers[row][col])); @@ -425,7 +425,7 @@ template <ScriptContext context> SQRESULT GetDataTableBool(HSquirrelVM* sqvm) template <ScriptContext context> SQRESULT GetDataTableVector(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableVector"); + // spdlog::info("start getDatatableVector"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -489,7 +489,7 @@ template <ScriptContext context> SQRESULT GetDataTableRowMatchingStringValue(HSq template <ScriptContext context> SQRESULT GetDataTableRowMatchingAssetValue(HSquirrelVM* sqvm) { - //spdlog::info("start getDatatableRowMatchingAsset"); + // spdlog::info("start getDatatableRowMatchingAsset"); csvData** dataPointer; long long typeId; g_pSquirrel<context>->getuserdata(sqvm, 2, (void**)&dataPointer, &typeId); @@ -733,8 +733,8 @@ template <ScriptContext context> 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<context>->pushinteger(sqvm, i); @@ -755,8 +755,8 @@ template <ScriptContext context> SQRESULT DumpDataTable(HSquirrelVM* sqvm) g_pSquirrel<context>->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 <ScriptContext context> SQRESULT DumpDataTableToFile(HSquirrelVM* sqvm) g_pSquirrel<context>->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<context>->getstring(sqvm, 2); std::ofstream ofs(pathName); @@ -861,8 +861,7 @@ void datatableReleaseHook(void* d, int size) delete data; } - -template <ScriptContext context> void RegisterDataTableFunctions() +template <ScriptContext context> void RegisterDataTableFunctions() { g_pSquirrel<context>->AddFuncOverride("GetDataTable", GetDatatable<context>); g_pSquirrel<context>->AddFuncOverride("GetDataTableColumnByName", GetDatatabeColumnByName<context>); @@ -876,7 +875,7 @@ template <ScriptContext context> void RegisterDataTableFunctions() g_pSquirrel<context>->AddFuncOverride("GetDataTableRowMatchingStringValue", GetDataTableRowMatchingStringValue<context>); g_pSquirrel<context>->AddFuncOverride("GetDataTableRowMatchingAssetValue", GetDataTableRowMatchingAssetValue<context>); g_pSquirrel<context>->AddFuncOverride("GetDataTableRowMatchingFloatValue", GetDataTableRowMatchingFloatValue<context>); - g_pSquirrel<context>->AddFuncOverride("GetDataTableRowMatchingIntValue", GetDataTableRowMatchingIntValue < context>); + g_pSquirrel<context>->AddFuncOverride("GetDataTableRowMatchingIntValue", GetDataTableRowMatchingIntValue<context>); g_pSquirrel<context>->AddFuncOverride("GetDataTableRowMatchingVectorValue", GetDataTableRowMatchingVectorValue<context>); g_pSquirrel<context>->AddFuncOverride( "GetDataTableRowLessThanOrEqualToFloatValue", GetDataTableRowLessThanOrEqualToFloatValue<context>); @@ -885,8 +884,6 @@ template <ScriptContext context> void RegisterDataTableFunctions() g_pSquirrel<context>->AddFuncOverride("GetDataTableRowLessThanOrEqualToIntValue", GetDataTableRowLessThanOrEqualToIntValue<context>); g_pSquirrel<context>->AddFuncOverride( "GetDataTableRowGreaterThanOrEqualToFloatValue", GetDataTableRowGreaterThanOrEqualToIntValue<context>); - - } ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CModule module)) @@ -894,15 +891,12 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CMod RegisterDataTableFunctions<ScriptContext::SERVER>(); g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration( "void", "DumpDataTable", "var", "Dumps rpak datatable contents to console", DumpDataTable<ScriptContext::SERVER>); - // g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration( "void", "DumpDataTableToFile", "var,string", "Dumps datatable contents to console", - // DumpDataTableToFile<ScriptContext::SERVER>); - - + // g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration( "void", "DumpDataTableToFile", "var,string", "Dumps datatable contents to + // console", DumpDataTableToFile<ScriptContext::SERVER>); getDataTableStructure = module.Offset(0x1250f0).As<void* (*)(HSquirrelVM*)>(); } - ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CModule module)) { @@ -910,7 +904,7 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CMod RegisterDataTableFunctions<ScriptContext::UI>(); } -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 dff5800e..62074587 100644 --- a/NorthstarDLL/scriptjson.cpp +++ b/NorthstarDLL/scriptjson.cpp @@ -206,7 +206,6 @@ template <ScriptContext context> void EncodeJSONArray( } } - // table function DecodeJSON( string json, bool fatalParseErrors = false ) template <ScriptContext context> SQRESULT SQ_DecodeJSON(HSquirrelVM* sqvm) { @@ -235,7 +234,6 @@ template <ScriptContext context> SQRESULT SQ_DecodeJSON(HSquirrelVM* sqvm) DecodeJsonTable<context>(sqvm, (rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>*)&doc); } - // string function EncodeJSON( table data ) template <ScriptContext context> SQRESULT SQ_EncodeJSON(HSquirrelVM* sqvm) { diff --git a/NorthstarDLL/scriptmodmenu.cpp b/NorthstarDLL/scriptmodmenu.cpp index fcd74024..d2f35285 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<ScriptContext::UI>->AddFuncRegistration("array<string>", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames); + g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( + "array<string>", "NSGetModNames", "", "Returns the names of all loaded mods", SQ_GetModNames); g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( "bool", "NSIsModEnabled", "string modName", "Returns whether a given mod is enabled", SQ_IsModEnabled); g_pSquirrel<ScriptContext::UI>->AddFuncRegistration( diff --git a/NorthstarDLL/scriptserverbrowser.cpp b/NorthstarDLL/scriptserverbrowser.cpp index bf63e35a..ba5b17e2 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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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<ScriptContext::UI>->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 db26cf31..7a1936cf 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<ScriptContext::UI>); } -ON_DLL_LOAD_RELIESON("server.dll", ServerSharedScriptUtility, ServerSquirrel, (CModule module)) +ON_DLL_LOAD_RELIESON("server.dll", ServerSharedScriptUtility, ServerSquirrel, (CModule module)) { g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration( "asset", "StringToAsset", "string assetName", "converts a given string to an asset", SQ_StringToAsset<ScriptContext::SERVER>); diff --git a/NorthstarDLL/serverauthentication.cpp b/NorthstarDLL/serverauthentication.cpp index e7a7ff00..366a391a 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 cfc1c213..9338cd9c 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 7cf46f4f..056fe401 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<ScriptContext::SERVER>; @@ -129,7 +129,7 @@ template <ScriptContext context> void SquirrelManager<context>::AddFuncRegistrat m_funcRegistrations.push_back(reg); } -template <ScriptContext context> SQRESULT SquirrelManager<context>::setupfunc(const SQChar* funcname) +template <ScriptContext context> SQRESULT SquirrelManager<context>::setupfunc(const SQChar* funcname) { pushroottable(sqvm); pushstring(sqvm, funcname, -1); @@ -143,7 +143,7 @@ template <ScriptContext context> SQRESULT SquirrelManager<context>::setupfunc(co template <ScriptContext context> void SquirrelManager<context>::AddFuncOverride(std::string name, SQFunction func) { m_funcOverrides[name] = func; -} +} // hooks template <ScriptContext context> void* (*sq_compiler_create)(HSquirrelVM* sqvm, void* a2, void* a3, SQBool bShouldThrowError); @@ -239,21 +239,18 @@ template <ScriptContext context> 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 <ScriptContext context> int64_t(*RegisterSquirrelFunction)(CSquirrelVM* sqvm, SQFuncRegistration* funcReg, char unknown); +template <ScriptContext context> int64_t (*RegisterSquirrelFunction)(CSquirrelVM* sqvm, SQFuncRegistration* funcReg, char unknown); template <ScriptContext context> int64_t RegisterSquirrelFunctionHook(CSquirrelVM* sqvm, SQFuncRegistration* funcReg, char unknown) { - + if (context == ScriptContext::CLIENT && sqvm == g_pSquirrel<ScriptContext::UI>->SquirrelVM) { if (g_pSquirrel<ScriptContext::UI>->m_funcOverrides.count(funcReg->squirrelFuncName)) @@ -361,9 +358,9 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel<ScriptContext::CLIENT> = new SquirrelManager<ScriptContext::CLIENT>; g_pSquirrel<ScriptContext::UI> = new SquirrelManager<ScriptContext::UI>; - - //g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc = module.Offset(0x108E0).As<RegisterSquirrelFuncType>(); - //g_pSquirrel<ScriptContext::UI>->RegisterSquirrelFunc = g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc; + + // g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc = module.Offset(0x108E0).As<RegisterSquirrelFuncType>(); + // g_pSquirrel<ScriptContext::UI>->RegisterSquirrelFunc = g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc; g_pSquirrel<ScriptContext::CLIENT>->__sq_defconst = module.Offset(0x12120).As<sq_defconstType>(); g_pSquirrel<ScriptContext::UI>->__sq_defconst = g_pSquirrel<ScriptContext::CLIENT>->__sq_defconst; @@ -399,7 +396,6 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel<ScriptContext::UI>->__sq_pushvector = g_pSquirrel<ScriptContext::CLIENT>->__sq_pushvector; g_pSquirrel<ScriptContext::UI>->__sq_pushasset = g_pSquirrel<ScriptContext::CLIENT>->__sq_pushasset; g_pSquirrel<ScriptContext::UI>->__sq_raiseerror = g_pSquirrel<ScriptContext::CLIENT>->__sq_raiseerror; - g_pSquirrel<ScriptContext::CLIENT>->__sq_getstring = module.Offset(0x60C0).As<sq_getstringType>(); g_pSquirrel<ScriptContext::CLIENT>->__sq_getinteger = module.Offset(0x60E0).As<sq_getintegerType>(); @@ -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<ScriptContext::CLIENT>, - &sq_compiler_create<ScriptContext::CLIENT>); + MAKEHOOK(module.Offset(0x8AD0), &sq_compiler_createHook<ScriptContext::CLIENT>, &sq_compiler_create<ScriptContext::CLIENT>); MAKEHOOK(module.Offset(0x12B00), &SQPrintHook<ScriptContext::CLIENT>, &SQPrint<ScriptContext::CLIENT>); MAKEHOOK(module.Offset(0x12BA0), &SQPrintHook<ScriptContext::UI>, &SQPrint<ScriptContext::UI>); MAKEHOOK(module.Offset(0x26130), &CreateNewVMHook<ScriptContext::CLIENT>, &CreateNewVM<ScriptContext::CLIENT>); MAKEHOOK(module.Offset(0x26E70), &DestroyVMHook<ScriptContext::CLIENT>, &DestroyVM<ScriptContext::CLIENT>); - MAKEHOOK( - module.Offset(0x79A50), - &ScriptCompileErrorHook<ScriptContext::CLIENT>, - &SQCompileError<ScriptContext::CLIENT>); + MAKEHOOK(module.Offset(0x79A50), &ScriptCompileErrorHook<ScriptContext::CLIENT>, &SQCompileError<ScriptContext::CLIENT>); - MAKEHOOK( - module.Offset(0x10190), - &CallScriptInitCallbackHook<ScriptContext::CLIENT>, - &CallScriptInitCallback<ScriptContext::CLIENT>); + MAKEHOOK(module.Offset(0x10190), &CallScriptInitCallbackHook<ScriptContext::CLIENT>, &CallScriptInitCallback<ScriptContext::CLIENT>); - MAKEHOOK(module.Offset(0x108E0), &RegisterSquirrelFunctionHook<ScriptContext::CLIENT>, &g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc); + MAKEHOOK( + module.Offset(0x108E0), + &RegisterSquirrelFunctionHook<ScriptContext::CLIENT>, + &g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc); g_pSquirrel<ScriptContext::UI>->RegisterSquirrelFunc = g_pSquirrel<ScriptContext::CLIENT>->RegisterSquirrelFunc; @@ -473,7 +464,7 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module)) g_pSquirrel<ScriptContext::SERVER> = new SquirrelManager<ScriptContext::SERVER>; - //g_pSquirrel<ScriptContext::SERVER>->RegisterSquirrelFunc = module.Offset(0x1DD10).As<RegisterSquirrelFuncType>(); + // g_pSquirrel<ScriptContext::SERVER>->RegisterSquirrelFunc = module.Offset(0x1DD10).As<RegisterSquirrelFuncType>(); g_pSquirrel<ScriptContext::SERVER>->__sq_defconst = module.Offset(0x1F550).As<sq_defconstType>(); g_pSquirrel<ScriptContext::SERVER>->__sq_compilebuffer = module.Offset(0x3110).As<sq_compilebufferType>(); @@ -506,23 +497,18 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module)) g_pSquirrel<ScriptContext::SERVER>->__sq_createuserdata = module.Offset(0x38D0).As<sq_createuserdataType>(); g_pSquirrel<ScriptContext::SERVER>->__sq_setuserdatatypeid = module.Offset(0x6470).As<sq_setuserdatatypeidType>(); - MAKEHOOK(module.Offset(0x8AA0), - &sq_compiler_createHook<ScriptContext::SERVER>, - &sq_compiler_create<ScriptContext::SERVER>); + MAKEHOOK(module.Offset(0x8AA0), &sq_compiler_createHook<ScriptContext::SERVER>, &sq_compiler_create<ScriptContext::SERVER>); MAKEHOOK(module.Offset(0x1FE90), &SQPrintHook<ScriptContext::SERVER>, &SQPrint<ScriptContext::SERVER>); MAKEHOOK(module.Offset(0x260E0), &CreateNewVMHook<ScriptContext::SERVER>, &CreateNewVM<ScriptContext::SERVER>); MAKEHOOK(module.Offset(0x26E20), &DestroyVMHook<ScriptContext::SERVER>, &DestroyVM<ScriptContext::SERVER>); - MAKEHOOK( - module.Offset(0x799E0), - &ScriptCompileErrorHook<ScriptContext::SERVER>, - &SQCompileError<ScriptContext::SERVER>); - MAKEHOOK( - module.Offset(0x1D5C0), - &CallScriptInitCallbackHook<ScriptContext::SERVER>, - &CallScriptInitCallback<ScriptContext::SERVER>); + MAKEHOOK(module.Offset(0x799E0), &ScriptCompileErrorHook<ScriptContext::SERVER>, &SQCompileError<ScriptContext::SERVER>); + MAKEHOOK(module.Offset(0x1D5C0), &CallScriptInitCallbackHook<ScriptContext::SERVER>, &CallScriptInitCallback<ScriptContext::SERVER>); - MAKEHOOK(module.Offset(0x1DD10), &RegisterSquirrelFunctionHook<ScriptContext::SERVER>, &g_pSquirrel<ScriptContext::SERVER>->RegisterSquirrelFunc); + MAKEHOOK( + module.Offset(0x1DD10), + &RegisterSquirrelFunctionHook<ScriptContext::SERVER>, + &g_pSquirrel<ScriptContext::SERVER>->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 f29ff05d..fc727357 100644 --- a/NorthstarDLL/squirrel.h +++ b/NorthstarDLL/squirrel.h @@ -259,7 +259,7 @@ template <ScriptContext context> 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); } |