bugfixes
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.4.20</version>
|
||||
<version>1.4.21</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -26,7 +26,7 @@ function addMessage(txt){
|
||||
messages.unshift(txt);
|
||||
if (messages.length>5) messages.pop();
|
||||
updateMessages();
|
||||
setTimeout(fadeMessage,30000);
|
||||
setTimeout(fadeMessage,60000);
|
||||
}
|
||||
|
||||
function addTile(x,y){
|
||||
|
||||
@@ -428,6 +428,10 @@ public class Route extends BaseClass {
|
||||
return nextPreparedRoute;
|
||||
}
|
||||
|
||||
public boolean hasTriggeredContacts() {
|
||||
return triggeredContacts.size()>0;
|
||||
}
|
||||
|
||||
public Id id() {
|
||||
if (isNull(id)) id = new Id(""+(generateName().hashCode()));
|
||||
return id;
|
||||
|
||||
@@ -195,7 +195,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
|
||||
public String brakeId(boolean reversed) {
|
||||
TreeSet<String> carIds = new TreeSet<String>();
|
||||
cars.stream().map(car -> car.id()+":"+(car.orientation == reversed ? "r":"f")).forEach(carIds::add);
|
||||
cars.stream()
|
||||
.filter(car -> car instanceof Locomotive)
|
||||
.map(car -> car.id()+":"+(car.orientation == reversed ? "r":"f"))
|
||||
.forEach(carIds::add);
|
||||
String brakeId = md5sum(carIds);
|
||||
LOG.debug("generated new {} brake id for {}: {}",reversed?"backward":"forward",this,brakeId);
|
||||
return brakeId;
|
||||
@@ -885,7 +888,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
public Train set(Block newBlock) {
|
||||
LOG.debug("{}.set({})",this,newBlock);
|
||||
if (isSet(currentBlock)) {
|
||||
if (newBlock == currentBlock) return this;
|
||||
if (newBlock == currentBlock) {
|
||||
if (currentBlock.occupyingTrain() != this) currentBlock.setTrain(this);
|
||||
return this;
|
||||
}
|
||||
currentBlock.free(this);
|
||||
}
|
||||
currentBlock = newBlock;
|
||||
@@ -1042,7 +1048,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
endBrake();
|
||||
setSpeed(0);
|
||||
quitAutopilot();
|
||||
if (isSet(route)) {
|
||||
if (isSet(route) && route.hasTriggeredContacts()) {
|
||||
stuckTrace = new HashSet<Tile>();
|
||||
for (Tile tile : route.path()) { // collect occupied tiles of route. stuckTrace is considered during next route search
|
||||
if (trace.contains(tile)) stuckTrace.add(tile);
|
||||
|
||||
@@ -78,6 +78,8 @@ public class RoutePrepper extends BaseClass implements Runnable{
|
||||
LOG.debug("{} is heading for {}, starting breadth-first search…",train,destination);
|
||||
|
||||
HashMap<Route,Candidate> predecessors = new HashMap<>() {
|
||||
private static final long serialVersionUID = -42682947866294566L;
|
||||
|
||||
public String toString() {
|
||||
return entrySet().stream()
|
||||
.sorted((e1,e2) -> e1.getValue().toString().compareTo(e2.getValue().toString()))
|
||||
|
||||
@@ -503,8 +503,12 @@ public abstract class Block extends StretchableTile{
|
||||
if (isSet(newTrain) && newTrain != occupyingTrain()) {
|
||||
free(occupyingTrain());
|
||||
newTrain.dropTrace();
|
||||
if (connections(newTrain.direction()).isEmpty()) newTrain.heading(null);
|
||||
newTrain.set(this);
|
||||
if (connections(newTrain.direction()).isEmpty()) newTrain.heading(null);
|
||||
newTrain.set(this);
|
||||
}
|
||||
if (newTrain.currentBlock() != this) {
|
||||
newTrain.dropTrace();
|
||||
newTrain.set(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user