summaryrefslogtreecommitdiff
path: root/src/yapf
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2007-07-04 00:12:02 +0000
committerKUDr <kudr@openttd.org>2007-07-04 00:12:02 +0000
commitdd697570e5ae4445c67e7507905da458450fedfb (patch)
tree1882a51a9fa2a5d869b8cabafbe83513a4cd16f9 /src/yapf
parent232cfb0fc1ce0602a9c0ac660dcb63a49705a176 (diff)
downloadopenttd-dd697570e5ae4445c67e7507905da458450fedfb.tar.xz
(svn r10423) -Fix [YAPF, r10301]: INVALID_TRACKDIR causing buffer overrun leading to desync in MP game (many thanks Rubidium)
Diffstat (limited to 'src/yapf')
-rw-r--r--src/yapf/yapf_costrail.hpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp
index 4fe1eb74f..477484994 100644
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -90,6 +90,8 @@ public:
FORCEINLINE int CurveCost(Trackdir td1, Trackdir td2)
{
+ assert(IsValidTrackdir(td1));
+ assert(IsValidTrackdir(td2));
int cost = 0;
if (TrackFollower::Allow90degTurns()
&& ((TrackdirToTrackdirBits(td2) & (TrackdirBits)TrackdirCrossesTrackdirs(td1)) != 0)) {
@@ -265,7 +267,7 @@ public:
TILE cur(n.m_key.m_tile, n.m_key.m_td);
// the previous tile will be needed for transition cost calculations
- TILE prev = has_parent ? TILE() : TILE(n.m_parent->GetLastTile(), n.m_parent->GetLastTrackdir());
+ TILE prev = !has_parent ? TILE() : TILE(n.m_parent->GetLastTile(), n.m_parent->GetLastTrackdir());
EndSegmentReasonBits end_segment_reason = ESRB_NONE;