X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetwork%2Fserver.cpp;h=c9a56e39b243d7673d15c80259d4410658aabe8f;hb=ce29d0ccf89840c9581314301de0ea2b5b261c43;hp=b3f4662a05079814bb618062245e0a6215ed8b70;hpb=e8d06e16ab1679eb87e21cbfa788eea02144927d;p=r2c2.git diff --git a/source/network/server.cpp b/source/network/server.cpp index b3f4662..c9a56e3 100644 --- a/source/network/server.cpp +++ b/source/network/server.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2009-2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include "libr2c2/driver.h" #include "libr2c2/route.h" @@ -77,6 +70,10 @@ void Server::train_added(Train &train) pkt.loco_type = train.get_locomotive_type().get_article_number().str(); pkt.name = train.get_name(); send(pkt); + + TrainStatus *status = new TrainStatus(train); + status->set_tag("server:status"); + status->signal_changed.connect(sigc::bind<0>(sigc::mem_fun(this, &Server::train_status_changed), sigc::ref(train))); } void Server::train_control_changed(const Train &train, const string &control, float value) @@ -194,10 +191,11 @@ void Server::Connection::handshake_done() pkt.functions = train.get_functions(); comm.send(pkt); } + if(TrainStatus *status = dynamic_cast(train.get_tagged_ai("server:status"))) { TrainStatusPacket pkt; pkt.address = train.get_address(); - pkt.status = train.get_status(); + pkt.status = status->get_status(); comm.send(pkt); } if(train.get_route())