Esempio n. 1
0
		public void SetFlag( RegionFlag flag, bool value ) {
			if( value )
				m_Flags |= flag;
			else {
				m_Flags &= ~flag;
			}
		}
 protected override void Load()
 {
     base.Load();
     Instance = this;
     Logger.Log("");
     Logger.Log("Loading ServerSwitcher, made by Mr.Kwabs.", ConsoleColor.Yellow);
     if (Configuration.Instance.RocketRegionsSupport)
     {
         RegionFlag.RegisterFlag("EnterServerSwitch", typeof(EnterServerSwitchFlag));
     }
     U.Events.OnPlayerConnected += OnPlayerConnected;
     Logger.Log("");
     Logger.Log($"Server List ({Configuration.Instance.Servers.Count} Total): ", ConsoleColor.Cyan);
     Logger.Log("");
     foreach (Server Server in Configuration.Instance.Servers)
     {
         Logger.Log($"Name: {Server.Name}", ConsoleColor.Cyan);
         Logger.Log($"IP & Port: {Server.IP}:{Server.Port}", ConsoleColor.Cyan);
         Logger.Log($"Password: {Server.Password}", ConsoleColor.Cyan);
         Logger.Log($"Permission: serverswitcher.server.{Server.Permission}", ConsoleColor.Cyan);
         Logger.Log($"Delay: {Server.Delay}", ConsoleColor.Cyan);
         if (Configuration.Instance.RocketRegionsSupport)
         {
             Logger.Log($"Can be used in Rocket Region: {Server.CanBeUsedInRocketRegion}", ConsoleColor.Cyan);
         }
         Logger.Log("");
     }
     Logger.Log("Successfully loaded ServerSwitcher, made by Mr.Kwabs.", ConsoleColor.Yellow);
 }
Esempio n. 3
0
        private RegionFlag DeserializeFlag(SerializableFlag flag)
        {
            try
            {
                flag.Name = RegionFlag.GetPrimaryFlagName(flag.Name);

                var type = RegionFlag.GetFlagType(flag.Name);

                var deserializedFlag = (RegionFlag)Activator.CreateInstance(type);
                deserializedFlag.Region = this;
                deserializedFlag.Name   = RegionFlag.GetFlagName(type);
                deserializedFlag.Value  = flag.Value;

                for (var i = 0; i < flag.GroupValues.Count; i++)
                {
                    deserializedFlag.SetValue(flag.GroupValues[i].Value, GroupExtensions.GetGroup(flag.GroupValues[i].GroupName));
                }

                deserializedFlag.GroupValues = flag.GroupValues ?? new List <GroupValue>();
                _flags.Add(deserializedFlag);
                return(deserializedFlag);
            }
            catch (Exception) { /*ignored*/ }
            return(null);
        }
Esempio n. 4
0
        protected override void Load()
        {
            Logger.Log($"Regions v{VERSION}", ConsoleColor.Cyan);
            Instance = this;

            if (Configuration.Instance.NoEquipIgnoredItems == null)
            {
                Configuration.Instance.NoEquipIgnoredItems = new List <ushort>();
            }

            if (Configuration.Instance.NoEquipWeaponIgnoredItems == null)
            {
                Configuration.Instance.NoEquipWeaponIgnoredItems = new List <ushort>();
            }

            RegionType.RegisterRegionType("rectangle", typeof(RectangleType));
            RegionType.RegisterRegionType("circle", typeof(CircleType));

            RegionFlag.RegisterFlag("Godmode", typeof(GodmodeFlag));
            RegionFlag.RegisterFlag("NoEnter", typeof(NoEnterFlag));
            RegionFlag.RegisterFlag("NoLeave", typeof(NoLeaveFlag));
            RegionFlag.RegisterFlag("NoZombies", typeof(NoZombiesFlag));
            RegionFlag.RegisterFlag("NoPlace", typeof(NoPlaceFlag));
            RegionFlag.RegisterFlag("NoDestroy", typeof(NoDestroyFlag));
            RegionFlag.RegisterFlag("NoVehiclesUsage", typeof(NoVehiclesUsageFlag));
            RegionFlag.RegisterFlag("NoEquip", typeof(NoEquipFlag));
            RegionFlag.RegisterFlag("NoEquipWeapon", typeof(NoEquipWeaponFlag));
            RegionFlag.RegisterFlag("EnterMessage", typeof(EnterMessageFlag));
            RegionFlag.RegisterFlag("LeaveMessage", typeof(LeaveMessageFlag));
            RegionFlag.RegisterFlag("Teleport", typeof(TeleportFlag));
            RegionFlag.RegisterFlag("UnlimitedGenerator", typeof(UnlimitedGeneratorFlag));
            RegionFlag.RegisterFlag("EnterEffect", typeof(EnterEffectFlag));
            RegionFlag.RegisterFlag("LeaveEffect", typeof(LeaveEffectFlag));
            RegionFlag.RegisterFlag("EnterURL", typeof(EnterURLFlag));
            RegionFlag.RegisterFlag("LeaveURL", typeof(LeaveURLFlag));
            RegionFlag.RegisterFlag("VanishFlag", typeof(VanishFlag));
            RegionFlag.RegisterFlag("NoDecay", typeof(NoDecayFlag));
            RegionFlag.RegisterFlag("EnterAddGroup", typeof(EnterAddGroupFlag));
            RegionFlag.RegisterFlag("EnterRemoveGroup", typeof(EnterRemoveGroupFlag));
            RegionFlag.RegisterFlag("LeaveAddGroup", typeof(LeaveAddGroupFlag));
            RegionFlag.RegisterFlag("LeaveRemoveGroup", typeof(LeaveRemoveGroupFlag));
            RegionFlag.RegisterFlag("Decay", typeof(DecayFlag));
            RegionFlag.RegisterFlag("NoVehicleDamage", typeof(NoVehiclesDamageFlag));
            RegionFlag.RegisterFlag("NoVehiclesLockpick", typeof(NoVehiclesLockpickFlag));
            Configuration.Load();

            _defaultPermissionsProvider = R.Permissions;
            R.Permissions              = new RegionsPermissionsProvider(_defaultPermissionsProvider);
            R.Plugins.OnPluginsLoaded += OnPluginsLoaded;

            foreach (var untPlayer in Provider.clients.Select(p => UnturnedPlayer.FromCSteamID(p.playerID.steamID)))
            {
                OnPlayerConnect(untPlayer);
            }
        }
Esempio n. 5
0
 public void SetFlag(RegionFlag flag, bool value)
 {
     if (value)
     {
         m_Flags |= flag;
     }
     else
     {
         m_Flags &= ~flag;
     }
 }
Esempio n. 6
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 3:
            {
                m_LightLevel = reader.ReadInt();
                goto case 2;
            }

            case 2:
            {
                m_Music = (MusicName)reader.ReadInt();
                goto case 1;
            }

            case 1:
            {
                Coords              = ReadRect2DArray(reader);
                m_Priority          = (CustomRegionPriority)reader.ReadInt();
                m_PlayerLogoutDelay = reader.ReadTimeSpan();

                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }

            case 0:
            {
                Coords = new ArrayList();

                Coords.Add(reader.ReadRect2D());
                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }
            }

            UpdateRegion();
        }
Esempio n. 7
0
        public void SetFlag(string name, object value, List <GroupValue> groupValues, bool save = true)
        {
            name = RegionFlag.GetPrimaryFlagName(name);
            var flagType = RegionFlag.GetFlagType(name);

            if (flagType == null)
            {
                throw new ArgumentException("Unknown flag: " + name);
            }

            if (Flags == null)
            {
                Flags = new List <SerializableFlag>();
            }

            foreach (var f in Flags.Where(f => f.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)))
            {
                Flags.Remove(f);
                break;
            }

            var flag = new SerializableFlag
            {
                Name        = name,
                Value       = value,
                GroupValues = groupValues
            };

            Flags.Add(flag);
            if (save)
            {
                RegionsPlugin.Instance.Configuration.Save();
            }

            if (_flags == null)
            {
                _flags = new List <RegionFlag>();
            }
            foreach (RegionFlag f in ParsedFlags.Where(f => f.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)))
            {
                f.Value = value;
                return;
            }

            var deserializedFlag = DeserializeFlag(flag);

            if (deserializedFlag != null)
            {
                deserializedFlag.Value = value;
            }
        }
Esempio n. 8
0
        public ActionResult AddRegionFlag(int playerId)
        {
            if (Convert.ToInt32(Session["userId"]) <= 0)
            {
                var loggedOutJson = new { response = "Must be logged in to flag players." };
                return(Json(loggedOutJson));
            }
            int  regionValue;
            bool validRegion = int.TryParse(Request["regionValue"], out regionValue);

            validRegion = validRegion && Enum.IsDefined(typeof(Region), regionValue);
            if (!validRegion)
            {
                var noNewNameJson = new { response = "Please specify what region this player is from." };
                return(Json(noNewNameJson));
            }

            Player foundPlayer = db.Players.Find(playerId);

            if (foundPlayer == null)
            {
                var playerNotFoundJson = new { response = "Something went wrong. Please try again later." };
                return(Json(playerNotFoundJson));
            }
            if (regionValue == foundPlayer.RegionValue)
            {
                var alreadyRightJson = new { response = "This player is already in this region." };
                return(Json(alreadyRightJson));
            }

            int        userId    = Convert.ToInt32(Session["userId"]);
            RegionFlag foundFlag = (from pf in db.RegionFlags
                                    where pf.userID == userId && pf.PlayerID == playerId
                                    select pf).FirstOrDefault();

            if (foundFlag != null)
            {
                var alreadyFlaggedJson = new { response = "You have already flagged this player." };
                return(Json(alreadyFlaggedJson));
            }

            RegionFlag newFlag = new RegionFlag(playerId, userId, regionValue);

            db.RegionFlags.Add(newFlag);
            db.SaveChanges();

            var savedJson = new { response = "Suggestion taken! Thank you." };

            return(Json(savedJson));
        }
Esempio n. 9
0
        private void DupeCustomBits(Region r)
        {
            //pla: replicate custom region
            if (r is CustomRegion)
            {
                RegionControl rc = (r as CustomRegion).GetRegionControler();

                if (rc != null)
                {
                    //copy all the flags and restricted stuff
                    this.m_Flags              = rc.m_Flags;
                    this.m_RestrictedSpells   = new BitArray(rc.m_RestrictedSpells);
                    this.m_RestrictedSkills   = new BitArray(rc.m_RestrictedSkills);
                    this.m_RestrictedMagicMsg = rc.m_RestrictedMagicMsg;
                    this.m_InnLogoutDelay     = rc.InnLogoutDelay;
                    this.m_IOBAlignment       = rc.IOBAlign;
                    this.m_MaxFollowers       = rc.MaxFollowerSlots;
                    this.m_Music              = r.Music;
                    this.SetFlag(RegionFlag.Music, (r.Music != MusicName.Invalid));

                    if (rc.LightLevel > 0)
                    {
                        this.m_LightLevel = rc.LightLevel;
                    }

                    this.m_Types.Clear();
                    if (rc.m_Types != null && rc.m_Types.Count > 0)
                    {
                        ArrayList t = rc.m_Types;
                        for (int i = 0; i < rc.m_Types.Count; ++i)
                        {
                            if (t[i] is string)
                            {
                                this.m_Types.Add((string)t[i]);
                            }
                        }
                    }
                }
                else
                {
                    this.SendMessage(String.Format("Region controller for custom region '" + r.Name + "' could not be found.\n\rCustom properties and flags have not been cloned successfully"));
                }
            }
        }
Esempio n. 10
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 14:
            {
                //version 14
                m_Coords    = ReadRect3DArray(reader);
                m_InnBounds = ReadRect3DArray(reader);
                goto case 13;
            }

            case 13:
            {
                m_TargetMap  = reader.ReadMap();
                m_GoLocation = reader.ReadPoint3D();
                m_MinZ       = reader.ReadInt();
                m_MaxZ       = reader.ReadInt();
                goto case 12;
            }

            case 12:
            {
                m_Enabled = reader.ReadBool();
                goto case 11;
            }

            case 11:
            {
                int size = reader.ReadInt();
                m_Types = new ArrayList(size);

                for (int i = 0; i < size; ++i)
                {
                    string typeName = reader.ReadString();
                    m_Types.Add(typeName);
                }
                goto case 10;
            }

            case 10:
            {
                m_MaxFollowers = reader.ReadInt();
                goto case 9;
            }

            case 9:
            {
                m_RestrictedMagicMsg = reader.ReadString();
                goto case 8;
            }

            case 8:
            {
                m_Music = (MusicName)reader.ReadInt();
                goto case 7;
            }

            case 7:
            {
                if (m_InnBounds == null)
                {
                    m_InnBounds = ReadRect2DArray(reader);
                }
                else
                {
                    m_InnBounds.AddRange(ReadRect2DArray(reader));
                }
                m_InnLogoutDelay = reader.ReadTimeSpan();

                goto case 6;
            }

            case 6:
            {
                m_PlayerLogoutDelay = reader.ReadTimeSpan();
                goto case 5;
            }

            case 5:
            {
                if (version < 13)
                {                                       // converted to a flag
                    bool m_IsDungeon = (bool)reader.ReadBool();
                    IsDungeon = m_IsDungeon;
                }
                goto case 4;
            }

            case 4:
            {
                m_IOBAlignment = (IOBAlignment)reader.ReadInt();
                goto case 3;
            }

            case 3:
            {
                m_LightLevel = reader.ReadInt();
                goto case 2;
            }

            case 2:
            {
                goto case 1;
            }

            case 1:
            {
                if (Coords == null)
                {
                    Coords = ReadRect2DArray(reader);
                }
                else
                {
                    Coords.AddRange(ReadRect2DArray(reader));
                }
                m_Priority = (CustomRegionPriority)reader.ReadInt();

                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }

            case 0:
            {
                Coords = new ArrayList();

                Coords.Add(reader.ReadRect2D());
                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }
            }
            if (version < 12)
            {
                m_Enabled = true;
            }

            if (version < 11)
            {
                m_Types = new ArrayList();
            }

            if (version < 8)
            {
                m_Music = MusicName.Invalid;
            }

            // fixup this table if Skills have been added or removed.
            if (SkillInfo.Table.Length != m_RestrictedSkills.Count)
            {
                BitArray temp          = new BitArray(SkillInfo.Table.Length);
                int      MaxIterations = Math.Min(temp.Length, m_RestrictedSkills.Count);
                for (int ix = 0; ix < MaxIterations; ix++)
                {
                    temp[ix] = m_RestrictedSkills[ix];
                }

                m_RestrictedSkills = temp;
            }

            // fixup this table if Spells have been added or removed.
            if (SpellRegistry.Types.Length != m_RestrictedSpells.Count)
            {
                BitArray temp          = new BitArray(SpellRegistry.Types.Length);
                int      MaxIterations = Math.Min(temp.Length, m_RestrictedSpells.Count);
                for (int ix = 0; ix < MaxIterations; ix++)
                {
                    temp[ix] = m_RestrictedSpells[ix];
                }

                m_RestrictedSkills = temp;
            }

            UpdateRegion();
        }
Esempio n. 11
0
		public override void Deserialize( GenericReader reader ) {
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch( version ) {
				case 6: {
						_minZ = reader.ReadInt();
						_maxZ = reader.ReadInt();

						goto case 5;
					}
				case 5: {
						m_EditAccessLevel = (AccessLevel)reader.ReadInt();

						goto case 4;
					}
				case 4: {
						m_RegionArea = ReadRect3DArray( reader );

						m_Flags = (RegionFlag)reader.ReadInt();

						m_RestrictedSpells = ReadBitArray( reader );
						m_RestrictedSkills = ReadBitArray( reader );

						m_Active = reader.ReadBool();

						m_RegionName = reader.ReadString();
						m_RegionPriority = reader.ReadInt();
						m_Music = (MusicName)reader.ReadInt();
						m_PlayerLogoutDelay = reader.ReadTimeSpan();
						m_LightLevel = reader.ReadInt();

						if( version <= 4 ) {
							reader.ReadMap();
							reader.ReadPoint3D();
							reader.ReadMap();
							reader.ReadPoint3D();
						}

						break;
					}
				case 3: //pre-RunUO 2.0
					{
						m_LightLevel = reader.ReadInt();
						goto case 2;
					}
				case 2: {
						m_Music = (MusicName)reader.ReadInt();
						goto case 1;
					}
				case 1: {
						List<Rectangle2D> rects2d = ReadRect2DArray( reader );
						foreach( Rectangle2D rect in rects2d ) {
							Rectangle3D newrect = Server.Region.ConvertTo3D( rect );
							DoChooseArea( null, this.Map, newrect.Start, newrect.End, this );
						}

						m_RegionPriority = reader.ReadInt();
						m_PlayerLogoutDelay = reader.ReadTimeSpan();

						m_RestrictedSpells = ReadBitArray( reader );
						m_RestrictedSkills = ReadBitArray( reader );

						m_Flags = (RegionFlag)reader.ReadInt();

						m_RegionName = reader.ReadString();
						break;
					}
				case 0: {
						List<Rectangle2D> rects2d = ReadRect2DArray( reader );
						foreach( Rectangle2D rect in rects2d ) {
							Rectangle3D newrect = Server.Region.ConvertTo3D( rect );
							DoChooseArea( null, this.Map, newrect.Start, newrect.End, this );
						}

						m_RestrictedSpells = ReadBitArray( reader );
						m_RestrictedSkills = ReadBitArray( reader );

						m_Flags = (RegionFlag)reader.ReadInt();

						m_RegionName = reader.ReadString();
						break;
					}
			}

			m_AllControls.Add( this );

			if( RegionNameTaken( m_RegionName ) )
				m_RegionName = FindNewName( m_RegionName );

			UpdateRegion();
		}
Esempio n. 12
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length < 2)
            {
                this.SendUsage(caller);
                return;
            }
            var name   = command[0];
            var region = RegionsPlugin.Instance.GetRegion(name, true);

            if (region == null)
            {
                UnturnedChat.Say(caller, "Region \"" + name + "\" not found", Color.red);
                return;
            }

            if (!region.IsOwner(caller) && !PermissionUtil.HasPermission(caller, "flag.override"))
            {
                UnturnedChat.Say(caller, "You're not the owner of this region!", Color.red);
                return;
            }

            var flagName = command[1];

            var t = RegionFlag.GetFlagType(flagName);

            if (t == null)
            {
                UnturnedChat.Say(caller, "Unknown flag: \"" + flagName + "\"", Color.red);
                return;
            }

            var f = region.GetFlag(t);

            if (f == null)
            {
                f      = (RegionFlag)Activator.CreateInstance(t);
                f.Name = RegionFlag.GetFlagName(t);
            }

            var hasFlagPermission = PermissionUtil.HasPermission(caller, "flag." + flagName);
            var usage             = "Usage: /rflag " + name + " " + f.Name + " " + f.Usage + " [-g <group>]";

            if (command.Length == 3 && command[2].Equals("--help"))
            {
                var description = f.Description;
                var value       = f.GetValue <object>();

                UnturnedChat.Say(caller, "Flag: " + f.Name, Color.blue);
                UnturnedChat.Say(caller, "Description: " + description, Color.blue);
                if (!hasFlagPermission)
                {
                    return;
                }
                UnturnedChat.Say(caller, usage);
                UnturnedChat.Say(caller, "Value: " + (value ?? "null"), Color.blue);
                return;
            }

            if (!hasFlagPermission)
            {
                UnturnedChat.Say(caller, "You don't have access to this flag!", Color.red);
                return;
            }


            f.Region = region;

            Group         group    = Group.ALL;
            List <string> args     = new List <string>();
            bool          isValue  = false;
            bool          groupSet = false;

            foreach (string arg in command.Skip(2))
            {
                if (!groupSet)
                {
                    if (isValue)
                    {
                        if (f.SupportsGroups)
                        {
                            group = GroupExtensions.GetGroup(arg);
                        }
                        groupSet = true;
                        isValue  = false;
                        continue;
                    }
                    if (arg.ToLower().Equals("-g") || arg.ToLower().Equals("--group"))
                    {
                        if (!f.SupportsGroups)
                        {
                            UnturnedChat.Say(caller, "Warning: Flag does not support groups", Color.red);
                        }
                        isValue = true;
                        continue;
                    }
                }

                args.Add(arg);
            }

            string shownValue;

            if (isValue || !f.ParseValue(caller, region, args.ToArray(), out shownValue, group))
            {
                UnturnedChat.Say(caller, usage, Color.red);
                return;
            }

            region.SetFlag(f.Name, f.Value, f.GroupValues);

            if (shownValue != null)
            {
                string msg = $"Flag has been set to: {shownValue}";
                if (f.SupportsGroups)
                {
                    msg += $" for group {group}!";
                }
                UnturnedChat.Say(caller, msg, Color.green);
            }

            RegionsPlugin.Instance.Configuration.Save();
        }
