mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 16:26:53 +00:00
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.
This commit is contained in:
parent
7e5113b423
commit
587811d852
@ -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) {
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
|
||||
private:
|
||||
Common::Array<RailNode *> _nodes;
|
||||
Common::Array<int16 *> _edges;
|
||||
Common::Array<int16> _edges;
|
||||
Common::List<NoWalkRect *> _noWalkRects;
|
||||
M4Surface *_walkCodes;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user