void ErrorMessageBox (const char *msg, const char *caption, unsigned int flags) { // Platform independent cleanup. SDL_Quit(); // not exiting threads causes another exception delete gameServer; gameServer = NULL; delete sound; sound = NULL; #ifdef _WIN32 // Windows implementation, using MessageBox. // Translate spring flags to corresponding win32 dialog flags unsigned int winFlags = 0; // MB_OK is default (0) if (flags & MBF_EXCL) winFlags |= MB_ICONEXCLAMATION; if (flags & MBF_INFO) winFlags |= MB_ICONINFORMATION; MessageBox (GetActiveWindow(), msg, caption, winFlags); // TODO: write Mac OS X specific message box #elif defined(__APPLE__) MacMessageBox(msg, caption, flags); #else // X implementation X_MessageBox(msg, caption, flags); #endif exit(-1); // continuing execution when SDL_Quit has already been run will result in a crash }
static void ExitMessage(const std::string& msg, const std::string& caption, unsigned int flags, bool forced) { logOutput.SetSubscribersEnabled(false); if (forced) LOG_L(L_ERROR, "failed to shutdown normally, exit forced"); LOG_L(L_ERROR, "%s %s", caption.c_str(), msg.c_str()); #if !defined(DEDICATED) && !defined(HEADLESS) #ifdef WIN32 //! Windows implementation, using MessageBox. // Translate spring flags to corresponding win32 dialog flags unsigned int winFlags = MB_TOPMOST; // MB_OK is default (0) if (flags & MBF_EXCL) winFlags |= MB_ICONEXCLAMATION; if (flags & MBF_INFO) winFlags |= MB_ICONINFORMATION; if (flags & MBF_CRASH) winFlags |= MB_ICONERROR; MessageBox(GetActiveWindow(), msg.c_str(), caption.c_str(), winFlags); #else // ifdef WIN32 //! X implementation // TODO: write Mac OS X specific message box X_MessageBox(msg.c_str(), caption.c_str(), flags); #endif // ifdef WIN32 #endif // if !defined(DEDICATED) && !defined(HEADLESS) #ifdef _MSC_VER TerminateProcess(GetCurrentProcess(), -1); #else exit(-1); // continuing execution when SDL_Quit has already been run will result in a crash #endif }