#include "route.h"
#include "trackiter.h"
#include "train.h"
+#include "trackchain.h"
#include "trainrouteplanner.h"
#include "trainrouter.h"
-#include "zone.h"
using namespace std;
using namespace Msp;
TrainAI(t),
priority(0),
arriving(0),
- dest_zone(0),
- dest_block(0),
+ destination(0),
update_pending(false)
{
train.get_layout().signal_block_reserved.connect(sigc::mem_fun(this, &TrainRouter::block_reserved));
route, but not when the planner calls this. */
if(!r)
{
- dest_zone = 0;
- dest_block = 0;
+ destination = 0;
}
train.refresh_blocks_from(*fncb);
return routes.front();
}
-void TrainRouter::set_destination(const Zone &zone)
+void TrainRouter::set_destination(const TrackChain &d)
{
- dest_zone = &zone;
- dest_block = 0;
+ destination = &d;
update_pending = true;
}
-void TrainRouter::set_destination(const Block &block)
-{
- dest_zone = 0;
- dest_block = █
- update_pending = true;
-}
-
-bool TrainRouter::has_destination() const
-{
- return dest_zone || dest_block;
-}
-
bool TrainRouter::is_destination(Track &track) const
{
- if(dest_zone)
- return dest_zone->has_track(track);
- else if(dest_block)
- return dest_block->has_track(track);
+ if(destination)
+ return destination->has_track(track);
else
return false;
}
}
else if(msg.type=="clear-route")
set_route(0);
- else if(msg.type=="set-destination-block")
- {
- if(msg.value.check_type<Block *>())
- set_destination(*msg.value.value<Block *>());
- else
- set_destination(*msg.value.value<const Block *>());
- }
- else if(msg.type=="set-destination-zone")
+ else if(msg.type=="set-destination")
{
- if(msg.value.check_type<Zone *>())
- set_destination(*msg.value.value<Zone *>());
+ if(msg.value.check_type<TrackChain *>())
+ set_destination(*msg.value.value<TrackChain *>());
else
- set_destination(*msg.value.value<const Zone *>());
+ set_destination(*msg.value.value<const TrackChain *>());
}
else if(msg.type=="set-departure-delay")
set_departure_delay(msg.value.value<Time::TimeDelta>());
class Block;
class Layout;
-class Route;
class Track;
-class Zone;
+class TrackChain;
class TrainRouter: public TrainAI
{
int priority;
RouteList routes;
unsigned arriving;
- const Zone *dest_zone;
- const Block *dest_block;
+ const TrackChain *destination;
std::list<Wait> waits;
Msp::Time::TimeDelta delay;
void add_wait(Block &, Train *);
const Route *get_route() const;
- void set_destination(const Zone &);
- void set_destination(const Block &);
- bool has_destination() const;
+ void set_destination(const TrackChain &);
+ const TrackChain *get_destination() const { return destination; }
bool is_destination(Track &) const;
void set_departure_delay(const Msp::Time::TimeDelta &);
const Msp::Time::TimeDelta &get_departure_delay() const { return delay; }