StrataSource / Engine

Issue tracker for Strata Source
47 stars 2 forks source link

Bug: Func_tracktrains don't respect deceleration speed when moving backwards, stopping immediately #1225

Open TheEnderek0 opened 1 month ago

TheEnderek0 commented 1 month ago

Describe the bug

When you have a func_tracktrain going backwards in a track, firing it the output SetSpeedDirAccel 0 (with properly set up keyvalues!) will make it stop, rather than make it slow down to 0 slowly. Video attached:

https://github.com/user-attachments/assets/dc22fede-c682-4faa-9930-158c6b7389c6

To Reproduce

  1. Open attached map

  2. Test with buttons:

    • Left button fires SetSpeedDirAccel 1 making the train move forwards
    • Middle button fires SetSpeedDirAccel 0 slowly stopping the train
    • Right button fires SetSpeedDirAccel -1 making the train move backwards
  3. Move the train to the end path_track using the left button

  4. Press the right button to move the train backwards, and while it's moving try to push the middle button.

  5. Observe that the train stopped instantaneously, instead of slowing down

Issue Map

trainissuemap.zip

Expected Behavior

The train should stop gracefully, not instantaneously

Operating System

No response

TheEnderek0 commented 1 month ago

I've tried fixing this issue on the 2013 SDK and I did it! It turns out, whenever the movement is reversed and you want to stop the train, the direction of movement changes (internally in code) since a function SetDirForward(newSpeed >= 0) gets called, this doesn't happen in forward motion because of that greater or equal operator, which only is false on negative newSpeed.

By implementing this if statement we can omit changing the direction for when newSpeed is 0 altogether, and there we go! Issue fixed.

https://github.com/user-attachments/assets/ab2b9ba4-a5d4-4710-8510-382a40e47c94

TheEnderek0 commented 1 month ago

Also note: Removing the greater or equal operator and changing to just greater than zero it also won't work, as now the entity will have trouble when stopping from forward motion!