bugfix: route preselct was broken
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>1.2.19</version>
|
||||
<version>1.2.20</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.keawe.tools.translations.Translation;
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Plan.Direction;
|
||||
import de.srsoftware.web4rail.actions.Action;
|
||||
import de.srsoftware.web4rail.conditions.Condition;
|
||||
import de.srsoftware.web4rail.moving.Car;
|
||||
@@ -55,6 +56,7 @@ public abstract class BaseClass implements Constants{
|
||||
private Condition condition;
|
||||
private Car car;
|
||||
private Contact contact;
|
||||
private Direction direction;
|
||||
|
||||
public Context(BaseClass object) {
|
||||
main = object;
|
||||
@@ -96,6 +98,15 @@ public abstract class BaseClass implements Constants{
|
||||
public Contact contact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public Direction direction() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public Context direction(Direction newDirection) {
|
||||
direction = newDirection;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Route route() {
|
||||
return route;
|
||||
@@ -115,6 +126,7 @@ public abstract class BaseClass implements Constants{
|
||||
StringBuffer sb = new StringBuffer(getClass().getSimpleName());
|
||||
sb.append("(");
|
||||
sb.append(t("Train: {}",train));
|
||||
if (isSet(direction)) sb.append(", "+t("Direction: {}",direction));
|
||||
if (isSet(route)) sb.append(", "+t("Route: {}",route));
|
||||
if (isSet(contact)) sb.append(", "+t("Contact: {}",contact));
|
||||
sb.append(")");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PathFinder extends BaseClass{
|
||||
if (error) return availableRoutes;
|
||||
|
||||
Block destination = train.destination();
|
||||
Direction direction = train.direction();
|
||||
Direction direction = context.direction();
|
||||
/* if (isSet(direction)) {
|
||||
LOG.debug("{}Looking for {}-bound routes from {}",inset,direction,block);
|
||||
} else {
|
||||
@@ -68,8 +68,7 @@ public class PathFinder extends BaseClass{
|
||||
priority = 1_000_000;
|
||||
} else {
|
||||
LOG.debug("{}- Candidate: {}",inset,routeCandidate.shortName());
|
||||
Context forwardContext = new Context(train);
|
||||
forwardContext.block(routeCandidate.endBlock()).route(null);
|
||||
Context forwardContext = new Context(train).block(routeCandidate.endBlock()).route(null).direction(routeCandidate.endDirection);
|
||||
visitedRoutes.add(routeCandidate);
|
||||
TreeMap<Integer, List<Route>> forwardRoutes = availableRoutes(forwardContext,visitedRoutes);
|
||||
visitedRoutes.remove(routeCandidate);
|
||||
|
||||
@@ -574,7 +574,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
}
|
||||
|
||||
public void reserveNext() {
|
||||
Context context = new Context(this).route(route).block(route.endBlock());
|
||||
Context context = new Context(this).route(route).block(route.endBlock()).direction(route.endDirection);
|
||||
Route nextRoute = PathFinder.chooseRoute(context);
|
||||
if (isNull(nextRoute)) return;
|
||||
|
||||
@@ -685,7 +685,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
if (maxSpeed() == 0) return t("Train has maximum speed of 0 {}, cannot go!",speedUnit);
|
||||
if (isSet(route)) route.reset(); // reset route previously chosen
|
||||
|
||||
Context context = new Context(this).block(this.currentBlock);
|
||||
Context context = new Context(this).block(currentBlock).direction(direction);
|
||||
String error = null;
|
||||
if (isSet(nextRoute)) {
|
||||
route = nextRoute;
|
||||
|
||||
Reference in New Issue
Block a user