Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RFHumpRoute Scan(GSTrackSearch it, Trackside origin)
- {
- if (!IncHops())
- return null;
- RFHumpRoute ret = null;
- Trackside prev = origin, found;
- while (it.SearchNextObject()) {
- if (!(found = cast <Trackside> it.GetObject()))
- continue;
- RFHumpMarker marker;
- Junction junc;
- if ((marker = cast <RFHumpMarker> found) and marker.HumpTrack >= 0) {
- if (marker.HumpTrack > 0) {
- ret = new RFHumpRoute();
- ret.TrackNumber = marker.HumpTrack;
- ret.MarkerId = marker.GetId();
- }
- break;
- }
- else if (junc = cast <Junction> found) {
- int dir = GetJunctionDirectionToObject(junc, prev);
- if (dir == Junction.DIRECTION_BACKWARD) {
- ret = new RFHumpRoute();
- ret.JnId = junc.GetId();
- ret.Left = Scan(junc.BeginTrackSearch(Junction.DIRECTION_LEFT), junc);
- ret.Right = Scan(junc.BeginTrackSearch(Junction.DIRECTION_RIGHT), junc);
- }
- else if (dir == Junction.DIRECTION_LEFT) {
- ret = new RFHumpRoute();
- ret.JnId = junc.GetId();
- ret.Left = Scan(junc.BeginTrackSearch(Junction.DIRECTION_BACKWARD), junc);
- }
- else if (dir == Junction.DIRECTION_RIGHT) {
- ret = new RFHumpRoute();
- ret.JnId = junc.GetId();
- ret.Right = Scan(junc.BeginTrackSearch(Junction.DIRECTION_BACKWARD), junc);
- }
- else {
- BadJunctionId = junc.GetId();
- }
- break;
- }
- if (it.GetDistance() > MaxSearchDistance)
- break;
- prev = found;
- IncOps();
- }
- DecHops();
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement