diff options
author | Max Horn | 2009-03-01 22:03:37 +0000 |
---|---|---|
committer | Max Horn | 2009-03-01 22:03:37 +0000 |
commit | 4f2f82adc2d9ce83407d2decf2fc2f8526d01b1c (patch) | |
tree | 0fa819669b272b690651125db9c0a3ad1d531795 /engines/sci/scicore/decompress1.cpp | |
parent | f509f65023d79e7f609a683c2614f9623552dcb7 (diff) | |
download | scummvm-rg350-4f2f82adc2d9ce83407d2decf2fc2f8526d01b1c.tar.gz scummvm-rg350-4f2f82adc2d9ce83407d2decf2fc2f8526d01b1c.tar.bz2 scummvm-rg350-4f2f82adc2d9ce83407d2decf2fc2f8526d01b1c.zip |
SCI: Unified some of the decompression funcs (they share so much code, would be nice to reduce the code duplication)
svn-id: r39057
Diffstat (limited to 'engines/sci/scicore/decompress1.cpp')
-rw-r--r-- | engines/sci/scicore/decompress1.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/engines/sci/scicore/decompress1.cpp b/engines/sci/scicore/decompress1.cpp index cadd390aeb..fa0e0abdf1 100644 --- a/engines/sci/scicore/decompress1.cpp +++ b/engines/sci/scicore/decompress1.cpp @@ -261,6 +261,7 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) { uint16 compressedLength; uint16 compressionMethod; uint8 *buffer; + uint16 type; if (sci_version == SCI_VERSION_1_EARLY) { result->id = stream.readUint16LE(); @@ -268,10 +269,7 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) { return SCI_ERROR_IO_ERROR; result->number = result->id & 0x07ff; - uint16 type = result->id >> 11; - - if ((result->number >= sci_max_resource_nr[SCI_VERSION_1_EARLY]) || (type > kResourceTypeInvalid)) - return SCI_ERROR_DECOMPRESSION_INSANE; + type = result->id >> 11; result->type = (ResourceType)type; } else { @@ -279,17 +277,17 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) { if (stream.err()) return SCI_ERROR_IO_ERROR; - uint16 type = result->id & 0x7f; + type = result->id & 0x7f; result->number = stream.readUint16LE(); if (stream.err()) return SCI_ERROR_IO_ERROR; - if ((result->number >= sci_max_resource_nr[SCI_VERSION_1_LATE]) || (type > kResourceTypeInvalid)) - return SCI_ERROR_DECOMPRESSION_INSANE; - result->type = (ResourceType)type; } + if ((result->number > sci_max_resource_nr[sci_version]) || (type > kResourceTypeInvalid)) + return SCI_ERROR_DECOMPRESSION_INSANE; + compressedLength = stream.readUint16LE(); result->size = stream.readUint16LE(); compressionMethod = stream.readUint16LE(); |