fix(core): Cleans up uninitialized packets (#397)
- [X] Encapsulates/abstracts buffer cache checking - [X] Changes mobile moving cache to use Span2D
This commit is contained in:
parent
0b9fb9c071
commit
8763be8a21
18 changed files with 417 additions and 529 deletions
|
|
@ -72,20 +72,14 @@ namespace Server
|
|||
|
||||
if (map != null)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
|
||||
var eable = map.GetClientsInRange(new Point3D(p));
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, soundID, p);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, soundID, p);
|
||||
state.Send(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -104,16 +98,9 @@ namespace Server
|
|||
|
||||
e.ProcessDelta();
|
||||
|
||||
Span<byte> preEffect = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];
|
||||
preEffect.InitializePacket();
|
||||
Span<byte> boltEffect = stackalloc byte[OutgoingEffectPackets.BoltEffectLength];
|
||||
boltEffect.InitializePacket();
|
||||
|
||||
Span<byte> soundEffect = sound ? stackalloc byte[OutgoingEffectPackets.SoundPacketLength] : null;
|
||||
if (sound)
|
||||
{
|
||||
soundEffect.InitializePacket();
|
||||
}
|
||||
Span<byte> preEffect = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
Span<byte> boltEffect = stackalloc byte[OutgoingEffectPackets.BoltEffectLength].InitializePacket();
|
||||
Span<byte> soundEffect = sound ? stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket() : null;
|
||||
|
||||
var eable = map.GetClientsInRange(e.Location);
|
||||
|
||||
|
|
@ -123,31 +110,19 @@ namespace Server
|
|||
{
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (preEffect[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateTargetParticleEffect(
|
||||
preEffect,
|
||||
e, 0, 10, 5, 0, 0, 5031, 3, 0
|
||||
);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateTargetParticleEffect(
|
||||
preEffect,
|
||||
e, 0, 10, 5, 0, 0, 5031, 3, 0
|
||||
);
|
||||
state.Send(preEffect);
|
||||
}
|
||||
|
||||
if (boltEffect[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateBoltEffect(boltEffect, e, hue);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateBoltEffect(boltEffect, e, hue);
|
||||
state.Send(boltEffect);
|
||||
|
||||
if (sound)
|
||||
{
|
||||
if (soundEffect[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(soundEffect, 0x29, e);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateSoundEffect(soundEffect, 0x29, e);
|
||||
state.Send(soundEffect);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,7 +139,7 @@ namespace Server
|
|||
Point3D p, Map map, int itemID, int duration, int speed = 10, int hue = 0, int renderMode = 0
|
||||
)
|
||||
{
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength];
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
OutgoingEffectPackets.CreateLocationHuedEffect(
|
||||
effect,
|
||||
p, itemID, speed, duration, hue, renderMode
|
||||
|
|
@ -194,14 +169,9 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];
|
||||
particles.InitializePacket();
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength] : null;
|
||||
if (itemID != 0)
|
||||
{
|
||||
regular.InitializePacket();
|
||||
}
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
|
||||
var eable = map.GetClientsInRange(e.Location);
|
||||
|
||||
|
|
@ -211,26 +181,18 @@ namespace Server
|
|||
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (particles[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateLocationParticleEffect(
|
||||
particles,
|
||||
e, itemID, speed, duration, hue, renderMode, effect, unknown
|
||||
);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateLocationParticleEffect(
|
||||
particles,
|
||||
e, itemID, speed, duration, hue, renderMode, effect, unknown
|
||||
);
|
||||
state.Send(particles);
|
||||
}
|
||||
else if (itemID != 0)
|
||||
{
|
||||
if (regular[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateLocationHuedEffect(
|
||||
regular,
|
||||
e.Location, itemID, speed, duration, hue, renderMode
|
||||
);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateLocationHuedEffect(
|
||||
regular,
|
||||
e.Location, itemID, speed, duration, hue, renderMode
|
||||
);
|
||||
state.Send(regular);
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +204,7 @@ namespace Server
|
|||
{
|
||||
(target as Mobile)?.ProcessDelta();
|
||||
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength];
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
OutgoingEffectPackets.CreateTargetHuedEffect(
|
||||
effect,
|
||||
target, itemID, speed, duration, hue, renderMode
|
||||
|
|
@ -273,14 +235,8 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];
|
||||
particles.InitializePacket();
|
||||
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength] : null;
|
||||
if (itemID != 0)
|
||||
{
|
||||
regular.InitializePacket();
|
||||
}
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
|
||||
var eable = map.GetClientsInRange(target.Location);
|
||||
|
||||
|
|
@ -290,23 +246,15 @@ namespace Server
|
|||
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (particles[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateTargetParticleEffect(
|
||||
particles,
|
||||
target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown
|
||||
);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateTargetParticleEffect(
|
||||
particles,
|
||||
target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown
|
||||
);
|
||||
state.Send(particles);
|
||||
}
|
||||
else if (itemID != 0)
|
||||
{
|
||||
if (regular[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateTargetHuedEffect(regular, target, itemID, speed, duration, hue, renderMode);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateTargetHuedEffect(regular, target, itemID, speed, duration, hue, renderMode);
|
||||
state.Send(regular);
|
||||
}
|
||||
}
|
||||
|
|
@ -503,14 +451,8 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];
|
||||
particles.InitializePacket();
|
||||
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength] : null;
|
||||
if (itemID != 0)
|
||||
{
|
||||
regular.InitializePacket();
|
||||
}
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
|
||||
var eable = map.GetClientsInRange(from.Location);
|
||||
|
||||
|
|
@ -520,27 +462,19 @@ namespace Server
|
|||
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (particles[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateMovingParticleEffect(
|
||||
particles,
|
||||
from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect,
|
||||
explodeEffect, explodeSound, layer, unknown
|
||||
);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateMovingParticleEffect(
|
||||
particles,
|
||||
from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect,
|
||||
explodeEffect, explodeSound, layer, unknown
|
||||
);
|
||||
state.Send(particles);
|
||||
}
|
||||
else if (itemID > 1)
|
||||
{
|
||||
if (regular[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateMovingHuedEffect(
|
||||
regular,
|
||||
from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode
|
||||
);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateMovingHuedEffect(
|
||||
regular,
|
||||
from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode
|
||||
);
|
||||
state.Send(regular);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,8 +369,7 @@ namespace Server
|
|||
|
||||
var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -378,11 +377,7 @@ namespace Server
|
|||
|
||||
if (!m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1140,20 +1135,10 @@ namespace Server
|
|||
|
||||
if (m_Map != null)
|
||||
{
|
||||
Span<byte> oldWorldItem = stackalloc byte[OutgoingItemPackets.MaxWorldItemPacketLength];
|
||||
oldWorldItem.InitializePacket();
|
||||
|
||||
Span<byte> saWorldItem = stackalloc byte[OutgoingItemPackets.MaxWorldItemPacketLength];
|
||||
saWorldItem.InitializePacket();
|
||||
|
||||
Span<byte> hsWorldItem = stackalloc byte[OutgoingItemPackets.MaxWorldItemPacketLength];
|
||||
hsWorldItem.InitializePacket();
|
||||
|
||||
Span<byte> opl = ObjectPropertyList.Enabled ? stackalloc byte[OutgoingEntityPackets.OPLPacketLength] : null;
|
||||
if (opl != null)
|
||||
{
|
||||
opl.InitializePacket();
|
||||
}
|
||||
Span<byte> oldWorldItem = stackalloc byte[OutgoingItemPackets.MaxWorldItemPacketLength].InitializePacket();
|
||||
Span<byte> saWorldItem = stackalloc byte[OutgoingItemPackets.MaxWorldItemPacketLength].InitializePacket();
|
||||
Span<byte> hsWorldItem = stackalloc byte[OutgoingItemPackets.MaxWorldItemPacketLength].InitializePacket();
|
||||
Span<byte> opl = ObjectPropertyList.Enabled ? stackalloc byte[OutgoingEntityPackets.OPLPacketLength].InitializePacket() : null;
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange());
|
||||
|
||||
|
|
@ -1214,8 +1199,7 @@ namespace Server
|
|||
{
|
||||
eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange());
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -1223,10 +1207,7 @@ namespace Server
|
|||
|
||||
if (!m.InRange(location, GetUpdateRange(m)))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1559,8 +1540,7 @@ namespace Server
|
|||
{
|
||||
eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange());
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -1568,11 +1548,7 @@ namespace Server
|
|||
|
||||
if (!m.InRange(value, GetUpdateRange(m)))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
@ -3357,8 +3333,7 @@ namespace Server
|
|||
var worldLoc = GetWorldLocation();
|
||||
var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -3366,12 +3341,12 @@ namespace Server
|
|||
|
||||
if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, m_ItemID, type, hue, 3, ascii, "ENU", Name, text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, m_ItemID, type, hue, 3, ascii, "ENU", Name, text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -3392,8 +3367,7 @@ namespace Server
|
|||
var worldLoc = GetWorldLocation();
|
||||
var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -3401,12 +3375,12 @@ namespace Server
|
|||
|
||||
if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, m_ItemID, type, hue, 3, number, Name, args
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, m_ItemID, type, hue, 3, number, Name, args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -3859,8 +3833,7 @@ namespace Server
|
|||
|
||||
var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -3868,11 +3841,7 @@ namespace Server
|
|||
|
||||
if (m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.Toolkit.HighPerformance.Extensions;
|
||||
using Microsoft.Toolkit.HighPerformance.Memory;
|
||||
using Server.Accounting;
|
||||
using Server.Buffers;
|
||||
using Server.ContextMenus;
|
||||
|
|
@ -3019,8 +3021,11 @@ namespace Server
|
|||
sendFacialHair = true;
|
||||
}
|
||||
|
||||
Span<byte> mobileMovingPackets = stackalloc byte[OutgoingMobilePackets.MobileMovingPacketCacheLength];
|
||||
mobileMovingPackets.InitializePackets(OutgoingMobilePackets.MobileMovingPacketLength);
|
||||
const int cacheLength = OutgoingMobilePackets.MobileMovingPacketCacheByteLength;
|
||||
var width = OutgoingMobilePackets.MobileMovingPacketLength;
|
||||
var height = OutgoingMobilePackets.MobileMovingPacketCacheHeight;
|
||||
|
||||
var mobileMovingCache = stackalloc byte[cacheLength].AsSpan2D(height, width).InitializePackets();
|
||||
|
||||
var ourState = m_NetState;
|
||||
|
||||
|
|
@ -3039,7 +3044,7 @@ namespace Server
|
|||
|
||||
if (sendMoving || !ourState.StygianAbyss && (sendHealthbarPoison || sendHealthbarYellow))
|
||||
{
|
||||
ourState.SendMobileMovingUsingCache(mobileMovingPackets, this, this);
|
||||
ourState.SendMobileMovingUsingCache(mobileMovingCache, this, this);
|
||||
}
|
||||
|
||||
if (ourState.StygianAbyss)
|
||||
|
|
@ -3146,40 +3151,25 @@ namespace Server
|
|||
|
||||
var eable = Map.GetClientsInRange(m_Location);
|
||||
|
||||
Span<byte> statBufferTrue = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength];
|
||||
statBufferTrue.InitializePacket();
|
||||
|
||||
Span<byte> statBufferFalse = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength];
|
||||
statBufferFalse.InitializePacket();
|
||||
|
||||
Span<byte> hbpBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength];
|
||||
hbpBuffer.InitializePacket();
|
||||
|
||||
Span<byte> hbyBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength];
|
||||
hbyBuffer.InitializePacket();
|
||||
|
||||
Span<byte> deadBuffer = stackalloc byte[OutgoingMobilePackets.BondedStatusPacketLength];
|
||||
deadBuffer.InitializePacket();
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
|
||||
Span<byte> hitsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength];
|
||||
hitsPacket.InitializePacket();
|
||||
Span<byte> statBufferTrue = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength].InitializePacket();
|
||||
Span<byte> statBufferFalse = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength].InitializePacket();
|
||||
Span<byte> hbpBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength].InitializePacket();
|
||||
Span<byte> hbyBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength].InitializePacket();
|
||||
Span<byte> deadBuffer = stackalloc byte[OutgoingMobilePackets.BondedStatusPacketLength].InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
Span<byte> hitsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength].InitializePacket();
|
||||
|
||||
var hairLength = removeHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> hairPacket = stackalloc byte[hairLength];
|
||||
hairPacket.InitializePacket();
|
||||
Span<byte> hairPacket = stackalloc byte[hairLength].InitializePacket();
|
||||
|
||||
var facialHairLength = removeFacialHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> facialhairPacket = stackalloc byte[facialHairLength];
|
||||
facialhairPacket.InitializePacket();
|
||||
Span<byte> facialhairPacket = stackalloc byte[facialHairLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -3192,11 +3182,7 @@ namespace Server
|
|||
|
||||
if (sendRemove)
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
|
||||
|
|
@ -3217,7 +3203,7 @@ namespace Server
|
|||
|
||||
if (sendMoving || !state.StygianAbyss && (sendHealthbarPoison || sendHealthbarYellow))
|
||||
{
|
||||
state.SendMobileMovingUsingCache(mobileMovingPackets, beholder, this);
|
||||
state.SendMobileMovingUsingCache(mobileMovingCache, beholder, this);
|
||||
}
|
||||
|
||||
if (state.StygianAbyss)
|
||||
|
|
@ -4574,8 +4560,11 @@ namespace Server
|
|||
|
||||
eable.Free();
|
||||
|
||||
Span<byte> mobileMovingPackets = stackalloc byte[OutgoingMobilePackets.MobileMovingPacketCacheLength];
|
||||
mobileMovingPackets.InitializePackets(OutgoingMobilePackets.MobileMovingPacketLength);
|
||||
const int cacheLength = OutgoingMobilePackets.MobileMovingPacketCacheByteLength;
|
||||
var width = OutgoingMobilePackets.MobileMovingPacketLength;
|
||||
var height = OutgoingMobilePackets.MobileMovingPacketCacheHeight;
|
||||
|
||||
var mobileMovingCache = stackalloc byte[cacheLength].AsSpan2D(height, width).InitializePackets();
|
||||
|
||||
foreach (var m in m_MoveClientList)
|
||||
{
|
||||
|
|
@ -4583,7 +4572,7 @@ namespace Server
|
|||
|
||||
if (ns != null && Utility.InUpdateRange(m_Location, m.m_Location) && m.CanSee(this))
|
||||
{
|
||||
ns.SendMobileMovingUsingCache(mobileMovingPackets, m, this);
|
||||
ns.SendMobileMovingUsingCache(mobileMovingCache, m, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5029,11 +5018,8 @@ namespace Server
|
|||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
var corpseSerial = c?.Serial ?? Serial.Zero;
|
||||
|
||||
Span<byte> deathAnimation = stackalloc byte[OutgoingMobilePackets.DeathAnimationPacketLength];
|
||||
deathAnimation.InitializePacket();
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> deathAnimation = stackalloc byte[OutgoingMobilePackets.DeathAnimationPacketLength].InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
|
|
@ -5048,11 +5034,7 @@ namespace Server
|
|||
|
||||
if (!state.Mobile.CanSee(this))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
@ -5326,27 +5308,23 @@ namespace Server
|
|||
var eable = map.GetClientsInRange(from.Location);
|
||||
var rootItem = root as Item;
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength].InitializePacket();
|
||||
|
||||
foreach (var ns in eable)
|
||||
{
|
||||
if (ns.Mobile != from && ns.Mobile.CanSee(from) && ns.Mobile.InLOS(from) &&
|
||||
ns.Mobile.CanSee(root))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingPlayerPackets.CreateDragEffect(
|
||||
buffer,
|
||||
rootItem?.Serial ?? Serial.Zero,
|
||||
rootItem?.Location ?? item.Location,
|
||||
from.Serial,
|
||||
from.Location,
|
||||
item.ItemID,
|
||||
item.Hue,
|
||||
amount
|
||||
);
|
||||
}
|
||||
OutgoingPlayerPackets.CreateDragEffect(
|
||||
buffer,
|
||||
rootItem?.Serial ?? Serial.Zero,
|
||||
rootItem?.Location ?? item.Location,
|
||||
from.Serial,
|
||||
from.Location,
|
||||
item.ItemID,
|
||||
item.Hue,
|
||||
amount
|
||||
);
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
|
@ -5485,34 +5463,28 @@ namespace Server
|
|||
|
||||
var eable = map.GetClientsInRange(m_Location);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength].InitializePacket();
|
||||
|
||||
foreach (var ns in eable)
|
||||
{
|
||||
if (ns.StygianAbyss)
|
||||
if (ns.StygianAbyss || ns.Mobile == this ||
|
||||
!ns.Mobile.CanSee(this) || !ns.Mobile.InLOS(this) || !ns.Mobile.CanSee(root))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ns.Mobile != this && ns.Mobile.CanSee(this) && ns.Mobile.InLOS(this) && ns.Mobile.CanSee(root))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingPlayerPackets.CreateDragEffect(
|
||||
buffer,
|
||||
Serial,
|
||||
Location,
|
||||
rootItem?.Serial ?? Serial.Zero,
|
||||
rootItem?.Location ?? item.Location,
|
||||
item.ItemID,
|
||||
item.Hue,
|
||||
item.Amount
|
||||
);
|
||||
}
|
||||
OutgoingPlayerPackets.CreateDragEffect(
|
||||
buffer,
|
||||
Serial,
|
||||
Location,
|
||||
rootItem?.Serial ?? Serial.Zero,
|
||||
rootItem?.Location ?? item.Location,
|
||||
item.ItemID,
|
||||
item.Hue,
|
||||
item.Amount
|
||||
);
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -5844,10 +5816,8 @@ namespace Server
|
|||
|
||||
ProcessDelta();
|
||||
|
||||
Span<byte> regBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
regBuffer.InitializePacket();
|
||||
Span<byte> mutBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)];
|
||||
mutBuffer.InitializePacket();
|
||||
Span<byte> regBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
Span<byte> mutBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)].InitializePacket();
|
||||
|
||||
// TODO: Should this be sorted like onSpeech is below?
|
||||
for (var i = 0; i < hears.Count; ++i)
|
||||
|
|
@ -5856,11 +5826,12 @@ namespace Server
|
|||
|
||||
if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext))
|
||||
{
|
||||
if (regBuffer[0] == 0)
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
regBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, text
|
||||
);
|
||||
|
||||
if (length != regBuffer.Length)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
regBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, text
|
||||
);
|
||||
regBuffer = regBuffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -5869,11 +5840,12 @@ namespace Server
|
|||
}
|
||||
else
|
||||
{
|
||||
if (mutBuffer[0] == 0)
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
mutBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, mutatedText
|
||||
);
|
||||
|
||||
if (length != mutBuffer.Length)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
mutBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, mutatedText
|
||||
);
|
||||
mutBuffer = mutBuffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -6917,60 +6889,58 @@ namespace Server
|
|||
|
||||
var eable = map.GetClientsInRange(m_Location);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMobilePackets.MobileAnimationPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMobilePackets.MobileAnimationPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
if (state.Mobile.CanSee(this))
|
||||
if (!state.Mobile.CanSee(this))
|
||||
{
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if (Body.IsGargoyle)
|
||||
{
|
||||
frameCount = 10;
|
||||
|
||||
if (Flying)
|
||||
{
|
||||
action = action switch
|
||||
{
|
||||
>= 9 and <= 11 => 71,
|
||||
>= 12 and <= 14 => 72,
|
||||
20 => 77,
|
||||
31 => 71,
|
||||
34 => 78,
|
||||
>= 200 and <= 259 => 75,
|
||||
>= 260 and <= 270 => 75,
|
||||
_ => action
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
action = action switch
|
||||
{
|
||||
>= 200 and <= 259 => 17,
|
||||
>= 260 and <= 270 => 16,
|
||||
_ => action
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingMobilePackets.CreateMobileAnimation(
|
||||
buffer,
|
||||
Serial,
|
||||
action,
|
||||
frameCount,
|
||||
repeatCount,
|
||||
forward,
|
||||
repeat,
|
||||
delay
|
||||
);
|
||||
}
|
||||
|
||||
state.Send(buffer);
|
||||
continue;
|
||||
}
|
||||
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if (Body.IsGargoyle)
|
||||
{
|
||||
frameCount = 10;
|
||||
|
||||
if (Flying)
|
||||
{
|
||||
action = action switch
|
||||
{
|
||||
>= 9 and <= 11 => 71,
|
||||
>= 12 and <= 14 => 72,
|
||||
20 => 77,
|
||||
31 => 71,
|
||||
34 => 78,
|
||||
>= 200 and <= 259 => 75,
|
||||
>= 260 and <= 270 => 75,
|
||||
_ => action
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
action = action switch
|
||||
{
|
||||
>= 200 and <= 259 => 17,
|
||||
>= 260 and <= 270 => 16,
|
||||
_ => action
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
OutgoingMobilePackets.CreateMobileAnimation(
|
||||
buffer,
|
||||
Serial,
|
||||
action,
|
||||
frameCount,
|
||||
repeatCount,
|
||||
forward,
|
||||
repeat,
|
||||
delay
|
||||
);
|
||||
|
||||
state.Send(buffer);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -6998,8 +6968,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
|
|
@ -7007,11 +6976,7 @@ namespace Server
|
|||
{
|
||||
if (state.Mobile.CanSee(this))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, soundID, this);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, soundID, this);
|
||||
state.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
|
@ -7066,18 +7031,13 @@ namespace Server
|
|||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
if (state != m_NetState && (everyone || !state.Mobile.CanSee(this)))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
@ -7320,19 +7280,14 @@ namespace Server
|
|||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
var m = state.Mobile;
|
||||
if (!m.CanSee(this))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
state.Send(removeEntity);
|
||||
}
|
||||
else
|
||||
|
|
@ -7556,18 +7511,13 @@ namespace Server
|
|||
|
||||
var eable = map.GetClientsInRange(oldLocation);
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var ns in eable)
|
||||
{
|
||||
if (ns != m_NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, Serial);
|
||||
ns.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
@ -9234,8 +9184,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
|
|
@ -9243,12 +9192,12 @@ namespace Server
|
|||
{
|
||||
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -9266,8 +9215,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
|
|
@ -9275,11 +9223,12 @@ namespace Server
|
|||
{
|
||||
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
);
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -9300,8 +9249,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(affix, args)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(affix, args)].InitializePacket();
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
|
|
@ -9309,11 +9257,12 @@ namespace Server
|
|||
{
|
||||
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, affixType, affix, args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, affixType, affix, args
|
||||
);
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -9348,8 +9297,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
|
|
@ -9357,11 +9305,12 @@ namespace Server
|
|||
{
|
||||
if (state != m_NetState && state.Mobile.CanSee(this))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
);
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -9379,8 +9328,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
|
||||
|
|
@ -9388,12 +9336,12 @@ namespace Server
|
|||
{
|
||||
if (state != m_NetState && state.Mobile.CanSee(this))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using System;
|
|||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Toolkit.HighPerformance.Memory;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
@ -42,25 +43,27 @@ namespace Server.Network
|
|||
// If LOCAL INIT is off, then stack/heap allocations have garbage data
|
||||
// Initializes the first byte (Packet ID) so it can be used as a flag.
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InitializePacket(this Span<byte> buffer)
|
||||
public static Span<byte> InitializePacket(this Span<byte> buffer)
|
||||
{
|
||||
#if NO_LOCAL_INIT
|
||||
buffer[0] = 0;
|
||||
if (buffer != null)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
}
|
||||
#endif
|
||||
return buffer;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InitializePackets(this Span<byte> buffer, int chunkLength)
|
||||
public static Span2D<byte> InitializePackets(this Span2D<byte> buffer)
|
||||
{
|
||||
#if NO_LOCAL_INIT
|
||||
var index = 0;
|
||||
|
||||
while (index < buffer.Length)
|
||||
for (var i = 0; i < buffer.Height; i++)
|
||||
{
|
||||
buffer[index] = 0;
|
||||
index += chunkLength;
|
||||
buffer.GetRowSpan(i)[0] = 0;
|
||||
}
|
||||
#endif
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[SoundPacketLength];
|
||||
Span<byte> buffer = stackalloc byte[SoundPacketLength].InitializePacket();
|
||||
CreateSoundEffect(buffer, soundID, target);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
@ -40,6 +40,11 @@ namespace Server.Network
|
|||
|
||||
public static void CreateSoundEffect(Span<byte> buffer, int soundID, IPoint3D target)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0x54); // Packet ID
|
||||
writer.Write((byte)1); // flags
|
||||
|
|
@ -57,6 +62,11 @@ namespace Server.Network
|
|||
int explodeEffect, int explodeSound, Serial serial, int layer, int unknown
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xC7); // Packet ID
|
||||
writer.Write((byte)type);
|
||||
|
|
@ -168,6 +178,11 @@ namespace Server.Network
|
|||
int speed, int duration, bool fixedDirection, bool explode, int hue, int renderMode
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xC0); // Packet ID
|
||||
writer.Write((byte)type);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ namespace Server.Network
|
|||
|
||||
public static void CreateRemoveEntity(Span<byte> buffer, Serial serial)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0x1D); // Packet ID
|
||||
writer.Write(serial);
|
||||
|
|
@ -64,7 +69,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[RemoveEntityLength];
|
||||
Span<byte> buffer = stackalloc byte[RemoveEntityLength].InitializePacket();
|
||||
CreateRemoveEntity(buffer, serial);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ namespace Server.Network
|
|||
Serial serial, int graphic, MessageType type, int hue, int font, int number, string name = "", string args = ""
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return buffer.Length;
|
||||
}
|
||||
|
||||
name ??= "";
|
||||
args ??= "";
|
||||
|
||||
|
|
@ -91,7 +96,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLocalizedAffixLength(affix, args)];
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLocalizedAffixLength(affix, args)].InitializePacket();
|
||||
var length = CreateMessageLocalizedAffix(
|
||||
buffer, serial, graphic, type, hue, font, number, name, affixType, affix, args
|
||||
);
|
||||
|
|
@ -108,6 +113,11 @@ namespace Server.Network
|
|||
AffixType affixType, string affix = "", string args = ""
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return buffer.Length;
|
||||
}
|
||||
|
||||
name ??= "";
|
||||
affix ??= "";
|
||||
args ??= "";
|
||||
|
|
@ -146,7 +156,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLength(text)];
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLength(text)].InitializePacket();
|
||||
var length = CreateMessage(
|
||||
buffer,
|
||||
serial,
|
||||
|
|
@ -179,6 +189,11 @@ namespace Server.Network
|
|||
string text
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return buffer.Length;
|
||||
}
|
||||
|
||||
name ??= "";
|
||||
text ??= "";
|
||||
lang ??= "ENU";
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using System;
|
|||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Toolkit.HighPerformance.Memory;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
@ -25,7 +26,8 @@ namespace Server.Network
|
|||
public const int BondedStatusPacketLength = 11;
|
||||
public const int DeathAnimationPacketLength = 13;
|
||||
public const int MobileMovingPacketLength = 17;
|
||||
public const int MobileMovingPacketCacheLength = MobileMovingPacketLength * 8 * 2; // 8 notoriety, 2 client versions
|
||||
public const int MobileMovingPacketCacheHeight = 16; // 8 notoriety, 2 client versions
|
||||
public const int MobileMovingPacketCacheByteLength = MobileMovingPacketLength * MobileMovingPacketCacheHeight;
|
||||
public const int AttributeMaximum = 100;
|
||||
public const int MobileAttributePacketLength = 9;
|
||||
public const int MobileAttributesPacketLength = 17;
|
||||
|
|
@ -87,6 +89,11 @@ namespace Server.Network
|
|||
|
||||
public static void CreateMobileMoving(Span<byte> buffer, Mobile m, int noto, bool stygianAbyss)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var loc = m.Location;
|
||||
var hue = m.SolidHueOverride >= 0 ? m.SolidHueOverride : m.Hue;
|
||||
|
||||
|
|
@ -114,18 +121,18 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileMovingPacketLength];
|
||||
CreateMobileMoving(span, target, noto, ns.StygianAbyss);
|
||||
ns.Send(span);
|
||||
Span<byte> buffer = stackalloc byte[MobileMovingPacketLength].InitializePacket();
|
||||
CreateMobileMoving(buffer, target, noto, ns.StygianAbyss);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SendMobileMovingUsingCache(this NetState ns, Span<byte> cache, Mobile source, Mobile target) =>
|
||||
public static void SendMobileMovingUsingCache(this NetState ns, Span2D<byte> cache, Mobile source, Mobile target) =>
|
||||
ns.SendMobileMovingUsingCache(cache, target, Notoriety.Compute(source, target));
|
||||
|
||||
// Requires a buffer of 16 packets, 17bytes per packet (272 bytes).
|
||||
// Requires cache to have the first byte of each packet zeroed.
|
||||
public static void SendMobileMovingUsingCache(this NetState ns, Span<byte> cache, Mobile target, int noto)
|
||||
public static void SendMobileMovingUsingCache(this NetState ns, Span2D<byte> cache, Mobile target, int noto)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
|
|
@ -133,14 +140,9 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
var stygianAbyss = ns.StygianAbyss;
|
||||
var startIndex = (noto * 2 + (stygianAbyss ? 1 : 0)) * MobileMovingPacketLength;
|
||||
var buffer = cache.Slice(startIndex, MobileMovingPacketLength);
|
||||
|
||||
// Packet not created yet
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
CreateMobileMoving(buffer, target, noto, stygianAbyss);
|
||||
}
|
||||
var row = noto * 2 + (stygianAbyss ? 1 : 0);
|
||||
var buffer = cache.GetRowSpan(row);
|
||||
CreateMobileMoving(buffer, target, noto, stygianAbyss);
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
|
@ -283,6 +285,11 @@ namespace Server.Network
|
|||
Serial mobile, int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0x6E); // Packet ID
|
||||
writer.Write(mobile);
|
||||
|
|
|
|||
|
|
@ -219,6 +219,11 @@ namespace Server.Network
|
|||
int itemID, int hue, int amount
|
||||
)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0x23); // Packet ID
|
||||
writer.Write((short)itemID);
|
||||
|
|
@ -247,9 +252,9 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[DragEffectPacketLength];
|
||||
CreateDragEffect(span, srcSerial, srcLocation, trgSerial, trgLocation, itemID, hue, amount);
|
||||
ns.Send(span);
|
||||
Span<byte> buffer = stackalloc byte[DragEffectPacketLength].InitializePacket();
|
||||
CreateDragEffect(buffer, srcSerial, srcLocation, trgSerial, trgLocation, itemID, hue, amount);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
|
|||
|
|
@ -152,19 +152,25 @@ namespace Server
|
|||
{
|
||||
var length = OutgoingMessagePackets.GetMaxMessageLength(text);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[length];
|
||||
length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial.MinusOne, -1, MessageType.Regular, hue, 3, ascii, "ENU", "System", text
|
||||
);
|
||||
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
Span<byte> buffer = stackalloc byte[length].InitializePacket();
|
||||
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
if (ns.Mobile != null)
|
||||
if (ns.Mobile == null)
|
||||
{
|
||||
ns.Send(buffer);
|
||||
continue;
|
||||
}
|
||||
|
||||
length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial.MinusOne, -1, MessageType.Regular, hue, 3, ascii, "ENU", "System", text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -416,18 +416,13 @@ namespace Server.Commands
|
|||
toAll
|
||||
);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in m.GetClientsInRange(12))
|
||||
{
|
||||
if (toAll || state.Mobile.CanSee(m))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, index, m);
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, index, m);
|
||||
state.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ namespace Server.Commands
|
|||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
removeEntity.InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
{
|
||||
|
|
@ -78,11 +77,7 @@ namespace Server.Commands
|
|||
|
||||
if (!m.CanSee(pm) && Utility.InUpdateRange(m, pm))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, pm.Serial);
|
||||
}
|
||||
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, pm.Serial);
|
||||
m.NetState?.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -503,28 +503,27 @@ namespace Server.Engines.Doom
|
|||
/* I cant find any better way to send "speech" using fonts other than default */
|
||||
public static void POHMessage(Mobile from, int index)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(Msgs[index])];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(Msgs[index])].InitializePacket();
|
||||
|
||||
var eable = from.Map.GetClientsInRange(from.Location);
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
MsgParams[index][0],
|
||||
MsgParams[index][1],
|
||||
true,
|
||||
null,
|
||||
from.Name,
|
||||
Msgs[index]
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
MsgParams[index][0],
|
||||
MsgParams[index][1],
|
||||
true,
|
||||
null,
|
||||
from.Name,
|
||||
Msgs[index]
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength("")];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength("")].InitializePacket();
|
||||
|
||||
foreach (var state in GetClientsInRange(12))
|
||||
{
|
||||
|
|
@ -104,13 +103,13 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
|
||||
if (m.CanSee(this) && m.InLOS(this) && m.CanBeginAction(this))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
// Double Click On Me For Help!
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
|
||||
);
|
||||
// Double Click On Me For Help!
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -370,7 +370,8 @@ namespace Server.Engines.PartySystem
|
|||
|
||||
public void SendToAll(int number, string args = "", int hue = 0x3B2)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)];
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer,
|
||||
Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", args
|
||||
|
|
@ -415,8 +416,7 @@ namespace Server.Engines.PartySystem
|
|||
|
||||
private void SendToStaffMessage(Mobile from, string text)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
foreach (var ns in from.GetClientsInRange(8))
|
||||
{
|
||||
|
|
@ -425,21 +425,21 @@ namespace Server.Engines.PartySystem
|
|||
if (mob?.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel &&
|
||||
mob.Party != this && !m_Listeners.Contains(mob))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
from.SpeechHue,
|
||||
3,
|
||||
false,
|
||||
from.Language,
|
||||
from.Name,
|
||||
text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
from.SpeechHue,
|
||||
3,
|
||||
false,
|
||||
from.Language,
|
||||
from.Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -504,8 +504,7 @@ namespace Server.Engines.PartySystem
|
|||
m_Mobile.SendLocalizedMessage(1005437); // You have rejoined the party.
|
||||
m_Mobile.Send(new PartyMemberList(p));
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(m_Mobile.Name, "")];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(m_Mobile.Name, "")].InitializePacket();
|
||||
|
||||
Span<byte> attrsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributesPacketLength];
|
||||
OutgoingMobilePackets.CreateMobileAttributes(attrsPacket, m_Mobile, true);
|
||||
|
|
@ -516,32 +515,34 @@ namespace Server.Engines.PartySystem
|
|||
{
|
||||
var m = mi.Mobile;
|
||||
|
||||
if (m != m_Mobile)
|
||||
if (m == m_Mobile)
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
|
||||
buffer,
|
||||
Serial.MinusOne,
|
||||
-1,
|
||||
MessageType.Label,
|
||||
0x3B2,
|
||||
3,
|
||||
1008087,
|
||||
"",
|
||||
AffixType.Prepend | AffixType.System,
|
||||
m_Mobile.Name
|
||||
);
|
||||
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
m.NetState?.Send(buffer);
|
||||
m.NetState.SendMobileStatusCompact(m_Mobile, m_Mobile.CanBeRenamedBy(m));
|
||||
m.NetState?.Send(attrsPacket);
|
||||
ns.SendMobileStatusCompact(m, m.CanBeRenamedBy(m_Mobile));
|
||||
ns.SendMobileAttributes(m, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
|
||||
buffer,
|
||||
Serial.MinusOne,
|
||||
-1,
|
||||
MessageType.Label,
|
||||
0x3B2,
|
||||
3,
|
||||
1008087,
|
||||
"",
|
||||
AffixType.Prepend | AffixType.System,
|
||||
m_Mobile.Name
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
m.NetState?.Send(buffer);
|
||||
m.NetState.SendMobileStatusCompact(m_Mobile, m_Mobile.CanBeRenamedBy(m));
|
||||
m.NetState?.Send(attrsPacket);
|
||||
ns.SendMobileStatusCompact(m, m.CanBeRenamedBy(m_Mobile));
|
||||
ns.SendMobileAttributes(m, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,16 +87,11 @@ namespace Server.Items
|
|||
}
|
||||
else
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in GetClientsInRange(2))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, 0x127, GetWorldLocation());
|
||||
}
|
||||
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, 0x127, GetWorldLocation());
|
||||
state.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,8 +330,7 @@ namespace Server.Guilds
|
|||
|
||||
public void AllianceChat(Mobile from, int hue, string text)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
for (var i = 0; i < m_Members.Count; i++)
|
||||
{
|
||||
|
|
@ -339,21 +338,21 @@ namespace Server.Guilds
|
|||
|
||||
for (var j = 0; j < g.Members.Count; j++)
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Alliance,
|
||||
hue,
|
||||
3,
|
||||
false,
|
||||
from.Language,
|
||||
from.Name,
|
||||
text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Alliance,
|
||||
hue,
|
||||
3,
|
||||
false,
|
||||
from.Language,
|
||||
from.Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
@ -1520,18 +1519,17 @@ namespace Server.Guilds
|
|||
|
||||
public void GuildChat(Mobile from, int hue, string text)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
for (var i = 0; i < Members.Count; i++)
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, from.Serial, from.Body, MessageType.Guild, hue, 3, false, from.Language,
|
||||
from.Name, text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, from.Serial, from.Body, MessageType.Guild, hue, 3, false, from.Language,
|
||||
from.Name, text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2818,8 +2818,7 @@ namespace Server.Mobiles
|
|||
|
||||
private static void SendToStaffMessage(Mobile from, string text)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
buffer.InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
foreach (var ns in from.GetClientsInRange(8))
|
||||
{
|
||||
|
|
@ -2827,21 +2826,21 @@ namespace Server.Mobiles
|
|||
|
||||
if (mob?.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel)
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
from.SpeechHue,
|
||||
3,
|
||||
false,
|
||||
from.Language,
|
||||
from.Name,
|
||||
text
|
||||
);
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer,
|
||||
from.Serial,
|
||||
from.Body,
|
||||
MessageType.Regular,
|
||||
from.SpeechHue,
|
||||
3,
|
||||
false,
|
||||
from.Language,
|
||||
from.Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue