Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 • committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -27,8 +27,8 @@ namespace Server.Mobiles
private static TimeSpan InventoryDecayTime = TimeSpan.FromHours(1.0);
private ArrayList m_ArmorBuyInfo = new ArrayList();
private ArrayList m_ArmorSellInfo = new ArrayList();
private List<IBuyItemInfo> m_ArmorBuyInfo = new List<IBuyItemInfo>();
private List<IShopSellInfo> m_ArmorSellInfo = new List<IShopSellInfo>();
public BaseVendor(string title)
: base(AIType.AI_Vendor, FightMode.None, 2, 1, 0.5, 2)
@ -39,18 +39,11 @@ namespace Server.Mobiles
InitBody();
InitOutfit();
Container pack;
//these packs MUST exist, or the client will crash when the packets are sent
pack = new Backpack();
pack.Layer = Layer.ShopBuy;
pack.Movable = false;
pack.Visible = false;
Container pack = new Backpack { Layer = Layer.ShopBuy, Movable = false, Visible = false };
AddItem(pack);
pack = new Backpack();
pack.Layer = Layer.ShopResale;
pack.Movable = false;
pack.Visible = false;
pack = new Backpack { Layer = Layer.ShopResale, Movable = false, Visible = false };
AddItem(pack);
LastRestock = DateTime.UtcNow;
@ -133,8 +126,7 @@ namespace Server.Mobiles
IShopSellInfo[] info = GetSellInfo();
int totalCost = 0;
List<BuyItemResponse> validBuy = new List<BuyItemResponse>(list.Count);
Container cont;
bool bought = false;
bool bought;
bool fromBank = false;
bool fullPurchase = true;
int controlSlots = buyer.FollowersMax - buyer.Followers;
@ -199,7 +191,7 @@ namespace Server.Mobiles
bought = buyer.AccessLevel >= AccessLevel.GameMaster;
cont = buyer.Backpack;
Container cont = buyer.Backpack;
if (!bought && cont != null)
{
if (cont.ConsumeTotal(typeof(Gold), totalCost))
@ -211,7 +203,7 @@ namespace Server.Mobiles
if (!bought && totalCost >= 2000)
{
cont = buyer.FindBankNoCreate();
if (cont != null && cont.ConsumeTotal(typeof(Gold), totalCost))
if (cont?.ConsumeTotal(typeof(Gold), totalCost) == true)
{
bought = true;
fromBank = true;
@ -268,10 +260,7 @@ namespace Server.Mobiles
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount);
if (buyItem == null)
buyItem = item;
buyItem = LiftItemDupe(item, item.Amount - amount) ?? item;
}
if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
@ -345,7 +334,6 @@ namespace Server.Mobiles
IBuyItemInfo[] buyInfo = GetBuyInfo();
int GiveGold = 0;
int Sold = 0;
Container cont;
foreach (SellItemResponse resp in list)
{
@ -398,7 +386,7 @@ namespace Server.Mobiles
if (!found)
{
cont = BuyPack;
Container cont = BuyPack;
if (amount < resp.Item.Amount)
{
@ -522,7 +510,7 @@ namespace Server.Mobiles
InitStats(100, 100, 25);
SpeechHue = Utility.RandomDyedHue();
Hue = Utility.RandomSkinHue();
Hue = Race.Human.RandomSkinHue();
if (Female = GetGender())
{
@ -551,10 +539,7 @@ namespace Server.Mobiles
public virtual int GetShoeHue()
{
if (0.1 > Utility.RandomDouble())
return 0;
return Utility.RandomNeutralHue();
return 0.1 > Utility.RandomDouble() ? 0 : Utility.RandomNeutralHue();
}
public virtual void CheckMorph()
@ -573,12 +558,7 @@ namespace Server.Mobiles
if (Map != Map.Tokuno)
return false;
NameList n;
if (Female)
n = NameList.GetNameList("tokuno female");
else
n = NameList.GetNameList("tokuno male");
NameList n = NameList.GetNameList(Female ? "tokuno female" : "tokuno male");
if (!n.ContainsName(Name))
TurnToTokuno();
@ -588,10 +568,7 @@ namespace Server.Mobiles
public virtual void TurnToTokuno()
{
if (Female)
Name = NameList.RandomName("tokuno female");
else
Name = NameList.RandomName("tokuno male");
Name = NameList.RandomName(Female ? "tokuno female" : "tokuno male");
}
public virtual bool CheckGargoyle()
@ -655,10 +632,7 @@ namespace Server.Mobiles
for (int i = 0; i < Items.Count; ++i)
{
Item item = Items[i];
if (item is Hair || item is Beard)
item.Hue = 0;
else if (item is BaseClothing || item is BaseWeapon || item is BaseArmor || item is BaseTool)
if (item is BaseClothing || item is BaseWeapon || item is BaseArmor || item is BaseTool)
item.Hue = GetRandomNecromancerHue();
}
@ -674,7 +648,7 @@ namespace Server.Mobiles
{
Item item = Items[i];
if (item is BaseClothing || item is Hair || item is Beard)
if (item is BaseClothing)
item.Delete();
}
@ -713,7 +687,7 @@ namespace Server.Mobiles
public virtual int GetHairHue()
{
return Utility.RandomHairHue();
return Race.RandomHairHue();
}
public virtual void InitOutfit()
@ -801,15 +775,13 @@ namespace Server.Mobiles
UpdateBuyInfo();
int count = 0;
List<BuyItemState> list;
IBuyItemInfo[] buyInfo = GetBuyInfo();
IShopSellInfo[] sellInfo = GetSellInfo();
list = new List<BuyItemState>(buyInfo.Length);
List<BuyItemState> list = new List<BuyItemState>(buyInfo.Length);
Container cont = BuyPack;
List<ObjectPropertyList> opls = null;
List<ObjectPropertyList> opls = new List<ObjectPropertyList>();
for (int idx = 0; idx < buyInfo.Length; idx++)
{
@ -818,19 +790,18 @@ namespace Server.Mobiles
if (buyItem.Amount <= 0 || list.Count >= 250)
continue;
// NOTE: Only GBI supported; if you use another implementation of IBuyItemInfo, this will crash
GenericBuyInfo gbi = (GenericBuyInfo)buyItem;
if (!(buyItem is GenericBuyInfo gbi))
return;
IEntity disp = gbi.GetDisplayEntity();
list.Add(new BuyItemState(buyItem.Name, cont.Serial, disp?.Serial ?? (Serial)0x7FC0FFEE, buyItem.Price,
buyItem.Amount, buyItem.ItemID, buyItem.Hue));
count++;
if (opls == null) opls = new List<ObjectPropertyList>();
if (disp is Item item)
opls.Add(item.PropertyList);
else if (disp is Mobile mobile) opls.Add(mobile.PropertyList);
else if (disp is Mobile mobile)
opls.Add(mobile.PropertyList);
}
List<Item> playerItems = cont.Items;
@ -864,10 +835,6 @@ namespace Server.Mobiles
if (name != null && list.Count < 250)
{
list.Add(new BuyItemState(name, cont.Serial, item.Serial, price, item.Amount, item.ItemID, item.Hue));
count++;
if (opls == null) opls = new List<ObjectPropertyList>();
opls.Add(item.PropertyList);
}
}
@ -876,37 +843,36 @@ namespace Server.Mobiles
//if ( list.Count > 255 )
// Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this );
if (list.Count > 0)
{
list.Sort(new BuyItemStateComparer());
if (list.Count <= 0)
return;
SendPacksTo(from);
list.Sort(new BuyItemStateComparer());
NetState ns = from.NetState;
SendPacksTo(from);
if (ns == null)
return;
NetState ns = from.NetState;
if (ns.ContainerGridLines)
from.Send(new VendorBuyContent6017(list));
else
from.Send(new VendorBuyContent(list));
if (ns == null)
return;
from.Send(new VendorBuyList(this, list));
if (ns.ContainerGridLines)
from.Send(new VendorBuyContent6017(list));
else
from.Send(new VendorBuyContent(list));
if (ns.HighSeas)
from.Send(new DisplayBuyListHS(this));
else
from.Send(new DisplayBuyList(this));
from.Send(new VendorBuyList(this, list));
from.Send(new MobileStatusExtended(from)); //make sure their gold amount is sent
if (ns.HighSeas)
from.Send(new DisplayBuyListHS(this));
else
from.Send(new DisplayBuyList(this));
if (opls != null)
for (int i = 0; i < opls.Count; ++i)
from.Send(opls[i]);
from.Send(new MobileStatusExtended(from)); //make sure their gold amount is sent
SayTo(from, 500186); // Greetings. Have a look around.
}
for (int i = 0; i < opls.Count; ++i)
from.Send(opls[i]);
SayTo(from, 500186); // Greetings. Have a look around.
}
public virtual void SendPacksTo(Mobile from)
@ -915,10 +881,7 @@ namespace Server.Mobiles
if (pack == null)
{
pack = new Backpack();
pack.Layer = Layer.ShopBuy;
pack.Movable = false;
pack.Visible = false;
pack = new Backpack { Layer = Layer.ShopBuy, Movable = false, Visible = false };
AddItem(pack);
}
@ -933,10 +896,7 @@ namespace Server.Mobiles
if (pack == null)
{
pack = new Backpack();
pack.Layer = Layer.ShopResale;
pack.Movable = false;
pack.Visible = false;
pack = new Backpack { Layer = Layer.ShopResale, Movable = false, Visible = false };
AddItem(pack);
}
@ -959,36 +919,36 @@ namespace Server.Mobiles
Container pack = from.Backpack;
if (pack != null)
if (pack == null)
return;
IShopSellInfo[] info = GetSellInfo();
Dictionary<Item, SellItemState> table = new Dictionary<Item, SellItemState>();
foreach (IShopSellInfo ssi in info)
{
IShopSellInfo[] info = GetSellInfo();
Item[] items = pack.FindItemsByType(ssi.Types);
Dictionary<Item, SellItemState> table = new Dictionary<Item, SellItemState>();
foreach (IShopSellInfo ssi in info)
foreach (Item item in items)
{
Item[] items = pack.FindItemsByType(ssi.Types);
if (item is Container container && container.Items.Count != 0)
continue;
foreach (Item item in items)
{
if (item is Container container && container.Items.Count != 0)
continue;
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
table[item] = new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item));
}
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
table[item] = new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item));
}
}
if (table.Count > 0)
{
SendPacksTo(from);
if (table.Count > 0)
{
SendPacksTo(from);
from.Send(new VendorSellList(this, table.Values));
}
else
{
Say(true, "You have nothing I would be interested in.");
}
from.Send(new VendorSellList(this, table.Values));
}
else
{
Say(true, "You have nothing I would be interested in.");
}
}
@ -1059,9 +1019,7 @@ namespace Server.Mobiles
for (int i = 0; i < buyInfo.Length; ++i)
{
GenericBuyInfo gbi = (GenericBuyInfo)buyInfo[i];
if (gbi.GetDisplayEntity() == obj)
if (buyInfo[i] is GenericBuyInfo gbi && gbi.GetDisplayEntity() == obj)
return gbi;
}
@ -1125,14 +1083,12 @@ namespace Server.Mobiles
for (int i = 1; i < amount; i++)
{
item = bii.GetEntity() as Item;
if (item != null)
if (bii.GetEntity() is Item newItem)
{
item.Amount = 1;
newItem.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
item.MoveToWorld(buyer.Location, buyer.Map);
if (cont == null || !cont.TryDropItem(buyer, newItem, false))
newItem.MoveToWorld(buyer.Location, buyer.Map);
}
}
}
@ -1151,19 +1107,15 @@ namespace Server.Mobiles
for (int i = 1; i < amount; ++i)
{
m = bii.GetEntity() as Mobile;
if (m != null)
if (bii.GetEntity() is Mobile newMobile)
{
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
newMobile.Direction = (Direction)Utility.Random(8);
newMobile.MoveToWorld(buyer.Location, buyer.Map);
bc = m as BaseCreature;
if (bc != null)
if (newMobile is BaseCreature newBc)
{
bc.SetControlMaster(buyer);
bc.ControlOrder = OrderType.Stop;
newBc.SetControlMaster(buyer);
newBc.ControlOrder = OrderType.Stop;
}
}
}
@ -1172,20 +1124,8 @@ namespace Server.Mobiles
public virtual bool CheckVendorAccess(Mobile from)
{
GuardedRegion reg = (GuardedRegion)Region.GetRegion(typeof(GuardedRegion));
if (reg != null && !reg.CheckVendorAccess(this, from))
return false;
if (Region != from.Region)
{
reg = (GuardedRegion)from.Region.GetRegion(typeof(GuardedRegion));
if (reg != null && !reg.CheckVendorAccess(this, from))
return false;
}
return true;
return Region.GetRegion<GuardedRegion>()?.CheckVendorAccess(this, from) != false ||
Region != from.Region && from.Region.GetRegion<GuardedRegion>()?.CheckVendorAccess(this, from) != false;
}
public override void Serialize(GenericWriter writer)
@ -1335,12 +1275,12 @@ namespace Server.Mobiles
public virtual IShopSellInfo[] GetSellInfo()
{
return (IShopSellInfo[])m_ArmorSellInfo.ToArray(typeof(IShopSellInfo));
return m_ArmorSellInfo.ToArray();
}
public virtual IBuyItemInfo[] GetBuyInfo()
{
return (IBuyItemInfo[])m_ArmorBuyInfo.ToArray(typeof(IBuyItemInfo));
return m_ArmorBuyInfo.ToArray();
}
private class BulkOrderInfoEntry : ContextMenuEntry
@ -1401,21 +1341,14 @@ namespace Server.Mobiles
public virtual int GetPriceScalar()
{
Town town = Town.FromRegion(Region);
if (town != null)
return 100 + town.Tax;
return 100;
return 100 + Town.FromRegion(Region)?.Tax ?? 0;
}
public void UpdateBuyInfo()
{
int priceScalar = GetPriceScalar();
IBuyItemInfo[] buyinfo = (IBuyItemInfo[])m_ArmorBuyInfo.ToArray(typeof(IBuyItemInfo));
foreach (IBuyItemInfo info in buyinfo)
foreach (IBuyItemInfo info in m_ArmorBuyInfo.ToArray())
info.PriceScalar = priceScalar;
}
@ -1516,4 +1449,4 @@ namespace Server
//called when its time for the whole shop to restock
void OnRestock();
}
}
}

View file

@ -11,22 +11,12 @@ namespace Server.Mobiles
private int m_Price;
public GenericBuyInfo(Type type, int price, int amount, int itemID, int hue) : this(null, type, price, amount,
itemID, hue, null)
{
}
public GenericBuyInfo(string name, Type type, int price, int amount, int itemID, int hue) : this(name, type, price,
amount, itemID, hue, null)
{
}
public GenericBuyInfo(Type type, int price, int amount, int itemID, int hue, object[] args) : this(null, type, price,
public GenericBuyInfo(Type type, int price, int amount, int itemID, int hue, object[] args = null) : this(null, type, price,
amount, itemID, hue, args)
{
}
public GenericBuyInfo(string name, Type type, int price, int amount, int itemID, int hue, object[] args)
public GenericBuyInfo(string name, Type type, int price, int amount, int itemID, int hue, object[] args = null)
{
Type = type;
m_Price = price;
@ -35,14 +25,10 @@ namespace Server.Mobiles
Hue = hue;
Args = args;
if (name == null)
Name = itemID < 0x4000 ? (1020000 + itemID).ToString() : (1078872 + itemID).ToString();
else
Name = name;
Name = name ?? (itemID < 0x4000 ? (1020000 + itemID).ToString() : (1078872 + itemID).ToString());
}
public virtual bool CanCacheDisplay //return ( m_Args == null || m_Args.Length == 0 ); }
=> false;
public virtual bool CanCacheDisplay => false;
public Type Type{ get; set; }
@ -315,4 +301,4 @@ namespace Server.Mobiles
}
}
}
}
}

View file

@ -59,9 +59,9 @@ namespace Server.Mobiles
public static int GetMaxStabled(Mobile from)
{
double taming = from.Skills[SkillName.AnimalTaming].Value;
double anlore = from.Skills[SkillName.AnimalLore].Value;
double vetern = from.Skills[SkillName.Veterinary].Value;
double taming = from.Skills.AnimalTaming.Value;
double anlore = from.Skills.AnimalLore.Value;
double vetern = from.Skills.Veterinary.Value;
double sklsum = taming + anlore + vetern;
int max;
@ -89,7 +89,7 @@ namespace Server.Mobiles
private void CloseClaimList(Mobile from)
{
from.CloseGump(typeof(ClaimListGump));
from.CloseGump<ClaimListGump>();
}
public void BeginClaimList(Mobile from)
@ -407,7 +407,7 @@ namespace Server.Mobiles
m_From = from;
m_List = list;
from.CloseGump(typeof(ClaimListGump));
from.CloseGump<ClaimListGump>();
AddPage(0);

View file

@ -99,7 +99,7 @@ namespace Server.Mobiles
{
if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
{
double theirSkill = pm.Skills[SkillName.Blacksmith].Base;
double theirSkill = pm.Skills.Blacksmith.Base;
if (theirSkill >= 70.1)
pm.NextSmithBulkOrder = TimeSpan.FromHours(6.0);
@ -124,7 +124,7 @@ namespace Server.Mobiles
public override bool SupportsBulkOrders(Mobile from)
{
return from is PlayerMobile && from.Skills[SkillName.Blacksmith].Base > 0;
return from is PlayerMobile && from.Skills.Blacksmith.Base > 0;
}
public override TimeSpan GetNextBulkOrder(Mobile from)

View file

@ -136,9 +136,9 @@ namespace Server.Mobiles
m_Vendor = vendor;
m_SellList = sellList;
from.CloseGump(typeof(HairstylistBuyGump));
from.CloseGump(typeof(ChangeHairHueGump));
from.CloseGump(typeof(ChangeHairstyleGump));
from.CloseGump<HairstylistBuyGump>();
from.CloseGump<ChangeHairHueGump>();
from.CloseGump<ChangeHairstyleGump>();
bool isFemale = from.Female || from.Body.IsFemale;
@ -282,9 +282,9 @@ namespace Server.Mobiles
m_FacialHair = facialHair;
m_Entries = entries;
from.CloseGump(typeof(HairstylistBuyGump));
from.CloseGump(typeof(ChangeHairHueGump));
from.CloseGump(typeof(ChangeHairstyleGump));
from.CloseGump<HairstylistBuyGump>();
from.CloseGump<ChangeHairHueGump>();
from.CloseGump<ChangeHairstyleGump>();
AddPage(0);
@ -434,9 +434,9 @@ namespace Server.Mobiles
m_FacialHair = facialHair;
m_Entries = entries;
from.CloseGump(typeof(HairstylistBuyGump));
from.CloseGump(typeof(ChangeHairHueGump));
from.CloseGump(typeof(ChangeHairstyleGump));
from.CloseGump<HairstylistBuyGump>();
from.CloseGump<ChangeHairHueGump>();
from.CloseGump<ChangeHairstyleGump>();
int tableWidth = m_FacialHair ? 2 : 3;
int tableHeight = (entries.Length + tableWidth - (m_FacialHair ? 1 : 2)) / tableWidth;

View file

@ -51,7 +51,7 @@ namespace Server.Mobiles
return false;
}
if (pm.Skills[SkillName.Stealing].Base < 60.0)
if (pm.Skills.Stealing.Base < 60.0)
{
SayTo(pm, 501051); // You must be at least a journeyman pickpocket to join this elite organization.
return false;

View file

@ -49,7 +49,7 @@ namespace Server.Mobiles
{
if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
{
double theirSkill = pm.Skills[SkillName.Tailoring].Base;
double theirSkill = pm.Skills.Tailoring.Base;
if (theirSkill >= 70.1)
pm.NextTailorBulkOrder = TimeSpan.FromHours(6.0);
@ -74,7 +74,7 @@ namespace Server.Mobiles
public override bool SupportsBulkOrders(Mobile from)
{
return from is PlayerMobile && from.Skills[SkillName.Tailoring].Base > 0;
return from is PlayerMobile && from.Skills.Tailoring.Base > 0;
}
public override TimeSpan GetNextBulkOrder(Mobile from)

View file

@ -68,7 +68,7 @@ namespace Server.Mobiles
{
if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
{
double theirSkill = pm.Skills[SkillName.Blacksmith].Base;
double theirSkill = pm.Skills.Blacksmith.Base;
if (theirSkill >= 70.1)
pm.NextSmithBulkOrder = TimeSpan.FromHours(6.0);
@ -93,7 +93,7 @@ namespace Server.Mobiles
public override bool SupportsBulkOrders(Mobile from)
{
return from is PlayerMobile && Core.AOS && from.Skills[SkillName.Blacksmith].Base > 0;
return from is PlayerMobile && Core.AOS && from.Skills.Blacksmith.Base > 0;
}
public override TimeSpan GetNextBulkOrder(Mobile from)

View file

@ -49,7 +49,7 @@ namespace Server.Mobiles
{
if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
{
double theirSkill = pm.Skills[SkillName.Tailoring].Base;
double theirSkill = pm.Skills.Tailoring.Base;
if (theirSkill >= 70.1)
pm.NextTailorBulkOrder = TimeSpan.FromHours(6.0);
@ -74,7 +74,7 @@ namespace Server.Mobiles
public override bool SupportsBulkOrders(Mobile from)
{
return from is PlayerMobile && from.Skills[SkillName.Tailoring].Base > 0;
return from is PlayerMobile && from.Skills.Tailoring.Base > 0;
}
public override TimeSpan GetNextBulkOrder(Mobile from)

View file

@ -217,28 +217,19 @@ namespace Server.Mobiles
public override bool HandlesOnSpeech(Mobile from)
{
if (InRange(from, 3))
return true;
return base.HandlesOnSpeech(from);
return InRange(from, 3) || base.HandlesOnSpeech(from);
}
private void ShoutNews_Callback(object state)
private void ShoutNews_Callback(TownCrierEntry tce, int index)
{
object[] states = (object[])state;
TownCrierEntry tce = (TownCrierEntry)states[0];
int index = (int)states[1];
if (index < 0 || index >= tce.Lines.Length)
{
m_NewsTimer?.Stop();
m_NewsTimer = null;
}
else
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, false, tce.Lines[index]);
states[1] = index + 1;
}
}
@ -278,8 +269,9 @@ namespace Server.Mobiles
}
else
{
int index = 0;
m_NewsTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(3.0),
new TimerStateCallback(ShoutNews_Callback), new object[] { tce, 0 });
() => ShoutNews_Callback(tce, index));
PublicOverheadMessage(MessageType.Regular, 0x3B2, 502978); // Some of the latest news!
}
@ -456,7 +448,7 @@ namespace Server.Mobiles
public void BeginChangeAppearance(Mobile from)
{
from.CloseGump(typeof(PlayerVendorCustomizeGump));
from.CloseGump<PlayerVendorCustomizeGump>();
from.SendGump(new PlayerVendorCustomizeGump(this, from));
}
@ -623,8 +615,8 @@ namespace Server.Mobiles
m_From = from;
m_Barkeeper = barkeeper;
from.CloseGump(typeof(BarkeeperGump));
from.CloseGump(typeof(BarkeeperTitleGump));
from.CloseGump<BarkeeperGump>();
from.CloseGump<BarkeeperTitleGump>();
Entry[] entries = m_Entries;
@ -767,8 +759,8 @@ namespace Server.Mobiles
m_From = from;
m_Barkeeper = barkeeper;
from.CloseGump(typeof(BarkeeperGump));
from.CloseGump(typeof(BarkeeperTitleGump));
from.CloseGump<BarkeeperGump>();
from.CloseGump<BarkeeperTitleGump>();
RenderBackground();
RenderCategories();

View file

@ -460,7 +460,7 @@ namespace Server.Mobiles
if (version < 1)
{
m_ShopName = "Shop Not Yet Named";
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(UpgradeFromVersion0), newVendorSystemActivated);
Timer.DelayCall(TimeSpan.Zero, UpgradeFromVersion0, newVendorSystemActivated);
}
else
{
@ -490,7 +490,7 @@ namespace Server.Mobiles
NameHue = -1;
}
private void UpgradeFromVersion0(object newVendorSystem)
private void UpgradeFromVersion0(bool newVendorSystem)
{
List<Item> toRemove = new List<Item>();
@ -505,7 +505,7 @@ namespace Server.Mobiles
House = BaseHouse.FindHouseAt(this);
if ((bool)newVendorSystem)
if (newVendorSystem)
ActivateNewVendorSystem();
}
@ -519,7 +519,7 @@ namespace Server.Mobiles
public void InitBody()
{
Hue = Utility.RandomSkinHue();
Hue = Race.Human.RandomSkinHue();
SpeechHue = 0x3B2;
if (!Core.AOS)
@ -859,8 +859,7 @@ namespace Server.Mobiles
if (IsOwner(from))
{
if (GetVendorItem(item) == null)
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(NonLocalDropCallback),
new object[] { from, item });
Timer.DelayCall(TimeSpan.Zero, () => OnItemGiven(from, item));
return true;
}
@ -869,31 +868,21 @@ namespace Server.Mobiles
return false;
}
private void NonLocalDropCallback(object state)
{
object[] aState = (object[])state;
Mobile from = (Mobile)aState[0];
Item item = (Item)aState[1];
OnItemGiven(from, item);
}
private void OnItemGiven(Mobile from, Item item)
{
VendorItem vi = GetVendorItem(item);
if (vi != null)
{
string name;
if (!string.IsNullOrEmpty(item.Name))
name = item.Name;
else
name = "#" + item.LabelNumber;
if (vi == null)
return;
from.SendLocalizedMessage(1043303, name); // Type in a price and description for ~1_ITEM~ (ESC=not for sale)
from.Prompt = new VendorPricePrompt(this, vi);
}
string name;
if (!string.IsNullOrEmpty(item.Name))
name = item.Name;
else
name = "#" + item.LabelNumber;
from.SendLocalizedMessage(1043303, name); // Type in a price and description for ~1_ITEM~ (ESC=not for sale)
from.Prompt = new VendorPricePrompt(this, vi);
}
public override bool AllowEquipFrom(Mobile from)
@ -955,15 +944,15 @@ namespace Server.Mobiles
{
if (BaseHouse.NewVendorSystem)
{
to.CloseGump(typeof(NewPlayerVendorOwnerGump));
to.CloseGump(typeof(NewPlayerVendorCustomizeGump));
to.CloseGump<NewPlayerVendorOwnerGump>();
to.CloseGump<NewPlayerVendorCustomizeGump>();
to.SendGump(new NewPlayerVendorOwnerGump(this));
}
else
{
to.CloseGump(typeof(PlayerVendorOwnerGump));
to.CloseGump(typeof(PlayerVendorCustomizeGump));
to.CloseGump<PlayerVendorOwnerGump>();
to.CloseGump<PlayerVendorCustomizeGump>();
to.SendGump(new PlayerVendorOwnerGump(this));
}
@ -1006,7 +995,7 @@ namespace Server.Mobiles
}
else
{
from.CloseGump(typeof(PlayerVendorBuyGump));
from.CloseGump<PlayerVendorBuyGump>();
from.SendGump(new PlayerVendorBuyGump(vendor, vi));
}
}
@ -1606,4 +1595,4 @@ namespace Server.Mobiles
}
}
}
}
}

