Kicked/Promote leader added but broke login. D/Cing now.

This commit is contained in:
Filip Maj 2016-12-21 18:02:50 -05:00
parent e89b7557b3
commit 16c9b741bf
30 changed files with 1120 additions and 211 deletions

View file

@ -0,0 +1,348 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
namespace FFXIVClassic_World_Server.Packets.Send.Subpackets
{
class GameMessagePacket
{
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR1 = 0x157;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR2 = 0x158;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR3 = 0x159;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR4 = 0x15a;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR5 = 0x15b;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x15c;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x15d;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x15e;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x15f;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x160;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x161;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x162;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x163;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x164;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x165;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x166;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x167;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x168;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x169;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x16a;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR1 = 0x30;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR2 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR3 = 0x40;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR4 = 0x50;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR5 = 0x70;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x48;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x58;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x68;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x78;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x98;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x30;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x40;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x50;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x60;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x28;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x48;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x68;
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint actorId, uint textOwnerActorId, ushort textId, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)actorId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITH_ACTOR1, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint actorId, uint textOwnerActorId, ushort textId, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)actorId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x14-12)
{
binWriter.Seek(0x14, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint textOwnerActorId, ushort textId, string sender, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
binWriter.Write(Encoding.ASCII.GetBytes(sender), 0, Encoding.ASCII.GetByteCount(sender) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sender));
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER1, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint textOwnerActorId, ushort textId, string sender, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
binWriter.Write(Encoding.ASCII.GetBytes(sender), 0, Encoding.ASCII.GetByteCount(sender) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sender));
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x14 - 12)
{
binWriter.Seek(0x30, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint textOwnerActorId, ushort textId, uint senderDisplayNameId, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)senderDisplayNameId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER1, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint textOwnerActorId, ushort textId, uint senderDisplayNameId, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)senderDisplayNameId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x14 - 12)
{
binWriter.Seek(0x14, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint textOwnerActorId, ushort textId, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITHOUT_ACTOR1, sourceId, targetId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint targetId, uint textOwnerActorId, ushort textId, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x8)
{
binWriter.Seek(0x10, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, targetId, data);
}
private static int findSizeOfParams(List<LuaParam> lParams)
{
int total = 0;
foreach (LuaParam l in lParams)
{
switch (l.typeID)
{
case 0:
case 1:
case 2:
total += 1 + 0x20;
break;
case 6:
total += 5;
break;
case 3:
case 4:
case 5:
total += 1;
break;
}
}
return total + 1;
}
}
}

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
class PartyLeavePacket
{
public bool invalidPacket = false;
public bool isDisband;
public PartyLeavePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
isDisband = binReader.ReadByte() == 1;
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -1,19 +1,21 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
class GroupMemberChangePacket
class PartyModifyPacket
{
public const int GROUP_MEMBER_ADD = 0;
public const int GROUP_MEMBER_REMOVE = 0;
public bool invalidPacket = false;
public uint controlCode;
public ulong groupId;
public uint memberId;
public GroupMemberChangePacket(byte[] data)
public const ushort MODIFY_LEADER = 0;
public const ushort MODIFY_KICKPLAYER = 1;
public ushort command;
public string name;
public PartyModifyPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
@ -21,9 +23,8 @@ namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
try
{
controlCode = binReader.ReadUInt32();
groupId = binReader.ReadUInt64();
memberId = binReader.ReadUInt32();
command = binReader.ReadUInt16();
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{

View file

@ -1,28 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using System;
using System.IO;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send.Group
{
class GroupMemberListEndPacket
{
public const ushort OPCODE = 0x1022;
public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(Session session, ulong groupId)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt64)groupId);
}
}
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
}
}
}

View file

@ -1,31 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using System;
using System.IO;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send.Group
{
class GroupMemberListPacket
{
public const ushort OPCODE = 0x1021;
public const uint PACKET_SIZE = 0x2C;
public static SubPacket BuildPacket(Session session, ulong groupId, uint numMembersInPacket)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt64)groupId);
binWriter.Write((UInt32)numMembersInPacket);
//Members
}
}
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
}
}
}

View file

@ -1,30 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using System;
using System.IO;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send.Group
{
class GroupMemberListStartPacket
{
public const ushort OPCODE = 0x1020;
public const uint PACKET_SIZE = 0x30;
public static SubPacket BuildPacket(Session session, int resultCode, ulong groupId, int numMembers)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32) resultCode);
binWriter.Write((UInt64) groupId);
binWriter.Write((UInt32) numMembers);
}
}
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
}
}
}

View file

@ -1,29 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using System;
using System.IO;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send.Group
{
class GroupWorkValuesPacket
{
public const ushort OPCODE = 0x1023;
public const uint PACKET_SIZE = 0x80;
public static SubPacket BuildPacket(Session session, ulong groupId)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt64)groupId);
//Write data
}
}
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
}
}
}