]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/route.cpp
Remove deprecated header
[r2c2.git] / source / libr2c2 / route.cpp
index aabe8807b71cd4b7d92927ca6427edce21f804d1..795ae3215bbcbff77fa7eadc9b0baded96f70dd7 100644 (file)
@@ -169,10 +169,10 @@ void Route::set_temporary(bool t)
 void Route::set_turnout(unsigned addr, unsigned path)
 {
        if(!addr)
-               throw InvalidParameterValue("Invalid turnout address");
+               throw invalid_argument("Route::set_turnout");
        int &state = get_item(turnouts, addr);
        if(state>=0 && path!=static_cast<unsigned>(state))
-               throw InvalidState("Setting conflicts with route");
+               throw logic_error("route conflict");
        state = path;
 }
 
@@ -198,7 +198,7 @@ void Route::update_turnouts()
                                {
                                        const TrackType::Endpoint &ep = links[j]->get_type().get_endpoint(links[j]->get_endpoint_by_link(**i));
                                        int p = get_turnout(tid2);
-                                       if(p>=0 && !(ep.paths&(1<<p)))
+                                       if(p>=0 && !ep.has_path(p))
                                        {
                                                // The linked track is a turnout and has a path which is incompatible with this endpoint
                                                mask &= ~endpoints[j].paths;
@@ -350,7 +350,7 @@ RouteValidityMask Route::check_validity(Track &trk) const
                        if(path>=0)
                        {
                                // Linking to a turnout with path set is only good if we're continuing that path
-                               if(ep.paths&(1<<path))
+                               if(ep.has_path(path))
                                        result |= ROUTE_LINEAR;
                        }
                        else
@@ -367,14 +367,14 @@ RouteValidityMask Route::check_validity(Track &trk) const
                                                        const TrackType::Endpoint &ep2 = tlinks[j]->get_type().get_endpoint(tlinks[j]->get_endpoint_by_link(**i));
                                                        path = get_turnout(tid2);
                                                        // Ignore a linked turnout with some other path set
-                                                       if(path>=0 && !(ep2.paths&(1<<path)))
+                                                       if(path>=0 && !ep2.has_path(path))
                                                                continue;
                                                }
 
                                                ++count;
 
                                                const TrackType::Endpoint &ep2 = (*i)->get_type().get_endpoint(j);
-                                               if(!(ep.paths&ep2.paths))
+                                               if(!ep.has_common_paths(ep2))
                                                        // Impossible path through the turnout - not good
                                                        result &= ~ROUTE_SMOOTH;
                                        }
@@ -419,7 +419,7 @@ Route *Route::find(const TrackIter &from, const set<Track *> &to)
 
 
 Route::Loader::Loader(Route &r):
-       DataFile::BasicLoader<Route>(r)
+       DataFile::ObjectLoader<Route>(r)
 {
        add("name",    &Route::name);
        add("turnout", &Loader::turnout);
@@ -438,10 +438,9 @@ void Route::Loader::finish()
                if(j==turnouts.end())
                        continue;
 
-               unsigned path_mask = 1<<j->second;
                const vector<TrackType::Endpoint> &eps = (*i)->get_type().get_endpoints();
                for(unsigned k=0; k<eps.size(); ++k)
-                       if(eps[k].paths&path_mask)
+                       if(eps[k].has_path(j->second))
                        {
                                Track *link = (*i)->get_link(k);
                                if(!obj.tracks.count(link))