diff options
author | cheapie <no-email-for-you@example.com> | 2024-05-10 19:18:46 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2024-05-10 19:18:46 -0500 |
commit | 5ac4571337aea7ea2f9153a3138c3d1db1ff981f (patch) | |
tree | 1686893be4a08b9f4049541e20d498cb9d3b36d6 /dispatcherfw.lua | |
parent | 79aae966416d5a5322d1bd74113382d16e997c54 (diff) | |
download | celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar.gz celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar.bz2 celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar.xz celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.zip |
Fix some minor bugs
This improves fire recall when the car is currently moving past the recall floor, and fixes a delay in hall call dispatching when a car is currently leaving the floor the call is on.
Diffstat (limited to 'dispatcherfw.lua')
-rw-r--r-- | dispatcherfw.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/dispatcherfw.lua b/dispatcherfw.lua index aac7e07..bb609d5 100644 --- a/dispatcherfw.lua +++ b/dispatcherfw.lua @@ -169,7 +169,15 @@ local function gettarget(floor) return target end -local function predictnextstop(carid,startpos,direction,carcalls,upcalls,dncalls) +local function predictnextstop(carid,startpos,direction,carcalls,upcalls,dncalls,leaving) + if leaving then + local vel = mem.carstatus[carid].vel + if vel > 0 then + startpos = startpos+1 + elseif vel < 0 then + startpos = startpos-1 + end + end if direction == "up" then if getnextcallabove(carid,"up",startpos,carcalls,upcalls,dncalls) then return getnextcallabove(carid,"up",startpos,carcalls,upcalls,dncalls),"up" @@ -216,7 +224,7 @@ local function estimatetraveltime(carid,src,dest) return estimate end -local function buildstopsequence(carid,startfloor,direction,target,targetdir) +local function buildstopsequence(carid,startfloor,direction,target,targetdir,leaving) local carcalls = cartorealfloor(carid,mem.carstatus[carid].carcalls) local upcalls = cartorealfloor(carid,mem.carstatus[carid].upcalls) local dncalls = cartorealfloor(carid,mem.carstatus[carid].dncalls) @@ -235,7 +243,7 @@ local function buildstopsequence(carid,startfloor,direction,target,targetdir) end repeat local src = carpos - carpos,direction = predictnextstop(carid,carpos,direction,carcalls,upcalls,dncalls) + carpos,direction = predictnextstop(carid,carpos,direction,carcalls,upcalls,dncalls,leaving) carcalls[carpos] = nil if direction == "up" then upcalls[carpos] = nil @@ -251,7 +259,8 @@ local function buildstopsequence(carid,startfloor,direction,target,targetdir) end local function calculateeta(carid,floor,direction) - local sequence = buildstopsequence(carid,getpos(carid),mem.carstatus[carid].direction,floor,direction) + local leaving = (getpos(carid) ~= getdpos(carid)) and (getpos(carid) == floor) + local sequence = buildstopsequence(carid,getpos(carid),mem.carstatus[carid].direction,floor,direction,leaving) local doorstate = mem.carstatus[carid].doorstate local doortimes = { closed = 0, |