]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/vehicle.cpp
BasicLoader is now called ObjectLoader
[r2c2.git] / source / libr2c2 / vehicle.cpp
index b7355c6a6e2fab2bd73caaeafafd4881ce989b2d..1699fd8eeef1cf0b89618cb806d3c6623aabc07b 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2010-2011  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #include <cmath>
 #include "catalogue.h"
 #include "driver.h"
@@ -48,7 +41,7 @@ Vehicle::~Vehicle()
 void Vehicle::attach_back(Vehicle &veh)
 {
        if(next || veh.prev)
-               throw InvalidState("Already attached");
+               throw attachment_error("already attached");
 
        next = &veh;
        veh.prev = this;
@@ -60,7 +53,7 @@ void Vehicle::attach_back(Vehicle &veh)
 void Vehicle::attach_front(Vehicle &veh)
 {
        if(prev || veh.next)
-               throw InvalidState("Already attached");
+               throw attachment_error("already attached");
 
        prev = &veh;
        veh.next = this;
@@ -72,7 +65,7 @@ void Vehicle::attach_front(Vehicle &veh)
 void Vehicle::detach_back()
 {
        if(!next)
-               throw InvalidState("Not attached");
+               throw attachment_error("not attached");
 
        next->prev = 0;
        next = 0;
@@ -81,7 +74,7 @@ void Vehicle::detach_back()
 void Vehicle::detach_front()
 {
        if(!prev)
-               throw InvalidState("Not attached");
+               throw attachment_error("not attached");
 
        prev->next = 0;
        prev = 0;
@@ -128,30 +121,30 @@ void Vehicle::advance(float d)
 const Vehicle::Axle &Vehicle::get_fixed_axle(unsigned i) const
 {
        if(i>=axles.size())
-               throw InvalidParameterValue("Axle index out of range");
+               throw out_of_range("Vehicle::get_fixed_axle");
        return axles[i];
 }
 
 const Vehicle::Bogie &Vehicle::get_bogie(unsigned i) const
 {
        if(i>=bogies.size())
-               throw InvalidParameterValue("Bogie index out of range");
+               throw out_of_range("Vehicle::get_bogie");
        return bogies[i];
 }
 
 const Vehicle::Axle &Vehicle::get_bogie_axle(unsigned i, unsigned j) const
 {
        if(i>=bogies.size())
-               throw InvalidParameterValue("Bogie index out of range");
+               throw out_of_range("Vehicle::get_bogie_axle");
        if(j>=bogies[i].axles.size())
-               throw InvalidParameterValue("Axle index out of range");
+               throw out_of_range("Vehicle::get_bogie_axle");
        return bogies[i].axles[j];
 }
 
 const Vehicle::Rod &Vehicle::get_rod(unsigned i) const
 {
        if(i>=rods.size())
-               throw InvalidParameterValue("Rod index out of range");
+               throw out_of_range("Vehicle::get_rod");
        return rods[i];
 }