From a743857b87bd6e7cec47c231943d3e8cef254ebf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Jan 2013 11:01:26 +0100 Subject: [PATCH] HOPKINS: (Courtesy of Eriktorbjorn) slight optimisation of the sound code --- engines/hopkins/sound.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 9fb45fa9fed..4da7bdac157 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -73,6 +73,7 @@ public: _cueSheet.clear(); _cueStream = NULL; _cue = 0; + _loadedCue = -1; for (;;) { char buf[3]; @@ -134,8 +135,14 @@ public: protected: bool loadCue(int nr) { + if (_loadedCue == _cueSheet[nr]) { + _cueStream->rewind(); + return true; + } + delete _cueStream; _cueStream = NULL; + _loadedCue = _cueSheet[nr]; Common::String filename = Common::String::format("%s_%02d", _name.c_str(), _cueSheet[nr]); Common::File *file = new Common::File(); @@ -151,6 +158,7 @@ protected: } warning("TwaAudioStream::loadCue: Missing cue %d (%s)", nr, filename.c_str()); + _loadedCue = -1; delete file; return false; } @@ -158,8 +166,9 @@ protected: private: Common::String _name; Common::Array _cueSheet; - Audio::AudioStream *_cueStream; + Audio::RewindableAudioStream *_cueStream; uint _cue; + int _loadedCue; }; Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStream *stream) {