Connection working again. Fixed type 7 ping packet.

This commit is contained in:
Filip Maj 2015-10-15 22:17:21 -04:00
parent 7c22cece93
commit 2e683892c8
5 changed files with 20 additions and 18 deletions

View File

@ -93,7 +93,6 @@
<Compile Include="packets\send\actor\inventory\EquipmentSetupPacket.cs" /> <Compile Include="packets\send\actor\inventory\EquipmentSetupPacket.cs" />
<Compile Include="packets\send\actor\RemoveActorPacket.cs" /> <Compile Include="packets\send\actor\RemoveActorPacket.cs" />
<Compile Include="packets\send\actor\SetActorNamePacket.cs" /> <Compile Include="packets\send\actor\SetActorNamePacket.cs" />
<Compile Include="packets\send\actor\SetActorPropetyPacket.cs" />
<Compile Include="packets\send\actor\SetActorSpeedPacket.cs" /> <Compile Include="packets\send\actor\SetActorSpeedPacket.cs" />
<Compile Include="packets\send\actor\SetActorStatePacket.cs" /> <Compile Include="packets\send\actor\SetActorStatePacket.cs" />
<Compile Include="packets\send\actor\SetActorTargetAnimatedPacket.cs" /> <Compile Include="packets\send\actor\SetActorTargetAnimatedPacket.cs" />

View File

@ -43,14 +43,11 @@ namespace FFXIVClassic_Lobby_Server
if (packet.header.isEncrypted == 0x01) if (packet.header.isEncrypted == 0x01)
BasePacket.decryptPacket(client.blowfish, ref packet); BasePacket.decryptPacket(client.blowfish, ref packet);
packet.debugPrintPacket();
List<SubPacket> subPackets = packet.getSubpackets(); List<SubPacket> subPackets = packet.getSubpackets();
foreach (SubPacket subpacket in subPackets) foreach (SubPacket subpacket in subPackets)
{ {
if (subpacket.header.type == 0x01) if (subpacket.header.type == 0x01)
{ {
BasePacket init = InitPacket.buildPacket(0, Utils.UnixTimeStampUTC());
BasePacket reply2 = new BasePacket("./packets/login/login2.bin"); BasePacket reply2 = new BasePacket("./packets/login/login2.bin");
//Already Handshaked //Already Handshaked
@ -65,7 +62,7 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
client.queuePacket(init);
client.queuePacket(reply2); client.queuePacket(reply2);
break; break;
} }
@ -121,13 +118,13 @@ namespace FFXIVClassic_Lobby_Server
//Get Character info //Get Character info
//Create player actor //Create player actor
client.queuePacket(init);
client.queuePacket(reply2); client.queuePacket(reply2);
break; break;
} }
else if (subpacket.header.type == 0x08) else if (subpacket.header.type == 0x07)
{ {
BasePacket init = InitPacket.buildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC());
client.queuePacket(init);
} }
else if (subpacket.header.type == 0x03) else if (subpacket.header.type == 0x03)
{ {

View File

@ -62,6 +62,8 @@ namespace FFXIVClassic_Lobby_Server
Console.WriteLine("{0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port); Console.WriteLine("{0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port);
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
mProcessor = new PacketProcessor(mConnectedPlayerList, mConnectionList);
//mGameThread = new Thread(new ThreadStart(mProcessor.update)); //mGameThread = new Thread(new ThreadStart(mProcessor.update));
//mGameThread.Start(); //mGameThread.Start();
return true; return true;
@ -69,6 +71,7 @@ namespace FFXIVClassic_Lobby_Server
private void acceptCallback(IAsyncResult result) private void acceptCallback(IAsyncResult result)
{ {
Log.conn("TEST.");
ClientConnection conn = null; ClientConnection conn = null;
Socket socket = (System.Net.Sockets.Socket)result.AsyncState; Socket socket = (System.Net.Sockets.Socket)result.AsyncState;
@ -133,7 +136,7 @@ namespace FFXIVClassic_Lobby_Server
//Build packets until can no longer or out of data //Build packets until can no longer or out of data
while(true) while(true)
{ {
BasePacket basePacket = buildPacket(ref offset, conn.buffer); BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead);
//If can't build packet, break, else process another //If can't build packet, break, else process another
if (basePacket == null) if (basePacket == null)
break; break;
@ -142,13 +145,13 @@ namespace FFXIVClassic_Lobby_Server
} }
//Not all bytes consumed, transfer leftover to beginning //Not all bytes consumed, transfer leftover to beginning
if (offset <= bytesRead) if (offset < bytesRead)
Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset); Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset);
//Build any queued subpackets into basepackets and send //Build any queued subpackets into basepackets and send
conn.flushQueuedSendPackets(); conn.flushQueuedSendPackets();
if (offset <= bytesRead) if (offset < bytesRead)
//Need offset since not all bytes consumed //Need offset since not all bytes consumed
conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn); conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn);
else else
@ -185,18 +188,21 @@ namespace FFXIVClassic_Lobby_Server
/// <param name="offset">Current offset in buffer.</param> /// <param name="offset">Current offset in buffer.</param>
/// <param name="buffer">Incoming buffer.</param> /// <param name="buffer">Incoming buffer.</param>
/// <returns>Returns either a BasePacket or null if not enough data.</returns> /// <returns>Returns either a BasePacket or null if not enough data.</returns>
public BasePacket buildPacket(ref int offset, byte[] buffer) public BasePacket buildPacket(ref int offset, byte[] buffer, int bytesRead)
{ {
BasePacket newPacket = null; BasePacket newPacket = null;
//Too small to even get length //Too small to even get length
if (buffer.Length <= offset + 1) if (bytesRead <= offset)
return null; return null;
ushort packetSize = BitConverter.ToUInt16(buffer, offset); ushort packetSize = BitConverter.ToUInt16(buffer, offset);
//Too small to whole packet //Too small to whole packet
if (buffer.Length <= offset + packetSize) if (bytesRead < offset + packetSize)
return null;
if (buffer.Length < offset + packetSize)
return null; return null;
newPacket = new BasePacket(buffer, ref offset); newPacket = new BasePacket(buffer, ref offset);

View File

@ -127,7 +127,7 @@ namespace FFXIVClassic_Lobby_Server.packets
if (header.type == 0x3) if (header.type == 0x3)
Array.Copy(getGameMessageBytes(), 0, outBytes, SUBPACKET_SIZE, GAMEMESSAGE_SIZE); Array.Copy(getGameMessageBytes(), 0, outBytes, SUBPACKET_SIZE, GAMEMESSAGE_SIZE);
Array.Copy(data, 0, outBytes, SUBPACKET_SIZE + header.type == 0x3 ? GAMEMESSAGE_SIZE : 0, data.Length); Array.Copy(data, 0, outBytes, SUBPACKET_SIZE + (header.type == 0x3 ? GAMEMESSAGE_SIZE : 0), data.Length);
return outBytes; return outBytes;
} }

View File

@ -10,7 +10,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login
{ {
class InitPacket class InitPacket
{ {
public static BasePacket buildPacket(uint unknown, uint time) public static BasePacket buildPacket(uint actorID, uint time)
{ {
byte[] data = new byte[0x18]; byte[] data = new byte[0x18];
@ -26,7 +26,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login
binWriter.Write((uint)0); binWriter.Write((uint)0);
binWriter.Write((uint)0xFFFFFD7F); binWriter.Write((uint)0xFFFFFD7F);
binWriter.Write((uint)unknown); binWriter.Write((uint)actorID);
binWriter.Write((uint)time); binWriter.Write((uint)time);
} }
catch (Exception) catch (Exception)