I have the key to One Eyed Willy

Allegiance discussion not belonging in another forum.
Post Reply
Wasp
Posts: 1084
Joined: Sun Aug 17, 2003 7:00 am

Post by Wasp »

By updating the joystick values within wintrek.cpp at the point where slew would be applied (if you were zooming), eliminates half of the controller lag. Also, hard coding the ships turn rate eliminates the other half of the lag caused when the code fetches the ships turn rate to see if slew should be applied.

I think these "lag" issues and the stuttering we see, are related.

I changed the code to what you see below. Don't critique my coding skillz, I already know they're sh!t. I have it this way because I was toggling on and off different values to test the response on each axis. If this is of any help in discovering the true cause, great, if not, it still seems like a suitable workaround.

Note: I changed the slew back to the original MS formula before Imago & madpeople modified it. I hard coded the ships turn rate to be 60 degrees per second which would be used to calculate how much to slow your turning IF you were zoomed in from your cockpit (which you NEVER EVER do anyway)... so hard coding that value won't affect anyone and eliminates that fetch routine which is causing trouble for everyone. Lastly, I have each axis updating at this point (whether it is being slewed or not) = lag eliminated. I'm not certain if this fixes the turret lag but I put a JS update here for when you are in a turret. That will need to be tested while online. If anyone wants to clean this code up properly, please do so, I know it's a mess.

If anyone wants to see what I've been crying about all of these years, here is the current version of alleg (as posted on Kage's github) with this "lag fix" added. Even you mouse users will see the difference. I suggest you turn your mouse sensitivity back to 100% within the game (ESC G Q).

Code: Select all

if (m_cm == cmCockpit)
                    {
                        if (trekClient.GetShip()->GetTurretID() != NA)
                        {
                            float   fov = (s_fMinFOV + 0.5f * (s_fMaxFOV - s_fMinFOV)) +
                                          (0.5f * (s_fMaxFOV - s_fMinFOV)) * js.controls.jsValues[c_axisThrottle];
                            m_cameraControl.SetFOV(fov);
                            {
                            if (1 > 0)
                            js.controls.jsValues[c_axisPitch] *= 1.0f;
                            }
                            {
                            if (1 > 0)
                            js.controls.jsValues[c_axisYaw] *= 1.0f;
                            }
                            {
                            if (1 > 0)
                            js.controls.jsValues[c_axisRoll] *= 1.0f;
                            }
                            {
                            if (1 > 0)
                            js.controls.jsValues[c_axisThrottle] *= 1.0f;
                            }

                        }
                        else
                        {
                            float   fov = m_cameraControl.GetFOV();
                            if (m_ptrekInput->IsTrekKeyDown(TK_ZoomIn, true))
                            {
                                fov -= dt;
                                if (fov < s_fMinFOV)
                                    fov = s_fMinFOV;

                                m_cameraControl.SetFOV(fov);
                            }
                            else if (m_ptrekInput->IsTrekKeyDown(TK_ZoomOut, true))
                            {
                                fov += dt;
                                if (fov > s_fMaxFOV)
                                    fov = s_fMaxFOV;

                                m_cameraControl.SetFOV(fov);
                            }

                            if (trekClient.GetShip()->GetBaseHullType() != NULL)
                            {
                                //What is the maximum desired rate of turn for this field of view?
                                //Use the same calculation as for turrets.
                                //Keep in sync with wintrek.cpp's FOV by throttle
                                
                                static const float  c_minRate = RadiansFromDegrees(7.5f);
                                static const float  c_maxRate = RadiansFromDegrees(75.0f);
                                
                                float   maxSlewRate = c_minRate + (c_maxRate - c_minRate) * fov / s_fMaxFOV;
                                                                
                                {    
                                    float pitch = RadiansFromDegrees(60);
                                    
                                    if (pitch > maxSlewRate)
                                        js.controls.jsValues[c_axisPitch] *= maxSlewRate / pitch;
                                    else
                                        js.controls.jsValues[c_axisPitch] *= 1.0f;
                                }
                                {
                                    float yaw = RadiansFromDegrees(60);
                                    
                                    if (yaw > maxSlewRate)
                                        js.controls.jsValues[c_axisYaw] *= maxSlewRate / yaw;
                                    else
                                        js.controls.jsValues[c_axisYaw] *= 1.0f;
                                }
                                {
                                    if (1 > 0)
                                    js.controls.jsValues[c_axisRoll] *= 1.0f;
                                }    
                                {    
                                    if (1 > 0)
                                    js.controls.jsValues[c_axisThrottle] *= 1.0f;
                                }
                            }
                        }
                    }
Last edited by Wasp on Wed Feb 22, 2017 6:40 pm, edited 1 time in total.
Wasp
Posts: 1084
Joined: Sun Aug 17, 2003 7:00 am

Post by Wasp »

I decided to try removing all of the slew code and hard code values that I knew would be representative of an interceptor and could tell right off that the lag got even better. Then I started ripping code out of wintrek.cpp wherever I could and each time, the lag improved, almost unnoticeable until enough code was ripped out.

Don't know what the deal is but it appears that the less there is to do in the loop, the less lag is felt on the controller. I haven't been able to change the stuttering behavior in the least. It appears that this Dx9 code is hiccuping along and that defect is presenting itself in the network, ship position (interpolation?) and controller input.

Since there is no hope in hell that this will ever be fixed, I recommend we offer a bastardized version, like what I posted above, so people can at least aim.
Last edited by Wasp on Fri Feb 24, 2017 2:26 pm, edited 1 time in total.
Papsmear
Posts: 4810
Joined: Sun Jul 06, 2003 7:00 am
Location: Toronto, Canada

Post by Papsmear »

I would love to get some feedback from other members of the community to see what they think to your "bastardized" coding efforts.
Are you still working on this and if so will you be posting updates?
Image
Image
Wasp
Posts: 1084
Joined: Sun Aug 17, 2003 7:00 am

Post by Wasp »

Papsmear wrote:QUOTE (Papsmear @ Feb 24 2017, 09:35 AM) I would love to get some feedback from other members of the community to see what they think to your "bastardized" coding efforts. Are you still working on this and if so will you be posting updates?
I think it is unlikely that anyone will produce a Dx7 version ported forward and that version has the least lag of all. BT's Dx7 version had less lag however, it wasn't a pure Dx7 version meaning that it still contained the Dx9 code and suffers as a result.

I would recommend taking BT's Dx7 version (which is already less laggy) and have the controller update where it would be updating if you were zooming anyway... and keep ripping out features that influence lag and present that build as an Allegiance lite.
raumvogel
Posts: 5910
Joined: Sun Jul 20, 2003 7:00 am
Location: My lawn
Contact:

Post by raumvogel »

After 15 years of flying with a joystick I finally gave up and am learning to fly with a mouse.
Image
MagisterXF94
Posts: 1935
Joined: Fri Aug 23, 2013 9:46 am
Location: Trieste, Italy

Post by MagisterXF94 »

raumvogel wrote:QUOTE (raumvogel @ Feb 24 2017, 06:07 PM) After 15 years of flying with a joystick I finally gave up and am learning to fly with a mouse.
and you still suck worse than me ;)
:iluv:
QUOTE ^cashto@Elem (all): yeah, i imagine if you're rusty, you could build op short for no reason, build a naked ref, then go two techpaths even though your mining is by all objective standards $#@!ed[/quote]
Image
Wasp
Posts: 1084
Joined: Sun Aug 17, 2003 7:00 am

Post by Wasp »

Would you two give this a try....play the tutorial and see if your joysticks work now.
raumvogel
Posts: 5910
Joined: Sun Jul 20, 2003 7:00 am
Location: My lawn
Contact:

Post by raumvogel »

My last joystick is in the trash...sorry,I won't be buying another.

The same thing happened with Warthunder.I tried playing with a joystick (because no one flew with a mouse in WW][!) but it sucked.I've learned to fly a P-51 with a mouse and doing ok. :roll:
Last edited by raumvogel on Sat Feb 25, 2017 2:24 am, edited 1 time in total.
Image
Wasp
Posts: 1084
Joined: Sun Aug 17, 2003 7:00 am

Post by Wasp »

Probably doesn't matter anyway. Even if I found the exact problem, fixed it and handed it over, FAO would never permit it to be distributed.

THEY WANT YOU TO FLY THEIR SCREWED UP MESS.
Papsmear
Posts: 4810
Joined: Sun Jul 06, 2003 7:00 am
Location: Toronto, Canada

Post by Papsmear »

If you can actually fix the problem I'm sure some of us would be happy to download it and use it.
I know I would.
With that in mind, please continue with what you are doing if you want.
I would love to be able to aim better with either a mouse or joystick.
Image
Image
Post Reply