mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
See description
* Renamed 'r5apexsdkd64.dll' to 'gamesdk.dll'. * Added required dedicated parameters to code instead. * Bug fixes around CCommandLine class (fixed misaligned VTable indexes). * SDK now supports being directly launched by the game executable. The SDK launcher will pass '-launcher' to the game, which indicated its being launched by the launcher. If the game does not receive '-launcher', it assumes its being launched directly from the game executable, which will instead load 'startup_(dedi_)default.cfg'. The sdk dll's are now added to the game's IAT by their dummy exports allowing for them to be loaded when the exe is loaded (the dll's do everything on init).
This commit is contained in:
parent
cfe920f971
commit
f2a5c8ac68
@ -1,4 +1,4 @@
|
||||
LIBRARY r5apexsdkd64
|
||||
LIBRARY gamesdk
|
||||
|
||||
EXPORTS
|
||||
DummyExport @1
|
||||
|
@ -31,7 +31,7 @@ void CHLClient::FrameStageNotify(CHLClient* pHLClient, ClientFrameStage_t frameS
|
||||
{
|
||||
KeyValues::Init();
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) // !TEMP UNTIL CHOSTSTATE IS BUILD AGNOSTIC! //
|
||||
if (!g_pCmdLine->CheckParm("-devsdk"))
|
||||
if (!CommandLine()->CheckParm("-devsdk"))
|
||||
{
|
||||
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server.cfg\"", cmd_source_t::kCommandSrcCode);
|
||||
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server.cfg\"", cmd_source_t::kCommandSrcCode);
|
||||
|
@ -2,14 +2,13 @@
|
||||
|
||||
#ifdef DEDICATED
|
||||
inline const char* g_szGameDll = "r5apex_ds.exe";
|
||||
void Dedicated_Init();
|
||||
#else
|
||||
inline const char* g_szGameDll = "r5apex.exe";
|
||||
#endif // DEDICATED
|
||||
|
||||
void Dedicated_Init();
|
||||
void RuntimePtc_Init();
|
||||
void RuntimePtc_Toggle();
|
||||
|
||||
#ifdef GAMEDLL_S3
|
||||
/* -------------- OTHER ------------------------------------------------------------------------------------------------------------------------------------------------- */
|
||||
inline CMemory dst007 = /*0x14028F3B0*/ FindPatternSIMD(g_szGameDll, reinterpret_cast<rsig_t>("\x48\x8B\xC4\x44\x89\x40\x18\x48\x89\x50\x10\x55\x53\x56\x57\x41"), "xxxxxxxxxxxxxxxx");
|
||||
|
@ -9,6 +9,7 @@
|
||||
#endif // !DEDICATED
|
||||
#include "windows/console.h"
|
||||
#include "windows/system.h"
|
||||
#include "launcher/launcher.h"
|
||||
|
||||
//#############################################################################
|
||||
// INITIALIZATION
|
||||
@ -16,8 +17,19 @@
|
||||
|
||||
void R5Dev_Init()
|
||||
{
|
||||
if (strstr(GetCommandLineA(), "-launcher"))
|
||||
{
|
||||
g_svCmdLine = GetCommandLineA();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_svCmdLine = LoadConfigFile(SDK_DEFAULT_CFG);
|
||||
}
|
||||
#ifndef DEDICATED
|
||||
if (strstr(GetCommandLineA(), "-wconsole")) { Console_Init(); }
|
||||
if (strstr(g_svCmdLine.c_str(), "-wconsole"))
|
||||
{
|
||||
Console_Init();
|
||||
}
|
||||
#else
|
||||
Console_Init();
|
||||
#endif // !DEDICATED
|
||||
|
@ -21,8 +21,9 @@
|
||||
#include "vstdlib/keyvaluessystem.h"
|
||||
#include "common/opcodes.h"
|
||||
#include "common/netmessages.h"
|
||||
#include "launcher/IApplication.h"
|
||||
#include "launcher/prx.h"
|
||||
#include "launcher/launcher.h"
|
||||
#include "launcher/IApplication.h"
|
||||
#include "filesystem/basefilesystem.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
#include "ebisusdk/EbisuSDK.h"
|
||||
@ -132,6 +133,7 @@ void Systems_Init()
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
// Hook functions
|
||||
Launcher_Attatch();
|
||||
IApplication_Attach();
|
||||
#ifdef DEDICATED
|
||||
//PRX_Attach();
|
||||
@ -231,6 +233,7 @@ void Systems_Shutdown()
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
// Unhook functions
|
||||
Launcher_Detatch();
|
||||
IApplication_Detach();
|
||||
#ifdef DEDICATED
|
||||
//PRX_Detach();
|
||||
|
@ -31,7 +31,7 @@ void SpdLog_Init(void)
|
||||
auto wconsole = spdlog::stdout_logger_mt("win_console");
|
||||
|
||||
// Determine if user wants ansi-color logging in the terminal.
|
||||
if (strstr(GetCommandLineA(), "-ansiclr"))
|
||||
if (strstr(g_svCmdLine.c_str(), "-ansiclr"))
|
||||
{
|
||||
wconsole->set_pattern("[%S.%e] %v\u001b[0m");
|
||||
g_bSpdLog_UseAnsiClr = true;
|
||||
|
@ -13,7 +13,9 @@ std::string g_svGreenB = "";
|
||||
std::string g_svBlueB = "";
|
||||
std::string g_svYellowB = "";
|
||||
|
||||
std::string g_svReset = "";
|
||||
std::string g_svReset = "";
|
||||
|
||||
std::string g_svCmdLine;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets the global ansi escape sequences.
|
||||
|
@ -13,4 +13,6 @@ extern std::string g_svYellowB;
|
||||
|
||||
extern std::string g_svReset;
|
||||
|
||||
extern std::string g_svCmdLine;
|
||||
|
||||
void AnsiColors_Init();
|
||||
|
@ -256,7 +256,7 @@ FORCEINLINE void CHostState::Think(void) const
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE void CHostState::LoadConfig(void) const
|
||||
{
|
||||
if (!g_pCmdLine->CheckParm("-devsdk"))
|
||||
if (!CommandLine()->CheckParm("-devsdk"))
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server.cfg\"", cmd_source_t::kCommandSrcCode);
|
||||
|
@ -1,4 +1,4 @@
|
||||
//====== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -10,6 +10,7 @@
|
||||
#include "tier1/cvar.h"
|
||||
#include "engine/sys_dll.h"
|
||||
#include "engine/sys_dll2.h"
|
||||
#include "engine/sys_utils.h"
|
||||
#include "client/vengineclient_impl.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -30,7 +31,8 @@ static bool IsValveMod(const char* pModName)
|
||||
//-----------------------------------------------------------------------------
|
||||
static bool IsRespawnMod(const char* pModName)
|
||||
{
|
||||
return (_stricmp(pModName, "r1") == 0 ||
|
||||
return (_stricmp(pModName, "platform") == 0 ||
|
||||
_stricmp(pModName, "r1") == 0 ||
|
||||
_stricmp(pModName, "r2") == 0 ||
|
||||
_stricmp(pModName, "r5") == 0);
|
||||
}
|
||||
|
@ -734,7 +734,7 @@ void IBrowser::SetStyleVar(void)
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
ImVec4* colors = style.Colors;
|
||||
|
||||
if (!g_pCmdLine->CheckParm("-imgui_default_theme"))
|
||||
if (!CommandLine()->CheckParm("-imgui_default_theme"))
|
||||
{
|
||||
colors[ImGuiCol_Text] = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.56f, 0.56f, 0.56f, 1.00f);
|
||||
|
@ -762,9 +762,8 @@ void CConsole::SetStyleVar(void)
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
ImVec4* colors = style.Colors;
|
||||
|
||||
if (!g_pCmdLine->CheckParm("-imgui_default_theme"))
|
||||
if (!CommandLine()->CheckParm("-imgui_default_theme"))
|
||||
{
|
||||
|
||||
colors[ImGuiCol_Text] = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.56f, 0.56f, 0.56f, 1.00f);
|
||||
colors[ImGuiCol_WindowBg] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f);
|
||||
|
178
r5dev/launcher/launcher.cpp
Normal file
178
r5dev/launcher/launcher.cpp
Normal file
@ -0,0 +1,178 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Defines the entry point for the application.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#include "core/stdafx.h"
|
||||
#include "tier0/commandline.h"
|
||||
#include "launcher/launcher.h"
|
||||
|
||||
int HWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||
{
|
||||
// !TODO [AMOS]: 'RemoveSpuriousGameParameters()' is inline with 'LauncherMain()' in S0 and S1,
|
||||
// and its the only function where we could append our own command line parameters early enough
|
||||
// programatically (has to be after 'CommandLine()->CreateCmdLine()', but before 'SetPriorityClass()')
|
||||
// For S0 and S1 we should modify the command line buffer passed to the entry point instead (here).
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
string svCmdLine = lpCmdLine;
|
||||
if (!strstr(GetCommandLineA(), "-launcher"))
|
||||
{
|
||||
svCmdLine = LoadConfigFile(SDK_DEFAULT_CFG);
|
||||
}
|
||||
return v_WinMain(hInstance, hPrevInstance, const_cast<LPSTR>(svCmdLine.c_str()), nShowCmd);
|
||||
#else
|
||||
return v_WinMain(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
|
||||
#endif
|
||||
}
|
||||
|
||||
int LauncherMain(HINSTANCE hInstance)
|
||||
{
|
||||
int results = v_LauncherMain(hInstance);
|
||||
printf("LauncherMain returned %s\n", ExitCodeToString(results));
|
||||
return results;
|
||||
}
|
||||
|
||||
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
|
||||
// Remove all but the last -game parameter.
|
||||
// This is for mods based off something other than Half-Life 2 (like HL2MP mods).
|
||||
// The Steam UI does 'steam -applaunch 320 -game c:\steam\steamapps\sourcemods\modname', but applaunch inserts
|
||||
// its own -game parameter, which would supercede the one we really want if we didn't intercede here.
|
||||
void RemoveSpuriousGameParameters()
|
||||
{
|
||||
AppendSDKParametersPreInit();
|
||||
|
||||
// Find the last -game parameter.
|
||||
int nGameArgs = 0;
|
||||
char lastGameArg[MAX_PATH];
|
||||
for (int i = 0; i < CommandLine()->ParmCount() - 1; i++)
|
||||
{
|
||||
if (_stricmp(CommandLine()->GetParm(i), "-game") == 0)
|
||||
{
|
||||
_snprintf(lastGameArg, sizeof(lastGameArg), "\"%s\"", CommandLine()->GetParm(i + 1));
|
||||
++nGameArgs;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// We only care if > 1 was specified.
|
||||
if (nGameArgs > 1)
|
||||
{
|
||||
CommandLine()->RemoveParm("-game");
|
||||
CommandLine()->AppendParm("-game", lastGameArg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Append required command line parameters.
|
||||
// This avoids having all these in the startup configuration files
|
||||
// as all there are required to run the game with the game sdk.
|
||||
void AppendSDKParametersPreInit()
|
||||
{
|
||||
#ifdef DEDICATED
|
||||
CommandLine()->AppendParm("-sw", "");
|
||||
CommandLine()->AppendParm("-lv", "");
|
||||
CommandLine()->AppendParm("-safe", "");
|
||||
CommandLine()->AppendParm("-high", "");
|
||||
CommandLine()->AppendParm("-rerun", "");
|
||||
CommandLine()->AppendParm("-collate", "");
|
||||
CommandLine()->AppendParm("-multiple", "");
|
||||
CommandLine()->AppendParm("-noorigin", "");
|
||||
CommandLine()->AppendParm("-novid", "");
|
||||
CommandLine()->AppendParm("-noshaderapi", "");
|
||||
CommandLine()->AppendParm("-nosound", "");
|
||||
CommandLine()->AppendParm("-nojoy", "");
|
||||
CommandLine()->AppendParm("-nomouse", "");
|
||||
CommandLine()->AppendParm("-nomenuvid", "");
|
||||
CommandLine()->AppendParm("-nosendtable", "");
|
||||
CommandLine()->AppendParm("-gamepad_ignore_local", "");
|
||||
#endif
|
||||
// Assume default configs if the game isn't launched with the SDKLauncher.
|
||||
if (!CommandLine()->FindParm("-launcher"))
|
||||
{
|
||||
string svArguments = LoadConfigFile(SDK_DEFAULT_CFG);
|
||||
ParseAndApplyConfigFile(svArguments);
|
||||
}
|
||||
}
|
||||
|
||||
string LoadConfigFile(const string& svConfig)
|
||||
{
|
||||
fs::path cfgPath = fs::current_path() /= svConfig; // Get cfg path for default startup.
|
||||
ifstream cfgFile(cfgPath);
|
||||
string svArguments;
|
||||
|
||||
if (cfgFile.good() && cfgFile)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << cfgFile.rdbuf();
|
||||
svArguments = ss.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::error("%s: '%s' does not exist!\n", __FUNCTION__, svConfig.c_str());
|
||||
cfgFile.close();
|
||||
return "";
|
||||
}
|
||||
cfgFile.close();
|
||||
|
||||
return svArguments;
|
||||
}
|
||||
|
||||
void ParseAndApplyConfigFile(const string& svConfig)
|
||||
{
|
||||
stringstream ss(svConfig);
|
||||
string svInput;
|
||||
|
||||
if (strlen(svConfig.c_str()) > 0)
|
||||
{
|
||||
while (std::getline(ss, svInput, '\n'))
|
||||
{
|
||||
size_t nPos = svInput.find(" ");
|
||||
if (!svInput.empty()
|
||||
&& nPos > 0
|
||||
&& nPos < svInput.size()
|
||||
&& nPos != svInput.size())
|
||||
{
|
||||
string svValue = svInput.substr(nPos + 1);
|
||||
string svArgument = svInput.erase(svInput.find(" "));
|
||||
|
||||
CommandLine()->AppendParm(svArgument.c_str(), svValue.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandLine()->AppendParm(svInput.c_str(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* ExitCodeToString(int nCode)
|
||||
{
|
||||
switch (nCode)
|
||||
{
|
||||
case EXIT_SUCCESS:
|
||||
return "EXIT_SUCCESS";
|
||||
case EXIT_FAILURE:
|
||||
return "EXIT_SUCCESS";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void Launcher_Attatch()
|
||||
{
|
||||
DetourAttach((LPVOID*)&v_WinMain, &HWinMain);
|
||||
DetourAttach((LPVOID*)&v_LauncherMain, &LauncherMain);
|
||||
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
|
||||
DetourAttach((LPVOID*)&v_RemoveSpuriousGameParameters, &RemoveSpuriousGameParameters);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Launcher_Detatch()
|
||||
{
|
||||
DetourDetach((LPVOID*)&v_WinMain, &HWinMain);
|
||||
DetourDetach((LPVOID*)&v_LauncherMain, &LauncherMain);
|
||||
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
|
||||
DetourDetach((LPVOID*)&v_RemoveSpuriousGameParameters, &RemoveSpuriousGameParameters);
|
||||
#endif
|
||||
}
|
44
r5dev/launcher/launcher.h
Normal file
44
r5dev/launcher/launcher.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef LAUNCHER_H
|
||||
#define LAUNCHER_H
|
||||
|
||||
inline CMemory p_WinMain = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x41\x8B\xD9\x49\x8B\xF8"), "xxxx?xxxx?xxxx?xxxxxxxxxxx");
|
||||
inline auto v_WinMain = p_WinMain.RCast<int (*)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)>();
|
||||
|
||||
inline CMemory p_LauncherMain = g_mGameDll.GetExportedFunction("LauncherMain");
|
||||
inline auto v_LauncherMain = p_LauncherMain.RCast<int(*)(HINSTANCE hInstance)>();
|
||||
|
||||
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
|
||||
inline CMemory p_RemoveSpuriousGameParameters = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x33\xED\x48\x8D\x3D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx????xxxxx????");
|
||||
inline auto v_RemoveSpuriousGameParameters = p_RemoveSpuriousGameParameters.RCast<void* (*)(void)>();
|
||||
#endif // !GAMEDLL_S0 || !GAMEDLL_S1
|
||||
|
||||
void AppendSDKParametersPreInit();
|
||||
string LoadConfigFile(const string& svConfig);
|
||||
void ParseAndApplyConfigFile(const string& svConfig);
|
||||
const char* ExitCodeToString(int nCode);
|
||||
|
||||
void Launcher_Attatch();
|
||||
void Launcher_Detatch();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class HLauncher : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
std::cout << "| FUN: WinMain : 0x" << std::hex << std::uppercase << p_WinMain.GetPtr() << std::setw(nPad) << " |" << std::endl;
|
||||
std::cout << "| FUN: LauncherMain : 0x" << std::hex << std::uppercase << p_LauncherMain.GetPtr() << std::setw(nPad) << " |" << std::endl;
|
||||
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
|
||||
std::cout << "| FUN: RemoveSpuriousGameParameters::Create : 0x" << std::hex << std::uppercase << p_RemoveSpuriousGameParameters.GetPtr() << std::setw(nPad) << " |" << std::endl;
|
||||
#endif // !GAMEDLL_S0 || !GAMEDLL_S1
|
||||
std::cout << "+----------------------------------------------------------------+" << std::endl;
|
||||
}
|
||||
virtual void GetFun(void) const { }
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const { }
|
||||
virtual void Attach(void) const { }
|
||||
virtual void Detach(void) const { }
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
REGISTER(HLauncher);
|
||||
#endif // LAUNCHER_H
|
@ -11,11 +11,11 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Initialize strings.
|
||||
std::string WorkerDll = std::string();
|
||||
std::string GameDirectory = std::string();
|
||||
std::string CommandLineArguments = std::string();
|
||||
std::string StartupCommandLine = std::string();
|
||||
std::string currentDirectory = std::filesystem::current_path().u8string();
|
||||
std::string svWorkerDll = std::string();
|
||||
std::string svGameDir = std::string();
|
||||
std::string svCmdLineArgs = std::string();
|
||||
std::string svStartCmdLine = std::string();
|
||||
std::string svCurrentDir = std::filesystem::current_path().u8string();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Determine launch mode.
|
||||
@ -28,8 +28,8 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
if (cfgFile.good() && cfgFile) // Does the cfg file exist?
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
CommandLineArguments = ss.str(); // Get all the contents of the cfg file.
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
svCmdLineArgs = ss.str() + "-launcher"; // Get all the contents of the cfg file.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -39,9 +39,9 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
}
|
||||
cfgFile.close(); // Close cfg file.
|
||||
|
||||
WorkerDll = currentDirectory + "\\r5apexsdkd64.dll"; // Get path to worker dll.
|
||||
GameDirectory = currentDirectory + "\\r5apex.exe"; // Get path to game executeable.
|
||||
StartupCommandLine = currentDirectory + "\\r5apex.exe " + CommandLineArguments; // Setup startup command line string.
|
||||
svWorkerDll = svCurrentDir + "\\gamesdk.dll"; // Get path to worker dll.
|
||||
svGameDir = svCurrentDir + "\\r5apex.exe"; // Get path to game executeable.
|
||||
svStartCmdLine = svCurrentDir + "\\r5apex.exe " + svCmdLineArgs; // Setup startup command line string.
|
||||
|
||||
spdlog::info("*** LAUNCHING GAME [DEBUG] ***\n");
|
||||
break;
|
||||
@ -53,8 +53,8 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
if (cfgFile.good() && cfgFile) // Does the cfg file exist?
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
CommandLineArguments = ss.str(); // Get all the contents of the cfg file.
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
svCmdLineArgs = ss.str() + "-launcher"; // Get all the contents of the cfg file.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -64,9 +64,9 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
}
|
||||
cfgFile.close(); // Close cfg file.
|
||||
|
||||
WorkerDll = currentDirectory + "\\r5apexsdkd64.dll"; // Get path to worker dll.
|
||||
GameDirectory = currentDirectory + "\\r5apex.exe"; // Get path to game executeable.
|
||||
StartupCommandLine = currentDirectory + "\\r5apex.exe " + CommandLineArguments; // Setup startup command line string.
|
||||
svWorkerDll = svCurrentDir + "\\gamesdk.dll"; // Get path to worker dll.
|
||||
svGameDir = svCurrentDir + "\\r5apex.exe"; // Get path to game executeable.
|
||||
svStartCmdLine = svCurrentDir + "\\r5apex.exe " + svCmdLineArgs; // Setup startup command line string.
|
||||
|
||||
spdlog::info("*** LAUNCHING GAME [RELEASE] ***\n");
|
||||
break;
|
||||
@ -78,8 +78,8 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
if (cfgFile.good() && cfgFile) // Does the cfg file exist?
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
CommandLineArguments = ss.str(); // Get all the contents of the cfg file.
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
svCmdLineArgs = ss.str() + "-launcher"; // Get all the contents of the cfg file.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -89,9 +89,9 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
}
|
||||
cfgFile.close(); // Close cfg file.
|
||||
|
||||
WorkerDll = currentDirectory + "\\dedicated.dll"; // Get path to worker dll.
|
||||
GameDirectory = currentDirectory + "\\r5apex_ds.exe"; // Get path to game executeable.
|
||||
StartupCommandLine = currentDirectory + "\\r5apex_ds.exe " + CommandLineArguments; // Setup startup command line string.
|
||||
svWorkerDll = svCurrentDir + "\\dedicated.dll"; // Get path to worker dll.
|
||||
svGameDir = svCurrentDir + "\\r5apex_ds.exe"; // Get path to game executeable.
|
||||
svStartCmdLine = svCurrentDir + "\\r5apex_ds.exe " + svCmdLineArgs; // Setup startup command line string.
|
||||
|
||||
spdlog::info("*** LAUNCHING DEDICATED [DEBUG] ***\n");
|
||||
break;
|
||||
@ -103,8 +103,8 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
if (cfgFile.good() && cfgFile) // Does the cfg file exist?
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
CommandLineArguments = ss.str(); // Get all the contents of the cfg file.
|
||||
ss << cfgFile.rdbuf(); // Read ifstream buffer into stringstream.
|
||||
svCmdLineArgs = ss.str(); // Get all the contents of the cfg file.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -114,9 +114,9 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
}
|
||||
cfgFile.close(); // Close cfg file.
|
||||
|
||||
WorkerDll = currentDirectory + "\\dedicated.dll"; // Get path to worker dll.
|
||||
GameDirectory = currentDirectory + "\\r5apex_ds.exe"; // Get path to game executeable.
|
||||
StartupCommandLine = currentDirectory + "\\r5apex_ds.exe " + CommandLineArguments; // Setup startup command line string.
|
||||
svWorkerDll = svCurrentDir + "\\dedicated.dll"; // Get path to worker dll.
|
||||
svGameDir = svCurrentDir + "\\r5apex_ds.exe"; // Get path to game executeable.
|
||||
svStartCmdLine = svCurrentDir + "\\r5apex_ds.exe " + svCmdLineArgs; // Setup startup command line string.
|
||||
|
||||
spdlog::info("*** LAUNCHING DEDICATED [RELEASE] ***\n");
|
||||
break;
|
||||
@ -131,17 +131,17 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Print the file paths and arguments.
|
||||
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
||||
spdlog::debug("- CWD: {}\n", currentDirectory);
|
||||
spdlog::debug("- EXE: {}\n", GameDirectory);
|
||||
spdlog::debug("- DLL: {}\n", WorkerDll);
|
||||
spdlog::debug("- CLI: {}\n", CommandLineArguments);
|
||||
spdlog::debug("- CWD: {}\n", svCurrentDir);
|
||||
spdlog::debug("- EXE: {}\n", svGameDir);
|
||||
spdlog::debug("- DLL: {}\n", svWorkerDll);
|
||||
spdlog::debug("- CLI: {}\n", svCmdLineArgs);
|
||||
std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Build our list of dlls to inject.
|
||||
LPCSTR DllsToInject[1] =
|
||||
{
|
||||
WorkerDll.c_str()
|
||||
svWorkerDll.c_str()
|
||||
};
|
||||
|
||||
STARTUPINFOA StartupInfo = { 0 };
|
||||
@ -154,14 +154,14 @@ bool LaunchR5Apex(eLaunchMode lMode, eLaunchState lState)
|
||||
// Create the game process in a suspended state with our dll.
|
||||
BOOL result = DetourCreateProcessWithDllsA
|
||||
(
|
||||
GameDirectory.c_str(), // lpApplicationName
|
||||
(LPSTR)StartupCommandLine.c_str(), // lpCommandLine
|
||||
svGameDir.c_str(), // lpApplicationName
|
||||
(LPSTR)svStartCmdLine.c_str(), // lpCommandLine
|
||||
NULL, // lpProcessAttributes
|
||||
NULL, // lpThreadAttributes
|
||||
FALSE, // bInheritHandles
|
||||
CREATE_SUSPENDED, // dwCreationFlags
|
||||
NULL, // lpEnvironment
|
||||
currentDirectory.c_str(), // lpCurrentDirectory
|
||||
svCurrentDir.c_str(), // lpCurrentDirectory
|
||||
&StartupInfo, // lpStartupInfo
|
||||
&ProcInfo, // lpProcessInformation
|
||||
sizeof(DllsToInject) / sizeof(LPCSTR), // nDlls
|
||||
|
@ -16,7 +16,13 @@
|
||||
|
||||
#define MAX_PLAYERS 128 // Max R5 players.
|
||||
|
||||
#define SDK_VERSION "VGameSDK024"
|
||||
#define SDK_VERSION "VGameSDK001" // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility).
|
||||
|
||||
#ifndef DEDICATED
|
||||
#define SDK_DEFAULT_CFG "platform\\cfg\\startup_default.cfg"
|
||||
#else
|
||||
#define SDK_DEFAULT_CFG "platform\\cfg\\startup_dedi_default.cfg"
|
||||
#endif
|
||||
|
||||
// #define COMPILETIME_MAX and COMPILETIME_MIN for max/min in constant expressions
|
||||
#define COMPILETIME_MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
|
||||
|
@ -88,13 +88,11 @@ const char* CCommandLine::ParmValue(const char* psz, const char* pDefaultVal)
|
||||
static int index = 7;
|
||||
return CallVFunc<const char*>(index, this, psz, pDefaultVal);
|
||||
}
|
||||
|
||||
int CCommandLine::ParmValue(const char* psz, int nDefaultVal)
|
||||
{
|
||||
static int index = 8;
|
||||
return CallVFunc<int>(index, this, psz, nDefaultVal);
|
||||
}
|
||||
|
||||
float CCommandLine::ParmValue(const char* psz, float flDefaultVal)
|
||||
{
|
||||
static int index = 9;
|
||||
@ -124,9 +122,17 @@ const char* CCommandLine::GetParm(int nIndex)
|
||||
|
||||
void CCommandLine::SetParm(int nIndex, char const* pParm)
|
||||
{
|
||||
static int index = 13;
|
||||
static int index = 14;
|
||||
CallVFunc<void>(index, this, nIndex, pParm);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
CCommandLine* g_pCmdLine = reinterpret_cast<CCommandLine*>(p_CCVar_GetCommandLineValue.FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 250).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr());
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Instance singleton and expose interface to rest of code
|
||||
//-----------------------------------------------------------------------------
|
||||
CCommandLine* CommandLine(void)
|
||||
{
|
||||
return g_pCmdLine;
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ public:
|
||||
const char* GetParm(int nIndex);
|
||||
void SetParm(int nIndex, char const* pParm);
|
||||
};
|
||||
extern CCommandLine* g_pCmdLine;
|
||||
CCommandLine* CommandLine(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class HCommandLine : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
std::cout << "| VAR: g_pCmdLine : 0x" << std::hex << std::uppercase << g_pCmdLine << std::setw(0) << " |" << std::endl;
|
||||
std::cout << "| VAR: g_pCmdLine : 0x" << std::hex << std::uppercase << CommandLine() << std::setw(0) << " |" << std::endl;
|
||||
std::cout << "+----------------------------------------------------------------+" << std::endl;
|
||||
}
|
||||
virtual void GetFun(void) const { }
|
||||
|
@ -169,10 +169,11 @@ void ConVar::InitShipped(void) const
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: unregister/disable unused ConVar's for dedicated.
|
||||
// Purpose: unregister/disable extraneous ConVar's.
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConVar::PurgeShipped(void) const
|
||||
{
|
||||
#ifdef DEDICATED
|
||||
const char* pszToPurge[] =
|
||||
{
|
||||
"bink_materials_enabled",
|
||||
@ -191,6 +192,7 @@ void ConVar::PurgeShipped(void) const
|
||||
pCVar->SetValue(0);
|
||||
}
|
||||
}
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -171,10 +171,11 @@ void ConCommand::InitShipped(void)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: unregister unused ConCommand's for dedicated.
|
||||
// Purpose: unregister extraneous ConCommand's.
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConCommand::PurgeShipped(void) const
|
||||
{
|
||||
#ifdef DEDICATED
|
||||
const char* pszCommandToRemove[] =
|
||||
{
|
||||
"bind",
|
||||
@ -183,14 +184,24 @@ void ConCommand::PurgeShipped(void) const
|
||||
"bind_list_abilities",
|
||||
"bind_US_standard",
|
||||
"bind_held_US_standard",
|
||||
"unbind",
|
||||
"unbind_US_standard",
|
||||
"unbindall",
|
||||
"unbind_all_gamepad",
|
||||
"unbindall_ignoreGamepad",
|
||||
"unbind_batch",
|
||||
"unbind_held",
|
||||
"unbind_held_US_standard",
|
||||
"getpos_bind",
|
||||
"connect",
|
||||
"silent_connect",
|
||||
"ping",
|
||||
"gameui_activate",
|
||||
"gameui_hide",
|
||||
"weaponSelectOrdnance",
|
||||
"weaponSelectPrimary0",
|
||||
"weaponSelectPrimary1",
|
||||
"weaponSelectPrimary2",
|
||||
"silent_connect",
|
||||
"+scriptCommand1",
|
||||
"-scriptCommand1",
|
||||
"+scriptCommand2",
|
||||
@ -220,6 +231,7 @@ void ConCommand::PurgeShipped(void) const
|
||||
g_pCVar->UnregisterConCommand(pCommandBase);
|
||||
}
|
||||
}
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -46,6 +46,7 @@
|
||||
<ClCompile Include="..\gameui\IBrowser.cpp" />
|
||||
<ClCompile Include="..\inputsystem\inputsystem.cpp" />
|
||||
<ClCompile Include="..\launcher\IApplication.cpp" />
|
||||
<ClCompile Include="..\launcher\launcher.cpp" />
|
||||
<ClCompile Include="..\materialsystem\cmaterialglue.cpp" />
|
||||
<ClCompile Include="..\materialsystem\cmaterialsystem.cpp" />
|
||||
<ClCompile Include="..\mathlib\adler32.cpp" />
|
||||
@ -152,6 +153,7 @@
|
||||
<ClInclude Include="..\inputsystem\ButtonCode.h" />
|
||||
<ClInclude Include="..\inputsystem\inputsystem.h" />
|
||||
<ClInclude Include="..\launcher\IApplication.h" />
|
||||
<ClInclude Include="..\launcher\launcher.h" />
|
||||
<ClInclude Include="..\materialsystem\cmaterialglue.h" />
|
||||
<ClInclude Include="..\materialsystem\cmaterialsystem.h" />
|
||||
<ClInclude Include="..\mathlib\adler32.h" />
|
||||
|
@ -417,6 +417,9 @@
|
||||
<ClCompile Include="..\vstdlib\callback.cpp">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\launcher\launcher.cpp">
|
||||
<Filter>sdk\launcher</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1190,6 +1193,9 @@
|
||||
<ClInclude Include="..\tier0\tslist.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\launcher\launcher.h">
|
||||
<Filter>sdk\launcher</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -169,6 +169,7 @@
|
||||
<ClInclude Include="..\game\server\fairfight_impl.h" />
|
||||
<ClInclude Include="..\game\server\gameinterface.h" />
|
||||
<ClInclude Include="..\launcher\IApplication.h" />
|
||||
<ClInclude Include="..\launcher\launcher.h" />
|
||||
<ClInclude Include="..\launcher\prx.h" />
|
||||
<ClInclude Include="..\materialsystem\cmaterialsystem.h" />
|
||||
<ClInclude Include="..\mathlib\adler32.h" />
|
||||
@ -395,6 +396,7 @@
|
||||
<ClCompile Include="..\game\server\ai_utility.cpp" />
|
||||
<ClCompile Include="..\game\server\gameinterface.cpp" />
|
||||
<ClCompile Include="..\launcher\IApplication.cpp" />
|
||||
<ClCompile Include="..\launcher\launcher.cpp" />
|
||||
<ClCompile Include="..\launcher\prx.cpp" />
|
||||
<ClCompile Include="..\mathlib\adler32.cpp" />
|
||||
<ClCompile Include="..\mathlib\bits.cpp" />
|
||||
|
@ -861,6 +861,9 @@
|
||||
<ClInclude Include="..\tier0\tslist.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\launcher\launcher.h">
|
||||
<Filter>sdk\launcher</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
@ -1085,6 +1088,9 @@
|
||||
<ClCompile Include="..\vstdlib\callback.cpp">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\launcher\launcher.cpp">
|
||||
<Filter>sdk\launcher</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Dedicated.def" />
|
||||
|
@ -52,6 +52,7 @@
|
||||
<ClCompile Include="..\game\server\gameinterface.cpp" />
|
||||
<ClCompile Include="..\inputsystem\inputsystem.cpp" />
|
||||
<ClCompile Include="..\launcher\IApplication.cpp" />
|
||||
<ClCompile Include="..\launcher\launcher.cpp" />
|
||||
<ClCompile Include="..\materialsystem\cmaterialglue.cpp" />
|
||||
<ClCompile Include="..\materialsystem\cmaterialsystem.cpp" />
|
||||
<ClCompile Include="..\mathlib\adler32.cpp" />
|
||||
@ -169,6 +170,7 @@
|
||||
<ClInclude Include="..\inputsystem\ButtonCode.h" />
|
||||
<ClInclude Include="..\inputsystem\inputsystem.h" />
|
||||
<ClInclude Include="..\launcher\IApplication.h" />
|
||||
<ClInclude Include="..\launcher\launcher.h" />
|
||||
<ClInclude Include="..\materialsystem\cmaterialglue.h" />
|
||||
<ClInclude Include="..\materialsystem\cmaterialsystem.h" />
|
||||
<ClInclude Include="..\mathlib\adler32.h" />
|
||||
@ -432,7 +434,7 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(SolutionDir)r5dev\;$(IncludePath);$(DXSDK_DIR)Include</IncludePath>
|
||||
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x64</LibraryPath>
|
||||
<TargetName>r5apexsdkd64</TargetName>
|
||||
<TargetName>gamesdk</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<ReferencePath>$(VC_ReferencesPath_x64);</ReferencePath>
|
||||
@ -441,7 +443,7 @@
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(SolutionDir)r5dev\;$(IncludePath);$(DXSDK_DIR)Include</IncludePath>
|
||||
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x64</LibraryPath>
|
||||
<TargetName>r5apexsdkd64</TargetName>
|
||||
<TargetName>gamesdk</TargetName>
|
||||
<ReferencePath>$(VC_ReferencesPath_x64);</ReferencePath>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
@ -469,7 +471,7 @@
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>IF EXIST "$(SolutionDir)..\..\r5apex.exe" del "$(SolutionDir)..\..\r5apexsdkd64.dll" && copy /Y "$(TargetPath)" "$(SolutionDir)..\..\</Command>
|
||||
<Command>IF EXIST "$(SolutionDir)..\..\r5apex.exe" del "$(SolutionDir)..\..\gamesdk.dll" && copy /Y "$(TargetPath)" "$(SolutionDir)..\..\</Command>
|
||||
</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
@ -511,7 +513,7 @@
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>IF EXIST "$(SolutionDir)..\..\r5apex.exe" del "$(SolutionDir)..\..\r5apexsdkd64.dll" && copy /Y "$(TargetPath)" "$(SolutionDir)..\..\</Command>
|
||||
<Command>IF EXIST "$(SolutionDir)..\..\r5apex.exe" del "$(SolutionDir)..\..\gamesdk.dll" && copy /Y "$(TargetPath)" "$(SolutionDir)..\..\</Command>
|
||||
</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
|
@ -447,6 +447,9 @@
|
||||
<ClCompile Include="..\vstdlib\callback.cpp">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\launcher\launcher.cpp">
|
||||
<Filter>sdk\launcher</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1253,6 +1256,9 @@
|
||||
<ClInclude Include="..\tier0\tslist.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\launcher\launcher.h">
|
||||
<Filter>sdk\launcher</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -97,7 +97,7 @@ void Console_Init()
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
|
||||
if (strstr(GetCommandLineA(), "-ansiclr"))
|
||||
if (strstr(g_svCmdLine.c_str(), "-ansiclr"))
|
||||
{
|
||||
GetConsoleMode(hOutput, &dwMode);
|
||||
dwMode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||
|
Loading…
x
Reference in New Issue
Block a user