aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/savegame.cpp4
-rw-r--r--engines/sci/engine/seg_manager.cpp6
-rw-r--r--engines/sci/engine/vm.h56
3 files changed, 36 insertions, 30 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 198d62e41b..710c6b8a20 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -445,12 +445,12 @@ static void sync_MemObjPtr(Common::Serializer &s, MemObject *&obj) {
if (s.isLoading()) {
//assert(!obj);
obj = (MemObject *)sci_calloc(1, sizeof(MemObject));
- obj->_type = type;
+ obj->data.tmp_dummy._type = type;
} else {
assert(obj);
}
- s.syncAsSint32LE(obj->_segmgrId);
+ s.syncAsSint32LE(obj->data.tmp_dummy._segmgrId);
switch (type) {
case MEM_OBJ_SCRIPT:
sync_Script(s, obj->data.script);
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index c48a6aeb34..2c615b2d1a 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -367,8 +367,8 @@ MemObject *SegManager::memObjAllocate(SegmentId segid, int hash_id, memObjType t
memset(heap + oldhs, 0, sizeof(MemObject *) * (heap_size - oldhs));
}
- mem->_segmgrId = hash_id;
- mem->_type = type;
+ mem->data.tmp_dummy._segmgrId = hash_id;
+ mem->data.tmp_dummy._type = type;
// hook it to the heap
heap[segid] = mem;
@@ -970,7 +970,7 @@ SystemStrings *SegManager::allocateSysStrings(SegmentId *segid) {
MemObject *memobj = allocNonscriptSegment(MEM_OBJ_SYS_STRINGS, segid);
SystemStrings *retval = &(memobj->data.sys_strings);
- memset(retval, 0, sizeof(SystemString)*SYS_STRINGS_MAX);
+ memset(retval->strings, 0, sizeof(retval->strings));
return retval;
}
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index b8e818b2b6..6d9c1f2b8b 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -34,6 +34,28 @@
namespace Sci {
+enum memObjType {
+ MEM_OBJ_INVALID = 0,
+ MEM_OBJ_SCRIPT = 1,
+ MEM_OBJ_CLONES = 2,
+ MEM_OBJ_LOCALS = 3,
+ MEM_OBJ_STACK = 4,
+ MEM_OBJ_SYS_STRINGS = 5,
+ MEM_OBJ_LISTS = 6,
+ MEM_OBJ_NODES = 7,
+ MEM_OBJ_HUNK = 8,
+ MEM_OBJ_DYNMEM = 9,
+ MEM_OBJ_STRING_FRAG = 10,
+
+ MEM_OBJ_MAX // For sanity checking
+};
+
+struct MemObjectNEW {
+ memObjType _type;
+ int _segmgrId; /**< Internal value used by the seg_manager's hash map */
+};
+
+
struct IntMapper;
enum {
@@ -51,7 +73,7 @@ struct SystemString {
reg_t *value;
};
-struct SystemStrings {
+struct SystemStrings : public MemObjectNEW {
SystemString strings[SYS_STRINGS_MAX];
};
@@ -149,7 +171,7 @@ struct CallsStruct {
int type; /**< Same as ExecStack.type */
};
-struct LocalVariables {
+struct LocalVariables : public MemObjectNEW {
int script_id; /**< Script ID this local variable block belongs to */
reg_t *locals;
int nr;
@@ -198,7 +220,7 @@ struct CodeBlock {
-struct Script {
+struct Script : public MemObjectNEW {
int nr; /**< Script number */
byte* buf; /**< Static data buffer, or NULL if not used */
size_t buf_size;
@@ -233,7 +255,7 @@ struct Script {
};
/** Data stack */
-struct dstack_t {
+struct dstack_t : MemObjectNEW {
int nr; /**< Number of stack entries */
reg_t *entries;
};
@@ -262,7 +284,7 @@ struct Hunk {
};
template<typename T, int INITIAL, int INCREMENT>
-struct Table {
+struct Table : public MemObjectNEW {
struct Entry : public T {
int next_free; /* Only used for free entries */
};
@@ -324,31 +346,15 @@ void free_Hunk_entry(HunkTable *table, int index);
// Free-style memory
-struct DynMem {
+struct DynMem : public MemObjectNEW {
int size;
char *description;
byte *buf;
};
-enum memObjType {
- MEM_OBJ_INVALID = 0,
- MEM_OBJ_SCRIPT = 1,
- MEM_OBJ_CLONES = 2,
- MEM_OBJ_LOCALS = 3,
- MEM_OBJ_STACK = 4,
- MEM_OBJ_SYS_STRINGS = 5,
- MEM_OBJ_LISTS = 6,
- MEM_OBJ_NODES = 7,
- MEM_OBJ_HUNK = 8,
- MEM_OBJ_DYNMEM = 9,
- MEM_OBJ_STRING_FRAG = 10,
- MEM_OBJ_MAX = 11 // For sanity checking
-};
-
struct MemObject {
- memObjType _type;
- int _segmgrId; /**< Internal value used by the seg_manager's hash map */
union {
+ MemObjectNEW tmp_dummy;
Script script;
CloneTable clones;
LocalVariables locals;
@@ -360,8 +366,8 @@ struct MemObject {
DynMem dynmem;
} data;
- inline memObjType getType() const { return _type; }
- inline int getSegMgrId() const { return _segmgrId; }
+ inline memObjType getType() const { return data.tmp_dummy._type; }
+ inline int getSegMgrId() const { return data.tmp_dummy._segmgrId; }
};