@ -41,7 +41,6 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -41,7 +41,6 @@ public class Car extends BaseClass implements Comparable<Car>{
@ -54,14 +53,9 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -54,14 +53,9 @@ public class Car extends BaseClass implements Comparable<Car>{
this(name,null);
}
publicCar(Stringname,Integerid){
publicCar(Stringname,Idid){
this.name=name;
if(id==null){
try{// make sure multiple consecutive creations get different ids
Thread.sleep(1);
}catch(InterruptedExceptione){}
id=Application.createId();
}
if(isNull(id))id=newId();
this.id=id;
cars.put(id,this);
}
@ -100,12 +94,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -100,12 +94,7 @@ public class Car extends BaseClass implements Comparable<Car>{
}
publicstaticCarget(Objectid){
returnisNull(id)?null:cars.get(Integer.parseInt(""+id));// try to get by id
}
publicintid(){
returnid;
returnisNull(id)?null:cars.get(newId(""+id));// try to get by id
}
publicJSONObjectjson(){
@ -130,7 +119,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -130,7 +119,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@ -148,7 +137,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -148,7 +137,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@ -158,7 +147,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -158,7 +147,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@ -249,7 +238,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@@ -249,7 +238,7 @@ public class Car extends BaseClass implements Comparable<Car>{
@ -39,7 +39,7 @@ public class Locomotive extends Car implements Constants,Device{
@@ -39,7 +39,7 @@ public class Locomotive extends Car implements Constants,Device{
super(name);
}
publicLocomotive(Stringname,Integerid){
publicLocomotive(Stringname,Idid){
super(name,id);
}
@ -82,7 +82,7 @@ public class Locomotive extends Car implements Constants,Device{
@@ -82,7 +82,7 @@ public class Locomotive extends Car implements Constants,Device{
}
publicstaticTagcockpit(ObjectlocoOrTrain){
intid=0;
Idid=null;
intspeed=0;
Stringrealm=null;
Traintrain=null;
@ -95,7 +95,7 @@ public class Locomotive extends Car implements Constants,Device{
@@ -95,7 +95,7 @@ public class Locomotive extends Car implements Constants,Device{
if(json.has(BLOCK))currentBlock=(Block)plan.get(json.getString(BLOCK),false).set(this);// do not move this up! during set, other fields will be referenced!
if(json.has(BLOCK))currentBlock=(Block)plan.get(newId(json.getString(BLOCK)),false).set(this);// do not move this up! during set, other fields will be referenced!
@ -31,8 +31,8 @@ public abstract class Signal extends Tile implements Comparable<Signal>{
@@ -31,8 +31,8 @@ public abstract class Signal extends Tile implements Comparable<Signal>{