From 585a3804c43874ad48f7c8998ea14fe214a3f61c Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 01:53:33 +0300 Subject: [PATCH 01/10] Remove unused serial check code --- Descent3/CMakeLists.txt | 2 - Descent3/TelCom.cpp | 49 -------- Descent3/d3serial.cpp | 227 -------------------------------------- Descent3/d3serial.h | 82 -------------- Descent3/multi_client.cpp | 6 +- editor/CMakeLists.txt | 2 - 6 files changed, 2 insertions(+), 366 deletions(-) delete mode 100644 Descent3/d3serial.cpp delete mode 100644 Descent3/d3serial.h diff --git a/Descent3/CMakeLists.txt b/Descent3/CMakeLists.txt index 7ae9570de..8cdd27559 100644 --- a/Descent3/CMakeLists.txt +++ b/Descent3/CMakeLists.txt @@ -43,7 +43,6 @@ set(HEADERS ctlconfigtxt.h d3movie.h d3music.h - d3serial.h damage.h damage_external.h deathinfo_external.h @@ -169,7 +168,6 @@ set(CPPS D3ForceFeedback.cpp d3movie.cpp d3music.cpp - d3serial.cpp damage.cpp debuggraph.cpp dedicated_server.cpp diff --git a/Descent3/TelCom.cpp b/Descent3/TelCom.cpp index f493cccbd..554f2f63b 100644 --- a/Descent3/TelCom.cpp +++ b/Descent3/TelCom.cpp @@ -3214,55 +3214,6 @@ void TelcomEndScreen(void) { float myrand(float max) { return (max * (((float)ps_rand()) / ((float)D3_RAND_MAX))); } -///////////////////////////////////////////////////////////////////////////// -// These are the functions used for serialization, yes they are out of place, -// But that is to keep them away from other parts of the code that has -// the rest of the serialization. These probably can be moved to some other -// file....if this function returns: -// 1 : than it's a serialized exe, num will be given the serial num -// 0 : than it isn't a serialized exe -// -1 : detected a hacked exe -#define INTERNAL_SERIALNUM_TAG "XFCABBFFAX" -char GetInternalSerializationNumber(int *num) { - static char mydata[] = INTERNAL_SERIALNUM_TAG; - - // first check to see if the value is the same (non-serialized EXE) - if (mydata[0] == 'X' && ((mydata[9] + 2) == 'Z')) { - int value = 0; - char c; - for (int i = 0; i < 8; i++) { - c = mydata[i + 1]; - if (c >= 'A' && c <= 'F') { - value = value * 16 + (c - 'A' + 10); - } else - goto get_num; - } - - if (value == 0xFCABBFFA) - return 0; - } - -get_num: - // we got to get the serial num if we can - int value = 0; - char c; - for (int i = 0; i < 8; i++) { - c = mydata[i + 1]; - if (c >= '0' && c <= '9') { - value = value * 16 + c - '0'; - } else if (c >= 'A' && c <= 'F') { - value = value * 16 + c - 'A' + 10; - } else - return -1; - } - - // now byte swap the value to get it to it's original value - value = (((value & 0xFF000000) >> 24) | ((value & 0xFF0000) >> 8) | ((value & 0xFF) << 24) | ((value & 0xFF00) << 8)); - - *num = value; - return 1; -} - /* **************************************************************** * TelCom Sound Functions * diff --git a/Descent3/d3serial.cpp b/Descent3/d3serial.cpp deleted file mode 100644 index 257d9a96f..000000000 --- a/Descent3/d3serial.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/main/d3serial.cpp $ - * $Revision: 15 $ - * $Date: 5/13/99 11:18a $ - * $Author: Matt $ - * - * Functions to check the copy of the executable for expiration, registered name - * - * $Log: /DescentIII/main/d3serial.cpp $ - * - * 15 5/13/99 11:18a Matt - * Added some text. - * - * 14 4/16/99 11:59a Matt - * Took out include of io.h, because it wasn't needed. - * - * 13 4/16/99 12:39a Matt - * Took out Linux ifdef around include of io.h, since it's a system header - * file and there's no harm in including it in the Windows version. - * - * 12 4/15/99 1:38a Jeff - * changes for linux compile - * - * 11 4/14/99 2:50a Jeff - * fixed some case mismatched #includes - * - * 10 2/17/99 3:06p Matt - * Updated copyrights. - * - * 9 10/18/98 9:12p Matt - * Use new symbolic constant for the program name. - * - * 8 10/13/98 2:30p Jeff - * changed serialization msg for demo - * - * 7 10/11/98 2:58a Jeff - * fixed serialization code - * - * 6 7/13/98 12:41p Jeff - * added serial number support - * - * 5 6/08/98 3:16p Matt - * Mucked with formatting & content of serialization message. - * - * 4 6/04/98 11:32a Jeff - * Better 'warning' box for the serialization - * - * 3 2/10/98 10:43a Jeff - * fixed it so a nonregistered version will run (to make development - * easier) - * - * 2 2/07/98 6:33p Jeff - * Initial Creation (Based on D2 serialization) - * - * $NoKeywords: $ - */ - -#include -#include -#include - -#include "d3serial.h" -#include "game.h" -#include "debug.h" -#include "descent.h" -#include -#include "mono.h" -#include "cfile.h" -#include "program.h" - -#include - -#define SERIAL_NO_ERR 0 -#define SERIAL_EXPIRED 1 -#define SERIAL_BAD_CHECKSUM 2 -#define SERIAL_UNREGISTERED 3 - -static char name_copy[DESC_ID_LEN]; - -static uint32_t d3_serialnum = 100000; - -// checks the exectuable (serialization) -int SerialCheck(void) { - char name2[] = DESC_ID_TAG "0000000000000000000000000000000000000000"; - char time_str[] = DESC_DEAD_TIME_TAG "00000000"; - int i, found; - uint32_t *checksum, test_checksum; - uint32_t *serialnum; - time_t current_time, saved_time; - -#ifdef DEMO - char regstr[] = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTICE " - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" - "\nThis Descent 3 Demo %s has been specially prepared for\n" - "\n" - "\t\t%s (Serial Num: %d)\n" - "\n" - " and is the Confidential Property of Outrage Entertainment, Inc.\n" - "\n" - "\n" - "\t\tDISTRIBUTION IS PROHIBITED\n" - "\n" - "\n" - " Descent 3 is Copyright (c) 1998,1999 Outrage Entertainment, Inc.\n" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; -#else - char regstr[] = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTICE " - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" - "\nThis pre-release version of Descent 3 has been specially prepared for\n" - "\n" - "\t\t%s (Serial Num: %d)\n" - "\n" - " and is the Confidential Property of Outrage Entertainment, Inc.\n" - "\n" - "\n" - "\t\tDISTRIBUTION IS PROHIBITED\n" - "\n" - "This version of Descent 3 should be used for evaluation and testing only.\n" - "Because the game is not yet complete, items may be missing the bugs may be\n" - "encountered.\n" - "\n" - " Descent 3 is Copyright (c) 1998,1999 Outrage Entertainment, Inc.\n" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; -#endif - - // get the expiration time of the executable - char *start_time = &time_str[DESC_DEAD_TIME_TAG_LEN]; - saved_time = (time_t)strtol(start_time, NULL, 16); - if (saved_time == (time_t)0) - // this guy has never been registered with the serialization program - return SERIAL_NO_ERR; - - // adjust pointer, so it points to the registered name - char *name = name2 + DESC_ID_TAG_LEN; - - // save for later use - strcpy(name_copy, name); - - // get current date from the system - current_time = time(NULL); - - // check to see if executable has expired - if (current_time >= saved_time) { - return SERIAL_EXPIRED; - } - - // check the checksum created by the registered name - test_checksum = 0; - for (i = 0; i < (signed)strlen(name); i++) { - found = 0; - test_checksum += name[i]; - if (((test_checksum / 2) * 2) != test_checksum) - found = 1; - test_checksum = test_checksum >> 1; - if (found) - test_checksum |= 0x80000000; - } - static char desc_id_checksum_str[] = DESC_CHKSUM_TAG "0000"; // 4-byte checksum - char *checksum_ptr = desc_id_checksum_str + DESC_CHKSUM_TAG_LEN; - - // compare generated checksum with that in the executable - checksum = (uint32_t *)&(checksum_ptr[0]); - if (test_checksum != *checksum) { - return SERIAL_BAD_CHECKSUM; - } - - static char desc_id_serialnum_str[] = DESC_SERIALNUM_TAG "0000"; // 4-byte serialnum - char *serialnum_ptr = desc_id_serialnum_str + DESC_SERIALNUM_TAG_LEN; - - serialnum = (uint32_t *)&(serialnum_ptr[0]); - d3_serialnum = *serialnum; - - // this guy is ok, we can exit clean now - char buffer[400]; - -#ifdef DEMO - char ver[10]; - snprintf(ver, sizeof(ver), "Beta %d.%d.%d", D3_MAJORVER, D3_MINORVER, D3_BUILD); - snprintf(buffer, sizeof(buffer), regstr, ver, name, d3_serialnum); -#else - snprintf(buffer, sizeof(buffer), regstr, name, d3_serialnum); -#endif - - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, buffer); - - return SERIAL_NO_ERR; -} - -// displays an error box displaying what went wrong with serialization checking -void SerialError(int error) { - switch (error) { - case SERIAL_EXPIRED: { - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, "Executable has expired"); - break; - } - case SERIAL_BAD_CHECKSUM: { - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, "Bad Checksum"); - break; - } - case SERIAL_UNREGISTERED: { - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, "This is unregistered, please serialize"); - break; - } - } -} - -uint32_t SerialGetSerialNum(void) { return d3_serialnum; } diff --git a/Descent3/d3serial.h b/Descent3/d3serial.h deleted file mode 100644 index 530d336e8..000000000 --- a/Descent3/d3serial.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/main/d3serial.h $ - * $Revision: 5 $ - * $Date: 10/11/98 2:58a $ - * $Author: Jeff $ - * - * file header for serialization - * - * $Log: /DescentIII/main/d3serial.h $ - * - * 5 10/11/98 2:58a Jeff - * fixed serialization code - * - * 4 9/29/98 3:04p Jeff - * - * 3 7/13/98 12:41p Jeff - * added serial number support - * - * 2 2/07/98 6:35p Jeff - * - * $NoKeywords: $ - */ - -#ifndef __SERIALIZE_H_ -#define __SERIALIZE_H_ - -#include -#include - -#define DESC_ID_LEN 40 // how long the id string can be -#define DESC_CHECKSUM_LEN 4 // checksum is 4 bytes -#define DESC_SERIALNUM_LEN 4 // serialnum is 4 bytes -#define DESC_DEAD_TIME_LEN 8 // dead time is 8 bytes - -#define DESC_ID_TAG "Midway in our life's journey, I went astray" -#define DESC_ID_TAG_LEN 43 - -#define DESC_CHKSUM_TAG "alone in a dark wood." -#define DESC_CHKSUM_TAG_LEN 21 - -#define DESC_SERIALNUM_TAG "You've entered Lord Spam's Pleasure Dome" -#define DESC_SERIALNUM_TAG_LEN 40 - -#define DESC_DEAD_TIME_TAG "from the straight road and woke to find myself" -#define DESC_DEAD_TIME_TAG_LEN 46 - -// checks exectuable (returns !0 on error) -int SerialCheck(void); - -// given return value from SerialCheck() it reports the error -void SerialError(int error); - -// returns the serialnumber of the user -uint32_t SerialGetSerialNum(void); - -///////////////////////////////////////////////////////////////////////////// -// These are the functions used for serialization -// if this function returns: -// 1 : than it's a serialized exe, num will be given the serial num -// 0 : than it isn't a serialized exe -// -1 : detected a hacked exe -char GetInternalSerializationNumber(int *num); - -#endif diff --git a/Descent3/multi_client.cpp b/Descent3/multi_client.cpp index c44ae29cd..98f253876 100644 --- a/Descent3/multi_client.cpp +++ b/Descent3/multi_client.cpp @@ -144,7 +144,6 @@ #include "pilot.h" #include "Mission.h" #include "stringtable.h" -#include "d3serial.h" #include "ship.h" #define WEAPONS_LOAD_UPDATE_INTERVAL 2.0 @@ -193,9 +192,8 @@ void MultiSendMyInfo() { memcpy(&data[count], Players[Player_num].tracker_id, len); count += len; } - int ser = 0; - GetInternalSerializationNumber(&ser); - MultiAddInt(ser, data, &count); + // Was serial + MultiAddInt(0, data, &count); // Send packets per second int pps = nw_ReccomendPPS(); diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 12f1b0c27..be985a52c 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -26,7 +26,6 @@ set(HEADERS ../descent3/ctlconfig.h ../descent3/ctlconfigtxt.h ../descent3/D3ForceFeedback.h - ../descent3/d3serial.h ../descent3/damage.h ../descent3/damage_external.h ../descent3/DeathInfo.h @@ -313,7 +312,6 @@ set(SOURCE ../descent3/D3ForceFeedback.cpp ../Descent3/d3movie.cpp ../Descent3/d3music.cpp - ../descent3/d3serial.cpp ../descent3/damage.cpp ../descent3/debuggraph.cpp ../descent3/dedicated_server.cpp From 21576c86a5ef2aff149b3809efe76288e9190732 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 02:03:42 +0300 Subject: [PATCH 02/10] Unify Debug_Init() for all platforms --- ddebug/CMakeLists.txt | 7 +++++-- ddebug/debug.cpp | 31 +++++++++++++++++++++++++++++++ ddebug/lnxdebug.cpp | 28 ++-------------------------- ddebug/windebug.cpp | 20 -------------------- 4 files changed, 38 insertions(+), 48 deletions(-) create mode 100644 ddebug/debug.cpp diff --git a/ddebug/CMakeLists.txt b/ddebug/CMakeLists.txt index a13dbba8c..254d398ed 100644 --- a/ddebug/CMakeLists.txt +++ b/ddebug/CMakeLists.txt @@ -1,8 +1,10 @@ set(HEADERS debug.h debugbreak.h - mono.h) + mono.h +) set(CPPS + debug.cpp $<$: lnxdebug.cpp lnxmono.cpp @@ -22,8 +24,9 @@ target_include_directories(ddebug PUBLIC PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h ) target_link_libraries(ddebug PRIVATE - mem + logger $<$: + mem misc > ) diff --git a/ddebug/debug.cpp b/ddebug/debug.cpp new file mode 100644 index 000000000..1dcb12f34 --- /dev/null +++ b/ddebug/debug.cpp @@ -0,0 +1,31 @@ +/* + * Descent 3 + * Copyright (C) 2024 Descent Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "debug.h" +#include "log.h" + +bool Debug_break = false; + +bool Debug_Init(bool debugger) { +#ifndef RELEASE + Debug_break = debugger; + LOG_DEBUG_IF(Debug_break) << "Debug Break enabled."; +#endif + + return true; +} diff --git a/ddebug/lnxdebug.cpp b/ddebug/lnxdebug.cpp index 8508233c3..20afb47fb 100644 --- a/ddebug/lnxdebug.cpp +++ b/ddebug/lnxdebug.cpp @@ -41,50 +41,26 @@ #include #include "debug.h" -#include "mono.h" /////////////////////////////////////////////////////////////////////////////// -bool Debug_break = false; - -static char *Debug_DumpInfo(); - -// if we are running under a debugger, then pass true -bool Debug_Init(bool debugger) { -#ifndef RELEASE - Debug_break = debugger; - - if (Debug_break) - mprintf(0, "Debug Break enabled.\n"); - -#endif // ifndef RELEASE - - return true; -} - // Does a messagebox with a stack dump // Messagebox shows topstring, then stack dump, then bottomstring // Return types are the same as the Windows return values int Debug_ErrorBox(int type, const char *topstring, const char *title, const char *bottomstring) { int answer = 0; - char *dumptext = Debug_DumpInfo(); - fprintf(stderr, "\r\n%s(%s)\r\n\n%s\r\n\n%s\r\n", title, topstring, dumptext, bottomstring); + fprintf(stderr, "\n%s(%s)\n\n%s\n\n%s\n", title, topstring, "System Error", bottomstring); debug_break(); return answer; } -// displays an message box +// displays a message box // Returns the same values as the Win32 MessageBox() function int Debug_MessageBox(int type, const char *title, const char *str) { return Debug_ErrorBox(type, str, "Descent 3 Message", ""); } /////////////////////////////////////////////////////////////////////////////// - -char *Debug_DumpInfo() { - static char e[] = "System Error"; - return e; -} diff --git a/ddebug/windebug.cpp b/ddebug/windebug.cpp index c1e2fcefc..e5396bfe6 100644 --- a/ddebug/windebug.cpp +++ b/ddebug/windebug.cpp @@ -199,26 +199,6 @@ /////////////////////////////////////////////////////////////////////////////// -bool Debug_break = false; - -/////////////////////////////////////////////////////////////////////////////// - -bool Debug_Init(bool debugger) { - // initialization of debugging consoles. - -#ifndef RELEASE - - Debug_break = debugger; - - if (Debug_break) { - mprintf(0, "Debug Break enabled.\n"); - } - -#endif // ifndef RELEASE - - return true; -} - /* Message Box functions */ // Does a messagebox with a stack dump From c3b1225c6e232c322fec2270f4c9ee7722d0229f Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 02:10:35 +0300 Subject: [PATCH 03/10] Remove mprintf_at() usage This function is stubbed and does nothing. --- ddebug/debug.h | 1 - ddebug/lnxmono.cpp | 2 -- ddebug/mono.h | 2 -- ddebug/winmono.cpp | 2 -- ddio/sdlcontroller.cpp | 3 --- editor/MainFrm.cpp | 2 -- editor/TerrainDialog.cpp | 2 -- editor/editor_lighting.cpp | 4 ---- editor/jaytest.cpp | 1 - editor/rad_cast.cpp | 8 -------- editor/rad_hemicube.cpp | 3 --- editor/rad_init.cpp | 3 --- legacy/renderer/opengl.cpp | 5 ----- networking/networking.cpp | 2 -- ui/UISystem.cpp | 1 - 15 files changed, 41 deletions(-) diff --git a/ddebug/debug.h b/ddebug/debug.h index 921c1daf4..336fb789c 100644 --- a/ddebug/debug.h +++ b/ddebug/debug.h @@ -163,7 +163,6 @@ int Debug_MessageBox(int type, const char *title, const char *str); // these functions deal with debug spew support void Debug_ConsolePrintf(int n, const char *format, ...); -void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...); // DEBUGGING MACROS // Break into the debugger, if this feature was enabled in Debug_init() diff --git a/ddebug/lnxmono.cpp b/ddebug/lnxmono.cpp index 1ca5da657..34e6ac7a3 100644 --- a/ddebug/lnxmono.cpp +++ b/ddebug/lnxmono.cpp @@ -63,5 +63,3 @@ void Debug_ConsolePrintf(int n, const char *format, ...) { printf("%s", Mono_buffer); } } - -void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...) {} diff --git a/ddebug/mono.h b/ddebug/mono.h index 33a874332..da2bfa717 100644 --- a/ddebug/mono.h +++ b/ddebug/mono.h @@ -75,10 +75,8 @@ // Prints a formatted string to the debug window #define mprintf(...) Debug_ConsolePrintf(__VA_ARGS__) // Prints a formatted string on window n at row, col. -#define mprintf_at(...) Debug_ConsolePrintfAt(__VA_ARGS__) #else // ifdef _DEBUG // DAJ defined in target headers #define mprintf(...) -#define mprintf_at(...) #endif // ifdef _DEBUG #endif diff --git a/ddebug/winmono.cpp b/ddebug/winmono.cpp index a10179f90..4762206bc 100644 --- a/ddebug/winmono.cpp +++ b/ddebug/winmono.cpp @@ -48,6 +48,4 @@ void Debug_ConsolePrintf(int n, const char *format, ...) { } } -void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...) {} - #endif diff --git a/ddio/sdlcontroller.cpp b/ddio/sdlcontroller.cpp index f8101d120..1de28ecd3 100644 --- a/ddio/sdlcontroller.cpp +++ b/ddio/sdlcontroller.cpp @@ -1169,9 +1169,6 @@ float sdlgameController::get_axis_value(int8_t controller, uint8_t axis, ct_form m_frame_time = 0.005f; // to trap potential errors. normalizer = ctldev->normalizer[axis] * m_frame_time; nullzone = MOUSE_DEADZONE; - if (axis == CT_X_AXIS) { - // mprintf_at(4, 4, 0, "m_dX:%03d normal:%03.2f", (int)axisval, normalizer); - } } else { normalizer = ctldev->normalizer[axis]; diff --git a/editor/MainFrm.cpp b/editor/MainFrm.cpp index c12cdf38f..07bc87a09 100644 --- a/editor/MainFrm.cpp +++ b/editor/MainFrm.cpp @@ -1562,11 +1562,9 @@ void CMainFrame::OnActivateApp(BOOL bActive, HTASK hTask) { if (bActive) { theApp.resume(); - mprintf_at(2,0,0, "App Active "); } else { theApp.pause(); - mprintf_at(2,0,0, "App Inactive"); } ((oeLnxApplication *)Descent)->run_handler(this->m_hWnd, WM_ACTIVATEAPP, (unsigned)bActive, 0); diff --git a/editor/TerrainDialog.cpp b/editor/TerrainDialog.cpp index 0a6ce2d62..60385fcb8 100644 --- a/editor/TerrainDialog.cpp +++ b/editor/TerrainDialog.cpp @@ -1788,8 +1788,6 @@ void CTerrainDialog::OnTerrainOcclusion() { int end_x = dest_x * OCCLUSION_SIZE; int dest_occlusion_index = dest_z * OCCLUSION_SIZE + dest_x; - mprintf_at(2, 5, 0, "Count=%7d", count++); - if (dest_occlusion_index == src_occlusion_index) { // This is us! int occ_byte = dest_occlusion_index / 8; diff --git a/editor/editor_lighting.cpp b/editor/editor_lighting.cpp index 205cab82f..fcc706747 100644 --- a/editor/editor_lighting.cpp +++ b/editor/editor_lighting.cpp @@ -1772,7 +1772,6 @@ void DoTerrainDynamicTable() { for (j = 0; j < Terrain_sky.num_satellites; j++) { raynum++; - mprintf_at(2, 4, 0, "Ray=%d ", raynum); if (gp.y > pos.y) continue; @@ -1804,8 +1803,6 @@ void ComputeTerrainSpeedTable() { pos.y = (Terrain_seg[tseg].y) + .001; raynum++; - if ((raynum % 1000) == 0) - mprintf_at(2, 4, 0, "Ray=%d ", raynum); for (j = 0; j < Terrain_sky.num_satellites; j++) TerrainLightSpeedup[j][tseg] = ShootRayForTerrainLight(&pos, &Terrain_sky.satellite_vectors[j], tseg); @@ -2279,7 +2276,6 @@ Dynamic lighting takes a long time)","Question",MB_YESNO))==IDYES) do_dynamic=1; for (j=0;jelements[t]; - if ((raycount % 1000) == 0) { - mprintf_at(2, 4, 0, "Ray=%d ", raycount); - mprintf_at(2, 5, 0, "Ignore=%d ", Rays_ignored); - } - raycount++; if (ignore) @@ -1104,8 +1099,5 @@ void CalculateFormFactorsRaycast() { if (rad_MaxSurface->surface_type == ST_ROOM && Calculate_specular_lighting) CheckToUpdateSpecularFace(dest_surf, &Current_max_specular_color, NULL); - - // mprintf_at(2,4,0,"Ray=%d ",raycount); - // mprintf_at(2,5,0,"Ignore=%d ",Rays_ignored); } } diff --git a/editor/rad_hemicube.cpp b/editor/rad_hemicube.cpp index f7f1a35a9..97c36d2e4 100644 --- a/editor/rad_hemicube.cpp +++ b/editor/rad_hemicube.cpp @@ -361,9 +361,6 @@ void EndHemicubeDrawing(int face) { EndEditorFrame(); - mprintf_at(2, 4, 0, "CTF=%d ", Cracks_this_frame); - mprintf_at(2, 5, 0, "CTS=%d ", Cracks_this_side); - if (Show_rad_progress) { int i, t; int key; diff --git a/editor/rad_init.cpp b/editor/rad_init.cpp index 42e692681..10c510492 100644 --- a/editor/rad_init.cpp +++ b/editor/rad_init.cpp @@ -277,8 +277,6 @@ void UpdateUnsentValues() { else rad_Convergence = 0.0; - mprintf_at(2, 3, 0, "Left=%f ", rad_Convergence); - if (timer_GetTime() - last_report_time > 10.0) { mprintf(0, "Percentage left=%f\n", rad_Convergence); last_report_time = timer_GetTime(); @@ -312,7 +310,6 @@ void CalculateRadiosity() { rad_DoneCalculating = 1; break; } - mprintf_at(2, 2, 0, "Lightcount=%d ", rad_StepCount); DoRadiosityIteration(); diff --git a/legacy/renderer/opengl.cpp b/legacy/renderer/opengl.cpp index 0683a464b..19a802e10 100644 --- a/legacy/renderer/opengl.cpp +++ b/legacy/renderer/opengl.cpp @@ -1861,11 +1861,6 @@ void opengl_Flip() { RTP_INCRVALUE(texture_uploads, OpenGL_uploads); RTP_INCRVALUE(polys_drawn, OpenGL_polys_drawn); - mprintf_at(1, 1, 0, "Uploads=%d Polys=%d Verts=%d ", OpenGL_uploads, OpenGL_polys_drawn, - OpenGL_verts_processed); - mprintf_at(1, 2, 0, "Sets= 0:%d 1:%d 2:%d 3:%d ", OpenGL_sets_this_frame[0], OpenGL_sets_this_frame[1], - OpenGL_sets_this_frame[2], OpenGL_sets_this_frame[3]); - mprintf_at(1, 3, 0, "Sets= 4:%d 5:%d ", OpenGL_sets_this_frame[4], OpenGL_sets_this_frame[5]); for (i = 0; i < 10; i++) OpenGL_sets_this_frame[i] = 0; #endif diff --git a/networking/networking.cpp b/networking/networking.cpp index d9a7b5f5c..c4c41ac56 100644 --- a/networking/networking.cpp +++ b/networking/networking.cpp @@ -1427,7 +1427,6 @@ void nw_WorkReliable(uint8_t *data, int len, network_address *naddr) { qsort(sort_ping, MAX_PING_HISTORY, sizeof(float), nw_PingCompare); rsocket->mean_ping = ((sort_ping[MAX_PING_HISTORY / 2] + sort_ping[(MAX_PING_HISTORY / 2) + 1])) / 2; - // mprintf_at(2,i+1,0,"Ping: %f ",rsocket->mean_ping); } rsocket->ping_pos++; if (rsocket->ping_pos >= MAX_PING_HISTORY) { @@ -2382,7 +2381,6 @@ int nw_SendWithID(uint8_t id, uint8_t *data, int len, network_address *who_to) { int my_comp_ratio = (float) ((float)Uncompressed_outgoing_data_len/(float)Compressed_outgoing_data_len); - mprintf_at(2,1,0,"Compression: %d%% ",my_comp_ratio); */ if (!Sockets_initted) { LOG_ERROR << "Network ==> Socket not inited in nw_Send"; diff --git a/ui/UISystem.cpp b/ui/UISystem.cpp index 2bb2eda7f..7a122b951 100644 --- a/ui/UISystem.cpp +++ b/ui/UISystem.cpp @@ -480,7 +480,6 @@ void ui_DoCursor() { u0 = (float)(UI_MOUSE_HOTX - UI_input.mx) / (float)cur_w; if (UI_input.my < UI_MOUSE_HOTY) v0 = (float)(UI_MOUSE_HOTY - UI_input.my) / (float)cur_h; - // mprintf_at(1,5,30,"mx=%d my=%d ", UI_input.mx,UI_input.my); rend_DrawScaledBitmap(UI_input.mx - UI_MOUSE_HOTX, UI_input.my - UI_MOUSE_HOTY, UI_input.mx + (int)((float)cur_w * u1) - UI_MOUSE_HOTX, UI_input.my + (int)((float)cur_h * v1) - UI_MOUSE_HOTY, UI_cursor_bm, u0, v0, u1, v1); From a59503f881e5275514a6560ac5aa59dab55af621 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 03:16:07 +0300 Subject: [PATCH 04/10] Move pserror.h to ddebug module --- 2dlib/CMakeLists.txt | 5 +++-- Descent3/d3music.cpp | 1 + Descent3/lightmap_info.cpp | 7 +++---- Descent3/lightmap_info.h | 3 +-- Descent3/list.cpp | 1 + Descent3/list.h | 3 --- Descent3/object.h | 5 +++-- Descent3/procedurals.h | 4 ++-- Descent3/special_face.cpp | 9 ++++----- Descent3/special_face.h | 4 ++-- Descent3/terrainrender.cpp | 4 ---- Descent3/viseffect_external.h | 3 +-- Descent3/weather.cpp | 5 +---- bitmap/pcx.cpp | 1 - cfile/CMakeLists.txt | 1 + dd_grwin32/CMakeLists.txt | 2 +- ddebug/CMakeLists.txt | 2 ++ {misc => ddebug}/error.cpp | 0 {misc => ddebug}/pserror.h | 0 ddio/CMakeLists.txt | 1 - ddio/lnxforcefeedback.cpp | 1 - grtext/CMakeLists.txt | 5 +++-- linux/CMakeLists.txt | 2 +- linux/lnxdata.cpp | 1 - manage/CMakeLists.txt | 2 +- manage/generic.cpp | 2 -- mem/CMakeLists.txt | 2 +- misc/CMakeLists.txt | 9 ++------- model/CMakeLists.txt | 4 +++- music/CMakeLists.txt | 2 +- music/music.h | 4 ++-- music/omflex.cpp | 7 ++++--- music/streamer.cpp | 1 + networking/CMakeLists.txt | 2 +- networking/networking.cpp | 2 -- physics/CMakeLists.txt | 1 + renderer/CMakeLists.txt | 1 + renderer/HardwareDraw.cpp | 1 + renderer/HardwareInstance.cpp | 4 +++- renderer/HardwareInternal.h | 2 -- renderer/HardwareSetup.cpp | 5 ++--- renderer/HardwareTransforms.cpp | 4 ++-- renderer/dyna_gl.h | 1 - sndlib/CMakeLists.txt | 2 +- sndlib/ddsoundload.cpp | 1 - stream_audio/CMakeLists.txt | 2 +- ui/CMakeLists.txt | 5 +++-- vecmat/CMakeLists.txt | 1 + win32/CMakeLists.txt | 1 - 49 files changed, 62 insertions(+), 76 deletions(-) rename {misc => ddebug}/error.cpp (100%) rename {misc => ddebug}/pserror.h (100%) diff --git a/2dlib/CMakeLists.txt b/2dlib/CMakeLists.txt index 8577875d8..e0bf4d254 100644 --- a/2dlib/CMakeLists.txt +++ b/2dlib/CMakeLists.txt @@ -1,6 +1,7 @@ set(HEADERS gr.h - lib2d.h) + lib2d.h +) set(CPPS font.cpp hardsurf.cpp @@ -15,9 +16,9 @@ set(CPPS add_library(2dlib STATIC ${HEADERS} ${CPPS}) target_link_libraries(2dlib PRIVATE cfile + ddebug logger mem - misc ) target_include_directories(2dlib PUBLIC $ +#include #include "lightmap_info.h" #include "lightmap.h" #include "mono.h" -#include "Ddgr.h" #include "grdefs.h" +#include "pserror.h" #include "renderer.h" -#include -#include #include "mem.h" #include "dedicated_server.h" diff --git a/Descent3/lightmap_info.h b/Descent3/lightmap_info.h index 518502a24..b6b295cbf 100644 --- a/Descent3/lightmap_info.h +++ b/Descent3/lightmap_info.h @@ -39,8 +39,7 @@ #define LIGHTMAP_INFO_H // Lightmap info header -#include "pstypes.h" -#include "pserror.h" +#include #include "vecmat.h" #define BAD_LMI_INDEX 65535 diff --git a/Descent3/list.cpp b/Descent3/list.cpp index a85f3011d..dff97cd25 100644 --- a/Descent3/list.cpp +++ b/Descent3/list.cpp @@ -19,6 +19,7 @@ #include "list.h" #include "log.h" #include "mem.h" +#include "pserror.h" // Allocates space for a new list node, returning the pointer to it listnode *NewListNode(void) { diff --git a/Descent3/list.h b/Descent3/list.h index f76932a8b..57a509bb0 100644 --- a/Descent3/list.h +++ b/Descent3/list.h @@ -19,9 +19,6 @@ #ifndef LIST_H #define LIST_H -#include "pstypes.h" -#include "pserror.h" - struct listnode { void *data; struct listnode *next; diff --git a/Descent3/object.h b/Descent3/object.h index bc52ab937..9c7f27061 100644 --- a/Descent3/object.h +++ b/Descent3/object.h @@ -628,10 +628,11 @@ #ifndef _OBJECT_H #define _OBJECT_H -#include "pstypes.h" -#include "pserror.h" +#include + #include "object_external_struct.h" #include "object_external.h" +#include "pserror.h" /* * CONSTANTS diff --git a/Descent3/procedurals.h b/Descent3/procedurals.h index 62225a3b3..8f7212e88 100644 --- a/Descent3/procedurals.h +++ b/Descent3/procedurals.h @@ -19,8 +19,8 @@ #ifndef PROCEDURALS_H #define PROCEDURALS_H -#include "pstypes.h" -#include "pserror.h" +#include + #include "fix.h" #define MAX_PROC_ELEMENTS 8000 diff --git a/Descent3/special_face.cpp b/Descent3/special_face.cpp index e3117b138..4a966c6f0 100644 --- a/Descent3/special_face.cpp +++ b/Descent3/special_face.cpp @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -#include "pstypes.h" +#include +#include -#include "special_face.h" -#include "mono.h" -#include -#include #include "mem.h" +#include "pserror.h" +#include "special_face.h" int Num_of_special_faces = 0; special_face SpecialFaces[MAX_SPECIAL_FACES]; diff --git a/Descent3/special_face.h b/Descent3/special_face.h index c70f5df9b..a2332ff02 100644 --- a/Descent3/special_face.h +++ b/Descent3/special_face.h @@ -19,8 +19,8 @@ #ifndef SPECIAL_FACE_H #define SPECIAL_FACE_H -#include "pstypes.h" -#include "pserror.h" +#include + #include "vecmat.h" #define BAD_SPECIAL_FACE_INDEX -1 diff --git a/Descent3/terrainrender.cpp b/Descent3/terrainrender.cpp index b37dba3db..0fc2863c9 100644 --- a/Descent3/terrainrender.cpp +++ b/Descent3/terrainrender.cpp @@ -794,16 +794,12 @@ void RenderMine(int viewer_roomnum, int flag_automap, int called_from_terrain, b #include "terrain.h" #include "grdefs.h" #include "3d.h" -#include "pstypes.h" #include "pserror.h" #include "renderer.h" #include "gametexture.h" #include "descent.h" #include "render.h" #include "game.h" -#include "ddio.h" -#include "polymodel.h" -#include "lighting.h" #include "vecmat.h" #include "renderobject.h" #include "findintersection.h" diff --git a/Descent3/viseffect_external.h b/Descent3/viseffect_external.h index 3f8f73288..ea0bc2943 100644 --- a/Descent3/viseffect_external.h +++ b/Descent3/viseffect_external.h @@ -50,8 +50,7 @@ #ifndef __VISEFFECT_EXTERNAL_H_ #define __VISEFFECT_EXTERNAL_H_ -#include "pstypes.h" -#include "pserror.h" +#include #include "vecmat.h" #define MAX_VIS_EFFECTS 5000 diff --git a/Descent3/weather.cpp b/Descent3/weather.cpp index d00bf09ae..29fb42bba 100644 --- a/Descent3/weather.cpp +++ b/Descent3/weather.cpp @@ -17,7 +17,6 @@ */ #include "pserror.h" -#include "pstypes.h" #include "fireball.h" #include "weather.h" #include "viseffect.h" @@ -28,10 +27,8 @@ #include "soundload.h" #include "hlsoundlib.h" #include "sounds.h" - -#include - #include "psrand.h" + weather Weather = {0}; int ThunderA_sound_handle = -1; diff --git a/bitmap/pcx.cpp b/bitmap/pcx.cpp index 5e84e7747..9a365da3a 100644 --- a/bitmap/pcx.cpp +++ b/bitmap/pcx.cpp @@ -61,7 +61,6 @@ #include "grdefs.h" #include "log.h" #include "mem.h" -#include "pserror.h" // load an 8bit pcx image static int bm_pcx_8bit_alloc_file(CFILE *infile); diff --git a/cfile/CMakeLists.txt b/cfile/CMakeLists.txt index 2deebbdcb..8ce507985 100644 --- a/cfile/CMakeLists.txt +++ b/cfile/CMakeLists.txt @@ -10,6 +10,7 @@ set(CPPS add_library(cfile STATIC ${HEADERS} ${CPPS}) target_link_libraries(cfile PRIVATE + ddebug ddio logger mem diff --git a/dd_grwin32/CMakeLists.txt b/dd_grwin32/CMakeLists.txt index 5f5240351..8ee75fb4b 100644 --- a/dd_grwin32/CMakeLists.txt +++ b/dd_grwin32/CMakeLists.txt @@ -11,8 +11,8 @@ set(CPPS add_library(dd_grwin32 STATIC ${HEADERS} ${CPPS}) target_link_libraries(dd_grwin32 PRIVATE 2dlib + ddebug logger - misc ) target_compile_definitions(dd_grwin32 PRIVATE DX_APP) target_link_libraries(dd_grwin32 PRIVATE ${DDRAW_LIBRARY}) diff --git a/ddebug/CMakeLists.txt b/ddebug/CMakeLists.txt index 254d398ed..c4dc53af0 100644 --- a/ddebug/CMakeLists.txt +++ b/ddebug/CMakeLists.txt @@ -2,9 +2,11 @@ set(HEADERS debug.h debugbreak.h mono.h + pserror.h ) set(CPPS debug.cpp + error.cpp $<$: lnxdebug.cpp lnxmono.cpp diff --git a/misc/error.cpp b/ddebug/error.cpp similarity index 100% rename from misc/error.cpp rename to ddebug/error.cpp diff --git a/misc/pserror.h b/ddebug/pserror.h similarity index 100% rename from misc/pserror.h rename to ddebug/pserror.h diff --git a/ddio/CMakeLists.txt b/ddio/CMakeLists.txt index 7c326b508..b2f7d4468 100644 --- a/ddio/CMakeLists.txt +++ b/ddio/CMakeLists.txt @@ -32,7 +32,6 @@ target_link_libraries(ddio PRIVATE ddebug logger mem - misc ) target_include_directories(ddio PUBLIC $ -#include "pstring.h" #include "forcefeedback.h" bool ddForce_found; // a Force Feedback device was found diff --git a/grtext/CMakeLists.txt b/grtext/CMakeLists.txt index c7e35ea49..32982864b 100644 --- a/grtext/CMakeLists.txt +++ b/grtext/CMakeLists.txt @@ -1,6 +1,7 @@ set(HEADERS grtext.h - grtextlib.h) + grtextlib.h +) set(CPPS grfont.cpp grtext.cpp @@ -9,10 +10,10 @@ set(CPPS add_library(grtext STATIC ${HEADERS} ${CPPS}) target_link_libraries(grtext PRIVATE + ddebug ddio logger mem - misc ) target_include_directories(grtext PUBLIC $ ) target_link_libraries(linux PRIVATE + ddebug ddio - misc SDL2::SDL2 ) diff --git a/linux/lnxdata.cpp b/linux/lnxdata.cpp index 24151b0c8..63ca79a0c 100644 --- a/linux/lnxdata.cpp +++ b/linux/lnxdata.cpp @@ -57,7 +57,6 @@ #include "appdatabase.h" #include "linux/lnxdatabase.h" -#include "pserror.h" #include "log.h" #include "pserror.h" #include "registry.h" diff --git a/manage/CMakeLists.txt b/manage/CMakeLists.txt index 262309fac..77cb7e325 100644 --- a/manage/CMakeLists.txt +++ b/manage/CMakeLists.txt @@ -24,10 +24,10 @@ set(CPPS add_library(manage STATIC ${HEADERS} ${CPPS}) target_link_libraries(manage PRIVATE cfile + ddebug ddio logger mem - misc model sndlib stream_audio diff --git a/manage/generic.cpp b/manage/generic.cpp index afed50c54..dd306d88e 100644 --- a/manage/generic.cpp +++ b/manage/generic.cpp @@ -363,8 +363,6 @@ #include "log.h" #include "pserror.h" #include "polymodel.h" -#include "ddio.h" -#include "robotfire.h" #include "weapon.h" #include "sounds.h" #include "mem.h" diff --git a/mem/CMakeLists.txt b/mem/CMakeLists.txt index 7e72ae847..65f710c70 100644 --- a/mem/CMakeLists.txt +++ b/mem/CMakeLists.txt @@ -6,8 +6,8 @@ target_compile_definitions(mem PUBLIC $<$:MEM_USE_RTL> ) target_link_libraries(mem PRIVATE + ddebug logger - misc ) target_include_directories(mem PUBLIC $ + #include "psclass.h" #include "streamaudio.h" diff --git a/music/omflex.cpp b/music/omflex.cpp index 4ce78f66f..9642681d8 100644 --- a/music/omflex.cpp +++ b/music/omflex.cpp @@ -71,14 +71,15 @@ * $NoKeywords: $ */ +#include +#include + #include "log.h" #include "music.h" #include "musiclib.h" #include "inffile.h" #include "mem.h" - -#include -#include +#include "pserror.h" // OMF INF FILE READ #define OMFFILEERR_ADDSECTION INFFILE_CUSTOM // error adding section to list. diff --git a/music/streamer.cpp b/music/streamer.cpp index d694d1633..2cdc3a8f2 100644 --- a/music/streamer.cpp +++ b/music/streamer.cpp @@ -63,6 +63,7 @@ #include "log.h" #include "music.h" #include "streamaudio.h" +#include "pserror.h" oms_stream::oms_stream() {} diff --git a/networking/CMakeLists.txt b/networking/CMakeLists.txt index 0f9d5802c..34b26c08e 100644 --- a/networking/CMakeLists.txt +++ b/networking/CMakeLists.txt @@ -12,10 +12,10 @@ endif() add_library(networking STATIC ${HEADERS} ${CPPS}) target_link_libraries(networking PRIVATE + ddebug ddio logger mem - misc module ${PLATFORM_LIBS} ) diff --git a/networking/networking.cpp b/networking/networking.cpp index c4c41ac56..4cf7fdd09 100644 --- a/networking/networking.cpp +++ b/networking/networking.cpp @@ -323,11 +323,9 @@ typedef int socklen_t; #include "networking.h" #include "ddio.h" #include "mem.h" -#include "module.h" #include "game.h" #include "args.h" #include "byteswap.h" -#include "pstring.h" #ifndef WIN32 bool Use_DirectPlay = false; diff --git a/physics/CMakeLists.txt b/physics/CMakeLists.txt index 729322e87..e0d68c69f 100644 --- a/physics/CMakeLists.txt +++ b/physics/CMakeLists.txt @@ -11,6 +11,7 @@ set(CPPS add_library(physics STATIC ${HEADERS} ${CPPS}) target_link_libraries(physics PRIVATE + ddebug ddio logger mem diff --git a/renderer/CMakeLists.txt b/renderer/CMakeLists.txt index 2d2dc9549..51faa986a 100644 --- a/renderer/CMakeLists.txt +++ b/renderer/CMakeLists.txt @@ -36,6 +36,7 @@ target_link_libraries(renderer PRIVATE glm::glm SDL2::SDL2 bitmap + ddebug ddio logger mem diff --git a/renderer/HardwareDraw.cpp b/renderer/HardwareDraw.cpp index 4daa329d3..71a23f1a6 100644 --- a/renderer/HardwareDraw.cpp +++ b/renderer/HardwareDraw.cpp @@ -18,6 +18,7 @@ #include "3d.h" #include "HardwareInternal.h" +#include "pserror.h" #include "renderer.h" #define round(v) ((int)(((v) + 0.5f))) diff --git a/renderer/HardwareInstance.cpp b/renderer/HardwareInstance.cpp index 487a184f1..c6cb12c48 100644 --- a/renderer/HardwareInstance.cpp +++ b/renderer/HardwareInstance.cpp @@ -16,9 +16,11 @@ * along with this program. If not, see . */ +#include + #include "3d.h" #include "HardwareInternal.h" -#include +#include "pserror.h" struct InstanceContext { matrix m_viewMatrix; // matrix diff --git a/renderer/HardwareInternal.h b/renderer/HardwareInternal.h index 791f48855..78c1ebb07 100644 --- a/renderer/HardwareInternal.h +++ b/renderer/HardwareInternal.h @@ -19,8 +19,6 @@ #ifndef __HARDWARE_INTERNAL_H__ #define __HARDWARE_INTERNAL_H__ -#include "pserror.h" - #define MAX_POINTS_IN_POLY 100 // These structs are for drawing with vertex arrays diff --git a/renderer/HardwareSetup.cpp b/renderer/HardwareSetup.cpp index da1bcf64d..8bee1d512 100644 --- a/renderer/HardwareSetup.cpp +++ b/renderer/HardwareSetup.cpp @@ -16,10 +16,9 @@ * along with this program. If not, see . */ -#include -#include +#include + #include "3d.h" -#include "pserror.h" #include "HardwareInternal.h" #include "renderer.h" diff --git a/renderer/HardwareTransforms.cpp b/renderer/HardwareTransforms.cpp index ed030154b..f013cb561 100644 --- a/renderer/HardwareTransforms.cpp +++ b/renderer/HardwareTransforms.cpp @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +#include + #include "3d.h" -#include "pserror.h" #include "HardwareInternal.h" #include "renderer.h" -#include // Whether or not to use T&L transforms or the pass-thru ones static int sUseTransformPassthru = -1; diff --git a/renderer/dyna_gl.h b/renderer/dyna_gl.h index 8dc74fb9f..3c435f06d 100644 --- a/renderer/dyna_gl.h +++ b/renderer/dyna_gl.h @@ -30,7 +30,6 @@ #include "descent.h" #include "log.h" #include "module.h" -#include "pserror.h" #if defined(WIN32) #define GLFUNCCALL __stdcall diff --git a/sndlib/CMakeLists.txt b/sndlib/CMakeLists.txt index 779a43183..4d79d5e5f 100644 --- a/sndlib/CMakeLists.txt +++ b/sndlib/CMakeLists.txt @@ -20,10 +20,10 @@ set(CPPS add_library(sndlib STATIC ${HEADERS} ${CPPS}) target_link_libraries(sndlib PRIVATE cfile + ddebug ddio logger mem - misc stream_audio physics SDL2::SDL2 diff --git a/sndlib/ddsoundload.cpp b/sndlib/ddsoundload.cpp index 20ab48662..800ae19ba 100644 --- a/sndlib/ddsoundload.cpp +++ b/sndlib/ddsoundload.cpp @@ -92,7 +92,6 @@ #include "ssl_lib.h" #include "cfile.h" #include "mem.h" -#include "pserror.h" #include "byteswap.h" #include "gamesequence.h" #include "log.h" diff --git a/stream_audio/CMakeLists.txt b/stream_audio/CMakeLists.txt index c1793be59..83f8e3837 100644 --- a/stream_audio/CMakeLists.txt +++ b/stream_audio/CMakeLists.txt @@ -7,10 +7,10 @@ set(CPPS add_library(stream_audio STATIC ${HEADERS} ${CPPS}) target_link_libraries(stream_audio PRIVATE + ddebug ddio logger mem - misc sndlib ) target_link_libraries(stream_audio PUBLIC diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index a11de00b5..5dcbbf7ae 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -3,7 +3,8 @@ set(HEADERS ui.h uidraw.h uires.h - uisys.h) + uisys.h +) set(CPPS UIButton.cpp UICombo.cpp @@ -24,11 +25,11 @@ set(CPPS add_library(ui STATIC ${HEADERS} ${CPPS}) target_link_libraries(ui PRIVATE + ddebug ddio grtext logger mem - misc ) target_include_directories(ui PUBLIC $ Date: Mon, 23 Sep 2024 04:16:34 +0300 Subject: [PATCH 05/10] Avoid using ASSERT in interface headers --- Descent3/AIGoal.cpp | 1 + Descent3/ConfigItem.cpp | 2 +- Descent3/CtlCfgElem.cpp | 6 +++--- Descent3/GameLoop.cpp | 1 + Descent3/NewPyroGauges.cpp | 9 +-------- Descent3/PilotPicsAPI.cpp | 2 +- Descent3/TelCom.cpp | 1 + Descent3/TelComEffects.cpp | 1 + Descent3/TelcomEffectsRender.cpp | 1 + Descent3/WeaponFire.cpp | 1 + Descent3/aiterrain.cpp | 7 ++++--- Descent3/ambient.cpp | 1 + Descent3/attach.cpp | 1 + Descent3/bnode.cpp | 2 +- Descent3/bsp.cpp | 1 + Descent3/cockpit.cpp | 1 + Descent3/config.cpp | 1 + Descent3/credits.cpp | 1 + Descent3/ctlconfig.cpp | 1 + Descent3/damage.cpp | 1 + Descent3/demofile.cpp | 1 + Descent3/game.h | 1 - Descent3/gameevent.cpp | 1 + Descent3/gamesave.cpp | 1 + Descent3/gauges.cpp | 1 + Descent3/hotspotmap.cpp | 1 + Descent3/hud.cpp | 1 + Descent3/hudmessage.cpp | 1 + Descent3/levelgoal.cpp | 1 + Descent3/lighting.cpp | 1 + Descent3/loadstate.cpp | 1 + Descent3/localization.cpp | 1 + Descent3/marker.cpp | 1 + Descent3/matcen.cpp | 1 + Descent3/mission_download.cpp | 1 + Descent3/mmItem.cpp | 7 +++---- Descent3/multi_client.cpp | 1 + Descent3/multi_connect.cpp | 1 + Descent3/multi_server.cpp | 1 + Descent3/multi_ui.cpp | 1 + Descent3/multisafe.cpp | 1 + Descent3/newui.cpp | 2 +- Descent3/newui_filedlg.cpp | 1 + Descent3/object.cpp | 18 ++++++++++++++++++ Descent3/object.h | 20 +------------------- Descent3/object_lighting.cpp | 1 + Descent3/pilot.cpp | 1 + Descent3/postrender.cpp | 2 +- Descent3/render.cpp | 4 ++-- Descent3/renderobject.cpp | 1 + Descent3/robotfire.cpp | 1 + Descent3/room.cpp | 1 + Descent3/screens.cpp | 1 + Descent3/splinter.cpp | 7 ++----- Descent3/terrain.cpp | 11 +++++++++++ Descent3/terrain.h | 9 +-------- Descent3/viseffect.cpp | 1 + ddebug/CMakeLists.txt | 3 ++- netgames/includes/DMFC.h | 12 ++++++++---- networking/networking.cpp | 1 + physics/physics.cpp | 1 + sndlib/sndrender.cpp | 2 +- ui/UIButton.cpp | 12 ++++++++++++ ui/UIConsole.cpp | 1 + ui/UIEdit.cpp | 2 +- ui/UIGadget.cpp | 1 + ui/UIGroup.cpp | 1 + ui/UIHotspot.cpp | 1 + ui/UIListBox.cpp | 1 + ui/UIObject.cpp | 1 + ui/UISlider.cpp | 1 + ui/UISystem.cpp | 1 + ui/UIWindow.cpp | 1 + ui/ui.h | 11 ++--------- vecmat/vector.cpp | 17 ++++++++--------- 75 files changed, 137 insertions(+), 83 deletions(-) diff --git a/Descent3/AIGoal.cpp b/Descent3/AIGoal.cpp index 103525ee9..22858d65a 100644 --- a/Descent3/AIGoal.cpp +++ b/Descent3/AIGoal.cpp @@ -475,6 +475,7 @@ #include "objinfo.h" #include "AIMain.h" #include "room.h" +#include "pserror.h" #include "psrand.h" #include "BOA.h" #include "findintersection.h" diff --git a/Descent3/ConfigItem.cpp b/Descent3/ConfigItem.cpp index 19fc5c40b..cd7a481a5 100644 --- a/Descent3/ConfigItem.cpp +++ b/Descent3/ConfigItem.cpp @@ -92,10 +92,10 @@ #include "ConfigItem.h" #include "newui.h" -#include "descent.h" #include "log.h" #include "gamefont.h" #include "mem.h" +#include "pserror.h" #include "stringtable.h" #define UI_CHECKBOX_OFF_CHAR 28 diff --git a/Descent3/CtlCfgElem.cpp b/Descent3/CtlCfgElem.cpp index 1a69f607e..3d9885720 100644 --- a/Descent3/CtlCfgElem.cpp +++ b/Descent3/CtlCfgElem.cpp @@ -113,18 +113,18 @@ * $NoKeywords: $ */ +#include + #include "CtlCfgElem.h" #include "descent.h" #include "Macros.h" #include "ddio.h" -#include "application.h" #include "renderer.h" #include "stringtable.h" #include "gamefont.h" #include "localization.h" - -#include +#include "pserror.h" #include "joystick.h" // all controller binding texts diff --git a/Descent3/GameLoop.cpp b/Descent3/GameLoop.cpp index c7d57ce10..cb6deb695 100644 --- a/Descent3/GameLoop.cpp +++ b/Descent3/GameLoop.cpp @@ -861,6 +861,7 @@ #include "gamefont.h" #include "renderobject.h" #include "buddymenu.h" +#include "pserror.h" #ifdef EDITOR #include "editor\d3edit.h" diff --git a/Descent3/NewPyroGauges.cpp b/Descent3/NewPyroGauges.cpp index 5a8d4e512..8ddc2cb6e 100644 --- a/Descent3/NewPyroGauges.cpp +++ b/Descent3/NewPyroGauges.cpp @@ -61,15 +61,8 @@ */ #include "NewPyroGauges.h" -#include "gauges.h" -#include "gamefont.h" -#include "game.h" -#include "hud.h" -#include "grdefs.h" -#include "bitmap.h" -#include "player.h" -#include "polymodel.h" #include "3d.h" +#include "pserror.h" #include "renderer.h" #include "gametexture.h" diff --git a/Descent3/PilotPicsAPI.cpp b/Descent3/PilotPicsAPI.cpp index 7d8de7cca..cd53c3c37 100644 --- a/Descent3/PilotPicsAPI.cpp +++ b/Descent3/PilotPicsAPI.cpp @@ -63,13 +63,13 @@ #include #include "bitmap.h" -#include "player.h" #include "pilot.h" #include "cfile.h" #include "log.h" #include "ddio.h" #include "manage.h" #include "PilotPicsAPI.h" +#include "pserror.h" #include "mem.h" #define PILOTPIC_DATABASE_HOG "PPics.Hog" diff --git a/Descent3/TelCom.cpp b/Descent3/TelCom.cpp index 554f2f63b..3eb970cdb 100644 --- a/Descent3/TelCom.cpp +++ b/Descent3/TelCom.cpp @@ -519,6 +519,7 @@ #include "hlsoundlib.h" #include "soundload.h" #include "textaux.h" +#include "pserror.h" #include "psrand.h" #include "controls.h" #include "d3music.h" diff --git a/Descent3/TelComEffects.cpp b/Descent3/TelComEffects.cpp index efccb0a73..4483de2bf 100644 --- a/Descent3/TelComEffects.cpp +++ b/Descent3/TelComEffects.cpp @@ -143,6 +143,7 @@ #include "vecmat.h" #include "textaux.h" #include "hlsoundlib.h" +#include "pserror.h" #include "soundload.h" tceffect TCEffects[MAX_TCEFFECTS]; diff --git a/Descent3/TelcomEffectsRender.cpp b/Descent3/TelcomEffectsRender.cpp index 9c2a269af..b11654a6f 100644 --- a/Descent3/TelcomEffectsRender.cpp +++ b/Descent3/TelcomEffectsRender.cpp @@ -56,6 +56,7 @@ #include "hlsoundlib.h" #include "log.h" #include "mem.h" +#include "pserror.h" #include "textaux.h" int glitch_dx = 0, glitch_dy = 0; diff --git a/Descent3/WeaponFire.cpp b/Descent3/WeaponFire.cpp index d544d8d5e..936867a42 100644 --- a/Descent3/WeaponFire.cpp +++ b/Descent3/WeaponFire.cpp @@ -936,6 +936,7 @@ #include "config.h" #include "ObjScript.h" #include "doorway.h" +#include "pserror.h" #include "psrand.h" #include "BOA.h" diff --git a/Descent3/aiterrain.cpp b/Descent3/aiterrain.cpp index f09870ea8..e31ed340d 100644 --- a/Descent3/aiterrain.cpp +++ b/Descent3/aiterrain.cpp @@ -48,12 +48,13 @@ * $NoKeywords: $ */ +#include "cstdint" +#include + #include "vecmat.h" #include "terrain.h" -#include "pstypes.h" -#include "findintersection.h" +#include "pserror.h" #include "aiterrain.h" -#include #define AI_MAX_SEGS_CHECKED 200 diff --git a/Descent3/ambient.cpp b/Descent3/ambient.cpp index ade9f295f..fe8dbcc0a 100644 --- a/Descent3/ambient.cpp +++ b/Descent3/ambient.cpp @@ -82,6 +82,7 @@ #include "room.h" #include "game.h" +#include "pserror.h" #include "psrand.h" #define MAX_AMBIENT_SOUND_PATTERNS 100 diff --git a/Descent3/attach.cpp b/Descent3/attach.cpp index eb7ea8f9d..0cc9e6a4c 100644 --- a/Descent3/attach.cpp +++ b/Descent3/attach.cpp @@ -24,6 +24,7 @@ #include "demofile.h" #include "polymodel.h" #include "objinfo.h" +#include "pserror.h" /* // Determines the necessary orientation and position of the moving object f_use_uvec = true; diff --git a/Descent3/bnode.cpp b/Descent3/bnode.cpp index f3e577ed0..1e9ad7d89 100644 --- a/Descent3/bnode.cpp +++ b/Descent3/bnode.cpp @@ -104,9 +104,9 @@ #include "mem.h" #include "vecmat.h" #include "terrain.h" -#include "room.h" #include "findintersection.h" #include "BOA.h" +#include "pserror.h" #include "psrand.h" bn_list BNode_terrain_list[8]; diff --git a/Descent3/bsp.cpp b/Descent3/bsp.cpp index 86fa96193..8cf81c3a1 100644 --- a/Descent3/bsp.cpp +++ b/Descent3/bsp.cpp @@ -52,6 +52,7 @@ #include "mem.h" #include "polymodel.h" #include "object.h" +#include "pserror.h" #include "psrand.h" #define BSP_TREE_VERSION 10003 diff --git a/Descent3/cockpit.cpp b/Descent3/cockpit.cpp index 65c2f416b..617e917a5 100644 --- a/Descent3/cockpit.cpp +++ b/Descent3/cockpit.cpp @@ -200,6 +200,7 @@ #include "log.h" #include "ship.h" #include "player.h" +#include "pserror.h" #include "room.h" #include "hlsoundlib.h" #include "sounds.h" diff --git a/Descent3/config.cpp b/Descent3/config.cpp index 8d69d7096..4a053eec7 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -291,6 +291,7 @@ #include "terrain.h" #include "physics.h" #include "pilot.h" +#include "pserror.h" #include "hud.h" #include "bitmap.h" #include "game.h" diff --git a/Descent3/credits.cpp b/Descent3/credits.cpp index 94a6efe21..584010def 100644 --- a/Descent3/credits.cpp +++ b/Descent3/credits.cpp @@ -92,6 +92,7 @@ #include "mem.h" #include "d3music.h" #include "hlsoundlib.h" +#include "pserror.h" #include "psrand.h" /* diff --git a/Descent3/ctlconfig.cpp b/Descent3/ctlconfig.cpp index 0338d0f6d..2fdddfb49 100644 --- a/Descent3/ctlconfig.cpp +++ b/Descent3/ctlconfig.cpp @@ -292,6 +292,7 @@ #include "D3ForceFeedback.h" #include "hlsoundlib.h" #include "ddio.h" +#include "pserror.h" ////////////////////////////////////////////////////////////////////////////// #define IDV_KCONFIG 10 diff --git a/Descent3/damage.cpp b/Descent3/damage.cpp index 76af8c9b5..7589de34f 100644 --- a/Descent3/damage.cpp +++ b/Descent3/damage.cpp @@ -586,6 +586,7 @@ #include "DeathInfo.h" #include "AIGoal.h" #include "viseffect.h" +#include "pserror.h" #include "psrand.h" diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index 2942c208e..2021f110e 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -294,6 +294,7 @@ #include "osiris_dll.h" #include "args.h" #include "gamecinematics.h" +#include "pserror.h" #include "psrand.h" #include "cockpit.h" // We borrow a lot of code from the savegame system diff --git a/Descent3/game.h b/Descent3/game.h index 3dce2becd..659bed415 100644 --- a/Descent3/game.h +++ b/Descent3/game.h @@ -183,7 +183,6 @@ #ifndef _GAME_H #define _GAME_H -#include "pserror.h" #include "renderer.h" #include "object.h" diff --git a/Descent3/gameevent.cpp b/Descent3/gameevent.cpp index db5c1491e..143d9cd6f 100644 --- a/Descent3/gameevent.cpp +++ b/Descent3/gameevent.cpp @@ -73,6 +73,7 @@ #include "spew.h" #include "mem.h" #include "player.h" +#include "pserror.h" int Num_events = 0; game_event GameEvent[MAX_EVENTS]; diff --git a/Descent3/gamesave.cpp b/Descent3/gamesave.cpp index 7209d2925..4f5c43641 100644 --- a/Descent3/gamesave.cpp +++ b/Descent3/gamesave.cpp @@ -296,6 +296,7 @@ #include "matcen.h" #include "marker.h" #include "d3music.h" +#include "pserror.h" #include "weather.h" // function prototypes. diff --git a/Descent3/gauges.cpp b/Descent3/gauges.cpp index 7abd32295..35f6dc3eb 100644 --- a/Descent3/gauges.cpp +++ b/Descent3/gauges.cpp @@ -200,6 +200,7 @@ #include "ship.h" #include "3d.h" #include "weapon.h" +#include "pserror.h" #include "stringtable.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/Descent3/hotspotmap.cpp b/Descent3/hotspotmap.cpp index edb1b4081..8f605a40e 100644 --- a/Descent3/hotspotmap.cpp +++ b/Descent3/hotspotmap.cpp @@ -110,6 +110,7 @@ #include "mem.h" #include "bitmap.h" #include "manage.h" +#include "pserror.h" static void makecorner(int corner_bmp, int back_bmp, const char *tmap, int l, int t, int r, int b); static int CreateHotSpotMap(const char *map, int width, int height, hotspotmap_t *hsmap); diff --git a/Descent3/hud.cpp b/Descent3/hud.cpp index fc47e9ba2..13c780908 100644 --- a/Descent3/hud.cpp +++ b/Descent3/hud.cpp @@ -431,6 +431,7 @@ #include "d3music.h" #include "demofile.h" #include "stringtable.h" +#include "pserror.h" #include "pstring.h" #include "config.h" #include "gamecinematics.h" diff --git a/Descent3/hudmessage.cpp b/Descent3/hudmessage.cpp index fd2648eaa..d5f83b6b5 100644 --- a/Descent3/hudmessage.cpp +++ b/Descent3/hudmessage.cpp @@ -350,6 +350,7 @@ #include "sounds.h" #include "hlsoundlib.h" #include "args.h" +#include "pserror.h" #define HUD_MESSAGE_NORMAL 0 #define HUD_MESSAGE_BLINKING 1 diff --git a/Descent3/levelgoal.cpp b/Descent3/levelgoal.cpp index 80e6f3f4d..4b157b1cc 100644 --- a/Descent3/levelgoal.cpp +++ b/Descent3/levelgoal.cpp @@ -175,6 +175,7 @@ #include "osiris_share.h" #include "multisafe.h" #include "multi_world_state.h" +#include "pserror.h" #define GOAL_MESSAGE_TIME 10.0 #define GOAL_MESSAGE_COLOR GR_RGB(0, 242, 148) diff --git a/Descent3/lighting.cpp b/Descent3/lighting.cpp index 1fb9614dc..1a128b771 100644 --- a/Descent3/lighting.cpp +++ b/Descent3/lighting.cpp @@ -43,6 +43,7 @@ #include "config.h" #include "dedicated_server.h" #include "objinfo.h" +#include "pserror.h" #define NUM_DYNAMIC_CLASSES 7 #define MAX_DYNAMIC_FACES 2000 diff --git a/Descent3/loadstate.cpp b/Descent3/loadstate.cpp index 5fe61a399..c64e4014e 100644 --- a/Descent3/loadstate.cpp +++ b/Descent3/loadstate.cpp @@ -217,6 +217,7 @@ #include "weather.h" #include "cockpit.h" #include "hud.h" +#include "pserror.h" extern void PageInAllData(); diff --git a/Descent3/localization.cpp b/Descent3/localization.cpp index 1e89a2b53..1ef046549 100644 --- a/Descent3/localization.cpp +++ b/Descent3/localization.cpp @@ -96,6 +96,7 @@ #include "localization.h" #include "log.h" #include "mem.h" +#include "pserror.h" struct tLangTag { const char *tag; diff --git a/Descent3/marker.cpp b/Descent3/marker.cpp index 40fac4aad..0d7294a6f 100644 --- a/Descent3/marker.cpp +++ b/Descent3/marker.cpp @@ -23,6 +23,7 @@ #include "player.h" #include "multi.h" #include "game.h" +#include "pserror.h" #ifdef _DEBUG #include "AIMain.h" #endif diff --git a/Descent3/matcen.cpp b/Descent3/matcen.cpp index b6742f210..24b6ae784 100644 --- a/Descent3/matcen.cpp +++ b/Descent3/matcen.cpp @@ -175,6 +175,7 @@ #include "ObjScript.h" #include "psrand.h" #include "demofile.h" +#include "pserror.h" // Beginning of the real file #define LEVEL_DATA_MATCEN_VERSION 1 diff --git a/Descent3/mission_download.cpp b/Descent3/mission_download.cpp index 5df68603e..3b5293932 100644 --- a/Descent3/mission_download.cpp +++ b/Descent3/mission_download.cpp @@ -135,6 +135,7 @@ #include "grtext.h" #include "Mission.h" #include "mission_download.h" +#include "pserror.h" #include "renderer.h" #include "unzip.h" diff --git a/Descent3/mmItem.cpp b/Descent3/mmItem.cpp index e5a692ef6..2abb3655f 100644 --- a/Descent3/mmItem.cpp +++ b/Descent3/mmItem.cpp @@ -109,6 +109,8 @@ * */ +#include + #include "mmItem.h" #include "game.h" #include "program.h" @@ -117,12 +119,9 @@ #include "hlsoundlib.h" #include "soundload.h" #include "d3music.h" - #include "ddio.h" -// #include #include "mem.h" - -#include +#include "pserror.h" // externed from newui.cpp extern int UI_frame_result; diff --git a/Descent3/multi_client.cpp b/Descent3/multi_client.cpp index 98f253876..37771bdeb 100644 --- a/Descent3/multi_client.cpp +++ b/Descent3/multi_client.cpp @@ -142,6 +142,7 @@ #include "player.h" #include "ddio.h" #include "pilot.h" +#include "pserror.h" #include "Mission.h" #include "stringtable.h" #include "ship.h" diff --git a/Descent3/multi_connect.cpp b/Descent3/multi_connect.cpp index a7af5b5a7..388a3ac53 100644 --- a/Descent3/multi_connect.cpp +++ b/Descent3/multi_connect.cpp @@ -263,6 +263,7 @@ #include "Mission.h" #include "stringtable.h" #include "pilot.h" +#include "pserror.h" #include "ship.h" #include "args.h" #include "ui.h" diff --git a/Descent3/multi_server.cpp b/Descent3/multi_server.cpp index ed5ae8b24..ddbabf158 100644 --- a/Descent3/multi_server.cpp +++ b/Descent3/multi_server.cpp @@ -639,6 +639,7 @@ #include "LoadLevel.h" #include "Mission.h" #include "game2dll.h" +#include "pserror.h" #include "stringtable.h" // #define USE_DIRECTPLAY diff --git a/Descent3/multi_ui.cpp b/Descent3/multi_ui.cpp index facde1fbe..cda686d64 100644 --- a/Descent3/multi_ui.cpp +++ b/Descent3/multi_ui.cpp @@ -331,6 +331,7 @@ #include "manage.h" #include "menu.h" #include "pilot.h" +#include "pserror.h" #include "ddio.h" #include "objinfo.h" #include "ship.h" diff --git a/Descent3/multisafe.cpp b/Descent3/multisafe.cpp index 5df2ca62b..4f3a9e5ef 100644 --- a/Descent3/multisafe.cpp +++ b/Descent3/multisafe.cpp @@ -657,6 +657,7 @@ #include "sounds.h" #include "ship.h" #include "player.h" +#include "pserror.h" #include "object_lighting.h" #include "soundload.h" #include "streamaudio.h" diff --git a/Descent3/newui.cpp b/Descent3/newui.cpp index 1edf1e191..d5c3a1507 100644 --- a/Descent3/newui.cpp +++ b/Descent3/newui.cpp @@ -304,7 +304,6 @@ #include "log.h" #include "newui.h" #include "game.h" -#include "descent.h" #include "renderer.h" #include "3d.h" #include "gamefont.h" @@ -314,6 +313,7 @@ #include "newui_core.h" #include "hlsoundlib.h" #include "dedicated_server.h" +#include "pserror.h" #define MSGBOX_HEIGHT msgbox.H() #define BTN_WIDTH 96 diff --git a/Descent3/newui_filedlg.cpp b/Descent3/newui_filedlg.cpp index 0c831afa4..15409fe62 100644 --- a/Descent3/newui_filedlg.cpp +++ b/Descent3/newui_filedlg.cpp @@ -109,6 +109,7 @@ #include "game.h" #include "log.h" #include "newui.h" +#include "pserror.h" #include "pstring.h" #include "renderer.h" #include "stringtable.h" diff --git a/Descent3/object.cpp b/Descent3/object.cpp index 74846ed75..8701fd2a8 100644 --- a/Descent3/object.cpp +++ b/Descent3/object.cpp @@ -3327,6 +3327,24 @@ bool ObjGetAnimUpdate(uint16_t objnum, custom_anim *multi_anim_info) { return false; } +void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove, bool play_sound_on_clients) { + int objnum = OBJNUM(obj); + ASSERT(objnum != -1); + ASSERT(objnum != 0); + ASSERT(obj->type != OBJ_NONE); + ASSERT(obj != Player_object); + + obj->flags |= OF_DEAD; + + if (tell_clients_to_remove) { + if (play_sound_on_clients) { + obj->flags |= OF_SEND_MULTI_REMOVE_ON_DEATHWS; + } else { + obj->flags |= OF_SEND_MULTI_REMOVE_ON_DEATH; + } + } +} + void SetObjectControlType(object *obj, int control_type) { ASSERT(obj); ASSERT(OBJNUM(obj) >= 0 && OBJNUM(obj) < MAX_OBJECTS); diff --git a/Descent3/object.h b/Descent3/object.h index 9c7f27061..eac08df16 100644 --- a/Descent3/object.h +++ b/Descent3/object.h @@ -632,7 +632,6 @@ #include "object_external_struct.h" #include "object_external.h" -#include "pserror.h" /* * CONSTANTS @@ -706,24 +705,7 @@ extern int16_t BigObjectList[MAX_BIG_OBJECTS]; // DAJ_MR utb int */ // Set the dead flag for an object -static inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove = false, bool play_sound_on_clients = false); -static inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove, bool play_sound_on_clients) { - int objnum = OBJNUM(obj); - ASSERT(objnum != -1); - ASSERT(objnum != 0); - ASSERT(obj->type != OBJ_NONE); - ASSERT(obj != Player_object); - - obj->flags |= OF_DEAD; - - if (tell_clients_to_remove) { - if (play_sound_on_clients) { - obj->flags |= OF_SEND_MULTI_REMOVE_ON_DEATHWS; - } else { - obj->flags |= OF_SEND_MULTI_REMOVE_ON_DEATH; - } - } -} +void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove = false, bool play_sound_on_clients = false); void SetObjectControlType(object *obj, int control_type); diff --git a/Descent3/object_lighting.cpp b/Descent3/object_lighting.cpp index 5b2caec74..ada517e1c 100644 --- a/Descent3/object_lighting.cpp +++ b/Descent3/object_lighting.cpp @@ -108,6 +108,7 @@ #include "hlsoundlib.h" #include "soundload.h" #include "hud.h" +#include "pserror.h" #include "stringtable.h" // How far the headlight casts light diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index 53d732f0a..d94e94caf 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -597,6 +597,7 @@ #include "newui.h" #include "pilot.h" #include "polymodel.h" +#include "pserror.h" #include "pstring.h" #include "renderer.h" #include "render.h" diff --git a/Descent3/postrender.cpp b/Descent3/postrender.cpp index 96fafc8db..284547831 100644 --- a/Descent3/postrender.cpp +++ b/Descent3/postrender.cpp @@ -76,13 +76,13 @@ #include "..\neweditor\globals.h" #endif -#include #include "object.h" #include "viseffect.h" #include "render.h" #include "renderobject.h" #include "room.h" #include "postrender.h" +#include "pserror.h" #include "config.h" #include "terrain.h" #include "renderer.h" diff --git a/Descent3/render.cpp b/Descent3/render.cpp index 43071b6e8..005abd6b9 100644 --- a/Descent3/render.cpp +++ b/Descent3/render.cpp @@ -29,6 +29,7 @@ * $NoKeywords: $ */ +#include #include #include @@ -58,6 +59,7 @@ #include "TelComAutoMap.h" #include "postrender.h" #include "mem.h" +#include "pserror.h" #include "psrand.h" #include "player.h" #include "args.h" @@ -65,8 +67,6 @@ #include "editor\d3edit.h" #endif -#include - // #define KATMAI // Katmai enhanced rotate only in a release build, because not diff --git a/Descent3/renderobject.cpp b/Descent3/renderobject.cpp index abf52abcc..082943092 100644 --- a/Descent3/renderobject.cpp +++ b/Descent3/renderobject.cpp @@ -608,6 +608,7 @@ #include "game2dll.h" #include "marker.h" #include "ship.h" +#include "pserror.h" #include "psrand.h" #ifdef EDITOR diff --git a/Descent3/robotfire.cpp b/Descent3/robotfire.cpp index f42101aaa..03e1139c6 100644 --- a/Descent3/robotfire.cpp +++ b/Descent3/robotfire.cpp @@ -36,6 +36,7 @@ #include "SmallViews.h" #include "physics.h" #include "AIMain.h" +#include "pserror.h" #include "psrand.h" // Fires a multiplayer and AI on/off weapon diff --git a/Descent3/room.cpp b/Descent3/room.cpp index 2c34864ba..b7b0fd633 100644 --- a/Descent3/room.cpp +++ b/Descent3/room.cpp @@ -416,6 +416,7 @@ #include "multi_world_state.h" #include "damage_external.h" #include "descent.h" +#include "pserror.h" #ifdef EDITOR #include "editor\editor_lighting.h" #endif diff --git a/Descent3/screens.cpp b/Descent3/screens.cpp index 5e67b4792..978bfd5c4 100644 --- a/Descent3/screens.cpp +++ b/Descent3/screens.cpp @@ -203,6 +203,7 @@ #include "log.h" #include "sounds.h" #include "pilot.h" +#include "pserror.h" #include "joystick.h" #define LVLRES_FADEIN_TIME 0.50f diff --git a/Descent3/splinter.cpp b/Descent3/splinter.cpp index 1e72d3a71..b5029a2fc 100644 --- a/Descent3/splinter.cpp +++ b/Descent3/splinter.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "fireball.h" #include "object.h" @@ -23,13 +24,9 @@ #include "polymodel.h" #include "renderer.h" #include "gametexture.h" - -#include "Macros.h" -#include - +#include "pserror.h" #include "psrand.h" -#include // Given an object, renders the representation of this splinter void DrawSplinterObject(object *obj) { diff --git a/Descent3/terrain.cpp b/Descent3/terrain.cpp index 67772c843..d982bc4b9 100644 --- a/Descent3/terrain.cpp +++ b/Descent3/terrain.cpp @@ -108,6 +108,17 @@ int Terrain_checksum = -1; uint8_t Terrain_occlusion_map[256][32]; int Terrain_occlusion_checksum = -2; +#ifndef RELEASE +int TERRAIN_REGION(int x) { + ASSERT(x != -1 && "invalid/unset room number (-1)!"); + // Note: due to the 0x7FFFFFFF mask, terrSegIdx will be >= 0 + int terrSegIdx = 0x7FFFFFFF & x; + // catch other invalid cell/segment numbers than -1 as well + ASSERT((terrSegIdx < TERRAIN_WIDTH * TERRAIN_DEPTH) && "invalid cellnum!"); + return (Terrain_seg[terrSegIdx].flags & TFM_REGION_MASK) >> 5; +} +#endif + // returns the index of the highest float int GetHighestDelta(float *deltas, int count) { int high_index = -999; diff --git a/Descent3/terrain.h b/Descent3/terrain.h index 10a0b17f1..e5b89fb73 100644 --- a/Descent3/terrain.h +++ b/Descent3/terrain.h @@ -214,14 +214,7 @@ extern int16_t Terrain_seg_render_objs[]; #ifdef RELEASE #define TERRAIN_REGION(x) ((Terrain_seg[0x7FFFFFFF & x].flags & TFM_REGION_MASK) >> 5) #else // debug(-ish) builds - check if x is valid -static inline int TERRAIN_REGION(int x) { - ASSERT(x != -1 && "invalid/unset room number (-1)!"); - // Note: due to the 0x7FFFFFFF mask, terrSegIdx will be >= 0 - int terrSegIdx = 0x7FFFFFFF & x; - // catch other invalid cell/segment numbers than -1 as well - ASSERT((terrSegIdx < TERRAIN_WIDTH * TERRAIN_DEPTH) && "invalid cellnum!"); - return (Terrain_seg[terrSegIdx].flags & TFM_REGION_MASK) >> 5; -} +int TERRAIN_REGION(int x); #endif extern terrain_sky Terrain_sky; diff --git a/Descent3/viseffect.cpp b/Descent3/viseffect.cpp index f3dddfcfa..6152f97cc 100644 --- a/Descent3/viseffect.cpp +++ b/Descent3/viseffect.cpp @@ -454,6 +454,7 @@ #include "physics.h" #include "player.h" #include "polymodel.h" +#include "pserror.h" #include "psrand.h" #include "room.h" #include "terrain.h" diff --git a/ddebug/CMakeLists.txt b/ddebug/CMakeLists.txt index c4dc53af0..2ebe17793 100644 --- a/ddebug/CMakeLists.txt +++ b/ddebug/CMakeLists.txt @@ -26,9 +26,10 @@ target_include_directories(ddebug PUBLIC PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h ) target_link_libraries(ddebug PRIVATE - logger $<$: mem misc > + PUBLIC + logger ) diff --git a/netgames/includes/DMFC.h b/netgames/includes/DMFC.h index dab757042..0d3256d5d 100644 --- a/netgames/includes/DMFC.h +++ b/netgames/includes/DMFC.h @@ -400,22 +400,26 @@ #endif // OS check #else // Release build + #ifdef DEBUG_BREAK #undef DEBUG_BREAK -#define DEBUG_BREAK() #endif +#define DEBUG_BREAK() + #define DLLASSERT(x) #define DLLmprintf(...) + #ifdef Int3 #undef Int3 -#define Int3() #endif #define Int3() + #ifdef ASSERT #undef ASSERT -#define ASSERT(x) -#endif #endif +#define ASSERT(x) + +#endif // #ifndef RELEASE #ifdef mprintf // undefine mprintf and redirect it to use DLLmprintf #undef mprintf diff --git a/networking/networking.cpp b/networking/networking.cpp index 4cf7fdd09..5c7af2f24 100644 --- a/networking/networking.cpp +++ b/networking/networking.cpp @@ -294,6 +294,7 @@ #include "directplay.h" #include "dplay.h" #include "dplobby.h" +#include "module.h" typedef int socklen_t; #endif diff --git a/physics/physics.cpp b/physics/physics.cpp index 54a17e70d..31badcd17 100644 --- a/physics/physics.cpp +++ b/physics/physics.cpp @@ -33,6 +33,7 @@ #include "physics.h" #include "player.h" #include "polymodel.h" +#include "pserror.h" #include "terrain.h" #include "vecmat.h" #include "viseffect.h" diff --git a/sndlib/sndrender.cpp b/sndlib/sndrender.cpp index 63e067fb0..aa651c742 100644 --- a/sndlib/sndrender.cpp +++ b/sndlib/sndrender.cpp @@ -59,7 +59,7 @@ #include "application.h" #include "soundload.h" #include "gametexture.h" - +#include "pserror.h" static llsGeometry *Geometry = NULL; static int16_t Sound_room_list[SOUND_RENDER_ROOM_LIMIT + 1]; diff --git a/ui/UIButton.cpp b/ui/UIButton.cpp index 1c0dffe9a..81c9d2a02 100644 --- a/ui/UIButton.cpp +++ b/ui/UIButton.cpp @@ -123,7 +123,9 @@ #include +#include "pserror.h" #include "UIlib.h" +#include "ui.h" #if defined(POSIX) int UIButton::m_ButtonFont; @@ -161,6 +163,11 @@ void UIButton::Create(UIWindow *parent, int id, UIItem *item, int x, int y, int UIGadget::Create(parent, id, x, y, w, h, flags); } +UIItem *UIButton::GetStateItem(int state) { + ASSERT(state < UI_BTS_NUM); + return m_Items[state]; +}; + // sets the background bitmap for a specified button state void UIButton::SetStateItem(int state, UIItem *item) { ASSERT(state < UI_BTS_NUM); @@ -172,6 +179,11 @@ void UIButton::SetStateItem(int state, UIItem *item) { m_Items[state] = item->CopyUIItem(); } +int UIButton::GetColor(int state) const { + ASSERT(state < UI_BTS_NUM); + return m_Colors[state]; +}; + // sets the background color for a specified button state void UIButton::SetColor(int state, ddgr_color col) { ASSERT(state < UI_BTS_NUM); diff --git a/ui/UIConsole.cpp b/ui/UIConsole.cpp index 764cc5488..b3d4eb34b 100644 --- a/ui/UIConsole.cpp +++ b/ui/UIConsole.cpp @@ -60,6 +60,7 @@ #include "UIlib.h" #include "grtext.h" #include "mem.h" +#include "pserror.h" #include "textaux.h" #define CONSOLE_LINE_FILLER 128 diff --git a/ui/UIEdit.cpp b/ui/UIEdit.cpp index 54f5b5b97..e0d91e7ee 100644 --- a/ui/UIEdit.cpp +++ b/ui/UIEdit.cpp @@ -141,7 +141,7 @@ #include "log.h" #include "Macros.h" #include "mem.h" - +#include "pserror.h" static UIEdit *UI_current_editbox = NULL; diff --git a/ui/UIGadget.cpp b/ui/UIGadget.cpp index 4e58aa1d4..2e8d42afe 100644 --- a/ui/UIGadget.cpp +++ b/ui/UIGadget.cpp @@ -121,6 +121,7 @@ #include "UIlib.h" #include "Macros.h" +#include "pserror.h" int UIGadget::m_LastKey = 0; int UIGadget::m_LastKeyCount = 0; diff --git a/ui/UIGroup.cpp b/ui/UIGroup.cpp index a0ff17dd0..ae4d6357a 100644 --- a/ui/UIGroup.cpp +++ b/ui/UIGroup.cpp @@ -49,6 +49,7 @@ #include "UIlib.h" #include "mem.h" +#include "pserror.h" // ---------------------------------------------------------------------------- // UIGroup diff --git a/ui/UIHotspot.cpp b/ui/UIHotspot.cpp index a761ad559..453335f8a 100644 --- a/ui/UIHotspot.cpp +++ b/ui/UIHotspot.cpp @@ -78,6 +78,7 @@ */ #include "UIlib.h" +#include "pserror.h" // ---------------------------------------------------------------------------- // UIHotspot diff --git a/ui/UIListBox.cpp b/ui/UIListBox.cpp index 2a100e8e1..4da92787b 100644 --- a/ui/UIListBox.cpp +++ b/ui/UIListBox.cpp @@ -162,6 +162,7 @@ #include "UIlib.h" #include "log.h" +#include "pserror.h" #define SCROLL_BUTTON_GAP 4 diff --git a/ui/UIObject.cpp b/ui/UIObject.cpp index ea9b4ad7c..7111e2ff6 100644 --- a/ui/UIObject.cpp +++ b/ui/UIObject.cpp @@ -40,6 +40,7 @@ #include "UIlib.h" #include "log.h" +#include "pserror.h" UIObject::UIObject() { m_X = m_Y = 0; diff --git a/ui/UISlider.cpp b/ui/UISlider.cpp index fb2e021c3..5a0f6ca5f 100644 --- a/ui/UISlider.cpp +++ b/ui/UISlider.cpp @@ -62,6 +62,7 @@ */ #include "UIlib.h" +#include "pserror.h" // Construction and destruction diff --git a/ui/UISystem.cpp b/ui/UISystem.cpp index 7a122b951..6fe0b0057 100644 --- a/ui/UISystem.cpp +++ b/ui/UISystem.cpp @@ -170,6 +170,7 @@ #include "application.h" #include "bitmap.h" #include "log.h" +#include "pserror.h" #include "renderer.h" #include "Macros.h" diff --git a/ui/UIWindow.cpp b/ui/UIWindow.cpp index 4fafe4323..f67611ae0 100644 --- a/ui/UIWindow.cpp +++ b/ui/UIWindow.cpp @@ -152,6 +152,7 @@ #include "UIlib.h" #include "Macros.h" #include "log.h" +#include "pserror.h" // the window font for all windows int UIWindow::m_WindowFont = 0; diff --git a/ui/ui.h b/ui/ui.h index ffab46002..a6d891703 100644 --- a/ui/ui.h +++ b/ui/ui.h @@ -270,7 +270,6 @@ #include #include "grdefs.h" -#include "pserror.h" #include "uires.h" // Class identification @@ -554,15 +553,9 @@ class UIButton : public UIGadget { protected: int m_State; // state of button - UIItem *GetStateItem(int state) { - ASSERT(state < UI_BTS_NUM); - return m_Items[state]; - }; + UIItem *GetStateItem(int state); - int GetColor(int state) const { - ASSERT(state < UI_BTS_NUM); - return m_Colors[state]; - }; + int GetColor(int state) const; public: static void SetDefaultFont(int font) { // sets the button font diff --git a/vecmat/vector.cpp b/vecmat/vector.cpp index 09164f105..6ae13b247 100644 --- a/vecmat/vector.cpp +++ b/vecmat/vector.cpp @@ -146,9 +146,8 @@ * $NoKeywords: $ */ -#include -#include -#include +#include +#include #include "vecmat.h" #include "mono.h" @@ -160,7 +159,7 @@ const matrix Identity_matrix = IDENTITY_MATRIX; void vm_AverageVector(vector *a, int num) { // Averages a vector. ie divides each component of vector a by num - assert(num != 0); + ASSERT(num != 0); a->x = a->x / (float)num; a->y = a->y / (float)num; a->z = a->z / (float)num; @@ -254,7 +253,7 @@ void vm_DivVector(vector *dest, vector *src, float n) { // Divides a vector into n portions // Dest can equal src - assert(n != 0); + ASSERT(n != 0); dest->x = src->x / n; dest->y = src->y / n; dest->z = src->z / n; @@ -325,7 +324,7 @@ void vm_TransposeMatrix(matrix *m) { void vm_MatrixMulVector(vector *result, vector *v, matrix *m) { // Rotates a vector thru a matrix - assert(result != v); + ASSERT(result != v); result->x = *v * m->rvec; result->y = *v * m->uvec; @@ -334,7 +333,7 @@ void vm_MatrixMulVector(vector *result, vector *v, matrix *m) { // Multiply a vector times the transpose of a matrix void vm_VectorMulTMatrix(vector *result, vector *v, matrix *m) { - assert(result != v); + ASSERT(result != v); result->x = vm_Dot3Vector(m->rvec.x, m->uvec.x, m->fvec.x, v); result->y = vm_Dot3Vector(m->rvec.y, m->uvec.y, m->fvec.y, v); @@ -344,7 +343,7 @@ void vm_VectorMulTMatrix(vector *result, vector *v, matrix *m) { void vm_MatrixMul(matrix *dest, matrix *src0, matrix *src1) { // For multiplying two 3x3 matrices together - assert((dest != src0) && (dest != src1)); + ASSERT((dest != src0) && (dest != src1)); dest->rvec.x = vm_Dot3Vector(src0->rvec.x, src0->uvec.x, src0->fvec.x, &src1->rvec); dest->uvec.x = vm_Dot3Vector(src0->rvec.x, src0->uvec.x, src0->fvec.x, &src1->uvec); @@ -363,7 +362,7 @@ void vm_MatrixMul(matrix *dest, matrix *src0, matrix *src1) { void vm_MatrixMulTMatrix(matrix *dest, matrix *src0, matrix *src1) { // For multiplying two 3x3 matrices together - assert((dest != src0) && (dest != src1)); + ASSERT((dest != src0) && (dest != src1)); dest->rvec.x = src0->rvec.x * src1->rvec.x + src0->uvec.x * src1->uvec.x + src0->fvec.x * src1->fvec.x; dest->uvec.x = src0->rvec.x * src1->rvec.y + src0->uvec.x * src1->uvec.y + src0->fvec.x * src1->fvec.y; From f7b7f18e0df86873130addca90b43060995ec62c Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 17:01:28 +0300 Subject: [PATCH 06/10] Replace debugbreak with SDL_assert() Reworked ASSERT() and Int3() macros to use SDL_assert(). SDL_assert() allows to debug break from user decision. Major reorganizing platform-dependent code to make it platform-independent. --- Descent3/DllWrappers.cpp | 7 +- ddebug/CMakeLists.txt | 2 +- ddebug/debug.h | 16 +--- ddebug/debugbreak.h | 192 --------------------------------------- ddebug/error.cpp | 28 +++--- ddebug/lnxdebug.cpp | 5 +- ddebug/pserror.h | 48 +++++----- ddebug/windebug.cpp | 2 +- win32/winapp.cpp | 4 +- 9 files changed, 45 insertions(+), 259 deletions(-) delete mode 100644 ddebug/debugbreak.h diff --git a/Descent3/DllWrappers.cpp b/Descent3/DllWrappers.cpp index a21c438e5..6505fc4ba 100644 --- a/Descent3/DllWrappers.cpp +++ b/Descent3/DllWrappers.cpp @@ -106,11 +106,8 @@ void SetObjectDeadFlagDLL(object *obj, bool tell_clients_to_remove, bool tell_cl void assertdll(int x, const char *expression, const char *file, int line) { #ifndef RELEASE if (!(unsigned)(x)) { - LOG_ERROR.printf("Assertion failed (%s) in %s line %d.", expression, file, line); - if (Debug_break) - DEBUG_BREAK(); - else - AssertionFailed(expression, file, line); + LOG_ERROR.printf("Assertion failed (%s) in %s:%d.", expression, file, line); + SDL_assert(x); } #endif } diff --git a/ddebug/CMakeLists.txt b/ddebug/CMakeLists.txt index 2ebe17793..8d4aec7d6 100644 --- a/ddebug/CMakeLists.txt +++ b/ddebug/CMakeLists.txt @@ -1,6 +1,5 @@ set(HEADERS debug.h - debugbreak.h mono.h pserror.h ) @@ -31,5 +30,6 @@ target_link_libraries(ddebug PRIVATE misc > PUBLIC + SDL2::SDL2 logger ) diff --git a/ddebug/debug.h b/ddebug/debug.h index 336fb789c..7efecb3f3 100644 --- a/ddebug/debug.h +++ b/ddebug/debug.h @@ -164,24 +164,12 @@ int Debug_MessageBox(int type, const char *title, const char *str); // these functions deal with debug spew support void Debug_ConsolePrintf(int n, const char *format, ...); -// DEBUGGING MACROS -// Break into the debugger, if this feature was enabled in Debug_init() -#if !defined(RELEASE) -#include "debugbreak.h" -#if defined(WIN32) -#elif defined(POSIX) -void ddio_InternalKeyClose(); -#else -#define debug_break() -#endif -#else -#define debug_break() -#endif - #if defined(WIN32) #include long WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data); + #endif + #endif diff --git a/ddebug/debugbreak.h b/ddebug/debugbreak.h deleted file mode 100644 index 110f64369..000000000 --- a/ddebug/debugbreak.h +++ /dev/null @@ -1,192 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -/* Copyright (c) 2011-2021, Scott Tsai - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef DEBUG_BREAK_H -#define DEBUG_BREAK_H - -#ifdef _MSC_VER - -#define debug_break __debugbreak - -#else - -#ifdef __cplusplus -extern "C" { -#endif - -#define DEBUG_BREAK_USE_TRAP_INSTRUCTION 1 -#define DEBUG_BREAK_USE_BULTIN_TRAP 2 -#define DEBUG_BREAK_USE_SIGTRAP 3 - -#if defined(__i386__) || defined(__x86_64__) - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__inline__ static void trap_instruction(void) -{ - __asm__ volatile("int $0x03"); -} -#elif defined(__thumb__) - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -/* FIXME: handle __THUMB_INTERWORK__ */ -__attribute__((always_inline)) -__inline__ static void trap_instruction(void) -{ - /* See 'arm-linux-tdep.c' in GDB source. - * Both instruction sequences below work. */ -#if 1 - /* 'eabi_linux_thumb_le_breakpoint' */ - __asm__ volatile(".inst 0xde01"); -#else - /* 'eabi_linux_thumb2_le_breakpoint' */ - __asm__ volatile(".inst.w 0xf7f0a000"); -#endif - - /* Known problem: - * After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB. - * 'step' would keep getting stuck on the same instruction. - * - * Workaround: use the new GDB commands 'debugbreak-step' and - * 'debugbreak-continue' that become available - * after you source the script from GDB: - * - * $ gdb -x debugbreak-gdb.py <... USUAL ARGUMENTS ...> - * - * 'debugbreak-step' would jump over the breakpoint instruction with - * roughly equivalent of: - * (gdb) set $instruction_len = 2 - * (gdb) tbreak *($pc + $instruction_len) - * (gdb) jump *($pc + $instruction_len) - */ -} -#elif defined(__arm__) && !defined(__thumb__) - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((always_inline)) -__inline__ static void trap_instruction(void) -{ - /* See 'arm-linux-tdep.c' in GDB source, - * 'eabi_linux_arm_le_breakpoint' */ - __asm__ volatile(".inst 0xe7f001f0"); - /* Known problem: - * Same problem and workaround as Thumb mode */ -} -#elif defined(__aarch64__) && defined(__APPLE__) - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP -#elif defined(__aarch64__) - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((always_inline)) -__inline__ static void trap_instruction(void) -{ - /* See 'aarch64-tdep.c' in GDB source, - * 'aarch64_default_breakpoint' */ - __asm__ volatile(".inst 0xd4200000"); -} -#elif defined(__powerpc__) - /* PPC 32 or 64-bit, big or little endian */ - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((always_inline)) -__inline__ static void trap_instruction(void) -{ - /* See 'rs6000-tdep.c' in GDB source, - * 'rs6000_breakpoint' */ - __asm__ volatile(".4byte 0x7d821008"); - - /* Known problem: - * After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB. - * 'step' stuck on the same instruction ("twge r2,r2"). - * - * The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py - * or manually jump over the instruction. */ -} -#elif defined(__riscv) - /* RISC-V 32 or 64-bit, whether the "C" extension - * for compressed, 16-bit instructions are supported or not */ - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((always_inline)) -__inline__ static void trap_instruction(void) -{ - /* See 'riscv-tdep.c' in GDB source, - * 'riscv_sw_breakpoint_from_kind' */ - __asm__ volatile(".4byte 0x00100073"); -} -#else - #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP -#endif - - -#ifndef DEBUG_BREAK_IMPL -#error "debugbreak.h is not supported on this target" -#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((always_inline)) -__inline__ static void debug_break(void) -{ - trap_instruction(); -} -#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_DEBUGTRAP -__attribute__((always_inline)) -__inline__ static void debug_break(void) -{ - __builtin_debugtrap(); -} -#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP -__attribute__((always_inline)) -__inline__ static void debug_break(void) -{ - __builtin_trap(); -} -#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP -#include -__attribute__((always_inline)) -__inline__ static void debug_break(void) -{ - raise(SIGTRAP); -} -#else -#error "invalid DEBUG_BREAK_IMPL value" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ifdef _MSC_VER */ - -#endif /* ifndef DEBUG_BREAK_H */ diff --git a/ddebug/error.cpp b/ddebug/error.cpp index bf58414ad..4c081ad5a 100644 --- a/ddebug/error.cpp +++ b/ddebug/error.cpp @@ -66,20 +66,17 @@ #include #include +#include +#include -#include -#include - -#include "mono.h" -#include "pserror.h" #include "debug.h" -#include "application.h" +#include "pserror.h" #define MAX_MSG_LEN 2000 // Debug break chain handlers -void (*DebugBreak_callback_stop)() = NULL; -void (*DebugBreak_callback_resume)() = NULL; +void (*DebugBreak_callback_stop)() = nullptr; +void (*DebugBreak_callback_resume)() = nullptr; // library initialized flag static bool Error_initialized = false; @@ -115,17 +112,16 @@ bool error_Init(bool debugger, const char *app_title) { // exits the application and prints out a standard error message void Error(const char *fmt, ...) { std::va_list arglist; - int exit_msg_len; strcpy(Exit_message, "Error: "); va_start(arglist, fmt); - exit_msg_len = strlen(Exit_message); + size_t exit_msg_len = strlen(Exit_message); std::vsnprintf(Exit_message + exit_msg_len, MAX_MSG_LEN - exit_msg_len, fmt, arglist); va_end(arglist); snprintf(Exit_title_str, sizeof(Exit_title_str), "%s Error", App_title); - mprintf(0, "%s\n", Exit_message); + LOG_ERROR.printf("%s", Exit_message); #ifdef _DEBUG int answer = IDOK; @@ -141,7 +137,7 @@ void Error(const char *fmt, ...) { switch (answer) { case IDRETRY: - debug_break(); // Step Out of this function to see where Error() was called + SDL_TriggerBreakpoint(); // Step Out of this function to see where Error() was called // fall into ignore/cancel case case IDIGNORE: case IDCANCEL: @@ -162,7 +158,7 @@ void Error(const char *fmt, ...) { #endif // Clear the DEBUG_BREAK() callbacks - SetDebugBreakHandlers(NULL, NULL); + SetDebugBreakHandlers(nullptr, nullptr); // Leave the program exit(0); @@ -175,7 +171,7 @@ void Int3MessageBox(const char *file, int line) { int answer; snprintf(title, sizeof(title), "%s Debug Break", App_title); - snprintf(message, sizeof(message), "Int3 in %s at line %d.", file, line); + snprintf(message, sizeof(message), "Int3 in %s:%d.", file, line); if (DebugBreak_callback_stop) (*DebugBreak_callback_stop)(); @@ -183,7 +179,7 @@ void Int3MessageBox(const char *file, int line) { answer = Debug_ErrorBox(OSMBOX_YESNO, title, message, "It's probably safe to continue. Continue?"); if (answer == IDNO) { - SetDebugBreakHandlers(NULL, NULL); + SetDebugBreakHandlers(nullptr, nullptr); exit(1); } @@ -207,7 +203,7 @@ void AssertionFailed(const char *expstr, const char *file, int line) { answer = Debug_ErrorBox(OSMBOX_YESNO, title, message, "Continue?"); if (answer == IDNO) { - SetDebugBreakHandlers(NULL, NULL); + SetDebugBreakHandlers(nullptr, nullptr); exit(1); } diff --git a/ddebug/lnxdebug.cpp b/ddebug/lnxdebug.cpp index 20afb47fb..4541f3b2a 100644 --- a/ddebug/lnxdebug.cpp +++ b/ddebug/lnxdebug.cpp @@ -39,6 +39,7 @@ */ #include +#include #include "debug.h" @@ -50,9 +51,9 @@ int Debug_ErrorBox(int type, const char *topstring, const char *title, const char *bottomstring) { int answer = 0; - fprintf(stderr, "\n%s(%s)\n\n%s\n\n%s\n", title, topstring, "System Error", bottomstring); + fprintf(stderr, "\n%s (%s)\n\n%s\n\n%s\n", topstring, title, "System Error", bottomstring); - debug_break(); + SDL_TriggerBreakpoint(); return answer; } diff --git a/ddebug/pserror.h b/ddebug/pserror.h index c6e24349e..dfc3a0841 100644 --- a/ddebug/pserror.h +++ b/ddebug/pserror.h @@ -148,9 +148,11 @@ #ifndef PSERROR_H #define PSERROR_H -#include + +#include + #include "debug.h" -#include "mono.h" +#include "log.h" // initializes error handler. bool error_Init(bool debugger, const char *app_title); @@ -161,10 +163,12 @@ void AssertionFailed(const char *expstr, const char *file, int line); // Brings up an error message for an int3 void Int3MessageBox(const char *file, int line); // Message box functions + #define MBOX_OK 1 #define MBOX_YESNO 2 #define MBOX_YESNOCANCEL 3 #define MBOX_ABORTRETRYIGNORE 4 + // prints out a standard OS messagebox void OutrageMessageBox(const char *str, ...); int OutrageMessageBox(int type, const char *str, ...); @@ -172,6 +176,7 @@ int OutrageMessageBox(int type, const char *str, ...); void SetMessageBoxTitle(const char *title); // Write a block of text to the system clipboard void DumpTextToClipboard(char *text); + ////////////////////////////////////////////////////////////////////////////// // development debugging functions // adds a function to be called when a debug break occurs. @@ -179,69 +184,60 @@ void DumpTextToClipboard(char *text); #ifdef ASSERT #undef ASSERT #endif + // this callback is invoked when a DEBUG_BREAK macro is used. // arguments // style = 1 if ASSERT // = 0 if Int3 debugger break. extern void (*DebugBreak_callback_stop)(); extern void (*DebugBreak_callback_resume)(); + // set DEBUG_BREAK callback static inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) { DebugBreak_callback_stop = stop; DebugBreak_callback_resume = resume; } -// DEBUG_BREAK() -// Calls the debug_break() macro surrounded by calls to the debug callbacks (to turn off & on graphics) -// ASSERT() -// Like the standard C assert(), but if the condition failed and debugging on, -// does a DEBUG_BREAK(). If debugging on, brings up a dialog. -// Int3() -// Does a DEBUG_BREAK() if debugging is turned on. Also does an mprintf(). -// Define the macros + #ifndef RELEASE #include +// Calls the SDL_assert(false) macro surrounded by calls to the debug callbacks (to turn off & on graphics) #define DEBUG_BREAK() \ do { \ if (DebugBreak_callback_stop) \ (*DebugBreak_callback_stop)(); \ - debug_break(); \ + SDL_assert(false); \ if (DebugBreak_callback_resume) \ (*DebugBreak_callback_resume)(); \ } while (0) +// Does a DEBUG_BREAK() if debugging is turned on. #define Int3() \ do { \ - mprintf(0, "Int3 at %s line %d.\n", __FILE__, __LINE__); \ - if (Debug_break) \ - DEBUG_BREAK(); \ - else \ - Int3MessageBox(__FILE__, __LINE__); \ + LOG_ERROR.printf("Int3 at %s:%d.", __FILE__, __LINE__); \ + DEBUG_BREAK(); \ } while (0) -#if defined(WIN32) - +// Like the standard C assert(), but if the condition failed and debugging on does a SDL_assert() with debug window. #define ASSERT(x) \ do { \ if (!(x)) { \ - mprintf(0, "Assertion failed (%s) in %s line %d.\n", #x, __FILE__, __LINE__); \ - if (Debug_break) \ - DEBUG_BREAK(); \ - else \ - AssertionFailed(#x, __FILE__, __LINE__); \ + LOG_ERROR.printf("Assertion failed (%s) in %s:%d.", #x, __FILE__, __LINE__); \ + SDL_assert(x); \ } \ } while (0) + +#if defined(WIN32) + #define HEAPCHECK() \ do { \ if (_heapchk() != _HEAPOK) \ Int3(); \ } while (0) -#elif defined(POSIX) -#include +#elif defined(POSIX) -#define ASSERT(x) SDL_assert(x) #define HEAPCHECK() #endif diff --git a/ddebug/windebug.cpp b/ddebug/windebug.cpp index e5396bfe6..75ebc04ca 100644 --- a/ddebug/windebug.cpp +++ b/ddebug/windebug.cpp @@ -217,7 +217,7 @@ int Debug_ErrorBox(int type, const char *title, const char *topstring, const cha else if (type == OSMBOX_OKCANCEL) flags = MB_OKCANCEL; else - debug_break(); + DEBUG_BREAK(); char *tmpbuf = mem_rmalloc(strlen(topstring) + strlen(bottomstring) + 5); wsprintf(tmpbuf, "%s\r\n\r\n%s", topstring, bottomstring); diff --git a/win32/winapp.cpp b/win32/winapp.cpp index 21163e4eb..2ddbf5168 100644 --- a/win32/winapp.cpp +++ b/win32/winapp.cpp @@ -149,9 +149,9 @@ #include "Application.h" #include "AppConsole.h" -#include "debugbreak.h" #include "log.h" #include "networking.h" +#include "pserror.h" #include #include @@ -639,7 +639,7 @@ LRESULT WINAPI MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (Win32_AppObjects[i].hWnd == NULL) break; if (i == MAX_WIN32APPS) - debug_break(); + Int3(); Win32_AppObjects[i].hWnd = hWnd; Win32_AppObjects[i].app = (oeWin32Application *)lpCreateStruct->lpCreateParams; From 3b83d493e211ceca5a71d385978b73df23dfc40d Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 22:14:39 +0300 Subject: [PATCH 07/10] Sync DMFC debug functionality with core codebase --- netgames/dmfc/CMakeLists.txt | 1 + netgames/includes/DMFC.h | 101 +++++++++-------------------------- 2 files changed, 25 insertions(+), 77 deletions(-) diff --git a/netgames/dmfc/CMakeLists.txt b/netgames/dmfc/CMakeLists.txt index e89206748..f0d5a0279 100644 --- a/netgames/dmfc/CMakeLists.txt +++ b/netgames/dmfc/CMakeLists.txt @@ -28,6 +28,7 @@ add_definitions(-DOUTRAGE_VERSION) add_library(dmfc STATIC ${HEADERS} ${CPPS}) target_link_libraries(dmfc PUBLIC + SDL2::SDL2 grtext misc module diff --git a/netgames/includes/DMFC.h b/netgames/includes/DMFC.h index 0d3256d5d..b30ced7d6 100644 --- a/netgames/includes/DMFC.h +++ b/netgames/includes/DMFC.h @@ -288,19 +288,17 @@ #ifndef __DMFC_H__ #define __DMFC_H__ -#include -#include -#include +#include +#include +#include +#include + #include "gamedll_header.h" #include "DMFCKeyCodes.h" -#if ((defined POSIX) && (!defined __i386__)) -#include -#endif - #ifndef RELEASE -#ifdef WIN32 +// Debug macros. Keep in sync with ddebug module (pserror.h) #ifdef DEBUG_BREAK #undef DEBUG_BREAK #endif @@ -308,22 +306,9 @@ do { \ if (DLLDebugBreak_callback_stop) \ DLLDebugBreak_callback_stop(); \ - debug_break(); \ - if (DebugBreak_callback_resume) \ - DebugBreak_callback_resume(); \ - } while (0) - -#define DLLASSERT(x) \ - do { \ - DLLassert(x, #x, __FILE__, __LINE__); \ - } while (0) -#define DLLmprintf(...) DLLDebug_ConsolePrintf(__VA_ARGS__) -#ifdef ASSERT -#undef ASSERT -#endif -#define ASSERT(x) \ - do { \ - DLLassert(x, #x, __FILE__, __LINE__); \ + SDL_assert(false); \ + if (DLLDebugBreak_callback_resume) \ + DLLDebugBreak_callback_resume(); \ } while (0) #ifdef Int3 @@ -331,38 +316,9 @@ #endif #define Int3() \ do { \ - mprintf(0, "Int3 at %s line %d.\n", __FILE__, __LINE__); \ - if (DLLDebugBreak_callback_stop) \ - DLLDebugBreak_callback_stop(); \ - debug_break(); \ - if (DLLDebugBreak_callback_resume) \ - DLLDebugBreak_callback_resume(); \ - } while (0) -#elif defined(POSIX) -// For some reason Linux doesn't like the \ continuation character, so I have to uglify this -#define DLLmprintf(...) DLLDebug_ConsolePrintf(__VA_ARGS__) -#ifdef DEBUG_BREAK -#undef DEBUG_BREAK -#endif -#if (defined __i386__) || defined(__x86_64__) -#define DEBUG_BREAK() \ - do { \ - if (DLLDebugBreak_callback_stop) \ - DLLDebugBreak_callback_stop(); \ - __asm__ __volatile__("int $3"); \ - if (DLLDebugBreak_callback_resume) \ - DLLDebugBreak_callback_resume(); \ - } while (0) -#else -#define DEBUG_BREAK() \ - do { \ - if (DLLDebugBreak_callback_stop) \ - DLLDebugBreak_callback_stop(); \ - raise(SIGTRAP); \ - if (DLLDebugBreak_callback_resume) \ - DLLDebugBreak_callback_resume(); \ + mprintf(0, "Int3 at %s:%d.\n", __FILE__, __LINE__); \ + DEBUG_BREAK(); \ } while (0) -#endif #ifdef ASSERT #undef ASSERT @@ -371,33 +327,24 @@ do { \ DLLassert(x, #x, __FILE__, __LINE__); \ } while (0) + #define DLLASSERT(x) ASSERT(x) -#ifdef Int3 -#undef Int3 -#endif -#define Int3() \ + +#define DLLmprintf(...) DLLDebug_ConsolePrintf(__VA_ARGS__) + +#if defined(WIN32) + +#define HEAPCHECK() \ do { \ - mprintf(0, "Int3 at %s line %d.\n", __FILE__, __LINE__); \ - DEBUG_BREAK(); \ + if (_heapchk() != _HEAPOK) \ + Int3(); \ } while (0) + +#elif defined(POSIX) + #define HEAPCHECK() -#else -#ifdef DEBUG_BREAK -#undef DEBUG_BREAK -#define DEBUG_BREAK() -#endif -#define DLLASSERT(x) -#define DLLmprintf(...) -#ifdef Int3 -#undef Int3 -#define Int3() -#endif -#define Int3() -#ifdef ASSERT -#undef ASSERT -#define ASSERT(x) + #endif -#endif // OS check #else // Release build From 68f877184586c18c1c44eba16d921576b6bc0bce Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Wed, 25 Sep 2024 23:47:03 +0300 Subject: [PATCH 08/10] Fix compilation of editor --- Descent3/SLEW.cpp | 1 + editor/GenericDeathDialog.cpp | 1 + editor/HObject.cpp | 1 + editor/HRoom.cpp | 1 + editor/HTexture.cpp | 1 + editor/HView.cpp | 1 + editor/LevelDialog.cpp | 1 + editor/OrphanRemoveDlg.cpp | 1 + editor/PreferencesDialog.cpp | 1 + editor/SelectRangeDialog.cpp | 1 + editor/TableFileFilterMng.cpp | 1 + editor/TableManage.cpp | 1 + editor/TerrainSoundDialog.cpp | 1 + editor/TriggerDialog.cpp | 1 + editor/editorDoc.cpp | 1 + editor/levelkeypad.cpp | 1 + win32/winapp.cpp | 2 +- 17 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Descent3/SLEW.cpp b/Descent3/SLEW.cpp index a7d8a1334..9c9a7db51 100644 --- a/Descent3/SLEW.cpp +++ b/Descent3/SLEW.cpp @@ -197,6 +197,7 @@ #ifdef EDITOR #include "editor\mainfrm.h" #include "editor\d3edit.h" +#include "pserror.h" #endif #include diff --git a/editor/GenericDeathDialog.cpp b/editor/GenericDeathDialog.cpp index 2c9909359..f66cad2da 100644 --- a/editor/GenericDeathDialog.cpp +++ b/editor/GenericDeathDialog.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include "editor.h" #include "GenericDeathDialog.h" +#include "pserror.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/editor/HObject.cpp b/editor/HObject.cpp index 0898abe5d..cc4f283e1 100644 --- a/editor/HObject.cpp +++ b/editor/HObject.cpp @@ -233,6 +233,7 @@ #include "d3edit.h" #include "mono.h" +#include "pserror.h" #include "vclip.h" #include "terrain.h" #include "player.h" diff --git a/editor/HRoom.cpp b/editor/HRoom.cpp index 181eaf77b..5c86e8c8f 100644 --- a/editor/HRoom.cpp +++ b/editor/HRoom.cpp @@ -411,6 +411,7 @@ #include "terrain.h" #include "HTexture.h" #include "trigger.h" +#include "pserror.h" // Make the Marked room/face the current room/face void SetMarkedRoom() { diff --git a/editor/HTexture.cpp b/editor/HTexture.cpp index 1fcea7749..b2149ee10 100644 --- a/editor/HTexture.cpp +++ b/editor/HTexture.cpp @@ -169,6 +169,7 @@ #include "room.h" #include "descent.h" #include "erooms.h" +#include "pserror.h" #define HTEX_CALIB_VAL ((float)(1.0 / 128.0)) diff --git a/editor/HView.cpp b/editor/HView.cpp index b7c9ab609..b788f6501 100644 --- a/editor/HView.cpp +++ b/editor/HView.cpp @@ -122,6 +122,7 @@ #include "terrain.h" #include "erooms.h" #include "editor.h" +#include "pserror.h" #define FACE_VIEW_DIST 5.0 diff --git a/editor/LevelDialog.cpp b/editor/LevelDialog.cpp index 5f8d8a337..1e0c30e3b 100644 --- a/editor/LevelDialog.cpp +++ b/editor/LevelDialog.cpp @@ -27,6 +27,7 @@ #include "room.h" #include "ambient.h" #include "hlsoundlib.h" +#include "pserror.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/editor/OrphanRemoveDlg.cpp b/editor/OrphanRemoveDlg.cpp index 8f2060fe2..fd25da70f 100644 --- a/editor/OrphanRemoveDlg.cpp +++ b/editor/OrphanRemoveDlg.cpp @@ -57,6 +57,7 @@ #include "weaponpage.h" #include "ddio.h" #include "mem.h" +#include "pserror.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/editor/PreferencesDialog.cpp b/editor/PreferencesDialog.cpp index 05ba3458c..a92a025d2 100644 --- a/editor/PreferencesDialog.cpp +++ b/editor/PreferencesDialog.cpp @@ -104,6 +104,7 @@ #include "PreferencesDialog.h" #include "game.h" #include "pilot.h" +#include "pserror.h" #include "slew.h" #ifdef _DEBUG diff --git a/editor/SelectRangeDialog.cpp b/editor/SelectRangeDialog.cpp index 9ea6d8097..aa882f4db 100644 --- a/editor/SelectRangeDialog.cpp +++ b/editor/SelectRangeDialog.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "editor.h" +#include "pserror.h" #include "SelectRangeDialog.h" #include "terrain.h" diff --git a/editor/TableFileFilterMng.cpp b/editor/TableFileFilterMng.cpp index f8a2f31b9..49275e73d 100644 --- a/editor/TableFileFilterMng.cpp +++ b/editor/TableFileFilterMng.cpp @@ -193,6 +193,7 @@ #include "fireball.h" #include "mem.h" #include "polymodel.h" +#include "pserror.h" #include "ddio.h" #include "DallasUtilities.h" #include "matcen.h" diff --git a/editor/TableManage.cpp b/editor/TableManage.cpp index 3e8872233..3772e1a92 100644 --- a/editor/TableManage.cpp +++ b/editor/TableManage.cpp @@ -40,6 +40,7 @@ #include "cfile.h" // #include "AppDatabase.h" #include "mem.h" +#include "pserror.h" //////////////////////////////////////////////////////////////// // GenericPageNode Class Members diff --git a/editor/TerrainSoundDialog.cpp b/editor/TerrainSoundDialog.cpp index 66f8b0647..d6e2643ea 100644 --- a/editor/TerrainSoundDialog.cpp +++ b/editor/TerrainSoundDialog.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "editor.h" +#include "pserror.h" #include "TerrainSoundDialog.h" #ifdef _DEBUG diff --git a/editor/TriggerDialog.cpp b/editor/TriggerDialog.cpp index 8fb1e99c1..a26a65914 100644 --- a/editor/TriggerDialog.cpp +++ b/editor/TriggerDialog.cpp @@ -136,6 +136,7 @@ #include "FindIntersection.h" #include "erooms.h" #include "mono.h" +#include "pserror.h" #include "DallasMainDlg.h" diff --git a/editor/editorDoc.cpp b/editor/editorDoc.cpp index de0ed0dc3..949e1f093 100644 --- a/editor/editorDoc.cpp +++ b/editor/editorDoc.cpp @@ -88,6 +88,7 @@ #include "ddio.h" #include "manage.h" #include "DallasMainDlg.h" +#include "pserror.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/editor/levelkeypad.cpp b/editor/levelkeypad.cpp index 67e1083a8..6bb03d989 100644 --- a/editor/levelkeypad.cpp +++ b/editor/levelkeypad.cpp @@ -29,6 +29,7 @@ #include "aiambient.h" #include "objinfo.h" #include "game.h" +#include "pserror.h" #include "soundload.h" #ifdef _DEBUG diff --git a/win32/winapp.cpp b/win32/winapp.cpp index 2ddbf5168..47a889703 100644 --- a/win32/winapp.cpp +++ b/win32/winapp.cpp @@ -651,7 +651,7 @@ LRESULT WINAPI MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { case WM_DESTROY: // get window handle and clear it. if (i == MAX_WIN32APPS) - debug_break(); + DEBUG_BREAK(); Win32_AppObjects[i].hWnd = NULL; Win32_AppObjects[i].app = NULL; i = -1; From 0e959cb4dec48b89d7113a4a21cf6f796f0193a5 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sat, 5 Oct 2024 05:18:51 +0300 Subject: [PATCH 09/10] Change error message for Int3() --- ddebug/pserror.h | 2 +- netgames/includes/DMFC.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddebug/pserror.h b/ddebug/pserror.h index dfc3a0841..e27aa6766 100644 --- a/ddebug/pserror.h +++ b/ddebug/pserror.h @@ -215,7 +215,7 @@ static inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) { // Does a DEBUG_BREAK() if debugging is turned on. #define Int3() \ do { \ - LOG_ERROR.printf("Int3 at %s:%d.", __FILE__, __LINE__); \ + LOG_ERROR.printf("Fatal error at %s:%d.", __FILE__, __LINE__); \ DEBUG_BREAK(); \ } while (0) diff --git a/netgames/includes/DMFC.h b/netgames/includes/DMFC.h index b30ced7d6..e9066577c 100644 --- a/netgames/includes/DMFC.h +++ b/netgames/includes/DMFC.h @@ -316,7 +316,7 @@ #endif #define Int3() \ do { \ - mprintf(0, "Int3 at %s:%d.\n", __FILE__, __LINE__); \ + mprintf(0, "Fatal error at %s:%d.\n", __FILE__, __LINE__); \ DEBUG_BREAK(); \ } while (0) From 51da6aaae828d253c32befd492ed076e9afcda25 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sat, 5 Oct 2024 05:21:41 +0300 Subject: [PATCH 10/10] Remove HEAPCHECK() macro as unused --- ddebug/pserror.h | 15 --------------- netgames/includes/DMFC.h | 14 -------------- 2 files changed, 29 deletions(-) diff --git a/ddebug/pserror.h b/ddebug/pserror.h index e27aa6766..4daf644e9 100644 --- a/ddebug/pserror.h +++ b/ddebug/pserror.h @@ -228,24 +228,9 @@ static inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) { } \ } while (0) -#if defined(WIN32) - -#define HEAPCHECK() \ - do { \ - if (_heapchk() != _HEAPOK) \ - Int3(); \ - } while (0) - -#elif defined(POSIX) - -#define HEAPCHECK() - -#endif - #else #define DEBUG_BREAK() #define ASSERT(x) #define Int3() -#define HEAPCHECK() #endif #endif diff --git a/netgames/includes/DMFC.h b/netgames/includes/DMFC.h index e9066577c..be10f7305 100644 --- a/netgames/includes/DMFC.h +++ b/netgames/includes/DMFC.h @@ -332,20 +332,6 @@ #define DLLmprintf(...) DLLDebug_ConsolePrintf(__VA_ARGS__) -#if defined(WIN32) - -#define HEAPCHECK() \ - do { \ - if (_heapchk() != _HEAPOK) \ - Int3(); \ - } while (0) - -#elif defined(POSIX) - -#define HEAPCHECK() - -#endif - #else // Release build #ifdef DEBUG_BREAK