aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2008-05-08 13:23:02 +0000
committerFilippos Karapetis2008-05-08 13:23:02 +0000
commita9b4058ba9fd94de7bd293b0763d71f9f90f84bc (patch)
treea7a31180e4707c803a399708f71ed4fdb7d8eeb6 /engines
parent4f108b76a3874a80e6c8a3b5c79c75d737e49ecb (diff)
downloadscummvm-rg350-a9b4058ba9fd94de7bd293b0763d71f9f90f84bc.tar.gz
scummvm-rg350-a9b4058ba9fd94de7bd293b0763d71f9f90f84bc.tar.bz2
scummvm-rg350-a9b4058ba9fd94de7bd293b0763d71f9f90f84bc.zip
Fixed some game crashes which occurred when ProjectReader::purgeCache() got called:
- MIDI music data is marked to be deleted in o1_STOPMUS now, instead of o1_PLAYMUS. - Added a FIXME to Screen::setFont() - purgeCache crashes the game if the active font is deleted svn-id: r31948
Diffstat (limited to 'engines')
-rw-r--r--engines/made/screen.cpp6
-rw-r--r--engines/made/scriptfuncs.h4
-rw-r--r--engines/made/scriptfuncs_lgop2.cpp10
-rw-r--r--engines/made/scriptfuncs_mhne.cpp10
-rw-r--r--engines/made/scriptfuncs_rtz.cpp10
5 files changed, 25 insertions, 15 deletions
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index c88244a8a2..f2888cada7 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -599,8 +599,10 @@ void Screen::flash(int flashCount) {
void Screen::setFont(int16 fontNum) {
if (fontNum == _currentFontNum)
return;
- if (_font)
- _vm->_res->freeResource(_font);
+ // FIXME: this causes crashes when
+ // ProjectReader::purgeCache() is called
+ //if (_font)
+ // _vm->_res->freeResource(_font);
_font = _vm->_res->getFont(fontNum);
_currentFontNum = fontNum;
}
diff --git a/engines/made/scriptfuncs.h b/engines/made/scriptfuncs.h
index 14645c6d1b..5f1a73d940 100644
--- a/engines/made/scriptfuncs.h
+++ b/engines/made/scriptfuncs.h
@@ -31,6 +31,8 @@
#include "common/func.h"
#include "common/stream.h"
+#include "made/resource.h"
+
namespace Made {
class MadeEngine;
@@ -60,7 +62,7 @@ protected:
Common::Array<const ExternalFunc*> _externalFuncs;
Common::Array<const char *> _externalFuncNames;
-
+ GenericResource *_xmidiRes;
};
class ScriptFunctionsLgop2 : public ScriptFunctions {
diff --git a/engines/made/scriptfuncs_lgop2.cpp b/engines/made/scriptfuncs_lgop2.cpp
index 2a78bd0e2c..d6589d791d 100644
--- a/engines/made/scriptfuncs_lgop2.cpp
+++ b/engines/made/scriptfuncs_lgop2.cpp
@@ -233,16 +233,18 @@ int16 ScriptFunctionsLgop2::o1_PLAYMUS(int16 argc, int16 *argv) {
int16 musicNum = argv[0];
if (musicNum > 0) {
- GenericResource *midi = _vm->_res->getMidi(musicNum);
- _vm->_music->playSMF(midi);
- _vm->_res->freeResource(midi);
+ _xmidiRes = _vm->_res->getXmidi(musicNum);
+ _vm->_music->playXMIDI(_xmidiRes);
}
*/
return 0;
}
int16 ScriptFunctionsLgop2::o1_STOPMUS(int16 argc, int16 *argv) {
- _vm->_music->stop();
+ if (_vm->_music->isPlaying()) {
+ _vm->_music->stop();
+ _vm->_res->freeResource(_xmidiRes);
+ }
return 0;
}
diff --git a/engines/made/scriptfuncs_mhne.cpp b/engines/made/scriptfuncs_mhne.cpp
index 4c942edec2..748bce3918 100644
--- a/engines/made/scriptfuncs_mhne.cpp
+++ b/engines/made/scriptfuncs_mhne.cpp
@@ -233,15 +233,17 @@ int16 ScriptFunctionsMhne::o1_PLAYSND(int16 argc, int16 *argv) {
int16 ScriptFunctionsMhne::o1_PLAYMUS(int16 argc, int16 *argv) {
int16 musicNum = argv[0];
if (musicNum > 0) {
- GenericResource *xmidi = _vm->_res->getXmidi(musicNum);
- _vm->_music->playXMIDI(xmidi);
- _vm->_res->freeResource(xmidi);
+ _xmidiRes = _vm->_res->getXmidi(musicNum);
+ _vm->_music->playXMIDI(_xmidiRes);
}
return 0;
}
int16 ScriptFunctionsMhne::o1_STOPMUS(int16 argc, int16 *argv) {
- _vm->_music->stop();
+ if (_vm->_music->isPlaying()) {
+ _vm->_music->stop();
+ _vm->_res->freeResource(_xmidiRes);
+ }
return 0;
}
diff --git a/engines/made/scriptfuncs_rtz.cpp b/engines/made/scriptfuncs_rtz.cpp
index 8f173dfa57..0cf32d4753 100644
--- a/engines/made/scriptfuncs_rtz.cpp
+++ b/engines/made/scriptfuncs_rtz.cpp
@@ -276,15 +276,17 @@ int16 ScriptFunctionsRtz::o1_PLAYSND(int16 argc, int16 *argv) {
int16 ScriptFunctionsRtz::o1_PLAYMUS(int16 argc, int16 *argv) {
int16 musicNum = argv[0];
if (musicNum > 0) {
- GenericResource *xmidi = _vm->_res->getXmidi(musicNum);
- _vm->_music->playXMIDI(xmidi);
- _vm->_res->freeResource(xmidi);
+ _xmidiRes = _vm->_res->getXmidi(musicNum);
+ _vm->_music->playXMIDI(_xmidiRes);
}
return 0;
}
int16 ScriptFunctionsRtz::o1_STOPMUS(int16 argc, int16 *argv) {
- _vm->_music->stop();
+ if (_vm->_music->isPlaying()) {
+ _vm->_music->stop();
+ _vm->_res->freeResource(_xmidiRes);
+ }
return 0;
}