Commit 977bdfc7 authored by Volker Krause's avatar Volker Krause
Browse files

Try harder to determine RCT2 ticket type

If we can't detect the ticket title in the location as required by the
specification, check fields intersecting that area. CD tickets for example
are sufficiently misplaced to not be detected otherwise.
parent 32c619a5
......@@ -4,6 +4,6 @@
"@type": "Rct2Ticket",
"passengerName": "Künqi Dr Dragn",
"title": "VVT: Einzel-Ticket",
"type": "http://schema.org/Unknown"
"type": "http://schema.org/Transport"
}
]
......@@ -137,6 +137,7 @@ static constexpr const struct {
{ "fahrkarte", Rct2Ticket::Transport },
{ "fahrschein", Rct2Ticket::Transport },
{ "cestovny listok", Rct2Ticket::Transport },
{ "jizdenka", Rct2Ticket::Transport },
{ "reservation", Rct2Ticket::Reservation },
{ "reservierung", Rct2Ticket::Reservation },
{ "interrail", Rct2Ticket::RailPass },
......@@ -162,6 +163,15 @@ Rct2Ticket::Type Rct2Ticket::type() const
}
}
// alternatively, check all fields covering the title area, for even more creative placements...
for (const auto &f : d->layout.fields(0, 14, 38, 2)) {
for (auto it = std::begin(rct2_ticket_type_map); it != std::end(rct2_ticket_type_map); ++it) {
if (f.text().toCaseFolded().contains(QLatin1String(it->name))) {
return it->type;
}
}
}
return Unknown;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment