File tree Expand file tree Collapse file tree
src/main/java/cam72cam/immersiverailroading Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,6 +257,9 @@ public static class ConfigDebug {
257257 @ Comment ("Keep rolling stock loaded even when it is not moving" )
258258 public static boolean keepStockLoaded = true ;
259259
260+ @ Comment ("Exclude unattached wagons from chunk loading when keepStockLoaded is true" )
261+ public static boolean excludeStandaloneWagons = false ;
262+
260263 @ Comment ( "Print extra chunk loading info" )
261264 public static boolean debugLog = false ;
262265
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ public String toString() {
100100 @ TagSync
101101 @ TagField ("hasElectricalPower" )
102102 private boolean hasElectricalPower ;
103+ private boolean linkedToLocomotive ;
103104 private boolean hadElectricalPower = false ;
104105 private int gotElectricalPowerTick = -1 ;
105106
@@ -186,17 +187,23 @@ public void onTick() {
186187
187188 if (this .getTickCount () % 5 == 0 ) {
188189 hasElectricalPower = false ;
189- this .mapTrain (this , false , stock ->
190- hasElectricalPower = hasElectricalPower ||
191- stock instanceof Locomotive && ((Locomotive ) stock ).providesElectricalPower ()
190+ linkedToLocomotive = false ;
191+ this .mapTrain (this , false , stock -> {
192+ hasElectricalPower = hasElectricalPower ||
193+ stock instanceof Locomotive && ((Locomotive ) stock ).providesElectricalPower ();
194+ linkedToLocomotive = linkedToLocomotive || stock instanceof Locomotive ;
195+ }
192196 );
193197 }
194198
195199 hadElectricalPower = hasElectricalPower ();
196200
197201 if (this .getCurrentState () != null && !this .getCurrentState ().atRest || ConfigDebug .keepStockLoaded ) {
198- keepLoaded ();
199- }
202+ //Then exclude stocks not linked to any locomotive
203+ if (!ConfigDebug .excludeStandaloneWagons || this .linkedToLocomotive ) {
204+ keepLoaded ();
205+ }
206+ }
200207
201208 slackFrontPercent = 0 ;
202209 slackRearPercent = 0 ;
You can’t perform that action at this time.
0 commit comments