Updates Packets & Randomizer (#43)
* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand. * WIP - Rewriting packets. * Cleanup and updates README * Converts more packets * Fixes header * Converts Effects packets. * Forgot the send command * Adds the start of containers packets. * Adds message packets with caching * Extends the send methods * Starts to add Acquire methods * Converted the packets * Cleanup * Cleanup * Adds more packets * Adds more packets * Fixes clearing arrays from pool. Adds Mobile Incoming * Converts more packets. * Moves more packets * Moves more packets * Test compression * Merges * Migrating to an idiomatic syntax that also supports compression, and proxying. * Optimize the stack alloc. Changes attributes * Converted container packets * Visual Studio doesn't auto save files. I am still getting used to subpar IDEs. * Adds static packet caching. Will profile later. Converts more packets * Fixes packets and changes how compression is configured * WIP - Adds basics for Gumps. Not finished though. * Fix file * Fixes formatting * Changed SpanWriter to be more idiomatic. * Fixes Span vs RawSpan and missing stackallocs * Converts over some more gumps * WIP - Deletes 32bit support. * Drops RDRand32 support. * Fixes gump compilation * Converting gump components * Removes old huffman compression function * Revert signature for backwards compatibility * WIP - Converting more gump components * Creates ArraySet for the strings. Updates AppendTo to reference that. * Converts the maining gump components * Cleans up gump components * Cleans up directives * Cleans up ArraySet and moves it. Adds null-coalescing-assignment * Cleanup, Target Packets, and C# 8 changes. * Removed OPL Packet * World packets * Fixing packet uses * Cleans up code. Fixes packet uses in various places. * More cleanup for packets * Code cleanup * Converts more packet uses and cleans up more code * More code cleanup * Finishes fixing the packets in Item * Updates secure trade packets * Updates core and gets it to compile. * Moved packets to scripts. Fixed account handler use of packets * Code cleanup * Updates chat packets * Code cleanuo * Adds party packets, but need to implement them. * Party packets WIP * Finishes party packets * Rearrange movement namespaces and classes * Finishes plant packets * Code Formatting * Fixes moving effects * Code cleanup, eliminates equipinfo * Adds more packets. Fixes bugs with various packets. * Finishes mahjon packets * Fixes mahjong packet * Code cleanup * Finishes mahjong packets * Adds Map packets * Add multifacet maps and charts * Cleans up some packets with UTF8 * Optimizes packets * Cleans up more packets. Moves the MessageHelper * Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets. * Updates protocol extensions packet receiver * Fixes a few bugs. Fixes a few more packets. * Code cleanup and fixing more packets * Fixes packet effects * Cleaned up more code * Buff Icon cleanup * Removed unused constructors * Code Cleanup. Adds BoatHS Packets * Moves house files. Updates house foundation packets. * Deployment cleanup * Fixes: * Code cleanup * More code cleanup * More code cleanup * Cleaned up BaseHouse * Enforces styling * Converts foreach to linq where possible. * Dont need that * Goals/Readme updates * Removes 32bit support at the highest level. Turns on HRT by default. * Code cleanup. Fixes extended features packet. * Fixes various bugs * Code cleanup * Code cleanup * Code cleanup. Fixes gump X/Y assignment. * Code cleanup using |= operator * More code cleanup * Cleanup * Fixes spacing issues. Thanks Visual Studio. You suck. * Compiler error * Fixes NPE from RunUO 2.7 * Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README * Fixes more packets. Stupid trailing nulls. * Fixes various bugs. * Fixes for gumps * Fixes more gump stuff. Going to split it out later since it is getting insane * Recoded the gump writing * WIP * *Added output path of scripts project to dev branch *Activated debugging in code
This commit is contained in:
parent
7aa8fd3df1
commit
179cb50557
588 changed files with 10843 additions and 16177 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Server.Accounting;
|
||||
using Server.Engines.Quests;
|
||||
using Server.Engines.Quests.Haven;
|
||||
using Server.Engines.Quests.Necro;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Server.Buffers;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -13,14 +14,21 @@ namespace Server.Items
|
|||
|
||||
public override int LabelNumber => 503057; // Impassable!
|
||||
|
||||
protected override Packet GetWorldPacketFor(NetState state)
|
||||
protected override void SendWorldPacketFor(NetState state)
|
||||
{
|
||||
Mobile mob = state.Mobile;
|
||||
|
||||
if (mob?.AccessLevel >= AccessLevel.GameMaster)
|
||||
return new GMItemPacket(this);
|
||||
{
|
||||
if (state.HighSeas)
|
||||
SendGMItemHS(state);
|
||||
else if (state.StygianAbyss)
|
||||
SendGMItemSA(state);
|
||||
else
|
||||
SendGMItem(state);
|
||||
}
|
||||
|
||||
return base.GetWorldPacketFor(state);
|
||||
base.SendWorldPacketFor(state);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -37,66 +45,138 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
public sealed class GMItemPacket : Packet
|
||||
private void SendGMItem(NetState ns)
|
||||
{
|
||||
public GMItemPacket(Item item) : base(0x1A)
|
||||
{
|
||||
EnsureCapacity(20);
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
// 14 base length
|
||||
// +2 - Amount
|
||||
// +2 - Hue
|
||||
// +1 - Flags
|
||||
SpanWriter w = new SpanWriter(stackalloc byte[20]);
|
||||
w.Write((byte)0x1A); // Packet ID
|
||||
w.Position += 2; // Dynamic Length
|
||||
|
||||
uint serial = item.Serial.Value;
|
||||
int itemID = 0x1183;
|
||||
int amount = item.Amount;
|
||||
Point3D loc = item.Location;
|
||||
int x = loc.X;
|
||||
int y = loc.Y;
|
||||
int hue = item.Hue;
|
||||
int flags = item.GetPacketFlags();
|
||||
int direction = (int)item.Direction;
|
||||
uint serial = Serial.Value;
|
||||
int itemId = 0x1183;
|
||||
int amount = Amount;
|
||||
Point3D loc = Location;
|
||||
int x = loc.X;
|
||||
int y = loc.Y;
|
||||
int hue = Hue;
|
||||
int flags = GetPacketFlags();
|
||||
int direction = (int)Direction;
|
||||
|
||||
if (amount != 0)
|
||||
serial |= 0x80000000;
|
||||
else
|
||||
serial &= 0x7FFFFFFF;
|
||||
if (amount != 0)
|
||||
serial |= 0x80000000;
|
||||
else
|
||||
serial &= 0x7FFFFFFF;
|
||||
|
||||
m_Stream.Write(serial);
|
||||
m_Stream.Write((short)(itemID & 0x7FFF));
|
||||
w.Write(serial);
|
||||
|
||||
if (amount != 0)
|
||||
m_Stream.Write((short)amount);
|
||||
w.Write((short)itemId);
|
||||
|
||||
x &= 0x7FFF;
|
||||
if (amount != 0)
|
||||
w.Write((short)amount);
|
||||
|
||||
if (direction != 0)
|
||||
x |= 0x8000;
|
||||
x &= 0x7FFF;
|
||||
|
||||
m_Stream.Write((short)x);
|
||||
if (direction != 0) x |= 0x8000;
|
||||
|
||||
y &= 0x3FFF;
|
||||
w.Write((short)x);
|
||||
|
||||
if (hue != 0)
|
||||
y |= 0x8000;
|
||||
y &= 0x3FFF;
|
||||
|
||||
if (flags != 0)
|
||||
y |= 0x4000;
|
||||
if (hue != 0) y |= 0x8000;
|
||||
|
||||
m_Stream.Write((short)y);
|
||||
if (flags != 0) y |= 0x4000;
|
||||
|
||||
if (direction != 0)
|
||||
m_Stream.Write((byte)direction);
|
||||
w.Write((short)y);
|
||||
|
||||
m_Stream.Write((sbyte)loc.Z);
|
||||
if (direction != 0)
|
||||
w.Write((byte)direction);
|
||||
|
||||
if (hue != 0)
|
||||
m_Stream.Write((ushort)hue);
|
||||
w.Write((sbyte)loc.Z);
|
||||
|
||||
if (flags != 0)
|
||||
m_Stream.Write((byte)flags);
|
||||
}
|
||||
if (hue != 0)
|
||||
w.Write((ushort)hue);
|
||||
|
||||
if (flags != 0)
|
||||
w.Write((byte)flags);
|
||||
|
||||
w.Position = 1;
|
||||
w.Write((ushort)w.WrittenCount);
|
||||
|
||||
ns.Send(w.Span);
|
||||
}
|
||||
|
||||
public void SendGMItemSA(NetState ns)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter w = new SpanWriter(stackalloc byte[24]);
|
||||
w.Write((byte)0xF3); // Packet ID
|
||||
|
||||
w.Write((short)0x01);
|
||||
|
||||
int itemId = 0x1183;
|
||||
|
||||
w.Position++; // w.Write((byte)0);
|
||||
|
||||
w.Write(Serial);
|
||||
|
||||
w.Write((short)itemId);
|
||||
|
||||
w.Write((byte)Direction);
|
||||
|
||||
short amount = (short)Amount;
|
||||
w.Write(amount);
|
||||
w.Write(amount);
|
||||
|
||||
Point3D loc = Location;
|
||||
w.Write((short)(loc.X & 0x7FFF));
|
||||
w.Write((short)(loc.Y & 0x3FFF));
|
||||
w.Write((sbyte)loc.Z);
|
||||
|
||||
w.Write((byte)Light);
|
||||
w.Write((short)Hue);
|
||||
w.Write((byte)GetPacketFlags());
|
||||
|
||||
ns.Send(w.RawSpan);
|
||||
}
|
||||
|
||||
public void SendGMItemHS(NetState ns)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter w = new SpanWriter(stackalloc byte[26]);
|
||||
w.Write((byte)0xF3); // Packet ID
|
||||
|
||||
w.Write((short)0x01);
|
||||
|
||||
int itemId = 0x1183;
|
||||
|
||||
w.Position++; // w.Write((byte)0);
|
||||
|
||||
w.Write(Serial);
|
||||
|
||||
w.Write((short)itemId);
|
||||
|
||||
w.Write((byte)Direction);
|
||||
|
||||
short amount = (short)Amount;
|
||||
w.Write(amount);
|
||||
w.Write(amount);
|
||||
|
||||
Point3D loc = Location;
|
||||
w.Write((short)(loc.X & 0x7FFF));
|
||||
w.Write((short)(loc.Y & 0x3FFF));
|
||||
w.Write((sbyte)loc.Z);
|
||||
|
||||
w.Write((byte)Light);
|
||||
w.Write((short)Hue);
|
||||
w.Write((byte)GetPacketFlags());
|
||||
|
||||
ns.Send(w.RawSpan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Buffers;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string BoardName{ get; set; }
|
||||
public string BoardName { get; set; }
|
||||
|
||||
public static bool CheckTime(DateTime time, TimeSpan range) => time + range < DateTime.UtcNow;
|
||||
|
||||
|
|
@ -66,8 +67,10 @@ namespace Server.Items
|
|||
|
||||
if (minutes != 0 && seconds != 0)
|
||||
return $"{minutes} minute{(minutes == 1 ? "" : "s")} and {seconds} second{(seconds == 1 ? "" : "s")}";
|
||||
|
||||
if (minutes != 0)
|
||||
return $"{minutes} minute{(minutes == 1 ? "" : "s")}";
|
||||
|
||||
return $"{seconds} second{(seconds == 1 ? "" : "s")}";
|
||||
}
|
||||
|
||||
|
|
@ -146,11 +149,8 @@ namespace Server.Items
|
|||
|
||||
NetState state = from.NetState;
|
||||
|
||||
state.Send(new BBDisplayBoard(this));
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new ContainerContent6017(from, this));
|
||||
else
|
||||
state.Send(new ContainerContent(from, this));
|
||||
BBPackets.SendBBDisplayBoard(state, this);
|
||||
Packets.SendContainerContent(state, from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -232,18 +232,14 @@ namespace Server.Items
|
|||
|
||||
public static void BBRequestContent(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
|
||||
{
|
||||
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
|
||||
return;
|
||||
|
||||
from.Send(new BBMessageContent(board, msg));
|
||||
if (World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg && msg.Parent == board)
|
||||
BBPackets.SendBBMessageContent(from.NetState, board, msg);
|
||||
}
|
||||
|
||||
public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
|
||||
{
|
||||
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
|
||||
return;
|
||||
|
||||
from.Send(new BBMessageHeader(board, msg));
|
||||
if (World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg && msg.Parent == board)
|
||||
BBPackets.SendBBMessageHeader(from.NetState, board, msg);
|
||||
}
|
||||
|
||||
public static void BBPostMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
|
||||
|
|
@ -271,7 +267,7 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
string subject = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte());
|
||||
string subject = pvSrc.ReadStringSafe(pvSrc.ReadByte());
|
||||
|
||||
if (subject.Length == 0)
|
||||
return;
|
||||
|
|
@ -282,7 +278,7 @@ namespace Server.Items
|
|||
return;
|
||||
|
||||
for (int i = 0; i < lines.Length; ++i)
|
||||
lines[i] = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte());
|
||||
lines[i] = pvSrc.ReadStringSafe(pvSrc.ReadByte());
|
||||
|
||||
board.PostMessage(from, thread, subject, lines);
|
||||
}
|
||||
|
|
@ -344,25 +340,25 @@ namespace Server.Items
|
|||
{
|
||||
}
|
||||
|
||||
public Mobile Poster{ get; private set; }
|
||||
public Mobile Poster { get; private set; }
|
||||
|
||||
public BulletinMessage Thread{ get; private set; }
|
||||
public BulletinMessage Thread { get; private set; }
|
||||
|
||||
public string Subject{ get; private set; }
|
||||
public string Subject { get; private set; }
|
||||
|
||||
public DateTime Time{ get; private set; }
|
||||
public DateTime Time { get; private set; }
|
||||
|
||||
public DateTime LastPostTime{ get; set; }
|
||||
public DateTime LastPostTime { get; set; }
|
||||
|
||||
public string PostedName{ get; private set; }
|
||||
public string PostedName { get; private set; }
|
||||
|
||||
public int PostedBody{ get; private set; }
|
||||
public int PostedBody { get; private set; }
|
||||
|
||||
public int PostedHue{ get; private set; }
|
||||
public int PostedHue { get; private set; }
|
||||
|
||||
public BulletinEquip[] PostedEquip{ get; private set; }
|
||||
public BulletinEquip[] PostedEquip { get; private set; }
|
||||
|
||||
public string[] Lines{ get; private set; }
|
||||
public string[] Lines { get; private set; }
|
||||
|
||||
public string GetTimeAsString() => Time.ToString("MMM dd, yyyy");
|
||||
|
||||
|
|
@ -452,70 +448,64 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
public class BBDisplayBoard : Packet
|
||||
public static class BBPackets
|
||||
{
|
||||
public BBDisplayBoard(BaseBulletinBoard board) : base(0x71)
|
||||
public static void SendBBDisplayBoard(NetState ns, BaseBulletinBoard board)
|
||||
{
|
||||
EnsureCapacity(38);
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[38]);
|
||||
writer.Write((byte)0x71); // Packet ID
|
||||
writer.Write((ushort)38); // Dynamic Length
|
||||
|
||||
byte[] buffer = Utility.UTF8.GetBytes(board.BoardName ?? "");
|
||||
writer.Position++; // writer.Write((byte)0); // Command
|
||||
writer.Write(board.Serial);
|
||||
writer.WriteAsciiNull(board.BoardName ?? "", 29);
|
||||
|
||||
m_Stream.Write((byte)0x00); // PacketID
|
||||
m_Stream.Write(board.Serial); // Bulletin board serial
|
||||
|
||||
// Bulletin board name
|
||||
if (buffer.Length >= 29)
|
||||
{
|
||||
m_Stream.Write(buffer, 0, 29);
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Write(buffer, 0, buffer.Length);
|
||||
m_Stream.Fill(30 - buffer.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class BBMessageHeader : Packet
|
||||
{
|
||||
public BBMessageHeader(BaseBulletinBoard board, BulletinMessage msg) : base(0x71)
|
||||
{
|
||||
string poster = SafeString(msg.PostedName);
|
||||
string subject = SafeString(msg.Subject);
|
||||
string time = SafeString(msg.GetTimeAsString());
|
||||
|
||||
EnsureCapacity(22 + poster.Length + subject.Length + time.Length);
|
||||
|
||||
m_Stream.Write((byte)0x01); // PacketID
|
||||
m_Stream.Write(board.Serial); // Bulletin board serial
|
||||
m_Stream.Write(msg.Serial); // Message serial
|
||||
|
||||
BulletinMessage thread = msg.Thread;
|
||||
|
||||
if (thread == null)
|
||||
m_Stream.Write(0); // Thread serial--root
|
||||
else
|
||||
m_Stream.Write(thread.Serial); // Thread serial--parent
|
||||
|
||||
WriteString(poster);
|
||||
WriteString(subject);
|
||||
WriteString(time);
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public void WriteString(string v)
|
||||
public static void SendBBMessageHeader(NetState ns, BaseBulletinBoard board, BulletinMessage msg)
|
||||
{
|
||||
byte[] buffer = Utility.UTF8.GetBytes(v);
|
||||
int len = buffer.Length + 1;
|
||||
string poster = msg.PostedName ?? "";
|
||||
string subject = msg.Subject ?? "";
|
||||
string time = msg.GetTimeAsString() ?? "";
|
||||
|
||||
if (len > 255)
|
||||
len = 255;
|
||||
byte posterLength = Math.Min((byte)poster.Length, (byte)254);
|
||||
byte subjectLength = Math.Min((byte)subject.Length, (byte)254);
|
||||
byte timeLength = Math.Min((byte)time.Length, (byte)254);
|
||||
|
||||
m_Stream.Write((byte)len);
|
||||
m_Stream.Write(buffer, 0, len - 1);
|
||||
m_Stream.Write((byte)0);
|
||||
int length = 22 + posterLength + subjectLength + timeLength;
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x71); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
|
||||
writer.Write((byte)0x01); // Command
|
||||
writer.Write(board.Serial); // Bulletin board serial
|
||||
writer.Write(msg.Serial); // Message serial
|
||||
writer.Write(msg.Thread?.Serial ?? 0);
|
||||
|
||||
writer.Write(posterLength);
|
||||
writer.WriteAsciiNull(poster, posterLength + 1);
|
||||
writer.Write(subjectLength);
|
||||
writer.WriteAsciiNull(subject, subjectLength + 1);
|
||||
writer.Write(timeLength);
|
||||
writer.WriteAsciiNull(time, timeLength + 1);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendBBMessageContent(NetState ns, BaseBulletinBoard board, BulletinMessage msg)
|
||||
{
|
||||
string poster = msg.PostedName ?? "";
|
||||
string subject = msg.Subject ?? "";
|
||||
string time = msg.GetTimeAsString() ?? "";
|
||||
|
||||
byte posterLength = Math.Min((byte)poster.Length, (byte)254);
|
||||
byte subjectLength = Math.Min((byte)subject.Length, (byte)254);
|
||||
byte timeLength = Math.Min((byte)time.Length, (byte)254);
|
||||
|
||||
int equipLength = Math.Min(msg.PostedEquip.Length, 255);
|
||||
int msgLength = Math.Min(msg.Lines.Length, 255);
|
||||
|
||||
public string SafeString(string v) => v ?? string.Empty;
|
||||
}
|
||||
|
||||
|
|
@ -529,72 +519,43 @@ namespace Server.Items
|
|||
|
||||
EnsureCapacity(22 + poster.Length + subject.Length + time.Length);
|
||||
|
||||
m_Stream.Write((byte)0x02); // PacketID
|
||||
m_Stream.Write(board.Serial); // Bulletin board serial
|
||||
m_Stream.Write(msg.Serial); // Message serial
|
||||
writer.Write((byte)0x02); // Command
|
||||
writer.Write(board.Serial); // Bulletin board serial
|
||||
writer.Write(msg.Serial); // Message serial
|
||||
|
||||
WriteString(poster);
|
||||
WriteString(subject);
|
||||
WriteString(time);
|
||||
writer.Write(posterLength);
|
||||
writer.WriteAsciiNull(poster, posterLength + 1);
|
||||
writer.Write(subjectLength);
|
||||
writer.WriteAsciiNull(subject, subjectLength + 1);
|
||||
writer.Write(timeLength);
|
||||
writer.WriteAsciiNull(time, timeLength + 1);
|
||||
|
||||
m_Stream.Write((short)msg.PostedBody);
|
||||
m_Stream.Write((short)msg.PostedHue);
|
||||
writer.Write((short)msg.PostedBody);
|
||||
writer.Write((short)msg.PostedHue);
|
||||
|
||||
int len = msg.PostedEquip.Length;
|
||||
writer.Write((byte)equipLength);
|
||||
|
||||
if (len > 255)
|
||||
len = 255;
|
||||
|
||||
m_Stream.Write((byte)len);
|
||||
|
||||
for (int i = 0; i < len; ++i)
|
||||
for (int i = 0; i < equipLength; ++i)
|
||||
{
|
||||
BulletinEquip eq = msg.PostedEquip[i];
|
||||
|
||||
m_Stream.Write((short)eq.itemID);
|
||||
m_Stream.Write((short)eq.hue);
|
||||
writer.Write((short)eq.itemID);
|
||||
writer.Write((short)eq.hue);
|
||||
}
|
||||
|
||||
len = msg.Lines.Length;
|
||||
writer.Write((byte)msgLength);
|
||||
|
||||
if (len > 255)
|
||||
len = 255;
|
||||
for (int i = 0; i < msgLength; ++i)
|
||||
{
|
||||
string line = msg.Lines[i];
|
||||
byte len = Math.Min((byte)line.Length, (byte)254);
|
||||
writer.WriteAsciiNull(line, len);
|
||||
}
|
||||
|
||||
m_Stream.Write((byte)len);
|
||||
writer.Position = 1;
|
||||
writer.Write((ushort)writer.WrittenCount);
|
||||
|
||||
for (int i = 0; i < len; ++i)
|
||||
WriteString(msg.Lines[i], true);
|
||||
}
|
||||
|
||||
public void WriteString(string v)
|
||||
{
|
||||
WriteString(v, false);
|
||||
}
|
||||
|
||||
public void WriteString(string v, bool padding)
|
||||
{
|
||||
byte[] buffer = Utility.UTF8.GetBytes(v);
|
||||
int tail = padding ? 2 : 1;
|
||||
int len = buffer.Length + tail;
|
||||
|
||||
if (len > 255)
|
||||
len = 255;
|
||||
|
||||
m_Stream.Write((byte)len);
|
||||
m_Stream.Write(buffer, 0, len - tail);
|
||||
|
||||
if (padding)
|
||||
m_Stream.Write((short)0); // padding compensates for a client bug
|
||||
else
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
|
||||
public string SafeString(string v)
|
||||
{
|
||||
if (v == null)
|
||||
return string.Empty;
|
||||
|
||||
return v;
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -29,14 +30,7 @@ namespace Server.Items
|
|||
|
||||
public int Amount{ get; }
|
||||
|
||||
public static CrystalRechargeInfo Get(Type type)
|
||||
{
|
||||
foreach (CrystalRechargeInfo info in Table)
|
||||
if (info.Type == type)
|
||||
return info;
|
||||
|
||||
return null;
|
||||
}
|
||||
public static CrystalRechargeInfo Get(Type type) => Table.FirstOrDefault(info => info.Type == type);
|
||||
}
|
||||
|
||||
public class BroadcastCrystal : Item
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -193,16 +193,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public virtual bool InstancedCorpse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Core.SE)
|
||||
return false;
|
||||
|
||||
return DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
|
||||
}
|
||||
}
|
||||
public virtual bool InstancedCorpse => Core.SE && DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
|
||||
|
||||
public override bool IsDecoContainer => false;
|
||||
|
||||
|
|
@ -302,9 +293,7 @@ namespace Server.Items
|
|||
Mobile dead = Owner;
|
||||
|
||||
if (GetFlag(CorpseFlag.Carved) || dead == null)
|
||||
{
|
||||
from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
|
||||
}
|
||||
else if (((Body)Amount).IsHuman && ItemID == 0x2006)
|
||||
{
|
||||
new Blood(0x122D).MoveToWorld(Location, Map);
|
||||
|
|
@ -328,13 +317,9 @@ namespace Server.Items
|
|||
from.CriminalAction(true);
|
||||
}
|
||||
else if (dead is BaseCreature creature)
|
||||
{
|
||||
creature.OnCarve(from, this, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsChildVisibleTo(Mobile m, Item child) =>
|
||||
|
|
@ -347,8 +332,7 @@ namespace Server.Items
|
|||
if (Aggressors.Count == 0 || Items.Count == 0)
|
||||
return;
|
||||
|
||||
if (m_InstancedItems == null)
|
||||
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
|
||||
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
|
||||
|
||||
List<Item> m_Stackables = new List<Item>();
|
||||
List<Item> m_Unstackables = new List<Item>();
|
||||
|
|
@ -401,7 +385,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
if (remainder == 0)
|
||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[attackers.Count - 1]));
|
||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[^1]));
|
||||
else
|
||||
m_Unstackables.Add(item);
|
||||
}
|
||||
|
|
@ -427,9 +411,7 @@ namespace Server.Items
|
|||
|
||||
if (InstancedCorpse)
|
||||
{
|
||||
if (m_InstancedItems == null)
|
||||
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
|
||||
|
||||
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
|
||||
m_InstancedItems.Add(carved, new InstancedItemInfo(carved, carver));
|
||||
}
|
||||
}
|
||||
|
|
@ -464,7 +446,6 @@ namespace Server.Items
|
|||
public override void OnAfterDelete()
|
||||
{
|
||||
m_DecayTimer?.Stop();
|
||||
|
||||
m_DecayTimer = null;
|
||||
}
|
||||
|
||||
|
|
@ -543,29 +524,23 @@ namespace Server.Items
|
|||
|
||||
writer.WriteDeltaTime(TimeOfDeath);
|
||||
|
||||
List<KeyValuePair<Item, Point3D>> list = m_RestoreTable == null
|
||||
? null
|
||||
: new List<KeyValuePair<Item, Point3D>>(m_RestoreTable);
|
||||
int count = list?.Count ?? 0;
|
||||
|
||||
writer.Write(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (m_RestoreTable == null)
|
||||
writer.Write(0);
|
||||
else
|
||||
{
|
||||
KeyValuePair<Item, Point3D> kvp = list[i];
|
||||
Item item = kvp.Key;
|
||||
Point3D loc = kvp.Value;
|
||||
writer.Write(m_RestoreTable.Count);
|
||||
|
||||
writer.Write(item);
|
||||
foreach (var (item, loc) in m_RestoreTable)
|
||||
{
|
||||
writer.Write(item);
|
||||
|
||||
if (item.Location == loc)
|
||||
{
|
||||
writer.Write(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.Write(loc);
|
||||
if (item.Location == loc)
|
||||
writer.Write(false);
|
||||
else
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.Write(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -757,12 +732,8 @@ namespace Server.Items
|
|||
if (!(((Body)Amount).IsHuman && ItemID == 0x2006))
|
||||
return;
|
||||
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new CorpseContent6017(state.Mobile, this));
|
||||
else
|
||||
state.Send(new CorpseContent(state.Mobile, this));
|
||||
|
||||
state.Send(new CorpseEquip(state.Mobile, this));
|
||||
CorpsePackets.SendCorpseContent(state, state.Mobile, this);
|
||||
CorpsePackets.SendCorpseEquip(state, state.Mobile, this);
|
||||
}
|
||||
|
||||
public bool IsCriminalAction(Mobile from)
|
||||
|
|
@ -836,8 +807,7 @@ namespace Server.Items
|
|||
if (item == null)
|
||||
return;
|
||||
|
||||
if (m_RestoreTable == null)
|
||||
m_RestoreTable = new Dictionary<Item, Point3D>();
|
||||
m_RestoreTable ??= new Dictionary<Item, Point3D>();
|
||||
|
||||
m_RestoreTable[item] = loc;
|
||||
}
|
||||
|
|
@ -1065,7 +1035,7 @@ namespace Server.Items
|
|||
ObjectPropertyList opl = PropertyList;
|
||||
|
||||
if (opl.Header > 0)
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs));
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs);
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
|
|
@ -1075,14 +1045,12 @@ namespace Server.Items
|
|||
if (ItemID == 0x2006) // Corpse form
|
||||
{
|
||||
if (m_CorpseName != null)
|
||||
from.Send(new AsciiMessage(Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName));
|
||||
Packets.SendAsciiMessage(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName);
|
||||
else
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name));
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name);
|
||||
}
|
||||
else // Bone form
|
||||
{
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name));
|
||||
}
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name);
|
||||
}
|
||||
|
||||
private class InstancedItemInfo
|
||||
|
|
|
|||
|
|
@ -1,24 +1,29 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Buffers;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public sealed class CorpseEquip : Packet
|
||||
public static class CorpsePackets
|
||||
{
|
||||
public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89)
|
||||
public static void SendCorpseEquip(NetState ns, Mobile beholder, Corpse beheld)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
List<Item> list = beheld.EquipItems;
|
||||
|
||||
int count = list.Count;
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
int length = 8 + list.Count * 5;
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
length += 5;
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
length += 5;
|
||||
|
||||
EnsureCapacity(8 + count * 5);
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x89); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
|
||||
m_Stream.Write(beheld.Serial);
|
||||
writer.Write(beheld.Serial);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
|
|
@ -26,173 +31,180 @@ namespace Server.Network
|
|||
|
||||
if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
|
||||
{
|
||||
m_Stream.Write((byte)(item.Layer + 1));
|
||||
m_Stream.Write(item.Serial);
|
||||
writer.Write((byte)(item.Layer + 1));
|
||||
writer.Write(item.Serial);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
writer.Write((byte)(Layer.Hair + 1));
|
||||
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 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);
|
||||
writer.Write((byte)(Layer.FacialHair + 1));
|
||||
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
|
||||
}
|
||||
|
||||
m_Stream.Write((byte)Layer.Invalid);
|
||||
writer.Position++; // writer.Write((byte)Layer.Invalid);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CorpseContent : Packet
|
||||
{
|
||||
public CorpseContent(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
public static void SendCorpseContent(NetState ns, Mobile beholder, Corpse corpse)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
if (ns.ContainerGridLines)
|
||||
SendCorpseContentNew(ns, beholder, corpse);
|
||||
else
|
||||
SendCorpseContentOld(ns, beholder, corpse);
|
||||
}
|
||||
|
||||
EnsureCapacity(5 + count * 19);
|
||||
public static void SendCorpseContentOld(NetState ns, Mobile beholder, Corpse corpse)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
long pos = m_Stream.Position;
|
||||
List<Item> items = corpse.EquipItems;
|
||||
int length = 5 + items.Count * 19;
|
||||
|
||||
int written = 0;
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
length += 19;
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
length += 19;
|
||||
|
||||
m_Stream.Write((ushort)0);
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x3C); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
writer.Position += 2;
|
||||
|
||||
ushort written = 0;
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
if (!child.Deleted && child.Parent == corpse && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write(child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
writer.Write(child.Serial);
|
||||
writer.Write((ushort)child.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)child.Amount);
|
||||
writer.Write((short)child.X);
|
||||
writer.Write((short)child.Y);
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
writer.Write(HairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.Hair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 4;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
writer.Write(FacialHairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.FacialHair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 4;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
writer.Position = 3;
|
||||
writer.Write(written);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CorpseContent6017 : Packet
|
||||
{
|
||||
public CorpseContent6017(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
public static void SendCorpseContentNew(NetState ns, Mobile beholder, Corpse corpse)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
List<Item> items = corpse.EquipItems;
|
||||
int length = 5 + items.Count * 20;
|
||||
|
||||
EnsureCapacity(5 + count * 20);
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
length += 20;
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
length += 20;
|
||||
|
||||
long pos = m_Stream.Position;
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x3C); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
writer.Position += 2;
|
||||
|
||||
int written = 0;
|
||||
|
||||
m_Stream.Write((ushort)0);
|
||||
ushort written = 0;
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
if (!child.Deleted && child.Parent == corpse && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write(child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
writer.Write(child.Serial);
|
||||
writer.Write((ushort)child.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)child.Amount);
|
||||
writer.Write((short)child.X);
|
||||
writer.Write((short)child.Y);
|
||||
writer.Position++; // grid location
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
writer.Write(HairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.Hair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 5;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
writer.Write(FacialHairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.FacialHair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 5;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
writer.Position = 3;
|
||||
writer.Write(written);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ namespace Server.Items
|
|||
{
|
||||
case ECEffectType.Lightning:
|
||||
{
|
||||
Effects.SendBoltEffect(from, false, EffectHue);
|
||||
Effects.SendBoltEffect(from, false);
|
||||
break;
|
||||
}
|
||||
case ECEffectType.Location:
|
||||
|
|
@ -334,4 +334,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ namespace Server.Items
|
|||
from.SendLocalizedMessage(1060581); // You've already lit it! Better throw it now!
|
||||
}
|
||||
|
||||
if (m_Users == null)
|
||||
m_Users = new List<Mobile>();
|
||||
m_Users ??= new List<Mobile>();
|
||||
|
||||
if (!m_Users.Contains(from))
|
||||
m_Users.Add(from);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
|
|
|
|||
|
|
@ -182,8 +182,7 @@ namespace Server.Items
|
|||
|
||||
if (addon != null)
|
||||
{
|
||||
if (count == 1 && Core.SE)
|
||||
isDecorableComponent = true;
|
||||
isDecorableComponent |= count == 1 && Core.SE;
|
||||
|
||||
if (m_Decorator.Command == DecorateCommand.Turn)
|
||||
{
|
||||
|
|
@ -191,8 +190,7 @@ namespace Server.Items
|
|||
(FlippableAddonAttribute[])addon.GetType()
|
||||
.GetCustomAttributes(typeof(FlippableAddonAttribute), false);
|
||||
|
||||
if (attributes.Length > 0)
|
||||
isDecorableComponent = true;
|
||||
isDecorableComponent = attributes.Length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Server.Network;
|
||||
using Server.Prompts;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -204,14 +203,9 @@ namespace Server.Items
|
|||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
string desc;
|
||||
string desc = m_KeyVal == 0 ? "(blank)" : m_Description?.Trim() ?? "";
|
||||
|
||||
if (m_KeyVal == 0)
|
||||
desc = "(blank)";
|
||||
else if ((desc = m_Description) == null || (desc = desc.Trim()).Length <= 0)
|
||||
desc = null;
|
||||
|
||||
if (desc != null)
|
||||
if (desc != "")
|
||||
list.Add(desc);
|
||||
}
|
||||
|
||||
|
|
@ -219,15 +213,10 @@ namespace Server.Items
|
|||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
string desc;
|
||||
|
||||
if (m_KeyVal == 0)
|
||||
desc = "(blank)";
|
||||
else if ((desc = m_Description) == null || (desc = desc.Trim()).Length <= 0)
|
||||
desc = "";
|
||||
string desc = m_KeyVal == 0 ? "(blank)" : m_Description?.Trim() ?? "";
|
||||
|
||||
if (desc.Length > 0)
|
||||
from.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", "", desc));
|
||||
Packets.SendUnicodeMessage(from.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", "", desc);
|
||||
}
|
||||
|
||||
public bool UseOn(Mobile from, ILockable o)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -109,14 +110,7 @@ namespace Server.Items
|
|||
UpdateItemID();
|
||||
}
|
||||
|
||||
public bool ContainsKey(uint keyValue)
|
||||
{
|
||||
foreach (Key key in Keys)
|
||||
if (key.KeyValue == keyValue)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool ContainsKey(uint keyValue) => Keys.Any(key => key.KeyValue == keyValue);
|
||||
|
||||
private void UpdateItemID()
|
||||
{
|
||||
|
|
@ -169,9 +163,7 @@ namespace Server.Items
|
|||
}
|
||||
else if (targeted is ILockable o)
|
||||
{
|
||||
foreach (Key key in m_KeyRing.Keys)
|
||||
if (key.UseOn(from, o))
|
||||
return;
|
||||
if (m_KeyRing.Keys.Any(key => key.UseOn(from, o))) return;
|
||||
|
||||
from.SendLocalizedMessage(1008140); // You do not have a key for that.
|
||||
}
|
||||
|
|
@ -182,4 +174,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Server.Buffers;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -19,13 +20,21 @@ namespace Server.Items
|
|||
TileData.ItemTable[0x21A2].Height = 20;
|
||||
}
|
||||
|
||||
protected override Packet GetWorldPacketFor(NetState state)
|
||||
protected override void SendWorldPacketFor(NetState state)
|
||||
{
|
||||
Mobile mob = state.Mobile;
|
||||
|
||||
if (mob?.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this);
|
||||
if (mob?.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
if (state.HighSeas)
|
||||
SendGMItemHS(state);
|
||||
else if (state.StygianAbyss)
|
||||
SendGMItemSA(state);
|
||||
else
|
||||
SendGMItem(state);
|
||||
}
|
||||
|
||||
return base.GetWorldPacketFor(state);
|
||||
base.SendWorldPacketFor(state);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -45,66 +54,138 @@ namespace Server.Items
|
|||
ItemID = 0x21A2;
|
||||
}
|
||||
|
||||
public sealed class GMItemPacket : Packet
|
||||
private void SendGMItem(NetState ns)
|
||||
{
|
||||
public GMItemPacket(Item item) : base(0x1A)
|
||||
{
|
||||
EnsureCapacity(20);
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
// 14 base length
|
||||
// +2 - Amount
|
||||
// +2 - Hue
|
||||
// +1 - Flags
|
||||
SpanWriter w = new SpanWriter(stackalloc byte[20]);
|
||||
w.Write((byte)0x1A); // Packet ID
|
||||
w.Position += 2; // Dynamic Length
|
||||
|
||||
uint serial = item.Serial.Value;
|
||||
int itemID = 0x36FF;
|
||||
int amount = item.Amount;
|
||||
Point3D loc = item.Location;
|
||||
int x = loc.X;
|
||||
int y = loc.Y;
|
||||
int hue = item.Hue;
|
||||
int flags = item.GetPacketFlags();
|
||||
int direction = (int)item.Direction;
|
||||
uint serial = Serial.Value;
|
||||
int itemId = 0x36FF;
|
||||
int amount = Amount;
|
||||
Point3D loc = Location;
|
||||
int x = loc.X;
|
||||
int y = loc.Y;
|
||||
int hue = Hue;
|
||||
int flags = GetPacketFlags();
|
||||
int direction = (int)Direction;
|
||||
|
||||
if (amount != 0)
|
||||
serial |= 0x80000000;
|
||||
else
|
||||
serial &= 0x7FFFFFFF;
|
||||
if (amount != 0)
|
||||
serial |= 0x80000000;
|
||||
else
|
||||
serial &= 0x7FFFFFFF;
|
||||
|
||||
m_Stream.Write(serial);
|
||||
m_Stream.Write((short)(itemID & 0x7FFF));
|
||||
w.Write(serial);
|
||||
|
||||
if (amount != 0)
|
||||
m_Stream.Write((short)amount);
|
||||
w.Write((short)itemId);
|
||||
|
||||
x &= 0x7FFF;
|
||||
if (amount != 0)
|
||||
w.Write((short)amount);
|
||||
|
||||
if (direction != 0)
|
||||
x |= 0x8000;
|
||||
x &= 0x7FFF;
|
||||
|
||||
m_Stream.Write((short)x);
|
||||
if (direction != 0) x |= 0x8000;
|
||||
|
||||
y &= 0x3FFF;
|
||||
w.Write((short)x);
|
||||
|
||||
if (hue != 0)
|
||||
y |= 0x8000;
|
||||
y &= 0x3FFF;
|
||||
|
||||
if (flags != 0)
|
||||
y |= 0x4000;
|
||||
if (hue != 0) y |= 0x8000;
|
||||
|
||||
m_Stream.Write((short)y);
|
||||
if (flags != 0) y |= 0x4000;
|
||||
|
||||
if (direction != 0)
|
||||
m_Stream.Write((byte)direction);
|
||||
w.Write((short)y);
|
||||
|
||||
m_Stream.Write((sbyte)loc.Z);
|
||||
if (direction != 0)
|
||||
w.Write((byte)direction);
|
||||
|
||||
if (hue != 0)
|
||||
m_Stream.Write((ushort)hue);
|
||||
w.Write((sbyte)loc.Z);
|
||||
|
||||
if (flags != 0)
|
||||
m_Stream.Write((byte)flags);
|
||||
}
|
||||
if (hue != 0)
|
||||
w.Write((ushort)hue);
|
||||
|
||||
if (flags != 0)
|
||||
w.Write((byte)flags);
|
||||
|
||||
w.Position = 1;
|
||||
w.Write((ushort)w.WrittenCount);
|
||||
|
||||
ns.Send(w.Span);
|
||||
}
|
||||
|
||||
public void SendGMItemSA(NetState ns)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter w = new SpanWriter(stackalloc byte[24]);
|
||||
w.Write((byte)0xF3); // Packet ID
|
||||
|
||||
w.Write((short)0x01);
|
||||
|
||||
int itemId = 0x36FF;
|
||||
|
||||
w.Position++; // w.Write((byte)0);
|
||||
|
||||
w.Write(Serial);
|
||||
|
||||
w.Write((short)itemId);
|
||||
|
||||
w.Write((byte)Direction);
|
||||
|
||||
short amount = (short)Amount;
|
||||
w.Write(amount);
|
||||
w.Write(amount);
|
||||
|
||||
Point3D loc = Location;
|
||||
w.Write((short)(loc.X & 0x7FFF));
|
||||
w.Write((short)(loc.Y & 0x3FFF));
|
||||
w.Write((sbyte)loc.Z);
|
||||
|
||||
w.Write((byte)Light);
|
||||
w.Write((short)Hue);
|
||||
w.Write((byte)GetPacketFlags());
|
||||
|
||||
ns.Send(w.RawSpan);
|
||||
}
|
||||
|
||||
public void SendGMItemHS(NetState ns)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter w = new SpanWriter(stackalloc byte[26]);
|
||||
w.Write((byte)0xF3); // Packet ID
|
||||
|
||||
w.Write((short)0x01);
|
||||
|
||||
int itemId = 0x36FF;
|
||||
|
||||
w.Position++; // w.Write((byte)0);
|
||||
|
||||
w.Write(Serial);
|
||||
|
||||
w.Write((short)itemId);
|
||||
|
||||
w.Write((byte)Direction);
|
||||
|
||||
short amount = (short)Amount;
|
||||
w.Write(amount);
|
||||
w.Write(amount);
|
||||
|
||||
Point3D loc = Location;
|
||||
w.Write((short)(loc.X & 0x7FFF));
|
||||
w.Write((short)(loc.Y & 0x3FFF));
|
||||
w.Write((sbyte)loc.Z);
|
||||
|
||||
w.Write((byte)Light);
|
||||
w.Write((short)Hue);
|
||||
w.Write((byte)GetPacketFlags());
|
||||
|
||||
ns.Send(w.RawSpan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Prompts;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.ContextMenus;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,7 @@ namespace Server.Items
|
|||
|
||||
private void AddGeneratorComponent(int itemID, int x, int y, int z)
|
||||
{
|
||||
AddonComponent component = new AddonComponent(itemID);
|
||||
component.Name = "a power generator";
|
||||
component.Hue = 0x451;
|
||||
|
||||
AddComponent(component, x, y, z);
|
||||
AddComponent(new AddonComponent(itemID){ Name = "a power generator", Hue = 0x451 }, x, y, z);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -148,9 +144,7 @@ namespace Server.Items
|
|||
visited[current.X, current.Y] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current = stack[--stackSize - 1];
|
||||
}
|
||||
}
|
||||
|
||||
Path = new Node[stackSize];
|
||||
|
|
@ -197,9 +191,8 @@ namespace Server.Items
|
|||
|
||||
public void DoDamage(Mobile to)
|
||||
{
|
||||
to.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "", "",
|
||||
"The generator shoots an arc of electricity at you!"));
|
||||
to.BoltEffect(0);
|
||||
Packets.SendMessageLocalized(to.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, 1152372); // The Nexus shoots an arc of energy at you!
|
||||
to.BoltEffect();
|
||||
to.LocalOverheadMessage(MessageType.Regular, 0xC9, true, "* Your body convulses from electric shock *");
|
||||
to.NonlocalOverheadMessage(MessageType.Regular, 0xC9, true, $"* {to.Name} spasms from electric shock *");
|
||||
|
||||
|
|
@ -358,7 +351,7 @@ namespace Server.Items
|
|||
hues[n.X, n.Y] = NodeHue.Blue;
|
||||
}
|
||||
|
||||
Node lastNode = path[path.Length - 1];
|
||||
Node lastNode = path[^1];
|
||||
hues[lastNode.X, lastNode.Y] = NodeHue.Red;
|
||||
|
||||
for (int i = 0; i < sideLength; i++)
|
||||
|
|
|
|||
|
|
@ -119,11 +119,7 @@ namespace Server.Items
|
|||
|
||||
private static void DeleteAll()
|
||||
{
|
||||
List<Item> list = new List<Item>();
|
||||
|
||||
foreach (Item item in World.Items.Values)
|
||||
if (item is PublicMoongate)
|
||||
list.Add(item);
|
||||
List<Item> list = World.Items.Values.OfType<PublicMoongate>().Cast<Item>().ToList();
|
||||
|
||||
foreach (Item item in list)
|
||||
item.Delete();
|
||||
|
|
@ -349,7 +345,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 0) // Cancel
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -157,10 +157,7 @@ namespace Server.Items
|
|||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (m_Active)
|
||||
list.Add(1060742); // active
|
||||
else
|
||||
list.Add(1060743); // inactive
|
||||
list.Add(m_Active ? 1060742 : 1060743);
|
||||
|
||||
if (m_MapDest != null)
|
||||
list.Add(1060658, "Map\t{0}", m_MapDest);
|
||||
|
|
@ -234,12 +231,12 @@ namespace Server.Items
|
|||
bool sendEffect = !m.Hidden || m.AccessLevel == AccessLevel.Player;
|
||||
|
||||
if (m_SourceEffect && sendEffect)
|
||||
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10, 10);
|
||||
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10);
|
||||
|
||||
m.MoveToWorld(p, map);
|
||||
|
||||
if (m_DestEffect && sendEffect)
|
||||
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10, 10);
|
||||
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10);
|
||||
|
||||
if (m_SoundID > 0 && sendEffect)
|
||||
Effects.PlaySound(m.Location, m.Map, m_SoundID);
|
||||
|
|
@ -395,11 +392,10 @@ namespace Server.Items
|
|||
if (m.BeginAction(this))
|
||||
{
|
||||
if (m_MessageString != null)
|
||||
m.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", null,
|
||||
m_MessageString));
|
||||
Packets.SendUnicodeMessage(m.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", "",
|
||||
m_MessageString);
|
||||
else if (m_MessageNumber != 0)
|
||||
m.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber, null,
|
||||
""));
|
||||
Packets.SendMessageLocalized(m.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => m.EndAction(this));
|
||||
}
|
||||
|
|
@ -525,12 +521,7 @@ namespace Server.Items
|
|||
if (!m.InRange(GetWorldLocation(), m_Range))
|
||||
return;
|
||||
|
||||
bool isMatch = false;
|
||||
|
||||
if (m_Keyword >= 0 && e.HasKeyword(m_Keyword))
|
||||
isMatch = true;
|
||||
else if (m_Substring != null && e.Speech.ToLower().IndexOf(m_Substring.ToLower()) >= 0)
|
||||
isMatch = true;
|
||||
bool isMatch = m_Keyword >= 0 && e.HasKeyword(m_Keyword) || m_Substring != null && e.Speech.ToLower().IndexOf(m_Substring.ToLower()) >= 0;
|
||||
|
||||
if (!isMatch || !CanTeleport(m))
|
||||
return;
|
||||
|
|
@ -820,10 +811,10 @@ namespace Server.Items
|
|||
writer.Write(TimeoutDelay);
|
||||
writer.Write(m_Teleporting.Count);
|
||||
|
||||
foreach (KeyValuePair<Mobile, Timer> kvp in m_Teleporting)
|
||||
foreach (var (key, value) in m_Teleporting)
|
||||
{
|
||||
writer.Write(kvp.Key);
|
||||
writer.Write(kvp.Value.Next);
|
||||
writer.Write(key);
|
||||
writer.Write(value.Next);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1063,9 +1054,7 @@ namespace Server.Items
|
|||
case Layer.Backpack:
|
||||
case Layer.Mount:
|
||||
case Layer.Bank:
|
||||
{
|
||||
continue; // ignore
|
||||
}
|
||||
default:
|
||||
{
|
||||
m.SendMessage("You must remove all of your equipment before proceeding.");
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace Server.Items
|
|||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
PublicOverheadMessage(MessageType.Regular, 0x3B2, message, "");
|
||||
PublicOverheadMessage(MessageType.Regular, 0x3B2, message);
|
||||
|
||||
for (int i = items.Count - 1; i >= 0; --i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Server.Items
|
|||
public void Carve(Mobile from, Item item)
|
||||
{
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x48F);
|
||||
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10, 10, 0, 0);
|
||||
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10);
|
||||
|
||||
if (0.3 > Utility.RandomDouble())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue