mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
radio channel selection tweak, minor bug fixes
This commit is contained in:
@@ -4601,10 +4601,12 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
|
||||
// wybór kanału radiowego (którego powinien używać AI, ręczny maszynista musi go ustawić sam)
|
||||
if (NewValue1 >= 0) {
|
||||
// wartości ujemne są zarezerwowane, -1 = nie zmieniać kanału
|
||||
iRadioChannel = NewValue1;
|
||||
if( AIControllFlag ) {
|
||||
iRadioChannel = NewValue1;
|
||||
}
|
||||
if( iGuardRadio ) {
|
||||
// kierownikowi też zmienić
|
||||
iGuardRadio = iRadioChannel;
|
||||
iGuardRadio = NewValue1;
|
||||
}
|
||||
}
|
||||
// NewValue2 może zawierać dodatkowo oczekiwany kod odpowiedzi, np. dla W29 "nawiązać
|
||||
|
||||
14
Event.cpp
14
Event.cpp
@@ -730,7 +730,8 @@ putvalues_event::run_() {
|
||||
m_input.data_value_2,
|
||||
loc );
|
||||
}
|
||||
else if( m_activator->ctOwner ) {
|
||||
else if( ( m_activator->ctOwner )
|
||||
&& ( is_command_for_owner( m_input ) ) ) {
|
||||
// send the command to consist owner,
|
||||
// we're acting on presumption there's hardly ever need to issue command to unmanned vehicle
|
||||
// and the intended recipient moved between vehicles after the event was queued
|
||||
@@ -765,6 +766,17 @@ putvalues_event::export_as_text_( std::ostream &Output ) const {
|
||||
<< m_input.data_value_2 << ' ';
|
||||
}
|
||||
|
||||
//determines whether provided input should be passed to consist owner
|
||||
bool
|
||||
putvalues_event::is_command_for_owner( input_data const &Input ) const {
|
||||
|
||||
if( Input.data_text.rfind( "Load=", 0 ) == std::string::npos ) { return false; }
|
||||
if( Input.data_text.rfind( "UnLoad=", 0 ) == std::string::npos ) { return false; }
|
||||
// TBD, TODO: add other exceptions
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// input data access
|
||||
std::string
|
||||
putvalues_event::input_text() const {
|
||||
|
||||
2
Event.h
2
Event.h
@@ -271,6 +271,8 @@ private:
|
||||
void run_() override;
|
||||
// export_as_text() subclass details
|
||||
void export_as_text_( std::ostream &Output ) const override;
|
||||
//determines whether provided input should be passed to consist owner
|
||||
bool is_command_for_owner( input_data const &Input ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ openal_buffer::openal_buffer( std::string const &Filename ) :
|
||||
}
|
||||
}
|
||||
else {
|
||||
ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file );
|
||||
ErrorLog( "Bad file: failed to load audio file \"" + Filename + "\"", logtype::file );
|
||||
}
|
||||
// we're done with the disk data
|
||||
drwav_close( file );
|
||||
@@ -70,7 +70,7 @@ openal_buffer::openal_buffer( std::string const &Filename ) :
|
||||
}
|
||||
}
|
||||
else {
|
||||
ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file );
|
||||
ErrorLog( "Bad file: failed to load audio file \"" + Filename + "\"", logtype::file );
|
||||
}
|
||||
// we're done with the disk data
|
||||
drflac_close( file );
|
||||
@@ -92,7 +92,7 @@ openal_buffer::openal_buffer( std::string const &Filename ) :
|
||||
}
|
||||
}
|
||||
else {
|
||||
ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file );
|
||||
ErrorLog( "Bad file: failed to load audio file \"" + Filename + "\"", logtype::file );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ buffer_manager::create( std::string const &Filename ) {
|
||||
return emplace( filelookup );
|
||||
}
|
||||
// if we still didn't find anything, give up
|
||||
ErrorLog( "Bad file: failed do locate audio file \"" + Filename + "\"", logtype::file );
|
||||
ErrorLog( "Bad file: failed to locate audio file \"" + Filename + "\"", logtype::file );
|
||||
return null_handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ timetable_panel::update() {
|
||||
tableline->Dh >= 0 ?
|
||||
to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Dm, true, 3 ) :
|
||||
u8" │ " ) };
|
||||
auto const candeparture { (
|
||||
auto const candepart { (
|
||||
( owner->iStationStart < table.StationIndex )
|
||||
&& ( i < table.StationIndex )
|
||||
&& ( ( tableline->Ah < 0 ) // pass-through, always valid
|
||||
@@ -398,7 +398,7 @@ timetable_panel::update() {
|
||||
auto const linecolor { (
|
||||
( i != owner->iStationStart ) ? Global.UITextColor :
|
||||
loadchangeinprogress ? loadingcolor :
|
||||
candeparture ? readycolor : // czas minął i odjazd był, to nazwa stacji będzie na zielono
|
||||
candepart ? readycolor : // czas minął i odjazd był, to nazwa stacji będzie na zielono
|
||||
isatpassengerstop ? waitcolor :
|
||||
Global.UITextColor ) };
|
||||
auto const trackcount{ ( tableline->TrackNo == 1 ? u8" ┃ " : u8" ║ " ) };
|
||||
|
||||
@@ -184,7 +184,7 @@ gamepad_input::recall_bindings() {
|
||||
|
||||
std::string bindingpoint {};
|
||||
entryparser >> bindingpoint;
|
||||
auto const splitbindingpoint { split_index( bindingpoint ) };
|
||||
auto const splitbindingpoint { split_string_and_number( bindingpoint ) };
|
||||
|
||||
if( splitbindingpoint.first == "axis" ) {
|
||||
// one or more sets of: [modeIDX] input type, parameters
|
||||
@@ -204,7 +204,7 @@ gamepad_input::recall_bindings() {
|
||||
std::string key {};
|
||||
entryparser >> key;
|
||||
// check for potential mode indicator
|
||||
auto const splitkey { split_index( key ) };
|
||||
auto const splitkey { split_string_and_number( key ) };
|
||||
if( splitkey.first == "mode" ) {
|
||||
// indicate we'll be processing specified mode
|
||||
controlmode = splitkey.second;
|
||||
|
||||
@@ -152,7 +152,7 @@ basic_controller::deserialize_operation( cParser &Input ) -> bool {
|
||||
}
|
||||
|
||||
if( false == operationparameter.empty() ) {
|
||||
auto const parameter{ split_index( operationparameter ) };
|
||||
auto const parameter{ split_string_and_number( operationparameter ) };
|
||||
operation.parameter1 = static_cast<short>( parameter.second );
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ basic_controller::log_error( std::string const &Error, int const Line ) const {
|
||||
auto
|
||||
basic_controller::guess_element_type_from_name( std::string const &Name ) const -> basic_element::type_e {
|
||||
|
||||
auto const name { split_index( Name ) };
|
||||
auto const name { split_string_and_number( Name ) };
|
||||
|
||||
if( ( name.first == "t" ) || ( name.first == "ton" ) || ( name.first.find( "timer." ) == 0 ) ) {
|
||||
return basic_element::type_e::timer;
|
||||
|
||||
15
mtable.cpp
15
mtable.cpp
@@ -329,6 +329,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
||||
{
|
||||
fin >> s;
|
||||
} while (!(s.find("[______________") != std::string::npos || fin.bad()));
|
||||
auto activeradiochannel{ -1 };
|
||||
while (!fin.bad() && !EndTable)
|
||||
{
|
||||
++StationCount;
|
||||
@@ -421,13 +422,23 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
||||
auto const stationware { Split( record->StationWare, ',' ) };
|
||||
for( auto const &entry : stationware ) {
|
||||
if( entry[ 0 ] == 'R' ) {
|
||||
auto const entrysplit { split_index( entry ) };
|
||||
auto const entrysplit { split_string_and_number( entry ) };
|
||||
if( ( entrysplit.first == "R" )
|
||||
&& ( entrysplit.second <= 10 ) ) {
|
||||
record->radio_channel = entrysplit.second;
|
||||
auto const radiochannel { entrysplit.second };
|
||||
if( ( record->radio_channel == -1 )
|
||||
|| ( radiochannel != activeradiochannel ) ) {
|
||||
// if the station has more than one radiochannel listed,
|
||||
// it generally means we should switch to the one we weren't using so far
|
||||
// TODO: reverse this behaviour (keep the channel used so far) once W28 signs are included in the system
|
||||
record->radio_channel = radiochannel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( record->radio_channel != -1 ) {
|
||||
activeradiochannel == record->radio_channel;
|
||||
}
|
||||
}
|
||||
record->TrackNo = atoi(s.c_str());
|
||||
fin >> s;
|
||||
|
||||
2
sound.h
2
sound.h
@@ -17,7 +17,7 @@ float const EU07_SOUND_GLOBALRANGE { -1.f };
|
||||
float const EU07_SOUND_CABCONTROLSCUTOFFRANGE { 7.5f };
|
||||
float const EU07_SOUND_BRAKINGCUTOFFRANGE { 100.f };
|
||||
float const EU07_SOUND_RUNNINGNOISECUTOFFRANGE { 200.f };
|
||||
float const EU07_SOUND_HANDHELDRADIORANGE { 750.f };
|
||||
float const EU07_SOUND_HANDHELDRADIORANGE { 3500.f };
|
||||
|
||||
enum class sound_type {
|
||||
single,
|
||||
|
||||
@@ -71,7 +71,7 @@ init() {
|
||||
", owned by: ",
|
||||
"none",
|
||||
"Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s[%.0f]%s%.0f@%.0f :: %.0f@%.0f%s[%.0f]%s%.0f@%.0f",
|
||||
" radio: ",
|
||||
" R",
|
||||
" oil pressure: ",
|
||||
"Controllers:\n master: %d(%d), secondary: %s\nEngine output: %.1f, current: %.0f\nRevolutions:\n engine: %.0f, motors: %.0f\n engine fans: %.0f, motor fans: %.0f+%.0f, cooling fans: %.0f+%.0f",
|
||||
" (shunt mode)",
|
||||
@@ -276,7 +276,7 @@ init() {
|
||||
", wlasciciel: ",
|
||||
"wolny",
|
||||
"Urzadzenia: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nTransfer pradow: %.0f@%.0f%s[%.0f]%s%.0f@%.0f :: %.0f@%.0f%s[%.0f]%s%.0f@%.0f",
|
||||
" radio: ",
|
||||
" R",
|
||||
" cisn.oleju: ",
|
||||
"Nastawniki:\n glowny: %d(%d), dodatkowy: %s\nMoc silnika: %.1f, prad silnika: %.0f\nObroty:\n silnik: %.0f, motory: %.0f\n went.silnika: %.0f, went.motorow: %.0f+%.0f, went.chlodnicy: %.0f+%.0f",
|
||||
" (tryb manewrowy)",
|
||||
|
||||
@@ -201,7 +201,7 @@ std::vector<std::string> Split(const std::string &s)
|
||||
}
|
||||
|
||||
std::pair<std::string, int>
|
||||
split_index( std::string const &Key ) {
|
||||
split_string_and_number( std::string const &Key ) {
|
||||
|
||||
auto const indexstart{ Key.find_first_of( "-1234567890" ) };
|
||||
auto const indexend{ Key.find_first_not_of( "-1234567890", indexstart ) };
|
||||
|
||||
@@ -110,7 +110,7 @@ std::string ExchangeCharInString( std::string const &Source, char const From, ch
|
||||
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems);
|
||||
std::vector<std::string> Split(const std::string &s, char delim);
|
||||
//std::vector<std::string> Split(const std::string &s);
|
||||
std::pair<std::string, int> split_index( std::string const &Key );
|
||||
std::pair<std::string, int> split_string_and_number( std::string const &Key );
|
||||
|
||||
std::string to_string(int Value);
|
||||
std::string to_string(unsigned int Value);
|
||||
|
||||
Reference in New Issue
Block a user