SUPERNOVA: Fixes segfault if dat file not found

This commit is contained in:
Joseph-Eugene Winzer 2018-01-07 23:09:01 +01:00 committed by Thierry Crozat
parent c0f47712c2
commit e40a017962
2 changed files with 17 additions and 7 deletions

View File

@ -121,6 +121,8 @@ SupernovaEngine::SupernovaEngine(OSystem *syst)
DebugMan.addDebugChannel(kDebugGeneral, "general", "Supernova general debug channel");
_rnd = new Common::RandomSource("supernova");
_soundMusic[0] = NULL;
_soundMusic[1] = NULL;
}
SupernovaEngine::~SupernovaEngine() {
@ -130,9 +132,6 @@ SupernovaEngine::~SupernovaEngine() {
delete _rnd;
delete _console;
delete _gm;
for (int i = 0; i < kAudioNumSamples; ++i) {
delete[] _soundSamples[i]._buffer;
}
delete _soundMusic[0];
delete _soundMusic[1];
}

View File

@ -76,6 +76,20 @@ private:
ScreenBuffer *_last;
};
struct SoundSample {
SoundSample()
: _buffer(NULL)
, _length(0)
{}
~SoundSample() {
delete _buffer;
}
byte *_buffer;
int _length;
};
class SupernovaEngine : public Engine {
public:
explicit SupernovaEngine(OSystem *syst);
@ -91,10 +105,7 @@ public:
byte _mouseNormal[256];
byte _mouseWait[256];
MSNImageDecoder *_currentImage;
struct SoundSample {
byte *_buffer;
int _length;
} _soundSamples[kAudioNumSamples];
SoundSample _soundSamples[kAudioNumSamples];
Common::MemoryReadStream *_soundMusic[2];
Common::Event _event;
int _screenWidth;