aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/scripting
diff options
context:
space:
mode:
authorMarisa-Chan2014-12-19 17:17:33 +0600
committerMarisa-Chan2014-12-19 17:17:33 +0600
commit3806aa44186e4ce383697f6cb2fed8a23042020b (patch)
treedf1d452c981336cb27f0e32da0ff2cf53b77903f /engines/zvision/scripting
parent6d1fcdbdbdf72d69eda6f458ff859bed7257410b (diff)
downloadscummvm-rg350-3806aa44186e4ce383697f6cb2fed8a23042020b.tar.gz
scummvm-rg350-3806aa44186e4ce383697f6cb2fed8a23042020b.tar.bz2
scummvm-rg350-3806aa44186e4ce383697f6cb2fed8a23042020b.zip
ZVISION: Fix explicit null dereferenced (CID 1257094)
Diffstat (limited to 'engines/zvision/scripting')
-rw-r--r--engines/zvision/scripting/sidefx/music_node.cpp45
-rw-r--r--engines/zvision/scripting/sidefx/music_node.h1
2 files changed, 28 insertions, 18 deletions
diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp
index c79dd0296d..56598189f6 100644
--- a/engines/zvision/scripting/sidefx/music_node.cpp
+++ b/engines/zvision/scripting/sidefx/music_node.cpp
@@ -47,6 +47,8 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
_pantrack = false;
_pantrackPosition = 0;
_sub = NULL;
+ _stereo = false;
+ _loaded = false;
Audio::RewindableAudioStream *audioStream = NULL;
@@ -59,30 +61,35 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
audioStream = makeRawZorkStream(filename, _engine);
}
- _stereo = audioStream->isStereo();
+ if (audioStream) {
+ _stereo = audioStream->isStereo();
- if (_loop) {
- Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
- } else {
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
- }
+ if (_loop) {
+ Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
+ } else {
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
+ }
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+
+ // Change filename.raw into filename.sub
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
- // Change filename.raw into filename.sub
- Common::String subname = filename;
- subname.setChar('s', subname.size() - 3);
- subname.setChar('u', subname.size() - 2);
- subname.setChar('b', subname.size() - 1);
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
- if (_engine->getSearchManager()->hasFile(subname))
- _sub = new Subtitle(_engine, subname);
+ _loaded = true;
+ }
}
MusicNode::~MusicNode() {
- _engine->_mixer->stopHandle(_handle);
+ if (!_loaded)
+ _engine->_mixer->stopHandle(_handle);
if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 2);
if (_sub)
@@ -110,7 +117,7 @@ void MusicNode::setFade(int32 time, uint8 target) {
}
bool MusicNode::process(uint32 deltaTimeInMillis) {
- if (! _engine->_mixer->isSoundHandleActive(_handle))
+ if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle))
return stop();
else {
uint8 _newvol = _volume;
@@ -137,6 +144,8 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
}
void MusicNode::setVolume(uint8 newVolume) {
+ if (!_loaded)
+ return;
if (_pantrack) {
int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
curX -= _pantrackPosition;
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
index c8077c7a6a..09bdc3707e 100644
--- a/engines/zvision/scripting/sidefx/music_node.h
+++ b/engines/zvision/scripting/sidefx/music_node.h
@@ -88,6 +88,7 @@ private:
bool _stereo;
Audio::SoundHandle _handle;
Subtitle *_sub;
+ bool _loaded;
};
class MusicMidiNode : public MusicNodeBASE {