X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fcentralstation.cpp;h=3a9624af1ba17b0049b17a832e317ecb055bb4dc;hb=ac3bd4db7b4d639488e05dab7d8316182f5368c7;hp=2e605ba3500d92b7ce91cfd594d997789ee93d17;hpb=374dc443d044f31c925342f339a628c860c08a7e;p=r2c2.git diff --git a/source/libr2c2/centralstation.cpp b/source/libr2c2/centralstation.cpp index 2e605ba..3a9624a 100644 --- a/source/libr2c2/centralstation.cpp +++ b/source/libr2c2/centralstation.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include @@ -149,6 +142,7 @@ void CentralStation::set_loco_function(unsigned addr, unsigned func, bool state) void CentralStation::add_turnout(unsigned addr, const TrackType &type) { + unsigned straight = type.get_paths(); bool left = false; bool right = false; bool cross = false; @@ -158,10 +152,11 @@ void CentralStation::add_turnout(unsigned addr, const TrackType &type) { TrackPoint start = i->get_point(0); TrackPoint end = i->get_point(i->get_length()); - if(end.dir>start.dir+0.01) - left = true; - else if(end.dirstart.dir+0.01 || end.dirstart.dir ? left : right) = true; + straight &= ~(1<get_path()); + } else if(start.dir<-0.01 || start.dir>0.01) cross = true; } @@ -172,9 +167,9 @@ void CentralStation::add_turnout(unsigned addr, const TrackType &type) else if(left && right) symbol = Turnout::THREEWAY; else if(left) - symbol = Turnout::LEFT; + symbol = (straight ? Turnout::LEFT : Turnout::CURVED_LEFT); else if(right) - symbol = Turnout::RIGHT; + symbol = (straight ? Turnout::RIGHT : Turnout::CURVED_RIGHT); unsigned id = map_address(turnouts, turnout_addr, addr); if(!id) @@ -620,7 +615,7 @@ CentralStation::Protocol CentralStation::map_protocol(const string &name) const else if(name=="MFX") return MFX; else - throw InvalidParameterValue("Unknown protocol"); + throw invalid_argument("CentralStation::map_protocol"); } template