Fixed incorrect msg lengths in CHARACTER_POSITION messages (+ calculating the length automatically)
This commit is contained in:
@@ -2067,18 +2067,16 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
msg.Write(ID);
|
msg.Write(ID);
|
||||||
|
|
||||||
|
NetBuffer tempBuffer = new NetBuffer();
|
||||||
|
|
||||||
if (this == c.Character)
|
if (this == c.Character)
|
||||||
{
|
{
|
||||||
//length of the message
|
tempBuffer.Write(true);
|
||||||
msg.Write((byte)(4+4+4));
|
tempBuffer.Write((UInt32)(LastNetworkUpdateID - memInput.Count - 1));
|
||||||
msg.Write(true);
|
|
||||||
msg.Write((UInt32)(LastNetworkUpdateID - memInput.Count - 1));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//length of the message
|
tempBuffer.Write(false);
|
||||||
msg.Write((byte)(4+4+1 + 1 + 1));
|
|
||||||
msg.Write(false);
|
|
||||||
|
|
||||||
bool aiming = false;
|
bool aiming = false;
|
||||||
bool use = false;
|
bool use = false;
|
||||||
@@ -2096,33 +2094,36 @@ namespace Barotrauma
|
|||||||
networkUpdateSent = true;
|
networkUpdateSent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Write(aiming);
|
tempBuffer.Write(aiming);
|
||||||
msg.Write(use);
|
tempBuffer.Write(use);
|
||||||
|
|
||||||
if (selectedCharacter != null || selectedConstruction != null)
|
if (selectedCharacter != null || selectedConstruction != null)
|
||||||
{
|
{
|
||||||
msg.Write(true);
|
tempBuffer.Write(true);
|
||||||
msg.Write(selectedCharacter != null ? selectedCharacter.ID : selectedConstruction.ID);
|
tempBuffer.Write(selectedCharacter != null ? selectedCharacter.ID : selectedConstruction.ID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.Write(false);
|
tempBuffer.Write(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aiming)
|
if (aiming)
|
||||||
{
|
{
|
||||||
//TODO: write this with less accuracy?
|
//TODO: write this with less accuracy?
|
||||||
|
|
||||||
|
|
||||||
msg.Write(cursorPosition.X);
|
|
||||||
msg.Write(cursorPosition.Y);
|
tempBuffer.Write(cursorPosition.X);
|
||||||
|
tempBuffer.Write(cursorPosition.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Write(AnimController.TargetDir == Direction.Right);
|
tempBuffer.Write(AnimController.TargetDir == Direction.Right);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Write(SimPosition.X);
|
tempBuffer.Write(SimPosition.X);
|
||||||
msg.Write(SimPosition.Y);
|
tempBuffer.Write(SimPosition.Y);
|
||||||
|
|
||||||
|
msg.Write((byte)tempBuffer.LengthBytes);
|
||||||
|
msg.Write(tempBuffer);
|
||||||
|
|
||||||
msg.WritePadBits();
|
msg.WritePadBits();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user