Party invite done, as well as chat. Fixed double output of say packets. Note: Still need to implement name version of invite!!!

This commit is contained in:
Filip Maj 2017-01-02 14:35:11 -05:00
parent 5af1f6dba6
commit 5d494255ad
16 changed files with 231 additions and 23 deletions

View File

@ -286,7 +286,7 @@
<Compile Include="packets\WorldPackets\Send\Group\CreateLinkshellPacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\DeleteLinkshellPacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\ModifyLinkshellPacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\PartyInviteResultPacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\GroupInviteResultPacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\PartyInvitePacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\PartyLeavePacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\PartyModifyPacket.cs" />

View File

@ -111,6 +111,7 @@ namespace FFXIVClassic_Map_Server
return; ;
}
if (chatMessage.logType == SendMessagePacket.MESSAGE_TYPE_SAY || chatMessage.logType == SendMessagePacket.MESSAGE_TYPE_SHOUT)
session.GetActor().BroadcastPacket(SendMessagePacket.BuildPacket(session.id, session.id, chatMessage.logType, session.GetActor().customDisplayName, chatMessage.message), false);
break;

View File

@ -748,6 +748,23 @@ namespace FFXIVClassic_Map_Server
currentPlayerParties.Remove(party.groupIndex);
}
public void CreateInvitePartyGroup(Player player, string name)
{
SubPacket invitePacket = PartyInvitePacket.BuildPacket(player.playerSession, name);
player.QueuePacket(invitePacket);
}
public void CreateInvitePartyGroup(Player player, uint actorId)
{
SubPacket invitePacket = PartyInvitePacket.BuildPacket(player.playerSession, actorId);
player.QueuePacket(invitePacket);
}
public void GroupInviteResult(Player player, uint groupType, uint result)
{
SubPacket groupInviteResultPacket = GroupInviteResultPacket.BuildPacket(player.playerSession, groupType, result);
player.QueuePacket(groupInviteResultPacket);
}
public Player GetPCInWorld(string name)
{
foreach (Zone zone in zoneList.Values)

View File

@ -608,14 +608,15 @@ namespace FFXIVClassic_Map_Server.Actors
public void BroadcastPacket(SubPacket packet, bool sendToSelf)
{
if (sendToSelf)
QueuePacket(packet);
foreach (Actor a in playerSession.actorInstanceList)
{
if (a is Player)
{
Player p = (Player)a;
if (p.Equals(this) && !sendToSelf)
continue;
SubPacket clonedPacket = new SubPacket(packet, a.actorId);
p.QueuePacket(clonedPacket);
}

View File

@ -9,18 +9,19 @@ using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group
{
class PartyInviteResultPacket
class GroupInviteResultPacket
{
public const ushort OPCODE = 0x1023;
public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(Session session, uint result)
public static SubPacket BuildPacket(Session session, uint groupType, uint result)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)groupType);
binWriter.Write((UInt32)result);
}
}

View File

@ -48,6 +48,17 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
return new List<GroupMember>();
}
public void SendGroupPacketsAll(params uint[] sessionIds)
{
for (int i = 0; i < sessionIds.Length; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendGroupPackets(session);
}
}
public void SendGroupPacketsAll(List<uint> sessionIds)
{
for (int i = 0; i < sessionIds.Count; i++)
@ -59,6 +70,28 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
}
}
public void SendDeletePackets(params uint[] sessionIds)
{
for (int i = 0; i < sessionIds.Length; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendDeletePacket(session);
}
}
public void SendDeletePackets(List<uint> sessionIds)
{
for (int i = 0; i < sessionIds.Count; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendDeletePacket(session);
}
}
public void SendGroupPackets(Session session)
{
ulong time = Utils.MilisUnixTimeStampUTC();
@ -87,6 +120,11 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
}
public void SendDeletePacket(Session session)
{
session.clientConnection.QueuePacket(DeleteGroupPacket.buildPacket(session.sessionId, this), true, false);
}
public virtual void SendInitWorkValues(Session session)
{

View File

@ -253,5 +253,17 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
return groupMembers;
}
public void OnPlayerJoin(Session inviteeSession)
{
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
session.SendGameMessage(30427, 0x20, (Object)Server.GetServer().GetNameForId(inviteeSession.sessionId));
}
}
}
}

