From 69b94552c2ce7e9d839d017b82697788e563d203 Mon Sep 17 00:00:00 2001 From: ArthurErlich Date: Mon, 5 Oct 2026 22:43:46 +0200 Subject: [PATCH] fix(prototype): count driving lanes from laneConfigs, require moving leader Co-Authored-By: Claude Opus 5.5 --- mod/content/overtake_probe.script.tl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mod/content/overtake_probe.script.tl b/mod/content/overtake_probe.script.tl index d48a242..e9e7a8a 100644 --- a/mod/content/overtake_probe.script.tl +++ b/mod/content/overtake_probe.script.tl @@ -47,10 +47,13 @@ local function rebuildable(seg : integer) : boolean, string local be = api.engine.getComponent(seg, api.type.ComponentType.BASE_EDGE) as Engine.Component.BaseEdge if be == nil then return false, "no BaseEdge" end if #be.objects > 0 then return false, "has edge objects" end - local tn = api.engine.getComponent(seg, api.type.ComponentType.TRANSPORT_NETWORK) as Engine.Component.TransportNetwork + -- count BaseEdge lanes, not TransportNetwork edges (town roads split each lane into several edges). + -- Sidewalks carry modes 0/1 only; driving lanes carry 2+ (observed: [2,3,4]). local driving = 0 - for _, e in ipairs(tn.edges) do - if e.speedLimit > 0 then driving = driving + 1 end + for _, lc in ipairs(be.laneConfigs) do + for k, on in pairs(lc.transportModes) do + if on and (tonumber(tostring(k)) or 0) >= 2 then driving = driving + 1 break end + end end if driving ~= 2 then return false, "driving lanes=" .. driving end return true, string.format("template=%s length=%.1f", tostring(be.roadTemplate), be.distance) @@ -116,7 +119,8 @@ local function dump(dt : number, state : GameScriptState) local a, b = cars[i], cars[j] -- ponytail: assumes pos grows in driving direction when dir=true (held so far in the logs) local ahead = (a.dir and b.pos > a.pos) or (not a.dir and b.pos < a.pos) - if i ~= j and ahead and math.abs(b.pos - a.pos) < MAX_GAP then + -- leader must be moving, otherwise it's a queue at a stop or junction, not a slow vehicle + if i ~= j and ahead and math.abs(b.pos - a.pos) < MAX_GAP and b.speed > 1.0 then local seg = laneSeg[key] local ok, why = rebuildable(seg) p(string.format("REBUILD_TEST candidate seg=%d follower=%d (pos=%.1f v=%.2f) leader=%d (pos=%.1f v=%.2f) ok=%s %s",