TrainRouter::TrainRouter(Train &t):
TrainAI(t),
priority(0),
- arriving(0),
+ arrival(ON_THE_WAY),
destination(0),
destination_changed(false),
metrics_stale(false),
if(!already_at_end)
{
+ arrival = ON_THE_WAY;
train.stop_at(0);
train.refresh_blocks_from(*fncb);
}
sequence_check_pending = false;
}
- if(arriving==1 && !train.get_speed())
+ if(arrival==RESERVED_TO_END && !train.get_speed())
{
signal_arrived.emit(destination);
signal_event.emit(Message("arrived", destination));
- arriving = 2;
+ arrival = ARRIVED;
}
- else if(arriving==2 && !train.get_block_allocator().is_active())
+ else if(arrival==ARRIVED && !train.get_block_allocator().is_active())
set_route(0);
}
if(reserving_route==routes.end() || !(*reserving_route)->has_track(*track))
{
reserving_route = routes.begin();
+ arrival = ON_THE_WAY;
track = t->get_block_allocator().first().track_iter();
for(; track; track=track.next())
{
{
if(!advance_to_track(reserving_route, *track))
{
+ arrival = RESERVED_TO_END;
train.stop_at(&block);
return;
}
}
}
}
-
- if(!routes.empty())
- {
- b_iter = b_iter.next();
- if(b_iter && !is_on_route(*b_iter))
- arriving = 1;
- }
}
void TrainRouter::create_metrics()
private:
typedef std::list<const Route *> RouteList;
+ enum ArrivalState
+ {
+ ON_THE_WAY,
+ RESERVED_TO_END,
+ ARRIVED
+ };
+
public:
sigc::signal<void, const Route *> signal_route_changed;
sigc::signal<void, const TrackChain *> signal_arrived;
int priority;
RouteList routes;
RouteList::iterator reserving_route;
- unsigned arriving;
+ ArrivalState arrival;
const TrackChain *destination;
std::vector<const TrackChain *> waypoints;
bool destination_changed;