| 109 | extern FILE *Logfile; |
| 110 | |
| 111 | [[noreturn]] void I_FatalError(const char *error, ...) |
| 112 | { |
| 113 | static bool alreadyThrown = false; |
| 114 | gameisdead = true; |
| 115 | |
| 116 | if (!alreadyThrown) // ignore all but the first message -- killough |
| 117 | { |
| 118 | alreadyThrown = true; |
| 119 | char errortext[MAX_ERRORTEXT]; |
| 120 | va_list argptr; |
| 121 | va_start(argptr, error); |
| 122 | vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); |
| 123 | va_end(argptr); |
| 124 | I_DebugPrint(errortext); |
| 125 | |
| 126 | // Record error to log (if logging) |
| 127 | if (Logfile) |
| 128 | { |
| 129 | fprintf(Logfile, "\n**** DIED WITH FATAL ERROR:\n%s\n", errortext); |
| 130 | fflush(Logfile); |
| 131 | } |
| 132 | |
| 133 | throw CFatalError(errortext); |
| 134 | } |
| 135 | std::terminate(); // recursive I_FatalErrors must immediately terminate. |
| 136 | } |
| 137 | |