int i;
char vabuf[1024];
+ Sys_SDL_Init();
+
+ Memory_Init();
+
host.hook.ConnectLocal = NULL;
host.hook.Disconnect = NULL;
host.hook.ToggleMenu = NULL;
/// called to yield for a little bit so as not to hog cpu when paused or debugging
double Sys_Sleep(double time);
+void Sys_SDL_Init(void);
/// Perform Key_Event () callbacks until the input que is empty
void Sys_SDL_HandleEvents(void);
#include <android/log.h>
#endif
-#include <signal.h>
-
/*
* Include this BEFORE darkplaces.h because it breaks wrapping
* _Static_assert. Cloudwalk has no idea how or why so don't ask.
SDL_Quit();
}
-static qbool nocrashdialog;
+// Sys_Error early in startup might screw with automated
+// workflows or something if we show the dialog by default.
+static qbool nocrashdialog = true;
void Sys_Error (const char *error, ...)
{
va_list argptr;
return data;
}
-int main (int argc, char *argv[])
+void Sys_SDL_Init(void)
{
- signal(SIGFPE, SIG_IGN);
-
-#ifdef __ANDROID__
- Sys_AllowProfiling(true);
-#endif
-
- sys.selffd = -1;
- sys.argc = argc;
- sys.argv = (const char **)argv;
-
- // Sys_Error this early in startup might screw with automated
- // workflows or something if we show the dialog by default.
- nocrashdialog = true;
-
- Sys_ProvideSelfFD();
+ // we don't know which systems we'll want to init, yet...
+ if (SDL_Init(0) < 0)
+ Sys_Error("SDL_Init failed: %s\n", SDL_GetError());
- // COMMANDLINEOPTION: -nocrashdialog disables "Engine Error" crash dialog boxes
+ // COMMANDLINEOPTION: sdl: -nocrashdialog disables "Engine Error" crash dialog boxes
if(!Sys_CheckParm("-nocrashdialog"))
nocrashdialog = false;
- // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
- if(Sys_CheckParm("-noterminal"))
- sys.outfd = -1;
- // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
- else if(Sys_CheckParm("-stderr"))
- sys.outfd = 2;
- else
- sys.outfd = 1;
-
-#ifndef WIN32
- fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
-#endif
-
- // we don't know which systems we'll want to init, yet...
- SDL_Init(0);
-
- // used by everything
- Memory_Init();
-
- Host_Main();
-
- Sys_Quit(0);
-
- return 0;
}
qbool sys_supportsdlgetticks = true;
# endif
#endif
+#include <signal.h>
+
static char sys_timestring[128];
char *Sys_TimeString(const char *timeformat)
{
{
}
#endif
+
+int main (int argc, char **argv)
+{
+ signal(SIGFPE, SIG_IGN);
+
+ sys.argc = argc;
+ sys.argv = (const char **)argv;
+
+ // COMMANDLINEOPTION: -noterminal disables console output on stdout
+ if(Sys_CheckParm("-noterminal"))
+ sys.outfd = -1;
+ // COMMANDLINEOPTION: -stderr moves console output to stderr
+ else if(Sys_CheckParm("-stderr"))
+ sys.outfd = 2;
+ else
+ sys.outfd = 1;
+
+ sys.selffd = -1;
+ Sys_ProvideSelfFD(); // may call Con_Printf() so must be after sys.outfd is set
+
+#ifndef WIN32
+ fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
+#endif
+
+#ifdef __ANDROID__
+ Sys_AllowProfiling(true);
+#endif
+
+ Host_Main();
+
+ Sys_Quit(0);
+
+ return 0;
+}
#include <fcntl.h>
#endif
-#include <signal.h>
-
#include "darkplaces.h"
sys_t sys;
return NULL;
}
-int main (int argc, char **argv)
+void Sys_SDL_Init(void)
{
- signal(SIGFPE, SIG_IGN);
- sys.selffd = -1;
- sys.argc = argc;
- sys.argv = (const char **)argv;
- Sys_ProvideSelfFD();
-
- // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
- if(Sys_CheckParm("-noterminal"))
- sys.outfd = -1;
- // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
- else if(Sys_CheckParm("-stderr"))
- sys.outfd = 2;
- else
- sys.outfd = 1;
-#ifndef WIN32
- fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
-#endif
-
- // used by everything
- Memory_Init();
-
- Host_Main();
-
- Sys_Quit(0);
-
- return 0;
}
qbool sys_supportsdlgetticks = false;