18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-28 16:12:05 +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

View File

@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/Logs.h"
#include "utilities/utilities.h"
#include "world/stationnames.h"
namespace Mtable {
@@ -125,8 +126,9 @@ int read_timetable(std::istream &fin, timetable_data &Data) {
break;
}
if (s != "|") {
Data.Relation1 = s;
win1250_to_ascii(Data.Relation1);
// the name is kept as written, for showing; the ascii form is what the rest of the simulator goes by
Data.RelationLabel1 = s;
Data.Relation1 = timetable::station_ascii(s);
}
else
conversionerror = -5;
@@ -138,8 +140,9 @@ int read_timetable(std::istream &fin, timetable_data &Data) {
if (s == "|")
break;
}
fin >> Data.Relation2;
win1250_to_ascii(Data.Relation2);
if (fin >> Data.RelationLabel2) {
Data.Relation2 = timetable::station_ascii(Data.RelationLabel2);
}
while (fin >> s) {
if (s == "Wymagany")
break;
@@ -195,9 +198,11 @@ int read_timetable(std::istream &fin, timetable_data &Data) {
}
while (false == contains(s, "|") && false == fin.fail())
fin >> s;
fin >> record->StationName;
// get rid of non-ascii chars. TODO: run correct version based on locale
win1250_to_ascii(record->StationName);
// the name is kept as written, for showing; the W4 stop points, the announcement files, the scenery
// events and the scripts go by its ascii form, as they always did
if (fin >> record->StationLabel) {
record->StationName = timetable::station_ascii(record->StationLabel);
}
do {
fin >> s;
} while (!(s == "1" || s == "2" || fin.fail()));