mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-16 08:35:07 +00:00
71bb96bf1e
Changes: - Moved alias mapping from Constants.cs to Stages.cs. - Added `odyssey` as an alias. - Hardcoded all known stage values. - Verfify that the stage input is either a alias or a known stage name. - Added an option to append `!` to a stage name to force sending even if the stage is not known (e.g. for custom kingdoms). Before it only checked that it was a known alias or that it contained `Stage` or `Zone`. That made it impossible to send players to`MoonWorldShopRoom` and `MoonWorldSphinxRoom`. And a typo would have resulted in a game crash.
24 lines
1 KiB
C#
24 lines
1 KiB
C#
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
using Shared.Packet;
|
|
using Shared.Packet.Packets;
|
|
|
|
namespace Shared;
|
|
|
|
public static class Constants {
|
|
public const int CostumeNameSize = 0x20;
|
|
|
|
// dictionary of packet types to packet
|
|
public static readonly Dictionary<Type, PacketAttribute> PacketMap = Assembly
|
|
.GetExecutingAssembly()
|
|
.GetTypes()
|
|
.Where(type => type.IsAssignableTo(typeof(IPacket)) && type.GetCustomAttribute<PacketAttribute>() != null)
|
|
.ToDictionary(type => type, type => type.GetCustomAttribute<PacketAttribute>()!);
|
|
public static readonly Dictionary<PacketType, Type> PacketIdMap = Assembly
|
|
.GetExecutingAssembly()
|
|
.GetTypes()
|
|
.Where(type => type.IsAssignableTo(typeof(IPacket)) && type.GetCustomAttribute<PacketAttribute>() != null)
|
|
.ToDictionary(type => type.GetCustomAttribute<PacketAttribute>()!.Type, type => type);
|
|
|
|
public static int HeaderSize { get; } = PacketHeader.StaticSize;
|
|
}
|