aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/engine.cpp36
-rw-r--r--base/engine.h9
-rw-r--r--engines/queen/queen.cpp22
-rw-r--r--engines/queen/queen.h2
-rw-r--r--engines/scumm/scumm.cpp20
-rw-r--r--engines/scumm/scumm.h2
-rw-r--r--engines/simon/simon.cpp21
-rw-r--r--engines/simon/simon.h2
-rw-r--r--engines/sky/sky.cpp19
-rw-r--r--engines/sky/sky.h2
-rw-r--r--engines/sword2/sword2.cpp22
-rw-r--r--engines/sword2/sword2.h2
12 files changed, 56 insertions, 103 deletions
diff --git a/base/engine.cpp b/base/engine.cpp
index 6db1c54a5d..6c915b2954 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -30,8 +30,13 @@
#include "common/savefile.h"
#include "common/system.h"
#include "sound/mixer.h"
+#include "gui/debugger.h"
#include "gui/message.h"
+#ifdef _WIN32_WCE
+extern bool isSmartphone(void);
+#endif
+
/* FIXME - BIG HACK for MidiEmu */
Engine *g_engine = 0;
@@ -165,26 +170,45 @@ void NORETURN CDECL error(const char *s, ...) {
char buf_output[STRINGBUFLEN];
va_list va;
+ // Generate the full error message
va_start(va, s);
vsnprintf(buf_input, STRINGBUFLEN, s, va);
va_end(va);
-#ifndef __GP32__
+
+ // Next, give the active engine (if any) a chance to augment the
+ // error message
if (g_engine) {
g_engine->errorString(buf_input, buf_output);
} else {
strcpy(buf_output, buf_input);
}
-#else
- strcpy(buf_output, buf_input);
-#endif
+
+
+ // Print the error message to stderr
#ifdef __GP32__
printf("ERROR: %s\n", buf_output);
-#else
-#ifndef _WIN32_WCE
+#elif !defined(_WIN32_WCE)
fprintf(stderr, "%s!\n", buf_output);
#endif
+
+
+#ifndef __GP32__
+ // Unless this error -originated- within the debugger itself, we
+ // now invoke the debugger, if available / supported.
+ if (g_engine) {
+ GUI::Debugger *debugger = g_engine->getDebugger();
+#ifdef _WIN32_WCE
+ if (isSmartphone())
+ debugger = 0;
#endif
+ if (debugger && !debugger->isAttached()) {
+ debugger->attach(buf_output);
+ debugger->onFrame();
+ }
+ }
+#endif
+
#if defined( USE_WINDBG )
#if defined( _WIN32_WCE )
diff --git a/base/engine.h b/base/engine.h
index e4055edb22..85798c219b 100644
--- a/base/engine.h
+++ b/base/engine.h
@@ -34,6 +34,9 @@ namespace Common {
class SaveFileManager;
class TimerManager;
}
+namespace GUI {
+ class Debugger;
+}
class Engine {
public:
@@ -80,6 +83,12 @@ public:
/** Initialized graphics and shows error message. */
void GUIErrorMessage(const Common::String msg);
+
+ /**
+ * Return the engine's debugger instance, if any. Used by error() to
+ * invoke the debugger when a severe error is reported.
+ */
+ virtual GUI::Debugger *getDebugger() { return 0; }
};
extern Engine *g_engine;
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index df854bf5fe..c19945d332 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -48,10 +48,6 @@
#include "sound/mididrv.h"
-#ifdef _WIN32_WCE
-bool isSmartphone();
-#endif
-
/* Flight of the Amazon Queen */
static const PlainGameDescriptor queen_setting[] = {
{ "queen", "Flight of the Amazon Queen" },
@@ -352,22 +348,8 @@ void QueenEngine::findGameStateDescriptions(char descriptions[100][32]) {
}
}
-void QueenEngine::errorString(const char *buf1, char *buf2) {
- strcpy(buf2, buf1);
-
-#ifdef _WIN32_WCE
- if (isSmartphone())
- return;
-#endif
-
- // Unless an error -originated- within the debugger, spawn the
- // debugger. Otherwise exit out normally.
- if (_debugger && !_debugger->isAttached()) {
- // (Print it again in case debugger segfaults)
- printf("%s\n", buf2);
- _debugger->attach(buf2);
- _debugger->onFrame();
- }
+GUI::Debugger *QueenEngine::getDebugger() {
+ return _debugger;
}
int QueenEngine::go() {
diff --git a/engines/queen/queen.h b/engines/queen/queen.h
index a1f8b45aa9..5bd697f40a 100644
--- a/engines/queen/queen.h
+++ b/engines/queen/queen.h
@@ -130,7 +130,7 @@ public:
protected:
- void errorString(const char *buf_input, char *buf_output);
+ GUI::Debugger *getDebugger();
int go();
int init();
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index d320bc55de..7da88fe5e6 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -63,10 +63,6 @@
#include "sound/mixer.h"
-#ifdef _WIN32_WCE
-extern bool isSmartphone(void);
-#endif
-
#if (defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
namespace Graphics {
extern void initfonts();
@@ -2117,6 +2113,9 @@ char ScummEngine::displayMessage(const char *altButton, const char *message, ...
#pragma mark --- Miscellaneous ---
#pragma mark -
+GUI::Debugger *ScummEngine::getDebugger() {
+ return _debugger;
+}
void ScummEngine::errorString(const char *buf1, char *buf2) {
if (_currentScript != 0xFF) {
@@ -2126,19 +2125,6 @@ void ScummEngine::errorString(const char *buf1, char *buf2) {
} else {
strcpy(buf2, buf1);
}
-
-#ifdef _WIN32_WCE
- if (isSmartphone())
- return;
-#endif
-
- // Unless an error -originated- within the debugger, spawn the debugger. Otherwise
- // exit out normally.
- if (_debugger && !_debugger->isAttached()) {
- printf("%s\n", buf2); // (Print it again in case debugger segfaults)
- _debugger->attach(buf2);
- _debugger->onFrame();
- }
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index d9ae984bda..36aa285a5a 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -417,7 +417,9 @@ class ScummEngine : public Engine {
friend class CharsetRenderer;
friend class ResourceManager;
+ GUI::Debugger *getDebugger();
void errorString(const char *buf_input, char *buf_output);
+
public:
/* Put often used variables at the top.
* That results in a shorter form of the opcode
diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp
index 2e0c2712f3..74ed56eb03 100644
--- a/engines/simon/simon.cpp
+++ b/engines/simon/simon.cpp
@@ -36,9 +36,6 @@
#include "simon/vga.h"
#include "sound/mididrv.h"
-#ifdef _WIN32_WCE
-extern bool isSmartphone(void);
-#endif
#ifdef PALMOS_68K
#include "globals.h"
@@ -611,22 +608,8 @@ SimonEngine::~SimonEngine() {
delete _sound;
}
-void SimonEngine::errorString(const char *buf1, char *buf2) {
- strcpy(buf2, buf1);
-
-#ifdef _WIN32_WCE
- if (isSmartphone())
- return;
-#endif
-
- // Unless an error -originated- within the debugger, spawn the
- // debugger. Otherwise exit out normally.
- if (_debugger && !_debugger->isAttached()) {
- // (Print it again in case debugger segfaults)
- printf("%s\n", buf2);
- _debugger->attach(buf2);
- _debugger->onFrame();
- }
+GUI::Debugger *SimonEngine::getDebugger() {
+ return _debugger;
}
void SimonEngine::paletteFadeOut(byte *palPtr, uint num, uint size) {
diff --git a/engines/simon/simon.h b/engines/simon/simon.h
index ee21e77ac4..49c35ba386 100644
--- a/engines/simon/simon.h
+++ b/engines/simon/simon.h
@@ -141,7 +141,7 @@ class SimonEngine : public Engine {
friend class Debugger;
friend class MoviePlayer;
- void errorString(const char *buf_input, char *buf_output);
+ GUI::Debugger *getDebugger();
typedef void (SimonEngine::*OpcodeProc) ();
void setupOpcodes();
diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp
index 48b3b1515b..f30a98a9bc 100644
--- a/engines/sky/sky.cpp
+++ b/engines/sky/sky.cpp
@@ -55,7 +55,6 @@
extern bool toolbar_drawn;
extern bool draw_keyboard;
-extern bool isSmartphone(void);
#endif
/*
@@ -148,22 +147,8 @@ SkyEngine::~SkyEngine() {
free(_itemList[i]);
}
-void SkyEngine::errorString(const char *buf1, char *buf2) {
- strcpy(buf2, buf1);
-
-#ifdef _WIN32_WCE
- if (isSmartphone())
- return;
-#endif
-
- // Unless an error -originated- within the debugger, spawn the
- // debugger. Otherwise exit out normally.
- if (_debugger && !_debugger->isAttached()) {
- // (Print it again in case debugger segfaults)
- printf("%s\n", buf2);
- _debugger->attach(buf2);
- _debugger->onFrame();
- }
+GUI::Debugger *SkyEngine::getDebugger() {
+ return _debugger;
}
void SkyEngine::initVirgin() {
diff --git a/engines/sky/sky.h b/engines/sky/sky.h
index 40b4630597..bb119b06dc 100644
--- a/engines/sky/sky.h
+++ b/engines/sky/sky.h
@@ -55,7 +55,7 @@ class Debugger;
class SkyCompact;
class SkyEngine : public Engine {
- void errorString(const char *buf_input, char *buf_output);
+ GUI::Debugger *getDebugger();
protected:
byte _keyPressed, _keyFlags;
bool _floppyIntro;
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 2f339545a5..99344106ad 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -42,10 +42,6 @@
#include "sword2/screen.h"
#include "sword2/sound.h"
-#ifdef _WIN32_WCE
-extern bool isSmartphone();
-#endif
-
namespace Sword2 {
struct GameSettings {
@@ -196,22 +192,8 @@ Sword2Engine::~Sword2Engine() {
delete _memory;
}
-void Sword2Engine::errorString(const char *buf1, char *buf2) {
- strcpy(buf2, buf1);
-
-#ifdef _WIN32_WCE
- if (isSmartphone())
- return;
-#endif
-
- // Unless an error -originated- within the debugger, spawn the
- // debugger. Otherwise exit out normally.
- if (_debugger && !_debugger->isAttached()) {
- // (Print it again in case debugger segfaults)
- printf("%s\n", buf2);
- _debugger->attach(buf2);
- _debugger->onFrame();
- }
+GUI::Debugger *Sword2Engine::getDebugger() {
+ return _debugger;
}
void Sword2Engine::registerDefaultSettings() {
diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h
index 79b07c9918..42ead0b864 100644
--- a/engines/sword2/sword2.h
+++ b/engines/sword2/sword2.h
@@ -210,7 +210,7 @@ public:
void sleepUntil(uint32 time);
- void errorString(const char *buf_input, char *buf_output);
+ GUI::Debugger *getDebugger();
void initialiseFontResourceFlags();
void initialiseFontResourceFlags(uint8 language);