From 205aa58cf95ed191fb932616d35d83dc6440be5a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 26 Aug 2009 16:50:22 +0000 Subject: 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 --- engines/sci/engine/vm.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'engines') 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; -- cgit v1.2.3