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.
74 lines
2.9 KiB
C++
74 lines
2.9 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 <array>
|
|
#include <istream>
|
|
#include <string>
|
|
|
|
#include "world/timetableflags.h"
|
|
|
|
// the reader of the timetable files (<train>.txt next to the scenery), without the parts of the engine the timetable
|
|
// of a running train needs (sounds, scenario time), so it can be tested on its own
|
|
namespace Mtable {
|
|
|
|
static int const MaxTTableSize = 100; // można by to robić dynamicznie
|
|
|
|
// one station of a timetable, as the file gives it
|
|
struct TMTableEntry {
|
|
float km{0.f}; // kilometraz linii
|
|
float vmax{-1.f}; // predkosc rozkladowa przed przystankiem
|
|
// nazwa stacji ('_' zamiast spacji), bez ogonków: the form the station is matched, looked up and handed over by
|
|
// (the W4 stop points, the announcement files, the scenery events, the scripts)
|
|
std::string StationName{"nowhere"};
|
|
// the name as the timetable spells it, in windows-1250 with its letters: for showing (timetable::station_caption())
|
|
std::string StationLabel{"nowhere"};
|
|
std::string StationWare; // typ i wyposazenie stacji, oddz. przecinkami, bez flag obsługi
|
|
int TrackNo{1}; // ilosc torow szlakowych
|
|
int Ah{-1};
|
|
float Am{-1.f}; // godz. i min. przyjazdu, -1 gdy bez postoju
|
|
int Dh{-1};
|
|
float Dm{-1.f}; // godz. i min. odjazdu
|
|
float tm{0.f}; // czas jazdy do tej stacji w min. (z kolumny)
|
|
bool is_maintenance{false};
|
|
int radio_channel{-1};
|
|
// the service flags which hold from this station on: the header's, changed by this and the earlier stations.
|
|
// entry 0 holds the header's
|
|
timetable::service_flags flags;
|
|
};
|
|
|
|
// what a timetable file holds
|
|
struct timetable_data {
|
|
std::string TrainName; // the name the file is looked up by, then the one the file gives
|
|
std::string TrainCategory;
|
|
std::string TrainLabel;
|
|
// the first and the last station, in the two forms a station name has (see TMTableEntry)
|
|
std::string Relation1;
|
|
std::string Relation2;
|
|
std::string RelationLabel1;
|
|
std::string RelationLabel2;
|
|
double BrakeRatio{0.0};
|
|
std::string LocSeries;
|
|
double LocLoad{0.0};
|
|
timetable::service_flags Flags; // of the whole train, the row "Flagi" of the header
|
|
int StationCount{0}; // stations 1..StationCount, entry 0 is the technical one
|
|
std::array<TMTableEntry, MaxTTableSize + 1> TimeTable;
|
|
};
|
|
|
|
// conversion errors of read_timetable, besides the ones it always had (-4: no station row where expected, -5: no
|
|
// first station of the relation)
|
|
int const timetable_truncated{-9}; // the file ends before the bottom line of the table (the reader used to hang)
|
|
int const timetable_too_long{-10}; // more stations than MaxTTableSize (the reader used to write past the table)
|
|
|
|
// reads the timetable from Input into Data. returns the conversion error, 0 when read
|
|
int read_timetable(std::istream &Input, timetable_data &Data);
|
|
|
|
} // namespace Mtable
|