Adds more unit tests (#133)

This commit is contained in:
Kamron Batman 2020-05-08 20:32:59 -07:00 • committed by GitHub
parent e138706536
commit 8278694105
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 1406 additions and 996 deletions

View file

@ -0,0 +1,59 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: AccountPackets.cs - Created: 2020/05/08 - Updated: 2020/05/08 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.Accounting;
namespace Server.Network
{
public sealed class ChangeCharacter : Packet
{
public ChangeCharacter(IAccount a) : base(0x81)
{
EnsureCapacity(305);
var count = 0;
for (var i = 0; i < a.Length; ++i)
if (a[i] != null)
++count;
Stream.Write((byte)count);
Stream.Write((byte)0);
for (var i = 0; i < a.Length; ++i)
if (a[i] != null)
{
var name = a[i].Name;
if (name == null)
name = "-null-";
else if ((name = name.Trim()).Length == 0)
name = "-empty-";
Stream.WriteAsciiFixed(name, 30);
Stream.Fill(30); // password
}
else
{
Stream.Fill(60);
}
}
}
}

View file

@ -0,0 +1,64 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: ArrowPackets.cs - Created: 2020/05/03 - Updated: 2020/05/03 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class CancelArrow : Packet
{
public CancelArrow() : base(0xBA, 6)
{
Stream.Write((byte)0);
Stream.Write((short)-1);
Stream.Write((short)-1);
}
}
public sealed class SetArrow : Packet
{
public SetArrow(int x, int y) : base(0xBA, 6)
{
Stream.Write((byte)1);
Stream.Write((short)x);
Stream.Write((short)y);
}
}
public sealed class CancelArrowHS : Packet
{
public CancelArrowHS(int x, int y, Serial s) : base(0xBA, 10)
{
Stream.Write((byte)0);
Stream.Write((short)x);
Stream.Write((short)y);
Stream.Write(s);
}
}
public sealed class SetArrowHS : Packet
{
public SetArrowHS(int x, int y, Serial s) : base(0xBA, 10)
{
Stream.Write((byte)1);
Stream.Write((short)x);
Stream.Write((short)y);
Stream.Write(s);
}
}
}

View file

@ -0,0 +1,56 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: DamagePackets.cs - Created: 2020/05/03 - Updated: 2020/05/03 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class DamagePacketOld : Packet
{
public DamagePacketOld(Mobile m, int amount) : base(0xBF)
{
EnsureCapacity(11);
Stream.Write((short)0x22);
Stream.Write((byte)1);
Stream.Write(m.Serial);
if (amount > 255)
amount = 255;
else if (amount < 0)
amount = 0;
Stream.Write((byte)amount);
}
}
public sealed class DamagePacket : Packet
{
public DamagePacket(Mobile m, int amount) : base(0x0B, 7)
{
Stream.Write(m.Serial);
if (amount > 0xFFFF)
amount = 0xFFFF;
else if (amount < 0)
amount = 0;
Stream.Write((ushort)amount);
}
}
}

View file

@ -0,0 +1,35 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: DisplayHuePicker.cs *
* Created: 2020/05/08 - Updated: 2020/05/08 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.HuePickers;
namespace Server.Network
{
public sealed class DisplayHuePicker : Packet
{
public DisplayHuePicker(HuePicker huePicker) : base(0x95, 9)
{
Stream.Write(huePicker.Serial);
Stream.Write((short)0);
Stream.Write((short)huePicker.ItemID);
}
}
}

View file

@ -0,0 +1,131 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: EquipmentPackets.cs - Created: 2020/05/07 - Updated: 2020/05/07 * *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server.Network
{
public class EquipInfoAttribute
{
public EquipInfoAttribute(int number, int charges = -1)
{
Number = number;
Charges = charges;
}
public int Number { get; }
public int Charges { get; }
}
public class EquipmentInfo
{
public EquipmentInfo(int number, Mobile crafter, bool unidentified, EquipInfoAttribute[] attributes)
{
Number = number;
Crafter = crafter;
Unidentified = unidentified;
Attributes = attributes;
}
public int Number { get; }
public Mobile Crafter { get; }
public bool Unidentified { get; }
public EquipInfoAttribute[] Attributes { get; }
}
public sealed class DisplayEquipmentInfo : Packet
{
public DisplayEquipmentInfo(Item item, EquipmentInfo info) : base(0xBF)
{
var attrs = info.Attributes;
EnsureCapacity(17 + (info.Crafter?.Name?.Length ?? 0) +
(info.Unidentified ? 4 : 0) + attrs.Length * 6);
Stream.Write((short)0x10);
Stream.Write(item.Serial);
Stream.Write(info.Number);
if (info.Crafter != null)
{
var name = info.Crafter.Name;
Stream.Write(-3);
if (name == null)
{
Stream.Write((ushort)0);
}
else
{
var length = name.Length;
Stream.Write((ushort)length);
Stream.WriteAsciiFixed(name, length);
}
}
if (info.Unidentified) Stream.Write(-4);
for (var i = 0; i < attrs.Length; ++i)
{
Stream.Write(attrs[i].Number);
Stream.Write((short)attrs[i].Charges);
}
Stream.Write(-1);
}
}
public sealed class EquipUpdate : Packet
{
public EquipUpdate(Item item) : base(0x2E, 15)
{
Serial parentSerial;
var parent = item.Parent as Mobile;
var hue = item.Hue;
if (parent != null)
{
parentSerial = parent.Serial;
if (parent.SolidHueOverride >= 0)
hue = parent.SolidHueOverride;
}
else
{
Console.WriteLine("Warning: EquipUpdate on item with !(parent is Mobile)");
parentSerial = Serial.Zero;
}
Stream.Write(item.Serial);
Stream.Write((short)item.ItemID);
Stream.Write((byte)0);
Stream.Write((byte)item.Layer);
Stream.Write(parentSerial);
Stream.Write((short)hue);
}
}
}

View file

@ -0,0 +1,54 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: MapPackets.cs - Created: 2020/05/03 - Updated: 2020/05/08 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class MapPatches : Packet
{
// TODO: Base this on the client version and expansion
public MapPatches() : base(0xBF)
{
EnsureCapacity(9 + 4 * 8);
Stream.Write((short)0x0018);
Stream.Write(4);
Stream.Write(Map.Felucca.Tiles.Patch.StaticBlocks);
Stream.Write(Map.Felucca.Tiles.Patch.LandBlocks);
Stream.Write(Map.Trammel.Tiles.Patch.StaticBlocks);
Stream.Write(Map.Trammel.Tiles.Patch.LandBlocks);
Stream.Write(Map.Ilshenar.Tiles.Patch.StaticBlocks);
Stream.Write(Map.Ilshenar.Tiles.Patch.LandBlocks);
Stream.Write(Map.Malas.Tiles.Patch.StaticBlocks);
Stream.Write(Map.Malas.Tiles.Patch.LandBlocks);
}
}
public sealed class InvalidMapEnable : Packet
{
public InvalidMapEnable() : base(0xC6, 1)
{
}
}
}

View file

