diff options
| -rw-r--r-- | common/engine.cpp | 38 | ||||
| -rw-r--r-- | common/engine.h | 5 | ||||
| -rw-r--r-- | scumm/scumm.h | 2 | ||||
| -rw-r--r-- | scumm/scummvm.cpp | 56 | ||||
| -rw-r--r-- | simon/simon.cpp | 4 | ||||
| -rw-r--r-- | simon/simon.h | 1 | ||||
| -rw-r--r-- | sky/sky.cpp | 4 | ||||
| -rw-r--r-- | sky/sky.h | 2 | 
8 files changed, 60 insertions, 52 deletions
| diff --git a/common/engine.cpp b/common/engine.cpp index 4dc1b1681c..e764a3d3f7 100644 --- a/common/engine.cpp +++ b/common/engine.cpp @@ -28,9 +28,11 @@  /* FIXME - BIG HACK for MidiEmu */  OSystem *g_system = 0;  SoundMixer *g_mixer = 0; +Engine *g_engine = 0;  Engine::Engine(GameDetector *detector, OSystem *syst)  	: _system(syst) { +	g_engine = this;  	_mixer = new SoundMixer();  	_gameDataPath = detector->_gameDataPath; @@ -93,6 +95,42 @@ Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst) {  	return engine;  } +void NORETURN CDECL error(const char *s, ...) { +	char buf_input[1024]; +	char buf_output[1024]; +	va_list va; + +	va_start(va, s); +	vsprintf(buf_input, s, va); +	va_end(va); + +	if (g_engine) { +		g_engine->errorString(buf_input, buf_output); +	} else { +		strcpy(buf_output, buf_input); +	} + +#ifdef __GP32__ //ph0x FIXME? +	printf("ERROR: %s\n", buf_output); +#else +	fprintf(stderr, "%s!\n", buf_output); +#endif + +#if defined( USE_WINDBG ) +	OutputDebugString(buf_output); +#endif + +#if defined ( _WIN32_WCE ) +	drawError(buf_output); +#endif + +	// Finally exit. quit() will terminate the program if g_system iss present +	if (g_system) +		g_system->quit(); +	 +	exit(1); +} +  void CDECL warning(const char *s, ...) {  	char buf[1024];  	va_list va; diff --git a/common/engine.h b/common/engine.h index 45b62e2169..3bf5f0b167 100644 --- a/common/engine.h +++ b/common/engine.h @@ -59,8 +59,13 @@ public:  	// Create a new engine object based on the detector - either   	// a Scumm or a SimonState object currently.  	static Engine *createFromDetector(GameDetector *detector, OSystem *syst); +	 +	// Specific for each engine preparare of erroe string +	virtual void errorString(const char *buf_input, char *buf_output) = 0;  }; +extern Engine *g_engine; +  #if defined(__GNUC__)  void CDECL error(const char *s, ...) NORETURN;  #else diff --git a/scumm/scumm.h b/scumm/scumm.h index 970a67b297..bcd8966b6e 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -256,9 +256,9 @@ struct langIndexNode {  };  class Scumm : public Engine { -	friend void NORETURN CDECL error(const char *s, ...);	// FIXME - ugly but error() accesses g_scumm...  	friend class ScummDebugger;  	friend class ScummRenderer;	// FIXME - this is mostly for the destructor +	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/scumm/scummvm.cpp b/scumm/scummvm.cpp index 68cf83b074..21aeadbf05 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1482,58 +1482,14 @@ int normalizeAngle(int angle) {  	return toSimpleDir(1, temp) * 45;  } -void NORETURN CDECL error(const char *s, ...) { -	char buf[1024]; -#if defined( USE_WINDBG ) || defined ( _WIN32_WCE ) -	char buf2[1024]; -#endif - -	va_list va; - -	va_start(va, s); -	vsprintf(buf, s, va); -	va_end(va); - -#ifdef __GP32__ //ph0x FIXME? -	printf("ERROR: %s\n", buf); -#endif - -	if (g_scumm && g_scumm->_currentScript != 0xFF) { -		ScriptSlot *ss = &g_scumm->vm.slot[g_scumm->_currentScript]; -		fprintf(stderr, "Error(%d:%d:0x%X): %s!\n", -						g_scumm->_roomResource, -						ss->number, -						g_scumm->_scriptPointer - g_scumm->_scriptOrgPointer, buf); -#if defined( USE_WINDBG ) || defined( _WIN32_WCE ) -		sprintf(buf2, "Error(%d:%d:0x%X): %s!\n", -			g_scumm->_roomResource, -			ss->number, -			g_scumm->_scriptPointer - g_scumm->_scriptOrgPointer, -			buf); -#if defined ( _WIN32_WCE )	 -		drawError(buf2); -#else -		OutputDebugString(buf2); -#endif -#endif - +void Scumm::errorString(const char *buf1, char *buf2) { +	if (_currentScript != 0xFF) { +		ScriptSlot *ss = &vm.slot[_currentScript]; +		sprintf(buf2, "(%d:%d:0x%X): %s", _roomResource, +			ss->number, _scriptPointer - _scriptOrgPointer, buf1);  	} else { -		fprintf(stderr, "Error: %s!\n", buf); -#if defined( USE_WINDBG ) || defined( _WIN32_WCE ) -		sprintf(&buf[strlen(buf)], "\n"); -#if defined ( _WIN32_WCE )	 -		drawError(buf); -#else -		OutputDebugString(buf); -#endif -#endif +		strcpy(buf2, buf1);  	} - -	// Finally exit. quit() will terminate the program if g_system iss present -	if (g_system) -		g_system->quit(); -	 -	exit(1);  }  void Scumm::waitForTimer(int msec_delay) { diff --git a/simon/simon.cpp b/simon/simon.cpp index 0b654232cf..0846ede986 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -214,6 +214,10 @@ SimonState::~SimonState() {  	delete [] _fcs_list;  } +void SimonState::errorString(const char *buf1, char *buf2) { +	strcpy(buf2, buf1); +} +  void palette_fadeout(uint32 *pal_values, uint num) {  	byte *p = (byte *)pal_values; diff --git a/simon/simon.h b/simon/simon.h index 305831eb91..e7c7e6a9f0 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -96,6 +96,7 @@ struct VgaTimerEntry {  struct GameSpecificSettings;  class SimonState : public Engine { +	void errorString(const char *buf_input, char *buf_output);  public:  	File *_mus_file;  	uint16 *_mus_offsets; diff --git a/sky/sky.cpp b/sky/sky.cpp index fbd4840b63..aa94406e06 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -62,6 +62,10 @@ SkyState::~SkyState() {  } +void SkyState::errorString(const char *buf1, char *buf2) { +	strcpy(buf2, buf1); +} +  void SkyState::pollMouseXY() {  	_mouse_x = _sdl_mouse_x; @@ -27,7 +27,7 @@  #include "common/util.h"  class SkyState : public Engine { - +	void errorString(const char *buf_input, char *buf_output);  protected:  	byte _game;  	bool _isCDVersion; | 
