r5sdk/r5dev/sdklauncher/sdklauncher.cpp

454 lines
17 KiB
C++
Raw Normal View History

Code base refactor + major performance and readability improvement. Read description for details. * Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable. * Document most functions with valve style 'Purpose' blocks. * Rename variables to match the rest of the codebase and Valve's naming convention. * Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK. * Obtain globals or pointers directly instead of waiting for runtime initialized data. * Dynamically search for all functions and globals (this doesn't count for dedicated yet!). * Initialize most in-SDK variables. * Move certain prints and other utilities under ConVars to reduce verbosity and increase performance. * Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future. * Type global var pointers appropriately if class or type is known and implemented. * Forward declare 'CClient' class to avoid having 2 'g_pClient' copies. * Add IDA's pseudo definitions for easier prototyping with decompiled assembly code. * RPAK decompress Command callback implementation. * Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\'). * VPK decompress Command callback implementation. * Move CRC32 ands Adler32 to implementation files. * Server will print out more details about the connecting client. * Upgrade ImGui lib to v1.86. * Don't compile id3dx.h for dedicated. * Don't compile id3dx.cpp for dedicated * Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console * Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors. * Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up. * Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00
#include "core/stdafx.h"
#include "basepanel.h"
#include "sdklauncher_const.h"
#include "sdklauncher.h"
#include <objidl.h>
#include "gdiplus.h"
#include "shellapi.h"
using namespace Gdiplus;
#pragma comment (lib,"Shell32.lib")
#pragma comment (lib,"Gdi32.lib")
#pragma comment (lib,"Gdiplus.lib")
#pragma comment (lib,"Advapi32.lib")
2021-08-01 02:25:29 -07:00
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
2021-10-21 15:56:45 -07:00
//-----------------------------------------------------------------------------
2022-01-19 23:14:50 +01:00
// Purpose switch case:
2021-08-01 02:25:29 -07:00
// * Launch the game in user specified mode and state.
// * Load specified command line arguments from a file on the disk.
// * Format the file paths for the game exe and specified hook dll.
//-----------------------------------------------------------------------------
bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState)
2021-04-13 04:45:22 -07:00
{
///////////////////////////////////////////////////////////////////////////
std::string svCmdLineArgs = std::string();
2021-04-13 04:45:22 -07:00
///////////////////////////////////////////////////////////////////////////
2021-08-01 02:25:29 -07:00
switch (lMode)
{
case eLaunchMode::LM_HOST_DEBUG:
{
fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_debug.cfg";
std::ifstream cfgFile(cfgPath);
if (cfgFile.good() && cfgFile)
{
std::stringstream ss;
ss << cfgFile.rdbuf();
svCmdLineArgs = ss.str() + "-launcher";
2021-08-01 02:25:29 -07:00
}
else
2021-08-01 02:25:29 -07:00
{
spdlog::error("File 'platform\\cfg\\startup_debug.cfg' does not exist!\n");
cfgFile.close();
return false;
}
cfgFile.close(); // Close cfg file.
2021-08-01 02:25:29 -07:00
m_svWorkerDll = m_svCurrentDir + "\\gamesdk.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex.exe " + svCmdLineArgs;
spdlog::info("*** LAUNCHING GAME [DEBUG] ***\n");
break;
}
case eLaunchMode::LM_HOST:
{
fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_retail.cfg";
std::ifstream cfgFile(cfgPath);
if (cfgFile.good() && cfgFile)
{
std::stringstream ss;
ss << cfgFile.rdbuf();
svCmdLineArgs = ss.str() + "-launcher";
2021-08-01 02:25:29 -07:00
}
else
2021-08-01 02:25:29 -07:00
{
spdlog::error("File 'platform\\cfg\\startup_retail.cfg' does not exist!\n");
cfgFile.close();
return false;
}
cfgFile.close(); // Close cfg file.
2021-08-01 02:25:29 -07:00
m_svWorkerDll = m_svCurrentDir + "\\gamesdk.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex.exe " + svCmdLineArgs;
spdlog::info("*** LAUNCHING GAME [RELEASE] ***\n");
break;
}
case eLaunchMode::LM_SERVER_DEBUG:
{
fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_dedi_debug.cfg";
std::ifstream cfgFile(cfgPath);
if (cfgFile.good() && cfgFile)
{
std::stringstream ss;
ss << cfgFile.rdbuf();
svCmdLineArgs = ss.str() + "-launcher";
}
else
{
spdlog::error("File 'platform\\cfg\\startup_dedi_debug.cfg' does not exist!\n");
cfgFile.close();
return false;
}
cfgFile.close(); // Close cfg file.
m_svWorkerDll = m_svCurrentDir + "\\dedicated.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex_ds.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex_ds.exe " + svCmdLineArgs;
spdlog::info("*** LAUNCHING DEDICATED [DEBUG] ***\n");
break;
}
case eLaunchMode::LM_SERVER:
{
fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_dedi_retail.cfg";
std::ifstream cfgFile(cfgPath);
if (cfgFile.good() && cfgFile)
{
std::stringstream ss;
ss << cfgFile.rdbuf();
svCmdLineArgs = ss.str(); +"-launcher";
2021-08-01 02:25:29 -07:00
}
else
2021-08-01 02:25:29 -07:00
{
spdlog::error("File 'platform\\cfg\\startup_dedi_retail.cfg' does not exist!\n");
cfgFile.close();
2021-08-01 02:25:29 -07:00
return false;
}
cfgFile.close(); // Close cfg file.
m_svWorkerDll = m_svCurrentDir + "\\dedicated.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex_ds.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex_ds.exe " + svCmdLineArgs;
spdlog::info("*** LAUNCHING DEDICATED [RELEASE] ***\n");
break;
}
default:
{
spdlog::error("*** NO LAUNCH MODE SPECIFIED ***\n");
return false;
}
}
///////////////////////////////////////////////////////////////////////////
// Print the file paths and arguments.
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
spdlog::debug("- CWD: {}\n", m_svCurrentDir);
spdlog::debug("- EXE: {}\n", m_svGameExe);
spdlog::debug("- DLL: {}\n", m_svWorkerDll);
spdlog::debug("- CLI: {}\n", svCmdLineArgs);
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
2021-04-13 04:45:22 -07:00
return true;
}
bool CLauncher::Setup(eLaunchMode lMode, const string& svCommandLine)
{
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
switch (lMode)
{
case eLaunchMode::LM_HOST_DEBUG:
{
m_svWorkerDll = m_svCurrentDir + "\\gamesdk.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex.exe " + svCommandLine;
spdlog::info("*** LAUNCHER SETUP FOR HOST [DEBUG] ***\n");
break;
}
case eLaunchMode::LM_HOST:
{
m_svWorkerDll = m_svCurrentDir + "\\gamesdk.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex.exe " + svCommandLine;
spdlog::info("*** LAUNCHER SETUP FOR HOST [RELEASE] ***\n");
break;
}
case eLaunchMode::LM_SERVER_DEBUG:
{
m_svWorkerDll = m_svCurrentDir + "\\dedicated.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex_ds.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex_ds.exe " + svCommandLine;
spdlog::info("*** LAUNCHER SETUP FOR DEDICATED [DEBUG] ***\n");
break;
}
case eLaunchMode::LM_SERVER:
{
m_svWorkerDll = m_svCurrentDir + "\\dedicated.dll";
m_svGameExe = m_svCurrentDir + "\\r5apex_ds.exe";
m_svCmdLine = m_svCurrentDir + "\\r5apex_ds.exe " + svCommandLine;
spdlog::info("*** LAUNCHER SETUP FOR DEDICATED [RELEASE] ***\n");
break;
}
default:
{
spdlog::error("*** INVALID LAUNCH MODE SPECIFIED ***\n");
return false;
}
}
///////////////////////////////////////////////////////////////////////////
// Print the file paths and arguments.
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
spdlog::debug("- CWD: {}\n", m_svCurrentDir);
spdlog::debug("- EXE: {}\n", m_svGameExe);
spdlog::debug("- DLL: {}\n", m_svWorkerDll);
spdlog::debug("- CLI: {}\n", svCommandLine);
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
return true;
}
bool CLauncher::Launch()
{
///////////////////////////////////////////////////////////////////////////
2021-04-13 04:45:22 -07:00
// Build our list of dlls to inject.
LPCSTR DllsToInject[1] =
{
m_svWorkerDll.c_str()
2021-04-13 04:45:22 -07:00
};
STARTUPINFOA StartupInfo = { 0 };
PROCESS_INFORMATION ProcInfo = { 0 };
// Initialize startup info struct.
StartupInfo.cb = sizeof(STARTUPINFOA);
///////////////////////////////////////////////////////////////////////////
2021-04-13 04:45:22 -07:00
// Create the game process in a suspended state with our dll.
BOOL result = DetourCreateProcessWithDllsA
(
m_svGameExe.c_str(), // lpApplicationName
(LPSTR)m_svCmdLine.c_str(), // lpCommandLine
NULL, // lpProcessAttributes
NULL, // lpThreadAttributes
FALSE, // bInheritHandles
CREATE_SUSPENDED, // dwCreationFlags
NULL, // lpEnvironment
m_svCurrentDir.c_str(), // lpCurrentDirectory
&StartupInfo, // lpStartupInfo
&ProcInfo, // lpProcessInformation
sizeof(DllsToInject) / sizeof(LPCSTR), // nDlls
DllsToInject, // rlpDlls
NULL // pfCreateProcessA
2021-04-13 04:45:22 -07:00
);
///////////////////////////////////////////////////////////////////////////
// Failed to create the process.
2021-04-13 04:45:22 -07:00
if (!result)
{
PrintLastError();
return false;
}
///////////////////////////////////////////////////////////////////////////
2021-04-13 04:45:22 -07:00
// Resume the process.
ResumeThread(ProcInfo.hThread);
///////////////////////////////////////////////////////////////////////////
2021-04-13 04:45:22 -07:00
// Close the process and thread handles.
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
return true;
}
///////////////////////////////////////////////////////////////////////////////
2021-06-28 15:51:32 -07:00
// Entrypoint.
2021-07-12 08:47:54 -07:00
///////////////////////////////////////////////////////////////////////////////
2021-04-13 04:45:22 -07:00
int main(int argc, char* argv[], char* envp[])
{
spdlog::set_pattern("[%^%l%$] %v");
spdlog::set_level(spdlog::level::trace);
if (argc < 2)
2021-08-01 02:25:29 -07:00
{
Forms::Application::EnableVisualStyles();
UIX::UIXTheme::InitializeRenderer(new Themes::KoreTheme());
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
g_pLauncher->m_pSurface = new CUIBaseSurface();
Forms::Application::Run(g_pLauncher->m_pSurface);
UIX::UIXTheme::ShutdownRenderer();
}
else
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
{
for (int i = 1; i < argc; ++i)
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
{
std::string arg = argv[i];
if ((arg == "-debug") || (arg == "-dbg"))
{
if (g_pLauncher->Setup(eLaunchMode::LM_HOST_DEBUG, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Sleep(2000);
return EXIT_FAILURE;
}
if ((arg == "-release") || (arg == "-rel"))
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
{
if (g_pLauncher->Setup(eLaunchMode::LM_HOST, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
Sleep(2000);
return EXIT_FAILURE;
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
}
if ((arg == "-dedicated_dev") || (arg == "-dedid"))
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
{
if (g_pLauncher->Setup(eLaunchMode::LM_SERVER_DEBUG, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
Sleep(2000);
return EXIT_FAILURE;
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
}
if ((arg == "-dedicated") || (arg == "-dedi"))
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
{
if (g_pLauncher->Setup(eLaunchMode::LM_SERVER, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
Sleep(2000);
return EXIT_FAILURE;
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
}
}
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
spdlog::warn("If a DEBUG option has been choosen as launch parameter, do not broadcast servers to the Server Browser!\n");
spdlog::warn("All FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ConVar's/ConCommand's will be enabled.\n");
spdlog::warn("Connected clients will be able to set and execute anything flagged FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY.\n");
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
spdlog::warn("Use DEBUG HOST [1] for research and development purposes.\n");
spdlog::warn("Use RELEASE HOST [2] for playing the game and creating servers.\n");
spdlog::warn("Use DEBUG SERVER [3] for research and development purposes.\n");
spdlog::warn("Use RELEASE SERVER [4] for running and hosting dedicated servers.\n");
spdlog::warn("Use DEBUG CLIENT [5] for research and development purposes.\n");
spdlog::warn("Use RELEASE CLIENT [6] for running client only builds against remote servers.\n");
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
spdlog::info("Enter '1' for 'DEBUG HOST'.\n");
spdlog::info("Enter '2' for 'RELEASE HOST'.\n");
spdlog::info("Enter '3' for 'DEBUG SERVER'.\n");
spdlog::info("Enter '4' for 'RELEASE SERVER'.\n");
spdlog::info("Enter '5' for 'DEBUG CLIENT'.\n");
spdlog::info("Enter '6' for 'RELEASE CLIENT'.\n");
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
std::cout << "User input: ";
std::string input = std::string();
if (std::cin >> input)
{
try
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
{
eLaunchMode mode = (eLaunchMode)std::stoi(input);
switch (mode)
{
case eLaunchMode::LM_HOST_DEBUG:
{
if (g_pLauncher->Setup(eLaunchMode::LM_HOST_DEBUG, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Sleep(2000);
return EXIT_FAILURE;
}
case eLaunchMode::LM_HOST:
{
if (g_pLauncher->Setup(eLaunchMode::LM_HOST, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Sleep(2000);
return EXIT_FAILURE;
}
case eLaunchMode::LM_SERVER_DEBUG:
{
if (g_pLauncher->Setup(eLaunchMode::LM_SERVER_DEBUG, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Sleep(2000);
return EXIT_FAILURE;
}
case eLaunchMode::LM_SERVER:
{
if (g_pLauncher->Setup(eLaunchMode::LM_SERVER, eLaunchState::LS_CHEATS))
{
if (g_pLauncher->Launch())
{
Sleep(2000);
return EXIT_SUCCESS;
}
}
Sleep(2000);
return EXIT_FAILURE;
}
default:
{
spdlog::error("R5Reloaded requires '1' for DEBUG GAME mode, '2' for RELEASE GAME mode, '3' for DEBUG DEDICATED mode, '4' for RELEASE DEDICATED mode.\n");
Sleep(5000);
return EXIT_FAILURE;
}
}
}
catch (std::exception& e)
{
spdlog::error("R5Reloaded only takes numerical input to launch. Error: {}.\n", e.what());
Sleep(5000);
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
return EXIT_FAILURE;
}
}
spdlog::error("R5Reloaded requires numerical input to launch.\n");
Merge indev into master. (#44) * Added separate function to resolve relative addresses in address.h * Added new patterns to the print function. * Updated IsFlagSet hooks. * Cleaned up code to properly mask off Dev and Cheat flags. * Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables. * Removed un-used define in hooks.h * Fixed potential crashes in r5net and added debug prints. * Potential crashes were when in certain post functions the returned status wasn't 200. * Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41) * Host Server shows normal map names * Changed a few stuff... * redid some stuff that isn't crucial * Update CCompanion.cpp * Update CCompanion.cpp * Updated mapname displaying. * Moved "ServerMap" as a static object into CCompanion::HostServerSection(). Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> * prevent squirrel compiler errors from killing game process (#43) * Read description for all changes. * Added ability to register custom ConVar. * Added 2 custom ConVars to open the CGameConsole and CCompanion Windows. * Changed ResolveRelativeAddress. * Added Config System for the Gui. * Added ImGui::Hotkey. * Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion. * Changed pattern for Squirrel_CompilerError to use a String. * Added IMemAlloc::AllocWrapper to patterns.h * Changes in description. * Added icon to launcher.exe * Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration. * Extended argument buffer for starting the game in launcher.exe. * Added exception printing if in the custom ConVars an invalid value gets passed. * Wrong return. * Added shortcut with launch params. * Fixed prints. Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com> Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00
Sleep(5000);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
Code base refactor + major performance and readability improvement. Read description for details. * Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable. * Document most functions with valve style 'Purpose' blocks. * Rename variables to match the rest of the codebase and Valve's naming convention. * Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK. * Obtain globals or pointers directly instead of waiting for runtime initialized data. * Dynamically search for all functions and globals (this doesn't count for dedicated yet!). * Initialize most in-SDK variables. * Move certain prints and other utilities under ConVars to reduce verbosity and increase performance. * Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future. * Type global var pointers appropriately if class or type is known and implemented. * Forward declare 'CClient' class to avoid having 2 'g_pClient' copies. * Add IDA's pseudo definitions for easier prototyping with decompiled assembly code. * RPAK decompress Command callback implementation. * Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\'). * VPK decompress Command callback implementation. * Move CRC32 ands Adler32 to implementation files. * Server will print out more details about the connecting client. * Upgrade ImGui lib to v1.86. * Don't compile id3dx.h for dedicated. * Don't compile id3dx.cpp for dedicated * Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console * Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors. * Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up. * Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00
}