Removed Fill/ReadNetworkData
These functions needed to be replaced because they rely heavily on reliability. Instead, new functions called (Write/Read)Data(Server/Client) will be added. Separating client and server code into completely separate functions will help ensure that proper security checks are performed.
This commit is contained in:
@@ -575,74 +575,6 @@ namespace Barotrauma
|
||||
spriteBatch.DrawString(GUI.Font, "updatetargets: "+updateTargetsTimer, pos - Vector2.UnitY * 100.0f, Color.Red);
|
||||
spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red);
|
||||
}
|
||||
|
||||
public override void FillNetworkData(NetBuffer message)
|
||||
{
|
||||
message.WriteRangedInteger(0, Enum.GetValues(typeof(AiState)).Length-1, (int)state);
|
||||
|
||||
//bool wallAttack = (wallAttackPos != Vector2.Zero && state == AiState.Attack);
|
||||
|
||||
//message.Write(wallAttack);
|
||||
|
||||
message.Write(MathUtils.AngleToByte(steeringManager.WanderAngle));
|
||||
|
||||
coolDownTimer = MathHelper.Clamp(coolDownTimer, 0.0f, 30.0f);
|
||||
message.WriteRangedSingle(coolDownTimer, 0.0f, 30.0f, 8);
|
||||
|
||||
message.Write(targetEntity==null ? (ushort)0 : (targetEntity as Entity).ID);
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(NetIncomingMessage message)
|
||||
{
|
||||
AiState newState = AiState.None;
|
||||
Vector2 newWallAttackPos = Vector2.Zero;
|
||||
float wanderAngle;
|
||||
|
||||
ushort targetID;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
newState = (AiState)message.ReadRangedInteger(0, Enum.GetValues(typeof(AiState)).Length - 1);
|
||||
|
||||
//bool wallAttack = message.ReadBoolean();
|
||||
|
||||
//if (wallAttack)
|
||||
//{
|
||||
// newWallAttackPos = new Vector2(
|
||||
// message.ReadRangedSingle(-50.0f, 50.0f, 10),
|
||||
// message.ReadRangedSingle(-50.0f, 50.0f, 10));
|
||||
|
||||
// newWallAttackPos += Submarine.Loaded.SimPosition;
|
||||
//}
|
||||
|
||||
//newVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
|
||||
//targetPosition = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
|
||||
wanderAngle = MathUtils.ByteToAngle(message.ReadByte());
|
||||
|
||||
coolDownTimer = message.ReadRangedSingle(0.0f, 30.0f, 8);
|
||||
|
||||
targetID = message.ReadUInt16();
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to read enemy ai update message", e);
|
||||
#endif
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
steeringManager.WanderAngle = wanderAngle;
|
||||
|
||||
if (targetID > 0) targetEntity = Entity.FindEntityByID(targetID) as IDamageable;
|
||||
//updateTargetsTimer = UpdateTargetsInterval;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//the "memory" of the Character
|
||||
|
||||
Reference in New Issue
Block a user