mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-22 12:47:46 +00:00
Some more work on the world server.
This commit is contained in:
parent
c67f74130f
commit
e24a6f99cb
7 changed files with 193 additions and 7 deletions
|
@ -18,15 +18,15 @@ namespace FFXIVClassic_World_Server
|
|||
|
||||
public static bool Load()
|
||||
{
|
||||
Program.Log.Info("Loading config.ini");
|
||||
Program.Log.Info("Loading world_config.ini");
|
||||
|
||||
if (!File.Exists("./config.ini"))
|
||||
if (!File.Exists("./world_config.ini"))
|
||||
{
|
||||
Program.Log.Error("FILE NOT FOUND!");
|
||||
return false;
|
||||
}
|
||||
|
||||
INIFile configIni = new INIFile("./config.ini");
|
||||
INIFile configIni = new INIFile("./world_config.ini");
|
||||
|
||||
ConfigConstants.OPTIONS_BINDIP = configIni.GetValue("General", "server_ip", "127.0.0.1");
|
||||
ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "54994");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -9,8 +10,31 @@ namespace FFXIVClassic_World_Server.DataObjects
|
|||
{
|
||||
class ZoneServer
|
||||
{
|
||||
public string zoneServerIp;
|
||||
public int zoneServerPort;
|
||||
public readonly string zoneServerIp;
|
||||
public readonly int zoneServerPort;
|
||||
public bool isConnected = false;
|
||||
public Socket zoneServerConnection;
|
||||
|
||||
public ZoneServer(string ip, int port)
|
||||
{
|
||||
zoneServerIp = ip;
|
||||
zoneServerPort = port;
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
Program.Log.Info("Connecting to zone server @ {0}:{1}", zoneServerIp, zoneServerPort);
|
||||
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(zoneServerIp), zoneServerPort);
|
||||
zoneServerConnection = new Socket(AddressFamily.InterNetwork,
|
||||
SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
try
|
||||
{
|
||||
zoneServerConnection.Connect(remoteEP);
|
||||
isConnected = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{ Program.Log.Error("Failed to connect"); return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Server.cs" />
|
||||
<Compile Include="WorldMaster.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace FFXIVClassic_World_Server
|
|||
|
||||
private Socket mServerSocket;
|
||||
|
||||
WorldManager worldManager;
|
||||
|
||||
private List<ClientConnection> mConnectionList = new List<ClientConnection>();
|
||||
private Dictionary<uint, Session> mSessionList = new Dictionary<uint, Session>();
|
||||
|
||||
|
@ -33,6 +35,9 @@ namespace FFXIVClassic_World_Server
|
|||
|
||||
public bool StartServer()
|
||||
{
|
||||
worldManager = new WorldManager(this);
|
||||
worldManager.LoadZoneServerList();
|
||||
worldManager.ConnectToZoneServers();
|
||||
|
||||
IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), int.Parse(ConfigConstants.OPTIONS_PORT));
|
||||
|
||||
|
@ -63,7 +68,7 @@ namespace FFXIVClassic_World_Server
|
|||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Program.Log.Info("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port);
|
||||
Program.Log.Info("World Server accepting connections @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
return true;
|
||||
|
|
144
FFXIVClassic Proxy Server/WorldMaster.cs
Normal file
144
FFXIVClassic Proxy Server/WorldMaster.cs
Normal file
|
@ -0,0 +1,144 @@
|
|||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_World_Server.DataObjects;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_World_Server
|
||||
{
|
||||
class WorldManager
|
||||
{
|
||||
private Server mServer;
|
||||
private Dictionary<string, ZoneServer> mZoneServerList;
|
||||
|
||||
public WorldManager(Server server)
|
||||
{
|
||||
mServer = server;
|
||||
}
|
||||
|
||||
public void LoadZoneServerList()
|
||||
{
|
||||
mZoneServerList = new Dictionary<string, ZoneServer>();
|
||||
|
||||
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
|
||||
serverIp,
|
||||
serverPort
|
||||
FROM server_zones
|
||||
WHERE serverIp IS NOT NULL";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
string ip = reader.GetString(0);
|
||||
int port = reader.GetInt32(1);
|
||||
string address = ip + ":" + port;
|
||||
|
||||
if (!mZoneServerList.ContainsKey(address))
|
||||
{
|
||||
ZoneServer zone = new ZoneServer(ip, port);
|
||||
mZoneServerList.Add(address, zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ConnectToZoneServers()
|
||||
{
|
||||
Program.Log.Info("--------------------------");
|
||||
Program.Log.Info("Connecting to zone servers");
|
||||
Program.Log.Info("--------------------------");
|
||||
|
||||
foreach (ZoneServer zs in mZoneServerList.Values)
|
||||
{
|
||||
zs.Connect();
|
||||
}
|
||||
}
|
||||
|
||||
//Moves the actor to the new zone if exists. No packets are sent nor position changed.
|
||||
public void DoSeamlessZoneServerChange(Session session, uint destinationZoneId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Moves actor to new zone, and sends packets to spawn at the given zone entrance
|
||||
public void DoZoneServerChange(Session session, uint zoneEntrance)
|
||||
{
|
||||
/*
|
||||
->Tell old server to save session info and remove
|
||||
->Update the position to zoneEntrance
|
||||
->Update routing
|
||||
->Tell new server to load session info and add
|
||||
*/
|
||||
}
|
||||
|
||||
//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)
|
||||
{
|
||||
/*
|
||||
->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
|
||||
public void DoLogin(Session session)
|
||||
{
|
||||
/*
|
||||
->Update routing
|
||||
->Tell new server to load session info and add
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ZoneEntrance
|
||||
{
|
||||
public uint zoneId;
|
||||
public string privateAreaName;
|
||||
public byte spawnType;
|
||||
public float spawnX;
|
||||
public float spawnY;
|
||||
public float spawnZ;
|
||||
public float spawnRotation;
|
||||
|
||||
public ZoneEntrance(uint zoneId, string privateAreaName, byte spawnType, float x, float y, float z, float rot)
|
||||
{
|
||||
this.zoneId = zoneId;
|
||||
this.privateAreaName = privateAreaName;
|
||||
this.spawnType = spawnType;
|
||||
this.spawnX = x;
|
||||
this.spawnY = y;
|
||||
this.spawnZ = z;
|
||||
this.spawnRotation = rot;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
<package id="NLog" version="4.3.5" targetFramework="net452" />
|
||||
<package id="NLog.Config" version="4.3.5" targetFramework="net452" />
|
||||
<package id="NLog.Schema" version="4.3.4" targetFramework="net452" />
|
||||
<package id="RabbitMQ.Client" version="4.0.0" targetFramework="net452" />
|
||||
</packages>
|
11
data/world_config.ini
Normal file
11
data/world_config.ini
Normal file
|
@ -0,0 +1,11 @@
|
|||
[General]
|
||||
server_ip=127.0.0.1
|
||||
showtimestamp = true
|
||||
|
||||
[Database]
|
||||
worldid=1
|
||||
host=127.0.0.1
|
||||
port=3306
|
||||
database=ffxiv_server
|
||||
username=root
|
||||
password=
|
Loading…
Add table
Reference in a new issue