示例#1
0
 private static void CleanupServer()
 {
     Netplay.StopListening();
     try
     {
         Netplay.ClosePort(Netplay.ListenPort);
     }
     catch
     {
     }
     for (int index = 0; index < 256; ++index)
     {
         Netplay.Clients[index].Reset();
     }
     if (Main.menuMode != 15)
     {
         Main.netMode  = 0;
         Main.menuMode = 10;
         WorldFile.SaveWorld();
         Main.menuMode = 0;
     }
     else
     {
         Main.netMode = 0;
     }
     Main.myPlayer = 0;
 }
示例#2
0
 private static void CleanupServer()
 {
     StopListening();
     try
     {
         ClosePort(ListenPort);
     }
     catch
     {
     }
     for (int i = 0; i < 256; i++)
     {
         Clients[i].Reset();
     }
     if (Main.menuMode != 15)
     {
         Main.netMode  = 0;
         Main.menuMode = 10;
         WorldFile.SaveWorld();
         Main.menuMode = 0;
     }
     else
     {
         Main.netMode = 0;
     }
     Main.myPlayer = 0;
 }
示例#3
0
        private void SaveWorker()
        {
            while (true)
            {
                lock (_saveLock)
                {
                    // NOTE: lock for the entire process so wait works in SaveWorld
                    if (_saveQueue.Count > 0)
                    {
                        SaveTask task = _saveQueue.Dequeue();
                        if (null == task)
                        {
                            return;
                        }
                        else
                        {
                            // Ensure that save handler errors don't bubble up and cause a recursive call
                            // These can be caused by an unexpected error such as a bad or out of date plugin
                            try
                            {
                                if (task.direct)
                                {
                                    OnSaveWorld(new WorldSaveEventArgs());
                                    WorldFile.SaveWorld(task.resetTime);
                                }
                                else
                                {
                                    WorldFile.SaveWorld(task.resetTime);
                                }

                                if (TShock.Config.AnnounceSave)
                                {
                                    TShock.Utils.Broadcast("World saved.", Color.Yellow);
                                }

                                TShock.Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
                            }
                            catch (Exception e)
                            {
                                TShock.Log.Error("World saved failed");
                                TShock.Log.Error(e.ToString());
                            }
                        }
                    }
                }
                _wh.WaitOne();
            }
        }