예제 #1
0
        private static void CSSave()
        {
            IndexFile.Serialize(SaveIndex);

            Maps.Export();
            Dungeons.Export();
            Lockouts.Export();

            RestoreFile.Serialize(SaveRestore);
            RestoreFile.SetHidden(true);
        }
예제 #2
0
        static Instances()
        {
            _BounceRestore = new Dictionary <PlayerMobile, MapPoint>(0x100);
            _ItemRestore   = new Dictionary <Item, IEntity>(0x1000);

            CSOptions = new InstanceMapsOptions();

            IndexFile = IOUtility.EnsureFile(VitaNexCore.SavesDirectory + "/InstanceMaps/Maps.idx");

            RestoreFile = IOUtility.EnsureFile(VitaNexCore.CacheDirectory + "/InstanceMaps/Restore.bin");
            RestoreFile.SetHidden(true);

            Lockouts = new BinaryDataStore <PlayerMobile, LockoutState>(VitaNexCore.SavesDirectory + "/InstanceMaps", "Lockouts")
            {
                Async         = true,
                OnSerialize   = SerializeLockouts,
                OnDeserialize = DeserializeLockouts
            };

            Maps = new BinaryDirectoryDataStore <InstanceMapSerial, InstanceMap>(VitaNexCore.SavesDirectory + "/InstanceMaps", "Maps", "bin")
            {
                Async         = true,
                OnSerialize   = SerializeMap,
                OnDeserialize = DeserializeMap
            };

            Dungeons = new BinaryDirectoryDataStore <DungeonSerial, Dungeon>(VitaNexCore.SavesDirectory + "/InstanceMaps", "Dungeons", "bin")
            {
                Async         = true,
                OnSerialize   = SerializeDungeon,
                OnDeserialize = DeserializeDungeon
            };

            DungeonTypes = typeof(Dungeon).GetConstructableChildren();

            var instances = DungeonTypes
                            .Select(t => t.CreateInstanceSafe <Dungeon>())
                            .Where(d => d != null && d.ID != DungeonID.None && d.GroupMax > 0)
                            .Where(d => d.MapParent != null && !(d.MapParent is InstanceMap))
                            .ToList();

            DungeonInfo = instances.Select(d => new DungeonInfo(d)).ToArray();

            instances.ForEach(d => d.Delete());
            instances.Free(true);

            DefragmentTimer = PollTimer.FromMinutes(10.0, Defragment, () => !_Defragmenting, false);
        }
예제 #3
0
        public void UnlockFile(string filename, string destination, string password)
        {
            Validate PasswordValidate = new PasswordValidation(password);

            PasswordValidate.ValidateData();
            IDecrypt Decrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Decrypter_Assembly"], GetSBNName(filename), password) as IDecrypt;

            try
            {
                Decrypter.DecryptFile();
            }
            catch (Exception DecryptFailure)
            {
                throw (new ApplicationException("Incorrect password"));
            }
            ExtractSTF STFContents = new ExtractSTF();

            UnlockParameters FileUnlockParams = STFContents.ExtractContents(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]));

            if (!Directory.Exists(destination))
            {
                throw (new ApplicationException("The destination directory does not exists"));
            }
            else
            {
                RestoreFile RestoreOriginalFile = new RestoreFile();
                RestoreOriginalFile.ExecuteRestore(FileUnlockParams, string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]), destination);
                if (File.Exists(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"])))
                {
                    File.Delete(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]));
                }
                if (File.Exists(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureExtension"])))
                {
                    File.Delete(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureExtension"]));
                }
            }
        }
예제 #4
0
 public void Restore()
 {
     RestoreFile.Execute(Metadata.ProjectFullPath);
 }
예제 #5
0
        public static void Restore()
        {
            RestoreFile.SetHidden(true);
            RestoreFile.Deserialize(LoadRestore);

            var bounce = new MapPoint(CSOptions.BounceMap, CSOptions.BounceLocation);

            if (bounce.InternalOrZero)
            {
                // Britain Peninsula (West of the Bank)
                bounce.Map      = Map.Felucca;
                bounce.Location = new Point3D(1383, 1713, 20);
            }

            foreach (var kv in _BounceRestore)
            {
                var m = kv.Key;
                var p = kv.Value;

                if (m == null || m.Deleted)
                {
                    continue;
                }

                if (p == null || p.InternalOrZero)
                {
                    p = bounce;
                }

                m.FixMap(p);
            }

            _BounceRestore.Clear();

            foreach (var kv in _ItemRestore)
            {
                var i = kv.Key;
                var p = kv.Value;

                if (i == null || i.Deleted || i.Map != null || p == null || p.Deleted)
                {
                    continue;
                }

#if NEWPARENT
                var cp = i.Parent;
#else
                var cp = i.ParentEntity;
#endif

                if (cp == p)
                {
                    continue;
                }

                if (p is Item)
                {
                    ((Item)p).AddItem(i);
                }
                else if (p is Mobile)
                {
                    ((Mobile)p).AddItem(i);
                }
                else
                {
                    i.Parent = p;
                }
            }

            _ItemRestore.Clear();
        }