Error and server list packets added. Reserve will send error to client if a character name is take for a server. Code to send out server list on GetCharacters added.

This commit is contained in:
Filip Maj 2015-09-02 14:07:45 -04:00
parent c982493d66
commit 091166b41a
8 changed files with 216 additions and 223 deletions

View file

@ -13,7 +13,7 @@ namespace FFXIVClassic_Lobby_Server.packets
public unsafe struct SessionPacket
{
[FieldOffset(0)]
public uint sequence;
public UInt64 sequence;
[FieldOffset(0x50)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
public String version;
@ -22,13 +22,35 @@ namespace FFXIVClassic_Lobby_Server.packets
public String session;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct WorldListPacket
{
public UInt64 sequence;
public byte isEndList;
public uint numWorlds;
public byte unknown1;
public ushort unknown2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public WorldListEntry[] worlds;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct WorldListEntry
{
public ushort id;
public ushort listPosition;
public uint population;
public UInt64 unknown;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x40)]
public String name;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct CharacterRequestPacket
{
public uint sequence;
public uint unknown;
public UInt64 sequence;
public uint characterId;
public uint unknown2;
public uint personType;
public byte slot;
public byte command;
public ushort worldId;
@ -38,6 +60,51 @@ namespace FFXIVClassic_Lobby_Server.packets
public String characterInfoEncoded;
}
//Response Packets
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ReserveCharaResponse
{
public UInt64 sequence;
public uint errorCode;
public uint statusCode;
public uint errorId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x2BB)]
public String errorMessage;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct MakeCharaResponse
{
public UInt64 sequence;
public uint errorCode;
public uint statusCode;
public uint errorId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x2BB)]
public String errorMessage;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct DeleteCharaResponse
{
public UInt64 sequence;
public uint errorCode;
public uint statusCode;
public uint errorId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x2BB)]
public String errorMessage;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ErrorPacket
{
public UInt64 sequence;
public uint errorCode;
public uint statusCode;
public uint errorId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x2BB)]
public String errorMessage;
}
public static unsafe CharacterRequestPacket toCharacterRequestStruct(byte[] bytes)
{
fixed (byte* pdata = &bytes[0])
@ -53,5 +120,22 @@ namespace FFXIVClassic_Lobby_Server.packets
return (SessionPacket)Marshal.PtrToStructure(new IntPtr(pdata), typeof(SessionPacket));
}
}
public static byte[] StructureToByteArray(object obj)
{
int len = Marshal.SizeOf(obj);
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(obj, ptr, true);
Marshal.Copy(ptr, arr, 0, len);
Marshal.FreeHGlobal(ptr);
return arr;
}
}
}