Trinitycore: Incorrect calculation of the first "fake" Catmull-Rom spline point

Created on 14 Sep 2018  路  5Comments  路  Source: TrinityCore/TrinityCore

This is how the first point is currently calculated on the server (present in the code twice, just a heads up):
Spline.cpp

points[0] = controls[0].lerp(controls[1], -1);

This is incorrent. Here's the fixed code that matches what the client is doing:

points[0] = controls[0] - G3D::Vector3 { cos(initialOrientation), sin(initialOrientation), 0.0f };

(of course this requires initialOrientation from MoveSplineInitArgs to be passed to spline initialization)

This fixes slight position desync for flying units. My players were constantly nagging me about Val'kyr Shadowguards on The Lich King encounter always teleporting forward a bit whenever they were stunned, this issue is the reason why that was happening: due to larger distance between the first "fake" and "real" points, the "easing-in" of unit's velocity happens much faster on the server, thus making the unit travel through the spline faster than it would visually appear on the client.

I won't be providing the proof for this, because the decompiled code looks more confusing than helpful, just trust me on this one. It's still in CGUnit_C::OnMonsterMovePacket if you want to find it yourself, look for sin/cos calls.

And just to please @TrinityCoreBot: 0f3156d324ff8134171bada01b40f5c23f5c43cc

Comp-Core Sub-Movement

All 5 comments

Offtopic: just a question. Is there a reason why you won't make a PR for the issues you are making?

I don't have TC code neither pulled nor compiled (and currently don't fancy jumping through the hoops to get boost or VS2017 to work), so I can't test any of these changes, and I would rather not commit anything I can't test. I am, however, working with a codebase that branched off of TC many years ago, so all the issues I post are still relevant. I do check everything I post on whether or not it has already been fixed here.

That, and I initially wanted to post all this on the forums like a year ago or so, but some bugs happened that prevented me from doing that (some crap with permissions, I did ask on TC's IRC but nobody volunteered to help) and I lost the motivation.

If you're getting triggered by SSE instructions it's a lot easier to see when you ignore hexrays. Also hexrays sometimes misses branches for no reasons (around SSE instructions). I'll try to check on data if I have the time (I definitely have the names)

Oh well, here's more or less what you should look for: https://i.imgur.com/vudpI4A.png

5e8b934

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jonne733 picture Jonne733  路  3Comments

Tatara902 picture Tatara902  路  3Comments

Rushor picture Rushor  路  3Comments

cbcs picture cbcs  路  3Comments

daddycaddy picture daddycaddy  路  3Comments