2016-08-23 16:57:24 -04:00
|
|
|
|
using FFXIVClassic.Common;
|
2016-08-24 14:18:37 -04:00
|
|
|
|
using FFXIVClassic_World_Server.DataObjects;
|
|
|
|
|
using FFXIVClassic_World_Server.Packets.Receive;
|
2016-08-24 15:41:54 -04:00
|
|
|
|
using FFXIVClassic_World_Server.Packets.Send;
|
2016-08-23 16:57:24 -04:00
|
|
|
|
using FFXIVClassic_World_Server.Packets.Send.Login;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace FFXIVClassic_World_Server
|
|
|
|
|
{
|
|
|
|
|
class PacketProcessor
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
Session Creation:
|
|
|
|
|
|
|
|
|
|
Get 0x1 from server
|
|
|
|
|
Send 0x7
|
|
|
|
|
Send 0x2
|
|
|
|
|
|
|
|
|
|
Zone Change:
|
|
|
|
|
|
|
|
|
|
Send 0x7
|
|
|
|
|
Get 0x8 - Wait??
|
|
|
|
|
Send 0x2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Server mServer;
|
|
|
|
|
|
|
|
|
|
public PacketProcessor(Server server)
|
|
|
|
|
{
|
|
|
|
|
mServer = server;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ProcessPacket(ClientConnection client, BasePacket packet)
|
|
|
|
|
{
|
2016-08-24 15:41:54 -04:00
|
|
|
|
if (packet.header.isCompressed == 0x01)
|
|
|
|
|
BasePacket.DecompressPacket(ref packet);
|
2016-08-23 16:57:24 -04:00
|
|
|
|
|
|
|
|
|
List<SubPacket> subPackets = packet.GetSubpackets();
|
|
|
|
|
foreach (SubPacket subpacket in subPackets)
|
|
|
|
|
{
|
|
|
|
|
//Initial Connect Packet, Create session
|
|
|
|
|
if (subpacket.header.type == 0x01)
|
2016-08-24 15:41:54 -04:00
|
|
|
|
{
|
2016-08-24 14:18:37 -04:00
|
|
|
|
HelloPacket hello = new HelloPacket(packet.data);
|
2016-08-23 16:57:24 -04:00
|
|
|
|
|
|
|
|
|
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
|
2016-08-24 14:18:37 -04:00
|
|
|
|
mServer.AddSession(client, Session.Channel.ZONE, hello.sessionId);
|
2016-08-23 16:57:24 -04:00
|
|
|
|
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
|
2016-08-24 15:41:54 -04:00
|
|
|
|
mServer.AddSession(client, Session.Channel.CHAT, hello.sessionId);
|
|
|
|
|
|
|
|
|
|
client.QueuePacket(_0x7Packet.BuildPacket(0x0E016EE5), true, false);
|
|
|
|
|
client.QueuePacket(_0x2Packet.BuildPacket(hello.sessionId), true, false);
|
2016-08-23 16:57:24 -04:00
|
|
|
|
}
|
|
|
|
|
//Ping from World Server
|
|
|
|
|
else if (subpacket.header.type == 0x07)
|
|
|
|
|
{
|
2016-08-24 15:41:54 -04:00
|
|
|
|
SubPacket init = _0x8PingPacket.BuildPacket(client.owner.sessionId);
|
2016-08-23 16:57:24 -04:00
|
|
|
|
client.QueuePacket(BasePacket.CreatePacket(init, true, false));
|
|
|
|
|
}
|
|
|
|
|
//Zoning Related
|
|
|
|
|
else if (subpacket.header.type == 0x08)
|
|
|
|
|
{
|
|
|
|
|
//Response, client's current [actorID][time]
|
|
|
|
|
//BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x07);
|
|
|
|
|
//client.QueuePacket(init);
|
|
|
|
|
packet.DebugPrintPacket();
|
|
|
|
|
}
|
|
|
|
|
//Game Message
|
|
|
|
|
else if (subpacket.header.type == 0x03)
|
|
|
|
|
{
|
|
|
|
|
//Send to the correct zone server
|
|
|
|
|
uint targetSession = subpacket.header.targetId;
|
2016-08-29 08:17:14 -04:00
|
|
|
|
mServer.GetSession(targetSession).routing1 = Server.GetServer().GetWorldManager().mZoneServerList["127.0.0.1:1989"];
|
2016-08-23 16:57:24 -04:00
|
|
|
|
|
|
|
|
|
if (mServer.GetSession(targetSession).routing1 != null)
|
|
|
|
|
mServer.GetSession(targetSession).routing1.SendPacket(subpacket);
|
|
|
|
|
|
|
|
|
|
if (mServer.GetSession(targetSession).routing2 != null)
|
|
|
|
|
mServer.GetSession(targetSession).routing2.SendPacket(subpacket);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
packet.DebugPrintPacket();
|
|
|
|
|
}
|
2016-08-29 08:17:14 -04:00
|
|
|
|
}
|
2016-08-23 16:57:24 -04:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|