After all the other refactors finally we can clean this up.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
===============
Host_Shutdown
-FIXME: this is a callback from Sys_Quit(). It would be better
-to run quit through here before the final handoff to the sys code.
+Cleanly shuts down after the main loop exits.
===============
*/
-void Host_Shutdown(void)
+static void Host_Shutdown(void)
{
- static qbool isdown = false;
-
- if (isdown)
- {
- Con_Print(CON_WARN "recursive shutdown\n");
- return;
- }
- if (setjmp(host.abortframe))
- {
- Con_Print(CON_WARN "aborted the quitting frame?!?\n");
- return;
- }
- isdown = true;
+ if (Sys_CheckParm("-profilegameonly"))
+ Sys_AllowProfiling(false);
if(cls.state != ca_dedicated)
CL_Shutdown();
host.sleeptime = Sys_Sleep(sleeptime);
}
- return;
+ Host_Shutdown();
}
extern host_static_t host;
void Host_Main(void);
-void Host_Shutdown(void);
void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
void Host_LockSession(void);
void Host_UnlockSession(void);
/// INFO: This is only called by Host_Shutdown so we dont need testing for recursion
void Sys_SDL_Shutdown(void);
-void Sys_Quit (int returnvalue);
/*! on some build/platform combinations (such as Linux gcc with the -pg
* profiling option) this can turn on/off profiling, used primarily to limit
}
-void Sys_Quit (int returnvalue)
-{
- // Unlock mutexes because the quit command may jump directly here, causing a deadlock
- if ((cmd_local)->cbuf->lock)
- Cbuf_Unlock((cmd_local)->cbuf);
- SV_UnlockThreadMutex();
- TaskQueue_Frame(true);
-
- if (Sys_CheckParm("-profilegameonly"))
- Sys_AllowProfiling(false);
- host.state = host_shutdown;
- Host_Shutdown();
-
-#ifdef __ANDROID__
- Sys_AllowProfiling(false);
-#endif
-
-#ifndef WIN32
- fcntl(fileno(stdout), F_SETFL, fcntl(fileno(stdout), F_GETFL, 0) & ~O_NONBLOCK);
- fcntl(fileno(stderr), F_SETFL, fcntl(fileno(stderr), F_GETFL, 0) & ~O_NONBLOCK);
-#endif
- fflush(stdout);
- fflush(stderr);
-
- exit(returnvalue);
-}
-
#ifdef __cplusplus
extern "C"
#endif
Host_Main();
- Sys_Quit(0);
+#ifdef __ANDROID__
+ Sys_AllowProfiling(false);
+#endif
+
+#ifndef WIN32
+ fcntl(fileno(stdout), F_SETFL, fcntl(fileno(stdout), F_GETFL, 0) & ~O_NONBLOCK);
+ fcntl(fileno(stderr), F_SETFL, fcntl(fileno(stderr), F_GETFL, 0) & ~O_NONBLOCK);
+#endif
+ fflush(stdout);
+ fflush(stderr);
return 0;
}