Esempio n. 13
0
		public bool GetFlag( RegionFlag flag ) {
			return ((m_Flags & flag) != 0);
		}
Esempio n. 14
0
		public override void Deserialize( GenericReader reader )
		{
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 20: //Loki edit
                    {
                        LokiPvP = reader.ReadBool();
                        goto case 19;
                    }
                case 19:
                    {
                        AllowBenefitPlayer = reader.ReadBool();
                        AllowHarmPlayer = reader.ReadBool();
                        AllowHousing = reader.ReadBool();
                        AllowSpawn = reader.ReadBool();
                        CanBeDamaged = reader.ReadBool();
                        CanHeal = reader.ReadBool();
                        CanRessurect = reader.ReadBool();
                        CanUseStuckMenu = reader.ReadBool();
                        ItemDecay = reader.ReadBool();
                        ShowEnterMessage = reader.ReadBool();
                        ShowExitMessage = reader.ReadBool();
                        AllowBenefitNPC = reader.ReadBool();
                        AllowHarmNPC = reader.ReadBool();
                        CanMountEthereal = reader.ReadBool();
                        CanEnter = reader.ReadBool();
                        CanLootPlayerCorpse = reader.ReadBool();
                        CanLootNPCCorpse = reader.ReadBool();
                        CanLootOwnCorpse = reader.ReadBool();
                        CanUsePotOthers = reader.ReadBool();
                        m_IsGuarded = reader.ReadBool();
                        EmptyNPCCorpse = reader.ReadBool();
                        EmptyPlayerCorpse = reader.ReadBool();
                        DeleteNPCCorpse = reader.ReadBool();
                        DeletePlayerCorpse = reader.ReadBool();
                        ResNPCOnDeath = reader.ReadBool();
                        ResPlayerOnDeath = reader.ReadBool();
                        m_MoveNPCOnDeath = reader.ReadBool();
                        m_MovePlayerOnDeath = reader.ReadBool();
                        NoPlayerItemDrop = reader.ReadBool();
                        NoNPCItemDrop = reader.ReadBool();
                        goto case 18;
                    }
                case 18:
                    {
                        FizzlePvP = reader.ReadBool();
                        goto case 17;
                    }
                case 17:
                    {
                        CanUsePotExplosion = reader.ReadBool();
                        IgnoreYoungProtection = reader.ReadBool();
                        goto case 16;
                    }
                case 16:
                    {
                        m_LogoutMap = reader.ReadMap();
                        goto case 15;
                    }
                case 15:
                    {
                        NoFameLoss = reader.ReadBool();
                        goto case 14;
                    }
                case 14:
                    {
                        BroadcastArriveMsg = reader.ReadBool();
                        goto case 13;
                    }
                case 13:
                    {
                        m_GoLocation = reader.ReadPoint3D();

                        goto case 12;
                    }
                case 12:
                    {
                        AllowSkillGain = reader.ReadBool();
                        goto case 11;
                    }
                case 11:
                    {
                        m_LogoutMove = reader.ReadBool();
                        m_LogoutLoc = reader.ReadPoint3D();
                        goto case 10;
                    }
                case 10:
                    {
                        AllowSpecialAttacks = reader.ReadBool();
                        goto case 9;
                    }
                case 9:
                    {
                        CanUnshrink = reader.ReadBool();
                        goto case 8;
                    }
                case 8:
                    {
                        CanPlaceVendors = reader.ReadBool();
                        goto case 7;
                    }
                case 7:
                    {
                        AllowPvP = reader.ReadBool();
                        goto case 6;
                    }
                case 6:
                    {
                        AllowTrade = reader.ReadBool();
                        goto case 5;
                    }
                case 5:
                    {
                        CanUsePotHeal = reader.ReadBool();
                        CanUsePotMana = reader.ReadBool();
                        CanUsePotStam = reader.ReadBool();
                        CanUsePotShrink = reader.ReadBool();
                        CanCutCorpse = reader.ReadBool();
                        HasAttackPenalty = reader.ReadBool();
                        goto case 4;
                    }
                // New RunUO 2.0 Version (case 4)
                case 4:
                {
                    m_RegionArea = ReadRect3DArray(reader);
                    
                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Active = reader.ReadBool();

                    m_RegionName = reader.ReadString();
                    m_RegionPriority = reader.ReadInt();
                    m_Music = (MusicName)reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();
                    m_LightLevel = reader.ReadInt();

                    m_MoveNPCToMap = reader.ReadMap();
                    m_MoveNPCToLoc = reader.ReadPoint3D();
                    m_MovePlayerToMap = reader.ReadMap();
                    m_MovePlayerToLoc = reader.ReadPoint3D();

                    break;
                }

                // Old RunUO 1.0 Version (cases 3-0)
                case 3:
                {
                    m_LightLevel = reader.ReadInt();
                    goto case 2;
                }
                case 2:
                {
                    m_Music = (MusicName)reader.ReadInt();
                    goto case 1;
                }
                case 1:
                {
                    List<Rectangle2D> rects2d = ReadRect2DArray(reader);
                    foreach (Rectangle2D rect in rects2d)
                    {
                        Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                        DoChooseArea(null, Map, newrect.Start, newrect.End, this);
                    }

                    m_RegionPriority = reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RegionName = reader.ReadString();
                    break;
                }
                case 0:
                {
                    List<Rectangle2D> rects2d = ReadRect2DArray(reader);
                    foreach (Rectangle2D rect in rects2d)
                    {
                        Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                        DoChooseArea(null, Map, newrect.Start, newrect.End, this);
                    }

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RegionName = reader.ReadString();
                    break;
                }
            }

            m_AllControls.Add(this);

            //if(RegionNameTaken(m_RegionName))
            //    m_RegionName = FindNewName(m_RegionName);

            if (version < 19)
            {
                AllowBenefitPlayer = GetFlag(RegionFlag.AllowBenefitPlayer);
                AllowHarmPlayer = GetFlag(RegionFlag.AllowHarmPlayer);
                AllowHousing = GetFlag(RegionFlag.AllowHousing);
                AllowSpawn = GetFlag(RegionFlag.AllowSpawn);
                CanBeDamaged = GetFlag(RegionFlag.CanBeDamaged);
                CanHeal = GetFlag(RegionFlag.CanHeal);
                CanRessurect = GetFlag(RegionFlag.CanRessurect);
                CanUseStuckMenu = GetFlag(RegionFlag.CanUseStuckMenu);
                ItemDecay = GetFlag(RegionFlag.ItemDecay);
                ShowEnterMessage = GetFlag(RegionFlag.ShowEnterMessage);
                ShowExitMessage = GetFlag(RegionFlag.ShowExitMessage);
                AllowBenefitNPC = GetFlag(RegionFlag.AllowBenefitNPC);
                AllowHarmNPC = GetFlag(RegionFlag.AllowHarmNPC);
                CanMountEthereal = GetFlag(RegionFlag.CanMountEthereal);
                CanEnter = GetFlag(RegionFlag.CanEnter);
                CanLootPlayerCorpse = GetFlag(RegionFlag.CanLootPlayerCorpse);
                CanLootNPCCorpse = GetFlag(RegionFlag.CanLootNPCCorpse);
                CanLootOwnCorpse = GetFlag(RegionFlag.CanLootOwnCorpse);
                CanUsePotOthers = GetFlag(RegionFlag.CanUsePotOthers);
                IsGuarded = GetFlag(RegionFlag.IsGuarded);
                EmptyNPCCorpse = GetFlag(RegionFlag.EmptyNPCCorpse);
                EmptyPlayerCorpse = GetFlag(RegionFlag.EmptyPlayerCorpse);
                DeleteNPCCorpse = GetFlag(RegionFlag.DeleteNPCCorpse);
                DeletePlayerCorpse = GetFlag(RegionFlag.DeletePlayerCorpse);
                ResNPCOnDeath = GetFlag(RegionFlag.ResNPCOnDeath);
                ResPlayerOnDeath = GetFlag(RegionFlag.ResPlayerOnDeath);
                MoveNPCOnDeath = GetFlag(RegionFlag.MoveNPCOnDeath);
                MovePlayerOnDeath = GetFlag(RegionFlag.MovePlayerOnDeath);
                NoPlayerItemDrop = GetFlag(RegionFlag.NoPlayerItemDrop);
                NoNPCItemDrop = GetFlag(RegionFlag.NoNPCItemDrop);
            }

            UpdateRegion();
		}
