Index: binary-improvements/7dtd-server-fixes/src/AllocsNetTelnetServer.cs
===================================================================
--- binary-improvements/7dtd-server-fixes/src/AllocsNetTelnetServer.cs	(revision 74)
+++ binary-improvements/7dtd-server-fixes/src/AllocsNetTelnetServer.cs	(revision 75)
@@ -9,98 +9,14 @@
 public class AllocsNetTelnetServer
 {
-	private class Connection
-	{
-		private bool authenticated = false;
-		private TcpClient client;
-		private NetworkStream stream;
-		private string lineBuffer = string.Empty;
-		private EndPoint endpoint;
-
-		public Connection (TcpClient client)
-		{
-			this.client = client;
-			this.stream = client.GetStream ();
-			this.endpoint = client.Client.RemoteEndPoint;
-		}
-
-		public EndPoint GetEndPoint ()
-		{
-			return endpoint;
-		}
-
-		private void WriteByte (byte v)
-		{
-			if (!IsClosed () && stream.CanWrite) {
-				stream.WriteByte (v);
-			}
-		}
-
-		public void WriteLine (string s)
-		{
-			if (!IsClosed () && stream.CanWrite) {
-				for (int i = 0; i < s.Length; i++) {
-					WriteByte ((byte)s [i]);
-				}
-				WriteByte (10);
-			}
-		}
-
-		public void Close ()
-		{
-			if (client != null)
-				client.Close ();
-			client = null;
-		}
-
-		public bool IsClosed ()
-		{
-			if (client != null && !client.Connected) {
-				Log.Out ("Telnet connection interrupted: " + endpoint);
-			}
-			return (client == null) || (!client.Connected);
-		}
-
-		public bool IsAuthenticated ()
-		{
-			return !authEnabled || authenticated;
-		}
-
-		public void SetAuthenticated ()
-		{
-			authenticated = true;
-		}
-
-		public bool Read ()
-		{
-			while (!IsClosed() && stream.CanRead && stream.DataAvailable) {
-				int b = stream.ReadByte ();
-				if (b == '\r' || b == '\n') {
-					if (lineBuffer.Length > 0)
-						return true;
-				} else {
-					lineBuffer += (char)b;
-				}
-			}
-			return false;
-		}
-
-		public string GetLine ()
-		{
-			string res = lineBuffer;
-			lineBuffer = string.Empty;
-			return res;
-		}
-	}
-
-	private static cl004c console = null;
+	private static ConsoleSdtd console = null;
 	private static Thread telnetThread = null;
 	private static TcpListener listener = null;
 	private static bool closed = false;
 	private static bool authEnabled = false;
-	private static List<Connection> conns = new List<Connection> ();
+	private static List<AllocsTelnetConnection> conns = new List<AllocsTelnetConnection> ();
 
 	public static void init (int port)
 	{
-		Log.Out ("[7dtd-server-fixes by Alloc] Version: " + Assembly.GetExecutingAssembly().GetName().Version);
+		Log.Out ("[7dtd-server-fixes by Alloc] Version: " + Assembly.GetExecutingAssembly ().GetName ().Version);
 		authEnabled = GamePrefs.GetString (EnumGamePrefs.TelnetPassword).Length != 0;
 		if (authEnabled)
@@ -121,5 +37,5 @@
 				Thread.Sleep (10);
 				if (listener.Pending ()) {
-					Connection c = new Connection (listener.AcceptTcpClient ());
+					AllocsTelnetConnection c = new AllocsTelnetConnection (listener.AcceptTcpClient (), authEnabled);
 					conns.Add (c);
 					Log.Out ("Telnet connection from: " + c.GetEndPoint ());
@@ -131,5 +47,5 @@
 				}
 
-				foreach (Connection c in conns) {
+				foreach (AllocsTelnetConnection c in conns) {
 					if (c.IsClosed ()) {
 						c.Close ();
@@ -157,5 +73,4 @@
 								break;
 							}
-
 							Log.Out ("Telnet executed \"" + line + "\" from: " + c.GetEndPoint ());
 							console.md000f (line);
@@ -172,5 +87,5 @@
 	}
 
-	private static void LoginMessage (Connection c)
+	private static void LoginMessage (AllocsTelnetConnection c)
 	{
 		c.WriteLine ("*** Connected with 7DTD server.");
@@ -208,5 +123,5 @@
 			listener.Stop ();
 		}
-		foreach (Connection c in conns) {
+		foreach (AllocsTelnetConnection c in conns) {
 			c.Close ();
 		}
@@ -214,12 +129,15 @@
 	}
 
-	public static void SetConsole (cl004c console)
+	public static void SetConsole (ConsoleSdtd console)
 	{
+		Log.Out("Telnet SetConsole called");
 		AllocsNetTelnetServer.console = console;
+		console.AddCommand(new GetTime(console));
+		console.AddCommand(new ListPlayersExtended(console));
 	}
 
 	private static void RemoveClosedConnections ()
 	{
-		foreach (Connection c in conns) {
+		foreach (AllocsTelnetConnection c in conns) {
 			if (c.IsClosed ()) {
 				c.Close ();
@@ -234,6 +152,6 @@
 		}
 		RemoveClosedConnections ();
-		foreach (Connection c in conns) {
-			if (c.IsAuthenticated())
+		foreach (AllocsTelnetConnection c in conns) {
+			if (c.IsAuthenticated ())
 				c.WriteLine (line);
 		}
