Ejemplo n.º 1
0
        internal static ArenaDB InitDb(string name)
        {
            IDbConnection db;

            if (TShock.Config.StorageType.ToLower() == "sqlite")
            {
                db =
                    new SqliteConnection(string.Format("uri=file://{0},Version=3",
                                                       Path.Combine(TShock.SavePath, name + ".sqlite")));
            }
            else if (TShock.Config.StorageType.ToLower() == "mysql")
            {
                try
                {
                    var host = TShock.Config.MySqlHost.Split(':');
                    db = new MySqlConnection
                    {
                        ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4}",
                                                         host[0],
                                                         host.Length == 1 ? "3306" : host[1],
                                                         TShock.Config.MySqlDbName,
                                                         TShock.Config.MySqlUsername,
                                                         TShock.Config.MySqlPassword
                                                         )
                    };
                }
                catch (MySqlException x)
                {
                    TShock.Log.Error(x.ToString());
                    throw new Exception("MySQL not setup correctly.");
                }
            }
            else
            {
                throw new Exception("Invalid storage type.");
            }
            var tempDB = new ArenaDB(db);

            return(tempDB);
        }
Ejemplo n.º 2
0
 internal ArenaUtils()
 {
     arena_db = ArenaDB.InitDb("Classes");
     arena_db.LoadArenas(ref arenas);
 }