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)
|
||||
return nullptr;
|
||||
|
||||
if (ppszValue)
|
||||
*ppszValue = nullptr;
|
||||
|
||||
char *pret = strstr(m_pszCmdLine, psz);
|
||||
if (!pret || !ppszValue)
|
||||
return pret;
|
||||
|
||||
*ppszValue = nullptr;
|
||||
|
||||
// find the next whitespace
|
||||
char *p1 = pret;
|
||||
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
|
||||
|
||||
#ifdef _WIN32
|
||||
#define VGUI
|
||||
#endif
|
||||
|
||||
#define LAUNCHER_ERROR -1
|
||||
#define LAUNCHER_OK 0
|
||||
|
||||
@ -44,3 +40,4 @@ extern IDedicatedServerAPI *engineAPI;
|
||||
bool Sys_SetupConsole();
|
||||
void Sys_PrepareConsoleInput();
|
||||
void Sys_InitPingboost();
|
||||
void Sys_WriteProcessIdFile();
|
||||
|
@ -153,7 +153,8 @@ int RunEngine()
|
||||
RunVGUIFrame();
|
||||
|
||||
bool bDone = false;
|
||||
while (!bDone) {
|
||||
while (!bDone)
|
||||
{
|
||||
// Running really fast, yield some time to other apps
|
||||
sys->Sleep(1);
|
||||
|
||||
@ -205,8 +206,6 @@ int StartServer(char* cmdline)
|
||||
CommandLine()->CreateCmdLine(cmdline);
|
||||
CommandLine()->AppendParm("-steam", nullptr);
|
||||
|
||||
Sys_InitPingboost();
|
||||
|
||||
// Load engine
|
||||
g_pEngineModule = Sys_LoadModule(ENGINE_LIB);
|
||||
if (!g_pEngineModule) {
|
||||
@ -214,6 +213,9 @@ int StartServer(char* cmdline)
|
||||
return LAUNCHER_ERROR;
|
||||
}
|
||||
|
||||
Sys_InitPingboost();
|
||||
Sys_WriteProcessIdFile();
|
||||
|
||||
// Load filesystem
|
||||
g_pFileSystemModule = Sys_LoadModule(STDIO_FILESYSTEM_LIB);
|
||||
if (!g_pFileSystemModule) {
|
||||
@ -240,8 +242,7 @@ int StartServer(char* cmdline)
|
||||
|
||||
// Init VGUI or Console mode
|
||||
#ifdef VGUI
|
||||
char *pszValue = nullptr;
|
||||
if (!CommandLine()->CheckParm("-console", &pszValue)) {
|
||||
if (!CommandLine()->CheckParm("-console")) {
|
||||
g_bVGui = true;
|
||||
StartVGUI();
|
||||
}
|
||||
@ -258,8 +259,9 @@ int StartServer(char* cmdline)
|
||||
return LAUNCHER_ERROR;
|
||||
}
|
||||
|
||||
if (!Sys_SetupConsole())
|
||||
if (!Sys_SetupConsole()) {
|
||||
return LAUNCHER_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VGUI
|
||||
@ -267,10 +269,9 @@ int StartServer(char* cmdline)
|
||||
/*// run vgui
|
||||
if (g_bVGui)
|
||||
{
|
||||
while (VGUIIsInConfig() && VGUIIsRunning())
|
||||
{
|
||||
RunVGUIFrame();
|
||||
}
|
||||
while (VGUIIsInConfig() && VGUIIsRunning()) {
|
||||
RunVGUIFrame();
|
||||
}
|
||||
}
|
||||
else*/
|
||||
#endif
|
||||
|
@ -56,20 +56,10 @@ ISys *sys = &g_Sys;
|
||||
char g_szEXEName[MAX_PATH];
|
||||
|
||||
SleepType Sys_Sleep;
|
||||
NET_Sleep_t NET_Sleep_Timeout = NULL;
|
||||
NET_Sleep_t NET_Sleep_Timeout = nullptr;
|
||||
|
||||
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()
|
||||
@ -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)
|
||||
{
|
||||
strcpy(out, g_szEXEName);
|
||||
|
@ -56,7 +56,7 @@ ISys *sys = &g_Sys;
|
||||
|
||||
CSys::CSys()
|
||||
{
|
||||
// Startup winock
|
||||
// Startup winsock
|
||||
WORD version = MAKEWORD(2, 0);
|
||||
WSADATA 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)
|
||||
{
|
||||
if (ShouldLaunchAppViaSteam(lpCmdLine, STDIO_FILESYSTEM_LIB, STDIO_FILESYSTEM_LIB))
|
||||
|
@ -58,7 +58,7 @@ int StartVGUI()
|
||||
const int numFactories = 4;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ int StartVGUI()
|
||||
vgui::surface()->SetEmbeddedPanel(g_pMainPanel->GetVPanel());
|
||||
|
||||
// load the scheme
|
||||
vgui::scheme()->LoadSchemeFromFile("Resource/TrackerScheme.res", NULL);
|
||||
vgui::scheme()->LoadSchemeFromFile("Resource/TrackerScheme.res", nullptr);
|
||||
|
||||
// localization
|
||||
vgui::localize()->AddFile("Resource/platform_%language%.txt");
|
||||
@ -103,8 +103,8 @@ int StartVGUI()
|
||||
// load the module
|
||||
g_pFullFileSystem->GetLocalCopy("Platform/Admin/AdminServer.dll");
|
||||
g_hAdminServerModule = Sys_LoadModule("Platform/Admin/AdminServer.dll");
|
||||
Assert(g_hAdminServerModule != NULL);
|
||||
CreateInterfaceFn adminFactory = NULL;
|
||||
Assert(g_hAdminServerModule != nullptr);
|
||||
CreateInterfaceFn adminFactory = nullptr;
|
||||
|
||||
if (!g_hAdminServerModule)
|
||||
{
|
||||
@ -114,10 +114,10 @@ int StartVGUI()
|
||||
{
|
||||
// make sure we get the right version
|
||||
adminFactory = Sys_GetFactory(g_hAdminServerModule);
|
||||
g_pAdminServer = (IAdminServer *)adminFactory(ADMINSERVER_INTERFACE_VERSION, NULL);
|
||||
g_pAdminVGuiModule = (IVGuiModule *)adminFactory("VGuiModuleAdminServer001", NULL);
|
||||
Assert(g_pAdminServer != NULL);
|
||||
Assert(g_pAdminVGuiModule != NULL);
|
||||
g_pAdminServer = (IAdminServer *)adminFactory(ADMINSERVER_INTERFACE_VERSION, nullptr);
|
||||
g_pAdminVGuiModule = (IVGuiModule *)adminFactory("VGuiModuleAdminServer001", nullptr);
|
||||
Assert(g_pAdminServer != nullptr);
|
||||
Assert(g_pAdminVGuiModule != nullptr);
|
||||
if (!g_pAdminServer || !g_pAdminVGuiModule)
|
||||
{
|
||||
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