示例#1
0
        /// <summary>
        /// We just throw errors, no need for a return value
        /// </summary>
        private void VerifyLocale(ILocale locale)
        {
            if (locale == null)
            {
                throw new ArgumentNullException("Locale must not be null.");
            }

            if (locale.Rooms().Any())
            {
                throw new ArgumentOutOfRangeException("Locale must be devoid of rooms.");
            }

            if (locale.Template <ILocaleTemplate>().FitnessProblems)
            {
                throw new ArgumentOutOfRangeException("Zone must have data integrity.");
            }
        }
示例#2
0
        /// <summary>
        /// Something went wrong with restoring the live backup, this loads all persistence singeltons from the database (rooms, paths, spawns)
        /// </summary>
        /// <returns>success state</returns>
        public bool NewWorldFallback()
        {
            LiveData liveDataAccessor = new LiveData();

            //This means we delete the entire Current livedata dir since we're falling back.
            string currentLiveDirectory = liveDataAccessor.BaseDirectory + liveDataAccessor.CurrentDirectoryName;

            //No backup directory? No live data.
            if (Directory.Exists(currentLiveDirectory))
            {
                DirectoryInfo currentDir = new DirectoryInfo(currentLiveDirectory);

                LoggingUtility.Log("Current Live directory deleted during New World Fallback Procedures.", LogChannels.Backup, true);

                try
                {
                    currentDir.Delete(true);
                }
                catch
                {
                    //occasionally will be pissy in an async situation
                }
            }

            //Only load in stuff that is static and spawns as singleton
            //We need to pick up any places that aren't already live from the file system incase someone added them during the last session\
            foreach (IGaiaTemplate thing in TemplateCache.GetAll <IGaiaTemplate>())
            {
                IGaia entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IGaia;
            }

            foreach (IZoneTemplate thing in TemplateCache.GetAll <IZoneTemplate>())
            {
                IZone entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IZone;
            }

            foreach (ILocaleTemplate thing in TemplateCache.GetAll <ILocaleTemplate>())
            {
                ILocale entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as ILocale;

                entityThing.ParentLocation = entityThing.Template <ILocaleTemplate>().ParentLocation.GetLiveInstance();
                entityThing.GetFromWorldOrSpawn();
            }

            foreach (IRoomTemplate thing in TemplateCache.GetAll <IRoomTemplate>())
            {
                IRoom entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IRoom;

                entityThing.ParentLocation = entityThing.Template <IRoomTemplate>().ParentLocation.GetLiveInstance();
                entityThing.GetFromWorldOrSpawn();
            }

            foreach (IPathwayTemplate thing in TemplateCache.GetAll <IPathwayTemplate>())
            {
                IPathway entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IPathway;
            }

            ParseDimension();

            LoggingUtility.Log("World restored from data fallback.", LogChannels.Backup, true);

            return(true);
        }