Formatting FIxes (#58)

This commit is contained in:
Kamron Batman 2019-10-04 23:08:13 -07:00 committed by GitHub
parent 57fb9fb525
commit 096d39609e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1318 changed files with 11633 additions and 22129 deletions

View file

@ -24,32 +24,19 @@ namespace Server
}
}
public static int Damage(Mobile m, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, null, damage, ignoreArmor, phys, fire, cold, pois, nrgy);
}
public static int Damage(Mobile m, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy) => Damage(m, null, damage, ignoreArmor, phys, fire, cold, pois, nrgy);
public static int Damage(Mobile m, int damage, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, null, damage, phys, fire, cold, pois, nrgy);
}
public static int Damage(Mobile m, int damage, int phys, int fire, int cold, int pois, int nrgy) => Damage(m, null, damage, phys, fire, cold, pois, nrgy);
public static int Damage(Mobile m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy);
}
public static int Damage(Mobile m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy) => Damage(m, from, damage, false, phys, fire, cold, pois, nrgy);
public static int Damage(Mobile m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy,
int chaos)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, chaos);
}
int chaos) =>
Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, chaos);
public static int Damage(Mobile m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy,
bool keepAlive)
{
return Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, 0, 0, keepAlive);
}
bool keepAlive) =>
Damage(m, from, damage, false, phys, fire, cold, pois, nrgy, 0, 0, keepAlive);
public static int Damage(Mobile m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois,
int nrgy, int chaos = 0, int direct = 0, bool keepAlive = false, bool archer = false, bool deathStrike = false)
@ -203,10 +190,7 @@ namespace Server
val = 0;
}
public static int Scale(int input, int percent)
{
return input * percent / 100;
}
public static int Scale(int input, int percent) => input * percent / 100;
public static int GetStatus(Mobile from, int index)
{
@ -525,10 +509,7 @@ namespace Server
return value;
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
public void AddStatBonuses(Mobile to)
{
@ -824,10 +805,7 @@ namespace Server
return value;
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
}
[Flags]
@ -921,10 +899,7 @@ namespace Server
return value;
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
}
public sealed class AosSkillBonuses : BaseAttributes
@ -1140,10 +1115,7 @@ namespace Server
SetValues(index, GetSkill(index), bonus);
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
public void CheckCancelMorph(Mobile m)
{
@ -1279,10 +1251,7 @@ namespace Server
set => this[AosElementAttribute.Direct] = value;
}
public override string ToString()
{
return "...";
}
public override string ToString() => "...";
}
[PropertyObject]

View file

@ -16,10 +16,7 @@ namespace Server.Misc
"Most Recent"
};
public AutoSave() : base(m_Delay - m_Warning, m_Delay)
{
Priority = TimerPriority.OneMinute;
}
public AutoSave() : base(m_Delay - m_Warning, m_Delay) => Priority = TimerPriority.OneMinute;
public static bool SavesEnabled{ get; set; } = true;
//private static TimeSpan m_Warning = TimeSpan.FromSeconds( 15.0 );
@ -161,10 +158,7 @@ namespace Server.Misc
return null;
}
private static string FormatDirectory(string root, string name, string timeStamp)
{
return Path.Combine(root, $"{name} ({timeStamp})");
}
private static string FormatDirectory(string root, string name, string timeStamp) => Path.Combine(root, $"{name} ({timeStamp})");
private static string FindTimeStamp(string input)
{

View file

@ -80,10 +80,8 @@ namespace Server
}
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args)
: this(iconID, titleCliloc, secondaryCliloc)
{
: this(iconID, titleCliloc, secondaryCliloc) =>
Args = args;
}
public BuffInfo(BuffIcon iconID, int titleCliloc, bool retainThroughDeath)
: this(iconID, titleCliloc, titleCliloc + 1, retainThroughDeath)
@ -91,10 +89,8 @@ namespace Server
}
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, bool retainThroughDeath)
: this(iconID, titleCliloc, secondaryCliloc)
{
: this(iconID, titleCliloc, secondaryCliloc) =>
RetainThroughDeath = retainThroughDeath;
}
public BuffInfo(BuffIcon iconID, int titleCliloc, TextDefinition args, bool retainThroughDeath)
: this(iconID, titleCliloc, titleCliloc + 1, args, retainThroughDeath)
@ -102,10 +98,8 @@ namespace Server
}
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args, bool retainThroughDeath)
: this(iconID, titleCliloc, secondaryCliloc, args)
{
: this(iconID, titleCliloc, secondaryCliloc, args) =>
RetainThroughDeath = retainThroughDeath;
}
public BuffInfo(BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m, TextDefinition args)
: this(iconID, titleCliloc, titleCliloc + 1, length, m, args)
@ -114,10 +108,8 @@ namespace Server
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m,
TextDefinition args)
: this(iconID, titleCliloc, secondaryCliloc, length, m)
{
: this(iconID, titleCliloc, secondaryCliloc, length, m) =>
Args = args;
}
public BuffInfo(BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m, TextDefinition args,
bool retainThroughDeath)

View file

