Merge branch 'new-netcode' of https://gitlab.com/poe.regalis/barotrauma into new-netcode
This commit is contained in:
@@ -207,6 +207,19 @@ namespace Barotrauma.Networking
|
||||
DebugConsole.Log(" Sequence channel: " + inc.SequenceChannel);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(downloadFolder))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(downloadFolder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not start a file transfer: failed to create the folder \""+downloadFolder+"\".", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var newTransfer = new FileTransferIn(inc.SenderConnection, Path.Combine(downloadFolder, fileName), (FileTransferType)fileType);
|
||||
newTransfer.SequenceChannel = inc.SequenceChannel;
|
||||
newTransfer.Status = FileTransferStatus.Receiving;
|
||||
|
||||
@@ -97,19 +97,30 @@ namespace Barotrauma.Networking
|
||||
msg.Write((byte)ClientNetObject.ENTITY_STATE);
|
||||
Write(msg, eventsToSync);
|
||||
}
|
||||
|
||||
|
||||
private UInt16? firstNewID;
|
||||
|
||||
/// <summary>
|
||||
/// Read the events from the message, ignoring ones we've already received
|
||||
/// </summary>
|
||||
public void Read(ServerNetObject type, NetIncomingMessage msg, float sendingTime)
|
||||
{
|
||||
UInt16 unreceivedEntityEventCount = 0;
|
||||
UInt16 firstNewID = 0;
|
||||
|
||||
if (type == ServerNetObject.ENTITY_EVENT_INITIAL)
|
||||
{
|
||||
unreceivedEntityEventCount = msg.ReadUInt16();
|
||||
firstNewID = msg.ReadUInt16();
|
||||
|
||||
DebugConsole.NewMessage("received midround syncing msg, unreceived: "+unreceivedEntityEventCount+", first new ID: "+firstNewID, Microsoft.Xna.Framework.Color.Yellow);
|
||||
|
||||
}
|
||||
else if (firstNewID != null)
|
||||
{
|
||||
DebugConsole.NewMessage("midround syncing complete, switching to ID "+ (UInt16)(firstNewID - 1), Microsoft.Xna.Framework.Color.Yellow);
|
||||
|
||||
lastReceivedID = (UInt16)(firstNewID - 1);
|
||||
firstNewID = null;
|
||||
}
|
||||
|
||||
UInt16 firstEventID = msg.ReadUInt16();
|
||||
@@ -165,15 +176,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
msg.ReadPadBits();
|
||||
}
|
||||
|
||||
if (type == ServerNetObject.ENTITY_EVENT_INITIAL)
|
||||
{
|
||||
if (lastReceivedID == unreceivedEntityEventCount - 1 ||
|
||||
unreceivedEntityEventCount == 0)
|
||||
{
|
||||
lastReceivedID = (UInt16)(firstNewID - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteEvent(NetBuffer buffer, NetEntityEvent entityEvent, Client recipient = null)
|
||||
@@ -195,6 +197,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
lastReceivedID = 0;
|
||||
|
||||
firstNewID = null;
|
||||
|
||||
events.Clear();
|
||||
eventLastSent.Clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user