]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/vehicletype.cpp
Replace various map lookups with functions from maputils.h
[r2c2.git] / source / libr2c2 / vehicletype.cpp
index 6c9d387ad7978f1da7ae4d65701050633eabe719..9f8814652770448aa1ae1dc84f5b4d542f4e167a 100644 (file)
@@ -1,10 +1,4 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2010-2011  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
+#include <msp/core/maputils.h>
 #include "vehicletype.h"
 
 using namespace std;
@@ -230,10 +224,7 @@ VehicleType::Rod::Loader::Loader(Rod &r, const map<string, unsigned> &t):
 
 void VehicleType::Rod::Loader::connect(const string &t, float px, float pz, float ox, float oz)
 {
-       map<string, unsigned>::const_iterator i = tags.find(t);
-       if(i==tags.end())
-               throw KeyError("Unknown rod tag", t);
-       obj.connect_index = i->second;
+       obj.connect_index = get_item(tags, t);
        obj.connect_point = Vector(px/1000, 0, pz/1000);
        obj.connect_offset = Vector(ox/1000, 0, oz/1000);
 }
@@ -258,11 +249,8 @@ void VehicleType::Rod::Loader::pivot_bogie_axle(unsigned i, unsigned j)
 
 void VehicleType::Rod::Loader::pivot_rod(const string &t)
 {
-       map<string, unsigned>::const_iterator i = tags.find(t);
-       if(i==tags.end())
-               throw KeyError("Unknown rod tag", t);
+       obj.pivot_index = get_item(tags, t);
        obj.pivot = ROD;
-       obj.pivot_index = i->second;
 }
 
 void VehicleType::Rod::Loader::position(float x, float y, float z)