From dd3f8f5c8c5535383571cd22b3e650fd581a8127 Mon Sep 17 00:00:00 2001 From: gmriggs Date: Tue, 18 May 2021 22:37:09 -0400 Subject: [PATCH] add option to enable constraint manager on server --- Source/ACE.Server/Managers/PropertyManager.cs | 1 + .../ACE.Server/Physics/Managers/ConstraintManager.cs | 4 ++-- Source/ACE.Server/Physics/PhysicsObj.cs | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/ACE.Server/Managers/PropertyManager.cs b/Source/ACE.Server/Managers/PropertyManager.cs index ffcb03822e..e484eb57c3 100644 --- a/Source/ACE.Server/Managers/PropertyManager.cs +++ b/Source/ACE.Server/Managers/PropertyManager.cs @@ -593,6 +593,7 @@ public static void LoadDefaultProperties() ("trajectory_alt_solver", new Property(false, "use the alternate trajectory solver for missiles and spell projectiles")), ("universal_masteries", new Property(true, "if TRUE, matches end of retail masteries - players wielding almost any weapon get +5 DR, except if the weapon \"seems tough to master\". " + "if FALSE, players start with mastery of 1 melee and 1 ranged weapon type based on heritage, and can later re-select these 2 masteries")), + ("use_constraint_manager", new Property(false, "enables the constraint manager on the server, which can mitigate some of the desyncs between the client and server movement methods")), ("use_generator_rotation_offset", new Property(true, "enables or disables using the generator's current rotation when offseting relative positions")), ("use_turbine_chat", new Property(true, "enables or disables global chat channels (General, LFG, Roleplay, Trade, Olthoi, Society, Allegience)")), ("use_wield_requirements", new Property(true, "disable this to bypass wield requirements. mostly for dev debugging")), diff --git a/Source/ACE.Server/Physics/Managers/ConstraintManager.cs b/Source/ACE.Server/Physics/Managers/ConstraintManager.cs index 7188b79055..43fec75d8d 100644 --- a/Source/ACE.Server/Physics/Managers/ConstraintManager.cs +++ b/Source/ACE.Server/Physics/Managers/ConstraintManager.cs @@ -36,7 +36,7 @@ public void ConstrainTo(Position position, float startDistance, float maxDistanc public bool IsFullyConstrained() { - return ConstraintDistanceMax * 0.9f < ConstraintPosOffset; + return ConstraintPosOffset > ConstraintDistanceMax * 0.9f; } public void SetPhysicsObject(PhysicsObj obj) @@ -73,7 +73,7 @@ public void adjust_offset(AFrame offset, double quantum) else offset.Origin = Vector3.Zero; } - ConstraintPosOffset = offset.Origin.Length(); + ConstraintPosOffset += offset.Origin.Length(); } } } diff --git a/Source/ACE.Server/Physics/PhysicsObj.cs b/Source/ACE.Server/Physics/PhysicsObj.cs index 0994b237e9..8127b92029 100644 --- a/Source/ACE.Server/Physics/PhysicsObj.cs +++ b/Source/ACE.Server/Physics/PhysicsObj.cs @@ -567,7 +567,7 @@ public float GetHeight() return PartArray.GetHeight(); } - public double GetMaxConstraintDistance() + public float GetMaxConstraintDistance() { return (Position.ObjCellID & 0xFFFF) < 0x100 ? 50.0f : 20.0f; } @@ -617,7 +617,7 @@ public uint GetSetupID() return PartArray.GetSetupID(); } - public double GetStartConstraintDistance() + public float GetStartConstraintDistance() { return (Position.ObjCellID & 0xFFFF) < 0x100 ? 5.0f : 10.0f; } @@ -4345,6 +4345,14 @@ public bool update_object_server_new(bool forcePos = true) } set_current_pos(RequestPos); + + if (PropertyManager.GetBool("use_constraint_manager").Item) + { + var startDist = GetStartConstraintDistance(); + var maxDist = GetMaxConstraintDistance(); + + ConstrainTo(RequestPos, startDist, maxDist); + } } // for teleport, use SetPosition?