16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 15:09:19 +02:00

support for binding multiple events to path pieces

This commit is contained in:
tmj-fstate
2018-06-13 21:42:22 +02:00
parent c2f0df9a0b
commit 0fe653cab9
6 changed files with 195 additions and 278 deletions

View File

@@ -418,15 +418,17 @@ void TController::TableClear()
eSignSkip = nullptr; // nic nie pomijamy eSignSkip = nullptr; // nic nie pomijamy
}; };
TEvent * TController::CheckTrackEvent( TTrack *Track, double const fDirection ) const std::vector<TEvent *> TController::CheckTrackEvent( TTrack *Track, double const fDirection ) const
{ // sprawdzanie eventów na podanym torze do podstawowego skanowania { // sprawdzanie eventów na podanym torze do podstawowego skanowania
TEvent *e = (fDirection > 0) ? Track->evEvent2 : Track->evEvent1; std::vector<TEvent *> events;
if (!e) auto const &eventsequence { ( fDirection > 0 ? Track->m_events2 : Track->m_events1 ) };
return NULL; for( auto const &event : eventsequence ) {
if (e->bEnabled) if( ( event.second != nullptr )
return NULL; && ( false == event.second->bEnabled ) ) {
// jednak wszystkie W4 do tabelki, bo jej czyszczenie na przystanku wprowadza zamieszanie events.emplace_back( event.second );
return e; }
}
return events;
} }
bool TController::TableAddNew() bool TController::TableAddNew()
@@ -462,7 +464,6 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
TTrack *pTrack{ nullptr }; // zaczynamy od ostatniego analizowanego toru TTrack *pTrack{ nullptr }; // zaczynamy od ostatniego analizowanego toru
double fTrackLength{ 0.0 }; // długość aktualnego toru (krótsza dla pierwszego) double fTrackLength{ 0.0 }; // długość aktualnego toru (krótsza dla pierwszego)
double fCurrentDistance{ 0.0 }; // aktualna przeskanowana długość double fCurrentDistance{ 0.0 }; // aktualna przeskanowana długość
TEvent *pEvent{ nullptr };
double fLastDir{ 0.0 }; double fLastDir{ 0.0 };
if (iTableDirection != iDirection ) { if (iTableDirection != iDirection ) {
@@ -538,7 +539,9 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
WriteLog( "Speed table for " + OwnerName() + " tracing through track " + pTrack->name() ); WriteLog( "Speed table for " + OwnerName() + " tracing through track " + pTrack->name() );
} }
if( ( pEvent = CheckTrackEvent( pTrack, fLastDir ) ) != nullptr ) // jeśli jest semafor na tym torze auto const events { CheckTrackEvent( pTrack, fLastDir ) };
for( auto *pEvent : events ) {
if( pEvent != nullptr ) // jeśli jest semafor na tym torze
{ // trzeba sprawdzić tabelkę, bo dodawanie drugi raz tego samego przystanku nie jest korzystne { // trzeba sprawdzić tabelkę, bo dodawanie drugi raz tego samego przystanku nie jest korzystne
if (TableNotFound(pEvent)) // jeśli nie ma if (TableNotFound(pEvent)) // jeśli nie ma
{ {
@@ -571,8 +574,8 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
} }
} }
else { else {
if ((true == newspeedpoint.IsProperSemaphor(OrderCurrentGet())) if( ( true == newspeedpoint.IsProperSemaphor( OrderCurrentGet() ) )
&& (SemNextIndex == -1)) { && ( SemNextIndex == -1 ) ) {
SemNextIndex = iLast; // sprawdzamy czy pierwszy na drodze SemNextIndex = iLast; // sprawdzamy czy pierwszy na drodze
} }
if (Global.iWriteLogEnabled & 8) { if (Global.iWriteLogEnabled & 8) {
@@ -582,6 +585,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
} }
} }
} }
}
} // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po odczytaniu prędkości następnego } // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po odczytaniu prędkości następnego
if( ( pTrack->VelocityGet() == 0.0 ) // zatrzymanie if( ( pTrack->VelocityGet() == 0.0 ) // zatrzymanie
@@ -5563,12 +5567,17 @@ bool TController::BackwardTrackBusy(TTrack *Track)
TEvent * TController::CheckTrackEventBackward(double fDirection, TTrack *Track) TEvent * TController::CheckTrackEventBackward(double fDirection, TTrack *Track)
{ // sprawdzanie eventu w torze, czy jest sygnałowym - skanowanie do tyłu { // sprawdzanie eventu w torze, czy jest sygnałowym - skanowanie do tyłu
TEvent *e = (fDirection > 0) ? Track->evEvent2 : Track->evEvent1; // NOTE: this method returns only one event which meets the conditions, due to limitations in the caller
if (e) // TBD, TODO: clean up the caller and return all suitable events, as in theory things will go awry if the track has more than one signal
if (!e->bEnabled) // jeśli sygnałowy (nie dodawany do kolejki) auto const &eventsequence { ( fDirection > 0 ? Track->m_events2 : Track->m_events1 ) };
if (e->Type == tp_GetValues) // PutValues nie może się zmienić for( auto const &event : eventsequence ) {
return e; if( ( event.second != nullptr )
return NULL; && ( false == event.second->bEnabled )
&& ( event.second->Type == tp_GetValues ) ) {
return event.second;
}
}
return nullptr;
}; };
TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, TEvent *&Event) TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, TEvent *&Event)

