Skip to content

Commit

Permalink
ZVISION: Remove dead code, and fix bad usage of assert()
Browse files Browse the repository at this point in the history
Since some compilers, like MSVC, strip out asserts in non-debug builds,
it's a bad idea to perform active commands within assert() statements.
In this particular case, the engine would attempt to open a file in an
assert statement
  • Loading branch information
bluegr committed Dec 25, 2014
1 parent dbbcf64 commit 11cf9b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
11 changes: 2 additions & 9 deletions engines/zvision/sound/zork_raw.cpp
Expand Up @@ -213,7 +213,6 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
}

int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {

int32 bytesRead = _streamReader.readBuffer(buffer, _stream.get(), numSamples);

if (_stream->eos())
Expand Down Expand Up @@ -241,16 +240,10 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre
return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
}

Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
int rate,
bool stereo,
DisposeAfterUse::Flag disposeAfterUse) {
return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
}

Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
Common::File *file = new Common::File();
assert(engine->getSearchManager()->openFile(*file, filePath));
if (!engine->getSearchManager()->openFile(*file, filePath))
error("File not found: %s", filePath.c_str());

// Get the file name
Common::StringTokenizer tokenizer(filePath, "/\\");
Expand Down
14 changes: 0 additions & 14 deletions engines/zvision/sound/zork_raw.h
Expand Up @@ -122,20 +122,6 @@ class RawZorkStream : public Audio::RewindableAudioStream {
bool rewind();
};

/**
* Creates an audio stream, which plays from the given buffer.
*
* @param buffer Buffer to play from.
* @param size Size of the buffer in bytes.
* @param rate Rate of the sound data.
* @param dispose AfterUse Whether to free the buffer after use (with free!).
* @return The new SeekableAudioStream (or 0 on failure).
*/
Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
int rate,
bool stereo,
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

/**
* Creates an audio stream, which plays from the given stream.
*
Expand Down

0 comments on commit 11cf9b5

Please sign in to comment.