Skip to content

Commit cbfc718

Browse files
authored
fix(debug): Replace NDEBUG preprocessor with RTS_DEBUG or RTS_RELEASE (#1791)
1 parent 5b5a973 commit cbfc718

File tree

10 files changed

+51
-58
lines changed

10 files changed

+51
-58
lines changed

Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool AABoxCollisionTestClass::Cull(const AABoxClass & box)
9999
void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation)
100100
{
101101

102-
#ifndef NDEBUG
102+
#ifdef RTS_DEBUG
103103

104104
int i;
105105
Matrix3D tm(1);
@@ -156,9 +156,7 @@ void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation)
156156
if (realmax.Z <= pts[i].Z) realmax.Z = pts[i].Z;
157157
}
158158

159-
160-
#endif
161-
159+
#endif // RTS_DEBUG
162160

163161
// rotate the test by the desired rotation about the Z axis, special cased for
164162
// 90 degree rotations about Z. arbitrary rotations cause the axis aligned
@@ -216,13 +214,13 @@ void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation)
216214
break;
217215
}
218216

219-
#ifndef NDEBUG
217+
#ifdef RTS_DEBUG
220218

221219
assert((Box.Center - realcenter).Length() < 0.001f);
222220
assert((SweepMin - realmin).Length() < 0.001f);
223221
assert((SweepMax - realmax).Length() < 0.001f);
224222

225-
#endif
223+
#endif // RTS_DEBUG
226224
}
227225

228226

Core/Libraries/Source/WWVegas/WWLib/ini.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2284,7 +2284,7 @@ void INIClass::DuplicateCRCError(const char *message, const char *section, const
22842284
OutputDebugString(buffer);
22852285
assert(0);
22862286

2287-
#ifdef NDEBUG
2287+
#ifdef RTS_RELEASE
22882288
#ifdef _WINDOWS
22892289
MessageBox(0, buffer, "Duplicate CRC in INI file.", MB_ICONSTOP | MB_OK);
22902290
#endif

Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
/* Help the optimizer with register allocation.
201201
* Don't activate this macro for a fair comparision with other algorithms.
202202
*/
203-
#if 1 && defined(NDEBUG) && !defined(__BOUNDS_CHECKING_ON)
203+
#if 1 && defined(RTS_RELEASE) && !defined(__BOUNDS_CHECKING_ON)
204204
# if defined(__GNUC__) && defined(__i386__)
205205
# if !defined(LZO_OPTIMIZE_GNUC_i386_IS_BUGGY)
206206
# define LZO_OPTIMIZE_GNUC_i386

Core/Libraries/Source/WWVegas/WWLib/refcount.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
// TheSuperHackers @build feliwir 17/04/2025 include __debugbreak macros
4545
#include <Utility/intrin_compat.h>
4646

47-
#ifndef NDEBUG
47+
#ifdef RTS_DEBUG
4848

4949
// #define PARANOID_REFCOUNTS
5050

@@ -161,14 +161,12 @@ void RefCountClass::Inc_Total_Refs(const RefCountClass * obj)
161161
assert(Validate_Active_Ref(obj));
162162
#endif
163163
TotalRefs++;
164-
165164
}
166165

167166
// SKB 7/21/99 Set BreakOnRefernce to a pointer and it will break when called.
168167
// This is used for debugging, please do not deleted.
169168
RefCountClass* BreakOnReference = 0;
170169

171-
#ifndef NDEBUG
172170
void RefCountClass::Add_Ref(void) const
173171
{
174172
NumRefs++;
@@ -179,7 +177,6 @@ void RefCountClass::Add_Ref(void) const
179177
}
180178
Inc_Total_Refs(this);
181179
}
182-
#endif
183180

