Avoid using ASSERT in interface headers

This commit is contained in:
Azamat H. Hackimov 2024-09-23 04:16:34 +03:00
parent a59503f881
commit cc9e054509
75 changed files with 137 additions and 83 deletions

View File

@ -475,6 +475,7 @@
#include "objinfo.h" #include "objinfo.h"
#include "AIMain.h" #include "AIMain.h"
#include "room.h" #include "room.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
#include "BOA.h" #include "BOA.h"
#include "findintersection.h" #include "findintersection.h"

View File

@ -92,10 +92,10 @@
#include "ConfigItem.h" #include "ConfigItem.h"
#include "newui.h" #include "newui.h"
#include "descent.h"
#include "log.h" #include "log.h"
#include "gamefont.h" #include "gamefont.h"
#include "mem.h" #include "mem.h"
#include "pserror.h"
#include "stringtable.h" #include "stringtable.h"
#define UI_CHECKBOX_OFF_CHAR 28 #define UI_CHECKBOX_OFF_CHAR 28

View File

@ -113,18 +113,18 @@
* $NoKeywords: $ * $NoKeywords: $
*/ */
#include <cstring>
#include "CtlCfgElem.h" #include "CtlCfgElem.h"
#include "descent.h" #include "descent.h"
#include "Macros.h" #include "Macros.h"
#include "ddio.h" #include "ddio.h"
#include "application.h"
#include "renderer.h" #include "renderer.h"
#include "stringtable.h" #include "stringtable.h"
#include "gamefont.h" #include "gamefont.h"
#include "localization.h" #include "localization.h"
#include "pserror.h"
#include <string.h>
#include "joystick.h" #include "joystick.h"
// all controller binding texts // all controller binding texts

View File

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

View File

@ -61,15 +61,8 @@
*/ */
#include "NewPyroGauges.h" #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 "3d.h"
#include "pserror.h"
#include "renderer.h" #include "renderer.h"
#include "gametexture.h" #include "gametexture.h"

View File

@ -63,13 +63,13 @@
#include <cstdio> #include <cstdio>
#include "bitmap.h" #include "bitmap.h"
#include "player.h"
#include "pilot.h" #include "pilot.h"
#include "cfile.h" #include "cfile.h"
#include "log.h" #include "log.h"
#include "ddio.h" #include "ddio.h"
#include "manage.h" #include "manage.h"
#include "PilotPicsAPI.h" #include "PilotPicsAPI.h"
#include "pserror.h"
#include "mem.h" #include "mem.h"
#define PILOTPIC_DATABASE_HOG "PPics.Hog" #define PILOTPIC_DATABASE_HOG "PPics.Hog"

View File

@ -519,6 +519,7 @@
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "soundload.h" #include "soundload.h"
#include "textaux.h" #include "textaux.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
#include "controls.h" #include "controls.h"
#include "d3music.h" #include "d3music.h"

View File

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

View File

@ -56,6 +56,7 @@
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "log.h" #include "log.h"
#include "mem.h" #include "mem.h"
#include "pserror.h"
#include "textaux.h" #include "textaux.h"
int glitch_dx = 0, glitch_dy = 0; int glitch_dx = 0, glitch_dy = 0;

View File

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

View File

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

View File

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

View File