@ -407,25 +407,13 @@ namespace Server
return false;
}
public static bool IsNorthFrame(int id)
{
return IsFrame(id, m_NorthFrames);
}
public static bool IsNorthFrame(int id) => IsFrame(id, m_NorthFrames);
public static bool IsSouthFrame(int id)
{
return IsFrame(id, m_SouthFrames);
}
public static bool IsSouthFrame(int id) => IsFrame(id, m_SouthFrames);
public static bool IsWestFrame(int id)
{
return IsFrame(id, m_WestFrames);
}
public static bool IsWestFrame(int id) => IsFrame(id, m_WestFrames);
public static bool IsEastFrame(int id)
{
return IsFrame(id, m_EastFrames);
}
public static bool IsEastFrame(int id) => IsFrame(id, m_EastFrames);
public static bool IsEastFrame(int x, int y, int z)
{

File diff suppressed because it is too large Load diff

View file

@ -5,10 +5,7 @@ namespace Server.Misc
{
public class FoodDecayTimer : Timer
{
public FoodDecayTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5))
{
Priority = TimerPriority.OneMinute;
}
public FoodDecayTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)) => Priority = TimerPriority.OneMinute;
public static void Initialize()
{

View file

@ -13,15 +13,9 @@ namespace Server.Misc
b = temp;
}
public static double RadiansToDegrees(double angle)
{
return angle * (180.0 / Math.PI);
}
public static double RadiansToDegrees(double angle) => angle * (180.0 / Math.PI);
public static double DegreesToRadians(double angle)
{
return angle * (Math.PI / 180.0);
}
public static double DegreesToRadians(double angle) => angle * (Math.PI / 180.0);
public static Point2D ArcPoint(Point3D loc, int radius, int angle)
{

View file

@ -80,10 +80,7 @@ namespace Server.Items
{
private Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0))
{
m_From = from;
}
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0)) => m_From = from;
protected override void OnTick()
{

View file

@ -66,10 +66,7 @@ namespace Server.Items
{
private Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0))
{
m_From = from;
}
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0)) => m_From = from;
protected override void OnTick()
{

View file

@ -61,10 +61,7 @@ namespace Server.Guilds
public RankFlags Flags{ get; private set; }
public bool GetFlag(RankFlags flag)
{
return (Flags & flag) != 0;
}
public bool GetFlag(RankFlags flag) => (Flags & flag) != 0;
public void SetFlag(RankFlags flag, bool value)
{
@ -267,25 +264,19 @@ namespace Server.Guilds
private AllianceInfo m_Alliance;
public AllianceRosterGump(PlayerMobile pm, Guild g, AllianceInfo alliance) : base(pm, g, true, "", 0,
alliance.m_Members, alliance.Name)
{
alliance.m_Members, alliance.Name) =>
m_Alliance = alliance;
}
public AllianceRosterGump(PlayerMobile pm, Guild g, AllianceInfo alliance, IComparer<Guild> currentComparer,
bool ascending, string filter, int startNumber) : base(pm, g, currentComparer, ascending, filter,
startNumber, alliance.m_Members, alliance.Name)
{
startNumber, alliance.m_Members, alliance.Name) =>
m_Alliance = alliance;
}
protected override bool AllowAdvancedSearch => false;
public override Gump GetResentGump(PlayerMobile pm, Guild g, IComparer<Guild> comparer, bool ascending,
string filter, int startNumber)
{
return new AllianceRosterGump(pm, g, m_Alliance, comparer, ascending, filter, startNumber);
}
string filter, int startNumber) =>
new AllianceRosterGump(pm, g, m_Alliance, comparer, ascending, filter, startNumber);
public override void OnResponse(NetState sender, RelayInfo info)
{
@ -498,10 +489,7 @@ namespace Server.Guilds
{
private static TimeSpan InternalDelay = TimeSpan.FromMinutes(1.0);
public WarTimer() : base(InternalDelay, InternalDelay)
{
Priority = TimerPriority.FiveSeconds;
}
public WarTimer() : base(InternalDelay, InternalDelay) => Priority = TimerPriority.FiveSeconds;
public static void Initialize()
{
@ -989,20 +977,11 @@ namespace Server.Guilds
#region Is<something>(...)
public bool IsMember(Mobile m)
{
return Members.Contains(m);
}
public bool IsMember(Mobile m) => Members.Contains(m);
public bool IsAlly(Guild g)
{
return NewGuildSystem ? Alliance?.IsMember(this) == true && Alliance.IsMember(g) : Allies.Contains(g);
}
public bool IsAlly(Guild g) => NewGuildSystem ? Alliance?.IsMember(this) == true && Alliance.IsMember(g) : Allies.Contains(g);
public bool IsEnemy(Guild g)
{
return Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type || IsWar(g);
}
public bool IsEnemy(Guild g) => Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type || IsWar(g);
public bool IsWar(Guild g)
{
@ -1385,16 +1364,11 @@ namespace Server.Guilds
#region Voting
public bool CanVote(Mobile m)
{
return (!NewGuildSystem || m is PlayerMobile pm && pm.GuildRank.GetFlag(RankFlags.CanVote)) &&
m?.Deleted == false && m.Guild == this;
}
public bool CanVote(Mobile m) =>
(!NewGuildSystem || m is PlayerMobile pm && pm.GuildRank.GetFlag(RankFlags.CanVote)) &&
m?.Deleted == false && m.Guild == this;
public bool CanBeVotedFor(Mobile m)
{
return (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow) && m?.Deleted == false && m.Guild == this;
}
public bool CanBeVotedFor(Mobile m) => (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow) && m?.Deleted == false && m.Guild == this;
public void CalculateGuildmaster()
{

File diff suppressed because it is too large Load diff

View file

@ -189,60 +189,58 @@ namespace Server.Misc
{
Dictionary<string, InternationalCodeCounter> ht = new Dictionary<string, InternationalCodeCounter>();
using (StreamWriter writer = new StreamWriter("languages.txt"))
{
if (CountAccounts)
foreach (Account acc in Accounts.GetAccounts())
for (int i = 0; i < acc.Length; i++)
{
Mobile mob = acc[i];
using StreamWriter writer = new StreamWriter("languages.txt");
if (CountAccounts)
foreach (Account acc in Accounts.GetAccounts())
for (int i = 0; i < acc.Length; i++)
{
Mobile mob = acc[i];
string lang = mob?.Language;
string lang = mob?.Language;
if (lang == null)
continue;
if (lang == null)
continue;
lang = lang.ToUpper();
lang = lang.ToUpper();
if (ht.TryGetValue(lang, out InternationalCodeCounter codes))
codes.Increase();
else
ht[lang] = new InternationalCodeCounter(lang);
if (ht.TryGetValue(lang, out InternationalCodeCounter codes))
codes.Increase();
else
ht[lang] = new InternationalCodeCounter(lang);
break;
}
else
foreach (Mobile mob in World.Mobiles.Values)
if (mob.Player)
{
string lang = mob.Language;
break;
}
else
foreach (Mobile mob in World.Mobiles.Values)
if (mob.Player)
{
string lang = mob.Language;
if (lang == null)
continue;
if (lang == null)
continue;
lang = lang.ToUpper();
lang = lang.ToUpper();
if (ht.TryGetValue(lang, out InternationalCodeCounter codes))
codes.Increase();
else
ht[lang] = new InternationalCodeCounter(lang);
}
if (ht.TryGetValue(lang, out InternationalCodeCounter codes))
codes.Increase();
else
ht[lang] = new InternationalCodeCounter(lang);
}
writer.WriteLine(
$"Language statistics. Numbers show how many {(CountAccounts ? "accounts" : "playermobile")} use the specified language.");
writer.WriteLine(
"====================================================================================================");
writer.WriteLine();
writer.WriteLine(
$"Language statistics. Numbers show how many {(CountAccounts ? "accounts" : "playermobile")} use the specified language.");
writer.WriteLine(
"====================================================================================================");
writer.WriteLine();
// sort the list
List<InternationalCodeCounter> list = new List<InternationalCodeCounter>(ht.Values);
list.Sort(InternationalCodeComparer.Instance);
// sort the list
List<InternationalCodeCounter> list = new List<InternationalCodeCounter>(ht.Values);
list.Sort(InternationalCodeComparer.Instance);
foreach (InternationalCodeCounter c in list)
writer.WriteLine($"{GetFormattedInfo(c.Code)} : {c.Count}");
foreach (InternationalCodeCounter c in list)
writer.WriteLine($"{GetFormattedInfo(c.Code)} : {c.Count}");
e.Mobile.SendMessage("Languages list generated.");
}
e.Mobile.SendMessage("Languages list generated.");
}
private struct InternationalCode
@ -260,10 +258,8 @@ namespace Server.Misc
public string Country_LocalName{ get; }
public InternationalCode(string code, string language, string country) : this(code, language, country, null,
null)
{
null) =>
m_HasLocalInfo = false;
}
public InternationalCode(string code, string language, string country, string language_localname,
string country_localname)

View file

@ -99,10 +99,7 @@ namespace Server
private class LightCycleTimer : Timer
{
public LightCycleTimer() : base(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(5.0))
{
Priority = TimerPriority.FiveSeconds;
}
public LightCycleTimer() : base(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(5.0)) => Priority = TimerPriority.FiveSeconds;
protected override void OnTick()
{

View file

@ -359,10 +359,7 @@ namespace Server
return Construct(OldWandTypes, WandTypes, NewWandTypes) as BaseWand;
}
public static BaseClothing RandomClothing()
{
return RandomClothing(false, false);
}
public static BaseClothing RandomClothing() => RandomClothing(false, false);
public static BaseClothing RandomClothing(bool inTokuno, bool isMondain)
{
@ -382,10 +379,7 @@ namespace Server
return Construct(ClothingTypes) as BaseClothing;
}
public static BaseWeapon RandomRangedWeapon()
{
return RandomRangedWeapon(false, false);
}
public static BaseWeapon RandomRangedWeapon() => RandomRangedWeapon(false, false);
public static BaseWeapon RandomRangedWeapon(bool inTokuno, bool isMondain)
{
@ -405,10 +399,7 @@ namespace Server
return Construct(RangedWeaponTypes) as BaseWeapon;
}
public static BaseWeapon RandomWeapon()
{
return RandomWeapon(false, false);
}
public static BaseWeapon RandomWeapon() => RandomWeapon(false, false);
public static BaseWeapon RandomWeapon(bool inTokuno, bool isMondain)
{
@ -428,10 +419,7 @@ namespace Server
return Construct(WeaponTypes) as BaseWeapon;
}
public static Item RandomWeaponOrJewelry()
{
return RandomWeaponOrJewelry(false, false);
}
public static Item RandomWeaponOrJewelry() => RandomWeaponOrJewelry(false, false);
public static Item RandomWeaponOrJewelry(bool inTokuno, bool isMondain)
{
@ -451,15 +439,9 @@ namespace Server
return Construct(WeaponTypes, JewelryTypes);
}
public static BaseJewel RandomJewelry()
{
return Construct(JewelryTypes) as BaseJewel;
}
public static BaseJewel RandomJewelry() => Construct(JewelryTypes) as BaseJewel;
public static BaseArmor RandomArmor()
{
return RandomArmor(false, false);
}
public static BaseArmor RandomArmor() => RandomArmor(false, false);
public static BaseArmor RandomArmor(bool inTokuno, bool isMondain)
{
@ -476,10 +458,7 @@ namespace Server
return Construct(ArmorTypes) as BaseArmor;
}
public static BaseHat RandomHat()
{
return RandomHat(false);
}
public static BaseHat RandomHat() => RandomHat(false);
public static BaseHat RandomHat(bool inTokuno)
{
@ -492,10 +471,7 @@ namespace Server
return Construct(HatTypes) as BaseHat;
}
public static Item RandomArmorOrHat()
{
return RandomArmorOrHat(false, false);
}
public static Item RandomArmorOrHat() => RandomArmorOrHat(false, false);
public static Item RandomArmorOrHat(bool inTokuno, bool isMondain)
{
@ -523,10 +499,7 @@ namespace Server
return Construct(ShieldTypes) as BaseShield;
}
public static BaseArmor RandomArmorOrShield()
{
return RandomArmorOrShield(false, false);
}
public static BaseArmor RandomArmorOrShield() => RandomArmorOrShield(false, false);
public static BaseArmor RandomArmorOrShield(bool inTokuno, bool isMondain)
{
@ -546,10 +519,7 @@ namespace Server
return Construct(ArmorTypes, ShieldTypes) as BaseArmor;
}
public static Item RandomArmorOrShieldOrJewelry()
{
return RandomArmorOrShieldOrJewelry(false, false);
}
public static Item RandomArmorOrShieldOrJewelry() => RandomArmorOrShieldOrJewelry(false, false);
public static Item RandomArmorOrShieldOrJewelry(bool inTokuno, bool isMondain)
{
@ -570,10 +540,7 @@ namespace Server
return Construct(ArmorTypes, HatTypes, ShieldTypes, JewelryTypes);
}
public static Item RandomArmorOrShieldOrWeapon()
{
return RandomArmorOrShieldOrWeapon(false, false);
}
public static Item RandomArmorOrShieldOrWeapon() => RandomArmorOrShieldOrWeapon(false, false);
public static Item RandomArmorOrShieldOrWeapon(bool inTokuno, bool isMondain)
{
@ -597,10 +564,7 @@ namespace Server
return Construct(WeaponTypes, RangedWeaponTypes, ArmorTypes, HatTypes, ShieldTypes);
}
public static Item RandomArmorOrShieldOrWeaponOrJewelry()
{
return RandomArmorOrShieldOrWeaponOrJewelry(false, false);
}
public static Item RandomArmorOrShieldOrWeaponOrJewelry() => RandomArmorOrShieldOrWeaponOrJewelry(false, false);
public static Item RandomArmorOrShieldOrWeaponOrJewelry(bool inTokuno, bool isMondain)
{
@ -627,27 +591,15 @@ namespace Server
#region Chest of Heirlooms
public static Item ChestOfHeirloomsContains()
{
return Construct(SEArmorTypes, SEHatTypes, SEWeaponTypes, SERangedWeaponTypes, JewelryTypes);
}
public static Item ChestOfHeirloomsContains() => Construct(SEArmorTypes, SEHatTypes, SEWeaponTypes, SERangedWeaponTypes, JewelryTypes);
#endregion
public static Item RandomGem()
{
return Construct(GemTypes);
}
public static Item RandomGem() => Construct(GemTypes);
public static Item RandomReagent()
{
return Construct(RegTypes);
}
public static Item RandomReagent() => Construct(RegTypes);
public static Item RandomNecromancyReagent()
{
return Construct(NecroRegTypes);
}
public static Item RandomNecromancyReagent() => Construct(NecroRegTypes);
public static Item RandomPossibleReagent()
{
@ -657,10 +609,7 @@ namespace Server
return Construct(RegTypes);
}
public static Item RandomPotion()
{
return Construct(PotionTypes);
}
public static Item RandomPotion() => Construct(PotionTypes);
public static BaseInstrument RandomInstrument()
{
@ -670,10 +619,7 @@ namespace Server
return Construct(InstrumentTypes) as BaseInstrument;
}
public static Item RandomStatue()
{
return Construct(StatueTypes);
}
public static Item RandomStatue() => Construct(StatueTypes);
public static SpellScroll RandomScroll(int minIndex, int maxIndex, SpellbookType type)
{
@ -699,25 +645,13 @@ namespace Server
return Construct(types, Utility.RandomMinMax(minIndex, maxIndex)) as SpellScroll;
}
public static BaseBook RandomGrimmochJournal()
{
return Construct(GrimmochJournalTypes) as BaseBook;
}
public static BaseBook RandomGrimmochJournal() => Construct(GrimmochJournalTypes) as BaseBook;
public static BaseBook RandomLysanderNotebook()
{
return Construct(LysanderNotebookTypes) as BaseBook;
}
public static BaseBook RandomLysanderNotebook() => Construct(LysanderNotebookTypes) as BaseBook;
public static BaseBook RandomTavarasJournal()
{
return Construct(TavarasJournalTypes) as BaseBook;
}
public static BaseBook RandomTavarasJournal() => Construct(TavarasJournalTypes) as BaseBook;
public static BaseBook RandomLibraryBook()
{
return Construct(LibraryBookTypes) as BaseBook;
}
public static BaseBook RandomLibraryBook() => Construct(LibraryBookTypes) as BaseBook;
public static BaseTalisman RandomTalisman()
{

View file

@ -88,10 +88,7 @@ namespace Server
private LootPackEntry[] m_Entries;
public LootPack(LootPackEntry[] entries)
{
m_Entries = entries;
}
public LootPack(LootPackEntry[] entries) => m_Entries = entries;
public static int GetLuckChance(Mobile killer, Mobile victim)
{
@ -133,10 +130,7 @@ namespace Server
return GetLuckChance(highest.m_Mobile, dead);
}
public static bool CheckLuck(int chance)
{
return chance > Utility.Random(10000);
}
public static bool CheckLuck(int chance) => chance > Utility.Random(10000);
public void Generate(Mobile from, Container cont, bool spawning, int luckChance)
{
@ -592,10 +586,7 @@ namespace Server
#region Mondain's Legacy
private static bool IsMondain(Mobile m)
{
return MondainsLegacy.IsMLRegion(m.Region);
}
private static bool IsMondain(Mobile m) => MondainsLegacy.IsMLRegion(m.Region);
#endregion

View file

@ -62,17 +62,15 @@ namespace Server
return false;
}
public static bool IsMLRegion(Region region)
{
return region.IsPartOf("Twisted Weald")
|| region.IsPartOf("Sanctuary")
|| region.IsPartOf("The Prism of Light")
|| region.IsPartOf("The Citadel")
|| region.IsPartOf("Bedlam")
|| region.IsPartOf("Blighted Grove")
|| region.IsPartOf("The Painted Caves")
|| region.IsPartOf("The Palace of Paroxysmus")
|| region.IsPartOf("Labyrinth");
}
public static bool IsMLRegion(Region region) =>
region.IsPartOf("Twisted Weald")
|| region.IsPartOf("Sanctuary")
|| region.IsPartOf("The Prism of Light")
|| region.IsPartOf("The Citadel")
|| region.IsPartOf("Bedlam")
|| region.IsPartOf("Blighted Grove")
|| region.IsPartOf("The Painted Caves")
|| region.IsPartOf("The Palace of Paroxysmus")
|| region.IsPartOf("Labyrinth");
}
}

View file

@ -5,96 +5,93 @@ using System.Xml;
namespace Server
{
public class NameList
{
public string Type { get; }
public class NameList
{
public string Type { get; }
public string[] List { get; }
public string[] List { get; }
public bool ContainsName( string name )
{
for ( int i = 0; i < List.Length; i++ )
if ( name == List[i] )
return true;
public bool ContainsName( string name )
{
for ( int i = 0; i < List.Length; i++ )
if ( name == List[i] )
return true;
return false;
}
return false;
}
public NameList( string type, XmlElement xml )
{
Type = type;
List = xml.InnerText.Split( ',' );
public NameList( string type, XmlElement xml )
{
Type = type;
List = xml.InnerText.Split( ',' );
for ( int i = 0; i < List.Length; ++i )
List[i] = Utility.Intern( List[i].Trim() );
}
for ( int i = 0; i < List.Length; ++i )
List[i] = Utility.Intern( List[i].Trim() );
}
public string GetRandomName()
{
if ( List.Length > 0 )
return List[Utility.Random( List.Length )];
public string GetRandomName()
{
if ( List.Length > 0 )
return List[Utility.Random( List.Length )];
return "";
}
return "";
}
public static NameList GetNameList( string type )
{
m_Table.TryGetValue( type, out NameList n );
return n;
}
public static NameList GetNameList( string type )
{
m_Table.TryGetValue( type, out NameList n );
return n;
}
public static string RandomName( string type )
{
return GetNameList( type )?.GetRandomName() ?? "";
}
public static string RandomName( string type ) => GetNameList( type )?.GetRandomName() ?? "";
private static Dictionary<string, NameList> m_Table;
private static Dictionary<string, NameList> m_Table;
static NameList()
{
m_Table = new Dictionary<string, NameList>( StringComparer.OrdinalIgnoreCase );
static NameList()
{
m_Table = new Dictionary<string, NameList>( StringComparer.OrdinalIgnoreCase );
string filePath = Path.Combine( Core.BaseDirectory, "Data/names.xml" );
string filePath = Path.Combine( Core.BaseDirectory, "Data/names.xml" );
if ( !File.Exists( filePath ) )
return;
if ( !File.Exists( filePath ) )
return;
try
{
Load( filePath );
}
catch ( Exception e )
{
Console.WriteLine( "Warning: Exception caught loading name lists:" );
Console.WriteLine( e );
}
}
try
{
Load( filePath );
}
catch ( Exception e )
{
Console.WriteLine( "Warning: Exception caught loading name lists:" );
Console.WriteLine( e );
}
}
private static void Load( string filePath )
{
XmlDocument doc = new XmlDocument();
doc.Load( filePath );
private static void Load( string filePath )
{
XmlDocument doc = new XmlDocument();
doc.Load( filePath );
XmlElement root = doc["names"];
XmlElement root = doc["names"];
foreach ( XmlElement element in root.GetElementsByTagName( "namelist" ) )
{
string type = element.GetAttribute( "type" );
foreach ( XmlElement element in root.GetElementsByTagName( "namelist" ) )
{
string type = element.GetAttribute( "type" );
if ( string.IsNullOrEmpty( type ) )
continue;
if ( string.IsNullOrEmpty( type ) )
continue;
try
{
NameList list = new NameList( type, element );
try
{
NameList list = new NameList( type, element );
m_Table[type] = list;
}
m_Table[type] = list;
}
catch
{
// ignored
}
}
}
}
}
}
}

View file

@ -116,11 +116,9 @@ namespace Server.Misc
}
public static bool Validate(string name, int minLength, int maxLength, bool allowLetters, bool allowDigits,
bool noExceptionsAtStart, int maxExceptions, char[] exceptions)
{
return Validate(name, minLength, maxLength, allowLetters, allowDigits, noExceptionsAtStart, maxExceptions,
bool noExceptionsAtStart, int maxExceptions, char[] exceptions) =>
Validate(name, minLength, maxLength, allowLetters, allowDigits, noExceptionsAtStart, maxExceptions,
exceptions, Disallowed, StartDisallowed);
}
public static bool Validate(string name, int minLength, int maxLength, bool allowLetters, bool allowDigits,
bool noExceptionsAtStart, int maxExceptions, char[] exceptions, string[] disallowed, string[] startDisallowed)

View file

@ -426,15 +426,9 @@ namespace Server.Misc
!house.IsFriend(c.ControlMaster);
}
public static bool IsPet(BaseCreature c)
{
return c?.Controlled == true;
}
public static bool IsPet(BaseCreature c) => c?.Controlled == true;
public static bool IsSummoned(BaseCreature c)
{
return c?.Summoned == true;
}
public static bool IsSummoned(BaseCreature c) => c?.Summoned == true;
public static bool CheckAggressor(List<AggressorInfo> list, Mobile target)
{

View file

@ -68,10 +68,7 @@ namespace Server
return newPoison ?? oldPoison;
}
public override Timer ConstructTimer(Mobile m)
{
return new PoisonTimer(m, this);
}
public override Timer ConstructTimer(Mobile m) => new PoisonTimer(m, this);
public class PoisonTimer : Timer
{

View file

@ -99,10 +99,7 @@ namespace Server.Misc
return hue;
}
public override int RandomSkinHue()
{
return Utility.Random(1002, 57) | 0x8000;
}
public override int RandomSkinHue() => Utility.Random(1002, 57) | 0x8000;
public override int ClipHairHue(int hue)
{
@ -113,10 +110,7 @@ namespace Server.Misc
return hue;
}
public override int RandomHairHue()
{
return Utility.Random(1102, 48);
}
public override int RandomHairHue() => Utility.Random(1102, 48);
}
private class Elf : Race
@ -177,15 +171,9 @@ namespace Server.Misc
}
}
public override bool ValidateFacialHair(bool female, int itemID)
{
return itemID == 0;
}
public override bool ValidateFacialHair(bool female, int itemID) => itemID == 0;
public override int RandomFacialHair(bool female)
{
return 0;
}
public override int RandomFacialHair(bool female) => 0;
public override int ClipSkinHue(int hue)
{
@ -196,10 +184,7 @@ namespace Server.Misc
return m_SkinHues[0];
}
public override int RandomSkinHue()
{
return m_SkinHues[Utility.Random(m_SkinHues.Length)] | 0x8000;
}
public override int RandomSkinHue() => m_SkinHues[Utility.Random(m_SkinHues.Length)] | 0x8000;
public override int ClipHairHue(int hue)
{
@ -210,10 +195,7 @@ namespace Server.Misc
return m_HairHues[0];
}
public override int RandomHairHue()
{
return m_HairHues[Utility.Random(m_HairHues.Length)];
}
public override int RandomHairHue() => m_HairHues[Utility.Random(m_HairHues.Length)];
}
#region SA
@ -282,25 +264,13 @@ namespace Server.Misc
return 0;
}
public override bool ValidateFacialHair(bool female, int itemID)
{
return !female && itemID >= 0x42AD && itemID <= 0x42B0;
}
public override bool ValidateFacialHair(bool female, int itemID) => !female && itemID >= 0x42AD && itemID <= 0x42B0;
public override int RandomFacialHair(bool female)
{
return female ? 0 : Utility.RandomList(0, 0x42AD, 0x42AE, 0x42AF, 0x42B0);
}
public override int RandomFacialHair(bool female) => female ? 0 : Utility.RandomList(0, 0x42AD, 0x42AE, 0x42AF, 0x42B0);
public override int ClipSkinHue(int hue)
{
return hue; // for hue information gathering
}
public override int ClipSkinHue(int hue) => hue;
public override int RandomSkinHue()
{
return m_BodyHues[Utility.Random(m_BodyHues.Length)] | 0x8000;
}
public override int RandomSkinHue() => m_BodyHues[Utility.Random(m_BodyHues.Length)] | 0x8000;
public override int ClipHairHue(int hue)
{
@ -311,10 +281,7 @@ namespace Server.Misc
return m_HornHues[0];
}
public override int RandomHairHue()
{
return m_HornHues[Utility.Random(m_HornHues.Length)];
}
public override int RandomHairHue() => m_HornHues[Utility.Random(m_HornHues.Length)];
}
#endregion

