Relation group work.

This commit is contained in:
Filip Maj 2017-01-02 11:47:14 -05:00
parent 6ba1f968c3
commit 5af1f6dba6
11 changed files with 234 additions and 16 deletions

View File

@ -286,6 +286,8 @@
<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\PartyInvitePacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\PartyLeavePacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\PartyModifyPacket.cs" />
<Compile Include="packets\WorldPackets\Send\SessionBeginConfirmPacket.cs" />

View File

@ -0,0 +1,45 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.dataobjects;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group
{
class PartyInvitePacket
{
public const ushort OPCODE = 0x1022;
public const uint PACKET_SIZE = 0x48;
public static SubPacket BuildPacket(Session session, string name)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt16)0);
binWriter.Write(Encoding.ASCII.GetBytes(name), 0, Encoding.ASCII.GetByteCount(name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(name));
}
}
return new SubPacket(true, OPCODE, session.id, session.id, data);
}
public static SubPacket BuildPacket(Session session, uint actorId)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt16)1);
binWriter.Write((UInt32)actorId);
}
}
return new SubPacket(true, OPCODE, session.id, session.id, data);
}
}
}

View File

@ -0,0 +1,31 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.dataobjects;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group
{
class PartyInviteResultPacket
{
public const ushort OPCODE = 0x1023;
public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(Session session, uint result)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)result);
}
}
return new SubPacket(true, OPCODE, session.id, session.id, data);
}
}
}

View File

@ -200,7 +200,7 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
public uint GetLeader()
{
return (uint)((partyGroupWork._globalTemp.owner >> 32) & 0xFFFFFFFF);
return (uint)(((ulong)partyGroupWork._globalTemp.owner >> 32) & 0xFFFFFFFF);
}
public uint GetIdForName(string name)

View File

@ -21,6 +21,16 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
work._globalTemp.variableCommand = command;
}
public uint GetHost()
{
return (uint)(((ulong)work._globalTemp.host >> 32) & 0xFFFFFFFF);
}
public uint GetOther()
{
return charaOther;
}
public override int GetMemberCount()
{
return 2;

View File

@ -108,7 +108,9 @@
<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\PartyLeavePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyInvitePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyModifyPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\SetActiveLinkshellPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\ModifyLinkshellPacket.cs" />

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
{
class PartyInvitePacket
{
public bool invalidPacket = false;
public ushort command;
public string name;
public uint actorId;
public PartyInvitePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
command = binReader.ReadUInt16();
if (command == 0)
actorId = binReader.ReadUInt32();
else
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

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 PartyInviteResultPacket
{
public bool invalidPacket = false;
public uint result;
public PartyInviteResultPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
result = binReader.ReadUInt32();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View File

@ -9,7 +9,8 @@ namespace FFXIVClassic_World_Server
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<ulong, Relation> mRelationList = new Dictionary<ulong, Relation>();
private Dictionary<ulong, Relation> mPartyRelationList = new Dictionary<ulong, Relation>();
private Dictionary<ulong, Relation> mLinkshellRelationList = new Dictionary<ulong, Relation>();
public RelationGroupManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
@ -18,23 +19,64 @@ namespace FFXIVClassic_World_Server
mCurrentWorldGroupsReference = worldGroupList;
}
public Relation CreateRelationGroup(uint hostCharaId, uint otherCharaId, uint command)
public Relation CreatePartyRelationGroup(uint hostCharaId, uint otherCharaId)
{
lock (mGroupLockReference)
{
ulong groupIndex = mWorldManager.GetGroupIndex();
Relation relation = new Relation(groupIndex, hostCharaId, otherCharaId, command);
mRelationList.Add(groupIndex, relation);
Relation relation = new Relation(groupIndex, hostCharaId, otherCharaId, 10001);
mPartyRelationList.Add(groupIndex, relation);
mCurrentWorldGroupsReference.Add(groupIndex, relation);
mWorldManager.IncrementGroupIndex();
return relation;
}
}
public Relation CreateLinkshellRelationGroup(uint hostCharaId, uint otherCharaId)
{
lock (mGroupLockReference)
{
ulong groupIndex = mWorldManager.GetGroupIndex();
Relation relation = new Relation(groupIndex, hostCharaId, otherCharaId, 10002);
mLinkshellRelationList.Add(groupIndex, relation);
mCurrentWorldGroupsReference.Add(groupIndex, relation);
mWorldManager.IncrementGroupIndex();
return relation;
}
}
public Relation GetPartyRelationGroup(uint charaId)
{
lock (mGroupLockReference)
{
foreach (Relation relation in mPartyRelationList.Values)
{
if (relation.GetHost() == charaId || relation.GetOther() == charaId)
return relation;
}
return null;
}
}
public Relation GetLinkshellRelationGroup(uint charaId)
{
lock (mGroupLockReference)
{
foreach (Relation relation in mLinkshellRelationList.Values)
{
if (relation.GetHost() == charaId || relation.GetOther() == charaId)
return relation;
}
return null;
}
}
public void DeleteRelationGroup(ulong groupId)
{
if (mRelationList.ContainsKey(groupId))
mRelationList.Remove(groupId);
if (mPartyRelationList.ContainsKey(groupId))
mPartyRelationList.Remove(groupId);
if (mLinkshellRelationList.ContainsKey(groupId))
mLinkshellRelationList.Remove(groupId);
if (mCurrentWorldGroupsReference.ContainsKey(groupId))
mCurrentWorldGroupsReference.Remove(groupId);
}

View File

@ -229,6 +229,21 @@ namespace FFXIVClassic_World_Server
else
leavePt.DisbandPlayerRequest(GetSession(subpacket.header.sourceId));
break;
//Party Invite Request
case 0x1022:
PartyInvitePacket partyInvitePacket = new PartyInvitePacket(subpacket.data);
if (partyInvitePacket.command == 0)
mWorldManager.ProcessPartyInvite(GetSession(subpacket.header.sourceId), partyInvitePacket.actorId);
else if (partyInvitePacket.command == 1)
{
}
break;
//Party Invite Result
case 0x1023:
PartyInviteResultPacket partyInviteResultPacket = new PartyInviteResultPacket(subpacket.data);
break;
//Linkshell create request
case 0x1025:

View File

@ -213,13 +213,6 @@ namespace FFXIVClassic_World_Server
//Send party, retainer, ls groups
Party pt = mPartyManager.GetParty(session.sessionId);
if (session.sessionId == 156)
{
mPartyManager.AddToParty(pt.groupIndex, 0x6c);
mPartyManager.AddToParty(pt.groupIndex, 157);
}
pt.SendGroupPackets(session);
SendPartySync(pt);
@ -228,7 +221,8 @@ namespace FFXIVClassic_World_Server
foreach (Linkshell ls in linkshells)
ls.SendGroupPackets(session);
mRelationGroupManager.CreateRelationGroup(157, session.sessionId, 10001).SendGroupPackets(session);
mRelationGroupManager.CreatePartyRelationGroup(157, session.sessionId).SendGroupPackets(session);
}
private void SendMotD(Session session)
@ -298,6 +292,11 @@ namespace FFXIVClassic_World_Server
}
}
public void ProcessPartyInvite(Session request, uint invitee)
{
throw new NotImplementedException();
}
public void IncrementGroupIndex()
{
mRunningGroupIndex++;
@ -332,6 +331,7 @@ namespace FFXIVClassic_World_Server
{
return mLinkshellManager;
}
}
}