Fix brake location calculation; was applying it to the wrong spot.

This commit is contained in:
Kistaro Windrider 2024-07-27 17:47:29 -07:00
parent 8fa98e3132
commit 00678f97fd
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -170,14 +170,14 @@ function constraints:constrain(s, want)
-- bmx: brake max
local v1, bmx = calc_velocity(s.dx, want, s.maxspd, s.drag), s.thrust + s.drag
local bd, bf = brake_dist(v1, bmx)
local bx, txm = s.x + bd, self.xmax
local bx, txm = s.x + bd + v1, self.xmax
if bx < self.xmin then
self.color = 9
want = s.thrust
txm = self.xmin
v1 = calc_velocity(s.dx, want, s.maxspd, s.drag)
bd, bf = brake_dist(v1, bmx)
bx = bd + s.x
bx = bd + s.x + v1
end
if (bx < txm) return want
self.color = 8