[General]: Clean global headers (#941)

This commit is contained in:
Edo 2023-04-17 14:47:29 +02:00 committed by GitHub
parent 6d427616b1
commit 777215b90a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 80 additions and 46 deletions

View File

@ -2,6 +2,7 @@
#include <Utils/InfoString.hpp> #include <Utils/InfoString.hpp>
#include "Modules/ArenaLength.hpp" #include "Modules/ArenaLength.hpp"
#include "Modules/Auth.hpp"
#include "Modules/Bans.hpp" #include "Modules/Bans.hpp"
#include "Modules/Bots.hpp" #include "Modules/Bots.hpp"
#include "Modules/Branding.hpp" #include "Modules/Branding.hpp"
@ -20,13 +21,20 @@
#include "Modules/Discovery.hpp" #include "Modules/Discovery.hpp"
#include "Modules/Download.hpp" #include "Modules/Download.hpp"
#include "Modules/Elevators.hpp" #include "Modules/Elevators.hpp"
#include "Modules/Exception.hpp"
#include "Modules/FastFiles.hpp" #include "Modules/FastFiles.hpp"
#include "Modules/Friends.hpp"
#include "Modules/Gamepad.hpp" #include "Modules/Gamepad.hpp"
#include "Modules/IPCPipe.hpp"
#include "Modules/Lean.hpp" #include "Modules/Lean.hpp"
#include "Modules/MapDump.hpp" #include "Modules/MapDump.hpp"
#include "Modules/MapRotation.hpp" #include "Modules/MapRotation.hpp"
#include "Modules/Materials.hpp"
#include "Modules/ModList.hpp"
#include "Modules/ModelSurfs.hpp"
#include "Modules/NetworkDebug.hpp" #include "Modules/NetworkDebug.hpp"
#include "Modules/News.hpp" #include "Modules/News.hpp"
#include "Modules/Node.hpp"
#include "Modules/Party.hpp" #include "Modules/Party.hpp"
#include "Modules/PlayerMovement.hpp" #include "Modules/PlayerMovement.hpp"
#include "Modules/PlayerName.hpp" #include "Modules/PlayerName.hpp"
@ -46,13 +54,16 @@
#include "Modules/Stats.hpp" #include "Modules/Stats.hpp"
#include "Modules/StringTable.hpp" #include "Modules/StringTable.hpp"
#include "Modules/StructuredData.hpp" #include "Modules/StructuredData.hpp"
#include "Modules/TextRenderer.hpp"
#include "Modules/Theatre.hpp" #include "Modules/Theatre.hpp"
#include "Modules/Threading.hpp" #include "Modules/Threading.hpp"
#include "Modules/Toast.hpp"
#include "Modules/UIFeeder.hpp" #include "Modules/UIFeeder.hpp"
#include "Modules/VisionFile.hpp" #include "Modules/VisionFile.hpp"
#include "Modules/Voice.hpp" #include "Modules/Voice.hpp"
#include "Modules/Vote.hpp" #include "Modules/Vote.hpp"
#include "Modules/Weapon.hpp" #include "Modules/Weapon.hpp"
#include "Modules/Window.hpp"
#include "Modules/BotLib/lPrecomp.hpp" #include "Modules/BotLib/lPrecomp.hpp"
@ -97,7 +108,7 @@ namespace Components
Register(new Logger()); Register(new Logger());
Register(new UIScript()); Register(new UIScript());
Register(new ZoneBuilder()); Register(new ZoneBuilder());
Register(new ArenaLength()); Register(new ArenaLength());
Register(new AssetHandler()); Register(new AssetHandler());
Register(new Bans()); Register(new Bans());

View File

@ -62,10 +62,8 @@ namespace Components
} }
// Priority // Priority
#include "Modules/Auth.hpp"
#include "Modules/Command.hpp" #include "Modules/Command.hpp"
#include "Modules/Dvar.hpp" #include "Modules/Dvar.hpp"
#include "Modules/Exception.hpp"
#include "Modules/Flags.hpp" #include "Modules/Flags.hpp"
#include "Modules/Network.hpp" #include "Modules/Network.hpp"
#include "Modules/Logger.hpp" #include "Modules/Logger.hpp"
@ -77,20 +75,11 @@ namespace Components
#include "Modules/Dedicated.hpp" #include "Modules/Dedicated.hpp"
#include "Modules/Events.hpp" #include "Modules/Events.hpp"
#include "Modules/FileSystem.hpp" #include "Modules/FileSystem.hpp"
#include "Modules/Friends.hpp"
#include "Modules/IPCPipe.hpp"
#include "Modules/Localization.hpp" #include "Modules/Localization.hpp"
#include "Modules/Maps.hpp" #include "Modules/Maps.hpp"
#include "Modules/Materials.hpp"
#include "Modules/Menus.hpp" #include "Modules/Menus.hpp"
#include "Modules/ModList.hpp"
#include "Modules/ModelSurfs.hpp"
#include "Modules/Node.hpp"
#include "Modules/Renderer.hpp" #include "Modules/Renderer.hpp"
#include "Modules/Scheduler.hpp" #include "Modules/Scheduler.hpp"
#include "Modules/TextRenderer.hpp"
#include "Modules/Toast.hpp"
#include "Modules/Window.hpp"
#include "Modules/Zones.hpp" #include "Modules/Zones.hpp"
#include "Modules/GSC/GSC.hpp" #include "Modules/GSC/GSC.hpp"

View File

@ -3,8 +3,11 @@
#include <proto/auth.pb.h> #include <proto/auth.pb.h>
#include "Auth.hpp"
#include "Bans.hpp" #include "Bans.hpp"
#include "Bots.hpp" #include "Bots.hpp"
#include "Friends.hpp"
#include "Toast.hpp"
namespace Components namespace Components
{ {

View File

@ -1,6 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Chat.hpp" #include "Chat.hpp"
#include "PlayerName.hpp" #include "PlayerName.hpp"
#include "TextRenderer.hpp"
#include "Voice.hpp" #include "Voice.hpp"
#include "GSC/Script.hpp" #include "GSC/Script.hpp"

View File

@ -1,5 +1,6 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ConnectProtocol.hpp" #include "ConnectProtocol.hpp"
#include "IPCPipe.hpp"
namespace Components namespace Components
{ {

View File

@ -1,5 +1,6 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Console.hpp" #include "Console.hpp"
#include "TextRenderer.hpp"
#include "Terminus_4.49.1.ttf.hpp" #include "Terminus_4.49.1.ttf.hpp"

View File

@ -1,5 +1,6 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Debug.hpp" #include "Debug.hpp"
#include "TextRenderer.hpp"
#include "Game/Engine/ScopedCriticalSection.hpp" #include "Game/Engine/ScopedCriticalSection.hpp"

View File

@ -1,6 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Discord.hpp" #include "Discord.hpp"
#include "Party.hpp" #include "Party.hpp"
#include "TextRenderer.hpp"
#include <discord_rpc.h> #include <discord_rpc.h>

View File

@ -1,5 +1,8 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Friends.hpp"
#include "TextRenderer.hpp"
namespace Components namespace Components
{ {
Dvar::Var Dvar::Name; Dvar::Var Dvar::Name;

View File

@ -1,5 +1,8 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Console.hpp" #include "Console.hpp"
#include "Exception.hpp"
#include "Window.hpp"
#include <version.hpp> #include <version.hpp>
@ -50,32 +53,39 @@ namespace Components
Game::Sys_SuspendOtherThreads(); Game::Sys_SuspendOtherThreads();
} }
void Exception::CopyMessageToClipboard(const std::string& error) void Exception::CopyMessageToClipboard(const char* error)
{ {
const auto hWndNewOwner = GetDesktopWindow(); const auto hWndNewOwner = GetDesktopWindow();
const auto result = OpenClipboard(hWndNewOwner); const auto result = OpenClipboard(hWndNewOwner);
if (result == FALSE) if (result == FALSE)
{
return; return;
}
EmptyClipboard(); const auto _0 = gsl::finally([]
auto* hMem = GlobalAlloc(GMEM_MOVEABLE, error.size() + 1);
if (hMem == nullptr)
{ {
CloseClipboard(); CloseClipboard();
});
EmptyClipboard();
const auto len = std::strlen(error);
auto* hMem = GlobalAlloc(GMEM_MOVEABLE, len + 1);
if (!hMem)
{
return; return;
} }
auto* lock = GlobalLock(hMem); auto* lock = GlobalLock(hMem);
if (lock != nullptr) if (lock)
{ {
std::memcpy(lock, error.data(), error.size() + 1); std::memcpy(lock, error, len + 1);
GlobalUnlock(hMem); GlobalUnlock(hMem);
SetClipboardData(1, hMem); SetClipboardData(CF_TEXT, hMem);
} }
CloseClipboard();
GlobalFree(hMem); GlobalFree(hMem);
} }
@ -88,18 +98,18 @@ namespace Components
return EXCEPTION_CONTINUE_EXECUTION; return EXCEPTION_CONTINUE_EXECUTION;
} }
std::string errorStr; const char* error;
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW)
{ {
errorStr = "Termination because of a stack overflow.\nCopy exception address to clipboard?"; error = "Termination because of a stack overflow.\nCopy exception address to clipboard?";
} }
else else
{ {
errorStr = Utils::String::VA("Fatal error (0x%08X) at 0x%08X.\nCopy exception address to clipboard?", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress); error = Utils::String::VA("Fatal error (0x%08X) at 0x%08X.\nCopy exception address to clipboard?", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
} }
// Message should be copied to the keyboard if no button is pressed // Message should be copied to the keyboard if no button is pressed
if (MessageBoxA(nullptr, errorStr.data(), nullptr, MB_YESNO | MB_ICONERROR) == IDYES) if (MessageBoxA(nullptr, error, nullptr, MB_YESNO | MB_ICONERROR) == IDYES)
{ {
CopyMessageToClipboard(Utils::String::VA("0x%08X", ExceptionInfo->ExceptionRecord->ExceptionAddress)); CopyMessageToClipboard(Utils::String::VA("0x%08X", ExceptionInfo->ExceptionRecord->ExceptionAddress));
} }
@ -136,8 +146,8 @@ namespace Components
MessageBoxA(nullptr, Utils::String::Format("There was an error creating the minidump ({})! Hit OK to close the program.", Utils::GetLastWindowsError()), "ERROR", MB_OK | MB_ICONERROR); MessageBoxA(nullptr, Utils::String::Format("There was an error creating the minidump ({})! Hit OK to close the program.", Utils::GetLastWindowsError()), "ERROR", MB_OK | MB_ICONERROR);
#ifdef _DEBUG #ifdef _DEBUG
OutputDebugStringA("Failed to create new minidump!"); OutputDebugStringA("Failed to create new minidump!");
#endif
Utils::OutputDebugLastError(); Utils::OutputDebugLastError();
#endif
TerminateProcess(GetCurrentProcess(), ExceptionInfo->ExceptionRecord->ExceptionCode); TerminateProcess(GetCurrentProcess(), ExceptionInfo->ExceptionRecord->ExceptionCode);
} }
@ -190,25 +200,6 @@ namespace Components
Utils::Hook(0x61F17D, LongJmp_Internal_Stub, HOOK_CALL).install()->quick(); Utils::Hook(0x61F17D, LongJmp_Internal_Stub, HOOK_CALL).install()->quick();
Utils::Hook(0x61F248, LongJmp_Internal_Stub, HOOK_CALL).install()->quick(); Utils::Hook(0x61F248, LongJmp_Internal_Stub, HOOK_CALL).install()->quick();
Utils::Hook(0x61F5E7, LongJmp_Internal_Stub, HOOK_CALL).install()->quick(); Utils::Hook(0x61F5E7, LongJmp_Internal_Stub, HOOK_CALL).install()->quick();
#ifdef MAP_TEST
Command::Add("mapTest", [](Command::Params* params)
{
Game::UI_UpdateArenas();
std::string command;
for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i)
{
const auto* mapName = ArenaLength::NewArenas[i % *Game::arenaCount].mapName;
if (!(i % 2)) command.append("wait 250;disconnect;wait 750;"); // Test a disconnect
else command.append("wait 500;"); // Test direct map switch
command.append(Utils::String::VA("map %s;", mapName));
}
Command::Execute(command, false);
});
#endif
} }
Exception::~Exception() Exception::~Exception()

