mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-28 08:02:22 +01:00
A timetable can now tell the AI how the train is served, for trams, underground trains and the like. The whole train gets them from a new row of the first box of the header: [ Flagi AI | drzwi_centralne=tak,stopien=nie,kierownik=nie,proba_hamulca=nie ] and a station changes them from there on with entries of its station ware (the second line of the station, next to R2, ph, @): [ | | po,kierownik=nie 1 12.54 | ] - drzwi_centralne=tak: the driver opens all the doors from the cab, those of mixed control too (otherwise left to the passengers) - stopien=tak/nie: the doorsteps switched on/off before the doors open (the AI didn't touch them before; new driver hints for it) - kierownik=nie: no conductor, so no departure signal (direct or by radio) and no first door kept open for him before the departure - proba_hamulca=nie: no running brake test A flag left out keeps today's behaviour, so a timetable without flags drives as before. Old builds skip the header row and keep the station entries as station ware text (none starts with R or holds @, po, pt). The reader moves out of TTrainParameters::LoadTTfile into world/timetablereader.cpp (eu07_core) unchanged, so the tests can run it; the flags come out of the station ware there. It now ends at the end of the file with an error where the old one spun forever (a truncated file, a missing number), and stops at 100 stations instead of writing past the table. Every .txt of the game's sceneries and of the SVN data reads the same as with the old reader (compared field by field against a verbatim copy of it); EU07_UNIT_TESTS_TIMETABLES=<scenery folder> reads them in the unit tests and EU07_UNIT_TESTS_TIMETABLES_DUMP writes what was read.
67 lines
2.4 KiB
C++
67 lines
2.4 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
|
|
std::string StationName{"nowhere"}; // nazwa stacji ('_' zamiast spacji)
|
|
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;
|
|
std::string Relation1;
|
|
std::string Relation2;
|
|
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
|