From 04e625f6a799c0fadf102f6dfe6f85de7d0eab05 Mon Sep 17 00:00:00 2001 From: superp00t Date: Mon, 14 Aug 2023 22:57:31 -0400 Subject: [PATCH] tidy(client): split CmdLine functions into separate files --- src/client/Client.cpp | 57 +------------------------------- src/client/CmdLine.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++ src/client/CmdLine.hpp | 57 ++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 56 deletions(-) create mode 100644 src/client/CmdLine.cpp create mode 100644 src/client/CmdLine.hpp diff --git a/src/client/Client.cpp b/src/client/Client.cpp index cc10ec3..108121e 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -1,6 +1,7 @@ #include "client/Client.hpp" #include "async/AsyncFile.hpp" #include "client/ClientServices.hpp" +#include "client/CmdLine.hpp" #include "console/CVar.hpp" #include "console/Client.hpp" #include "console/Device.hpp" @@ -17,7 +18,6 @@ #include #include #include -#include CVar* Client::g_accountListVar; HEVENTCONTEXT Client::g_clientEventContext; @@ -136,61 +136,6 @@ int32_t InitializeEngineCallback(const void* a1, void* a2) { return 1; } -int32_t CmdLineProcess() { - // engine-specific flags. - static ARGLIST s_argList[] = { - {0x0, CMD_D3D, "d3d", nullptr}, - {0x0, CMD_D3D9EX, "d3d9ex", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_DATADIR, "datadir", nullptr}, - {0x0, CMD_NO_LAG_FIX, "nolagfix", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_LOADFILE, "loadfile", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_GAMETYPE, "gametype", nullptr}, - {0x0, CMD_OPENGL, "opengl", nullptr}, - {0x0, CMD_SWTNL, "swtnl", nullptr}, - {0x0, CMD_TIMEDEMO, "timedemo", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_DEMOREZ, "rez", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_DEMODEPTH, "depth", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_DEMODETAIL, "detail", nullptr}, - {STORM_COMMAND_TYPE_STRING, CMD_DEMOSOUND, "sound", nullptr}, - {0x0, CMD_FULLSCREEN, "fullscreen", nullptr}, - {0x0, CMD_22050HZ, "22050", nullptr}, - {0x0, CMD_NO_WARNINGS, "nowarnings", nullptr} - }; - - // load engine-specific launch flags - SCmdRegisterArgList(s_argList, std::size(s_argList)); - - // parse command line - return SCmdProcessCommandLine(0, 0); -} - -static void ProcessCommandLine() { - static ARGLIST s_wowArgList[] = { - {0x0, WOWCMD_RES_800x600, "800x600", nullptr}, - {0x0, WOWCMD_RES_1024x768, "1024x768", nullptr}, - {0x0, WOWCMD_RES_1280x960, "1280x960", nullptr}, - {0x0, WOWCMD_RES_1280x1024, "1280x1024", nullptr}, - {0x0, WOWCMD_RES_1600x1200, "1600x1200", nullptr}, - {0x0, WOWCMD_16_BIT, "16bit", nullptr}, - {0x0, WOWCMD_UP_TO_DATE, "uptodate", nullptr}, - {0x0, WOWCMD_NO_SOUND, "nosound", nullptr}, - {0x0, WOWCMD_SOUND_CHAOS, "soundchaos", nullptr}, - {0x0, WOWCMD_NO_FIX_LAG, "nofixlag", nullptr}, - {0x0, WOWCMD_DEPTH_16, "d16", nullptr}, - {0x0, WOWCMD_DEPTH_24, "d24", nullptr}, - {0x0, WOWCMD_DEPTH_32, "d32", nullptr}, - {0x0, WOWCMD_WINDOWED, "windowed", nullptr}, - {0x0, WOWCMD_HW_DETECT, "hwdetect", nullptr}, - {0x0, WOWCMD_CONSOLE, "console", nullptr}, - {STORM_COMMAND_TYPE_STRING, WOWCMD_GX_OVERRIDE, "gxoverride", nullptr} - }; - - // Load wow-specific launch flags - SCmdRegisterArgList(s_wowArgList, std::size(s_wowArgList)); - - CmdLineProcess(); -} - int32_t InitializeGlobal() { // TODO diff --git a/src/client/CmdLine.cpp b/src/client/CmdLine.cpp new file mode 100644 index 0000000..0de72a1 --- /dev/null +++ b/src/client/CmdLine.cpp @@ -0,0 +1,74 @@ +#include "client/CmdLine.hpp" + +#include + +int32_t CmdLineProcess() { + // engine-specific flags. + static ARGLIST s_argList[] = { + {0x0, CMD_D3D, "d3d", nullptr}, + {0x0, CMD_D3D9EX, "d3d9ex", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_DATADIR, "datadir", nullptr}, + {0x0, CMD_NO_LAG_FIX, "nolagfix", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_LOADFILE, "loadfile", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_GAMETYPE, "gametype", nullptr}, + {0x0, CMD_OPENGL, "opengl", nullptr}, + {0x0, CMD_SWTNL, "swtnl", nullptr}, + {0x0, CMD_TIMEDEMO, "timedemo", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_DEMOREZ, "rez", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_DEMODEPTH, "depth", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_DEMODETAIL, "detail", nullptr}, + {STORM_COMMAND_TYPE_STRING, CMD_DEMOSOUND, "sound", nullptr}, + {0x0, CMD_FULLSCREEN, "fullscreen", nullptr}, + {0x0, CMD_22050HZ, "22050", nullptr}, + {0x0, CMD_NO_WARNINGS, "nowarnings", nullptr} + }; + + // load engine-specific launch flags + SCmdRegisterArgList(s_argList, std::size(s_argList)); + + // parse command line + return SCmdProcessCommandLine(0, 0); +} + +void ProcessCommandLine() { + static ARGLIST s_wowArgList[] = { + {0x0, WOWCMD_RES_800x600, "800x600", nullptr}, + {0x0, WOWCMD_RES_1024x768, "1024x768", nullptr}, + {0x0, WOWCMD_RES_1280x960, "1280x960", nullptr}, + {0x0, WOWCMD_RES_1280x1024, "1280x1024", nullptr}, + {0x0, WOWCMD_RES_1600x1200, "1600x1200", nullptr}, + {0x0, WOWCMD_16_BIT, "16bit", nullptr}, + {0x0, WOWCMD_UP_TO_DATE, "uptodate", nullptr}, + {0x0, WOWCMD_NO_SOUND, "nosound", nullptr}, + {0x0, WOWCMD_SOUND_CHAOS, "soundchaos", nullptr}, + {0x0, WOWCMD_NO_FIX_LAG, "nofixlag", nullptr}, + {0x0, WOWCMD_DEPTH_16, "d16", nullptr}, + {0x0, WOWCMD_DEPTH_24, "d24", nullptr}, + {0x0, WOWCMD_DEPTH_32, "d32", nullptr}, + {0x0, WOWCMD_WINDOWED, "windowed", nullptr}, + {0x0, WOWCMD_HW_DETECT, "hwdetect", nullptr}, + {0x0, WOWCMD_CONSOLE, "console", nullptr}, + {STORM_COMMAND_TYPE_STRING, WOWCMD_GX_OVERRIDE, "gxoverride", nullptr} + }; + + // Load wow-specific launch flags + SCmdRegisterArgList(s_wowArgList, std::size(s_wowArgList)); + + CmdLineProcess(); +} + +const char* CmdLineGetString(uint32_t opt) { + static char buffer[260] = {0}; + + SCmdGetString(opt, buffer, 260); + + return buffer; +} + +uint32_t CmdLineGetUint(uint32_t opt) { + return SCmdGetNum(opt); +} + +int32_t CmdLineGetBool(uint32_t opt) { + return SCmdGetBool(opt); +} diff --git a/src/client/CmdLine.hpp b/src/client/CmdLine.hpp new file mode 100644 index 0000000..0bebabc --- /dev/null +++ b/src/client/CmdLine.hpp @@ -0,0 +1,57 @@ +#ifndef CLIENT_CMD_LINE_HPP +#define CLIENT_CMD_LINE_HPP + +#include + +enum CMDOPT { + CMD_D3D = 0, + CMD_D3D9EX = 1, + CMD_DATA_DIR = 2, + CMD_NO_LAG_FIX = 3, + CMD_LOADFILE = 4, + CMD_GAMETYPE = 5, + CMD_OPENGL = 6, + CMD_SW_TNL = 7, + CMD_TIMEDEMO = 8, + CMD_DEMOREZ = 9, + CMD_DEMODEPTH = 10, + CMD_DEMODETAIL = 11, + CMD_DEMOSOUND = 12, + CMD_FULL_SCREEN = 13, + CMD_22050HZ = 14, + CMD_NO_WARNINGS = 15, + CMDOPTS +}; + +enum WOWCMDOPT { + WOWCMD_RES_800x600 = 16, + WOWCMD_RES_1024x768 = 17, + WOWCMD_RES_1280x960 = 18, + WOWCMD_RES_1280x1024 = 19, + WOWCMD_RES_1600x1200 = 20, + WOWCMD_UP_TO_DATE = 21, + WOWCMD_16_BIT = 22, + WOWCMD_NO_FIX_LAG = 24, + WOWCMD_NO_SOUND = 26, + WOWCMD_SOUND_CHAOS = 27, + WOWCMD_DEPTH_16 = 29, + WOWCMD_DEPTH_24 = 30, + WOWCMD_DEPTH_32 = 31, + WOWCMD_WINDOWED = 32, + WOWCMD_CONSOLE = 35, + WOWCMD_HW_DETECT = 36, + WOWCMD_GX_OVERRIDE = 39, + WOWCMD_OPTS +}; + +static int32_t CmdLineProcess(); + +static void ProcessCommandLine(); + +const char* CmdLineGetString(uint32_t opt); + +uint32_t CmdLineGetUint(uint32_t opt); + +int32_t CmdLineGetBool(uint32_t opt); + +#endif