I adapted one of my railcars so it makes use of the GearUp/GearDown sound triggers (101/102). I am using revision #2194.
I noticed that the GearDown trigger has no effect: the corresponding sound is never played. The GearUp trigger works fine. I tested former versions of ORTS, and found out that the problem was introduced by revision #2039. I also identified the code in GearBox.cs which causes this issue.
Before revision #2039, we had:
if ((clutch <= 0.05) || (clutch >= 1f)) { if (currentGearIndex < nextGearIndex) DieselEngine.locomotive.SignalEvent(Event.GearUp); if (currentGearIndex > nextGearIndex) DieselEngine.locomotive.SignalEvent(Event.GearDown); currentGearIndex = nextGearIndex; }
This code was changed as follows at revision #2039:
if ((clutch <= 0.05) || (clutch >= 1f)) { if (currentGearIndex < nextGearIndex) DieselEngine.locomotive.SignalEvent(Event.GearUp); currentGearIndex = nextGearIndex; } if ((clutch <= 0.05) || (clutch >= 0.5f)) { if (currentGearIndex > nextGearIndex) DieselEngine.locomotive.SignalEvent(Event.GearDown); currentGearIndex = nextGearIndex; }
If I just change the order of the two conditional blocks (handling GearDown event before GearUp one), then I observe the opposite effect: the GearDown sound is played, whereas the GearUp one dosn't work anymore! The problem is caused by the modification of the gear index in the first block, which is performed even if the condition on its current value is not met. This modifies the initial conditions for the second block.
I fixed the problem as follows (the modification of the gear index is placed in the same conditional block as the event Handler):
if ((clutch <= 0.05) || (clutch >= 1f)) { if (currentGearIndex < nextGearIndex) { DieselEngine.locomotive.SignalEvent(Event.GearUp); currentGearIndex = nextGearIndex; } } if ((clutch <= 0.05) || (clutch >= 0.5f)) { if (currentGearIndex > nextGearIndex) { DieselEngine.locomotive.SignalEvent(Event.GearDown); currentGearIndex = nextGearIndex; } }
A SVN patch (applies to GearBox.cs) is attached to this message.
Regards
Attached File(s)
-
GearBox.cs.patch.zip (434bytes)
Number of downloads: 209