Esempio n. 15
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            Point3D customGoLoc = new Point3D(0,0,0);
            switch (version)
            {
            //---------------------------- Solaris Battlegrounds addition (3/3) begin ----------------------------------------------------

            /*  This allows region controllers to be used to define "battlegrounds" where player versus player combat is completely no-holds-barred.
            There is no notoriety problems like criminal/murder status, and is intended for PVP tourneys or all-around-PVP fun.

            */
                case 6:		//case 6 - added battlegrounds flag to serialized data
                {
                    _Battlegrounds = reader.ReadBool();
                    goto case 5;
                }
            //--------------------------- Solaris Battlegrounds addition (3/3) end ------------------------------------------------------
                // New RunUO 2.0 Version (case 5 and 4)
                case 5:
                {
                    customGoLoc = reader.ReadPoint3D();
                    goto case 4;
                }
                case 4:
                {
                    m_RegionArea = ReadRect3DArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Active = reader.ReadBool();

                    m_RegionName = reader.ReadString();
                    m_RegionPriority = reader.ReadInt();
                    m_Music = (MusicName)reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();
                    m_LightLevel = reader.ReadInt();

                    m_MoveNPCToMap = reader.ReadMap();
                    m_MoveNPCToLoc = reader.ReadPoint3D();
                    m_MovePlayerToMap = reader.ReadMap();
                    m_MovePlayerToLoc = reader.ReadPoint3D();

                    break;
                }

                // Old RunUO 1.0 Version (cases 3-0)
                case 3:
                {
                    m_LightLevel = reader.ReadInt();
                    goto case 2;
                }
                case 2:
                {
                    m_Music = (MusicName)reader.ReadInt();
                    goto case 1;
                }
                case 1:
                {
                    List<Rectangle2D> rects2d = ReadRect2DArray(reader);
                    foreach (Rectangle2D rect in rects2d)
                    {
                        Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                        DoChooseArea(null, this.Map, newrect.Start, newrect.End, this);
                    }

                    m_RegionPriority = reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();
                    if (NoPlayerCorpses)
                    {
                        DeleteNPCCorpse = true;
                        DeletePlayerCorpse = true;
                    }
                    if (NoItemDrop)
                    {
                        NoPlayerItemDrop = true;
                        NoNPCItemDrop = true;
                    }
                    // Invert because of change from "Cannot" to "Can"
                    if (CanLootOwnCorpse)
                    {
                        CanLootOwnCorpse = false;
                    }
                    if (CanEnter)
                    {
                        CanEnter = false;
                    }

                    m_RegionName = reader.ReadString();
                    break;
                }
                case 0:
                {
                    List<Rectangle2D> rects2d = ReadRect2DArray(reader);
                    foreach (Rectangle2D rect in rects2d)
                    {
                        Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                        DoChooseArea(null, this.Map, newrect.Start, newrect.End, this);
                    }

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();
                    if (NoPlayerCorpses)
                    {
                        DeleteNPCCorpse = true;
                        DeletePlayerCorpse = true;
                    }
                    if (NoItemDrop)
                    {
                        NoPlayerItemDrop = true;
                        NoNPCItemDrop = true;
                    }
                    // Invert because of change from "Cannot" to "Can"
                    if (CanLootOwnCorpse)
                    {
                        CanLootOwnCorpse = false;
                    }
                    if (CanEnter)
                    {
                        CanEnter = false;
                    }

                    m_RegionName = reader.ReadString();
                    break;
                }
            }

            m_AllControls.Add(this);

            if(RegionNameTaken(m_RegionName))
                m_RegionName = FindNewName(m_RegionName);

            UpdateRegion();
            m_CustomGoLocation = customGoLoc;
            CustomGoLocation = customGoLoc;
            UpdateRegion();
        }
Esempio n. 16
0
 public void SetDefaultFlags()
 {
     // Set the default region control settings
     m_PlayerLogoutDelay = TimeSpan.FromMinutes(5.0);
     m_ExtFlags = ExtRegionFlag.AllowGateIn | ExtRegionFlag.AllowHiding | ExtRegionFlag.AllowRecallIn | ExtRegionFlag.AllowCutCorpse;
     m_Flags = RegionFlag.AllowBenefitNPC | RegionFlag.AllowBenefitPlayer | RegionFlag.AllowHarmNPC | RegionFlag.AllowHarmPlayer
         | RegionFlag.AllowSpawn | RegionFlag.CanBeDamaged | RegionFlag.CanEnter | RegionFlag.CanHeal
         | RegionFlag.CanLootNPCCorpse | RegionFlag.CanLootOwnCorpse | RegionFlag.CanLootPlayerCorpse
         | RegionFlag.CanMountEthereal | RegionFlag.CanRessurect | RegionFlag.CanUsePotions
         | RegionFlag.CanUseStuckMenu | RegionFlag.ItemDecay;
 }
Esempio n. 17
0
 private bool GetFlag(RegionFlag flag)
 {
     return((m_Flags & flag) != 0);
 }
