(0bab4a8d4) More reliable item wall attaching syncing. The problem was similar as the one fixed in 0835d92: the server occasionally received the unreliable attach inputs after the reliable item drop message, preventing the character from attaching the item server-side because it was not in the character's inventory anymore.
This commit is contained in:
@@ -426,11 +426,11 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override bool Use(float deltaTime, Character character = null)
|
public override bool Use(float deltaTime, Character character = null)
|
||||||
{
|
{
|
||||||
if (!attachable || item.body == null) return (character == null || character.IsKeyDown(InputType.Aim));
|
if (!attachable || item.body == null) { return character == null || character.IsKeyDown(InputType.Aim); }
|
||||||
if (character != null)
|
if (character != null)
|
||||||
{
|
{
|
||||||
if (!character.IsKeyDown(InputType.Aim)) return false;
|
if (!character.IsKeyDown(InputType.Aim)) { return false; }
|
||||||
if (!CanBeAttached()) return false;
|
if (!CanBeAttached()) { return false; }
|
||||||
#if SERVER
|
#if SERVER
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
@@ -438,10 +438,13 @@ namespace Barotrauma.Items.Components
|
|||||||
GameServer.Log(character.LogName + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction);
|
GameServer.Log(character.LogName + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
item.Drop(character);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachToWall();
|
if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)
|
||||||
|
{
|
||||||
|
if (character != null) { item.Drop(character); }
|
||||||
|
AttachToWall();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -552,7 +555,7 @@ namespace Barotrauma.Items.Components
|
|||||||
public override void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
public override void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
||||||
{
|
{
|
||||||
base.ServerWrite(msg, c, extraData);
|
base.ServerWrite(msg, c, extraData);
|
||||||
if (!attachable || body == null) return;
|
if (!attachable || body == null) { return; }
|
||||||
|
|
||||||
msg.Write(Attached);
|
msg.Write(Attached);
|
||||||
msg.Write(body.SimPosition.X);
|
msg.Write(body.SimPosition.X);
|
||||||
|
|||||||
Reference in New Issue
Block a user