184181
/***********************************************************************************************
185182
* RefCountClass::Validate_Active_Ref -- decrements the total reference count *
@@ -206,8 +203,4 @@ void RefCountClass::Dec_Total_Refs(const RefCountClass * obj)
206203
}
207204
}
208205

209-
210-
211-
#endif
212-
213-
206+
#endif // RTS_DEBUG

Core/Libraries/Source/WWVegas/WWLib/refcount.h

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
class RefCountClass;
4444

4545

46-
#ifndef NDEBUG
46+
#ifdef RTS_DEBUG
4747

4848
struct ActiveRefStruct
4949
{
@@ -59,7 +59,7 @@ struct ActiveRefStruct
5959
#define NEW_REF( C, P ) ( W3DNEW C P )
6060
#define SET_REF_OWNER( P ) P
6161

62-
#endif
62+
#endif // RTS_DEBUG
6363

6464

6565
/*
@@ -101,31 +101,31 @@ class RefCountClass
101101
{
102102
public:
103103

104-
RefCountClass(void) :
105-
NumRefs(1)
106-
#ifndef NDEBUG
107-
,ActiveRefNode(this)
108-
#endif
104+
RefCountClass(void)
105+
: NumRefs(1)
106+
#ifdef RTS_DEBUG
107+
, ActiveRefNode(this)
108+
#endif
109109
{
110-
#ifndef NDEBUG
110+
#ifdef RTS_DEBUG
111111
Add_Active_Ref(this);
112112
Inc_Total_Refs(this);
113-
#endif
113+
#endif
114114
}
115115

116116
/*
117117
** The reference counter value cannot be copied.
118118
*/
119-
RefCountClass(const RefCountClass & ) :
120-
NumRefs(1)
121-
#ifndef NDEBUG
122-
,ActiveRefNode(this)
123-
#endif
119+
RefCountClass(const RefCountClass & )
120+
: NumRefs(1)
121+
#ifdef RTS_DEBUG
122+
, ActiveRefNode(this)
123+
#endif
124124
{
125-
#ifndef NDEBUG
125+
#ifdef RTS_DEBUG
126126
Add_Active_Ref(this);
127127
Inc_Total_Refs(this);
128-
#endif
128+
#endif
129129
}
130130

131131
RefCountClass& operator=(const RefCountClass&) { return *this; }
@@ -134,24 +134,26 @@ class RefCountClass
134134
** Add_Ref, call this function if you are going to keep a pointer
135135
** to this object.
136136
*/
137-
#ifdef NDEBUG
138-
WWINLINE void Add_Ref(void) const { NumRefs++; }
139-
#else
137+
#ifdef RTS_DEBUG
140138
void Add_Ref(void) const;
139+
#else
140+
WWINLINE void Add_Ref(void) const { NumRefs++; }
141141
#endif
142142

143143
/*
144144
** Release_Ref, call this function when you no longer need the pointer
145145
** to this object.
146146
*/
147-
WWINLINE void Release_Ref(void) const {
148-
#ifndef NDEBUG
149-
Dec_Total_Refs(this);
150-
#endif
151-
NumRefs--;
152-
WWASSERT(NumRefs >= 0);
153-
if (NumRefs == 0) const_cast<RefCountClass*>(this)->Delete_This();
154-
}
147+
WWINLINE void Release_Ref(void) const
148+
{
149+
#ifdef RTS_DEBUG
150+
Dec_Total_Refs(this);
151+
#endif
152+
NumRefs--;
153+
WWASSERT(NumRefs >= 0);
154+
if (NumRefs == 0)
155+
const_cast<RefCountClass*>(this)->Delete_This();
156+
}
155157

156158

157159
/*
@@ -180,9 +182,9 @@ class RefCountClass
180182
*/
181183
virtual ~RefCountClass(void)
182184
{
183-
#ifndef NDEBUG
185+
#ifdef RTS_DEBUG
184186
Remove_Active_Ref(this);
185-
#endif
187+
#endif
186188
WWASSERT(NumRefs == 0);
187189
}
188190

@@ -211,7 +213,7 @@ class RefCountClass
211213

212214
public:
213215

214-
#ifndef NDEBUG // Debugging stuff
216+
#ifdef RTS_DEBUG // Debugging stuff
215217

