Exemple #1
0
 private static void ResetDatabase()
 {
     database             = new HEROsModDatabase();
     database.players     = new List <DatabasePlayer>();
     database.groups      = new List <DatabaseGroup>();
     database.worlds      = new List <DatabaseWorld>();
     currentDatabaseWorld = null;
     //database.regions = new List<DatabaseRegion>();
 }
Exemple #2
0
        public static void LoadSetting(string settingName)
        {
            ModUtils.DebugText("LoadSetting");
            Directory.CreateDirectory(Main.SavePath);
            string path = string.Concat(new object[]
            {
                Main.SavePath,
                Path.DirectorySeparatorChar,
                settingName,
                ".json"
            });

            if (File.Exists(path))
            {
                ModUtils.DebugText("LoadSetting File Exists");
                using (StreamReader r = new StreamReader(path))
                {
                    string json = r.ReadToEnd();
                    database = JsonConvert.DeserializeObject <HEROsModDatabase>(json);
                }
            }
            else
            {
                ModUtils.DebugText("LoadSetting File Doesn't Exist");
            }
            if (database == null)
            {
                ModUtils.DebugText("Warning: Database null in LoadSetting");
                database = new HEROsModDatabase();
            }
            if (database.players == null)
            {
                ModUtils.DebugText("Warning: Database players null in LoadSetting");
                database.players = new List <DatabasePlayer>();
            }
            if (database.worlds == null)
            {
                ModUtils.DebugText("Warning: Database worlds null in LoadSetting");
                database.worlds = new List <DatabaseWorld>();
            }
            //foreach (var world in database.worlds)
            //{
            //	if(world.worldID == Main.worldID)
            //	{
            //		currentDatabaseWorld = world;
            //	}
            //}
            //if(currentDatabaseWorld == null)
            //{
            //	currentDatabaseWorld = new DatabaseWorld() { worldID = Main.worldID };
            //}
            //if (database.regions == null)
            //{
            //	ModUtils.DebugText("Warning: Database regions null in LoadSetting");
            //	database.regions = new List<DatabaseRegion>();
            //}
            if (database.groups == null)
            {
                ModUtils.DebugText("Warning: Database groups null in LoadSetting");
                database.groups = new List <DatabaseGroup>();
            }
            //Console.WriteLine("LoadSetting End");
            //if (Main.netMode != (int)NetworkMode.Server)
            //{
            //	database.groups.Clear();
            //	database.players.Clear();
            //}
        }