mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user