If a player tries to zone to a offline server they will see a standard error message. Also a reconnection attempt will be made on a disconnected server.

This commit is contained in:
Filip Maj 2016-12-03 14:00:24 -05:00
parent 260878df38
commit 4ce4647a75
9 changed files with 112 additions and 24 deletions

View file

@ -35,7 +35,7 @@ namespace FFXIVClassic_World_Server.DataObjects
ownedZoneIds.Add(id);
}
public void Connect()
public bool Connect()
{
Program.Log.Info("Connecting to zone server @ {0}:{1}", zoneServerIp, zoneServerPort);
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(zoneServerIp), zoneServerPort);
@ -60,7 +60,9 @@ namespace FFXIVClassic_World_Server.DataObjects
}
}
catch (Exception e)
{ Program.Log.Error("Failed to connect"); return; }
{ Program.Log.Error("Failed to connect"); return false; }
return true;
}
public void SendPacket(SubPacket subpacket)

View file

@ -77,6 +77,7 @@
<Compile Include="Packets\WorldPackets\Receive\SessionBeginConfirmPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\WorldRequestZoneChangePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\SessionEndConfirmPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\ErrorPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\SessionBeginPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\SessionEndPacket.cs" />
<Compile Include="Program.cs" />

View file

@ -0,0 +1,37 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send
{
class ErrorPacket
{
public const ushort OPCODE = 0x100A;
public const uint PACKET_SIZE = 0x24;
public static SubPacket BuildPacket(Session session, uint errorCode)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Write((UInt32)errorCode);
}
catch (Exception)
{ }
}
}
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
}
}
}

View file

@ -1,5 +1,6 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.Packets.WorldPackets.Send;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
@ -167,7 +168,13 @@ namespace FFXIVClassic_World_Server
//Moves actor to new zone, and sends packets to spawn at the given coords.
public void DoZoneServerChange(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
{
session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation);
ZoneServer zs = GetZoneServer(destinationZoneId);
if (zs.isConnected)
session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation);
else if (zs.Connect())
session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation);
else
session.routing1.SendPacket(ErrorPacket.BuildPacket(session, 1));
}
//Login Zone In