aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2011-05-25 16:42:16 +0200
committerMax Horn2011-05-25 16:42:16 +0200
commit587811d852713dfd14a23e48bedc06ae9d99a79b (patch)
tree36a443b4988d30919703d87b0a9736437667839e /engines
parent7e5113b4230d2186a85e2e5ef0920d9d7e753c6d (diff)
downloadscummvm-rg350-587811d852713dfd14a23e48bedc06ae9d99a79b.tar.gz
scummvm-rg350-587811d852713dfd14a23e48bedc06ae9d99a79b.tar.bz2
scummvm-rg350-587811d852713dfd14a23e48bedc06ae9d99a79b.zip
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.
Diffstat (limited to 'engines')
-rw-r--r--engines/m4/rails.cpp8
-rw-r--r--engines/m4/rails.h2
2 files changed, 4 insertions, 6 deletions
diff --git a/engines/m4/rails.cpp b/engines/m4/rails.cpp
index d706af8ef1..f51d81c8f4 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 ccc9e00536..80bb55e9de 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;