22
22
* *
23
23
* Project Name : WWDebug *
24
24
* *
25
- * $Archive:: /VSS_Sync/ wwdebug/wwdebug.cpp $*
25
+ * $Archive:: /Commando/Code/ wwdebug/wwdebug.cpp $*
26
26
* *
27
- * $Author:: Vss_sync $*
27
+ * $Author:: Greg_h $*
28
28
* *
29
- * $Modtime:: 10/19/00 2:12p $*
29
+ * $Modtime:: 1/13/02 1:46p $*
30
30
* *
31
- * $Revision:: 13 $*
31
+ * $Revision:: 16 $*
32
32
* *
33
33
*---------------------------------------------------------------------------------------------*
34
34
* Functions: *
50
50
#include < stdio.h>
51
51
#include < assert.h>
52
52
#include < string.h>
53
+ #include < signal.h>
54
+ #include " Except.h"
53
55
54
56
55
57
static PrintFunc _CurMessageHandler = NULL ;
@@ -93,7 +95,7 @@ int Get_Last_System_Error()
93
95
* 2/19/98 GTH : Created. *
94
96
*=============================================================================================*/
95
97
PrintFunc WWDebug_Install_Message_Handler (PrintFunc func)
96
- {
98
+ {
97
99
PrintFunc tmp = _CurMessageHandler;
98
100
_CurMessageHandler = func;
99
101
return tmp;
@@ -192,13 +194,13 @@ ProfileFunc WWDebug_Install_Profile_Stop_Handler(ProfileFunc func)
192
194
* HISTORY: *
193
195
* 2/19/98 GTH : Created. *
194
196
*=============================================================================================*/
195
- # ifdef WWDEBUG
197
+
196
198
void WWDebug_Printf (const char * format,...)
197
199
{
198
200
if (_CurMessageHandler != NULL ) {
199
-
201
+
200
202
va_list va;
201
- char buffer[1024 ];
203
+ char buffer[4096 ];
202
204
203
205
va_start (va, format);
204
206
vsprintf (buffer, format, va);
@@ -209,7 +211,6 @@ void WWDebug_Printf(const char * format,...)
209
211
210
212
}
211
213
}
212
- #endif
213
214
214
215
/* **********************************************************************************************
215
216
* WWDebug_Printf_Warning -- Internal function for passing messages to installed handler *
@@ -223,13 +224,13 @@ void WWDebug_Printf(const char * format,...)
223
224
* HISTORY: *
224
225
* 2/19/98 GTH : Created. *
225
226
*=============================================================================================*/
226
- # ifdef WWDEBUG
227
+
227
228
void WWDebug_Printf_Warning (const char * format,...)
228
229
{
229
230
if (_CurMessageHandler != NULL ) {
230
-
231
+
231
232
va_list va;
232
- char buffer[1024 ];
233
+ char buffer[4096 ];
233
234
234
235
va_start (va, format);
235
236
vsprintf (buffer, format, va);
@@ -240,7 +241,6 @@ void WWDebug_Printf_Warning(const char * format,...)
240
241
241
242
}
242
243
}
243
- #endif
244
244
245
245
/* **********************************************************************************************
246
246
* WWDebug_Printf_Error -- Internal function for passing messages to installed handler *
@@ -254,13 +254,13 @@ void WWDebug_Printf_Warning(const char * format,...)
254
254
* HISTORY: *
255
255
* 2/19/98 GTH : Created. *
256
256
*=============================================================================================*/
257
- # ifdef WWDEBUG
257
+
258
258
void WWDebug_Printf_Error (const char * format,...)
259
259
{
260
260
if (_CurMessageHandler != NULL ) {
261
-
261
+
262
262
va_list va;
263
- char buffer[1024 ];
263
+ char buffer[4096 ];
264
264
265
265
va_start (va, format);
266
266
vsprintf (buffer, format, va);
@@ -271,7 +271,6 @@ void WWDebug_Printf_Error(const char * format,...)
271
271
272
272
}
273
273
}
274
- #endif
275
274
276
275
/* **********************************************************************************************
277
276
* WWDebug_Assert_Fail -- Internal function for passing assert messages to installed handler *
@@ -289,20 +288,70 @@ void WWDebug_Printf_Error(const char * format,...)
289
288
void WWDebug_Assert_Fail (const char * expr,const char * file, int line)
290
289
{
291
290
if (_CurAssertHandler != NULL ) {
292
-
293
- char buffer[1024 ];
291
+
292
+ char buffer[4096 ];
294
293
sprintf (buffer," %s (%d) Assert: %s\n " ,file,line,expr);
295
294
_CurAssertHandler (buffer);
296
295
297
296
} else {
298
297
299
- assert (0 );
298
+ /*
299
+ // If the exception handler is try to quit the game then don't show an assert.
300
+ */
301
+ if (Is_Trying_To_Exit ()) {
302
+ ExitProcess (0 );
303
+ }
300
304
301
- }
305
+ char assertbuf[4096 ];
306
+ sprintf (assertbuf, " Assert failed\n\n . File %s Line %d" , file, line);
307
+
308
+ int code = MessageBoxA (NULL , assertbuf, " WWDebug_Assert_Fail" , MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
309
+
310
+ if (code == IDABORT) {
311
+ raise (SIGABRT);
312
+ _exit (3 );
313
+ }
314
+
315
+ if (code == IDRETRY) {
316
+ WWDEBUG_BREAK
317
+ return ;
318
+ }
319
+ }
302
320
}
303
321
#endif
304
322
305
323
324
+
325
+
326
+ /* **********************************************************************************************
327
+ * _assert -- Catch all asserts by overriding lib function *
328
+ * *
329
+ * *
330
+ * *
331
+ * INPUT: Assert stuff *
332
+ * *
333
+ * OUTPUT: Nothing *
334
+ * *
335
+ * WARNINGS: None *
336
+ * *
337
+ * HISTORY: *
338
+ * 12/11/2001 3:56PM ST : Created *
339
+ *=============================================================================================*/
340
+ #if 0 //(gth) this is giving me link errors for some reason...
341
+
342
+ #ifndef W3D_MAX4
343
+ #ifdef WWDEBUG
344
+ void __cdecl _assert(void *expr, void *filename, unsigned lineno)
345
+ {
346
+ WWDebug_Assert_Fail((const char*)expr, (const char*)filename, lineno);
347
+ }
348
+ #endif //WWDEBUG
349
+ #endif
350
+
351
+ #endif
352
+
353
+
354
+
306
355
/* **********************************************************************************************
307
356
* WWDebug_Assert_Fail_Print -- Internal function, passes assert message to handler *
308
357
* *
@@ -320,14 +369,14 @@ void WWDebug_Assert_Fail_Print(const char * expr,const char * file, int line,con
320
369
{
321
370
if (_CurAssertHandler != NULL ) {
322
371
323
- char buffer[1024 ];
372
+ char buffer[4096 ];
324
373
sprintf (buffer," %s (%d) Assert: %s %s\n " ,file,line,expr, string);
325
374
_CurAssertHandler (buffer);
326
375
327
376
} else {
328
377
329
378
assert (0 );
330
-
379
+
331
380
}
332
381
}
333
382
#endif
@@ -422,7 +471,7 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
422
471
if ( !heventDBWIN )
423
472
{
424
473
// MessageBox(NULL, "DBWIN_BUFFER_READY nonexistent", NULL, MB_OK);
425
- return ;
474
+ return ;
426
475
}
427
476
428
477
/* get a handle to the data synch object */
@@ -431,11 +480,11 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
431
480
{
432
481
// MessageBox(NULL, "DBWIN_DATA_READY nonexistent", NULL, MB_OK);
433
482
CloseHandle (heventDBWIN);
434
- return ;
483
+ return ;
435
484
}
436
-
485
+
437
486
hSharedFile = CreateFileMapping ((HANDLE)-1 , NULL , PAGE_READWRITE, 0 , 4096 , " DBWIN_BUFFER" );
438
- if (!hSharedFile)
487
+ if (!hSharedFile)
439
488
{
440
489
// MessageBox(NULL, "DebugTrace: Unable to create file mapping object DBWIN_BUFFER", "Error", MB_OK);
441
490
CloseHandle (heventDBWIN);
@@ -444,7 +493,7 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
444
493
}
445
494
446
495
lpszSharedMem = (LPSTR)MapViewOfFile (hSharedFile, FILE_MAP_WRITE, 0 , 0 , 512 );
447
- if (!lpszSharedMem)
496
+ if (!lpszSharedMem)
448
497
{
449
498
// MessageBox(NULL, "DebugTrace: Unable to map shared memory", "Error", MB_OK);
450
499
CloseHandle (heventDBWIN);
@@ -470,4 +519,3 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
470
519
return ;
471
520
}
472
521
#endif // WWDEBUG
473
-
0 commit comments