Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
wwdebug.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WWDebug *
24 * *
25 * $Archive:: /Commando/Code/wwdebug/wwdebug.h $*
26 * *
27 * $Author:: Jani_p $*
28 * *
29 * $Modtime:: 5/04/01 7:43p $*
30 * *
31 * $Revision:: 18 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#if _MSC_VER >= 1000
38#pragma once
39#endif // _MSC_VER >= 1000
40
41#ifndef WWDEBUG_H
42#define WWDEBUG_H
43
44// The macro MESSAGE allows user to put:
45// #pragma MESSAGE("Hello world")
46// anywhere in a source file. The message:
47// sourcefname.cpp (123) : Hello world
48// would be printed if put in sourcefname.cpp on line 123 in compile window like an error.
49// You can then use next/prev error hot keys to see where comment is. It is not an error and
50// will be printed everytime it is compiled. Very useful to put comments in code that cannot
51// be forgoten.
52#define STRING_IT(a) #a
53#define TOKEN_IT(a) STRING_IT(,##a)
54#define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a)
55
56void Convert_System_Error_To_String(int error_id, char* buffer, int buf_len);
58
59/*
60** If 'WWDEBUG' is turned off, all WWDEBUG_xxx macros will
61** be discarded.
62*/
69
70typedef void (*PrintFunc)(DebugType type, const char * message);
71typedef void (*AssertPrintFunc)(const char * message);
72typedef bool (*TriggerFunc)(int trigger_num);
73typedef void (*ProfileFunc)(const char * title);
74
80
81
82/*
83** Users should not call the following three functions directly! Use the macros below instead...
84*/
85void WWDebug_Printf(const char * format,...);
86void WWDebug_Printf_Warning(const char * format,...);
87void WWDebug_Printf_Error(const char * format,...);
88#ifdef WWDEBUG
89void WWDebug_Assert_Fail(const char * expr,const char * file, int line);
90void WWDebug_Assert_Fail_Print(const char * expr,const char * file, int line,const char * string);
91bool WWDebug_Check_Trigger(int trigger_num);
92void WWDebug_Profile_Start( const char * title);
93void WWDebug_Profile_Stop( const char * title);
94
95/*
96** A message handler to display to DBWIN32
97*/
98void WWDebug_DBWin32_Message_Handler( const char * message);
99#endif
100
101
102/*
103** Use the following #define so that all of the debugging messages
104** and strings go away when the release version is built.
105** WWDEBUG_SAY(("dir = %f\n",dir));
106*/
107
108#include "..\..\..\..\gameengine\include\common\debug.h"
109
110#ifdef DEBUG_LOGGING
111#define WWDEBUG_SAY(x) DEBUG_LOG(x)
112#define WWDEBUG_WARNING(x) DEBUG_LOG(x)
113#else
114#define WWDEBUG_SAY(x)
115#define WWDEBUG_WARNING(x)
116#endif
117
118// WW3d is compiled at warning level 4, causes DEBUG_ASSERTCRASH to generate
119// the 4127 warning (constant conditional expression)
120#pragma warning(disable:4127)
121#define WWRELEASE_SAY(x) WWDebug_Printf x
122#define WWRELEASE_WARNING(x) WWDebug_Printf_Warning x
123#define WWRELEASE_ERROR(x) WWDebug_Printf_Error x
124/*
125** The WWASSERT and WWASSERT_PRINT macros will send messages to your
126** assert handler.
127*/
128#ifdef DEBUG_CRASHING
129#define WWASSERT(expr) DEBUG_ASSERTCRASH(expr, ("%s, %s, %d", #expr,__FILE__,__LINE__))
130#define WWASSERT_PRINT( expr, string ) DEBUG_ASSERTCRASH(expr, ("%s, %s, %d - %s", #expr,__FILE__,__LINE__,string))
131#define W3D_DIE DEBUG_CRASH(("DIE!, %s, %d", __FILE__,__LINE__))
132#define WWDEBUG_ERROR(x) DEBUG_CRASH(x)
133#else
134#define WWASSERT( expr )
135#define WWASSERT_PRINT( expr, string )
136#define W3D_DIE
137#define WWDEBUG_ERROR(x)
138#endif
139
140/*
141** The WWDEBUG_BREAK macro will cause the application to break into
142** the debugger...
143*/
144#ifdef WWDEBUG
145#define WWDEBUG_BREAK _asm int 0x03
146#else
147#define WWDEBUG_BREAK _asm int 0x03
148#endif
149
150/*
151** The WWDEBUG_TRIGGER macro can be used to ask the application if
152** a debug trigger is set. We define a couple of generic triggers
153** for casual use.
154*/
155#define WWDEBUG_TRIGGER_GENERIC0 0
156#define WWDEBUG_TRIGGER_GENERIC1 1
157
158#ifdef WWDEBUG
159#define WWDEBUG_TRIGGER(x) WWDebug_Check_Trigger(x)
160#else
161#define WWDEBUG_TRIGGER(x) (0)
162#endif
163
164
165/*
166** The WWDEBUG_PROFILE macros can be used to time blocks of code
167*/
168#ifdef WWDEBUG
169#define WWDEBUG_PROFILE_START(x) WWDebug_Profile_Start(x)
170#define WWDEBUG_PROFILE_STOP(x) WWDebug_Profile_Stop(x)
171#else
172#define WWDEBUG_PROFILE_START(x)
173#define WWDEBUG_PROFILE_STOP(x)
174#endif
175
176#endif
#define bool
Definition gimex.h:284
void WWDebug_Profile_Stop(const char *title)
Definition wwdebug.cpp:439
bool WWDebug_Check_Trigger(int trigger_num)
Definition wwdebug.cpp:397
void WWDebug_Profile_Start(const char *title)
Definition wwdebug.cpp:419
DebugType
Definition wwdebug.h:63
@ WWDEBUG_TYPE_ERROR
Definition wwdebug.h:66
@ WWDEBUG_TYPE_INFORMATION
Definition wwdebug.h:64
@ WWDEBUG_TYPE_USER
Definition wwdebug.h:67
@ WWDEBUG_TYPE_WARNING
Definition wwdebug.h:65
ProfileFunc WWDebug_Install_Profile_Stop_Handler(ProfileFunc func)
Definition wwdebug.cpp:177
void(* ProfileFunc)(const char *title)
Definition wwdebug.h:73
TriggerFunc WWDebug_Install_Trigger_Handler(TriggerFunc func)
Definition wwdebug.cpp:137
void(* PrintFunc)(DebugType type, const char *message)
Definition wwdebug.h:70
void WWDebug_Printf_Warning(const char *format,...)
Definition wwdebug.cpp:228
bool(* TriggerFunc)(int trigger_num)
Definition wwdebug.h:72
ProfileFunc WWDebug_Install_Profile_Start_Handler(ProfileFunc func)
Definition wwdebug.cpp:157
void Convert_System_Error_To_String(int error_id, char *buffer, int buf_len)
Definition wwdebug.cpp:66
PrintFunc WWDebug_Install_Message_Handler(PrintFunc func)
Definition wwdebug.cpp:97
AssertPrintFunc WWDebug_Install_Assert_Handler(AssertPrintFunc func)
Definition wwdebug.cpp:117
void WWDebug_Printf(const char *format,...)
Definition wwdebug.cpp:198
int Get_Last_System_Error()
Definition wwdebug.cpp:80
void WWDebug_Printf_Error(const char *format,...)
Definition wwdebug.cpp:258
void(* AssertPrintFunc)(const char *message)
Definition wwdebug.h:71