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

@ -329,7 +329,7 @@ namespace Server.Network
public static void EncodedCommand(NetState state, PacketReader pvSrc)
{
IEntity e = World.FindEntity(pvSrc.ReadInt32());
IEntity e = World.FindEntity(pvSrc.ReadUInt32());
int packetID = pvSrc.ReadUInt16();
EncodedPacketHandler ph = GetEncodedHandler(packetID);
@ -361,7 +361,7 @@ namespace Server.Network
public static void RenameRequest(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
Mobile targ = World.FindMobile(pvSrc.ReadInt32());
Mobile targ = World.FindMobile(pvSrc.ReadUInt32());
if (targ != null)
EventSink.InvokeRenameRequest(new RenameRequestEventArgs(from, targ, pvSrc.ReadStringSafe()));
@ -378,7 +378,7 @@ namespace Server.Network
{
case 1: // Cancel
{
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
if (World.FindItem(serial) is SecureTradeContainer cont && cont.Trade != null &&
(cont.Trade.From.Mobile == state.Mobile || cont.Trade.To.Mobile == state.Mobile))
@ -388,7 +388,7 @@ namespace Server.Network
}
case 2: // Check
{
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
if (World.FindItem(serial) is SecureTradeContainer cont)
{
@ -412,7 +412,7 @@ namespace Server.Network
}
case 3: // Update Gold
{
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
if (World.FindItem(serial) is SecureTradeContainer cont)
{
@ -447,7 +447,7 @@ namespace Server.Network
pvSrc.Seek(1, SeekOrigin.Begin);
int msgSize = pvSrc.ReadUInt16();
Mobile vendor = World.FindMobile(pvSrc.ReadInt32());
Mobile vendor = World.FindMobile(pvSrc.ReadUInt32());
byte flag = pvSrc.ReadByte();
if (vendor == null) return;
@ -469,7 +469,7 @@ namespace Server.Network
while (msgSize > 0)
{
byte layer = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
int amount = pvSrc.ReadInt16();
buyList.Add(new BuyItemResponse(serial, amount));
@ -487,7 +487,7 @@ namespace Server.Network
public static void VendorSellReply(NetState state, PacketReader pvSrc)
{
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
Mobile vendor = World.FindMobile(serial);
if (vendor == null) return;
@ -505,7 +505,7 @@ namespace Server.Network
for (int i = 0; i < count; i++)
{
Item item = World.FindItem(pvSrc.ReadInt32());
Item item = World.FindItem(pvSrc.ReadUInt32());
int Amount = pvSrc.ReadInt16();
if (item != null && Amount > 0)
@ -567,7 +567,7 @@ namespace Server.Network
{
Mobile from = state.Mobile;
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
int unk = pvSrc.ReadByte();
string lang = pvSrc.ReadString(3);
@ -590,7 +590,7 @@ namespace Server.Network
public static void MobileNameRequest(NetState state, PacketReader pvSrc)
{
Mobile m = World.FindMobile(pvSrc.ReadInt32());
Mobile m = World.FindMobile(pvSrc.ReadUInt32());
if (m != null && Utility.InUpdateRange(state.Mobile, m) && state.Mobile.CanSee(m))
state.Send(new MobileName(m));
@ -605,7 +605,7 @@ namespace Server.Network
public static void AttackReq(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
Mobile m = World.FindMobile(pvSrc.ReadInt32());
Mobile m = World.FindMobile(pvSrc.ReadUInt32());
if (m != null)
from.Attack(m);
@ -613,7 +613,7 @@ namespace Server.Network
public static void HuePickerResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
uint serial = pvSrc.ReadUInt32();
int value = pvSrc.ReadInt16();
int hue = pvSrc.ReadInt16() & 0x3FFF;
@ -836,7 +836,7 @@ namespace Server.Network
if (split.Length > 0)
{
int spellID = Utility.ToInt32(split[0]) - 1;
int serial = split.Length > 1 ? Utility.ToInt32(split[1]) : -1;
uint serial = split.Length > 1 ? Utility.ToUInt32(split[1]) : (uint)Serial.MinusOne;
EventSink.InvokeCastSpellRequest(new CastSpellRequestEventArgs(m, spellID, World.FindItem(serial)));
}
@ -892,7 +892,7 @@ namespace Server.Network
public static void AsciiPromptResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
uint serial = pvSrc.ReadUInt32();
int prompt = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string text = pvSrc.ReadStringSafe();
@ -916,7 +916,7 @@ namespace Server.Network
public static void UnicodePromptResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
uint serial = pvSrc.ReadUInt32();
int prompt = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string lang = pvSrc.ReadString(4);
@ -941,7 +941,7 @@ namespace Server.Network
public static void MenuResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
uint serial = pvSrc.ReadUInt32();
int menuID = pvSrc.ReadInt16(); // unused in our implementation
int index = pvSrc.ReadInt16();
int itemID = pvSrc.ReadInt16();
@ -966,7 +966,7 @@ namespace Server.Network
public static void ProfileReq(NetState state, PacketReader pvSrc)
{
int type = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
Mobile beholder = state.Mobile;
Mobile beheld = World.FindMobile(serial);
@ -1006,14 +1006,11 @@ namespace Server.Network
public static void LiftReq(NetState state, PacketReader pvSrc)
{
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
int amount = pvSrc.ReadUInt16();
Item item = World.FindItem(serial);
bool rejected;
LRReason reject;
state.Mobile.Lift(item, amount, out rejected, out reject);
state.Mobile.Lift(item, amount, out bool rejected, out LRReason reject);
}
public static void EquipReq(NetState state, PacketReader pvSrc)
@ -1028,7 +1025,7 @@ namespace Server.Network
if (!valid) return;
pvSrc.Seek(5, SeekOrigin.Current);
Mobile to = World.FindMobile(pvSrc.ReadInt32());
Mobile to = World.FindMobile(pvSrc.ReadUInt32());
if (to == null)
to = from;
@ -1045,7 +1042,7 @@ namespace Server.Network
int x = pvSrc.ReadInt16();
int y = pvSrc.ReadInt16();
int z = pvSrc.ReadSByte();
Serial dest = pvSrc.ReadInt32();
Serial dest = pvSrc.ReadUInt32();
Point3D loc = new Point3D(x, y, z);
@ -1083,7 +1080,7 @@ namespace Server.Network
int y = pvSrc.ReadInt16();
int z = pvSrc.ReadSByte();
pvSrc.ReadByte(); // Grid Location?
Serial dest = pvSrc.ReadInt32();
Serial dest = pvSrc.ReadUInt32();
Point3D loc = new Point3D(x, y, z);
@ -1140,7 +1137,7 @@ namespace Server.Network
int type = pvSrc.ReadByte();
int targetID = pvSrc.ReadInt32();
int flags = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16(), z = pvSrc.ReadInt16();
int graphic = pvSrc.ReadUInt16();
@ -1164,7 +1161,7 @@ namespace Server.Network
// User pressed escape
t.Cancel(from, TargetCancelType.Canceled);
}
else if (Target.TargetIDValidation && t.TargetID != targetID)
else if (t.TargetID != targetID)
{
// Sanity, prevent fake target
}
@ -1240,92 +1237,93 @@ namespace Server.Network
public static void DisplayGumpResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
uint serial = pvSrc.ReadUInt32();
int typeID = pvSrc.ReadInt32();
int buttonID = pvSrc.ReadInt32();
foreach (Gump gump in state.Gumps)
if (gump.Serial == serial && gump.TypeID == typeID)
{
if (gump.Serial != serial || gump.TypeID != typeID)
continue;
bool buttonExists = buttonID == 0; // 0 is always 'close'
if (!buttonExists)
foreach (GumpEntry e in gump.Entries)
{
if (e is GumpButton button && button.ButtonID == buttonID)
{
buttonExists = true;
break;
}
if (e is GumpImageTileButton tileButton && tileButton.ButtonID == buttonID)
{
buttonExists = true;
break;
}
}
if (!buttonExists)
{
bool buttonExists = buttonID == 0; // 0 is always 'close'
if (!buttonExists)
foreach (GumpEntry e in gump.Entries)
{
if (e is GumpButton button && button.ButtonID == buttonID)
{
buttonExists = true;
break;
}
if (e is GumpImageTileButton tileButton && tileButton.ButtonID == buttonID)
{
buttonExists = true;
break;
}
}
if (!buttonExists)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
int switchCount = pvSrc.ReadInt32();
if (switchCount < 0 || switchCount > gump.m_Switches)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
int[] switches = new int[switchCount];
for (int j = 0; j < switches.Length; ++j)
switches[j] = pvSrc.ReadInt32();
int textCount = pvSrc.ReadInt32();
if (textCount < 0 || textCount > gump.m_TextEntries)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
TextRelay[] textEntries = new TextRelay[textCount];
for (int j = 0; j < textEntries.Length; ++j)
{
int entryID = pvSrc.ReadUInt16();
int textLength = pvSrc.ReadUInt16();
if (textLength > 239)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
string text = pvSrc.ReadUnicodeStringSafe(textLength);
textEntries[j] = new TextRelay(entryID, text);
}
state.RemoveGump(gump);
GumpProfile prof = GumpProfile.Acquire(gump.GetType());
prof?.Start();
gump.OnResponse(state, new RelayInfo(buttonID, switches, textEntries));
prof?.Finish();
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
int switchCount = pvSrc.ReadInt32();
if (switchCount < 0 || switchCount > gump.m_Switches)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
int[] switches = new int[switchCount];
for (int j = 0; j < switches.Length; ++j)
switches[j] = pvSrc.ReadInt32();
int textCount = pvSrc.ReadInt32();
if (textCount < 0 || textCount > gump.m_TextEntries)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
TextRelay[] textEntries = new TextRelay[textCount];
for (int j = 0; j < textEntries.Length; ++j)
{
int entryID = pvSrc.ReadUInt16();
int textLength = pvSrc.ReadUInt16();
if (textLength > 239)
{
state.WriteConsole("Invalid gump response, disconnecting...");
state.Dispose();
return;
}
string text = pvSrc.ReadUnicodeStringSafe(textLength);
textEntries[j] = new TextRelay(entryID, text);
}
state.RemoveGump(gump);
GumpProfile prof = GumpProfile.Acquire(gump.GetType());
prof?.Start();
gump.OnResponse(state, new RelayInfo(buttonID, switches, textEntries));
prof?.Finish();
return;
}
if (typeID == 461)
{
// Virtue gump
@ -1333,7 +1331,7 @@ namespace Server.Network
if (buttonID == 1 && switchCount > 0)
{
Mobile beheld = World.FindMobile(pvSrc.ReadInt32());
Mobile beheld = World.FindMobile(pvSrc.ReadUInt32());
if (beheld != null)
EventSink.InvokeVirtueGumpRequest(new VirtueGumpRequestEventArgs(state.Mobile, beheld));
@ -1466,7 +1464,7 @@ namespace Server.Network
if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0)
{
int value = pvSrc.ReadInt32();
uint value = pvSrc.ReadUInt32();
if ((value & ~0x7FFFFFFF) != 0)
{
@ -1504,7 +1502,7 @@ namespace Server.Network
{
Mobile from = state.Mobile;
Serial s = pvSrc.ReadInt32();
Serial s = pvSrc.ReadUInt32();
if (s.IsMobile)
{
@ -1609,28 +1607,22 @@ namespace Server.Network
PacketHandler ph = GetExtendedHandler(packetID);
if (ph != null)
if (ph == null)
{
if (ph.Ingame && state.Mobile == null)
{
pvSrc.Trace(state);
return;
}
if (ph.Ingame && state.Mobile?.Deleted != false)
{
if (state.Mobile == null)
Console.WriteLine(
"Client: {0}: Sent ingame packet (0xBFx{1:X2}) before having been attached to a mobile", state,
packetID);
state.Dispose();
}
else if (ph.Ingame && state.Mobile.Deleted)
{
state.Dispose();
}
else
{
ph.OnReceive(state, pvSrc);
}
state.Dispose();
}
else
{
pvSrc.Trace(state);
}
ph.OnReceive(state, pvSrc);
}
public static void CastSpell(NetState state, PacketReader pvSrc)
@ -1643,7 +1635,7 @@ namespace Server.Network
Item spellbook = null;
if (pvSrc.ReadInt16() == 1)
spellbook = World.FindItem(pvSrc.ReadInt32());
spellbook = World.FindItem(pvSrc.ReadUInt32());
int spellID = pvSrc.ReadInt16() - 1;
@ -1659,12 +1651,12 @@ namespace Server.Network
if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0)
{
Item bandage = World.FindItem(pvSrc.ReadInt32());
Item bandage = World.FindItem(pvSrc.ReadUInt32());
if (bandage == null)
return;
Mobile target = World.FindMobile(pvSrc.ReadInt32());
Mobile target = World.FindMobile(pvSrc.ReadUInt32());
if (target == null)
return;
@ -1700,7 +1692,7 @@ namespace Server.Network
for (int i = 0; i < count; ++i)
{
Serial s = pvSrc.ReadInt32();
Serial s = pvSrc.ReadUInt32();
if (s.IsMobile)
{
@ -1727,7 +1719,7 @@ namespace Server.Network
Mobile from = state.Mobile;
Serial s = pvSrc.ReadInt32();
Serial s = pvSrc.ReadUInt32();
if (s.IsMobile)
{
@ -1789,13 +1781,13 @@ namespace Server.Network
public static void PartyMessage_RemoveMember(NetState state, PacketReader pvSrc)
{
if (PartyCommands.Handler != null)
PartyCommands.Handler.OnRemove(state.Mobile, World.FindMobile(pvSrc.ReadInt32()));
PartyCommands.Handler.OnRemove(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
}
public static void PartyMessage_PrivateMessage(NetState state, PacketReader pvSrc)
{
if (PartyCommands.Handler != null)
PartyCommands.Handler.OnPrivateMessage(state.Mobile, World.FindMobile(pvSrc.ReadInt32()),
PartyCommands.Handler.OnPrivateMessage(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()),
pvSrc.ReadUnicodeStringSafe());
}
@ -1814,13 +1806,13 @@ namespace Server.Network
public static void PartyMessage_Accept(NetState state, PacketReader pvSrc)
{
if (PartyCommands.Handler != null)
PartyCommands.Handler.OnAccept(state.Mobile, World.FindMobile(pvSrc.ReadInt32()));
PartyCommands.Handler.OnAccept(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
}
public static void PartyMessage_Decline(NetState state, PacketReader pvSrc)
{
if (PartyCommands.Handler != null)
PartyCommands.Handler.OnDecline(state.Mobile, World.FindMobile(pvSrc.ReadInt32()));
PartyCommands.Handler.OnDecline(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
}
public static void StunRequest(NetState state, PacketReader pvSrc)
@ -1875,7 +1867,7 @@ namespace Server.Network
if (menu != null && from == menu.From)
{
IEntity entity = World.FindEntity(pvSrc.ReadInt32());
IEntity entity = World.FindEntity(pvSrc.ReadUInt32());
if (entity != null && entity == menu.Target && from.CanSee(entity))
{
@ -1910,7 +1902,7 @@ namespace Server.Network
public static void ContextMenuRequest(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
IEntity target = World.FindEntity(pvSrc.ReadInt32());
IEntity target = World.FindEntity(pvSrc.ReadUInt32());
if (from != null && target != null && from.Map == target.Map && from.CanSee(target))
{
@ -1941,7 +1933,7 @@ namespace Server.Network
public static void CloseStatus(NetState state, PacketReader pvSrc)
{
Serial serial = pvSrc.ReadInt32();
Serial serial = pvSrc.ReadUInt32();
}
public static void Language(NetState state, PacketReader pvSrc)
@ -1981,7 +1973,7 @@ namespace Server.Network
pvSrc.ReadInt32(); // 0xEDEDEDED
int type = pvSrc.ReadByte();
Mobile m = World.FindMobile(pvSrc.ReadInt32());
Mobile m = World.FindMobile(pvSrc.ReadUInt32());
if (m != null)
switch (type)