minor improvements
* when a train in shunting mode is directed to an occupied block, the train there is moved to the parking list of that block * some null pointer checks
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.28</version>
|
<version>1.4.29</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>
|
||||||
|
|||||||
@@ -401,6 +401,7 @@ public class Route extends BaseClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void freeIgnoring(Vector<Tile> skipTiles) {
|
private void freeIgnoring(Vector<Tile> skipTiles) {
|
||||||
|
if (isNull(context)) return;
|
||||||
Train train = context.train();
|
Train train = context.train();
|
||||||
Vector<Tile> reversedPath = reverse(path());
|
Vector<Tile> reversedPath = reverse(path());
|
||||||
if (isSet(skipTiles)) reversedPath.removeAll(skipTiles);
|
if (isSet(skipTiles)) reversedPath.removeAll(skipTiles);
|
||||||
|
|||||||
@@ -432,10 +432,11 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void dropTrace(boolean dropStuck) {
|
public Train dropTrace(boolean dropStuck) {
|
||||||
while (!trace.isEmpty()) trace.stream().findFirst().get().free(this);
|
while (!trace.isEmpty()) trace.stream().findFirst().get().free(this);
|
||||||
trace.clear();
|
trace.clear();
|
||||||
if (dropStuck) stuckTrace = null;
|
if (dropStuck) stuckTrace = null;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BrakeProcess endBrake() {
|
private BrakeProcess endBrake() {
|
||||||
@@ -453,7 +454,6 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
direction = endedRoute.endDirection; // muss vor der Auswertung des Destination-Tags stehen!
|
direction = endedRoute.endDirection; // muss vor der Auswertung des Destination-Tags stehen!
|
||||||
Block endBlock = endedRoute.endBlock();
|
Block endBlock = endedRoute.endBlock();
|
||||||
Block startBlock = endedRoute.startBlock();
|
Block startBlock = endedRoute.startBlock();
|
||||||
shunting = false;
|
|
||||||
if (endBlock == destination) {
|
if (endBlock == destination) {
|
||||||
destination = null;
|
destination = null;
|
||||||
|
|
||||||
@@ -504,6 +504,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
if ((!autopilot) || isNull(nextPreparedRoute) || (isSet(waitTime) && waitTime > 0)) setSpeed(0);
|
if ((!autopilot) || isNull(nextPreparedRoute) || (isSet(waitTime) && waitTime > 0)) setSpeed(0);
|
||||||
route = null;
|
route = null;
|
||||||
endBlock.setTrain(this);
|
endBlock.setTrain(this);
|
||||||
|
shunting = false; // wird in setTrain verwendet, muss also danach stehen
|
||||||
currentBlock = endBlock;
|
currentBlock = endBlock;
|
||||||
trace.add(endBlock);
|
trace.add(endBlock);
|
||||||
if (!trace.contains(startBlock)) startBlock.dropTrain(this);
|
if (!trace.contains(startBlock)) startBlock.dropTrain(this);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public class BrakeProcess extends BaseClass implements Runnable{
|
|||||||
updateDistance();
|
updateDistance();
|
||||||
LOG.debug("updateTime(): start speed was {} {}.",startSpeed,BaseClass.speedUnit);
|
LOG.debug("updateTime(): start speed was {} {}.",startSpeed,BaseClass.speedUnit);
|
||||||
Integer newTimeStep = timeStep;
|
Integer newTimeStep = timeStep;
|
||||||
|
if (isNull(newTimeStep)) return;
|
||||||
long calculated;
|
long calculated;
|
||||||
int step = 32*newTimeStep;
|
int step = 32*newTimeStep;
|
||||||
for (int i=0; i<20; i++) {
|
for (int i=0; i<20; i++) {
|
||||||
|
|||||||
@@ -453,6 +453,15 @@ public abstract class Block extends StretchableTile{
|
|||||||
internalContacts.remove(blockContact);
|
internalContacts.remove(blockContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setTrain(Train newTrain) {
|
||||||
|
if (isDisabled()) return false;
|
||||||
|
if (isNull(newTrain)) return false;
|
||||||
|
Train occupyingTrain = occupyingTrain();
|
||||||
|
if (isSet(occupyingTrain) && newTrain != occupyingTrain && newTrain.isShunting()) parkedTrains.add(occupyingTrain.dropTrace(false));
|
||||||
|
return super.setTrain(newTrain);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract List<Connector> startPoints();
|
public abstract List<Connector> startPoints();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -465,10 +465,10 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
if (isNull(newTrain)) return false;
|
if (isNull(newTrain)) return false;
|
||||||
if (isSet(reservingTrain) && newTrain != reservingTrain) return false;
|
if (isSet(reservingTrain) && newTrain != reservingTrain) return false;
|
||||||
if (isSet(lockingTrain) && newTrain != lockingTrain) return false;
|
if (isSet(lockingTrain) && newTrain != lockingTrain) return false;
|
||||||
if (isSet(occupyingTrain) && newTrain != occupyingTrain) return false;
|
if (isSet(occupyingTrain) && (newTrain != occupyingTrain) && !newTrain.isShunting()) return false;
|
||||||
|
reservingTrain = lockingTrain = null;
|
||||||
if (occupyingTrain == newTrain) return true;
|
if (occupyingTrain == newTrain) return true;
|
||||||
occupyingTrain = newTrain;
|
occupyingTrain = newTrain;
|
||||||
reservingTrain = lockingTrain = null;
|
|
||||||
plan.place(this);
|
plan.place(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user