Particle.FindAdjacentHulls exception fix, OpenAL "invalid value" dix, radar sync, better ragdoll sync, autoupdate cancel/retry on error
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Subsurface.Networking
|
||||
NetPeerConfiguration config = new NetPeerConfiguration("subsurface");
|
||||
|
||||
#if DEBUG
|
||||
config.SimulatedLoss = 0.2f;
|
||||
config.SimulatedLoss = 0.1f;
|
||||
config.SimulatedMinimumLatency = 0.3f;
|
||||
#endif
|
||||
|
||||
@@ -90,11 +90,14 @@ namespace Subsurface.Networking
|
||||
catch (ArgumentNullException e)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't connect to "+hostIP+". Error message: "+e.Message);
|
||||
Disconnect();
|
||||
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create timespan of 30ms
|
||||
updateInterval = new TimeSpan(0, 0, 0, 0, 200);
|
||||
|
||||
updateInterval = new TimeSpan(0, 0, 0, 0, 100);
|
||||
|
||||
// Set timer to tick every 50ms
|
||||
//update = new System.Timers.Timer(50);
|
||||
@@ -127,6 +130,9 @@ namespace Subsurface.Networking
|
||||
Disconnect();
|
||||
GameMain.NetworkMember = null;
|
||||
GameMain.MainMenuScreen.Select();
|
||||
|
||||
GameMain.MainMenuScreen.SelectTab(MainMenuScreen.Tab.LoadGame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,11 +166,21 @@ namespace Subsurface.Networking
|
||||
if (packetType == (byte)PacketTypes.LoggedIn)
|
||||
{
|
||||
myID = inc.ReadInt32();
|
||||
if (inc.ReadBoolean() && Screen.Selected != GameMain.GameScreen)
|
||||
bool gameStarted= inc.ReadBoolean();
|
||||
if (gameStarted && Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start.");
|
||||
}
|
||||
|
||||
bool hasCharacter = inc.ReadBoolean();
|
||||
|
||||
if (gameStarted && !hasCharacter && myCharacter!=null)
|
||||
{
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
|
||||
new GUIMessageBox("Connection timed out", "You were disconnected for too long and your character was deleted. Please wait for another round to start.");
|
||||
}
|
||||
|
||||
GameMain.NetLobbyScreen.ClearPlayers();
|
||||
|
||||
//add the names of other connected clients to the lobby screen
|
||||
@@ -173,12 +189,12 @@ namespace Subsurface.Networking
|
||||
{
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
GameMain.NetLobbyScreen.AddPlayer(otherClient);
|
||||
GameMain.NetLobbyScreen.AddPlayer(otherClient.name);
|
||||
otherClients.Add(otherClient);
|
||||
}
|
||||
|
||||
//add the name of own client to the lobby screen
|
||||
GameMain.NetLobbyScreen.AddPlayer(new Client(name, myID));
|
||||
GameMain.NetLobbyScreen.AddPlayer(name);
|
||||
|
||||
CanStart = true;
|
||||
}
|
||||
@@ -245,7 +261,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (client.ConnectionStatus == NetConnectionStatus.Disconnected)
|
||||
{
|
||||
GameMain.NetLobbyScreen.RemovePlayer(myID);
|
||||
//GameMain.NetLobbyScreen.RemovePlayer(myID);
|
||||
if (reconnectBox==null)
|
||||
{
|
||||
reconnectBox = new GUIMessageBox("CONNECTION LOST", "You have been disconnected from the server. Reconnecting...", new string[0]);
|
||||
@@ -330,7 +346,7 @@ namespace Subsurface.Networking
|
||||
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
GameMain.NetLobbyScreen.AddPlayer(otherClient);
|
||||
GameMain.NetLobbyScreen.AddPlayer(otherClient.name);
|
||||
otherClients.Add(otherClient);
|
||||
|
||||
AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server);
|
||||
@@ -340,13 +356,15 @@ namespace Subsurface.Networking
|
||||
int leavingID = inc.ReadInt32();
|
||||
|
||||
AddChatMessage(inc.ReadString(), ChatMessageType.Server);
|
||||
GameMain.NetLobbyScreen.RemovePlayer(otherClients.Find(c => c.ID==leavingID));
|
||||
Client disconnectedClient = otherClients.Find(c => c.ID == leavingID);
|
||||
if (disconnectedClient != null) GameMain.NetLobbyScreen.RemovePlayer(disconnectedClient.name);
|
||||
|
||||
break;
|
||||
|
||||
case (byte)PacketTypes.KickedOut:
|
||||
string msg = inc.ReadString();
|
||||
|
||||
new GUIMessageBox("KICKED", msg);
|
||||
new GUIMessageBox("You have been kicked out from the server", msg);
|
||||
|
||||
GameMain.MainMenuScreen.Select();
|
||||
|
||||
@@ -370,9 +388,7 @@ namespace Subsurface.Networking
|
||||
new GUIMessageBox("You are the Traitor!", "Your secret task is to assassinate " + targetName + "!");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,6 +404,16 @@ namespace Subsurface.Networking
|
||||
string mapName = inc.ReadString();
|
||||
string mapHash = inc.ReadString();
|
||||
|
||||
string modeName = inc.ReadString();
|
||||
|
||||
GameModePreset gameMode = GameModePreset.list.Find(gm => gm.Name == modeName);
|
||||
|
||||
if (gameMode == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Game mode ''"+gameMode+"'' not found!");
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
if (!GameMain.NetLobbyScreen.TrySelectMap(mapName, mapHash))
|
||||
{
|
||||
yield return CoroutineStatus.Success;
|
||||
@@ -401,7 +427,7 @@ namespace Subsurface.Networking
|
||||
Rand.SetSyncedSeed(seed);
|
||||
//int gameModeIndex = inc.ReadInt32();
|
||||
|
||||
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedMap, "", GameMain.NetLobbyScreen.SelectedMode);
|
||||
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedMap, "", gameMode);
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
@@ -508,6 +534,7 @@ namespace Subsurface.Networking
|
||||
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
client.Shutdown("");
|
||||
GameMain.NetworkMember = null;
|
||||
}
|
||||
|
||||
public void SendCharacterData()
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace Subsurface.Networking
|
||||
private NetServer server;
|
||||
private NetPeerConfiguration config;
|
||||
|
||||
private TimeSpan SparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
|
||||
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
|
||||
private DateTime sparseUpdateTimer;
|
||||
|
||||
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 40);
|
||||
private DateTime refreshMasterTimer;
|
||||
|
||||
|
||||
private bool masterServerResponded;
|
||||
|
||||
private bool registeredToMaster;
|
||||
@@ -110,9 +110,8 @@ namespace Subsurface.Networking
|
||||
{
|
||||
RegisterToMasterServer();
|
||||
}
|
||||
|
||||
|
||||
updateInterval = new TimeSpan(0, 0, 0, 0, 30);
|
||||
|
||||
updateInterval = new TimeSpan(0, 0, 0, 0, 60);
|
||||
|
||||
DebugConsole.NewMessage("Server started", Color.Green);
|
||||
|
||||
@@ -203,17 +202,15 @@ namespace Subsurface.Networking
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (!started) return;
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
|
||||
if (gameStarted)
|
||||
{
|
||||
if (myCharacter!=null) new NetworkEvent(myCharacter.ID, true);
|
||||
|
||||
inGameHUD.Update((float)Physics.step);
|
||||
}
|
||||
|
||||
@@ -221,6 +218,13 @@ namespace Subsurface.Networking
|
||||
{
|
||||
disconnectedClients[i].deleteDisconnectedTimer -= deltaTime;
|
||||
if (disconnectedClients[i].deleteDisconnectedTimer > 0.0f) continue;
|
||||
|
||||
if (gameStarted && disconnectedClients[i].character!=null)
|
||||
{
|
||||
disconnectedClients[i].character.Remove();
|
||||
disconnectedClients[i].character = null;
|
||||
}
|
||||
|
||||
disconnectedClients.RemoveAt(i);
|
||||
}
|
||||
|
||||
@@ -240,6 +244,21 @@ namespace Subsurface.Networking
|
||||
// if 30ms has passed
|
||||
if (updateTimer < DateTime.Now)
|
||||
{
|
||||
if (gameStarted)
|
||||
{
|
||||
if (myCharacter != null) new NetworkEvent(myCharacter.ID, true);
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (c as AICharacter == null) continue;
|
||||
|
||||
if (c.SimPosition == Vector2.Zero || c.SimPosition.Length() < 100.0f)
|
||||
{
|
||||
new NetworkEvent(c.ID, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (server.ConnectionsCount > 0)
|
||||
{
|
||||
if (sparseUpdateTimer < DateTime.Now) SparseUpdate();
|
||||
@@ -260,26 +279,9 @@ namespace Subsurface.Networking
|
||||
|
||||
private void SparseUpdate()
|
||||
{
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
bool isClient = false;
|
||||
foreach (Client client in connectedClients)
|
||||
{
|
||||
if (client.character != c) continue;
|
||||
isClient = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isClient && (c.SimPosition==Vector2.Zero || c.SimPosition.Length() < 300.0f))
|
||||
{
|
||||
c.LargeUpdateTimer -= 2;
|
||||
new NetworkEvent(c.ID, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (gameStarted) new NetworkEvent(Submarine.Loaded.ID, false);
|
||||
|
||||
sparseUpdateTimer = DateTime.Now + SparseUpdateInterval;
|
||||
sparseUpdateTimer = DateTime.Now + sparseUpdateInterval;
|
||||
}
|
||||
|
||||
private void ReadMessage(NetIncomingMessage inc)
|
||||
@@ -313,7 +315,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
//AssignJobs();
|
||||
|
||||
GameMain.NetLobbyScreen.AddPlayer(sender);
|
||||
GameMain.NetLobbyScreen.AddPlayer(sender.name);
|
||||
|
||||
// Notify the client that they have logged in
|
||||
outmsg = server.CreateMessage();
|
||||
@@ -324,6 +326,8 @@ namespace Subsurface.Networking
|
||||
|
||||
outmsg.Write(gameStarted);
|
||||
|
||||
outmsg.Write(gameStarted && sender.character!=null);
|
||||
|
||||
//notify the client about other clients already logged in
|
||||
outmsg.Write((characterInfo == null) ? connectedClients.Count - 1 : connectedClients.Count);
|
||||
foreach (Client c in connectedClients)
|
||||
@@ -365,7 +369,8 @@ namespace Subsurface.Networking
|
||||
disconnectedClients.Add(connectedClient);
|
||||
}
|
||||
|
||||
DisconnectClient(inc.SenderConnection);
|
||||
DisconnectClient(inc.SenderConnection,
|
||||
connectedClient != null ? connectedClient.name+" has disconnected" : "");
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -392,9 +397,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (recipients.Count == 0) break;
|
||||
server.SendMessage(outmsg, recipients, inc.DeliveryMethod, 0);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Sending networkevent (" + outmsg.LengthBytes+" bytes)");
|
||||
|
||||
|
||||
break;
|
||||
case (byte)PacketTypes.Chatmessage:
|
||||
ChatMessageType messageType = (ChatMessageType)inc.ReadByte();
|
||||
@@ -537,10 +540,9 @@ namespace Subsurface.Networking
|
||||
private void SendNetworkEvents()
|
||||
{
|
||||
if (NetworkEvent.events.Count == 0) return;
|
||||
|
||||
|
||||
foreach (NetworkEvent networkEvent in NetworkEvent.events)
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine("networkevent "+networkEvent.ID);
|
||||
|
||||
List<NetConnection> recipients = new List<NetConnection>();
|
||||
|
||||
@@ -565,16 +567,13 @@ namespace Subsurface.Networking
|
||||
|
||||
networkEvent.FillData(message);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Sending networkevent " + Entity.FindEntityByID(networkEvent.ID).ToString() + " (" + message.LengthBytes + " bytes)");
|
||||
|
||||
if (server.ConnectionsCount>0)
|
||||
{
|
||||
server.SendMessage(message, recipients,
|
||||
(networkEvent.IsImportant) ? NetDeliveryMethod.Unreliable : NetDeliveryMethod.ReliableUnordered, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
NetworkEvent.events.Clear();
|
||||
NetworkEvent.events.Clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -661,6 +660,8 @@ namespace Subsurface.Networking
|
||||
msg.Write(GameMain.NetLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(GameMain.NetLobbyScreen.SelectedMap.MD5Hash.Hash);
|
||||
|
||||
msg.Write(GameMain.NetLobbyScreen.SelectedMode.Name);
|
||||
|
||||
msg.Write(GameMain.NetLobbyScreen.GameDuration.TotalMinutes);
|
||||
|
||||
msg.Write((myCharacter == null) ? connectedClients.Count : connectedClients.Count + 1);
|
||||
@@ -677,8 +678,11 @@ namespace Subsurface.Networking
|
||||
}
|
||||
|
||||
SendMessage(msg, NetDeliveryMethod.ReliableUnordered, null);
|
||||
|
||||
CreateCrewFrame(crew);
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
//give some time for the clients to load the map
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
@@ -686,8 +690,6 @@ namespace Subsurface.Networking
|
||||
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
CreateCrewFrame(crew);
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
|
||||
}
|
||||
@@ -758,10 +760,10 @@ namespace Subsurface.Networking
|
||||
|
||||
}
|
||||
|
||||
private void DisconnectClient(NetConnection senderConnection)
|
||||
private void DisconnectClient(NetConnection senderConnection, string msg = "", string targetmsg = "")
|
||||
{
|
||||
Client client = connectedClients.Find(x => x.Connection == senderConnection);
|
||||
if (client != null) DisconnectClient(client);
|
||||
if (client != null) DisconnectClient(client, msg, targetmsg);
|
||||
}
|
||||
|
||||
private void DisconnectClient(Client client, string msg = "", string targetmsg = "")
|
||||
@@ -770,8 +772,8 @@ namespace Subsurface.Networking
|
||||
|
||||
if (gameStarted && client.character != null) client.character.ClearInputs();
|
||||
|
||||
if (msg == "") msg = client.name + " has left the server";
|
||||
if (targetmsg == "") targetmsg = "You have left the server";
|
||||
if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server";
|
||||
if (string.IsNullOrWhiteSpace(targetmsg)) targetmsg = "You have left the server";
|
||||
|
||||
NetOutgoingMessage outmsg = server.CreateMessage();
|
||||
outmsg.Write((byte)PacketTypes.KickedOut);
|
||||
@@ -785,7 +787,7 @@ namespace Subsurface.Networking
|
||||
outmsg.Write(client.ID);
|
||||
outmsg.Write(msg);
|
||||
|
||||
GameMain.NetLobbyScreen.RemovePlayer(client);
|
||||
GameMain.NetLobbyScreen.RemovePlayer(client.name);
|
||||
|
||||
if (server.Connections.Count > 0)
|
||||
{
|
||||
@@ -1092,7 +1094,7 @@ namespace Subsurface.Networking
|
||||
|
||||
public override void Disconnect()
|
||||
{
|
||||
server.Shutdown("");
|
||||
server.Shutdown("The server has shut down");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
public static List<NetworkEvent> events = new List<NetworkEvent>();
|
||||
|
||||
private static bool[] isImportant = { false, true, false, true, true, true, true, false };
|
||||
private static bool[] isImportant = { false, true, false, true, true, true, true };
|
||||
|
||||
private int id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user