Esempio n. 18
0
		public void CloneFromRegionObject(Region r, bool loadedFromXML)
		{
			if (r != null)
			{
				//Clear flags before copy
				m_Flags = RegionFlag.None;

				// if we have a custom region, get this special bits
				if (r is CustomRegion)
					DupeCustomBits(r);

				if (r.Coords != null && r.Coords.Count > 0)
				{
					m_Coords.Clear();
					ArrayList c = r.Coords;

					for (int i = 0; i < c.Count; i++)
					{
						if (c[i] is Rectangle2D)
							m_Coords.Add((Rectangle2D)c[i]);
						//plasma: add missing 3d rects lol!
						if (c[i] is Rectangle3D)
							m_Coords.Add((Rectangle3D)c[i]);
					}
				}

				if (r.InnBounds != null && r.InnBounds.Count > 0)
				{
					m_InnBounds.Clear();
					ArrayList c = r.InnBounds;

					for (int i = 0; i < c.Count; i++)
					{
						if (c[i] is Rectangle2D)
							m_InnBounds.Add((Rectangle2D)c[i]);
						if (c[i] is Rectangle3D)
							m_InnBounds.Add((Rectangle3D)c[i]);
					}
				}

				//default these to true for non custom regions
				this.SetFlag(RegionFlag.CanUsePotions, true);
				this.SetFlag(RegionFlag.CanRessurect, true);
				this.SetFlag(RegionFlag.CanUseStuckMenu, true);
				this.SetFlag(RegionFlag.IsHouseRegion, r is HouseRegion);
				this.SetFlag(RegionFlag.AllowTravelSpellsInRegion, !IsFeluccaDungeon(r,loadedFromXML) && !(r is AngelIsland || r.Name.Equals("AngelIsland"))) ;
				//set guards and murder zone
				this.SetFlag(RegionFlag.IsGuarded, IsGuardedRegion(r,loadedFromXML));
				this.SetFlag(RegionFlag.NoMurderCounts, r.IsNoMurderZone);
				//Non custom regions only have a static InnLogoutDelay
				this.m_InnLogoutDelay = Region.InnLogoutDelay;
				//Blank the restricted spells / skills
				this.m_RestrictedSpells = new BitArray(SpellRegistry.Types.Length);
				this.m_RestrictedSkills = new BitArray(SkillInfo.Table.Length);

				//Assign generic props						
				this.m_Priority = MapPriority(r.Priority);
				this.m_Music = r.Music;
				this.SetFlag(RegionFlag.Music, (r.Music != MusicName.Invalid));
				this.m_RegionName = r.Name;
				this.m_TargetMap = r.Map;

				// LightLevel - defualts to 0, use -1 for region to inherit and use light level/cycle across the world.            
				if (this.m_LightLevel <= 0)
					this.m_LightLevel = -1;

				// Dungeon - Setting to True will set the regions light level to that of the dungon light level, has no other effects.
				this.SetFlag(RegionFlag.IsDungeon, IsFeluccaDungeon(r,loadedFromXML));
				this.m_GoLocation = r.GoLocation;
				this.m_MaxZ = r.MaxZ;
				this.m_MinZ = r.MinZ;

				//Plasma:  Felucca dungeons and AI need recall and gate OFF!
				if (IsFeluccaDungeon(r, loadedFromXML) || r is AngelIsland || r.Name.Equals("AngelIsland"))
				{
					NoGateInto = true;
					NoRecallInto = true;
				}

				UpdateRegion();
				this.SendMessage(String.Format("Region cloned from '" + r.Name + "'."));
			}
			else
			{
				this.SendMessage(String.Format("No region by the name '" + r.Name + "' found."));
			}
		}
Esempio n. 19
0
		private void DupeCustomBits(Region r)
		{
			//pla: replicate custom region
			if (r is CustomRegion)
			{
				RegionControl rc = (r as CustomRegion).GetRegionControler();

				if (rc != null)
				{
					//copy all the flags and restricted stuff
					this.m_Flags = rc.m_Flags;
					this.m_RestrictedSpells = new BitArray(rc.m_RestrictedSpells);
					this.m_RestrictedSkills = new BitArray(rc.m_RestrictedSkills);
					this.m_RestrictedMagicMsg = rc.m_RestrictedMagicMsg;
					this.m_InnLogoutDelay = rc.InnLogoutDelay;
					this.m_IOBAlignment = rc.IOBAlign;
					this.m_MaxFollowers = rc.MaxFollowerSlots;
					this.m_Music = r.Music;
					this.SetFlag(RegionFlag.Music, (r.Music != MusicName.Invalid));

					if (rc.LightLevel > 0)
						this.m_LightLevel = rc.LightLevel;

					this.m_Types.Clear();
					if (rc.m_Types != null && rc.m_Types.Count > 0)
					{
						ArrayList t = rc.m_Types;
						for (int i = 0; i < rc.m_Types.Count; ++i)
							if (t[i] is string)
								this.m_Types.Add((string)t[i]);
					}
				}
				else
				{
					this.SendMessage(String.Format("Region controller for custom region '" + r.Name + "' could not be found.\n\rCustom properties and flags have not been cloned successfully"));
				}
			}
		}
Esempio n. 20
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			switch (version)
			{
				case 14:
					{
						//version 14
						m_Coords=ReadRect3DArray(reader);
						m_InnBounds=ReadRect3DArray(reader);
						goto case 13;
					}
				case 13:
					{
						m_TargetMap = reader.ReadMap();
						m_GoLocation = reader.ReadPoint3D();
						m_MinZ = reader.ReadInt();
						m_MaxZ = reader.ReadInt();
						goto case 12;
					}
				case 12:
					{
						m_Enabled = reader.ReadBool();
						goto case 11;
					}
				case 11:
					{
						int size = reader.ReadInt();
						m_Types = new ArrayList(size);

						for (int i = 0; i < size; ++i)
						{
							string typeName = reader.ReadString();
							m_Types.Add(typeName);

						}
						goto case 10;
					}

				case 10:
					{
						m_MaxFollowers = reader.ReadInt();
						goto case 9;
					}
				case 9:
					{
						m_RestrictedMagicMsg = reader.ReadString();
						goto case 8;
					}
				case 8:
					{
						m_Music = (MusicName)reader.ReadInt();
						goto case 7;
					}

				case 7:
					{
						if (m_InnBounds == null)
						{
							m_InnBounds = ReadRect2DArray(reader);
						}
						else
						{
							m_InnBounds.AddRange(ReadRect2DArray(reader));
						}
						m_InnLogoutDelay = reader.ReadTimeSpan();

						goto case 6;
					}
				case 6:
					{
						m_PlayerLogoutDelay = reader.ReadTimeSpan();
						goto case 5;
					}
				case 5:
					{
						if (version < 13)
						{	// converted to a flag
							bool m_IsDungeon = (bool)reader.ReadBool();
							IsDungeon = m_IsDungeon;
						}
						goto case 4;
					}
				case 4:
					{
						m_IOBAlignment = (IOBAlignment)reader.ReadInt();
						goto case 3;
					}

				case 3:
					{
						m_LightLevel = reader.ReadInt();
						goto case 2;
					}
				case 2:
					{
						goto case 1;
					}
				case 1:
					{
						if (Coords == null)
						{
							Coords = ReadRect2DArray(reader);
						}
						else
						{
							Coords.AddRange(ReadRect2DArray(reader));
						}
						m_Priority = (CustomRegionPriority)reader.ReadInt();

						m_RestrictedSpells = ReadBitArray(reader);
						m_RestrictedSkills = ReadBitArray(reader);

						m_Flags = (RegionFlag)reader.ReadInt();

						m_RegionName = reader.ReadString();
						break;
					}
				case 0:
					{
						Coords = new ArrayList();

						Coords.Add(reader.ReadRect2D());
						m_RestrictedSpells = ReadBitArray(reader);
						m_RestrictedSkills = ReadBitArray(reader);

						m_Flags = (RegionFlag)reader.ReadInt();

						m_RegionName = reader.ReadString();
						break;
					}
			}
			if (version < 12)
			{
				m_Enabled = true;
			}

			if (version < 11)
			{
				m_Types = new ArrayList();
			}

			if (version < 8)
			{
				m_Music = MusicName.Invalid;
			}

			// fixup this table if Skills have been added or removed.
			if (SkillInfo.Table.Length != m_RestrictedSkills.Count)
			{
				BitArray temp = new BitArray(SkillInfo.Table.Length);
				int MaxIterations = Math.Min(temp.Length, m_RestrictedSkills.Count);
				for (int ix = 0; ix < MaxIterations; ix++)
					temp[ix] = m_RestrictedSkills[ix];

				m_RestrictedSkills = temp;
			}

			// fixup this table if Spells have been added or removed.
			if (SpellRegistry.Types.Length != m_RestrictedSpells.Count)
			{
				BitArray temp = new BitArray(SpellRegistry.Types.Length);
				int MaxIterations = Math.Min(temp.Length, m_RestrictedSpells.Count);
				for (int ix = 0; ix < MaxIterations; ix++)
					temp[ix] = m_RestrictedSpells[ix];

				m_RestrictedSkills = temp;
			}

			UpdateRegion();

		}
