Skip to content

Commit 8c52b6a

Browse files
committed
unify(debug): Merge GameEngine's Debug code (#1384)
Generals inherits the following changes: 1. The ignore button is now default selected on assert dialogs (simply press ENTER to skip) 2. Debug now works in Generals World Builder 3. The fullscreen game will now hide on release crash 4. The German serious error message is removed
1 parent aaac77d commit 8c52b6a

File tree

3 files changed

+30
-26
lines changed
  • GeneralsMD/Code/GameEngine/Source/Common/System
  • Generals/Code/GameEngine

3 files changed

+30
-26
lines changed

Generals/Code/GameEngine/Include/Common/Debug.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,21 @@
5050

5151
class AsciiString;
5252

53+
#define NO_RELEASE_DEBUG_LOGGING
54+
55+
#ifdef RELEASE_DEBUG_LOGGING ///< Creates a DebugLogFile.txt (No I or D) with all the debug log goodness. Good for startup problems.
56+
#define ALLOW_DEBUG_UTILS 1
57+
#define DEBUG_LOGGING 1
58+
#define DISABLE_DEBUG_CRASHING 1
59+
#define DISABLE_DEBUG_STACKTRACE 1
60+
#define DISABLE_DEBUG_PROFILE 1
61+
#endif
62+
5363
// These are stolen from the WW3D Debug file. REALLY useful. :-)
5464
#define STRING_IT(a) #a
5565
#define TOKEN_IT(a) STRING_IT(,##a)
5666
#define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a)
5767

58-
// BGC, 3/26/03 - put this in so we can build internal worldbuilder for a patch that doesn't
59-
// have any debugging of any kind.
60-
//#define DISABLE_DEBUG_LOGGING
61-
6268
// by default, turn on ALLOW_DEBUG_UTILS if RTS_DEBUG is turned on.
6369
#if defined(RTS_DEBUG) && !defined(ALLOW_DEBUG_UTILS) && !defined(DISABLE_ALLOW_DEBUG_UTILS)
6470
#define ALLOW_DEBUG_UTILS 1

Generals/Code/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,22 @@
5454
// deterministic or the same on all peers in multiplayer games.
5555
//#define INCLUDE_DEBUG_LOG_IN_CRC_LOG
5656

57-
#include "Common/CommandLine.h"
5857
#define DEBUG_THREADSAFE
5958
#ifdef DEBUG_THREADSAFE
6059
#include "Common/CriticalSection.h"
6160
#endif
61+
#include "Common/CommandLine.h"
6262
#include "Common/Debug.h"
6363
#include "Common/CRCDebug.h"
64-
#include "Common/Registry.h"
6564
#include "Common/SystemInfo.h"
6665
#include "Common/UnicodeString.h"
6766
#include "GameClient/ClientInstance.h"
6867
#include "GameClient/GameText.h"
6968
#include "GameClient/Keyboard.h"
7069
#include "GameClient/Mouse.h"
71-
#include "Common/StackDump.h"
70+
#if defined(DEBUG_STACKTRACE) || defined(IG_DEBUG_STACKTRACE)
71+
#include "Common/StackDump.h"
72+
#endif
7273

7374
// Horrible reference, but we really, really need to know if we are windowed.
7475
extern bool DX8Wrapper_IsWindowed;
@@ -271,8 +272,8 @@ static int doCrashBox(const char *buffer, Bool logResult)
271272
int result;
272273

273274
if (!ignoringAsserts()) {
274-
//result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3);
275-
result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING);
275+
result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING|MB_DEFBUTTON3);
276+
//result = MessageBoxWrapper(buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_TASKMODAL|MB_ICONWARNING);
276277
} else {
277278
result = IDIGNORE;
278279
}
@@ -358,7 +359,7 @@ void DebugInit(int flags)
358359
// ::MessageBox(NULL, "Debug already inited", "", MB_OK|MB_APPLMODAL);
359360

360361
// just quietly allow multiple calls to this, so that static ctors can call it.
361-
if (theDebugFlags == 0 && strcmp(gAppPrefix, "wb_") != 0)
362+
if (theDebugFlags == 0)
362363
{
363364
theDebugFlags = flags;
364365

@@ -722,6 +723,11 @@ void ReleaseCrash(const char *reason)
722723
{
723724
/// do additional reporting on the crash, if possible
724725

726+
if (!DX8Wrapper_IsWindowed) {
727+
if (ApplicationHWnd) {
728+
ShowWindow(ApplicationHWnd, SW_HIDE);
729+
}
730+
}
725731

726732
char prevbuf[ _MAX_PATH ];
727733
char curbuf[ _MAX_PATH ];
@@ -767,15 +773,13 @@ void ReleaseCrash(const char *reason)
767773
#else
768774
// crash error messaged changed 3/6/03 BGC
769775
// ::MessageBox(NULL, "Sorry, a serious error occurred.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR);
776+
// ::MessageBox(NULL, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR);
777+
778+
// crash error message changed again 8/22/03 M Lorenzen... made this message box modal to the system so it will appear on top of any task-modal windows, splash-screen, etc.
779+
::MessageBox(NULL, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.",
780+
"Technical Difficulties...",
781+
MB_OK|MB_SYSTEMMODAL|MB_ICONERROR);
770782

771-
if (!GetRegistryLanguage().compareNoCase("german2") || !GetRegistryLanguage().compareNoCase("german") )
772-
{
773-
::MessageBox(NULL, "Es ist ein gravierender Fehler aufgetreten. Solche Fehler k\366nnen durch viele verschiedene Dinge wie Viren, \374berhitzte Hardware und Hardware, die den Mindestanforderungen des Spiels nicht entspricht, ausgel\366st werden. Tipps zur Vorgehensweise findest du in den Foren unter www.generals.ea.com, Informationen zum Technischen Kundendienst im Handbuch zum Spiel.", "Fehler...", MB_OK|MB_TASKMODAL|MB_ICONERROR);
774-
}
775-
else
776-
{
777-
::MessageBox(NULL, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR);
778-
}
779783

780784
#endif
781785

GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void DebugCrash(const char *format, ...)
524524
if (useLogging)
525525
{
526526
#ifdef DEBUG_LOGGING
527-
if (ignoringAsserts())
527+
if (ignoringAsserts())
528528
{
529529
doLogOutput("**** CRASH IN FULL SCREEN - Auto-ignored, CHECK THIS LOG!");
530530
}
@@ -728,13 +728,6 @@ void ReleaseCrash(const char *reason)
728728
ShowWindow(ApplicationHWnd, SW_HIDE);
729729
}
730730
}
731-
//#if defined(RTS_DEBUG)
732-
// /* static */ char buff[8192]; // not so static so we can be threadsafe
733-
// snprintf(buff, 8192, "Sorry, a serious error occurred. (%s)", reason);/
734-
// ::MessageBox(NULL, buff, "Technical Difficulties...", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR);
735-
//#else
736-
// ::MessageBox(NULL, "Sorry, a serious error occurred.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR);
737-
//#endif
738731

739732
char prevbuf[ _MAX_PATH ];
740733
char curbuf[ _MAX_PATH ];
@@ -772,6 +765,7 @@ void ReleaseCrash(const char *reason)
772765
ShowWindow(ApplicationHWnd, SW_HIDE);
773766
}
774767
}
768+
775769
#if defined(RTS_DEBUG)
776770
/* static */ char buff[8192]; // not so static so we can be threadsafe
777771
snprintf(buff, 8192, "Sorry, a serious error occurred. (%s)", reason);

0 commit comments

Comments
 (0)