aboutsummaryrefslogtreecommitdiff
path: root/engines/cruise
diff options
context:
space:
mode:
authorPaul Gilbert2009-05-15 04:07:10 +0000
committerPaul Gilbert2009-05-15 04:07:10 +0000
commit03f5ad5cbbabc93fa0eda4366da5d77da0545014 (patch)
treeb504fc5058f801504ffe57308faabc66b5c5b0d4 /engines/cruise
parentcf62299c4aaee02d8b1461de8a424872e894ba08 (diff)
downloadscummvm-rg350-03f5ad5cbbabc93fa0eda4366da5d77da0545014.tar.gz
scummvm-rg350-03f5ad5cbbabc93fa0eda4366da5d77da0545014.tar.bz2
scummvm-rg350-03f5ad5cbbabc93fa0eda4366da5d77da0545014.zip
Bugfix for loadSetEntry to ensure graphics get allocated enough space. It's not exactly the way the original did it, but should suffice to ensure grahpics have sufficient space
svn-id: r40587
Diffstat (limited to 'engines/cruise')
-rw-r--r--engines/cruise/dataLoader.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/engines/cruise/dataLoader.cpp b/engines/cruise/dataLoader.cpp
index b3719ec013..a3ee46b383 100644
--- a/engines/cruise/dataLoader.cpp
+++ b/engines/cruise/dataLoader.cpp
@@ -135,23 +135,23 @@ void decodeGfxUnified(dataFileEntry *pCurrentFileEntry, int16 format) {
pCurrentFileEntry->subData.ptr = buffer;
}
-int updateResFileEntry(int height, int width, int entryNumber, int resType) {
+int updateResFileEntry(int height, int width, int size, int entryNumber, int resType) {
int div = 0;
resetFileEntry(entryNumber);
filesDatabase[entryNumber].subData.compression = 0;
- int maskSize = height * width; // for sprites: width * height
+ int maskSize = size;
if (resType == 4) {
div = maskSize / 4;
} else if (resType == 5) {
width = (width * 8) / 5;
- maskSize = height * width;
+ maskSize = MAX(size, height * width);
}
- filesDatabase[entryNumber].subData.ptr = (uint8 *) mallocAndZero(maskSize + div);
+ filesDatabase[entryNumber].subData.ptr = (uint8 *)mallocAndZero(maskSize + div);
if (!filesDatabase[entryNumber].subData.ptr)
return (-2);
@@ -166,11 +166,10 @@ int updateResFileEntry(int height, int width, int entryNumber, int resType) {
return entryNumber;
}
-int createResFileEntry(int width, int height, int resType) {
+int createResFileEntry(int width, int height, int size, int resType) {
int i;
int entryNumber;
int div = 0;
- int size;
printf("Executing untested createResFileEntry!\n");
exit(1);
@@ -188,8 +187,6 @@ int createResFileEntry(int width, int height, int resType) {
filesDatabase[entryNumber].subData.compression = 0;
- size = width * height; // for sprites: width * height
-
if (resType == 4) {
div = size / 4;
} else if (resType == 5) {
@@ -360,9 +357,9 @@ int loadFNTSub(uint8 *ptr, int destIdx) {
flipLong(&loadFileVar1);
if (destIdx == -1) {
- fileIndex = createResFileEntry(loadFileVar1, 1, 1);
+ fileIndex = createResFileEntry(loadFileVar1, 1, loadFileVar1, 1);
} else {
- fileIndex = updateResFileEntry(loadFileVar1, 1, destIdx, 1);
+ fileIndex = updateResFileEntry(loadFileVar1, 1, loadFileVar1, destIdx, 1);
}
destPtr = filesDatabase[fileIndex].subData.ptr;
@@ -439,9 +436,9 @@ int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentD
localBuffer.width -= 10;
if (currentDestEntry == -1) {
- fileIndex = createResFileEntry(localBuffer.width, localBuffer.height, localBuffer.type);
+ fileIndex = createResFileEntry(localBuffer.width, localBuffer.height, resourceSize, localBuffer.type);
} else {
- fileIndex = updateResFileEntry(localBuffer.height, localBuffer.width, currentDestEntry, localBuffer.type);
+ fileIndex = updateResFileEntry(localBuffer.height, localBuffer.width, resourceSize, currentDestEntry, localBuffer.type);
}
if (fileIndex < 0) {
@@ -458,6 +455,7 @@ int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentD
ptr5 = ptr3 + localBuffer.offset + numIdx * 16;
memcpy(filesDatabase[fileIndex].subData.ptr, ptr5, resourceSize);
+
ptr5 += resourceSize;
switch (localBuffer.type) {