Esempio n. 21
0
 public bool GetFlag(RegionFlag flag)
 {
     return((m_Flags & flag) != 0);
 }
		public override void Deserialize( GenericReader reader )
		{
            base.Deserialize(reader);

            int version = reader.ReadInt();

            // Point3D customGoLoc = new Point3D(0,0,0); // REMOVED
            switch (version)
            {
                // New RunUO 2.0 Version (case 5 and 4)
                case 5:
                {
                    // customGoLoc = reader.ReadPoint3D(); // REMOVED
                    goto case 4;
                }
                case 4:
                {
                    m_RegionArea = ReadRect3DArray(reader);
                    
                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Active = reader.ReadBool();

                    m_RegionName = reader.ReadString();
                    m_RegionPriority = reader.ReadInt();
                    m_Music = (MusicName)reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();
                    m_LightLevel = reader.ReadInt();

                    m_MoveNPCToMap = reader.ReadMap();
                    m_MoveNPCToLoc = reader.ReadPoint3D();
                    m_MovePlayerToMap = reader.ReadMap();
                    m_MovePlayerToLoc = reader.ReadPoint3D();

                    break;
                }

                // Old RunUO 1.0 Version (cases 3-0)
                case 3:
                {
                    m_LightLevel = reader.ReadInt();
                    goto case 2;
                }
                case 2:
                {
                    m_Music = (MusicName)reader.ReadInt();
                    goto case 1;
                }
                case 1:
                {
                    List<Rectangle2D> rects2d = ReadRect2DArray(reader);
                    foreach (Rectangle2D rect in rects2d)
                    {
                        Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                        DoChooseArea(null, this.Map, newrect.Start, newrect.End, this);
                    }

                    m_RegionPriority = reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();
                    if (NoPlayerCorpses)
                    {
                        DeleteNPCCorpse = true;
                        DeletePlayerCorpse = true;                          
                    }
                    if (NoItemDrop)
                    {
                        NoPlayerItemDrop = true;
                        NoNPCItemDrop = true;
                    }
                    // Invert because of change from "Cannot" to "Can"
                    if (CanLootOwnCorpse)
                    {
                        CanLootOwnCorpse = false;
                    }
                    if (CanEnter)
                    {
                        CanEnter = false;
                    }

                    m_RegionName = reader.ReadString();
                    break;
                }
                case 0:
                {
                    List<Rectangle2D> rects2d = ReadRect2DArray(reader);
                    foreach (Rectangle2D rect in rects2d)
                    {
                        Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                        DoChooseArea(null, this.Map, newrect.Start, newrect.End, this);
                    }

                    m_RestrictedSpells = ReadBitArray(reader);
                    m_RestrictedSkills = ReadBitArray(reader);

                    m_Flags = (RegionFlag)reader.ReadInt();
                    if (NoPlayerCorpses)
                    {
                        DeleteNPCCorpse = true;
                        DeletePlayerCorpse = true;
                    }
                    if (NoItemDrop)
                    {
                        NoPlayerItemDrop = true;
                        NoNPCItemDrop = true;
                    }
                    // Invert because of change from "Cannot" to "Can"
                    if (CanLootOwnCorpse)
                    {
                        CanLootOwnCorpse = false;
                    }
                    if (CanEnter)
                    {
                        CanEnter = false;
                    }

                    m_RegionName = reader.ReadString();
                    break;
                }
            }

            m_AllControls.Add(this);

            if(RegionNameTaken(m_RegionName))
                m_RegionName = FindNewName(m_RegionName);

            UpdateRegion();
           // m_CustomGoLocation = customGoLoc;  // REMOVED
           // CustomGoLocation = customGoLoc;   // REMOVED
            UpdateRegion();
		}
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
            m_LogoutMoveMap = Map.Internal;

			int version = reader.ReadInt();

			switch ( version )
			{
                case 7:
                {
                    m_CastWithoutReagents=reader.ReadBool();
                    goto case 6;
                }
                case 6:
                {
                    m_LogoutMoveLocation = reader.ReadPoint3D();
                    m_LogoutMoveMap = reader.ReadMap();
                    goto case 5;
                }
                case 5:
                {
                    m_AlwaysGrey = reader.ReadBool();
                    m_CannotTrade = reader.ReadBool();
                    goto case 4;
                }
                case 4:
                {
                    m_NoFameKarma = reader.ReadBool();
                    m_NoPvPPoints = reader.ReadBool();
                    m_NoMurderCounts = reader.ReadBool();
                    m_NoFactionEffects = reader.ReadBool();
                    m_CannotTakeRewards = reader.ReadBool();
                    goto case 3;
                }
                case 3:
				{
					m_LightLevel = reader.ReadInt();
					goto case 2;
				}
				case 2:
				{
					m_Music = (MusicName)reader.ReadInt();
					goto case 1;
				}
				case 1:
				{
					Coords = ReadRect2DArray( reader );
					m_Priority = (CustomRegionPriority) reader.ReadInt();
					m_PlayerLogoutDelay = reader.ReadTimeSpan();

					m_RestrictedSpells = ReadBitArray( reader );
					m_RestrictedSkills = ReadBitArray( reader );

					m_Flags = (RegionFlag)reader.ReadInt();

					m_RegionName = reader.ReadString();
					break;
				}
				case 0:
				{
					Coords = new ArrayList();

					Coords.Add( reader.ReadRect2D() );
					m_RestrictedSpells = ReadBitArray( reader );
					m_RestrictedSkills = ReadBitArray( reader );

					m_Flags = (RegionFlag)reader.ReadInt();

					m_RegionName = reader.ReadString();
					break;
				}
			}

			UpdateRegion();

		}
