mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 190402. basic implementation for script generated vehicle destination sign textures
This commit is contained in:
55
dictionary.cpp
Normal file
55
dictionary.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
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/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dictionary.h"
|
||||
|
||||
#include "simulation.h"
|
||||
#include "utilities.h"
|
||||
#include "DynObj.h"
|
||||
#include "Driver.h"
|
||||
#include "mtable.h"
|
||||
|
||||
dictionary_source::dictionary_source( std::string const &Input ) {
|
||||
|
||||
auto const keyvaluepairs { Split( Input, '&' ) };
|
||||
|
||||
for( auto const &keyvaluepair : keyvaluepairs ) {
|
||||
|
||||
auto const valuepos { keyvaluepair.find( '=' ) };
|
||||
if( keyvaluepair[ 0 ] != '$' ) {
|
||||
// regular key, value pairs
|
||||
insert(
|
||||
ToLower( keyvaluepair.substr( 0, valuepos ) ),
|
||||
keyvaluepair.substr( valuepos + 1 ) );
|
||||
}
|
||||
else {
|
||||
// special case, $key indicates request to include certain dataset clarified by value
|
||||
auto const key { ToLower( keyvaluepair.substr( 0, valuepos ) ) };
|
||||
auto const value { keyvaluepair.substr( valuepos + 1 ) };
|
||||
|
||||
if( key == "$timetable" ) {
|
||||
// timetable pulled from (preferably) the owner/direct controller of specified vehicle
|
||||
auto const *vehicle { simulation::Vehicles.find( value ) };
|
||||
auto const *controller { (
|
||||
vehicle == nullptr ? nullptr :
|
||||
vehicle->ctOwner == nullptr ? vehicle->Mechanik :
|
||||
vehicle->ctOwner ) };
|
||||
auto const *timetable { (
|
||||
controller != nullptr ?
|
||||
controller->TrainTimetable() :
|
||||
nullptr ) };
|
||||
|
||||
if( timetable != nullptr ) {
|
||||
timetable->serialize( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user