@ -24,6 +24,7 @@
#include "demofile.h" #include "demofile.h"
#include "polymodel.h" #include "polymodel.h"
#include "objinfo.h" #include "objinfo.h"
#include "pserror.h"
/* // Determines the necessary orientation and position of the moving object /* // Determines the necessary orientation and position of the moving object
f_use_uvec = true; f_use_uvec = true;

View File

@ -104,9 +104,9 @@
#include "mem.h" #include "mem.h"
#include "vecmat.h" #include "vecmat.h"
#include "terrain.h" #include "terrain.h"
#include "room.h"
#include "findintersection.h" #include "findintersection.h"
#include "BOA.h" #include "BOA.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
bn_list BNode_terrain_list[8]; bn_list BNode_terrain_list[8];

View File

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

View File

@ -200,6 +200,7 @@
#include "log.h" #include "log.h"
#include "ship.h" #include "ship.h"
#include "player.h" #include "player.h"
#include "pserror.h"
#include "room.h" #include "room.h"
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "sounds.h" #include "sounds.h"

View File

@ -291,6 +291,7 @@
#include "terrain.h" #include "terrain.h"
#include "physics.h" #include "physics.h"
#include "pilot.h" #include "pilot.h"
#include "pserror.h"
#include "hud.h" #include "hud.h"
#include "bitmap.h" #include "bitmap.h"
#include "game.h" #include "game.h"

View File

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

View File

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

View File

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

View File

@ -294,6 +294,7 @@
#include "osiris_dll.h" #include "osiris_dll.h"
#include "args.h" #include "args.h"
#include "gamecinematics.h" #include "gamecinematics.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
#include "cockpit.h" #include "cockpit.h"
// We borrow a lot of code from the savegame system // We borrow a lot of code from the savegame system

View File

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

View File

@ -73,6 +73,7 @@
#include "spew.h" #include "spew.h"
#include "mem.h" #include "mem.h"
#include "player.h" #include "player.h"
#include "pserror.h"
int Num_events = 0; int Num_events = 0;
game_event GameEvent[MAX_EVENTS]; game_event GameEvent[MAX_EVENTS];

View File

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

View File

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

View File

@ -110,6 +110,7 @@
#include "mem.h" #include "mem.h"
#include "bitmap.h" #include "bitmap.h"
#include "manage.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 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); static int CreateHotSpotMap(const char *map, int width, int height, hotspotmap_t *hsmap);

View File

@ -431,6 +431,7 @@
#include "d3music.h" #include "d3music.h"
#include "demofile.h" #include "demofile.h"
#include "stringtable.h" #include "stringtable.h"
#include "pserror.h"
#include "pstring.h" #include "pstring.h"
#include "config.h" #include "config.h"
#include "gamecinematics.h" #include "gamecinematics.h"

View File

@ -350,6 +350,7 @@
#include "sounds.h" #include "sounds.h"
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "args.h" #include "args.h"
#include "pserror.h"
#define HUD_MESSAGE_NORMAL 0 #define HUD_MESSAGE_NORMAL 0
#define HUD_MESSAGE_BLINKING 1 #define HUD_MESSAGE_BLINKING 1

View File

@ -175,6 +175,7 @@
#include "osiris_share.h" #include "osiris_share.h"
#include "multisafe.h" #include "multisafe.h"
#include "multi_world_state.h" #include "multi_world_state.h"
#include "pserror.h"
#define GOAL_MESSAGE_TIME 10.0 #define GOAL_MESSAGE_TIME 10.0
#define GOAL_MESSAGE_COLOR GR_RGB(0, 242, 148) #define GOAL_MESSAGE_COLOR GR_RGB(0, 242, 148)

View File

@ -43,6 +43,7 @@
#include "config.h" #include "config.h"
#include "dedicated_server.h" #include "dedicated_server.h"
#include "objinfo.h" #include "objinfo.h"
#include "pserror.h"
#define NUM_DYNAMIC_CLASSES 7 #define NUM_DYNAMIC_CLASSES 7
#define MAX_DYNAMIC_FACES 2000 #define MAX_DYNAMIC_FACES 2000

View File

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

View File

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

View File

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

View File

@ -175,6 +175,7 @@
#include "ObjScript.h" #include "ObjScript.h"
#include "psrand.h" #include "psrand.h"
#include "demofile.h" #include "demofile.h"
#include "pserror.h"
// Beginning of the real file // Beginning of the real file
#define LEVEL_DATA_MATCEN_VERSION 1 #define LEVEL_DATA_MATCEN_VERSION 1

View File

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

View File

@ -109,6 +109,8 @@
* *
*/ */
#include <cstring>
#include "mmItem.h" #include "mmItem.h"
#include "game.h" #include "game.h"
#include "program.h" #include "program.h"
@ -117,12 +119,9 @@
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "soundload.h" #include "soundload.h"
#include "d3music.h" #include "d3music.h"
#include "ddio.h" #include "ddio.h"
// #include <malloc.h>
#include "mem.h" #include "mem.h"
#include "pserror.h"
#include <string.h>
// externed from newui.cpp // externed from newui.cpp
extern int UI_frame_result; extern int UI_frame_result;

View File

@ -142,6 +142,7 @@
#include "player.h" #include "player.h"
#include "ddio.h" #include "ddio.h"
#include "pilot.h" #include "pilot.h"
#include "pserror.h"
#include "Mission.h" #include "Mission.h"
#include "stringtable.h" #include "stringtable.h"
#include "ship.h" #include "ship.h"

View File

@ -263,6 +263,7 @@
#include "Mission.h" #include "Mission.h"
#include "stringtable.h" #include "stringtable.h"
#include "pilot.h" #include "pilot.h"
#include "pserror.h"
#include "ship.h" #include "ship.h"
#include "args.h" #include "args.h"
#include "ui.h" #include "ui.h"

View File

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

View File

@ -331,6 +331,7 @@
#include "manage.h" #include "manage.h"
#include "menu.h" #include "menu.h"
#include "pilot.h" #include "pilot.h"
#include "pserror.h"
#include "ddio.h" #include "ddio.h"
#include "objinfo.h" #include "objinfo.h"
#include "ship.h" #include "ship.h"

View File

@ -657,6 +657,7 @@
#include "sounds.h" #include "sounds.h"
#include "ship.h" #include "ship.h"
#include "player.h" #include "player.h"
#include "pserror.h"
#include "object_lighting.h" #include "object_lighting.h"
#include "soundload.h" #include "soundload.h"
#include "streamaudio.h" #include "streamaudio.h"

View File

@ -304,7 +304,6 @@
#include "log.h" #include "log.h"
#include "newui.h" #include "newui.h"
#include "game.h" #include "game.h"
#include "descent.h"
#include "renderer.h" #include "renderer.h"
#include "3d.h" #include "3d.h"
#include "gamefont.h" #include "gamefont.h"
@ -314,6 +313,7 @@
#include "newui_core.h" #include "newui_core.h"
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "dedicated_server.h" #include "dedicated_server.h"
#include "pserror.h"
#define MSGBOX_HEIGHT msgbox.H() #define MSGBOX_HEIGHT msgbox.H()
#define BTN_WIDTH 96 #define BTN_WIDTH 96

View File

@ -109,6 +109,7 @@
#include "game.h" #include "game.h"
#include "log.h" #include "log.h"
#include "newui.h" #include "newui.h"
#include "pserror.h"
#include "pstring.h" #include "pstring.h"
#include "renderer.h" #include "renderer.h"
#include "stringtable.h" #include "stringtable.h"

View File

