mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 08:27:46 +00:00
some cleanup, move lobby to Sapphire::Lobby
This commit is contained in:
parent
eb5431a80e
commit
5dc4b94f10
42 changed files with 126 additions and 282 deletions
|
@ -1,89 +0,0 @@
|
||||||
#ifndef _FORWARDS_H
|
|
||||||
#define _FORWARDS_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Sapphire
|
|
||||||
{
|
|
||||||
class Cell;
|
|
||||||
class Zone;
|
|
||||||
class Item;
|
|
||||||
class ItemContainer;
|
|
||||||
class Inventory;
|
|
||||||
class Session;
|
|
||||||
class ZonePosition;
|
|
||||||
using ZonePtr = std::shared_ptr< Zone >;
|
|
||||||
using ItemPtr = std::shared_ptr< Item >;
|
|
||||||
using ItemContainerPtr = std::shared_ptr< ItemContainer >;
|
|
||||||
using InventoryPtr = std::shared_ptr< Inventory >;
|
|
||||||
using SessionPtr = std::shared_ptr< Session >;
|
|
||||||
using ZonePositionPtr = std::shared_ptr< ZonePosition >;
|
|
||||||
|
|
||||||
namespace StatusEffect
|
|
||||||
{
|
|
||||||
class StatusEffect;
|
|
||||||
class StatusEffectContainer;
|
|
||||||
using StatusEffectPtr = std::shared_ptr< StatusEffect >;
|
|
||||||
using StatusEffectContainerPtr = std::shared_ptr< StatusEffectContainer >;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Entity
|
|
||||||
{
|
|
||||||
class Chara;
|
|
||||||
class Player;
|
|
||||||
class BattleNpc;
|
|
||||||
using ActorPtr = std::shared_ptr< Chara >;
|
|
||||||
using PlayerPtr = std::shared_ptr< Player >;
|
|
||||||
using BattleNpcPtr = std::shared_ptr< BattleNpc >;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Event
|
|
||||||
{
|
|
||||||
class EventHandler;
|
|
||||||
using EventPtr = std::shared_ptr< EventHandler >;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Action
|
|
||||||
{
|
|
||||||
class Action;
|
|
||||||
class ActionTeleport;
|
|
||||||
class EventAction;
|
|
||||||
using ActionPtr = std::shared_ptr< Action >;
|
|
||||||
using ActionTeleportPtr = std::shared_ptr< ActionTeleport >;
|
|
||||||
using EventActionPtr = std::shared_ptr< EventAction >;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Network
|
|
||||||
{
|
|
||||||
class Hive;
|
|
||||||
class Acceptor;
|
|
||||||
class Connection;
|
|
||||||
class WorldConnection;
|
|
||||||
class SessionConnection;
|
|
||||||
class ZoneConnection;
|
|
||||||
using HivePtr = std::shared_ptr< Hive >;
|
|
||||||
using AcceptorPtr = std::shared_ptr< Acceptor >;
|
|
||||||
using ConnectionPtr = std::shared_ptr< Connection >;
|
|
||||||
using WorldConnectionPtr = std::shared_ptr< WorldConnection >;
|
|
||||||
using ZoneConnectionPtr = std::shared_ptr< ZoneConnection >;
|
|
||||||
using SessionConnectionPtr = std::shared_ptr< SessionConnection >;
|
|
||||||
|
|
||||||
namespace Packets
|
|
||||||
{
|
|
||||||
class GamePacket;
|
|
||||||
using GamePacketPtr = std::shared_ptr< GamePacket >;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Scripting
|
|
||||||
{
|
|
||||||
using EventReturnCallback = std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t,
|
|
||||||
uint16_t ) >;
|
|
||||||
}
|
|
||||||
|
|
||||||
using ActionCallback = std::function< void( Entity::Player&, uint32_t, uint64_t ) >;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,14 +0,0 @@
|
||||||
#include "LoginSession.h"
|
|
||||||
|
|
||||||
namespace Sapphire {
|
|
||||||
LoginSession::LoginSession( void )
|
|
||||||
{
|
|
||||||
//setSocket(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
LoginSession::~LoginSession( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef _CLoginSession_H_
|
|
||||||
#define _CLoginSession_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
namespace Sapphire
|
|
||||||
{
|
|
||||||
|
|
||||||
class LoginSession
|
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t m_ip;
|
|
||||||
uint32_t m_accountId;
|
|
||||||
uint8_t m_sessionId[56];
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::string newCharName;
|
|
||||||
|
|
||||||
LoginSession( void );
|
|
||||||
|
|
||||||
~LoginSession( void );
|
|
||||||
|
|
||||||
uint32_t getIp()
|
|
||||||
{
|
|
||||||
return m_ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSessionId( uint8_t* sessionId )
|
|
||||||
{
|
|
||||||
memcpy( m_sessionId, sessionId, 56 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIp( uint32_t ip )
|
|
||||||
{
|
|
||||||
m_ip = ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getAccountId()
|
|
||||||
{
|
|
||||||
return m_accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAccountId( uint32_t id )
|
|
||||||
{
|
|
||||||
m_accountId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
extern Sapphire::Data::ExdDataGenerated g_exdDataGen;
|
extern Sapphire::Data::ExdDataGenerated g_exdDataGen;
|
||||||
|
|
||||||
namespace Sapphire {
|
namespace Sapphire::API {
|
||||||
|
|
||||||
using namespace Common;
|
using namespace Common;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace Sapphire
|
namespace Sapphire::API
|
||||||
{
|
{
|
||||||
|
|
||||||
class PlayerMinimal
|
class PlayerMinimal
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
|
|
||||||
#include <Database/DatabaseDef.h>
|
#include <Database/DatabaseDef.h>
|
||||||
|
|
||||||
bool Sapphire::Network::SapphireAPI::login( const std::string& username, const std::string& pass, std::string& sId )
|
using namespace Sapphire::API;
|
||||||
|
|
||||||
|
bool SapphireAPI::login( const std::string& username, const std::string& pass, std::string& sId )
|
||||||
{
|
{
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT account_id FROM accounts WHERE account_name = '" + username + "' AND account_pass = '" + pass + "';";
|
"SELECT account_id FROM accounts WHERE account_name = '" + username + "' AND account_pass = '" + pass + "';";
|
||||||
|
@ -53,7 +55,7 @@ bool Sapphire::Network::SapphireAPI::login( const std::string& username, const s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Sapphire::Network::SapphireAPI::insertSession( const uint32_t accountId, std::string& sId )
|
bool SapphireAPI::insertSession( const uint32_t accountId, std::string& sId )
|
||||||
{
|
{
|
||||||
// create session for the new sessionid and store to sessionlist
|
// create session for the new sessionid and store to sessionlist
|
||||||
auto pSession = std::make_shared< Session >();
|
auto pSession = std::make_shared< Session >();
|
||||||
|
@ -66,7 +68,7 @@ bool Sapphire::Network::SapphireAPI::insertSession( const uint32_t accountId, st
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Network::SapphireAPI::createAccount( const std::string& username, const std::string& pass, std::string& sId )
|
bool SapphireAPI::createAccount( const std::string& username, const std::string& pass, std::string& sId )
|
||||||
{
|
{
|
||||||
// get account from login name
|
// get account from login name
|
||||||
auto pQR = g_charaDb.query( "SELECT account_id FROM accounts WHERE account_name = '" + username + "';" );
|
auto pQR = g_charaDb.query( "SELECT account_id FROM accounts WHERE account_name = '" + username + "';" );
|
||||||
|
@ -96,11 +98,11 @@ bool Sapphire::Network::SapphireAPI::createAccount( const std::string& username,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sapphire::Network::SapphireAPI::createCharacter( const uint32_t accountId, const std::string& name,
|
int SapphireAPI::createCharacter( const uint32_t accountId, const std::string& name,
|
||||||
const std::string& infoJson,
|
const std::string& infoJson,
|
||||||
const uint32_t gmRank )
|
const uint32_t gmRank )
|
||||||
{
|
{
|
||||||
Sapphire::PlayerMinimal newPlayer;
|
API::PlayerMinimal newPlayer;
|
||||||
|
|
||||||
newPlayer.setAccountId( accountId );
|
newPlayer.setAccountId( accountId );
|
||||||
newPlayer.setId( getNextCharId() );
|
newPlayer.setId( getNextCharId() );
|
||||||
|
@ -169,7 +171,7 @@ int Sapphire::Network::SapphireAPI::createCharacter( const uint32_t accountId, c
|
||||||
return newPlayer.getAccountId();
|
return newPlayer.getAccountId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Network::SapphireAPI::deleteCharacter( std::string name, const uint32_t accountId )
|
void SapphireAPI::deleteCharacter( std::string name, const uint32_t accountId )
|
||||||
{
|
{
|
||||||
PlayerMinimal deletePlayer;
|
PlayerMinimal deletePlayer;
|
||||||
auto charList = getCharList( accountId );
|
auto charList = getCharList( accountId );
|
||||||
|
@ -199,17 +201,17 @@ void Sapphire::Network::SapphireAPI::deleteCharacter( std::string name, const ui
|
||||||
g_charaDb.execute( "DELETE FROM charaquest WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
|
g_charaDb.execute( "DELETE FROM charaquest WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< Sapphire::PlayerMinimal > Sapphire::Network::SapphireAPI::getCharList( uint32_t accountId )
|
std::vector< PlayerMinimal > SapphireAPI::getCharList( uint32_t accountId )
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector< Sapphire::PlayerMinimal > charList;
|
std::vector< API::PlayerMinimal > charList;
|
||||||
|
|
||||||
auto pQR = g_charaDb.query(
|
auto pQR = g_charaDb.query(
|
||||||
"SELECT CharacterId, ContentId FROM charainfo WHERE AccountId = " + std::to_string( accountId ) + ";" );
|
"SELECT CharacterId, ContentId FROM charainfo WHERE AccountId = " + std::to_string( accountId ) + ";" );
|
||||||
|
|
||||||
while( pQR->next() )
|
while( pQR->next() )
|
||||||
{
|
{
|
||||||
Sapphire::PlayerMinimal player;
|
API::PlayerMinimal player;
|
||||||
|
|
||||||
uint32_t charId = pQR->getUInt( 1 );
|
uint32_t charId = pQR->getUInt( 1 );
|
||||||
|
|
||||||
|
@ -220,7 +222,7 @@ std::vector< Sapphire::PlayerMinimal > Sapphire::Network::SapphireAPI::getCharLi
|
||||||
return charList;
|
return charList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Network::SapphireAPI::checkNameTaken( std::string name )
|
bool SapphireAPI::checkNameTaken( std::string name )
|
||||||
{
|
{
|
||||||
|
|
||||||
g_charaDb.escapeString( name );
|
g_charaDb.escapeString( name );
|
||||||
|
@ -234,7 +236,7 @@ bool Sapphire::Network::SapphireAPI::checkNameTaken( std::string name )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Sapphire::Network::SapphireAPI::getNextCharId()
|
uint32_t SapphireAPI::getNextCharId()
|
||||||
{
|
{
|
||||||
uint32_t charId = 0;
|
uint32_t charId = 0;
|
||||||
|
|
||||||
|
@ -250,7 +252,7 @@ uint32_t Sapphire::Network::SapphireAPI::getNextCharId()
|
||||||
return charId;
|
return charId;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Sapphire::Network::SapphireAPI::getNextContentId()
|
uint64_t SapphireAPI::getNextContentId()
|
||||||
{
|
{
|
||||||
uint64_t contentId = 0;
|
uint64_t contentId = 0;
|
||||||
|
|
||||||
|
@ -266,7 +268,7 @@ uint64_t Sapphire::Network::SapphireAPI::getNextContentId()
|
||||||
return contentId;
|
return contentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sapphire::Network::SapphireAPI::checkSession( const std::string& sId )
|
int SapphireAPI::checkSession( const std::string& sId )
|
||||||
{
|
{
|
||||||
auto it = m_sessionMap.find( sId );
|
auto it = m_sessionMap.find( sId );
|
||||||
|
|
||||||
|
@ -277,7 +279,7 @@ int Sapphire::Network::SapphireAPI::checkSession( const std::string& sId )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Sapphire::Network::SapphireAPI::removeSession( const std::string& sId )
|
bool SapphireAPI::removeSession( const std::string& sId )
|
||||||
{
|
{
|
||||||
auto it = m_sessionMap.find( sId );
|
auto it = m_sessionMap.find( sId );
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "PlayerMinimal.h"
|
#include "PlayerMinimal.h"
|
||||||
|
|
||||||
namespace Sapphire
|
namespace Sapphire::API
|
||||||
{
|
{
|
||||||
class Session;
|
class Session;
|
||||||
}
|
|
||||||
|
|
||||||
namespace Sapphire::Network
|
|
||||||
{
|
|
||||||
|
|
||||||
class SapphireAPI
|
class SapphireAPI
|
||||||
{
|
{
|
||||||
|
@ -34,7 +30,7 @@ namespace Sapphire::Network
|
||||||
|
|
||||||
bool insertSession( uint32_t accountId, std::string& sId );
|
bool insertSession( uint32_t accountId, std::string& sId );
|
||||||
|
|
||||||
std::vector< Sapphire::PlayerMinimal > getCharList( uint32_t accountId );
|
std::vector< API::PlayerMinimal > getCharList( uint32_t accountId );
|
||||||
|
|
||||||
bool checkNameTaken( std::string name );
|
bool checkNameTaken( std::string name );
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Session.h"
|
#include "Session.h"
|
||||||
|
|
||||||
namespace Sapphire {
|
using namespace Sapphire::API;
|
||||||
|
|
||||||
Session::Session()
|
Session::Session()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -35,4 +36,3 @@ void Session::setAccountId( uint32_t id )
|
||||||
{
|
{
|
||||||
m_accountId = id;
|
m_accountId = id;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace Sapphire
|
namespace Sapphire::API
|
||||||
{
|
{
|
||||||
|
|
||||||
class Session
|
class Session
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <Framework.h>
|
#include <Framework.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
|
|
||||||
#include "Forwards.h"
|
|
||||||
#include "SapphireAPI.h"
|
#include "SapphireAPI.h"
|
||||||
|
|
||||||
#include <Util/CrashHandler.h>
|
#include <Util/CrashHandler.h>
|
||||||
|
@ -38,7 +37,7 @@ Sapphire::Common::Util::CrashHandler crashHandler;
|
||||||
|
|
||||||
Sapphire::Db::DbWorkerPool< Sapphire::Db::ZoneDbConnection > g_charaDb;
|
Sapphire::Db::DbWorkerPool< Sapphire::Db::ZoneDbConnection > g_charaDb;
|
||||||
Sapphire::Data::ExdDataGenerated g_exdDataGen;
|
Sapphire::Data::ExdDataGenerated g_exdDataGen;
|
||||||
Sapphire::Network::SapphireAPI g_sapphireAPI;
|
Sapphire::API::SapphireAPI g_sapphireAPI;
|
||||||
|
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ Sapphire::Common::Config::ApiConfig m_config;
|
||||||
|
|
||||||
void reloadConfig()
|
void reloadConfig()
|
||||||
{
|
{
|
||||||
auto pConfig = std::make_shared< Sapphire::ConfigMgr >();
|
auto pConfig = std::make_shared< Sapphire::Common::ConfigMgr >();
|
||||||
|
|
||||||
Logger::info( "Loading config " + configPath );
|
Logger::info( "Loading config " + configPath );
|
||||||
|
|
||||||
|
@ -336,7 +335,7 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
|
||||||
std::string name = json["name"];
|
std::string name = json["name"];
|
||||||
std::string infoJson = json["infoJson"];
|
std::string infoJson = json["infoJson"];
|
||||||
|
|
||||||
std::string finalJson = Sapphire::Util::base64Decode( infoJson );
|
std::string finalJson = Common::Util::base64Decode( infoJson );
|
||||||
|
|
||||||
// reloadConfig();
|
// reloadConfig();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Sapphire
|
||||||
|
{
|
||||||
|
class Framework;
|
||||||
|
using FrameworkPtr = std::shared_ptr< Framework >;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Sapphire::Common
|
namespace Sapphire::Common
|
||||||
{
|
{
|
||||||
class ConfigMgr;
|
class ConfigMgr;
|
||||||
|
@ -11,7 +17,7 @@ namespace Sapphire::Common
|
||||||
using FrameworkPtr = std::shared_ptr< Framework >;
|
using FrameworkPtr = std::shared_ptr< Framework >;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Sapphire::Common::Network
|
namespace Sapphire::Network
|
||||||
{
|
{
|
||||||
class Hive;
|
class Hive;
|
||||||
class Acceptor;
|
class Acceptor;
|
||||||
|
@ -21,7 +27,7 @@ namespace Sapphire::Common::Network
|
||||||
using ConnectionPtr = std::shared_ptr< Connection >;
|
using ConnectionPtr = std::shared_ptr< Connection >;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
class GamePacket;
|
class GamePacket;
|
||||||
class FFXIVPacketBase;
|
class FFXIVPacketBase;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace Sapphire::Common
|
namespace Sapphire
|
||||||
{
|
{
|
||||||
|
|
||||||
class Framework
|
class Framework
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire;
|
||||||
|
|
||||||
Network::Acceptor::Acceptor( HivePtr hive ) :
|
Network::Acceptor::Acceptor( HivePtr hive ) :
|
||||||
m_hive( hive ),
|
m_hive( hive ),
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Sapphire::Common::Network
|
namespace Sapphire::Network
|
||||||
{
|
{
|
||||||
|
|
||||||
class Connection;
|
class Connection;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// The following enumerations are structures to require their type be included.
|
// The following enumerations are structures to require their type be included.
|
||||||
// They are also defined within the Sapphire::Common namespace to avoid collisions.
|
// They are also defined within the Sapphire::Common namespace to avoid collisions.
|
||||||
// +---------------------------------------------------------------------------
|
// +---------------------------------------------------------------------------
|
||||||
namespace Sapphire::Common::Network::ActorControl
|
namespace Sapphire::Network::ActorControl
|
||||||
{
|
{
|
||||||
|
|
||||||
enum ActorControlType : uint16_t
|
enum ActorControlType : uint16_t
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "PacketDef/Ipcs.h"
|
#include "PacketDef/Ipcs.h"
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Framework.h"
|
#include "Framework.h"
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire;
|
||||||
|
|
||||||
Network::Connection::Connection( HivePtr hive, FrameworkPtr pFw ) :
|
Network::Connection::Connection( HivePtr hive, FrameworkPtr pFw ) :
|
||||||
m_hive( hive ),
|
m_hive( hive ),
|
||||||
|
|
|
@ -12,13 +12,7 @@
|
||||||
#include "Acceptor.h"
|
#include "Acceptor.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Sapphire::Common
|
namespace Sapphire::Network
|
||||||
{
|
|
||||||
class Framework;
|
|
||||||
using FrameworkPtr = std::shared_ptr< Framework >;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Sapphire::Common::Network
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Hive;
|
class Hive;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "CommonNetwork.h"
|
#include "CommonNetwork.h"
|
||||||
#include "PacketDef/Ipcs.h"
|
#include "PacketDef/Ipcs.h"
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
|
|
||||||
// Must forward define these in order to enable the compiler to produce the
|
// Must forward define these in order to enable the compiler to produce the
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include <string.h> // memcpy
|
#include <string.h> // memcpy
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire;
|
||||||
using namespace Sapphire::Common::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
|
|
||||||
PacketParseResult Network::Packets::getHeader( const std::vector< uint8_t >& buffer,
|
PacketParseResult Network::Packets::getHeader( const std::vector< uint8_t >& buffer,
|
||||||
const uint32_t offset,
|
const uint32_t offset,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "CommonNetwork.h"
|
#include "CommonNetwork.h"
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
|
|
||||||
enum PacketParseResult
|
enum PacketParseResult
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Hive.h"
|
#include "Hive.h"
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Sapphire::Common::Network
|
namespace Sapphire::Network
|
||||||
{
|
{
|
||||||
|
|
||||||
class Hive : public std::enable_shared_from_this< Hive >
|
class Hive : public std::enable_shared_from_this< Hive >
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire;
|
||||||
|
|
||||||
Network::Packets::PacketContainer::PacketContainer( uint32_t segmentTargetOverride ) :
|
Network::Packets::PacketContainer::PacketContainer( uint32_t segmentTargetOverride ) :
|
||||||
m_segmentTargetOverride( segmentTargetOverride )
|
m_segmentTargetOverride( segmentTargetOverride )
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "GamePacket.h"
|
#include "GamePacket.h"
|
||||||
#include "Forwards.h"
|
#include "Forwards.h"
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
|
|
||||||
using FFXIVPacketBasePtr = std::shared_ptr< FFXIVPacketBase >;
|
using FFXIVPacketBasePtr = std::shared_ptr< FFXIVPacketBase >;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
#include <Network/CommonNetwork.h>
|
#include <Network/CommonNetwork.h>
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets::Server
|
namespace Sapphire::Network::Packets::Server
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
#include <Network/CommonNetwork.h>
|
#include <Network/CommonNetwork.h>
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets::Server {
|
namespace Sapphire::Network::Packets::Server {
|
||||||
|
|
||||||
struct FFXIVIpcRetainerList :
|
struct FFXIVIpcRetainerList :
|
||||||
FFXIVIpcBasePacket< LobbyRetainerList >
|
FFXIVIpcBasePacket< LobbyRetainerList >
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
#include <Network/CommonNetwork.h>
|
#include <Network/CommonNetwork.h>
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets::Client
|
namespace Sapphire::Network::Packets::Client
|
||||||
{
|
{
|
||||||
|
|
||||||
struct FFXIVIpcGmCommand1 :
|
struct FFXIVIpcGmCommand1 :
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
#include <Network/CommonNetwork.h>
|
#include <Network/CommonNetwork.h>
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets::Server
|
namespace Sapphire::Network::Packets::Server
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
|
|
||||||
inline bool Sapphire::Common::FFXIVARR_POSITION3::operator == ( const FFXIVARR_POSITION3& target ) const
|
using namespace Sapphire::Common;
|
||||||
|
|
||||||
|
inline bool FFXIVARR_POSITION3::operator == ( const FFXIVARR_POSITION3& target ) const
|
||||||
{
|
{
|
||||||
return x == target.x && y == target.y && z == target.z;
|
return x == target.x && y == target.y && z == target.z;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
namespace Sapphire {
|
namespace Sapphire::Version
|
||||||
namespace Version {
|
{
|
||||||
|
|
||||||
const std::string GIT_HASH = "@GIT_SHA1@";
|
const std::string GIT_HASH = "@GIT_SHA1@";
|
||||||
const std::string VERSION = "@VERSION@";
|
const std::string VERSION = "@VERSION@";
|
||||||
|
|
||||||
} /* Version */
|
} /* Sapphire::Version */
|
||||||
} /* Sapphire */
|
|
||||||
|
|
|
@ -17,10 +17,7 @@ DbManager::DbManager( const std::string& host, const std::string& database, cons
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DbManager::~DbManager()
|
DbManager::~DbManager() = default;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DbManager::execute( const std::string& sql )
|
bool DbManager::execute( const std::string& sql )
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,11 @@ x ## Ptr make_ ## x( Args &&...args ) { \
|
||||||
return std::make_shared< x >( std::forward< Args >( args ) ... ); }\
|
return std::make_shared< x >( std::forward< Args >( args ) ... ); }\
|
||||||
typedef std::vector< x > x ## PtrList;
|
typedef std::vector< x > x ## PtrList;
|
||||||
|
|
||||||
|
namespace Sapphire
|
||||||
|
{
|
||||||
|
TYPE_FORWARD( Framework );
|
||||||
|
}
|
||||||
|
|
||||||
namespace Sapphire::Lobby
|
namespace Sapphire::Lobby
|
||||||
{
|
{
|
||||||
TYPE_FORWARD( LobbySession );
|
TYPE_FORWARD( LobbySession );
|
||||||
|
@ -22,14 +27,14 @@ namespace Sapphire::Lobby::Network
|
||||||
TYPE_FORWARD( GameConnection );
|
TYPE_FORWARD( GameConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Sapphire::Common::Network
|
namespace Sapphire::Network
|
||||||
{
|
{
|
||||||
TYPE_FORWARD( Hive );
|
TYPE_FORWARD( Hive );
|
||||||
TYPE_FORWARD( Acceptor );
|
TYPE_FORWARD( Acceptor );
|
||||||
TYPE_FORWARD( Connection );
|
TYPE_FORWARD( Connection );
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Sapphire::Common::Network::Packets
|
namespace Sapphire::Network::Packets
|
||||||
{
|
{
|
||||||
TYPE_FORWARD( GamePacket );
|
TYPE_FORWARD( GamePacket );
|
||||||
TYPE_FORWARD( FFXIVPacketBase );
|
TYPE_FORWARD( FFXIVPacketBase );
|
||||||
|
|
|
@ -15,17 +15,19 @@
|
||||||
#include "RestConnector.h"
|
#include "RestConnector.h"
|
||||||
#include "LobbySession.h"
|
#include "LobbySession.h"
|
||||||
|
|
||||||
|
#include "Forwards.h"
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
using namespace Sapphire::Common::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
using namespace Sapphire::Common::Network::Packets::Server;
|
using namespace Sapphire::Network::Packets::Server;
|
||||||
|
|
||||||
extern Lobby::ServerLobby g_serverLobby;
|
extern Lobby::ServerLobby g_serverLobby;
|
||||||
extern Lobby::Network::RestConnector g_restConnector;
|
extern Lobby::Network::RestConnector g_restConnector;
|
||||||
|
|
||||||
Lobby::Network::GameConnection::GameConnection( Common::Network::HivePtr pHive,
|
Lobby::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pHive,
|
||||||
Common::Network::AcceptorPtr pAcceptor,
|
Sapphire::Network::AcceptorPtr pAcceptor,
|
||||||
Common::FrameworkPtr pFw ) :
|
FrameworkPtr pFw ) :
|
||||||
Common::Network::Connection( pHive, pFw ),
|
Sapphire::Network::Connection( pHive, pFw ),
|
||||||
m_pAcceptor( pAcceptor ),
|
m_pAcceptor( pAcceptor ),
|
||||||
m_bEncryptionInitialized( false )
|
m_bEncryptionInitialized( false )
|
||||||
{
|
{
|
||||||
|
@ -56,8 +58,8 @@ void Lobby::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
||||||
{
|
{
|
||||||
m_packets.insert( std::end( m_packets ), std::begin( buffer ), std::end( buffer ) );
|
m_packets.insert( std::end( m_packets ), std::begin( buffer ), std::end( buffer ) );
|
||||||
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
||||||
Common::Network::Packets::FFXIVARR_PACKET_HEADER packetHeader{};
|
Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER packetHeader{};
|
||||||
const auto headerResult = Common::Network::Packets::getHeader( m_packets, 0, packetHeader );
|
const auto headerResult = Sapphire::Network::Packets::getHeader( m_packets, 0, packetHeader );
|
||||||
|
|
||||||
if( headerResult == Incomplete )
|
if( headerResult == Incomplete )
|
||||||
return;
|
return;
|
||||||
|
@ -70,8 +72,8 @@ void Lobby::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dissect packet list
|
// Dissect packet list
|
||||||
std::vector< Common::Network::Packets::FFXIVARR_PACKET_RAW > packetList;
|
std::vector< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW > packetList;
|
||||||
const auto packetResult = Common::Network::Packets::getPackets( m_packets, sizeof( struct FFXIVARR_PACKET_HEADER ),
|
const auto packetResult = Sapphire::Network::Packets::getPackets( m_packets, sizeof( struct FFXIVARR_PACKET_HEADER ),
|
||||||
packetHeader, packetList );
|
packetHeader, packetList );
|
||||||
|
|
||||||
if( packetResult == Incomplete )
|
if( packetResult == Incomplete )
|
||||||
|
@ -381,7 +383,7 @@ bool Lobby::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::Network::GameConnection::handleGamePacket( Common::Network::Packets::FFXIVARR_PACKET_RAW& packet )
|
void Lobby::Network::GameConnection::handleGamePacket( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& packet )
|
||||||
{
|
{
|
||||||
|
|
||||||
uint32_t tmpId = packet.segHdr.target_actor;
|
uint32_t tmpId = packet.segHdr.target_actor;
|
||||||
|
@ -428,7 +430,7 @@ void Lobby::Network::GameConnection::sendPacket( Packets::LobbyPacketContainer&
|
||||||
send( sendBuffer );
|
send( sendBuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::Network::GameConnection::sendPackets( Common::Network::Packets::PacketContainer* pPacket )
|
void Lobby::Network::GameConnection::sendPackets( Sapphire::Network::Packets::PacketContainer* pPacket )
|
||||||
{
|
{
|
||||||
std::vector< uint8_t > sendBuffer;
|
std::vector< uint8_t > sendBuffer;
|
||||||
|
|
||||||
|
@ -457,8 +459,8 @@ void Lobby::Network::GameConnection::generateEncryptionKey( uint32_t key, const
|
||||||
Common::Util::md5( m_baseKey, m_encKey, 0x2C );
|
Common::Util::md5( m_baseKey, m_encKey, 0x2C );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::Network::GameConnection::handlePackets( const Common::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
void Lobby::Network::GameConnection::handlePackets( const Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||||
const std::vector< Common::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
const std::vector< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
||||||
{
|
{
|
||||||
|
|
||||||
for( auto inPacket : packetData )
|
for( auto inPacket : packetData )
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
namespace Sapphire::Lobby::Network
|
namespace Sapphire::Lobby::Network
|
||||||
{
|
{
|
||||||
|
|
||||||
class GameConnection : public Common::Network::Connection
|
class GameConnection : public Sapphire::Network::Connection
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -32,16 +32,16 @@ namespace Sapphire::Lobby::Network
|
||||||
|
|
||||||
bool m_bEncryptionInitialized;
|
bool m_bEncryptionInitialized;
|
||||||
|
|
||||||
Common::Network::AcceptorPtr m_pAcceptor;
|
Sapphire::Network::AcceptorPtr m_pAcceptor;
|
||||||
|
|
||||||
LobbySessionPtr m_pSession;
|
LobbySessionPtr m_pSession;
|
||||||
|
|
||||||
Common::Util::LockedQueue< Common::Network::Packets::GamePacketPtr > m_inQueue;
|
Common::Util::LockedQueue< Sapphire::Network::Packets::GamePacketPtr > m_inQueue;
|
||||||
Common::Util::LockedQueue< Common::Network::Packets::GamePacketPtr > m_outQueue;
|
Common::Util::LockedQueue< Sapphire::Network::Packets::GamePacketPtr > m_outQueue;
|
||||||
std::vector< uint8_t > m_packets;
|
std::vector< uint8_t > m_packets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameConnection( Common::Network::HivePtr pHive, Common::Network::AcceptorPtr pAcceptor, Common::FrameworkPtr pFw );
|
GameConnection( Sapphire::Network::HivePtr pHive, Sapphire::Network::AcceptorPtr pAcceptor, FrameworkPtr pFw );
|
||||||
|
|
||||||
~GameConnection();
|
~GameConnection();
|
||||||
|
|
||||||
|
@ -58,26 +58,26 @@ namespace Sapphire::Lobby::Network
|
||||||
|
|
||||||
void sendError( uint64_t sequence, uint32_t errorcode, uint16_t messageId, uint32_t tmpId );
|
void sendError( uint64_t sequence, uint32_t errorcode, uint16_t messageId, uint32_t tmpId );
|
||||||
|
|
||||||
void getCharList( Common::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
void getCharList( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||||
|
|
||||||
void enterWorld( Common::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
void enterWorld( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||||
|
|
||||||
bool sendServiceAccountList( Common::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
bool sendServiceAccountList( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||||
|
|
||||||
bool createOrModifyChar( Common::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
bool createOrModifyChar( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||||
|
|
||||||
void handlePackets( const Common::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
void handlePackets( const Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||||
const std::vector< Common::Network::Packets::FFXIVARR_PACKET_RAW >& packetData );
|
const std::vector< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW >& packetData );
|
||||||
|
|
||||||
void handleGamePacket( Common::Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
void handleGamePacket( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
||||||
|
|
||||||
void handlePacket( Common::Network::Packets::FFXIVPacketBasePtr pPacket );
|
void handlePacket( Sapphire::Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||||
|
|
||||||
void sendPackets( Common::Network::Packets::PacketContainer* pPacket );
|
void sendPackets( Sapphire::Network::Packets::PacketContainer* pPacket );
|
||||||
|
|
||||||
void sendPacket( Packets::LobbyPacketContainer& pLpc );
|
void sendPacket( Packets::LobbyPacketContainer& pLpc );
|
||||||
|
|
||||||
void sendSinglePacket( Common::Network::Packets::FFXIVPacketBasePtr pPacket );
|
void sendSinglePacket( Sapphire::Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire::Common;
|
||||||
using namespace Sapphire::Common::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
|
|
||||||
Lobby::Network::Packets::LobbyPacketContainer::LobbyPacketContainer( uint8_t* encKey )
|
Lobby::Network::Packets::LobbyPacketContainer::LobbyPacketContainer( uint8_t* encKey )
|
||||||
{
|
{
|
||||||
memset( &m_header, 0, sizeof( Common::Network::Packets::FFXIVARR_PACKET_HEADER ) );
|
memset( &m_header, 0, sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER ) );
|
||||||
m_header.size = sizeof( Common::Network::Packets::FFXIVARR_PACKET_HEADER );
|
m_header.size = sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER );
|
||||||
|
|
||||||
m_encKey = encKey;
|
m_encKey = encKey;
|
||||||
|
|
||||||
|
@ -51,6 +51,6 @@ uint8_t* Lobby::Network::Packets::LobbyPacketContainer::getRawData( bool addstuf
|
||||||
m_header.unknown_0 = 0xff41a05252;
|
m_header.unknown_0 = 0xff41a05252;
|
||||||
m_header.timestamp = Common::Util::getTimeMs();
|
m_header.timestamp = Common::Util::getTimeMs();
|
||||||
}
|
}
|
||||||
memcpy( m_dataBuf, &m_header, sizeof( Common::Network::Packets::FFXIVARR_PACKET_HEADER ) );
|
memcpy( m_dataBuf, &m_header, sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER ) );
|
||||||
return m_dataBuf;
|
return m_dataBuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
namespace Sapphire::Lobby::Network::Packets
|
namespace Sapphire::Lobby::Network::Packets
|
||||||
{
|
{
|
||||||
|
|
||||||
using FFXIVPacketBasePtr = std::shared_ptr< Common::Network::Packets::FFXIVPacketBase >;
|
using FFXIVPacketBasePtr = std::shared_ptr< Sapphire::Network::Packets::FFXIVPacketBase >;
|
||||||
|
|
||||||
class LobbyPacketContainer
|
class LobbyPacketContainer
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ namespace Sapphire::Lobby::Network::Packets
|
||||||
uint8_t* getRawData( bool addstuff = true );
|
uint8_t* getRawData( bool addstuff = true );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::Network::Packets::FFXIVARR_PACKET_HEADER m_header;
|
Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER m_header;
|
||||||
|
|
||||||
uint8_t* m_encKey;
|
uint8_t* m_encKey;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
using namespace Sapphire;
|
||||||
|
|
||||||
Sapphire::Lobby::Network::RestConnector g_restConnector;
|
Sapphire::Lobby::Network::RestConnector g_restConnector;
|
||||||
|
|
||||||
namespace Sapphire::Lobby
|
namespace Sapphire::Lobby
|
||||||
|
@ -63,15 +65,15 @@ namespace Sapphire::Lobby
|
||||||
|
|
||||||
Logger::setLogLevel( m_config.global.general.logLevel );
|
Logger::setLogLevel( m_config.global.general.logLevel );
|
||||||
|
|
||||||
auto pFw = std::make_shared< Common::Framework >();
|
auto pFw = std::make_shared< Framework >();
|
||||||
Common::Network::HivePtr hive( new Common::Network::Hive() );
|
auto hive = Sapphire::Network::make_Hive();
|
||||||
Common::Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive, pFw );
|
Sapphire::Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive, pFw );
|
||||||
|
|
||||||
Logger::info( "Lobby server running on {0}:{1}", m_ip, m_port );
|
Logger::info( "Lobby server running on {0}:{1}", m_ip, m_port );
|
||||||
|
|
||||||
std::vector< std::thread > threadGroup;
|
std::vector< std::thread > threadGroup;
|
||||||
|
|
||||||
threadGroup.emplace_back( std::bind( &Common::Network::Hive::run, hive.get() ) );
|
threadGroup.emplace_back( std::bind( &Sapphire::Network::Hive::run, hive.get() ) );
|
||||||
|
|
||||||
for( auto& thread : threadGroup )
|
for( auto& thread : threadGroup )
|
||||||
if( thread.joinable() )
|
if( thread.joinable() )
|
||||||
|
|
|
@ -28,12 +28,12 @@ namespace Sapphire::Network
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameConnection : public Common::Network::Connection
|
class GameConnection : public Network::Connection
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef void ( GameConnection::* Handler )( FrameworkPtr pFw,
|
typedef void ( GameConnection::* Handler )( FrameworkPtr pFw,
|
||||||
const Common::Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
const Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||||
Entity::Player& player );
|
Entity::Player& player );
|
||||||
|
|
||||||
using HandlerMap = std::map< uint16_t, Handler >;
|
using HandlerMap = std::map< uint16_t, Handler >;
|
||||||
|
@ -51,7 +51,7 @@ namespace Sapphire::Network
|
||||||
|
|
||||||
World::SessionPtr m_pSession;
|
World::SessionPtr m_pSession;
|
||||||
|
|
||||||
Common::Util::LockedQueue< Common::Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
|
Common::Util::LockedQueue< Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
|
||||||
Common::Util::LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
|
Common::Util::LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
|
||||||
std::vector< uint8_t > m_packets;
|
std::vector< uint8_t > m_packets;
|
||||||
|
|
||||||
|
@ -82,15 +82,15 @@ namespace Sapphire::Network
|
||||||
|
|
||||||
void processOutQueue();
|
void processOutQueue();
|
||||||
|
|
||||||
void handlePacket( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
void handlePacket( Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
||||||
|
|
||||||
void handleZonePacket( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
void handleZonePacket( Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
||||||
|
|
||||||
void handleChatPacket( Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
void handleChatPacket( Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
||||||
|
|
||||||
void sendPackets( Packets::PacketContainer* pPacket );
|
void sendPackets( Packets::PacketContainer* pPacket );
|
||||||
|
|
||||||
void sendSinglePacket( Sapphire::Network::Packets::FFXIVPacketBasePtr pPacket );
|
void sendSinglePacket( Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||||
|
|
||||||
void injectPacket( const std::string& packetpath, Entity::Player& player );
|
void injectPacket( const std::string& packetpath, Entity::Player& player );
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ size_t Sapphire::World::ServerMgr::getSessionCount() const
|
||||||
|
|
||||||
bool Sapphire::World::ServerMgr::loadSettings( int32_t argc, char* argv[] )
|
bool Sapphire::World::ServerMgr::loadSettings( int32_t argc, char* argv[] )
|
||||||
{
|
{
|
||||||
auto pConfig = framework()->get< Sapphire::ConfigMgr >();
|
auto pConfig = framework()->get< Common::ConfigMgr >();
|
||||||
|
|
||||||
Logger::info( "Loading config {0}", m_configName );
|
Logger::info( "Loading config {0}", m_configName );
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
|
||||||
|
|
||||||
printBanner();
|
printBanner();
|
||||||
|
|
||||||
auto pConfig = std::make_shared< ConfigMgr >();
|
auto pConfig = std::make_shared< Common::ConfigMgr >();
|
||||||
framework()->set< ConfigMgr >( pConfig );
|
framework()->set< Common::ConfigMgr >( pConfig );
|
||||||
if( !loadSettings( argc, argv ) )
|
if( !loadSettings( argc, argv ) )
|
||||||
{
|
{
|
||||||
Logger::fatal( "Unable to load settings!" );
|
Logger::fatal( "Unable to load settings!" );
|
||||||
|
|
|
@ -12,7 +12,7 @@ Common::Util::CrashHandler crashHandler;
|
||||||
|
|
||||||
int main( int32_t argc, char* argv[] )
|
int main( int32_t argc, char* argv[] )
|
||||||
{
|
{
|
||||||
auto pFramework = Sapphire::make_Framework();
|
auto pFramework = make_Framework();
|
||||||
auto pServer = std::make_shared< ServerMgr >( "world.ini", pFramework );
|
auto pServer = std::make_shared< ServerMgr >( "world.ini", pFramework );
|
||||||
pFramework->set< ServerMgr >( pServer );
|
pFramework->set< ServerMgr >( pServer );
|
||||||
pServer->run( argc, argv );
|
pServer->run( argc, argv );
|
||||||
|
|
Loading…
Add table
Reference in a new issue