aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/scicore/decompress11.cpp
diff options
context:
space:
mode:
authorMax Horn2009-02-20 16:03:50 +0000
committerMax Horn2009-02-20 16:03:50 +0000
commitbc360ee5258b44ab2e08adb70d619a230027ee29 (patch)
treee0ce556b592e0b780039ab3545cc93305d70a364 /engines/sci/scicore/decompress11.cpp
parente736b7fa625f6155737fdad333d337dd282096a8 (diff)
downloadscummvm-rg350-bc360ee5258b44ab2e08adb70d619a230027ee29.tar.gz
scummvm-rg350-bc360ee5258b44ab2e08adb70d619a230027ee29.tar.bz2
scummvm-rg350-bc360ee5258b44ab2e08adb70d619a230027ee29.zip
SCI: Started rewriting file handling. Warning: This will likely introduce
regressions, but we just have to start somewhere. - factored out some common code in engine/kfile.cpp into a separate func - replaced many uses of chdir, getcwd, sci_init_dir etc. by equivalent or better functionality from SearchMan etc. - replaced many uses of sci_open and sci_fopen by using Common::File and Common::Stream - C++ified some stuff - simplified ResourceSource a bit (loosing some unused functionality) svn-id: r38597
Diffstat (limited to 'engines/sci/scicore/decompress11.cpp')
-rw-r--r--engines/sci/scicore/decompress11.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/engines/sci/scicore/decompress11.cpp b/engines/sci/scicore/decompress11.cpp
index be4fa9794c..99b1b9e22e 100644
--- a/engines/sci/scicore/decompress11.cpp
+++ b/engines/sci/scicore/decompress11.cpp
@@ -34,7 +34,7 @@ void decryptinit3(void);
int decrypt3(guint8* dest, guint8* src, int length, int complength);
int decrypt4(guint8* dest, guint8* src, int length, int complength);
-int decompress11(resource_t *result, int resh, int sci_version) {
+int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version) {
guint16 compressedLength;
guint16 compressionMethod, result_size;
guint8 *buffer;
@@ -42,13 +42,13 @@ int decompress11(resource_t *result, int resh, int sci_version) {
DDEBUG("d1");
- if (read(resh, &tempid, 1) != 1)
+ if (stream.read(&tempid, 1) != 1)
return SCI_ERROR_IO_ERROR;
result->id = tempid;
result->type = result->id & 0x7f;
- if (read(resh, &(result->number), 2) != 2)
+ if (stream.read(&(result->number), 2) != 2)
return SCI_ERROR_IO_ERROR;
#ifdef WORDS_BIGENDIAN
@@ -57,9 +57,9 @@ int decompress11(resource_t *result, int resh, int sci_version) {
if ((result->type > sci_invalid_resource))
return SCI_ERROR_DECOMPRESSION_INSANE;
- if ((read(resh, &compressedLength, 2) != 2) ||
- (read(resh, &result_size, 2) != 2) ||
- (read(resh, &compressionMethod, 2) != 2))
+ if ((stream.read(&compressedLength, 2) != 2) ||
+ (stream.read(&result_size, 2) != 2) ||
+ (stream.read(&compressionMethod, 2) != 2))
return SCI_ERROR_IO_ERROR;
#ifdef WORDS_BIGENDIAN
@@ -88,15 +88,14 @@ int decompress11(resource_t *result, int resh, int sci_version) {
buffer = (guint8*)sci_malloc(compressedLength);
result->data = (unsigned char*)sci_malloc(result->size);
- if (read(resh, buffer, compressedLength) != compressedLength) {
+ if (stream.read(buffer, compressedLength) != compressedLength) {
free(result->data);
free(buffer);
return SCI_ERROR_IO_ERROR;
};
if (!(compressedLength & 1)) { /* Align */
- int foo;
- read(resh, &foo, 1);
+ stream.readByte();
}
#ifdef _SCI_DECOMPRESS_DEBUG