static void IocBind(WorldParameters param) { _worldParameters = param; if (string.IsNullOrEmpty(_settingsManager.Settings.DatabasePath)) { _settingsManager.Settings.DatabasePath = Path.Combine(XmlSettingsManager.GetFilePath("", SettingsStorage.ApplicationData), "Server", "MultiPlayer", param.Seed.ToString(), "ServerWorld.db"); } Console.WriteLine("Database path is " + _settingsManager.Settings.DatabasePath); _sqLiteStorageManager = new SqliteStorageManager(_settingsManager.Settings.DatabasePath, null, param); IWorldProcessor processor = null; IEntitySpawningControler entitySpawningControler = null; switch (param.Configuration.WorldProcessor) { case WorldConfiguration.WorldProcessors.Flat: processor = new FlatWorldProcessor(); break; case WorldConfiguration.WorldProcessors.Utopia: processor = new UtopiaProcessor(param, _serverFactory, new LandscapeBufferManager()); entitySpawningControler = new UtopiaEntitySpawningControler((UtopiaWorldConfiguration)param.Configuration); break; default: break; } _worldGenerator = new WorldGenerator(param, processor); _worldGenerator.EntitySpawningControler = entitySpawningControler; }
public void Dispose() { if (Server != null) { Server.LoginManager.PlayerEntityNeeded -= LoginManagerPlayerEntityNeeded; Server.Dispose(); _server = null; } if (_serverSqliteStorageSinglePlayer != null) { _serverSqliteStorageSinglePlayer.Dispose(); _serverSqliteStorageSinglePlayer = null; } }
public ServerUsersStorage(SqliteStorageManager storage, ServerWebApi webApi) { if (storage == null) { throw new ArgumentNullException("storage"); } if (webApi == null) { throw new ArgumentNullException("webApi"); } DefaultRole = UserRole.Guest; _storage = storage; _webApi = webApi; }
/// <summary> /// Creates Storage Manager according to StorageType value in Settings file. /// </summary> /// <returns>Storame Manager</returns> public static IStorageManager CreateStorageManager() { //Get a reference to the settings var settings = MDSSettings.Instance; //Create storage manager according to the settings var storageType = settings["StorageType"]; IStorageManager storageManager; if (storageType.Equals("MySQL-ODBC", StringComparison.OrdinalIgnoreCase)) { storageManager = new MySqlOdbcStorageManager { ConnectionString = settings["ConnectionString"] }; } else if (storageType.Equals("MySQL-Net", StringComparison.OrdinalIgnoreCase)) { storageManager = new MySqlNetStorageManager { ConnectionString = settings["ConnectionString"] }; } else if (storageType.Equals("MSSQL", StringComparison.OrdinalIgnoreCase)) { storageManager = new MsSqlStorageManager { ConnectionString = settings["ConnectionString"] }; } else if (storageType.Equals("SQLite", StringComparison.OrdinalIgnoreCase)) { storageManager = new SqliteStorageManager(); } else if (storageType.Equals("MongoDB", StringComparison.OrdinalIgnoreCase)) { storageManager = new MongoDBStorageManager(); } else //Default storage manager { storageManager = new MemoryStorageManager(); } //Wrap storageManager with FaultToleratedStorageManagerWrapper and return it return(new FaultToleratedStorageManagerWrapper(storageManager)); }
public void InitSinglePlayerServer(WorldParameters worldParam) { if (Server != null) { throw new InvalidOperationException("Already initialized"); } _worldParam = worldParam; _serverFactory = new EntityFactory(); _serverFactory.Config = _worldParam.Configuration; var dbPath = Path.Combine(_vars.ApplicationDataPath, "Server", "Singleplayer", worldParam.WorldName, "ServerWorld.db"); logger.Info("Local world db path is {0}", dbPath); _serverSqliteStorageSinglePlayer = new SqliteStorageManager(dbPath, _serverFactory, worldParam); _serverSqliteStorageSinglePlayer.Register("local", "qwe123".GetSHA1Hash(), UserRole.Administrator); var settings = new XmlSettingsManager <ServerSettings>(@"Server\localServer.config"); settings.Load(); settings.Save(); //Utopia New Landscape Test IWorldProcessor processor = null; IEntitySpawningControler entitySpawningControler = null; switch (worldParam.Configuration.WorldProcessor) { case WorldConfiguration.WorldProcessors.Flat: processor = new FlatWorldProcessor(); break; case WorldConfiguration.WorldProcessors.Utopia: processor = new UtopiaProcessor(worldParam, _serverFactory, _landscapeEntityManager); entitySpawningControler = new UtopiaEntitySpawningControler((UtopiaWorldConfiguration)worldParam.Configuration); break; default: break; } var worldGenerator = new WorldGenerator(worldParam, processor); worldGenerator.EntitySpawningControler = entitySpawningControler; //Old s33m3 landscape //IWorldProcessor processor1 = new s33m3WorldProcessor(worldParam); //IWorldProcessor processor2 = new LandscapeLayersProcessor(worldParam, _serverFactory); //var worldGenerator = new WorldGenerator(worldParam, processor1, processor2); //Vlad Generator //var planProcessor = new PlanWorldProcessor(wp, _serverFactory); //var worldGenerator = new WorldGenerator(wp, planProcessor); settings.Settings.ChunksCountLimit = 1024 * 3; // better use viewRange * viewRange * 3 var port = 4815; while (!TcpConnectionListener.IsPortFree(port)) { port++; } settings.Settings.ServerPort = port; _server = new ServerCore(settings, worldGenerator, _serverSqliteStorageSinglePlayer, _serverSqliteStorageSinglePlayer, _serverSqliteStorageSinglePlayer, _serverSqliteStorageSinglePlayer, _serverFactory, worldParam); _serverFactory.LandscapeManager = Server.LandscapeManager; _serverFactory.DynamicEntityManager = Server.AreaManager; _serverFactory.GlobalStateManager = Server.GlobalStateManager; _serverFactory.ScheduleManager = Server.Scheduler; _serverFactory.ServerSide = true; _server.Initialize(); Server.ConnectionManager.LocalMode = true; Server.ConnectionManager.Listen(); Server.LoginManager.PlayerEntityNeeded += LoginManagerPlayerEntityNeeded; Server.LoginManager.GenerationParameters = default(Utopia.Shared.World.PlanGenerator.GenerationParameters); // planProcessor.WorldPlan.Parameters; Server.Clock.SetCurrentTimeOfDay(UtopiaTimeSpan.FromHours(12)); }