diff options
author | richiesams | 2013-07-07 11:31:05 -0500 |
---|---|---|
committer | richiesams | 2013-08-04 13:32:05 -0500 |
commit | ca89f7679881aeb2ce056592f5d38531db2465fd (patch) | |
tree | 0b725f2033f4d1153925ada220f032dce0d26746 | |
parent | 399e512be232746f956b6be52b8387b52114d35b (diff) | |
download | scummvm-rg350-ca89f7679881aeb2ce056592f5d38531db2465fd.tar.gz scummvm-rg350-ca89f7679881aeb2ce056592f5d38531db2465fd.tar.bz2 scummvm-rg350-ca89f7679881aeb2ce056592f5d38531db2465fd.zip |
ZVISION: Move early break out above the for loop. LzssReadStream::decompressBytes()
The other code would go through each of the for loops and do nothing due to EOS.
-rw-r--r-- | engines/zvision/lzss_read_stream.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp index 69b49c596c..61b5b16393 100644 --- a/engines/zvision/lzss_read_stream.cpp +++ b/engines/zvision/lzss_read_stream.cpp @@ -52,49 +52,49 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) { while (!_source->eos() && bytesRead <= numberOfBytes) { byte flagbyte = _source->readByte(); + if (_source->eos()) + break; byte mask = 1; for (uint32 i = 0; i < 8; i++) { - if (!_source->eos()) { - if ((flagbyte & mask) == mask) + if ((flagbyte & mask) == mask) + { + byte data = _source->readByte(); + bytesRead++; + if (_source->eos()) + break; + + _window[_windowCursor] = data; + _destination.push_back(data); + + // Increment and wrap the window cursor + _windowCursor = (_windowCursor + 1) & 0xFFF; + } + else + { + byte low = _source->readByte(); + bytesRead++; + if (_source->eos()) + break; + + byte high = _source->readByte(); + bytesRead++; + if (_source->eos()) + break; + + uint16 length = (high & 0xF) + 2; + uint16 offset = low | ((high & 0xF0)<<4); + + for(byte j = 0; j <= length; j++) { - byte data = _source->readByte(); - bytesRead++; - if (_source->eos()) - break; - - _window[_windowCursor] = data; - _destination.push_back(data); - - // Increment and wrap the window cursor + byte temp = _window[(offset + j) & 0xFFF]; + _window[_windowCursor] = temp; + _destination.push_back(temp); _windowCursor = (_windowCursor + 1) & 0xFFF; } - else - { - byte low = _source->readByte(); - bytesRead++; - if (_source->eos()) - break; - - byte high = _source->readByte(); - bytesRead++; - if (_source->eos()) - break; - - uint16 length = (high & 0xF) + 2; - uint16 offset = low | ((high & 0xF0)<<4); - - for(byte j = 0; j <= length; j++) - { - byte temp = _window[(offset + j) & 0xFFF]; - _window[_windowCursor] = temp; - _destination.push_back(temp); - _windowCursor = (_windowCursor + 1) & 0xFFF; - } - }; - - mask = mask << 1; - } + }; + + mask = mask << 1; } } } |