diff options
author | Filippos Karapetis | 2010-06-02 15:31:20 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-06-02 15:31:20 +0000 |
commit | c4bdca72d7fcd837e51a449ff68a1d93977a0d18 (patch) | |
tree | 2f5a756a675cb9a6271ab110f25f321e6526af58 /engines/sci/engine/segment.cpp | |
parent | a8deacfc7eaf6b845d93b7a3f7343b55ee7ec097 (diff) | |
download | scummvm-rg350-c4bdca72d7fcd837e51a449ff68a1d93977a0d18.tar.gz scummvm-rg350-c4bdca72d7fcd837e51a449ff68a1d93977a0d18.tar.bz2 scummvm-rg350-c4bdca72d7fcd837e51a449ff68a1d93977a0d18.zip |
Fixed regression from commit #49332 (merging of the SCI0 and SCI11 relocate functions, where the SCI0 equivalent had a +1 count): it seems that we should skip over zero exports, however the total number of valid exports remains the same. Fixes KQ5 and QFG2. This also fixes the relocation calculation of script 71 in SQ3, so remove the comment that the script has broken relocation entries
svn-id: r49394
Diffstat (limited to 'engines/sci/engine/segment.cpp')
-rw-r--r-- | engines/sci/engine/segment.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 10d73d7325..988ee67741 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -101,7 +101,7 @@ Script::Script() : SegmentObj(SEG_TYPE_SCRIPT) { _localsSegment = 0; _localsBlock = NULL; - _markedAsDeleted = 0; + _markedAsDeleted = false; } Script::~Script() { @@ -306,17 +306,20 @@ void Script::relocate(reg_t block) { "Relocation block outside of script\n"); int count = READ_SCI11ENDIAN_UINT16(heap + block.offset); + int exportIndex = 0; for (int i = 0; i < count; i++) { - int pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (i * 2)) + heapOffset; - // This occurs in SCI01/SCI1 games where every other export - // value is zero. I have no idea what it's supposed to mean. - // - // Yes, there is code in the original to handle this situation, - // but we need an example of it happening in order to determine - // what to do. - if (!pos) - continue; // FIXME: Just ignore it for now. + int pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset; + // This occurs in SCI01/SCI1 games where every usually one export + // value is zero. It seems that in this situation, we should skip + // the export and move to the next one, though the total count + // of valid exports remains the same + if (!pos) { + exportIndex++; + pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset; + if (!pos) + error("Script::relocate(): Consecutive zero exports found"); + } if (!relocateLocal(block.segment, pos)) { bool done = false; @@ -339,18 +342,19 @@ void Script::relocate(reg_t block) { } if (!done) { - printf("While processing relocation block %04x:%04x:\n", PRINT_REG(block)); - printf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count); + debug("While processing relocation block %04x:%04x:\n", PRINT_REG(block)); + debug("Relocation failed for index %04x (%d/%d)\n", pos, exportIndex + 1, count); if (_localsBlock) - printf("- locals: %d at %04x\n", _localsBlock->_locals.size(), _localsOffset); + debug("- locals: %d at %04x\n", _localsBlock->_locals.size(), _localsOffset); else - printf("- No locals\n"); + debug("- No locals\n"); for (it = _objects.begin(), k = 0; it != end; ++it, ++k) - printf("- obj#%d at %04x w/ %d vars\n", k, it->_value.getPos().offset, it->_value.getVarCount()); - // SQ3 script 71 has broken relocation entries. - printf("Trying to continue anyway...\n"); + debug("- obj#%d at %04x w/ %d vars\n", k, it->_value.getPos().offset, it->_value.getVarCount()); + debug("Trying to continue anyway...\n"); } } + + exportIndex++; } } |