diff options
author | Peter Kohaut | 2018-03-24 17:20:27 +0100 |
---|---|---|
committer | Peter Kohaut | 2018-03-24 17:28:34 +0100 |
commit | 5e9985bd6e4d136ec20e5e3be7589d34051227f1 (patch) | |
tree | e8b8f70ad0f509ec7b919c68c2f09bd2bbf0e8a1 /engines/bladerunner/archive.cpp | |
parent | 2a646f8cc287a98f90e561ce8072c2af4322fd22 (diff) | |
download | scummvm-rg350-5e9985bd6e4d136ec20e5e3be7589d34051227f1.tar.gz scummvm-rg350-5e9985bd6e4d136ec20e5e3be7589d34051227f1.tar.bz2 scummvm-rg350-5e9985bd6e4d136ec20e5e3be7589d34051227f1.zip |
BLADERUNNER: Load game methods
save methods update
replaced few char* with Common::String
changed few pointers to references
Diffstat (limited to 'engines/bladerunner/archive.cpp')
-rw-r--r-- | engines/bladerunner/archive.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/engines/bladerunner/archive.cpp b/engines/bladerunner/archive.cpp index 8088e1ac67..c116eeb94f 100644 --- a/engines/bladerunner/archive.cpp +++ b/engines/bladerunner/archive.cpp @@ -51,7 +51,7 @@ bool MIXArchive::open(const Common::String &filename) { _entries.resize(_entryCount); for (uint16 i = 0; i != _entryCount; ++i) { - _entries[i].id = _fd.readSint32LE(); + _entries[i].hash = _fd.readUint32LE(); _entries[i].offset = _fd.readUint32LE(); _entries[i].length = _fd.readUint32LE(); @@ -61,7 +61,7 @@ bool MIXArchive::open(const Common::String &filename) { // Verify that the entries are sorted by id. Note that id is signed. if (i > 0) { - assert(_entries[i].id > _entries[i - 1].id); + assert(_entries[i].hash > _entries[i - 1].hash); } } @@ -86,7 +86,7 @@ bool MIXArchive::isOpen() const { #define ROL(n) ((n << 1) | ((n >> 31) & 1)) -int32 mix_id(const Common::String &name) { +int32 MIXArchive::getHash(const Common::String &name) { char buffer[12] = { 0 }; for (uint i = 0; i != name.size() && i < 12u; ++i) { @@ -103,11 +103,10 @@ int32 mix_id(const Common::String &name) { id = ROL(id) + t; } - return reinterpret_cast<int32&>(id); + return id; } -static -int32 tlk_id(const Common::String &name) { +static uint32 tlk_id(const Common::String &name) { char buffer[12] = { 0 }; for (uint i = 0; i != name.size() && i < 12u; ++i) @@ -124,15 +123,15 @@ int32 tlk_id(const Common::String &name) { return 10000 * actor_id + speech_id; } -uint32 MIXArchive::indexForId(int32 id) const { +uint32 MIXArchive::indexForHash(int32 hash) const { uint32 lo = 0, hi = _entryCount; while (lo < hi) { uint32 mid = lo + (hi - lo) / 2; - if (id > _entries[mid].id) { + if (hash > _entries[mid].hash) { lo = mid + 1; - } else if (id < _entries[mid].id) { + } else if (hash < _entries[mid].hash) { hi = mid; } else { return mid; @@ -142,14 +141,15 @@ uint32 MIXArchive::indexForId(int32 id) const { } Common::SeekableReadStream *MIXArchive::createReadStreamForMember(const Common::String &name) { - int32 id; + int32 hash; - if (_isTLK) - id = tlk_id(name); - else - id = mix_id(name); + if (_isTLK) { + hash = tlk_id(name); + } else { + hash = MIXArchive::getHash(name); + } - uint32 i = indexForId(id); + uint32 i = indexForHash(hash); if (i == _entryCount) { return nullptr; |