216218
/*
217219
** Node in the Active Refs List
@@ -248,7 +250,7 @@ class RefCountClass
248250
*/
249251
static bool Validate_Active_Ref(RefCountClass * obj);
250252

251-
#endif // NDEBUG
253+
#endif // RTS_DEBUG
252254

253255
};
254256

Core/Libraries/Source/debug/test3/test3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//
2727
// Debug module - Test 3 (Checking FLAT I/O, logging)
2828
//////////////////////////////////////////////////////////////////////////////
29-
#ifdef NDEBUG
29+
3030
#include "../debug.h"
3131

3232
unsigned divByNull;

Core/Tools/Autorun/TTFont.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ int TTFontClass::Set_YSpacing( int y )
662662
* 06/20/1887 BNA : Modified to handle new fonts. *
663663
*=============================================================================================*/
664664

665-
#if(NDEBUG)
665+
#ifdef RTS_RELEASE
666666

667667
Point2D TTFontClass::Print(
668668
HDC hdc,
@@ -772,7 +772,7 @@ Point2D TTFontClass::Print(
772772
return( point );
773773
}
774774

775-
#endif
775+
#endif // RTS_RELEASE
776776

777777
/***********************************************************************************************
778778
* TTFontClass::Print -- Print text to the surface specified. CHAR version. *

Core/Tools/W3DView/W3DView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void CW3DViewApp::OnAppAbout()
318318
*/
319319
void Debug_Refs(void)
320320
{
321-
#ifndef NDEBUG
321+
#ifdef RTS_DEBUG
322322
TRACE("Detecting Active Refs...\r\n");
323323
//ODS("At time %s", cMiscUtil::Get_Text_Time());
324324
RefCountNodeClass * first = RefCountClass::ActiveRefList.First();
@@ -368,7 +368,7 @@ void Debug_Refs(void)
368368
}
369369
TRACE("Done.\r\n");
370370
//ODS("At time %s", cMiscUtil::Get_Text_Time());
371-
#endif
371+
#endif // RTS_DEBUG
372372
}
373373

374374

Core/Tools/textureCompress/textureCompress.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void logStuff(const char *fmt, ...)
6464
::MessageBox(NULL, buffer, "textureCompress", MB_OK);
6565
}
6666

67-
#ifndef NDEBUG
67+
#ifdef RTS_DEBUG
6868

6969
class DebugMunkee
7070
{
@@ -96,7 +96,7 @@ static void debugLog(const char *fmt, ...)
9696

9797
#define DEBUG_LOG(x) {}
9898

99-
#endif // NDEBUG
99+
#endif // RTS_DEBUG
100100

101101

102102
static void usage(const char *progname)
@@ -619,7 +619,7 @@ int main(int argc, const char **argv)
619619
const char *targetDir = argv[2];
620620
const char *cacheDir = argv[3];
621621

622-
#ifndef NDEBUG
622+
#ifdef RTS_DEBUG
623623
theDebugMunkee = new DebugMunkee(argv[4]);
624624
#endif
625625

@@ -631,7 +631,7 @@ int main(int argc, const char **argv)
631631
//printSet( hasAlpha, "Using Alpha Channel" );
632632
//tearDownLoadWindow();
633633

634-
#ifndef NDEBUG
634+
#ifdef RTS_DEBUG
635635
delete theDebugMunkee;
636636
theDebugMunkee = NULL;
637637
#endif

cmake/config-build.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ endif()
6767
if(RTS_BUILD_OPTION_DEBUG)
6868
target_compile_definitions(core_config INTERFACE RTS_DEBUG WWDEBUG DEBUG)
6969
else()
70-
target_compile_definitions(core_config INTERFACE RTS_RELEASE)
70+
target_compile_definitions(core_config INTERFACE RTS_RELEASE NDEBUG)
7171
endif()
7272

7373
if(RTS_BUILD_OPTION_PROFILE)

0 commit comments

Comments
 (0)