]> git.tdb.fi Git - r2c2.git/blobdiff - source/network/client.cpp
Make Client hold a non-const reference to the Catalogue
[r2c2.git] / source / network / client.cpp
index ac4f018e83d9b72777429aed65bda99d1725d197..ec8e408582a657f2f1a3b07576c56735c5fb0c12 100644 (file)
@@ -1,10 +1,4 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2009-2011  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
+#include <msp/core/maputils.h>
 #include "client.h"
 
 using namespace std;
@@ -12,7 +6,7 @@ using namespace Msp;
 
 namespace R2C2 {
 
-Client::Client(const Catalogue &c):
+Client::Client(Catalogue &c):
        catalogue(c),
        socket(0),
        comm(0),
@@ -63,10 +57,7 @@ void Client::set_halt(bool h)
 
 NetTrain &Client::get_train(unsigned addr) const
 {
-       map<unsigned, NetTrain *>::const_iterator i = trains.find(addr);
-       if(i==trains.end())
-               throw KeyError("Unknown train");
-       return *i->second;
+       return *get_item(trains, addr);
 }
 
 void Client::receive(const DriverStatePacket &pkt)