diff options
author | Eugene Sandulenko | 2011-07-10 16:59:13 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2011-07-10 18:11:00 +0300 |
commit | 18cbb63cba75c41602bd54d7796d6e0f21e7fa61 (patch) | |
tree | 62abea84fe2e3ab0264ca0aa1af46946987e617b /engines/sword25/kernel/inputpersistenceblock.cpp | |
parent | 1c711da8fc2f8099e641cfbe0a726e2f5ff8e308 (diff) | |
download | scummvm-rg350-18cbb63cba75c41602bd54d7796d6e0f21e7fa61.tar.gz scummvm-rg350-18cbb63cba75c41602bd54d7796d6e0f21e7fa61.tar.bz2 scummvm-rg350-18cbb63cba75c41602bd54d7796d6e0f21e7fa61.zip |
SWORD25: Removed custom endianness code in persistence code
This is first step towards making saves portable. Binary footprint
left intact, so the saves are compatible.
Diffstat (limited to 'engines/sword25/kernel/inputpersistenceblock.cpp')
-rw-r--r-- | engines/sword25/kernel/inputpersistenceblock.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp index 2d45dfb640..cdce539c31 100644 --- a/engines/sword25/kernel/inputpersistenceblock.cpp +++ b/engines/sword25/kernel/inputpersistenceblock.cpp @@ -55,8 +55,8 @@ void InputPersistenceBlock::read(int16 &value) { void InputPersistenceBlock::read(signed int &value) { if (checkMarker(SINT_MARKER)) { - rawRead(&value, sizeof(signed int)); - value = convertEndianessFromStorageToSystem(value); + value = (int32)READ_LE_UINT32(_iter); + _iter += 4; } else { value = 0; } @@ -64,8 +64,8 @@ void InputPersistenceBlock::read(signed int &value) { void InputPersistenceBlock::read(uint &value) { if (checkMarker(UINT_MARKER)) { - rawRead(&value, sizeof(uint)); - value = convertEndianessFromStorageToSystem(value); + value = READ_LE_UINT32(_iter); + _iter += 4; } else { value = 0; } @@ -73,8 +73,10 @@ void InputPersistenceBlock::read(uint &value) { void InputPersistenceBlock::read(float &value) { if (checkMarker(FLOAT_MARKER)) { - rawRead(&value, sizeof(float)); - value = convertEndianessFromStorageToSystem(value); + uint32 tmp[1]; + tmp[0] = READ_LE_UINT32(_iter); + value = ((float *)tmp)[0]; + _iter += 4; } else { value = 0.0f; } @@ -82,12 +84,11 @@ void InputPersistenceBlock::read(float &value) { void InputPersistenceBlock::read(bool &value) { if (checkMarker(BOOL_MARKER)) { - uint uintBool; - rawRead(&uintBool, sizeof(float)); - uintBool = convertEndianessFromStorageToSystem(uintBool); + uint uintBool = READ_LE_UINT32(_iter); + _iter += 4; value = uintBool == 0 ? false : true; } else { - value = 0.0f; + value = false; } } @@ -117,13 +118,6 @@ void InputPersistenceBlock::readByteArray(Common::Array<byte> &value) { } } -void InputPersistenceBlock::rawRead(void *destPtr, size_t size) { - if (checkBlockSize(size)) { - memcpy(destPtr, &*_iter, size); - _iter += size; - } -} - bool InputPersistenceBlock::checkBlockSize(int size) { if (_data.end() - _iter >= size) { return true; |