diff options
author | md5 | 2011-03-14 20:00:26 +0200 |
---|---|---|
committer | md5 | 2011-03-14 20:00:26 +0200 |
commit | ca1f9a075f7914ae3ceb83b9a01b5b7a193041e9 (patch) | |
tree | 3f74a24e5782f531d62a78af13d2751eacd26cae /engines/sci | |
parent | 75319afbfdc1e42179e261065a876bcf6f685bab (diff) | |
download | scummvm-rg350-ca1f9a075f7914ae3ceb83b9a01b5b7a193041e9.tar.gz scummvm-rg350-ca1f9a075f7914ae3ceb83b9a01b5b7a193041e9.tar.bz2 scummvm-rg350-ca1f9a075f7914ae3ceb83b9a01b5b7a193041e9.zip |
SCI: Got rid of VERIFY() and removed some newlines in error messages
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/script.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 9 |
3 files changed, 14 insertions, 21 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 3c81a93767..fb96518f19 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -70,7 +70,7 @@ void Script::init(int script_nr, ResourceManager *resMan) { Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); if (!script) - error("Script %d not found\n", script_nr); + error("Script %d not found", script_nr); _localsOffset = 0; _localsBlock = NULL; @@ -257,9 +257,8 @@ Object *Script::scriptObjInit(reg_t obj_pos, bool fullObjectInit) { if (getSciVersion() < SCI_VERSION_1_1 && fullObjectInit) obj_pos.offset += 8; // magic offset (SCRIPT_OBJECT_MAGIC_OFFSET) - VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n"); - - VERIFY(obj_pos.offset + kOffsetFunctionArea < (int)_bufSize, "Function area pointer stored beyond end of script\n"); + if (obj_pos.offset >= _bufSize) + error("Attempt to initialize object beyond end of script"); // Get the object at the specified position and init it. This will // automatically "allocate" space for it in the _objects map if necessary. @@ -327,8 +326,9 @@ void Script::relocateSci0Sci21(reg_t block) { heapOffset = _scriptSize; } - VERIFY(block.offset < (uint16)heapSize && READ_SCI11ENDIAN_UINT16(heap + block.offset) * 2 + block.offset < (uint16)heapSize, - "Relocation block outside of script\n"); + if (block.offset >= (uint16)heapSize || + READ_SCI11ENDIAN_UINT16(heap + block.offset) * 2 + block.offset >= (uint16)heapSize) + error("Relocation block outside of script"); int count = READ_SCI11ENDIAN_UINT16(heap + block.offset); int exportIndex = 0; @@ -418,7 +418,8 @@ uint16 Script::validateExportFunc(int pubfunct, bool relocate) { offset = relocateOffsetSci3(pubfunct * 2 + 22); } - VERIFY(offset < _bufSize, "invalid export function pointer"); + if (offset >= _bufSize) + error("Invalid export function pointer"); // Check if the offset found points to a second export table (e.g. script 912 // in Camelot and script 306 in KQ4). Such offsets are usually small (i.e. < 10), @@ -432,7 +433,8 @@ uint16 Script::validateExportFunc(int pubfunct, bool relocate) { if (secondExportTable) { secondExportTable += 3; // skip header plus 2 bytes (secondExportTable is a uint16 pointer) offset = READ_SCI11ENDIAN_UINT16(secondExportTable + pubfunct); - VERIFY(offset < _bufSize, "invalid export function pointer"); + if (offset >= _bufSize) + error("Invalid export function pointer"); } } diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index a3e5239906..0dc245a991 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -152,7 +152,8 @@ Script *SegManager::allocateScript(int script_nr, SegmentId *segid) { } void SegManager::deallocate(SegmentId seg) { - VERIFY(check(seg), "invalid seg id"); + if (!check(seg)) + error("SegManager::deallocate(): invalid segment ID"); SegmentObj *mobj = _heap[seg]; @@ -359,9 +360,8 @@ LocalVariables *SegManager::allocLocalsSegment(Script *scr) { if (scr->_localsSegment) { locals = (LocalVariables *)_heap[scr->_localsSegment]; - VERIFY(locals != NULL, "Re-used locals segment was NULL'd out"); - VERIFY(locals->getType() == SEG_TYPE_LOCALS, "Re-used locals segment did not consist of local variables"); - VERIFY(locals->script_id == scr->getScriptNumber(), "Re-used locals segment belonged to other script"); + if (!locals || locals->getType() != SEG_TYPE_LOCALS || locals->script_id != scr->getScriptNumber()) + error("Invalid script locals segment while allocating locals"); } else locals = (LocalVariables *)allocSegment(new LocalVariables(), &scr->_localsSegment); diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 58c88ca870..d402afbf1a 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -36,15 +36,6 @@ namespace Sci { /** - * Verify the the given condition is true, output the message if condition is false, and exit. - * @param cond condition to be verified - * @param msg the message to be printed if condition fails - */ -#define VERIFY( cond, msg ) if (!(cond)) {\ - error("%s, line, %d, %s", __FILE__, __LINE__, msg); \ - } - -/** * Parameters for getScriptSegment(). */ enum ScriptLoadType { |