Browse Source

fixed bug:

Die Condition "block free" meldete true, wenn der Context den Zug enthielt, der sich im getesteten Block aufhält.
Nun verhält es sich korrekt: bei einem belegten Block wird immer "false" zurückgeliefert, unabhängig vom Zug im Kontext
master
Stephan Richter 4 years ago
parent
commit
f8ad1b42e0
  1. 2
      pom.xml
  2. 2
      src/main/java/de/srsoftware/web4rail/conditions/BlockFree.java

2
pom.xml

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId>
<version>1.5.27</version>
<version>1.5.28</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

2
src/main/java/de/srsoftware/web4rail/conditions/BlockFree.java

@ -25,6 +25,8 @@ public class BlockFree extends Condition { @@ -25,6 +25,8 @@ public class BlockFree extends Condition {
@Override
public boolean fulfilledBy(Context context) {
if (isNull(context)) return false;
if (isSet(context.train())) context = context.clone().train(null); // block.isFree would return true, if context.train == block.train. That has to be avoided!
if (!inverted) return block.isFreeFor(context);
return !block.isFreeFor(new Context(block)); // block.isFreeFor würde true liefern, wenn der Zug im Kontext gleich dem Zug im Block wäre. Da wir aber nur wissen wollen, ob der Block belegt ist, brauchen wir einen Context ohne Zug.
}

Loading…
Cancel
Save