Merge pull request #614 from winterheart/ddebug-update

ddebug submodule update
This commit is contained in:
Louis Gombert 2024-10-05 17:21:19 +02:00 committed by GitHub
commit 7ca92bd1bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
160 changed files with 314 additions and 967 deletions

View File

@ -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
$<BUILD_INTERFACE:

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -113,18 +113,18 @@
* $NoKeywords: $
*/
#include <cstring>
#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 <string.h>
#include "pserror.h"
#include "joystick.h"
// all controller binding texts

View File

@ -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
}

View File

@ -861,6 +861,7 @@
#include "gamefont.h"
#include "renderobject.h"
#include "buddymenu.h"
#include "pserror.h"
#ifdef EDITOR
#include "editor\d3edit.h"

View File

@ -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"

View File

@ -63,13 +63,13 @@
#include <cstdio>
#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"

View File

@ -197,6 +197,7 @@
#ifdef EDITOR
#include "editor\mainfrm.h"
#include "editor\d3edit.h"
#include "pserror.h"
#endif
#include <cstdlib>

View File

@ -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"
@ -3214,55 +3215,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 *

View File

@ -143,6 +143,7 @@
#include "vecmat.h"
#include "textaux.h"
#include "hlsoundlib.h"
#include "pserror.h"
#include "soundload.h"
tceffect TCEffects[MAX_TCEFFECTS];

View File

@ -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;

View File

@ -936,6 +936,7 @@
#include "config.h"
#include "ObjScript.h"
#include "doorway.h"
#include "pserror.h"
#include "psrand.h"
#include "BOA.h"

View File

@ -48,12 +48,13 @@
* $NoKeywords: $
*/
#include "cstdint"
#include <cstring>
#include "vecmat.h"
#include "terrain.h"
#include "pstypes.h"
#include "findintersection.h"
#include "pserror.h"
#include "aiterrain.h"
#include <string.h>
#define AI_MAX_SEGS_CHECKED 200

View File

@ -82,6 +82,7 @@
#include "room.h"
#include "game.h"
#include "pserror.h"
#include "psrand.h"
#define MAX_AMBIENT_SOUND_PATTERNS 100

View File

@ -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;

View File

@ -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];

View File

@ -52,6 +52,7 @@
#include "mem.h"
#include "polymodel.h"
#include "object.h"
#include "pserror.h"
#include "psrand.h"
#define BSP_TREE_VERSION 10003

View File

@ -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"

View File

@ -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"

View File

@ -92,6 +92,7 @@
#include "mem.h"
#include "d3music.h"
#include "hlsoundlib.h"
#include "pserror.h"
#include "psrand.h"
/*

View File

@ -292,6 +292,7 @@
#include "D3ForceFeedback.h"
#include "hlsoundlib.h"
#include "ddio.h"
#include "pserror.h"
//////////////////////////////////////////////////////////////////////////////
#define IDV_KCONFIG 10

View File

@ -19,6 +19,7 @@
#include "d3music.h"
#include "log.h"
#include "music.h"
#include "pserror.h"
// generic constants
#define MUSIC_IDLE_TIME 240.0f // how many seconds before background music silences.

View File

@ -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 <http://www.gnu.org/licenses/>.
--- 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "d3serial.h"
#include "game.h"
#include "debug.h"
#include "descent.h"
#include <time.h>
#include "mono.h"
#include "cfile.h"
#include "program.h"
#include <fcntl.h>
#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; }

View File

@ -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 <http://www.gnu.org/licenses/>.
--- 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 <cstdint>
#include <ctime>
#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

View File

@ -586,6 +586,7 @@
#include "DeathInfo.h"
#include "AIGoal.h"
#include "viseffect.h"
#include "pserror.h"
#include "psrand.h"

View File

@ -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

View File

@ -183,7 +183,6 @@
#ifndef _GAME_H
#define _GAME_H
#include "pserror.h"
#include "renderer.h"
#include "object.h"

View File

@ -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];

View File

@ -296,6 +296,7 @@
#include "matcen.h"
#include "marker.h"
#include "d3music.h"
#include "pserror.h"
#include "weather.h"
// function prototypes.

View File

@ -200,6 +200,7 @@
#include "ship.h"
#include "3d.h"
#include "weapon.h"
#include "pserror.h"
#include "stringtable.h"
//////////////////////////////////////////////////////////////////////////////

View File

@ -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);

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -17,16 +17,15 @@
*/
// Lightmap info
#include "pstypes.h"
#include <cstdlib>
#include <cstring>
#include "lightmap_info.h"
#include "lightmap.h"
#include "mono.h"
#include "Ddgr.h"
#include "grdefs.h"
#include "pserror.h"
#include "renderer.h"
#include <stdlib.h>
#include <string.h>
#include "mem.h"
#include "dedicated_server.h"

