diff --git a/station_broadcast.lua b/station_broadcast.lua index 84bde65..e329200 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -3080,19 +3080,25 @@ local function tryCorrectUpcomingEntryWithCurrentTrain(entry) if not sameTrain and not samePlatform then return entry end local validId = looksLikeValidDestinationText(entry.trainName) local validDest = looksLikeValidDestinationText(entry.dest) + if not validId and ctId and ctId ~= "" then entry.trainName = ctId end - if not validDest and ctDest and ctDest ~= "" then - entry.dest = ctDest - elseif sameTrain and ctDest and ctDest ~= "" then - if not Utils.isFuzzyMatch(entry.dest or "", ctDest) then - local entryDestValid = looksLikeValidDestinationText(entry.dest) - if not entryDestValid then - entry.dest = ctDest - end + if sameTrain and ctId and ctId ~= "" and tostring(entry.trainName or "") ~= tostring(ctId) then + if Utils.isFuzzyMatch(entry.trainName or "", ctId) or not validId then + entry.trainName = ctId end end + + if not validDest and ctDest and ctDest ~= "" then + entry.dest = ctDest + end + if (sameTrain or samePlatform) and ctDest and ctDest ~= "" and tostring(entry.dest or "") ~= tostring(ctDest) then + if Utils.isFuzzyMatch(entry.dest or "", ctDest) or not validDest then + entry.dest = ctDest + end + end + return entry end @@ -3223,10 +3229,10 @@ function Main.loop() platform = platform }) if preCorrected then - if not looksLikeValidDestinationText(trainName) and preCorrected.trainName then + if preCorrected.trainName and tostring(preCorrected.trainName) ~= tostring(trainName) then trainName = preCorrected.trainName end - if not looksLikeValidDestinationText(destination) and preCorrected.dest then + if preCorrected.dest and tostring(preCorrected.dest) ~= tostring(destination) then destination = preCorrected.dest end end @@ -3384,10 +3390,10 @@ function Main.loop() platform = entryPlatform }) if preCorrectedCT then - if tName and not looksLikeValidDestinationText(tName) and preCorrectedCT.trainName then + if preCorrectedCT.trainName and tostring(preCorrectedCT.trainName) ~= tostring(tName or "") then tName = preCorrectedCT.trainName end - if dest and not looksLikeValidDestinationText(dest) and preCorrectedCT.dest then + if preCorrectedCT.dest and tostring(preCorrectedCT.dest) ~= tostring(dest or "") then dest = preCorrectedCT.dest end end