fix(client): 优化停站预告判断条件,彻底解决停站倒秒重复播报
修复由于列车时刻表中的目的站字符串与 NBT 或显示器获取到的目的地字符串不完全匹配,导致 `isAtStation` 判断失败的问题。 现在判断列车是否在站(`isAtStation`)主要依据 `trainName` 与 `State.currentTrain.id` 是否匹配。 对于未命名列车(如 ??? 或 Unknown),会额外通过模糊匹配或基础名称匹配目的地,从而保证当任何一列车在站台停留期间,系统正确识别它已停站,并忽略它因为离站倒数带来的 `etaSeconds > 0` 从而错误触发进站预告。
This commit is contained in:
+29
-3
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.56"
|
local APP_VERSION_TEXT = "v1.0.57"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -2725,7 +2725,20 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local isAtStation = State.currentTrain and State.currentTrain.id == trainName and State.currentTrain.dest == destination
|
local isAtStation = false
|
||||||
|
if State.currentTrain then
|
||||||
|
if State.currentTrain.id == trainName then
|
||||||
|
if trainName == "???" or trainName == "Unknown" or trainName == "" then
|
||||||
|
local currentDest = Utils.getBaseName(State.currentTrain.dest)
|
||||||
|
local nbtDest = Utils.getBaseName(destination)
|
||||||
|
if currentDest == nbtDest or currentDest:find(nbtDest, 1, true) or nbtDest:find(currentDest, 1, true) then
|
||||||
|
isAtStation = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
isAtStation = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if not isAtStation and etaSeconds > 0 and etaSeconds <= 45 then
|
if not isAtStation and etaSeconds > 0 and etaSeconds <= 45 then
|
||||||
if not seenApproachKeys[announceKey] then
|
if not seenApproachKeys[announceKey] then
|
||||||
seenApproachKeys[announceKey] = true
|
seenApproachKeys[announceKey] = true
|
||||||
@@ -2863,7 +2876,20 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local isAtStation = State.currentTrain and State.currentTrain.id == tName and State.currentTrain.dest == dest
|
local isAtStation = false
|
||||||
|
if State.currentTrain then
|
||||||
|
if State.currentTrain.id == tName then
|
||||||
|
if tName == "???" or tName == "Unknown" or tName == "" then
|
||||||
|
local currentDest = Utils.getBaseName(State.currentTrain.dest)
|
||||||
|
local nbtDest = Utils.getBaseName(dest)
|
||||||
|
if currentDest == nbtDest or currentDest:find(nbtDest, 1, true) or nbtDest:find(currentDest, 1, true) then
|
||||||
|
isAtStation = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
isAtStation = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if not isAtStation and etaSeconds > 0 and etaSeconds <= 45 then
|
if not isAtStation and etaSeconds > 0 and etaSeconds <= 45 then
|
||||||
if not seenApproachKeys[announceKey] then
|
if not seenApproachKeys[announceKey] then
|
||||||
seenApproachKeys[announceKey] = true
|
seenApproachKeys[announceKey] = true
|
||||||
|
|||||||
Reference in New Issue
Block a user