View file

@ -39,15 +39,9 @@ namespace Server.Misc
m.CheckSkill(skill, n);
}
private static bool CheckTransform(Mobile m, Type type)
{
return TransformationSpellHelper.UnderTransformation(m, type);
}
private static bool CheckTransform(Mobile m, Type type) => TransformationSpellHelper.UnderTransformation(m, type);
private static bool CheckAnimal(Mobile m, Type type)
{
return AnimalForm.UnderTransformation(m, type);
}
private static bool CheckAnimal(Mobile m, Type type) => AnimalForm.UnderTransformation(m, type);
private static TimeSpan Mobile_HitsRegenRate(Mobile from)
{

File diff suppressed because it is too large Load diff

View file

@ -471,15 +471,9 @@ namespace Server.Misc
m_Polls.Enqueue(poller);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
public override void OnResponse(NetState sender, RelayInfo info)
{

View file

@ -8,20 +8,11 @@ namespace Server
private static int[] m_Table;
public static int Lookup(Mobile m)
{
return Lookup(m.Body.BodyID, DefaultItemID);
}
public static int Lookup(Mobile m) => Lookup(m.Body.BodyID, DefaultItemID);
public static int Lookup(int body)
{
return Lookup(body, DefaultItemID);
}
public static int Lookup(int body) => Lookup(body, DefaultItemID);
public static int Lookup(Mobile m, int defaultValue)
{
return Lookup(m.Body.BodyID, defaultValue);
}
public static int Lookup(Mobile m, int defaultValue) => Lookup(m.Body.BodyID, defaultValue);
public static int Lookup(int body, int defaultValue)
{
@ -51,35 +42,33 @@ namespace Server
m_Table = new int[1000];
using (StreamReader ip = new StreamReader(path))
using StreamReader ip = new StreamReader(path);
string line;
while ((line = ip.ReadLine()) != null)
{
string line;
line = line.Trim();
while ((line = ip.ReadLine()) != null)
if (line.Length == 0 || line.StartsWith("#"))
continue;
try
{
line = line.Trim();
string[] split = line.Split('\t');
if (line.Length == 0 || line.StartsWith("#"))
continue;
try
if (split.Length >= 2)
{
string[] split = line.Split('\t');
int body = Utility.ToInt32(split[0]);
int item = Utility.ToInt32(split[1]);
if (split.Length >= 2)
{
int body = Utility.ToInt32(split[0]);
int item = Utility.ToInt32(split[1]);
if (body >= 0 && body < m_Table.Length)
m_Table[body] = item;
}
}
catch
{
// ignored
if (body >= 0 && body < m_Table.Length)
m_Table[body] = item;
}
}
catch
{
// ignored
}
}
}
}

View file

@ -25,16 +25,11 @@ namespace Server
public override string ToString() => Number > 0 ? $"#{Number}" : String ?? "";
public string Format(bool propsGump)
{
return Number > 0 ? $"{Number} (0x{Number:X})" :
String != null ? $"\"{String}\"" : propsGump ? "-empty-" : "empty";
}
public string Format(bool propsGump) =>
Number > 0 ? $"{Number} (0x{Number:X})" :
String != null ? $"\"{String}\"" : propsGump ? "-empty-" : "empty";
public string GetValue()
{
return Number > 0 ? Number.ToString() : String ?? "";
}
public string GetValue() => Number > 0 ? Number.ToString() : String ?? "";
public static void Serialize(GenericWriter writer, TextDefinition def)
{
@ -83,25 +78,13 @@ namespace Server
list.Add(def.String);
}
public static implicit operator TextDefinition(int v)
{
return new TextDefinition(v);
}
public static implicit operator TextDefinition(int v) => new TextDefinition(v);
public static implicit operator TextDefinition(string s)
{
return new TextDefinition(s);
}
public static implicit operator TextDefinition(string s) => new TextDefinition(s);
public static implicit operator int(TextDefinition m)
{
return m?.Number ?? 0;
}
public static implicit operator int(TextDefinition m) => m?.Number ?? 0;
public static implicit operator string(TextDefinition m)
{
return m?.String;
}
public static implicit operator string(TextDefinition m) => m?.String;
public static void AddHtmlText(Gump g, int x, int y, int width, int height, TextDefinition def, bool back,
bool scroll, int numberColor, int stringColor)
@ -180,9 +163,6 @@ namespace Server
return isInteger ? new TextDefinition(i) : new TextDefinition(value);
}
public static bool IsNullOrEmpty(TextDefinition def)
{
return def == null || def.IsEmpty;
}
public static bool IsNullOrEmpty(TextDefinition def) => def == null || def.IsEmpty;
}
}

