This commit is contained in:
Stephan Richter
2020-11-12 18:45:03 +01:00
parent 64435ef68b
commit f103954a30
7 changed files with 13 additions and 8 deletions

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId>
<version>0.11.8</version>
<version>0.11.9</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

View File

@@ -234,7 +234,7 @@ public class Application extends BaseClass{
}
Object response = handle(params);
LOG.debug("response ({}): {}",response.getClass().getSimpleName(),response);
if (isSet(response)) LOG.debug("response ({}): {}",response.getClass().getSimpleName(),response);
send(client,response instanceof String || response instanceof Tag ? response : plan.html());
} catch (Exception e) {

View File

@@ -587,6 +587,7 @@ public class Plan extends BaseClass{
* @param tile
*/
private void remove(Tile tile) {
if (isNull(tile)) return;
removeTile(tile.x,tile.y);
if (tile instanceof Block) blocks.remove(tile);
for (int i=1; i<tile.width(); i++) removeTile(tile.x+i, tile.y); // remove shadow tiles

View File

@@ -365,13 +365,13 @@ public class Route extends BaseClass{
}
if (isSet(train)) {
train.set(endBlock);
train.heading(endDirection.inverse());
if (endBlock == train.destination()) {
train.destination(null).quitAutopilot();
plan.stream(t("{} reached it`s destination!",train));
} else {
train.setWaitTime(endBlock.getWaitTime(train));
}
train.heading(endDirection.inverse());
if (train.route == this) train.route = null;
}
train = null;
@@ -589,6 +589,7 @@ public class Route extends BaseClass{
train.set(startBlock);
train.heading(startDirection);
if (train.route == this) train.route = null;
train = null;
}
triggeredContacts.clear();
return true;

View File

@@ -17,6 +17,7 @@ public class TrainLength extends Condition {
@Override
public boolean fulfilledBy(Context context) {
if (isNull(context.train)) return false;
return (context.train.length() < maxLength) != inverted;
}

View File

@@ -585,7 +585,8 @@ public class Train extends BaseClass implements Comparable<Train> {
}
public void setWaitTime(Range waitTime) {
if (autopilot != null) autopilot.waitTime = waitTime.random();
if (isNull(autopilot)) return;
autopilot.waitTime = waitTime.random();
LOG.debug("{} waiting {} secs...",this,autopilot.waitTime/1000d);
}
@@ -633,7 +634,10 @@ public class Train extends BaseClass implements Comparable<Train> {
public Object stopNow() {
quitAutopilot();
setSpeed(0);
if (isSet(route)) route.reset();
if (isSet(route)) {
route.reset();
route = null;
}
return t("Stopped {}.",this);
}

View File

@@ -337,9 +337,7 @@ public abstract class Block extends StretchableTile implements Comparable<Block>
Train newTrain = Train.get(trainId);
if (isSet(newTrain) && newTrain != train) {
newTrain.dropTrace();
if (connections(newTrain.direction()).isEmpty()) {
newTrain.heading(null);
}
if (connections(newTrain.direction()).isEmpty()) newTrain.heading(null);
newTrain.set(this);
}
}