mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-02 19:42:05 -04:00
Began working on server zone changes.
This commit is contained in:
parent
5370f13b2b
commit
58fda93b45
@ -8,6 +8,7 @@ using System.IO;
|
|||||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||||
using FFXIVClassic_Map_Server.packets.send;
|
using FFXIVClassic_Map_Server.packets.send;
|
||||||
using FFXIVClassic_Map_Server.lua;
|
using FFXIVClassic_Map_Server.lua;
|
||||||
|
using FFXIVClassic_Map_Server.Actors;
|
||||||
|
|
||||||
namespace FFXIVClassic_Map_Server
|
namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
@ -74,7 +75,9 @@ namespace FFXIVClassic_Map_Server
|
|||||||
if (cmd.Any())
|
if (cmd.Any())
|
||||||
{
|
{
|
||||||
// if client isnt null, take player to be the player actor
|
// if client isnt null, take player to be the player actor
|
||||||
var player = session.GetActor();
|
Player player = null;
|
||||||
|
if (session != null)
|
||||||
|
player = session.GetActor();
|
||||||
|
|
||||||
if (cmd.Equals("help"))
|
if (cmd.Equals("help"))
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,18 @@ namespace FFXIVClassic_Map_Server
|
|||||||
//Normal Game Opcode
|
//Normal Game Opcode
|
||||||
switch (subpacket.gameMessage.opcode)
|
switch (subpacket.gameMessage.opcode)
|
||||||
{
|
{
|
||||||
|
//World Server - End Session
|
||||||
|
case 0x1000:
|
||||||
|
session.GetActor().CleanupAndSave();
|
||||||
|
break;
|
||||||
|
//World Server - End Session and Zone
|
||||||
|
case 0x1001:
|
||||||
|
|
||||||
|
session.GetActor().CleanupAndSave();
|
||||||
|
break;
|
||||||
|
//World Server - Begin Session
|
||||||
|
case 0x1002:
|
||||||
|
break;
|
||||||
//Ping
|
//Ping
|
||||||
case 0x0001:
|
case 0x0001:
|
||||||
//subpacket.DebugPrintSubPacket();
|
//subpacket.DebugPrintSubPacket();
|
||||||
@ -86,7 +98,7 @@ namespace FFXIVClassic_Map_Server
|
|||||||
//Update Position
|
//Update Position
|
||||||
case 0x00CA:
|
case 0x00CA:
|
||||||
//Update Position
|
//Update Position
|
||||||
//subpacket.DebugPrintSubPacket();
|
subpacket.DebugPrintSubPacket();
|
||||||
UpdatePlayerPositionPacket posUpdate = new UpdatePlayerPositionPacket(subpacket.data);
|
UpdatePlayerPositionPacket posUpdate = new UpdatePlayerPositionPacket(subpacket.data);
|
||||||
session.UpdatePlayerActorPosition(posUpdate.x, posUpdate.y, posUpdate.z, posUpdate.rot, posUpdate.moveState);
|
session.UpdatePlayerActorPosition(posUpdate.x, posUpdate.y, posUpdate.z, posUpdate.rot, posUpdate.moveState);
|
||||||
session.GetActor().SendInstanceUpdate();
|
session.GetActor().SendInstanceUpdate();
|
||||||
|
@ -6,6 +6,7 @@ using System.Net.Sockets;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FFXIVClassic.Common;
|
using FFXIVClassic.Common;
|
||||||
|
using FFXIVClassic_World_Server.Packets.WorldPackets.Send;
|
||||||
|
|
||||||
namespace FFXIVClassic_World_Server.DataObjects
|
namespace FFXIVClassic_World_Server.DataObjects
|
||||||
{
|
{
|
||||||
@ -134,6 +135,15 @@ namespace FFXIVClassic_World_Server.DataObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendGoodbye(Session session)
|
||||||
|
{
|
||||||
|
SendPacket(SessionEndPacket.BuildPacket(session));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendSessionEnd(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
|
||||||
|
{
|
||||||
|
SendPacket(SessionEndAndZonePacket.BuildPacket(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,9 @@
|
|||||||
<Compile Include="Packets\Send\_0x2Packet.cs" />
|
<Compile Include="Packets\Send\_0x2Packet.cs" />
|
||||||
<Compile Include="Packets\Send\_0x7Packet.cs" />
|
<Compile Include="Packets\Send\_0x7Packet.cs" />
|
||||||
<Compile Include="Packets\Send\_0x8PingPacket.cs" />
|
<Compile Include="Packets\Send\_0x8PingPacket.cs" />
|
||||||
|
<Compile Include="Packets\WorldPackets\Send\SessionBeginPacket.cs" />
|
||||||
|
<Compile Include="Packets\WorldPackets\Send\SessionEndZonePacket.cs" />
|
||||||
|
<Compile Include="Packets\WorldPackets\Send\SessionEndPacket.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Server.cs" />
|
<Compile Include="Server.cs" />
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
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 SessionBeginPacket
|
||||||
|
{
|
||||||
|
public const ushort OPCODE = 0x1000;
|
||||||
|
public const uint PACKET_SIZE = 0x24;
|
||||||
|
|
||||||
|
public static SubPacket BuildPacket(Session session)
|
||||||
|
{
|
||||||
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
|
|
||||||
|
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
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 SessionEndPacket
|
||||||
|
{
|
||||||
|
public const ushort OPCODE = 0x1001;
|
||||||
|
public const uint PACKET_SIZE = 0x24;
|
||||||
|
|
||||||
|
public static SubPacket BuildPacket(Session session)
|
||||||
|
{
|
||||||
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
|
|
||||||
|
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
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 SessionEndAndZonePacket
|
||||||
|
{
|
||||||
|
public const ushort OPCODE = 0x1002;
|
||||||
|
public const uint PACKET_SIZE = 0x48;
|
||||||
|
|
||||||
|
public static SubPacket BuildPacket(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
|
||||||
|
{
|
||||||
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
|
|
||||||
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
|
{
|
||||||
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
binWriter.Write((UInt32)destinationZoneId);
|
||||||
|
binWriter.Write((UInt32)destinationZoneId);
|
||||||
|
binWriter.Write((UInt32)spawnType);
|
||||||
|
binWriter.Write((Single)spawnX);
|
||||||
|
binWriter.Write((Single)spawnY);
|
||||||
|
binWriter.Write((Single)spawnZ);
|
||||||
|
binWriter.Write((Single)spawnRotation);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,7 @@ namespace FFXIVClassic_World_Server
|
|||||||
mPacketProcessor = new PacketProcessor(this);
|
mPacketProcessor = new PacketProcessor(this);
|
||||||
mWorldManager = new WorldManager(this);
|
mWorldManager = new WorldManager(this);
|
||||||
mWorldManager.LoadZoneServerList();
|
mWorldManager.LoadZoneServerList();
|
||||||
|
mWorldManager.LoadZoneEntranceList();
|
||||||
mWorldManager.ConnectToZoneServers();
|
mWorldManager.ConnectToZoneServers();
|
||||||
|
|
||||||
IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), int.Parse(ConfigConstants.OPTIONS_PORT));
|
IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), int.Parse(ConfigConstants.OPTIONS_PORT));
|
||||||
@ -136,7 +137,6 @@ namespace FFXIVClassic_World_Server
|
|||||||
|
|
||||||
public void OnReceiveSubPacketFromZone(ZoneServer zoneServer, SubPacket subpacket)
|
public void OnReceiveSubPacketFromZone(ZoneServer zoneServer, SubPacket subpacket)
|
||||||
{
|
{
|
||||||
//subpacket.DebugPrintSubPacket();
|
|
||||||
uint sessionId = subpacket.header.targetId;
|
uint sessionId = subpacket.header.targetId;
|
||||||
|
|
||||||
if (mZoneSessionList.ContainsKey(sessionId))
|
if (mZoneSessionList.ContainsKey(sessionId))
|
||||||
|
@ -15,6 +15,7 @@ namespace FFXIVClassic_World_Server
|
|||||||
{
|
{
|
||||||
private Server mServer;
|
private Server mServer;
|
||||||
public Dictionary<string, ZoneServer> mZoneServerList;
|
public Dictionary<string, ZoneServer> mZoneServerList;
|
||||||
|
private Dictionary<uint, ZoneEntrance> zoneEntranceList;
|
||||||
|
|
||||||
public WorldManager(Server server)
|
public WorldManager(Server server)
|
||||||
{
|
{
|
||||||
@ -66,6 +67,57 @@ namespace FFXIVClassic_World_Server
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadZoneEntranceList()
|
||||||
|
{
|
||||||
|
zoneEntranceList = new Dictionary<uint, ZoneEntrance>();
|
||||||
|
int count = 0;
|
||||||
|
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
string query = @"
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
zoneId,
|
||||||
|
spawnType,
|
||||||
|
spawnX,
|
||||||
|
spawnY,
|
||||||
|
spawnZ,
|
||||||
|
spawnRotation,
|
||||||
|
privateAreaName
|
||||||
|
FROM server_zones_spawnlocations";
|
||||||
|
|
||||||
|
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||||
|
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
uint id = reader.GetUInt32(0);
|
||||||
|
string privArea = null;
|
||||||
|
|
||||||
|
if (!reader.IsDBNull(7))
|
||||||
|
privArea = reader.GetString(7);
|
||||||
|
|
||||||
|
ZoneEntrance entance = new ZoneEntrance(reader.GetUInt32(1), privArea, reader.GetByte(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetFloat(6));
|
||||||
|
zoneEntranceList[id] = entance;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (MySqlException e)
|
||||||
|
{ Console.WriteLine(e); }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Program.Log.Info(String.Format("Loaded {0} zone spawn locations.", count));
|
||||||
|
}
|
||||||
|
|
||||||
public void ConnectToZoneServers()
|
public void ConnectToZoneServers()
|
||||||
{
|
{
|
||||||
Program.Log.Info("--------------------------");
|
Program.Log.Info("--------------------------");
|
||||||
@ -87,23 +139,20 @@ namespace FFXIVClassic_World_Server
|
|||||||
//Moves actor to new zone, and sends packets to spawn at the given zone entrance
|
//Moves actor to new zone, and sends packets to spawn at the given zone entrance
|
||||||
public void DoZoneServerChange(Session session, uint zoneEntrance)
|
public void DoZoneServerChange(Session session, uint zoneEntrance)
|
||||||
{
|
{
|
||||||
/*
|
if (!zoneEntranceList.ContainsKey(zoneEntrance))
|
||||||
->Tell old server to save session info and remove session. Start zone packets.
|
{
|
||||||
->Update the position to zoneEntrance
|
Program.Log.Error("Given zone entrance was not found: " + zoneEntrance);
|
||||||
->Update routing
|
return;
|
||||||
->Tell new server to load session info and add session. Send end zone packets.
|
}
|
||||||
*/
|
|
||||||
|
ZoneEntrance ze = zoneEntranceList[zoneEntrance];
|
||||||
|
DoZoneServerChange(session, ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Moves actor to new zone, and sends packets to spawn at the given coords.
|
//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)
|
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);
|
||||||
->Tell old server to save session info and remove
|
|
||||||
->Update the position to params
|
|
||||||
->Update routing
|
|
||||||
->Tell new server to load session info and add
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Login Zone In
|
//Login Zone In
|
||||||
|
Loading…
Reference in New Issue
Block a user