start block of route should only be freed, if corresponding action is fired.
however, train should not be available from previous start block after route has finished.
@ -70,6 +69,7 @@ public class Train implements Comparable<Train>,Constants {
@@ -70,6 +69,7 @@ public class Train implements Comparable<Train>,Constants {
@ -149,6 +149,47 @@ public class Train implements Comparable<Train>,Constants {
@@ -149,6 +149,47 @@ public class Train implements Comparable<Train>,Constants {
@ -188,10 +229,18 @@ public class Train implements Comparable<Train>,Constants {
@@ -188,10 +229,18 @@ public class Train implements Comparable<Train>,Constants {
if(this.block==block)returnthis;// nothing to update
if(this.block!=null){
this.block.trailingTrain(this);
previousBlocks.add(this.block);
}
this.block=block;
block.train(this);
if(resetPreviousBlocks)resetPreviousBlocks();
returnthis;
}
privateTagcarList(){
TaglocoProp=newTag("li").content(t("Cars:"));
TaglocoList=newTag("ul").clazz("carlist");
@ -235,6 +284,7 @@ public class Train implements Comparable<Train>,Constants {
@@ -235,6 +284,7 @@ public class Train implements Comparable<Train>,Constants {
publicTrainheading(Directiondir){
direction=dir;
if(block!=null)plan.place(block);
returnthis;
}
@ -353,17 +403,7 @@ public class Train implements Comparable<Train>,Constants {
@@ -353,17 +403,7 @@ public class Train implements Comparable<Train>,Constants {
@ -438,7 +478,20 @@ public class Train implements Comparable<Train>,Constants {
@@ -438,7 +478,20 @@ public class Train implements Comparable<Train>,Constants {
@ -468,44 +521,25 @@ public class Train implements Comparable<Train>,Constants {
@@ -468,44 +521,25 @@ public class Train implements Comparable<Train>,Constants {
if(route==null)returnt("No free routes from {}",block);
if(!route.lock())returnt("Was not able to lock {}",route);
Stringerror=null;
if(direction!=route.startDirection)turn();
Stringerror=null;
if(!route.setTurnouts())error=t("Was not able to set all turnouts!");
route.fireSetupActions(context);
if(error==null&&!route.fireSetupActions(context))error=t("Was not able to fire all setup actions of route!");
if(error==null&&!route.setSignals(null))error=t("Was not able to set all signals!");
if(error==null&&!route.train(this))error=t("Was not able to assign {} to {}!",this,route);
if(error==null){
setSpeed(128);
returnt("Started {}",this);
if(error!=null){
route.reset();
returnerror;
}
route.unlock();
this.block.train(this);// re-set train on previous block
this.route=null;
returnerror;
setSpeed(128);
returnt("Started {}",this);
}
privateObjectstopNow(){
@ -537,9 +571,7 @@ public class Train implements Comparable<Train>,Constants {
@@ -537,9 +571,7 @@ public class Train implements Comparable<Train>,Constants {
direction=direction.inverse();
for(Locomotiveloco:locos)loco.turn();
}
if(block!=null)try{
plan.place(block.train(this));
}catch(IOExceptione){}
if(block!=null)plan.place(block.train(this));
returnt("{} turned.",this);
}
@ -559,9 +591,4 @@ public class Train implements Comparable<Train>,Constants {
@@ -559,9 +591,4 @@ public class Train implements Comparable<Train>,Constants {