aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2011-11-05 10:07:03 +0200
committerFilippos Karapetis2011-11-05 10:07:03 +0200
commit58190c36b4cc84b3200239211d91b0291301db56 (patch)
treefb21e29ce777cc9750809e0195a698bb31355b53 /engines/sci
parent267c6f1756c9582b8bd9534334c7f264a2400929 (diff)
downloadscummvm-rg350-58190c36b4cc84b3200239211d91b0291301db56.tar.gz
scummvm-rg350-58190c36b4cc84b3200239211d91b0291301db56.tar.bz2
scummvm-rg350-58190c36b4cc84b3200239211d91b0291301db56.zip
SCI: Made the object map hashmap of the Script class private
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp12
-rw-r--r--engines/sci/engine/savegame.cpp8
-rw-r--r--engines/sci/engine/script.h10
-rw-r--r--engines/sci/engine/seg_manager.cpp3
4 files changed, 17 insertions, 16 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 664fa6747b..b852de74a9 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -1881,11 +1881,12 @@ bool Console::segmentInfo(int nr) {
else
DebugPrintf(" Locals : none\n");
- DebugPrintf(" Objects: %4d\n", scr->_objects.size());
+ ObjMap objects = scr->getObjectMap();
+ DebugPrintf(" Objects: %4d\n", objects.size());
ObjMap::iterator it;
- const ObjMap::iterator end = scr->_objects.end();
- for (it = scr->_objects.begin(); it != end; ++it) {
+ const ObjMap::iterator end = objects.end();
+ for (it = objects.begin(); it != end; ++it) {
DebugPrintf(" ");
// Object header
const Object *obj = _engine->_gamestate->_segMan->getObject(it->_value.getPos());
@@ -2942,9 +2943,10 @@ void Console::printKernelCallsFound(int kernelFuncNum, bool showFoundScripts) {
script = customSegMan->getScript(scriptSegment);
// Iterate through all the script's objects
+ ObjMap objects = script->getObjectMap();
ObjMap::iterator it;
- const ObjMap::iterator end = script->_objects.end();
- for (it = script->_objects.begin(); it != end; ++it) {
+ const ObjMap::iterator end = objects.end();
+ for (it = objects.begin(); it != end; ++it) {
const Object *obj = customSegMan->getObject(it->_value.getPos());
const char *objName = customSegMan->getObjectName(it->_value.getPos());
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 2f87137d7f..f1c7133d01 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -203,7 +203,8 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
// Now, load the script itself
scr->load(g_sci->getResMan());
- for (ObjMap::iterator it = scr->_objects.begin(); it != scr->_objects.end(); ++it)
+ ObjMap objects = scr->getObjectMap();
+ for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it)
it->_value.syncBaseObject(scr->getBuf(it->_value.getPos().offset));
}
@@ -228,7 +229,8 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
Script *scr = (Script *)_heap[i];
scr->syncLocalsBlock(this);
- for (ObjMap::iterator it = scr->_objects.begin(); it != scr->_objects.end(); ++it) {
+ ObjMap objects = scr->getObjectMap();
+ for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it) {
reg_t addr = it->_value.getPos();
Object *obj = scr->scriptObjInit(addr, false);
@@ -237,7 +239,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
// TODO/FIXME: This should not be happening at all. It might indicate a possible issue
// with the garbage collector. It happens for example in LSL5 (German, perhaps English too).
warning("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr));
- scr->_objects.erase(addr.toUint16());
+ objects.erase(addr.toUint16());
}
}
}
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index b6610aadea..8c5495d852 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -62,7 +62,7 @@ private:
const uint16 *_exportTable; /**< Abs. offset of the export table or 0 if not present */
uint16 _numExports; /**< Number of entries in the exports table */
- const byte *_synonyms; /**< Synonyms block or 0 if not present*/
+ const byte *_synonyms; /**< Synonyms block or 0 if not present */
uint16 _numSynonyms; /**< Number of entries in the synonyms block */
int _localsOffset;
@@ -72,12 +72,7 @@ private:
SegmentId _localsSegment; /**< The local variable segment */
LocalVariables *_localsBlock;
-public:
- /**
- * Table for objects, contains property variables.
- * Indexed by the TODO offset.
- */
- ObjMap _objects;
+ ObjMap _objects; /**< Table for objects, contains property variables */
public:
int getLocalsOffset() const { return _localsOffset; }
@@ -92,6 +87,7 @@ public:
SegmentId getLocalsSegment() const { return _localsSegment; }
reg_t *getLocalsBegin() { return _localsBlock ? _localsBlock->_locals.begin() : NULL; }
void syncLocalsBlock(SegManager *segMan);
+ ObjMap getObjectMap() const { return _objects; }
public:
Script();
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 4e822a5a1e..09d586a1c6 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -270,7 +270,8 @@ reg_t SegManager::findObjectByName(const Common::String &name, int index) {
if (mobj->getType() == SEG_TYPE_SCRIPT) {
// It's a script, scan all objects in it
const Script *scr = (const Script *)mobj;
- for (ObjMap::const_iterator it = scr->_objects.begin(); it != scr->_objects.end(); ++it) {
+ ObjMap objects = scr->getObjectMap();
+ for (ObjMap::const_iterator it = objects.begin(); it != objects.end(); ++it) {
objpos.offset = it->_value.getPos().offset;
if (name == getObjectName(objpos))
result.push_back(objpos);