Пример #1
0
        public Client()
        {
            var startup = new Timer(6000);

            startup.Tick += (o, e) =>
            {
                startup.Stop();
                BindConsoleCommand("reconnect", (a) =>
                {
                    if (System.IO.File.Exists("miv_lastserver.ini"))
                    {
                        darkscreen = new ClientRectangleView(new System.Drawing.RectangleF(0, 0, 2000, 2000), System.Drawing.Color.Black);
                        Game.FadeScreenOut(1);
                        string[] lines   = System.IO.File.ReadAllLines("miv_lastserver.ini");
                        INIReader reader = new INIReader(lines);
                        initAndConnect(reader.getString("ip"), reader.getInt16("port"), reader.getString("nickname"));
                    }
                });
                if (System.IO.File.Exists("_serverinit.ini"))
                {
                    darkscreen = new ClientRectangleView(new System.Drawing.RectangleF(0, 0, 2000, 2000), System.Drawing.Color.Black);
                    string[]  lines           = System.IO.File.ReadAllLines("_serverinit.ini");
                    INIReader reader          = new INIReader(lines);
                    Int64     timestamp_saved = reader.getInt64("timestamp");
                    Int64     timestamp_now   = System.Diagnostics.Stopwatch.GetTimestamp();
                    TimeSpan  time_delta      = new TimeSpan(timestamp_now - timestamp_saved);
                    if (time_delta.Minutes < 5)
                    {
                        System.IO.File.Delete("_serverinit.ini");
                        System.IO.File.WriteAllLines("miv_lastserver.ini", lines);
                        initAndConnect(reader.getString("ip"), reader.getInt16("port"), reader.getString("nickname"));
                    }
                }
                else
                {
                    FileSystemOverlay.crashIfSPPreparationFail();
                }
            };
            startup.Start();
            // nope? nothing to do
        }
Пример #2
0
 public Client()
 {
     var startup = new Timer(6000);
     startup.Tick += (o, e) =>
     {
         startup.Stop();
         BindConsoleCommand("reconnect", (a) =>
         {
             if (System.IO.File.Exists("miv_lastserver.ini"))
             {
                 darkscreen = new ClientRectangleView(new System.Drawing.RectangleF(0, 0, 2000, 2000), System.Drawing.Color.Black);
                 Game.FadeScreenOut(1);
                 string[] lines = System.IO.File.ReadAllLines("miv_lastserver.ini");
                 INIReader reader = new INIReader(lines);
                 initAndConnect(reader.getString("ip"), reader.getInt16("port"), reader.getString("nickname"));
             }
         });
         if (System.IO.File.Exists("_serverinit.ini"))
         {
             darkscreen = new ClientRectangleView(new System.Drawing.RectangleF(0, 0, 2000, 2000), System.Drawing.Color.Black);
             string[] lines = System.IO.File.ReadAllLines("_serverinit.ini");
             INIReader reader = new INIReader(lines);
             Int64 timestamp_saved = reader.getInt64("timestamp");
             Int64 timestamp_now = System.Diagnostics.Stopwatch.GetTimestamp();
             TimeSpan time_delta = new TimeSpan(timestamp_now - timestamp_saved);
             if (time_delta.Minutes < 5)
             {
                 System.IO.File.Delete("_serverinit.ini");
                 System.IO.File.WriteAllLines("miv_lastserver.ini", lines);
                 initAndConnect(reader.getString("ip"), reader.getInt16("port"), reader.getString("nickname"));
             }
         }
         else
         {
             FileSystemOverlay.crashIfSPPreparationFail();
         }
     };
     startup.Start();
     // nope? nothing to do
 }