diff options
author | Johannes Schickel | 2016-04-06 23:05:54 +0200 |
---|---|---|
committer | Johannes Schickel | 2016-04-06 23:05:54 +0200 |
commit | c51c89ca3232a4bb128949b033f8f771aeff6dc3 (patch) | |
tree | 5c6060b5b84697721db70f812dbc87bdf9a22860 /engines/sci/engine/segment.h | |
parent | 8fa543f58f251ef5c695f6c288ecd0303ec14144 (diff) | |
parent | c11b09dff91bdb5047722a0a4399f34fcc042589 (diff) | |
download | scummvm-rg350-c51c89ca3232a4bb128949b033f8f771aeff6dc3.tar.gz scummvm-rg350-c51c89ca3232a4bb128949b033f8f771aeff6dc3.tar.bz2 scummvm-rg350-c51c89ca3232a4bb128949b033f8f771aeff6dc3.zip |
Merge pull request #721 from lordhoto/sci-saveload-cleanup
SCI: Cleanup of Save/Load Code
Diffstat (limited to 'engines/sci/engine/segment.h')
-rw-r--r-- | engines/sci/engine/segment.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index 2699bc2e5b..50c77d0538 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -210,16 +210,17 @@ struct Hunk { template<typename T> struct SegmentObjTable : public SegmentObj { typedef T value_type; - struct Entry : public T { + struct Entry { + T data; int next_free; /* Only used for free entries */ }; enum { HEAPENTRY_INVALID = -1 }; - int first_free; /**< Beginning of a singly linked list for entries */ int entries_used; /**< Statistical information */ - Common::Array<Entry> _table; + typedef Common::Array<Entry> ArrayType; + ArrayType _table; public: SegmentObjTable(SegmentType type) : SegmentObj(type) { @@ -272,6 +273,14 @@ public: tmp.push_back(make_reg(segId, i)); return tmp; } + + uint size() const { return _table.size(); } + + T &at(uint index) { return _table[index].data; } + const T &at(uint index) const { return _table[index].data; } + + T &operator[](uint index) { return at(index); } + const T &operator[](uint index) const { return at(index); } }; @@ -323,8 +332,8 @@ struct HunkTable : public SegmentObjTable<Hunk> { } void freeEntryContents(int idx) { - free(_table[idx].mem); - _table[idx].mem = 0; + free(at(idx).mem); + at(idx).mem = 0; } virtual void freeEntry(int idx) { @@ -502,7 +511,7 @@ struct StringTable : public SegmentObjTable<SciString> { StringTable() : SegmentObjTable<SciString>(SEG_TYPE_STRING) {} virtual void freeAtAddress(SegManager *segMan, reg_t sub_addr) { - _table[sub_addr.getOffset()].destroy(); + at(sub_addr.getOffset()).destroy(); freeEntry(sub_addr.getOffset()); } |