View file

@ -357,10 +357,7 @@ namespace Server.Misc
return highest;
}
private static string GetSkillLevel(Skill skill)
{
return m_Levels[GetTableIndex(skill), GetTableType(skill)];
}
private static string GetSkillLevel(Skill skill) => m_Levels[GetTableIndex(skill), GetTableType(skill)];
private static int GetTableType(Skill skill)
{

View file

@ -22,43 +22,40 @@ namespace Server
int i = 0, x = 0, y = 0;
if (File.Exists(filePath))
using (StreamReader ip = new StreamReader(filePath))
{
string line;
{
using StreamReader ip = new StreamReader(filePath);
string line;
while ((line = ip.ReadLine()) != null)
while ((line = ip.ReadLine()) != null)
{
i++;
try
{
i++;
string[] split = line.Split(' ');
x = Convert.ToInt32(split[0]);
y = Convert.ToInt32(split[1]);
try
{
string[] split = line.Split(' ');
x = Convert.ToInt32(split[0]);
y = Convert.ToInt32(split[1]);
try
{
new TreasureRegion(x, y, Map.Felucca);
new TreasureRegion(x, y, Map.Trammel);
}
catch (Exception e)
{
Console.WriteLine("{0} {1} {2} {3}", i, x, y, e);
}
new TreasureRegion(x, y, Map.Felucca);
new TreasureRegion(x, y, Map.Trammel);
}
catch
catch (Exception e)
{
Console.WriteLine("Warning: Error in Line '{0}' of Data/treasure.cfg", line);
Console.WriteLine("{0} {1} {2} {3}", i, x, y, e);
}
}
catch
{
Console.WriteLine("Warning: Error in Line '{0}' of Data/treasure.cfg", line);
}
}
}
}
public override bool AllowHousing(Mobile from, Point3D p)
{
return false;
}
public override bool AllowHousing(Mobile from, Point3D p) => false;
public override void OnEnter(Mobile m)
{

View file

@ -106,18 +106,14 @@ namespace Server
return itemID >= 0x406 && itemID <= 0x51A;
}
private static bool IsStaticFloor(int itemID)
{
return itemID >= 0x495 && itemID <= 0x514
|| itemID >= 0x519 && itemID <= 0x53A;
}
private static bool IsStaticFloor(int itemID) =>
itemID >= 0x495 && itemID <= 0x514
|| itemID >= 0x519 && itemID <= 0x53A;
private static bool IsDisplayCase(int itemID)
{
return itemID >= 0xB00 && itemID <= 0xB02
|| itemID >= 0xB06 && itemID <= 0xB0A
|| itemID >= 0xB0D && itemID <= 0xB17;
}
private static bool IsDisplayCase(int itemID) =>
itemID >= 0xB00 && itemID <= 0xB02
|| itemID >= 0xB06 && itemID <= 0xB0A
|| itemID >= 0xB0D && itemID <= 0xB17;
private static void Process(Map map, Rectangle2D[] regions)
{
@ -258,31 +254,23 @@ namespace Server
}
}
private static bool IsClothes(int itemID)
{
return itemID >= 0x1515 && itemID <= 0x1518 || itemID >= 0x152E && itemID <= 0x1531 || itemID >= 0x1537
&& itemID <= 0x154C || itemID >= 0x1EFD && itemID <= 0x1F04 || itemID >= 0x170B && itemID <= 0x171C;
}
private static bool IsClothes(int itemID) =>
itemID >= 0x1515 && itemID <= 0x1518 || itemID >= 0x152E && itemID <= 0x1531 || itemID >= 0x1537
&& itemID <= 0x154C || itemID >= 0x1EFD && itemID <= 0x1F04 || itemID >= 0x170B && itemID <= 0x171C;
private static bool IsArmor(int itemID)
{
return itemID >= 0x13BB && itemID <= 0x13E2 || itemID >= 0x13E5 && itemID <= 0x13F2 ||
itemID >= 0x1408 && itemID <= 0x141A || itemID >= 0x144E && itemID <= 0x1457;
}
private static bool IsArmor(int itemID) =>
itemID >= 0x13BB && itemID <= 0x13E2 || itemID >= 0x13E5 && itemID <= 0x13F2 ||
itemID >= 0x1408 && itemID <= 0x141A || itemID >= 0x144E && itemID <= 0x1457;
private static bool IsMetalWeapon(int itemID)
{
return itemID >= 0xF43 && itemID <= 0xF4E || itemID >= 0xF51 && itemID <= 0xF52 ||
itemID >= 0xF5C && itemID <= 0xF63 || itemID >= 0x13AF && itemID <= 0x13B0 ||
itemID >= 0x13B5 && itemID <= 0x13BA || itemID >= 0x13FA && itemID <= 0x13FB ||
itemID >= 0x13FE && itemID <= 0x1407 || itemID >= 0x1438 && itemID <= 0x1443;
}
private static bool IsMetalWeapon(int itemID) =>
itemID >= 0xF43 && itemID <= 0xF4E || itemID >= 0xF51 && itemID <= 0xF52 ||
itemID >= 0xF5C && itemID <= 0xF63 || itemID >= 0x13AF && itemID <= 0x13B0 ||
itemID >= 0x13B5 && itemID <= 0x13BA || itemID >= 0x13FA && itemID <= 0x13FB ||
itemID >= 0x13FE && itemID <= 0x1407 || itemID >= 0x1438 && itemID <= 0x1443;
private static bool IsArcheryWeapon(int itemID)
{
return itemID >= 0xF4F && itemID <= 0xF50 || itemID >= 0x13B1 && itemID <= 0x13B2 ||
itemID >= 0x13FC && itemID <= 0x13FD;
}
private static bool IsArcheryWeapon(int itemID) =>
itemID >= 0xF4F && itemID <= 0xF50 || itemID >= 0x13B1 && itemID <= 0x13B2 ||
itemID >= 0x13FC && itemID <= 0x13FD;
private static ShopFlags ProcessDisplayedItem(int itemID)
{

View file

@ -5,353 +5,348 @@ using Server.Network;
namespace Server.Misc
{
public class Weather
{
private static Map[] m_Facets;
private static Dictionary<Map, List<Weather>> m_WeatherByFacet = new Dictionary<Map, List<Weather>>();
public class Weather
{
private static Map[] m_Facets;
private static Dictionary<Map, List<Weather>> m_WeatherByFacet = new Dictionary<Map, List<Weather>>();
public static void Initialize()
{
m_Facets = new[]{ Map.Felucca, Map.Trammel };
public static void Initialize()
{
m_Facets = new[]{ Map.Felucca, Map.Trammel };
/* Static weather:
*
* Format:
* AddWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, <area ...> );
*/
/* Static weather:
*
* Format:
* AddWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, <area ...> );
*/
// ice island
AddWeather( -15, 100, 5, new Rectangle2D( 3850, 160, 390, 320 ), new Rectangle2D( 3900, 480, 380, 180 ), new Rectangle2D( 4160, 660, 150, 110 ) );
// ice island
AddWeather( -15, 100, 5, new Rectangle2D( 3850, 160, 390, 320 ), new Rectangle2D( 3900, 480, 380, 180 ), new Rectangle2D( 4160, 660, 150, 110 ) );
// covetous entrance, around vesper and minoc
AddWeather( +15, 50, 5, new Rectangle2D( 2425, 725, 250, 250 ) );
// covetous entrance, around vesper and minoc
AddWeather( +15, 50, 5, new Rectangle2D( 2425, 725, 250, 250 ) );
// despise entrance, north of britain
AddWeather( +15, 50, 5, new Rectangle2D( 1245, 1045, 250, 250 ) );
// despise entrance, north of britain
AddWeather( +15, 50, 5, new Rectangle2D( 1245, 1045, 250, 250 ) );
/* Dynamic weather:
*
* Format:
* AddDynamicWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, moveSpeed, width, height, bounds );
*/
/* Dynamic weather:
*
* Format:
* AddDynamicWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, moveSpeed, width, height, bounds );
*/
for ( int i = 0; i < 15; ++i )
AddDynamicWeather( +15, 100, 5, 8, 400, 400, new Rectangle2D( 0, 0, 5120, 4096 ) );
}
for ( int i = 0; i < 15; ++i )
AddDynamicWeather( +15, 100, 5, 8, 400, 400, new Rectangle2D( 0, 0, 5120, 4096 ) );
}
public static List<Weather> GetWeatherList( Map facet )
{
if ( facet == null )
return null;
public static List<Weather> GetWeatherList( Map facet )
{
if ( facet == null )
return null;
if (!m_WeatherByFacet.TryGetValue( facet, out List<Weather> list ))
m_WeatherByFacet[facet] = list = new List<Weather>();
if (!m_WeatherByFacet.TryGetValue( facet, out List<Weather> list ))
m_WeatherByFacet[facet] = list = new List<Weather>();
return list;
}
return list;
}
public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds )
{
for ( int i = 0; i < m_Facets.Length; ++i )
{
Rectangle2D area = new Rectangle2D();
bool isValid = false;
public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds )
{
for ( int i = 0; i < m_Facets.Length; ++i )
{
Rectangle2D area = new Rectangle2D();
bool isValid = false;
for ( int j = 0; j < 10; ++j )
{
area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height );
for ( int j = 0; j < 10; ++j )
{
area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height );
if ( !CheckWeatherConflict( m_Facets[i], null, area ) )
isValid = true;
if ( !CheckWeatherConflict( m_Facets[i], null, area ) )
isValid = true;
if ( isValid )
break;
}
if ( isValid )
break;
}
if ( !isValid )
continue;
if ( !isValid )
continue;
new Weather(m_Facets[i], new[] { area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature,
TimeSpan.FromSeconds(30.0)) { Bounds = bounds, MoveSpeed = moveSpeed };
}
}
new Weather(m_Facets[i], new[] { area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature,
TimeSpan.FromSeconds(30.0)) { Bounds = bounds, MoveSpeed = moveSpeed };
}
}
public static void AddWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, params Rectangle2D[] area )
{
for ( int i = 0; i < m_Facets.Length; ++i )
new Weather( m_Facets[i], area, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) );
}
public static void AddWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, params Rectangle2D[] area )
{
for ( int i = 0; i < m_Facets.Length; ++i )
new Weather( m_Facets[i], area, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) );
}
public static bool CheckWeatherConflict( Map facet, Weather exclude, Rectangle2D area )
{
List<Weather> list = GetWeatherList( facet );
public static bool CheckWeatherConflict( Map facet, Weather exclude, Rectangle2D area )
{
List<Weather> list = GetWeatherList( facet );
if ( list == null )
return false;
if ( list == null )
return false;
for ( int i = 0; i < list.Count; ++i )
{
Weather w = list[i];
for ( int i = 0; i < list.Count; ++i )
{
Weather w = list[i];
if ( w != exclude && w.IntersectsWith( area ) )
return true;
}
if ( w != exclude && w.IntersectsWith( area ) )
return true;
}
return false;
}
return false;
}
public Map Facet { get; }
public Map Facet { get; }
public Rectangle2D[] Area { get; set; }
public Rectangle2D[] Area { get; set; }
public int Temperature { get; set; }
public int Temperature { get; set; }
public int ChanceOfPercipitation { get; set; }
public int ChanceOfPercipitation { get; set; }
public int ChanceOfExtremeTemperature { get; set; }
public int ChanceOfExtremeTemperature { get; set; }
// For dynamic weather:
// For dynamic weather:
public Rectangle2D Bounds { get; set; }
public Rectangle2D Bounds { get; set; }
public int MoveSpeed { get; set; }
public int MoveSpeed { get; set; }
public int MoveAngleX { get; set; }
public int MoveAngleX { get; set; }
public int MoveAngleY { get; set; }
public int MoveAngleY { get; set; }
public static bool CheckIntersection( Rectangle2D r1, Rectangle2D r2 )
{
return r1.X < r2.X + r2.Width && r2.X < r1.X + r1.Width && r1.Y < r2.Y + r2.Height && r2.Y < r1.Y + r1.Height;
}
public static bool CheckIntersection( Rectangle2D r1, Rectangle2D r2 ) => r1.X < r2.X + r2.Width && r2.X < r1.X + r1.Width && r1.Y < r2.Y + r2.Height && r2.Y < r1.Y + r1.Height;
public static bool CheckContains( Rectangle2D big, Rectangle2D small )
{
return small.X >= big.X && small.Y >= big.Y && small.X + small.Width <= big.X + big.Width
&& small.Y + small.Height <= big.Y + big.Height;
}
public static bool CheckContains( Rectangle2D big, Rectangle2D small ) =>
small.X >= big.X && small.Y >= big.Y && small.X + small.Width <= big.X + big.Width
&& small.Y + small.Height <= big.Y + big.Height;
public virtual bool IntersectsWith( Rectangle2D area )
{
for ( int i = 0; i < Area.Length; ++i )
{
if ( CheckIntersection( area, Area[i] ) )
return true;
}
public virtual bool IntersectsWith( Rectangle2D area )
{
for ( int i = 0; i < Area.Length; ++i )
{
if ( CheckIntersection( area, Area[i] ) )
return true;
}
return false;
}
return false;
}
public Weather( Map facet, Rectangle2D[] area, int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, TimeSpan interval )
{
Facet = facet;
Area = area;
Temperature = temperature;
ChanceOfPercipitation = chanceOfPercipitation;
ChanceOfExtremeTemperature = chanceOfExtremeTemperature;
public Weather( Map facet, Rectangle2D[] area, int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, TimeSpan interval )
{
Facet = facet;
Area = area;
Temperature = temperature;
ChanceOfPercipitation = chanceOfPercipitation;
ChanceOfExtremeTemperature = chanceOfExtremeTemperature;
List<Weather> list = GetWeatherList( facet );
List<Weather> list = GetWeatherList( facet );
list?.Add( this );
list?.Add( this );
Timer.DelayCall( TimeSpan.FromSeconds( (0.2+Utility.RandomDouble()*0.8) * interval.TotalSeconds ), interval, OnTick );
}
Timer.DelayCall( TimeSpan.FromSeconds( (0.2+Utility.RandomDouble()*0.8) * interval.TotalSeconds ), interval, OnTick );
}
public virtual void Reposition()
{
if ( Area.Length == 0 )
return;
public virtual void Reposition()
{
if ( Area.Length == 0 )
return;
int width = Area[0].Width;
int height = Area[0].Height;
int width = Area[0].Width;
int height = Area[0].Height;
Rectangle2D area = new Rectangle2D();
bool isValid = false;
Rectangle2D area = new Rectangle2D();
bool isValid = false;
for ( int j = 0; j < 10; ++j )
{
area = new Rectangle2D( Bounds.X + Utility.Random( Bounds.Width - width ), Bounds.Y + Utility.Random( Bounds.Height - height ), width, height );
for ( int j = 0; j < 10; ++j )
{
area = new Rectangle2D( Bounds.X + Utility.Random( Bounds.Width - width ), Bounds.Y + Utility.Random( Bounds.Height - height ), width, height );
if ( !CheckWeatherConflict( Facet, this, area ) )
isValid = true;
if ( !CheckWeatherConflict( Facet, this, area ) )
isValid = true;
if ( isValid )
break;
}
if ( isValid )
break;
}
if ( !isValid )
return;
if ( !isValid )
return;
Area[0] = area;
}
Area[0] = area;
}
public virtual void RecalculateMovementAngle()
{
double angle = Utility.RandomDouble() * Math.PI * 2.0;
public virtual void RecalculateMovementAngle()
{
double angle = Utility.RandomDouble() * Math.PI * 2.0;
double cos = Math.Cos( angle );
double sin = Math.Sin( angle );
double cos = Math.Cos( angle );
double sin = Math.Sin( angle );
MoveAngleX = (int)(100 * cos);
MoveAngleY = (int)(100 * sin);
}
MoveAngleX = (int)(100 * cos);
MoveAngleY = (int)(100 * sin);
}
public virtual void MoveForward()
{
if ( Area.Length == 0 )
return;
public virtual void MoveForward()
{
if ( Area.Length == 0 )
return;
for ( int i = 0; i < 5; ++i ) // try 5 times to find a valid spot
{
int xOffset = MoveSpeed * MoveAngleX / 100;
int yOffset = MoveSpeed * MoveAngleY / 100;
for ( int i = 0; i < 5; ++i ) // try 5 times to find a valid spot
{
int xOffset = MoveSpeed * MoveAngleX / 100;
int yOffset = MoveSpeed * MoveAngleY / 100;
Rectangle2D oldArea = Area[0];
Rectangle2D newArea = new Rectangle2D( oldArea.X + xOffset, oldArea.Y + yOffset, oldArea.Width, oldArea.Height );
Rectangle2D oldArea = Area[0];
Rectangle2D newArea = new Rectangle2D( oldArea.X + xOffset, oldArea.Y + yOffset, oldArea.Width, oldArea.Height );
if ( !CheckWeatherConflict( Facet, this, newArea ) && CheckContains( Bounds, newArea ) )
{
Area[0] = newArea;
break;
}
RecalculateMovementAngle();
}
}
private int m_Stage;
private bool m_Active;
private bool m_ExtremeTemperature;
public virtual void OnTick()
{
if ( m_Stage == 0 )
{
m_Active = ChanceOfPercipitation > Utility.Random( 100 );
m_ExtremeTemperature = ChanceOfExtremeTemperature > Utility.Random( 100 );
if ( !CheckWeatherConflict( Facet, this, newArea ) && CheckContains( Bounds, newArea ) )
{
Area[0] = newArea;
break;
}
if ( MoveSpeed > 0 )
{
Reposition();
RecalculateMovementAngle();
}
}
RecalculateMovementAngle();
}
}
if ( m_Active )
{
if ( m_Stage > 0 && MoveSpeed > 0 )
MoveForward();
private int m_Stage;
private bool m_Active;
private bool m_ExtremeTemperature;
int type, density;
int temperature = Temperature;
public virtual void OnTick()
{
if ( m_Stage == 0 )
{
m_Active = ChanceOfPercipitation > Utility.Random( 100 );
m_ExtremeTemperature = ChanceOfExtremeTemperature > Utility.Random( 100 );
if ( m_ExtremeTemperature )
temperature *= -1;
if ( MoveSpeed > 0 )
{
Reposition();
RecalculateMovementAngle();
}
}
if ( m_Stage < 15 )
{
density = m_Stage * 5;
}
else
{
density = 150 - m_Stage * 5;
if ( m_Active )
{
if ( m_Stage > 0 && MoveSpeed > 0 )
MoveForward();
if ( density < 10 )
density = 10;
else if ( density > 70 )
density = 70;
}
int type, density;
int temperature = Temperature;
if ( density == 0 )
type = 0xFE;
else if ( temperature > 0 )
type = 0;
else
type = 2;
if ( m_ExtremeTemperature )
temperature *= -1;
List<NetState> states = NetState.Instances;
if ( m_Stage < 15 )
{
density = m_Stage * 5;
}
else
{
density = 150 - m_Stage * 5;
Packet weatherPacket = null;
if ( density < 10 )
density = 10;
else if ( density > 70 )
density = 70;
}
for ( int i = 0; i < states.Count; ++i )
{
NetState ns = states[i];
Mobile mob = ns.Mobile;
if ( density == 0 )
type = 0xFE;
else if ( temperature > 0 )
type = 0;
else
type = 2;
if ( mob == null || mob.Map != Facet )
continue;
List<NetState> states = NetState.Instances;
bool contains = Area.Length == 0;
Packet weatherPacket = null;
for ( int j = 0; !contains && j < Area.Length; ++j )
contains = Area[j].Contains( mob.Location );
if ( !contains )
continue;
for ( int i = 0; i < states.Count; ++i )
{
NetState ns = states[i];
Mobile mob = ns.Mobile;
if ( weatherPacket == null )
weatherPacket = Packet.Acquire( new Server.Network.Weather( type, density, temperature ) );
if ( mob == null || mob.Map != Facet )
continue;
ns.Send( weatherPacket );
}
bool contains = Area.Length == 0;
Packet.Release( weatherPacket );
}
m_Stage++;
m_Stage %= 30;
}
}
for ( int j = 0; !contains && j < Area.Length; ++j )
contains = Area[j].Contains( mob.Location );
if ( !contains )
continue;
public class WeatherMap : MapItem
{
public override string DefaultName => "weather map";
if ( weatherPacket == null )
weatherPacket = Packet.Acquire( new Server.Network.Weather( type, density, temperature ) );
[Constructible]
public WeatherMap()
{
SetDisplay( 0, 0, 5119, 4095, 400, 400 );
}
ns.Send( weatherPacket );
}
public override void OnDoubleClick( Mobile from )
{
Map facet = from.Map;
Packet.Release( weatherPacket );
}
m_Stage++;
m_Stage %= 30;
}
}
if ( facet == null )
return;
public class WeatherMap : MapItem
{
public override string DefaultName => "weather map";
List<Weather> list = Weather.GetWeatherList( facet );
[Constructible]
public WeatherMap()
{
SetDisplay( 0, 0, 5119, 4095, 400, 400 );
}
ClearPins();
public override void OnDoubleClick( Mobile from )
{
Map facet = from.Map;
for ( int i = 0; i < list.Count; ++i )
{
Weather w = list[i];
if ( facet == null )
return;
for ( int j = 0; j < w.Area.Length; ++j )
AddWorldPin( w.Area[j].X + w.Area[j].Width/2, w.Area[j].Y + w.Area[j].Height/2 );
}
List<Weather> list = Weather.GetWeatherList( facet );
base.OnDoubleClick( from );
}
ClearPins();
public WeatherMap( Serial serial ) : base( serial )
{
}
for ( int i = 0; i < list.Count; ++i )
{
Weather w = list[i];
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
for ( int j = 0; j < w.Area.Length; ++j )
AddWorldPin( w.Area[j].X + w.Area[j].Width/2, w.Area[j].Y + w.Area[j].Height/2 );
}
writer.Write( 0 );
}
base.OnDoubleClick( from );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public WeatherMap( Serial serial ) : base( serial )
{
}
int version = reader.ReadInt();
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}

View file

@ -24,10 +24,8 @@ namespace Server.Misc
private static readonly object _StatusLock = new object();
public StatusPage()
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(60.0))
{
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(60.0)) =>
Priority = TimerPriority.FiveSeconds;
}
public static void Initialize()
{

View file

@ -43,13 +43,7 @@ namespace Server.Misc
m.Stam -= (int)fatigue;
}
public static int GetMaxWeight(Mobile m)
{
//return ((( Core.ML && m.Race == Race.Human) ? 100 : 40 ) + (int)(3.5 * m.Str));
//Moved to core virtual method for use there
return m.MaxWeight;
}
public static int GetMaxWeight(Mobile m) => m.MaxWeight;
public static void EventSink_Movement(MovementEventArgs e)
{