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