aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2017-02-26 20:52:40 +0100
committerStrangerke2017-02-26 20:54:35 +0100
commite12a25cb756aa344a07e88e1af85f34598bb0193 (patch)
tree8fe80c93f360a5c0120b6598027b3b76d4e7048d
parent9734d518de262e33ba9556609e95819fc01c10eb (diff)
downloadscummvm-rg350-e12a25cb756aa344a07e88e1af85f34598bb0193.tar.gz
scummvm-rg350-e12a25cb756aa344a07e88e1af85f34598bb0193.tar.bz2
scummvm-rg350-e12a25cb756aa344a07e88e1af85f34598bb0193.zip
CRYO: Improve syncTapePointers
-rw-r--r--engines/cryo/eden.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp
index 999124319e..410a510c81 100644
--- a/engines/cryo/eden.cpp
+++ b/engines/cryo/eden.cpp
@@ -6774,20 +6774,42 @@ void EdenGame::syncCitadelRoomPointers(Common::Serializer s) {
}
void EdenGame::syncTapePointers(Common::Serializer s) {
- int persoIdx, dialogIdx;
+ int persoIdx;
for (int i = 0; i < 16; i++) {
+ int index, subIndex;
if (s.isSaving()) {
+ index = NULLPTR;
+ char *closerPtr = nullptr;
+ for (int j = (getElem((char *)_gameDialogs, 0) - (char *)_gameDialogs) / sizeof(char *) - 1; j >= 0; j--) {
+ char *tmpPtr = getElem((char *)_gameDialogs, j);
+ if ((tmpPtr <= (char *)_tapes[i]._dialog) && (tmpPtr > closerPtr)) {
+ index = j;
+ closerPtr = tmpPtr;
+ }
+ }
+
+ subIndex = NULLPTR;
+ if (index != NULLPTR)
+ subIndex = ((char *)_tapes[i]._dialog - closerPtr);
+
IDXOUT(_tapes[i]._perso, _persons, perso_t, persoIdx);
- IDXOUT(_tapes[i]._dialog, _gameDialogs, Dialog, dialogIdx);
}
s.syncAsUint32LE(persoIdx);
- s.syncAsUint32LE(dialogIdx);
+ s.syncAsUint32LE(index);
+ s.syncAsUint32LE(subIndex);
if (s.isLoading()) {
_tapes[i]._perso = (persoIdx == NULLPTR) ? nullptr : &_persons[persoIdx];
- _tapes[i]._dialog = (dialogIdx == NULLPTR) ? nullptr : (Dialog *)getElem(_gameDialogs, dialogIdx);
+ char *tmpPtr = nullptr;
+
+ if (index != NULLPTR) {
+ tmpPtr = getElem((char *)_gameDialogs, index);
+ if (subIndex != NULLPTR)
+ tmpPtr += subIndex;
+ }
+ _tapes[i]._dialog = (Dialog *)tmpPtr;
}
}
}