@ -0,0 +1,228 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: MenuPackets.cs - Created: 2020/05/08 - Updated: 2020/05/08 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.ContextMenus;
using Server.Menus;
using Server.Menus.ItemLists;
using Server.Menus.Questions;
namespace Server.Network
{
public sealed class DisplayItemListMenu : Packet
{
public DisplayItemListMenu(ItemListMenu menu) : base(0x7C)
{
EnsureCapacity(256);
Stream.Write(((IMenu)menu).Serial);
Stream.Write((short)0);
var question = menu.Question;
if (question == null)
{
Stream.Write((byte)0);
}
else
{
var questionLength = question.Length;
Stream.Write((byte)questionLength);
Stream.WriteAsciiFixed(question, questionLength);
}
var entries = menu.Entries;
int entriesLength = (byte)entries.Length;
Stream.Write((byte)entriesLength);
for (var i = 0; i < entriesLength; ++i)
{
var e = entries[i];
Stream.Write((ushort)e.ItemID);
Stream.Write((short)e.Hue);
var name = e.Name;
if (name == null)
{
Stream.Write((byte)0);
}
else
{
var nameLength = name.Length;
Stream.Write((byte)nameLength);
Stream.WriteAsciiFixed(name, nameLength);
}
}
}
}
public sealed class DisplayQuestionMenu : Packet
{
public DisplayQuestionMenu(QuestionMenu menu) : base(0x7C)
{
EnsureCapacity(256);
Stream.Write(((IMenu)menu).Serial);
Stream.Write((short)0);
var question = menu.Question;
if (question == null)
{
Stream.Write((byte)0);
}
else
{
var questionLength = question.Length;
Stream.Write((byte)questionLength);
Stream.WriteAsciiFixed(question, questionLength);
}
var answers = menu.Answers;
int answersLength = (byte)answers.Length;
Stream.Write((byte)answersLength);
for (var i = 0; i < answersLength; ++i)
{
Stream.Write(0);
var answer = answers[i];
if (answer == null)
{
Stream.Write((byte)0);
}
else
{
var answerLength = answer.Length;
Stream.Write((byte)answerLength);
Stream.WriteAsciiFixed(answer, answerLength);
}
}
}
}
public sealed class DisplayContextMenu : Packet
{
public DisplayContextMenu(ContextMenu menu) : base(0xBF)
{
var entries = menu.Entries;
int length = (byte)entries.Length;
EnsureCapacity(12 + length * 8);
Stream.Write((short)0x14);
Stream.Write((short)0x02);
var target = menu.Target;
Stream.Write(target.Serial);
Stream.Write((byte)length);
Point3D p = target switch
{
Mobile _ => target.Location,
Item item => item.GetWorldLocation(),
_ => Point3D.Zero
};
for (var i = 0; i < length; ++i)
{
var e = entries[i];
Stream.Write(e.Number);
Stream.Write((short)i);
var range = e.Range;
if (range == -1)
range = 18;
var flags = e.Flags;
if (!(e.Enabled && menu.From.InRange(p, range)))
flags |= CMEFlags.Disabled;
Stream.Write((short)flags);
}
}
}
public sealed class DisplayContextMenuOld : Packet
{
public DisplayContextMenuOld(ContextMenu menu) : base(0xBF)
{
var entries = menu.Entries;
int length = (byte)entries.Length;
EnsureCapacity(12 + length * 8);
Stream.Write((short)0x14);
Stream.Write((short)0x01);
var target = menu.Target;
Stream.Write(target.Serial);
Stream.Write((byte)length);
Point3D p = target switch
{
Mobile _ => target.Location,
Item item => item.GetWorldLocation(),
_ => Point3D.Zero
};
for (var i = 0; i < length; ++i)
{
var e = entries[i];
Stream.Write((short)i);
Stream.Write((ushort)(e.Number - 3000000));
var range = e.Range;
if (range == -1)
range = 18;
var flags = e.Flags;
if (!(e.Enabled && menu.From.InRange(p, range)))
flags |= CMEFlags.Disabled;
var color = e.Color & 0xFFFF;
if (color != 0xFFFF)
flags |= CMEFlags.Colored;
Stream.Write((short)flags);
if ((flags & CMEFlags.Colored) != 0)
Stream.Write((short)color);
}
}
}
}

View file

@ -0,0 +1,45 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: MobilePackets.cs - Created: 2020/05/07 - Updated: 2020/05/07 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class DeathAnimation : Packet
{
public DeathAnimation(Mobile killed, Item corpse) : base(0xAF, 13)
{
Stream.Write(killed.Serial);
Stream.Write(corpse?.Serial ?? Serial.Zero);
Stream.Write(0);
}
}
public sealed class BondedStatus : Packet
{
public BondedStatus(Serial serial, bool bonded) : base(0xBF)
{
EnsureCapacity(11);
Stream.Write((short)0x19);
Stream.Write((byte)0);
Stream.Write(serial);
Stream.Write((byte)(bonded ? 1 : 0));
}
}
}

View file

@ -0,0 +1,34 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: ObjectHelpResponse.cs *
* Created: 2020/05/03 - Updated: 2020/05/03 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class ObjectHelpResponse : Packet
{
public ObjectHelpResponse(IEntity e, string text) : base(0xB7)
{
EnsureCapacity(9 + text.Length * 2);
Stream.Write(e.Serial);
Stream.WriteBigUniNull(text);
}
}
}

View file

@ -0,0 +1,154 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: PlayerPackets.cs - Created: 2020/05/07 - Updated: 2020/05/07 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class StatLockInfo : Packet
{
public StatLockInfo(Mobile m) : base(0xBF)
{
EnsureCapacity(12);
Stream.Write((short)0x19);
Stream.Write((byte)2);
Stream.Write(m.Serial);
Stream.Write((byte)0);
var lockBits = ((int)m.StrLock << 4) | ((int)m.DexLock << 2) | (int)m.IntLock;
Stream.Write((byte)lockBits);
}
}
public sealed class ChangeCombatant : Packet
{
public ChangeCombatant(Mobile combatant) : base(0xAA, 5)
{
Stream.Write(combatant?.Serial ?? Serial.Zero);
}
}
public sealed class ChangeUpdateRange : Packet
{
private static readonly ChangeUpdateRange[] m_Cache = new ChangeUpdateRange[0x100];
public ChangeUpdateRange(int range) : base(0xC8, 2)
{
Stream.Write((byte)range);
}
public static ChangeUpdateRange Instantiate(int range)
{
var idx = (byte)range;
var p = m_Cache[idx];
if (p == null)
{
m_Cache[idx] = p = new ChangeUpdateRange(range);
p.SetStatic();
}
return p;
}
}
public sealed class DeathStatus : Packet
{
public static readonly Packet Dead = SetStatic(new DeathStatus(true));
public static readonly Packet Alive = SetStatic(new DeathStatus(false));
public DeathStatus(bool dead) : base(0x2C, 2)
{
Stream.Write((byte)(dead ? 0 : 2));
}
public static Packet Instantiate(bool dead) => dead ? Dead : Alive;
}
public sealed class SpeedControl : Packet
{
public static readonly Packet WalkSpeed = SetStatic(new SpeedControl(2));
public static readonly Packet MountSpeed = SetStatic(new SpeedControl(1));
public static readonly Packet Disable = SetStatic(new SpeedControl(0));
public SpeedControl(int speedControl) : base(0xBF)
{
EnsureCapacity(3);
Stream.Write((short)0x26);
Stream.Write((byte)speedControl);
}
}
public sealed class ToggleSpecialAbility : Packet
{
public ToggleSpecialAbility(int abilityID, bool active) : base(0xBF)
{
EnsureCapacity(7);
Stream.Write((short)0x25);
Stream.Write((short)abilityID);
Stream.Write(active);
}
}
public sealed class GlobalLightLevel : Packet
{
private static readonly GlobalLightLevel[] m_Cache = new GlobalLightLevel[0x100];
public GlobalLightLevel(int level) : base(0x4F, 2)
{
Stream.Write((sbyte)level);
}
public static GlobalLightLevel Instantiate(int level)
{
var lvl = (byte)level;
var p = m_Cache[lvl];
if (p == null)
{
m_Cache[lvl] = p = new GlobalLightLevel(level);
p.SetStatic();
}
return p;
}
}
public sealed class PersonalLightLevel : Packet
{
public PersonalLightLevel(Mobile m, int level) : base(0x4E, 6)
{
Stream.Write(m.Serial);
Stream.Write((sbyte)level);
}
}
public sealed class PersonalLightLevelZero : Packet
{
public PersonalLightLevelZero(Mobile m) : base(0x4E, 6)
{
Stream.Write(m.Serial);
Stream.Write((sbyte)0);
}
}
}

View file

@ -0,0 +1,115 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SecureTradePackets.cs *
* Created: 2020/05/03 - Updated: 2020/05/03 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.Items;
namespace Server.Network
{
public sealed class DisplaySecureTrade : Packet
{
public DisplaySecureTrade(Mobile them, Container first, Container second, string name)
: base(0x6F)
{
name ??= "";
EnsureCapacity(18 + name.Length);
Stream.Write((byte)0); // Display
Stream.Write(them.Serial);
Stream.Write(first.Serial);
Stream.Write(second.Serial);
Stream.Write(true);
Stream.WriteAsciiFixed(name, 30);
}
}
public sealed class CloseSecureTrade : Packet
{
public CloseSecureTrade(Container cont)
: base(0x6F)
{
EnsureCapacity(8);
Stream.Write((byte)1); // Close
Stream.Write(cont.Serial);
}
}
public enum TradeFlag : byte
{
Display = 0x0,
Close = 0x1,
Update = 0x2,
UpdateGold = 0x3,
UpdateLedger = 0x4
}
public sealed class UpdateSecureTrade : Packet
{
public UpdateSecureTrade(Container cont, bool first, bool second)
: this(cont, TradeFlag.Update, first ? 1 : 0, second ? 1 : 0)
{
}
public UpdateSecureTrade(Container cont, TradeFlag flag, int first, int second)
: base(0x6F)
{
EnsureCapacity(17);
Stream.Write((byte)flag);
Stream.Write(cont.Serial);
Stream.Write(first);
Stream.Write(second);
}
}
public sealed class SecureTradeEquip : Packet
{
public SecureTradeEquip(Item item, Mobile m) : base(0x25, 20)
{
Stream.Write(item.Serial);
Stream.Write((short)item.ItemID);
Stream.Write((byte)0);
Stream.Write((short)item.Amount);
Stream.Write((short)item.X);
Stream.Write((short)item.Y);
Stream.Write(m.Serial);
Stream.Write((short)item.Hue);
}
}
public sealed class SecureTradeEquip6017 : Packet
{
public SecureTradeEquip6017(Item item, Mobile m) : base(0x25, 21)
{
Stream.Write(item.Serial);
Stream.Write((short)item.ItemID);
Stream.Write((byte)0);
Stream.Write((short)item.Amount);
Stream.Write((short)item.X);
Stream.Write((short)item.Y);
Stream.Write((byte)0); // Grid Location?
Stream.Write(m.Serial);
Stream.Write((short)item.Hue);
}
}
}

View file

@ -0,0 +1,38 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: UnicodePrompt.cs - Created: 2020/05/08 - Updated: 2020/05/08 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.Prompts;
namespace Server.Network
{
public sealed class UnicodePrompt : Packet
{
public UnicodePrompt(Prompt prompt) : base(0xC2)
{
EnsureCapacity(21);
Stream.Write(prompt.Serial); // TODO: Does this value even matter?
Stream.Write(prompt.Serial);
Stream.Write(0);
Stream.Write(0);
Stream.Write((short)0);
}
}
}

View file

