[Scummvm-cvs-logs] scummvm master -> 8615cecfe07ee4d76d9620dd96d11c8ce4df5011

fingolfin max at quendi.de
Wed May 25 16:46:34 CEST 2011


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

Summary:
7e5113b423 TSAGE: Silence another (incorrect but still annoying) uninitialized var warning
587811d852 M4: Attempt to fix the broken Rails code
8615cecfe0 SCI: Constify Object::_baseVars


Commit: 7e5113b4230d2186a85e2e5ef0920d9d7e753c6d
    https://github.com/scummvm/scummvm/commit/7e5113b4230d2186a85e2e5ef0920d9d7e753c6d
Author: Max Horn (max at quendi.de)
Date: 2011-05-25T07:35:09-07:00

Commit Message:
TSAGE: Silence another (incorrect but still annoying) uninitialized var warning

Changed paths:
    engines/tsage/saveload.cpp



diff --git a/engines/tsage/saveload.cpp b/engines/tsage/saveload.cpp
index 6ae6256..56df321 100644
--- a/engines/tsage/saveload.cpp
+++ b/engines/tsage/saveload.cpp
@@ -64,14 +64,12 @@ Saver::~Saver() {
 
 void Serializer::syncPointer(SavedObject **ptr, Common::Serializer::Version minVersion,
 		Common::Serializer::Version maxVersion) {
-	int idx;
+	int idx = 0;
 	assert(ptr);
 
 	if (isSaving()) {
 		// Get the object index for the given pointer and write it out
-		if (!*ptr) {
-			idx = 0;
-		} else {
+		if (*ptr) {
 			idx = _saver->blockIndexOf(*ptr);
 			assert(idx > 0);
 		}


Commit: 587811d852713dfd14a23e48bedc06ae9d99a79b
    https://github.com/scummvm/scummvm/commit/587811d852713dfd14a23e48bedc06ae9d99a79b
Author: Max Horn (max at quendi.de)
Date: 2011-05-25T07:42:16-07:00

Commit Message:
M4: Attempt to fix the broken Rails code

I am not sure how this code could have ever worked without lots of
crashing, but maybe I am missing something... Still, casting an
arbitrary integer value to an int *pointer* and then later dereferencing
it does not seem like a good idea :).

Changed the code to do what I *guess* it was meant to do. But somebody
who actually knows M4 and its games should double check.

Changed paths:
    engines/m4/rails.cpp
    engines/m4/rails.h



diff --git a/engines/m4/rails.cpp b/engines/m4/rails.cpp
index d706af8..f51d81c 100644
--- a/engines/m4/rails.cpp
+++ b/engines/m4/rails.cpp
@@ -61,9 +61,7 @@ void Rails::clearRails() {
 		delete tempNode;
 	}
 
-	for (i = 0; i < _edges.size(); i++) {
-		_edges.remove_at(i);
-	}
+	_edges.clear();
 
 	for (j = _noWalkRects.begin(); j != _noWalkRects.end(); ++j)
 		delete (*j);
@@ -246,7 +244,7 @@ void Rails::createEdge(int32 node1, int32 node2) {
 		} else {
 			distance = SqrtF16(FixedMul(deltaX, deltaX) + FixedMul(deltaY, deltaY)) << 8;
 		}
-		_edges.insert_at(index, (int16*)(distance >> 16));
+		_edges.insert_at(index, distance >> 16);
 	}
 
 	debugCN(kDebugCore, "node1 = %d, node2 = %d, valid = %d\n", node1, node2, valid);
@@ -312,7 +310,7 @@ int16 Rails::getEdgeLength(int32 node1, int32 node2) {
 	// Find the table entry i.e. tableWidth * node1 + node2 and then subtract
 	// n(n+1)/2, since only the upper triangle of the table is stored
 	index = (MAXRAILNODES-1)*node1 + node2 - 1 - (node1*(node1+1)>>1);
-	return *_edges[index];
+	return _edges[index];
 }
 
 void Rails::disposePath(RailNode *pathStart) {
diff --git a/engines/m4/rails.h b/engines/m4/rails.h
index ccc9e00..80bb55e 100644
--- a/engines/m4/rails.h
+++ b/engines/m4/rails.h
@@ -73,7 +73,7 @@ public:
 
 private:
 	Common::Array<RailNode *> _nodes;
-	Common::Array<int16 *> _edges;
+	Common::Array<int16> _edges;
 	Common::List<NoWalkRect *> _noWalkRects;
 	M4Surface *_walkCodes;
 


Commit: 8615cecfe07ee4d76d9620dd96d11c8ce4df5011
    https://github.com/scummvm/scummvm/commit/8615cecfe07ee4d76d9620dd96d11c8ce4df5011
Author: Max Horn (max at quendi.de)
Date: 2011-05-25T07:44:50-07:00

Commit Message:
SCI: Constify Object::_baseVars

This may have to be undone if we ever want to start free'ing _baseVars again.

Changed paths:
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h



diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp
index aee93ff..f09f182 100644
--- a/engines/sci/engine/object.cpp
+++ b/engines/sci/engine/object.cpp
@@ -58,14 +58,14 @@ void Object::init(byte *buf, reg_t obj_pos, bool initVariables) {
 
 	if (getSciVersion() <= SCI_VERSION_1_LATE) {
 		_variables.resize(READ_LE_UINT16(data + kOffsetSelectorCounter));
-		_baseVars = (uint16 *)(_baseObj + _variables.size() * 2);
+		_baseVars = (const uint16 *)(_baseObj + _variables.size() * 2);
 		_methodCount = READ_LE_UINT16(data + READ_LE_UINT16(data + kOffsetFunctionArea) - 2);
 		for (int i = 0; i < _methodCount * 2 + 2; ++i) {
 			_baseMethod.push_back(READ_SCI11ENDIAN_UINT16(data + READ_LE_UINT16(data + kOffsetFunctionArea) + i * 2));
 		}
 	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
 		_variables.resize(READ_SCI11ENDIAN_UINT16(data + 2));
-		_baseVars = (uint16 *)(buf + READ_SCI11ENDIAN_UINT16(data + 4));
+		_baseVars = (const uint16 *)(buf + READ_SCI11ENDIAN_UINT16(data + 4));
 		_methodCount = READ_SCI11ENDIAN_UINT16(buf + READ_SCI11ENDIAN_UINT16(data + 6));
 		for (int i = 0; i < _methodCount * 2 + 3; ++i) {
 			_baseMethod.push_back(READ_SCI11ENDIAN_UINT16(buf + READ_SCI11ENDIAN_UINT16(data + 6) + i * 2));
diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h
index 7e07fb2..80c8e9e 100644
--- a/engines/sci/engine/object.h
+++ b/engines/sci/engine/object.h
@@ -236,7 +236,7 @@ private:
 	void initSelectorsSci3(const byte *buf);
 
 	const byte *_baseObj; /**< base + object offset within base */
-	uint16 *_baseVars; /**< Pointer to the varselector area for this object */
+	const uint16 *_baseVars; /**< Pointer to the varselector area for this object */
 	Common::Array<uint16> _baseMethod; /**< Pointer to the method selector area for this object */
 	uint16 *_propertyOffsetsSci3; /**< This is used to enable relocation of property valuesa in SCI3 */
 






More information about the Scummvm-git-logs mailing list