Server(bool newInstance) { if (instance != null) { Console.Error.WriteLine("Server instance already exists, recreating"); } instance = this; var stateFileInfo = new FileInfo(Settings.Default.DefaultServerStatePath); if (stateFileInfo.Exists && stateFileInfo.Length > 0) { State = ServerState.FromFile(Settings.Default.DefaultServerStatePath); } else if (File.Exists(Settings.Default.GalaxyTemplatePath)) { Console.Error.Write("No state found, loading galaxy from xml."); State = new ServerState {Galaxy = Galaxy.FromFile(Settings.Default.GalaxyTemplatePath)}; SaveState(); } else { throw new Exception("No state or galaxy found."); } }
// for unit testing public Server(ServerState state) { if (instance != null) { Console.Error.WriteLine("Server instance already exists, recreating"); } instance = this; State = state; }