[Scummvm-cvs-logs] CVS: scummvm/sky disk.cpp,1.29,1.30 logic.cpp,1.96,1.97

Robert G?ffringmann lavosspawn at users.sourceforge.net
Mon Jun 9 13:42:04 CEST 2003


Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv7782/sky

Modified Files:
	disk.cpp logic.cpp 
Log Message:
fixed issue about file decompression.

Index: disk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/disk.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- disk.cpp	9 Jun 2003 02:33:26 -0000	1.29
+++ disk.cpp	9 Jun 2003 20:41:08 -0000	1.30
@@ -156,57 +156,51 @@
 
 	//if cflag == 0 then file is compressed, 1 == uncompressed
 
-	if (!cflag) {
-		debug(2, "File is compressed...");
+	if ((!cflag) && ((FROM_LE_16(((dataFileHeader*)_fileDest)->flag) >> 7)&1)) {
+		debug(2, "File is RNC compressed.");
 
 		memcpy(&fileHeader, _fileDest, sizeof(struct dataFileHeader));
-		if ( (uint8)((FROM_LE_16(fileHeader.flag) >> 7) & 0x1)	 ) {
-			debug(2, "with RNC!");
-
-			_decompSize = (FROM_LE_16(fileHeader.flag) & 0xFFFFFF00) << 8;
-			_decompSize |= FROM_LE_16((uint16)fileHeader.s_tot_size);
+		_decompSize = (FROM_LE_16(fileHeader.flag) & 0xFFFFFF00) << 8;
+		_decompSize |= FROM_LE_16((uint16)fileHeader.s_tot_size);
 
-			if (_fixedDest == NULL) // is this valid?
-				_compDest = (uint8 *)malloc(_decompSize);
+		if (_fixedDest == NULL) // is this valid?
+			_compDest = (uint8 *)malloc(_decompSize);
 
-			inputPtr = _fileDest;
-			outputPtr = _compDest;
+		inputPtr = _fileDest;
+		outputPtr = _compDest;
 
-			if ( (uint8)(_fileFlags >> (22) & 0x1) ) //do we include the header?
-				inputPtr += sizeof(struct dataFileHeader);
-			else {
-				memcpy(outputPtr, inputPtr, sizeof(struct dataFileHeader));
-				inputPtr += sizeof(struct dataFileHeader);
-				outputPtr += sizeof(struct dataFileHeader);
-			}
+		if ( (uint8)(_fileFlags >> (22) & 0x1) ) //do we include the header?
+			inputPtr += sizeof(struct dataFileHeader);
+		else {
+			memcpy(outputPtr, inputPtr, sizeof(struct dataFileHeader));
+			inputPtr += sizeof(struct dataFileHeader);
+			outputPtr += sizeof(struct dataFileHeader);
+		}
 
-			RncDecoder rncDecoder;
-			int32 unPackLen = rncDecoder.unpackM1(inputPtr, outputPtr, 0);
+		RncDecoder rncDecoder;
+		int32 unPackLen = rncDecoder.unpackM1(inputPtr, outputPtr, 0);
 
-			debug(3, "UnpackM1 returned: %d", unPackLen);
+		debug(3, "UnpackM1 returned: %d", unPackLen);
 
-			if (unPackLen == 0) { //Unpack returned 0: file was probably not packed.
-				if (_fixedDest == NULL)
-					free(_compDest);
+		if (unPackLen == 0) { //Unpack returned 0: file was probably not packed.
+			if (_fixedDest == NULL)
+				free(_compDest);
 			
-				return _fileDest;
-			}
+			return _fileDest;
+		}
 
-			if (! (uint8)(_fileFlags >> (22) & 0x1) ) { // include header?
-				unPackLen += sizeof(struct dataFileHeader);
+		if (! (uint8)(_fileFlags >> (22) & 0x1) ) { // include header?
+			unPackLen += sizeof(struct dataFileHeader);
 
-				if (unPackLen != (int32)_decompSize) {
-					debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", unPackLen, _decompSize);
-				}
+			if (unPackLen != (int32)_decompSize) {
+				debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", unPackLen, _decompSize);
 			}
+		}
 
-			_lastLoadedFileSize = _decompSize; //including header
+		_lastLoadedFileSize = _decompSize; //including header
 			
-			if (_fixedDest == NULL)
-				free(_fileDest);
-
-		} else
-			debug(2, "but not with RNC! (?!)");
+		if (_fixedDest == NULL)
+			free(_fileDest);
 	} else
 		return _fileDest;
 
@@ -289,7 +283,7 @@
 	uint8 cnt = 0;
 	uint16 *fList = (uint16*)SkyState::fetchCompact(list);
 	do {
-		_buildList[cnt] = fList[cnt];
+		_buildList[cnt] = fList[cnt] & 0x7FFFU;
 		cnt++;
 	} while (fList[cnt-1]);
 }
@@ -312,7 +306,7 @@
 			targCnt++;
 		} else {
 			free(SkyState::_itemList[_loadedFilesList[lCnt] & 2047]);
-			SkyState::_itemList[_loadedFilesList[lCnt] & 2047] = NULL;
+			SkyState::_itemList[_loadedFilesList[lCnt] & 2047] = NULL;		
 		}
 		lCnt++;
 	}
@@ -339,6 +333,8 @@
 		targCnt++;
 		_loadedFilesList[targCnt] = 0;
 		SkyState::_itemList[_buildList[bCnt] & 2047] = (void**)loadFile(_buildList[bCnt] & 0x7FFF, NULL);
+		if (!SkyState::_itemList[_buildList[bCnt] & 2047])
+			warning("fnCacheFiles: SkyDisk::loadFile() returned NULL for file %d\n",_buildList[bCnt] & 0x7FFF);
 		bCnt++;
 	}
 	_buildList[0] = 0;

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- logic.cpp	9 Jun 2003 18:15:01 -0000	1.96
+++ logic.cpp	9 Jun 2003 20:41:08 -0000	1.97
@@ -1403,6 +1403,11 @@
 		return false; 
 	}
 	uint16 *getToTable = cpt->getToTable;
+	if (!getToTable) { 
+		// FIXME: This should never happen
+		warning("Place compact's getToTable is NULL!");
+		return false; 
+	}
 
 	while (*getToTable != targetPlaceId)
 		getToTable += 2;
@@ -1500,7 +1505,8 @@
 }
 
 bool SkyLogic::fnAddButtons(uint32 a, uint32 b, uint32 c) {
-	error("Stub: fnAddButtons");
+	_scriptVariables[MOUSE_STATUS] |= 4;
+	return true;
 }
 
 bool SkyLogic::fnNoButtons(uint32 a, uint32 b, uint32 c) {
@@ -1871,6 +1877,15 @@
 
 	Compact *cpt = SkyState::fetchCompact(id);
 	uint16 *rst = (uint16 *)SkyState::fetchCompact(resetBlock);
+	SkyCompact::jobsworth;
+	if (!cpt) {
+		warning("fnResetId(): Compact %d (id) == NULL\n",id);
+		return true;
+	}
+	if (!rst) {
+		warning("fnResetId(): Compact %d (resetBlock) == NULL\n",resetBlock);
+		return true;
+	}
 
 	uint16 off;
 	while ((off = *rst++) != 0xffff)





More information about the Scummvm-git-logs mailing list