mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-27 21:45:16 +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.
60 lines
2.6 KiB
C++
60 lines
2.6 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 <cstdint>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
// the way a train is served, set by its timetable for the AI driver (eu07/maszyna#95): trams and underground trains
|
|
// open all the doors from the cab, have no doorstep, no conductor, no running brake test. each flag the timetable
|
|
// leaves out keeps the behaviour of the vehicles, as before the flags.
|
|
//
|
|
// the whole train: a row of the first box of the header
|
|
// [ Flagi AI | kierownik=nie,proba_hamulca=nie ]
|
|
// from a station on: entries of its station ware (the second line of the station, with R2, ph, @...)
|
|
// [ | | R2,ph,drzwi_centralne=tak,stopien=nie 1 12.47 | ]
|
|
// a station's entry holds from that station on, until another station changes it
|
|
namespace timetable {
|
|
|
|
enum class tristate : std::uint8_t {
|
|
unset, // left to the vehicles, as before the flags
|
|
yes,
|
|
no
|
|
};
|
|
|
|
struct service_flags {
|
|
tristate central_doors{tristate::unset}; // drzwi_centralne: the driver opens all the doors, of mixed control too
|
|
tristate doorstep{tristate::unset}; // stopien: the doorsteps on (tak) or off (nie) before the doors open
|
|
tristate conductor{tristate::unset}; // kierownik: no conductor (nie), no departure signal, no door kept open for him
|
|
tristate brake_test{tristate::unset}; // proba_hamulca: no running brake test (nie)
|
|
|
|
bool operator==(service_flags const &) const = default;
|
|
bool empty() const { return *this == service_flags{}; }
|
|
// the flags Other sets explicitly override these
|
|
void apply(service_flags const &Other);
|
|
};
|
|
|
|
// reads one entry, key=value (tak/nie, 1/0), into Flags. returns false for an entry which isn't a flag, so the caller
|
|
// keeps it; a flag with a value it doesn't know is reported to the log and taken as handled
|
|
bool read_flag(std::string_view Entry, service_flags &Flags);
|
|
|
|
// reads the flags out of a station ware list (comma separated entries) into Flags. returns the list without them: the
|
|
// list as it was when it had none
|
|
std::string extract_flags(std::string const &Ware, service_flags &Flags);
|
|
|
|
// the timetable entry whose flags hold at the stop the train makes for or stands at: the current one (StationIndex),
|
|
// within 0 (the header's flags) and the last station
|
|
int stop_flags_entry(int StationIndex, int StationCount);
|
|
// the entry whose flags hold on the way: the station the train left last, 0 (the header's flags) before the first one
|
|
int run_flags_entry(int StationIndex, int StationCount);
|
|
|
|
} // namespace timetable
|