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

@ -121,7 +121,7 @@ namespace Server.Items
if (tradeInfo != null)
{
if (owner.NetState != null && !owner.NetState.NewSecureTrading)
if (owner.NetState?.NewSecureTrading == false)
{
int plat = Math.DivRem(Worth, AccountGold.CurrencyThreshold, out int gold);

View file

@ -3,12 +3,7 @@ namespace Server.Items
public class Beeswax : Item
{
[Constructible]
public Beeswax() : this(1)
{
}
[Constructible]
public Beeswax(int amount) : base(0x1422)
public Beeswax(int amount = 1) : base(0x1422)
{
Weight = 1.0;
Stackable = true;
@ -34,4 +29,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -66,7 +66,7 @@ namespace Server.Items
public override void Confirm(Mobile from)
{
if (m_Item != null && !m_Item.Deleted && m_Item.IsChildOf(from.Backpack))
if (m_Item?.Deleted == false && m_Item.IsChildOf(from.Backpack))
{
if (from.HairItemID != 0)
{
@ -92,4 +92,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -20,7 +20,7 @@ namespace Server.Items
{
Mobile mob = state.Mobile;
if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster)
if (mob?.AccessLevel >= AccessLevel.GameMaster)
return new GMItemPacket(this);
return base.GetWorldPacketFor(state);
@ -51,7 +51,7 @@ namespace Server.Items
// +2 - Hue
// +1 - Flags
uint serial = (uint)item.Serial.Value;
uint serial = item.Serial.Value;
int itemID = 0x1183;
int amount = item.Amount;
Point3D loc = item.Location;
@ -102,4 +102,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -9,12 +9,7 @@ namespace Server.Items
public class Bola : Item
{
[Constructible]
public Bola() : this(1)
{
}
[Constructible]
public Bola(int amount) : base(0x26AC)
public Bola(int amount = 1) : base(0x26AC)
{
Weight = 4.0;
Stackable = true;
@ -103,13 +98,13 @@ namespace Server.Items
if (pack != null)
{
if (one != null && one.Movable)
if (one?.Movable == true)
{
pack.DropItem(one);
one = null;
}
if (two != null && two.Movable)
if (two?.Movable == true)
{
pack.DropItem(two);
two = null;
@ -118,13 +113,13 @@ namespace Server.Items
}
else if (Core.AOS)
{
if (one != null && one.Movable)
if (one?.Movable == true)
{
from.AddToBackpack(one);
one = null;
}
if (two != null && two.Movable)
if (two?.Movable == true)
{
from.AddToBackpack(two);
two = null;
@ -214,4 +209,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -3,12 +3,7 @@ namespace Server.Items
public class BolaBall : Item
{
[Constructible]
public BolaBall() : this(1)
{
}
[Constructible]
public BolaBall(int amount) : base(0xE73)
public BolaBall(int amount = 1) : base(0xE73)
{
Weight = 4.0;
Stackable = true;
@ -34,4 +29,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -468,14 +468,9 @@ namespace Server.Items
{
public BBDisplayBoard(BaseBulletinBoard board) : base(0x71)
{
string name = board.BoardName;
if (name == null)
name = "";
EnsureCapacity(38);
byte[] buffer = Utility.UTF8.GetBytes(name);
byte[] buffer = Utility.UTF8.GetBytes(board.BoardName ?? "");
m_Stream.Write((byte)0x00); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
@ -535,10 +530,7 @@ namespace Server.Items
public string SafeString(string v)
{
if (v == null)
return string.Empty;
return v;
return v ?? string.Empty;
}
}
@ -620,4 +612,4 @@ namespace Server.Items
return v;
}
}
}
}

View file

@ -46,12 +46,7 @@ namespace Server.Items
private int m_Charges;
[Constructible]
public BroadcastCrystal() : this(2000)
{
}
[Constructible]
public BroadcastCrystal(int charges) : base(0x1ED0)
public BroadcastCrystal(int charges = 2000) : base(0x1ED0)
{
Light = LightType.Circle150;
@ -452,4 +447,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -289,9 +289,9 @@ namespace Server.Items
public void Carve(Mobile from, Item item)
{
if (IsCriminalAction(from) && Map != null && (Map.Rules & MapRules.HarmfulRestrictions) != 0)
if (IsCriminalAction(from) && (Map?.Rules & MapRules.HarmfulRestrictions) != 0)
{
if (Owner == null || !Owner.Player)
if (Owner?.Player != true)
from.SendLocalizedMessage(1005035); // You did not earn the right to loot this creature!
else
from.SendLocalizedMessage(1010049); // You may not loot this corpse.
@ -339,14 +339,9 @@ namespace Server.Items
public override bool IsChildVisibleTo(Mobile m, Item child)
{
if (!m.Player || m.AccessLevel > AccessLevel.Player) //Staff and creatures not subject to instancing.
return true;
if (m_InstancedItems != null && m_InstancedItems.TryGetValue(child, out InstancedItemInfo info)
&& (InstancedCorpse || info.Perpetual))
return info.IsOwner(m); //IsOwner checks Party stuff.
return true;
return !m.Player || m.AccessLevel > AccessLevel.Player || m_InstancedItems == null ||
!m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) || !InstancedCorpse && !info.Perpetual
|| info.IsOwner(m);
}
private void AssignInstancedLoot()
@ -364,7 +359,7 @@ namespace Server.Items
{
Item item = Items[i];
if (item.LootType != LootType.Cursed) //Don't have curesd items take up someone's item spot.. (?)
if (item.LootType != LootType.Cursed) //Don't have cursed items take up someone's item spot.. (?)
{
if (item.Stackable)
m_Stackables.Add(item);
@ -384,7 +379,7 @@ namespace Server.Items
attackers[i] = temp;
}
//stackables first, for the remaining stackables, have those be randomly added after
// stackables first, for the remaining stackables, have those be randomly added after
for (int i = 0; i < m_Stackables.Count; i++)
{
@ -488,11 +483,9 @@ namespace Server.Items
public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
List<Item> initialContent, List<Item> equipItems)
{
Corpse c;
if (owner is MilitiaFighter)
c = new MilitiaFighterCorpse(owner, hair, facialhair, equipItems);
else
c = new Corpse(owner, hair, facialhair, equipItems);
Corpse c = owner is MilitiaFighter ?
new MilitiaFighterCorpse(owner, hair, facialhair, equipItems) :
new Corpse(owner, hair, facialhair, equipItems);
owner.Corpse = c;
@ -757,8 +750,8 @@ namespace Server.Items
public bool DevourCorpse()
{
if (Devoured || Deleted || Killer == null || Killer.Deleted || !Killer.Alive || !(Killer is IDevourer devourer) ||
Owner == null || Owner.Deleted)
if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || !(Killer is IDevourer devourer) ||
Owner?.Deleted != false)
return false;
m_Devourer = devourer; // Set the devourer the killer
@ -769,15 +762,15 @@ namespace Server.Items
{
base.SendInfoTo(state, sendOplPacket);
if (((Body)Amount).IsHuman && ItemID == 0x2006)
{
if (state.ContainerGridLines)
state.Send(new CorpseContent6017(state.Mobile, this));
else
state.Send(new CorpseContent(state.Mobile, this));
if (!(((Body)Amount).IsHuman && ItemID == 0x2006))
return;
state.Send(new CorpseEquip(state.Mobile, this));
}
if (state.ContainerGridLines)
state.Send(new CorpseContent6017(state.Mobile, this));
else
state.Send(new CorpseContent(state.Mobile, this));
state.Send(new CorpseEquip(state.Mobile, this));
}
public bool IsCriminalAction(Mobile from)
@ -787,7 +780,7 @@ namespace Server.Items
Party p = Party.Get(Owner);
if (p != null && p.Contains(from))
if (p?.Contains(from) == true)
{
PartyMemberInfo pmi = p[Owner];
@ -800,21 +793,12 @@ namespace Server.Items
public override bool CheckItemUse(Mobile from, Item item)
{
if (!base.CheckItemUse(from, item))
return false;
if (item != this)
return CanLoot(from, item);
return true;
return base.CheckItemUse(from, item) && (item == this || CanLoot(from, item));
}
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
{
if (!base.CheckLift(from, item, ref reject))
return false;
return CanLoot(from, item);
return base.CheckLift(from, item, ref reject) && CanLoot(from, item);
}
public override void OnItemUsed(Mobile from, Item item)
@ -888,17 +872,14 @@ namespace Server.Items
public bool CanLoot(Mobile from, Item item)
{
if (!IsCriminalAction(from))
return true;
return Map != null && (Map.Rules & MapRules.HarmfulRestrictions) == 0;
return !IsCriminalAction(from) || (Map.Rules & MapRules.HarmfulRestrictions) == 0;
}
public bool CheckLoot(Mobile from, Item item)
{
if (!CanLoot(from, item))
{
if (Owner == null || !Owner.Player)
if (Owner?.Player != true)
from.SendLocalizedMessage(1005035); // You did not earn the right to loot this creature!
else
from.SendLocalizedMessage(1010049); // You may not loot this corpse.
@ -908,7 +889,7 @@ namespace Server.Items
if (IsCriminalAction(from))
{
if (Owner == null || !Owner.Player)
if (Owner?.Player != true)
from.SendLocalizedMessage(1005036); // Looting this monster corpse will be a criminal act!
else
from.SendLocalizedMessage(1005038); // Looting this corpse will be a criminal act!
@ -965,12 +946,12 @@ namespace Server.Items
!GetRestoreInfo(item, ref loc))
continue;
if (pack != null && pack.CheckHold(from, item, false, true))
if (pack?.CheckHold(from, item, false, true) == true)
{
item.Location = loc;
pack.AddItem(item);
if (RestoreEquip != null && RestoreEquip.Contains(item))
if (RestoreEquip?.Contains(item) == true)
from.EquipItem(item);
}
else

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Network;
using Server.Spells;
using Server.Targeting;
@ -14,12 +15,7 @@ namespace Server.Items
private List<Mobile> m_Users;
[Constructible]
public Firebomb() : this(0x99B)
{
}
[Constructible]
public Firebomb(int itemID) : base(itemID)
public Firebomb(int itemID = 0x99B) : base(itemID)
{
//Name = "a firebomb";
Weight = 2.0;
@ -128,11 +124,8 @@ namespace Server.Items
}
else if (RootParent == null)
{
List<Mobile> toDamage = new List<Mobile>();
IPooledEnumerable<Mobile> eable = Map.GetMobilesInRange(Location, 1);
foreach (Mobile m in eable)
toDamage.Add(m);
List<Mobile> toDamage = eable.ToList();
eable.Free();
@ -290,4 +283,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -23,7 +23,7 @@ namespace Server.Items
public virtual void Flip(Mobile from, Item addon)
{
if (Directions != null && Directions.Length > 1)
if (Directions?.Length > 1)
try
{
MethodInfo flipMethod = addon.GetType().GetMethod(m_MethodName, m_Params);
@ -44,7 +44,7 @@ namespace Server.Items
ClearComponents(addon);
flipMethod.Invoke(addon, new object[2] { from, Directions[index] });
flipMethod.Invoke(addon, new object[] { from, Directions[index] });
BaseHouse house = null;
AddonFitResult result = AddonFitResult.Valid;
@ -86,6 +86,7 @@ namespace Server.Items
}
catch
{
// ignored
}
}
@ -113,4 +114,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Reflection;
using Server.Commands;
using Server.Targeting;
@ -56,11 +55,6 @@ namespace Server.Items
[AttributeUsage(AttributeTargets.Class)]
public class FlippableAttribute : Attribute
{
public FlippableAttribute()
: this(null)
{
}
public FlippableAttribute(params int[] itemIDs)
{
ItemIDs = itemIDs;
@ -74,12 +68,11 @@ namespace Server.Items
{
try
{
MethodInfo flipMethod = item.GetType().GetMethod("Flip", Type.EmptyTypes);
if (flipMethod != null)
flipMethod.Invoke(item, new object[0]);
item.GetType().GetMethod("Flip", Type.EmptyTypes)?.Invoke(item, new object[0]);
}
catch
{
// ignored
}
}
else
@ -99,4 +92,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -5,18 +5,13 @@ namespace Server.Items
{
public class Gold : Item
{
[Constructible]
public Gold() : this(1)
{
}
[Constructible]
public Gold(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo))
{
}
[Constructible]
public Gold(int amount) : base(0xEED)
public Gold(int amount = 1) : base(0xEED)
{
Stackable = true;
Amount = amount;
@ -82,7 +77,7 @@ namespace Server.Items
if (tradeInfo != null)
{
if (owner.NetState != null && !owner.NetState.NewSecureTrading)
if (owner.NetState?.NewSecureTrading == false)
{
int plat = Math.DivRem(Amount, AccountGold.CurrencyThreshold, out int gold);

View file

@ -74,10 +74,10 @@ namespace Server.Items
AddBackground(100, 10, 350, 355, 2600);
AddBackground(120, 54, 110, 270, 5100);
AddHtmlLocalized(70, 25, 400, 35, 1011013, false, false); // <center>Hair Color Selection Menu</center>
AddHtmlLocalized(70, 25, 400, 35, 1011013); // <center>Hair Color Selection Menu</center>
AddButton(149, 328, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(185, 329, 250, 35, 1011014, false, false); // Dye my hair this color!
AddButton(149, 328, 4005, 4007, 1);
AddHtmlLocalized(185, 329, 250, 35, 1011014); // Dye my hair this color!
for (int i = 0; i < m_Entries.Length; ++i)
{
@ -166,4 +166,4 @@ namespace Server.Items
public int HueCount{ get; }
}
}
}
}

View file

@ -79,7 +79,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(from);
return house != null && house.IsCoOwner(from);
return house?.IsCoOwner(from) == true;
}
public static bool CheckUse(InteriorDecorator tool, Mobile from)
@ -105,15 +105,14 @@ namespace Server.Items
AddBackground(0, 0, 200, 200, 2600);
AddButton(50, 45, decorator.Command == DecorateCommand.Turn ? 2154 : 2152, 2154, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(90, 50, 70, 40, 1018323, false, false); // Turn
AddButton(50, 45, decorator.Command == DecorateCommand.Turn ? 2154 : 2152, 2154, 1);
AddHtmlLocalized(90, 50, 70, 40, 1018323); // Turn
AddButton(50, 95, decorator.Command == DecorateCommand.Up ? 2154 : 2152, 2154, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(90, 100, 70, 40, 1018324, false, false); // Up
AddButton(50, 95, decorator.Command == DecorateCommand.Up ? 2154 : 2152, 2154, 2);
AddHtmlLocalized(90, 100, 70, 40, 1018324); // Up
AddButton(50, 145, decorator.Command == DecorateCommand.Down ? 2154 : 2152, 2154, 3, GumpButtonType.Reply,
0);
AddHtmlLocalized(90, 150, 70, 40, 1018325, false, false); // Down
AddButton(50, 145, decorator.Command == DecorateCommand.Down ? 2154 : 2152, 2154, 3);
AddHtmlLocalized(90, 150, 70, 40, 1018325); // Down
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -334,4 +333,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -24,32 +24,16 @@ namespace Server.Items
private uint m_KeyVal;
[Constructible]
public Key() : this(KeyType.Iron, 0)
public Key(uint val = 0) : this(KeyType.Iron, val)
{
}
[Constructible]
public Key(KeyType type) : this(type, 0)
{
}
[Constructible]
public Key(uint val) : this(KeyType.Iron, val)
{
}
[Constructible]
public Key(KeyType type, uint LockVal) : this(type, LockVal, null)
{
m_KeyVal = LockVal;
}
public Key(KeyType type, uint LockVal, Item link) : base((int)type)
public Key(KeyType type, uint val = 0, Item link = null) : base((int)type)
{
Weight = 1.0;
MaxRange = 3;
m_KeyVal = LockVal;
m_KeyVal = val;
Link = link;
}
@ -404,4 +388,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -26,7 +26,7 @@ namespace Server.Items
{
Mobile mob = state.Mobile;
if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this);
if (mob?.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this);
return base.GetWorldPacketFor(state);
}
@ -59,7 +59,7 @@ namespace Server.Items
// +2 - Hue
// +1 - Flags
uint serial = (uint)item.Serial.Value;
uint serial = item.Serial.Value;
int itemID = 0x36FF;
int amount = item.Amount;
Point3D loc = item.Location;
@ -110,4 +110,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Linq;
namespace Server.Items
{
@ -80,21 +81,8 @@ namespace Server.Items
public void Refresh()
{
bool found = false;
foreach (Mobile mob in GetMobilesInRange(CurrentRange))
{
if (mob.Hidden && mob.AccessLevel > AccessLevel.Player)
continue;
found = true;
break;
}
if (found)
ItemID = ActiveItemID;
else
ItemID = InactiveItemID;
bool found = GetMobilesInRange(CurrentRange).Any(mob => !mob.Hidden || mob.AccessLevel <= AccessLevel.Player);
ItemID = found ? ActiveItemID : InactiveItemID;
Visible = ItemID != 0x1;
}
@ -141,4 +129,4 @@ namespace Server.Items
Timer.DelayCall(TimeSpan.Zero, Refresh);
}
}
}
}

View file

@ -27,7 +27,7 @@ namespace Server.Items
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( 0 ); // version
}
public override void Deserialize( GenericReader reader )
@ -56,7 +56,7 @@ namespace Server.Items
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( 0 ); // version
}
public override void Deserialize( GenericReader reader )
@ -99,7 +99,7 @@ namespace Server.Items
{
base.Serialize( writer );
writer.Write( (int) 1 );
writer.Write( 1 );
writer.Write( (int) Level );
@ -441,7 +441,7 @@ namespace Server.Items
{
if ( page >= 1 && page <= board.Messages.Count )
{
PlayerBBMessage message = (PlayerBBMessage)board.Messages[page - 1];
PlayerBBMessage message = board.Messages[page - 1];
Mobile poster = message.Poster;
if ( poster == null )
@ -510,7 +510,7 @@ namespace Server.Items
PlayerBBMessage message = board.Greeting;
if ( page >= 1 && page <= board.Messages.Count )
message = (PlayerBBMessage)board.Messages[page - 1];
message = board.Messages[page - 1];
from.SendGump( new PlayerBBGump( from, house, board, page ) );
from.SendGump( new PropertiesGump( from, message ) );
@ -534,26 +534,26 @@ namespace Server.Items
AddImage( 30, 30, 5400 );
AddButton( 393, 145, 2084, 2084, 4, GumpButtonType.Reply, 0 ); // Scroll up
AddButton( 390, 371, 2085, 2085, 5, GumpButtonType.Reply, 0 ); // Scroll down
AddButton( 393, 145, 2084, 2084, 4); // Scroll up
AddButton( 390, 371, 2085, 2085, 5); // Scroll down
AddButton( 32, 183, 5412, 5413, 1, GumpButtonType.Reply, 0 ); // Post message
AddButton( 32, 183, 5412, 5413, 1); // Post message
if ( house.IsOwner( from ) )
{
AddButton( 63, 90, 5601, 5605, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 81, 89, 230, 20, 1062400, LabelColor, false, false ); // Set title
AddButton( 63, 90, 5601, 5605, 2);
AddHtmlLocalized( 81, 89, 230, 20, 1062400, LabelColor ); // Set title
AddButton( 63, 109, 5601, 5605, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 81, 108, 230, 20, 1062401, LabelColor, false, false ); // Post greeting
AddButton( 63, 109, 5601, 5605, 3);
AddHtmlLocalized( 81, 108, 230, 20, 1062401, LabelColor ); // Post greeting
}
string title = board.Title;
if ( title != null )
AddHtml( 183, 68, 180, 23, title, false, false );
AddHtml( 183, 68, 180, 23, title );
AddHtmlLocalized( 385, 89, 60, 20, 1062409, LabelColor, false, false ); // Post
AddHtmlLocalized( 385, 89, 60, 20, 1062409, LabelColor ); // Post
AddLabel( 440, 89, LabelHue, page.ToString() );
AddLabel( 455, 89, LabelHue, "/" );
@ -562,16 +562,16 @@ namespace Server.Items
PlayerBBMessage message = board.Greeting;
if ( page >= 1 && page <= board.Messages.Count )
message = (PlayerBBMessage)board.Messages[page - 1];
message = board.Messages[page - 1];
AddImageTiled( 150, 220, 240, 1, 2700 ); // Separator
AddHtmlLocalized( 150, 180, 100, 20, 1062405, 16715, false, false ); // Posted On:
AddHtmlLocalized( 150, 200, 100, 20, 1062406, 16715, false, false ); // Posted By:
AddHtmlLocalized( 150, 180, 100, 20, 1062405, 16715 ); // Posted On:
AddHtmlLocalized( 150, 200, 100, 20, 1062406, 16715 ); // Posted By:
if ( message != null )
{
AddHtml( 255, 180, 150, 20, message.Time.ToString( "yyyy-MM-dd HH:mm:ss" ), false, false );
AddHtml( 255, 180, 150, 20, message.Time.ToString( "yyyy-MM-dd HH:mm:ss" ) );
Mobile poster = message.Poster;
string name = poster?.Name;
@ -579,26 +579,21 @@ namespace Server.Items
if ( name == null || (name = name.Trim()).Length == 0 )
name = "Someone";
AddHtml( 255, 200, 150, 20, name, false, false );
AddHtml( 255, 200, 150, 20, name );
string body = message.Message;
if ( body == null )
body = "";
AddHtml( 150, 240, 250, 100, body, false, false );
AddHtml( 150, 240, 250, 100, message.Message ?? "" );
if ( message != board.Greeting && house.IsOwner( from ) )
{
AddButton( 130, 395, 1209, 1210, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 150, 393, 150, 20, 1062410, LabelColor, false, false ); // Banish Poster
AddButton( 130, 395, 1209, 1210, 6);
AddHtmlLocalized( 150, 393, 150, 20, 1062410, LabelColor ); // Banish Poster
AddButton( 310, 395, 1209, 1210, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 330, 393, 150, 20, 1062411, LabelColor, false, false ); // Delete Message
AddButton( 310, 395, 1209, 1210, 7);
AddHtmlLocalized( 330, 393, 150, 20, 1062411, LabelColor ); // Delete Message
}
if ( from.AccessLevel >= AccessLevel.GameMaster )
AddButton( 135, 242, 1209, 1210, 8, GumpButtonType.Reply, 0 ); // Post props
AddButton( 135, 242, 1209, 1210, 8); // Post props
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
@ -325,10 +324,10 @@ namespace Server.Items
AddBackground(95, 20, 442, 90, 0xA28);
AddHtml(229, 35, 300, 45, "GENERATOR CONTROL PANEL", false, false);
AddHtml(229, 35, 300, 45, "GENERATOR CONTROL PANEL");
AddHtml(223, 60, 300, 70, "Use the Directional Controls to", false, false);
AddHtml(253, 75, 300, 85, "Close the Grid Circuit", false, false);
AddHtml(223, 60, 300, 70, "Use the Directional Controls to");
AddHtml(253, 75, 300, 85, "Close the Grid Circuit");
AddImage(140, 40, 0x28D3);
AddImage(420, 40, 0x28D3);
@ -341,10 +340,10 @@ namespace Server.Items
AddImage(414, 189, 0x589);
AddImage(435, 210, 0xA52);
AddButton(408, 222, 0x29EA, 0x29EC, 1, GumpButtonType.Reply, 0); // Left
AddButton(448, 185, 0x29CC, 0x29CE, 2, GumpButtonType.Reply, 0); // Up
AddButton(473, 222, 0x29D6, 0x29D8, 3, GumpButtonType.Reply, 0); // Right
AddButton(448, 243, 0x29E0, 0x29E2, 4, GumpButtonType.Reply, 0); // Down
AddButton(408, 222, 0x29EA, 0x29EC, 1); // Left
AddButton(448, 185, 0x29CC, 0x29CE, 2); // Up
AddButton(473, 222, 0x29D6, 0x29D8, 3); // Right
AddButton(448, 243, 0x29E0, 0x29E2, 4); // Down
AddBackground(90, 115, 30 + 40 * sideLength, 30 + 40 * sideLength, 0xA28);
AddBackground(100, 125, 10 + 40 * sideLength, 10 + 40 * sideLength, 0x1400);
@ -385,8 +384,8 @@ namespace Server.Items
if (from.Skills.Lockpicking.Value >= 65.0)
{
AddButton(365, 350, 0xFA6, 0xFA7, 5, GumpButtonType.Reply, 0);
AddHtml(405, 345, 140, 40, "Attempt to Decipher the Circuit Path", false, false);
AddButton(365, 350, 0xFA6, 0xFA7, 5);
AddHtml(405, 345, 140, 40, "Attempt to Decipher the Circuit Path");
}
}

View file

@ -58,7 +58,7 @@ namespace Server.Items
{
base.Serialize( writer );
writer.Write( (int)0 );
writer.Write( 0 );
}
public override void Deserialize( GenericReader reader )
@ -82,11 +82,11 @@ namespace Server.Items
AddPage( 0 );
AddBackground( 0, 0, 240, 135, 0x2422 );
AddHtmlLocalized( 15, 15, 210, 75, 1070972, 0x0, true, false ); // Click "OKAY" to redeem the following promotional item:
AddHtmlLocalized( 15, 15, 210, 75, 1070972, 0x0, true ); // Click "OKAY" to redeem the following promotional item:
TextDefinition.AddHtmlText( this, 15, 60, 210, 75, m_Token.ItemGumpName, false, false );
AddButton( 160, 95, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 ); //Okay
AddButton( 90, 95, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0 ); //Cancel
AddButton( 160, 95, 0xF7, 0xF8, 1); //Okay
AddButton( 90, 95, 0xF2, 0xF1, 0); //Cancel
}
public override void OnResponse( NetState sender, RelayInfo info )
@ -143,7 +143,7 @@ namespace Server.Items
{
base.Serialize( writer );
writer.Write( (int)0 );
writer.Write( 0 );
}
public override void Deserialize( GenericReader reader )

View file

@ -314,18 +314,18 @@ namespace Server.Items
AddBackground(0, 0, 380, 280, 5054);
AddButton(10, 210, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(45, 210, 140, 25, 1011036, false, false); // OKAY
AddButton(10, 210, 4005, 4007, 1);
AddHtmlLocalized(45, 210, 140, 25, 1011036); // OKAY
AddButton(10, 235, 4005, 4007, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(45, 235, 140, 25, 1011012, false, false); // CANCEL
AddButton(10, 235, 4005, 4007, 0);
AddHtmlLocalized(45, 235, 140, 25, 1011012); // CANCEL
AddHtmlLocalized(5, 5, 200, 20, 1012011, false, false); // Pick your destination:
AddHtmlLocalized(5, 5, 200, 20, 1012011); // Pick your destination:
for (int i = 0; i < checkLists.Length; ++i)
{
AddButton(10, 35 + i * 25, 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(m_Lists, checkLists[i]) + 1);
AddHtmlLocalized(30, 35 + i * 25, 150, 20, checkLists[i].Number, false, false);
AddHtmlLocalized(30, 35 + i * 25, 150, 20, checkLists[i].Number);
}
for (int i = 0; i < m_Lists.Length; ++i)
@ -339,14 +339,14 @@ namespace Server.Items
AddPage(index + 1);
AddButton(10, 35 + offset * 25, 2117, 2118, 0, GumpButtonType.Page, index + 1);
AddHtmlLocalized(30, 35 + offset * 25, 150, 20, list.SelNumber, false, false);
AddHtmlLocalized(30, 35 + offset * 25, 150, 20, list.SelNumber);
PMEntry[] entries = list.Entries;
for (int i = 0; i < entries.Length; ++i)
{
AddRadio(200, 35 + i * 25, 210, 211, false, index * 100 + i);
AddHtmlLocalized(225, 35 + i * 25, 150, 20, entries[i].Number, false, false);
AddHtmlLocalized(225, 35 + i * 25, 150, 20, entries[i].Number);
}
}
@ -418,4 +418,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -3,12 +3,7 @@ namespace Server.Items
public class Rope : Item
{
[Constructible]
public Rope() : this(1)
{
}
[Constructible]
public Rope(int amount) : base(0x14F8)
public Rope(int amount = 1) : base(0x14F8)
{
Stackable = true;
Weight = 1.0;
@ -38,12 +33,7 @@ namespace Server.Items
public class IronWire : Item
{
[Constructible]
public IronWire() : this(1)
{
}
[Constructible]
public IronWire(int amount) : base(0x1876)
public IronWire(int amount = 1) : base(0x1876)
{
Stackable = true;
Weight = 5.0;
@ -76,12 +66,7 @@ namespace Server.Items
public class SilverWire : Item
{
[Constructible]
public SilverWire() : this(1)
{
}
[Constructible]
public SilverWire(int amount) : base(0x1877)
public SilverWire(int amount = 1) : base(0x1877)
{
Stackable = true;
Weight = 5.0;
@ -114,12 +99,7 @@ namespace Server.Items
public class GoldWire : Item
{
[Constructible]
public GoldWire() : this(1)
{
}
[Constructible]
public GoldWire(int amount) : base(0x1878)
public GoldWire(int amount = 1) : base(0x1878)
{
Stackable = true;
Weight = 5.0;
@ -152,12 +132,7 @@ namespace Server.Items
public class CopperWire : Item
{
[Constructible]
public CopperWire() : this(1)
{
}
[Constructible]
public CopperWire(int amount) : base(0x1879)
public CopperWire(int amount = 1) : base(0x1879)
{
Stackable = true;
Weight = 5.0;
@ -190,12 +165,7 @@ namespace Server.Items
public class WhiteDriedFlowers : Item
{
[Constructible]
public WhiteDriedFlowers() : this(1)
{
}
[Constructible]
public WhiteDriedFlowers(int amount) : base(0xC3C)
public WhiteDriedFlowers(int amount = 1) : base(0xC3C)
{
Stackable = true;
Weight = 1.0;
@ -225,12 +195,7 @@ namespace Server.Items
public class GreenDriedFlowers : Item
{
[Constructible]
public GreenDriedFlowers() : this(1)
{
}
[Constructible]
public GreenDriedFlowers(int amount) : base(0xC3E)
public GreenDriedFlowers(int amount = 1) : base(0xC3E)
{
Stackable = true;
Weight = 1.0;
@ -260,12 +225,7 @@ namespace Server.Items
public class DriedOnions : Item
{
[Constructible]
public DriedOnions() : this(1)
{
}
[Constructible]
public DriedOnions(int amount) : base(0xC40)
public DriedOnions(int amount = 1) : base(0xC40)
{
Stackable = true;
Weight = 1.0;
@ -295,12 +255,7 @@ namespace Server.Items
public class DriedHerbs : Item
{
[Constructible]
public DriedHerbs() : this(1)
{
}
[Constructible]
public DriedHerbs(int amount) : base(0xC42)
public DriedHerbs(int amount = 1) : base(0xC42)
{
Stackable = true;
Weight = 1.0;
@ -704,4 +659,4 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -9,11 +9,7 @@ namespace Server.Items
{
}
public SerpentPillar(string word, Rectangle2D destination) : this(word, destination, true)
{
}
public SerpentPillar(string word, Rectangle2D destination, bool active) : base(0x233F)
public SerpentPillar(string word, Rectangle2D destination, bool active = true) : base(0x233F)
{
Movable = false;

View file

@ -69,9 +69,9 @@ namespace Server.Items
AddPage(0);
AddBackground(150, 60, 350, 358, 2600);
AddBackground(170, 104, 110, 270, 5100);
AddHtmlLocalized(230, 75, 200, 20, 1011013, false, false); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1013007, false, false); // Dye my beard this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); // DYE HAIR
AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1013007); // Dye my beard this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR
for (int i = 0; i < m_Entries.Length; ++i)
{
@ -159,4 +159,4 @@ namespace Server.Items
public int HueCount{ get; }
}
}
}
}

View file

@ -69,9 +69,9 @@ namespace Server.Items
AddPage(0);
AddBackground(150, 60, 350, 358, 2600);
AddBackground(170, 104, 110, 270, 5100);
AddHtmlLocalized(230, 75, 200, 20, 1011013, false, false); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1011014, false, false); // Dye my hair this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); // DYE HAIR
AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1011014); // Dye my hair this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR
for (int i = 0; i < m_Entries.Length; ++i)
{
@ -160,4 +160,4 @@ namespace Server.Items
public int HueCount{ get; }
}
}
}
}

View file

@ -18,20 +18,12 @@ namespace Server.Items
private bool m_SourceEffect;
[Constructible]
public Teleporter()
: this(new Point3D(0, 0, 0), null, false)
public Teleporter() : this(new Point3D(0, 0, 0))
{
}
[Constructible]
public Teleporter(Point3D pointDest, Map mapDest)
: this(pointDest, mapDest, false)
{
}
[Constructible]
public Teleporter(Point3D pointDest, Map mapDest, bool creatures)
: base(0x1BC3)
public Teleporter(Point3D pointDest, Map mapDest = null, bool creatures = false) : base(0x1BC3)
{
Movable = false;
Visible = false;
@ -45,8 +37,7 @@ namespace Server.Items
m_CriminalCheck = false;
}
public Teleporter(Serial serial)
: base(serial)
public Teleporter(Serial serial) : base(serial)
{
}

View file

@ -30,7 +30,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
Effects.PlaySound(Location, Map, 0x3B3);
from.SendLocalizedMessage(500461); // You destroy the item.
@ -144,4 +144,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -3,12 +3,7 @@ namespace Server.Items
public class TribalBerry : Item
{
[Constructible]
public TribalBerry() : this(1)
{
}
[Constructible]
public TribalBerry(int amount) : base(0x9D0)
public TribalBerry(int amount = 1) : base(0x9D0)
{
Weight = 1.0;
Stackable = true;
@ -40,4 +35,4 @@ namespace Server.Items
Hue = 6;
}
}
}
}

View file

@ -9,15 +9,11 @@ namespace Server.Items
private WayPoint m_Next;
[Constructible]
public WayPoint() : base(0x1f14)
public WayPoint(WayPoint prev = null) : base(0x1f14)
{
Hue = 0x498;
Visible = false;
//this.Movable = false;
}
public WayPoint(WayPoint prev) : this()
{
if (prev != null)
prev.NextPoint = this;
}
@ -147,4 +143,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -52,17 +52,14 @@ namespace Server.Items
public bool IsOwner(Mobile mob)
{
BaseHouse house = BaseHouse.FindHouseAt(this);
return house != null && house.IsOwner(mob);
return BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
}
public override void OnDoubleClick(Mobile from)
{
if (IsOwner(from))
{
OnOffGump onOffGump = new OnOffGump(this);
from.SendGump(onOffGump);
from.SendGump(new OnOffGump(this));
}
else
{
@ -104,12 +101,11 @@ namespace Server.Items
m_Chimes = chimes;
AddBackground(0, 0, 300, 150, 0xA28);
AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034, false,
false); // [De]Activate this item
AddButton(40, 53, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(80, 55, 65, 35, 1011036, false, false); // OKAY
AddButton(150, 53, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(190, 55, 100, 35, 1011012, false, false); // CANCEL
AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034); // [De]Activate this item
AddButton(40, 53, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY
AddButton(150, 53, 0xFA5, 0xFA7, 0);
AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -184,4 +180,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}