View File

@ -39,8 +39,7 @@
#define LIGHTMAP_INFO_H
// Lightmap info header
#include "pstypes.h"
#include "pserror.h"
#include <cstdint>
#include "vecmat.h"
#define BAD_LMI_INDEX 65535

View File

@ -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) {

View File

@ -19,9 +19,6 @@
#ifndef LIST_H
#define LIST_H
#include "pstypes.h"
#include "pserror.h"
struct listnode {
void *data;
struct listnode *next;

View File

@ -217,6 +217,7 @@
#include "weather.h"
#include "cockpit.h"
#include "hud.h"
#include "pserror.h"
extern void PageInAllData();

View File

@ -96,6 +96,7 @@
#include "localization.h"
#include "log.h"
#include "mem.h"
#include "pserror.h"
struct tLangTag {
const char *tag;

View File

@ -23,6 +23,7 @@
#include "player.h"
#include "multi.h"
#include "game.h"
#include "pserror.h"
#ifdef _DEBUG
#include "AIMain.h"
#endif

View File

@ -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

View File

@ -135,6 +135,7 @@
#include "grtext.h"
#include "Mission.h"
#include "mission_download.h"
#include "pserror.h"
#include "renderer.h"
#include "unzip.h"

View File

@ -109,6 +109,8 @@
*
*/
#include <cstring>
#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 <malloc.h>
#include "mem.h"
#include <string.h>
#include "pserror.h"
// externed from newui.cpp
extern int UI_frame_result;

View File

@ -142,9 +142,9 @@
#include "player.h"
#include "ddio.h"
#include "pilot.h"
#include "pserror.h"
#include "Mission.h"
#include "stringtable.h"
#include "d3serial.h"
#include "ship.h"
#define WEAPONS_LOAD_UPDATE_INTERVAL 2.0
@ -193,9 +193,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();

View File

@ -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"

View File

@ -639,6 +639,7 @@
#include "LoadLevel.h"
#include "Mission.h"
#include "game2dll.h"
#include "pserror.h"
#include "stringtable.h"
// #define USE_DIRECTPLAY

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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);

View File

@ -628,8 +628,8 @@
#ifndef _OBJECT_H
#define _OBJECT_H
#include "pstypes.h"
#include "pserror.h"
#include <cstdint>
#include "object_external_struct.h"
#include "object_external.h"
@ -705,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);

View File

@ -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

View File

@ -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"

View File

@ -76,13 +76,13 @@
#include "..\neweditor\globals.h"
#endif
#include <stdlib.h>
#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"

View File

@ -19,8 +19,8 @@
#ifndef PROCEDURALS_H
#define PROCEDURALS_H
#include "pstypes.h"
#include "pserror.h"
#include <cstdint>
#include "fix.h"
#define MAX_PROC_ELEMENTS 8000

View File

@ -29,6 +29,7 @@
* $NoKeywords: $
*/
#include <algorithm>
#include <cstdlib>
#include <cstring>
@ -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 <algorithm>
// #define KATMAI
// Katmai enhanced rotate only in a release build, because not

View File

@ -608,6 +608,7 @@
#include "game2dll.h"
#include "marker.h"
#include "ship.h"
#include "pserror.h"
#include "psrand.h"
#ifdef EDITOR

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -16,13 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pstypes.h"
#include <cstdlib>
#include <cstring>
#include "special_face.h"
#include "mono.h"
#include <stdlib.h>
#include <string.h>
#include "mem.h"
#include "pserror.h"
#include "special_face.h"
int Num_of_special_faces = 0;
special_face SpecialFaces[MAX_SPECIAL_FACES];

View File

@ -19,8 +19,8 @@
#ifndef SPECIAL_FACE_H
#define SPECIAL_FACE_H
#include "pstypes.h"
#include "pserror.h"
#include <cstdint>
#include "vecmat.h"
#define BAD_SPECIAL_FACE_INDEX -1

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include "fireball.h"
#include "object.h"
@ -23,13 +24,9 @@
#include "polymodel.h"
#include "renderer.h"
#include "gametexture.h"
#include "Macros.h"
#include <stdlib.h>
#include "pserror.h"
#include "psrand.h"
#include <algorithm>
// Given an object, renders the representation of this splinter
void DrawSplinterObject(object *obj) {

View File

@ -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;

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -50,8 +50,7 @@
#ifndef __VISEFFECT_EXTERNAL_H_
#define __VISEFFECT_EXTERNAL_H_
#include "pstypes.h"
#include "pserror.h"
#include <cstdint>
#include "vecmat.h"
#define MAX_VIS_EFFECTS 5000

View File

@ -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 <stdlib.h>
#include "psrand.h"
weather Weather = {0};
int ThunderA_sound_handle = -1;

View File

@ -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);

View File

@ -10,6 +10,7 @@ set(CPPS
add_library(cfile STATIC ${HEADERS} ${CPPS})
target_link_libraries(cfile PRIVATE
ddebug
ddio
logger
mem

View File

@ -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})

View File

@ -1,8 +1,11 @@
set(HEADERS
debug.h
debugbreak.h
mono.h)
mono.h
pserror.h
)
set(CPPS
debug.cpp
error.cpp
$<$<PLATFORM_ID:Darwin,Linux,OpenBSD>:
lnxdebug.cpp
lnxmono.cpp
@ -22,8 +25,11 @@ target_include_directories(ddebug PUBLIC
PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h
)
target_link_libraries(ddebug PRIVATE
mem
$<$<PLATFORM_ID:Windows>:
mem
misc
>
PUBLIC
SDL2::SDL2
logger
)

31
ddebug/debug.cpp Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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;
}