@ -3327,6 +3327,24 @@ bool ObjGetAnimUpdate(uint16_t objnum, custom_anim *multi_anim_info) {
return false; 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) { void SetObjectControlType(object *obj, int control_type) {
ASSERT(obj); ASSERT(obj);
ASSERT(OBJNUM(obj) >= 0 && OBJNUM(obj) < MAX_OBJECTS); ASSERT(OBJNUM(obj) >= 0 && OBJNUM(obj) < MAX_OBJECTS);

View File

@ -632,7 +632,6 @@
#include "object_external_struct.h" #include "object_external_struct.h"
#include "object_external.h" #include "object_external.h"
#include "pserror.h"
/* /*
* CONSTANTS * CONSTANTS
@ -706,24 +705,7 @@ extern int16_t BigObjectList[MAX_BIG_OBJECTS]; // DAJ_MR utb int
*/ */
// Set the dead flag for an object // 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); 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 SetObjectControlType(object *obj, int control_type); void SetObjectControlType(object *obj, int control_type);

View File

@ -108,6 +108,7 @@
#include "hlsoundlib.h" #include "hlsoundlib.h"
#include "soundload.h" #include "soundload.h"
#include "hud.h" #include "hud.h"
#include "pserror.h"
#include "stringtable.h" #include "stringtable.h"
// How far the headlight casts light // How far the headlight casts light

View File

@ -597,6 +597,7 @@
#include "newui.h" #include "newui.h"
#include "pilot.h" #include "pilot.h"
#include "polymodel.h" #include "polymodel.h"
#include "pserror.h"
#include "pstring.h" #include "pstring.h"
#include "renderer.h" #include "renderer.h"
#include "render.h" #include "render.h"

View File

@ -76,13 +76,13 @@
#include "..\neweditor\globals.h" #include "..\neweditor\globals.h"
#endif #endif
#include <stdlib.h>
#include "object.h" #include "object.h"
#include "viseffect.h" #include "viseffect.h"
#include "render.h" #include "render.h"
#include "renderobject.h" #include "renderobject.h"
#include "room.h" #include "room.h"
#include "postrender.h" #include "postrender.h"
#include "pserror.h"
#include "config.h" #include "config.h"
#include "terrain.h" #include "terrain.h"
#include "renderer.h" #include "renderer.h"

View File

@ -29,6 +29,7 @@
* $NoKeywords: $ * $NoKeywords: $
*/ */
#include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -58,6 +59,7 @@
#include "TelComAutoMap.h" #include "TelComAutoMap.h"
#include "postrender.h" #include "postrender.h"
#include "mem.h" #include "mem.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
#include "player.h" #include "player.h"
#include "args.h" #include "args.h"
@ -65,8 +67,6 @@
#include "editor\d3edit.h" #include "editor\d3edit.h"
#endif #endif
#include <algorithm>
// #define KATMAI // #define KATMAI
// Katmai enhanced rotate only in a release build, because not // Katmai enhanced rotate only in a release build, because not

View File

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

View File

@ -36,6 +36,7 @@
#include "SmallViews.h" #include "SmallViews.h"
#include "physics.h" #include "physics.h"
#include "AIMain.h" #include "AIMain.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
// Fires a multiplayer and AI on/off weapon // Fires a multiplayer and AI on/off weapon

View File

@ -416,6 +416,7 @@
#include "multi_world_state.h" #include "multi_world_state.h"
#include "damage_external.h" #include "damage_external.h"
#include "descent.h" #include "descent.h"
#include "pserror.h"
#ifdef EDITOR #ifdef EDITOR
#include "editor\editor_lighting.h" #include "editor\editor_lighting.h"
#endif #endif

View File

@ -203,6 +203,7 @@
#include "log.h" #include "log.h"
#include "sounds.h" #include "sounds.h"
#include "pilot.h" #include "pilot.h"
#include "pserror.h"
#include "joystick.h" #include "joystick.h"
#define LVLRES_FADEIN_TIME 0.50f #define LVLRES_FADEIN_TIME 0.50f

View File

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

View File

@ -108,6 +108,17 @@ int Terrain_checksum = -1;
uint8_t Terrain_occlusion_map[256][32]; uint8_t Terrain_occlusion_map[256][32];
int Terrain_occlusion_checksum = -2; 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 // returns the index of the highest float
int GetHighestDelta(float *deltas, int count) { int GetHighestDelta(float *deltas, int count) {
int high_index = -999; int high_index = -999;

View File

@ -214,14 +214,7 @@ extern int16_t Terrain_seg_render_objs[];
#ifdef RELEASE #ifdef RELEASE
#define TERRAIN_REGION(x) ((Terrain_seg[0x7FFFFFFF & x].flags & TFM_REGION_MASK) >> 5) #define TERRAIN_REGION(x) ((Terrain_seg[0x7FFFFFFF & x].flags & TFM_REGION_MASK) >> 5)
#else // debug(-ish) builds - check if x is valid #else // debug(-ish) builds - check if x is valid
static inline int TERRAIN_REGION(int x) { 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 #endif
extern terrain_sky Terrain_sky; extern terrain_sky Terrain_sky;

View File

@ -454,6 +454,7 @@
#include "physics.h" #include "physics.h"
#include "player.h" #include "player.h"
#include "polymodel.h" #include "polymodel.h"
#include "pserror.h"
#include "psrand.h" #include "psrand.h"
#include "room.h" #include "room.h"
#include "terrain.h" #include "terrain.h"

View File

@ -26,9 +26,10 @@ target_include_directories(ddebug PUBLIC
PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h
) )
target_link_libraries(ddebug PRIVATE target_link_libraries(ddebug PRIVATE
logger
$<$<PLATFORM_ID:Windows>: $<$<PLATFORM_ID:Windows>:
mem mem
misc misc
> >
PUBLIC
logger
) )

View File

@ -400,22 +400,26 @@
#endif // OS check #endif // OS check
#else // Release build #else // Release build
#ifdef DEBUG_BREAK #ifdef DEBUG_BREAK
#undef DEBUG_BREAK #undef DEBUG_BREAK
#define DEBUG_BREAK()
#endif #endif
#define DEBUG_BREAK()
#define DLLASSERT(x) #define DLLASSERT(x)
#define DLLmprintf(...) #define DLLmprintf(...)
#ifdef Int3 #ifdef Int3
#undef Int3 #undef Int3
#define Int3()
#endif #endif
#define Int3() #define Int3()
#ifdef ASSERT #ifdef ASSERT
#undef ASSERT #undef ASSERT
#endif
#define ASSERT(x) #define ASSERT(x)
#endif
#endif #endif // #ifndef RELEASE
#ifdef mprintf // undefine mprintf and redirect it to use DLLmprintf #ifdef mprintf // undefine mprintf and redirect it to use DLLmprintf
#undef mprintf #undef mprintf

View File

@ -294,6 +294,7 @@
#include "directplay.h" #include "directplay.h"
#include "dplay.h" #include "dplay.h"
#include "dplobby.h" #include "dplobby.h"
#include "module.h"
typedef int socklen_t; typedef int socklen_t;
#endif #endif

View File

@ -33,6 +33,7 @@
#include "physics.h" #include "physics.h"
#include "player.h" #include "player.h"
#include "polymodel.h" #include "polymodel.h"
#include "pserror.h"
#include "terrain.h" #include "terrain.h"
#include "vecmat.h" #include "vecmat.h"
#include "viseffect.h" #include "viseffect.h"

View File

@ -59,7 +59,7 @@
#include "application.h" #include "application.h"
#include "soundload.h" #include "soundload.h"
#include "gametexture.h" #include "gametexture.h"
#include "pserror.h"
static llsGeometry *Geometry = NULL; static llsGeometry *Geometry = NULL;
static int16_t Sound_room_list[SOUND_RENDER_ROOM_LIMIT + 1]; static int16_t Sound_room_list[SOUND_RENDER_ROOM_LIMIT + 1];

View File

@ -123,7 +123,9 @@
#include <cstring> #include <cstring>
#include "pserror.h"
#include "UIlib.h" #include "UIlib.h"
#include "ui.h"
#if defined(POSIX) #if defined(POSIX)
int UIButton::m_ButtonFont; 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); 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 // sets the background bitmap for a specified button state
void UIButton::SetStateItem(int state, UIItem *item) { void UIButton::SetStateItem(int state, UIItem *item) {
ASSERT(state < UI_BTS_NUM); ASSERT(state < UI_BTS_NUM);
@ -172,6 +179,11 @@ void UIButton::SetStateItem(int state, UIItem *item) {
m_Items[state] = item->CopyUIItem(); 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 // sets the background color for a specified button state
void UIButton::SetColor(int state, ddgr_color col) { void UIButton::SetColor(int state, ddgr_color col) {
ASSERT(state < UI_BTS_NUM); ASSERT(state < UI_BTS_NUM);

View File

@ -60,6 +60,7 @@
#include "UIlib.h" #include "UIlib.h"
#include "grtext.h" #include "grtext.h"
#include "mem.h" #include "mem.h"
#include "pserror.h"
#include "textaux.h" #include "textaux.h"
#define CONSOLE_LINE_FILLER 128 #define CONSOLE_LINE_FILLER 128

View File

@ -141,7 +141,7 @@
#include "log.h" #include "log.h"
#include "Macros.h" #include "Macros.h"
#include "mem.h" #include "mem.h"
#include "pserror.h"
static UIEdit *UI_current_editbox = NULL; static UIEdit *UI_current_editbox = NULL;

View File

@ -121,6 +121,7 @@
#include "UIlib.h" #include "UIlib.h"
#include "Macros.h" #include "Macros.h"
#include "pserror.h"
int UIGadget::m_LastKey = 0; int UIGadget::m_LastKey = 0;
int UIGadget::m_LastKeyCount = 0; int UIGadget::m_LastKeyCount = 0;

View File

@ -49,6 +49,7 @@
#include "UIlib.h" #include "UIlib.h"
#include "mem.h" #include "mem.h"
#include "pserror.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// UIGroup // UIGroup

View File

@ -78,6 +78,7 @@
*/ */
#include "UIlib.h" #include "UIlib.h"
#include "pserror.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// UIHotspot // UIHotspot

View File

@ -162,6 +162,7 @@
#include "UIlib.h" #include "UIlib.h"
#include "log.h" #include "log.h"
#include "pserror.h"
#define SCROLL_BUTTON_GAP 4 #define SCROLL_BUTTON_GAP 4

View File

@ -40,6 +40,7 @@
#include "UIlib.h" #include "UIlib.h"
#include "log.h" #include "log.h"
#include "pserror.h"
UIObject::UIObject() { UIObject::UIObject() {
m_X = m_Y = 0; m_X = m_Y = 0;

View File

@ -62,6 +62,7 @@
*/ */
#include "UIlib.h" #include "UIlib.h"
#include "pserror.h"
// Construction and destruction // Construction and destruction

View File

@ -170,6 +170,7 @@
#include "application.h" #include "application.h"
#include "bitmap.h" #include "bitmap.h"
#include "log.h" #include "log.h"
#include "pserror.h"
#include "renderer.h" #include "renderer.h"
#include "Macros.h" #include "Macros.h"

View File

@ -152,6 +152,7 @@
#include "UIlib.h" #include "UIlib.h"
#include "Macros.h" #include "Macros.h"
#include "log.h" #include "log.h"
#include "pserror.h"
// the window font for all windows // the window font for all windows
int UIWindow::m_WindowFont = 0; int UIWindow::m_WindowFont = 0;

11
ui/ui.h
View File

@ -270,7 +270,6 @@
#include <cstdint> #include <cstdint>
#include "grdefs.h" #include "grdefs.h"
#include "pserror.h"
#include "uires.h" #include "uires.h"
// Class identification // Class identification
@ -554,15 +553,9 @@ private:
protected: protected:
int m_State; // state of button int m_State; // state of button
UIItem *GetStateItem(int state) { UIItem *GetStateItem(int state);
ASSERT(state < UI_BTS_NUM);
return m_Items[state];
};
int GetColor(int state) const { int GetColor(int state) const;
ASSERT(state < UI_BTS_NUM);
return m_Colors[state];
};
public: public:
static void SetDefaultFont(int font) { // sets the button font static void SetDefaultFont(int font) { // sets the button font

View File

@ -146,9 +146,8 @@
* $NoKeywords: $ * $NoKeywords: $
*/ */
#include <string.h> #include <cmath>
#include <stdlib.h> #include <cstring>
#include <math.h>
#include "vecmat.h" #include "vecmat.h"
#include "mono.h" #include "mono.h"
@ -160,7 +159,7 @@ const matrix Identity_matrix = IDENTITY_MATRIX;
void vm_AverageVector(vector *a, int num) { void vm_AverageVector(vector *a, int num) {
// Averages a vector. ie divides each component of vector a by 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->x = a->x / (float)num;
a->y = a->y / (float)num; a->y = a->y / (float)num;
a->z = a->z / (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 // Divides a vector into n portions
// Dest can equal src // Dest can equal src
assert(n != 0); ASSERT(n != 0);
dest->x = src->x / n; dest->x = src->x / n;
dest->y = src->y / n; dest->y = src->y / n;
dest->z = src->z / n; dest->z = src->z / n;
@ -325,7 +324,7 @@ void vm_TransposeMatrix(matrix *m) {
void vm_MatrixMulVector(vector *result, vector *v, matrix *m) { void vm_MatrixMulVector(vector *result, vector *v, matrix *m) {
// Rotates a vector thru a matrix // Rotates a vector thru a matrix
assert(result != v); ASSERT(result != v);
result->x = *v * m->rvec; result->x = *v * m->rvec;
result->y = *v * m->uvec; 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 // Multiply a vector times the transpose of a matrix
void vm_VectorMulTMatrix(vector *result, vector *v, matrix *m) { 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->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); 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) { void vm_MatrixMul(matrix *dest, matrix *src0, matrix *src1) {
// For multiplying two 3x3 matrices together // 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->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); 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) { void vm_MatrixMulTMatrix(matrix *dest, matrix *src0, matrix *src1) {
// For multiplying two 3x3 matrices together // 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->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; dest->uvec.x = src0->rvec.x * src1->rvec.y + src0->uvec.x * src1->uvec.y + src0->fvec.x * src1->fvec.y;