diff options
author | Paweł Kołodziejski | 2003-03-07 15:38:11 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2003-03-07 15:38:11 +0000 |
commit | 243c4ffbc0818d51d385052177de1b695c49d795 (patch) | |
tree | 6d4962c17da16133d0c4c9d8c3029618d07e8882 /common | |
parent | 1e0b221341c9a0a941286cfbcfeb3129bb223546 (diff) | |
download | scummvm-rg350-243c4ffbc0818d51d385052177de1b695c49d795.tar.gz scummvm-rg350-243c4ffbc0818d51d385052177de1b695c49d795.tar.bz2 scummvm-rg350-243c4ffbc0818d51d385052177de1b695c49d795.zip |
implemented formating string error for each engine
svn-id: r6744
Diffstat (limited to 'common')
-rw-r--r-- | common/engine.cpp | 38 | ||||
-rw-r--r-- | common/engine.h | 5 |
2 files changed, 43 insertions, 0 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 |