Adds more unit tests (#133)
This commit is contained in:
parent
e138706536
commit
8278694105
37 changed files with 1406 additions and 996 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
131
Projects/Server/Network/Packets/Old Packets/EquipmentPackets.cs
Normal file
131
Projects/Server/Network/Packets/Old Packets/EquipmentPackets.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MapPatches.cs - Created: 2020/05/03 - Updated: 2020/05/03 *
|
||||
* 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 *
|
||||
|
|
@ -44,4 +44,11 @@ namespace Server.Network
|
|||
Stream.Write(Map.Malas.Tiles.Patch.LandBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class InvalidMapEnable : Packet
|
||||
{
|
||||
public InvalidMapEnable() : base(0xC6, 1)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
228
Projects/Server/Network/Packets/Old Packets/MenuPackets.cs
Normal file
228
Projects/Server/Network/Packets/Old Packets/MenuPackets.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Projects/Server/Network/Packets/Old Packets/MobilePackets.cs
Normal file
45
Projects/Server/Network/Packets/Old Packets/MobilePackets.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
154
Projects/Server/Network/Packets/Old Packets/PlayerPackets.cs
Normal file
154
Projects/Server/Network/Packets/Old Packets/PlayerPackets.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Projects/Server/Network/Packets/Old Packets/UnicodePrompt.cs
Normal file
38
Projects/Server/Network/Packets/Old Packets/UnicodePrompt.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -109,9 +109,20 @@ namespace Server.Network
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue