From f5cd696f9ee80d5edf17d44080c63db78919caef Mon Sep 17 00:00:00 2001 From: Jakob Erdmann Date: Thu, 12 Sep 2024 17:33:28 +0200 Subject: [PATCH] fixing invalid route index for siding search start. refs #15474 --- src/microsim/traffic_lights/MSDriveWay.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/microsim/traffic_lights/MSDriveWay.cpp b/src/microsim/traffic_lights/MSDriveWay.cpp index 91a43a12bfb..d7bacef3268 100644 --- a/src/microsim/traffic_lights/MSDriveWay.cpp +++ b/src/microsim/traffic_lights/MSDriveWay.cpp @@ -1713,6 +1713,12 @@ MSDriveWay::addFoeCheckSiding(MSDriveWay* foe) { forwardNormals++; } } + if (forwardNormals == (int)foe->myRoute.size()) { +#ifdef DEBUG_BUILD_SIDINGS + std::cout << "checkSiding " << getID() << " foe=" << foe->getID() << " forwardNormals=" << forwardNormals << " frSize=" << foe->myRoute.size() << " aborted\n"; +#endif + return; + } auto foeSearchBeg = foe->myRoute.begin() + forwardNormals; auto foeSearchEnd = foe->myRoute.end(); if (foeEndBidi == nullptr) { @@ -1721,17 +1727,17 @@ MSDriveWay::addFoeCheckSiding(MSDriveWay* foe) { int i; int start = -1; double length = 0; - for (i = (int)myRoute.size() - 1; i >= 0; i--) { + for (i = 0; i < (int)myRoute.size(); i++) { if (myRoute[i] == foeEndBidi) { break; } } - if (i == -1) { + if (i == (int)myRoute.size()) { throw ProcessError("addFoeCheckSiding " + getID() + " foe=" + foe->getID() + " foeEndBidi=" + foeEndBidi->getID() + " not on route\n"); } const MSEdge* next = myRoute[i]; #ifdef DEBUG_BUILD_SIDINGS - std::cout << "checkSiding " << getID() << " foe=" << foe->getID() << " i=" << i << " next=" << next->getID() << " foeSearchBeg=" << (*foeSearchBeg)->getID() << "\n"; + std::cout << "checkSiding " << getID() << " foe=" << foe->getID() << " i=" << i << " next=" << next->getID() << " forwardNormals=" << forwardNormals << " frSize=" << foe->myRoute.size() << " foeSearchBeg=" << (*foeSearchBeg)->getID() << "\n"; #endif i--; for (; i >= 0; i--) {