X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetwork%2Fserver.cpp;h=bf404e9b5ea90eae6116d7ce5651f7e5b7acf429;hb=dec294d40194a640e7b4bccf20dd1baa4a87038c;hp=73cee24a4f0c2f5d7676b98a507be2f25dcce6fd;hpb=3acb396462f2d6361423b744e489c13ef64c8114;p=r2c2.git diff --git a/source/network/server.cpp b/source/network/server.cpp index 73cee24..bf404e9 100644 --- a/source/network/server.cpp +++ b/source/network/server.cpp @@ -75,9 +75,8 @@ void Server::train_added(Train &train) 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))); + if(!train.get_ai_of_type()) + new TrainStatus(train); } void Server::train_control_changed(const Train &train, const string &control, float value) @@ -107,14 +106,13 @@ void Server::train_ai_event(const Train &train, TrainAI &, const TrainAI::Messag pkt.route = route->get_name(); send(pkt); } -} - -void Server::train_status_changed(const Train &train, const string &status) -{ - TrainStatusPacket pkt; - pkt.address = train.get_address(); - pkt.status = status; - send(pkt); + else if(ev.type=="status-changed") + { + TrainStatusPacket pkt; + pkt.address = train.get_address(); + pkt.status = ev.value.value(); + send(pkt); + } } template @@ -198,14 +196,14 @@ void Server::Connection::handshake_done() pkt.functions = train.get_functions(); comm.send(pkt); } - if(TrainStatus *status = dynamic_cast(train.get_tagged_ai("server:status"))) + if(TrainStatus *status = train.get_ai_of_type()) { TrainStatusPacket pkt; pkt.address = train.get_address(); pkt.status = status->get_status(); comm.send(pkt); } - if(TrainRouter *router = dynamic_cast(train.get_tagged_ai("router"))) + if(TrainRouter *router = train.get_ai_of_type()) { TrainRoutePacket pkt; pkt.address = train.get_address();