+#include <msp/core/maputils.h>
#include "client.h"
using namespace std;
namespace R2C2 {
-Client::Client(const Catalogue &c):
+Client::Client(Catalogue &c):
catalogue(c),
socket(0),
comm(0),
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)
get_train(pkt.address).process_packet(pkt);
}
+void Client::receive(const TrainAIControlPacket &pkt)
+{
+ get_train(pkt.address).process_packet(pkt);
+}
+
void Client::receive(const TrainStatusPacket &pkt)
{
get_train(pkt.address).process_packet(pkt);