mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-30 12:50:51 +00:00
* 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 svn-id: r23894
This commit is contained in:
parent
fd12695e59
commit
651d22b873
@ -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 )
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void errorString(const char *buf_input, char *buf_output);
|
||||
GUI::Debugger *getDebugger();
|
||||
|
||||
int go();
|
||||
int init();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user