mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-27 21:45:16 +01:00
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.
41 lines
2.0 KiB
C++
41 lines
2.0 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
// the names of the stations (MaSzyna-EU07/maszyna#94): a timetable and the W4 stop points of a scenery name a station
|
|
// each in its own file, in windows-1250, and they don't have to spell it the same way (with or without the polish
|
|
// letters, in another case). a name has three forms here:
|
|
// - as written, with its letters: what the files hold and what the player is shown (station_caption())
|
|
// - the ascii one, the polish letters without their marks: what the timetable always kept as the name of a station,
|
|
// what the scenery events, the scripts and the file names of the announcements and destination boards go by
|
|
// (station_ascii())
|
|
// - the key two spellings are the same station by (station_key(), same_station())
|
|
namespace timetable {
|
|
|
|
// what a W4 text starts with: "PassengerStopPoint:<station>". in the scenery a "#<part which makes the name of the
|
|
// event unique>" follows; the event cuts it as it's read, a memory cell keeps the whole of its text
|
|
inline constexpr std::string_view stop_point_prefix{"PassengerStopPoint:"};
|
|
|
|
// the name without the marks of the polish letters of windows-1250, the rest as written
|
|
std::string station_ascii(std::string Name);
|
|
// the key of a name: the ascii form in lower case, spaces as underscores
|
|
std::string station_key(std::string_view Name);
|
|
// whether the two names are spellings of the same station
|
|
bool same_station(std::string_view Left, std::string_view Right);
|
|
// whether the W4 text, as an event or a memory cell holds it, is for the station of given name, in any spelling of the two
|
|
bool stop_point_is_for(std::string_view Text, std::string_view Station);
|
|
// the name for the player: utf-8, with its letters, underscores as spaces
|
|
std::string station_caption(std::string const &Name);
|
|
|
|
} // namespace timetable
|