Browse Source

fixed bug: orientation of cars has not been saved

lookup-tables
Stephan Richter 4 years ago
parent
commit
8ab3b6d1a0
  1. 2
      pom.xml
  2. 3
      src/main/java/de/srsoftware/web4rail/moving/Car.java
  3. 3
      src/main/java/de/srsoftware/web4rail/moving/Locomotive.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.3.42</version>
<version>1.3.43</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

3
src/main/java/de/srsoftware/web4rail/moving/Car.java

@ -46,6 +46,7 @@ public class Car extends BaseClass implements Comparable<Car>{ @@ -46,6 +46,7 @@ public class Car extends BaseClass implements Comparable<Car>{
private static final String MAX_SPEED = "max_speed";
private static final String MAX_SPEED_REVERSE = "max_speed_reverse";
private static final String ORDER = "order";
private static final String ORIENTATION = "orientation";
protected HashSet<String> tags = new HashSet<String>();
private String name;
@ -122,6 +123,7 @@ public class Car extends BaseClass implements Comparable<Car>{ @@ -122,6 +123,7 @@ public class Car extends BaseClass implements Comparable<Car>{
json.put(LENGTH, length);
if (maxSpeedForward != 0) json.put(MAX_SPEED, maxSpeedForward);
if (maxSpeedReverse != 0) json.put(MAX_SPEED_REVERSE, maxSpeedReverse);
json.put(ORIENTATION, orientation);
json.put(STOCK_ID, stockId);
if (!tags.isEmpty()) json.put(TAGS, tags);
return json;
@ -165,6 +167,7 @@ public class Car extends BaseClass implements Comparable<Car>{ @@ -165,6 +167,7 @@ public class Car extends BaseClass implements Comparable<Car>{
if (json.has(MAX_SPEED_REVERSE)) maxSpeedReverse = json.getInt(MAX_SPEED_REVERSE);
if (json.has(STOCK_ID)) stockId = json.getString(STOCK_ID);
if (json.has(TAGS)) json.getJSONArray(TAGS).forEach(elem -> { tags.add(elem.toString()); });
if (json.has(ORIENTATION)) orientation=json.getBoolean(ORIENTATION);
return this;
}

3
src/main/java/de/srsoftware/web4rail/moving/Locomotive.java

@ -31,7 +31,6 @@ import de.srsoftware.web4rail.tiles.Block; @@ -31,7 +31,6 @@ import de.srsoftware.web4rail.tiles.Block;
public class Locomotive extends Car implements Constants,Device{
private static final String REVERSE = "reverse";
public static final String LOCOMOTIVE = "locomotive";
private static final Integer CV_ADDR = 1;
private static final String CVS = "cvs";
@ -243,7 +242,6 @@ public class Locomotive extends Car implements Constants,Device{ @@ -243,7 +242,6 @@ public class Locomotive extends Car implements Constants,Device{
public JSONObject json() {
JSONObject json = super.json();
JSONObject loco = new JSONObject();
loco.put(REVERSE, orientation);
loco.put(PROTOCOL, proto);
json.put(LOCOMOTIVE, loco);
loco.put(CVS, cvs);
@ -255,7 +253,6 @@ public class Locomotive extends Car implements Constants,Device{ @@ -255,7 +253,6 @@ public class Locomotive extends Car implements Constants,Device{
super.load(json);
if (json.has(LOCOMOTIVE)) {
JSONObject loco = json.getJSONObject(LOCOMOTIVE);
if (loco.has(REVERSE)) orientation = loco.getBoolean(REVERSE);
if (loco.has(PROTOCOL)) proto = Protocol.valueOf(loco.getString(PROTOCOL));
if (loco.has(ADDRESS)) setAddress(loco.getInt(ADDRESS));
if (loco.has(CVS)) {

Loading…
Cancel
Save