16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 04:39:18 +02:00

reformat: remove redundant parentheses

This commit is contained in:
jerrrrycho
2026-06-30 21:19:46 +02:00
parent 7c88907f6b
commit d85096f64d
108 changed files with 4098 additions and 4662 deletions

View File

@@ -46,7 +46,7 @@ int vk_to_glfw_key( int const Keycode ) {
ErrorLog("unknown key: " + std::to_string(Keycode));
}
return ((int)modifier << 8) | key;
return (int)modifier << 8 | key;
}
bool TEventLauncher::Load(cParser *parser)
@@ -71,11 +71,9 @@ bool TEventLauncher::Load(cParser *parser)
{ "radio_call3", radio_message::call3 }
};
auto lookup = messages.find( token );
iKey = (
lookup != messages.end() ?
lookup->second :
// a jak więcej, to jakby numer klawisza jest
vk_to_glfw_key( stol_def( token, 0 ) ) );
iKey = lookup != messages.end() ? lookup->second :
// a jak więcej, to jakby numer klawisza jest
vk_to_glfw_key(stol_def(token, 0));
}
}
parser->getTokens();
@@ -86,7 +84,7 @@ bool TEventLauncher::Load(cParser *parser)
parser->getTokens();
*parser >> token;
asEvent2Name = token; // drugi event
if ((asEvent2Name == "end") || (asEvent2Name == "condition") || (asEvent2Name == "traintriggered"))
if (asEvent2Name == "end" || asEvent2Name == "condition" || asEvent2Name == "traintriggered")
{ // drugiego eventu może nie być, bo są z tym problemy, ale ciii...
token = asEvent2Name; // rozpoznane słowo idzie do dalszego przetwarzania
asEvent2Name = "none"; // a drugiego eventu nie ma
@@ -143,7 +141,7 @@ bool TEventLauncher::Load(cParser *parser)
auto const timeoffset{ static_cast<int>( Global.ScenarioTimeOffset * 60 ) };
if( timeoffset != 0 ) {
auto const adjustedtime{ clamp_circular( iHour * 60 + iMinute + timeoffset, 24 * 60 ) };
iHour = ( adjustedtime / 60 ) % 24;
iHour = adjustedtime / 60 % 24;
iMinute = adjustedtime % 60;
}
@@ -217,8 +215,8 @@ bool TEventLauncher::check_conditions() {
auto bCond { true };
if( ( iCheckMask != 0 )
&& ( MemCell != nullptr ) ) {
if( iCheckMask != 0
&& MemCell != nullptr ) {
// sprawdzanie warunku na komórce pamięci
bCond = MemCell->Compare( szText, fVal1, fVal2, iCheckMask );
}
@@ -229,15 +227,12 @@ bool TEventLauncher::check_conditions() {
// sprawdzenie, czy jest globalnym wyzwalaczem czasu
bool TEventLauncher::IsGlobal() const {
return ( ( DeltaTime == 0 )
&& ( iHour >= 0 )
&& ( iMinute >= 0 )
&& ( dRadius < 0.0 ) ); // bez ograniczenia zasięgu
return DeltaTime == 0 && iHour >= 0 && iMinute >= 0 && dRadius < 0.0; // bez ograniczenia zasięgu
}
bool TEventLauncher::IsRadioActivated() const {
return ( iKey < 0 );
return iKey < 0;
}
// radius() subclass details, calculates node's bounding radius
@@ -293,8 +288,8 @@ TEventLauncher::export_as_text_( std::ostream &Output ) const {
}
else {
// single activation at specified time
if( ( iHour < 0 )
&& ( iMinute < 0 ) ) {
if( iHour < 0
&& iMinute < 0 ) {
Output << DeltaTime << ' ';
}
else {
@@ -302,7 +297,7 @@ TEventLauncher::export_as_text_( std::ostream &Output ) const {
auto const timeoffset{ static_cast<int>( Global.ScenarioTimeOffset * 60 ) };
auto const adjustedtime{ clamp_circular( iHour * 60 + iMinute - timeoffset, 24 * 60 ) };
Output
<< ( adjustedtime / 60 ) % 24
<< adjustedtime / 60 % 24
<< ( adjustedtime % 60 )
<< ' ';
}

View File

@@ -164,7 +164,7 @@ basic_event::event_conditions::test() const {
"[*]" )
+ " - ";
comparisonlog += ( comparisonresult ? "Pass" : "Fail" );
comparisonlog += comparisonresult ? "Pass" : "Fail";
WriteLog( comparisonlog );
@@ -182,9 +182,9 @@ basic_event::event_conditions::deserialize( cParser &Input ) {
// przetwarzanie warunków, wspólne dla Multiple i UpdateValues
std::string token;
while( ( true == Input.getTokens() )
&& ( false == ( token = Input.peek() ).empty() )
&& ( false == basic_event::is_keyword( token ) ) ) {
while( true == Input.getTokens()
&& false == (token = Input.peek()).empty()
&& false == basic_event::is_keyword(token) ) {
if( token == "trackoccupied" ) {
flags |= flags::track_busy;
@@ -192,7 +192,7 @@ basic_event::event_conditions::deserialize( cParser &Input ) {
else if( token == "trackfree" ) {
flags |= flags::track_free;
}
else if( ( token == "propability" ) || ( token == "probability" )) { //remove propability in few years after changing old scenery scripts 01.2021
else if( token == "propability" || token == "probability") { //remove propability in few years after changing old scenery scripts 01.2021
flags |= flags::probability;
Input.getTokens();
Input >> probability;
@@ -304,8 +304,8 @@ basic_event::deserialize( cParser &Input, scene::scratch_data &Scratchpad ) {
deserialize_( Input, Scratchpad );
// subclass method is expected to leave next token past its own data preloaded on its exit
while( ( false == ( token = Input.peek() ).empty() )
&& ( token != "endevent" ) ) {
while( false == (token = Input.peek()).empty()
&& token != "endevent" ) {
if( token == "randomdelay" ) { // losowe opóźnienie
Input.getTokens();
@@ -335,7 +335,7 @@ basic_event::deserialize_targets( std::string const &Input ) {
void
basic_event::run() {
WriteLog( "EVENT LAUNCHED" + ( m_activator ? ( " by " + m_activator->asName ) : "" ) + ": " + m_name );
WriteLog( "EVENT LAUNCHED" + ( m_activator ? " by " + m_activator->asName : "" ) + ": " + m_name );
run_();
}
@@ -442,9 +442,9 @@ basic_event::input_location() const {
bool
basic_event::is_keyword( std::string const &Token ) {
// TODO: convert to array lookup if keyword list gets longer
return ( Token == "endevent" )
|| ( Token == "randomdelay" )
|| ( Token == "departuredelay" );
return Token == "endevent"
|| Token == "randomdelay"
|| Token == "departuredelay";
}
@@ -476,10 +476,7 @@ updatevalues_event::init() {
std::string
updatevalues_event::type() const {
return (
( m_input.flags & flags::mode_add ) == 0 ?
"updatevalues" :
"addvalues" );
return (m_input.flags & flags::mode_add) == 0 ? "updatevalues" : "addvalues";
}
// deserialize() subclass details
@@ -504,8 +501,8 @@ updatevalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpa
Input.getTokens();
// optional blocks
std::string token;
while( ( false == ( token = Input.peek() ).empty() )
&& ( false == is_keyword( token ) ) ) {
while( false == (token = Input.peek()).empty()
&& false == is_keyword(token) ) {
if( token == "condition" ) {
m_conditions.deserialize( Input );
@@ -521,10 +518,10 @@ updatevalues_event::run_() {
if( false == m_conditions.test() ) { return; }
WriteLog( "Type: " + std::string( ( m_input.flags & flags::mode_add ) ? "AddValues" : "UpdateValues" ) + " & Track command - ["
+ ( ( m_input.flags & flags::text ) ? m_input.data_text : "X" ) + "] ["
+ ( ( m_input.flags & flags::value1 ) ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] ["
+ ( ( m_input.flags & flags::value2 ) ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" );
WriteLog( "Type: " + std::string( m_input.flags & flags::mode_add ? "AddValues" : "UpdateValues" ) + " & Track command - ["
+ ( m_input.flags & flags::text ? m_input.data_text : "X" ) + "] ["
+ ( m_input.flags & flags::value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] ["
+ ( m_input.flags & flags::value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" );
for( auto &target : m_targets ) {
auto *targetcell { static_cast<TMemCell *>( std::get<scene::basic_node *>( target ) ) };
if( targetcell == nullptr ) { continue; }
@@ -566,7 +563,7 @@ updatevalues_event::export_as_text_( std::ostream &Output ) const {
bool
updatevalues_event::is_instant() const {
return ( ( ( m_input.flags & flags::mode_add ) != 0 ) && ( m_delay == 0.0 ) );
return (m_input.flags & flags::mode_add) != 0 && m_delay == 0.0;
}
@@ -625,7 +622,7 @@ getvalues_event::run_() {
cell->PutCommand(
m_activator->Mechanik,
&( cell->location() ) );
&cell->location() );
// potwierdzenie wykonania dla serwera (odczyt semafora już tak nie działa)
if( Global.iMultiplayer ) {
@@ -670,7 +667,7 @@ double
getvalues_event::input_value( int Index ) const {
Index &= 1; // tylko 1 albo 2 jest prawidłowy
return ( Index == 1 ? m_input.data_cell()->Value1() : m_input.data_cell()->Value2() );
return Index == 1 ? m_input.data_cell()->Value1() : m_input.data_cell()->Value2();
}
glm::dvec3
@@ -792,8 +789,8 @@ putvalues_event::run_() {
m_input.data_value_2,
loc );
}
else if( ( m_activator->ctOwner )
&& ( is_command_for_owner( m_input ) ) ) {
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
@@ -859,7 +856,7 @@ double
putvalues_event::input_value( int Index ) const {
Index &= 1; // tylko 1 albo 2 jest prawidłowy
return ( Index == 1 ? m_input.data_value_1 : m_input.data_value_2 );
return Index == 1 ? m_input.data_value_1 : m_input.data_value_2;
}
glm::dvec3
@@ -894,14 +891,14 @@ copyvalues_event::type() const {
void
copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
m_input.flags = ( flags::text | flags::value1 | flags::value2 ); // normalnie trzy
m_input.flags = flags::text | flags::value1 | flags::value2; // normalnie trzy
std::string token;
int paramidx { 0 };
while( ( true == Input.getTokens() )
&& ( false == ( token = Input.peek() ).empty() )
&& ( false == is_keyword( token ) ) ) {
while( true == Input.getTokens()
&& false == (token = Input.peek()).empty()
&& false == is_keyword(token) ) {
Input >> token;
switch( ++paramidx ) {
@@ -910,7 +907,7 @@ copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad
break;
}
case 2: { // maska wartości
m_input.flags = stol_def( token, ( flags::text | flags::value1 | flags::value2 ) );
m_input.flags = stol_def( token, flags::text | flags::value1 | flags::value2 );
break;
}
default: {
@@ -931,9 +928,9 @@ copyvalues_event::run_() {
m_input.data_value_2 = datasource->Value2();
WriteLog( "Type: CopyValues - ["
+ ( ( m_input.flags & flags::text ) ? m_input.data_text : "X" ) + "] ["
+ ( ( m_input.flags & flags::value1 ) ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] ["
+ ( ( m_input.flags & flags::value2 ) ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" );
+ ( m_input.flags & flags::text ? m_input.data_text : "X" ) + "] ["
+ ( m_input.flags & flags::value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] ["
+ ( m_input.flags & flags::value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" );
// TODO: dump status of target cells after the operation
for( auto &target : m_targets ) {
auto *targetcell { static_cast<TMemCell *>( std::get<scene::basic_node *>( target ) ) };
@@ -991,19 +988,19 @@ whois_event::type() const {
void
whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
m_input.flags = ( flags::text | flags::value1 | flags::value2 ); // normalnie trzy
m_input.flags = flags::text | flags::value1 | flags::value2; // normalnie trzy
std::string token;
int paramidx { 0 };
while( ( true == Input.getTokens() )
&& ( false == ( token = Input.peek() ).empty() )
&& ( false == is_keyword( token ) ) ) {
while( true == Input.getTokens()
&& false == (token = Input.peek()).empty()
&& false == is_keyword(token) ) {
Input >> token;
switch( ++paramidx ) {
case 1: { // maska wartości
m_input.flags = stol_def( token, ( flags::text | flags::value1 | flags::value2 ) );
m_input.flags = stol_def( token, flags::text | flags::value1 | flags::value2 );
break;
}
default: {
@@ -1014,7 +1011,7 @@ whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
}
// run() subclass details
void
void
whois_event::run_() {
for( auto &target : m_targets ) {
@@ -1032,7 +1029,7 @@ whois_event::run_() {
// next station name
if( m_input.flags & flags::mode_alt ) {
auto const *owner { (
( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->primary() ) ) ?
m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ?
m_activator->Mechanik :
m_activator->ctOwner ) };
auto const nextstop { (
@@ -1040,7 +1037,7 @@ whois_event::run_() {
owner->TrainTimetable().NextStop() :
"none" ) };
auto const isstop { (
( ( owner != nullptr ) && ( owner->IsStop() ) ) ?
owner != nullptr && owner->IsStop() ?
1 :
0 ) }; // 1, gdy ma tu zatrzymanie
@@ -1078,7 +1075,7 @@ whois_event::run_() {
// jeśli typ pojazdu
// TODO: define and recognize individual request types
auto const owner { (
( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->primary() ) ) ?
m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ?
m_activator->Mechanik :
m_activator->ctOwner ) };
auto const consistbrakelevel { (
@@ -1253,9 +1250,9 @@ multi_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
m_conditions.has_else = false;
std::string token;
while( ( true == Input.getTokens() )
&& ( false == ( token = Input.peek() ).empty() )
&& ( false == is_keyword( token ) ) ) {
while( true == Input.getTokens()
&& false == (token = Input.peek()).empty()
&& false == is_keyword(token) ) {
if( token == "condition" ) {
m_conditions.deserialize( Input );
@@ -1273,7 +1270,7 @@ multi_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
WriteLog( "Multi-event \"" + m_name + "\" ignored link to event \"" + token + "\"" );
}
else {
m_children.emplace_back( token, nullptr, ( m_conditions.has_else == false ) );
m_children.emplace_back( token, nullptr, m_conditions.has_else == false );
}
}
}
@@ -1762,9 +1759,9 @@ lights_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
int lightidx { 0 };
std::string token;
while( ( true == Input.getTokens() )
&& ( false == ( token = Input.peek() ).empty() )
&& ( false == is_keyword( token ) ) ) {
while( true == Input.getTokens()
&& false == (token = Input.peek()).empty()
&& false == is_keyword(token) ) {
if( lightidx < lightcountlimit ) {
Input >> m_lights[ lightidx++ ];
@@ -1807,8 +1804,8 @@ void
lights_event::export_as_text_( std::ostream &Output ) const {
auto lightidx{ 0 };
while( ( lightidx < iMaxNumLights )
&& ( false == std::isnan( m_lights[ lightidx ] ) ) ) {
while( lightidx < iMaxNumLights
&& false == std::isnan(m_lights[lightidx]) ) {
Output << m_lights[ lightidx ] << ' ';
++lightidx;
}
@@ -1830,8 +1827,8 @@ switch_event::init() {
// jeśli nie jest zwrotnicą ani obrotnicą to będzie się zmieniał stan uszkodzenia
targettrack->iAction |= 0x100;
}
if( ( m_switchstate == 0 )
&& ( m_switchmovedelay >= 0.0 ) ) {
if( m_switchstate == 0
&& m_switchmovedelay >= 0.0 ) {
// jeśli przełącza do stanu 0 & jeśli jest zdefiniowany dodatkowy ruch iglic
// przesłanie parametrów
targettrack->Switch(
@@ -1896,8 +1893,8 @@ void
switch_event::export_as_text_( std::ostream &Output ) const {
Output << m_switchstate << ' ';
if( ( m_switchmoverate < 0.f )
|| ( m_switchmovedelay < 0.f ) ) {
if( m_switchmoverate < 0.f
|| m_switchmovedelay < 0.f ) {
Output << m_switchmoverate << ' ';
}
if( m_switchmovedelay < 0.f ) {
@@ -2099,7 +2096,7 @@ void
friction_event::run_() {
// zmiana tarcia na scenerii
WriteLog( "Type: Friction" );
Global.fFriction = ( m_friction );
Global.fFriction = m_friction;
}
// export_as_text() subclass details
@@ -2173,9 +2170,9 @@ void
message_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
// wyświetlenie komunikatu
std::string token;
while( ( true == Input.getTokens() )
&& ( false == ( token = Input.peek() ).empty() )
&& ( false == is_keyword( token ) ) ) {
while( true == Input.getTokens()
&& false == (token = Input.peek()).empty()
&& false == is_keyword(token) ) {
m_message += ( m_message.empty() ? "" : " " ) + token;
}
}
@@ -2255,10 +2252,10 @@ void
event_manager::queue_receivers( radio_message const Message, glm::dvec3 const &Location ) {
for( auto *launcher : m_radiodrivenlaunchers.sequence() ) {
if( ( launcher->key() == Message )
&& ( ( launcher->dRadius < 0 )
|| ( glm::length2( launcher->location() - Location ) < launcher->dRadius ) )
&& ( true == launcher->check_conditions() ) ) {
if( launcher->key() == Message
&& ( launcher->dRadius < 0
|| glm::length2(launcher->location() - Location) < launcher->dRadius )
&& true == launcher->check_conditions() ) {
// NOTE: only execution of event1 is supported for radio messages
// TBD, TODO: consider ability/way to execute event2
simulation::Events.AddToQuery( launcher->Event1, nullptr );
@@ -2337,8 +2334,8 @@ event_manager::insert( basic_event *Event ) {
if( lookup == m_eventmap.end() ) {
// if it's first event with such name, it's potential candidate for the execution queue
m_eventmap.emplace( Event->m_name, m_events.size() - 1 );
if( ( Event->m_ignored != true )
&& ( contains( Event->m_name, "onstart" ) ) ) {
if( Event->m_ignored != true
&& contains(Event->m_name, "onstart") ) {
// event uruchamiany automatycznie po starcie
AddToQuery( Event, nullptr );
}
@@ -2381,7 +2378,7 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub
if( Event->m_passive ) { return false; } // jeśli może być dodany do kolejki (nie używany w skanowaniu)
if( Event->m_inqueue > 0 ) { return false; } // jeśli nie dodany jeszcze do kolejki
// kolejka eventów jest posortowana względem (fStartTime)
Event->m_activator = Owner;
if( Event->is_instant() ) {
@@ -2394,24 +2391,24 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub
Event = Event->m_sibling;
// NOTE: we could've received a new event from joint event above, so we need to check conditions just in case and discard the bad events
// TODO: refactor this arrangement, it's hardly optimal
} while( ( Event != nullptr )
&& ( ( Event->m_passive )
|| ( Event->m_inqueue > 0 ) ) );
} while( Event != nullptr
&& ( Event->m_passive
|| Event->m_inqueue > 0 ) );
}
if( ( Event != nullptr )
&& ( false == Event->m_ignored ) ) {
if( Event != nullptr
&& false == Event->m_ignored ) {
// standardowe dodanie do kolejki
++(Event->m_inqueue); // zabezpieczenie przed podwójnym dodaniem do kolejki
WriteLog( "EVENT ADDED TO QUEUE" + ( Owner ? ( " by " + Owner->asName ) : "" ) + ": " + Event->m_name );
++Event->m_inqueue; // zabezpieczenie przed podwójnym dodaniem do kolejki
WriteLog( "EVENT ADDED TO QUEUE" + ( Owner ? " by " + Owner->asName : "" ) + ": " + Event->m_name );
Event->m_launchtime = delay + std::abs( Event->m_delay ) + Timer::GetTime(); // czas od uruchomienia scenerii
if( Event->m_delayrandom > 0.0 ) {
// doliczenie losowego czasu opóźnienia
Event->m_launchtime += Event->m_delayrandom * Random();
}
if( ( Owner != nullptr )
&& ( false == std::isnan( Event->m_delaydeparture ) ) ) {
if( Owner != nullptr
&& false == std::isnan(Event->m_delaydeparture) ) {
auto const *timetableowner { (
( ( Owner->Mechanik != nullptr ) && ( Owner->Mechanik->primary() ) ) ?
Owner->Mechanik != nullptr && Owner->Mechanik->primary() ?
Owner->Mechanik :
Owner->ctOwner ) };
if( timetableowner != nullptr ) {
@@ -2427,8 +2424,8 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub
if( QueryRootEvent != nullptr ) {
basic_event *target { QueryRootEvent };
basic_event *previous { nullptr };
while( ( Event->m_launchtime >= target->m_launchtime )
&& ( target->m_next != nullptr ) ) {
while( Event->m_launchtime >= target->m_launchtime
&& target->m_next != nullptr ) {
previous = target;
target = target->m_next;
}
@@ -2464,8 +2461,8 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub
bool
event_manager::CheckQuery() {
while( ( QueryRootEvent != nullptr )
&& ( QueryRootEvent->m_launchtime < Timer::GetTime() ) )
while( QueryRootEvent != nullptr
&& QueryRootEvent->m_launchtime < Timer::GetTime() )
{ // eventy są posortowana wg czasu wykonania
m_workevent = QueryRootEvent; // wyjęcie eventu z kolejki
if (QueryRootEvent->m_sibling) // jeśli jest kolejny o takiej samej nazwie
@@ -2479,9 +2476,9 @@ event_manager::CheckQuery() {
}
else // a jak nazwa jest unikalna, to kolejka idzie dalej
QueryRootEvent = QueryRootEvent->m_next; // NULL w skrajnym przypadku
if( ( false == m_workevent->m_ignored ) && ( false == m_workevent->m_passive ) ) {
if( false == m_workevent->m_ignored && false == m_workevent->m_passive ) {
// w zasadzie te wyłączone są skanowane i nie powinny się nigdy w kolejce znaleźć
--(m_workevent->m_inqueue); // teraz moze być ponownie dodany do kolejki
--m_workevent->m_inqueue; // teraz moze być ponownie dodany do kolejki
m_workevent->run();
} // if (tmpEvent->bEnabled)
} // while

View File

@@ -659,10 +659,7 @@ public:
inline
bool
insert( TEventLauncher *Launcher ) {
return (
Launcher->IsRadioActivated() ?
m_radiodrivenlaunchers.insert( Launcher ) :
m_inputdrivenlaunchers.insert( Launcher ) ); }
return Launcher->IsRadioActivated() ? m_radiodrivenlaunchers.insert(Launcher) : m_inputdrivenlaunchers.insert(Launcher); }
inline void purge (TEventLauncher *Launcher) {
m_radiodrivenlaunchers.purge(Launcher);
m_inputdrivenlaunchers.purge(Launcher); }

View File

@@ -163,23 +163,23 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
compare( szText, szTestText, TextOperator ) :
compare( szText.substr( 0, range ), szTestText.substr( 0, range ), TextOperator ) ) };
checkpassed |= result;
checkfailed |= ( !result );
checkfailed |= !result;
}
if( TestFlag( CheckMask, basic_event::flags::value1 ) ) {
auto const result { compare( fValue1, fTestValue1, Value1Operator ) };
checkpassed |= result;
checkfailed |= ( !result );
checkfailed |= !result;
}
if( TestFlag( CheckMask, basic_event::flags::value2 ) ) {
auto const result { compare( fValue2, fTestValue2, Value2Operator ) };
checkpassed |= result;
checkfailed |= ( !result );
checkfailed |= !result;
}
switch( Pass ) {
case comparison_pass::all: { return ( checkfailed == false ); }
case comparison_pass::any: { return ( checkpassed == true ); }
case comparison_pass::none: { return ( checkpassed == false ); }
case comparison_pass::all: { return checkfailed == false; }
case comparison_pass::any: { return checkpassed == true; }
case comparison_pass::none: { return checkpassed == false; }
default: { return false; }
}
};
@@ -190,7 +190,7 @@ bool TMemCell::IsVelocity() const
return true;
if (eCommand == TCommandType::cm_ShuntVelocity)
return true;
return (eCommand == TCommandType::cm_SetProximityVelocity);
return eCommand == TCommandType::cm_SetProximityVelocity;
};
void TMemCell::StopCommandSent()

View File

@@ -115,20 +115,17 @@ bool TSegment::Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 N
fLength = 0.01; // crude workaround TODO: fix this properly
}
fStoop = std::atan2((Point2.y - Point1.y), fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie
fStoop = std::atan2(Point2.y - Point1.y, fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie
fStep = fNewStep;
// NOTE: optionally replace this part with the commented version, after solving geometry issues with double switches
if( ( pOwner->eType == tt_Switch )
&& ( fStep * ( 3.0 * Global.SplineFidelity ) > fLength ) ) {
if( pOwner->eType == tt_Switch
&& fStep * (3.0 * Global.SplineFidelity) > fLength ) {
// NOTE: a workaround for too short switches (less than 3 segments) messing up animation/generation of blades
fStep = fLength / ( 3.0 * Global.SplineFidelity );
}
// iSegCount = static_cast<int>( std::ceil( fLength / fStep ) ); // potrzebne do VBO
iSegCount = (
pOwner->eType == tt_Switch ?
6 * Global.SplineFidelity :
static_cast<int>( std::ceil( fLength / fStep ) ) ); // potrzebne do VBO
iSegCount = pOwner->eType == tt_Switch ? 6 * Global.SplineFidelity : static_cast<int>(std::ceil(fLength / fStep)); // potrzebne do VBO
fStep = fLength / iSegCount; // update step to equalize size of individual pieces
@@ -170,7 +167,7 @@ double TSegment::RombergIntegral(double const fA, double const fB) const
double ms_apfRom[2][ms_iOrder];
ms_apfRom[0][0] =
0.5 * fH * ((glm::length(GetFirstDerivative(fA))) + glm::length(GetFirstDerivative(fB)));
0.5 * fH * (glm::length(GetFirstDerivative(fA)) + glm::length(GetFirstDerivative(fB)));
for (int i0 = 2, iP0 = 1; i0 <= ms_iOrder; i0++, iP0 *= 2, fH *= 0.5)
{
// approximations via the trapezoid rule
@@ -249,14 +246,14 @@ double TSegment::ComputeLength() const // McZapkie-150503: dlugosc miedzy punkta
l += t; // zwiększenie wyliczanej długości
last = tmp;
}
return (l);
return l;
}
// finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1
double
TSegment::find_nearest_point( glm::dvec3 const &Point ) const {
if( ( false == bCurve ) || ( iSegCount == 1 ) ) {
if( false == bCurve || iSegCount == 1 ) {
// for straight track just treat it as a single segment
return
nearest_segment_point(
@@ -300,22 +297,22 @@ glm::dvec3 TSegment::GetDirection(double const fDistance) const
{ // takie toporne liczenie pochodnej dla podanego dystansu od Point1
double t1 = GetTFromS(fDistance - fDirectionOffset);
if (t1 <= 0.0)
return (CPointOut - Point1); // na zewnątrz jako prosta
return CPointOut - Point1; // na zewnątrz jako prosta
double t2 = GetTFromS(fDistance + fDirectionOffset);
if (t2 >= 1.0)
return (Point1 - CPointIn); // na zewnątrz jako prosta
return (FastGetPoint(t2) - FastGetPoint(t1));
return Point1 - CPointIn; // na zewnątrz jako prosta
return FastGetPoint(t2) - FastGetPoint(t1);
}
glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset)
{ // takie toporne liczenie pochodnej dla parametru 0.0÷1.0
double t1 = fDistance - fOffset;
if (t1 <= 0.0)
return (CPointOut - Point1); // wektor na początku jest stały
return CPointOut - Point1; // wektor na początku jest stały
double t2 = fDistance + fOffset;
if (t2 >= 1.0)
return (Point2 - CPointIn); // wektor na końcu jest stały
return (FastGetPoint(t2) - FastGetPoint(t1));
return Point2 - CPointIn; // wektor na końcu jest stały
return FastGetPoint(t2) - FastGetPoint(t1);
}
/*
Math3D::vector3 TSegment::GetPoint(double const fDistance) const
@@ -366,9 +363,7 @@ void TSegment::RaPositionGet(double const fDistance, glm::dvec3 &position, glm::
glm::dvec3 TSegment::FastGetPoint(double const t) const
{
// return (bCurve?std::lerp(t,Point1,CPointOut,CPointIn,Point2):((1.0-t)*Point1+(t)*Point2));
return (
( ( true == bCurve ) || ( iSegCount != 1 ) ) ?
RaInterpolate( t ) : glm::mix(Point1, Point2, t));
return true == bCurve || iSegCount != 1 ? RaInterpolate(t) : glm::mix(Point1, Point2, t);
}
bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, const gfx::vertex_array &ShapePoints, bool const Transition, double fTextureLength, double Texturescale, int iSkip, int iEnd, std::pair<float, float> fOffsetX, glm::vec3 **p, bool bRender)
@@ -424,7 +419,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin,
jmm2 = 1.f - m2; // nowa pozycja
if( i == iEnd ) { // gdy przekroczyliśmy koniec - stąd dziury w torach...
step -= ( s - fEnd ); // jeszcze do wyliczenia mapowania potrzebny
step -= s - fEnd; // jeszcze do wyliczenia mapowania potrzebny
s = fEnd;
m2 = 1.f;
jmm2 = 0.f;
@@ -465,7 +460,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin,
if( *p )
if( !j ) // to dla pierwszego punktu
{
*( *p ) = pt;
**p = pt;
( *p )++;
} // zapamiętanie brzegu jezdni
// dla trapezu drugi koniec ma inne współrzędne
@@ -484,7 +479,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin,
if( *p )
if( !j ) // to dla pierwszego punktu
if( i == iSegCount ) {
*( *p ) = pt;
**p = pt;
( *p )++;
} // zapamiętanie brzegu jezdni
}

View File

@@ -132,7 +132,7 @@ public:
inline
int
RaSegCount() const {
return ( fTsBuffer.empty() ? 1 : iSegCount ); };
return fTsBuffer.empty() ? 1 : iSegCount; };
void
render_lines(std::vector<gfx::basic_vertex> &out, float quality = 1.0f) const;

View File

@@ -34,12 +34,12 @@ glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 con
auto deltaV = pPosition1 - pPosition2;
// Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term
auto Dterm = (glm::dot(deltaV,deltaP) * Kd) / dist;
auto Dterm = glm::dot(deltaV, deltaP) * Kd / dist;
//Dterm = 0;
// ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector
// ScaleVector(&springForce,-(Hterm + Dterm),&springForce); // Calc Force
springForce = deltaP / dist * ( -( Hterm + Dterm ));
springForce = deltaP / dist * -(Hterm + Dterm);
// VectorSum(&p1->f,&springForce,&p1->f); // Apply to Particle 1
// VectorDifference(&p2->f,&springForce,&p2->f); // - Force on Particle 2
}

View File

@@ -58,16 +58,16 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int const what)
fOffset2 = 0.f; // w zasadniczym wewnętrzna iglica dolega
Segments[0] = std::make_shared<TSegment>(owner); // z punktu 1 do 2
Segments[1] = std::make_shared<TSegment>(owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4)
Segments[2] = (what >= 3) ?
Segments[2] = what >= 3 ?
std::make_shared<TSegment>(owner) :
nullptr; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1":
Segments[3] = (what >= 4) ?
Segments[3] = what >= 4 ?
std::make_shared<TSegment>(owner) :
nullptr; // z punktu 4 do 1 1 1=4 0 0=3
Segments[4] = (what >= 5) ?
Segments[4] = what >= 5 ?
std::make_shared<TSegment>(owner) :
nullptr; // z punktu 1 do 3 4 x 3 3 3 x 2 2
Segments[5] = (what >= 6) ?
Segments[5] = what >= 6 ?
std::make_shared<TSegment>(owner) :
nullptr; // z punktu 3 do 2 2 2 1 1
}
@@ -142,10 +142,7 @@ void TIsolated::Modify(int i, TDynamicObject *o)
simulation::Events.AddToQuery(evBusy, o); // dodanie zajętości do kolejki
if (Global.iMultiplayer) // jeśli multiplayer
{
auto const *owner = (
((o->Mechanik != nullptr) && (o->Mechanik->primary())) ?
o->Mechanik :
o->ctOwner);
auto const *owner = o->Mechanik != nullptr && o->Mechanik->primary() ? o->Mechanik : o->ctOwner;
auto textline = owner != nullptr ? Bezogonkow(owner->TrainName(), true) : "none";
if ("none" != textline && Global.bIsolatedTrainName) {
textline = ":" + Bezogonkow(owner->TrainName(), true);
@@ -234,7 +231,7 @@ TTrack * TTrack::NullCreate(int dir)
nodedata.name = "auto_null"; // track isn't visible so only name is needed
trk = new TTrack( nodedata );
trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
trk->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy
trk->iCategoryFlag = iCategoryFlag & 15 | 0x80; // taki sam typ plus informacja, że dodatkowy
float r1, r2;
Segment->GetRolls(r1, r2); // pobranie przechyłek na początku toru
glm::dvec3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu
@@ -277,7 +274,7 @@ TTrack * TTrack::NullCreate(int dir)
trk->Init(); // utworzenie segmentu
trk2 = new TTrack( nodedata );
trk2->iCategoryFlag =
(iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy
iCategoryFlag & 15 | 0x80; // taki sam typ plus informacja, że dodatkowy
trk2->m_visible = false;
trk2->fVelocity = 20.0; // zawracanie powoli
trk2->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło narastająco
@@ -329,7 +326,7 @@ void TTrack::ConnectPrevPrev(TTrack *pTrack, int typ)
if (pTrack)
{ //(pTrack) może być zwrotnicą, a (this) tylko zwykłym odcinkiem
trPrev = pTrack;
iPrevDirection = ((pTrack->eType == tt_Switch) ? 0 : (typ & 2));
iPrevDirection = pTrack->eType == tt_Switch ? 0 : typ & 2;
pTrack->trPrev = this;
pTrack->iPrevDirection = 0;
}
@@ -346,11 +343,10 @@ void TTrack::ConnectPrevNext(TTrack *pTrack, int typ)
if (pTrack->m_visible)
if (eType == tt_Normal) // jeśli łączone są dwa normalne
if (pTrack->eType == tt_Normal)
if ((fTrackWidth !=
pTrack->fTrackWidth) // Ra: jeśli kolejny ma inne wymiary
if (fTrackWidth != pTrack->fTrackWidth // Ra: jeśli kolejny ma inne wymiary
||
(fTexHeight1 != pTrack->fTexHeight1) ||
(fTexWidth != pTrack->fTexWidth) || (fTexSlope != pTrack->fTexSlope))
fTexHeight1 != pTrack->fTexHeight1 ||
fTexWidth != pTrack->fTexWidth || fTexSlope != pTrack->fTexSlope)
pTrack->iTrapezoid |= 2; // to rysujemy potworka
}
}
@@ -359,18 +355,17 @@ void TTrack::ConnectNextPrev(TTrack *pTrack, int typ)
if (pTrack)
{
trNext = pTrack;
iNextDirection = ((pTrack->eType == tt_Switch) ? 0 : (typ & 2));
iNextDirection = pTrack->eType == tt_Switch ? 0 : typ & 2;
pTrack->trPrev = this;
pTrack->iPrevDirection = 1;
if (m_visible)
if (pTrack->m_visible)
if (eType == tt_Normal) // jeśli łączone są dwa normalne
if (pTrack->eType == tt_Normal)
if ((fTrackWidth !=
pTrack->fTrackWidth) // Ra: jeśli kolejny ma inne wymiary
if (fTrackWidth != pTrack->fTrackWidth // Ra: jeśli kolejny ma inne wymiary
||
(fTexHeight1 != pTrack->fTexHeight1) ||
(fTexWidth != pTrack->fTexWidth) || (fTexSlope != pTrack->fTexSlope))
fTexHeight1 != pTrack->fTexHeight1 ||
fTexWidth != pTrack->fTexWidth || fTexSlope != pTrack->fTexSlope)
iTrapezoid |= 2; // to rysujemy potworka
}
}
@@ -479,16 +474,13 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
parser->getTokens();
*parser >> token;
m_visible = (token.compare("vis") == 0); // visible
m_visible = token.compare("vis") == 0; // visible
if (m_visible)
{
parser->getTokens();
*parser >> str; // railtex
replace_slashes(str);
m_material1 = (
str == "none" ?
null_handle :
GfxRenderer->Fetch_Material( str ) );
m_material1 = str == "none" ? null_handle : GfxRenderer->Fetch_Material(str);
parser->getTokens();
*parser >> fTexLength; // tex tile length
if (fTexLength < 0.01)
@@ -496,10 +488,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
parser->getTokens();
*parser >> str; // sub || railtex
replace_slashes(str);
m_material2 = (
str == "none" ?
null_handle :
GfxRenderer->Fetch_Material( str ) );
m_material2 = str == "none" ? null_handle : GfxRenderer->Fetch_Material(str);
parser->getTokens(3);
*parser
>> fTexHeight1
@@ -561,8 +550,8 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
// length2 is better than length for comparing because it does not require sqrt function
if( (glm::length2(( p1 + p1 + p2 ) / 3.0 - p1 - cp1) < sq(0.02))
|| (glm::length2(( p1 + p2 + p2 ) / 3.0 - p2 + cp1) < sq(0.02)) ) {
if( glm::length2((p1 + p1 + p2) / 3.0 - p1 - cp1) < sq(0.02)
|| glm::length2((p1 + p2 + p2) / 3.0 - p2 + cp1) < sq(0.02) ) {
// "prostowanie" prostych z kontrolnymi, dokładność 2cm
cp1 = cp2 = glm::dvec3(0, 0, 0);
}
@@ -577,7 +566,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
else {
// HACK: crude check whether claimed straight is an actual straight piece
if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
if (cp1 == glm::dvec3() && cp2 == glm::dvec3())
{
segsize = 10.0; // for straights, 10m per segment works good enough
}
@@ -591,7 +580,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
}
if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
if (cp1 == glm::dvec3() && cp2 == glm::dvec3())
{
// Ra: hm, czasem dla prostego są podane...
// gdy prosty, kontrolne wyliczane przy zmiennej przechyłce
@@ -602,7 +591,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
Segment->Init( p1, cp1 + p1, cp2 + p2, p2, segsize, r1, r2 );
}
if ((r1 != 0) || (r2 != 0))
if (r1 != 0 || r2 != 0)
iTrapezoid = 1; // są przechyłki do uwzględniania w rysowaniu
if (eType == tt_Table) // obrotnica ma doklejkę
@@ -675,7 +664,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
else {
// HACK: crude check whether claimed straight is an actual straight piece
if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
if (cp1 == glm::dvec3() && cp2 == glm::dvec3())
{
segsize = 10.0; // for straights, 10m per segment works good enough
}
@@ -689,7 +678,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
}
if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
if (cp1 == glm::dvec3() && cp2 == glm::dvec3())
{
// Ra: hm, czasem dla prostego są podane...
// gdy prosty, kontrolne wyliczane przy zmiennej przechyłce
@@ -723,8 +712,8 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if( eType != tt_Cross ) {
// dla skrzyżowań muszą być podane kontrolne
// length2 is better than length for comparing because it does not require sqrt function
if( (glm::length2(( p3 + p3 + p4 ) / 3.0 - p3 - cp3) < sq(0.02))
|| (glm::length2(( p3 + p4 + p4 ) / 3.0 - p4 + cp3) < sq(0.02)) ) {
if( glm::length2((p3 + p3 + p4) / 3.0 - p3 - cp3) < sq(0.02)
|| glm::length2((p3 + p4 + p4) / 3.0 - p4 + cp3) < sq(0.02) ) {
// "prostowanie" prostych z kontrolnymi, dokładność 2cm
cp3 = cp4 = glm::dvec3(0, 0, 0);
}
@@ -740,7 +729,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
else {
// HACK: crude check whether claimed straight is an actual straight piece
if ((cp3 == glm::dvec3()) && (cp4 == glm::dvec3()))
if (cp3 == glm::dvec3() && cp4 == glm::dvec3())
{
segsize = 10.0; // for straights, 10m per segment works good enough
}
@@ -754,7 +743,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
}
}
if ((cp3 == glm::dvec3()) && (cp4 == glm::dvec3()))
if (cp3 == glm::dvec3() && cp4 == glm::dvec3())
{
// Ra: hm, czasem dla prostego są podane...
// gdy prosty, kontrolne wyliczane przy zmiennej przechyłce
@@ -990,7 +979,7 @@ bool TTrack::AssignEvents() {
{ "event2", &m_events2 }, { "eventall2", &m_events2all } };
for( auto &eventsequence : eventsequences ) {
for( auto &event : *( eventsequence.second ) ) {
for( auto &event : *eventsequence.second ) {
event.second = simulation::Events.FindEvent( event.first );
if( event.second != nullptr ) {
m_events = true;
@@ -1004,8 +993,8 @@ bool TTrack::AssignEvents() {
auto const trackname { name() };
if( ( Global.iHiddenEvents & 1 )
&& ( false == trackname.empty() ) ) {
if (Global.iHiddenEvents & 1
&& false == trackname.empty() ) {
// jeśli podana jest nazwa torów, można szukać eventów skojarzonych przez nazwę
for( auto &eventsequence : eventsequences ) {
auto *event = simulation::Events.FindEvent( trackname + ':' + eventsequence.first );
@@ -1017,7 +1006,7 @@ bool TTrack::AssignEvents() {
}
}
return ( lookupfail == false );
return lookupfail == false;
}
bool TTrack::AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus)
@@ -1045,8 +1034,8 @@ void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Ow
void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Owner, double const Delaylimit ) {
for( auto const &event : Events ) {
if( ( event.second != nullptr )
&& ( event.second->m_delay <= Delaylimit) ) {
if( event.second != nullptr
&& event.second->m_delay <= Delaylimit ) {
simulation::Events.AddToQuery( event.second, Owner );
}
}
@@ -1109,7 +1098,7 @@ bool TTrack::RemoveDynamicObject(TDynamicObject *Dynamic)
Dynamics.pop_front();
result = true;
}
else if( *( --Dynamics.end() ) == Dynamic ) {
else if( *--Dynamics.end() == Dynamic ) {
// ...or the back of the queue...
Dynamics.pop_back();
result = true;
@@ -1153,12 +1142,9 @@ bool TTrack::InMovement()
if (!SwitchExtension->CurrentIndex)
return false; // 0=zablokowana się nie animuje
// trzeba każdorazowo porównywać z kątem modelu
auto ac = (
SwitchExtension->pModel ?
SwitchExtension->pModel->GetContainer() :
nullptr );
auto ac = SwitchExtension->pModel ? SwitchExtension->pModel->GetContainer() : nullptr;
return ac ?
(ac->AngleGet() != SwitchExtension->fOffset) ||
ac->AngleGet() != SwitchExtension->fOffset ||
!(ac->TransGet() == SwitchExtension->vTrans) :
false;
// return true; //jeśli jest taki obiekt
@@ -1174,7 +1160,7 @@ void TTrack::RaAssign( TAnimModel *am, basic_event *done, basic_event *joined )
SwitchExtension->pModel = am;
SwitchExtension->evMinus = done; // event zakończenia animacji (zadanie nowej przedłuża)
SwitchExtension->evPlus = joined; // event potwierdzenia połączenia (gdy nie znajdzie, to się nie połączy)
if( ( am != nullptr ) && ( am->GetContainer() ) ) {// może nie być?
if( am != nullptr && am->GetContainer() ) {// może nie być?
am->GetContainer()->EventAssign( done ); // zdarzenie zakończenia animacji
}
}
@@ -1372,7 +1358,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// optional vertical shift of the auto-generated ballast (sleepermodel ballastZ).
// positive value raises the trackbed, negative pushes it down so a custom
// sleeper model placed on top can sit flush with the ballast surface.
if( m_sleeper_enabled && ( m_sleeper_ballast_z != 0.f ) ) {
if( m_sleeper_enabled && m_sleeper_ballast_z != 0.f ) {
for( auto &v : bpts1 ) {
v.position.y += m_sleeper_ballast_z;
}
@@ -1380,10 +1366,10 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
auto const texturelength { texture_length( m_material2 ) };
gfx::vertex_array vertices;
Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid > 0, texturelength);
if( ( Bank != 0 ) && ( true == Geometry2.empty() ) ) {
if( Bank != 0 && true == Geometry2.empty() ) {
Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
}
if( ( Bank == 0 ) && ( false == Geometry2.empty() ) ) {
if( Bank == 0 && false == Geometry2.empty() ) {
// special variant, replace existing data for a turntable track
GfxRenderer->Replace(vertices, empty_userdata, Geometry2[0], GL_TRIANGLE_STRIP);
}
@@ -1393,14 +1379,14 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
auto const nnumPts { track_rail_profile( m_profile1.second ).size() / 2 };
auto const texturelength { texture_length( m_material1 ) };
gfx::vertex_array vertices;
if( ( Bank != 0 ) && ( true == Geometry1.empty() ) ) {
if( Bank != 0 && true == Geometry1.empty() ) {
Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid > 0, texturelength );
Geometry1.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
vertices.clear(); // reuse the scratchpad
Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid > 0, texturelength );
Geometry1.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
}
if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) {
if( Bank == 0 && false == Geometry1.empty() ) {
// special variant, replace existing data for a turntable track
Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid > 0, texturelength );
GfxRenderer->Replace(vertices, empty_userdata, Geometry1[0], GL_TRIANGLE_STRIP);
@@ -1550,13 +1536,13 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony
create_road_side_profile( rpts1, rpts2, bpts1 );
gfx::vertex_array vertices;
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
if( fTexHeight1 >= 0.0 || slop != 0.0 ) {
// tylko jeśli jest z prawej
Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid > 0, texturelength );
Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
vertices.clear();
}
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
if( fTexHeight1 >= 0.0 || side != 0.0 ) {
// tylko jeśli jest z lewej
Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid > 0, texturelength );
Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
@@ -1627,13 +1613,13 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony
create_road_side_profile( rpts1, rpts2, bpts1, true );
// Ra 2014-07: trzeba to przerobić na pętlę i pobierać profile (przynajmniej 2..4) z sąsiednich dróg
bool render = ( m_material2 != 0 ); // renderować nie trzeba, ale trzeba wyznaczyć punkty brzegowe nawierzchni
bool render = m_material2 != 0; // renderować nie trzeba, ale trzeba wyznaczyć punkty brzegowe nawierzchni
auto const side{ std::abs( fTexWidth ) }; // szerokść podsypki na zewnątrz szyny albo pobocza
auto const texturelength{ texture_length( m_material2 ) };
gfx::vertex_array vertices;
if (SwitchExtension->iRoads == 4)
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
if( fTexHeight1 >= 0.0 || side != 0.0 ) {
SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, true, texturelength, 1.0, 0, 0, {}, &b, render );
if( true == render ) {
Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
@@ -1658,7 +1644,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
}
else {
// punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
if( fTexHeight1 >= 0.0 || side != 0.0 ) {
SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, true, texturelength, 1.0, 0, 0, {}, &b, render ); // z P2 do P4
if( true == render ) {
Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP));
@@ -1680,8 +1666,8 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// renderowanie nawierzchni na końcu
double sina0 = sin(a[0]), cosa0 = cos(a[0]);
double u, v;
if( ( false == SwitchExtension->bPoints ) // jeśli tablica nie wypełniona
&& ( b != nullptr ) ) {
if( false == SwitchExtension->bPoints // jeśli tablica nie wypełniona
&& b != nullptr ) {
SwitchExtension->bPoints = true; // tablica punktów została wypełniona
}
@@ -1862,13 +1848,13 @@ bool TTrack::Switch(int i, float const t, float const d)
if (trNext || trPrev)
{
fVelocity = 6.0; // jazda dozwolona
if( ( trPrev )
&& ( trPrev->fVelocity == 0.0 ) ) {
if( trPrev
&& trPrev->fVelocity == 0.0 ) {
// ustawienie 0 da możliwość zatrzymania AI na obrotnicy
trPrev->VelocitySet( 6.0 ); // odblokowanie dołączonego toru do jazdy
}
if( ( trNext )
&& ( trNext->fVelocity == 0.0 ) ) {
if( trNext
&& trNext->fVelocity == 0.0 ) {
trNext->VelocitySet( 6.0 );
}
if( SwitchExtension->evPlus ) { // w starych sceneriach może nie być
@@ -1937,15 +1923,15 @@ int TTrack::CrossSegment(int from, int into)
break;
case 1: // left
// WriteLog( "Turning left from P" + to_string( from + 1 ) + " on " + name() );
i = (SwitchExtension->iRoads == 4) ? iLewo4[from] : iLewo3[from];
i = SwitchExtension->iRoads == 4 ? iLewo4[from] : iLewo3[from];
break;
case 2: // right
// WriteLog( "Turning right from P" + to_string( from + 1 ) + " on " + name() );
i = (SwitchExtension->iRoads == 4) ? iPrawo4[from] : iPrawo3[from];
i = SwitchExtension->iRoads == 4 ? iPrawo4[from] : iPrawo3[from];
break;
case 3: // stright
// WriteLog( "Going straight from P" + to_string( from + 1 ) + " on " + name() );
i = (SwitchExtension->iRoads == 4) ? iProsto4[from] : iProsto3[from];
i = SwitchExtension->iRoads == 4 ? iProsto4[from] : iProsto3[from];
break;
}
if (i)
@@ -1958,7 +1944,7 @@ int TTrack::CrossSegment(int from, int into)
void TTrack::RaAnimListAdd(TTrack *t)
{ // dodanie toru do listy animacyjnej
if ((t != nullptr) && (SwitchExtension != nullptr))
if (t != nullptr && SwitchExtension != nullptr)
{
if (t == this)
return; // siebie nie dodajemy drugi raz do listy
@@ -2014,10 +2000,10 @@ TTrack * TTrack::RaAnimate()
}
}
// skip the geometry update if no geometry for this track was generated yet
if( ( ( m_material1 != 0 )
|| ( m_material2 != 0 ) )
&& ( ( false == Geometry1.empty() )
|| ( false == Geometry2.empty() ) ) ) {
if( ( m_material1 != 0
|| m_material2 != 0 )
&& ( false == Geometry1.empty()
|| false == Geometry2.empty() ) ) {
// iglice liczone tylko dla zwrotnic
gfx::vertex_array rpts1, rpts2;
create_track_rail_profile( rpts1, rpts2 );
@@ -2075,12 +2061,10 @@ TTrack * TTrack::RaAnimate()
SwitchExtension->CurrentIndex) // 0=zablokowana się nie animuje
{ // trzeba każdorazowo porównywać z kątem modelu
// //pobranie kąta z modelu
auto ac = (
SwitchExtension->pModel ?
SwitchExtension->pModel->GetContainer() : // pobranie głównego submodelu
nullptr );
auto ac = SwitchExtension->pModel ? SwitchExtension->pModel->GetContainer() : // pobranie głównego submodelu
nullptr;
if( ac ) {
if( ( ac->AngleGet() != SwitchExtension->fOffset )
if( ac->AngleGet() != SwitchExtension->fOffset
|| !( ac->TransGet() == SwitchExtension->vTrans ) ) { // czy przemieściło się od ostatniego sprawdzania
double hlen = 0.5 * SwitchExtension->Segments[ 0 ]->GetLength(); // połowa długości
@@ -2127,9 +2111,9 @@ double TTrack::WidthTotal()
bool TTrack::IsGroupable()
{ // czy wyświetlanie toru może być zgrupwane z innymi
if ((eType == tt_Switch) || (eType == tt_Table))
if (eType == tt_Switch || eType == tt_Table)
return false; // tory ruchome nie są grupowane
if ((eEnvironment == e_canyon) || (eEnvironment == e_tunnel))
if (eEnvironment == e_canyon || eEnvironment == e_tunnel)
return false; // tory ze zmianą światła
return true;
};
@@ -2322,10 +2306,7 @@ TTrack::export_as_text_( std::ostream &Output ) const {
<< texturefile << ' '
<< fTexLength << ' ';
texturefile = (
m_material2 != null_handle ?
GfxRenderer->Material( m_material2 )->GetName() :
"none" );
texturefile = m_material2 != null_handle ? GfxRenderer->Material(m_material2)->GetName() : "none";
if( texturefile.find( paths::textures ) == 0 ) {
// don't include 'textures/' in the path
texturefile.erase( 0, std::string{ paths::textures }.size() );
@@ -2333,7 +2314,7 @@ TTrack::export_as_text_( std::ostream &Output ) const {
Output << texturefile << ' ';
Output
<< (fTexHeight1 - fTexHeightOffset ) * ( ( iCategoryFlag & 4 ) ? -1 : 1 ) << ' '
<< (fTexHeight1 - fTexHeightOffset ) * ( iCategoryFlag & 4 ? -1 : 1 ) << ' '
<< fTexWidth << ' '
<< fTexSlope << ' ';
}
@@ -2367,7 +2348,7 @@ TTrack::export_as_text_( std::ostream &Output ) const {
{ "event2", &m_events2 }, { "eventall2", &m_events2all } };
for( auto &eventsequence : eventsequences ) {
for( auto &event : *( eventsequence.second ) ) {
for( auto &event : *eventsequence.second ) {
// NOTE: actual event name can be potentially different from its cached name, if it was renamed in the editor
// therefore on export we pull the name from the event itself, if the binding isn't broken
Output
@@ -2378,8 +2359,8 @@ TTrack::export_as_text_( std::ostream &Output ) const {
<< ' ';
}
}
if( ( SwitchExtension )
&& ( SwitchExtension->fVelocity != -1.0 ) ) {
if( SwitchExtension
&& SwitchExtension->fVelocity != -1.0 ) {
Output << "velocity " << SwitchExtension->fVelocity << ' ';
}
else {
@@ -2396,8 +2377,8 @@ TTrack::export_as_text_( std::ostream &Output ) const {
if( fVerticalRadius != 0.f ) {
Output << "vradius " << fVerticalRadius << ' ';
}
if( ( eType == tt_Switch )
&& ( SwitchExtension->m_material3 != null_handle ) ) {
if( eType == tt_Switch
&& SwitchExtension->m_material3 != null_handle) {
auto texturefile { GfxRenderer->Material( m_material2 )->GetName() };
if( texturefile.find( paths::textures ) == 0 ) {
// don't include 'textures/' in the path
@@ -2408,7 +2389,7 @@ TTrack::export_as_text_( std::ostream &Output ) const {
if( false == m_friction.first.empty() ) {
Output << "friction " << m_friction.first << ' ';
}
if( m_sleeper_enabled && ( false == m_sleeper_model_name.empty() ) ) {
if( m_sleeper_enabled && false == m_sleeper_model_name.empty() ) {
Output
<< "sleepermodel "
<< m_sleeper_frequency << ' '
@@ -2546,10 +2527,7 @@ TTrack::texture_length( material_handle const Material ) {
return fTexLength;
}
auto const texturelength { GfxRenderer->Material( Material )->GetSize().y };
return (
texturelength < 0.f ?
fTexLength :
texturelength );
return texturelength < 0.f ? fTexLength : texturelength;
}
void TTrack::MovedUp1(float const dh)
@@ -2561,17 +2539,17 @@ void TTrack::MovedUp1(float const dh)
// ustawienie prędkości z ograniczeniem do pierwotnej wartości (zapisanej w scenerii)
void TTrack::VelocitySet(float v) {
// TBD, TODO: add a variable to preserve potential speed limit set by the track configuration on basic track pieces
if( ( SwitchExtension )
&& ( SwitchExtension->fVelocity != -1 ) ) {
if( SwitchExtension
&& SwitchExtension->fVelocity != -1 ) {
// zwrotnica może mieć odgórne ograniczenie, nieprzeskakiwalne eventem
fVelocity =
min_speed<float>(
v,
( SwitchExtension->fVelocity > 0 ?
SwitchExtension->fVelocity > 0 ?
SwitchExtension->fVelocity : // positive limit applies to both switch tracks
( SwitchExtension->CurrentIndex == 0 ?
SwitchExtension->CurrentIndex == 0 ?
-1 : // negative limit applies only to the diverging track
-SwitchExtension->fVelocity ) ) );
-SwitchExtension->fVelocity );
}
else {
fVelocity = v; // nie ma ograniczenia
@@ -2580,7 +2558,7 @@ void TTrack::VelocitySet(float v) {
double TTrack::VelocityGet()
{ // pobranie dozwolonej prędkości podczas skanowania
return ((iDamageFlag & 128) ? 0.0 : fVelocity); // tor uszkodzony = prędkość zerowa
return iDamageFlag & 128 ? 0.0 : fVelocity; // tor uszkodzony = prędkość zerowa
};
float TTrack::Friction() const {
@@ -2616,14 +2594,8 @@ TTrack::DoubleSlip() const {
// crude way to discern part of double slip switch:
// a switch with name ending in _a or _b or _c or _d
return (
( iCategoryFlag == 1 )
&& ( eType == tt_Switch )
&& ( m_name.size() > 2 )
&& ( m_name.back() >= 'a' )
&& ( m_name.back() <= 'd' )
&& ( ( m_name[ m_name.size() - 2 ] == '_' )
|| ( m_name.rfind( '_' ) != std::string::npos ) ) );
return iCategoryFlag == 1 && eType == tt_Switch && m_name.size() > 2 && m_name.back() >= 'a' && m_name.back() <= 'd' &&
(m_name[m_name.size() - 2] == '_' || m_name.rfind('_') != std::string::npos);
}
@@ -2633,7 +2605,7 @@ TTrack * TTrack::Connected(int s, double &d) const
TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej
if (eType != tt_Cross)
{ // jeszcze trzeba sprawdzić zgodność
t = (s > 0) ? trNext : trPrev;
t = s > 0 ? trNext : trPrev;
if (t) // o ile jest na co przejść, zmieniamy znak kierunku na nowym torze
if (t->eType == tt_Cross)
{ // jeśli wjazd na skrzyżowanie, trzeba ustalić segment, bo od tego zależy zmiana
@@ -2644,33 +2616,33 @@ TTrack * TTrack::Connected(int s, double &d) const
}
else
{
if ((s > 0) ? iNextDirection : !iPrevDirection)
if (s > 0 ? iNextDirection : !iPrevDirection)
d = -d; // następuje zmiana kierunku wózka albo kierunku skanowania
// s=((s>0)?iNextDirection:iPrevDirection)?-1:1; //kierunek toru po zmianie
}
return (t); // zwrotnica ma odpowiednio ustawione (trNext)
return t; // zwrotnica ma odpowiednio ustawione (trNext)
}
switch ((SwitchExtension->iRoads == 4) ? iEnds4[s + 6] :
switch (SwitchExtension->iRoads == 4 ? iEnds4[s + 6] :
iEnds3[s + 6]) // numer końca 0..3, -1 to błąd
{ // zjazd ze skrzyżowania
case 0:
if (SwitchExtension->pPrevs[0])
if ((s > 0) == SwitchExtension->iPrevDirection[0])
if (s > 0 == SwitchExtension->iPrevDirection[0])
d = -d;
return SwitchExtension->pPrevs[0];
case 1:
if (SwitchExtension->pNexts[0])
if ((s > 0) == SwitchExtension->iNextDirection[0])
if (s > 0 == SwitchExtension->iNextDirection[0])
d = -d;
return SwitchExtension->pNexts[0];
case 2:
if (SwitchExtension->pPrevs[1])
if ((s > 0) == SwitchExtension->iPrevDirection[1])
if (s > 0 == SwitchExtension->iPrevDirection[1])
d = -d;
return SwitchExtension->pPrevs[1];
case 3:
if (SwitchExtension->pNexts[1])
if ((s > 0) == SwitchExtension->iNextDirection[1])
if (s > 0 == SwitchExtension->iNextDirection[1])
d = -d;
return SwitchExtension->pNexts[1];
}
@@ -2834,11 +2806,7 @@ TTrack::create_track_blade_profile( gfx::vertex_array &Right, gfx::vertex_array
void
TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previous, TTrack const *Next ) {
// geometry parameters
auto * profilesource = (
eType != tt_Switch ? this :
Previous && Previous->eType != tt_Switch ? Previous :
Next && Next->eType != tt_Switch ? Next :
this );
auto * profilesource = eType != tt_Switch ? this : Previous && Previous->eType != tt_Switch ? Previous : Next && Next->eType != tt_Switch ? Next : this;
auto const texheight1 { profilesource->fTexHeight1 };
auto const texwidth { profilesource->fTexWidth };
@@ -2861,10 +2829,10 @@ TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previ
glm::vec3 normal2;
float fHTW2, side2, slop2, rozp2, fTexHeight2, hypot2;
if( ( Next != nullptr )
&& ( Next->eType != tt_Switch )
&& ( ( iTrapezoid & 2 ) // ten bit oznacza, że istnieje odpowiednie pNext
|| ( eType == tt_Switch ) ) ) {
if( Next != nullptr
&& Next->eType != tt_Switch
&& ( iTrapezoid & 2 // ten bit oznacza, że istnieje odpowiednie pNext
|| eType == tt_Switch ) ) {
fHTW2 = 0.5f * std::abs(Next->fTrackWidth); // połowa rozstawu/nawierzchni
side2 = std::abs(Next->fTexWidth);
slop2 = std::abs(Next->fTexSlope); // nie jest używane później
@@ -2905,7 +2873,7 @@ TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previ
cos2 { std::cos( roll2 ) };
// profile
auto const transition { ( iTrapezoid != 0 ) || ( eType == tt_Switch ) };
auto const transition { iTrapezoid != 0 || eType == tt_Switch };
auto const pointcount { transition ? 10 : 5 };
Output.resize( pointcount );
// potentially retrieve texture length override from the assigned material
@@ -3081,7 +3049,7 @@ TTrack::create_road_profile( gfx::vertex_array &Output, bool const Forcetransiti
auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1
auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2
auto const transition { ( true == Forcetransition ) || ( iTrapezoid != 0 ) };
auto const transition { true == Forcetransition || iTrapezoid != 0 };
auto const pointcount{ transition ? 4 : 2 };
Output.resize( pointcount );
@@ -3156,7 +3124,7 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L
auto const texturelength{ texture_length( m_material2 ) };
auto const transition { ( true == Forcetransition ) || ( iTrapezoid != 0 ) };
auto const transition { true == Forcetransition || iTrapezoid != 0 };
auto const pointcount{ transition ? 6 : 3 };
Right.resize( pointcount );
@@ -3221,22 +3189,10 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L
// krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy
auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm
auto const max = fTexRatio2 * texturelength; // test: szerokość proporcjonalna do długości
auto const map1l = (
max > 0.f ?
side / max :
0.484375f ); // obcięcie tekstury od lewej strony punktu 1
auto const map1r = (
max > 0.f ?
slop / max :
0.484375f ); // obcięcie tekstury od prawej strony punktu 1
auto const h1r = (
slop > d ?
-fTexHeight1 :
0.f );
auto const h1l = (
side > d ?
-fTexHeight1 :
0.f );
auto const map1l = max > 0.f ? side / max : 0.484375f; // obcięcie tekstury od lewej strony punktu 1
auto const map1r = max > 0.f ? slop / max : 0.484375f; // obcięcie tekstury od prawej strony punktu 1
auto const h1r = slop > d ? -fTexHeight1 : 0.f;
auto const h1l = side > d ? -fTexHeight1 : 0.f;
Right[ 0 ] = {
{Road[ 0 ].position.x + slop, Road[ 0 ].position.y + h1r, 0.f},
@@ -3265,26 +3221,11 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L
if( transition ) {
// pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
slop2 = (
std::fabs( ( iTrapezoid & 2 ) ?
slop2 :
slop ) ); // szerokość chodnika po prawej
auto const map2l = (
max > 0.f ?
side2 / max :
0.484375f ); // obcięcie tekstury od lewej strony punktu 2
auto const map2r = (
max > 0.f ?
slop2 / max :
0.484375f ); // obcięcie tekstury od prawej strony punktu 2
auto const h2r = (
slop2 > d ?
-fTexHeight2 :
0.f );
auto const h2l = (
side2 > d ?
-fTexHeight2 :
0.f );
slop2 = std::fabs(iTrapezoid & 2 ? slop2 : slop); // szerokość chodnika po prawej
auto const map2l = max > 0.f ? side2 / max : 0.484375f; // obcięcie tekstury od lewej strony punktu 2
auto const map2r = max > 0.f ? slop2 / max : 0.484375f; // obcięcie tekstury od prawej strony punktu 2
auto const h2r = slop2 > d ? -fTexHeight2 : 0.f;
auto const h2l = side2 > d ? -fTexHeight2 : 0.f;
Right[ 3 ] = {
{Road[ 2 ].position.x + slop2, Road[ 2 ].position.y + h2r, 0.f},
@@ -3317,14 +3258,12 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L
void
TTrack::create_switch_trackbed( gfx::vertex_array &Output ) {
// try to get trackbed material from a regular track connected to the primary path
if( ( SwitchExtension->m_material3 == null_handle )
&& ( trPrev != nullptr )
&& ( trPrev->eType == tt_Normal ) ) {
if( SwitchExtension->m_material3 == null_handle && trPrev != nullptr
&& trPrev->eType == tt_Normal ) {
SwitchExtension->m_material3 = trPrev->m_material2;
}
if( ( SwitchExtension->m_material3 == null_handle )
&& ( trNext != nullptr )
&& ( trNext->eType == tt_Normal ) ) {
if( SwitchExtension->m_material3 == null_handle && trNext != nullptr
&& trNext->eType == tt_Normal ) {
SwitchExtension->m_material3 = trNext->m_material2;
}
// without material don't bother
@@ -3429,7 +3368,7 @@ TTrack::copy_adjacent_trackbed_material( TTrack const *Exclude ) {
}
for( auto *adjacent : adjacents ) {
if( ( adjacent != nullptr ) && ( adjacent != Exclude ) ) {
if( adjacent != nullptr && adjacent != Exclude ) {
material = adjacent->copy_adjacent_trackbed_material( this );
if( material != null_handle ) { break; } // got what we wanted
}
@@ -3574,8 +3513,8 @@ path_table::InitTracks() {
}
} // switch
if( ( trackname[ 0 ] == '*' )
&& ( !track->CurrentPrev() && track->CurrentNext() ) ) {
if( trackname[0] == '*'
&& !track->CurrentPrev() && track->CurrentNext() ) {
// możliwy portal, jeśli nie podłączony od strony 1
// ustawienie flagi portalu
track->iCategoryFlag |= 0x100;
@@ -3642,8 +3581,8 @@ void
path_table::TrackBusyList() const {
// wysłanie informacji o wszystkich zajętych odcinkach
for( auto const *path : m_items ) {
if( ( false == path->name().empty() ) // musi być nazwa
&& ( false == path->Dynamics.empty() ) ) {
if( false == path->name().empty() // musi być nazwa
&& false == path->Dynamics.empty() ) {
// zajęty
multiplayer::WyslijString( path->name(), 8 );
}
@@ -3753,7 +3692,7 @@ void TTrack::build_sleeper_transforms()
return;
}
// resolve replacable skin (optional)
if( ( false == m_sleeper_skin_name.empty() ) && ( m_sleeper_skin_name != "none" ) ) {
if( false == m_sleeper_skin_name.empty() && m_sleeper_skin_name != "none" ) {
auto skinpath { m_sleeper_skin_name };
replace_slashes( skinpath );
m_sleeper_skin = GfxRenderer->Fetch_Material( skinpath );

View File

@@ -115,15 +115,15 @@ public:
inline
bool
Busy() {
return (iAxles > 0); };
return iAxles > 0; };
inline
static TIsolated *
Root() {
return (pRoot); };
return pRoot; };
inline
TIsolated *
Next() {
return (pNext); };
return pNext; };
inline
void
parent( TIsolated *Parent ) {
@@ -270,19 +270,13 @@ public:
bool SwitchForced(int i, TDynamicObject *o);
int CrossSegment(int from, int into);
inline int GetSwitchState() {
return (
SwitchExtension ?
SwitchExtension->CurrentIndex :
-1); };
return SwitchExtension ? SwitchExtension->CurrentIndex : -1; };
// returns number of different routes possible to take from given point
// TODO: specify entry point, number of routes for switches can vary
inline
int
RouteCount() const {
return (
SwitchExtension != nullptr ?
SwitchExtension->iRoads - 1 :
1 ); }
return SwitchExtension != nullptr ? SwitchExtension->iRoads - 1 : 1; }
void Load(cParser *parser, glm::dvec3 const &pOrigin);
bool AssignEvents();
bool AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus);

View File

@@ -131,15 +131,12 @@ TTraction::Load( cParser *parser, glm::dvec3 const &pOrigin ) {
auto const minheight { parser->getToken<double>() };
fHeightDifference = ( pPoint3.y - pPoint1.y + pPoint4.y - pPoint2.y ) * 0.5 - minheight;
auto const segmentlength { parser->getToken<double>() };
iNumSections = (
segmentlength ?
glm::length( ( pPoint1 - pPoint2 ) ) / segmentlength :
0 );
iNumSections = segmentlength ? glm::length(pPoint1 - pPoint2) / segmentlength : 0;
parser->getTokens( 2 );
*parser
>> Wires
>> WireOffset;
m_visible = ( parser->getToken<std::string>() == "vis" );
m_visible = parser->getToken<std::string>() == "vis";
std::string token { parser->getToken<std::string>() };
if( token == "parallel" ) {
@@ -147,8 +144,8 @@ TTraction::Load( cParser *parser, glm::dvec3 const &pOrigin ) {
parser->getTokens();
*parser >> asParallel;
}
while( ( false == token.empty() )
&& ( token != "endtraction" ) ) {
while( false == token.empty()
&& token != "endtraction" ) {
token = parser->getToken<std::string>();
}
@@ -210,10 +207,10 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
pPoint3.z - m_origin.z );
for( int i = 0; i < iNumSections - 1; ++i ) {
pt3 = pPoint3 + v1 * f;
t = ( 1 - std::fabs( f - mid ) * 2 );
if( ( Wires < 4 )
|| ( ( i != 0 )
&& ( i != iNumSections - 2 ) ) ) {
t = 1 - std::fabs(f - mid) * 2;
if( Wires < 4
|| ( i != 0
&& i != iNumSections - 2 ) ) {
endvertex.position =
glm::vec3(
pt3.x - m_origin.x,
@@ -259,13 +256,12 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
pPoint3.z - m_origin.z );
for( int i = 0; i < iNumSections - 1; ++i ) {
pt3 = pPoint3 + v1 * f;
t = ( 1 - std::fabs( f - mid ) * 2 );
t = 1 - std::fabs(f - mid) * 2;
endvertex.position =
glm::vec3(
pt3.x - m_origin.x,
pt3.y - std::sqrt( t ) * fHeightDifference - (
( ( i == 0 )
|| ( i == iNumSections - 2 ) ) ?
i == 0 || i == iNumSections - 2 ?
0.25f * fHeightDifference :
0.05 )
- m_origin.y,
@@ -292,12 +288,12 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
for( int i = 0; i < iNumSections - 1; ++i ) {
pt3 = pPoint3 + v1 * f;
pt4 = pPoint1 + v2 * f;
t = ( 1 - std::fabs( f - mid ) * 2 );
if( ( i % 2 ) == 0 ) {
t = 1 - std::fabs(f - mid) * 2;
if( i % 2 == 0 ) {
startvertex.position =
glm::vec3(
pt3.x - m_origin.x,
pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - m_origin.y,
pt3.y - std::sqrt( t ) * fHeightDifference - ( i == 0 || i == iNumSections - 2 ? flo : flo1 ) - m_origin.y,
pt3.z - m_origin.z );
endvertex.position =
glm::vec3(
@@ -311,7 +307,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
startvertex.position =
glm::vec3(
pt3.x - m_origin.x,
pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - m_origin.y,
pt3.y - std::sqrt( t ) * fHeightDifference - ( i == 0 || i == iNumSections - 2 ? flo : flo1 ) - m_origin.y,
pt3.z - m_origin.z );
endvertex.position =
glm::vec3(
@@ -321,9 +317,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
vertices.emplace_back( startvertex );
vertices.emplace_back( endvertex );
}
if( ( ( Wires == 4 )
&& ( ( i == 1 )
|| ( i == iNumSections - 3 ) ) ) ) {
if( Wires == 4 && (i == 1 || i == iNumSections - 3) ) {
startvertex.position =
glm::vec3(
pt3.x - m_origin.x,
@@ -351,12 +345,12 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
int TTraction::TestPoint(glm::dvec3 const &Point)
{ // sprawdzanie, czy przęsła można połączyć
if( ( hvNext[ 0 ] == nullptr )
&& ( glm::all( glm::epsilonEqual( Point, pPoint1, 0.025 ) ) ) ) {
if( hvNext[0] == nullptr
&& glm::all(glm::epsilonEqual(Point, pPoint1, 0.025)) ) {
return 0;
}
if( ( hvNext[ 1 ] == nullptr )
&& ( glm::all( glm::epsilonEqual( Point, pPoint2, 0.025 ) ) ) ) {
if( hvNext[1] == nullptr
&& glm::all(glm::epsilonEqual(Point, pPoint2, 0.025)) ) {
return 1;
}
return -1;
@@ -369,8 +363,8 @@ TTraction::Connect(int my, TTraction *with, int to) {
hvNext[ my ] = with;
iNext[ my ] = to;
if( ( hvNext[ 0 ] != nullptr )
&& ( hvNext[ 1 ] != nullptr ) ) {
if( hvNext[0] != nullptr
&& hvNext[1] != nullptr ) {
// jeśli z obu stron podłączony to nie jest ostatnim
iLast = 0;
}
@@ -380,8 +374,8 @@ TTraction::Connect(int my, TTraction *with, int to) {
with->hvNext[ to ] = this;
with->iNext[ to ] = my;
if( ( with->hvNext[ 0 ] != nullptr )
&& ( with->hvNext[ 1 ] != nullptr ) ) {
if( with->hvNext[0] != nullptr
&& with->hvNext[1] != nullptr ) {
// temu też, bo drugi raz łączenie się nie nie wykona
with->iLast = 0;
}
@@ -392,7 +386,7 @@ bool TTraction::WhereIs() {
if( iLast ) {
// ma już ustaloną informację o położeniu
return ( iLast & 1 );
return iLast & 1;
}
for( int endindex = 0; endindex < 2; ++endindex ) {
if( hvNext[ endindex ] == nullptr ) {
@@ -404,7 +398,7 @@ bool TTraction::WhereIs() {
iLast |= 2;
}
}
return (iLast & 1); // ostatnie będą dostawać zasilanie
return iLast & 1; // ostatnie będą dostawać zasilanie
}
void TTraction::Init()
@@ -423,8 +417,8 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
ps = psPower[d ^ 1]; // zasilacz od przeciwnej strony niż idzie analiza
d = iNext[d]; // kierunek
PowerState = 4;
while( ( t != nullptr )
&& ( t->psPower[d] == nullptr ) ) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza
while( t != nullptr
&& t->psPower[d] == nullptr ) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza
{ // ustawienie zasilacza i policzenie rezystancji zastępczej
if( t->PowerState != 4 ) {
// przęsła zasilającego nie modyfikować
@@ -480,16 +474,10 @@ double TTraction::VoltageGet(double u, double i)
// 1. zasilacz psPower[0] z rezystancją fResistance[0] oraz jego wewnętrzną
// 2. zasilacz psPower[1] z rezystancją fResistance[1] oraz jego wewnętrzną
// 3. zasilacz psPowered z jego wewnętrzną rezystancją dla przęseł zasilanych bezpośrednio
double res = (
(i != 0.0) ?
(u / i) :
10000.0 );
double res = i != 0.0 ? u / i : 10000.0;
if( psPowered != nullptr ) {
// yB: dla zasilanego nie baw się w gwiazdy, tylko bierz bezpośrednio
return (
( res != 0.0 ) ?
psPowered->CurrentGet( res ) * res :
0.0 );
return res != 0.0 ? psPowered->CurrentGet(res) * res : 0.0;
}
if( ( psPower[0] && psPower[0]->Fuse() )
|| ( psPower[1] && psPower[1]->Fuse() ) ) {
@@ -506,10 +494,10 @@ double TTraction::VoltageGet(double u, double i)
// yB: Gdy wywali podstacja, to zaczyna się robić nieciekawie - napięcie w sekcji na jednym końcu jest równe zasilaniu,
// yB: a na drugim końcu jest równe 0. Kolejna sprawa to rozróżnienie uszynienia sieci na podstacji/odłączniku (czyli
// yB: potencjał masy na sieci) od braku zasilania (czyli odłączenie źródła od sieci i brak jego wpływu na napięcie).
if ((r0t > 0.0) && (r1t > 0.0))
if (r0t > 0.0 && r1t > 0.0)
{ // rezystancje w mianowniku nie mogą być zerowe
r0g = res + r0t + (res * r0t) / r1t; // przeliczenie z trójkąta na gwiazdę
r1g = res + r1t + (res * r1t) / r0t;
r0g = res + r0t + res * r0t / r1t; // przeliczenie z trójkąta na gwiazdę
r1g = res + r1t + res * r1t / r0t;
// pobierane są prądy dla każdej rezystancji, a suma jest mnożona przez rezystancję
// pojazdu w celu uzyskania napięcia
i0 = psPower[0]->CurrentGet(r0g); // oddzielnie dla sprawdzenia
@@ -523,11 +511,11 @@ double TTraction::VoltageGet(double u, double i)
else
return 0.0; // co z tym zrobić?
}
else if (psPower[0] && (r0t >= 0.0))
else if (psPower[0] && r0t >= 0.0)
{ // jeśli odcinek podłączony jest tylko z jednej strony
return psPower[0]->CurrentGet(res + r0t) * res;
}
else if (psPower[1] && (r1t >= 0.0))
else if (psPower[1] && r1t >= 0.0)
return psPower[1]->CurrentGet(res + r1t) * res;
return 0.0; // gdy nie podłączony wcale?
};
@@ -596,10 +584,7 @@ TTraction::wire_color() const {
}
case 4: {
// white for powered, red for ends
color = (
psPowered != nullptr ?
glm::vec3{ 239.f / 255.f, 239.f / 255.f, 239.f / 255.f } :
glm::vec3{ 239.f / 255.f, 128.f / 255.f, 128.f / 255.f } );
color = psPowered != nullptr ? glm::vec3{239.f / 255.f, 239.f / 255.f, 239.f / 255.f} : glm::vec3{239.f / 255.f, 128.f / 255.f, 128.f / 255.f};
break;
}
default: { break; }
@@ -709,8 +694,8 @@ traction_table::InitTraction() {
traction->PowerSet( powersource );
}
else {
if( ( traction->asPowerSupplyName != "*" ) // gwiazdka dla przęsła z izolatorem
&& ( traction->asPowerSupplyName != "none" ) ) { // dopuszczamy na razie brak podłączenia?
if( traction->asPowerSupplyName != "*" // gwiazdka dla przęsła z izolatorem
&& traction->asPowerSupplyName != "none" ) { // dopuszczamy na razie brak podłączenia?
// logowanie błędu i utworzenie zasilacza o domyślnej zawartości
ErrorLog( "Bad scenario: traction piece connected to nonexistent power source \"" + traction->asPowerSupplyName + "\"" );
scene::node_data nodedata;
@@ -746,19 +731,19 @@ traction_table::InitTraction() {
}
if( traction->hvNext[ 0 ] ) {
// jeśli został podłączony
if( ( traction->psSection != nullptr )
&& ( matchingtraction->psSection != nullptr ) ) {
if( traction->psSection != nullptr
&& matchingtraction->psSection != nullptr ) {
// tylko przęsło z izolatorem może nie mieć zasilania, bo ma 2, trzeba sprawdzać sąsiednie
if( traction->psSection != matchingtraction->psSection ) {
// połączone odcinki mają różne zasilacze
// to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo błąd
if( ( true == traction->psSection->bSection )
&& ( false == matchingtraction->psSection->bSection ) ) {
if( true == traction->psSection->bSection
&& false == matchingtraction->psSection->bSection ) {
//(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji
matchingtraction->PowerSet( traction->psSection ); // zastąpienie wskazaniem sekcji
}
else if( ( false == traction->psSection->bSection )
&& ( true == matchingtraction->psSection->bSection ) ) {
else if( false == traction->psSection->bSection
&& true == matchingtraction->psSection->bSection ) {
//(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji
traction->PowerSet( matchingtraction->psSection ); // zastąpienie wskazaniem sekcji
}
@@ -785,18 +770,18 @@ traction_table::InitTraction() {
}
if( traction->hvNext[ 1 ] ) {
// jeśli został podłączony
if( ( traction->psSection != nullptr )
&& ( matchingtraction->psSection != nullptr ) ) {
if( traction->psSection != nullptr
&& matchingtraction->psSection != nullptr ) {
// tylko przęsło z izolatorem może nie mieć zasilania, bo ma 2, trzeba sprawdzać sąsiednie
if( traction->psSection != matchingtraction->psSection ) {
// to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo błąd
if( ( true == traction->psSection->bSection )
&& ( false == matchingtraction->psSection->bSection ) ) {
if( true == traction->psSection->bSection
&& false == matchingtraction->psSection->bSection ) {
//(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji
matchingtraction->PowerSet( traction->psSection ); // zastąpienie wskazaniem sekcji
}
else if( ( false == traction->psSection->bSection )
&& ( true == matchingtraction->psSection->bSection ) ) {
else if( false == traction->psSection->bSection
&& true == matchingtraction->psSection->bSection ) {
//(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji
traction->PowerSet( matchingtraction->psSection ); // zastąpienie wskazaniem sekcji
}
@@ -830,8 +815,8 @@ traction_table::InitTraction() {
//łączenie bieżni wspólnych, w tym oznaczanie niepodanych jawnie
if( false == traction->asParallel.empty() ) {
// będzie wskaźnik na inne przęsło
if( ( traction->asParallel == "none" )
|| ( traction->asParallel == "*" ) ) {
if( traction->asParallel == "none"
|| traction->asParallel == "*" ) {
// jeśli nieokreślone
traction->iLast |= 2; // jakby przedostatni - niech po prostu szuka (iLast już przeliczone)
}

View File

@@ -56,8 +56,8 @@ bool TTractionPowerSource::Load(cParser *parser) {
bSection = true;
}
// skip rest of the section
while( ( false == token.empty() )
&& ( token != "end" ) ) {
while( false == token.empty()
&& token != "end" ) {
token = parser->getToken<std::string>();
}
@@ -123,10 +123,10 @@ double TTractionPowerSource::CurrentGet(double res)
FuseTimer = 0;
return 0;
}
if ((res > 0) || ((res < 0) && (Recuperation || true)))
if (res > 0 || (res < 0 && (Recuperation || true)))
TotalAdmitance += 1.0 / res; // połączenie równoległe rezystancji jest równoważne sumie admitancji
float NomVolt = (TotalPreviousAdmitance < 0 ? NominalVoltage * 1.083 : NominalVoltage);
TotalCurrent = (TotalPreviousAdmitance != 0.0) ?
float NomVolt = TotalPreviousAdmitance < 0 ? NominalVoltage * 1.083 : NominalVoltage;
TotalCurrent = TotalPreviousAdmitance != 0.0 ?
NomVolt / (InternalRes + 1.0 / TotalPreviousAdmitance) :
0.0; // napięcie dzielone przez sumę rezystancji wewnętrznej i obciążenia
OutputVoltage = NomVolt - InternalRes * TotalCurrent; // napięcie na obciążeniu

View File

@@ -29,7 +29,7 @@ public:
NominalVoltage = v; };
void PowerSet(TTractionPowerSource *ps);
bool Fuse() const {
return ( FastFuse || SlowFuse ); }
return FastFuse || SlowFuse; }
// members
TTractionPowerSource *psNode[ 2 ] = { nullptr, nullptr }; // zasilanie na końcach dla sekcji
bool bSection = false; // czy jest sekcją

View File

@@ -33,7 +33,7 @@ bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir)
SetCurrentTrack(pTrack, 0);
iEventFlag = 3; // na torze startowym również wykonać eventy 1/2
iEventallFlag = 3;
if ((pCurrentSegment)) // && (pCurrentSegment->GetLength()<fFirstDistance))
if (pCurrentSegment) // && (pCurrentSegment->GetLength()<fFirstDistance))
return false;
return true;
}
@@ -51,7 +51,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
{
case tt_Switch: // jeśli zwrotnica, to przekładamy ją, aby uzyskać dobry segment
{
int i = (end ? pCurrentTrack->iNextDirection : pCurrentTrack->iPrevDirection);
int i = end ? pCurrentTrack->iNextDirection : pCurrentTrack->iPrevDirection;
if (i > 0) // jeżeli wjazd z ostrza
pTrack->SwitchForced(i >> 1, Owner); // to przełożenie zwrotnicy - rozprucie!
}
@@ -91,7 +91,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
pCurrentTrack->AxleCounter(-1, Owner); // opuszczenie tamtego toru
}
pCurrentTrack = pTrack;
pCurrentSegment = ( pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr );
pCurrentSegment = pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr;
if (!pCurrentTrack)
Error(Owner->MoverParameters->Name + " at NULL track");
return pCurrentTrack;
@@ -121,19 +121,19 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( false == ismoving ) {
//McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi
if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->primary() ) ) {
if( Owner->Mechanik != nullptr
&& Owner->Mechanik->primary() ) {
// tylko dla jednego członu
pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner );
}
pCurrentTrack->QueueEvents( pCurrentTrack->m_events0all, Owner );
}
else if( (fDistance < 0) && ( eventfilter < 0 ) ) {
else if( fDistance < 0 && eventfilter < 0 ) {
// event1, eventall1
if( SetFlag( iEventFlag, -1 ) ) {
// zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona
if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->primary() ) ) {
if( Owner->Mechanik != nullptr
&& Owner->Mechanik->primary() ) {
// tylko dla jednego członu
// McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner );
@@ -144,12 +144,12 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner );
}
}
else if( ( fDistance > 0 ) && ( eventfilter > 0 ) ) {
else if( fDistance > 0 && eventfilter > 0 ) {
// event2, eventall2
if( SetFlag( iEventFlag, -2 ) ) {
// zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona
if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->primary() ) ) {
if( Owner->Mechanik != nullptr
&& Owner->Mechanik->primary() ) {
// tylko dla jednego członu
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner );
}
@@ -181,7 +181,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
*/
if (s < 0)
{ // jeśli przekroczenie toru od strony Point1
bCanSkip = ( bPrimary && pCurrentTrack->CheckDynamicObject( Owner ) );
bCanSkip = bPrimary && pCurrentTrack->CheckDynamicObject(Owner);
if( bCanSkip ) {
// tylko główna oś przenosi pojazd do innego toru
// zdejmujemy pojazd z dotychczasowego toru
@@ -217,7 +217,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
}
else if (s > pCurrentSegment->GetLength())
{ // jeśli przekroczenie toru od strony Point2
bCanSkip = ( bPrimary && pCurrentTrack->CheckDynamicObject( Owner ) );
bCanSkip = bPrimary && pCurrentTrack->CheckDynamicObject(Owner);
if (bCanSkip) // tylko główna oś przenosi pojazd do innego toru
Owner->MyTrack->RemoveDynamicObject(Owner); // zdejmujemy pojazd z dotychczasowego toru
fDistance = s - pCurrentSegment->GetLength();
@@ -274,7 +274,7 @@ bool TTrackFollower::ComputatePosition()
vAngles.x = -vAngles.x; // przechyłka jest w przecinwą stronę
vAngles.y = -vAngles.y; // pochylenie jest w przecinwą stronę
vAngles.z +=
(vAngles.z >= M_PI) ? -M_PI : M_PI; // ale kierunek w planie jest obrócony o 180°
vAngles.z >= M_PI ? -M_PI : M_PI; // ale kierunek w planie jest obrócony o 180°
}
if (fOffsetH != 0.0)
{ // jeśli przesunięcie względem osi toru, to je doliczyć

View File

@@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/.
double TTrainParameters::CheckTrainLatency()
{
if ((LastStationLatency > 1.0) || (LastStationLatency < 0))
if (LastStationLatency > 1.0 || LastStationLatency < 0)
return LastStationLatency; /*spoznienie + lub do przodu - z tolerancja 1 min*/
else
return 0;
@@ -66,7 +66,7 @@ TTrainParameters::last_stop_sound() const {
bool TTrainParameters::IsStop() const
{ // zapytanie, czy zatrzymywać na następnym punkcie rozkładu
if ((StationIndex <= StationCount))
if (StationIndex <= StationCount)
return TimeTable[StationIndex].Ah >= 0; //-1 to brak postoju
else
return true; // na ostatnim się zatrzymać zawsze
@@ -74,19 +74,19 @@ bool TTrainParameters::IsStop() const
bool TTrainParameters::IsLastStop() const {
return ( StationIndex >= StationCount );
return StationIndex >= StationCount;
}
bool TTrainParameters::IsMaintenance() const {
if( ( StationIndex <= StationCount ) )
if( StationIndex <= StationCount )
return TimeTable[ StationIndex ].is_maintenance;
else
return false;
}
int TTrainParameters::radio_channel() const {
if( ( StationIndex <= StationCount ) )
if( StationIndex <= StationCount )
return TimeTable[ StationIndex ].radio_channel;
else
return -1;
@@ -94,7 +94,7 @@ int TTrainParameters::radio_channel() const {
// returns: sound file associated with current station, or -1
sound_source TTrainParameters::current_stop_sound() const {
if( ( StationIndex <= StationCount ) )
if( StationIndex <= StationCount )
return TimeTable[ StationIndex ].name_sound;
else
return { sound_placement::engine };
@@ -167,11 +167,11 @@ bool TTrainParameters::IsTimeToGo(double hh, double mm)
// sprawdzenie, czy można już odjechać z aktualnego zatrzymania
// StationIndex to numer następnego po dodarciu do aktualnego
{
if ((StationIndex < 1))
if (StationIndex < 1)
return true; // przed pierwszą jechać
else if ((StationIndex < StationCount))
else if (StationIndex < StationCount)
{ // oprócz ostatniego przystanku
if ((TimeTable[StationIndex].Ah < 0)) // odjazd z poprzedniego
if (TimeTable[StationIndex].Ah < 0) // odjazd z poprzedniego
return true; // czas przyjazdu nie był podany - przelot
else
return CompareTime(hh, mm, TimeTable[StationIndex].Dh, TimeTable[StationIndex].Dm) <= 0;
@@ -183,17 +183,17 @@ bool TTrainParameters::IsTimeToGo(double hh, double mm)
// returns: difference between specified time and scheduled departure from current stop, in seconds
double TTrainParameters::seconds_until_departure( double const Hour, double const Minute ) const {
if( ( TimeTable[ StationStart ].Ah < 0 ) ) { // passthrough
if( TimeTable[StationStart].Ah < 0 ) { // passthrough
return 0;
}
return ( 60.0 * CompareTime( Hour, Minute, TimeTable[ StationStart ].Dh, TimeTable[ StationStart ].Dm ) );
return 60.0 * CompareTime(Hour, Minute, TimeTable[StationStart].Dh, TimeTable[StationStart].Dm);
}
std::string TTrainParameters::ShowRelation() const
/*zwraca informację o relacji*/
{
// if (Relation1=TimeTable[1].StationName) and (Relation2=TimeTable[StationCount].StationName)
if ((Relation1 != "") && (Relation2 != ""))
if (Relation1 != "" && Relation2 != "")
return Relation1 + " - " + Relation2;
else
return "";
@@ -233,7 +233,7 @@ void TTrainParameters::UpdateVelocity(int StationCount, double vActual)
{
int i = StationCount;
// TTVmax:=vActual; {PROWIZORKA!!!}
while ((i >= 0) && (TimeTable[i].vmax == -1))
while (i >= 0 && TimeTable[i].vmax == -1)
{
TimeTable[i].vmax = vActual; // prędkość dojazdu do przystanku i
--i; // ewentualnie do poprzedniego też
@@ -256,7 +256,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
int ConversionError = 0;
EndTable = false;
if ((TrainName == ""))
if (TrainName == "")
{ // jeśli pusty rozkład
// UpdateVelocity(StationCount,vMax); //ograniczenie do prędkości startowej
}
@@ -274,7 +274,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
if (!fin.is_open())
{ // jeśli nie ma pliku
vmax = atoi(TrainName.c_str()); // nie ma pliku ale jest liczba
if ((vmax > 10) && (vmax < 200))
if (vmax > 10 && vmax < 200)
{
TTVmax = vmax; // Ra 2014-07: zamiast rozkładu można podać Vmax
UpdateVelocity(StationCount, vmax); // ograniczenie do prędkości startowej
@@ -286,7 +286,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
else
{ /*analiza rozkładu jazdy*/
ConversionError = 0;
while (fin.good() && !((ConversionError != 0) || EndTable))
while (fin.good() && !(ConversionError != 0 || EndTable))
{
std::getline(fin, lines); /*wczytanie linii*/
if (contains( lines, "___________________") ) /*linia pozioma górna*/
@@ -299,7 +299,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!(s == "|") || (fin.eof())); /*środkowy pion*/
} while (!(s == "|") || fin.eof()); /*środkowy pion*/
}
}
else if (lines == "")
@@ -323,7 +323,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s == "|") || (fin.bad())));
} while (!(s == "|" || fin.bad()));
fin >> TrainCategory;
continue;
}
@@ -332,7 +332,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s == "|") || (fin.bad())));
} while (!(s == "|" || fin.bad()));
fin >> TrainLabel;
continue;
}
@@ -375,7 +375,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
} // while (!();
while (fin >> s || !fin.bad())
{
if ((s == "|") || (s == "\n"))
if (s == "|" || s == "\n")
break;
} // while (!());
fin >> s;
@@ -389,7 +389,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s == "|") || (fin.bad())));
} while (!(s == "|" || fin.bad()));
fin >> LocSeries;
fin >> LocLoad; // = s2rE(ReadWord(fin));
do
@@ -403,7 +403,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s == "[") || (fin.bad())));
} while (!(s == "[" || fin.bad()));
TMTableLine *record = &TimeTable[StationCount];
{
if (s == "[")
@@ -431,7 +431,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s == "1") || (s == "2") || fin.bad()));
} while (!(s == "1" || s == "2" || fin.bad()));
record->TrackNo = atoi(s.c_str());
fin >> s;
if (s != "|")
@@ -450,13 +450,13 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s != "|") || (fin.bad())));
} while (!(s != "|" || fin.bad()));
if (s != "]")
record->tm = atof(s.c_str());
do
{
fin >> s;
} while (!((s == "[") || fin.bad()));
} while (!(s == "[" || fin.bad()));
fin >> s;
if (false == contains(s,"|"))
{
@@ -476,14 +476,14 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
fin >> s;
// stationware. added fix for empty entry
fin >> s;
while( false == ( ( s == "1" )
|| ( s == "2" )
while( false == ( s == "1"
|| s == "2"
|| fin.bad() ) ) {
record->StationWare += s;
fin >> s;
}
// cache relevant station data
record->is_maintenance = ( contains( s, "pt" ) );
record->is_maintenance = contains(s, "pt");
{
auto const stationware { Split( record->StationWare, ',' ) };
for( auto const &entry : stationware ) {
@@ -491,11 +491,11 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
continue;
}
auto const entrysplit { split_string_and_number( entry ) };
if( ( entrysplit.first == "R" )
&& ( entrysplit.second <= 10 ) ) {
if( entrysplit.first == "R"
&& entrysplit.second <= 10 ) {
auto const radiochannel { entrysplit.second };
if( ( record->radio_channel == -1 )
|| ( radiochannel != activeradiochannel ) ) {
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
@@ -530,7 +530,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
do
{
fin >> s;
} while (!((s != "|") || (fin.bad())));
} while (!(s != "|" || fin.bad()));
if (s != "]")
record->tm = atof(s.c_str());
do
@@ -554,7 +554,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
}
while (false == contains( s, "|" ) )
fin >> s;
while ((false == contains( s,"]") ))
while (false == contains(s, "]"))
fin >> s;
if (contains( s,"_|_") )
EndTable = true;
@@ -567,8 +567,8 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
}
if (ConversionError == 0)
{
if ((TimeTable[1].StationName == Relation1)) // jeśli nazwa pierwszego zgodna z relacją
if ((TimeTable[1].Ah < 0)) // a nie podany czas przyjazdu
if (TimeTable[1].StationName == Relation1) // jeśli nazwa pierwszego zgodna z relacją
if (TimeTable[1].Ah < 0) // a nie podany czas przyjazdu
{ // to mamy zatrzymanie na pierwszym, a nie przelot
TimeTable[1].Ah = TimeTable[1].Dh;
TimeTable[1].Am = TimeTable[1].Dm;
@@ -584,17 +584,17 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
float adjustedtime; // do zwiększania czasu
for (auto i = 1; i < i_end; ++i) // bez with, bo ciężko się przenosi na C++
{
if ((TimeTable[i].Ah >= 0))
if (TimeTable[i].Ah >= 0)
{
adjustedtime = clamp_circular<float>( TimeTable[i].Ah * 60 + TimeTable[i].Am + timeoffset, 24 * 60 ); // nowe minuty
TimeTable[i].Am = (int(60 * adjustedtime) % 3600) / 60.f;
TimeTable[i].Ah = int((adjustedtime) / 60) % 24;
TimeTable[i].Am = int(60 * adjustedtime) % 3600 / 60.f;
TimeTable[i].Ah = int(adjustedtime / 60) % 24;
}
if ((TimeTable[i].Dh >= 0))
if (TimeTable[i].Dh >= 0)
{
adjustedtime = clamp_circular<float>( TimeTable[i].Dh * 60 + TimeTable[i].Dm + timeoffset, 24 * 60 ); // nowe minuty
TimeTable[i].Dm = (int(60 * adjustedtime) % 3600) / 60.f;
TimeTable[i].Dh = int((adjustedtime) / 60) % 24;
TimeTable[i].Dm = int(60 * adjustedtime) % 3600 / 60.f;
TimeTable[i].Dh = int(adjustedtime / 60) % 24;
}
}
}
@@ -632,7 +632,7 @@ TTrainParameters::load_sounds() {
bool TTrainParameters::DirectionChange()
// sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy
{
if ((StationIndex > 0) && (StationIndex < StationCount)) // dla ostatniej stacji nie
if (StationIndex > 0 && StationIndex < StationCount) // dla ostatniej stacji nie
if (contains( TimeTable[StationIndex].StationWare, '@') )
return true;
return false;
@@ -657,15 +657,15 @@ void TTrainParameters::serialize( dictionary_source *Output ) const {
for( auto stationidx = 1; stationidx <= StationCount; ++stationidx ) {
auto const stationlabel { "train_station" + std::to_string( stationidx ) + "_" };
auto const &timetableline { TimeTable[ stationidx ] };
Output->insert( ( stationlabel + "name" ), Bezogonkow( timetableline.StationName ) );
Output->insert( ( stationlabel + "fclt" ), Bezogonkow( timetableline.StationWare ) );
Output->insert( ( stationlabel + "lctn" ), timetableline.km );
Output->insert( ( stationlabel + "vmax" ), timetableline.vmax );
Output->insert( ( stationlabel + "ah" ), timetableline.Ah );
Output->insert( ( stationlabel + "am" ), timetableline.Am );
Output->insert( ( stationlabel + "dh" ), timetableline.Dh );
Output->insert( ( stationlabel + "dm" ), timetableline.Dm );
Output->insert( ( stationlabel + "tracks" ), timetableline.TrackNo );
Output->insert( stationlabel + "name", Bezogonkow( timetableline.StationName ) );
Output->insert( stationlabel + "fclt", Bezogonkow( timetableline.StationWare ) );
Output->insert( stationlabel + "lctn", timetableline.km );
Output->insert( stationlabel + "vmax", timetableline.vmax );
Output->insert( stationlabel + "ah", timetableline.Ah );
Output->insert( stationlabel + "am", timetableline.Am );
Output->insert( stationlabel + "dh", timetableline.Dh );
Output->insert( stationlabel + "dm", timetableline.Dm );
Output->insert( stationlabel + "tracks", timetableline.TrackNo );
}
}
}

View File

@@ -74,7 +74,7 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch
loadcount *= 2;
}
if( ( unloadcount > 0 ) || ( loadcount > 0 ) ) {
if( unloadcount > 0 || loadcount > 0 ) {
vehicle->LoadExchange( unloadcount, loadcount, Platform );
exchangetime = std::max( exchangetime, vehicle->LoadExchangeTime() );