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

build 170602. completed fix for infinite event loop, modified horn controls to work independent of each other

This commit is contained in:
tmj-fstate
2017-06-02 16:35:36 +02:00
parent a28b3d5af9
commit 5f0069bf60
6 changed files with 96 additions and 145 deletions

View File

@@ -610,16 +610,32 @@ void TEvent::Load(cParser *parser, vector3 *org)
}
};
void TEvent::AddToQuery(TEvent *e)
{ // dodanie eventu do kolejki
if( ( evNext != nullptr )
&& ( e->fStartTime > evNext->fStartTime ) ) {
evNext->AddToQuery( e ); // sortowanie wg czasu
void TEvent::AddToQuery( TEvent *Event, TEvent *&Start ) {
TEvent *target( Start );
TEvent *previous( nullptr );
while( ( Event->fStartTime >= target->fStartTime )
&& ( target->evNext != nullptr ) ) {
previous = target;
target = target->evNext;
}
else
{ // dodanie z przodu
e->evNext = evNext;
evNext = e;
// the new event will be either before or after the one we located
if( Event->fStartTime >= target->fStartTime ) {
assert( target->evNext == nullptr );
target->evNext = Event;
// if we have resurrected event land at the end of list, the link from previous run could potentially "add" unwanted events to the queue
Event->evNext = nullptr;
}
else {
if( previous != nullptr ) {
previous->evNext = Event;
Event->evNext = target;
}
else {
// special case, we're inserting our event before the provided start point
Event->evNext = Start;
Start = Event;
}
}
}