Esempio n. 1
0
/**
 * @brief Errors out of the game.
 * @note The error message should not have a newline - it's added inside of this function
 * @note This function does never return
 */
void Sys_Error (const char *error, ...)
{
	va_list argptr;
	char string[1024];

	Sys_Backtrace();

#ifdef COMPILE_UFO
	Sys_ConsoleShutdown();
#endif

	/* change stdin to non blocking */
	fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);

#ifdef COMPILE_MAP
	Mem_Shutdown();
#endif

	va_start(argptr,error);
	Q_vsnprintf(string, sizeof(string), error, argptr);
	va_end(argptr);

	fprintf(stderr, "Error: %s\n", string);

	exit(1);
}
Esempio n. 2
0
/**
 * @brief Callback for subsystem failures. Depending on the severity, we may try to
 * recover, or we may shut the entire engine down and exit.
 */
static void Error(err_t err, const char *msg) {

	if (quetoo.debug_mask & DEBUG_BREAKPOINT) {
		SDL_TriggerBreakpoint();
	}

	Print(va("^1%s\n", msg));

	if (err == ERROR_DROP && !jmp_set) {
		err = ERROR_FATAL;
	}

	switch (err) {
		case ERROR_DROP:
			Sv_ShutdownServer(msg);
			Cl_Disconnect();
			quetoo.recursive_error = false;
			longjmp(env, err);
			break;

		case ERROR_FATAL:
		default:
			Sys_Backtrace();
			Shutdown(msg);
			exit(err);
			break;
	}
}
Esempio n. 3
0
/*
 * The final exit point of the program under abnormal exit conditions.
 */
void Sys_Error(const char *error, ...) {
	va_list args;
	char string[MAX_STRING_CHARS];

	Sys_Backtrace();

	va_start(args, error);
	vsnprintf(string, sizeof(string), error, args);
	va_end(args);

	fprintf(stderr, "ERROR: %s\n", string);

	exit(1);
}
Esempio n. 4
0
/*
 * Sys_Signal
 *
 * Catch kernel interrupts and dispatch the appropriate exit routine.
 */
void Sys_Signal(int s) {

	switch (s) {
	case SIGHUP:
	case SIGINT:
	case SIGQUIT:
	case SIGTERM:
		Com_Print("Received signal %d, quitting...\n", s);
		Sys_Quit();
		break;
	default:
		Sys_Backtrace();
		Sys_Error("Received signal %d.\n", s);
		break;
	}
}
Esempio n. 5
0
/**
 * @note Both client and server can use this, and it will
 * do the appropriate things.
 */
void Com_Error (int code, const char* fmt, ...)
{
	va_list argptr;
	static char msg[MAXPRINTMSG];
	static bool recursive = false;

	if (recursive)
		Sys_Error("recursive error after: %s", msg);
	recursive = true;

	va_start(argptr, fmt);
	Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
	va_end(argptr);

	switch (code) {
	case ERR_DISCONNECT:
		Com_Printf("%s\n", msg);
		CL_Drop();
		recursive = false;
		Com_Drop();
	case ERR_DROP:
		Com_Printf("********************\n");
		Com_Printf("ERROR: %s\n", msg);
		Com_Printf("********************\n");
		Sys_Backtrace();
		SV_Shutdown("Server crashed.", false);
		CL_Drop();
		recursive = false;
		Com_Drop();
	default:
		Com_Printf("%s\n", msg);
		SV_Shutdown("Server fatal crashed", false);

		/* send an receive net messages a last time */
		NET_Wait(0);

		FS_CloseFile(&logfile);
		if (pipefile.f != nullptr) {
			FS_CloseFile(&pipefile);
			FS_RemoveFile(va("%s/%s", FS_Gamedir(), pipefile.name));
		}

		CL_Shutdown();
		Qcommon_Shutdown();
		Sys_Error("Shutdown");
	}
}
Esempio n. 6
0
void Sys_Error (const char *error, ...)
{
	va_list argptr;
	char text[1024];

	Sys_Backtrace();

#ifdef COMPILE_MAP
	Mem_Shutdown();
#endif

	va_start(argptr, error);
	Q_vsnprintf(text, sizeof(text), error, argptr);
	va_end(argptr);

	/* Echo to console */
	Sys_ConsoleOutput("\n");
	Sys_ConsoleOutput(text);
	Sys_ConsoleOutput("\n");

	/* Display the message and set a timer so we can flash the text */
	SetWindowText(sys_console.hWndMsg, text);
	SetTimer(sys_console.hWnd, 1, 1000, NULL);

	sys_console.timerActive = true;

	/* Show/hide everything we need */
	ShowWindow(sys_console.hWndMsg, SW_SHOW);
	ShowWindow(sys_console.hWndInput, SW_HIDE);

	Sys_ShowConsole(true);

	/* Wait for the user to quit */
	while (1) {
		Sys_ConsoleLoop(true);
		/* Don't hog the CPU */
		Sys_Sleep(25);
	}
}