aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Göffringmann2003-12-18 01:15:15 +0000
committerRobert Göffringmann2003-12-18 01:15:15 +0000
commit127e5ce5f94e2526a41c802c1adbe6480790c796 (patch)
tree3dadda04549c5e894d88f4f4a73ba5b3af0bcce9
parentaa6e1ba76045f9be0965b05b0aea9b2f23a852cd (diff)
downloadscummvm-rg350-127e5ce5f94e2526a41c802c1adbe6480790c796.tar.gz
scummvm-rg350-127e5ce5f94e2526a41c802c1adbe6480790c796.tar.bz2
scummvm-rg350-127e5ce5f94e2526a41c802c1adbe6480790c796.zip
changed endian conversion for compact data
svn-id: r11728
-rw-r--r--sword1/resman.cpp28
1 files changed, 7 insertions, 21 deletions
diff --git a/sword1/resman.cpp b/sword1/resman.cpp
index 041cb488b9..ca3e3b7a72 100644
--- a/sword1/resman.cpp
+++ b/sword1/resman.cpp
@@ -270,28 +270,14 @@ void ResMan::openCptResourceBigEndian(uint32 id) {
resOpen(id);
BsMemHandle *handle = resHandle(id);
uint32 totSize = handle->size;
- uint8 *data = ((uint8*)handle->data) + sizeof(Header);
+ uint32 *data = (uint32*)((uint8*)handle->data + sizeof(Header));
totSize -= sizeof(Header);
-
- uint32 numCpts = *(uint32*)data = READ_LE_UINT32(data);
- data += 4;
- uint32 *dataIdx = (uint32*)data;
-
- for (uint32 cnt = 0; cnt < numCpts; cnt++) {
- uint32 cptSize;
- //uint32 cptPos = READ_LE_UINT32(data + cnt * 4);
- uint32 cptPos = dataIdx[cnt] = READ_LE_UINT32(dataIdx + cnt);
- if (cnt == numCpts-1)
- cptSize = totSize - cptPos - 4;
- else
- cptSize = READ_LE_UINT32(data + (cnt + 1) * 4) - cptPos;
- if (cptSize & 3)
- error("Odd compact size during endian conversion. Resource ID = %d, Cpt = %d of %d, Size %d\n", id, cnt, numCpts, cptSize);
-
- cptSize >>= 2;
- uint32 *cptData = (uint32*)(data + cptPos);
- for (uint32 elemCnt = 0; elemCnt < cptSize; elemCnt++)
- cptData[elemCnt] = READ_LE_UINT32(cptData + elemCnt);
+ if (totSize & 3)
+ error("Illegal compact size for id %d: %d", id, totSize);
+ totSize /= 4;
+ for (uint32 cnt = 0; cnt < totSize; cnt++) {
+ *data = READ_LE_UINT32(data);
+ data++;
}
}