Fixes cast errors (#106)
This commit is contained in:
parent
55fb749f17
commit
bc50bea867
6 changed files with 140 additions and 143 deletions
|
|
@ -805,7 +805,7 @@ namespace Server.Commands
|
|||
|
||||
if (indexOf >= 0)
|
||||
{
|
||||
// Must supress stackable warnings
|
||||
// Must suppress stackable warnings
|
||||
|
||||
bool wasStackable = item.Stackable;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,12 @@ namespace Server.Commands.Generic
|
|||
|
||||
IPooledEnumerable<IEntity> eable = map.GetObjectsInBounds(rect, items, mobiles);
|
||||
|
||||
List<object> objs = eable.Where(obj => !mobiles || !(obj is Mobile) || BaseCommand.IsAccessible(from, obj))
|
||||
.Where(obj => ext.IsValid(obj)).Cast<object>().ToList();
|
||||
List<object> objs = new List<object>();
|
||||
|
||||
foreach (IEntity obj in eable)
|
||||
if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj))
|
||||
objs.Add(obj);
|
||||
|
||||
|
||||
eable.Free();
|
||||
ext.Filter(objs);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace Server.Items
|
|||
public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
|
||||
: base(0x2006)
|
||||
{
|
||||
// To supress console warnings, stackable must be true
|
||||
// To suppress console warnings, stackable must be true
|
||||
Stackable = true;
|
||||
Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
|
||||
Stackable = false;
|
||||
|
|
@ -859,161 +859,157 @@ namespace Server.Items
|
|||
|
||||
public virtual void Open(Mobile from, bool checkSelfLoot)
|
||||
{
|
||||
if (from.AccessLevel > AccessLevel.Player || from.InRange(GetWorldLocation(), 2))
|
||||
if (from.AccessLevel <= AccessLevel.Player && !from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
#region Self Looting
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkSelfLoot && from == Owner && !GetFlag(CorpseFlag.SelfLooted) && Items.Count != 0)
|
||||
#region Self Looting
|
||||
|
||||
if (checkSelfLoot && from == Owner && !GetFlag(CorpseFlag.SelfLooted) && Items.Count != 0)
|
||||
{
|
||||
if (from.FindItemOnLayer(Layer.OuterTorso) is DeathRobe robe)
|
||||
{
|
||||
if (from.FindItemOnLayer(Layer.OuterTorso) is DeathRobe robe)
|
||||
{
|
||||
Map map = from.Map;
|
||||
Map map = from.Map;
|
||||
|
||||
if (map != null && map != Map.Internal)
|
||||
{
|
||||
robe.MoveToWorld(from.Location, map);
|
||||
robe.BeginDecay();
|
||||
}
|
||||
if (map != null && map != Map.Internal)
|
||||
{
|
||||
robe.MoveToWorld(from.Location, map);
|
||||
robe.BeginDecay();
|
||||
}
|
||||
}
|
||||
|
||||
Container pack = from.Backpack;
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if (RestoreEquip != null && pack != null)
|
||||
if (RestoreEquip != null && pack != null)
|
||||
{
|
||||
List<Item> packItems = new List<Item>(pack.Items); // Only items in the top-level pack are re-equipped
|
||||
|
||||
for (int i = 0; i < packItems.Count; i++)
|
||||
{
|
||||
List<Item>
|
||||
packItems = new List<Item>(pack.Items); // Only items in the top-level pack are re-equipped
|
||||
Item packItem = packItems[i];
|
||||
|
||||
for (int i = 0; i < packItems.Count; i++)
|
||||
{
|
||||
Item packItem = packItems[i];
|
||||
|
||||
if (RestoreEquip.Contains(packItem) && packItem.Movable)
|
||||
from.EquipItem(packItem);
|
||||
}
|
||||
if (RestoreEquip.Contains(packItem) && packItem.Movable)
|
||||
from.EquipItem(packItem);
|
||||
}
|
||||
}
|
||||
|
||||
List<Item> items = new List<Item>(Items);
|
||||
List<Item> items = new List<Item>(Items);
|
||||
|
||||
bool didntFit = false;
|
||||
bool didntFit = false;
|
||||
|
||||
for (int i = 0; !didntFit && i < items.Count; ++i)
|
||||
for (int i = 0; !didntFit && i < items.Count; ++i)
|
||||
{
|
||||
Item item = items[i];
|
||||
Point3D loc = item.Location;
|
||||
|
||||
if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable ||
|
||||
!GetRestoreInfo(item, ref loc))
|
||||
continue;
|
||||
|
||||
if (pack?.CheckHold(from, item, false, true) == true)
|
||||
{
|
||||
Item item = items[i];
|
||||
Point3D loc = item.Location;
|
||||
item.Location = loc;
|
||||
pack.AddItem(item);
|
||||
|
||||
if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable ||
|
||||
!GetRestoreInfo(item, ref loc))
|
||||
continue;
|
||||
|
||||
if (pack?.CheckHold(from, item, false, true) == true)
|
||||
{
|
||||
item.Location = loc;
|
||||
pack.AddItem(item);
|
||||
|
||||
if (RestoreEquip?.Contains(item) == true)
|
||||
from.EquipItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
didntFit = true;
|
||||
}
|
||||
}
|
||||
|
||||
from.PlaySound(0x3E3);
|
||||
|
||||
if (Items.Count != 0)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062472); // You gather some of your belongings. The rest remain on the corpse.
|
||||
if (RestoreEquip?.Contains(item) == true)
|
||||
from.EquipItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFlag(CorpseFlag.Carved, true);
|
||||
|
||||
if (ItemID == 0x2006)
|
||||
{
|
||||
ProcessDelta();
|
||||
SendRemovePacket();
|
||||
ItemID = Utility.Random(0xECA, 9); // bone graphic
|
||||
Hue = 0;
|
||||
ProcessDelta();
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(1062471); // You quickly gather all of your belongings.
|
||||
didntFit = true;
|
||||
}
|
||||
|
||||
SetFlag(CorpseFlag.SelfLooted, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
from.PlaySound(0x3E3);
|
||||
|
||||
if (!CheckLoot(from, null))
|
||||
return;
|
||||
|
||||
#region Quests
|
||||
|
||||
if (from is PlayerMobile player)
|
||||
if (Items.Count != 0)
|
||||
{
|
||||
QuestSystem qs = player.Quest;
|
||||
from.SendLocalizedMessage(1062472); // You gather some of your belongings. The rest remain on the corpse.
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFlag(CorpseFlag.Carved, true);
|
||||
|
||||
if (qs is UzeraanTurmoilQuest)
|
||||
if (ItemID == 0x2006)
|
||||
{
|
||||
GetDaemonBoneObjective obj = qs.FindObjective<GetDaemonBoneObjective>();
|
||||
if (obj?.CorpseWithBone == this && (!obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone(player)))
|
||||
{
|
||||
Item bone = new QuestDaemonBone();
|
||||
|
||||
if (player.PlaceInBackpack(bone))
|
||||
{
|
||||
obj.CorpseWithBone = null;
|
||||
player.SendLocalizedMessage(1049341, "",
|
||||
0x22); // You rummage through the bones and find a Daemon Bone! You quickly place the item in your pack.
|
||||
|
||||
if (!obj.Completed)
|
||||
obj.Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
bone.Delete();
|
||||
player.SendLocalizedMessage(1049342, "",
|
||||
0x22); // Rummaging through the bones you find a Daemon Bone, but can't pick it up because your pack is too full. Come back when you have more room in your pack.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
ProcessDelta();
|
||||
SendRemovePacket();
|
||||
ItemID = Utility.Random(0xECA, 9); // bone graphic
|
||||
Hue = 0;
|
||||
ProcessDelta();
|
||||
}
|
||||
else if (qs is TheSummoningQuest)
|
||||
{
|
||||
VanquishDaemonObjective obj = qs.FindObjective<VanquishDaemonObjective>();
|
||||
if (obj?.Completed == true && obj.CorpseWithSkull == this)
|
||||
{
|
||||
GoldenSkull sk = new GoldenSkull();
|
||||
|
||||
if (player.PlaceInBackpack(sk))
|
||||
{
|
||||
obj.CorpseWithSkull = null;
|
||||
player.SendLocalizedMessage(
|
||||
1050022); // For your valor in combating the devourer, you have been awarded a golden skull.
|
||||
qs.Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
sk.Delete();
|
||||
player.SendLocalizedMessage(
|
||||
1050023); // You find a golden skull, but your backpack is too full to carry it.
|
||||
}
|
||||
}
|
||||
}
|
||||
from.SendLocalizedMessage(1062471); // You quickly gather all of your belongings.
|
||||
}
|
||||
|
||||
#endregion
|
||||
SetFlag(CorpseFlag.SelfLooted, true);
|
||||
}
|
||||
|
||||
base.OnDoubleClick(from);
|
||||
}
|
||||
else
|
||||
#endregion
|
||||
|
||||
if (!CheckLoot(from, null))
|
||||
return;
|
||||
|
||||
#region Quests
|
||||
|
||||
if (!(from is PlayerMobile player)) return;
|
||||
|
||||
QuestSystem qs = player.Quest;
|
||||
|
||||
if (qs is UzeraanTurmoilQuest)
|
||||
{
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
GetDaemonBoneObjective obj = qs.FindObjective<GetDaemonBoneObjective>();
|
||||
if (obj?.CorpseWithBone == this && (!obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone(player)))
|
||||
{
|
||||
Item bone = new QuestDaemonBone();
|
||||
|
||||
if (player.PlaceInBackpack(bone))
|
||||
{
|
||||
obj.CorpseWithBone = null;
|
||||
player.SendLocalizedMessage(1049341, "",
|
||||
0x22); // You rummage through the bones and find a Daemon Bone! You quickly place the item in your pack.
|
||||
|
||||
if (!obj.Completed)
|
||||
obj.Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
bone.Delete();
|
||||
player.SendLocalizedMessage(1049342, "",
|
||||
0x22); // Rummaging through the bones you find a Daemon Bone, but can't pick it up because your pack is too full. Come back when you have more room in your pack.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (qs is TheSummoningQuest)
|
||||
{
|
||||
VanquishDaemonObjective obj = qs.FindObjective<VanquishDaemonObjective>();
|
||||
if (obj?.Completed == true && obj.CorpseWithSkull == this)
|
||||
{
|
||||
GoldenSkull sk = new GoldenSkull();
|
||||
|
||||
if (player.PlaceInBackpack(sk))
|
||||
{
|
||||
obj.CorpseWithSkull = null;
|
||||
player.SendLocalizedMessage(
|
||||
1050022); // For your valor in combating the devourer, you have been awarded a golden skull.
|
||||
qs.Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
sk.Delete();
|
||||
player.SendLocalizedMessage(
|
||||
1050023); // You find a golden skull, but your backpack is too full to carry it.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
base.OnDoubleClick(from);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ namespace Server.Network
|
|||
List<Item> list = beheld.EquipItems;
|
||||
|
||||
int count = list.Count;
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity(8 + count * 5);
|
||||
|
|
@ -31,13 +31,13 @@ namespace Server.Network
|
|||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write((byte)(Layer.Hair + 1));
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write((byte)(Layer.FacialHair + 1));
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
|
|
@ -55,7 +55,7 @@ namespace Server.Network
|
|||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
|
@ -87,7 +87,7 @@ namespace Server.Network
|
|||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
|
|
@ -128,9 +128,9 @@ namespace Server.Network
|
|||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity(5 + count * 20);
|
||||
|
|
@ -161,7 +161,7 @@ namespace Server.Network
|
|||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
|
|
@ -176,7 +176,7 @@ namespace Server.Network
|
|||
++written;
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
|
|
@ -195,4 +195,4 @@ namespace Server.Network
|
|||
m_Stream.Write((ushort)written);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ namespace Server.Multis
|
|||
}
|
||||
|
||||
public List<Mobile> AvailableVendorsFor(Mobile m) =>
|
||||
PlayerVendors.Where(vendor => vendor.CanInteractWith(m, false)).Cast<Mobile>().ToList();
|
||||
PlayerVendors.Where(vendor => vendor.CanInteractWith(m, false)).ToList<Mobile>();
|
||||
|
||||
public bool AreThereAvailableVendorsFor(Mobile m) =>
|
||||
PlayerVendors.Any(vendor => vendor.CanInteractWith(m, false));
|
||||
|
|
|
|||
|
|
@ -200,10 +200,7 @@ namespace Server.Items
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool CanClose()
|
||||
{
|
||||
return Map != null && !Deleted && GetObjectsInRange(0).Cast<object>().All(o => o == this);
|
||||
}
|
||||
public bool CanClose() => Map != null && !Deleted && GetObjectsInRange(0).All(o => o == this);
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue