public static void SetupConfig() { try { if (File.Exists(ConfigPath)) { StarryboundServer.serverConfig = ServerFile.Read(ConfigPath); } StarryboundServer.serverConfig.gamePort = StarryboundServer.config.serverPort; StarryboundServer.privatePassword = Utils.GenerateSecureSalt(); StarryboundServer.serverConfig.serverPasswords = new string[] { StarryboundServer.privatePassword }; StarryboundServer.serverConfig.maxPlayers = StarryboundServer.config.maxClients + 10; StarryboundServer.serverConfig.bind = StarryboundServer.config.proxyIP; if (StarryboundServer.serverConfig.useDefaultWorldCoordinate) { string[] spawnPlanet = StarryboundServer.serverConfig.defaultWorldCoordinate.Split(':'); if (spawnPlanet.Length == 5) { StarryboundServer.spawnPlanet = new WorldCoordinate(spawnPlanet[0], Convert.ToInt32(spawnPlanet[1]), Convert.ToInt32(spawnPlanet[2]), Convert.ToInt32(spawnPlanet[3]), Convert.ToInt32(spawnPlanet[4]), 0); } else { StarryboundServer.spawnPlanet = new WorldCoordinate(spawnPlanet[0], Convert.ToInt32(spawnPlanet[1]), Convert.ToInt32(spawnPlanet[2]), Convert.ToInt32(spawnPlanet[3]), Convert.ToInt32(spawnPlanet[4]), Convert.ToInt32(spawnPlanet[5])); } } StarryboundServer.serverConfig.Write(ConfigPath); } catch (Exception e) { StarryboundServer.logFatal("Failed to parse starbound.config: " + e.ToString()); Thread.Sleep(5000); Environment.Exit(8); } }
public static ServerFile Read(string path) { if (!File.Exists(path)) { return(new ServerFile()); } using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { ServerFile file = Read(fs); StarryboundServer.logInfo("Starbound server config loaded successfully."); return(file); } }