X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Flayout.cpp;h=7fd0d4ddac4b112073374fc25f6d4f96284f29c1;hb=51779f52d3f1fe23e2bdb8864c88b5edd49c57ed;hp=2881e8d33c82ed23d8c5c6edcffa09e684b8f8fa;hpb=495c54e187ddbb7514c983e1829a69d82ccad5f3;p=r2c2.git diff --git a/source/3d/layout.cpp b/source/3d/layout.cpp index 2881e8d..7fd0d4d 100644 --- a/source/3d/layout.cpp +++ b/source/3d/layout.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include "layout.h" #include "track.h" #include "vehicle.h" @@ -58,10 +51,7 @@ void Layout3D::get_bounds(Vector &minp, Vector &maxp) const void Layout3D::add_track(Track3D &t) { - if(tracks.count(&t.get_track())) - throw KeyError("Duplicate track"); - - tracks[&t.get_track()] = &t; + insert_unique(tracks, &t.get_track(), &t); } void Layout3D::remove_track(Track3D &t) @@ -71,19 +61,12 @@ void Layout3D::remove_track(Track3D &t) Track3D &Layout3D::get_track(Track &t) const { - TrackMap::const_iterator i = tracks.find(&t); - if(i==tracks.end()) - throw KeyError("Unknown track"); - - return *i->second; + return *get_item(tracks, &t); } void Layout3D::add_vehicle(Vehicle3D &v) { - if(vehicles.count(&v.get_vehicle())) - throw KeyError("Duplicate vehicle"); - - vehicles[&v.get_vehicle()] = &v; + insert_unique(vehicles, &v.get_vehicle(), &v); } void Layout3D::remove_vehicle(Vehicle3D &v) @@ -93,11 +76,7 @@ void Layout3D::remove_vehicle(Vehicle3D &v) Vehicle3D &Layout3D::get_vehicle(Vehicle &v) const { - VehicleMap::const_iterator i = vehicles.find(&v); - if(i==vehicles.end()) - throw KeyError("Unknown vehicle"); - - return *i->second; + return *get_item(vehicles, &v); } void Layout3D::track_added(Track &t)