WIP network message validation
This commit is contained in:
@@ -475,19 +475,37 @@ namespace Subsurface
|
||||
|
||||
public override void ReadNetworkData(NetIncomingMessage message)
|
||||
{
|
||||
state = (AiState)(message.ReadByte());
|
||||
AiState newState = AiState.None;
|
||||
Vector2 newWallAttackPos;
|
||||
float wanderAngle;
|
||||
float updateTargetsTimer, raycastTimer, coolDownTimer;
|
||||
|
||||
wallAttackPos.X = message.ReadFloat();
|
||||
wallAttackPos.Y = message.ReadFloat();
|
||||
int targetID;
|
||||
|
||||
steeringManager.WanderAngle = message.ReadFloat();
|
||||
updateTargetsTimer = message.ReadFloat();
|
||||
raycastTimer = message.ReadFloat();
|
||||
coolDownTimer = message.ReadFloat();
|
||||
try
|
||||
{
|
||||
|
||||
int targetID = message.ReadInt32();
|
||||
|
||||
if (targetID>-1)
|
||||
newState = (AiState)(message.ReadByte());
|
||||
newWallAttackPos = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
|
||||
wanderAngle = MathUtils.WrapAngleTwoPi(message.ReadFloat());
|
||||
updateTargetsTimer = MathHelper.Clamp(message.ReadFloat(), 0.0f, UpdateTargetsInterval);
|
||||
raycastTimer = MathHelper.Clamp(message.ReadFloat(), 0.0f, RaycastInterval);
|
||||
coolDownTimer = MathHelper.Clamp(message.ReadFloat(), 0.0f, attackCoolDown);
|
||||
|
||||
targetID = message.ReadInt32();
|
||||
}
|
||||
|
||||
catch { return; }
|
||||
|
||||
wallAttackPos = newWallAttackPos;
|
||||
|
||||
steeringManager.WanderAngle = wanderAngle;
|
||||
this.updateTargetsTimer = updateTargetsTimer;
|
||||
this.raycastTimer = raycastTimer;
|
||||
this.coolDownTimer = coolDownTimer;
|
||||
|
||||
if (targetID > -1)
|
||||
targetEntity = Entity.FindEntityByID(targetID) as IDamageable;
|
||||
|
||||
}
|
||||
|
||||
@@ -972,23 +972,35 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
actionKeyDown.State = message.ReadBoolean();
|
||||
secondaryKeyDown.State = message.ReadBoolean();
|
||||
bool actionKeyState = false;
|
||||
bool secondaryKeyState = false;
|
||||
double sendingTime = 0.0f;
|
||||
Vector2 targetMovement = Vector2.Zero;
|
||||
bool targetDir = false;
|
||||
Vector2 cursorPos = Vector2.Zero;
|
||||
|
||||
double sendingTime = message.ReadDouble();
|
||||
|
||||
Vector2 targetMovement = Vector2.Zero;
|
||||
|
||||
targetMovement.X = message.ReadFloat();
|
||||
targetMovement.Y = message.ReadFloat();
|
||||
try
|
||||
{
|
||||
actionKeyState = message.ReadBoolean();
|
||||
secondaryKeyState = message.ReadBoolean();
|
||||
|
||||
sendingTime = message.ReadDouble();
|
||||
|
||||
targetMovement = new Vector2 (message.ReadFloat(), message.ReadFloat());
|
||||
targetDir = message.ReadBoolean();
|
||||
|
||||
cursorPos = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AnimController.IsStanding = true;
|
||||
|
||||
bool targetDir = message.ReadBoolean();
|
||||
|
||||
Vector2 cursorPos = Vector2.Zero;
|
||||
cursorPos.X = message.ReadFloat();
|
||||
cursorPos.Y = message.ReadFloat();
|
||||
actionKeyDown.State = actionKeyState;
|
||||
secondaryKeyDown.State = secondaryKeyState;
|
||||
|
||||
if (sendingTime <= LastNetworkUpdate) return;
|
||||
|
||||
@@ -1012,9 +1024,9 @@ namespace Subsurface
|
||||
float rotation = message.ReadFloat();
|
||||
float angularVel = message.ReadFloat();
|
||||
|
||||
if (vel != Vector2.Zero && vel.Length() > 100.0f) { }
|
||||
//if (vel != Vector2.Zero && vel.Length() > 100.0f) { }
|
||||
|
||||
if (pos != Vector2.Zero && pos.Length() > 100.0f) { }
|
||||
//if (pos != Vector2.Zero && pos.Length() > 100.0f) { }
|
||||
|
||||
if (limb.body != null)
|
||||
{
|
||||
|
||||
@@ -62,7 +62,11 @@ namespace Subsurface
|
||||
public Vector2 TargetMovement
|
||||
{
|
||||
get { return (correctionMovement == Vector2.Zero) ? targetMovement : correctionMovement; }
|
||||
set { targetMovement = value; }
|
||||
set
|
||||
{
|
||||
targetMovement.X = MathHelper.Clamp(value.X, -3.0f, 3.0f);
|
||||
targetMovement.Y = MathHelper.Clamp(value.Y, -3.0f, 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public float HeadPosition
|
||||
|
||||
Reference in New Issue
Block a user