mirror of
https://github.com/rehlds/rehlds.git
synced 2025-02-05 10:10:44 +03:00
Launcher fix crash on linux (#468)
This commit is contained in:
parent
4663183f7a
commit
5ae03d2c5c
@ -320,12 +320,13 @@ const char *CCommandLine::CheckParm(const char *psz, char **ppszValue) const
|
|||||||
if (!m_pszCmdLine)
|
if (!m_pszCmdLine)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if (ppszValue)
|
||||||
|
*ppszValue = nullptr;
|
||||||
|
|
||||||
char *pret = strstr(m_pszCmdLine, psz);
|
char *pret = strstr(m_pszCmdLine, psz);
|
||||||
if (!pret || !ppszValue)
|
if (!pret || !ppszValue)
|
||||||
return pret;
|
return pret;
|
||||||
|
|
||||||
*ppszValue = nullptr;
|
|
||||||
|
|
||||||
// find the next whitespace
|
// find the next whitespace
|
||||||
char *p1 = pret;
|
char *p1 = pret;
|
||||||
do {
|
do {
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef ICOMMANDLINE_H
|
|
||||||
#define ICOMMANDLINE_H
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Interface to engine command line
|
|
||||||
class ICommandLine {
|
|
||||||
public:
|
|
||||||
virtual void CreateCmdLine(const char *commandline) = 0;
|
|
||||||
virtual void CreateCmdLine(int argc, const char **argv) = 0;
|
|
||||||
virtual const char *GetCmdLine() const = 0;
|
|
||||||
|
|
||||||
// Check whether a particular parameter exists
|
|
||||||
virtual const char *CheckParm(const char *psz, char **ppszValue = nullptr) const = 0;
|
|
||||||
virtual void RemoveParm(const char *pszParm) = 0;
|
|
||||||
virtual void AppendParm(const char *pszParm, const char *pszValues) = 0;
|
|
||||||
|
|
||||||
virtual void SetParm(const char *pszParm, const char *pszValues) = 0;
|
|
||||||
virtual void SetParm(const char *pszParm, int iValue) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
ICommandLine *CommandLine();
|
|
||||||
|
|
||||||
#endif // ICOMMANDLINE_H
|
|
@ -28,10 +28,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define VGUI
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LAUNCHER_ERROR -1
|
#define LAUNCHER_ERROR -1
|
||||||
#define LAUNCHER_OK 0
|
#define LAUNCHER_OK 0
|
||||||
|
|
||||||
@ -44,3 +40,4 @@ extern IDedicatedServerAPI *engineAPI;
|
|||||||
bool Sys_SetupConsole();
|
bool Sys_SetupConsole();
|
||||||
void Sys_PrepareConsoleInput();
|
void Sys_PrepareConsoleInput();
|
||||||
void Sys_InitPingboost();
|
void Sys_InitPingboost();
|
||||||
|
void Sys_WriteProcessIdFile();
|
||||||
|
@ -153,7 +153,8 @@ int RunEngine()
|
|||||||
RunVGUIFrame();
|
RunVGUIFrame();
|
||||||
|
|
||||||
bool bDone = false;
|
bool bDone = false;
|
||||||
while (!bDone) {
|
while (!bDone)
|
||||||
|
{
|
||||||
// Running really fast, yield some time to other apps
|
// Running really fast, yield some time to other apps
|
||||||
sys->Sleep(1);
|
sys->Sleep(1);
|
||||||
|
|
||||||
@ -205,8 +206,6 @@ int StartServer(char* cmdline)
|
|||||||
CommandLine()->CreateCmdLine(cmdline);
|
CommandLine()->CreateCmdLine(cmdline);
|
||||||
CommandLine()->AppendParm("-steam", nullptr);
|
CommandLine()->AppendParm("-steam", nullptr);
|
||||||
|
|
||||||
Sys_InitPingboost();
|
|
||||||
|
|
||||||
// Load engine
|
// Load engine
|
||||||
g_pEngineModule = Sys_LoadModule(ENGINE_LIB);
|
g_pEngineModule = Sys_LoadModule(ENGINE_LIB);
|
||||||
if (!g_pEngineModule) {
|
if (!g_pEngineModule) {
|
||||||
@ -214,6 +213,9 @@ int StartServer(char* cmdline)
|
|||||||
return LAUNCHER_ERROR;
|
return LAUNCHER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sys_InitPingboost();
|
||||||
|
Sys_WriteProcessIdFile();
|
||||||
|
|
||||||
// Load filesystem
|
// Load filesystem
|
||||||
g_pFileSystemModule = Sys_LoadModule(STDIO_FILESYSTEM_LIB);
|
g_pFileSystemModule = Sys_LoadModule(STDIO_FILESYSTEM_LIB);
|
||||||
if (!g_pFileSystemModule) {
|
if (!g_pFileSystemModule) {
|
||||||
@ -240,8 +242,7 @@ int StartServer(char* cmdline)
|
|||||||
|
|
||||||
// Init VGUI or Console mode
|
// Init VGUI or Console mode
|
||||||
#ifdef VGUI
|
#ifdef VGUI
|
||||||
char *pszValue = nullptr;
|
if (!CommandLine()->CheckParm("-console")) {
|
||||||
if (!CommandLine()->CheckParm("-console", &pszValue)) {
|
|
||||||
g_bVGui = true;
|
g_bVGui = true;
|
||||||
StartVGUI();
|
StartVGUI();
|
||||||
}
|
}
|
||||||
@ -258,8 +259,9 @@ int StartServer(char* cmdline)
|
|||||||
return LAUNCHER_ERROR;
|
return LAUNCHER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Sys_SetupConsole())
|
if (!Sys_SetupConsole()) {
|
||||||
return LAUNCHER_ERROR;
|
return LAUNCHER_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VGUI
|
#ifdef VGUI
|
||||||
@ -267,10 +269,9 @@ int StartServer(char* cmdline)
|
|||||||
/*// run vgui
|
/*// run vgui
|
||||||
if (g_bVGui)
|
if (g_bVGui)
|
||||||
{
|
{
|
||||||
while (VGUIIsInConfig() && VGUIIsRunning())
|
while (VGUIIsInConfig() && VGUIIsRunning()) {
|
||||||
{
|
RunVGUIFrame();
|
||||||
RunVGUIFrame();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else*/
|
else*/
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,20 +56,10 @@ ISys *sys = &g_Sys;
|
|||||||
char g_szEXEName[MAX_PATH];
|
char g_szEXEName[MAX_PATH];
|
||||||
|
|
||||||
SleepType Sys_Sleep;
|
SleepType Sys_Sleep;
|
||||||
NET_Sleep_t NET_Sleep_Timeout = NULL;
|
NET_Sleep_t NET_Sleep_Timeout = nullptr;
|
||||||
|
|
||||||
CSys::CSys()
|
CSys::CSys()
|
||||||
{
|
{
|
||||||
char *fname;
|
|
||||||
if (CommandLine()->CheckParm("-pidfile", &fname) && fname) {
|
|
||||||
FILE *pidFile = fopen(fname, "w");
|
|
||||||
if (pidFile) {
|
|
||||||
fprintf(pidFile, "%i\n", getpid());
|
|
||||||
fclose(pidFile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("Warning: unable to open pidfile (%s)\n", fname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSys::~CSys()
|
CSys::~CSys()
|
||||||
@ -186,6 +176,23 @@ void Sys_InitPingboost()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sys_WriteProcessIdFile()
|
||||||
|
{
|
||||||
|
char *fname;
|
||||||
|
if (!CommandLine()->CheckParm("-pidfile", &fname) || !fname) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *pidFile = fopen(fname, "w");
|
||||||
|
if (!pidFile) {
|
||||||
|
printf("Warning: unable to open pidfile (%s)\n", fname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(pidFile, "%i\n", getpid());
|
||||||
|
fclose(pidFile);
|
||||||
|
}
|
||||||
|
|
||||||
bool CSys::GetExecutableName(char *out)
|
bool CSys::GetExecutableName(char *out)
|
||||||
{
|
{
|
||||||
strcpy(out, g_szEXEName);
|
strcpy(out, g_szEXEName);
|
||||||
|
@ -56,7 +56,7 @@ ISys *sys = &g_Sys;
|
|||||||
|
|
||||||
CSys::CSys()
|
CSys::CSys()
|
||||||
{
|
{
|
||||||
// Startup winock
|
// Startup winsock
|
||||||
WORD version = MAKEWORD(2, 0);
|
WORD version = MAKEWORD(2, 0);
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
WSAStartup(version, &wsaData);
|
WSAStartup(version, &wsaData);
|
||||||
@ -232,6 +232,11 @@ void Sys_InitPingboost()
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sys_WriteProcessIdFile()
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||||
{
|
{
|
||||||
if (ShouldLaunchAppViaSteam(lpCmdLine, STDIO_FILESYSTEM_LIB, STDIO_FILESYSTEM_LIB))
|
if (ShouldLaunchAppViaSteam(lpCmdLine, STDIO_FILESYSTEM_LIB, STDIO_FILESYSTEM_LIB))
|
||||||
|
@ -58,7 +58,7 @@ int StartVGUI()
|
|||||||
const int numFactories = 4;
|
const int numFactories = 4;
|
||||||
if (!InitializeVGui(&ifaceFactory, numFactories))
|
if (!InitializeVGui(&ifaceFactory, numFactories))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Fatal Error: Could not initialize vgui.", "Steam - Fatal Error", MB_OK | MB_ICONERROR);
|
MessageBox(nullptr, "Fatal Error: Could not initialize vgui.", "Steam - Fatal Error", MB_OK | MB_ICONERROR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ int StartVGUI()
|
|||||||
vgui::surface()->SetEmbeddedPanel(g_pMainPanel->GetVPanel());
|
vgui::surface()->SetEmbeddedPanel(g_pMainPanel->GetVPanel());
|
||||||
|
|
||||||
// load the scheme
|
// load the scheme
|
||||||
vgui::scheme()->LoadSchemeFromFile("Resource/TrackerScheme.res", NULL);
|
vgui::scheme()->LoadSchemeFromFile("Resource/TrackerScheme.res", nullptr);
|
||||||
|
|
||||||
// localization
|
// localization
|
||||||
vgui::localize()->AddFile("Resource/platform_%language%.txt");
|
vgui::localize()->AddFile("Resource/platform_%language%.txt");
|
||||||
@ -103,8 +103,8 @@ int StartVGUI()
|
|||||||
// load the module
|
// load the module
|
||||||
g_pFullFileSystem->GetLocalCopy("Platform/Admin/AdminServer.dll");
|
g_pFullFileSystem->GetLocalCopy("Platform/Admin/AdminServer.dll");
|
||||||
g_hAdminServerModule = Sys_LoadModule("Platform/Admin/AdminServer.dll");
|
g_hAdminServerModule = Sys_LoadModule("Platform/Admin/AdminServer.dll");
|
||||||
Assert(g_hAdminServerModule != NULL);
|
Assert(g_hAdminServerModule != nullptr);
|
||||||
CreateInterfaceFn adminFactory = NULL;
|
CreateInterfaceFn adminFactory = nullptr;
|
||||||
|
|
||||||
if (!g_hAdminServerModule)
|
if (!g_hAdminServerModule)
|
||||||
{
|
{
|
||||||
@ -114,10 +114,10 @@ int StartVGUI()
|
|||||||
{
|
{
|
||||||
// make sure we get the right version
|
// make sure we get the right version
|
||||||
adminFactory = Sys_GetFactory(g_hAdminServerModule);
|
adminFactory = Sys_GetFactory(g_hAdminServerModule);
|
||||||
g_pAdminServer = (IAdminServer *)adminFactory(ADMINSERVER_INTERFACE_VERSION, NULL);
|
g_pAdminServer = (IAdminServer *)adminFactory(ADMINSERVER_INTERFACE_VERSION, nullptr);
|
||||||
g_pAdminVGuiModule = (IVGuiModule *)adminFactory("VGuiModuleAdminServer001", NULL);
|
g_pAdminVGuiModule = (IVGuiModule *)adminFactory("VGuiModuleAdminServer001", nullptr);
|
||||||
Assert(g_pAdminServer != NULL);
|
Assert(g_pAdminServer != nullptr);
|
||||||
Assert(g_pAdminVGuiModule != NULL);
|
Assert(g_pAdminVGuiModule != nullptr);
|
||||||
if (!g_pAdminServer || !g_pAdminVGuiModule)
|
if (!g_pAdminServer || !g_pAdminVGuiModule)
|
||||||
{
|
{
|
||||||
vgui::ivgui()->DPrintf2("Admin Error: module version (Admin/AdminServer.dll, %s) invalid, not loading\n", IMANAGESERVER_INTERFACE_VERSION);
|
vgui::ivgui()->DPrintf2("Admin Error: module version (Admin/AdminServer.dll, %s) invalid, not loading\n", IMANAGESERVER_INTERFACE_VERSION);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user