Server clears EntityEventManager before starting a new round, not just when ending it (fixes events breaking during the next round if an item created an event when unloading the previous sub) + some additional error checks
This commit is contained in:
@@ -2044,12 +2044,27 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (GameMain.Server == null) return;
|
if (GameMain.Server == null) return;
|
||||||
|
|
||||||
|
if (c.Character != this)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
DebugConsole.Log("Received a character update message from a client who's not controlling the character");
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ClientNetObject.CHARACTER_INPUT:
|
case ClientNetObject.CHARACTER_INPUT:
|
||||||
|
|
||||||
UInt32 networkUpdateID = msg.ReadUInt32();
|
UInt32 networkUpdateID = msg.ReadUInt32();
|
||||||
byte inputCount = msg.ReadByte();
|
byte inputCount = msg.ReadByte();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
if (((long)networkUpdateID - (long)LastNetworkUpdateID)>10000)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("((long)networkUpdateID - (long)LastNetworkUpdateID) > 10000");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < inputCount; i++)
|
for (int i = 0; i < inputCount; i++)
|
||||||
{
|
{
|
||||||
@@ -2107,7 +2122,7 @@ namespace Barotrauma
|
|||||||
public virtual void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
public virtual void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
||||||
{
|
{
|
||||||
if (GameMain.Server == null) return;
|
if (GameMain.Server == null) return;
|
||||||
|
|
||||||
if (extraData != null)
|
if (extraData != null)
|
||||||
{
|
{
|
||||||
switch ((NetEntityEvent.Type)extraData[0])
|
switch ((NetEntityEvent.Type)extraData[0])
|
||||||
|
|||||||
@@ -511,9 +511,15 @@ namespace Barotrauma
|
|||||||
Submarine.MainSub.GodMode = !Submarine.MainSub.GodMode;
|
Submarine.MainSub.GodMode = !Submarine.MainSub.GodMode;
|
||||||
break;
|
break;
|
||||||
case "dumpids":
|
case "dumpids":
|
||||||
int count = commands.Length < 2 ? 10 : int.Parse(commands[1]);
|
try
|
||||||
|
{
|
||||||
Entity.DumpIds(count);
|
int count = commands.Length < 2 ? 10 : int.Parse(commands[1]);
|
||||||
|
Entity.DumpIds(count);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "heal":
|
case "heal":
|
||||||
if (Character.Controlled != null)
|
if (Character.Controlled != null)
|
||||||
|
|||||||
@@ -1250,6 +1250,8 @@ namespace Barotrauma
|
|||||||
if (GameMain.GameScreen.Cam != null) GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
if (GameMain.GameScreen.Cam != null) GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||||
|
|
||||||
Entity.RemoveAll();
|
Entity.RemoveAll();
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.Assert(Item.ItemList.Count == 0);
|
||||||
|
|
||||||
PhysicsBody.list.Clear();
|
PhysicsBody.list.Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -909,11 +909,12 @@ namespace Barotrauma.Networking
|
|||||||
private IEnumerable<object> StartGame(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
|
private IEnumerable<object> StartGame(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
|
||||||
{
|
{
|
||||||
Item.Spawner.Clear();
|
Item.Spawner.Clear();
|
||||||
|
entityEventManager.Clear();
|
||||||
|
|
||||||
GameMain.NetLobbyScreen.StartButton.Enabled = false;
|
GameMain.NetLobbyScreen.StartButton.Enabled = false;
|
||||||
|
|
||||||
GUIMessageBox.CloseAll();
|
GUIMessageBox.CloseAll();
|
||||||
|
|
||||||
roundStartSeed = DateTime.Now.Millisecond;
|
roundStartSeed = DateTime.Now.Millisecond;
|
||||||
Rand.SetSyncedSeed(roundStartSeed);
|
Rand.SetSyncedSeed(roundStartSeed);
|
||||||
|
|
||||||
@@ -1150,6 +1151,7 @@ namespace Barotrauma.Networking
|
|||||||
} while (secondsLeft > 0.0f);
|
} while (secondsLeft > 0.0f);
|
||||||
|
|
||||||
Submarine.Unload();
|
Submarine.Unload();
|
||||||
|
entityEventManager.Clear();
|
||||||
|
|
||||||
GameMain.NetLobbyScreen.Select();
|
GameMain.NetLobbyScreen.Select();
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ namespace Barotrauma.Networking
|
|||||||
tempBuffer.LengthBytes < 256,
|
tempBuffer.LengthBytes < 256,
|
||||||
"Maximum EntityEvent size exceeded when serializing \""+e.Entity+"\"!");
|
"Maximum EntityEvent size exceeded when serializing \""+e.Entity+"\"!");
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
if (Entity.FindEntityByID(e.Entity.ID) != e.Entity)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Error in NetEntityEventManager.Write (FindEntityByID(e.Entity.ID) != e.Entity)");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
msg.Write((UInt16)e.Entity.ID);
|
msg.Write((UInt16)e.Entity.ID);
|
||||||
msg.Write((byte)tempBuffer.LengthBytes);
|
msg.Write((byte)tempBuffer.LengthBytes);
|
||||||
msg.Write(tempBuffer);
|
msg.Write(tempBuffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user