fix(client): 在 NBT 分支中也应用非车站指令过滤
将 `isStationDestination` 的过滤逻辑同时应用于 Block Reader(读取车站方块 NBT)的分支, 确保无论是通过显示屏还是 NBT 读取,都不会把“设置最高速度”等非停站指令当作列车进站播报。 同时已包含 `etaSeconds > 0` 修复,解决完全停站后重复播报的问题。
This commit is contained in:
+41
-33
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.53"
|
local APP_VERSION_TEXT = "v1.0.54"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -2559,6 +2559,37 @@ local function mapTrainStatusReason(statusId)
|
|||||||
return known[tail] or tail
|
return known[tail] or tail
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function isStationDestination(destName)
|
||||||
|
if not destName then return false end
|
||||||
|
local blacklist = {
|
||||||
|
"速度", "speed",
|
||||||
|
"名称", "rename", "重命名",
|
||||||
|
"时刻表", "schedule",
|
||||||
|
"区段", "section",
|
||||||
|
"卸", "unload",
|
||||||
|
"装", "load",
|
||||||
|
"等待", "wait",
|
||||||
|
"条件", "condition",
|
||||||
|
"动力", "powered",
|
||||||
|
"物品", "item",
|
||||||
|
"流体", "fluid",
|
||||||
|
"玩家", "player",
|
||||||
|
"时间", "time",
|
||||||
|
"抛弃", "discard",
|
||||||
|
"限制", "limit",
|
||||||
|
"货物", "cargo",
|
||||||
|
"无载", "unloaded",
|
||||||
|
"空载", "empty"
|
||||||
|
}
|
||||||
|
local lowerDest = string.lower(destName)
|
||||||
|
for _, word in ipairs(blacklist) do
|
||||||
|
if string.find(lowerDest, word, 1, true) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function Main.loop()
|
function Main.loop()
|
||||||
while true do
|
while true do
|
||||||
local now = os.epoch("utc")
|
local now = os.epoch("utc")
|
||||||
@@ -2643,7 +2674,14 @@ function Main.loop()
|
|||||||
if type(stop.Stopovers) == "table" and #stop.Stopovers > 0 then
|
if type(stop.Stopovers) == "table" and #stop.Stopovers > 0 then
|
||||||
destination = stop.Stopovers[#stop.Stopovers] or destination
|
destination = stop.Stopovers[#stop.Stopovers] or destination
|
||||||
end
|
end
|
||||||
local platform = stop.StationInfo and stop.StationInfo.Platform or State.stationPlatform or "1"
|
|
||||||
|
if isStationDestination(destination) then
|
||||||
|
local platform = "1"
|
||||||
|
if st.ScheduledStation and st.ScheduledStation.StationInfo and st.ScheduledStation.StationInfo.Platform then
|
||||||
|
platform = st.ScheduledStation.StationInfo.Platform
|
||||||
|
else
|
||||||
|
platform = State.stationPlatform or "1"
|
||||||
|
end
|
||||||
local cancelled = false
|
local cancelled = false
|
||||||
local reason = nil
|
local reason = nil
|
||||||
local tr = stop.Train
|
local tr = stop.Train
|
||||||
@@ -2749,6 +2787,7 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for k, _ in pairs(State.pendingAlerts) do
|
for k, _ in pairs(State.pendingAlerts) do
|
||||||
if not seenAlertKeys[k] then
|
if not seenAlertKeys[k] then
|
||||||
@@ -2768,37 +2807,6 @@ function Main.loop()
|
|||||||
local seenAlertKeys = {}
|
local seenAlertKeys = {}
|
||||||
local seenApproachKeys = {}
|
local seenApproachKeys = {}
|
||||||
|
|
||||||
local function isStationDestination(destName)
|
|
||||||
if not destName then return false end
|
|
||||||
local blacklist = {
|
|
||||||
"速度", "speed",
|
|
||||||
"名称", "rename", "重命名",
|
|
||||||
"时刻表", "schedule",
|
|
||||||
"区段", "section",
|
|
||||||
"卸", "unload",
|
|
||||||
"装", "load",
|
|
||||||
"等待", "wait",
|
|
||||||
"条件", "condition",
|
|
||||||
"动力", "powered",
|
|
||||||
"物品", "item",
|
|
||||||
"流体", "fluid",
|
|
||||||
"玩家", "player",
|
|
||||||
"时间", "time",
|
|
||||||
"抛弃", "discard",
|
|
||||||
"限制", "limit",
|
|
||||||
"货物", "cargo",
|
|
||||||
"无载", "unloaded",
|
|
||||||
"空载", "empty"
|
|
||||||
}
|
|
||||||
local lowerDest = string.lower(destName)
|
|
||||||
for _, word in ipairs(blacklist) do
|
|
||||||
if string.find(lowerDest, word, 1, true) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
cleanupTimestampMap(State.announcedApproaching, now, tonumber(CONFIG.APPROACHING_COOLDOWN_MS) or 120000)
|
cleanupTimestampMap(State.announcedApproaching, now, tonumber(CONFIG.APPROACHING_COOLDOWN_MS) or 120000)
|
||||||
cleanupTimestampMap(State.announcedAlerts, now, tonumber(CONFIG.ALERT_COOLDOWN_MS) or 300000)
|
cleanupTimestampMap(State.announcedAlerts, now, tonumber(CONFIG.ALERT_COOLDOWN_MS) or 300000)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user