Skip to content

Commit b348ee0

Browse files
committed
Containers: reject save and warn player during a container load/unload operation
1 parent a8e1cc7 commit b348ee0

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Source/Documentation/Manual/driving.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,8 @@ this occurs when the wagon is at the boundary of the crane displacement range; t
12531253
move the wagon towards the inside of the crane displacement range and stop the train. The crane
12541254
will then continue its loading mission up to the end.
12551255

1256-
It is advised not to perform a Save (key ``<F2>``) when a loading or unloading operation is ongoing.
1256+
Saves (key ``<F2>``) are rejected and a message appears on the display when a loading
1257+
or unloading operation is ongoing.
12571258

12581259
.. _driving-autopilot:
12591260

Source/Orts.Simulation/Simulation/Container.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ public class ContainerManager
273273
public Dictionary<int, ContainerHandlingItem> ContainerHandlingItems;
274274
public List<Container> Containers;
275275
public static Dictionary<string, Container> LoadedContainers = new Dictionary<string, Container>();
276+
public static int ActiveOperationsCounter;
276277

277278
public ContainerManager(Simulator simulator)
278279
{
@@ -907,6 +908,8 @@ public void Update()
907908
MoveY = false;
908909
Status = ContainerStationStatus.Idle;
909910
MSTSWagon.RefillProcess.OkToRefill = false;
911+
ContainerManager.ActiveOperationsCounter--;
912+
if (ContainerManager.ActiveOperationsCounter < 0) ContainerManager.ActiveOperationsCounter = 0;
910913
}
911914
break;
912915
default:
@@ -916,6 +919,7 @@ public void Update()
916919

917920
public void PrepareForUnload(FreightAnimationDiscrete linkedFreightAnimation)
918921
{
922+
ContainerManager.ActiveOperationsCounter++;
919923
LinkedFreightAnimation = linkedFreightAnimation;
920924
RelativeContainerPosition = new Matrix();
921925
LinkedFreightAnimation.Wagon.WorldPosition.NormalizeTo(ShapePosition.TileX, ShapePosition.TileZ);
@@ -934,6 +938,7 @@ public void PrepareForUnload(FreightAnimationDiscrete linkedFreightAnimation)
934938

935939
public void PrepareForLoad(FreightAnimationDiscrete linkedFreightAnimation)
936940
{
941+
ContainerManager.ActiveOperationsCounter++;
937942
LinkedFreightAnimation = linkedFreightAnimation;
938943
SelectedStackLocationIndex = SelectLoadPosition();
939944
if (SelectedStackLocationIndex == -1) return;

Source/RunActivity/Viewer3D/Processes/GameStateRunActivity.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ void Start(UserSettings settings, string acttype, string[] args)
343343
public static void Save()
344344
{
345345
if (MPManager.IsMultiPlayer() && !MPManager.IsServer()) return; //no save for multiplayer sessions yet
346+
if (ContainerManager.ActiveOperationsCounter > 0)
347+
// don't save if performing a container load/unload
348+
{
349+
Simulator.Confirmer.Message(ConfirmLevel.Warning, Viewer.Catalog.GetString("Game save is not allowed during container load/unload"));
350+
return;
351+
}
346352
// Prefix with the activity filename so that, when resuming from the Menu.exe, we can quickly find those Saves
347353
// that are likely to match the previously chosen route and activity.
348354
// Append the current date and time, so that each file is unique.

0 commit comments

Comments
 (0)