View File

@ -17,7 +17,7 @@ namespace Components
static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo); static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo);
static __declspec(noreturn) void LongJmp_Internal_Stub(jmp_buf env, int status); static __declspec(noreturn) void LongJmp_Internal_Stub(jmp_buf env, int status);
static void CopyMessageToClipboard(const std::string& error); static void CopyMessageToClipboard(const char* error);
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter_Stub(LPTOP_LEVEL_EXCEPTION_FILTER); static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter_Stub(LPTOP_LEVEL_EXCEPTION_FILTER);

View File

@ -5,7 +5,12 @@
#include <proto/friends.pb.h> #include <proto/friends.pb.h>
#pragma warning(pop) #pragma warning(pop)
#include "Friends.hpp"
#include "Materials.hpp"
#include "Node.hpp"
#include "Party.hpp" #include "Party.hpp"
#include "TextRenderer.hpp"
#include "Toast.hpp"
#include "UIFeeder.hpp" #include "UIFeeder.hpp"
namespace Components namespace Components

View File

@ -1,6 +1,8 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <proto/ipc.pb.h> #include <proto/ipc.pb.h>
#include "IPCPipe.hpp"
namespace Components namespace Components
{ {
Pipe IPCPipe::ServerPipe; Pipe IPCPipe::ServerPipe;

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Materials.hpp"
namespace Components namespace Components
{ {

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ModList.hpp"
#include "UIFeeder.hpp" #include "UIFeeder.hpp"
namespace Components namespace Components

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ModelSurfs.hpp"
namespace Components namespace Components
{ {

View File

@ -4,6 +4,7 @@
#include <proto/node.pb.h> #include <proto/node.pb.h>
#include "Node.hpp"
#include "ServerList.hpp" #include "ServerList.hpp"
#include "Session.hpp" #include "Session.hpp"

View File

@ -1,8 +1,11 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <Utils/InfoString.hpp> #include <Utils/InfoString.hpp>
#include "Auth.hpp"
#include "Download.hpp" #include "Download.hpp"
#include "Friends.hpp"
#include "Gamepad.hpp" #include "Gamepad.hpp"
#include "Node.hpp"
#include "Party.hpp" #include "Party.hpp"
#include "ServerList.hpp" #include "ServerList.hpp"
#include "Stats.hpp" #include "Stats.hpp"

View File

@ -1,6 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ClanTags.hpp" #include "ClanTags.hpp"
#include "PlayerName.hpp" #include "PlayerName.hpp"
#include "TextRenderer.hpp"
namespace Components namespace Components
{ {

View File

@ -2,6 +2,8 @@
#include <Utils/Compression.hpp> #include <Utils/Compression.hpp>
#include "QuickPatch.hpp" #include "QuickPatch.hpp"
#include "TextRenderer.hpp"
#include "Toast.hpp"
namespace Components namespace Components
{ {
@ -196,10 +198,14 @@ namespace Components
void QuickPatch::CL_KeyEvent_OnEscape() void QuickPatch::CL_KeyEvent_OnEscape()
{ {
if (Game::Con_CancelAutoComplete()) if (Game::Con_CancelAutoComplete())
{
return; return;
}
if (TextRenderer::HandleFontIconAutocompleteKey(0, TextRenderer::FONT_ICON_ACI_CONSOLE, Game::K_ESCAPE)) if (TextRenderer::HandleFontIconAutocompleteKey(0, TextRenderer::FONT_ICON_ACI_CONSOLE, Game::K_ESCAPE))
{
return; return;
}
// Close console // Close console
Game::Key_RemoveCatcher(0, ~Game::KEYCATCH_CONSOLE); Game::Key_RemoveCatcher(0, ~Game::KEYCATCH_CONSOLE);

View File

@ -1,6 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Gamepad.hpp" #include "Gamepad.hpp"
#include "RawMouse.hpp" #include "RawMouse.hpp"
#include "Window.hpp"
namespace Components namespace Components
{ {

View File

@ -1,6 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include <Utils/InfoString.hpp> #include <Utils/InfoString.hpp>
#include "Friends.hpp"
#include "Gamepad.hpp" #include "Gamepad.hpp"
#include "Party.hpp" #include "Party.hpp"
#include "ServerInfo.hpp" #include "ServerInfo.hpp"

View File

@ -2,8 +2,11 @@
#include <Utils/InfoString.hpp> #include <Utils/InfoString.hpp>
#include "Discovery.hpp" #include "Discovery.hpp"
#include "Node.hpp"
#include "Party.hpp" #include "Party.hpp"
#include "ServerList.hpp" #include "ServerList.hpp"
#include "TextRenderer.hpp"
#include "Toast.hpp"
#include "UIFeeder.hpp" #include "UIFeeder.hpp"
#include <version.hpp> #include <version.hpp>

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "TextRenderer.hpp"
namespace Game namespace Game
{ {

View File

@ -1,5 +1,8 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Materials.hpp"
#include "Toast.hpp"
namespace Components namespace Components
{ {
std::queue<Toast::UIToast> Toast::Queue; std::queue<Toast::UIToast> Toast::Queue;

View File

@ -1,6 +1,7 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "FastFiles.hpp" #include "FastFiles.hpp"
#include "Window.hpp"
namespace Components namespace Components
{ {

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Components/Modules/Auth.hpp"
STEAM_IGNORE_WARNINGS_START STEAM_IGNORE_WARNINGS_START