View File

@@ -349,7 +349,7 @@ private:
int OrderDirectionChange(int newdir, TMoverParameters *Vehicle); int OrderDirectionChange(int newdir, TMoverParameters *Vehicle);
void Lights(int head, int rear); void Lights(int head, int rear);
// Ra: metody obsługujące skanowanie toru // Ra: metody obsługujące skanowanie toru
TEvent *CheckTrackEvent(TTrack *Track, double const fDirection ) const; std::vector<TEvent *> CheckTrackEvent(TTrack *Track, double const fDirection ) const;
bool TableAddNew(); bool TableAddNew();
bool TableNotFound(TEvent const *Event) const; bool TableNotFound(TEvent const *Event) const;
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = nullptr); void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = nullptr);

226
Track.cpp
View File

@@ -763,37 +763,37 @@ void TTrack::Load(cParser *parser, Math3D::vector3 pOrigin)
{ {
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
asEvent0Name = token; m_events0.emplace_back( token, nullptr );
} }
else if (str == "event1") else if (str == "event1")
{ {
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
asEvent1Name = token; m_events1.emplace_back( token, nullptr );
} }
else if (str == "event2") else if (str == "event2")
{ {
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
asEvent2Name = token; m_events2.emplace_back( token, nullptr );
} }
else if (str == "eventall0") else if (str == "eventall0")
{ {
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
asEventall0Name = token; m_events0all.emplace_back( token, nullptr );
} }
else if (str == "eventall1") else if (str == "eventall1")
{ {
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
asEventall1Name = token; m_events1all.emplace_back( token, nullptr );
} }
else if (str == "eventall2") else if (str == "eventall2")
{ {
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
asEventall2Name = token; m_events2all.emplace_back( token, nullptr );
} }
else if (str == "velocity") else if (str == "velocity")
{ {
@@ -869,153 +869,44 @@ void TTrack::Load(cParser *parser, Math3D::vector3 pOrigin)
/ 3.0 } ); / 3.0 } );
} }
// TODO: refactor this mess bool TTrack::AssignEvents() {
bool TTrack::AssignEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2, bool const Explicit )
{
bool bError = false;
if( NewEvent0 == nullptr ) { bool lookupfail { false };
if( false == asEvent0Name.empty() ) {
bError = true; std::vector< std::pair< std::string, event_sequence * > > const eventsequences {
if( true == Explicit ) { { "event0", &m_events0 }, { "eventall0", &m_events0all },
ErrorLog( "Bad event: event \"" + asEvent0Name + "\" assigned to track \"" + m_name + "\" does not exist" ); { "event1", &m_events1 }, { "eventall1", &m_events1all },
} { "event2", &m_events2 }, { "eventall2", &m_events2all } };
}
for( auto &eventsequence : eventsequences ) {
for( auto &event : *( eventsequence.second ) ) {
event.second = simulation::Events.FindEvent( event.first );
if( event.second != nullptr ) {
m_events = true;
} }
else { else {
if( evEvent0 == nullptr ) { ErrorLog( "Bad event: event \"" + event.first + "\" assigned to track \"" + m_name + "\" does not exist" );
evEvent0 = NewEvent0; lookupfail = true;
/*
// preserve event names, we'll need them if we want the scenario export to be unaffected by missing events and such
asEvent0Name = "";
*/
iEvents |= 1; // sumaryczna informacja o eventach
} }
else {
ErrorLog( "Bad track: event \"" + NewEvent0->asName + "\" cannot be assigned to track, track already has one" );
bError = true;
} }
} }
if( NewEvent1 == nullptr ) { auto const trackname { name() };
if( false == asEvent1Name.empty() ) {
bError = true; if( ( Global.iHiddenEvents & 1 )
if( true == Explicit ) { && ( false == trackname.empty() ) ) {
ErrorLog( "Bad event: event \"" + asEvent1Name + "\" assigned to track \"" + m_name + "\" does not exist" ); // 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 );
if( event != nullptr ) {
// HACK: auto-associated events come with empty lookup string, to avoid including them in the text format export
eventsequence.second->emplace_back( "", event );
m_events = true;
} }
} }
} }
else {
if( evEvent1 == nullptr ) {
evEvent1 = NewEvent1;
/*
asEvent1Name = "";
*/
iEvents |= 2; // sumaryczna informacja o eventach
}
else {
ErrorLog( "Bad track: event \"" + NewEvent1->asName + "\" cannot be assigned to track, track already has one" );
bError = true;
}
}
if( NewEvent2 == nullptr ) { return ( lookupfail == false );
if( false == asEvent2Name.empty() ) {
bError = true;
if( true == Explicit ) {
ErrorLog( "Bad event: event \"" + asEvent2Name + "\" assigned to track \"" + m_name + "\" does not exist" );
}
}
}
else {
if( evEvent2 == nullptr ) {
evEvent2 = NewEvent2;
/*
asEvent2Name = "";
*/
iEvents |= 4; // sumaryczna informacja o eventach
}
else {
ErrorLog( "Bad track: event \"" + NewEvent2->asName + "\" cannot be assigned to track, track already has one" );
bError = true;
}
}
return ( bError == false );
}
bool TTrack::AssignallEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2, bool const Explicit)
{
bool bError = false;
if( NewEvent0 == nullptr ) {
if( false == asEventall0Name.empty() ) {
bError = true;
if( true == Explicit ) {
ErrorLog( "Bad event: event \"" + asEventall0Name + "\" assigned to track \"" + m_name + "\" does not exist" );
}
}
}
else {
if( evEventall0 == nullptr ) {
evEventall0 = NewEvent0;
/*
// preserve event names, we'll need them if we want the scenario export to be unaffected by missing events and such
asEventall0Name = "";
*/
iEvents |= 8; // sumaryczna informacja o eventach
}
else {
ErrorLog( "Bad track: event \"" + NewEvent0->asName + "\" cannot be assigned to track, track already has one" );
bError = true;
}
}
if( NewEvent1 == nullptr ) {
if( false == asEventall1Name.empty() ) {
bError = true;
if( true == Explicit ) {
ErrorLog( "Bad event: event \"" + asEventall1Name + "\" assigned to track \"" + m_name + "\" does not exist" );
}
}
}
else {
if( evEventall1 == nullptr ) {
evEventall1 = NewEvent1;
/*
asEventall1Name = "";
*/
iEvents |= 16; // sumaryczna informacja o eventach
}
else {
ErrorLog( "Bad track: event \"" + NewEvent1->asName + "\" cannot be assigned to track, track already has one" );
bError = true;
}
}
if( NewEvent2 == nullptr ) {
if( false == asEventall2Name.empty() ) {
bError = true;
if( true == Explicit ) {
ErrorLog( "Bad event: event \"" + asEventall2Name + "\" assigned to track \"" + m_name + "\" does not exist" );
}
}
}
else {
if( evEventall2 == nullptr ) {
evEventall2 = NewEvent2;
/*
asEventall2Name = "";
*/
iEvents |= 32; // sumaryczna informacja o eventach
}
else {
ErrorLog( "Bad track: event \"" + NewEvent2->asName + "\" cannot be assigned to track, track already has one" );
bError = true;
}
}
return ( bError == false );
} }
bool TTrack::AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus) bool TTrack::AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus)
@@ -2903,23 +2794,19 @@ TTrack::export_as_text_( std::ostream &Output ) const {
<< path.radius << ' '; << path.radius << ' ';
} }
// optional attributes // optional attributes
if( false == asEvent0Name.empty() ) { std::vector< std::pair< std::string, event_sequence const * > > const eventsequences {
Output << "event0 " << asEvent0Name << ' '; { "event0", &m_events0 }, { "eventall0", &m_events0all },
{ "event1", &m_events1 }, { "eventall1", &m_events1all },
{ "event2", &m_events2 }, { "eventall2", &m_events2all } };
for( auto &eventsequence : eventsequences ) {
for( auto &event : *( eventsequence.second ) ) {
if( false == event.first.empty() ) {
Output
<< eventsequence.first << ' '
<< event.first << ' ';
} }
if( false == asEvent1Name.empty() ) {
Output << "event1 " << asEvent1Name << ' ';
} }
if( false == asEvent2Name.empty() ) {
Output << "event2 " << asEvent2Name << ' ';
}
if( false == asEventall0Name.empty() ) {
Output << "eventall0 " << asEventall0Name << ' ';
}
if( false == asEventall1Name.empty() ) {
Output << "eventall1 " << asEventall1Name << ' ';
}
if( false == asEventall2Name.empty() ) {
Output << "eventall2 " << asEventall2Name << ' ';
} }
if( ( SwitchExtension ) if( ( SwitchExtension )
&& ( SwitchExtension->fVelocity != -1.0 ) ) { && ( SwitchExtension->fVelocity != -1.0 ) ) {
@@ -3063,33 +2950,10 @@ path_table::InitTracks() {
for( auto first = std::rbegin(m_items); first != std::rend(m_items); ++first ) { for( auto first = std::rbegin(m_items); first != std::rend(m_items); ++first ) {
auto *track = *first; auto *track = *first;
#endif #endif
track->AssignEvents();
track->AssignEvents(
simulation::Events.FindEvent( track->asEvent0Name ),
simulation::Events.FindEvent( track->asEvent1Name ),
simulation::Events.FindEvent( track->asEvent2Name ) );
track->AssignallEvents(
simulation::Events.FindEvent( track->asEventall0Name ),
simulation::Events.FindEvent( track->asEventall1Name ),
simulation::Events.FindEvent( track->asEventall2Name ) );
auto const trackname { track->name() }; auto const trackname { track->name() };
if( ( Global.iHiddenEvents & 1 )
&& ( false == trackname.empty() ) ) {
// jeśli podana jest nazwa torów, można szukać eventów skojarzonych przez nazwę
track->AssignEvents(
simulation::Events.FindEvent( trackname + ":event0" ),
simulation::Events.FindEvent( trackname + ":event1" ),
simulation::Events.FindEvent( trackname + ":event2" ),
false );
track->AssignallEvents(
simulation::Events.FindEvent( trackname + ":eventall0" ),
simulation::Events.FindEvent( trackname + ":eventall1" ),
simulation::Events.FindEvent( trackname + ":eventall2" ),
false );
}
switch (track->eType) { switch (track->eType) {
// TODO: re-enable // TODO: re-enable
case tt_Table: { case tt_Table: {

20
Track.h
View File

@@ -149,16 +149,26 @@ private:
glm::dvec3 m_origin; glm::dvec3 m_origin;
material_handle m_material1 = 0; // tekstura szyn albo nawierzchni material_handle m_material1 = 0; // tekstura szyn albo nawierzchni
material_handle m_material2 = 0; // tekstura automatycznej podsypki albo pobocza material_handle m_material2 = 0; // tekstura automatycznej podsypki albo pobocza
typedef std::vector<gfx::geometry_handle> geometryhandle_sequence; using geometryhandle_sequence = std::vector<gfx::geometry_handle>;
geometryhandle_sequence Geometry1; // geometry chunks textured with texture 1 geometryhandle_sequence Geometry1; // geometry chunks textured with texture 1
geometryhandle_sequence Geometry2; // geometry chunks textured with texture 2 geometryhandle_sequence Geometry2; // geometry chunks textured with texture 2
std::vector<segment_data> m_paths; // source data for owned paths std::vector<segment_data> m_paths; // source data for owned paths
public: public:
typedef std::deque<TDynamicObject *> dynamics_sequence; using dynamics_sequence = std::deque<TDynamicObject *>;
using event_sequence = std::vector<std::pair<std::string, TEvent *> >;
dynamics_sequence Dynamics; dynamics_sequence Dynamics;
int iEvents = 0; // Ra: flaga informująca o obecności eventów event_sequence
m_events0all,
m_events1all,
m_events2all,
m_events0,
m_events1,
m_events2;
bool m_events { false }; // Ra: flaga informująca o obecności eventów
/*
TEvent *evEventall0 = nullptr; // McZapkie-140302: wyzwalany gdy pojazd stoi TEvent *evEventall0 = nullptr; // McZapkie-140302: wyzwalany gdy pojazd stoi
TEvent *evEventall1 = nullptr; TEvent *evEventall1 = nullptr;
TEvent *evEventall2 = nullptr; TEvent *evEventall2 = nullptr;
@@ -171,6 +181,7 @@ public:
std::string asEvent0Name; std::string asEvent0Name;
std::string asEvent1Name; std::string asEvent1Name;
std::string asEvent2Name; std::string asEvent2Name;
*/
int iNextDirection = 0; // 0:Point1, 1:Point2, 3:do odchylonego na zwrotnicy int iNextDirection = 0; // 0:Point1, 1:Point2, 3:do odchylonego na zwrotnicy
int iPrevDirection = 0; // domyślnie wirtualne odcinki dołączamy stroną od Point1 int iPrevDirection = 0; // domyślnie wirtualne odcinki dołączamy stroną od Point1
TTrackType eType = tt_Normal; // domyślnie zwykły TTrackType eType = tt_Normal; // domyślnie zwykły
@@ -234,8 +245,7 @@ public:
SwitchExtension->iRoads - 1 : SwitchExtension->iRoads - 1 :
1 ); } 1 ); }
void Load(cParser *parser, Math3D::vector3 pOrigin); void Load(cParser *parser, Math3D::vector3 pOrigin);
bool AssignEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2, bool const Explicit = true ); bool AssignEvents();
bool AssignallEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2, bool const Explicit = true );
bool AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus); bool AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus);
bool CheckDynamicObject(TDynamicObject *Dynamic); bool CheckDynamicObject(TDynamicObject *Dynamic);
bool AddDynamicObject(TDynamicObject *Dynamic); bool AddDynamicObject(TDynamicObject *Dynamic);

View File

@@ -101,7 +101,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
{ // pętla przesuwająca wózek przez kolejne tory, aż do trafienia w jakiś { // pętla przesuwająca wózek przez kolejne tory, aż do trafienia w jakiś
if( pCurrentTrack == nullptr ) { return false; } // nie ma toru, to nie ma przesuwania if( pCurrentTrack == nullptr ) { return false; } // nie ma toru, to nie ma przesuwania
// TODO: refactor following block as track method // TODO: refactor following block as track method
if( pCurrentTrack->iEvents ) { // sumaryczna informacja o eventach if( pCurrentTrack->m_events ) { // sumaryczna informacja o eventach
// omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma) // omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma)
if( ( std::abs( fDistance ) < 0.01 ) if( ( std::abs( fDistance ) < 0.01 )
&& ( Owner->GetVelocity() < 0.01 ) ) { && ( Owner->GetVelocity() < 0.01 ) ) {
@@ -109,14 +109,18 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->Primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
if( ( pCurrentTrack->evEvent0 ) for( auto &event : pCurrentTrack->m_events0 ) {
&& ( pCurrentTrack->evEvent0->iQueued == 0 ) ) { if( ( event.second != nullptr )
simulation::Events.AddToQuery( pCurrentTrack->evEvent0, Owner ); && ( event.second->iQueued == 0 ) ) {
simulation::Events.AddToQuery( event.second, Owner );
} }
} }
if( ( pCurrentTrack->evEventall0 ) }
&& ( pCurrentTrack->evEventall0->iQueued == 0 ) ) { for( auto &event : pCurrentTrack->m_events0all ) {
simulation::Events.AddToQuery( pCurrentTrack->evEventall0, Owner ); if( ( event.second != nullptr )
&& ( event.second->iQueued == 0 ) ) {
simulation::Events.AddToQuery( event.second, Owner );
}
} }
} }
else if (fDistance < 0) { else if (fDistance < 0) {
@@ -127,20 +131,27 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->Primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
// McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada // McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada
if( ( true == bPrimary ) if( true == bPrimary ) {
&& ( pCurrentTrack->evEvent1 != nullptr ) for( auto &event : pCurrentTrack->m_events1 ) {
&& ( pCurrentTrack->evEvent1->iQueued == 0 ) ) { if( ( event.second != nullptr )
&& ( event.second->iQueued == 0 ) ) {
// dodanie do kolejki // dodanie do kolejki
simulation::Events.AddToQuery( pCurrentTrack->evEvent1, Owner ); simulation::Events.AddToQuery( event.second, Owner );
}
}
} }
} }
} }
if( SetFlag( iEventallFlag, -1 ) ) { if( SetFlag( iEventallFlag, -1 ) ) {
// McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow
if( ( true == bPrimary ) if( true == bPrimary ) {
&& ( pCurrentTrack->evEventall1 != nullptr ) for( auto &event : pCurrentTrack->m_events1all ) {
&& ( pCurrentTrack->evEventall1->iQueued == 0 ) ) { if( ( event.second != nullptr )
simulation::Events.AddToQuery( pCurrentTrack->evEventall1, Owner ); // dodanie do kolejki && ( event.second->iQueued == 0 ) ) {
// dodanie do kolejki
simulation::Events.AddToQuery( event.second, Owner );
}
}
} }
} }
} }
@@ -151,19 +162,27 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->Primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
if( ( true == bPrimary ) if( true == bPrimary ) {
&& ( pCurrentTrack->evEvent2 != nullptr ) for( auto &event : pCurrentTrack->m_events2 ) {
&& ( pCurrentTrack->evEvent2->iQueued == 0 ) ) { if( ( event.second != nullptr )
simulation::Events.AddToQuery( pCurrentTrack->evEvent2, Owner ); && ( event.second->iQueued == 0 ) ) {
// dodanie do kolejki
simulation::Events.AddToQuery( event.second, Owner );
}
}
} }
} }
} }
if( SetFlag( iEventallFlag, -2 ) ) { if( SetFlag( iEventallFlag, -2 ) ) {
// sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0 // sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0
if( ( true == bPrimary ) if( true == bPrimary ) {
&& ( pCurrentTrack->evEventall2 != nullptr ) for( auto &event : pCurrentTrack->m_events2all ) {
&& ( pCurrentTrack->evEventall2->iQueued == 0 ) ) { if( ( event.second != nullptr )
simulation::Events.AddToQuery( pCurrentTrack->evEventall2, Owner ); && ( event.second->iQueued == 0 ) ) {
// dodanie do kolejki
simulation::Events.AddToQuery( event.second, Owner );
}
}
} }
} }
} }
@@ -258,18 +277,33 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
{ // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru) { // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru)
if (bPrimary) if (bPrimary)
{ // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki { // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki
if (Owner->MoverParameters->ActiveCab != 0) if (Owner->MoverParameters->ActiveCab != 0) {
// if (Owner->MoverParameters->CabNo!=0)
{ for( auto &event : pCurrentTrack->m_events1 ) {
if (pCurrentTrack->evEvent1 && pCurrentTrack->evEvent1->fDelay <= -1.0f) if( ( event.second != nullptr )
simulation::Events.AddToQuery(pCurrentTrack->evEvent1, Owner); && ( event.second->fDelay <= -1.0 ) ) {
if (pCurrentTrack->evEvent2 && pCurrentTrack->evEvent2->fDelay <= -1.0f) simulation::Events.AddToQuery( event.second, Owner );
simulation::Events.AddToQuery(pCurrentTrack->evEvent2, Owner); }
}
for( auto &event : pCurrentTrack->m_events2 ) {
if( ( event.second != nullptr )
&& ( event.second->fDelay <= -1.0 ) ) {
simulation::Events.AddToQuery( event.second, Owner );
}
}
}
for( auto &event : pCurrentTrack->m_events1all ) {
if( ( event.second != nullptr )
&& ( event.second->fDelay <= -1.0 ) ) {
simulation::Events.AddToQuery( event.second, Owner );
}
}
for( auto &event : pCurrentTrack->m_events2all ) {
if( ( event.second != nullptr )
&& ( event.second->fDelay <= -1.0 ) ) {
simulation::Events.AddToQuery( event.second, Owner );
}
} }
if (pCurrentTrack->evEventall1 && pCurrentTrack->evEventall1->fDelay <= -1.0f)
simulation::Events.AddToQuery(pCurrentTrack->evEventall1, Owner);
if (pCurrentTrack->evEventall2 && pCurrentTrack->evEventall2->fDelay <= -1.0f)
simulation::Events.AddToQuery(pCurrentTrack->evEventall2, Owner);
} }
fCurrentDistance = s; fCurrentDistance = s;
// fDistance=0; // fDistance=0;

View File

@@ -789,7 +789,7 @@ state_manager::deserialize_dynamic( cParser &Input, scene::scratch_data &Scratch
} }
if( ( true == Scratchpad.trainset.vehicles.empty() ) // jeśli pierwszy pojazd, if( ( true == Scratchpad.trainset.vehicles.empty() ) // jeśli pierwszy pojazd,
&& ( false == path->asEvent0Name.empty() ) // tor ma Event0 && ( false == path->m_events0.empty() ) // tor ma Event0
&& ( std::abs( velocity ) <= 1.f ) // a skład stoi && ( std::abs( velocity ) <= 1.f ) // a skład stoi
&& ( Scratchpad.trainset.offset >= 0.0 ) // ale może nie sięgać na owy tor && ( Scratchpad.trainset.offset >= 0.0 ) // ale może nie sięgać na owy tor
&& ( Scratchpad.trainset.offset < 8.0 ) ) { // i raczej nie sięga && ( Scratchpad.trainset.offset < 8.0 ) ) { // i raczej nie sięga