Skip to content

Commit 611b019

Browse files
authored
Merge pull request #733 from Sharpe49/fix/battery-switch-sound
Fixed battery switch sound being repeted
2 parents 4c26d6d + 72947b0 commit 611b019

File tree

1 file changed

+6
-6
lines changed
  • Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies

1 file changed

+6
-6
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/BatterySwitch.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,47 +235,47 @@ public virtual void HandleEvent(PowerSupplyEvent evt)
235235
switch (evt)
236236
{
237237
case PowerSupplyEvent.CloseBatterySwitch:
238-
if (Mode == ModeType.Switch)
238+
if (Mode == ModeType.Switch && !CommandSwitch)
239239
{
240240
CommandSwitch = true;
241241
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
242242
}
243243
break;
244244

245245
case PowerSupplyEvent.OpenBatterySwitch:
246-
if (Mode == ModeType.Switch)
246+
if (Mode == ModeType.Switch && CommandSwitch)
247247
{
248248
CommandSwitch = false;
249249
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
250250
}
251251
break;
252252

253253
case PowerSupplyEvent.CloseBatterySwitchButtonPressed:
254-
if (Mode == ModeType.PushButtons)
254+
if (Mode == ModeType.PushButtons && !CommandButtonOn)
255255
{
256256
CommandButtonOn = true;
257257
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
258258
}
259259
break;
260260

261261
case PowerSupplyEvent.CloseBatterySwitchButtonReleased:
262-
if (Mode == ModeType.PushButtons)
262+
if (Mode == ModeType.PushButtons && CommandButtonOn)
263263
{
264264
CommandButtonOn = false;
265265
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
266266
}
267267
break;
268268

269269
case PowerSupplyEvent.OpenBatterySwitchButtonPressed:
270-
if (Mode == ModeType.PushButtons)
270+
if (Mode == ModeType.PushButtons && !CommandButtonOff)
271271
{
272272
CommandButtonOff = true;
273273
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
274274
}
275275
break;
276276

277277
case PowerSupplyEvent.OpenBatterySwitchButtonReleased:
278-
if (Mode == ModeType.PushButtons)
278+
if (Mode == ModeType.PushButtons && CommandButtonOff)
279279
{
280280
CommandButtonOff = false;
281281
Wagon.SignalEvent(Event.BatterySwitchCommandOff);

0 commit comments

Comments
 (0)