[Scummvm-cvs-logs] scummvm master -> 18cbb63cba75c41602bd54d7796d6e0f21e7fa61

sev- sev at scummvm.org
Sun Jul 10 17:15:54 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1c711da8fc SWORD25: Fix regression introduced in 5dd8f2575b0f
18cbb63cba SWORD25: Removed custom endianness code in persistence code


Commit: 1c711da8fc2f8099e641cfbe0a726e2f5ff8e308
    https://github.com/scummvm/scummvm/commit/1c711da8fc2f8099e641cfbe0a726e2f5ff8e308
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2011-07-10T08:10:58-07:00

Commit Message:
SWORD25: Fix regression introduced in 5dd8f2575b0f

Janitorial removed function call which had a side effect.
Thus the actor image load code crashed.

Changed paths:
    engines/sword25/gfx/image/vectorimage.cpp



diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp
index 45d43c4..81f4fc2 100644
--- a/engines/sword25/gfx/image/vectorimage.cpp
+++ b/engines/sword25/gfx/image/vectorimage.cpp
@@ -247,6 +247,9 @@ VectorImage::VectorImage(const byte *pFileData, uint fileSize, bool &success, co
 		return;
 	}
 
+	// readout SWF size
+	flashRectToBSRect(bs);
+
 	// Get frame rate and frame count
 	/* uint32 frameRate = */
 	bs.getUInt16();


Commit: 18cbb63cba75c41602bd54d7796d6e0f21e7fa61
    https://github.com/scummvm/scummvm/commit/18cbb63cba75c41602bd54d7796d6e0f21e7fa61
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2011-07-10T08:11:00-07:00

Commit Message:
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.

Changed paths:
    engines/sword25/kernel/inputpersistenceblock.cpp
    engines/sword25/kernel/inputpersistenceblock.h
    engines/sword25/kernel/outputpersistenceblock.cpp
    engines/sword25/kernel/persistenceblock.h



diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp
index 2d45dfb..cdce539 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;
diff --git a/engines/sword25/kernel/inputpersistenceblock.h b/engines/sword25/kernel/inputpersistenceblock.h
index 7e68137..2518d7e 100644
--- a/engines/sword25/kernel/inputpersistenceblock.h
+++ b/engines/sword25/kernel/inputpersistenceblock.h
@@ -69,7 +69,6 @@ public:
 private:
 	bool checkMarker(byte marker);
 	bool checkBlockSize(int size);
-	void rawRead(void *destPtr, size_t size);
 
 	Common::Array<byte> _data;
 	Common::Array<byte>::const_iterator _iter;
diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp
index cf28ea4..e29d956 100644
--- a/engines/sword25/kernel/outputpersistenceblock.cpp
+++ b/engines/sword25/kernel/outputpersistenceblock.cpp
@@ -43,19 +43,23 @@ OutputPersistenceBlock::OutputPersistenceBlock() {
 
 void OutputPersistenceBlock::write(signed int value) {
 	writeMarker(SINT_MARKER);
-	value = convertEndianessFromSystemToStorage(value);
+	value = TO_LE_32(value);
 	rawWrite(&value, sizeof(value));
 }
 
 void OutputPersistenceBlock::write(uint value) {
 	writeMarker(UINT_MARKER);
-	value = convertEndianessFromSystemToStorage(value);
+	value = TO_LE_32(value);
 	rawWrite(&value, sizeof(value));
 }
 
 void OutputPersistenceBlock::write(float value) {
 	writeMarker(FLOAT_MARKER);
-	value = convertEndianessFromSystemToStorage(value);
+	uint32 tmp[1];
+
+	((float *)tmp)[0] = value;
+	tmp[0] = TO_LE_32(tmp[0]);
+
 	rawWrite(&value, sizeof(value));
 }
 
@@ -63,7 +67,7 @@ void OutputPersistenceBlock::write(bool value) {
 	writeMarker(BOOL_MARKER);
 
 	uint uintBool = value ? 1 : 0;
-	uintBool = convertEndianessFromSystemToStorage(uintBool);
+	uintBool = TO_LE_32(uintBool);
 	rawWrite(&uintBool, sizeof(uintBool));
 }
 
diff --git a/engines/sword25/kernel/persistenceblock.h b/engines/sword25/kernel/persistenceblock.h
index d8440fa..8ac3e84 100644
--- a/engines/sword25/kernel/persistenceblock.h
+++ b/engines/sword25/kernel/persistenceblock.h
@@ -64,48 +64,6 @@ protected:
 		BLOCK_MARKER
 	};
 
-	// -----------------------------------------------------------------------------
-	// Endianess Conversions
-	// -----------------------------------------------------------------------------
-	//
-	// Everything is stored in Little Endian
-	// Big Endian Systems will need to be byte swapped during both saving and reading of saved values
-	//
-
-	template<typename T>
-	static T convertEndianessFromSystemToStorage(T value) {
-		if (isBigEndian())
-			reverseByteOrder(&value);
-		return value;
-	}
-
-	template<typename T>
-	static T convertEndianessFromStorageToSystem(T value) {
-		if (isBigEndian())
-			reverseByteOrder(&value);
-		return value;
-	}
-
-private:
-	static bool isBigEndian() {
-		uint dummy = 1;
-		byte *dummyPtr = reinterpret_cast<byte *>(&dummy);
-		return dummyPtr[0] == 0;
-	}
-
-	template<typename T>
-	static void swap(T &one, T &two) {
-		T temp = one;
-		one = two;
-		two = temp;
-	}
-
-	static void reverseByteOrder(void *ptr) {
-		// Reverses the byte order of the 32-bit word pointed to by Ptr
-		byte *charPtr = static_cast<byte *>(ptr);
-		swap(charPtr[0], charPtr[3]);
-		swap(charPtr[1], charPtr[2]);
-	}
 };
 
 #define CTASSERT(ex) typedef char ctassert_type[(ex) ? 1 : -1]






More information about the Scummvm-git-logs mailing list