diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index 3e95f82d0..e3a848d2e 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -150,6 +150,7 @@
+
diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs
index a7a61d1a2..8705f28dc 100644
--- a/Subsurface/Source/DebugConsole.cs
+++ b/Subsurface/Source/DebugConsole.cs
@@ -191,7 +191,8 @@ namespace Barotrauma
NewMessage("kick [name]: kick a player out from the server", Color.Cyan);
- NewMessage("ban [name]: kick and ban the player", Color.Cyan);
+ NewMessage("ban [name]: kick and ban the player from the server", Color.Cyan);
+ NewMessage("banip [IP address]: ban the IP address from the server", Color.Cyan);
NewMessage("debugdraw: toggles the ''debug draw mode''", Color.Cyan);
NewMessage("netstats: toggles the visibility of the network statistics panel", Color.Cyan);
@@ -289,6 +290,19 @@ namespace Barotrauma
if (GameMain.Server == null || commands.Length < 2) break;
GameMain.Server.KickPlayer(string.Join(" ", commands.Skip(1)), true);
break;
+ case "banip":
+ if (GameMain.Server == null || commands.Length < 2) break;
+
+ var client = GameMain.Server.ConnectedClients.Find(c => c.Connection.RemoteEndPoint.Address.ToString() == commands[1]);
+ if (client == null)
+ {
+ GameMain.Server.BanList.BanPlayer("Unnamed", commands[1]);
+ }
+ else
+ {
+ GameMain.Server.KickClient(client, true);
+ }
+ break;
case "startclient":
if (commands.Length == 1) return;
if (GameMain.Client == null)
diff --git a/Subsurface/Source/Networking/BanList.cs b/Subsurface/Source/Networking/BanList.cs
index 310e99084..3908ba0bf 100644
--- a/Subsurface/Source/Networking/BanList.cs
+++ b/Subsurface/Source/Networking/BanList.cs
@@ -66,7 +66,10 @@ namespace Barotrauma.Networking
{
if (bannedPlayers.Any(bp => bp.IP == ip)) return;
+ DebugConsole.Log("Banned " + name);
+
bannedPlayers.Add(new BannedPlayer(name, ip));
+ Save();
}
public bool IsBanned(string IP)
@@ -108,10 +111,13 @@ namespace Barotrauma.Networking
BannedPlayer banned = obj as BannedPlayer;
if (banned == null) return false;
+ DebugConsole.Log("Removing ban from " + banned.Name);
GameServer.Log("Removing ban from " + banned.Name, null);
bannedPlayers.Remove(banned);
+ Save();
+
if (banFrame != null)
{
banFrame.Parent.RemoveChild(banFrame);
@@ -130,7 +136,6 @@ namespace Barotrauma.Networking
public void Save()
{
-
GameServer.Log("Saving banlist", null);
List lines = new List();
diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs
index a0bbfdbe3..f296de32c 100644
--- a/Subsurface/Source/Networking/GameClient.cs
+++ b/Subsurface/Source/Networking/GameClient.cs
@@ -108,21 +108,13 @@ namespace Barotrauma.Networking
config.DisableMessageType(NetIncomingMessageType.DebugMessage | NetIncomingMessageType.WarningMessage | NetIncomingMessageType.Receipt
| NetIncomingMessageType.ErrorMessage | NetIncomingMessageType.Error);
- // Create new client, with previously created configs
client = new NetClient(config);
netPeer = client;
reliableChannel = new ReliableChannel(client);
-
- NetOutgoingMessage outmsg = client.CreateMessage();
client.Start();
+ NetOutgoingMessage outmsg = client.CreateMessage();
outmsg.Write((byte)PacketTypes.Login);
- outmsg.Write(myID);
- outmsg.Write(password);
- outmsg.Write(GameMain.Version.ToString());
- outmsg.Write(GameMain.SelectedPackage.Name);
- outmsg.Write(GameMain.SelectedPackage.MD5hash.Hash);
- outmsg.Write(name);
System.Net.IPEndPoint IPEndPoint = null;
@@ -141,6 +133,7 @@ namespace Barotrauma.Networking
try
{
client.Connect(IPEndPoint, outmsg);
+
}
catch (Exception e)
{
@@ -150,17 +143,9 @@ namespace Barotrauma.Networking
GameMain.ServerListScreen.Select();
return;
}
-
-
+
updateInterval = new TimeSpan(0, 0, 0, 0, 150);
- // Set timer to tick every 50ms
- //update = new System.Timers.startTimer(50);
-
- // When time has elapsed ( 50ms in this case ), call "update_Elapsed" funtion
- //update.Elapsed += new System.Timers.ElapsedEventHandler(Update);
-
- // Funtion that waits for connection approval info from server
if (reconnectBox==null)
{
reconnectBox = new GUIMessageBox("CONNECTING", "Connecting to " + serverIP, new string[] { "Cancel" });
@@ -169,7 +154,7 @@ namespace Barotrauma.Networking
reconnectBox.Buttons[0].OnClicked += reconnectBox.Close;
}
- CoroutineManager.StartCoroutine(WaitForStartingInfo());
+ CoroutineManager.StartCoroutine(WaitForStartingInfo(password));
// Start the timer
//update.Start();
@@ -203,7 +188,7 @@ namespace Barotrauma.Networking
}
// Before main looping starts, we loop here and wait for approval message
- private IEnumerable