From f8460040911f11717a052469144cc5c2d8f9aba6 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Mon, 3 Aug 2026 12:04:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(client):=20=E8=BF=87=E6=BB=A4=E9=9D=9E?= =?UTF-8?q?=E8=BD=A6=E7=AB=99=E6=8C=87=E4=BB=A4=E5=B9=B6=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=88=97=E8=BD=A6=E5=81=9C=E7=AB=99=E5=90=8E=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=92=AD=E6=8A=A5=E8=BF=9B=E7=AB=99=E9=A2=84=E5=91=8A=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增 `isStationDestination` 过滤器,在通过显示屏(Create Target)读取时刻表时, 自动忽略包含“速度”、“重命名”、“时刻表”、“等待”、“卸载”等关键字的非车站指令, 防止将这些指令当作车站并错误触发进站预告。 2. 修复显示屏读取到的负数 ETA 被错误解析为正数的问题(增加可选负号匹配)。 3. 将触发进站预告的条件从 `etaSeconds >= 0` 修改为 `etaSeconds > 0`。 这样当列车完全停站(ETA=0或负数)时,将不再触发进站预告,彻底解决停站时间 超过冷却期后导致的重复播报“进站预告”的问题。 --- station_broadcast.lua | 53 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/station_broadcast.lua b/station_broadcast.lua index 18c8471..4938070 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.52" +local APP_VERSION_TEXT = "v1.0.53" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -2713,7 +2713,7 @@ function Main.loop() end end - if etaSeconds >= 0 and etaSeconds <= 45 then + if etaSeconds > 0 and etaSeconds <= 45 then if not seenApproachKeys[announceKey] then seenApproachKeys[announceKey] = true local pending = State.pendingApproaching[announceKey] @@ -2768,6 +2768,37 @@ function Main.loop() local seenAlertKeys = {} 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.announcedAlerts, now, tonumber(CONFIG.ALERT_COOLDOWN_MS) or 300000) @@ -2787,22 +2818,24 @@ function Main.loop() platform, etaStr, tName, dest = string.match(cleanLine, "^([^%s]+)%s+(.-)%s+([^%s]+)%s+(.*)$") end - if tName and etaStr then + if tName and etaStr and isStationDestination(dest) then local announceKey = normalizeUpcomingKey(tName, dest) local etaSeconds = -1 local isNow = string.find(etaStr, "现在") - + if isNow then etaSeconds = 0 else - local mm, ss = string.match(etaStr, "^(%d+)%s*:%s*(%d+)%s*$") + local sign_mm, mm, ss = string.match(etaStr, "^%s*(%-?)%s*(%d+)%s*:%s*(%d+)%s*$") if mm and ss then etaSeconds = tonumber(mm) * 60 + tonumber(ss) + if sign_mm == "-" then etaSeconds = -etaSeconds end else - local num, unit = string.match(etaStr, "(%d+)%s*(.*)") + local sign, num, unit = string.match(etaStr, "^%s*(%-?)%s*(%d+)%s*(.*)") if num then num = tonumber(num) + if sign == "-" then num = -num end if string.find(unit, "秒") or string.find(unit, "s") or string.find(unit, "sec") or (unit == "??" and num > 10) then etaSeconds = num @@ -2812,15 +2845,15 @@ function Main.loop() end end end - + table.insert(newUpcoming, { trainName = tName, dest = dest, platform = platform or State.stationPlatform or "1", eta = etaSeconds >= 0 and etaSeconds or 0, etaLabel = buildEtaLabel(etaSeconds >= 0 and etaSeconds or 0, { - value = string.match(etaStr, "(%d+)"), - unit = string.match(etaStr, "%d+%s*(.*)") + value = string.match(etaStr, "(%-?%d+)"), + unit = string.match(etaStr, "%-?%d+%s*(.*)") }), delay = delay, cancelled = false, @@ -2847,7 +2880,7 @@ function Main.loop() end end - if etaSeconds >= 0 and etaSeconds <= 45 then + if etaSeconds > 0 and etaSeconds <= 45 then if not seenApproachKeys[announceKey] then seenApproachKeys[announceKey] = true local pending = State.pendingApproaching[announceKey]