View File

@ -90,6 +90,8 @@
<Compile Include="LinkshellManager.cs" />
<Compile Include="PacketProcessor.cs" />
<Compile Include="Packets\Receive\HelloPacket.cs" />
<Compile Include="Packets\Receive\Subpackets\PartyChatMessagePacket.cs" />
<Compile Include="Packets\Receive\Subpackets\ChatMessagePacket.cs" />
<Compile Include="Packets\Receive\Subpackets\GroupCreatedPacket.cs" />
<Compile Include="Packets\Send\Subpackets\GameMessagePacket.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\CreateNamedGroup.cs" />
@ -108,7 +110,7 @@
<Compile Include="Packets\Send\_0x2Packet.cs" />
<Compile Include="Packets\Send\_0x7Packet.cs" />
<Compile Include="Packets\Send\_0x8PingPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyInviteResultPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\GroupInviteResultPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyLeavePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyInvitePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyModifyPacket.cs" />

View File

@ -1,9 +1,11 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.DataObjects.Group;
using FFXIVClassic_World_Server.Packets.Receive;
using FFXIVClassic_World_Server.Packets.Receive.Subpackets;
using FFXIVClassic_World_Server.Packets.Send;
using FFXIVClassic_World_Server.Packets.Send.Login;
using FFXIVClassic_World_Server.Packets.Send.Subpackets;
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive;
using FFXIVClassic_World_Server.Packets.WorldPackets.Send;
using System;
@ -151,6 +153,19 @@ namespace FFXIVClassic_World_Server
{
switch (subpacket.gameMessage.opcode)
{
case 0x00C9:
subpacket.DebugPrintSubPacket();
PartyChatMessagePacket partyChatMessagePacket = new PartyChatMessagePacket(subpacket.data);
Party playerParty = mServer.GetWorldManager().GetPartyManager().GetParty(session.sessionId);
for (int i = 0; i < playerParty.members.Count; i++)
{
Session thatSession = mServer.GetSession(playerParty.members[i]);
if (thatSession != null && !session.Equals(thatSession))
{
thatSession.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, thatSession.sessionId, SendMessagePacket.MESSAGE_TYPE_PARTY, mServer.GetNameForId(session.sessionId), partyChatMessagePacket.message), true, false);
}
}
break;
case 0x6:
mServer.GetWorldManager().DoLogin(session);
break;

View File

@ -0,0 +1,42 @@
using System;
using System.IO;
using System.Text;
namespace FFXIVClassic_World_Server.Packets.Receive.Subpackets
{
class ChatMessagePacket
{
public float posX;
public float posY;
public float posZ;
public float posRot;
public uint logType;
public string message;
public bool invalidPacket = false;
public ChatMessagePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try{
binReader.ReadUInt64();
posX = binReader.ReadSingle();
posY = binReader.ReadSingle();
posZ = binReader.ReadSingle();
posRot = binReader.ReadSingle();
logType = binReader.ReadUInt32();
message = Encoding.ASCII.GetString(binReader.ReadBytes(0x200)).Trim(new [] { '\0' });
}
catch (Exception){
invalidPacket = true;
}
}
}
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.IO;
using System.Text;
namespace FFXIVClassic_World_Server.Packets.Receive.Subpackets
{
class PartyChatMessagePacket
{
public uint actorId;
public string message;
public bool invalidPacket = false;
public PartyChatMessagePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try{
actorId = binReader.ReadUInt32();
message = Encoding.ASCII.GetString(binReader.ReadBytes(0x200)).Trim(new [] { '\0' });
}
catch (Exception){
invalidPacket = true;
}
}
}
}
}
}

View File

@ -46,6 +46,7 @@ namespace FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups
binWriter.Seek(0x64, SeekOrigin.Begin);
//Does this change chat????
binWriter.Write((UInt32)0x6D);
binWriter.Write((UInt32)0x6D);
binWriter.Write((UInt32)0x6D);

View File

