Skip to content

Commit

Permalink
fix #14519
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 15, 2024
1 parent 28d54c1 commit f5bdfaf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/microsim/MSVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,9 @@ MSVehicle::joinTrainPartFront(MSVehicle* veh) {
double gap = veh->getBackPositionOnLane(backLane) - getPositionOnLane();
if (isStopped() && myStops.begin()->joinTriggered && backLane == getLane()
&& gap >= 0 && gap <= getVehicleType().getMinGap() + 1) {
double skippedLaneLengths = 0;
if (veh->myFurtherLanes.size() > 0) {
skippedLaneLengths += getLane()->getLength();
// this vehicle must be moved to the lane of veh
// ensure that lane and furtherLanes of veh match our route
int routeIndex = getRoutePosition();
Expand All @@ -2001,13 +2003,14 @@ MSVehicle::joinTrainPartFront(MSVehicle* veh) {
return false;
}
for (int i = (int)veh->myFurtherLanes.size() - 2; i >= 0; i--) {
enterLaneAtMove(veh->myFurtherLanes[i]);
skippedLaneLengths += veh->myFurtherLanes[i]->getLength();
}
}

const double newLength = myType->getLength() + veh->getVehicleType().getLength();
getSingularType().setLength(newLength);
assert(myLane == veh->getLane());
myState.myPos = veh->getPositionOnLane();
// lane will be advanced just as for regular movement
myState.myPos = skippedLaneLengths + veh->getPositionOnLane();
myStops.begin()->joinTriggered = false;
if (myAmRegisteredAsWaiting) {
MSNet::getInstance()->getVehicleControl().unregisterOneWaiting();
Expand Down

0 comments on commit f5bdfaf

Please sign in to comment.