- DockingPort syncing fix: server waits until the port is locked before sending hull/gap IDs, clients can't lock the port until the server tells them to
- fixed crew commands being disabled in single player instead of multiplayer - server-side ID error logging fix
This commit is contained in:
@@ -158,7 +158,7 @@ namespace Barotrauma
|
|||||||
guiFrame.Update(deltaTime);
|
guiFrame.Update(deltaTime);
|
||||||
|
|
||||||
//TODO: implement AI commands in multiplayer?
|
//TODO: implement AI commands in multiplayer?
|
||||||
if (GameMain.NetworkMember != null &&
|
if (GameMain.NetworkMember == null &&
|
||||||
GameMain.Config.KeyBind(InputType.CrewOrders).IsHit())
|
GameMain.Config.KeyBind(InputType.CrewOrders).IsHit())
|
||||||
{
|
{
|
||||||
//deselect construction unless it's the ladders the character is climbing
|
//deselect construction unless it's the ladders the character is climbing
|
||||||
|
|||||||
@@ -236,8 +236,10 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Lock()
|
public void Lock(bool isNetworkMessage)
|
||||||
{
|
{
|
||||||
|
if (GameMain.Client != null && !isNetworkMessage) return;
|
||||||
|
|
||||||
if (dockingTarget==null)
|
if (dockingTarget==null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error - attempted to lock a docking port that's not connected to anything");
|
DebugConsole.ThrowError("Error - attempted to lock a docking port that's not connected to anything");
|
||||||
@@ -245,7 +247,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
else if (joint is WeldJoint)
|
else if (joint is WeldJoint)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error - attempted to lock a docking port that's already locked");
|
//DebugConsole.ThrowError("Error - attempted to lock a docking port that's already locked");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,11 +262,14 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
CreateJoint(true);
|
CreateJoint(true);
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
item.CreateServerEvent(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!item.linkedTo.Any(e => e is Hull) && !dockingTarget.item.linkedTo.Any(e => e is Hull))
|
if (!item.linkedTo.Any(e => e is Hull) && !dockingTarget.item.linkedTo.Any(e => e is Hull))
|
||||||
{
|
{
|
||||||
CreateHull();
|
CreateHull();
|
||||||
|
|
||||||
//item.NewComponentEvent(this, false, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,7 +606,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f)
|
if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -621,24 +626,24 @@ namespace Barotrauma.Items.Components
|
|||||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||||
{
|
{
|
||||||
if (dockingState == 0.0f) return;
|
if (dockingState == 0.0f) return;
|
||||||
|
|
||||||
Vector2 drawPos = item.DrawPosition;
|
Vector2 drawPos = item.DrawPosition;
|
||||||
drawPos.Y = -drawPos.Y;
|
drawPos.Y = -drawPos.Y;
|
||||||
|
|
||||||
var rect = overlaySprite.SourceRect;
|
var rect = overlaySprite.SourceRect;
|
||||||
|
|
||||||
if (IsHorizontal)
|
if (IsHorizontal)
|
||||||
{
|
{
|
||||||
drawPos.Y -= rect.Height / 2;
|
drawPos.Y -= rect.Height / 2;
|
||||||
|
|
||||||
if (dockingDir == 1)
|
if (dockingDir == 1)
|
||||||
{
|
{
|
||||||
spriteBatch.Draw(overlaySprite.Texture,
|
spriteBatch.Draw(overlaySprite.Texture,
|
||||||
drawPos,
|
drawPos,
|
||||||
new Rectangle(
|
new Rectangle(
|
||||||
rect.Center.X + (int)(rect.Width / 2 * (1.0f - dockingState)), rect.Y,
|
rect.Center.X + (int)(rect.Width / 2 * (1.0f - dockingState)), rect.Y,
|
||||||
(int)(rect.Width / 2 * dockingState), rect.Height), Color.White);
|
(int)(rect.Width / 2 * dockingState), rect.Height), Color.White);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -647,29 +652,28 @@ namespace Barotrauma.Items.Components
|
|||||||
new Rectangle(
|
new Rectangle(
|
||||||
rect.X, rect.Y,
|
rect.X, rect.Y,
|
||||||
(int)(rect.Width / 2 * dockingState), rect.Height), Color.White);
|
(int)(rect.Width / 2 * dockingState), rect.Height), Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawPos.X -= rect.Width / 2;
|
drawPos.X -= rect.Width / 2;
|
||||||
|
|
||||||
if (dockingDir == 1)
|
if (dockingDir == 1)
|
||||||
{
|
|
||||||
spriteBatch.Draw(overlaySprite.Texture,
|
|
||||||
drawPos,
|
|
||||||
new Rectangle(
|
|
||||||
rect.X, rect.Y + rect.Height/2 + (int)(rect.Height / 2 * (1.0f - dockingState)),
|
|
||||||
rect.Width, (int)(rect.Height / 2 * dockingState)), Color.White);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
spriteBatch.Draw(overlaySprite.Texture,
|
spriteBatch.Draw(overlaySprite.Texture,
|
||||||
drawPos - Vector2.UnitY * (rect.Height / 2 * dockingState),
|
drawPos - Vector2.UnitY * (rect.Height / 2 * dockingState),
|
||||||
new Rectangle(
|
new Rectangle(
|
||||||
rect.X, rect.Y,
|
rect.X, rect.Y,
|
||||||
rect.Width, (int)(rect.Height / 2 * dockingState)), Color.White);
|
rect.Width, (int)(rect.Height / 2 * dockingState)), Color.White);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spriteBatch.Draw(overlaySprite.Texture,
|
||||||
|
drawPos,
|
||||||
|
new Rectangle(
|
||||||
|
rect.X, rect.Y + rect.Height / 2 + (int)(rect.Height / 2 * (1.0f - dockingState)),
|
||||||
|
rect.Width, (int)(rect.Height / 2 * dockingState)), Color.White);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,9 +754,17 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
msg.Write(dockingTarget.item.ID);
|
msg.Write(dockingTarget.item.ID);
|
||||||
|
|
||||||
msg.Write((ushort)hullIds[0]);
|
if (hullIds[0] != null && hullIds[1] != null && gapId != null)
|
||||||
msg.Write((ushort)hullIds[1]);
|
{
|
||||||
msg.Write((ushort)gapId);
|
msg.Write(true);
|
||||||
|
msg.Write((ushort)hullIds[0]);
|
||||||
|
msg.Write((ushort)hullIds[1]);
|
||||||
|
msg.Write((ushort)gapId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.Write(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,12 +774,17 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (isDocked)
|
if (isDocked)
|
||||||
{
|
{
|
||||||
ushort dockingTargetID = msg.ReadUInt16();
|
ushort dockingTargetID = msg.ReadUInt16();
|
||||||
|
|
||||||
|
bool isLocked = msg.ReadBoolean();
|
||||||
|
|
||||||
|
if (isLocked)
|
||||||
|
{
|
||||||
|
hullIds[0] = msg.ReadUInt16();
|
||||||
|
hullIds[1] = msg.ReadUInt16();
|
||||||
|
gapId = msg.ReadUInt16();
|
||||||
|
}
|
||||||
|
|
||||||
hullIds[0] = msg.ReadUInt16();
|
|
||||||
hullIds[1] = msg.ReadUInt16();
|
|
||||||
gapId = msg.ReadUInt16();
|
|
||||||
|
|
||||||
Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
|
Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
|
||||||
if (targetEntity == null || !(targetEntity is Item))
|
if (targetEntity == null || !(targetEntity is Item))
|
||||||
{
|
{
|
||||||
@@ -782,22 +799,22 @@ namespace Barotrauma.Items.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hulls != null)
|
|
||||||
{
|
|
||||||
if (hulls[0] != null) hulls[0].ID = (ushort)hullIds[0];
|
|
||||||
if (hulls[1] != null) hulls[1].ID = (ushort)hullIds[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gap != null) gap.ID = (ushort)gapId;
|
|
||||||
|
|
||||||
Dock(dockingTarget);
|
Dock(dockingTarget);
|
||||||
|
|
||||||
|
if (isLocked)
|
||||||
|
{
|
||||||
|
Lock(true);
|
||||||
|
|
||||||
|
hulls[0].ID = (ushort)hullIds[0];
|
||||||
|
hulls[1].ID = (ushort)hullIds[1];
|
||||||
|
gap.ID = (ushort)gapId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Undock();
|
Undock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
|
|
||||||
myPort.Dock(linkedPort);
|
myPort.Dock(linkedPort);
|
||||||
myPort.Lock();
|
myPort.Lock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub.SetPosition(sub.WorldPosition - Submarine.WorldPosition);
|
sub.SetPosition(sub.WorldPosition - Submarine.WorldPosition);
|
||||||
|
|||||||
@@ -703,10 +703,10 @@ namespace Barotrauma.Networking
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
//client thinks they've received a msg we haven't sent yet (corrupted packet, msg read/written incorrectly?)
|
//client thinks they've received a msg we haven't sent yet (corrupted packet, msg read/written incorrectly?)
|
||||||
if (NetIdUtils.IdMoreRecent(lastRecvChatMsgID, c.lastChatMsgQueueID))
|
if (NetIdUtils.IdMoreRecent(lastRecvChatMsgID, c.lastChatMsgQueueID))
|
||||||
DebugConsole.ThrowError("client.lastRecvChatMsgID > lastChatMsgQueueID (" + c.lastRecvChatMsgID + " > " + c.lastChatMsgQueueID + ")");
|
DebugConsole.ThrowError("client.lastRecvChatMsgID > lastChatMsgQueueID (" + lastRecvChatMsgID + " > " + c.lastChatMsgQueueID + ")");
|
||||||
|
|
||||||
if (lastRecvEntityEventID > lastEntityEventID)
|
if (lastRecvEntityEventID > lastEntityEventID)
|
||||||
DebugConsole.ThrowError("client.lastRecvEntityEventID > lastEntityEventID (" + c.lastRecvEntityEventID + " > " + lastEntityEventID + ")");
|
DebugConsole.ThrowError("client.lastRecvEntityEventID > lastEntityEventID (" + lastRecvEntityEventID + " > " + lastEntityEventID + ")");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NetIdUtils.IdMoreRecent(lastRecvChatMsgID, c.lastRecvChatMsgID)) c.lastRecvChatMsgID = lastRecvChatMsgID;
|
if (NetIdUtils.IdMoreRecent(lastRecvChatMsgID, c.lastRecvChatMsgID)) c.lastRecvChatMsgID = lastRecvChatMsgID;
|
||||||
|
|||||||
Reference in New Issue
Block a user