bugfixes
This commit is contained in:
@@ -82,10 +82,6 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
|
||||
public boolean fire(Context context,Object cause) {
|
||||
for (Action action : actions) {
|
||||
if (context.invalidated()) {
|
||||
LOG.debug("Context has been invalidated, aborting {}",this);
|
||||
return false;
|
||||
}
|
||||
LOG.debug("firing \"{}\"",action);
|
||||
if (!action.fire(context,cause)) {
|
||||
LOG.warn("{} failed",action);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class PreserveRoute extends Action {
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
if (context.invalidated()) return false;
|
||||
Train train = context.train();
|
||||
Route route = context.route();
|
||||
// These are errors:
|
||||
|
||||
@@ -35,6 +35,7 @@ public class SetSignal extends Action {
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
if (context.invalidated()) return false;
|
||||
if (isNull(signal)) return false;
|
||||
return signal.state(state);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class SetSpeed extends Action{
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
if (context.invalidated()) return false;
|
||||
if (isNull(context.train())) return false;
|
||||
context.train().setSpeed(speed);
|
||||
return true;
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SetTurnout extends Action {
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
if (context.invalidated()) return false;
|
||||
if (isNull(turnout)) return false;
|
||||
if (!turnout.state(state).succeeded()) return false;
|
||||
if (turnout.address() == 0) return true;
|
||||
|
||||
@@ -570,7 +570,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
});
|
||||
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);
|
||||
if (isSet(currentBlock)) currentBlock.add(Train.this, direction);
|
||||
if (isSet(currentBlock)) {
|
||||
currentBlock.setTrain(Train.this);
|
||||
currentBlock.add(Train.this, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,9 +41,9 @@ public class BrakeProcess extends BaseClass implements Runnable{
|
||||
lastSpeed = train.speed;
|
||||
updateDistance();
|
||||
if (lastSpeed > targetSpeed) lastSpeed -= 10;
|
||||
if (lastSpeed < targetSpeed && (ended = true)) lastSpeed = targetSpeed;
|
||||
if (ended) break;
|
||||
if (lastSpeed != train.speed) train.setSpeed(lastSpeed);
|
||||
if (lastSpeed <= targetSpeed && (ended = true)) lastSpeed = targetSpeed;
|
||||
train.setSpeed(lastSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user