@ -5,13 +5,14 @@ using System.Text;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
class PartyInviteResultPacket
class GroupInviteResultPacket
{
public bool invalidPacket = false;
public uint groupType;
public uint result;
public PartyInviteResultPacket(byte[] data)
public GroupInviteResultPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
@ -19,6 +20,7 @@ namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
try
{
groupType = binReader.ReadUInt32();
result = binReader.ReadUInt32();
}
catch (Exception)

View File

@ -23,7 +23,7 @@ namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
command = binReader.ReadUInt16();
if (command == 0)
if (command == 1)
actorId = binReader.ReadUInt32();
else
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });

View File

@ -233,16 +233,23 @@ namespace FFXIVClassic_World_Server
//Party Invite Request
case 0x1022:
PartyInvitePacket partyInvitePacket = new PartyInvitePacket(subpacket.data);
if (partyInvitePacket.command == 0)
if (partyInvitePacket.command == 1)
mWorldManager.ProcessPartyInvite(GetSession(subpacket.header.sourceId), partyInvitePacket.actorId);
else if (partyInvitePacket.command == 1)
else if (partyInvitePacket.command == 0)
{
}
break;
//Party Invite Result
//Group Invite Result
case 0x1023:
PartyInviteResultPacket partyInviteResultPacket = new PartyInviteResultPacket(subpacket.data);
GroupInviteResultPacket groupInviteResultPacket = new GroupInviteResultPacket(subpacket.data);
switch (groupInviteResultPacket.groupType)
{
case 0x2711:
mWorldManager.ProcessPartyInviteResult(GetSession(subpacket.header.sourceId), groupInviteResultPacket.result);
break;
}
break;
//Linkshell create request

View File

@ -220,9 +220,6 @@ namespace FFXIVClassic_World_Server
List<Linkshell> linkshells = mLinkshellManager.GetPlayerLinkshellMembership(session.sessionId);
foreach (Linkshell ls in linkshells)
ls.SendGroupPackets(session);
mRelationGroupManager.CreatePartyRelationGroup(157, session.sessionId).SendGroupPackets(session);
}
private void SendMotD(Session session)
@ -292,9 +289,50 @@ namespace FFXIVClassic_World_Server
}
}
public void ProcessPartyInvite(Session request, uint invitee)
public void ProcessPartyInvite(Session requestSession, uint invitee)
{
throw new NotImplementedException();
if (mServer.GetSession(invitee) == null)
{
requestSession.SendGameMessage(30544, 0x20);
}
else
{
Session inviteeSession = mServer.GetSession(invitee);
Relation inviteRelation = mRelationGroupManager.CreatePartyRelationGroup(requestSession.sessionId, invitee);
inviteRelation.SendGroupPacketsAll(requestSession.sessionId, invitee);
inviteeSession.SendGameMessage(30430, 0x20, (object)mServer.GetNameForId(requestSession.sessionId)); //X Invited you
requestSession.SendGameMessage(30433, 0x20, (object)mServer.GetNameForId(inviteeSession.sessionId)); //You invite X
}
}
public void ProcessPartyInviteResult(Session inviteeSession, uint resultCode)
{
Relation relation = mRelationGroupManager.GetPartyRelationGroup(inviteeSession.sessionId);
Session inviterSession = mServer.GetSession(relation.GetHost());
//Accept
if (resultCode == 1)
{
Party oldParty = mPartyManager.GetParty(inviteeSession.sessionId);
if (oldParty.members.Count == 1)
{
mPartyManager.DeleteParty(oldParty.groupIndex);
Party newParty = mPartyManager.GetParty(inviterSession.sessionId);
mPartyManager.AddToParty(newParty.groupIndex, inviteeSession.sessionId);
newParty.SendGroupPacketsAll(newParty.members);
SendPartySync(newParty);
newParty.OnPlayerJoin(inviteeSession);
}
}
else //Refuse
{
inviterSession.SendGameMessage(30573, 0x20, (object)mServer.GetNameForId(inviteeSession.sessionId)); //X rejects your invite
}
//Delete the relation
mRelationGroupManager.DeleteRelationGroup(relation.groupIndex);
relation.SendDeletePackets(inviterSession.sessionId, inviteeSession.sessionId);
}
public void IncrementGroupIndex()