Ejemplo n.º 1
0
		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.");
			}
		}
Ejemplo n.º 2
0
		// for unit testing

		public Server(ServerState state)
		{
			if (instance != null) {
				Console.Error.WriteLine("Server instance already exists, recreating");
			}
			instance = this;
			State = state;
		}
Ejemplo n.º 3
0
		public void Dispose()
		{
			instance = null;
		}