bugfixes
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>1.4.23</version>
|
<version>1.4.24</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ function runAction(ev){
|
|||||||
|
|
||||||
function stream(ev){
|
function stream(ev){
|
||||||
var data = ev.data;
|
var data = ev.data;
|
||||||
//console.log("received: ",data);
|
console.log("received: ",data);
|
||||||
if (data.startsWith('<svg')) return place(data);
|
if (data.startsWith('<svg')) return place(data);
|
||||||
if (data.startsWith("heartbeat")) return heartbeat(data);
|
if (data.startsWith("heartbeat")) return heartbeat(data);
|
||||||
if (data.startsWith("place ")) return place(data.substring(6));
|
if (data.startsWith("place ")) return place(data.substring(6));
|
||||||
@@ -336,8 +336,8 @@ function toggleFullscreen(){
|
|||||||
|
|
||||||
function updateMessages() {
|
function updateMessages() {
|
||||||
if (messages.length>0) {
|
if (messages.length>0) {
|
||||||
messageOpacity = 100;
|
messageOpacity = 1000;
|
||||||
$('#messages').html(messages.join('<br/>')).css('opacity',messageOpacity/OPAC);
|
$('#messages').html(messages.slice().reverse().join('<br/>')).css('opacity',messageOpacity/OPAC);
|
||||||
} else $('#messages').html('');
|
} else $('#messages').html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ Date/Time : Datum/Zeit
|
|||||||
Decoder address : Decoder-Adresse
|
Decoder address : Decoder-Adresse
|
||||||
decouple : Abkuppeln
|
decouple : Abkuppeln
|
||||||
decoupler : decoupler
|
decoupler : decoupler
|
||||||
Decoupler : Entkuppler
|
Decoupler : Entkuppler
|
||||||
|
Default maintenance intervall : Standard-Wartungsintervall
|
||||||
DelayedAction : verzögerte Aktion
|
DelayedAction : verzögerte Aktion
|
||||||
Delay must not be less than zero! : Verzögerung darf nicht kleiner als null sein!
|
Delay must not be less than zero! : Verzögerung darf nicht kleiner als null sein!
|
||||||
delete : entfernen
|
delete : entfernen
|
||||||
@@ -262,6 +263,7 @@ Origin and destination : Start und Ziel
|
|||||||
Origin\: {} to {} : Start: {} nach {}
|
Origin\: {} to {} : Start: {} nach {}
|
||||||
parked trains : abgestellte Züge
|
parked trains : abgestellte Züge
|
||||||
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
||||||
|
Plan updated. : Plan aktualisiert.
|
||||||
Port for state {} : Anschluss für Status {}
|
Port for state {} : Anschluss für Status {}
|
||||||
PreserveRoute : Anschlußroute vorwählen
|
PreserveRoute : Anschlußroute vorwählen
|
||||||
Programming : Programmierung
|
Programming : Programmierung
|
||||||
@@ -339,6 +341,7 @@ simplify name : Name vereinfachen
|
|||||||
Simulating movement of {}... : Simuliere Fahrt von {}...
|
Simulating movement of {}... : Simuliere Fahrt von {}...
|
||||||
Slower ({} {}) : {} {} langsamer
|
Slower ({} {}) : {} {} langsamer
|
||||||
SOUTH : Süden
|
SOUTH : Süden
|
||||||
|
Speed step : Geschwindigketis-Schritt
|
||||||
Speed unit : Geschwindigkeits-Einheit
|
Speed unit : Geschwindigkeits-Einheit
|
||||||
Split behind : Nach
|
Split behind : Nach
|
||||||
SplitTrain : Zug teilen
|
SplitTrain : Zug teilen
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ public abstract class LoadCallback {
|
|||||||
public abstract void afterLoad();
|
public abstract void afterLoad();
|
||||||
|
|
||||||
public static void fire() {
|
public static void fire() {
|
||||||
for (LoadCallback callback : callbacks) callback.afterLoad();
|
while (!callbacks.isEmpty()) callbacks.removeFirst().afterLoad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ public class Plan extends BaseClass{
|
|||||||
private static final String DISCOVERY_MODE = "discovery_mode";
|
private static final String DISCOVERY_MODE = "discovery_mode";
|
||||||
private static final String DISCOVER_NEW = "discover_new";
|
private static final String DISCOVER_NEW = "discover_new";
|
||||||
private static final String DISCOVER_UPDATE = "discover_update";
|
private static final String DISCOVER_UPDATE = "discover_update";
|
||||||
|
private static final String MAINTENANCE_INTERVAL = "maintenance_interval";
|
||||||
|
|
||||||
private String name = DEFAULT_NAME;
|
private String name = DEFAULT_NAME;
|
||||||
|
|
||||||
private ControlUnit controlUnit = new ControlUnit(this); // the control unit, to which the plan is connected
|
private ControlUnit controlUnit = new ControlUnit(this); // the control unit, to which the plan is connected
|
||||||
@@ -536,6 +538,7 @@ public class Plan extends BaseClass{
|
|||||||
.put(FINAL_SPEED, Train.defaultEndSpeed)
|
.put(FINAL_SPEED, Train.defaultEndSpeed)
|
||||||
.put(SPEED_STEP, Train.defaultSpeedStep)
|
.put(SPEED_STEP, Train.defaultSpeedStep)
|
||||||
.put(FREE_BEHIND_TRAIN, Route.freeBehindTrain)
|
.put(FREE_BEHIND_TRAIN, Route.freeBehindTrain)
|
||||||
|
.put(MAINTENANCE_INTERVAL, Car.defaulMaintenanceDist)
|
||||||
.put(LENGTH_UNIT, lengthUnit)
|
.put(LENGTH_UNIT, lengthUnit)
|
||||||
.put(SPEED_UNIT, speedUnit)
|
.put(SPEED_UNIT, speedUnit)
|
||||||
.put(TILE, jTiles);
|
.put(TILE, jTiles);
|
||||||
@@ -566,6 +569,7 @@ public class Plan extends BaseClass{
|
|||||||
if (json.has(FINAL_SPEED)) Train.defaultEndSpeed = json.getInt(FINAL_SPEED);
|
if (json.has(FINAL_SPEED)) Train.defaultEndSpeed = json.getInt(FINAL_SPEED);
|
||||||
if (json.has(SPEED_STEP)) Train.defaultSpeedStep = json.getInt(SPEED_STEP);
|
if (json.has(SPEED_STEP)) Train.defaultSpeedStep = json.getInt(SPEED_STEP);
|
||||||
if (json.has(FREE_BEHIND_TRAIN)) Route.freeBehindTrain = json.getBoolean(FREE_BEHIND_TRAIN);
|
if (json.has(FREE_BEHIND_TRAIN)) Route.freeBehindTrain = json.getBoolean(FREE_BEHIND_TRAIN);
|
||||||
|
if (json.has(MAINTENANCE_INTERVAL)) Car.defaulMaintenanceDist = json.getLong(MAINTENANCE_INTERVAL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Car.loadAll(name+".cars",plan);
|
Car.loadAll(name+".cars",plan);
|
||||||
@@ -747,8 +751,9 @@ public class Plan extends BaseClass{
|
|||||||
formInputs.add(null, new Input(ACTION,ACTION_UPDATE));
|
formInputs.add(null, new Input(ACTION,ACTION_UPDATE));
|
||||||
formInputs.add(t("Length unit"),new Input(LENGTH_UNIT, lengthUnit));
|
formInputs.add(t("Length unit"),new Input(LENGTH_UNIT, lengthUnit));
|
||||||
formInputs.add(t("Speed unit"),new Input(SPEED_UNIT, speedUnit));
|
formInputs.add(t("Speed unit"),new Input(SPEED_UNIT, speedUnit));
|
||||||
formInputs.add(t("Speed step"),new Input(SPEED_STEP, Train.defaultSpeedStep).attr("title", t("Speeds are always increadsed/decreased by this value")));
|
formInputs.add(t("Speed step"),new Input(SPEED_STEP, Train.defaultSpeedStep).attr("title", t("Speeds are always increadsed/decreased by this value")).addTo(new Tag("span")).content(NBSP+Plan.speedUnit));
|
||||||
formInputs.add(t("Lower speed limit"),new Input(FINAL_SPEED, Train.defaultEndSpeed).attr("title", t("Final speed after breaking, before halting")));
|
formInputs.add(t("Lower speed limit"),new Input(FINAL_SPEED, Train.defaultEndSpeed).attr("title", t("Final speed after breaking, before halting")).addTo(new Tag("span")).content(NBSP+Plan.speedUnit));
|
||||||
|
formInputs.add(t("Default maintenance intervall"),new Input(MAINTENANCE_INTERVAL, Car.defaulMaintenanceDist).numeric().addTo(new Tag("span")).content(NBSP+Plan.lengthUnit));
|
||||||
formInputs.add(t("Free tiles behind train"),new Checkbox(FREE_BEHIND_TRAIN, t("If checked, tiles behind the train are freed according to the length of the train and the tiles. If it is unchecked, tiles will not get free before route is finished."), Route.freeBehindTrain));
|
formInputs.add(t("Free tiles behind train"),new Checkbox(FREE_BEHIND_TRAIN, t("If checked, tiles behind the train are freed according to the length of the train and the tiles. If it is unchecked, tiles will not get free before route is finished."), Route.freeBehindTrain));
|
||||||
formInputs.add(t("Allow editing JSON of action lists"),new Checkbox(ALLOW_JSON_EDIT, t("Do you know, what you are doing?"), allowJsonEdit ));
|
formInputs.add(t("Allow editing JSON of action lists"),new Checkbox(ALLOW_JSON_EDIT, t("Do you know, what you are doing?"), allowJsonEdit ));
|
||||||
|
|
||||||
@@ -1064,10 +1069,13 @@ public class Plan extends BaseClass{
|
|||||||
if (params.containsKey(SPEED_UNIT)) speedUnit = params.get(SPEED_UNIT);
|
if (params.containsKey(SPEED_UNIT)) speedUnit = params.get(SPEED_UNIT);
|
||||||
if (params.containsKey(SPEED_STEP)) Train.defaultSpeedStep = Integer.parseInt(params.get(SPEED_STEP));
|
if (params.containsKey(SPEED_STEP)) Train.defaultSpeedStep = Integer.parseInt(params.get(SPEED_STEP));
|
||||||
if (params.containsKey(FINAL_SPEED)) Train.defaultEndSpeed = Integer.parseInt(params.get(FINAL_SPEED));
|
if (params.containsKey(FINAL_SPEED)) Train.defaultEndSpeed = Integer.parseInt(params.get(FINAL_SPEED));
|
||||||
|
if (params.containsKey(MAINTENANCE_INTERVAL)) try {
|
||||||
|
Car.defaulMaintenanceDist = Long.parseLong(params.get(MAINTENANCE_INTERVAL));
|
||||||
|
} catch(NumberFormatException e) {};
|
||||||
allowJsonEdit = "on".equalsIgnoreCase(params.get(ALLOW_JSON_EDIT));
|
allowJsonEdit = "on".equalsIgnoreCase(params.get(ALLOW_JSON_EDIT));
|
||||||
Route.freeBehindTrain = "on".equalsIgnoreCase(params.get(FREE_BEHIND_TRAIN));
|
Route.freeBehindTrain = "on".equalsIgnoreCase(params.get(FREE_BEHIND_TRAIN));
|
||||||
|
|
||||||
return t("Plan updated.");
|
return properties(t("Plan updated."));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object updateTimes(HashMap<String, String> params) throws IOException {
|
private Object updateTimes(HashMap<String, String> params) throws IOException {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import de.srsoftware.web4rail.BaseClass;
|
import de.srsoftware.web4rail.BaseClass;
|
||||||
import de.srsoftware.web4rail.LoadCallback;
|
import de.srsoftware.web4rail.LoadCallback;
|
||||||
|
import de.srsoftware.web4rail.moving.Train;
|
||||||
import de.srsoftware.web4rail.tags.Fieldset;
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
import de.srsoftware.web4rail.tags.Window;
|
import de.srsoftware.web4rail.tags.Window;
|
||||||
import de.srsoftware.web4rail.tiles.Block;
|
import de.srsoftware.web4rail.tiles.Block;
|
||||||
@@ -23,8 +24,12 @@ public class DetermineTrainInBlock extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fire(Context context,Object cause) {
|
public boolean fire(Context context,Object cause) {
|
||||||
context.block(block);
|
if (isNull(block)) return false;
|
||||||
context.train(block.occupyingTrain());
|
Train train = block.occupyingTrain();
|
||||||
|
if (isSet(train)) {
|
||||||
|
context.block(block);
|
||||||
|
context.train(block.occupyingTrain());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,12 +64,11 @@ public class BlockFree extends Condition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object update(HashMap<String, String> params) {
|
protected Object update(HashMap<String, String> params) {
|
||||||
if (!params.containsKey(BLOCK)) return t("No block id passed to BlockFree.update()!");
|
if (params.containsKey(BLOCK)) {
|
||||||
Tile tile = plan.get(new Id(params.get(BLOCK)), true);
|
Tile tile = plan.get(new Id(params.get(BLOCK)), true);
|
||||||
if (tile instanceof Block) {
|
if (tile instanceof Block) {
|
||||||
block = (Block) tile;
|
block = (Block) tile;
|
||||||
} else {
|
} else return t("Clicked tile is not a {}!",t("block"));
|
||||||
return t("Clicked tile is not a {}!",t("block"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.update(params);
|
return super.update(params);
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
private static final String DRIVEN_DISTANCE = "driven_distance";
|
private static final String DRIVEN_DISTANCE = "driven_distance";
|
||||||
|
|
||||||
private static final String MAINTENANCE = "maintenance";
|
private static final String MAINTENANCE = "maintenance";
|
||||||
|
|
||||||
|
public static long defaulMaintenanceDist = 1_000_000;
|
||||||
|
|
||||||
protected HashSet<String> tags = new HashSet<>();
|
protected HashSet<String> tags = new HashSet<>();
|
||||||
private HashSet<MaintnanceTask> tasks = new HashSet<>();
|
private HashSet<MaintnanceTask> tasks = new HashSet<>();
|
||||||
|
|
||||||
@@ -222,7 +225,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
new Input(ACTION,ACTION_ADD).hideIn(form);
|
new Input(ACTION,ACTION_ADD).hideIn(form);
|
||||||
new Input(REALM_CAR,id()).hideIn(form);
|
new Input(REALM_CAR,id()).hideIn(form);
|
||||||
MaintnanceTask.selector().addTo(new Label(t("Task type")+NBSP)).addTo(form);
|
MaintnanceTask.selector().addTo(new Label(t("Task type")+NBSP)).addTo(form);
|
||||||
new Input(MaintnanceTask.INTERVAL,1_000_000).numeric().addTo(new Label(t("Interval")+NBSP)).content(NBSP+Plan.lengthUnit).addTo(form);
|
new Input(MaintnanceTask.INTERVAL,Car.defaulMaintenanceDist).numeric().addTo(new Label(t("Interval")+NBSP)).content(NBSP+Plan.lengthUnit).addTo(form);
|
||||||
new Button(t("add"), form).addTo(form);
|
new Button(t("add"), form).addTo(form);
|
||||||
return form.addTo(fieldset);
|
return form.addTo(fieldset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,9 +432,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void dropTrace() {
|
public void dropTrace(boolean dropStuck) {
|
||||||
trace.forEach(tile -> tile.free(this));
|
while (!trace.isEmpty()) trace.stream().findFirst().get().free(this);
|
||||||
trace.clear();
|
trace.clear();
|
||||||
|
if (dropStuck) stuckTrace = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BrakeProcess endBrake() {
|
private BrakeProcess endBrake() {
|
||||||
@@ -1103,6 +1104,12 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
reverse(cars);
|
reverse(cars);
|
||||||
return reverse();
|
return reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unTrace(Tile tile) {
|
||||||
|
if (isSet(trace)) trace.remove(tile);
|
||||||
|
if (isSet(stuckTrace)) stuckTrace.remove(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected Window update(HashMap<String, String> params) {
|
protected Window update(HashMap<String, String> params) {
|
||||||
LOG.debug("update({})",params);
|
LOG.debug("update({})",params);
|
||||||
@@ -1166,8 +1173,12 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
trace = newTrace;
|
trace = newTrace;
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean usesAutopilot() {
|
public boolean usesAutopilot() {
|
||||||
return autopilot;
|
return autopilot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
Direction startDirection = c.direction();
|
Direction startDirection = c.direction();
|
||||||
LOG.debug("RoutePrepper.availableRoutes({},{},{}), dest = {}",startBlock,startDirection,train,destination);
|
LOG.debug("RoutePrepper.availableRoutes({},{},{}), dest = {}",startBlock,startDirection,train,destination);
|
||||||
|
|
||||||
TreeMap<Integer, LinkedList<Route>> candidates = routesFrom(c);
|
TreeMap<Integer, LinkedList<Route>> candidates = routesFrom(c); // map: score → [route]
|
||||||
|
|
||||||
if (isNull(destination)) {
|
if (isNull(destination)) {
|
||||||
LOG.debug("{} has no destination, returning {}",train,candidates);
|
LOG.debug("{} has no destination, returning {}",train,candidates);
|
||||||
@@ -91,6 +91,7 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
TreeMap<Integer,LinkedList<Route>> routesToDest = new TreeMap<>();
|
TreeMap<Integer,LinkedList<Route>> routesToDest = new TreeMap<>();
|
||||||
|
|
||||||
int level = 0;
|
int level = 0;
|
||||||
|
int level2 = 0;
|
||||||
|
|
||||||
while (!candidates.isEmpty()) {
|
while (!candidates.isEmpty()) {
|
||||||
LOG.debug("Candidates for level {}:",level);
|
LOG.debug("Candidates for level {}:",level);
|
||||||
@@ -148,8 +149,9 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!routesToDest.isEmpty()) return routesToDest;
|
if (!routesToDest.isEmpty()) {
|
||||||
LOG.debug("No routes to {} found with distance {}!",destination,level);
|
if (level2++ > 5) return routesToDest;
|
||||||
|
} else LOG.debug("No routes to {} found with distance {}!",destination,level);
|
||||||
level ++;
|
level ++;
|
||||||
candidates = queue;
|
candidates = queue;
|
||||||
}
|
}
|
||||||
@@ -263,14 +265,20 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
|
|
||||||
Direction startDirection = c.direction();
|
Direction startDirection = c.direction();
|
||||||
|
|
||||||
LOG.debug(" RoutePrepper.routesFrom({},{},{}), dest = {}",startBlock,startDirection,train,destination);
|
LOG.debug(" RoutePrepper.routesFrom({},{},{}), dest = {}:",startBlock,startDirection,train,destination);
|
||||||
|
|
||||||
TreeMap<Integer, LinkedList<Route>> routes = new TreeMap<>();
|
TreeMap<Integer, LinkedList<Route>> routes = new TreeMap<>();
|
||||||
|
|
||||||
for (Route route : startBlock.leavingRoutes()) {
|
for (Route route : startBlock.leavingRoutes()) {
|
||||||
LOG.debug(" - evaluating {}",route);
|
|
||||||
|
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
|
if (isSet(startDirection) && route.startDirection != startDirection) { // Route startet entgegen der aktuellen Fahrtrichtung des Zuges
|
||||||
|
if (!train.pushPull) continue; // Zug kann nicht wenden
|
||||||
|
if (!startBlock.turnAllowed) continue; // Wenden im Block nicht gestattet
|
||||||
|
score -= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.debug(" - evaluating {}",route);
|
||||||
|
|
||||||
if (!route.allowed(new Context(train).block(startBlock).direction(startDirection))) {
|
if (!route.allowed(new Context(train).block(startBlock).direction(startDirection))) {
|
||||||
LOG.debug(" - {} not allowed for {}", route, train);
|
LOG.debug(" - {} not allowed for {}", route, train);
|
||||||
@@ -280,11 +288,6 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
|||||||
|
|
||||||
if (route.endBlock() == destination) score = 100_000;
|
if (route.endBlock() == destination) score = 100_000;
|
||||||
|
|
||||||
if (isSet(startDirection) && route.startDirection != startDirection) { // Route startet entgegen der aktuellen Fahrtrichtung des Zuges
|
|
||||||
if (!train.pushPull) continue; // Zug kann nicht wenden
|
|
||||||
if (!startBlock.turnAllowed) continue; // Wenden im Block nicht gestattet
|
|
||||||
score -= 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
LinkedList<Route> routesForScore = routes.get(score);
|
LinkedList<Route> routesForScore = routes.get(score);
|
||||||
if (isNull(routesForScore)) routes.put(score, routesForScore = new LinkedList<Route>());
|
if (isNull(routesForScore)) routes.put(score, routesForScore = new LinkedList<Route>());
|
||||||
|
|||||||
@@ -407,7 +407,9 @@ public abstract class Block extends StretchableTile{
|
|||||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm,String...errors) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm,String...errors) {
|
||||||
formInputs.add(t("Name"),new Input(NAME, name));
|
formInputs.add(t("Name"),new Input(NAME, name));
|
||||||
formInputs.add("",new Checkbox(ALLOW_TURN,t("Turn allowed"),turnAllowed));
|
formInputs.add("",new Checkbox(ALLOW_TURN,t("Turn allowed"),turnAllowed));
|
||||||
formInputs.add(t("Train"),Train.selector(parkedTrains.first(), null));
|
Train train = occupyingTrain();
|
||||||
|
if (isNull(train)) train = parkedTrains.first();
|
||||||
|
formInputs.add(t("Train"),Train.selector(train, null));
|
||||||
postForm.add(contactForm());
|
postForm.add(contactForm());
|
||||||
postForm.add(waitTimeForm());
|
postForm.add(waitTimeForm());
|
||||||
if (!parkedTrains.isEmpty()) postForm.add(trainList());
|
if (!parkedTrains.isEmpty()) postForm.add(trainList());
|
||||||
@@ -502,12 +504,12 @@ public abstract class Block extends StretchableTile{
|
|||||||
Train newTrain = Train.get(trainId);
|
Train newTrain = Train.get(trainId);
|
||||||
if (isSet(newTrain) && newTrain != occupyingTrain()) {
|
if (isSet(newTrain) && newTrain != occupyingTrain()) {
|
||||||
free(occupyingTrain());
|
free(occupyingTrain());
|
||||||
newTrain.dropTrace();
|
newTrain.dropTrace(true);
|
||||||
if (connections(newTrain.direction()).isEmpty()) newTrain.heading(null);
|
if (connections(newTrain.direction()).isEmpty()) newTrain.heading(null);
|
||||||
newTrain.set(this);
|
newTrain.set(this);
|
||||||
}
|
}
|
||||||
if (newTrain.currentBlock() != this) {
|
if (newTrain.currentBlock() != this) {
|
||||||
newTrain.dropTrace();
|
newTrain.dropTrace(true);
|
||||||
newTrain.set(this);
|
newTrain.set(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,12 +100,13 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
|
|
||||||
public boolean free(Train oldTrain) {
|
public boolean free(Train oldTrain) {
|
||||||
if (isNull(oldTrain)) return false;
|
if (isNull(oldTrain)) return false;
|
||||||
if (isSet(reservingTrain) && reservingTrain != oldTrain) return false;
|
boolean result = false;
|
||||||
if (isSet(lockingTrain) && lockingTrain != oldTrain) return false;
|
if (reservingTrain == oldTrain && (result = true)) reservingTrain = null;
|
||||||
if (isSet(occupyingTrain) && occupyingTrain != oldTrain) return false;
|
if (lockingTrain == oldTrain && (result = true)) lockingTrain = null;
|
||||||
reservingTrain = lockingTrain = occupyingTrain = null;
|
if (occupyingTrain == oldTrain && (result = true)) occupyingTrain = null;
|
||||||
plan.place(this);
|
oldTrain.unTrace(this);
|
||||||
return true;
|
if (result) plan.place(this);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int height() {
|
public int height() {
|
||||||
@@ -140,7 +141,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFreeFor(Context newTrain) {
|
public boolean isFreeFor(Context newTrain) {
|
||||||
LOG.debug("{}.isFreeFor({})", this, newTrain);
|
//LOG.debug("{}.isFreeFor({})", this, newTrain);
|
||||||
if (isDisabled()) {
|
if (isDisabled()) {
|
||||||
LOG.debug("{} is disabled!", this);
|
LOG.debug("{} is disabled!", this);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user