-/* $Id$
-
-This file is part of R²C²
-Copyright © 2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
#include <algorithm>
#include <msp/core/refptr.h>
#include <msp/io/print.h>
void CentralStation::add_turnout(unsigned addr, const TrackType &type)
{
+ unsigned straight = type.get_paths();
bool left = false;
bool right = false;
bool cross = false;
{
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.dir<start.dir-0.01)
- right = true;
+ if(end.dir>start.dir+0.01 || end.dir<start.dir-0.01)
+ {
+ (end.dir>start.dir ? left : right) = true;
+ straight &= ~(1<<i->get_path());
+ }
else if(start.dir<-0.01 || start.dir>0.01)
cross = true;
}
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)
else if(name=="MFX")
return MFX;
else
- throw InvalidParameterValue("Unknown protocol");
+ throw invalid_argument("CentralStation::map_protocol");
}
template<typename T>