From b3011faaef07e607dc3b7a9813d3bd788179a225 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 28 Jun 2010 12:28:12 +0000 Subject: [PATCH] SCI: Make various SegManager const svn-id: r50439 --- engines/sci/engine/seg_manager.cpp | 14 +++++++------- engines/sci/engine/seg_manager.h | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 56591c47269..ea1fc389cda 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -168,7 +168,7 @@ int SegManager::deallocate(SegmentId seg, bool recursive) { return 1; } -bool SegManager::isHeapObject(reg_t pos) { +bool SegManager::isHeapObject(reg_t pos) const { const Object *obj = getObject(pos); if (obj == NULL || (obj && obj->isFreed())) return false; @@ -194,36 +194,36 @@ Script *SegManager::getScript(const SegmentId seg) { return (Script *)_heap[seg]; } -Script *SegManager::getScriptIfLoaded(const SegmentId seg) { +Script *SegManager::getScriptIfLoaded(const SegmentId seg) const { if (seg < 1 || (uint)seg >= _heap.size() || !_heap[seg] || _heap[seg]->getType() != SEG_TYPE_SCRIPT) return 0; return (Script *)_heap[seg]; } -SegmentId SegManager::findSegmentByType(int type) { +SegmentId SegManager::findSegmentByType(int type) const { for (uint i = 0; i < _heap.size(); i++) if (_heap[i] && _heap[i]->getType() == type) return i; return 0; } -SegmentObj *SegManager::getSegmentObj(SegmentId seg) { +SegmentObj *SegManager::getSegmentObj(SegmentId seg) const { if (seg < 1 || (uint)seg >= _heap.size() || !_heap[seg]) return 0; return _heap[seg]; } -SegmentType SegManager::getSegmentType(SegmentId seg) { +SegmentType SegManager::getSegmentType(SegmentId seg) const { if (seg < 1 || (uint)seg >= _heap.size() || !_heap[seg]) return SEG_TYPE_INVALID; return _heap[seg]->getType(); } -SegmentObj *SegManager::getSegment(SegmentId seg, SegmentType type) { +SegmentObj *SegManager::getSegment(SegmentId seg, SegmentType type) const { return getSegmentType(seg) == type ? _heap[seg] : NULL; } -Object *SegManager::getObject(reg_t pos) { +Object *SegManager::getObject(reg_t pos) const { SegmentObj *mobj = getSegmentObj(pos.segment); Object *obj = NULL; diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 4af2965bc73..0ef904618bf 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -161,7 +161,7 @@ public: * @param seg ID of the script segment to check for * @return A pointer to the Script object, or NULL */ - Script *getScriptIfLoaded(SegmentId seg); + Script *getScriptIfLoaded(SegmentId seg) const; // 2. Clones @@ -387,33 +387,33 @@ public: * @param type The type of the segment to find * @return The segment number, or -1 if the segment wasn't found */ - SegmentId findSegmentByType(int type); + SegmentId findSegmentByType(int type) const; // TODO: document this - SegmentObj *getSegmentObj(SegmentId seg); + SegmentObj *getSegmentObj(SegmentId seg) const; // TODO: document this - SegmentType getSegmentType(SegmentId seg); + SegmentType getSegmentType(SegmentId seg) const; // TODO: document this - SegmentObj *getSegment(SegmentId seg, SegmentType type); + SegmentObj *getSegment(SegmentId seg, SegmentType type) const; /** * Retrieves an object from the specified location * @param[in] offset Location (segment, offset) of the object * @return The object in question, or NULL if there is none */ - Object *getObject(reg_t pos); + Object *getObject(reg_t pos) const; /** * Checks whether a heap address contains an object * @parm obj The address to check * @return True if it is an object, false otherwise */ - bool isObject(reg_t obj) { return getObject(obj) != NULL; } + bool isObject(reg_t obj) const { return getObject(obj) != NULL; } // TODO: document this - bool isHeapObject(reg_t pos); + bool isHeapObject(reg_t pos) const; /** * Determines the name of an object