fix(core): Removes implicit cast between Serial and uint (#728)
* Fixes spellbooks using serial ctor * Fixes misc items where someone thought they had an amount and it didn't * Fixes all `Food` types.
This commit is contained in:
parent
17521c9cd7
commit
0dc4acc164
74 changed files with 319 additions and 248 deletions
|
|
@ -1029,7 +1029,7 @@ namespace Server.Accounting
|
|||
try
|
||||
{
|
||||
var index = Utility.GetXMLInt32(Utility.GetAttribute(ele, "index", "0"), 0);
|
||||
var serial = Utility.GetXMLUInt32(Utility.GetText(ele, "0"), 0);
|
||||
var serial = (Serial)Utility.GetXMLUInt32(Utility.GetText(ele, "0"), 0);
|
||||
|
||||
if (index >= 0 && index < list.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Server.Accounting
|
|||
{
|
||||
get
|
||||
{
|
||||
uint last = _lastAccount;
|
||||
var last = _lastAccount;
|
||||
|
||||
for (uint i = 0; i < uint.MaxValue; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Server.Commands.Generic
|
|||
{
|
||||
if (e.Length >= 2)
|
||||
{
|
||||
Serial serial = e.GetUInt32(0);
|
||||
Serial serial = (Serial)e.GetUInt32(0);
|
||||
|
||||
object obj = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ namespace Server.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
var ser = e.GetUInt32(0);
|
||||
var ser = (Serial)e.GetUInt32(0);
|
||||
|
||||
var ent = World.FindEntity(ser);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Server.Commands
|
|||
{
|
||||
if (e.Length == 1)
|
||||
{
|
||||
var ent = World.FindEntity(e.GetUInt32(0));
|
||||
var ent = World.FindEntity((Serial)e.GetUInt32(0));
|
||||
|
||||
if (ent == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
2 => new Hinge(3),
|
||||
3 => new Key(),
|
||||
4 => new Scissors(),
|
||||
5 => new BarrelTap(3),
|
||||
5 => new BarrelTap(),
|
||||
6 => new BarrelHoops(),
|
||||
7 => new Gears(3),
|
||||
8 => new Lockpick(3),
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ namespace Server.Engines.MLQuests
|
|||
var quest = MLQuestSystem.ReadQuestRef(reader);
|
||||
|
||||
// TODO: Serialize quester TYPE too, the quest giver reference then becomes optional (only for escorts)
|
||||
var quester = World.FindEntity(reader.ReadUInt()) as IQuestGiver;
|
||||
var quester = reader.ReadEntity<IEntity>() as IQuestGiver;
|
||||
|
||||
var claimReward = reader.ReadBool();
|
||||
var objectives = reader.ReadInt();
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace Server.Gumps
|
|||
{
|
||||
try
|
||||
{
|
||||
var serial = Utility.ToUInt32(text);
|
||||
var serial = (Serial)Utility.ToUInt32(text);
|
||||
|
||||
var toSet = World.FindEntity(serial);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Server.Items
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
|
||||
{
|
||||
return;
|
||||
|
|
@ -52,7 +52,7 @@ namespace Server.Items
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
|
||||
{
|
||||
return;
|
||||
|
|
@ -88,7 +88,7 @@ namespace Server.Items
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Server.Network
|
|||
|
||||
int packetID = reader.ReadByte();
|
||||
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BaseBulletinBoard board || !board.CheckRange(from))
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBulletinBoard board || !board.CheckRange(from))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBRequestContent(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBPostMessage(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
var thread = World.FindItem(reader.ReadUInt32()) as BulletinMessage;
|
||||
var thread = World.FindItem((Serial)reader.ReadUInt32()) as BulletinMessage;
|
||||
|
||||
if (thread != null && thread.Parent != board)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBRemoveMessage(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Server.Items
|
|||
{
|
||||
public abstract class Food : Item
|
||||
{
|
||||
public Food(int itemID, int amount) : base(itemID)
|
||||
public Food(int itemID, int amount = 1) : base(itemID)
|
||||
{
|
||||
Stackable = true;
|
||||
Amount = amount;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
public static void OnPacket(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var game = World.FindItem(reader.ReadUInt32()) as MahjongGame;
|
||||
var game = World.FindItem((Serial)reader.ReadUInt32()) as MahjongGame;
|
||||
|
||||
game?.Players.CheckPlayers();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Server.Network
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is MapItem map))
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is MapItem map))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,8 +227,6 @@ namespace Server.Items
|
|||
writer.WriteEncodedInt(TriggerRange);
|
||||
}
|
||||
|
||||
private IEntity ReadEntity(IGenericReader reader) => World.FindEntity(reader.ReadUInt());
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
|
@ -243,8 +241,8 @@ namespace Server.Items
|
|||
TriggerDelay = reader.ReadTimeSpan();
|
||||
SoundDelay = reader.ReadTimeSpan();
|
||||
|
||||
m_Source = ReadEntity(reader);
|
||||
m_Target = ReadEntity(reader);
|
||||
m_Source = reader.ReadEntity<IEntity>();
|
||||
m_Target = reader.ReadEntity<IEntity>();
|
||||
Sequence = reader.ReadEntity<EffectController>();
|
||||
|
||||
FixedDirection = reader.ReadBool();
|
||||
|
|
|
|||
|
|
@ -928,7 +928,7 @@ namespace Server.Guilds
|
|||
else
|
||||
{
|
||||
var g = uint.TryParse(arg, out var id)
|
||||
? World.FindGuild(id) as Guild
|
||||
? World.FindGuild((Serial)id) as Guild
|
||||
: FindByAbbrev(arg) as Guild ?? FindByName(arg) as Guild;
|
||||
|
||||
if (g != null)
|
||||
|
|
|
|||
|
|
@ -845,6 +845,8 @@ namespace Server.Mobiles
|
|||
PackGold(100, 200);
|
||||
}
|
||||
|
||||
private static readonly Serial _COFFEE = (Serial)0x7FC0FFEE;
|
||||
|
||||
public virtual void VendorBuy(Mobile from)
|
||||
{
|
||||
if (!IsActiveSeller)
|
||||
|
|
@ -898,7 +900,7 @@ namespace Server.Mobiles
|
|||
new BuyItemState(
|
||||
buyItem.Name,
|
||||
cont.Serial,
|
||||
disp?.Serial ?? 0x7FC0FFEE,
|
||||
disp?.Serial ?? _COFFEE,
|
||||
buyItem.Price,
|
||||
buyItem.Amount,
|
||||
buyItem.ItemID,
|
||||
|
|
|
|||
|
|
@ -3002,7 +3002,7 @@ namespace Server.Multis
|
|||
for (var i = 0; i < relocatedCount; i++)
|
||||
{
|
||||
var relLocation = reader.ReadPoint3D();
|
||||
var entity = World.FindEntity(reader.ReadUInt());
|
||||
var entity = reader.ReadEntity<IEntity>();
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1770,7 +1770,7 @@ namespace Server.Multis
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (World.FindItem(reader.ReadUInt32()) is HouseFoundation foundation && from.Map == foundation.Map &&
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is HouseFoundation foundation && from.Map == foundation.Map &&
|
||||
from.InRange(foundation.GetWorldLocation(), 24) &&
|
||||
from.CanSee(foundation))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Server.Multis
|
|||
private const int maxPerPlaneOffsetBuffer = 750;
|
||||
private static readonly int maxPackedPlaneOffsetBuffer = Zlib.MaxPackSize(maxPerPlaneOffsetBuffer * 5);
|
||||
|
||||
public static byte[] CreateHouseDesignStateDetailed(uint serial, int revision, MultiComponentList components)
|
||||
public static byte[] CreateHouseDesignStateDetailed(Serial serial, int revision, MultiComponentList components)
|
||||
{
|
||||
var xMin = components.Min.X;
|
||||
var yMin = components.Min.Y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue