- [X] Fixes map issues at New Haven by turning off static diffs - [X] Some code cleanup and reformatting of tile matrix, tile matrix patch, and tile data - [X] Adds NetState.Flush for generating spawners so it doesn't feel like the server is frozen - [X] Reverts NativeReader changes from a while back. - [X] Adds more string reading for BufferReader. Notes: BufferReader is still `little endian` compared to `SpanReader` which is `big endian` (for packets). To that end, the RunUO deserialization `ReadString()` was made obsolete since it is ambiguous, and contains extra fields other than simply reading a string. Furthermore, we shouldn't be using UTF8 (for now) since it is slow.
91 lines
3 KiB
C#
91 lines
3 KiB
C#
/*************************************************************************
|
|
* ModernUO *
|
|
* Copyright 2019-2020 - ModernUO Development Team *
|
|
* Email: hi@modernuo.com *
|
|
* File: OutgoingMapPackets.cs *
|
|
* *
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
*************************************************************************/
|
|
|
|
using System.Buffers;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Server.Network
|
|
{
|
|
public static class OutgoingMapPackets
|
|
{
|
|
public static void SendMapPatches(this NetState ns)
|
|
{
|
|
if (ns == null || ns.ProtocolChanges >= ProtocolChanges.Version6000)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int count;
|
|
|
|
if (ns.HasFlag(ClientFlags.TerMur))
|
|
{
|
|
count = 6;
|
|
}
|
|
else if (ns.HasFlag(ClientFlags.Tokuno))
|
|
{
|
|
count = 5;
|
|
}
|
|
else if (ns.HasFlag(ClientFlags.Malas))
|
|
{
|
|
count = 4;
|
|
}
|
|
else if (ns.HasFlag(ClientFlags.Ilshenar))
|
|
{
|
|
count = 3;
|
|
}
|
|
else if (ns.HasFlag(ClientFlags.Trammel))
|
|
{
|
|
count = 2;
|
|
}
|
|
else if (ns.HasFlag(ClientFlags.Felucca))
|
|
{
|
|
count = 1;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
var writer = new SpanWriter(stackalloc byte[9 + count * 8]);
|
|
writer.Write((byte)0xBF); // Packet ID
|
|
writer.Write((ushort)41); // Length
|
|
writer.Write((ushort)0x18); // Subpacket
|
|
writer.Write(count);
|
|
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
var map = Map.Maps[i];
|
|
|
|
writer.Write(map.Tiles.Patch.StaticBlocks);
|
|
writer.Write(map.Tiles.Patch.LandBlocks);
|
|
}
|
|
|
|
ns.Send(writer.Span);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void SendInvalidMap(this NetState ns) => ns?.Send(stackalloc byte[] { 0xC6 });
|
|
|
|
public static void SendMapChange(this NetState ns, Map map)
|
|
{
|
|
if (map == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ns?.Send(stackalloc byte[] { 0xBF, 0x00, 0x06, 0x00, 0x08, (byte)map.MapID });
|
|
}
|
|
}
|
|
}
|