View file

@ -118,8 +118,7 @@ namespace Server.Mobiles
public void SendRentalExpireMessage(Mobile to)
{
int days, hours;
ComputeRentalExpireDelay(out days, out hours);
ComputeRentalExpireDelay(out int days, out int hours);
to.SendLocalizedMessage(1062464,
days + "\t" +
@ -230,14 +229,14 @@ namespace Server.Mobiles
if (m_Vendor.IsOwner(from))
{
from.CloseGump(typeof(RenterVendorRentalGump));
from.CloseGump<RenterVendorRentalGump>();
from.SendGump(new RenterVendorRentalGump(m_Vendor));
m_Vendor.SendRentalExpireMessage(from);
}
else if (m_Vendor.IsLandlord(from))
{
from.CloseGump(typeof(LandlordVendorRentalGump));
from.CloseGump<LandlordVendorRentalGump>();
from.SendGump(new LandlordVendorRentalGump(m_Vendor));
m_Vendor.SendRentalExpireMessage(from);
@ -314,9 +313,7 @@ namespace Server.Mobiles
text = text.Trim();
int amount;
if (!int.TryParse(text, out amount))
if (!int.TryParse(text, out int amount))
amount = -1;
Mobile owner = m_Vendor.Owner;
@ -340,7 +337,7 @@ namespace Server.Mobiles
{
from.SendLocalizedMessage(1062504); // Please wait while the renter considers your offer.
owner.CloseGump(typeof(VendorRentalRefundGump));
owner.CloseGump<VendorRentalRefundGump>();
owner.SendGump(new VendorRentalRefundGump(m_Vendor, from, amount));
}
}