Elvas Tower: GearDown sound trigger no longer played since rev #2039 - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

GearDown sound trigger no longer played since rev #2039 Rate Topic: -----

#1 User is offline   BB25187 

  • Fireman
  • Group: Status: Active Member
  • Posts: 138
  • Joined: 09-December 12
  • Gender:Male
  • Simulator:OpenRails MSTS
  • Country:

Posted 27 April 2014 - 05:23 AM

Hi,

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)



#2 User is offline   BB25187 

  • Fireman
  • Group: Status: Active Member
  • Posts: 138
  • Joined: 09-December 12
  • Gender:Male
  • Simulator:OpenRails MSTS
  • Country:

Posted 27 April 2014 - 08:27 AM

I logged this one as Bug #1313386.
The patch is also attached there

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users