aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/util.cpp110
-rw-r--r--engines/engine.cpp109
2 files changed, 110 insertions, 109 deletions
diff --git a/common/util.cpp b/common/util.cpp
index 1a5452d1fc..f5ac5ec077 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -22,6 +22,8 @@
#include "common/stdafx.h"
#include "engines/engine.h"
#include "common/util.h"
+#include "common/system.h"
+#include "gui/debugger.h"
namespace Common {
@@ -429,3 +431,111 @@ void CDECL debugC(int level, uint32 engine_level, const char *s, ...) {
debugHelper(buf);
}
+
+void NORETURN CDECL error(const char *s, ...) {
+ char buf_input[STRINGBUFLEN];
+ 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);
+
+
+ // 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);
+ }
+
+
+ // Print the error message to stderr
+#ifdef __GP32__
+ printf("ERROR: %s\n", buf_output);
+#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];
+ MultiByteToWideChar(CP_ACP, 0, buf_output, strlen(buf_output) + 1, buf_output_unicode, sizeof(buf_output_unicode));
+ OutputDebugString(buf_output_unicode);
+#else
+ OutputDebugString(buf_output);
+#endif
+#endif
+
+#if defined ( _WIN32_WCE )
+ drawError(buf_output);
+#endif
+
+#ifdef PALMOS_MODE
+ PalmFatalError(buf_output);
+#endif
+
+#ifdef __SYMBIAN32__
+ Symbian::FatalError(buf_output);
+#endif
+ // Finally exit. quit() will terminate the program if g_system is present
+ if (g_system)
+ g_system->quit();
+
+ exit(1);
+}
+
+void CDECL warning(const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
+ va_end(va);
+
+#ifdef __GP32__ //ph0x FIXME: implement fprint?
+ printf("WARNING: %s\n", buf);
+#else
+#if !defined (_WIN32_WCE) && !defined (__SYMBIAN32__)
+ fprintf(stderr, "WARNING: %s!\n", buf);
+#endif
+#endif
+#if defined( USE_WINDBG )
+ strcat(buf, "\n");
+#if defined( _WIN32_WCE )
+ TCHAR buf_unicode[1024];
+ MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
+ OutputDebugString(buf_unicode);
+#else
+ OutputDebugString(buf);
+#endif
+#endif
+}
+
+void checkHeap() {
+#if defined(WIN32) && !defined(__SYMBIAN32__)
+ if (_heapchk() != _HEAPOK) {
+ error("Heap is invalid!");
+ }
+#endif
+}
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 740020ec33..819b04da46 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -30,7 +30,6 @@
#include "common/savefile.h"
#include "common/system.h"
#include "sound/mixer.h"
-#include "gui/debugger.h"
#include "gui/message.h"
#ifdef _WIN32_WCE
@@ -165,114 +164,6 @@ void Engine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
-void NORETURN CDECL error(const char *s, ...) {
- char buf_input[STRINGBUFLEN];
- 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);
-
-
- // 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);
- }
-
-
- // Print the error message to stderr
-#ifdef __GP32__
- printf("ERROR: %s\n", buf_output);
-#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];
- MultiByteToWideChar(CP_ACP, 0, buf_output, strlen(buf_output) + 1, buf_output_unicode, sizeof(buf_output_unicode));
- OutputDebugString(buf_output_unicode);
-#else
- OutputDebugString(buf_output);
-#endif
-#endif
-
-#if defined ( _WIN32_WCE )
- drawError(buf_output);
-#endif
-
-#ifdef PALMOS_MODE
- PalmFatalError(buf_output);
-#endif
-
-#ifdef __SYMBIAN32__
- Symbian::FatalError(buf_output);
-#endif
- // Finally exit. quit() will terminate the program if g_system is present
- if (g_system)
- g_system->quit();
-
- exit(1);
-}
-
-void CDECL warning(const char *s, ...) {
- char buf[STRINGBUFLEN];
- va_list va;
-
- va_start(va, s);
- vsnprintf(buf, STRINGBUFLEN, s, va);
- va_end(va);
-
-#ifdef __GP32__ //ph0x FIXME: implement fprint?
- printf("WARNING: %s\n", buf);
-#else
-#if !defined (_WIN32_WCE) && !defined (__SYMBIAN32__)
- fprintf(stderr, "WARNING: %s!\n", buf);
-#endif
-#endif
-#if defined( USE_WINDBG )
- strcat(buf, "\n");
-#if defined( _WIN32_WCE )
- TCHAR buf_unicode[1024];
- MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
- OutputDebugString(buf_unicode);
-#else
- OutputDebugString(buf);
-#endif
-#endif
-}
-
-void checkHeap() {
-#if defined(WIN32) && !defined(__SYMBIAN32__)
- if (_heapchk() != _HEAPOK) {
- error("Heap is invalid!");
- }
-#endif
-}
-
void Engine::GUIErrorMessage(const Common::String msg) {
_system->setWindowCaption("Error");
_system->beginGFXTransaction();