Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -614,21 +614,12 @@ namespace Server
[CommandProperty(AccessLevel.GameMaster)]
public Race Race
{
get
{
if (m_Race == null)
m_Race = Race.DefaultRace;
return m_Race;
}
get => m_Race ?? (m_Race = Race.DefaultRace);
set
{
Race oldRace = Race;
m_Race = value;
if (m_Race == null)
m_Race = Race.DefaultRace;
m_Race = value ?? Race.DefaultRace;
Body = m_Race.Body(this);
UpdateResistances();
@ -1465,7 +1456,8 @@ namespace Server
{
get
{
if (m_NetState != null && m_NetState.Socket == null && !m_NetState.IsDisposing) NetState = null;
if (m_NetState != null && m_NetState.Socket == null && !m_NetState.IsDisposing)
NetState = null;
return m_NetState;
}
@ -1489,7 +1481,7 @@ namespace Server
BankBox box = FindBankNoCreate();
if (box != null && box.Opened)
if (box?.Opened == true)
box.Close();
// REMOVED:
@ -1591,7 +1583,7 @@ namespace Server
{
m_GuildTitle = value;
if (m_Guild != null && !m_Guild.Disbanded && m_GuildTitle != null)
if (m_Guild?.Disbanded == false && m_GuildTitle != null)
SendLocalizedMessage(1018026, true, m_GuildTitle); // Your guild title has changed :
InvalidateProperties();
@ -1881,7 +1873,7 @@ namespace Server
{
get
{
if (m_BankBox != null && !m_BankBox.Deleted && m_BankBox.Parent == this)
if (m_BankBox?.Deleted == false && m_BankBox.Parent == this)
return m_BankBox;
m_BankBox = FindItemOnLayer(Layer.Bank) as BankBox;
@ -1898,10 +1890,10 @@ namespace Server
{
get
{
if (m_Backpack != null && !m_Backpack.Deleted && m_Backpack.Parent == this)
return m_Backpack;
if (m_Backpack?.Deleted != false || m_Backpack.Parent != this)
m_Backpack = FindItemOnLayer(Layer.Backpack) as Container;
return m_Backpack = FindItemOnLayer(Layer.Backpack) as Container;
return m_Backpack;
}
}
@ -3076,10 +3068,7 @@ namespace Server
public virtual void AddNameProperties(ObjectPropertyList list)
{
string name = Name;
if (name == null)
name = string.Empty;
string name = Name ?? string.Empty;
string prefix = "";
@ -3095,10 +3084,8 @@ namespace Server
if (guild != null && (m_Player || m_DisplayGuildTitle))
{
if (suffix.Length > 0)
suffix = string.Format("{0} [{1}]", suffix, Utility.FixHtml(guild.Abbreviation));
else
suffix = string.Format("[{0}]", Utility.FixHtml(guild.Abbreviation));
suffix = suffix.Length > 0 ? $"{suffix} [{Utility.FixHtml(guild.Abbreviation)}]"
: $"[{Utility.FixHtml(guild.Abbreviation)}]";
}
suffix = ApplyNameSuffix(suffix);
@ -3114,12 +3101,7 @@ namespace Server
else
type = "";
string title = GuildTitle;
if (title == null)
title = "";
else
title = title.Trim();
string title = GuildTitle?.Trim() ?? "";
if (NewGuildDisplay && title.Length > 0)
{
@ -3349,12 +3331,7 @@ namespace Server
public bool InLOS(Point3D target)
{
if (Deleted || m_Map == null)
return false;
if (m_AccessLevel > AccessLevel.Player)
return true;
return m_Map.LineOfSight(this, target);
return !Deleted && m_Map != null && (m_AccessLevel > AccessLevel.Player || m_Map.LineOfSight(this, target));
}
public bool BeginAction<T>()
@ -3433,7 +3410,7 @@ namespace Server
public override string ToString()
{
return string.Format("0x{0:X} \"{1}\"", Serial.Value, Name);
return $"0x{Serial.Value:X} \"{Name}\"";
}
public virtual void SendSkillMessage()
@ -3849,7 +3826,7 @@ namespace Server
BankBox box = FindBankNoCreate();
if (box != null && box.Opened)
if (box?.Opened == true)
box.Close();
Point3D newLocation = m_Location;
@ -3859,7 +3836,7 @@ namespace Server
{
// We are actually moving (not just a direction change)
if (m_Spell != null && !m_Spell.OnCasterMoving(d))
if (m_Spell?.OnCasterMoving(d) == false)
return false;
if (m_Paralyzed || m_Frozen)
@ -4090,9 +4067,8 @@ namespace Server
{
if (ns.StygianAbyss)
{
Packet p;
int noto = Notoriety.Compute(m, this);
p = cache[0][noto];
Packet p = cache[0][noto];
if (p == null)
cache[0][noto] = p = Packet.Acquire(new MobileMoving(this, noto));
@ -4101,9 +4077,8 @@ namespace Server
}
else
{
Packet p;
int noto = Notoriety.Compute(m, this);
p = cache[1][noto];
Packet p = cache[1][noto];
if (p == null)
cache[1][noto] = p = Packet.Acquire(new MobileMovingOld(this, noto));
@ -4114,8 +4089,8 @@ namespace Server
}
for (int i = 0; i < cache.Length; ++i)
for (int j = 0; j < cache[i].Length; ++j)
Packet.Release(ref cache[i][j]);
for (int j = 0; j < cache[i].Length; ++j)
Packet.Release(ref cache[i][j]);
for (int i = 0; i < m_MoveList.Count; ++i)
{
@ -4286,7 +4261,7 @@ namespace Server
BankBox box = FindBankNoCreate();
if (box != null && box.Opened)
if (box?.Opened == true)
box.Close();
Poison = null;
@ -4447,7 +4422,7 @@ namespace Server
BankBox box = FindBankNoCreate();
if (box != null && box.Opened)
if (box?.Opened == true)
box.Close();
m_NetState?.CancelAllTrades();
@ -4659,12 +4634,12 @@ namespace Server
public virtual void Use(Item item)
{
if (item == null || item.Deleted || item.QuestItem || Deleted)
if (item?.Deleted != false || item.QuestItem || Deleted)
return;
DisruptiveAction();
if (m_Spell != null && !m_Spell.OnCasterUsingObject(item))
if (m_Spell?.OnCasterUsingObject(item) == false)
return;
IEntity root = item.RootParent;
@ -4722,12 +4697,12 @@ namespace Server
public virtual void Use(Mobile m)
{
if (m == null || m.Deleted || Deleted)
if (m?.Deleted != false || Deleted)
return;
DisruptiveAction();
if (m_Spell != null && !m_Spell.OnCasterUsingObject(m))
if (m_Spell?.OnCasterUsingObject(m) == false)
return;
if (!Utility.InUpdateRange(this, m))
@ -5202,24 +5177,24 @@ namespace Server
foreach (IEntity o in eable)
if (o is Mobile heard)
{
if (heard.CanSee(this) && (NoSpeechLOS || !heard.Player || heard.InLOS(this)))
if (!heard.CanSee(this) || !NoSpeechLOS && heard.Player && !heard.InLOS(this))
continue;
if (heard.m_NetState != null)
hears.Add(heard);
if (heard.HandlesOnSpeech(this))
onSpeech.Add(heard);
for (int i = 0; i < heard.Items.Count; ++i)
{
if (heard.m_NetState != null)
hears.Add(heard);
Item item = heard.Items[i];
if (heard.HandlesOnSpeech(this))
onSpeech.Add(heard);
if (item.HandlesOnSpeech)
onSpeech.Add(item);
for (int i = 0; i < heard.Items.Count; ++i)
{
Item item = heard.Items[i];
if (item.HandlesOnSpeech)
onSpeech.Add(item);
if (item is Container container)
AddSpeechItemsFrom(onSpeech, container);
}
if (item is Container container)
AddSpeechItemsFrom(onSpeech, container);
}
}
else if (o is Item item)
@ -6244,7 +6219,7 @@ namespace Server
public void AddItem(Item item)
{
if (item == null || item.Deleted)
if (item?.Deleted != false)
return;
if (item.Parent == this)
@ -6840,7 +6815,7 @@ namespace Server
BankBox box = FindBankNoCreate();
if (box != null && box.Opened)
if (box?.Opened == true)
box.Close();
m_NetState?.ValidateAllTrades();
@ -6919,24 +6894,24 @@ namespace Server
if (ObjectPropertyList.Enabled) m.m_NetState.Send(OPLPacket);
}
if (!inOldRange && CanSee(m))
if (inOldRange || !CanSee(m))
continue;
ourState.Send(MobileIncoming.Create(ourState, this, m));
if (ourState.StygianAbyss)
{
ourState.Send(MobileIncoming.Create(ourState, this, m));
//if ( m.Poisoned )
ourState.Send(new HealthbarPoison(m));
if (ourState.StygianAbyss)
{
//if ( m.Poisoned )
ourState.Send(new HealthbarPoison(m));
//if ( m.Blessed || m.YellowHealthbar )
ourState.Send(new HealthbarYellow(m));
}
if (m.IsDeadBondedPet)
ourState.Send(new BondedStatus(0, m.Serial, 1));
if (ObjectPropertyList.Enabled) ourState.Send(m.OPLPacket);
//if ( m.Blessed || m.YellowHealthbar )
ourState.Send(new HealthbarYellow(m));
}
if (m.IsDeadBondedPet)
ourState.Send(new BondedStatus(0, m.Serial, 1));
if (ObjectPropertyList.Enabled) ourState.Send(m.OPLPacket);
}
eeable.Free();
@ -6996,10 +6971,8 @@ namespace Server
public BankBox FindBankNoCreate()
{
if (m_BankBox != null && !m_BankBox.Deleted && m_BankBox.Parent == this)
return m_BankBox;
m_BankBox = FindItemOnLayer(Layer.Bank) as BankBox;
if (m_BankBox?.Deleted != false || m_BankBox.Parent != this)
m_BankBox = FindItemOnLayer(Layer.Bank) as BankBox;
return m_BankBox;
}
@ -7021,32 +6994,32 @@ namespace Server
public void SendIncomingPacket()
{
if (m_Map != null)
{
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
if (m_Map == null)
return;
foreach (NetState state in eable)
if (state.Mobile.CanSee(this))
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this))
{
state.Send(MobileIncoming.Create(state, state.Mobile, this));
if (state.StygianAbyss)
{
state.Send(MobileIncoming.Create(state, state.Mobile, this));
if (m_Poison != null)
state.Send(new HealthbarPoison(this));
if (state.StygianAbyss)
{
if (m_Poison != null)
state.Send(new HealthbarPoison(this));
if (m_Blessed || m_YellowHealthbar)
state.Send(new HealthbarYellow(this));
}
if (IsDeadBondedPet)
state.Send(new BondedStatus(0, Serial, 1));
if (ObjectPropertyList.Enabled) state.Send(OPLPacket);
if (m_Blessed || m_YellowHealthbar)
state.Send(new HealthbarYellow(this));
}
eable.Free();
}
if (IsDeadBondedPet)
state.Send(new BondedStatus(0, Serial, 1));
if (ObjectPropertyList.Enabled) state.Send(OPLPacket);
}
eable.Free();
}
public bool PlaceInBackpack(Item item)
@ -7054,9 +7027,7 @@ namespace Server
if (item.Deleted)
return false;
Container pack = Backpack;
return pack != null && pack.TryDropItem(this, item, false);
return Backpack?.TryDropItem(this, item, false) == true;
}
public bool AddToBackpack(Item item)
@ -7089,10 +7060,7 @@ namespace Server
public virtual bool CheckNonlocalLift(Mobile from, Item item)
{
if (from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster)
return true;
return false;
return from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster;
}
public virtual bool CheckTrade(Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems,
@ -7101,12 +7069,7 @@ namespace Server
return true;
}
public bool OpenTrade(Mobile from)
{
return OpenTrade(from, null);
}
public virtual bool OpenTrade(Mobile from, Item offer)
public virtual bool OpenTrade(Mobile from, Item offer = null)
{
if (!from.Player || !Player || !from.Alive || !Alive) return false;
@ -7138,15 +7101,10 @@ namespace Server
if (from == this)
{
Container pack = Backpack;
if (pack != null)
return dropped.DropToItem(from, pack, new Point3D(-1, -1, 0));
return false;
return pack != null && dropped.DropToItem(from, pack, new Point3D(-1, -1, 0));
}
if (from.InRange(Location, 2)) return OpenTrade(from, dropped);
return false;
return from.InRange(Location, 2) && OpenTrade(from, dropped);
}
public virtual bool CheckEquip(Item item)
@ -7267,10 +7225,7 @@ namespace Server
public virtual bool CheckNonlocalDrop(Mobile from, Item item, Item target)
{
if (from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster)
return true;
return false;
return from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster;
}
public virtual bool CheckItemUse(Mobile from, Item item)
@ -7299,12 +7254,12 @@ namespace Server
public virtual bool EquipItem(Item item)
{
if (item == null || item.Deleted || !item.CanEquip(this))
if (item?.Deleted != false || !item.CanEquip(this))
return false;
if (CheckEquip(item) && OnEquip(item) && item.OnEquip(this))
{
if (m_Spell != null && !m_Spell.OnCasterEquipping(item))
if (m_Spell?.OnCasterEquipping(item) == false)
return false;
//if ( m_Spell != null && m_Spell.State == SpellState.Casting )
@ -7364,6 +7319,7 @@ namespace Server
}
catch
{
// ignored
}
}
else
@ -7396,22 +7352,15 @@ namespace Server
{
}
public bool CheckAlive()
public bool CheckAlive(bool message = true)
{
return CheckAlive(true);
}
if (Alive)
return true;
public bool CheckAlive(bool message)
{
if (!Alive)
{
if (message)
LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019048); // I am dead and cannot do that.
if (message)
LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019048); // I am dead and cannot do that.
return false;
}
return true;
return false;
}
public void LaunchBrowser(string url)
@ -7483,9 +7432,8 @@ namespace Server
/// </summary>
public virtual void OnSingleClick(Mobile from)
{
if (Deleted)
return;
if (AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this)
if (Deleted ||
AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this)
return;
if (GuildClickMessage)
@ -7523,10 +7471,7 @@ namespace Server
else
hue = Notoriety.GetHue(Notoriety.Compute(from, this));
string name = Name;
if (name == null)
name = string.Empty;
string name = Name ?? string.Empty;
string prefix = "";
@ -7535,7 +7480,7 @@ namespace Server
string suffix = "";
if (ClickTitle && Title != null && Title.Length > 0)
if (ClickTitle && !string.IsNullOrEmpty(Title))
suffix = Title;
suffix = ApplyNameSuffix(suffix);
@ -7556,32 +7501,22 @@ namespace Server
public bool CheckSkill(SkillName skill, double minSkill, double maxSkill)
{
if (SkillCheckLocationHandler == null)
return false;
return SkillCheckLocationHandler(this, skill, minSkill, maxSkill);
return SkillCheckLocationHandler?.Invoke(this, skill, minSkill, maxSkill) == true;
}
public bool CheckSkill(SkillName skill, double chance)
{
if (SkillCheckDirectLocationHandler == null)
return false;
return SkillCheckDirectLocationHandler(this, skill, chance);
return SkillCheckDirectLocationHandler?.Invoke(this, skill, chance) == true;
}
public bool CheckTargetSkill(SkillName skill, object target, double minSkill, double maxSkill)
{
if (SkillCheckTargetHandler == null)
return false;
return SkillCheckTargetHandler(this, skill, target, minSkill, maxSkill);
return SkillCheckTargetHandler?.Invoke(this, skill, target, minSkill, maxSkill) == true;
}
public bool CheckTargetSkill(SkillName skill, object target, double chance)
{
if (SkillCheckDirectTargetHandler == null)
return false;
return SkillCheckDirectTargetHandler(this, skill, target, chance);
return SkillCheckDirectTargetHandler?.Invoke(this, skill, target, chance) == true;
}
public virtual void DisruptiveAction()
@ -8022,8 +7957,7 @@ namespace Server
{
private Mobile m_Mobile;
public CombatTimer(Mobile m)
: base(TimeSpan.FromSeconds(0.0), TimeSpan.FromSeconds(0.01), 0)
public CombatTimer(Mobile m) : base(TimeSpan.FromSeconds(0.0), TimeSpan.FromSeconds(0.01))
{
m_Mobile = m;
@ -8033,32 +7967,32 @@ namespace Server
protected override void OnTick()
{
if (Core.TickCount - m_Mobile.NextCombatTime >= 0)
if (Core.TickCount - m_Mobile.NextCombatTime < 0)
return;
Mobile combatant = m_Mobile.Combatant;
// If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat
if (combatant?.Deleted != false || m_Mobile.Deleted || combatant.m_Map != m_Mobile.m_Map ||
!combatant.Alive || !m_Mobile.Alive || !m_Mobile.CanSee(combatant) || combatant.IsDeadBondedPet ||
m_Mobile.IsDeadBondedPet)
{
Mobile combatant = m_Mobile.Combatant;
m_Mobile.Combatant = null;
return;
}
// If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat
if (combatant == null || combatant.Deleted || m_Mobile.Deleted || combatant.m_Map != m_Mobile.m_Map ||
!combatant.Alive || !m_Mobile.Alive || !m_Mobile.CanSee(combatant) || combatant.IsDeadBondedPet ||
m_Mobile.IsDeadBondedPet)
{
m_Mobile.Combatant = null;
return;
}
IWeapon weapon = m_Mobile.Weapon;
IWeapon weapon = m_Mobile.Weapon;
if (!m_Mobile.InRange(combatant, weapon.MaxRange))
return;
if (!m_Mobile.InRange(combatant, weapon.MaxRange))
return;
if (m_Mobile.InLOS(combatant))
{
weapon.OnBeforeSwing(m_Mobile,
combatant); //OnBeforeSwing for checking in regards to being hidden and whatnot
m_Mobile.RevealingAction();
m_Mobile.NextCombatTime =
Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds;
}
if (m_Mobile.InLOS(combatant))
{
weapon.OnBeforeSwing(m_Mobile,
combatant); //OnBeforeSwing for checking in regards to being hidden and whatnot
m_Mobile.RevealingAction();
m_Mobile.NextCombatTime =
Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds;
}
}
}
@ -8393,12 +8327,7 @@ namespace Server
PublicOverheadMessage(MessageType.Regular, SpeechHue, number, type, affix, args);
}
public void Say(int number)
{
Say(number, "");
}
public void Say(int number, string args)
public void Say(int number, string args = "")
{
PublicOverheadMessage(MessageType.Regular, SpeechHue, number, args);
}
@ -8413,12 +8342,7 @@ namespace Server
Emote(string.Format(format, args));
}
public void Emote(int number)
{
Emote(number, "");
}
public void Emote(int number, string args)
public void Emote(int number, string args = "")
{
PublicOverheadMessage(MessageType.Emote, EmoteHue, number, args);
}
@ -8433,12 +8357,7 @@ namespace Server
Whisper(string.Format(format, args));
}
public void Whisper(int number)
{
Whisper(number, "");
}
public void Whisper(int number, string args)
public void Whisper(int number, string args = "")
{
PublicOverheadMessage(MessageType.Whisper, WhisperHue, number, args);
}
@ -8453,12 +8372,7 @@ namespace Server
Yell(string.Format(format, args));
}
public void Yell(int number)
{
Yell(number, "");
}
public void Yell(int number, string args)
public void Yell(int number, string args = "")
{
PublicOverheadMessage(MessageType.Yell, YellHue, number, args);
}
@ -8467,12 +8381,7 @@ namespace Server
#region Gumps/Menus
public bool SendHuePicker(HuePicker p)
{
return SendHuePicker(p, false);
}
public bool SendHuePicker(HuePicker p, bool throwOnOffline)
public bool SendHuePicker(HuePicker p, bool throwOnOffline = false)
{
if (m_NetState != null)
{
@ -9739,88 +9648,64 @@ namespace Server
#region Overhead messages
public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text)
public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight = true)
{
PublicOverheadMessage(type, hue, ascii, text, true);
if (m_Map == null)
return;
Packet p = ascii
? (Packet)new AsciiMessage(Serial, Body, type, hue, 3, Name, text)
: new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text);
p.Acquire();
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
state.Send(p);
Packet.Release(p);
eable.Free();
}
public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight)
public void PublicOverheadMessage(MessageType type, int hue, int number, string args = "", bool noLineOfSight = true)
{
if (m_Map != null)
{
Packet p = null;
if (m_Map == null)
return;
if (ascii)
p = new AsciiMessage(Serial, Body, type, hue, 3, Name, text);
else
p = new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text);
Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args));
p.Acquire();
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
state.Send(p);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
state.Send(p);
Packet.Release(p);
Packet.Release(p);
eable.Free();
}
}
public void PublicOverheadMessage(MessageType type, int hue, int number)
{
PublicOverheadMessage(type, hue, number, "", true);
}
public void PublicOverheadMessage(MessageType type, int hue, int number, string args)
{
PublicOverheadMessage(type, hue, number, args, true);
}
public void PublicOverheadMessage(MessageType type, int hue, int number, string args, bool noLineOfSight)
{
if (m_Map != null)
{
Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args));
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
state.Send(p);
Packet.Release(p);
eable.Free();
}
eable.Free();
}
public void PublicOverheadMessage(MessageType type, int hue, int number, AffixType affixType, string affix,
string args)
string args = "", bool noLineOfSight = false)
{
PublicOverheadMessage(type, hue, number, affixType, affix, args, true);
}
if (m_Map == null)
return;
public void PublicOverheadMessage(MessageType type, int hue, int number, AffixType affixType, string affix,
string args, bool noLineOfSight)
{
if (m_Map != null)
{
Packet p = Packet.Acquire(new MessageLocalizedAffix(Serial, Body, type, hue, 3, number, Name, affixType,
affix, args));
Packet p = Packet.Acquire(new MessageLocalizedAffix(Serial, Body, type, hue, 3, number, Name, affixType,
affix, args));
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
state.Send(p);
foreach (NetState state in eable)
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
state.Send(p);
Packet.Release(p);
Packet.Release(p);
eable.Free();
}
eable.Free();
}
public void PrivateOverheadMessage(MessageType type, int hue, bool ascii, string text, NetState state)
@ -9848,73 +9733,58 @@ namespace Server
{
NetState ns = m_NetState;
if (ns != null)
{
if (ascii)
ns.Send(new AsciiMessage(Serial, Body, type, hue, 3, Name, text));
else
ns.Send(new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text));
}
if (ns == null)
return;
if (ascii)
ns.Send(new AsciiMessage(Serial, Body, type, hue, 3, Name, text));
else
ns.Send(new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text));
}
public void LocalOverheadMessage(MessageType type, int hue, int number)
public void LocalOverheadMessage(MessageType type, int hue, int number, string args = "")
{
LocalOverheadMessage(type, hue, number, "");
m_NetState?.Send(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args));
}
public void LocalOverheadMessage(MessageType type, int hue, int number, string args)
public void NonlocalOverheadMessage(MessageType type, int hue, int number, string args = "")
{
NetState ns = m_NetState;
if (m_Map == null)
return;
ns?.Send(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args));
}
Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args));
public void NonlocalOverheadMessage(MessageType type, int hue, int number)
{
NonlocalOverheadMessage(type, hue, number, "");
}
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
public void NonlocalOverheadMessage(MessageType type, int hue, int number, string args)
{
if (m_Map != null)
{
Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args));
foreach (NetState state in eable)
if (state != m_NetState && state.Mobile.CanSee(this))
state.Send(p);
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
Packet.Release(p);
foreach (NetState state in eable)
if (state != m_NetState && state.Mobile.CanSee(this))
state.Send(p);
Packet.Release(p);
eable.Free();
}
eable.Free();
}
public void NonlocalOverheadMessage(MessageType type, int hue, bool ascii, string text)
{
if (m_Map != null)
{
Packet p = null;
if (m_Map == null)
return;
if (ascii)
p = new AsciiMessage(Serial, Body, type, hue, 3, Name, text);
else
p = new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text);
Packet p = ascii
? (Packet)new AsciiMessage(Serial, Body, type, hue, 3, Name, text)
: new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text);
p.Acquire();
p.Acquire();
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable)
if (state != m_NetState && state.Mobile.CanSee(this))
state.Send(p);
foreach (NetState state in eable)
if (state != m_NetState && state.Mobile.CanSee(this))
state.Send(p);
Packet.Release(p);
Packet.Release(p);
eable.Free();
}
eable.Free();
}
#endregion
@ -9923,47 +9793,20 @@ namespace Server
public void SendLocalizedMessage(int number)
{
NetState ns = m_NetState;
ns?.Send(MessageLocalized.InstantiateGeneric(number));
m_NetState?.Send(MessageLocalized.InstantiateGeneric(number));
}
public void SendLocalizedMessage(int number, string args)
public void SendLocalizedMessage(int number, string args, int hue = 0x3B2)
{
SendLocalizedMessage(number, args, 0x3B2);
}
public void SendLocalizedMessage(int number, string args, int hue)
{
if (hue == 0x3B2 && (args == null || args.Length == 0))
{
NetState ns = m_NetState;
ns?.Send(MessageLocalized.InstantiateGeneric(number));
}
if (hue == 0x3B2 && string.IsNullOrEmpty(args))
m_NetState?.Send(MessageLocalized.InstantiateGeneric(number));
else
{
NetState ns = m_NetState;
ns?.Send(new MessageLocalized(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", args));
}
m_NetState?.Send(new MessageLocalized(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", args));
}
public void SendLocalizedMessage(int number, bool append, string affix)
public void SendLocalizedMessage(int number, bool append, string affix, string args = "", int hue = 0x3B2)
{
SendLocalizedMessage(number, append, affix, "", 0x3B2);
}
public void SendLocalizedMessage(int number, bool append, string affix, string args)
{
SendLocalizedMessage(number, append, affix, args, 0x3B2);
}
public void SendLocalizedMessage(int number, bool append, string affix, string args, int hue)
{
NetState ns = m_NetState;
ns?.Send(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System",
m_NetState?.Send(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System",
(append ? AffixType.Append : AffixType.Prepend) | AffixType.System, affix, args));
}
@ -9983,9 +9826,7 @@ namespace Server
public void SendMessage(int hue, string text)
{
NetState ns = m_NetState;
ns?.Send(new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text));
m_NetState?.Send(new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text));
}
public void SendMessage(int hue, string format, params object[] args)
@ -10005,9 +9846,7 @@ namespace Server
public void SendAsciiMessage(int hue, string text)
{
NetState ns = m_NetState;
ns?.Send(new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text));
m_NetState?.Send(new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text));
}
public void SendAsciiMessage(int hue, string format, params object[] args)