Skip to content

Commit

Permalink
fix #4673
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Oct 19, 2018
1 parent eba3ac8 commit 6f29dcb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/microsim/traffic_lights/MSTrafficLightLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ MSTrafficLightLogic::init(NLDetectorBuilder&) {
bool haveWarnedAboutUnusedStates = false;
std::vector<bool> foundGreen(phases.front()->getState().size(), false);
for (int i = 0; i < (int)phases.size(); ++i) {
// warn about unused stats
// warn about unused states
const int iNext = phases[i]->nextPhase < 0 ? (i + 1) % phases.size() : phases[i]->nextPhase;
if (iNext < 0 || iNext >= (int)phases.size()) {
throw ProcessError("Invalid nextPhase " + toString(iNext) + " in tlLogic '" + getID()
Expand All @@ -135,6 +135,12 @@ MSTrafficLightLogic::init(NLDetectorBuilder&) {
+ " after tl-index " + toString((int)myLanes.size() - 1));
haveWarnedAboutUnusedStates = true;
}
// detect illegal states
const std::string::size_type illegal = state1.find_first_not_of(SUMOXMLDefinitions::ALLOWED_TLS_LINKSTATES);
if (std::string::npos != illegal) {
throw ProcessError("Illegal character '" + toString(state1[illegal]) + "' in tlLogic '" + getID()
+ "', program '" + getProgramID() + "' in phase " + toString(i));
}
// warn about transitions from green to red without intermediate yellow
for (int j = 0; j < (int)MIN3(state1.size(), state2.size(), myLanes.size()); ++j) {
if ((LinkState)state2[j] == LINKSTATE_TL_RED
Expand Down
3 changes: 2 additions & 1 deletion tests/sumo/basic/tls/errors/invalid_state/errors.sumo
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Warning: Missing green phase in tlLogic '0', program 'broken' for tl-index 0
Error: Illegal character '0' in tlLogic '0', program 'broken' in phase 0
Quitting (on error).
1 change: 1 addition & 0 deletions tests/sumo/basic/tls/errors/invalid_state/exitcode.sumo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit 6f29dcb

Please sign in to comment.