Displaying the names of the connected players in the server lobby
This commit is contained in:
@@ -546,16 +546,23 @@ namespace Barotrauma.Networking
|
||||
if (connectionStatus == NetConnectionStatus.Disconnected)
|
||||
{
|
||||
string disconnectMsg = inc.ReadString();
|
||||
if (disconnectMsg == "The server has been shut down")
|
||||
|
||||
switch (disconnectMsg)
|
||||
{
|
||||
var msgBox = new GUIMessageBox("CONNECTION LOST", "The server has been shut down");
|
||||
msgBox.Buttons[0].OnClicked += ReturnToServerList;
|
||||
}
|
||||
else if (reconnectBox == null)
|
||||
{
|
||||
reconnectBox = new GUIMessageBox("CONNECTION LOST", "You have been disconnected from the server. Reconnecting...", new string[0]);
|
||||
connected = false;
|
||||
ConnectToServer(serverIP);
|
||||
case "The server has been shut down":
|
||||
case "You have been banned from the server":
|
||||
case "You have been kicked from the server":
|
||||
var msgBox = new GUIMessageBox("CONNECTION LOST", disconnectMsg);
|
||||
msgBox.Buttons[0].OnClicked += ReturnToServerList;
|
||||
break;
|
||||
default:
|
||||
reconnectBox = new GUIMessageBox(
|
||||
"CONNECTION LOST",
|
||||
"You have been disconnected from the server. Reconnecting...", new string[0]);
|
||||
|
||||
connected = false;
|
||||
ConnectToServer(serverIP);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -743,8 +750,15 @@ namespace Barotrauma.Networking
|
||||
|
||||
string levelSeed = inc.ReadString();
|
||||
|
||||
bool autoRestartEnabled = inc.ReadBoolean();
|
||||
float autoRestartTimer = autoRestartEnabled ? inc.ReadFloat() : 0.0f;
|
||||
bool autoRestartEnabled = inc.ReadBoolean();
|
||||
float autoRestartTimer = autoRestartEnabled ? inc.ReadFloat() : 0.0f;
|
||||
|
||||
int clientCount = inc.ReadByte();
|
||||
List<string> clientNames = new List<string>();
|
||||
for (int i = 0; i < clientCount; i++)
|
||||
{
|
||||
clientNames.Add(inc.ReadString());
|
||||
}
|
||||
|
||||
//ignore the message if we already a more up-to-date one
|
||||
if (updateID > GameMain.NetLobbyScreen.LastUpdateID)
|
||||
@@ -764,6 +778,12 @@ namespace Barotrauma.Networking
|
||||
GameMain.NetLobbyScreen.LevelSeed = levelSeed;
|
||||
|
||||
GameMain.NetLobbyScreen.SetAutoRestart(autoRestartEnabled, autoRestartTimer);
|
||||
|
||||
GameMain.NetLobbyScreen.ClearPlayers();
|
||||
foreach (string clientName in clientNames)
|
||||
{
|
||||
GameMain.NetLobbyScreen.AddPlayer(clientName);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastSentChatMsgID = inc.ReadUInt32();
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Barotrauma.Networking
|
||||
config.SimulatedDuplicatesChance = 0.05f;
|
||||
config.SimulatedMinimumLatency = 0.1f;
|
||||
|
||||
config.ConnectionTimeout = 60.0f;
|
||||
config.ConnectionTimeout = 5.0f;
|
||||
#endif
|
||||
config.Port = port;
|
||||
Port = port;
|
||||
@@ -504,7 +504,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateTimer = DateTime.Now + updateInterval;
|
||||
}
|
||||
|
||||
@@ -690,7 +690,6 @@ namespace Barotrauma.Networking
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -811,6 +810,12 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
outmsg.Write(AutoRestartTimer);
|
||||
}
|
||||
|
||||
outmsg.Write((byte)connectedClients.Count);
|
||||
foreach (Client client in connectedClients)
|
||||
{
|
||||
outmsg.Write(client.name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1269,8 +1274,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
client.Connection.Disconnect(targetmsg);
|
||||
|
||||
GameMain.NetLobbyScreen.RemovePlayer(client.name);
|
||||
|
||||
GameMain.NetLobbyScreen.RemovePlayer(client.name);
|
||||
connectedClients.Remove(client);
|
||||
|
||||
AddChatMessage(msg, ChatMessageType.Server);
|
||||
|
||||
@@ -202,6 +202,8 @@ namespace Barotrauma.Networking
|
||||
unauthClient = null;
|
||||
ConnectedClients.Add(newClient);
|
||||
|
||||
GameMain.NetLobbyScreen.AddPlayer(newClient.name);
|
||||
|
||||
AddChatMessage(clName+" has joined the server.", ChatMessageType.Server);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user