[Scummvm-cvs-logs] SF.net SVN: scummvm: [23894] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Sep 16 21:31:42 CEST 2006


Revision: 23894
          http://svn.sourceforge.net/scummvm/?rev=23894&view=rev
Author:   fingolfin
Date:     2006-09-16 12:31:23 -0700 (Sat, 16 Sep 2006)

Log Message:
-----------
* Added virtual Engine::getDebugger() method
* Removed code from errorString() methods that hooked the debugger(s)
  into error(), in favor of using getDebugger() from within error()
* As a consequence, removed most custom errorString() methods

Modified Paths:
--------------
    scummvm/trunk/base/engine.cpp
    scummvm/trunk/base/engine.h
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/queen/queen.h
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/scumm/scumm.h
    scummvm/trunk/engines/simon/simon.cpp
    scummvm/trunk/engines/simon/simon.h
    scummvm/trunk/engines/sky/sky.cpp
    scummvm/trunk/engines/sky/sky.h
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/sword2/sword2.h

Modified: scummvm/trunk/base/engine.cpp
===================================================================
--- scummvm/trunk/base/engine.cpp	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/base/engine.cpp	2006-09-16 19:31:23 UTC (rev 23894)
@@ -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,27 +170,46 @@
 	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 )
 	TCHAR buf_output_unicode[1024];

Modified: scummvm/trunk/base/engine.h
===================================================================
--- scummvm/trunk/base/engine.h	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/base/engine.h	2006-09-16 19:31:23 UTC (rev 23894)
@@ -34,6 +34,9 @@
 	class SaveFileManager;
 	class TimerManager;
 }
+namespace GUI {
+	class Debugger;
+}
 
 class Engine {
 public:
@@ -80,6 +83,12 @@
 
 	/** 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;

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/queen/queen.cpp	2006-09-16 19:31:23 UTC (rev 23894)
@@ -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::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() {

Modified: scummvm/trunk/engines/queen/queen.h
===================================================================
--- scummvm/trunk/engines/queen/queen.h	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/queen/queen.h	2006-09-16 19:31:23 UTC (rev 23894)
@@ -130,7 +130,7 @@
 
 protected:
 
-	void errorString(const char *buf_input, char *buf_output);
+	GUI::Debugger *getDebugger();
 
 	int go();
 	int init();

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2006-09-16 19:31:23 UTC (rev 23894)
@@ -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 @@
 #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 @@
 	} 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();
-	}
 }
 
 

Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/scumm/scumm.h	2006-09-16 19:31:23 UTC (rev 23894)
@@ -417,7 +417,9 @@
 	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

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-09-16 19:31:23 UTC (rev 23894)
@@ -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 @@
 	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) {

Modified: scummvm/trunk/engines/simon/simon.h
===================================================================
--- scummvm/trunk/engines/simon/simon.h	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/simon/simon.h	2006-09-16 19:31:23 UTC (rev 23894)
@@ -141,7 +141,7 @@
 	friend class Debugger;
 	friend class MoviePlayer;
 
-	void errorString(const char *buf_input, char *buf_output);
+	GUI::Debugger *getDebugger();
 
 	typedef void (SimonEngine::*OpcodeProc) ();
 	void setupOpcodes();

Modified: scummvm/trunk/engines/sky/sky.cpp
===================================================================
--- scummvm/trunk/engines/sky/sky.cpp	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/sky/sky.cpp	2006-09-16 19:31:23 UTC (rev 23894)
@@ -55,7 +55,6 @@
 
 extern bool toolbar_drawn;
 extern bool draw_keyboard;
-extern bool isSmartphone(void);
 #endif
 
 /*
@@ -148,22 +147,8 @@
 			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() {

Modified: scummvm/trunk/engines/sky/sky.h
===================================================================
--- scummvm/trunk/engines/sky/sky.h	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/sky/sky.h	2006-09-16 19:31:23 UTC (rev 23894)
@@ -55,7 +55,7 @@
 class SkyCompact;
 
 class SkyEngine : public Engine {
-	void errorString(const char *buf_input, char *buf_output);
+	GUI::Debugger *getDebugger();
 protected:
 	byte _keyPressed, _keyFlags;
 	bool _floppyIntro;

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2006-09-16 19:31:23 UTC (rev 23894)
@@ -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 @@
 	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() {

Modified: scummvm/trunk/engines/sword2/sword2.h
===================================================================
--- scummvm/trunk/engines/sword2/sword2.h	2006-09-16 17:56:26 UTC (rev 23893)
+++ scummvm/trunk/engines/sword2/sword2.h	2006-09-16 19:31:23 UTC (rev 23894)
@@ -210,7 +210,7 @@
 
 	void sleepUntil(uint32 time);
 
-	void errorString(const char *buf_input, char *buf_output);
+	GUI::Debugger *getDebugger();
 	void initialiseFontResourceFlags();
 	void initialiseFontResourceFlags(uint8 language);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list