Modernization Fixes & Updates to Default Values (#3)
This commit is contained in:
parent
445eddff68
commit
dcf64091b1
768 changed files with 10507 additions and 14196 deletions
|
|
@ -70,9 +70,7 @@ namespace Server.Regions
|
|||
|
||||
foreach (XmlNode node in spawning.ChildNodes)
|
||||
{
|
||||
XmlElement el = node as XmlElement;
|
||||
|
||||
if (el != null)
|
||||
if (node is XmlElement el)
|
||||
{
|
||||
SpawnDefinition def = SpawnDefinition.GetSpawnDefinition(el);
|
||||
if (def == null)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace Server.Regions
|
|||
private static void CheckGuarded_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
GuardedRegion reg = (GuardedRegion)from.Region.GetRegion(typeof(GuardedRegion));
|
||||
GuardedRegion reg = from.Region.GetRegion<GuardedRegion>();
|
||||
|
||||
if (reg == null)
|
||||
from.SendMessage("You are not in a guardable region.");
|
||||
|
|
@ -95,7 +95,7 @@ namespace Server.Regions
|
|||
|
||||
if (e.Length == 1)
|
||||
{
|
||||
GuardedRegion reg = (GuardedRegion)from.Region.GetRegion(typeof(GuardedRegion));
|
||||
GuardedRegion reg = from.Region.GetRegion<GuardedRegion>();
|
||||
|
||||
if (reg == null)
|
||||
{
|
||||
|
|
@ -122,7 +122,7 @@ namespace Server.Regions
|
|||
private static void ToggleGuarded_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
GuardedRegion reg = (GuardedRegion)from.Region.GetRegion(typeof(GuardedRegion));
|
||||
GuardedRegion reg = from.Region.GetRegion<GuardedRegion>();
|
||||
|
||||
if (reg == null)
|
||||
{
|
||||
|
|
@ -342,7 +342,7 @@ namespace Server.Regions
|
|||
public bool IsGuardCandidate(Mobile m)
|
||||
{
|
||||
if (m is BaseGuard || !m.Alive || m.AccessLevel > AccessLevel.Player || m.Blessed ||
|
||||
m is BaseCreature && ((BaseCreature)m).IsInvulnerable || IsDisabled())
|
||||
m is BaseCreature creature && creature.IsInvulnerable || IsDisabled())
|
||||
return false;
|
||||
|
||||
return !AllowReds && m.Kills >= 5 || m.Criminal;
|
||||
|
|
|
|||
|
|
@ -86,10 +86,12 @@ namespace Server.Regions
|
|||
|
||||
m_Recursion = true;
|
||||
|
||||
if (m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions)
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
|
||||
if (bc?.NoHouseRestrictions == true)
|
||||
{
|
||||
}
|
||||
else if (m is BaseCreature && ((BaseCreature)m).IsHouseSummonable &&
|
||||
else if (bc.IsHouseSummonable == true &&
|
||||
!(BaseCreature.Summoning || House.IsInside(oldLocation, 16)))
|
||||
{
|
||||
}
|
||||
|
|
@ -122,8 +124,8 @@ namespace Server.Regions
|
|||
|
||||
if (House.InternalizedVendors.Count > 0 && House.IsInside(m) && !House.IsInside(oldLocation, 16) &&
|
||||
House.IsOwner(m) && m.Alive &&
|
||||
!m.HasGump(typeof(NoticeGump)))
|
||||
m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180, null, null));
|
||||
!m.HasGump<NoticeGump>())
|
||||
m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180));
|
||||
|
||||
m_Recursion = false;
|
||||
}
|
||||
|
|
@ -133,20 +135,21 @@ namespace Server.Regions
|
|||
if (!base.OnMoveInto(from, d, newLocation, oldLocation))
|
||||
return false;
|
||||
|
||||
if (from is BaseCreature && ((BaseCreature)from).NoHouseRestrictions)
|
||||
BaseCreature bc = from as BaseCreature;
|
||||
|
||||
if (bc?.NoHouseRestrictions == true)
|
||||
{
|
||||
}
|
||||
else if (from is BaseCreature && !((BaseCreature)from).Controlled
|
||||
) // Untamed creatures cannot enter public houses
|
||||
else if (bc?.Controlled == false) // Untamed creatures cannot enter public houses
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (from is BaseCreature && ((BaseCreature)from).IsHouseSummonable &&
|
||||
else if (bc?.IsHouseSummonable == true &&
|
||||
!(BaseCreature.Summoning || House.IsInside(oldLocation, 16)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (from is BaseCreature && !((BaseCreature)from).Controlled && House.IsAosRules && !House.Public)
|
||||
else if (bc?.Controlled == false && House.IsAosRules && !House.Public)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -181,8 +184,8 @@ namespace Server.Regions
|
|||
|
||||
if (House.InternalizedVendors.Count > 0 && House.IsInside(from) && !House.IsInside(oldLocation, 16) &&
|
||||
House.IsOwner(from) && from.Alive &&
|
||||
!from.HasGump(typeof(NoticeGump)))
|
||||
from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180, null, null));
|
||||
!from.HasGump<NoticeGump>())
|
||||
from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -241,8 +244,8 @@ namespace Server.Regions
|
|||
}
|
||||
else if (isOwner)
|
||||
{
|
||||
from.CloseGump(typeof(ConfirmHouseResize));
|
||||
from.CloseGump(typeof(HouseGumpAOS));
|
||||
from.CloseGump<ConfirmHouseResize>();
|
||||
from.CloseGump<HouseGumpAOS>();
|
||||
from.SendGump(new ConfirmHouseResize(from, House));
|
||||
}
|
||||
else
|
||||
|
|
@ -255,23 +258,12 @@ namespace Server.Regions
|
|||
return;
|
||||
if (e.HasKeyword(0x33)) // remove thyself
|
||||
{
|
||||
if (isFriend)
|
||||
{
|
||||
from.SendLocalizedMessage(501326); // Target the individual to eject from this house.
|
||||
from.Target = new HouseKickTarget(House);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(502094); // You must be in your house to do this.
|
||||
}
|
||||
from.SendLocalizedMessage(501326); // Target the individual to eject from this house.
|
||||
from.Target = new HouseKickTarget(House);
|
||||
}
|
||||
else if (e.HasKeyword(0x34)) // I ban thee
|
||||
{
|
||||
if (!isFriend)
|
||||
{
|
||||
from.SendLocalizedMessage(502094); // You must be in your house to do this.
|
||||
}
|
||||
else if (!House.Public && House.IsAosRules)
|
||||
if (!House.Public && House.IsAosRules)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062521); // You cannot ban someone from a private house. Revoke their access instead.
|
||||
|
|
@ -289,13 +281,9 @@ namespace Server.Regions
|
|||
from.SendLocalizedMessage(502097); // Lock what down?
|
||||
from.Target = new LockdownTarget(false, House);
|
||||
}
|
||||
else if (isFriend)
|
||||
{
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(502094); // You must be in your house to do this.
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
}
|
||||
}
|
||||
else if (e.HasKeyword(0x24)) // I wish to release this
|
||||
|
|
@ -305,13 +293,9 @@ namespace Server.Regions
|
|||
from.SendLocalizedMessage(502100); // Choose the item you wish to release
|
||||
from.Target = new LockdownTarget(true, House);
|
||||
}
|
||||
else if (isFriend)
|
||||
{
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(502094); // You must be in your house to do this.
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
}
|
||||
}
|
||||
else if (e.HasKeyword(0x25)) // I wish to secure this
|
||||
|
|
@ -344,28 +328,22 @@ namespace Server.Regions
|
|||
from.SendLocalizedMessage(502109); // Owners do not get a strongbox of their own.
|
||||
else if (isCoOwner)
|
||||
House.AddStrongBox(from);
|
||||
else if (isFriend)
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
else
|
||||
from.SendLocalizedMessage(502094); // You must be in your house to do this.
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
}
|
||||
else if (e.HasKeyword(0x28)) // trash barrel
|
||||
{
|
||||
if (isCoOwner)
|
||||
House.AddTrashBarrel(from);
|
||||
else if (isFriend)
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
else
|
||||
from.SendLocalizedMessage(502094); // You must be in your house to do this.
|
||||
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnDoubleClick(Mobile from, object o)
|
||||
{
|
||||
if (o is Container)
|
||||
if (o is Container c)
|
||||
{
|
||||
Container c = (Container)o;
|
||||
|
||||
SecureAccessResult res = House.CheckSecureAccess(from, c);
|
||||
|
||||
switch (res)
|
||||
|
|
@ -383,10 +361,8 @@ namespace Server.Regions
|
|||
|
||||
public override bool OnSingleClick(Mobile from, object o)
|
||||
{
|
||||
if (o is Item)
|
||||
if (o is Item item)
|
||||
{
|
||||
Item item = (Item)o;
|
||||
|
||||
if (House.HasLockedDownItem(item))
|
||||
item.LabelTo(from, 501643); // [locked down]
|
||||
else if (House.HasSecureItem(item))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Server.Regions
|
|||
if (!Region.ReadString(xml, "name", ref group))
|
||||
return null;
|
||||
|
||||
SpawnDefinition def = (SpawnDefinition)SpawnGroup.Table[group];
|
||||
SpawnDefinition def = SpawnGroup.Table[@group];
|
||||
|
||||
if (def == null)
|
||||
{
|
||||
|
|
@ -121,12 +121,12 @@ namespace Server.Regions
|
|||
|
||||
public class SpawnMobile : SpawnType
|
||||
{
|
||||
private static Hashtable m_Table = new Hashtable();
|
||||
private static Dictionary<Type, SpawnMobile> m_Table = new Dictionary<Type, SpawnMobile>();
|
||||
|
||||
protected bool m_Land;
|
||||
protected bool m_Water;
|
||||
private bool m_Land;
|
||||
private bool m_Water;
|
||||
|
||||
protected SpawnMobile(Type type) : base(type)
|
||||
public SpawnMobile(Type type) : base(type)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -152,13 +152,10 @@ namespace Server.Regions
|
|||
|
||||
public static SpawnMobile Get(Type type)
|
||||
{
|
||||
SpawnMobile sm = (SpawnMobile)m_Table[type];
|
||||
SpawnMobile sm = m_Table[type];
|
||||
|
||||
if (sm == null)
|
||||
{
|
||||
sm = new SpawnMobile(type);
|
||||
m_Table[type] = sm;
|
||||
}
|
||||
m_Table[type] = sm = new SpawnMobile(type);
|
||||
|
||||
return sm;
|
||||
}
|
||||
|
|
@ -177,9 +174,7 @@ namespace Server.Regions
|
|||
{
|
||||
Mobile mobile = CreateMobile();
|
||||
|
||||
BaseCreature creature = mobile as BaseCreature;
|
||||
|
||||
if (creature != null)
|
||||
if (mobile is BaseCreature creature)
|
||||
{
|
||||
creature.Home = entry.HomeLocation;
|
||||
creature.HomeMap = map;
|
||||
|
|
@ -204,7 +199,7 @@ namespace Server.Regions
|
|||
|
||||
public class SpawnItem : SpawnType
|
||||
{
|
||||
private static Hashtable m_Table = new Hashtable();
|
||||
private static Dictionary<Type, SpawnItem> m_Table = new Dictionary<Type, SpawnItem>();
|
||||
|
||||
protected int m_Height;
|
||||
|
||||
|
|
@ -226,13 +221,10 @@ namespace Server.Regions
|
|||
|
||||
public static SpawnItem Get(Type type)
|
||||
{
|
||||
SpawnItem si = (SpawnItem)m_Table[type];
|
||||
SpawnItem si = m_Table[type];
|
||||
|
||||
if (si == null)
|
||||
{
|
||||
si = new SpawnItem(type);
|
||||
m_Table[type] = si;
|
||||
}
|
||||
m_Table[type] = si = new SpawnItem(type);
|
||||
|
||||
return si;
|
||||
}
|
||||
|
|
@ -327,9 +319,7 @@ namespace Server.Regions
|
|||
List<SpawnGroupElement> list = new List<SpawnGroupElement>();
|
||||
foreach (XmlNode node in xmlDef.ChildNodes)
|
||||
{
|
||||
XmlElement el = node as XmlElement;
|
||||
|
||||
if (el != null)
|
||||
if (node is XmlElement el)
|
||||
{
|
||||
SpawnDefinition def = GetSpawnDefinition(el);
|
||||
if (def == null)
|
||||
|
|
@ -364,7 +354,7 @@ namespace Server.Regions
|
|||
m_TotalWeight += elements[i].Weight;
|
||||
}
|
||||
|
||||
public static Hashtable Table{ get; } = new Hashtable();
|
||||
public static Dictionary<string, SpawnGroup> Table{ get; } = new Dictionary<string, SpawnGroup>();
|
||||
|
||||
public string Name{ get; }
|
||||
|
||||
|
|
@ -372,7 +362,7 @@ namespace Server.Regions
|
|||
|
||||
public static void Register(SpawnGroup group)
|
||||
{
|
||||
if (Table.Contains(group.Name))
|
||||
if (Table.ContainsKey(group.Name))
|
||||
Console.WriteLine("Warning: Double SpawnGroup name '{0}'", group.Name);
|
||||
else
|
||||
Table[group.Name] = group;
|
||||
|
|
@ -404,4 +394,4 @@ namespace Server.Regions
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ namespace Server.Regions
|
|||
MaxSpawnTime = maxSpawnTime;
|
||||
Running = false;
|
||||
|
||||
if (Table.Contains(id))
|
||||
if (Table.ContainsKey(id))
|
||||
Console.WriteLine("Warning: double SpawnEntry ID '{0}'", id);
|
||||
else
|
||||
Table[id] = this;
|
||||
}
|
||||
|
||||
public static Hashtable Table{ get; } = new Hashtable();
|
||||
public static Dictionary<int, SpawnEntry> Table{ get; } = new Dictionary<int, SpawnEntry>();
|
||||
|
||||
|
||||
// When a creature's AI is deactivated (PlayerRangeSensitive optimization) does it return home?
|
||||
|
|
@ -122,8 +122,8 @@ namespace Server.Regions
|
|||
|
||||
spawn.Spawner = this;
|
||||
|
||||
if (spawn is BaseCreature)
|
||||
((BaseCreature)spawn).RemoveIfUntamed = RemoveIfUntamed;
|
||||
if (spawn is BaseCreature creature)
|
||||
creature.RemoveIfUntamed = RemoveIfUntamed;
|
||||
}
|
||||
|
||||
private TimeSpan RandomTime()
|
||||
|
|
@ -218,13 +218,7 @@ namespace Server.Regions
|
|||
writer.Write(SpawnedObjects.Count);
|
||||
|
||||
for (int i = 0; i < SpawnedObjects.Count; i++)
|
||||
{
|
||||
ISpawnable spawn = SpawnedObjects[i];
|
||||
|
||||
int serial = spawn.Serial;
|
||||
|
||||
writer.Write(serial);
|
||||
}
|
||||
writer.Write(SpawnedObjects[i].Serial);
|
||||
|
||||
writer.Write(Running);
|
||||
|
||||
|
|
@ -245,10 +239,7 @@ namespace Server.Regions
|
|||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int serial = reader.ReadInt();
|
||||
ISpawnable spawnableEntity = World.FindEntity(serial) as ISpawnable;
|
||||
|
||||
if (spawnableEntity != null)
|
||||
if (World.FindEntity(reader.ReadUInt()) is ISpawnable spawnableEntity)
|
||||
Add(spawnableEntity);
|
||||
}
|
||||
|
||||
|
|
@ -276,8 +267,7 @@ namespace Server.Regions
|
|||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int serial = reader.ReadInt();
|
||||
IEntity entity = World.FindEntity(serial);
|
||||
IEntity entity = World.FindEntity(reader.ReadUInt());
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
|
|
@ -442,4 +432,4 @@ namespace Server.Regions
|
|||
args.Mobile.SendMessage("Spawners of region '{0}' have stopped.", region);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue