Removed the code used for tracking script code block relocations in SCI0-SCI1 games, as we don't actually relocate these blocks, and it was used solely for verification of the exports table. The issue that this warning was created for should no longer occur

svn-id: r49669
This commit is contained in:
Filippos Karapetis 2010-06-14 20:45:00 +00:00
parent 86878450ee
commit 1fde7f1abc
3 changed files with 16 additions and 63 deletions

View File

@ -179,7 +179,10 @@ void SegManager::scriptInitialiseLocals(SegmentId segmentId) {
void SegManager::scriptInitialiseObjectsSci11(SegmentId seg) {
Script *scr = getScript(seg);
const byte *seeker = scr->_heapStart + 4 + READ_SCI11ENDIAN_UINT16(scr->_heapStart + 2) * 2;
const byte *seeker = scr->_heapStart;;
uint16 entrySize = READ_SCI11ENDIAN_UINT16(seeker + 2) * 2;
seeker += entrySize; // skip first entry
seeker += 4; // skip header
while (READ_SCI11ENDIAN_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
if (READ_SCI11ENDIAN_UINT16(seeker + 14) & kInfoFlagClass) { // -info- selector
@ -251,10 +254,6 @@ void script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
addr = make_reg(segmentId, curOffset);;
switch (objType) {
case SCI_OBJ_CODE:
if (pass == 0)
scr->scriptAddCodeBlock(addr);
break;
case SCI_OBJ_OBJECT:
case SCI_OBJ_CLASS:
if (pass == 0 && objType == SCI_OBJ_CLASS) {

View File

@ -115,7 +115,6 @@ void Script::freeScript() {
_bufSize = 0;
_objects.clear();
_codeBlocks.clear();
}
void Script::init(int script_nr, ResourceManager *resMan) {
@ -125,8 +124,6 @@ void Script::init(int script_nr, ResourceManager *resMan) {
_localsBlock = NULL;
_localsCount = 0;
_codeBlocks.clear();
_markedAsDeleted = false;
_nr = script_nr;
@ -188,8 +185,6 @@ void Script::load(ResourceManager *resMan) {
memcpy(_heapStart, heap->data, heap->size);
}
_codeBlocks.clear();
_exportTable = 0;
_numExports = 0;
_synonyms = 0;
@ -310,13 +305,6 @@ bool Script::relocateLocal(SegmentId segment, int location) {
return false;
}
void Script::scriptAddCodeBlock(reg_t location) {
CodeBlock cb;
cb.pos = location;
cb.size = READ_SCI11ENDIAN_UINT16(_buf + location.offset - 2);
_codeBlocks.push_back(cb);
}
void Script::relocate(reg_t block) {
byte *heap = _buf;
uint16 heapSize = (uint16)_bufSize;
@ -333,13 +321,14 @@ void Script::relocate(reg_t block) {
int count = READ_SCI11ENDIAN_UINT16(heap + block.offset);
int exportIndex = 0;
int pos = 0;
for (int i = 0; i < count; i++) {
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
pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset;
// This occurs in SCI01/SCI1 games where 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;
@ -347,37 +336,15 @@ void Script::relocate(reg_t block) {
error("Script::relocate(): Consecutive zero exports found");
}
// In SCI0-SCI1, script local variables, objects and code are relocated. We only relocate
// locals and objects here, and ignore relocation of code blocks. In SCI1.1 and newer
// versions, only locals and objects are relocated.
if (!relocateLocal(block.segment, pos)) {
bool done = false;
uint k;
ObjMap::iterator it;
// Not a local? It's probably an object or code block. If it's an object, relocate it.
const ObjMap::iterator end = _objects.end();
for (it = _objects.begin(); !done && it != end; ++it) {
for (ObjMap::iterator it = _objects.begin(); it != end; ++it)
if (it->_value.relocate(block.segment, pos, _scriptSize))
done = true;
}
// Sanity check for SCI0-SCI1
if (getSciVersion() < SCI_VERSION_1_1) {
for (k = 0; !done && k < _codeBlocks.size(); k++) {
if (pos >= _codeBlocks[k].pos.offset &&
pos < _codeBlocks[k].pos.offset + _codeBlocks[k].size)
done = true;
}
}
if (!done) {
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)
debug("- locals: %d at %04x\n", _localsBlock->_locals.size(), _localsOffset);
else
debug("- No locals\n");
for (it = _objects.begin(), k = 0; it != end; ++it, ++k)
debug("- obj#%d at %04x w/ %d vars\n", k, it->_value.getPos().offset, it->_value.getVarCount());
debug("Trying to continue anyway...\n");
}
break;
}
exportIndex++;

View File

@ -331,11 +331,6 @@ private:
reg_t _pos; /**< Object offset within its script; for clones, this is their base */
};
struct CodeBlock {
reg_t pos;
int size;
};
typedef Common::HashMap<uint16, Object> ObjMap;
class Script : public SegmentObj {
@ -362,8 +357,6 @@ private:
const byte *_synonyms; /**< Synonyms block or 0 if not present*/
uint16 _numSynonyms; /**< Number of entries in the synonyms block */
Common::Array<CodeBlock> _codeBlocks;
int _localsOffset;
uint16 _localsCount;
@ -402,12 +395,6 @@ public:
Object *getObject(uint16 offset);
const Object *getObject(uint16 offset) const;
/**
* Informs the segment manager that a code block must be relocated
* @param location Start of block to relocate
*/
void scriptAddCodeBlock(reg_t location);
/**
* Initializes an object within the segment manager
* @param obj_pos Location (segment, offset) of the object. It must