Optimized mouse position syncing from server to clients, removed a redundant WritePadBits from Character.ServerWrite
This commit is contained in:
@@ -1399,8 +1399,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (AnimController.TargetDir == Direction.Left) newInput |= InputNetFlags.FacingLeft;
|
if (AnimController.TargetDir == Direction.Left) newInput |= InputNetFlags.FacingLeft;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 relativeCursorPos = cursorPosition - AnimController.Collider.Position;
|
Vector2 relativeCursorPos = cursorPosition - AnimController.Collider.Position;
|
||||||
relativeCursorPos.Normalize();
|
relativeCursorPos.Normalize();
|
||||||
UInt16 intAngle = (UInt16)(65535.0*Math.Atan2(relativeCursorPos.Y,relativeCursorPos.X)/(2.0*Math.PI));
|
UInt16 intAngle = (UInt16)(65535.0*Math.Atan2(relativeCursorPos.Y,relativeCursorPos.X)/(2.0*Math.PI));
|
||||||
@@ -2152,11 +2150,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (aiming)
|
if (aiming)
|
||||||
{
|
{
|
||||||
//TODO: write this with less accuracy?
|
Vector2 relativeCursorPos = cursorPosition - AnimController.Collider.Position;
|
||||||
|
tempBuffer.Write((UInt16)(65535.0 * Math.Atan2(relativeCursorPos.Y, relativeCursorPos.X) / (2.0 * Math.PI)));
|
||||||
|
|
||||||
tempBuffer.Write(cursorPosition.X);
|
|
||||||
tempBuffer.Write(cursorPosition.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tempBuffer.Write(AnimController.TargetDir == Direction.Right);
|
tempBuffer.Write(AnimController.TargetDir == Direction.Right);
|
||||||
@@ -2167,8 +2162,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
msg.Write((byte)tempBuffer.LengthBytes);
|
msg.Write((byte)tempBuffer.LengthBytes);
|
||||||
msg.Write(tempBuffer);
|
msg.Write(tempBuffer);
|
||||||
|
|
||||||
msg.WritePadBits();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2222,9 +2215,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (aimInput)
|
if (aimInput)
|
||||||
{
|
{
|
||||||
cursorPosition = new Vector2(
|
double aimAngle = ((double)msg.ReadUInt16() / 65535.0) * 2.0 * Math.PI;
|
||||||
msg.ReadFloat(),
|
cursorPosition = AnimController.Collider.Position + new Vector2((float)Math.Cos(aimAngle), (float)Math.Sin(aimAngle)) * 60.0f;
|
||||||
msg.ReadFloat());
|
|
||||||
|
|
||||||
TransformCursorPos();
|
TransformCursorPos();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user