FLHDE / freelancer-hd-edition

Freelancer: HD Edition is a mod that aims to improve every aspect of the game Freelancer (2003) while keeping the look and feel as close to vanilla as possible.
https://www.moddb.com/mods/freelancer-hd-edition
182 stars 15 forks source link

Bug with the "Rotation Lock" hotkey feature from JFLP #240

Open Caenen opened 2 months ago

Caenen commented 2 months ago

There is a bug that sneaks in when using the Rotation Lock feature JFLP adds/restores to the game. After toggling it on in space, then docking, it is still enabled after undocking but runs into a huge error where the ship controls brick themselves upon hitting some pitch elevation limit around 65° up or down.

Video example: https://drive.google.com/file/d/1H3f_D1md_Ii3wwjvOtueicMVP_i37LeA/view?usp=sharing

Repro steps:

  1. after undocking, toggle Rotation Lock. Observe that it works (ship no longer banks in turns, just like in turret view)
  2. dock with anything to exit space
  3. Return to space. If your pitch reaches some upwards or downwards angle, your controls lock up until you toggle Rotation Lock again

Some additional observations:

BC46 commented 2 months ago

Any ideas @adoxa?

adoxa commented 2 months ago

I'll see if I can automatically disable/toggle on dock/launch, but I won't say when...

BC46 commented 2 months ago

I may have found a solution that works without disabling or re-toggling the Rotation Lock control. I tested it for a bit and it seems to have resolved the problem on my end, but I can't guarantee its stability as it's not the cleanest solution. I've temporarily pushed the code to a separate branch on the FLSharp repo: https://github.com/BC46/FLSharp/commit/6e578bc4fa1409143c28406db503ce8e44995fab.

I think the problem was that when docked the game's behavior manager wasn't aware of the last rotation lock state and thus after undocking it assumed it wasn't changed from the default. Hence making the behavior manager aware of this seems to help.

BC46 commented 2 months ago

@Caenen told me on Discord about a bug related to Auto Level where if you disable it while in space, then dock and undock, it's automatically enabled but you have to press the hotkey twice in order to disable it again. I fixed it by telling the behavior manager that auto leveling should be disabled after undocking if that's what it was prior to docking. The implementation can be found here: https://github.com/BC46/FLSharp/commit/4fa19eec638bfc380dbd272f5144ffa74ffb70e2.

@adoxa if you want to automatically set Rotation Lock and and Auto Level to the default values when undocking, all you have to do is update the booleans [esi+0x44] and 0x612700, respectively. Though you may also have to call the IBehaviorManager functions like I did too but I'm not sure.

adoxa commented 2 months ago

I'd be more inclined to restore default, i.e. they're always off when you launch. People have until I do it to change my mind. :)

BC46 commented 2 months ago

I think restoring defaults makes the most sense too since FL already does that for mouse flight. Also you may have to find a better launch hook because I found out that BaseWatcher::set_pointer gets called in instances other than just on-launch, e.g. when toggling cockpit view.