18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 01:55:21 +01:00

feat(timetable): station names keep their polish letters, a W4 finds its station by one key

MaSzyna-EU07/maszyna#94. The timetable reader and the W4 event (putvalues PassengerStopPoint:<station>) threw
the polish letters of a name away as they read it. Now:

- the reader keeps the name as the file spells it in TMTableEntry::StationLabel and
  timetable_data::RelationLabel1/2 (TTrainParameters::RelationLabel1/2), for showing; StationName and
  Relation1/2 hold the ascii form as before, byte for byte, so the announcement files, the destination
  boards, the memory cells written by WhoIs events, the python dictionary, the log and the black box get
  what they always got
- the W4 event keeps its text as the scenery spells it (a scenery saved by the editor no longer loses the
  letters of its W4 events); the black box map still gets the ascii form
- world/stationnames.h has the one place which tells whether a W4 is for a station:
  timetable::stop_point_is_for(), used by TController::TableUpdateStopPoint() and
  TTrainParameters::RewindTimeTable(). It compares keys (ascii form, lower case, spaces as underscores), so
  the timetable and the W4 may each spell the station with or without the letters
- TTrainParameters::relation_caption() / station_caption() and TController::NextStop() give the names for
  the player: with the letters, in utf-8

The folding stays in the matching because the game data needs it: in 36 scenario x station pairs of the
Steam install (6 of the SVN) the timetable and the W4 spell the station differently (BALTYK_GLOWNY in
capitals against Baltyk_Glowny, Rzepedz with one of its two marks, Lupkow without them), and no
announcement file has a letter outside of ascii in its name.

Every W4 which matched a station still does. New matches, none of them in the game data: a memory cell
text spelled with polish letters, a space where the timetable has an underscore, a name longer than the 32
characters (sizeof(std::string)) the old comparison took. A memory cell text with a # part is still
compared whole.

win1250_to_ascii() builds its map once: the comparison runs it for every stop point a driver scans.
This commit is contained in:
jerrrrycho
2026-11-18 23:50:07 +01:00
parent c0a0a4204e
commit 022e59fde3
13 changed files with 459 additions and 23 deletions
+8 -5
View File
@@ -122,16 +122,19 @@ void minimap_tool::gather_stations()
if (false == stale(m_stations_seen))
return;
std::map<std::string, station> found;
// the texts are in windows-1250; the ones of the events lost their polish letters as they were read
auto const add = [&](std::string const &Text, bool const Letters, glm::dvec3 const &Point, TTrack *Track) {
// the texts are in windows-1250; the stop points of a station can spell it with or without its polish letters
std::unordered_set<std::string> lettered;
auto const add = [&](std::string const &Text, glm::dvec3 const &Point, TTrack *Track) {
auto const name{stop_name(Text)};
if (name.empty())
return;
auto const key{folded(name)};
auto &entry{found[key]};
entry.key = key;
// the station is shown by a spelling with the letters, when any of its stop points has one
auto const letters{std::ranges::any_of(name, [](char const Character) { return static_cast<unsigned char>(Character) >= 0x80; })};
// the timetables join the words with underscores
if (entry.name.empty() || Letters)
if (entry.name.empty() || (letters && lettered.insert(key).second))
{
entry.name = win1250_to_utf8(name);
std::replace(entry.name.begin(), entry.name.end(), '_', ' ');
@@ -145,10 +148,10 @@ void minimap_tool::gather_stations()
};
for (auto *cell : simulation::Memory.sequence())
if (cell != nullptr && cell->Text().starts_with(stop_prefix))
add(cell->Text(), true, cell->location(), cell->Track);
add(cell->Text(), cell->location(), cell->Track);
for (auto *event : simulation::Events.sequence())
if (auto const *values{dynamic_cast<putvalues_event const *>(event)}; values != nullptr && values->input_command() == TCommandType::cm_PassengerStopPoint)
add(values->input_text(), false, values->input_location(), nullptr);
add(values->input_text(), values->input_location(), nullptr);
std::vector<station> stations;
for (auto &entry : found)
stations.push_back(std::move(entry.second));