View File

@ -163,26 +163,13 @@ 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()
#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 <windows.h>
long WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data);
#endif
#endif

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/* 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 <signal.h>
__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 */

View File

@ -66,20 +66,17 @@
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stdlib.h>
#include <string.h>
#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);
}

View File

@ -39,52 +39,29 @@
*/
#include <cstdio>
#include <SDL_assert.h>
#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", topstring, title, "System Error", bottomstring);
debug_break();
SDL_TriggerBreakpoint();
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;
}

View File

@ -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, ...) {}

View File

@ -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

View File

@ -148,9 +148,11 @@
#ifndef PSERROR_H
#define PSERROR_H
#include <cassert>
#include <SDL_assert.h>
#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,77 +184,53 @@ 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 <cstdlib>
// 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("Fatal error 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)
#define HEAPCHECK() \
do { \
if (_heapchk() != _HEAPOK) \
Int3(); \
} while (0)
#elif defined(POSIX)
#include <SDL.h>
#define ASSERT(x) SDL_assert(x)
#define HEAPCHECK()
#endif
#else
#define DEBUG_BREAK()
#define ASSERT(x)
#define Int3()
#define HEAPCHECK()
#endif
#endif

View File

@ -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
@ -237,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<char>(strlen(topstring) + strlen(bottomstring) + 5);
wsprintf(tmpbuf, "%s\r\n\r\n%s", topstring, bottomstring);

View File

@ -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

View File

@ -32,7 +32,6 @@ target_link_libraries(ddio PRIVATE
ddebug
logger
mem
misc
)
target_include_directories(ddio PUBLIC
$<BUILD_INTERFACE:

View File

@ -41,7 +41,6 @@
*/
#include <filesystem>
#include "pstring.h"
#include "forcefeedback.h"
bool ddForce_found; // a Force Feedback device was found

View File

@ -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];

View File

@ -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

View File

@ -22,6 +22,7 @@
#include "stdafx.h"
#include "editor.h"
#include "GenericDeathDialog.h"
#include "pserror.h"
#ifdef _DEBUG
#define new DEBUG_NEW

View File

@ -233,6 +233,7 @@
#include "d3edit.h"
#include "mono.h"
#include "pserror.h"
#include "vclip.h"
#include "terrain.h"
#include "player.h"

View File

@ -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() {

View File

@ -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))

View File

@ -122,6 +122,7 @@
#include "terrain.h"
#include "erooms.h"
#include "editor.h"
#include "pserror.h"
#define FACE_VIEW_DIST 5.0

View File

@ -27,6 +27,7 @@
#include "room.h"
#include "ambient.h"
#include "hlsoundlib.h"
#include "pserror.h"
#ifdef _DEBUG
#define new DEBUG_NEW

View File

@ -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);

View File

@ -57,6 +57,7 @@
#include "weaponpage.h"
#include "ddio.h"
#include "mem.h"
#include "pserror.h"
#ifdef _DEBUG
#define new DEBUG_NEW

Some files were not shown because too many files have changed in this diff Show More