Fixed clients being unable to toggle doors when they've predicted the state of the door and waiting for a confirmation from the server, reading a position update for an item with no body doesn't throw an exception

This commit is contained in:
Regalis
2017-05-10 21:19:10 +03:00
parent ad90cf804d
commit 1d3da3e70b
2 changed files with 22 additions and 38 deletions

View File

@@ -488,26 +488,27 @@ namespace Barotrauma.Items.Components
{
if (isStuck) return;
bool wasOpen = isOpen;
bool wasOpen = predictedState == null ? isOpen : predictedState.Value;
if (connection.Name == "toggle")
{
SetState(!isOpen, false, true);
SetState(!wasOpen, false, true);
}
else if (connection.Name == "set_state")
{
SetState(signal != "0", false, true);
}
if (sender != null && wasOpen != isOpen)
bool newState = predictedState == null ? isOpen : predictedState.Value;
if (sender != null && wasOpen != newState)
{
GameServer.Log(sender.Name + (isOpen ? " opened " : " closed ") + item.Name, ServerLog.MessageType.ItemInteraction);
GameServer.Log(sender.Name + (newState ? " opened " : " closed ") + item.Name, ServerLog.MessageType.ItemInteraction);
}
}
public void SetState(bool open, bool isNetworkMessage, bool sendNetworkMessage = false)
{
if (isStuck || isOpen == open) return;
if (isStuck || (predictedState == null && isOpen == open) || (predictedState != null && isOpen == predictedState.Value)) return;
if (GameMain.Client != null && !isNetworkMessage)
{