From 52382657023f6376e1f4bc17101c85999f790864 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Fri, 29 Mar 2019 21:26:37 -0500 Subject: [PATCH] Implement assert support (#791) --- Source/appfat.cpp | 35 ++++---- Source/appfat.h | 7 +- Source/codec.cpp | 2 +- Source/debug.cpp | 4 +- Source/diablo.cpp | 6 +- Source/dthread.cpp | 8 +- Source/dx.cpp | 8 +- Source/effects.cpp | 2 +- Source/engine.cpp | 6 +- Source/gendung.cpp | 2 +- Source/init.cpp | 10 +-- Source/interfac.cpp | 2 +- Source/loadsave.cpp | 2 +- Source/mainmenu.cpp | 6 +- Source/monster.cpp | 194 ++++++++++++++++++++++---------------------- Source/mpqapi.cpp | 8 +- Source/msg.cpp | 6 +- Source/multi.cpp | 4 +- Source/nthread.cpp | 8 +- Source/pfile.cpp | 32 ++++---- Source/player.cpp | 148 ++++++++++++++++----------------- Source/scrollrt.cpp | 48 +++++------ Source/setmaps.cpp | 2 +- Source/sound.cpp | 2 +- Source/sync.cpp | 2 +- Source/trigs.cpp | 2 +- defs.h | 8 ++ 27 files changed, 291 insertions(+), 273 deletions(-) diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 461208819..eeac26af0 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -195,7 +195,7 @@ char *__cdecl TraceLastError() return GetErrorStr(GetLastError()); } -void TermMsg(char *pszFmt, ...) +void app_fatal(const char *pszFmt, ...) { va_list va; @@ -211,7 +211,7 @@ void TermMsg(char *pszFmt, ...) exit(1); } -void __fastcall MsgBox(char *pszFmt, va_list va) +void __fastcall MsgBox(const char *pszFmt, va_list va) { char Text[256]; // [esp+0h] [ebp-100h] @@ -251,13 +251,20 @@ void DrawDlg(char *pszFmt, ...) SDrawMessageBox(text, "Diablo", MB_TASKMODAL | MB_ICONEXCLAMATION); } +#ifdef _DEBUG +void __fastcall assert_fail(int nLineNo, const char *pszFile, const char *pszFail) +{ + app_fatal("assertion failed (%d:%s)\n%s", nLineNo, pszFile, pszFail); +} +#endif + void __fastcall DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path) { char *msg; if (error_code) { msg = GetErrorStr(error_code); - TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, log_line_nr, msg); + app_fatal("Direct draw error (%s:%d)\n%s", log_file_path, log_line_nr, msg); } } @@ -267,7 +274,7 @@ void __fastcall DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path) if (error_code) { msg = GetErrorStr(error_code); - TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, log_line_nr, msg); + app_fatal("Direct sound error (%s:%d)\n%s", log_file_path, log_line_nr, msg); } } @@ -287,7 +294,7 @@ void __fastcall center_window(HWND hDlg) ReleaseDC(hDlg, hdc); if (!SetWindowPos(hDlg, HWND_TOP, (screenW - w) / 2, (screenH - h) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) { - TermMsg("center_window: %s", TraceLastError()); + app_fatal("center_window: %s", TraceLastError()); } } @@ -304,9 +311,9 @@ void __fastcall ErrDlg(int template_id, DWORD error_code, char *log_file_path, i wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr); if (DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1) - TermMsg("ErrDlg: %d", template_id); + app_fatal("ErrDlg: %d", template_id); - TermMsg(NULL); + app_fatal(NULL); } BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text) @@ -358,9 +365,9 @@ void __fastcall FileErrDlg(const char *error) error = ""; if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1) - TermMsg("FileErrDlg"); + app_fatal("FileErrDlg"); - TermMsg(NULL); + app_fatal(NULL); } void __fastcall DiskFreeDlg(char *error) @@ -368,9 +375,9 @@ void __fastcall DiskFreeDlg(char *error) FreeDlg(); if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1) - TermMsg("DiskFreeDlg"); + app_fatal("DiskFreeDlg"); - TermMsg(NULL); + app_fatal(NULL); } BOOL __cdecl InsertCDDlg() @@ -381,7 +388,7 @@ BOOL __cdecl InsertCDDlg() nResult = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) ""); if (nResult == -1) - TermMsg("InsertCDDlg"); + app_fatal("InsertCDDlg"); ShowCursor(FALSE); @@ -393,7 +400,7 @@ void __fastcall DirErrorDlg(char *error) FreeDlg(); if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1) - TermMsg("DirErrorDlg"); + app_fatal("DirErrorDlg"); - TermMsg(NULL); + app_fatal(NULL); } diff --git a/Source/appfat.h b/Source/appfat.h index 536d97262..4c1e56d4e 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -10,10 +10,13 @@ char *__fastcall GetErrorStr(DWORD error_code); void __fastcall TraceErrorDD(DWORD error_code, char *error_buf, int error_buf_len); void __fastcall TraceErrorDS(DWORD error_code, char *error_buf, int error_buf_len); char *__cdecl TraceLastError(); -void TermMsg(char *pszFmt, ...); -void __fastcall MsgBox(char *pszFmt, va_list va); +void app_fatal(const char *pszFmt, ...); +void __fastcall MsgBox(const char *pszFmt, va_list va); void __cdecl FreeDlg(); void DrawDlg(char *pszFmt, ...); +#ifdef _DEBUG +void __fastcall assert_fail(int nLineNo, const char *pszFile, const char *pszFail); +#endif void __fastcall DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path); void __fastcall DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path); void __fastcall center_window(HWND hDlg); diff --git a/Source/codec.cpp b/Source/codec.cpp index 49912ad6a..4af11d514 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -117,7 +117,7 @@ void __fastcall codec_encode(void *pbSrcDst, int size, int size_64, char *pszPas v4 = (char *)pbSrcDst; v12 = size; if (size_64 != codec_get_encoded_len(size)) - TermMsg("Invalid encode parameters"); + app_fatal("Invalid encode parameters"); codec_init_key(1, pszPassword); v5 = 0; if (v12) { diff --git a/Source/debug.cpp b/Source/debug.cpp index 152f21240..f9a591757 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -28,9 +28,9 @@ void __cdecl CheckDungeonClear() for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dMonster[i][j]) - TermMsg("Monsters not cleared"); + app_fatal("Monsters not cleared"); if (dPlayer[i][j]) - TermMsg("Players not cleared"); + app_fatal("Players not cleared"); dMonsDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_VISIBLE; dFlagDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_POPULATED; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 7c2f6a7bb..b0e82e14f 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1013,7 +1013,7 @@ void __fastcall diablo_hotkey_msg(int dwMsg) v1 = dwMsg; if (gbMaxPlayers != 1) { if (!GetModuleFileName(ghInst, Filename, 0x104u)) - TermMsg("Can't get program name"); + app_fatal("Can't get program name"); v2 = strrchr(Filename, '\\'); if (v2) *v2 = 0; @@ -1596,7 +1596,7 @@ void __cdecl LoadLvlGFX() level_special_cel = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); break; default: - TermMsg("LoadLvlGFX"); + app_fatal("LoadLvlGFX"); return; } } @@ -1647,7 +1647,7 @@ void __fastcall CreateLevel(int lvldir) hnd = 4; break; default: - TermMsg("CreateLevel"); + app_fatal("CreateLevel"); return; } diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 7643c21f6..60092b2dd 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -88,7 +88,7 @@ void __cdecl dthread_start() sghWorkToDoEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!sghWorkToDoEvent) { error_buf = TraceLastError(); - TermMsg("dthread:1\n%s", error_buf); + app_fatal("dthread:1\n%s", error_buf); } dthread_running = TRUE; @@ -96,7 +96,7 @@ void __cdecl dthread_start() sghThread = (HANDLE)_beginthreadex(NULL, 0, dthread_handler, NULL, 0, &glpDThreadId); if (sghThread == INVALID_HANDLE_VALUE) { error_buf = TraceLastError(); - TermMsg("dthread2:\n%s", error_buf); + app_fatal("dthread2:\n%s", error_buf); } } @@ -109,7 +109,7 @@ unsigned int __stdcall dthread_handler(void *unused) while (dthread_running) { if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1) { error_buf = TraceLastError(); - TermMsg("dthread4:\n%s", error_buf); + app_fatal("dthread4:\n%s", error_buf); } EnterCriticalSection(&sgMemCrit); @@ -153,7 +153,7 @@ void __cdecl dthread_cleanup() if (sghThread != INVALID_HANDLE_VALUE && glpDThreadId != GetCurrentThreadId()) { if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { error_buf = TraceLastError(); - TermMsg("dthread3:\n(%s)", error_buf); + app_fatal("dthread3:\n(%s)", error_buf); } CloseHandle(sghThread); sghThread = INVALID_HANDLE_VALUE; diff --git a/Source/dx.cpp b/Source/dx.cpp index 76163720b..50264611b 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -219,7 +219,7 @@ void __cdecl lock_buf_priv() if (lpDDSBackBuf == NULL) { Sleep(20000); - TermMsg("lock_buf_priv"); + app_fatal("lock_buf_priv"); sgdwLockCount++; return; } @@ -246,7 +246,7 @@ void __fastcall j_unlock_buf_priv(BYTE idx) { #ifdef _DEBUG if (!locktbl[idx]) - TermMsg("Draw lock underflow: 0x%x", idx); + app_fatal("Draw lock underflow: 0x%x", idx); --locktbl[idx]; #endif unlock_buf_priv(); @@ -257,9 +257,9 @@ void __cdecl unlock_buf_priv() HRESULT error_code; if (sgdwLockCount == 0) - TermMsg("draw main unlock error"); + app_fatal("draw main unlock error"); if (!gpBuffer) - TermMsg("draw consistency error"); + app_fatal("draw consistency error"); sgdwLockCount--; if (sgdwLockCount == 0) { diff --git a/Source/effects.cpp b/Source/effects.cpp index bae460f44..bc10fbe4e 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1185,7 +1185,7 @@ void __cdecl stream_update() } else if (plr[myplr]._pClass == PC_SORCERER) { mask = SFX_SORCEROR; } else { - TermMsg("effects:1"); + app_fatal("effects:1"); } priv_sound_init(mask); diff --git a/Source/engine.cpp b/Source/engine.cpp index 6643d7e3a..58b3aa24c 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -2401,7 +2401,7 @@ BYTE *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen) *pdwFileLen = fileLen; if (!fileLen) - TermMsg("Zero length SFILE:\n%s", pszName); + app_fatal("Zero length SFILE:\n%s", pszName); buf = (BYTE *)DiabloAllocPtr(fileLen); @@ -2421,11 +2421,11 @@ void __fastcall LoadFileWithMem(char *pszName, void *buf) v2 = (char *)buf; v3 = pszName; if (!buf) - TermMsg("LoadFileWithMem(NULL):\n%s", pszName); + app_fatal("LoadFileWithMem(NULL):\n%s", pszName); WOpenFile(v3, &a1, 0); v4 = WGetFileSize(a1, 0); if (!v4) - TermMsg("Zero length SFILE:\n%s", v3); + app_fatal("Zero length SFILE:\n%s", v3); WReadFile(a1, v2, v4); WCloseFile(a1); } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 6188d0237..3f6ce7fad 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -99,7 +99,7 @@ void __cdecl FillSolidBlockTbls() pSBFile = LoadFileInMem("Levels\\L4Data\\L4.SOL", (int *)&dwTiles); break; default: - TermMsg("FillSolidBlockTbls"); + app_fatal("FillSolidBlockTbls"); } pTmp = pSBFile; diff --git a/Source/init.cpp b/Source/init.cpp index f85f3e8a0..095f72967 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -163,7 +163,7 @@ void __fastcall init_create_window(int nCmdShow) wcex.lpszClassName = "DIABLO"; wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); if (!RegisterClassEx(&wcex)) - TermMsg("Unable to register window class"); + app_fatal("Unable to register window class"); if (GetSystemMetrics(SM_CXSCREEN) >= 640) nWidth = GetSystemMetrics(SM_CXSCREEN); else @@ -174,7 +174,7 @@ void __fastcall init_create_window(int nCmdShow) nHeight = 480; hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL); if (!hWnd) - TermMsg("Unable to create main window"); + app_fatal("Unable to create main window"); ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow) UpdateWindow(hWnd); init_await_mom_parent_exit(); @@ -270,12 +270,12 @@ HANDLE __fastcall init_test_access(char *mpq_path, char *mpq_name, char *reg_loc mpq_namea = mpq_name; v5 = mpq_path; if (!GetCurrentDirectory(0x104u, Buffer)) - TermMsg("Can't get program path"); + app_fatal("Can't get program path"); init_strip_trailing_slash(Buffer); if (!SFileSetBasePath(Buffer)) - TermMsg("SFileSetBasePath"); + app_fatal("SFileSetBasePath"); if (!GetModuleFileName(ghInst, Filename, 0x104u)) - TermMsg("Can't get program name"); + app_fatal("Can't get program name"); v7 = strrchr(Filename, '\\'); if (v7) *v7 = 0; diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 443ec9cec..f799d3657 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -374,7 +374,7 @@ void __fastcall InitCutscene(unsigned int uMsg) v6 = "Gendata\\Cutstart.pal"; goto LABEL_30; default: - TermMsg("Unknown progress mode"); + app_fatal("Unknown progress mode"); goto LABEL_33; } } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 841e24834..02fc49462 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -19,7 +19,7 @@ void __fastcall LoadGame(BOOL firstflag) tbuff = LoadBuff; if (ILoad() != 'RETL') - TermMsg("Invalid save file"); + app_fatal("Invalid save file"); setlevel = OLoad(); setlvlnum = WLoad(); diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index eecde605e..56f738faa 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -45,7 +45,7 @@ int __stdcall mainmenu_select_hero_dialog( &dlgresult, gszHero, &gnDifficulty)) - TermMsg("Unable to display SelHeroSing"); + app_fatal("Unable to display SelHeroSing"); if (dlgresult == 2) gbLoadGame = TRUE; @@ -60,7 +60,7 @@ int __stdcall mainmenu_select_hero_dialog( &dlgresult, &hero_is_created, gszHero)) { - TermMsg("Can't load multiplayer dialog"); + app_fatal("Can't load multiplayer dialog"); } if (dlgresult == 4) { SErrSetLastError(1223); @@ -91,7 +91,7 @@ void __cdecl mainmenu_loop() do { menu = 0; if (!UiMainMenuDialog("Diablo v1.09", &menu, effects_play_sound, 30)) - TermMsg("Unable to display mainmenu"); + app_fatal("Unable to display mainmenu"); switch (menu) { case MAINMENU_SINGLE_PLAYER: diff --git a/Source/monster.cpp b/Source/monster.cpp index bbbe1dc5f..6e3da422b 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -2024,11 +2024,11 @@ void __fastcall M_DiabloDeath(int i, BOOL sendmsg) void __fastcall M2MStartHit(int mid, int i, int dam) { if ((DWORD)mid >= MAXMONSTERS) { - TermMsg("Invalid monster %d getting hit by monster", mid); + app_fatal("Invalid monster %d getting hit by monster", mid); } if (monster[mid].MType == NULL) { - TermMsg("Monster %d \"%s\" getting hit by monster: MType NULL", mid, monster[mid].mName); + app_fatal("Monster %d \"%s\" getting hit by monster: MType NULL", mid, monster[mid].mName); } if (i >= 0) @@ -2072,10 +2072,10 @@ void __fastcall MonstStartKill(int i, int pnum, BOOL sendmsg) int md; if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MonstStartKill: Invalid monster %d", i); + app_fatal("MonstStartKill: Invalid monster %d", i); } if (!monster[i].MType) { - TermMsg("MonstStartKill: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("MonstStartKill: Monster %d \"%s\" MType NULL", i, monster[i].mName); } if (pnum >= 0) @@ -2123,11 +2123,11 @@ void __fastcall M2MStartKill(int i, int mid) int md; if ((DWORD)i >= MAXMONSTERS) { - TermMsg("M2MStartKill: Invalid monster (attacker) %d", i); - TermMsg("M2MStartKill: Invalid monster (killed) %d", mid); + app_fatal("M2MStartKill: Invalid monster (attacker) %d", i); + app_fatal("M2MStartKill: Invalid monster (killed) %d", mid); } if (!monster[i].MType) - TermMsg("M2MStartKill: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); + app_fatal("M2MStartKill: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); delta_kill_monster(mid, monster[mid]._mx, monster[mid]._my, currlevel); NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[mid]._mx, monster[mid]._my, mid); @@ -2175,7 +2175,7 @@ void __fastcall M2MStartKill(int i, int mid) void __fastcall M_StartKill(int i, int pnum) { if ((DWORD)i >= MAXMONSTERS) { - TermMsg("M_StartKill: Invalid monster %d", i); + app_fatal("M_StartKill: Invalid monster %d", i); } if (myplr == pnum) { @@ -2193,7 +2193,7 @@ void __fastcall M_StartKill(int i, int pnum) void __fastcall M_SyncStartKill(int i, int x, int y, int pnum) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_SyncStartKill: Invalid monster %d", i); + app_fatal("M_SyncStartKill: Invalid monster %d", i); if (monster[i]._mhitpoints == 0 || monster[i]._mmode == MM_DEATH) { return; @@ -2218,9 +2218,9 @@ void __fastcall M_SyncStartKill(int i, int x, int y, int pnum) void __fastcall M_StartFadein(int i, int md, BOOL backwards) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_StartFadein: Invalid monster %d", i); + app_fatal("M_StartFadein: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_StartFadein: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_StartFadein: Monster %d \"%s\" MType NULL", i, monster[i].mName); NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); monster[i]._mmode = MM_FADEIN; @@ -2242,9 +2242,9 @@ void __fastcall M_StartFadein(int i, int md, BOOL backwards) void __fastcall M_StartFadeout(int i, int md, BOOL backwards) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_StartFadeout: Invalid monster %d", i); + app_fatal("M_StartFadeout: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_StartFadeout: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_StartFadeout: Monster %d \"%s\" MType NULL", i, monster[i].mName); NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); monster[i]._mmode = MM_FADEOUT; @@ -2267,9 +2267,9 @@ void __fastcall M_StartHeal(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_StartHeal: Invalid monster %d", i); + app_fatal("M_StartHeal: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_StartHeal: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_StartHeal: Monster %d \"%s\" MType NULL", i, monster[i].mName); Monst = &monster[i]; Monst->_mAnimData = Monst->MType->Anims[MA_SPECIAL].Data[Monst->_mdir]; @@ -2284,7 +2284,7 @@ void __fastcall M_ChangeLightOffset(int monst) int lx, ly, _mxoff, _myoff, sign; if ((DWORD)monst >= MAXMONSTERS) - TermMsg("M_ChangeLightOffset: Invalid monster %d", monst); + app_fatal("M_ChangeLightOffset: Invalid monster %d", monst); lx = monster[monst]._mxoff + 2 * monster[monst]._myoff; ly = 2 * monster[monst]._myoff - monster[monst]._mxoff; @@ -2312,9 +2312,9 @@ int __fastcall M_DoStand(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoStand: Invalid monster %d", i); + app_fatal("M_DoStand: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoStand: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoStand: Monster %d \"%s\" MType NULL", i, monster[i].mName); Monst = &monster[i]; if (Monst->MType->mtype == MT_GOLEM) @@ -2335,9 +2335,9 @@ BOOL __fastcall M_DoWalk(int i) BOOL rv; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoWalk: Invalid monster %d", i); + app_fatal("M_DoWalk: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoWalk: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoWalk: Monster %d \"%s\" MType NULL", i, monster[i].mName); rv = FALSE; if (monster[i]._mVar8 == monster[i].MType->Anims[MA_WALK].Frames) { @@ -2368,9 +2368,9 @@ BOOL __fastcall M_DoWalk2(int i) BOOL rv; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoWalk2: Invalid monster %d", i); + app_fatal("M_DoWalk2: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoWalk2: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoWalk2: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i]._mVar8 == monster[i].MType->Anims[MA_WALK].Frames) { dMonster[monster[i]._mVar1][monster[i]._mVar2] = 0; @@ -2399,9 +2399,9 @@ BOOL __fastcall M_DoWalk3(int i) BOOL rv; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoWalk3: Invalid monster %d", i); + app_fatal("M_DoWalk3: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoWalk3: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoWalk3: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i]._mVar8 == monster[i].MType->Anims[MA_WALK].Frames) { dMonster[monster[i]._mx][monster[i]._my] = 0; @@ -2434,10 +2434,10 @@ void __fastcall M_TryM2MHit(int i, int mid, int hper, int mind, int maxd) BOOL ret; if ((DWORD)mid >= MAXMONSTERS) { - TermMsg("M_TryM2MHit: Invalid monster %d", mid); + app_fatal("M_TryM2MHit: Invalid monster %d", mid); } if (monster[mid].MType == NULL) - TermMsg("M_TryM2MHit: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); + app_fatal("M_TryM2MHit: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); if (monster[mid]._mhitpoints >> 6 > 0 && (monster[mid].MType->mtype != MT_ILLWEAV || monster[mid]._mgoal != MGOAL_RETREAT)) { int hit = random(4, 100); if (monster[mid]._mmode == MM_STONE) @@ -2504,10 +2504,10 @@ void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) plr_num = pnum; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_TryH2HHit: Invalid monster %d", i); + app_fatal("M_TryH2HHit: Invalid monster %d", i); v6 = v5; if (monster[v5].MType == NULL) - TermMsg("M_TryH2HHit: Monster %d \"%s\" MType NULL", v5, monster[v6].mName); + app_fatal("M_TryH2HHit: Monster %d \"%s\" MType NULL", v5, monster[v6].mName); if (monster[v6]._mFlags & MFLAG_TARGETS_MONSTER) { M_TryM2MHit(v5, plr_num, Hit, MinDam, MaxDam); return; @@ -2663,13 +2663,13 @@ BOOL __fastcall M_DoAttack(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoAttack: Invalid monster %d", i); + app_fatal("M_DoAttack: Invalid monster %d", i); Monst = &monster[i]; if (Monst->MType == NULL) - TermMsg("M_DoAttack: Monster %d \"%s\" MType NULL", i, Monst->mName); + app_fatal("M_DoAttack: Monster %d \"%s\" MType NULL", i, Monst->mName); if (Monst->MType == NULL) // BUGFIX: should check MData - TermMsg("M_DoAttack: Monster %d \"%s\" MData NULL", i, Monst->mName); + app_fatal("M_DoAttack: Monster %d \"%s\" MData NULL", i, Monst->mName); if (monster[i]._mAnimFrame == monster[i].MData->mAFNum) { M_TryH2HHit(i, monster[i]._menemy, monster[i].mHit, monster[i].mMinDamage, monster[i].mMaxDamage); @@ -2699,11 +2699,11 @@ BOOL __fastcall M_DoRAttack(int i) int multimissiles, mi; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoRAttack: Invalid monster %d", i); + app_fatal("M_DoRAttack: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoRAttack: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoRAttack: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i].MType == NULL) // BUGFIX: should check MData - TermMsg("M_DoRAttack: Monster %d \"%s\" MData NULL", i, monster[i].mName); + app_fatal("M_DoRAttack: Monster %d \"%s\" MData NULL", i, monster[i].mName); if (monster[i]._mAnimFrame == monster[i].MData->mAFNum) { if (monster[i]._mVar1 != -1) { @@ -2739,11 +2739,11 @@ BOOL __fastcall M_DoRAttack(int i) int __fastcall M_DoRSpAttack(int i) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoRSpAttack: Invalid monster %d", i); + app_fatal("M_DoRSpAttack: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoRSpAttack: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoRSpAttack: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i].MType == NULL) // BUGFIX: should check MData - TermMsg("M_DoRSpAttack: Monster %d \"%s\" MData NULL", i, monster[i].mName); + app_fatal("M_DoRSpAttack: Monster %d \"%s\" MData NULL", i, monster[i].mName); if (monster[i]._mAnimFrame == monster[i].MData->mAFNum2 && !monster[i]._mAnimCnt) { AddMissile( @@ -2781,11 +2781,11 @@ int __fastcall M_DoRSpAttack(int i) BOOL __fastcall M_DoSAttack(int i) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoSAttack: Invalid monster %d", i); + app_fatal("M_DoSAttack: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoSAttack: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoSAttack: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i].MType == NULL) // BUGFIX: should check MData - TermMsg("M_DoSAttack: Monster %d \"%s\" MData NULL", i, monster[i].mName); + app_fatal("M_DoSAttack: Monster %d \"%s\" MData NULL", i, monster[i].mName); if (monster[i]._mAnimFrame == monster[i].MData->mAFNum2) M_TryH2HHit(i, monster[i]._menemy, monster[i].mHit2, monster[i].mMinDamage2, monster[i].mMaxDamage2); @@ -2801,7 +2801,7 @@ BOOL __fastcall M_DoSAttack(int i) BOOL __fastcall M_DoFadein(int i) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoFadein: Invalid monster %d", i); + app_fatal("M_DoFadein: Invalid monster %d", i); if ((!(monster[i]._mFlags & MFLAG_LOCK_ANIMATION) || monster[i]._mAnimFrame != 1) && (monster[i]._mFlags & MFLAG_LOCK_ANIMATION || monster[i]._mAnimFrame != monster[i]._mAnimLen)) { @@ -2819,7 +2819,7 @@ BOOL __fastcall M_DoFadeout(int i) int mt; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoFadeout: Invalid monster %d", i); + app_fatal("M_DoFadeout: Invalid monster %d", i); if ((!(monster[i]._mFlags & MFLAG_LOCK_ANIMATION) || monster[i]._mAnimFrame != 1) && (monster[i]._mFlags & MFLAG_LOCK_ANIMATION || monster[i]._mAnimFrame != monster[i]._mAnimLen)) { @@ -2852,7 +2852,7 @@ int __fastcall M_DoHeal(int i) v1 = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoHeal: Invalid monster %d", i); + app_fatal("M_DoHeal: Invalid monster %d", i); v2 = v1; if (monster[v1]._mFlags & MFLAG_NOHEAL) { monster[v2]._mFlags &= ~MFLAG_ALLOW_SPECIAL; @@ -2890,7 +2890,7 @@ int __fastcall M_DoTalk(int i) v1 = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoTalk: Invalid monster %d", i); + app_fatal("M_DoTalk: Invalid monster %d", i); v2 = v1; M_StartStand(v1, monster[v1]._mdir); _LOBYTE(monster[v1]._mgoal) = MGOAL_TALKING; @@ -2931,7 +2931,7 @@ int __fastcall M_DoTalk(int i) } if (quests[QTYPE_BOL]._qvar1 < 2u) { sprintf(tempstr, "SS Talk = %i, Flags = %i", monster[v2].mtalkmsg, monster[v2]._mFlags); - TermMsg(tempstr); + app_fatal(tempstr); } } if (monster[v2].mName == UniqMonst[7].mName) { @@ -2970,7 +2970,7 @@ void __fastcall M_Teleport(int i) int k, j, x, y, _mx, _my, rx, ry; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_Teleport: Invalid monster %d", i); + app_fatal("M_Teleport: Invalid monster %d", i); tren = FALSE; @@ -3009,10 +3009,10 @@ void __fastcall M_Teleport(int i) BOOL __fastcall M_DoGotHit(int i) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoGotHit: Invalid monster %d", i); + app_fatal("M_DoGotHit: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoGotHit: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoGotHit: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i]._mAnimFrame == monster[i]._mAnimLen) { M_StartStand(i, monster[i]._mdir); @@ -3027,7 +3027,7 @@ void __fastcall M_UpdateLeader(int i) int ma, j; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_UpdateLeader: Invalid monster %d", i); + app_fatal("M_UpdateLeader: Invalid monster %d", i); for (j = 0; j < nummonsters; j++) { ma = monstactive[j]; @@ -3118,9 +3118,9 @@ BOOL __fastcall M_DoDeath(int i) int x, y; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoDeath: Invalid monster %d", i); + app_fatal("M_DoDeath: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoDeath: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoDeath: Monster %d \"%s\" MType NULL", i, monster[i].mName); monster[i]._mVar1++; var1 = monster[i]._mVar1; @@ -3159,9 +3159,9 @@ BOOL __fastcall M_DoDeath(int i) BOOL __fastcall M_DoSpStand(int i) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoSpStand: Invalid monster %d", i); + app_fatal("M_DoSpStand: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoSpStand: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoSpStand: Monster %d \"%s\" MType NULL", i, monster[i].mName); if (monster[i]._mAnimFrame == monster[i].MData->mAFNum2) PlayEffect(i, 3); @@ -3180,9 +3180,9 @@ BOOL __fastcall M_DoDelay(int i) int oFrame; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoDelay: Invalid monster %d", i); + app_fatal("M_DoDelay: Invalid monster %d", i); if (monster[i].MType == NULL) - TermMsg("M_DoDelay: Monster %d \"%s\" MType NULL", i, monster[i].mName); + app_fatal("M_DoDelay: Monster %d \"%s\" MType NULL", i, monster[i].mName); monster[i]._mAnimData = monster[i].MType->Anims[MA_STAND].Data[M_GetDir(i)]; if (monster[i]._mAi == AI_LAZURUS) { @@ -3206,7 +3206,7 @@ BOOL __fastcall M_DoDelay(int i) BOOL __fastcall M_DoStone(int i) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoStone: Invalid monster %d", i); + app_fatal("M_DoStone: Invalid monster %d", i); if (!monster[i]._mhitpoints) { dMonster[monster[i]._mx][monster[i]._my] = 0; @@ -3221,7 +3221,7 @@ void __fastcall M_WalkDir(int i, int md) int mwi; if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_WalkDir: Invalid monster %d", i); + app_fatal("M_WalkDir: Invalid monster %d", i); mwi = monster[i].MType->Anims[MA_WALK].Frames - 1; switch (md) { @@ -3267,7 +3267,7 @@ void __fastcall GroupUnity(int i) v1 = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("GroupUnity: Invalid monster %d", i); + app_fatal("GroupUnity: Invalid monster %d", i); v2 = v1; if (monster[v1].leaderflag) { v3 = (unsigned char)monster[v2].leader; @@ -3418,7 +3418,7 @@ BOOL __fastcall M_PathWalk(int i) (int, int, int); if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_PathWalk: Invalid monster %d", i); + app_fatal("M_PathWalk: Invalid monster %d", i); Check = PosOkMonst3; if (!(monster[i]._mFlags & MFLAG_CAN_OPEN_DOOR)) @@ -3523,7 +3523,7 @@ void __fastcall MAI_Zombie(int i) int md, v; if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MAI_Zombie: Invalid monster %d", i); + app_fatal("MAI_Zombie: Invalid monster %d", i); } Monst = &monster[i]; @@ -3567,7 +3567,7 @@ void __fastcall MAI_SkelSd(int i) int mx, my, x, y, md; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SkelSd: Invalid monster %d", i); + app_fatal("MAI_SkelSd: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mmode != MM_STAND || !Monst->_msquelch) { @@ -3604,7 +3604,7 @@ BOOL __fastcall MAI_Path(int i) BOOL clear; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Path: Invalid monster %d", i); + app_fatal("MAI_Path: Invalid monster %d", i); Monst = &monster[i]; if (Monst->MType->mtype != MT_GOLEM) { @@ -3685,7 +3685,7 @@ void __fastcall MAI_Snake(int i) esi1 = i; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Snake: Invalid monster %d", i); + app_fatal("MAI_Snake: Invalid monster %d", i); pattern[2] = 0; pattern[3] = -1; pattern[4] = -1; @@ -3819,7 +3819,7 @@ void __fastcall MAI_Bat(int i) int fx, fy, xd, yd; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Bat: Invalid monster %d", i); + app_fatal("MAI_Bat: Invalid monster %d", i); Monst = &monster[i]; pnum = Monst->_menemy; @@ -3884,7 +3884,7 @@ void __fastcall MAI_SkelBow(int i) walking = FALSE; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SkelBow: Invalid monster %d", i); + app_fatal("MAI_SkelBow: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mmode != MM_STAND || !Monst->_msquelch) { @@ -3926,7 +3926,7 @@ void __fastcall MAI_Fat(int i) int mx, my, md, v; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Fat: Invalid monster %d", i); + app_fatal("MAI_Fat: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mmode != MM_STAND || !Monst->_msquelch) { @@ -3978,7 +3978,7 @@ void __fastcall MAI_Sneak(int i) v1 = i; arglist = i; if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MAI_Sneak: Invalid monster %d", i); + app_fatal("MAI_Sneak: Invalid monster %d", i); } v2 = &monster[v1]; @@ -4052,7 +4052,7 @@ void __fastcall MAI_Fireman(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Fireman: Invalid monster %d", i); + app_fatal("MAI_Fireman: Invalid monster %d", i); Monst = &monster[i]; if (monster[i]._mmode != MM_STAND || !Monst->_msquelch) @@ -4112,7 +4112,7 @@ void __fastcall MAI_Fallen(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MAI_Fallen: Invalid monster %d", i); + app_fatal("MAI_Fallen: Invalid monster %d", i); } if (monster[i]._mgoal == MGOAL_SHOOT) { if (monster[i]._mgoalvar1) @@ -4183,7 +4183,7 @@ void __fastcall MAI_Cleaver(int i) int x, y, mx, my, md; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Cleaver: Invalid monster %d", i); + app_fatal("MAI_Cleaver: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mmode != MM_STAND || !Monst->_msquelch) { @@ -4241,7 +4241,7 @@ void __fastcall MAI_Round(int i, BOOL special) v27 = special; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Round: Invalid monster %d", i); + app_fatal("MAI_Round: Invalid monster %d", i); v3 = &monster[v2]; if (v3->_mmode == MM_STAND && v3->_msquelch) { v4 = v3->_my; @@ -4330,7 +4330,7 @@ void __fastcall MAI_Ranged(int i, int missile_type, BOOL special) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Ranged: Invalid monster %d", i); + app_fatal("MAI_Ranged: Invalid monster %d", i); Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { @@ -4409,7 +4409,7 @@ void __fastcall MAI_Scav(int i) v1 = i; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Scav: Invalid monster %d", i); + app_fatal("MAI_Scav: Invalid monster %d", i); v2 = v1; v20 = 0; if (monster[v1]._mmode == MM_STAND) { @@ -4525,7 +4525,7 @@ void __fastcall MAI_Garg(int i) int mx, my, dx, dy, md; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Garg: Invalid monster %d", i); + app_fatal("MAI_Garg: Invalid monster %d", i); Monst = &monster[i]; dx = Monst->_mx - Monst->_lastx; @@ -4598,7 +4598,7 @@ void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoor missile_typea = missile_type; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_RoundRanged: Invalid monster %d", i); + app_fatal("MAI_RoundRanged: Invalid monster %d", i); v6 = &monster[v5]; if (v6->_mmode == MM_STAND && v6->_msquelch) { v7 = v6->_my; @@ -4752,7 +4752,7 @@ void __fastcall MAI_RR2(int i, int mistype, int dam) missile_type = mistype; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_RR2: Invalid monster %d", i); + app_fatal("MAI_RR2: Invalid monster %d", i); v4 = &monster[v3]; v5 = v4->_my - (unsigned char)v4->_menemyy; if (abs(v4->_mx - (unsigned char)v4->_menemyx) >= 5 || abs(v5) >= 5) { @@ -4873,7 +4873,7 @@ void __fastcall MAI_Golum(int i) BOOL have_enemy, ok; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Golum: Invalid monster %d", i); + app_fatal("MAI_Golum: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mx == 1 && Monst->_my == 0) { @@ -4983,7 +4983,7 @@ void __fastcall MAI_SkelKing(int i) v1 = i; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SkelKing: Invalid monster %d", i); + app_fatal("MAI_SkelKing: Invalid monster %d", i); v2 = &monster[v1]; if (v2->_mmode == MM_STAND && v2->_msquelch) { v3 = v2->_my; @@ -5112,7 +5112,7 @@ void __fastcall MAI_Rhino(int i) esi1 = i; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Rhino: Invalid monster %d", i); + app_fatal("MAI_Rhino: Invalid monster %d", i); esi3 = &monster[esi1]; if (esi3->_mmode == MM_STAND && esi3->_msquelch) { v3 = esi3->_my; @@ -5251,7 +5251,7 @@ void __fastcall MAI_Counselor(int i) v1 = i; arglist = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Counselor: Invalid monster %d", i); + app_fatal("MAI_Counselor: Invalid monster %d", i); v2 = v1; if (monster[v1]._mmode == MM_STAND && monster[v2]._msquelch) { v3 = monster[v2]._mx; @@ -5373,7 +5373,7 @@ void __fastcall MAI_Garbud(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Garbud: Invalid monster %d", i); + app_fatal("MAI_Garbud: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mmode != MM_STAND) { @@ -5417,7 +5417,7 @@ void __fastcall MAI_Zhar(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Zhar: Invalid monster %d", i); + app_fatal("MAI_Zhar: Invalid monster %d", i); Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { @@ -5463,7 +5463,7 @@ void __fastcall MAI_SnotSpil(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SnotSpil: Invalid monster %d", i); + app_fatal("MAI_SnotSpil: Invalid monster %d", i); Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { @@ -5515,7 +5515,7 @@ void __fastcall MAI_Lazurus(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Lazurus: Invalid monster %d", i); + app_fatal("MAI_Lazurus: Invalid monster %d", i); Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { @@ -5572,7 +5572,7 @@ void __fastcall MAI_Lazhelp(int i) v1 = i; ia = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Lazhelp: Invalid monster %d", i); + app_fatal("MAI_Lazhelp: Invalid monster %d", i); v2 = v1; if (monster[v2]._mmode == MM_STAND) { v3 = monster[v2]._my; @@ -5604,7 +5604,7 @@ void __fastcall MAI_Lachdanan(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Lachdanan: Invalid monster %d", i); + app_fatal("MAI_Lachdanan: Invalid monster %d", i); Monst = &monster[i]; if (Monst->_mmode != MM_STAND) { @@ -5641,7 +5641,7 @@ void __fastcall MAI_Warlord(int i) int mx, my, md; if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Warlord: Invalid monster %d", i); + app_fatal("MAI_Warlord: Invalid monster %d", i); Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { @@ -5753,7 +5753,7 @@ void __cdecl ProcessMonsters() if (monster[v1]._mFlags & MFLAG_TARGETS_MONSTER) { v5 = monster[v1]._menemy; if (v5 >= MAXMONSTERS) - TermMsg("Illegal enemy monster %d for monster \"%s\"", v5, monster[v1].mName); + app_fatal("Illegal enemy monster %d for monster \"%s\"", v5, monster[v1].mName); v6 = monster[v1]._menemy; v7 = monster[v6]._mfutx; monster[v1]._lastx = v7; @@ -5764,7 +5764,7 @@ void __cdecl ProcessMonsters() } else { v9 = monster[v1]._menemy; if (v9 >= MAX_PLRS) - TermMsg("Illegal enemy player %d for monster \"%s\"", v9, monster[v1].mName); + app_fatal("Illegal enemy player %d for monster \"%s\"", v9, monster[v1].mName); v10 = monster[v1]._menemy; v11 = (*v4 & DFLAG_VISIBLE) == 0; v12 = (char *)&plr[v10]._px; @@ -5933,7 +5933,7 @@ BOOL __fastcall DirOK(int i, int mdir) v25 = mdir; a1 = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("DirOK: Invalid monster %d", i); + app_fatal("DirOK: Invalid monster %d", i); v4 = v2; v5 = offset_y[v3]; v6 = monster[v4]._mx + offset_x[v3]; @@ -6272,7 +6272,7 @@ void __fastcall SyncMonsterAnim(int i) v1 = i; if ((DWORD)i >= MAXMONSTERS) - TermMsg("SyncMonsterAnim: Invalid monster %d", i); + app_fatal("SyncMonsterAnim: Invalid monster %d", i); v2 = v1; v3 = monster[v1]._mMTidx; v4 = Monsters[v3].MData; @@ -6540,12 +6540,12 @@ void __fastcall MissToMonst(int i, int x, int y) v3 = i; v30 = x; if ((DWORD)i >= MAXMISSILES) - TermMsg("MissToMonst: Invalid missile %d", i); + app_fatal("MissToMonst: Invalid missile %d", i); v4 = &missile[v3]; v5 = v4->_misource; ia = v4->_misource; if (v5 >= MAXMONSTERS) - TermMsg("MissToMonst: Invalid monster %d", v5); + app_fatal("MissToMonst: Invalid monster %d", v5); v32 = v4->_mix; v31 = v4->_miy; v6 = &monster[v5]; @@ -6877,7 +6877,7 @@ void __fastcall TalktoMonster(int i) int pnum, itm; if ((DWORD)i >= MAXMONSTERS) - TermMsg("TalktoMonster: Invalid monster %d", i); + app_fatal("TalktoMonster: Invalid monster %d", i); Monst = &monster[i]; pnum = Monst->_menemy; @@ -6902,7 +6902,7 @@ void __fastcall TalktoMonster(int i) void __fastcall SpawnGolum(int i, int x, int y, int mi) { if ((DWORD)i >= MAXMONSTERS) - TermMsg("SpawnGolum: Invalid monster %d", i); + app_fatal("SpawnGolum: Invalid monster %d", i); dMonster[x][y] = i + 1; monster[i]._mx = x; @@ -6935,7 +6935,7 @@ void __fastcall SpawnGolum(int i, int x, int y, int mi) BOOL __fastcall CanTalkToMonst(int m) { if ((DWORD)m >= MAXMONSTERS) { - TermMsg("CanTalkToMonst: Invalid monster %d", m); + app_fatal("CanTalkToMonst: Invalid monster %d", m); } if (monster[m]._mgoal == MGOAL_INQUIRING) { @@ -6948,7 +6948,7 @@ BOOL __fastcall CanTalkToMonst(int m) BOOL __fastcall CheckMonsterHit(int m, BOOL *ret) { if ((DWORD)m >= MAXMONSTERS) { - TermMsg("CheckMonsterHit: Invalid monster %d", m); + app_fatal("CheckMonsterHit: Invalid monster %d", m); } if (monster[m]._mAi == AI_GARG && monster[m]._mFlags & MFLAG_ALLOW_SPECIAL) { diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 5ba345a68..119341e1f 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -179,7 +179,7 @@ LABEL_2: } v8 = v3 + v2 == sgdwMpqOffset; if (v3 + v2 > sgdwMpqOffset) { - TermMsg("MPQ free list error"); + app_fatal("MPQ free list error"); v8 = v3 + v2 == sgdwMpqOffset; } if (v8) { @@ -204,7 +204,7 @@ _BLOCKENTRY *__fastcall mpqapi_new_block(int *block_index) ++v2; ++result; if (v2 >= 0x800) { - TermMsg("Out of free block entries"); + app_fatal("Out of free block entries"); return 0; } } @@ -300,7 +300,7 @@ _BLOCKENTRY *__fastcall mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, v5 = Hash(v3, 1); v11 = Hash(v3, 2); if (mpqapi_get_hash_index(v4, v5, v11, 0) != -1) - TermMsg("Hash collision between \"%s\" and existing file\n", v3); + app_fatal("Hash collision between \"%s\" and existing file\n", v3); v6 = 2048; v7 = v4 & 0x7FF; while (1) { @@ -315,7 +315,7 @@ _BLOCKENTRY *__fastcall mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, } } if (v6 < 0) - TermMsg("Out of hash space"); + app_fatal("Out of hash space"); if (!v12) v12 = mpqapi_new_block(&block_index); v9 = v7; diff --git a/Source/msg.cpp b/Source/msg.cpp index 930538d1d..bae22728f 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1219,7 +1219,7 @@ void __fastcall DeltaImportData(BYTE cmd, DWORD recv_offset) src = DeltaImportObject(src, sgLevels[i].object); DeltaImportMonster(src, sgLevels[i].monster); } else { - TermMsg("msg:1"); + app_fatal("msg:1"); } sgbDeltaChunks++; @@ -1486,7 +1486,7 @@ BOOL __fastcall delta_get_item(TCmdGItem *pI, BYTE bLevel) sgbDeltaChanged = 1; return TRUE; } else { - TermMsg("delta:1"); + app_fatal("delta:1"); } return result; } @@ -1629,7 +1629,7 @@ void __fastcall delta_put_item(TCmdPItem *pI, int x, int y, BYTE bLevel) && pD->dwSeed == pI->dwSeed) { if (pD->bCmd == CMD_ACK_PLRINFO) return; - TermMsg("Trying to drop a floor item?"); + app_fatal("Trying to drop a floor item?"); } } diff --git a/Source/multi.cpp b/Source/multi.cpp index 4f76a6657..4dead192c 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -629,7 +629,7 @@ char __fastcall multi_event_handler(int a1) v4 = (int)v2(event_types[v3], multi_handle_events); if (!v4 && v1) { v5 = TraceLastError(); - TermMsg("SNetRegisterEventHandler:\n%s", v5); + app_fatal("SNetRegisterEventHandler:\n%s", v5); } ++v3; } while (v3 < 3); @@ -873,7 +873,7 @@ BOOL __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA unused = 0; if (!SNetCreateGame("local", "local", "local", 0, (char *)&sgGameInitInfo.dwSeed, 8, 1, "local", "local", &unused)) { - TermMsg("SNetCreateGame1:\n%s", TraceLastError()); + app_fatal("SNetCreateGame1:\n%s", TraceLastError()); } myplr = 0; diff --git a/Source/nthread.cpp b/Source/nthread.cpp index f57001644..0f77effff 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -59,7 +59,7 @@ void __fastcall nthread_terminate_game(const char *pszFcn) if (sErr == STORM_ERROR_GAME_TERMINATED || sErr == STORM_ERROR_NOT_IN_GAME) { gbGameDestroyed = 1; } else { - TermMsg("%s:\n%s", pszFcn, TraceLastError()); + app_fatal("%s:\n%s", pszFcn, TraceLastError()); } } } @@ -166,7 +166,7 @@ void __fastcall nthread_start(BOOL set_turn_upper_bit) caps.size = 36; if (!SNetGetProviderCaps(&caps)) { err = TraceLastError(); - TermMsg("SNetGetProviderCaps:\n%s", err); + app_fatal("SNetGetProviderCaps:\n%s", err); } gdwTurnsInTransit = caps.defaultturnsintransit; if (!caps.defaultturnsintransit) @@ -200,7 +200,7 @@ void __fastcall nthread_start(BOOL set_turn_upper_bit) sghThread = (HANDLE)_beginthreadex(NULL, 0, nthread_handler, NULL, 0, &glpNThreadId); if (sghThread == (HANDLE)-1) { err2 = TraceLastError(); - TermMsg("nthread2:\n%s", err2); + app_fatal("nthread2:\n%s", err2); } SetThreadPriority(sghThread, THREAD_PRIORITY_HIGHEST); } @@ -257,7 +257,7 @@ void __cdecl nthread_cleanup() if (!sgbThreadIsRunning) LeaveCriticalSection(&sgMemCrit); if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { - TermMsg("nthread3:\n(%s)", TraceLastError()); + app_fatal("nthread3:\n(%s)", TraceLastError()); } CloseHandle(sghThread); sghThread = (HANDLE)-1; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 65915fb5a..5f1b10161 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -20,7 +20,7 @@ void __cdecl pfile_init_save_directory() } if (!len) - TermMsg("Unable to initialize save directory"); + app_fatal("Unable to initialize save directory"); else pfile_check_available_space(Buffer); } @@ -125,7 +125,7 @@ void __fastcall pfile_get_save_path(char *pszBuf, DWORD dwBufSize, unsigned int *s = '\0'; if (!plen) - TermMsg("Unable to get save directory"); + app_fatal("Unable to get save directory"); sprintf(path, fmt, save_num); strcat(pszBuf, path); @@ -303,7 +303,7 @@ char *__fastcall GetSaveDirectory(char *dst, int dst_size, unsigned int save_num } if (!dirLen) - TermMsg("Unable to get save directory"); + app_fatal("Unable to get save directory"); sprintf(FileName, savename, save_num); strcat(dst, FileName); @@ -488,9 +488,9 @@ void __cdecl pfile_read_player_from_save() save_num = pfile_get_save_num_from_name(gszHero); archive = pfile_open_save_archive(NULL, save_num); if (archive == NULL) - TermMsg("Unable to open archive"); + app_fatal("Unable to open archive"); if (!pfile_read_hero(archive, &pkplr)) - TermMsg("Unable to load character"); + app_fatal("Unable to load character"); UnPackPlayer(&pkplr, myplr, FALSE); gbValidSaveFile = pfile_archive_contains_game(archive, save_num); @@ -515,7 +515,7 @@ void __fastcall GetPermLevelNames(char *szPerm) save_num = pfile_get_save_num_from_name(plr[myplr]._pName); GetTempLevelNames(szPerm); if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to read to save file archive"); + app_fatal("Unable to read to save file archive"); has_file = mpqapi_has_file(szPerm); pfile_flush(TRUE, save_num); @@ -539,7 +539,7 @@ void __cdecl pfile_remove_temp_files() if (gbMaxPlayers <= 1) { unsigned int save_num = pfile_get_save_num_from_name(plr[myplr]._pName); if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to write to save file archive"); + app_fatal("Unable to write to save file archive"); mpqapi_remove_hash_entries(GetTempSaveNames); pfile_flush(TRUE, save_num); } @@ -570,7 +570,7 @@ void __cdecl pfile_rename_temp_to_perm() save_num = pfile_get_save_num_from_name(plr[myplr]._pName); if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to write to save file archive"); + app_fatal("Unable to write to save file archive"); i = 0; while (GetTempSaveNames(i, TempName)) { @@ -617,7 +617,7 @@ void __fastcall pfile_write_save_file(const char *pszName, BYTE *pbData, DWORD d codec_encode(pbData, dwLen, qwLen, password); } if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to write so save file archive"); + app_fatal("Unable to write so save file archive"); mpqapi_write_file(FileName, pbData, qwLen); pfile_flush(TRUE, save_num); } @@ -639,18 +639,18 @@ BYTE *__fastcall pfile_read(const char *pszName, DWORD *pdwLen) save_num = pfile_get_save_num_from_name(plr[myplr]._pName); archive = pfile_open_save_archive(NULL, save_num); if (archive == NULL) - TermMsg("Unable to open save file archive"); + app_fatal("Unable to open save file archive"); if (!SFileOpenFileEx(archive, FileName, 0, &save)) - TermMsg("Unable to open save file"); + app_fatal("Unable to open save file"); *pdwLen = SFileGetFileSize(save, NULL); if (*pdwLen == 0) - TermMsg("Invalid save file"); + app_fatal("Invalid save file"); buf = (BYTE *)DiabloAllocPtr(*pdwLen); if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) - TermMsg("Unable to read save file"); + app_fatal("Unable to read save file"); SFileCloseFile(save); pfile_SFileCloseArchive(archive); @@ -668,14 +668,14 @@ BYTE *__fastcall pfile_read(const char *pszName, DWORD *pdwLen) if (gbMaxPlayers > 1) { GetComputerName(password, &nSize); if (SFileSetFilePointer(save, 0, NULL, 0)) - TermMsg("Unable to read save file"); + app_fatal("Unable to read save file"); if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) - TermMsg("Unable to read save file"); + app_fatal("Unable to read save file"); *pdwLen = codec_decode(buf, *pdwLen, password); } if (*pdwLen == 0) - TermMsg("Invalid save file"); + app_fatal("Invalid save file"); } } return buf; diff --git a/Source/player.cpp b/Source/player.cpp index f3872d6af..f8d3726da 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -126,7 +126,7 @@ void __fastcall LoadPlrGFX(int pnum, player_graphic gfxflag) DWORD i; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("LoadPlrGFX: illegal player %d", pnum); + app_fatal("LoadPlrGFX: illegal player %d", pnum); } p = &plr[pnum]; @@ -216,7 +216,7 @@ void __fastcall LoadPlrGFX(int pnum, player_graphic gfxflag) pAnim = (UCHAR *)p->_pBAnim; break; default: - TermMsg("PLR:2"); + app_fatal("PLR:2"); break; } @@ -230,7 +230,7 @@ void __fastcall LoadPlrGFX(int pnum, player_graphic gfxflag) void __fastcall InitPlayerGFX(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlayerGFX: illegal player %d", pnum); + app_fatal("InitPlayerGFX: illegal player %d", pnum); } if (plr[pnum]._pHitPoints >> 6 == 0) { @@ -244,7 +244,7 @@ void __fastcall InitPlayerGFX(int pnum) void __fastcall InitPlrGFXMem(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlrGFXMem: illegal player %d", pnum); + app_fatal("InitPlrGFXMem: illegal player %d", pnum); } if (!(plr_gfx_flag & 0x1)) { //STAND @@ -349,7 +349,7 @@ void __fastcall FreePlayerGFX(int pnum) void *ptr; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("FreePlayerGFX: illegal player %d", pnum); + app_fatal("FreePlayerGFX: illegal player %d", pnum); } ptr = plr[pnum]._pNData; @@ -385,7 +385,7 @@ void __fastcall FreePlayerGFX(int pnum) void __fastcall NewPlrAnim(int pnum, unsigned char *Peq, int numFrames, int Delay, int width) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("NewPlrAnim: illegal player %d", pnum); + app_fatal("NewPlrAnim: illegal player %d", pnum); } plr[pnum]._pAnimData = Peq; @@ -400,7 +400,7 @@ void __fastcall NewPlrAnim(int pnum, unsigned char *Peq, int numFrames, int Dela void __fastcall ClearPlrPVars(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ClearPlrPVars: illegal player %d", pnum); + app_fatal("ClearPlrPVars: illegal player %d", pnum); } plr[pnum]._pVar1 = 0; @@ -418,7 +418,7 @@ void __fastcall SetPlrAnims(int pnum) int pc, gn; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrAnims: illegal player %d", pnum); + app_fatal("SetPlrAnims: illegal player %d", pnum); } pc = plr[pnum]._pClass; @@ -524,7 +524,7 @@ void __fastcall CreatePlayer(int pnum, char c) SetRndSeed(GetTickCount()); if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("CreatePlayer: illegal player %d", pnum); + app_fatal("CreatePlayer: illegal player %d", pnum); } plr[pnum]._pClass = c; @@ -686,7 +686,7 @@ void __fastcall NextPlrLevel(int pnum) int hp, mana; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("NextPlrLevel: illegal player %d", pnum); + app_fatal("NextPlrLevel: illegal player %d", pnum); } plr[pnum]._pLevel++; @@ -743,7 +743,7 @@ void __fastcall AddPlrExperience(int pnum, int lvl, int exp) } if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("AddPlrExperience: illegal player %d", myplr); + app_fatal("AddPlrExperience: illegal player %d", myplr); } if (plr[myplr]._pHitPoints <= 0) { @@ -818,7 +818,7 @@ void __fastcall InitPlayer(int pnum, BOOL FirstTime) DWORD i; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlayer: illegal player %d", pnum); + app_fatal("InitPlayer: illegal player %d", pnum); } ClearPlrRVars(&plr[pnum]); @@ -928,7 +928,7 @@ void __fastcall InitPlayer(int pnum, BOOL FirstTime) void __cdecl InitMultiView() { if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("InitPlayer: illegal player %d", myplr); + app_fatal("InitPlayer: illegal player %d", myplr); } ViewX = plr[myplr].WorldX; @@ -942,7 +942,7 @@ void __fastcall InitPlayerLoc(int pnum, BOOL flag) USHORT *pieces; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlayer: illegal player %d", pnum); + app_fatal("InitPlayer: illegal player %d", pnum); } x = plr[pnum].WorldX - 1; @@ -1006,7 +1006,7 @@ BOOL __fastcall PlrDirOK(int pnum, int dir) BOOL isOk; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrDirOK: illegal player %d", pnum); + app_fatal("PlrDirOK: illegal player %d", pnum); } px = plr[pnum].WorldX + offset_x[dir]; @@ -1059,7 +1059,7 @@ void __fastcall PlrDoTrans(int x, int y) void __fastcall SetPlayerOld(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlayerOld: illegal player %d", pnum); + app_fatal("SetPlayerOld: illegal player %d", pnum); } plr[pnum]._poldx = plr[pnum].WorldX; @@ -1069,7 +1069,7 @@ void __fastcall SetPlayerOld(int pnum) void __fastcall FixPlayerLocation(int pnum, int dir) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("FixPlayerLocation: illegal player %d", pnum); + app_fatal("FixPlayerLocation: illegal player %d", pnum); } plr[pnum]._px = plr[pnum].WorldX; @@ -1092,7 +1092,7 @@ void __fastcall FixPlayerLocation(int pnum, int dir) void __fastcall StartStand(int pnum, int dir) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartStand: illegal player %d", pnum); + app_fatal("StartStand: illegal player %d", pnum); } if (!plr[pnum]._pInvincible || plr[pnum]._pHitPoints || pnum != myplr) { @@ -1114,7 +1114,7 @@ void __fastcall StartStand(int pnum, int dir) void __fastcall StartWalkStand(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalkStand: illegal player %d", pnum); + app_fatal("StartWalkStand: illegal player %d", pnum); } plr[pnum]._pmode = 0; @@ -1143,7 +1143,7 @@ void __fastcall PM_ChangeLightOff(int pnum) const LightListStruct *l; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_ChangeLightOff: illegal player %d", pnum); + app_fatal("PM_ChangeLightOff: illegal player %d", pnum); } l = &LightList[plr[pnum]._plid]; @@ -1180,7 +1180,7 @@ void __fastcall PM_ChangeOffset(int pnum) int px, py; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_ChangeOffset: illegal player %d", pnum); + app_fatal("PM_ChangeOffset: illegal player %d", pnum); } plr[pnum]._pVar8++; @@ -1205,7 +1205,7 @@ void __fastcall StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int int px, py; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalk: illegal player %d", pnum); + app_fatal("StartWalk: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1276,7 +1276,7 @@ void __fastcall StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int int px, py; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalk2: illegal player %d", pnum); + app_fatal("StartWalk2: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1356,7 +1356,7 @@ void __fastcall StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int int px, py, x, y; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalk3: illegal player %d", pnum); + app_fatal("StartWalk3: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1435,7 +1435,7 @@ void __fastcall StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int void __fastcall StartAttack(int pnum, int d) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartAttack: illegal player %d", pnum); + app_fatal("StartAttack: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1456,7 +1456,7 @@ void __fastcall StartAttack(int pnum, int d) void __fastcall StartRangeAttack(int pnum, int d, int cx, int cy) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartRangeAttack: illegal player %d", pnum); + app_fatal("StartRangeAttack: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1479,7 +1479,7 @@ void __fastcall StartRangeAttack(int pnum, int d, int cx, int cy) void __fastcall StartPlrBlock(int pnum, int dir) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartPlrBlock: illegal player %d", pnum); + app_fatal("StartPlrBlock: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1502,7 +1502,7 @@ void __fastcall StartPlrBlock(int pnum, int dir) void __fastcall StartSpell(int pnum, int d, int cx, int cy) { if ((DWORD)pnum >= MAX_PLRS) - TermMsg("StartSpell: illegal player %d", pnum); + app_fatal("StartSpell: illegal player %d", pnum); if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { SyncPlrKill(pnum, -1); @@ -1551,7 +1551,7 @@ void __fastcall FixPlrWalkTags(int pnum) int dx, dy, y, x; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("FixPlrWalkTags: illegal player %d", pnum); + app_fatal("FixPlrWalkTags: illegal player %d", pnum); } pp = pnum + 1; @@ -1597,7 +1597,7 @@ void __fastcall StartPlrHit(int pnum, int dam, BOOL forcehit) int pd; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartPlrHit: illegal player %d", pnum); + app_fatal("StartPlrHit: illegal player %d", pnum); } if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { @@ -1675,7 +1675,7 @@ void __fastcall StartPlayerKill(int pnum, int earflag) diablolevel = gbMaxPlayers > 1 && plr[pnum].plrlevel == 16; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartPlayerKill: illegal player %d", pnum); + app_fatal("StartPlayerKill: illegal player %d", pnum); } if (plr[pnum]._pClass == PC_WARRIOR) { @@ -1776,7 +1776,7 @@ void __fastcall PlrDeadItem(int pnum, ItemStruct *itm, int xx, int yy) return; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrDeadItem: illegal player %d", pnum); + app_fatal("PlrDeadItem: illegal player %d", pnum); } x = xx + plr[pnum].WorldX; @@ -1809,7 +1809,7 @@ void __fastcall DropHalfPlayersGold(int pnum) int i, hGold; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("DropHalfPlayersGold: illegal player %d", pnum); + app_fatal("DropHalfPlayersGold: illegal player %d", pnum); } hGold = plr[pnum]._pGold >> 1; @@ -1999,7 +1999,7 @@ void __fastcall StartNewLvl(int pnum, int fom, int lvl) InitLevelChange(pnum); if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartNewLvl: illegal player %d", pnum); + app_fatal("StartNewLvl: illegal player %d", pnum); } switch (fom) { @@ -2021,7 +2021,7 @@ void __fastcall StartNewLvl(int pnum, int fom, int lvl) case WM_DIABRETOWN: break; default: - TermMsg("StartNewLvl"); + app_fatal("StartNewLvl"); break; } @@ -2038,7 +2038,7 @@ void __fastcall RestartTownLvl(int pnum) { InitLevelChange(pnum); if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("RestartTownLvl: illegal player %d", pnum); + app_fatal("RestartTownLvl: illegal player %d", pnum); } plr[pnum].plrlevel = 0; @@ -2088,7 +2088,7 @@ BOOL __fastcall PM_DoWalk(int pnum) int vel; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoWalk: illegal player %d", pnum); + app_fatal("PM_DoWalk: illegal player %d", pnum); } if (plr[pnum]._pAnimFrame == 3 @@ -2141,7 +2141,7 @@ BOOL __fastcall PM_DoWalk2(int pnum) int vel; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoWalk2: illegal player %d", pnum); + app_fatal("PM_DoWalk2: illegal player %d", pnum); } if (plr[pnum]._pAnimFrame == 3 @@ -2191,7 +2191,7 @@ BOOL __fastcall PM_DoWalk3(int pnum) int vel; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoWalk3: illegal player %d", pnum); + app_fatal("PM_DoWalk3: illegal player %d", pnum); } if (plr[pnum]._pAnimFrame == 3 @@ -2252,7 +2252,7 @@ BOOL __fastcall WeaponDur(int pnum, int durrnd) } if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("WeaponDur: illegal player %d", pnum); + app_fatal("WeaponDur: illegal player %d", pnum); } if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) { @@ -2320,7 +2320,7 @@ BOOL __fastcall PlrHitMonst(int pnum, int m) int hit, hper, mind, maxd, dam, lvl, phanditype, mClass, skdam, tac; if ((DWORD)m >= MAXMONSTERS) { - TermMsg("PlrHitMonst: illegal monster %d", m); + app_fatal("PlrHitMonst: illegal monster %d", m); } if ((monster[m]._mhitpoints >> 6) <= 0) { @@ -2336,7 +2336,7 @@ BOOL __fastcall PlrHitMonst(int pnum, int m) } if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrHitMonst: illegal player %d", pnum); + app_fatal("PlrHitMonst: illegal player %d", pnum); } rv = FALSE; @@ -2498,7 +2498,7 @@ BOOL __fastcall PlrHitPlr(int pnum, char p) int hit, hper, blk, blkper, dir, mind, maxd, dam, lvl, skdam, tac; if ((DWORD)p >= MAX_PLRS) { - TermMsg("PlrHitPlr: illegal target player %d", p); + app_fatal("PlrHitPlr: illegal target player %d", p); } rv = FALSE; @@ -2512,7 +2512,7 @@ BOOL __fastcall PlrHitPlr(int pnum, char p) } if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrHitPlr: illegal attacking player %d", pnum); + app_fatal("PlrHitPlr: illegal attacking player %d", pnum); } hit = random(4, 100); @@ -2609,7 +2609,7 @@ BOOL __fastcall PM_DoAttack(int pnum) BOOL didhit; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoAttack: illegal player %d", pnum); + app_fatal("PM_DoAttack: illegal player %d", pnum); } frame = plr[pnum]._pAnimFrame; @@ -2695,7 +2695,7 @@ BOOL __fastcall PM_DoRangeAttack(int pnum) int origFrame, mistype; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoRangeAttack: illegal player %d", pnum); + app_fatal("PM_DoRangeAttack: illegal player %d", pnum); } origFrame = plr[pnum]._pAnimFrame; @@ -2751,7 +2751,7 @@ void __fastcall ShieldDur(int pnum) } if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ShieldDur: illegal player %d", pnum); + app_fatal("ShieldDur: illegal player %d", pnum); } if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { @@ -2782,7 +2782,7 @@ void __fastcall ShieldDur(int pnum) BOOL __fastcall PM_DoBlock(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoBlock: illegal player %d", pnum); + app_fatal("PM_DoBlock: illegal player %d", pnum); } if (plr[pnum]._pIFlags & ISPL_FASTBLOCK && plr[pnum]._pAnimFrame != 1) { @@ -2805,7 +2805,7 @@ BOOL __fastcall PM_DoBlock(int pnum) BOOL __fastcall PM_DoSpell(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoSpell: illegal player %d", pnum); + app_fatal("PM_DoSpell: illegal player %d", pnum); } if (plr[pnum]._pVar8 == plr[pnum]._pSFNum) { @@ -2863,7 +2863,7 @@ BOOL __fastcall PM_DoGotHit(int pnum) int frame; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoGotHit: illegal player %d", pnum); + app_fatal("PM_DoGotHit: illegal player %d", pnum); } frame = plr[pnum]._pAnimFrame; @@ -2901,7 +2901,7 @@ void __fastcall ArmorDur(int pnum) } if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ArmorDur: illegal player %d", pnum); + app_fatal("ArmorDur: illegal player %d", pnum); } p = &plr[pnum]; @@ -2943,7 +2943,7 @@ void __fastcall ArmorDur(int pnum) BOOL __fastcall PM_DoDeath(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoDeath: illegal player %d", pnum); + app_fatal("PM_DoDeath: illegal player %d", pnum); } if (plr[pnum]._pVar8 >= 2 * plr[pnum]._pDFrames) { @@ -2981,7 +2981,7 @@ void __fastcall CheckNewPath(int pnum) int xvel3, xvel, yvel; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("CheckNewPath: illegal player %d", pnum); + app_fatal("CheckNewPath: illegal player %d", pnum); } if (plr[pnum].destAction == ACTION_ATTACKMON) { @@ -3301,7 +3301,7 @@ BOOL __fastcall PlrDeathModeOK(int pnum) } if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrDeathModeOK: illegal player %d", pnum); + app_fatal("PlrDeathModeOK: illegal player %d", pnum); } if (plr[pnum]._pmode == PM_DEATH) { @@ -3323,7 +3323,7 @@ void __cdecl ValidatePlayer() msk = 0; if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("ValidatePlayer: illegal player %d", myplr); + app_fatal("ValidatePlayer: illegal player %d", myplr); } if (plr[myplr]._pLevel > 50) plr[myplr]._pLevel = 50; @@ -3373,7 +3373,7 @@ void __cdecl ProcessPlayers() BOOL tplayer; if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("ProcessPlayers: illegal player %d", myplr); + app_fatal("ProcessPlayers: illegal player %d", myplr); } if (plr[myplr].pLvlLoad > 0) { @@ -3496,7 +3496,7 @@ void __fastcall CheckCheatStats(int pnum) void __fastcall ClrPlrPath(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ClrPlrPath: illegal player %d", pnum); + app_fatal("ClrPlrPath: illegal player %d", pnum); } memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath)); @@ -3558,7 +3558,7 @@ void __fastcall MakePlrPath(int pnum, int xx, int yy, BOOL endspace) int path; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("MakePlrPath: illegal player %d", pnum); + app_fatal("MakePlrPath: illegal player %d", pnum); } plr[pnum]._ptargx = xx; @@ -3619,7 +3619,7 @@ void __fastcall CheckPlrSpell() int rspell, sd, sl; if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("CheckPlrSpell: illegal player %d", myplr); + app_fatal("CheckPlrSpell: illegal player %d", myplr); } rspell = plr[myplr]._pRSpell; @@ -3705,7 +3705,7 @@ void __fastcall SyncPlrAnim(int pnum) int dir, sType; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SyncPlrAnim: illegal player %d", pnum); + app_fatal("SyncPlrAnim: illegal player %d", pnum); } dir = plr[pnum]._pdir; @@ -3748,7 +3748,7 @@ void __fastcall SyncPlrAnim(int pnum) plr[pnum]._pAnimData = plr[pnum]._pAAnim[dir]; break; default: - TermMsg("SyncPlrAnim"); + app_fatal("SyncPlrAnim"); break; } } @@ -3806,7 +3806,7 @@ void __fastcall SyncInitPlrPos(int pnum) void __fastcall SyncInitPlr(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SyncInitPlr: illegal player %d", pnum); + app_fatal("SyncInitPlr: illegal player %d", pnum); } SetPlrAnims(pnum); @@ -3818,7 +3818,7 @@ void __fastcall CheckStats(int pnum) int c, i; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("CheckStats: illegal player %d", pnum); + app_fatal("CheckStats: illegal player %d", pnum); } if (plr[pnum]._pClass == PC_WARRIOR) { @@ -3868,7 +3868,7 @@ void __fastcall ModifyPlrStr(int pnum, int l) int max; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrStr: illegal player %d", pnum); + app_fatal("ModifyPlrStr: illegal player %d", pnum); } max = MaxStats[plr[pnum]._pClass][ATTRIB_STR]; @@ -3897,7 +3897,7 @@ void __fastcall ModifyPlrMag(int pnum, int l) int max, ms; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrMag: illegal player %d", pnum); + app_fatal("ModifyPlrMag: illegal player %d", pnum); } max = MaxStats[plr[pnum]._pClass][ATTRIB_MAG]; @@ -3932,7 +3932,7 @@ void __fastcall ModifyPlrDex(int pnum, int l) int max; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrDex: illegal player %d", pnum); + app_fatal("ModifyPlrDex: illegal player %d", pnum); } max = MaxStats[plr[pnum]._pClass][ATTRIB_DEX]; @@ -3958,7 +3958,7 @@ void __fastcall ModifyPlrVit(int pnum, int l) int max, ms; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrVit: illegal player %d", pnum); + app_fatal("ModifyPlrVit: illegal player %d", pnum); } max = MaxStats[plr[pnum]._pClass][ATTRIB_VIT]; @@ -3989,7 +3989,7 @@ void __fastcall ModifyPlrVit(int pnum, int l) void __fastcall SetPlayerHitPoints(int pnum, int newhp) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlayerHitPoints: illegal player %d", pnum); + app_fatal("SetPlayerHitPoints: illegal player %d", pnum); } plr[pnum]._pHitPoints = newhp; @@ -4005,7 +4005,7 @@ void __fastcall SetPlrStr(int pnum, int v) int dm; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrStr: illegal player %d", pnum); + app_fatal("SetPlrStr: illegal player %d", pnum); } plr[pnum]._pBaseStr = v; @@ -4025,7 +4025,7 @@ void __fastcall SetPlrMag(int pnum, int v) int m; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrMag: illegal player %d", pnum); + app_fatal("SetPlrMag: illegal player %d", pnum); } plr[pnum]._pBaseMag = v; @@ -4045,7 +4045,7 @@ void __fastcall SetPlrDex(int pnum, int v) int dm; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrDex: illegal player %d", pnum); + app_fatal("SetPlrDex: illegal player %d", pnum); } plr[pnum]._pBaseDex = v; @@ -4065,7 +4065,7 @@ void __fastcall SetPlrVit(int pnum, int v) int hp; if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrVit: illegal player %d", pnum); + app_fatal("SetPlrVit: illegal player %d", pnum); } plr[pnum]._pBaseVit = v; @@ -4083,7 +4083,7 @@ void __fastcall SetPlrVit(int pnum, int v) void __fastcall InitDungMsgs(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitDungMsgs: illegal player %d", pnum); + app_fatal("InitDungMsgs: illegal player %d", pnum); } plr[pnum].pDungMsgs = 0; @@ -4092,7 +4092,7 @@ void __fastcall InitDungMsgs(int pnum) void __cdecl PlayDungMsgs() { if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("PlayDungMsgs: illegal player %d", myplr); + app_fatal("PlayDungMsgs: illegal player %d", myplr); } if (currlevel == 1 && !plr[myplr]._pLvlVisited[1] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATHEDRAL)) { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index c8ed1c826..dd7217a0b 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -83,13 +83,13 @@ void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, BOOL p if(m->_mix == x && m->_miy == y && m->_miPreFlag == pre && m->_miDrawFlag) { pCelBuff = m->_miAnimData; if(!pCelBuff) { - // TermMsg("Draw Missile type %d: NULL Cel Buffer", m->_mitype); + // app_fatal("Draw Missile type %d: NULL Cel Buffer", m->_mitype); return; } nCel = m->_miAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Draw Missile: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); + // app_fatal("Draw Missile: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); return; } mx = sx + m->_mixoff - m->_miAnimWidth2; @@ -107,13 +107,13 @@ void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, BOOL p if(m->_miPreFlag == pre && m->_miDrawFlag) { pCelBuff = m->_miAnimData; if(!pCelBuff) { - // TermMsg("Draw Missile 2 type %d: NULL Cel Buffer", m->_mitype); + // app_fatal("Draw Missile 2 type %d: NULL Cel Buffer", m->_mitype); return; } nCel = m->_miAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Draw Missile 2: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); + // app_fatal("Draw Missile 2: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); return; } mx = sx + m->_mixoff - m->_miAnimWidth2; @@ -144,13 +144,13 @@ void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, if(m->_mix == x && m->_miy == y && m->_miPreFlag == pre && m->_miDrawFlag) { pCelBuff = m->_miAnimData; if(!pCelBuff) { - // TermMsg("Draw Missile type %d Clipped: NULL Cel Buffer", m->_mitype); + // app_fatal("Draw Missile type %d Clipped: NULL Cel Buffer", m->_mitype); return; } nCel = m->_miAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Draw Clipped Missile: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); + // app_fatal("Draw Clipped Missile: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); return; } mx = sx + m->_mixoff - m->_miAnimWidth2; @@ -168,13 +168,13 @@ void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, if(m->_miPreFlag == pre && m->_miDrawFlag) { pCelBuff = m->_miAnimData; if(!pCelBuff) { - // TermMsg("Draw Missile 2 type %d Clipped: NULL Cel Buffer", m->_mitype); + // app_fatal("Draw Missile 2 type %d Clipped: NULL Cel Buffer", m->_mitype); return; } nCel = m->_miAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Draw Clipped Missile 2: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); + // app_fatal("Draw Clipped Missile 2: frame %d of %d, missile type==%d", nCel, pFrameTable[0], m->_mitype); return; } mx = sx + m->_mixoff - m->_miAnimWidth2; @@ -208,13 +208,13 @@ void __fastcall DrawDeadPlayer(int x, int y, int sx, int sy, int a5, int a6, BOO if(p->plractive && !p->_pHitPoints && p->plrlevel == (unsigned char)currlevel && p->WorldX == x && p->WorldY == y) { pCelBuff = p->_pAnimData; if(!pCelBuff) { - // TermMsg("Drawing dead player %d \"%s\": NULL Cel Buffer", i, p->_pName); + // app_fatal("Drawing dead player %d \"%s\": NULL Cel Buffer", i, p->_pName); break; } nCel = p->_pAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Drawing dead player %d \"%s\": facing %d, frame %d of %d", i, p->_pName, p->_pdir, nCel, pFrameTable[0]); + // app_fatal("Drawing dead player %d \"%s\": facing %d, frame %d of %d", i, p->_pName, p->_pdir, nCel, pFrameTable[0]); break; } dFlags[x][y] |= DFLAG_DEAD_PLAYER; @@ -232,7 +232,7 @@ void __fastcall DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuf if(dFlags[x][y] & DFLAG_LIT || plr[myplr]._pInfraFlag || !setlevel && !currlevel) { if(!pCelBuff) { - // TermMsg("Drawing player %d \"%s\": NULL Cel Buffer", pnum, plr[pnum]._pName); + // app_fatal("Drawing player %d \"%s\": NULL Cel Buffer", pnum, plr[pnum]._pName); return; } pFrameTable = (DWORD *)pCelBuff; @@ -241,7 +241,7 @@ void __fastcall DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuf const char *szMode = "unknown action"; if(plr[pnum]._pmode <= 11) szMode = szPlrModeAssert[plr[pnum]._pmode]; - TermMsg( + app_fatal( "Drawing player %d \"%s\" %s: facing %d, frame %d of %d", pnum, plr[pnum]._pName, @@ -308,7 +308,7 @@ void __fastcall DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE * if(dFlags[x][y] & DFLAG_LIT || plr[myplr]._pInfraFlag) { if(!pCelBuff) { - // TermMsg("Drawing player %d \"%s\" clipped: NULL Cel Buffer", pnum, plr[pnum]._pName); + // app_fatal("Drawing player %d \"%s\" clipped: NULL Cel Buffer", pnum, plr[pnum]._pName); return; } pFrameTable = (DWORD *)pCelBuff; @@ -317,7 +317,7 @@ void __fastcall DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE * const char *szMode = "unknown action"; if(plr[pnum]._pmode <= 11) szMode = szPlrModeAssert[plr[pnum]._pmode]; - TermMsg( + app_fatal( "Drawing player %d \"%s\" %s clipped: facing %d, frame %d of %d", pnum, plr[pnum]._pName, @@ -943,13 +943,13 @@ void __fastcall DrawClippedMonster(int x, int y, int mx, int my, int m, int a6, DWORD *pFrameTable; if((DWORD)m >= MAXMONSTERS) { - // TermMsg("Draw Monster Clipped: tried to draw illegal monster %d", m); + // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", m); return; } pCelBuff = monster[m]._mAnimData; if(!pCelBuff) { - // TermMsg("Draw Monster \"%s\" Clipped: NULL Cel Buffer", monster[m].mName); + // app_fatal("Draw Monster \"%s\" Clipped: NULL Cel Buffer", monster[m].mName); return; } @@ -960,7 +960,7 @@ void __fastcall DrawClippedMonster(int x, int y, int mx, int my, int m, int a6, const char *szMode = "unknown action"; if(monster[m]._mmode <= 17) szMode = szMonModeAssert[monster[m]._mmode]; - TermMsg( + app_fatal( "Draw Monster \"%s\" %s Clipped: facing %d, frame %d of %d", monster[m].mName, szMode, @@ -1020,14 +1020,14 @@ void __fastcall DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int a6 pCelBuff = object[bv]._oAnimData; if(!pCelBuff) { - // TermMsg("Draw Object type %d Clipped: NULL Cel Buffer", object[bv]._otype); + // app_fatal("Draw Object type %d Clipped: NULL Cel Buffer", object[bv]._otype); return; } nCel = object[bv]._oAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Draw Clipped Object: frame %d of %d, object type==%d", nCel, pFrameTable[0], object[bv]._otype); + // app_fatal("Draw Clipped Object: frame %d of %d, object type==%d", nCel, pFrameTable[0], object[bv]._otype); return; } @@ -1908,13 +1908,13 @@ void __fastcall DrawMonster(int x, int y, int mx, int my, int m, int a6, int a7) DWORD *pFrameTable; if((DWORD)m >= MAXMONSTERS) { - // TermMsg("Draw Monster: tried to draw illegal monster %d", m); + // app_fatal("Draw Monster: tried to draw illegal monster %d", m); return; } pCelBuff = monster[m]._mAnimData; if(!pCelBuff) { - // TermMsg("Draw Monster \"%s\": NULL Cel Buffer", monster[m].mName); + // app_fatal("Draw Monster \"%s\": NULL Cel Buffer", monster[m].mName); return; } @@ -1925,7 +1925,7 @@ void __fastcall DrawMonster(int x, int y, int mx, int my, int m, int a6, int a7) const char *szMode = "unknown action"; if(monster[m]._mmode <= 17) szMode = szMonModeAssert[monster[m]._mmode]; - TermMsg( + app_fatal( "Draw Monster \"%s\" %s: facing %d, frame %d of %d", monster[m].mName, szMode, @@ -1985,14 +1985,14 @@ void __fastcall DrawObject(int x, int y, int ox, int oy, BOOL pre, int a6, int d pCelBuff = object[bv]._oAnimData; if(!pCelBuff) { - // TermMsg("Draw Object type %d: NULL Cel Buffer", object[bv]._otype); + // app_fatal("Draw Object type %d: NULL Cel Buffer", object[bv]._otype); return; } nCel = object[bv]._oAnimFrame; pFrameTable = (DWORD *)pCelBuff; if(nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { - // TermMsg("Draw Object: frame %d of %d, object type==%d", nCel, pFrameTable[0], object[bv]._otype); + // app_fatal("Draw Object: frame %d of %d, object type==%d", nCel, pFrameTable[0], object[bv]._otype); return; } diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index a67ade7c6..6efdccd19 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -75,7 +75,7 @@ int __fastcall ObjIndex(int x, int y) if (object[oi]._ox == x && object[oi]._oy == y) return oi; } - TermMsg("ObjIndex: Active object not found at (%d,%d)", x, y); + app_fatal("ObjIndex: Active object not found at (%d,%d)", x, y); return -1; } diff --git a/Source/sound.cpp b/Source/sound.cpp index b9ae59d05..c4e62042e 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -232,7 +232,7 @@ TSnd *__fastcall sound_file_load(char *path) wave_file = LoadWaveFile(file, &pSnd->fmt, &pSnd->chunk); if (!wave_file) - TermMsg("Invalid sound format on file %s", pSnd->sound_path); + app_fatal("Invalid sound format on file %s", pSnd->sound_path); sound_CreateSoundBuffer(pSnd); diff --git a/Source/sync.cpp b/Source/sync.cpp index b8caffb28..6f029d81a 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -231,7 +231,7 @@ int __fastcall SyncData(int pnum, TSyncHeader *packet) v3 = (TSyncMonster *)(&packet->bPInvId + 1); v4 = pnum; if (packet->bCmd != CMD_SYNCDATA) - TermMsg("bad sync command"); + app_fatal("bad sync command"); if (gbBufferMsgs != 1 && v4 != myplr) { v5 = v2->wLen; if (v5 >= 5u) { diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 6115cf7ce..22504ed63 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -1130,7 +1130,7 @@ void __cdecl CheckTriggers() TWarpFrom = currlevel; StartNewLvl(myplr, v4, 0); } else { - TermMsg("Unknown trigger msg"); + app_fatal("Unknown trigger msg"); } goto LABEL_34; } diff --git a/defs.h b/defs.h index 1afa50386..91b9be44b 100644 --- a/defs.h +++ b/defs.h @@ -93,6 +93,14 @@ mem_free_dbg(p__p); \ } +#undef assert + +#ifndef _DEBUG +#define assert(exp) ((void)0) +#else +#define assert(exp) (void)( (exp) || (assert_fail(__LINE__, __FILE__, #exp), 0) ) +#endif + #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif