diff --git a/.clang-format b/.clang-format deleted file mode 100644 index ecf9fec8b..000000000 --- a/.clang-format +++ /dev/null @@ -1,39 +0,0 @@ -Language: Cpp -Standard: Cpp11 -IndentWidth: 4 -TabWidth: 4 -UseCRLF: false -AccessModifierOffset: -4 -AlignTrailingComments: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortFunctionsOnASingleLine: Inline -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakTemplateDeclarations: No -BinPackArguments: false -BinPackParameters: false -ExperimentalAutoDetectBinPacking: false -IndentCaseLabels: false -ObjCBinPackProtocolList: Auto -SpacesInSquareBrackets: false -SpacesInParentheses: false -SpaceAfterCStyleCast: false -SpaceInEmptyParentheses: false -SpaceAfterLogicalNot: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -UseTab: Always -ColumnLimit: 140 -BreakBeforeBraces: Allman -AlignAfterOpenBracket: AlwaysBreak -IndentExternBlock: Indent -PointerAlignment: Left -SortIncludes: false -NamespaceIndentation: All -PackConstructorInitializers: NextLine -BreakConstructorInitializersBeforeComma: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e562dc3bf..8c71c3785 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,25 +44,3 @@ jobs: name: NorthstarLauncher-${{ matrix.config.name }}-${{ steps.extract.outputs.commit }} path: | game/ - - format-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: DoozyX/clang-format-lint-action@v0.16.2 - with: - source: 'primedev' - exclude: 'primedev/include primedev/thirdparty primedev/wsockproxy' - extensions: 'h,cpp' - clangFormatVersion: 16 - style: file - - format-check-cmake-files: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: puneetmatharu/cmake-format-lint-action@v1.0.4 - with: - args: "--in-place" - - run: | - git diff --exit-code diff --git a/README.md b/README.md index 80be8fd0f..5620749d6 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ Check [BUILD.md](BUILD.md) for instructions on how to compile, you can also down ## Format -This project uses [clang-format](https://clang.llvm.org/docs/ClangFormat.html), make sure you run `clang-format -i --style=file --exclude=primedev/include primedev/*.cpp primedev/*.h` when opening a Pull Request. Check the tool's website for instructions on how to integrate it with your IDE. +For project coding standards checkout [STANDARDS.md](STANDARDS.md). \ No newline at end of file diff --git a/STANDARDS.md b/STANDARDS.md new file mode 100644 index 000000000..6ed343b7a --- /dev/null +++ b/STANDARDS.md @@ -0,0 +1,57 @@ +# Code standards + +There are exceptions, ask for them! + +### Preamble + +We do not use any auto-formatting tools as most solutions are limited in what they can do and setting them up can be a pain in the ass. + +We used to use clang-format but have swapped it with this document. + +You are more than welcome to reformat any files using the old formatting rules, but please SPLIT your formatting changes from the rest by making a separate PR! + +### General rules + +> Basic rules that apply all the time. + +Always assert your assumptions! + +Use PascalCase for all names. + +Suffix structs with `_t`. + +Prefix classes with `C` (class) and `I` (abstract class). + +Prefix all class member variables with `m_`. + +Prefixes `g_` for global variables and `s_` for static variables are welcome. + +For hooking we use `o_` for function pointers pointing to the original implementation and `h_` for functions we replace them with. + +Document all function implementations and their arguments (if the argument is self explanatory you don't need to document it) valve style: +``` +//----------------------------------------------------------------------------- +// Purpose: MH_MakeHook wrapper +// Input : *ppOriginal - Original function being detoured +// pDetour - Detour function +// Output : true on success, false otherwise +//----------------------------------------------------------------------------- +``` + +Don't overcomment your code unless nescessary, expect the reader to have limited knowledge. + +Use `FIXME` comments for possible improvements/issues, `NOTE` for important information one might want to look into. + +### Valve source files + +> Rules that apply to all files from original valve code base. + +When adding or just modifying a file that's present in valve source place it where valve put it. + +Always use hungarian notation in these files. + +### New files + +> Rules that apply to respawn or our own files. + +When adding new files follow the general rules, you don't have to use hungarian notation. Put the file where you think it makes the most sense. diff --git a/primedev/client/audio.cpp b/primedev/client/audio.cpp index 635014141..e4b1f16fd 100644 --- a/primedev/client/audio.cpp +++ b/primedev/client/audio.cpp @@ -389,10 +389,8 @@ bool ShouldPlayAudioEvent(const char* eventName, const std::shared_ptr((*((__int64*)a2 + 6))); return sub_1800294C0(a1, a2); } -// clang-format off AUTOHOOK(MilesLog, client.dll + 0x57DAD0, void, __fastcall, (int level, const char* string)) -// clang-format on { if (!Cvar_mileslog_enable->GetBool()) return; diff --git a/primedev/client/clientauthhooks.cpp b/primedev/client/clientauthhooks.cpp index 35ae3aa77..433967e43 100644 --- a/primedev/client/clientauthhooks.cpp +++ b/primedev/client/clientauthhooks.cpp @@ -12,10 +12,8 @@ const int NOT_DECIDED_TO_SEND_TOKEN = 0; const int AGREED_TO_SEND_TOKEN = 1; const int DISAGREED_TO_SEND_TOKEN = 2; -// clang-format off AUTOHOOK(AuthWithStryder, engine.dll + 0x1843A0, void, __fastcall, (void* a1)) -// clang-format on { // don't attempt to do Atlas auth if we are in vanilla compatibility mode // this prevents users from joining untrustworthy servers (unless they use a concommand or something) @@ -43,10 +41,8 @@ void, __fastcall, (void* a1)) char* p3PToken; -// clang-format off AUTOHOOK(Auth3PToken, engine.dll + 0x183760, char*, __fastcall, ()) -// clang-format on { if (!g_pVanillaCompatibility->GetVanillaCompatibility() && g_pMasterServerManager->m_sOwnClientAuthToken[0]) { diff --git a/primedev/client/clientruihooks.cpp b/primedev/client/clientruihooks.cpp index ad50d11a8..82f18643c 100644 --- a/primedev/client/clientruihooks.cpp +++ b/primedev/client/clientruihooks.cpp @@ -4,10 +4,8 @@ AUTOHOOK_INIT() ConVar* Cvar_rui_drawEnable; -// clang-format off AUTOHOOK(DrawRUIFunc, engine.dll + 0xFC500, bool, __fastcall, (void* a1, float* a2)) -// clang-format on { if (!Cvar_rui_drawEnable->GetBool()) return 0; diff --git a/primedev/client/clientvideooverrides.cpp b/primedev/client/clientvideooverrides.cpp index d8aa27541..2090cbdff 100644 --- a/primedev/client/clientvideooverrides.cpp +++ b/primedev/client/clientvideooverrides.cpp @@ -2,10 +2,8 @@ AUTOHOOK_INIT() -// clang-format off AUTOHOOK_PROCADDRESS(BinkOpen, bink2w64.dll, BinkOpen, void*, __fastcall, (const char* path, uint32_t flags)) -// clang-format on { std::string filename(fs::path(path).filename().string()); spdlog::info("BinkOpen {}", filename); diff --git a/primedev/client/debugoverlay.cpp b/primedev/client/debugoverlay.cpp index 7f2e09015..51a8d0363 100644 --- a/primedev/client/debugoverlay.cpp +++ b/primedev/client/debugoverlay.cpp @@ -122,10 +122,8 @@ OverlayBase_t** s_pOverlays; int* g_nRenderTickCount; int* g_nOverlayTickCount; -// clang-format off AUTOHOOK(DrawOverlay, engine.dll + 0xABCB0, void, __fastcall, (OverlayBase_t * pOverlay)) -// clang-format on { EnterCriticalSection(s_OverlayMutex); @@ -205,10 +203,8 @@ void, __fastcall, (OverlayBase_t * pOverlay)) LeaveCriticalSection(s_OverlayMutex); } -// clang-format off AUTOHOOK(DrawAllOverlays, engine.dll + 0xAB780, void, __fastcall, (bool bRender)) -// clang-format on { EnterCriticalSection(s_OverlayMutex); diff --git a/primedev/client/languagehooks.cpp b/primedev/client/languagehooks.cpp index 36b5d5aed..92bf0411f 100644 --- a/primedev/client/languagehooks.cpp +++ b/primedev/client/languagehooks.cpp @@ -48,10 +48,8 @@ std::string GetAnyInstalledAudioLanguage() return "NO LANGUAGE DETECTED"; } -// clang-format off AUTOHOOK(GetGameLanguage, tier0.dll + 0xF560, char*, __fastcall, ()) -// clang-format on { auto tier0Handle = GetModuleHandleA("tier0.dll"); auto Tier0_DetectDefaultLanguageType = GetProcAddress(tier0Handle, "Tier0_DetectDefaultLanguage"); diff --git a/primedev/client/latencyflex.cpp b/primedev/client/latencyflex.cpp index 395578709..01bda47ee 100644 --- a/primedev/client/latencyflex.cpp +++ b/primedev/client/latencyflex.cpp @@ -6,10 +6,8 @@ ConVar* Cvar_r_latencyflex; void (*m_winelfx_WaitAndBeginFrame)(); -// clang-format off AUTOHOOK(OnRenderStart, client.dll + 0x1952C0, void, __fastcall, ()) -// clang-format on { if (Cvar_r_latencyflex->GetBool() && m_winelfx_WaitAndBeginFrame) m_winelfx_WaitAndBeginFrame(); diff --git a/primedev/client/modlocalisation.cpp b/primedev/client/modlocalisation.cpp index 2b73876b3..87ca147db 100644 --- a/primedev/client/modlocalisation.cpp +++ b/primedev/client/modlocalisation.cpp @@ -4,10 +4,8 @@ AUTOHOOK_INIT() void* g_pVguiLocalize; -// clang-format off AUTOHOOK(CLocalize__AddFile, localize.dll + 0x6D80, bool, __fastcall, (void* pVguiLocalize, const char* path, const char* pathId, bool bIncludeFallbackSearchPaths)) -// clang-format on { // save this for later g_pVguiLocalize = pVguiLocalize; @@ -19,10 +17,8 @@ bool, __fastcall, (void* pVguiLocalize, const char* path, const char* pathId, bo return true; } -// clang-format off AUTOHOOK(CLocalize__ReloadLocalizationFiles, localize.dll + 0xB830, void, __fastcall, (void* pVguiLocalize)) -// clang-format on { // load all mod localization manually, so we keep track of all files, not just previously loaded ones for (Mod mod : g_pModManager->m_LoadedMods) @@ -34,10 +30,8 @@ void, __fastcall, (void* pVguiLocalize)) CLocalize__ReloadLocalizationFiles(pVguiLocalize); } -// clang-format off AUTOHOOK(CEngineVGui__Init, engine.dll + 0x247E10, void, __fastcall, (void* self)) -// clang-format on { CEngineVGui__Init(self); // this loads r1_english, valve_english, dev_english diff --git a/primedev/client/rejectconnectionfixes.cpp b/primedev/client/rejectconnectionfixes.cpp index 1b326a3c8..0230b1491 100644 --- a/primedev/client/rejectconnectionfixes.cpp +++ b/primedev/client/rejectconnectionfixes.cpp @@ -3,10 +3,8 @@ AUTOHOOK_INIT() // this is called from when our connection is rejected, this is the only case we're hooking this for -// clang-format off AUTOHOOK(COM_ExplainDisconnection, engine.dll + 0x1342F0, void,, (bool a1, const char* fmt, ...)) -// clang-format on { va_list va; va_start(va, fmt); diff --git a/primedev/core/filesystem/filesystem.cpp b/primedev/core/filesystem/filesystem.cpp index b39939e45..41e0a5b54 100644 --- a/primedev/core/filesystem/filesystem.cpp +++ b/primedev/core/filesystem/filesystem.cpp @@ -44,10 +44,8 @@ std::string ReadVPKOriginalFile(const char* path) return ret; } -// clang-format off HOOK(AddSearchPathHook, AddSearchPath, void, __fastcall, (IFileSystem * fileSystem, const char* pPath, const char* pathID, SearchPathAdd_t addType)) -// clang-format on { AddSearchPath(fileSystem, pPath, pathID, addType); @@ -97,10 +95,8 @@ bool TryReplaceFile(const char* pPath, bool shouldCompile) } // force modded files to be read from mods, not cache -// clang-format off HOOK(ReadFromCacheHook, ReadFromCache, bool, __fastcall, (IFileSystem * filesystem, char* pPath, void* result)) -// clang-format off { if (TryReplaceFile(pPath, true)) return false; @@ -109,10 +105,8 @@ bool, __fastcall, (IFileSystem * filesystem, char* pPath, void* result)) } // force modded files to be read from mods, not vpk -// clang-format off AUTOHOOK(ReadFileFromVPK, filesystem_stdio.dll + 0x5CBA0, FileHandle_t, __fastcall, (VPKData* vpkInfo, uint64_t* b, char* filename)) -// clang-format on { // don't compile here because this is only ever called from OpenEx, which already compiles if (TryReplaceFile(filename, false)) @@ -124,10 +118,8 @@ FileHandle_t, __fastcall, (VPKData* vpkInfo, uint64_t* b, char* filename)) return ReadFileFromVPK(vpkInfo, b, filename); } -// clang-format off AUTOHOOK(CBaseFileSystem__OpenEx, filesystem_stdio.dll + 0x15F50, FileHandle_t, __fastcall, (IFileSystem* filesystem, const char* pPath, const char* pOptions, uint32_t flags, const char* pPathID, char **ppszResolvedFilename)) -// clang-format on { TryReplaceFile(pPath, true); return CBaseFileSystem__OpenEx(filesystem, pPath, pOptions, flags, pPathID, ppszResolvedFilename); diff --git a/primedev/core/filesystem/rpakfilesystem.cpp b/primedev/core/filesystem/rpakfilesystem.cpp index da72646b9..eef522c35 100644 --- a/primedev/core/filesystem/rpakfilesystem.cpp +++ b/primedev/core/filesystem/rpakfilesystem.cpp @@ -174,10 +174,8 @@ void LoadCustomMapPaks(char** pakName, bool* bNeedToFreePakName) } } -// clang-format off HOOK(LoadPakAsyncHook, LoadPakAsync, int, __fastcall, (char* pPath, void* unknownSingleton, int flags, void* pCallback0, void* pCallback1)) -// clang-format on { HandlePakAliases(&pPath); @@ -233,10 +231,8 @@ int, __fastcall, (char* pPath, void* unknownSingleton, int flags, void* pCallbac return iPakHandle; } -// clang-format off HOOK(UnloadPakHook, UnloadPak, void*, __fastcall, (int nPakHandle, void* pCallback)) -// clang-format on { // stop tracking the pak g_pPakLoadManager->RemoveLoadedPak(nPakHandle); @@ -255,10 +251,8 @@ void*, __fastcall, (int nPakHandle, void* pCallback)) // we hook this exclusively for resolving stbsp paths, but seemingly it's also used for other stuff like vpk, rpak, mprj and starpak loads // tbh this actually might be for memory mapped files or something, would make sense i think -// clang-format off HOOK(ReadFileAsyncHook, ReadFileAsync, void*, __fastcall, (const char* pPath, void* pCallback)) -// clang-format on { fs::path path(pPath); std::string newPath = ""; diff --git a/primedev/core/math/color.cpp b/primedev/core/math/color.cpp index 7b98043a3..c6991dcc6 100644 --- a/primedev/core/math/color.cpp +++ b/primedev/core/math/color.cpp @@ -1,5 +1,4 @@ -// clang-format off namespace NS::Colors { Color SCRIPT_UI (100, 255, 255); @@ -24,4 +23,3 @@ namespace NS::Colors Color CRIT (255, 0 , 0 ); Color OFF (0 , 0 , 0 ); }; -// clang-format on diff --git a/primedev/core/sourceinterface.cpp b/primedev/core/sourceinterface.cpp index 5a72beb07..302ffe52a 100644 --- a/primedev/core/sourceinterface.cpp +++ b/primedev/core/sourceinterface.cpp @@ -5,10 +5,8 @@ AUTOHOOK_INIT() // really wanted to do a modular callback system here but honestly couldn't be bothered so hardcoding stuff for now: todo later -// clang-format off AUTOHOOK_PROCADDRESS(ClientCreateInterface, client.dll, CreateInterface, void*, __fastcall, (const char* pName, const int* pReturnCode)) -// clang-format on { void* ret = ClientCreateInterface(pName, pReturnCode); spdlog::info("CreateInterface CLIENT {}", pName); @@ -19,10 +17,8 @@ void*, __fastcall, (const char* pName, const int* pReturnCode)) return ret; } -// clang-format off AUTOHOOK_PROCADDRESS(ServerCreateInterface, server.dll, CreateInterface, void*, __fastcall, (const char* pName, const int* pReturnCode)) -// clang-format on { void* ret = ServerCreateInterface(pName, pReturnCode); spdlog::info("CreateInterface SERVER {}", pName); @@ -30,10 +26,8 @@ void*, __fastcall, (const char* pName, const int* pReturnCode)) return ret; } -// clang-format off AUTOHOOK_PROCADDRESS(EngineCreateInterface, engine.dll, CreateInterface, void*, __fastcall, (const char* pName, const int* pReturnCode)) -// clang-format on { void* ret = EngineCreateInterface(pName, pReturnCode); spdlog::info("CreateInterface ENGINE {}", pName); @@ -41,8 +35,6 @@ void*, __fastcall, (const char* pName, const int* pReturnCode)) return ret; } -// clang-format off ON_DLL_LOAD("client.dll", ClientInterface, (CModule module)) {AUTOHOOK_DISPATCH_MODULE(client.dll)} ON_DLL_LOAD("server.dll", ServerInterface, (CModule module)) {AUTOHOOK_DISPATCH_MODULE(server.dll)} ON_DLL_LOAD("engine.dll", EngineInterface, (CModule module)) {AUTOHOOK_DISPATCH_MODULE(engine.dll)} -// clang-format on diff --git a/primedev/dedicated/dedicated.cpp b/primedev/dedicated/dedicated.cpp index eca9b9f1f..d8c4c7a1c 100644 --- a/primedev/dedicated/dedicated.cpp +++ b/primedev/dedicated/dedicated.cpp @@ -114,10 +114,8 @@ DWORD WINAPI ConsoleInputThread(PVOID pThreadParameter) return 0; } -// clang-format off AUTOHOOK(IsGameActiveWindow, engine.dll + 0x1CDC80, bool,, ()) -// clang-format on { return true; } @@ -270,10 +268,8 @@ ON_DLL_LOAD_DEDI("tier0.dll", DedicatedServerOrigin, (CModule module)) module.GetExportedFunction("Tier0_InitOrigin").Patch("C3"); } -// clang-format off AUTOHOOK(PrintSquirrelError, server.dll + 0x794D0, void, __fastcall, (void* sqvm)) -// clang-format on { PrintSquirrelError(sqvm); diff --git a/primedev/dedicated/dedicatedmaterialsystem.cpp b/primedev/dedicated/dedicatedmaterialsystem.cpp index 010780862..3aba056e5 100644 --- a/primedev/dedicated/dedicatedmaterialsystem.cpp +++ b/primedev/dedicated/dedicatedmaterialsystem.cpp @@ -3,7 +3,6 @@ AUTOHOOK_INIT() -// clang-format off AUTOHOOK(D3D11CreateDevice, materialsystem_dx11.dll + 0xD9A0E, HRESULT, __stdcall, ( void* pAdapter, @@ -16,7 +15,6 @@ HRESULT, __stdcall, ( void** ppDevice, int* pFeatureLevel, void** ppImmediateContext)) -// clang-format on { // note: this is super duper temp pretty much just messing around with it // does run surprisingly well on dedi for a software driver tho if you ignore the +1gb ram usage at times, seems like dedi doesn't diff --git a/primedev/engine/host.cpp b/primedev/engine/host.cpp index dacb8fc1c..dfef4a599 100644 --- a/primedev/engine/host.cpp +++ b/primedev/engine/host.cpp @@ -8,10 +8,8 @@ AUTOHOOK_INIT() -// clang-format off AUTOHOOK(Host_Init, engine.dll + 0x155EA0, void, __fastcall, (bool bDedicated)) -// clang-format on { spdlog::info("Host_Init()"); Host_Init(bDedicated); diff --git a/primedev/engine/hoststate.cpp b/primedev/engine/hoststate.cpp index d5942551a..5bb9589a2 100644 --- a/primedev/engine/hoststate.cpp +++ b/primedev/engine/hoststate.cpp @@ -53,10 +53,8 @@ void ServerStartingOrChangingMap() g_pServerAuthentication->m_bStartingLocalSPGame = false; } -// clang-format off AUTOHOOK(CHostState__State_NewGame, engine.dll + 0x16E7D0, void, __fastcall, (CHostState* self)) -// clang-format on { spdlog::info("HostState: NewGame"); @@ -82,10 +80,8 @@ void, __fastcall, (CHostState* self)) g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false; } -// clang-format off AUTOHOOK(CHostState__State_LoadGame, engine.dll + 0x16E730, void, __fastcall, (CHostState* self)) -// clang-format on { // singleplayer server starting // useless in 99% of cases but without it things could potentially break very much @@ -109,10 +105,8 @@ void, __fastcall, (CHostState* self)) g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false; } -// clang-format off AUTOHOOK(CHostState__State_ChangeLevelMP, engine.dll + 0x16E520, void, __fastcall, (CHostState* self)) -// clang-format on { spdlog::info("HostState: ChangeLevelMP"); @@ -125,10 +119,8 @@ void, __fastcall, (CHostState* self)) g_pServerPresence->SetMap(g_pHostState->m_levelName); } -// clang-format off AUTOHOOK(CHostState__State_GameShutdown, engine.dll + 0x16E640, void, __fastcall, (CHostState* self)) -// clang-format on { spdlog::info("HostState: GameShutdown"); @@ -153,10 +145,8 @@ void, __fastcall, (CHostState* self)) } } -// clang-format off AUTOHOOK(CHostState__FrameUpdate, engine.dll + 0x16DB00, void, __fastcall, (CHostState* self, double flCurrentTime, float flFrameTime)) -// clang-format on { CHostState__FrameUpdate(self, flCurrentTime, flFrameTime); diff --git a/primedev/engine/runframe.cpp b/primedev/engine/runframe.cpp index ddfd92534..be4d49c2c 100644 --- a/primedev/engine/runframe.cpp +++ b/primedev/engine/runframe.cpp @@ -5,10 +5,8 @@ AUTOHOOK_INIT() -// clang-format off AUTOHOOK(CEngine__Frame, engine.dll + 0x1C8650, void, __fastcall, (CEngine* self)) -// clang-format on { CEngine__Frame(self); } diff --git a/primedev/logging/crashhandler.cpp b/primedev/logging/crashhandler.cpp index 75ca85442..484d89547 100644 --- a/primedev/logging/crashhandler.cpp +++ b/primedev/logging/crashhandler.cpp @@ -212,7 +212,6 @@ const CHAR* CCrashHandler::GetExceptionString() const //----------------------------------------------------------------------------- const CHAR* CCrashHandler::GetExceptionString(DWORD dwExceptionCode) const { - // clang-format off switch (dwExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: return "EXCEPTION_ACCESS_VIOLATION"; @@ -239,7 +238,6 @@ const CHAR* CCrashHandler::GetExceptionString(DWORD dwExceptionCode) const case EXCEPTION_INVALID_HANDLE: return "EXCEPTION_INVALID_HANDLE"; case 3765269347: return "RUNTIME_EXCEPTION"; } - // clang-format on return "UNKNOWN_EXCEPTION"; } @@ -256,7 +254,6 @@ bool CCrashHandler::IsExceptionFatal() const //----------------------------------------------------------------------------- bool CCrashHandler::IsExceptionFatal(DWORD dwExceptionCode) const { - // clang-format off switch (dwExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: @@ -283,7 +280,6 @@ bool CCrashHandler::IsExceptionFatal(DWORD dwExceptionCode) const case EXCEPTION_INVALID_HANDLE: return true; } - // clang-format on return false; } diff --git a/primedev/logging/loghooks.cpp b/primedev/logging/loghooks.cpp index dcd9b85a8..731b8e8ea 100644 --- a/primedev/logging/loghooks.cpp +++ b/primedev/logging/loghooks.cpp @@ -70,10 +70,8 @@ const std::unordered_map PrintSpewTypes_Short = { ICenterPrint* pInternalCenterPrint = NULL; -// clang-format off AUTOHOOK(TextMsg, client.dll + 0x198710, void,, (BFRead* msg)) -// clang-format on { TextMsgPrintType_t msg_dest = (TextMsgPrintType_t)msg->ReadByte(); @@ -103,10 +101,8 @@ void,, (BFRead* msg)) } } -// clang-format off AUTOHOOK(Hook_fprintf, engine.dll + 0x51B1F0, int,, (void* const stream, const char* const format, ...)) -// clang-format on { NOTE_UNUSED(stream); @@ -127,19 +123,15 @@ int,, (void* const stream, const char* const format, ...)) return 0; } -// clang-format off AUTOHOOK(ConCommand_echo, engine.dll + 0x123680, void,, (const CCommand& arg)) -// clang-format on { if (arg.ArgC() >= 2) NS::log::echo->info("{}", arg.ArgS()); } -// clang-format off AUTOHOOK(EngineSpewFunc, engine.dll + 0x11CA80, void, __fastcall, (void* pEngineServer, SpewType_t type, const char* format, va_list args)) -// clang-format on { NOTE_UNUSED(pEngineServer); if (!Cvar_spewlog_enable->GetBool()) @@ -214,10 +206,8 @@ void, __fastcall, (void* pEngineServer, SpewType_t type, const char* format, va_ } // used for printing the output of status -// clang-format off AUTOHOOK(Status_ConMsg, engine.dll + 0x15ABD0, void,, (const char* text, ...)) -// clang-format on { char formatted[2048]; va_list list; @@ -233,10 +223,8 @@ void,, (const char* text, ...)) spdlog::info(formatted); } -// clang-format off AUTOHOOK(CClientState_ProcessPrint, engine.dll + 0x1A1530, bool,, (void* thisptr, uintptr_t msg)) -// clang-format on { NOTE_UNUSED(thisptr); diff --git a/primedev/logging/sourceconsole.cpp b/primedev/logging/sourceconsole.cpp index 55be47237..73fdc59c2 100644 --- a/primedev/logging/sourceconsole.cpp +++ b/primedev/logging/sourceconsole.cpp @@ -56,10 +56,8 @@ void SourceConsoleSink::sink_it_(const spdlog::details::log_msg& msg) void SourceConsoleSink::flush_() {} -// clang-format off HOOK(OnCommandSubmittedHook, OnCommandSubmitted, void, __fastcall, (CConsoleDialog* consoleDialog, const char* pCommand)) -// clang-format on { consoleDialog->m_pConsolePanel->Print("] "); consoleDialog->m_pConsolePanel->Print(pCommand); diff --git a/primedev/ns_version.h b/primedev/ns_version.h index d30594fbd..13ce7bba4 100644 --- a/primedev/ns_version.h +++ b/primedev/ns_version.h @@ -1,7 +1,4 @@ #pragma once #ifndef NORTHSTAR_VERSION -// Turning off clang-format here so it doesn't mess with style as it needs to be this way for regex-ing with CI -// clang-format off #define NORTHSTAR_VERSION 0,0,0,1 -// clang-format on #endif diff --git a/primedev/pch.h b/primedev/pch.h index bfd255976..876d6b208 100644 --- a/primedev/pch.h +++ b/primedev/pch.h @@ -20,9 +20,7 @@ namespace fs = std::filesystem; -// clang-format off #define assert_msg(exp, msg) assert((exp, msg)) -//clang-format on #define NOTE_UNUSED(var) do { (void)var; } while(false) diff --git a/primedev/scripts/client/clientchathooks.cpp b/primedev/scripts/client/clientchathooks.cpp index e084f47e9..940462bcb 100644 --- a/primedev/scripts/client/clientchathooks.cpp +++ b/primedev/scripts/client/clientchathooks.cpp @@ -8,10 +8,8 @@ AUTOHOOK_INIT() -// clang-format off AUTOHOOK(CHudChat__AddGameLine, client.dll + 0x22E580, void, __fastcall, (void* self, const char* message, int inboxId, bool isTeam, bool isDead)) -// clang-format on { // This hook is called for each HUD, but we only want our logic to run once. if (self != *CHudChat::allHuds) diff --git a/primedev/scripts/client/scriptbrowserhooks.cpp b/primedev/scripts/client/scriptbrowserhooks.cpp index dcf051d22..4da495bd0 100644 --- a/primedev/scripts/client/scriptbrowserhooks.cpp +++ b/primedev/scripts/client/scriptbrowserhooks.cpp @@ -3,10 +3,8 @@ AUTOHOOK_INIT() bool* bIsOriginOverlayEnabled; -// clang-format off AUTOHOOK(OpenExternalWebBrowser, engine.dll + 0x184E40, void, __fastcall, (char* pUrl, char flags)) -// clang-format on { bool bIsOriginOverlayEnabledOriginal = *bIsOriginOverlayEnabled; bool isHttp = !strncmp(pUrl, "http://", 7) || !strncmp(pUrl, "https://", 8); diff --git a/primedev/scripts/scripthttprequesthandler.cpp b/primedev/scripts/scripthttprequesthandler.cpp index 69828a5a2..da3885a1f 100644 --- a/primedev/scripts/scripthttprequesthandler.cpp +++ b/primedev/scripts/scripthttprequesthandler.cpp @@ -152,7 +152,6 @@ bool IsHttpDestinationHostAllowed(const std::string& host, std::string& outHostn } // Fast checks for private ranges of IPv4. - // clang-format off { auto addrBytes = sockaddr_ipv4->sin_addr.S_un.S_un_b; @@ -182,9 +181,7 @@ bool IsHttpDestinationHostAllowed(const std::string& host, std::string& outHostn return false; } } - - // clang-format on - + char resolvedStr[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &sockaddr_ipv4->sin_addr, resolvedStr, INET_ADDRSTRLEN); diff --git a/primedev/scripts/server/scriptuserinfo.cpp b/primedev/scripts/server/scriptuserinfo.cpp index c53a9d223..fdf8e6719 100644 --- a/primedev/scripts/server/scriptuserinfo.cpp +++ b/primedev/scripts/server/scriptuserinfo.cpp @@ -2,10 +2,8 @@ #include "engine/r2engine.h" #include "server/r2server.h" -// clang-format off ADD_SQFUNC("string", GetUserInfoKVString_Internal, "entity player, string key, string defaultValue = \"\"", "Gets the string value of a given player's userinfo convar by name", ScriptContext::SERVER) -// clang-format on { const CBasePlayer* pPlayer = g_pSquirrel->template getentity(sqvm, 1); if (!pPlayer) @@ -22,10 +20,8 @@ ADD_SQFUNC("string", GetUserInfoKVString_Internal, "entity player, string key, s return SQRESULT_NOTNULL; } -// clang-format off ADD_SQFUNC("asset", GetUserInfoKVAsset_Internal, "entity player, string key, asset defaultValue = $\"\"", "Gets the asset value of a given player's userinfo convar by name", ScriptContext::SERVER) -// clang-format on { const CBasePlayer* pPlayer = g_pSquirrel->template getentity(sqvm, 1); if (!pPlayer) @@ -43,10 +39,8 @@ ADD_SQFUNC("asset", GetUserInfoKVAsset_Internal, "entity player, string key, ass return SQRESULT_NOTNULL; } -// clang-format off ADD_SQFUNC("int", GetUserInfoKVInt_Internal, "entity player, string key, int defaultValue = 0", "Gets the int value of a given player's userinfo convar by name", ScriptContext::SERVER) -// clang-format on { const CBasePlayer* pPlayer = g_pSquirrel->template getentity(sqvm, 1); if (!pPlayer) @@ -63,10 +57,8 @@ ADD_SQFUNC("int", GetUserInfoKVInt_Internal, "entity player, string key, int def return SQRESULT_NOTNULL; } -// clang-format off ADD_SQFUNC("float", GetUserInfoKVFloat_Internal, "entity player, string key, float defaultValue = 0", "Gets the float value of a given player's userinfo convar by name", ScriptContext::SERVER) -// clang-format on { const CBasePlayer* pPlayer = g_pSquirrel->getentity(sqvm, 1); if (!pPlayer) @@ -83,10 +75,8 @@ ADD_SQFUNC("float", GetUserInfoKVFloat_Internal, "entity player, string key, flo return SQRESULT_NOTNULL; } -// clang-format off ADD_SQFUNC("bool", GetUserInfoKVBool_Internal, "entity player, string key, bool defaultValue = false", "Gets the bool value of a given player's userinfo convar by name", ScriptContext::SERVER) -// clang-format on { const CBasePlayer* pPlayer = g_pSquirrel->getentity(sqvm, 1); if (!pPlayer) diff --git a/primedev/server/auth/serverauthentication.cpp b/primedev/server/auth/serverauthentication.cpp index d0d4c698f..a19de9fd4 100644 --- a/primedev/server/auth/serverauthentication.cpp +++ b/primedev/server/auth/serverauthentication.cpp @@ -207,7 +207,6 @@ void ServerAuthenticationManager::WritePersistentData(CBaseClient* pPlayer) char* pNextPlayerToken; uint64_t iNextPlayerUid; -// clang-format off AUTOHOOK(CBaseServer__ConnectClient, engine.dll + 0x114430, void*,, ( void* self, @@ -227,7 +226,6 @@ void*,, ( int64_t uid, uint32_t a16, uint32_t a17)) -// clang-format on { // auth tokens are sent with serverfilter, can't be accessed from player struct to my knowledge, so have to do this here pNextPlayerToken = serverFilter; @@ -238,10 +236,8 @@ void*,, ( ConVar* Cvar_ns_allowuserclantags; -// clang-format off AUTOHOOK(CBaseClient__Connect, engine.dll + 0x101740, bool,, (CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer, void* a5, char pDisconnectReason[256], void* a7)) -// clang-format on { const char* pAuthenticationFailure = nullptr; char pVerifiedName[64]; @@ -279,10 +275,8 @@ bool,, (CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer, voi return true; } -// clang-format off AUTOHOOK(CBaseClient__ActivatePlayer, engine.dll + 0x100F80, void,, (CBaseClient* self)) -// clang-format on { // if we're authed, write our persistent data // RemovePlayerAuthData returns true if it removed successfully, i.e. on first call only, and we only want to write on >= second call @@ -297,10 +291,8 @@ void,, (CBaseClient* self)) CBaseClient__ActivatePlayer(self); } -// clang-format off AUTOHOOK(_CBaseClient__Disconnect, engine.dll + 0x1012C0, void,, (CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...)) -// clang-format on { // have to manually format message because can't pass varargs to original func char buf[1024]; diff --git a/primedev/server/buildainfile.cpp b/primedev/server/buildainfile.cpp index 19a6d0e36..bca0a83a6 100644 --- a/primedev/server/buildainfile.cpp +++ b/primedev/server/buildainfile.cpp @@ -359,20 +359,16 @@ void DumpAINInfo(CAI_Network* aiNetwork) writeStream.close(); } -// clang-format off AUTOHOOK(CAI_NetworkBuilder__Build, server.dll + 0x385E20, void, __fastcall, (void* builder, CAI_Network* aiNetwork, void* unknown)) -// clang-format on { CAI_NetworkBuilder__Build(builder, aiNetwork, unknown); DumpAINInfo(aiNetwork); } -// clang-format off AUTOHOOK(LoadAINFile, server.dll + 0x3933A0, void, __fastcall, (void* aimanager, void* buf, const char* filename)) -// clang-format on { LoadAINFile(aimanager, buf, filename); diff --git a/primedev/server/serverchathooks.cpp b/primedev/server/serverchathooks.cpp index d3ac47762..1862aa014 100644 --- a/primedev/server/serverchathooks.cpp +++ b/primedev/server/serverchathooks.cpp @@ -35,10 +35,8 @@ void(__fastcall* MessageWriteString)(const char* sz); void(__fastcall* MessageWriteBool)(bool bValue); bool bShouldCallSayTextHook = false; -// clang-format off AUTOHOOK(_CServerGameDLL__OnReceivedSayTextMessage, server.dll + 0x1595C0, void, __fastcall, (CServerGameDLL* self, unsigned int senderPlayerId, const char* text, bool isTeam)) -// clang-format on { RemoveAsciiControlSequences(const_cast(text), true); diff --git a/primedev/server/serverpresence.cpp b/primedev/server/serverpresence.cpp index 099f6e648..fcd5bb202 100644 --- a/primedev/server/serverpresence.cpp +++ b/primedev/server/serverpresence.cpp @@ -73,7 +73,6 @@ std::string UnescapeUnicode(const std::string& str) void ServerPresenceManager::CreateConVars() { - // clang-format off // register convars Cvar_ns_server_presence_update_rate = new ConVar( "ns_server_presence_update_rate", "5000", FCVAR_GAMEDLL, "How often we update our server's presence on server lists in ms"); @@ -104,7 +103,6 @@ void ServerPresenceManager::CreateConVars() Cvar_ns_report_server_to_masterserver = new ConVar("ns_report_server_to_masterserver", "1", FCVAR_GAMEDLL, "Whether we should report this server to the masterserver"); Cvar_ns_report_sp_server_to_masterserver = new ConVar("ns_report_sp_server_to_masterserver", "0", FCVAR_GAMEDLL, "Whether we should report this server to the masterserver, when started in singleplayer"); - // clang-format on } void ServerPresenceManager::AddPresenceReporter(ServerPresenceReporter* reporter) diff --git a/primedev/shared/exploit_fixes/exploitfixes.cpp b/primedev/shared/exploit_fixes/exploitfixes.cpp index 1b3069f5a..a0c1a8181 100644 --- a/primedev/shared/exploit_fixes/exploitfixes.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes.cpp @@ -29,20 +29,16 @@ ConVar* Cvar_sv_cheats; // block bad netmessages // Servers can literally request a screenshot from any client, yeah no -// clang-format off AUTOHOOK(CLC_Screenshot_WriteToBuffer, engine.dll + 0x22AF20, bool, __fastcall, (void* thisptr, void* buffer)) // 48 89 5C 24 ? 57 48 83 EC 20 8B 42 10 -// clang-format on { if (g_pVanillaCompatibility->GetVanillaCompatibility()) return CLC_Screenshot_WriteToBuffer(thisptr, buffer); return false; } -// clang-format off AUTOHOOK(CLC_Screenshot_ReadFromBuffer, engine.dll + 0x221F00, bool, __fastcall, (void* thisptr, void* buffer)) // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B DA 48 8B 52 38 -// clang-format on { if (g_pVanillaCompatibility->GetVanillaCompatibility()) return CLC_Screenshot_ReadFromBuffer(thisptr, buffer); @@ -50,20 +46,16 @@ bool, __fastcall, (void* thisptr, void* buffer)) // 48 89 5C 24 ? 48 89 6C 24 ? } // This is unused ingame and a big client=>server=>client exploit vector -// clang-format off AUTOHOOK(Base_CmdKeyValues_ReadFromBuffer, engine.dll + 0x220040, bool, __fastcall, (void* thisptr, void* buffer)) // 40 55 48 81 EC ? ? ? ? 48 8D 6C 24 ? 48 89 5D 70 -// clang-format on { NOTE_UNUSED(thisptr); NOTE_UNUSED(buffer); return false; } -// clang-format off AUTOHOOK(CClient_ProcessSetConVar, engine.dll + 0x75CF0, bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10 -// clang-format on { constexpr int ENTRY_STR_LEN = 260; @@ -157,10 +149,8 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10 } // prevent invalid user CMDs -// clang-format off AUTOHOOK(CClient_ProcessUsercmds, engine.dll + 0x1040F0, bool, __fastcall, (void* thisptr, void* pMsg)) // 40 55 56 48 83 EC 58 -// clang-format on { struct CLC_Move { @@ -193,10 +183,8 @@ bool, __fastcall, (void* thisptr, void* pMsg)) // 40 55 56 48 83 EC 58 return CClient_ProcessUsercmds(thisptr, pMsg); } -// clang-format off AUTOHOOK(ReadUsercmd, server.dll + 0x2603F0, void, __fastcall, (void* buf, void* pCmd_move, void* pCmd_from)) // 4C 89 44 24 ? 53 55 56 57 -// clang-format on { // Let normal usercmd read happen first, it's safe ReadUsercmd(buf, pCmd_move, pCmd_from); @@ -278,10 +266,8 @@ void, __fastcall, (void* buf, void* pCmd_move, void* pCmd_from)) // 4C 89 44 24 // ensure that GetLocalBaseClient().m_bRestrictServerCommands is set correctly, which the return value of this function controls // this is IsValveMod in source, but we're making it IsRespawnMod now since valve didn't make this one -// clang-format off AUTOHOOK(IsRespawnMod, engine.dll + 0x1C6360, bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D 15 ? ? ? ? E8 ? ? ? ? 85 C0 74 63 -// clang-format on { // somewhat temp, store the modname here, since we don't have a proper ptr in engine to it rn size_t iSize = strlen(pModName); @@ -295,10 +281,8 @@ bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D } // ratelimit stringcmds, and prevent remote clients from calling commands that they shouldn't -// clang-format off AUTOHOOK(CGameClient__ExecuteStringCommand, engine.dll + 0x1022E0, bool, __fastcall, (CBaseClient* self, uint32_t unknown, const char* pCommandString)) -// clang-format on { if (Cvar_ns_should_log_all_clientcommands->GetBool()) spdlog::info("player {} (UID: {}) sent command: \"{}\"", self->m_Name, self->m_UID, pCommandString); @@ -369,10 +353,8 @@ bool, __fastcall, (CBaseClient* self, uint32_t unknown, const char* pCommandStri // prevent clients from crashing servers through overflowing CNetworkStringTableContainer::WriteBaselines bool bWasWritingStringTableSuccessful; -// clang-format off AUTOHOOK(CBaseClient__SendServerInfo, engine.dll + 0x104FB0, void, __fastcall, (void* self)) -// clang-format on { bWasWritingStringTableSuccessful = true; CBaseClient__SendServerInfo(self); @@ -383,10 +365,8 @@ void, __fastcall, (void* self)) // return null when GetEntByIndex is passed an index >= 0x4000 // this is called from exactly 1 script clientcommand that can be given an arbitrary index, and going above 0x4000 crashes -// clang-format off AUTOHOOK(GetEntByIndex, server.dll + 0x2A8A50, void*, __fastcall, (int i)) -// clang-format on { const int MAX_ENT_IDX = 0x4000; @@ -398,10 +378,9 @@ void*, __fastcall, (int i)) return GetEntByIndex(i); } -// clang-format off + AUTOHOOK(CL_CopyExistingEntity, engine.dll + 0x6F940, bool, __fastcall, (void* a1)) -// clang-format on { struct CEntityReadInfo { diff --git a/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp b/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp index 9a9a5691c..c38fceab0 100644 --- a/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes_lzss.cpp @@ -11,10 +11,8 @@ struct lzss_header_t // Rewrite of CLZSS::SafeUncompress to fix a vulnerability where malicious compressed payloads could cause the decompressor to try to read // out of the bounds of the output buffer. -// clang-format off AUTOHOOK(CLZSS__SafeDecompress, engine.dll + 0x432A10, unsigned int, __fastcall, (void* self, const unsigned char* pInput, unsigned char* pOutput, unsigned int unBufSize)) -// clang-format on { NOTE_UNUSED(self); unsigned int totalBytes = 0; diff --git a/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp b/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp index d63ba38a1..e4213ab49 100644 --- a/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp +++ b/primedev/shared/exploit_fixes/exploitfixes_utf8parser.cpp @@ -169,10 +169,8 @@ bool __fastcall CheckUTF8Valid(INT64* a1, DWORD* a2, char* strData) } // prevent utf8 parser from crashing when provided bad data, which can be sent through user-controlled openinvites -// clang-format off AUTOHOOK(Rson_ParseUTF8, engine.dll + 0xEF670, bool, __fastcall, (INT64* a1, DWORD* a2, char* strData)) // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 54 41 55 41 56 41 57 48 83 EC 20 8B 1A -// clang-format on { static void* targetRetAddr = CModule("engine.dll").FindPatternSIMD("84 C0 75 2C 49 8B 16"); diff --git a/primedev/shared/exploit_fixes/ns_limits.cpp b/primedev/shared/exploit_fixes/ns_limits.cpp index 63abbf69b..0f5c1b9f9 100644 --- a/primedev/shared/exploit_fixes/ns_limits.cpp +++ b/primedev/shared/exploit_fixes/ns_limits.cpp @@ -90,10 +90,8 @@ bool ServerLimitsManager::CheckChatLimits(CBaseClient* player) return true; } -// clang-format off AUTOHOOK(CNetChan__ProcessMessages, engine.dll + 0x2140A0, char, __fastcall, (void* self, void* buf)) -// clang-format on { enum eNetChanLimitMode { @@ -231,10 +229,8 @@ struct alignas(4) SV_CUserCmd float frameTime; }; -// clang-format off AUTOHOOK(CPlayerMove__RunCommand, server.dll + 0x5B8100, void, __fastcall, (void* self, CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4)) -// clang-format on { if (g_pServerLimits->Cvar_sv_antispeedhack_enable->GetBool()) { diff --git a/primedev/shared/keyvalues.cpp b/primedev/shared/keyvalues.cpp index 46ce4e04d..3ace7c995 100644 --- a/primedev/shared/keyvalues.cpp +++ b/primedev/shared/keyvalues.cpp @@ -1296,10 +1296,8 @@ ON_DLL_LOAD("vstdlib.dll", KeyValues, (CModule module)) AUTOHOOK_INIT() -// clang-format off AUTOHOOK(KeyValues__LoadFromBuffer, engine.dll + 0x426C30, char, __fastcall, (KeyValues* self, const char* pResourceName, const char* pBuffer, void* pFileSystem, void* a5, void* a6, int a7)) -// clang-format on { static void* pSavedFilesystemPtr = nullptr; diff --git a/primedev/shared/maxplayers.cpp b/primedev/shared/maxplayers.cpp index 69d625f2f..c650d2b7d 100644 --- a/primedev/shared/maxplayers.cpp +++ b/primedev/shared/maxplayers.cpp @@ -65,10 +65,8 @@ template void ChangeOffset(CMemory addr, unsigned int offset) addr.Patch((BYTE*)&offset, sizeof(T)); } -// clang-format off AUTOHOOK(StringTables_CreateStringTable, engine.dll + 0x22E220, void*,, (void* thisptr, const char* name, int maxentries, int userdatafixedsize, int userdatanetworkbits, int flags)) -// clang-format on { // Change the amount of entries to account for a bigger player amount if (!strcmp(name, "userinfo")) @@ -132,10 +130,8 @@ HMODULE serverBase = 0; auto RandomIntZeroMax = (__int64(__fastcall*)())0; // lazy rebuild -// clang-format off AUTOHOOK(RunUserCmds, server.dll + 0x483D10, void,, (bool a1, float a2)) -// clang-format on { unsigned char v3; // bl int v5; // er14 @@ -276,10 +272,8 @@ void,, (bool a1, float a2)) } } -// clang-format off AUTOHOOK(SendPropArray2, server.dll + 0x12B130, __int64,, (__int64 recvProp, int elements, int flags, const char* name, __int64 proxyFn, unsigned char unk1)) -// clang-format on { // Change the amount of elements to account for a bigger player amount if (!strcmp(name, "\"player_array\"")) @@ -447,10 +441,8 @@ ON_DLL_LOAD("server.dll", MaxPlayersOverride_Server, (CModule module)) DT_Team_Construct(); } -// clang-format off AUTOHOOK(RecvPropArray2, client.dll + 0x1CEDA0, __int64,, (__int64 recvProp, int elements, int flags, const char* name, __int64 proxyFn)) -// clang-format on { // Change the amount of elements to account for a bigger player amount if (!strcmp(name, "\"player_array\"")) diff --git a/primedev/shared/playlist.cpp b/primedev/shared/playlist.cpp index 2b9ad9798..c8b0f0d8d 100644 --- a/primedev/shared/playlist.cpp +++ b/primedev/shared/playlist.cpp @@ -19,10 +19,8 @@ namespace R2 ConVar* Cvar_ns_use_clc_SetPlaylistVarOverride; -// clang-format off AUTOHOOK(clc_SetPlaylistVarOverride__Process, engine.dll + 0x222180, char, __fastcall, (void* a1, void* a2)) -// clang-format on { // the private_match playlist on mp_lobby is the only situation where there should be any legitimate sending of this netmessage if (!Cvar_ns_use_clc_SetPlaylistVarOverride->GetBool() || strcmp(R2::GetCurrentPlaylistName(), "private_match") || @@ -32,10 +30,8 @@ char, __fastcall, (void* a1, void* a2)) return clc_SetPlaylistVarOverride__Process(a1, a2); } -// clang-format off AUTOHOOK(SetCurrentPlaylist, engine.dll + 0x18EB20, bool, __fastcall, (const char* pPlaylistName)) -// clang-format on { bool bSuccess = SetCurrentPlaylist(pPlaylistName); @@ -48,10 +44,8 @@ bool, __fastcall, (const char* pPlaylistName)) return bSuccess; } -// clang-format off AUTOHOOK(SetPlaylistVarOverride, engine.dll + 0x18ED00, void, __fastcall, (const char* pVarName, const char* pValue)) -// clang-format on { if (strlen(pValue) >= 64) return; @@ -59,10 +53,8 @@ void, __fastcall, (const char* pVarName, const char* pValue)) SetPlaylistVarOverride(pVarName, pValue); } -// clang-format off AUTOHOOK(GetCurrentPlaylistVar, engine.dll + 0x18C680, const char*, __fastcall, (const char* pVarName, bool bUseOverrides)) -// clang-format on { if (!bUseOverrides && !strcmp(pVarName, "max_players")) bUseOverrides = true; @@ -70,10 +62,8 @@ const char*, __fastcall, (const char* pVarName, bool bUseOverrides)) return GetCurrentPlaylistVar(pVarName, bUseOverrides); } -// clang-format off AUTOHOOK(GetCurrentGamemodeMaxPlayers, engine.dll + 0x18C430, int, __fastcall, ()) -// clang-format on { const char* pMaxPlayers = R2::GetCurrentPlaylistVar("max_players", 0); if (!pMaxPlayers) diff --git a/primedev/squirrel/squirrel.cpp b/primedev/squirrel/squirrel.cpp index 29540ccea..658f3380d 100644 --- a/primedev/squirrel/squirrel.cpp +++ b/primedev/squirrel/squirrel.cpp @@ -36,11 +36,9 @@ namespace NS::log template std::shared_ptr squirrel_logger() { // Switch statements can't be constexpr afaik - // clang-format off if constexpr (context == ScriptContext::UI) { return SCRIPT_UI; } if constexpr (context == ScriptContext::CLIENT) { return SCRIPT_CL; } if constexpr (context == ScriptContext::SERVER) { return SCRIPT_SV; } - // clang-format on } }; // namespace NS::log diff --git a/primedev/squirrel/squirrel.h b/primedev/squirrel/squirrel.h index 086ab9c67..f2c67d803 100644 --- a/primedev/squirrel/squirrel.h +++ b/primedev/squirrel/squirrel.h @@ -356,9 +356,6 @@ void InitialiseSquirrelManagers(); #pragma region MessageBuffer templates -// Clang-formatting makes this whole thing unreadable -// clang-format off - #ifndef MessageBufferFuncs #define MessageBufferFuncs // Bools @@ -444,7 +441,6 @@ inline void SqRecurseArgs(FunctionVector& v, T& arg, Args... args) { SqRecurseArgs(v, args...); } -// clang-format on #endif #pragma endregion diff --git a/primedev/squirrel/squirrelclasstypes.h b/primedev/squirrel/squirrelclasstypes.h index 3a39c957e..74dea884a 100644 --- a/primedev/squirrel/squirrelclasstypes.h +++ b/primedev/squirrel/squirrelclasstypes.h @@ -81,7 +81,6 @@ enum class ScriptContext : int typedef std::vector> FunctionVector; typedef std::function VoidFunction; -// clang-format off template concept is_map = // Simple maps @@ -114,8 +113,6 @@ concept is_iterable = requires(std::ranges::range_value_t x) x.end(); // and `x.end()` }; -// clang-format on - class SquirrelMessage { public: diff --git a/primedev/util/printmaps.cpp b/primedev/util/printmaps.cpp index 28325db93..ece0a59ac 100644 --- a/primedev/util/printmaps.cpp +++ b/primedev/util/printmaps.cpp @@ -128,10 +128,8 @@ void RefreshMapList() } } -// clang-format off AUTOHOOK(_Host_Map_f_CompletionFunc, engine.dll + 0x161AE0, int, __fastcall, (const char *const cmdname, const char *const partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])) -// clang-format on { RefreshMapList(); @@ -194,9 +192,7 @@ void ConCommand_maps(const CCommand& args) spdlog::info("({}) {}", PrintMapSource.at(map.source), map.name); } -// clang-format off AUTOHOOK(Host_Map_f, engine.dll + 0x15B340, void, __fastcall, (const CCommand& args)) -// clang-format on { RefreshMapList();