minor bugfixes

This commit is contained in:
Stephan Richter
2020-11-13 11:55:59 +01:00
parent 9eb8f5443a
commit f2ee754064
7 changed files with 15 additions and 12 deletions

View File

@@ -525,7 +525,6 @@ public class Route extends BaseClass implements Comparable<Route>{
if (o instanceof JSONObject) new Route().load((JSONObject)o, plan);
}
fis.close();
LOG.debug("json: {}",json.getClass());
}
private void loadConditions(JSONArray arr) {

View File

@@ -55,6 +55,7 @@ public class DelayedAction extends Action {
public void run() {
try {
Thread.sleep(delay);
LOG.debug("{} ms passed by, firing actions:",delay);
} catch (InterruptedException e) {
LOG.warn("Interrupted Exception thrown while waiting:",e);
}

View File

@@ -18,11 +18,9 @@ public class SetSpeed extends Action{
@Override
public boolean fire(Context context) {
if (context.train != null && context.train.speed > maxSpeed) {
context.train.setSpeed(maxSpeed);
return true;
}
return false;
if (isNull(context.train)) return false;
context.train.setSpeed(maxSpeed);
return true;
}
@Override

View File

@@ -631,6 +631,7 @@ public class Train extends BaseClass implements Comparable<Train> {
if (isNull(error) && !route.train(this)) error = t("Was not able to assign {} to {}!",this,route);
if (isSet(error)) {
route.reset();
route = null;
return error;
}
setSpeed(128);

View File

@@ -47,8 +47,9 @@ public class Contact extends Tile{
}
public Contact addr(int address) {
contactsByAddr.remove(addr); // alte ID aus der Map löschen
addr = address;
contactsByAddr.put(addr, this);
if (addr != 0) contactsByAddr.put(addr, this); // neue ID setzen
return this;
}