aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2009-05-19 21:09:43 +0000
committerEugene Sandulenko2009-05-19 21:09:43 +0000
commit40dd214789ec627624a7703798907b7afbf50b8e (patch)
tree1c65aababcb8bb0c811c649e1a037c8f788624cb
parenta1364e37f7182d3a88aea659e07fc9e9f196719b (diff)
downloadscummvm-rg350-40dd214789ec627624a7703798907b7afbf50b8e.tar.gz
scummvm-rg350-40dd214789ec627624a7703798907b7afbf50b8e.tar.bz2
scummvm-rg350-40dd214789ec627624a7703798907b7afbf50b8e.zip
Start of fixing bug #2537054: "AGI: Using GMM to load causes graphics glitches"
The engine still crashes when load from GMM occured with a text box on screen. svn-id: r40733
-rw-r--r--engines/agi/agi.h1
-rw-r--r--engines/agi/keyboard.cpp2
-rw-r--r--engines/agi/saveload.cpp15
-rw-r--r--engines/agi/text.cpp20
4 files changed, 36 insertions, 2 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 0e1c1fedf4..4f57f6c9fb 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -968,6 +968,7 @@ public:
int messageBox(const char *);
int selectionBox(const char *, const char **);
void closeWindow(void);
+ void forgetWindow(void);
void drawWindow(int, int, int, int);
void printText(const char *, int, int, int, int, int, int, bool checkerboard = false);
void printTextConsole(const char *, int, int, int, int, int);
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index 6aa7c0fe1f..3bbdc95192 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -379,7 +379,7 @@ int AgiEngine::waitKey() {
}
debugC(3, kDebugLevelInput, "waiting...");
- while (!(shouldQuit() || restartGame)) {
+ while (!(shouldQuit() || restartGame || getflag(fRestoreJustRan))) {
_gfx->pollTimer(); /* msdos driver -> does nothing */
key = doPollKeyboard();
if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT)
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 1b694e711c..bd0a0a5112 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -613,6 +613,16 @@ int AgiEngine::selectSlot() {
_gfx->pollTimer(); /* msdos driver -> does nothing */
key = doPollKeyboard();
+
+ // It may happen that somebody will open GMM while
+ // this dialog is open, and load a game
+ // We are processing it here, effectively jumping
+ // out of the dead loop
+ if (getflag(fRestoreJustRan)) {
+ rc = -2;
+ goto getout;
+ }
+
switch (key) {
case KEY_ENTER:
rc = active;
@@ -724,6 +734,7 @@ press:
getout:
closeWindow();
+
return rc;
}
@@ -844,7 +855,9 @@ int AgiEngine::loadGameDialog() {
slot = selectSlot();
if (slot < 0) {
- messageBox("Game NOT restored.");
+ if (slot == -1) // slot = -2 when GMM was launched
+ messageBox("Game NOT restored.");
+
return errOK;
}
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index bf16f926b2..189a48c804 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -299,6 +299,11 @@ char *AgiEngine::wordWrapString(const char *s, int *len) {
*/
void AgiEngine::closeWindow() {
debugC(4, kDebugLevelText, "closeWindow()");
+
+ if (getflag(fRestoreJustRan)) {
+ forgetWindow();
+ }
+
_sprites->eraseBoth();
eraseTextbox(); /* remove window, if any */
_sprites->blitBoth();
@@ -307,6 +312,18 @@ void AgiEngine::closeWindow() {
}
/**
+ * Remove existing window without restoring anything
+ */
+void AgiEngine::forgetWindow() {
+ debugC(4, kDebugLevelText, "forgetWindow()");
+
+ free(_game.window.buffer);
+ _game.window.buffer = 0;
+ _game.window.active = false;
+ _game.hasWindow = false;
+}
+
+/**
* Display a message box.
* This function displays the specified message in a text box
* centered in the screen and waits until a key is pressed.
@@ -466,6 +483,9 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
setvar(vKey, 0);
do {
+ if (getflag(fRestoreJustRan))
+ break;
+
mainCycle();
if (_game.keypress == KEY_ENTER) {
debugC(4, kDebugLevelText, "KEY_ENTER");