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.3.68</version>
|
||||
<version>1.3.69</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -524,7 +524,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
public void afterLoad() {
|
||||
if (json.has(TRACE)) json.getJSONArray(TRACE).forEach(elem -> {
|
||||
Tile tile = plan.get(new Id(elem.toString()), false);
|
||||
if (tile.setTrain(Train.this)) trace.add(tile);
|
||||
if (tile instanceof Block) {
|
||||
((Block)tile).add(Train.this, direction);
|
||||
} else if (tile.setTrain(Train.this));
|
||||
trace.add(tile);
|
||||
});
|
||||
if (json.has(BLOCK)) {// do not move this up! during set, other fields will be referenced!
|
||||
currentBlock = (Block) plan.get(Id.from(json, BLOCK), false);
|
||||
@@ -759,7 +762,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
|
||||
public void set(Block newBlock) {
|
||||
LOG.debug("{}.set({})",this,newBlock);
|
||||
if (isSet(currentBlock)) currentBlock.free(this);
|
||||
if (isSet(currentBlock)) {
|
||||
if (newBlock == currentBlock) return;
|
||||
currentBlock.free(this);
|
||||
}
|
||||
currentBlock = newBlock;
|
||||
if (isSet(currentBlock)) {
|
||||
currentBlock.setTrain(this);
|
||||
|
||||
@@ -395,8 +395,9 @@ public abstract class Block extends StretchableTile{
|
||||
Train train = BaseClass.get(tID);
|
||||
Direction direction = to.has(DIRECTION) ? Direction.valueOf(to.getString(DIRECTION)) : null;
|
||||
if (isSet(train)) {
|
||||
trains.add(train, direction);
|
||||
train.set(Block.this);
|
||||
trains.add(train, direction);
|
||||
status = Status.OCCUPIED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user