@ -0,0 +1,128 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: VendorBuyPackets.cs - Created: 2020/05/03 - Updated: 2020/05/03 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System.Collections.Generic;
using Server.Items;
namespace Server.Network
{
public sealed class VendorBuyContent : Packet
{
public VendorBuyContent(List<BuyItemState> list) : base(0x3C)
{
EnsureCapacity(list.Count * 19 + 5);
Stream.Write((short)list.Count);
for (var i = list.Count - 1; i >= 0; --i)
{
var bis = list[i];
Stream.Write(bis.MySerial);
Stream.Write((ushort)bis.ItemID);
Stream.Write((byte)0); // itemID offset
Stream.Write((ushort)bis.Amount);
Stream.Write((short)(i + 1)); // x
Stream.Write((short)1); // y
Stream.Write(bis.ContainerSerial);
Stream.Write((ushort)bis.Hue);
}
}
}
public sealed class VendorBuyContent6017 : Packet
{
public VendorBuyContent6017(List<BuyItemState> list) : base(0x3C)
{
EnsureCapacity(list.Count * 20 + 5);
Stream.Write((short)list.Count);
for (var i = list.Count - 1; i >= 0; --i)
{
var bis = list[i];
Stream.Write(bis.MySerial);
Stream.Write((ushort)bis.ItemID);
Stream.Write((byte)0); // itemID offset
Stream.Write((ushort)bis.Amount);
Stream.Write((short)(i + 1)); // x
Stream.Write((short)1); // y
Stream.Write((byte)0); // Grid Location?
Stream.Write(bis.ContainerSerial);
Stream.Write((ushort)bis.Hue);
}
}
}
public sealed class DisplayBuyList : Packet
{
public DisplayBuyList(Mobile vendor) : base(0x24, 7)
{
Stream.Write(vendor.Serial);
Stream.Write((short)0x30); // buy window id?
}
}
public sealed class DisplayBuyListHS : Packet
{
public DisplayBuyListHS(Mobile vendor) : base(0x24, 9)
{
Stream.Write(vendor.Serial);
Stream.Write((short)0x30); // buy window id?
Stream.Write((short)0x00);
}
}
public sealed class VendorBuyList : Packet
{
public VendorBuyList(Mobile vendor, List<BuyItemState> list) : base(0x74)
{
EnsureCapacity(256);
Stream.Write(!(vendor.FindItemOnLayer(Layer.ShopBuy) is Container buyPack) ? Serial.MinusOne : buyPack.Serial);
Stream.Write((byte)list.Count);
for (var i = 0; i < list.Count; ++i)
{
var bis = list[i];
Stream.Write(bis.Price);
var desc = bis.Description ?? "";
// TODO: Test if this is actually WriteAsciiFixed and the extra null doesn't matter.
Stream.Write((byte)(desc.Length + 1));
Stream.WriteAsciiNull(desc);
}
}
}
public sealed class EndVendorBuy : Packet
{
public EndVendorBuy(Mobile vendor) : base(0x3B, 8)
{
Stream.Write((ushort)8); // length
Stream.Write(vendor.Serial);
Stream.Write((byte)0);
}
}
}

View file

@ -0,0 +1,61 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: VendorSellPackets.cs *
* Created: 2020/05/07 - Updated: 2020/05/07 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System.Collections.Generic;
namespace Server.Network
{
public sealed class VendorSellList : Packet
{
public VendorSellList(Mobile shopkeeper, List<SellItemState> sis) : base(0x9E)
{
EnsureCapacity(256);
Stream.Write(shopkeeper.Serial);
Stream.Write((ushort)sis.Count);
foreach (var state in sis)
{
Stream.Write(state.Item.Serial);
Stream.Write((ushort)state.Item.ItemID);
Stream.Write((ushort)state.Item.Hue);
Stream.Write((ushort)state.Item.Amount);
Stream.Write((ushort)state.Price);
var name = string.IsNullOrWhiteSpace(state.Item.Name) ? state.Name ?? "" : state.Item.Name.Trim();
Stream.Write((ushort)name.Length);
Stream.WriteAsciiFixed(name, (ushort)name.Length);
}
}
}
public sealed class EndVendorSell : Packet
{
public EndVendorSell(Mobile vendor) : base(0x3B, 8)
{
Stream.Write((ushort)8); // length
Stream.Write(vendor.Serial);
Stream.Write((byte)0);
}
}
}