Esempio n. 24
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 3:
                {
                    m_LightLevel = reader.ReadInt();
                    goto case 2;
                }
                case 2:
                {
                    m_Music = (MusicName)reader.ReadInt();
                    goto case 1;
                }
                case 1:
                {
                    Coords = ReadRect2DArray( reader );
                    m_Priority = (CustomRegionPriority) reader.ReadInt();
                    m_PlayerLogoutDelay = reader.ReadTimeSpan();

                    m_RestrictedSpells = ReadBitArray( reader );
                    m_RestrictedSkills = ReadBitArray( reader );

                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RegionName = reader.ReadString();
                    break;
                }
                case 0:
                {
                    Coords = new ArrayList();

                    Coords.Add( reader.ReadRect2D() );
                    m_RestrictedSpells = ReadBitArray( reader );
                    m_RestrictedSkills = ReadBitArray( reader );

                    m_Flags = (RegionFlag)reader.ReadInt();

                    m_RegionName = reader.ReadString();
                    break;
                }
            }

            UpdateRegion();
        }
Esempio n. 25
0
        public void CloneFromRegionObject(Region r, bool loadedFromXML)
        {
            if (r != null)
            {
                //Clear flags before copy
                m_Flags = RegionFlag.None;

                // if we have a custom region, get this special bits
                if (r is CustomRegion)
                {
                    DupeCustomBits(r);
                }

                if (r.Coords != null && r.Coords.Count > 0)
                {
                    m_Coords.Clear();
                    ArrayList c = r.Coords;

                    for (int i = 0; i < c.Count; i++)
                    {
                        if (c[i] is Rectangle2D)
                        {
                            m_Coords.Add((Rectangle2D)c[i]);
                        }
                        //plasma: add missing 3d rects lol!
                        if (c[i] is Rectangle3D)
                        {
                            m_Coords.Add((Rectangle3D)c[i]);
                        }
                    }
                }

                if (r.InnBounds != null && r.InnBounds.Count > 0)
                {
                    m_InnBounds.Clear();
                    ArrayList c = r.InnBounds;

                    for (int i = 0; i < c.Count; i++)
                    {
                        if (c[i] is Rectangle2D)
                        {
                            m_InnBounds.Add((Rectangle2D)c[i]);
                        }
                        if (c[i] is Rectangle3D)
                        {
                            m_InnBounds.Add((Rectangle3D)c[i]);
                        }
                    }
                }

                //default these to true for non custom regions
                this.SetFlag(RegionFlag.CanUsePotions, true);
                this.SetFlag(RegionFlag.CanRessurect, true);
                this.SetFlag(RegionFlag.CanUseStuckMenu, true);
                this.SetFlag(RegionFlag.IsHouseRegion, r is HouseRegion);
                this.SetFlag(RegionFlag.AllowTravelSpellsInRegion, !IsFeluccaDungeon(r, loadedFromXML) && !(r is AngelIsland || r.Name.Equals("AngelIsland")));
                //set guards and murder zone
                this.SetFlag(RegionFlag.IsGuarded, IsGuardedRegion(r, loadedFromXML));
                this.SetFlag(RegionFlag.NoMurderCounts, r.IsNoMurderZone);
                //Non custom regions only have a static InnLogoutDelay
                this.m_InnLogoutDelay = Region.InnLogoutDelay;
                //Blank the restricted spells / skills
                this.m_RestrictedSpells = new BitArray(SpellRegistry.Types.Length);
                this.m_RestrictedSkills = new BitArray(SkillInfo.Table.Length);

                //Assign generic props
                this.m_Priority = MapPriority(r.Priority);
                this.m_Music    = r.Music;
                this.SetFlag(RegionFlag.Music, (r.Music != MusicName.Invalid));
                this.m_RegionName = r.Name;
                this.m_TargetMap  = r.Map;

                // LightLevel - defualts to 0, use -1 for region to inherit and use light level/cycle across the world.
                if (this.m_LightLevel <= 0)
                {
                    this.m_LightLevel = -1;
                }

                // Dungeon - Setting to True will set the regions light level to that of the dungon light level, has no other effects.
                this.SetFlag(RegionFlag.IsDungeon, IsFeluccaDungeon(r, loadedFromXML));
                this.m_GoLocation = r.GoLocation;
                this.m_MaxZ       = r.MaxZ;
                this.m_MinZ       = r.MinZ;

                //Plasma:  Felucca dungeons and AI need recall and gate OFF!
                if (IsFeluccaDungeon(r, loadedFromXML) || r is AngelIsland || r.Name.Equals("AngelIsland"))
                {
                    NoGateInto   = true;
                    NoRecallInto = true;
                }

                UpdateRegion();
                this.SendMessage(String.Format("Region cloned from '" + r.Name + "'."));
            }
            else
            {
                this.SendMessage(String.Format("No region by the name '" + r.Name + "' found."));
            }
        }
Esempio n. 26
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 6: {
                _minZ = reader.ReadInt();
                _maxZ = reader.ReadInt();

                goto case 5;
            }

            case 5: {
                m_EditAccessLevel = (AccessLevel)reader.ReadInt();

                goto case 4;
            }

            case 4: {
                m_RegionArea = ReadRect3DArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Active = reader.ReadBool();

                m_RegionName        = reader.ReadString();
                m_RegionPriority    = reader.ReadInt();
                m_Music             = (MusicName)reader.ReadInt();
                m_PlayerLogoutDelay = reader.ReadTimeSpan();
                m_LightLevel        = reader.ReadInt();

                if (version <= 4)
                {
                    reader.ReadMap();
                    reader.ReadPoint3D();
                    reader.ReadMap();
                    reader.ReadPoint3D();
                }

                break;
            }

            case 3:                     //pre-RunUO 2.0
            {
                m_LightLevel = reader.ReadInt();
                goto case 2;
            }

            case 2: {
                m_Music = (MusicName)reader.ReadInt();
                goto case 1;
            }

            case 1: {
                List <Rectangle2D> rects2d = ReadRect2DArray(reader);
                foreach (Rectangle2D rect in rects2d)
                {
                    Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                    DoChooseArea(null, this.Map, newrect.Start, newrect.End, this);
                }

                m_RegionPriority    = reader.ReadInt();
                m_PlayerLogoutDelay = reader.ReadTimeSpan();

                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }

            case 0: {
                List <Rectangle2D> rects2d = ReadRect2DArray(reader);
                foreach (Rectangle2D rect in rects2d)
                {
                    Rectangle3D newrect = Server.Region.ConvertTo3D(rect);
                    DoChooseArea(null, this.Map, newrect.Start, newrect.End, this);
                }

                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }
            }

            m_AllControls.Add(this);

            if (RegionNameTaken(m_RegionName))
            {
                m_RegionName = FindNewName(m_RegionName);
            }

            UpdateRegion();
        }