mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-09 05:54:50 +02:00
More work on the world server.
This commit is contained in:
parent
e24a6f99cb
commit
a1ca960543
7 changed files with 248 additions and 15 deletions
133
FFXIVClassic Proxy Server/PacketProcessor.cs
Normal file
133
FFXIVClassic Proxy Server/PacketProcessor.cs
Normal file
|
@ -0,0 +1,133 @@
|
|||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_World_Server.Packets.Send.Login;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
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;
|
||||
List<ClientConnection> mConnections;
|
||||
|
||||
public PacketProcessor(Server server)
|
||||
{
|
||||
mServer = server;
|
||||
}
|
||||
|
||||
public void ProcessPacket(ClientConnection client, BasePacket packet)
|
||||
{
|
||||
//if (packet.header.isCompressed == 0x01)
|
||||
// BasePacket.DecryptPacket(client.blowfish, ref packet);
|
||||
|
||||
List<SubPacket> subPackets = packet.GetSubpackets();
|
||||
foreach (SubPacket subpacket in subPackets)
|
||||
{
|
||||
//Initial Connect Packet, Create session
|
||||
if (subpacket.header.type == 0x01)
|
||||
{
|
||||
packet.DebugPrintPacket();
|
||||
byte[] reply1Data = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFD, 0xFF, 0xFF,
|
||||
0xE5, 0x6E, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x0
|
||||
};
|
||||
|
||||
byte[] reply2Data = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x38, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x2B, 0x5F, 0x26,
|
||||
0x66, 0x00, 0x00, 0x00, 0xC8, 0xD6, 0xAF, 0x2B, 0x38, 0x2B, 0x5F, 0x26, 0xB8, 0x8D, 0xF0, 0x2B,
|
||||
0xC8, 0xFD, 0x85, 0xFE, 0xA8, 0x7C, 0x5B, 0x09, 0x38, 0x2B, 0x5F, 0x26, 0xC8, 0xD6, 0xAF, 0x2B,
|
||||
0xB8, 0x8D, 0xF0, 0x2B, 0x88, 0xAF, 0x5E, 0x26
|
||||
};
|
||||
|
||||
BasePacket reply1 = new BasePacket(reply1Data);
|
||||
BasePacket reply2 = new BasePacket(reply2Data);
|
||||
|
||||
//Write Timestamp into Reply1
|
||||
using (MemoryStream mem = new MemoryStream(reply1.data))
|
||||
{
|
||||
using (BinaryWriter binReader = new BinaryWriter(mem))
|
||||
{
|
||||
binReader.BaseStream.Seek(0x14, SeekOrigin.Begin);
|
||||
binReader.Write((UInt32)Utils.UnixTimeStampUTC());
|
||||
}
|
||||
}
|
||||
|
||||
//Read in Actor Id that owns this connection
|
||||
uint actorID = 0;
|
||||
using (MemoryStream mem = new MemoryStream(packet.data))
|
||||
{
|
||||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] readIn = new byte[12];
|
||||
binReader.BaseStream.Seek(0x14, SeekOrigin.Begin);
|
||||
binReader.Read(readIn, 0, 12);
|
||||
actorID = UInt32.Parse(Encoding.ASCII.GetString(readIn));
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
mServer.AddSession(actorID);
|
||||
|
||||
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
|
||||
Program.Log.Info("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.GetAddress());
|
||||
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
|
||||
Program.Log.Info("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.GetAddress());
|
||||
|
||||
break;
|
||||
}
|
||||
//Ping from World Server
|
||||
else if (subpacket.header.type == 0x07)
|
||||
{
|
||||
SubPacket init = Login0x7ResponsePacket.BuildPacket(0x50);
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue