Browse Source

bugfixes

lookup-tables
Stephan Richter 5 years ago
parent
commit
f103954a30
  1. 2
      pom.xml
  2. 2
      src/main/java/de/srsoftware/web4rail/Application.java
  3. 1
      src/main/java/de/srsoftware/web4rail/Plan.java
  4. 3
      src/main/java/de/srsoftware/web4rail/Route.java
  5. 1
      src/main/java/de/srsoftware/web4rail/conditions/TrainLength.java
  6. 8
      src/main/java/de/srsoftware/web4rail/moving/Train.java
  7. 4
      src/main/java/de/srsoftware/web4rail/tiles/Block.java

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>0.11.8</version> <version>0.11.9</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>

2
src/main/java/de/srsoftware/web4rail/Application.java

@ -234,7 +234,7 @@ public class Application extends BaseClass{
} }
Object response = handle(params); 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()); send(client,response instanceof String || response instanceof Tag ? response : plan.html());
} catch (Exception e) { } catch (Exception e) {

1
src/main/java/de/srsoftware/web4rail/Plan.java

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

3
src/main/java/de/srsoftware/web4rail/Route.java

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

1
src/main/java/de/srsoftware/web4rail/conditions/TrainLength.java

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

8
src/main/java/de/srsoftware/web4rail/moving/Train.java

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

4
src/main/java/de/srsoftware/web4rail/tiles/Block.java

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

Loading…
Cancel
Save