fix(announce): 修复进站预告音频终点站名字被跳过的问题

根因链:
- station_broadcast.lua 通过 BlockReader / CreateTarget 两个分支触发 train_approaching 发送时,只带 destination (中文名/站名),未带 destCode;server 端只能走 getStationCodeFromName(destination) 正则解析,正则没匹配到就会得到 UNK → ch-UNK.wav / ja-UNK.wav 不存在 → 整条目的地段音频被 ffmpeg concat 跳过
- 对比 train_arrival (Peripherals.station 分支) 是有 destCode 字段的(由 Utils.getStationCode + schedule 解析得到),所以到站广播终点站名能正常播出,预告(走 Display/BlockReader 分支)不能
修复:
1. station_broadcast.lua 四处 train_approaching / train_alert Network.send 全部补 destCode = Utils.getStationCode(destination):
   - L4053 (alert, blockreader) / L4091 (approach, blockreader)
   - L4221 (alert, createTarget) / L4257 (approach, createTarget)
2. server.js 新增 resolveStationAudioCode(rawCode, rawName) 三级兜底解析:
   - L1: 直接用 raw destCode(优先级最高,客户端算好的)
   - L2: 正则解析 destination 名字抽取 code(parens/dash/下划线模式)
   - L3: 把 destination 名拿去 findStationByFlexibleName 已注册站台表里 fuzzy 匹配,取其 code
   - 解析不到就打 WARN 日志,提示会跳过这一段
3. handleTrainApproaching / handleTrainArrival / handleTrainDeparture 三个 handler 的 destCode / nextCode 全部切到 resolveStationAudioCode 统一入口,不再各写一遍正则,所有预告/到站/发车音频用同一条解析链,保证结果一致
APP_VERSION_TEXT bump 到 v1.0.110
This commit is contained in:
2026-08-17 18:05:21 +08:00
parent fb17de6493
commit a58632272e
2 changed files with 57 additions and 18 deletions
+17 -13
View File
@@ -1,6 +1,6 @@
-- 1. Configuration & Constants
local APP_VERSION_TEXT = "v1.0.109"
local APP_VERSION_TEXT = "v1.0.110"
local CONFIG = {
CLOUD_URL = "ws://stabadmin.fse-media.group",
@@ -4044,18 +4044,19 @@ function Main.loop()
Utils.log("INFO", string.format("Train Alert: %s (ETA: %ds, Delay: %dm, Cancelled: %s, Reason: %s)", trainName, etaSeconds, displayDelayMinutes, tostring(cancelled), tostring(reason or "")))
if Utils.isLocalStationMaster() then
Network.send({
type = "train_alert",
stationName = State.stationName,
stationCode = State.stationCode,
stationPlatform = platform,
trainId = trainName,
destination = destination,
eta = tostring(etaSeconds) .. "s",
etaSeconds = etaSeconds,
delay = displayDelayMinutes,
cancelled = cancelled,
reason = reason
})
type = "train_alert",
stationName = State.stationName,
stationCode = State.stationCode,
stationPlatform = platform,
trainId = trainName,
destination = destination,
destCode = Utils.getStationCode(destination),
eta = tostring(etaSeconds) .. "s",
etaSeconds = etaSeconds,
delay = displayDelayMinutes,
cancelled = cancelled,
reason = reason
})
end
end
end
@@ -4087,6 +4088,7 @@ function Main.loop()
stationPlatform = platform,
trainId = trainName,
destination = destination,
destCode = Utils.getStationCode(destination),
eta = string.format("%.1fs", etaSeconds),
etaSeconds = etaSeconds,
delay = displayDelayMinutes,
@@ -4216,6 +4218,7 @@ function Main.loop()
stationPlatform = platform or State.stationPlatform or "1",
trainId = tName,
destination = dest,
destCode = Utils.getStationCode(dest),
eta = etaStr,
etaSeconds = etaSeconds,
delay = delay
@@ -4251,6 +4254,7 @@ function Main.loop()
stationPlatform = platform or State.stationPlatform or "1",
trainId = tName,
destination = dest,
destCode = Utils.getStationCode(dest),
eta = etaStr,
etaSeconds = etaSeconds,
delay = delay