diff options
author | Filippos Karapetis | 2009-08-26 16:50:22 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-08-26 16:50:22 +0000 |
commit | 205aa58cf95ed191fb932616d35d83dc6440be5a (patch) | |
tree | 1e625575c40a248e7cd9595d150dd855f23a0cb1 /engines/sci/engine | |
parent | c98941d6d7e725c769263100bb73054f87d39c32 (diff) | |
download | scummvm-rg350-205aa58cf95ed191fb932616d35d83dc6440be5a.tar.gz scummvm-rg350-205aa58cf95ed191fb932616d35d83dc6440be5a.tar.bz2 scummvm-rg350-205aa58cf95ed191fb932616d35d83dc6440be5a.zip |
Added a safeguard to avoid getting stuck in an endless loop when initializing some problematic scripts in certain demos (e.g. the EcoQuest 1 demo), and fixed the return values of script_instantiate_sci0() in the process
svn-id: r43759
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/vm.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index f05a290d94..acd251f191 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1629,6 +1629,14 @@ int script_instantiate_sci0(ResourceManager *resourceManager, SegManager *segMan objlength = scr->getHeap(reg.offset + 2); + // This happens in some demos (e.g. the EcoQuest 1 demo). Not sure what is the + // actual cause of it, but the scripts of these demos can't be loaded properly + // and we're stuck forever in this loop, as objlength never changes + if (!objlength) { + warning("script_instantiate_sci0: objlength is 0, unable to parse script"); + return 0; + } + data_base = reg; data_base.offset += 4; @@ -1654,11 +1662,11 @@ int script_instantiate_sci0(ResourceManager *resourceManager, SegManager *segMan int species; species = scr->getHeap(addr.offset - SCRIPT_OBJECT_MAGIC_OFFSET + SCRIPT_SPECIES_OFFSET); if (species < 0 || species >= (int)segManager->_classtable.size()) { - error("Invalid species %d(0x%x) not in interval " + warning("Invalid species %d(0x%x) not in interval " "[0,%d) while instantiating script %d\n", species, species, segManager->_classtable.size(), script_nr); - return 1; + return 0; } segManager->_classtable[species].reg = addr; |