diff options
author | Max Horn | 2009-09-17 00:46:01 +0000 |
---|---|---|
committer | Max Horn | 2009-09-17 00:46:01 +0000 |
commit | 280bee663ef57c20b9ae8dad7b202b6a48bf7122 (patch) | |
tree | 5014d8722e2c88331626e89a809953aecb77f4e4 /engines/sci | |
parent | 10f898c90eef6c63995d21c2150f022ae012ea4d (diff) | |
download | scummvm-rg350-280bee663ef57c20b9ae8dad7b202b6a48bf7122.tar.gz scummvm-rg350-280bee663ef57c20b9ae8dad7b202b6a48bf7122.tar.bz2 scummvm-rg350-280bee663ef57c20b9ae8dad7b202b6a48bf7122.zip |
SCI: Change SegmentId from int to uint16; consistently use segment 0 to indicate an invalid segment
svn-id: r44131
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kstring.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/memobj.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 14 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 4 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/vm_types.h | 4 |
6 files changed, 14 insertions, 18 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index cbe5dfca7a..d6161ca954 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -148,7 +148,7 @@ reg_t kSetSynonyms(EngineState *s, int, int argc, reg_t *argv) { script = GET_SEL32V(objpos, number); seg = s->segMan->getScriptSegment(script); - if (seg >= 0) + if (seg > 0) _numSynonyms = s->segMan->getScript(seg)->getSynonymsNr(); if (_numSynonyms) { diff --git a/engines/sci/engine/memobj.h b/engines/sci/engine/memobj.h index 7889f529f8..e792ac80ae 100644 --- a/engines/sci/engine/memobj.h +++ b/engines/sci/engine/memobj.h @@ -269,7 +269,7 @@ public: Common::Array<Object> _objects; int _localsOffset; - int _localsSegment; /**< The local variable segment */ + SegmentId _localsSegment; /**< The local variable segment */ LocalVariables *_localsBlock; Common::Array<CodeBlock> _codeBlocks; diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 402a690e62..c503d7bcd0 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -116,7 +116,7 @@ SegmentObj *SegManager::allocSegment(SegmentType type, SegmentId *segid) { Script *SegManager::allocateScript(int script_nr, SegmentId *seg_id) { // Check if the script already has an allocated segment. If it // does have one, return it. - *seg_id = _scriptSegMap.getVal(script_nr, -1); + *seg_id = _scriptSegMap.getVal(script_nr, 0); if (*seg_id > 0) { return (Script *)_heap[*seg_id]; } @@ -223,7 +223,7 @@ SegmentId SegManager::findSegmentByType(int type) { for (uint i = 0; i < _heap.size(); i++) if (_heap[i] && _heap[i]->getType() == type) return i; - return -1; + return 0; } SegmentObj *SegManager::getSegmentObj(SegmentId seg) { @@ -414,9 +414,9 @@ void Script::heapRelocate(reg_t block) { } } -// return the seg if script_id is valid and in the map, else -1 +// return the seg if script_id is valid and in the map, else 0 SegmentId SegManager::getScriptSegment(int script_id) const { - return _scriptSegMap.getVal(script_id, -1); + return _scriptSegMap.getVal(script_id, 0); } SegmentId SegManager::getScriptSegment(int script_nr, ScriptLoadType load) { @@ -430,10 +430,8 @@ SegmentId SegManager::getScriptSegment(int script_nr, ScriptLoadType load) { if (segment > 0) { if ((load & SCRIPT_GET_LOCK) == SCRIPT_GET_LOCK) getScript(segment)->incrementLockers(); - - return segment; - } else - return -1; + } + return segment; } reg_t SegManager::getClassAddress(int classnr, ScriptLoadType lock, reg_t caller) { diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 4b1f0aaf99..e3d6099f1e 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -93,7 +93,7 @@ public: /** * Determines the segment occupied by a certain script, if any. * @param script_nr Number of the script to look up - * @return The script's segment ID, or -1 on failure + * @return The script's segment ID, or 0 on failure */ SegmentId getScriptSegment(int script_nr) const; @@ -102,7 +102,7 @@ public: * load it, or load & lock it. * @param[in] script_nr Number of the script to look up * @param[in] load flag determining whether to load/lock the script - * @return The script's segment ID, or -1 on failure + * @return The script's segment ID, or 0 on failure */ SegmentId getScriptSegment(int script_nr, ScriptLoadType load); diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 7d45f2153b..c0381519cc 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1509,9 +1509,6 @@ reg_t script_lookup_export(SegManager *segMan, int script_nr, int export_index) #define INST_LOOKUP_CLASS(id) ((id == 0xffff)? NULL_REG : segMan->getClassAddress(id, SCRIPT_GET_LOCK, reg)) int script_instantiate_common(ResourceManager *resMan, SegManager *segMan, int script_nr, Resource **script, Resource **heap, int *was_new) { - int seg_id; - reg_t reg; - *was_new = 1; *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); @@ -1529,7 +1526,7 @@ int script_instantiate_common(ResourceManager *resMan, SegManager *segMan, int s return 0; } - seg_id = segMan->getScriptSegment(script_nr); + SegmentId seg_id = segMan->getScriptSegment(script_nr); Script *scr = segMan->getScriptIfLoaded(seg_id); if (scr) { if (!scr->isMarkedAsDeleted()) { @@ -1548,6 +1545,7 @@ int script_instantiate_common(ResourceManager *resMan, SegManager *segMan, int s scr->init(script_nr, resMan); + reg_t reg; reg.segment = seg_id; reg.offset = 0; diff --git a/engines/sci/engine/vm_types.h b/engines/sci/engine/vm_types.h index cf7ba2573c..6152501f46 100644 --- a/engines/sci/engine/vm_types.h +++ b/engines/sci/engine/vm_types.h @@ -31,10 +31,10 @@ namespace Sci { // Segment ID type -typedef int SegmentId; +typedef uint16 SegmentId; struct reg_t { - uint16 segment; + SegmentId segment; uint16 offset; bool isNull() const { |