mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Merge pull request #563 from NotAdam/develop
move some namespaces around, somewhat working action lut
This commit is contained in:
commit
8547f1724b
114 changed files with 1764 additions and 1956 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;
|
||||
|
||||
namespace Sapphire {
|
||||
namespace Sapphire::Api {
|
||||
|
||||
using namespace Common;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Api
|
||||
{
|
||||
|
||||
class PlayerMinimal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "SapphireAPI.h"
|
||||
#include "SapphireApi.h"
|
||||
#include <Crypt/base64.h>
|
||||
#include "Session.h"
|
||||
#include "PlayerMinimal.h"
|
||||
|
@ -10,7 +10,9 @@
|
|||
|
||||
#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 =
|
||||
"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
|
||||
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
|
||||
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,
|
||||
const std::string& infoJson,
|
||||
const uint32_t gmRank )
|
||||
int SapphireApi::createCharacter( const uint32_t accountId, const std::string& name,
|
||||
const std::string& infoJson,
|
||||
const uint32_t gmRank )
|
||||
{
|
||||
Sapphire::PlayerMinimal newPlayer;
|
||||
Api::PlayerMinimal newPlayer;
|
||||
|
||||
newPlayer.setAccountId( accountId );
|
||||
newPlayer.setId( getNextCharId() );
|
||||
|
@ -169,7 +171,7 @@ int Sapphire::Network::SapphireAPI::createCharacter( const uint32_t accountId, c
|
|||
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;
|
||||
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 ) + "';" );
|
||||
}
|
||||
|
||||
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(
|
||||
"SELECT CharacterId, ContentId FROM charainfo WHERE AccountId = " + std::to_string( accountId ) + ";" );
|
||||
|
||||
while( pQR->next() )
|
||||
{
|
||||
Sapphire::PlayerMinimal player;
|
||||
Api::PlayerMinimal player;
|
||||
|
||||
uint32_t charId = pQR->getUInt( 1 );
|
||||
|
||||
|
@ -220,7 +222,7 @@ std::vector< Sapphire::PlayerMinimal > Sapphire::Network::SapphireAPI::getCharLi
|
|||
return charList;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::SapphireAPI::checkNameTaken( std::string name )
|
||||
bool SapphireApi::checkNameTaken( std::string name )
|
||||
{
|
||||
|
||||
g_charaDb.escapeString( name );
|
||||
|
@ -234,7 +236,7 @@ bool Sapphire::Network::SapphireAPI::checkNameTaken( std::string name )
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Network::SapphireAPI::getNextCharId()
|
||||
uint32_t SapphireApi::getNextCharId()
|
||||
{
|
||||
uint32_t charId = 0;
|
||||
|
||||
|
@ -250,7 +252,7 @@ uint32_t Sapphire::Network::SapphireAPI::getNextCharId()
|
|||
return charId;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Network::SapphireAPI::getNextContentId()
|
||||
uint64_t SapphireApi::getNextContentId()
|
||||
{
|
||||
uint64_t contentId = 0;
|
||||
|
||||
|
@ -266,7 +268,7 @@ uint64_t Sapphire::Network::SapphireAPI::getNextContentId()
|
|||
return contentId;
|
||||
}
|
||||
|
||||
int Sapphire::Network::SapphireAPI::checkSession( const std::string& sId )
|
||||
int SapphireApi::checkSession( const std::string& 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 );
|
||||
|
|
@ -7,19 +7,15 @@
|
|||
#include <memory>
|
||||
#include "PlayerMinimal.h"
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Api
|
||||
{
|
||||
class Session;
|
||||
}
|
||||
|
||||
namespace Sapphire::Network
|
||||
{
|
||||
|
||||
class SapphireAPI
|
||||
class SapphireApi
|
||||
{
|
||||
public:
|
||||
SapphireAPI() = default;
|
||||
~SapphireAPI() = default;
|
||||
SapphireApi() = default;
|
||||
~SapphireApi() = default;
|
||||
|
||||
using SessionMap = std::map< std::string, std::shared_ptr< Session > >;
|
||||
|
||||
|
@ -34,7 +30,7 @@ namespace Sapphire::Network
|
|||
|
||||
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 );
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include "Session.h"
|
||||
|
||||
namespace Sapphire {
|
||||
using namespace Sapphire::Api;
|
||||
|
||||
Session::Session()
|
||||
{
|
||||
|
||||
|
@ -35,4 +36,3 @@ void Session::setAccountId( uint32_t id )
|
|||
{
|
||||
m_accountId = id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Api
|
||||
{
|
||||
|
||||
class Session
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
#include <Framework.h>
|
||||
#include <Logging/Logger.h>
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "SapphireAPI.h"
|
||||
#include "SapphireApi.h"
|
||||
|
||||
#include <Util/CrashHandler.h>
|
||||
|
||||
|
@ -38,7 +37,7 @@ Sapphire::Common::Util::CrashHandler crashHandler;
|
|||
|
||||
Sapphire::Db::DbWorkerPool< Sapphire::Db::ZoneDbConnection > g_charaDb;
|
||||
Sapphire::Data::ExdDataGenerated g_exdDataGen;
|
||||
Sapphire::Network::SapphireAPI g_sapphireAPI;
|
||||
Sapphire::Api::SapphireApi g_sapphireAPI;
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
|
@ -59,7 +58,7 @@ Sapphire::Common::Config::ApiConfig m_config;
|
|||
|
||||
void reloadConfig()
|
||||
{
|
||||
auto pConfig = std::make_shared< Sapphire::ConfigMgr >();
|
||||
auto pConfig = std::make_shared< Sapphire::Common::ConfigMgr >();
|
||||
|
||||
Logger::info( "Loading config " + configPath );
|
||||
|
||||
|
@ -106,7 +105,7 @@ bool loadSettings( int32_t argc, char* argv[] )
|
|||
|
||||
try
|
||||
{
|
||||
arg = Sapphire::Util::toLowerCopy( std::string( args[ i ] ) );
|
||||
arg = Common::Util::toLowerCopy( std::string( args[ i ] ) );
|
||||
val = std::string( args[ i + 1 ] );
|
||||
|
||||
// trim '-' from start of arg
|
||||
|
@ -336,7 +335,7 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
|
|||
std::string name = json["name"];
|
||||
std::string infoJson = json["infoJson"];
|
||||
|
||||
std::string finalJson = Sapphire::Util::base64Decode( infoJson );
|
||||
std::string finalJson = Common::Util::base64Decode( infoJson );
|
||||
|
||||
// reloadConfig();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
class case_insensitive_equals {
|
||||
public:
|
||||
bool operator()(const std::string &key1, const std::string &key2) const {
|
||||
return Sapphire::Util::toLowerCopy( key1 ) == Sapphire::Util::toLowerCopy( key2 );
|
||||
return Sapphire::Common::Util::toLowerCopy( key1 ) == Sapphire::Common::Util::toLowerCopy( key2 );
|
||||
}
|
||||
};
|
||||
class case_insensitive_hash {
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
{
|
||||
std::size_t seed=0;
|
||||
for( auto &c : key )
|
||||
Sapphire::Util::hashCombine< char >( seed, std::tolower( c ) );
|
||||
Sapphire::Common::Util::hashCombine< char >( seed, std::tolower( c ) );
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
|
@ -388,7 +388,7 @@ namespace SimpleWeb {
|
|||
|
||||
auto range=request->header.equal_range("Connection");
|
||||
for(auto it=range.first;it!=range.second;it++) {
|
||||
if( Sapphire::Util::toLowerCopy( it->second ) == "close" )
|
||||
if( Sapphire::Common::Util::toLowerCopy( it->second ) == "close" )
|
||||
return;
|
||||
}
|
||||
if(http_version>1.05)
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
|
||||
/**
|
||||
* Loads an ini file and parses it
|
||||
* @param configName the name of ini file relative to m_configFolderRoot to load alongside global.ini
|
||||
* @return true if loading was successful
|
||||
*/
|
||||
bool Sapphire::ConfigMgr::loadConfig( const std::string& configName )
|
||||
bool ConfigMgr::loadConfig( const std::string& configName )
|
||||
{
|
||||
// get global config
|
||||
auto configFile = fs::path( fs::path( m_configFolderRoot ) / configName );
|
||||
|
@ -29,7 +32,7 @@ bool Sapphire::ConfigMgr::loadConfig( const std::string& configName )
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const std::string& configName )
|
||||
bool ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const std::string& configName )
|
||||
{
|
||||
auto configFile = fs::path( fs::path( m_configFolderRoot ) / configName );
|
||||
|
||||
|
@ -71,7 +74,7 @@ bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::ConfigMgr::copyDefaultConfig( const std::string& configName )
|
||||
bool ConfigMgr::copyDefaultConfig( const std::string& configName )
|
||||
{
|
||||
fs::path configPath( m_configFolderRoot );
|
||||
configPath /= configName;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <stdint.h>
|
||||
#include "ConfigDef.h"
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Common
|
||||
{
|
||||
class ConfigMgr
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ static inline bool is_base64( uint8_t c )
|
|||
return ( isalnum( c ) || ( c == '+' ) || ( c == '/' ) );
|
||||
}
|
||||
|
||||
std::string Sapphire::Util::base64Encode( uint8_t const* bytes_to_encode, uint32_t in_len )
|
||||
std::string Sapphire::Common::Util::base64Encode( uint8_t const* bytes_to_encode, uint32_t in_len )
|
||||
{
|
||||
std::string ret;
|
||||
int32_t i = 0;
|
||||
|
@ -87,7 +87,7 @@ std::string Sapphire::Util::base64Encode( uint8_t const* bytes_to_encode, uint32
|
|||
|
||||
}
|
||||
|
||||
std::string Sapphire::Util::base64Decode( std::string const& encoded_string )
|
||||
std::string Sapphire::Common::Util::base64Decode( std::string const& encoded_string )
|
||||
{
|
||||
int32_t in_len = encoded_string.size();
|
||||
int32_t i = 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <string>
|
||||
|
||||
namespace Sapphire::Util
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
std::string base64Encode( uint8_t const*, uint32_t len );
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
(b)[(i) + 3] = (uint8_t) ( (n) >> 24 ); \
|
||||
}
|
||||
|
||||
void Sapphire::Util::md5_starts( md5_context* ctx )
|
||||
void Sapphire::Common::Util::md5_starts( md5_context* ctx )
|
||||
{
|
||||
ctx->total[ 0 ] = 0;
|
||||
ctx->total[ 1 ] = 0;
|
||||
|
@ -48,7 +48,7 @@ void Sapphire::Util::md5_starts( md5_context* ctx )
|
|||
ctx->state[ 3 ] = 0x10325476;
|
||||
}
|
||||
|
||||
void md5_process( Sapphire::Util::md5_context* ctx, uint8_t data[64] )
|
||||
void md5_process( Sapphire::Common::Util::md5_context* ctx, uint8_t data[64] )
|
||||
{
|
||||
uint32_t X[16], A, B, C, D;
|
||||
|
||||
|
@ -171,7 +171,7 @@ void md5_process( Sapphire::Util::md5_context* ctx, uint8_t data[64] )
|
|||
ctx->state[ 3 ] += D;
|
||||
}
|
||||
|
||||
void Sapphire::Util::md5_update( md5_context* ctx, uint8_t* input, uint32_t length )
|
||||
void Sapphire::Common::Util::md5_update( md5_context* ctx, uint8_t* input, uint32_t length )
|
||||
{
|
||||
uint32_t left, fill;
|
||||
|
||||
|
@ -219,7 +219,7 @@ static uint8_t md5_padding[64] =
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
void Sapphire::Util::md5_finish( md5_context* ctx, uint8_t digest[16] )
|
||||
void Sapphire::Common::Util::md5_finish( md5_context* ctx, uint8_t digest[16] )
|
||||
{
|
||||
uint32_t last, padn;
|
||||
uint32_t high, low;
|
||||
|
@ -248,7 +248,7 @@ void Sapphire::Util::md5_finish( md5_context* ctx, uint8_t digest[16] )
|
|||
* those are the standard RFC 1321 test vectors
|
||||
*/
|
||||
|
||||
void Sapphire::Util::md5( uint8_t* text, uint8_t* hash, int32_t size )
|
||||
void Sapphire::Common::Util::md5( uint8_t* text, uint8_t* hash, int32_t size )
|
||||
{
|
||||
md5_context ctx;
|
||||
md5_starts( &ctx );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Sapphire::Util
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
using md5_context = struct
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ Sapphire::Db::DbConnection::DbConnection( ConnectionInfo& connInfo ) :
|
|||
|
||||
}
|
||||
|
||||
Sapphire::Db::DbConnection::DbConnection( Sapphire::LockedWaitQueue< std::shared_ptr< Operation > >* queue,
|
||||
Sapphire::Db::DbConnection::DbConnection( Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* queue,
|
||||
Sapphire::Db::ConnectionInfo& connInfo ) :
|
||||
m_reconnecting( false ),
|
||||
m_prepareError( false ),
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Sapphire::Db
|
|||
DbConnection( ConnectionInfo& connInfo );
|
||||
|
||||
// Constructor for asynchronous connections.
|
||||
DbConnection( Sapphire::LockedWaitQueue< std::shared_ptr< Operation > >* queue, ConnectionInfo& connInfo );
|
||||
DbConnection( Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* queue, ConnectionInfo& connInfo );
|
||||
|
||||
virtual ~DbConnection();
|
||||
|
||||
|
@ -92,7 +92,7 @@ namespace Sapphire::Db
|
|||
bool m_prepareError;
|
||||
|
||||
private:
|
||||
LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
|
||||
Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
|
||||
std::shared_ptr< DbWorker > m_worker;
|
||||
std::shared_ptr< Mysql::Connection > m_pConnection;
|
||||
ConnectionInfo& m_connectionInfo;
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#include "Operation.h"
|
||||
#include "Util/LockedWaitQueue.h"
|
||||
|
||||
Sapphire::Db::DbWorker::DbWorker( Sapphire::LockedWaitQueue< std::shared_ptr< Operation > >* newQueue,
|
||||
using namespace Sapphire::Common;
|
||||
|
||||
Sapphire::Db::DbWorker::DbWorker( Util::LockedWaitQueue< std::shared_ptr< Operation > >* newQueue,
|
||||
DbConnection* pConn )
|
||||
{
|
||||
m_pConn = pConn;
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace Sapphire::Db
|
|||
class DbWorker
|
||||
{
|
||||
public:
|
||||
DbWorker( LockedWaitQueue< std::shared_ptr< Operation > >* newQueue, DbConnection* connection );
|
||||
DbWorker( Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* newQueue, DbConnection* connection );
|
||||
|
||||
~DbWorker();
|
||||
|
||||
private:
|
||||
LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
|
||||
Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
|
||||
DbConnection* m_pConn;
|
||||
|
||||
void workerThread();
|
||||
|
|
|
@ -21,7 +21,7 @@ class PingOperation : public Sapphire::Db::Operation
|
|||
|
||||
template< class T >
|
||||
Sapphire::Db::DbWorkerPool< T >::DbWorkerPool() :
|
||||
m_queue( new Sapphire::LockedWaitQueue< std::shared_ptr< Operation > >() ),
|
||||
m_queue( new Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >() ),
|
||||
m_asyncThreads( 0 ),
|
||||
m_synchThreads( 0 )
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Sapphire::Db
|
|||
|
||||
const std::string& getDatabaseName() const;
|
||||
|
||||
std::unique_ptr< Sapphire::LockedWaitQueue< std::shared_ptr< Operation > > > m_queue;
|
||||
std::unique_ptr< Common::Util::LockedWaitQueue< std::shared_ptr< Operation > > > m_queue;
|
||||
std::array< std::vector< std::shared_ptr< T > >, IDX_SIZE > m_connections;
|
||||
ConnectionInfo m_connectionInfo;
|
||||
uint8_t m_asyncThreads;
|
||||
|
|
|
@ -6,7 +6,7 @@ Sapphire::Db::ZoneDbConnection::ZoneDbConnection( ConnectionInfo& connInfo ) :
|
|||
{
|
||||
}
|
||||
|
||||
Sapphire::Db::ZoneDbConnection::ZoneDbConnection( Sapphire::LockedWaitQueue< std::shared_ptr< Operation > >* q,
|
||||
Sapphire::Db::ZoneDbConnection::ZoneDbConnection( Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* q,
|
||||
ConnectionInfo& connInfo ) :
|
||||
DbConnection( q, connInfo )
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace Sapphire::Db
|
|||
|
||||
ZoneDbConnection( ConnectionInfo& connInfo );
|
||||
|
||||
ZoneDbConnection( Sapphire::LockedWaitQueue< std::shared_ptr< Operation > >* q, ConnectionInfo& connInfo );
|
||||
ZoneDbConnection( Common::Util::LockedWaitQueue< std::shared_ptr< Operation > >* q, ConnectionInfo& connInfo );
|
||||
|
||||
~ZoneDbConnection();
|
||||
|
||||
|
|
|
@ -5,12 +5,16 @@
|
|||
|
||||
namespace Sapphire
|
||||
{
|
||||
class ConfigMgr;
|
||||
class Framework;
|
||||
using ConfigMgrPtr = std::shared_ptr< ConfigMgr >;
|
||||
using FrameworkPtr = std::shared_ptr< Framework >;
|
||||
}
|
||||
|
||||
namespace Sapphire::Common
|
||||
{
|
||||
class ConfigMgr;
|
||||
using ConfigMgrPtr = std::shared_ptr< ConfigMgr >;
|
||||
}
|
||||
|
||||
namespace Sapphire::Network
|
||||
{
|
||||
class Hive;
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#include "Acceptor.h"
|
||||
#include "Connection.h"
|
||||
|
||||
Sapphire::Network::Acceptor::Acceptor( HivePtr hive ) :
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
Network::Acceptor::Acceptor( HivePtr hive ) :
|
||||
m_hive( hive ),
|
||||
m_acceptor( hive->getService() ),
|
||||
m_io_strand( hive->getService() ),
|
||||
|
@ -10,21 +13,21 @@ Sapphire::Network::Acceptor::Acceptor( HivePtr hive ) :
|
|||
{
|
||||
}
|
||||
|
||||
Sapphire::Network::Acceptor::~Acceptor()
|
||||
Network::Acceptor::~Acceptor()
|
||||
{
|
||||
}
|
||||
|
||||
bool Sapphire::Network::Acceptor::onAccept( ConnectionPtr connection, const std::string& host, uint16_t port )
|
||||
bool Network::Acceptor::onAccept( ConnectionPtr connection, const std::string& host, uint16_t port )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::onError( const asio::error_code& error )
|
||||
void Network::Acceptor::onError( const asio::error_code& error )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::startError( const asio::error_code& error )
|
||||
void Network::Acceptor::startError( const asio::error_code& error )
|
||||
{
|
||||
uint32_t v1 = 1;
|
||||
uint32_t v2 = 0;
|
||||
|
@ -37,7 +40,7 @@ void Sapphire::Network::Acceptor::startError( const asio::error_code& error )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::dispatchAccept( ConnectionPtr connection )
|
||||
void Network::Acceptor::dispatchAccept( ConnectionPtr connection )
|
||||
{
|
||||
m_acceptor.async_accept( connection->getSocket(),
|
||||
connection->getStrand().wrap( std::bind( &Acceptor::handleAccept,
|
||||
|
@ -46,7 +49,7 @@ void Sapphire::Network::Acceptor::dispatchAccept( ConnectionPtr connection )
|
|||
connection ) ) );
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::handleAccept( const asio::error_code& error, ConnectionPtr connection )
|
||||
void Network::Acceptor::handleAccept( const asio::error_code& error, ConnectionPtr connection )
|
||||
{
|
||||
if( error || hasError() || m_hive->hasStopped() )
|
||||
{
|
||||
|
@ -72,17 +75,17 @@ void Sapphire::Network::Acceptor::handleAccept( const asio::error_code& error, C
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::stop()
|
||||
void Network::Acceptor::stop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::accept( ConnectionPtr connection )
|
||||
void Network::Acceptor::accept( ConnectionPtr connection )
|
||||
{
|
||||
m_io_strand.post( std::bind( &Acceptor::dispatchAccept, shared_from_this(), connection ) );
|
||||
}
|
||||
|
||||
void Sapphire::Network::Acceptor::listen( const std::string& host, const uint16_t& port )
|
||||
void Network::Acceptor::listen( const std::string& host, const uint16_t& port )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -103,17 +106,17 @@ void Sapphire::Network::Acceptor::listen( const std::string& host, const uint16_
|
|||
|
||||
}
|
||||
|
||||
Sapphire::Network::HivePtr Sapphire::Network::Acceptor::getHive()
|
||||
Network::HivePtr Network::Acceptor::getHive()
|
||||
{
|
||||
return m_hive;
|
||||
}
|
||||
|
||||
asio::ip::tcp::acceptor& Sapphire::Network::Acceptor::getAcceptor()
|
||||
asio::ip::tcp::acceptor& Network::Acceptor::getAcceptor()
|
||||
{
|
||||
return m_acceptor;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::Acceptor::hasError()
|
||||
bool Network::Acceptor::hasError()
|
||||
{
|
||||
uint32_t v1 = 1;
|
||||
uint32_t v2 = 1;
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
#include <functional>
|
||||
#include "Framework.h"
|
||||
|
||||
Sapphire::Network::Connection::Connection( HivePtr hive, FrameworkPtr pFw ) :
|
||||
using namespace Sapphire;
|
||||
|
||||
Network::Connection::Connection( HivePtr hive, FrameworkPtr pFw ) :
|
||||
m_hive( hive ),
|
||||
m_socket( hive->getService() ),
|
||||
m_io_strand( hive->getService() ),
|
||||
|
@ -13,11 +15,9 @@ Sapphire::Network::Connection::Connection( HivePtr hive, FrameworkPtr pFw ) :
|
|||
{
|
||||
}
|
||||
|
||||
Sapphire::Network::Connection::~Connection()
|
||||
{
|
||||
}
|
||||
Network::Connection::~Connection() = default;
|
||||
|
||||
void Sapphire::Network::Connection::bind( const std::string& ip, uint16_t port )
|
||||
void Network::Connection::bind( const std::string& ip, uint16_t port )
|
||||
{
|
||||
asio::ip::tcp::endpoint endpoint( asio::ip::address::from_string( ip ), port );
|
||||
m_socket.open( endpoint.protocol() );
|
||||
|
@ -25,7 +25,7 @@ void Sapphire::Network::Connection::bind( const std::string& ip, uint16_t port )
|
|||
m_socket.bind( endpoint );
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::startSend()
|
||||
void Network::Connection::startSend()
|
||||
{
|
||||
if( !m_pending_sends.empty() )
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ void Sapphire::Network::Connection::startSend()
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::startRecv( int32_t total_bytes )
|
||||
void Network::Connection::startRecv( int32_t total_bytes )
|
||||
{
|
||||
if( total_bytes > 0 )
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ void Sapphire::Network::Connection::startRecv( int32_t total_bytes )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::startError( const asio::error_code& error )
|
||||
void Network::Connection::startError( const asio::error_code& error )
|
||||
{
|
||||
uint32_t v1 = 1;
|
||||
uint32_t v2 = 0;
|
||||
|
@ -74,7 +74,7 @@ void Sapphire::Network::Connection::startError( const asio::error_code& error )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::handleConnect( const asio::error_code& error )
|
||||
void Network::Connection::handleConnect( const asio::error_code& error )
|
||||
{
|
||||
if( error || hasError() || m_hive->hasStopped() )
|
||||
{
|
||||
|
@ -94,8 +94,8 @@ void Sapphire::Network::Connection::handleConnect( const asio::error_code& error
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::handleSend( const asio::error_code& error,
|
||||
std::list< std::vector< uint8_t > >::iterator itr )
|
||||
void Network::Connection::handleSend( const asio::error_code& error,
|
||||
std::list< std::vector< uint8_t > >::iterator itr )
|
||||
{
|
||||
if( error || hasError() || m_hive->hasStopped() )
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ void Sapphire::Network::Connection::handleSend( const asio::error_code& error,
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::handleRecv( const asio::error_code& error, int32_t actual_bytes )
|
||||
void Network::Connection::handleRecv( const asio::error_code& error, int32_t actual_bytes )
|
||||
{
|
||||
if( error || hasError() || m_hive->hasStopped() )
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ void Sapphire::Network::Connection::handleRecv( const asio::error_code& error, i
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::dispatchSend( std::vector< uint8_t > buffer )
|
||||
void Network::Connection::dispatchSend( std::vector< uint8_t > buffer )
|
||||
{
|
||||
bool should_start_send = m_pending_sends.empty();
|
||||
m_pending_sends.push_back( buffer );
|
||||
|
@ -138,7 +138,7 @@ void Sapphire::Network::Connection::dispatchSend( std::vector< uint8_t > buffer
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::dispatchRecv( int32_t total_bytes )
|
||||
void Network::Connection::dispatchRecv( int32_t total_bytes )
|
||||
{
|
||||
bool should_start_receive = m_pending_recvs.empty();
|
||||
m_pending_recvs.push_back( total_bytes );
|
||||
|
@ -149,7 +149,7 @@ void Sapphire::Network::Connection::dispatchRecv( int32_t total_bytes )
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Network::Connection::connect( const std::string& host, uint16_t port )
|
||||
void Network::Connection::connect( const std::string& host, uint16_t port )
|
||||
{
|
||||
asio::ip::tcp::resolver resolver( m_hive->getService() );
|
||||
asio::ip::tcp::resolver::query query( host, std::to_string( port ) );
|
||||
|
@ -160,48 +160,48 @@ void Sapphire::Network::Connection::connect( const std::string& host, uint16_t p
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::disconnect()
|
||||
void Network::Connection::disconnect()
|
||||
{
|
||||
onDisconnect();
|
||||
m_socket.close();
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::recv( int32_t total_bytes )
|
||||
void Network::Connection::recv( int32_t total_bytes )
|
||||
{
|
||||
m_io_strand.post( std::bind( &Connection::dispatchRecv, shared_from_this(), total_bytes ) );
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::send( const std::vector< uint8_t >& buffer )
|
||||
void Network::Connection::send( const std::vector< uint8_t >& buffer )
|
||||
{
|
||||
m_io_strand.post( std::bind( &Connection::dispatchSend, shared_from_this(), buffer ) );
|
||||
}
|
||||
|
||||
asio::ip::tcp::socket& Sapphire::Network::Connection::getSocket()
|
||||
asio::ip::tcp::socket& Network::Connection::getSocket()
|
||||
{
|
||||
return m_socket;
|
||||
}
|
||||
|
||||
asio::strand& Sapphire::Network::Connection::getStrand()
|
||||
asio::strand& Network::Connection::getStrand()
|
||||
{
|
||||
return m_io_strand;
|
||||
}
|
||||
|
||||
Sapphire::Network::HivePtr Sapphire::Network::Connection::getHive()
|
||||
Network::HivePtr Network::Connection::getHive()
|
||||
{
|
||||
return m_hive;
|
||||
}
|
||||
|
||||
void Sapphire::Network::Connection::setReceiveBufferSize( int32_t size )
|
||||
void Network::Connection::setReceiveBufferSize( int32_t size )
|
||||
{
|
||||
m_receive_buffer_size = size;
|
||||
}
|
||||
|
||||
int32_t Sapphire::Network::Connection::getReceiveBufferSize() const
|
||||
int32_t Network::Connection::getReceiveBufferSize() const
|
||||
{
|
||||
return m_receive_buffer_size;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::Connection::hasError()
|
||||
bool Network::Connection::hasError()
|
||||
{
|
||||
uint32_t v1 = 1;
|
||||
uint32_t v2 = 1;
|
||||
|
|
|
@ -12,12 +12,6 @@
|
|||
#include "Acceptor.h"
|
||||
#include <memory>
|
||||
|
||||
namespace Sapphire
|
||||
{
|
||||
class Framework;
|
||||
using FrameworkPtr = std::shared_ptr< Framework >;
|
||||
}
|
||||
|
||||
namespace Sapphire::Network
|
||||
{
|
||||
|
||||
|
@ -41,7 +35,7 @@ namespace Sapphire::Network
|
|||
std::list< std::vector< uint8_t > > m_pending_sends;
|
||||
int32_t m_receive_buffer_size;
|
||||
std::atomic< uint32_t > m_error_state;
|
||||
Sapphire::FrameworkPtr m_pFw;
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
Connection( HivePtr hive, FrameworkPtr pFw );
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace Sapphire::Network::Packets
|
|||
|
||||
// The IPC type itself.
|
||||
m_ipcHdr.type = static_cast< ServerZoneIpcType >( m_data._ServerIpcType );
|
||||
m_ipcHdr.timestamp = Util::getTimeSeconds();
|
||||
m_ipcHdr.timestamp = Common::Util::getTimeSeconds();
|
||||
m_segHdr.size = sizeof( T ) + sizeof( FFXIVARR_IPC_HEADER ) + sizeof( FFXIVARR_PACKET_SEGMENT_HEADER );
|
||||
};
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#include <string.h> // memcpy
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
||||
PacketParseResult Sapphire::Network::Packets::getHeader( const std::vector< uint8_t >& buffer,
|
||||
PacketParseResult Network::Packets::getHeader( const std::vector< uint8_t >& buffer,
|
||||
const uint32_t offset,
|
||||
FFXIVARR_PACKET_HEADER& header )
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ PacketParseResult Sapphire::Network::Packets::getHeader( const std::vector< uint
|
|||
return Success;
|
||||
}
|
||||
|
||||
PacketParseResult Sapphire::Network::Packets::getSegmentHeader( const std::vector< uint8_t >& buffer,
|
||||
PacketParseResult Network::Packets::getSegmentHeader( const std::vector< uint8_t >& buffer,
|
||||
const uint32_t offset,
|
||||
FFXIVARR_PACKET_SEGMENT_HEADER& header )
|
||||
{
|
||||
|
@ -42,7 +43,7 @@ PacketParseResult Sapphire::Network::Packets::getSegmentHeader( const std::vecto
|
|||
return Success;
|
||||
}
|
||||
|
||||
PacketParseResult Sapphire::Network::Packets::getPackets( const std::vector< uint8_t >& buffer,
|
||||
PacketParseResult Network::Packets::getPackets( const std::vector< uint8_t >& buffer,
|
||||
const uint32_t offset,
|
||||
const FFXIVARR_PACKET_HEADER& packetHeader,
|
||||
std::vector< FFXIVARR_PACKET_RAW >& packets )
|
||||
|
@ -81,7 +82,7 @@ PacketParseResult Sapphire::Network::Packets::getPackets( const std::vector< uin
|
|||
return Success;
|
||||
}
|
||||
|
||||
PacketParseResult Sapphire::Network::Packets::getPacket( const std::vector< uint8_t >& buffer, const uint32_t offset,
|
||||
PacketParseResult Network::Packets::getPacket( const std::vector< uint8_t >& buffer, const uint32_t offset,
|
||||
FFXIVARR_PACKET_RAW& packet )
|
||||
{
|
||||
// Copy segment header
|
||||
|
@ -103,7 +104,7 @@ PacketParseResult Sapphire::Network::Packets::getPacket( const std::vector< uint
|
|||
return Success;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::Packets::checkHeader( const FFXIVARR_PACKET_HEADER& header )
|
||||
bool Network::Packets::checkHeader( const FFXIVARR_PACKET_HEADER& header )
|
||||
{
|
||||
// Max size of the packet is capped at 1MB for now.
|
||||
if( header.size > 1 * 1024 * 1024 )
|
||||
|
@ -116,7 +117,7 @@ bool Sapphire::Network::Packets::checkHeader( const FFXIVARR_PACKET_HEADER& head
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::Packets::checkSegmentHeader( const FFXIVARR_PACKET_SEGMENT_HEADER& header )
|
||||
bool Network::Packets::checkSegmentHeader( const FFXIVARR_PACKET_SEGMENT_HEADER& header )
|
||||
{
|
||||
// Max size of individual message is capped at 256KB for now.
|
||||
if( header.size > 256 * 1024 )
|
||||
|
|
|
@ -2,41 +2,43 @@
|
|||
#include <functional>
|
||||
#include "Hive.h"
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Sapphire::Network::Hive::Hive() :
|
||||
Network::Hive::Hive() :
|
||||
m_work_ptr( new asio::io_service::work( m_io_service ) ),
|
||||
m_shutdown( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
Sapphire::Network::Hive::~Hive()
|
||||
Network::Hive::~Hive()
|
||||
{
|
||||
}
|
||||
|
||||
asio::io_service& Sapphire::Network::Hive::getService()
|
||||
asio::io_service& Network::Hive::getService()
|
||||
{
|
||||
return m_io_service;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::Hive::hasStopped()
|
||||
bool Network::Hive::hasStopped()
|
||||
{
|
||||
uint32_t v1 = 1;
|
||||
uint32_t v2 = 1;
|
||||
return m_shutdown.compare_exchange_strong( v1, v2 );
|
||||
}
|
||||
|
||||
void Sapphire::Network::Hive::poll()
|
||||
void Network::Hive::poll()
|
||||
{
|
||||
m_io_service.poll();
|
||||
}
|
||||
|
||||
void Sapphire::Network::Hive::run()
|
||||
void Network::Hive::run()
|
||||
{
|
||||
m_io_service.run();
|
||||
}
|
||||
|
||||
void Sapphire::Network::Hive::stop()
|
||||
void Network::Hive::stop()
|
||||
{
|
||||
uint32_t v1 = 1;
|
||||
uint32_t v2 = 0;
|
||||
|
@ -48,7 +50,7 @@ void Sapphire::Network::Hive::stop()
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::Hive::reset()
|
||||
void Network::Hive::reset()
|
||||
{
|
||||
uint32_t v1 = 0;
|
||||
uint32_t v2 = 1;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace Sapphire:: Network
|
||||
namespace Sapphire::Network
|
||||
{
|
||||
|
||||
class Hive : public std::enable_shared_from_this< Hive >
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include <string.h>
|
||||
#include <memory>
|
||||
|
||||
Sapphire::Network::Packets::PacketContainer::PacketContainer( uint32_t segmentTargetOverride ) :
|
||||
using namespace Sapphire;
|
||||
|
||||
Network::Packets::PacketContainer::PacketContainer( uint32_t segmentTargetOverride ) :
|
||||
m_segmentTargetOverride( segmentTargetOverride )
|
||||
{
|
||||
memset( &m_ipcHdr, 0, sizeof( FFXIVARR_PACKET_HEADER ) );
|
||||
|
@ -15,12 +17,12 @@ Sapphire::Network::Packets::PacketContainer::PacketContainer( uint32_t segmentTa
|
|||
m_ipcHdr.count = 0;
|
||||
}
|
||||
|
||||
Sapphire::Network::Packets::PacketContainer::~PacketContainer()
|
||||
Network::Packets::PacketContainer::~PacketContainer()
|
||||
{
|
||||
m_entryList.clear();
|
||||
}
|
||||
|
||||
void Sapphire::Network::Packets::PacketContainer::addPacket( Sapphire::Network::Packets::FFXIVPacketBasePtr entry )
|
||||
void Network::Packets::PacketContainer::addPacket( Network::Packets::FFXIVPacketBasePtr entry )
|
||||
{
|
||||
m_entryList.push_back( entry );
|
||||
|
||||
|
@ -28,7 +30,7 @@ void Sapphire::Network::Packets::PacketContainer::addPacket( Sapphire::Network::
|
|||
m_ipcHdr.count++;
|
||||
}
|
||||
|
||||
void Sapphire::Network::Packets::PacketContainer::fillSendBuffer( std::vector< uint8_t >& sendBuffer )
|
||||
void Network::Packets::PacketContainer::fillSendBuffer( std::vector< uint8_t >& sendBuffer )
|
||||
{
|
||||
std::vector< uint8_t > tempBuffer( m_ipcHdr.size );
|
||||
memset( &tempBuffer[ 0 ], 0, m_ipcHdr.size );
|
||||
|
@ -67,7 +69,7 @@ void Sapphire::Network::Packets::PacketContainer::fillSendBuffer( std::vector< u
|
|||
|
||||
}
|
||||
|
||||
std::string Sapphire::Network::Packets::PacketContainer::toString()
|
||||
std::string Network::Packets::PacketContainer::toString()
|
||||
{
|
||||
std::vector< uint8_t > tmpBuffer;
|
||||
|
||||
|
@ -76,7 +78,7 @@ std::string Sapphire::Network::Packets::PacketContainer::toString()
|
|||
std::string str = "\n";
|
||||
for( uint32_t i = 0; i < m_ipcHdr.size; i++ )
|
||||
{
|
||||
str += Util::intToHexString( static_cast< int32_t >( tmpBuffer[ i ] & 0xFF ) ) + " ";
|
||||
str += Common::Util::intToHexString( static_cast< int32_t >( tmpBuffer[ i ] & 0xFF ) ) + " ";
|
||||
|
||||
if( ( i + 1 ) % 16 == 0 )
|
||||
str += "\n";
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
#include <Common.h>
|
||||
#include <Network/CommonNetwork.h>
|
||||
|
||||
namespace Sapphire {
|
||||
namespace Network {
|
||||
namespace Packets {
|
||||
namespace Server {
|
||||
namespace Sapphire::Network::Packets::Server
|
||||
{
|
||||
|
||||
/**
|
||||
* Structural representation of the packet sent by the server as response
|
||||
|
@ -31,10 +29,7 @@ struct FFXIVIpcTellErrNotFound : FFXIVIpcBasePacket< TellErrNotFound >
|
|||
char receipientName[32];
|
||||
};
|
||||
|
||||
} /* Server */
|
||||
} /* Packets */
|
||||
} /* Network */
|
||||
} /* Sapphire */
|
||||
} /* Sapphire::Common::Network::Packets::Server */
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
#include <Common.h>
|
||||
#include <Network/CommonNetwork.h>
|
||||
|
||||
namespace Sapphire {
|
||||
namespace Network {
|
||||
namespace Packets {
|
||||
namespace Server {
|
||||
namespace Sapphire::Network::Packets::Server {
|
||||
|
||||
struct FFXIVIpcRetainerList :
|
||||
FFXIVIpcBasePacket< LobbyRetainerList >
|
||||
|
@ -152,7 +149,5 @@ struct FFXIVIpcLobbyError : FFXIVIpcBasePacket< LobbyError >
|
|||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
#include <Common.h>
|
||||
#include <Network/CommonNetwork.h>
|
||||
|
||||
namespace Sapphire {
|
||||
namespace Network {
|
||||
namespace Packets {
|
||||
namespace Client {
|
||||
namespace Sapphire::Network::Packets::Client
|
||||
{
|
||||
|
||||
struct FFXIVIpcGmCommand1 :
|
||||
FFXIVIpcBasePacket< GMCommand1 >
|
||||
|
@ -325,9 +323,6 @@ struct FFXIVIpcMarketBoardRequestItemListingInfo :
|
|||
/* 0000 */ uint32_t requestId;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_CORE_NETWORK_PACKETS_ZONE_CLIENT_IPC_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
|
||||
template< class T >
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
|
||||
template< typename T >
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <unordered_map>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Sapphire::Util
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
|
||||
template< typename T, typename ActorIdType = uint32_t >
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
std::string Sapphire::Util::binaryToHexString( uint8_t* pBinData, uint16_t size )
|
||||
using namespace Sapphire::Common;
|
||||
|
||||
std::string Util::binaryToHexString( uint8_t* pBinData, uint16_t size )
|
||||
{
|
||||
std::string outStr;
|
||||
|
||||
|
@ -17,26 +19,26 @@ std::string Sapphire::Util::binaryToHexString( uint8_t* pBinData, uint16_t size
|
|||
return outStr;
|
||||
|
||||
}
|
||||
std::string Sapphire::Util::toLowerCopy( const std::string& inStr )
|
||||
std::string Util::toLowerCopy( const std::string& inStr )
|
||||
{
|
||||
std::string out = inStr;
|
||||
std::transform( inStr.begin(), inStr.end(), out.begin(), [](unsigned char c) -> unsigned char { return ::tolower(c); });
|
||||
return out;
|
||||
}
|
||||
|
||||
void Sapphire::Util::eraseAll( std::string& inOutStr, char remove )
|
||||
void Util::eraseAll( std::string& inOutStr, char remove )
|
||||
{
|
||||
inOutStr.erase( std::remove( inOutStr.begin(), inOutStr.end(), remove ), inOutStr.end() );
|
||||
}
|
||||
|
||||
void Sapphire::Util::eraseAllIn( std::string& inOutStr, std::string& remove )
|
||||
void Util::eraseAllIn( std::string& inOutStr, std::string& remove )
|
||||
{
|
||||
for( auto rem : remove )
|
||||
inOutStr.erase( std::remove( inOutStr.begin(), inOutStr.end(), rem ), inOutStr.end() );
|
||||
}
|
||||
|
||||
|
||||
std::string Sapphire::Util::intToHexString( uint64_t intValue, uint8_t width )
|
||||
std::string Util::intToHexString( uint64_t intValue, uint8_t width )
|
||||
{
|
||||
std::string hexStr;
|
||||
|
||||
|
@ -51,7 +53,7 @@ std::string Sapphire::Util::intToHexString( uint64_t intValue, uint8_t width )
|
|||
return hexStr;
|
||||
}
|
||||
|
||||
std::string Sapphire::Util::binaryToHexDump( uint8_t* pBinData, uint16_t size )
|
||||
std::string Util::binaryToHexDump( uint8_t* pBinData, uint16_t size )
|
||||
{
|
||||
int bytesPerLine = 16;
|
||||
constexpr char hexChars[] = "0123456789ABCDEF";
|
||||
|
@ -112,25 +114,25 @@ std::string Sapphire::Util::binaryToHexDump( uint8_t* pBinData, uint16_t size )
|
|||
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Util::getTimeMs()
|
||||
uint64_t Util::getTimeMs()
|
||||
{
|
||||
std::chrono::milliseconds epoch = std::chrono::duration_cast< std::chrono::milliseconds >
|
||||
( std::chrono::system_clock::now().time_since_epoch() );
|
||||
return epoch.count();
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Util::getTimeSeconds()
|
||||
uint32_t Util::getTimeSeconds()
|
||||
{
|
||||
auto currClock = std::chrono::system_clock::now();
|
||||
return std::chrono::time_point_cast< std::chrono::seconds >( currClock ).time_since_epoch().count();
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Util::getEorzeanTimeStamp()
|
||||
uint64_t Util::getEorzeanTimeStamp()
|
||||
{
|
||||
return static_cast< uint64_t >( getTimeSeconds() * 20.571428571428573f );
|
||||
}
|
||||
|
||||
void Sapphire::Util::valueToFlagByteIndexValue( uint32_t inVal, uint8_t& outVal, uint16_t& outIndex )
|
||||
void Util::valueToFlagByteIndexValue( uint32_t inVal, uint8_t& outVal, uint16_t& outIndex )
|
||||
{
|
||||
uint32_t id = inVal;
|
||||
outIndex = id / 8;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace Sapphire::Util
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
|
||||
std::string binaryToHexString( uint8_t* pBinData, uint16_t size );
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include <cmath>
|
||||
#include "UtilMath.h"
|
||||
|
||||
float Sapphire::Util::distanceSq( float x, float y, float z, float x1, float y1, float z1 )
|
||||
using namespace Sapphire::Common;
|
||||
|
||||
float Util::distanceSq( float x, float y, float z, float x1, float y1, float z1 )
|
||||
{
|
||||
float deltaX = x - x1;
|
||||
float deltaY = y - y1;
|
||||
|
@ -10,29 +12,30 @@ float Sapphire::Util::distanceSq( float x, float y, float z, float x1, float y1,
|
|||
return ( deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ );
|
||||
}
|
||||
|
||||
float Sapphire::Util::distance( float x, float y, float z, float x1, float y1, float z1 )
|
||||
float Util::distance( float x, float y, float z, float x1, float y1, float z1 )
|
||||
{
|
||||
return sqrtf( distanceSq( x, y, z, x1, y1, z1 ) );
|
||||
}
|
||||
|
||||
float Sapphire::Util::distance( const Common::FFXIVARR_POSITION3& pos1, const Common::FFXIVARR_POSITION3& pos2 )
|
||||
float Util::distance( const Sapphire::Common::FFXIVARR_POSITION3& pos1,
|
||||
const Sapphire::Common::FFXIVARR_POSITION3& pos2 )
|
||||
{
|
||||
return sqrtf( distanceSq( pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z ) );
|
||||
}
|
||||
|
||||
float Sapphire::Util::distance2DSq( float x, float y, float x1, float y1 )
|
||||
float Util::distance2DSq( float x, float y, float x1, float y1 )
|
||||
{
|
||||
float deltaX = x - x1;
|
||||
float deltaY = y - y1;
|
||||
return ( deltaX * deltaX + deltaY * deltaY );
|
||||
}
|
||||
|
||||
float Sapphire::Util::distance2D( float x, float y, float x1, float y1 )
|
||||
float Util::distance2D( float x, float y, float x1, float y1 )
|
||||
{
|
||||
return sqrtf( distance2DSq( x, y, x1, y1 ) );
|
||||
}
|
||||
|
||||
float Sapphire::Util::calcAngTo( float x, float y, float x1, float y1 )
|
||||
float Util::calcAngTo( float x, float y, float x1, float y1 )
|
||||
{
|
||||
float dx = x - x1;
|
||||
float dy = y - y1;
|
||||
|
@ -46,7 +49,7 @@ float Sapphire::Util::calcAngTo( float x, float y, float x1, float y1 )
|
|||
}
|
||||
}
|
||||
|
||||
float Sapphire::Util::calcAngFrom( float x, float y, float x1, float y1 )
|
||||
float Util::calcAngFrom( float x, float y, float x1, float y1 )
|
||||
{
|
||||
float dx = x - x1;
|
||||
float dy = y - y1;
|
||||
|
@ -60,17 +63,17 @@ float Sapphire::Util::calcAngFrom( float x, float y, float x1, float y1 )
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Util::floatToUInt16( float val )
|
||||
uint16_t Util::floatToUInt16( float val )
|
||||
{
|
||||
return static_cast< uint16_t >( 0x8000 + val * 32.767f );
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Util::floatToUInt16Rot( float val )
|
||||
uint16_t Util::floatToUInt16Rot( float val )
|
||||
{
|
||||
return static_cast< uint16_t >( 0x8000 * ( ( val + PI ) ) / PI );
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Util::floatToUInt8Rot( float val )
|
||||
uint8_t Util::floatToUInt8Rot( float val )
|
||||
{
|
||||
return static_cast< uint8_t >( 0x80 * ( ( val + PI ) ) / PI );
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#define PI 3.14159265358979323846f
|
||||
|
||||
namespace Sapphire::Util
|
||||
namespace Sapphire::Common::Util
|
||||
{
|
||||
|
||||
float distanceSq( float x, float y, float z, float x1, float y1, float z1 );
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#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;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#include "Version.h"
|
||||
|
||||
namespace Sapphire {
|
||||
namespace Version {
|
||||
namespace Sapphire::Version
|
||||
{
|
||||
|
||||
const std::string GIT_HASH = "@GIT_SHA1@";
|
||||
const std::string VERSION = "@VERSION@";
|
||||
const std::string GIT_HASH = "@GIT_SHA1@";
|
||||
const std::string VERSION = "@VERSION@";
|
||||
|
||||
} /* Version */
|
||||
} /* Sapphire */
|
||||
} /* Sapphire::Version */
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -13,8 +13,14 @@ return std::make_shared< x >( std::forward< Args >( args ) ... ); }\
|
|||
typedef std::vector< x > x ## PtrList;
|
||||
|
||||
namespace Sapphire
|
||||
{
|
||||
TYPE_FORWARD( Framework );
|
||||
}
|
||||
|
||||
namespace Sapphire::Lobby
|
||||
{
|
||||
TYPE_FORWARD( LobbySession );
|
||||
TYPE_FORWARD( GameConnection );
|
||||
}
|
||||
|
||||
namespace Sapphire::Network
|
||||
|
@ -22,7 +28,6 @@ namespace Sapphire::Network
|
|||
TYPE_FORWARD( Hive );
|
||||
TYPE_FORWARD( Acceptor );
|
||||
TYPE_FORWARD( Connection );
|
||||
TYPE_FORWARD( GameConnection );
|
||||
}
|
||||
|
||||
namespace Sapphire::Network::Packets
|
||||
|
|
|
@ -15,30 +15,32 @@
|
|||
#include "RestConnector.h"
|
||||
#include "LobbySession.h"
|
||||
|
||||
extern Sapphire::ServerLobby g_serverLobby;
|
||||
extern Sapphire::Network::RestConnector g_restConnector;
|
||||
#include "Forwards.h"
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
|
||||
Sapphire::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pHive,
|
||||
Sapphire::Network::AcceptorPtr pAcceptor,
|
||||
FrameworkPtr pFw ) :
|
||||
Connection( pHive, pFw ),
|
||||
extern Lobby::ServerLobby g_serverLobby;
|
||||
extern Lobby::RestConnector g_restConnector;
|
||||
|
||||
Lobby::GameConnection::GameConnection( Sapphire::Network::HivePtr pHive,
|
||||
Sapphire::Network::AcceptorPtr pAcceptor,
|
||||
FrameworkPtr pFw ) :
|
||||
Sapphire::Network::Connection( pHive, pFw ),
|
||||
m_pAcceptor( pAcceptor ),
|
||||
m_bEncryptionInitialized( false )
|
||||
{
|
||||
}
|
||||
|
||||
Sapphire::Network::GameConnection::~GameConnection()
|
||||
Lobby::GameConnection::~GameConnection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// overwrite the parents onConnect for our game socket needs
|
||||
void Sapphire::Network::GameConnection::onAccept( const std::string& host, uint16_t port )
|
||||
void Lobby::GameConnection::onAccept( const std::string& host, uint16_t port )
|
||||
{
|
||||
auto connection = make_GameConnection( m_hive, m_pAcceptor, m_pFw );
|
||||
m_pAcceptor->accept( connection );
|
||||
|
@ -47,17 +49,17 @@ void Sapphire::Network::GameConnection::onAccept( const std::string& host, uint1
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Network::GameConnection::onDisconnect()
|
||||
void Lobby::GameConnection::onDisconnect()
|
||||
{
|
||||
Logger::debug( "DISCONNECT" );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
||||
void Lobby::GameConnection::onRecv( std::vector< uint8_t >& 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.
|
||||
Packets::FFXIVARR_PACKET_HEADER packetHeader{};
|
||||
const auto headerResult = Packets::getHeader( m_packets, 0, packetHeader );
|
||||
FFXIVARR_PACKET_HEADER packetHeader{};
|
||||
const auto headerResult = getHeader( m_packets, 0, packetHeader );
|
||||
|
||||
if( headerResult == Incomplete )
|
||||
return;
|
||||
|
@ -70,9 +72,9 @@ void Sapphire::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
|||
}
|
||||
|
||||
// Dissect packet list
|
||||
std::vector< Packets::FFXIVARR_PACKET_RAW > packetList;
|
||||
const auto packetResult = Packets::getPackets( m_packets, sizeof( struct FFXIVARR_PACKET_HEADER ),
|
||||
packetHeader, packetList );
|
||||
std::vector< FFXIVARR_PACKET_RAW > packetList;
|
||||
const auto packetResult = getPackets( m_packets, sizeof( struct FFXIVARR_PACKET_HEADER ),
|
||||
packetHeader, packetList );
|
||||
|
||||
if( packetResult == Incomplete )
|
||||
return;
|
||||
|
@ -90,31 +92,31 @@ void Sapphire::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::onError( const asio::error_code& error )
|
||||
void Lobby::GameConnection::onError( const asio::error_code& error )
|
||||
{
|
||||
Logger::info( "GameConnection closed: {0}", error.message() );
|
||||
}
|
||||
|
||||
void
|
||||
Sapphire::Network::GameConnection::sendError( uint64_t sequence, uint32_t errorcode, uint16_t messageId, uint32_t tmpId )
|
||||
Lobby::GameConnection::sendError( uint64_t sequence, uint32_t errorcode, uint16_t messageId, uint32_t tmpId )
|
||||
{
|
||||
auto errorPacket = makeLobbyPacket< FFXIVIpcLobbyError >( tmpId );
|
||||
errorPacket->data().seq = sequence;
|
||||
errorPacket->data().error_id = errorcode;
|
||||
errorPacket->data().message_id = messageId;
|
||||
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
pRP.addPacket( errorPacket );
|
||||
sendPacket( pRP );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
void Lobby::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
{
|
||||
uint64_t sequence = *reinterpret_cast< uint64_t* >( &packet.data[ 0 ] + 0x10 );
|
||||
Logger::info( "Sequence [{0}]", sequence );
|
||||
|
||||
Logger::info( "[{0}] ReqCharList", m_pSession->getAccountID() );
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
|
||||
auto serverListPacket = makeLobbyPacket< FFXIVIpcServerList >( tmpId );
|
||||
serverListPacket->data().seq = 1;
|
||||
|
@ -185,14 +187,14 @@ void Sapphire::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet
|
|||
charListPacket->data().counter = ( i * 4 ) + 1;
|
||||
charListPacket->data().unknown4 = 128;
|
||||
}
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
pRP.addPacket( charListPacket );
|
||||
sendPacket( pRP );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
void Lobby::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
{
|
||||
uint64_t sequence = *reinterpret_cast< uint64_t* >( &packet.data[ 0 ] + 0x10 );
|
||||
Logger::info( "Sequence [{0}]", sequence );
|
||||
|
@ -221,7 +223,7 @@ void Sapphire::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet,
|
|||
|
||||
Logger::info( "[{0}] Logging in as {1} ({2})", m_pSession->getAccountID(), logInCharName, logInCharId );
|
||||
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
|
||||
auto enterWorldPacket = makeLobbyPacket< FFXIVIpcEnterWorld >( tmpId );
|
||||
enterWorldPacket->data().contentId = lookupId;
|
||||
|
@ -234,7 +236,7 @@ void Sapphire::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet,
|
|||
sendPacket( pRP );
|
||||
}
|
||||
|
||||
bool Sapphire::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
bool Lobby::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
{
|
||||
LobbySessionPtr pSession = g_serverLobby.getSession( ( char* ) &packet.data[ 0 ] + 0x22 );
|
||||
|
||||
|
@ -259,7 +261,7 @@ bool Sapphire::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_
|
|||
serviceIdInfoPacket->data().u2 = 0x99;
|
||||
serviceIdInfoPacket->data().serviceAccount[ 0 ].id = 0x002E4A2B;
|
||||
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
pRP.addPacket( serviceIdInfoPacket );
|
||||
sendPacket( pRP );
|
||||
}
|
||||
|
@ -273,7 +275,7 @@ bool Sapphire::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
bool Lobby::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& packet, uint32_t tmpId )
|
||||
{
|
||||
uint64_t sequence = *reinterpret_cast< uint64_t* >( &packet.data[ 0 ] + 0x10 );
|
||||
uint8_t type = *reinterpret_cast< uint8_t* >( &packet.data[ 0 ] + 0x29 );
|
||||
|
@ -292,7 +294,7 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
|
|||
|
||||
Logger::info( "[{0}] Type 1: {1}", m_pSession->getAccountID(), name );
|
||||
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
|
||||
m_pSession->newCharName = name;
|
||||
|
||||
|
@ -323,7 +325,7 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
|
|||
if( g_restConnector.createCharacter( ( char* ) m_pSession->getSessionId(), m_pSession->newCharName, charDetails ) !=
|
||||
-1 )
|
||||
{
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
|
||||
auto charCreatePacket = makeLobbyPacket< FFXIVIpcCharCreate >( tmpId );
|
||||
charCreatePacket->data().content_id = newContentId;
|
||||
|
@ -365,7 +367,7 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
|
|||
charCreatePacket->data().unknown_7 = 1;
|
||||
charCreatePacket->data().unknown_8 = 1;
|
||||
|
||||
Packets::LobbyPacketContainer pRP( m_encKey );
|
||||
LobbyPacketContainer pRP( m_encKey );
|
||||
pRP.addPacket( charCreatePacket );
|
||||
sendPacket( pRP );
|
||||
}
|
||||
|
@ -381,7 +383,7 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
|
|||
return false;
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::handleGamePacket( Packets::FFXIVARR_PACKET_RAW& packet )
|
||||
void Lobby::GameConnection::handleGamePacket( Network::Packets::FFXIVARR_PACKET_RAW& packet )
|
||||
{
|
||||
|
||||
uint32_t tmpId = packet.segHdr.target_actor;
|
||||
|
@ -419,7 +421,7 @@ void Sapphire::Network::GameConnection::handleGamePacket( Packets::FFXIVARR_PACK
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::sendPacket( Packets::LobbyPacketContainer& pLpc )
|
||||
void Lobby::GameConnection::sendPacket( LobbyPacketContainer& pLpc )
|
||||
{
|
||||
uint16_t size = pLpc.getSize();
|
||||
uint8_t* dataPtr = pLpc.getRawData( false );
|
||||
|
@ -428,7 +430,7 @@ void Sapphire::Network::GameConnection::sendPacket( Packets::LobbyPacketContaine
|
|||
send( sendBuffer );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::sendPackets( Packets::PacketContainer* pPacket )
|
||||
void Lobby::GameConnection::sendPackets( Network::Packets::PacketContainer* pPacket )
|
||||
{
|
||||
std::vector< uint8_t > sendBuffer;
|
||||
|
||||
|
@ -436,14 +438,14 @@ void Sapphire::Network::GameConnection::sendPackets( Packets::PacketContainer* p
|
|||
send( sendBuffer );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::sendSinglePacket( FFXIVPacketBasePtr pPacket )
|
||||
void Lobby::GameConnection::sendSinglePacket( FFXIVPacketBasePtr pPacket )
|
||||
{
|
||||
PacketContainer pRP = PacketContainer();
|
||||
pRP.addPacket( pPacket );
|
||||
sendPackets( &pRP );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::generateEncryptionKey( uint32_t key, const std::string& keyPhrase )
|
||||
void Lobby::GameConnection::generateEncryptionKey( uint32_t key, const std::string& keyPhrase )
|
||||
{
|
||||
memset( m_baseKey, 0, 0x2C );
|
||||
m_baseKey[ 0 ] = 0x78;
|
||||
|
@ -454,11 +456,11 @@ void Sapphire::Network::GameConnection::generateEncryptionKey( uint32_t key, con
|
|||
m_baseKey[ 8 ] = 0xC6;
|
||||
m_baseKey[ 9 ] = 0x11;
|
||||
memcpy( ( char* ) m_baseKey + 0x0C, keyPhrase.c_str(), keyPhrase.size() );
|
||||
Sapphire::Util::md5( m_baseKey, m_encKey, 0x2C );
|
||||
Common::Util::md5( m_baseKey, m_encKey, 0x2C );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||
const std::vector< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
||||
void Lobby::GameConnection::handlePackets( const Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||
const std::vector< Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
||||
{
|
||||
|
||||
for( auto inPacket : packetData )
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
#define DECLARE_HANDLER( x ) void x( Packets::GamePacketPtr pInPacket, Entity::PlayerPtr pPlayer )
|
||||
|
||||
namespace Sapphire::Network
|
||||
namespace Sapphire::Lobby
|
||||
{
|
||||
|
||||
class GameConnection : public Connection
|
||||
class GameConnection : public Network::Connection
|
||||
{
|
||||
|
||||
private:
|
||||
|
@ -32,16 +32,16 @@ namespace Sapphire::Network
|
|||
|
||||
bool m_bEncryptionInitialized;
|
||||
|
||||
AcceptorPtr m_pAcceptor;
|
||||
Network::AcceptorPtr m_pAcceptor;
|
||||
|
||||
LobbySessionPtr m_pSession;
|
||||
|
||||
LockedQueue< Packets::GamePacketPtr > m_inQueue;
|
||||
LockedQueue< Packets::GamePacketPtr > m_outQueue;
|
||||
Common::Util::LockedQueue< Network::Packets::GamePacketPtr > m_inQueue;
|
||||
Common::Util::LockedQueue< Network::Packets::GamePacketPtr > m_outQueue;
|
||||
std::vector< uint8_t > m_packets;
|
||||
|
||||
public:
|
||||
GameConnection( HivePtr pHive, AcceptorPtr pAcceptor, FrameworkPtr pFw );
|
||||
GameConnection( Network::HivePtr pHive, Network::AcceptorPtr pAcceptor, FrameworkPtr pFw );
|
||||
|
||||
~GameConnection();
|
||||
|
||||
|
@ -58,26 +58,26 @@ namespace Sapphire::Network
|
|||
|
||||
void sendError( uint64_t sequence, uint32_t errorcode, uint16_t messageId, uint32_t tmpId );
|
||||
|
||||
void getCharList( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
void getCharList( Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
|
||||
void enterWorld( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
void enterWorld( Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
|
||||
bool sendServiceAccountList( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
bool sendServiceAccountList( Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
|
||||
bool createOrModifyChar( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
bool createOrModifyChar( Network::Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
|
||||
|
||||
void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||
const std::vector< Packets::FFXIVARR_PACKET_RAW >& packetData );
|
||||
void handlePackets( const Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||
const std::vector< Network::Packets::FFXIVARR_PACKET_RAW >& packetData );
|
||||
|
||||
void handleGamePacket( Packets::FFXIVARR_PACKET_RAW& pPacket );
|
||||
void handleGamePacket( Network::Packets::FFXIVARR_PACKET_RAW& pPacket );
|
||||
|
||||
void handlePacket( Packets::FFXIVPacketBasePtr pPacket );
|
||||
void handlePacket( Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||
|
||||
void sendPackets( Packets::PacketContainer* pPacket );
|
||||
void sendPackets( Network::Packets::PacketContainer* pPacket );
|
||||
|
||||
void sendPacket( Packets::LobbyPacketContainer& pLpc );
|
||||
void sendPacket( Network::Packets::LobbyPacketContainer& pLpc );
|
||||
|
||||
void sendSinglePacket( Packets::FFXIVPacketBasePtr pPacket );
|
||||
void sendSinglePacket( Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#include <Crypt/blowfish.h>
|
||||
#include <Common.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
||||
Sapphire::Network::Packets::LobbyPacketContainer::LobbyPacketContainer( uint8_t* encKey )
|
||||
LobbyPacketContainer::LobbyPacketContainer( uint8_t* encKey )
|
||||
{
|
||||
memset( &m_header, 0, sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER ) );
|
||||
m_header.size = sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER );
|
||||
|
@ -17,12 +18,12 @@ Sapphire::Network::Packets::LobbyPacketContainer::LobbyPacketContainer( uint8_t*
|
|||
memset( m_dataBuf, 0, 0x1570 );
|
||||
}
|
||||
|
||||
Sapphire::Network::Packets::LobbyPacketContainer::~LobbyPacketContainer()
|
||||
LobbyPacketContainer::~LobbyPacketContainer()
|
||||
{
|
||||
m_entryList.clear();
|
||||
}
|
||||
|
||||
void Sapphire::Network::Packets::LobbyPacketContainer::addPacket( FFXIVPacketBasePtr pEntry )
|
||||
void LobbyPacketContainer::addPacket( FFXIVPacketBasePtr pEntry )
|
||||
{
|
||||
memcpy( m_dataBuf + m_header.size, &pEntry->getData()[ 0 ], pEntry->getSize() );
|
||||
|
||||
|
@ -38,17 +39,17 @@ void Sapphire::Network::Packets::LobbyPacketContainer::addPacket( FFXIVPacketBas
|
|||
m_header.count++;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Network::Packets::LobbyPacketContainer::getSize() const
|
||||
uint16_t LobbyPacketContainer::getSize() const
|
||||
{
|
||||
return m_header.size;
|
||||
}
|
||||
|
||||
uint8_t* Sapphire::Network::Packets::LobbyPacketContainer::getRawData( bool addstuff )
|
||||
uint8_t* LobbyPacketContainer::getRawData( bool addstuff )
|
||||
{
|
||||
if( addstuff )
|
||||
{
|
||||
m_header.unknown_0 = 0xff41a05252;
|
||||
m_header.timestamp = Sapphire::Util::getTimeMs();
|
||||
m_header.timestamp = Common::Util::getTimeMs();
|
||||
}
|
||||
memcpy( m_dataBuf, &m_header, sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER ) );
|
||||
return m_dataBuf;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Sapphire::Network::Packets
|
||||
{
|
||||
|
||||
using FFXIVPacketBasePtr = std::shared_ptr< FFXIVPacketBase >;
|
||||
using FFXIVPacketBasePtr = std::shared_ptr< Sapphire::Network::Packets::FFXIVPacketBase >;
|
||||
|
||||
class LobbyPacketContainer
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "LobbySession.h"
|
||||
|
||||
namespace Sapphire {
|
||||
using namespace Sapphire::Lobby;
|
||||
|
||||
LobbySession::LobbySession( void )
|
||||
{
|
||||
//setSocket(NULL);
|
||||
|
@ -11,5 +12,4 @@ LobbySession::~LobbySession( void )
|
|||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Lobby
|
||||
{
|
||||
|
||||
class LobbySession
|
||||
|
|
|
@ -8,19 +8,21 @@
|
|||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
typedef std::vector< std::tuple< std::string, uint32_t, uint64_t, std::string > > CharList;
|
||||
|
||||
Sapphire::Network::RestConnector::RestConnector()
|
||||
Lobby::RestConnector::RestConnector()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Sapphire::Network::RestConnector::~RestConnector()
|
||||
Lobby::RestConnector::~RestConnector()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HttpResponse Sapphire::Network::RestConnector::requestApi( std::string endpoint, std::string data )
|
||||
HttpResponse Lobby::RestConnector::requestApi( std::string endpoint, std::string data )
|
||||
{
|
||||
HttpClient client( restHost );
|
||||
|
||||
|
@ -39,7 +41,7 @@ HttpResponse Sapphire::Network::RestConnector::requestApi( std::string endpoint,
|
|||
return r;
|
||||
}
|
||||
|
||||
Sapphire::LobbySessionPtr Sapphire::Network::RestConnector::getSession( char* sId )
|
||||
Lobby::LobbySessionPtr Lobby::RestConnector::getSession( char* sId )
|
||||
{
|
||||
std::string json_string = "{\"sId\": \"" + std::string( sId ) + "\",\"secret\": \"" + serverSecret + "\"}";
|
||||
|
||||
|
@ -65,7 +67,7 @@ Sapphire::LobbySessionPtr Sapphire::Network::RestConnector::getSession( char* sI
|
|||
|
||||
if( content.find( "invalid" ) == std::string::npos )
|
||||
{
|
||||
LobbySessionPtr pSession( new Sapphire::LobbySession() );
|
||||
LobbySessionPtr pSession( new Lobby::LobbySession() );
|
||||
pSession->setAccountID( json["result"].get< uint32_t >() );
|
||||
pSession->setSessionId( ( uint8_t* ) sId );
|
||||
return pSession;
|
||||
|
@ -81,7 +83,7 @@ Sapphire::LobbySessionPtr Sapphire::Network::RestConnector::getSession( char* sI
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Network::RestConnector::checkNameTaken( std::string name )
|
||||
bool Lobby::RestConnector::checkNameTaken( std::string name )
|
||||
{
|
||||
std::string json_string = "{\"name\": \"" + name + "\",\"secret\": \"" + serverSecret + "\"}";
|
||||
|
||||
|
@ -115,7 +117,7 @@ bool Sapphire::Network::RestConnector::checkNameTaken( std::string name )
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Network::RestConnector::getNextCharId()
|
||||
uint32_t Lobby::RestConnector::getNextCharId()
|
||||
{
|
||||
std::string json_string = "{\"secret\": \"" + serverSecret + "\"}";
|
||||
|
||||
|
@ -154,7 +156,7 @@ uint32_t Sapphire::Network::RestConnector::getNextCharId()
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Network::RestConnector::getNextContentId()
|
||||
uint64_t Lobby::RestConnector::getNextContentId()
|
||||
{
|
||||
std::string json_string = "{\"secret\": \"" + serverSecret + "\"}";
|
||||
|
||||
|
@ -193,7 +195,7 @@ uint64_t Sapphire::Network::RestConnector::getNextContentId()
|
|||
}
|
||||
}
|
||||
|
||||
CharList Sapphire::Network::RestConnector::getCharList( char* sId )
|
||||
CharList Lobby::RestConnector::getCharList( char* sId )
|
||||
{
|
||||
std::string json_string = "{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\"}";
|
||||
|
||||
|
@ -249,7 +251,7 @@ CharList Sapphire::Network::RestConnector::getCharList( char* sId )
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Network::RestConnector::deleteCharacter( char* sId, std::string name )
|
||||
bool Lobby::RestConnector::deleteCharacter( char* sId, std::string name )
|
||||
{
|
||||
std::string json_string =
|
||||
"{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name + "\"}";
|
||||
|
@ -283,11 +285,11 @@ bool Sapphire::Network::RestConnector::deleteCharacter( char* sId, std::string n
|
|||
}
|
||||
}
|
||||
|
||||
int Sapphire::Network::RestConnector::createCharacter( char* sId, std::string name, std::string infoJson )
|
||||
int Lobby::RestConnector::createCharacter( char* sId, std::string name, std::string infoJson )
|
||||
{
|
||||
std::string json_string =
|
||||
"{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name +
|
||||
"\",\"infoJson\": \"" + Sapphire::Util::base64Encode( ( uint8_t* ) infoJson.c_str(), infoJson.length() ) + "\"}";
|
||||
"\",\"infoJson\": \"" + Common::Util::base64Encode( ( uint8_t* ) infoJson.c_str(), infoJson.length() ) + "\"}";
|
||||
|
||||
HttpResponse r = requestApi( "createCharacter", json_string );
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Sapphire
|
|||
class Session;
|
||||
}
|
||||
|
||||
namespace Sapphire::Network
|
||||
namespace Sapphire::Lobby
|
||||
{
|
||||
class LobbySession;
|
||||
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
|
||||
#include <thread>
|
||||
|
||||
Sapphire::Network::RestConnector g_restConnector;
|
||||
using namespace Sapphire;
|
||||
|
||||
namespace Sapphire
|
||||
Sapphire::Lobby::RestConnector g_restConnector;
|
||||
|
||||
namespace Sapphire::Lobby
|
||||
{
|
||||
|
||||
|
||||
|
@ -31,7 +33,7 @@ namespace Sapphire
|
|||
m_configPath( configPath ),
|
||||
m_numConnections( 0 )
|
||||
{
|
||||
m_pConfig = std::make_shared< ConfigMgr >();
|
||||
m_pConfig = std::make_shared< Sapphire::Common::ConfigMgr >();
|
||||
}
|
||||
|
||||
LobbySessionPtr ServerLobby::getSession( char* sessionId )
|
||||
|
@ -63,15 +65,15 @@ namespace Sapphire
|
|||
|
||||
Logger::setLogLevel( m_config.global.general.logLevel );
|
||||
|
||||
auto pFw = std::make_shared< Framework >();
|
||||
Network::HivePtr hive( new Network::Hive() );
|
||||
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive, pFw );
|
||||
auto pFw = make_Framework();
|
||||
auto hive = Network::make_Hive();
|
||||
Network::addServerToHive< GameConnection >( m_ip, m_port, hive, pFw );
|
||||
|
||||
Logger::info( "Lobby server running on {0}:{1}", m_ip, m_port );
|
||||
|
||||
std::vector< std::thread > threadGroup;
|
||||
|
||||
threadGroup.emplace_back( std::bind( &Network::Hive::run, hive.get() ) );
|
||||
threadGroup.emplace_back( std::bind( &Sapphire::Network::Hive::run, hive.get() ) );
|
||||
|
||||
for( auto& thread : threadGroup )
|
||||
if( thread.joinable() )
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
|
||||
const std::string LOBBY_VERSION = "0.0.5";
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::Common
|
||||
{
|
||||
class ConfigMgr;
|
||||
}
|
||||
|
||||
namespace Sapphire::Lobby
|
||||
{
|
||||
class LobbySession;
|
||||
class ConfigMgr;
|
||||
|
||||
using LobbySessionMap = std::map< std::string, LobbySessionPtr >;
|
||||
|
||||
|
@ -29,7 +33,7 @@ namespace Sapphire
|
|||
uint16_t m_port;
|
||||
std::string m_ip;
|
||||
|
||||
std::shared_ptr< ConfigMgr > m_pConfig;
|
||||
std::shared_ptr< Sapphire::Common::ConfigMgr > m_pConfig;
|
||||
|
||||
public:
|
||||
ServerLobby( const std::string& configPath );
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
class case_insensitive_equals {
|
||||
public:
|
||||
bool operator()(const std::string &key1, const std::string &key2) const {
|
||||
return Sapphire::Util::toLowerCopy( key1 ) == Sapphire::Util::toLowerCopy( key2 );
|
||||
return Sapphire::Common::Util::toLowerCopy( key1 ) == Sapphire::Common::Util::toLowerCopy( key2 );
|
||||
}
|
||||
};
|
||||
class case_insensitive_hash {
|
||||
public:
|
||||
size_t operator()( const std::string &key ) const
|
||||
size_t operator()( const std::string &key ) const
|
||||
{
|
||||
std::size_t seed=0;
|
||||
for( auto &c : key )
|
||||
Sapphire::Util::hashCombine< char >( seed, std::tolower( c ) );
|
||||
Sapphire::Common::Util::hashCombine< char >( seed, std::tolower( c ) );
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Sapphire::Common::Util::CrashHandler crashHandler;
|
||||
|
||||
Sapphire::ServerLobby g_serverLobby( "lobby.ini" );
|
||||
Sapphire::Lobby::ServerLobby g_serverLobby( "lobby.ini" );
|
||||
|
||||
int main( int32_t argc, char* argv[] )
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
void onExecute( Sapphire::World::Action::Action& action ) override
|
||||
{
|
||||
if( !action.getSourceChara()->isPlayer() )
|
||||
return;
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
void onExecute( Sapphire::World::Action::Action& action ) override
|
||||
{
|
||||
auto sourceChara = action.getSourceChara();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
void onExecute( Sapphire::World::Action::Action& action ) override
|
||||
{
|
||||
auto player = action.getSourceChara()->getAsPlayer();
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionHeavyShot97 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionHeavyShot97() :
|
||||
Sapphire::ScriptAPI::ActionScript( 97 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
if( auto player = action.getSourceChara()->getAsPlayer() )
|
||||
player->sendDebug( "Imagine you just hit an enemy for 150 potency. Incredible, right?" );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionHeavyShot97 );
|
|
@ -1,22 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionCure120 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionCure120() :
|
||||
Sapphire::ScriptAPI::ActionScript( 120 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionCure120 );
|
|
@ -1,24 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionAbyssalDrain3641 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionAbyssalDrain3641() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3641 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
for( auto& chara : action.getHitCharas() )
|
||||
{
|
||||
chara->takeDamage( chara->getMaxHp() * 0.5f );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionAbyssalDrain3641 );
|
|
@ -1,23 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionHardSlash3617 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionHardSlash3617() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3617 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
auto chara = action.getHitChara();
|
||||
chara->takeDamage( chara->getMaxHp() * 0.34f );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionHardSlash3617 );
|
|
@ -1,22 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionPowerSlash3627 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionPowerSlash3627() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3627 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionPowerSlash3627 );
|
|
@ -1,22 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionSpinningSlash3619 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionSpinningSlash3619() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3619 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionSpinningSlash3619 );
|
|
@ -1,22 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionSyphonStrike3623 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionSyphonStrike3623() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3623 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionSyphonStrike3623 );
|
|
@ -1,24 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionUnleash3621 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionUnleash3621() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3621 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
for( auto& chara : action.getHitCharas() )
|
||||
{
|
||||
chara->takeDamage( chara->getMaxHp() * 0.34f );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionUnleash3621 );
|
|
@ -1,22 +0,0 @@
|
|||
#include <Script/NativeScriptApi.h>
|
||||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
#include <Action/Action.h>
|
||||
|
||||
class ActionAsylum3569 :
|
||||
public Sapphire::ScriptAPI::ActionScript
|
||||
{
|
||||
public:
|
||||
ActionAsylum3569() :
|
||||
Sapphire::ScriptAPI::ActionScript( 3569 )
|
||||
{
|
||||
}
|
||||
|
||||
void onExecute( Sapphire::Action::Action& action ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ActionAsylum3569 );
|
|
@ -257,14 +257,14 @@ int main()
|
|||
// Logger::info( out );
|
||||
}
|
||||
|
||||
std::ifstream ifs( "ActionLut.cpp.tmpl" );
|
||||
std::ifstream ifs( "ActionLutData.cpp.tmpl" );
|
||||
|
||||
std::string actionTmpl( ( std::istreambuf_iterator< char >( ifs ) ),
|
||||
std::istreambuf_iterator< char >() );
|
||||
|
||||
auto result = std::regex_replace( actionTmpl, std::regex( "%INSERT_GARBAGE%" ), output );
|
||||
|
||||
std::ofstream outH( "ActionLut.cpp" );
|
||||
std::ofstream outH( "ActionLutData.cpp" );
|
||||
outH << result;
|
||||
outH.close();
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <ExdCat.h>
|
||||
#include <Exd.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
// garbage to ignore models
|
||||
bool ignoreModels = false;
|
||||
|
||||
|
@ -165,7 +167,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
info.name = teriName;
|
||||
zoneInfoMap[ row.first ] = info;
|
||||
|
||||
if( !found && ( Sapphire::Util::toLowerCopy( name ) == Sapphire::Util::toLowerCopy( teriName ) ) )
|
||||
if( !found && ( Common::Util::toLowerCopy( name ) == Common::Util::toLowerCopy( teriName ) ) )
|
||||
{
|
||||
found = true;
|
||||
path = teriPath;
|
||||
|
@ -177,7 +179,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
{
|
||||
for( const auto& entry : zoneInfoMap )
|
||||
{
|
||||
if( found = Sapphire::Util::toLowerCopy( name ) == Sapphire::Util::toLowerCopy( entry.second.name ) )
|
||||
if( found = Common::Util::toLowerCopy( name ) == Common::Util::toLowerCopy( entry.second.name ) )
|
||||
{
|
||||
path = entry.second.path;
|
||||
zoneId = entry.second.id;
|
||||
|
|
|
@ -62,7 +62,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
{
|
||||
std::string path;
|
||||
|
||||
auto it = g_nameMap.find( Sapphire::Util::toLowerCopy( name ) );
|
||||
auto it = g_nameMap.find( Common::Util::toLowerCopy( name ) );
|
||||
if( it != g_nameMap.end() )
|
||||
return it->second;
|
||||
|
||||
|
@ -79,7 +79,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
if( teriName.empty() )
|
||||
continue;
|
||||
|
||||
if( Sapphire::Util::toLowerCopy( name ) == Sapphire::Util::toLowerCopy( teriName ) )
|
||||
if( Common::Util::toLowerCopy( name ) == Common::Util::toLowerCopy( teriName ) )
|
||||
{
|
||||
path = teriPath;
|
||||
break;
|
||||
|
@ -90,7 +90,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
{
|
||||
path = std::string( "bg/" ) + path.substr( 0, path.find( "/level/" ) );
|
||||
Logger::debug( "Found path for {0}: {1}", name, path );
|
||||
g_nameMap[ Sapphire::Util::toLowerCopy( name ) ] = path;
|
||||
g_nameMap[ Common::Util::toLowerCopy( name ) ] = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ void loadAllInstanceContentEntries()
|
|||
name = name.replace( name.begin() + i, name.begin() + i + 1, { '_' } );
|
||||
|
||||
std::string remove = ",★_ '()[]-\xae\x1a\x1\x2\x1f\x1\x3.:";
|
||||
Sapphire::Util::eraseAllIn( name, remove );
|
||||
Common::Util::eraseAllIn( name, remove );
|
||||
name[ 0 ] = toupper( name[ 0 ] );
|
||||
contentList.push_back( { contentId, name, tt->name, type } );
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ int main( int argc, char* argv[] )
|
|||
{
|
||||
name = eobjNameMap[ id ];
|
||||
std::string remove = ",★_ '()[]-\xae\x1a\x1\x2\x1f\x1\x3.:";
|
||||
Sapphire::Util::eraseAllIn( name, remove );
|
||||
Common::Util::eraseAllIn( name, remove );
|
||||
name[ 0 ] = toupper( name[ 0 ] );
|
||||
}
|
||||
if( name.empty() )
|
||||
|
|
|
@ -55,7 +55,7 @@ std::string generateEnum( const std::string& exd, int8_t nameIndex, const std::s
|
|||
}
|
||||
|
||||
std::string remove = ",_-':!(){} \x02\x1f\x01\x03";
|
||||
Sapphire::Util::eraseAllIn( value, remove );
|
||||
Common::Util::eraseAllIn( value, remove );
|
||||
|
||||
value[ 0 ] = std::toupper( value[ 0 ] );
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ std::string binaryToHexString( uint8_t* pBinData, uint16_t size )
|
|||
|
||||
for( uint32_t i = 0; i < size; i++ )
|
||||
{
|
||||
outStr += Sapphire::Util::intToHexString( pBinData[ i ] & 0xFF );
|
||||
outStr += Common::Util::intToHexString( pBinData[ i ] & 0xFF );
|
||||
}
|
||||
|
||||
return outStr;
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <ExdCat.h>
|
||||
#include <Exd.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
// garbage to ignore models
|
||||
bool noObj = false;
|
||||
|
||||
|
@ -121,7 +123,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
if( teriName.empty() )
|
||||
continue;
|
||||
auto teriPath = std::get< std::string >( fields.at( static_cast< size_t >( TerritoryTypeExdIndexes::Path ) ) );
|
||||
if( !found && ( Sapphire::Util::toLowerCopy( name ) == Sapphire::Util::toLowerCopy( teriName ) ) )
|
||||
if( !found && ( Common::Util::toLowerCopy( name ) == Common::Util::toLowerCopy( teriName ) ) )
|
||||
{
|
||||
path = teriPath;
|
||||
found = true;
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <ExdCat.h>
|
||||
#include <Exd.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
// garbage to ignore models
|
||||
bool noObj = false;
|
||||
|
||||
|
@ -123,7 +125,7 @@ std::string zoneNameToPath( const std::string& name )
|
|||
if( teriName.empty() )
|
||||
continue;
|
||||
auto teriPath = std::get< std::string >( fields.at( static_cast< size_t >( TerritoryTypeExdIndexes::Path ) ) );
|
||||
if( !found && ( Sapphire::Util::toLowerCopy( name ) == Sapphire::Util::toLowerCopy( teriName ) ) )
|
||||
if( !found && ( Common::Util::toLowerCopy( name ) == Common::Util::toLowerCopy( teriName ) ) )
|
||||
{
|
||||
path = teriPath;
|
||||
found = true;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "Action.h"
|
||||
#include "ActionLut.h"
|
||||
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Util/Util.h>
|
||||
|
@ -20,39 +21,40 @@
|
|||
#include <Logging/Logger.h>
|
||||
#include <Util/ActorFilter.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
using namespace Sapphire::World;
|
||||
|
||||
|
||||
Sapphire::Action::Action::Action() = default;
|
||||
Sapphire::Action::Action::~Action() = default;
|
||||
Action::Action::Action() = default;
|
||||
Action::Action::~Action() = default;
|
||||
|
||||
Sapphire::Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, FrameworkPtr fw ) :
|
||||
Action( std::move( caster ), actionId, nullptr, std::move( fw ) )
|
||||
Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, FrameworkPtr fw ) :
|
||||
Action( std::move( caster ), actionId, nullptr, std::move( fw ) )
|
||||
{
|
||||
}
|
||||
|
||||
Sapphire::Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId,
|
||||
Data::ActionPtr actionData, FrameworkPtr fw ) :
|
||||
m_pSource( std::move( caster ) ),
|
||||
m_pFw( std::move( fw ) ),
|
||||
m_actionData( std::move( actionData ) ),
|
||||
m_id( actionId ),
|
||||
m_targetId( 0 ),
|
||||
m_startTime( 0 ),
|
||||
m_interruptType( Common::ActionInterruptType::None )
|
||||
Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, Data::ActionPtr actionData, FrameworkPtr fw ) :
|
||||
m_pSource( std::move( caster ) ),
|
||||
m_pFw( std::move( fw ) ),
|
||||
m_actionData( std::move( actionData ) ),
|
||||
m_id( actionId ),
|
||||
m_targetId( 0 ),
|
||||
m_startTime( 0 ),
|
||||
m_interruptType( Common::ActionInterruptType::None )
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Action::Action::getId() const
|
||||
uint32_t Action::Action::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::init()
|
||||
bool Action::Action::init()
|
||||
{
|
||||
if( !m_actionData )
|
||||
{
|
||||
|
@ -121,62 +123,62 @@ bool Sapphire::Action::Action::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
|
||||
void Action::Action::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
|
||||
{
|
||||
m_pos = pos;
|
||||
}
|
||||
|
||||
Sapphire::Common::FFXIVARR_POSITION3 Sapphire::Action::Action::getPos() const
|
||||
Sapphire::Common::FFXIVARR_POSITION3 Action::Action::getPos() const
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::setTargetId( uint64_t targetId )
|
||||
void Action::Action::setTargetId( uint64_t targetId )
|
||||
{
|
||||
m_targetId = targetId;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Action::Action::getTargetId() const
|
||||
uint64_t Action::Action::getTargetId() const
|
||||
{
|
||||
return m_targetId;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::hasClientsideTarget() const
|
||||
bool Action::Action::hasClientsideTarget() const
|
||||
{
|
||||
return m_targetId > 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::isInterrupted() const
|
||||
bool Action::Action::isInterrupted() const
|
||||
{
|
||||
return m_interruptType != Common::ActionInterruptType::None;
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::setInterrupted( Common::ActionInterruptType type )
|
||||
void Action::Action::setInterrupted( Common::ActionInterruptType type )
|
||||
{
|
||||
m_interruptType = type;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Action::Action::getCastTime() const
|
||||
uint32_t Action::Action::getCastTime() const
|
||||
{
|
||||
return m_castTimeMs;
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::setCastTime( uint32_t castTime )
|
||||
void Action::Action::setCastTime( uint32_t castTime )
|
||||
{
|
||||
m_castTimeMs = castTime;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::hasCastTime() const
|
||||
bool Action::Action::hasCastTime() const
|
||||
{
|
||||
return m_castTimeMs > 0;
|
||||
}
|
||||
|
||||
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getSourceChara() const
|
||||
Sapphire::Entity::CharaPtr Action::Action::getSourceChara() const
|
||||
{
|
||||
return m_pSource;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::update()
|
||||
bool Action::Action::update()
|
||||
{
|
||||
// action has not been started yet
|
||||
if( m_startTime == 0 )
|
||||
|
@ -193,7 +195,7 @@ bool Sapphire::Action::Action::update()
|
|||
// todo: check if the target is still in range
|
||||
}
|
||||
|
||||
uint64_t tickCount = Util::getTimeMs();
|
||||
uint64_t tickCount = Common::Util::getTimeMs();
|
||||
|
||||
if( !hasCastTime() || std::difftime( tickCount, m_startTime ) > m_castTimeMs )
|
||||
{
|
||||
|
@ -204,11 +206,11 @@ bool Sapphire::Action::Action::update()
|
|||
return false;
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::start()
|
||||
void Action::Action::start()
|
||||
{
|
||||
assert( m_pSource );
|
||||
|
||||
m_startTime = Util::getTimeMs();
|
||||
m_startTime = Common::Util::getTimeMs();
|
||||
|
||||
auto player = m_pSource->getAsPlayer();
|
||||
|
||||
|
@ -236,14 +238,16 @@ void Sapphire::Action::Action::start()
|
|||
player->queuePacket( actionStartPkt );
|
||||
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
if( !pScriptMgr->onStart( *this ) )
|
||||
|
||||
// check the lut too and see if we have something usable, otherwise cancel the cast
|
||||
if( !pScriptMgr->onStart( *this ) && !ActionLut::validEntryExists( getId() ) )
|
||||
{
|
||||
// script not implemented
|
||||
// script not implemented and insufficient lut data (no potencies)
|
||||
interrupt();
|
||||
|
||||
if( player )
|
||||
{
|
||||
player->sendUrgent( "Action not implemented, missing script for action#{0}", getId() );
|
||||
player->sendUrgent( "Action not implemented, missing script/lut entry for action#{0}", getId() );
|
||||
player->setCurrentAction( nullptr );
|
||||
}
|
||||
|
||||
|
@ -255,7 +259,7 @@ void Sapphire::Action::Action::start()
|
|||
execute();
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::interrupt()
|
||||
void Action::Action::interrupt()
|
||||
{
|
||||
assert( m_pSource );
|
||||
|
||||
|
@ -289,7 +293,7 @@ void Sapphire::Action::Action::interrupt()
|
|||
pScriptMgr->onInterrupt( *this );
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::execute()
|
||||
void Action::Action::execute()
|
||||
{
|
||||
assert( m_pSource );
|
||||
|
||||
|
@ -329,7 +333,17 @@ void Sapphire::Action::Action::execute()
|
|||
if( !m_hitActors.empty() )
|
||||
{
|
||||
// only call script if actors are hit
|
||||
pScriptMgr->onExecute( *this );
|
||||
if( !pScriptMgr->onExecute( *this ) && ActionLut::validEntryExists( getId() ) )
|
||||
{
|
||||
auto lutEntry = ActionLut::getEntry( getId() );
|
||||
|
||||
// no script exists but we have a valid lut entry
|
||||
if( auto player = getSourceChara()->getAsPlayer() )
|
||||
{
|
||||
player->sendDebug( "Hit target: pot: {} (f: {}, r: {}), heal pot: {}",
|
||||
lutEntry.potency, lutEntry.flankPotency, lutEntry.rearPotency, lutEntry.curePotency );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( auto player = m_pSource->getAsPlayer() )
|
||||
|
@ -346,18 +360,18 @@ void Sapphire::Action::Action::execute()
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::precheck()
|
||||
bool Action::Action::preCheck()
|
||||
{
|
||||
if( auto player = m_pSource->getAsPlayer() )
|
||||
{
|
||||
if( !playerPrecheck( *player ) )
|
||||
if( !playerPreCheck( *player ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::playerPrecheck( Entity::Player& player )
|
||||
bool Action::Action::playerPreCheck( Entity::Player& player )
|
||||
{
|
||||
// lol
|
||||
if( !player.isAlive() )
|
||||
|
@ -387,17 +401,18 @@ bool Sapphire::Action::Action::playerPrecheck( Entity::Player& player )
|
|||
return false;
|
||||
}
|
||||
|
||||
// reset target on actions that can only be casted on yourself while having a target set
|
||||
// todo: check what actions send when targeting an enemy
|
||||
// if( m_actionData->canTargetSelf &&
|
||||
// !m_actionData->canTargetFriendly &&
|
||||
// !m_actionData->canTargetHostile &&
|
||||
// !m_actionData->canTargetParty )
|
||||
// {
|
||||
// setTargetId( getSourceChara() );
|
||||
// }
|
||||
if( !m_actionData->canTargetSelf && getTargetId() == m_pSource->getId() )
|
||||
return false;
|
||||
|
||||
// todo: party/enemy validation
|
||||
// todo: does this need to check for party/alliance stuff or it's just same type?
|
||||
// todo: m_pTarget doesn't exist at this stage because we only fill it when we snapshot targets
|
||||
// if( !m_actionData->canTargetFriendly && m_pSource->getObjKind() == m_pTarget->getObjKind() )
|
||||
// return false;
|
||||
//
|
||||
// if( !m_actionData->canTargetHostile && m_pSource->getObjKind() != m_pTarget->getObjKind() )
|
||||
// return false;
|
||||
|
||||
// todo: party/dead validation
|
||||
|
||||
// validate range
|
||||
|
||||
|
@ -408,17 +423,17 @@ bool Sapphire::Action::Action::playerPrecheck( Entity::Player& player )
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Action::Action::getAdditionalData() const
|
||||
uint32_t Action::Action::getAdditionalData() const
|
||||
{
|
||||
return m_additionalData;
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::setAdditionalData( uint32_t data )
|
||||
void Action::Action::setAdditionalData( uint32_t data )
|
||||
{
|
||||
m_additionalData = data;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::isComboAction() const
|
||||
bool Action::Action::isComboAction() const
|
||||
{
|
||||
auto lastActionId = m_pSource->getLastComboActionId();
|
||||
|
||||
|
@ -430,7 +445,7 @@ bool Sapphire::Action::Action::isComboAction() const
|
|||
return m_actionData->actionCombo == lastActionId;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::primaryCostCheck( bool subtractCosts )
|
||||
bool Action::Action::primaryCostCheck( bool subtractCosts )
|
||||
{
|
||||
switch( m_primaryCostType )
|
||||
{
|
||||
|
@ -473,23 +488,23 @@ bool Sapphire::Action::Action::primaryCostCheck( bool subtractCosts )
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::secondaryCostCheck( bool subtractCosts )
|
||||
bool Action::Action::secondaryCostCheck( bool subtractCosts )
|
||||
{
|
||||
// todo: these need to be mapped
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::hasResources()
|
||||
bool Action::Action::hasResources()
|
||||
{
|
||||
return primaryCostCheck( false ) && secondaryCostCheck( false );
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::consumeResources()
|
||||
bool Action::Action::consumeResources()
|
||||
{
|
||||
return primaryCostCheck( true ) && secondaryCostCheck( true );
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::snapshotAffectedActors( std::vector< Entity::CharaPtr >& actors )
|
||||
bool Action::Action::snapshotAffectedActors( std::vector< Entity::CharaPtr >& actors )
|
||||
{
|
||||
for( const auto& actor : m_pSource->getInRangeActors( true ) )
|
||||
{
|
||||
|
@ -519,12 +534,12 @@ bool Sapphire::Action::Action::snapshotAffectedActors( std::vector< Entity::Char
|
|||
return !actors.empty();
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::addActorFilter( World::Util::ActorFilterPtr filter )
|
||||
void Action::Action::addActorFilter( World::Util::ActorFilterPtr filter )
|
||||
{
|
||||
m_actorFilters.push_back( std::move( filter ) );
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::addDefaultActorFilters()
|
||||
void Action::Action::addDefaultActorFilters()
|
||||
{
|
||||
switch( m_castType )
|
||||
{
|
||||
|
@ -561,7 +576,7 @@ void Sapphire::Action::Action::addDefaultActorFilters()
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Action::Action::preFilterActor( Sapphire::Entity::Actor& actor ) const
|
||||
bool Action::Action::preFilterActor( Sapphire::Entity::Actor& actor ) const
|
||||
{
|
||||
auto kind = actor.getObjKind();
|
||||
|
||||
|
@ -574,12 +589,12 @@ bool Sapphire::Action::Action::preFilterActor( Sapphire::Entity::Actor& actor )
|
|||
return true;
|
||||
}
|
||||
|
||||
std::vector< Sapphire::Entity::CharaPtr >& Sapphire::Action::Action::getHitCharas()
|
||||
std::vector< Sapphire::Entity::CharaPtr >& Action::Action::getHitCharas()
|
||||
{
|
||||
return m_hitActors;
|
||||
}
|
||||
|
||||
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getHitChara()
|
||||
Sapphire::Entity::CharaPtr Action::Action::getHitChara()
|
||||
{
|
||||
if( !m_hitActors.empty() )
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Sapphire::Data
|
|||
using ActionPtr = std::shared_ptr< Action >;
|
||||
}
|
||||
|
||||
namespace Sapphire::Action
|
||||
namespace Sapphire::World::Action
|
||||
{
|
||||
|
||||
class Action
|
||||
|
@ -75,7 +75,7 @@ namespace Sapphire::Action
|
|||
* @brief Tests if an action is castable by the current source chara
|
||||
* @return true if castable, false if the caster doesn't meet the requirements
|
||||
*/
|
||||
bool precheck();
|
||||
bool preCheck();
|
||||
|
||||
/*!
|
||||
* @brief Snapshots characters affected by a cast.
|
||||
|
@ -130,12 +130,10 @@ namespace Sapphire::Action
|
|||
|
||||
protected:
|
||||
|
||||
void calculateActionCost();
|
||||
|
||||
bool primaryCostCheck( bool subtractCosts );
|
||||
bool secondaryCostCheck( bool subtractCosts );
|
||||
|
||||
bool playerPrecheck( Entity::Player& player );
|
||||
bool playerPreCheck( Entity::Player& player );
|
||||
|
||||
bool preFilterActor( Entity::Actor& actor ) const;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,6 +21,9 @@ namespace Sapphire::World::Action
|
|||
public:
|
||||
using Lut = std::unordered_map< uint16_t, ActionEntry >;
|
||||
|
||||
static bool validEntryExists( uint16_t actionId );
|
||||
static const ActionEntry& getEntry( uint16_t actionId );
|
||||
|
||||
static Lut m_actionLut;
|
||||
};
|
||||
}
|
||||
|
|
1120
src/world/Action/ActionLutData.cpp
Normal file
1120
src/world/Action/ActionLutData.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -11,15 +11,17 @@
|
|||
#include "EventAction.h"
|
||||
#include "Framework.h"
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::World;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
Sapphire::Action::EventAction::EventAction( Entity::CharaPtr pActor, uint32_t eventId, uint16_t action,
|
||||
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional,
|
||||
FrameworkPtr pFw )
|
||||
Action::EventAction::EventAction( Entity::CharaPtr pActor, uint32_t eventId, uint16_t action,
|
||||
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional,
|
||||
FrameworkPtr pFw )
|
||||
{
|
||||
m_additional = additional;
|
||||
m_eventId = eventId;
|
||||
|
@ -33,14 +35,14 @@ Sapphire::Action::EventAction::EventAction( Entity::CharaPtr pActor, uint32_t ev
|
|||
m_interruptType = Common::ActionInterruptType::None;
|
||||
}
|
||||
|
||||
Sapphire::Action::EventAction::~EventAction() = default;
|
||||
Action::EventAction::~EventAction() = default;
|
||||
|
||||
void Sapphire::Action::EventAction::start()
|
||||
void Action::EventAction::start()
|
||||
{
|
||||
if( !m_pSource )
|
||||
return;
|
||||
|
||||
m_startTime = Util::getTimeMs();
|
||||
m_startTime = Common::Util::getTimeMs();
|
||||
|
||||
auto control = makeActorControl142( m_pSource->getId(), ActorControlType::CastStart, 1, m_id, 0x4000004E );
|
||||
|
||||
|
@ -54,7 +56,7 @@ void Sapphire::Action::EventAction::start()
|
|||
m_pSource->sendToInRangeSet( control );
|
||||
}
|
||||
|
||||
void Sapphire::Action::EventAction::execute()
|
||||
void Action::EventAction::execute()
|
||||
{
|
||||
if( !m_pSource )
|
||||
return;
|
||||
|
@ -90,7 +92,7 @@ void Sapphire::Action::EventAction::execute()
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Action::EventAction::interrupt()
|
||||
void Action::EventAction::interrupt()
|
||||
{
|
||||
if( !m_pSource )
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "ForwardsZone.h"
|
||||
#include "Action.h"
|
||||
|
||||
namespace Sapphire::Action
|
||||
namespace Sapphire::World::Action
|
||||
{
|
||||
|
||||
class EventAction : public Action
|
||||
|
|
73
src/world/Action/ItemAction.cpp
Normal file
73
src/world/Action/ItemAction.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include "ItemAction.h"
|
||||
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
|
||||
#include <Actor/Player.h>
|
||||
#include <Network/PacketWrappers/EffectPacket.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::World::Action;
|
||||
|
||||
ItemAction::ItemAction( Sapphire::Entity::CharaPtr source, uint32_t itemId,
|
||||
Sapphire::Data::ItemActionPtr itemActionData, uint16_t itemSourceSlot,
|
||||
uint16_t itemSourceContainer, Sapphire::FrameworkPtr fw ) :
|
||||
m_itemAction( std::move( itemActionData ) ),
|
||||
m_itemSourceSlot( itemSourceSlot ),
|
||||
m_itemSourceContainer( itemSourceContainer )
|
||||
{
|
||||
m_id = itemId;
|
||||
m_pSource = std::move( source );
|
||||
m_pFw = std::move( fw );
|
||||
}
|
||||
|
||||
void ItemAction::start()
|
||||
{
|
||||
if( !m_pSource->isPlayer() )
|
||||
return;
|
||||
|
||||
// todo: check inv slot for item
|
||||
|
||||
// todo: can we just do this?
|
||||
execute();
|
||||
}
|
||||
|
||||
void ItemAction::execute()
|
||||
{
|
||||
switch( m_itemAction->type )
|
||||
{
|
||||
default:
|
||||
{
|
||||
getSourceChara()->getAsPlayer()->sendDebug( "ItemAction type {0} not supported.", m_itemAction->type );
|
||||
break;
|
||||
}
|
||||
|
||||
case Common::ItemActionType::ItemActionVFX:
|
||||
case Common::ItemActionType::ItemActionVFX2:
|
||||
{
|
||||
handleVFXItem();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ItemAction::interrupt()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ItemAction::handleVFXItem()
|
||||
{
|
||||
Common::EffectEntry effect{};
|
||||
effect.effectType = Common::ActionEffectType::VFX;
|
||||
effect.value = m_itemAction->data[ 0 ];
|
||||
|
||||
auto effectPacket = std::make_shared< Network::Packets::Server::EffectPacket >( getSourceChara()->getId(),
|
||||
getSourceChara()->getId(), getId() );
|
||||
effectPacket->setTargetActor( getSourceChara()->getId() );
|
||||
effectPacket->setAnimationId( Common::ItemActionType::ItemActionVFX );
|
||||
effectPacket->setDisplayType( Common::ActionEffectDisplayType::ShowItemName );
|
||||
effectPacket->addEffect( effect );
|
||||
|
||||
m_pSource->sendToInRangeSet( effectPacket, true );
|
||||
}
|
38
src/world/Action/ItemAction.h
Normal file
38
src/world/Action/ItemAction.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef SAPPHIRE_ITEMACTION_H
|
||||
#define SAPPHIRE_ITEMACTION_H
|
||||
|
||||
#include "Action.h"
|
||||
|
||||
namespace Sapphire::Data
|
||||
{
|
||||
struct ItemAction;
|
||||
using ItemActionPtr = std::shared_ptr< ItemAction >;
|
||||
}
|
||||
|
||||
namespace Sapphire::World::Action
|
||||
{
|
||||
class ItemAction : public Action
|
||||
{
|
||||
public:
|
||||
ItemAction( Entity::CharaPtr source, uint32_t itemId, Data::ItemActionPtr itemActionData,
|
||||
uint16_t itemSourceSlot, uint16_t itemSourceContainer, FrameworkPtr fw );
|
||||
virtual ~ItemAction() = default;
|
||||
|
||||
void start() override;
|
||||
|
||||
void execute() override;
|
||||
|
||||
void interrupt() override;
|
||||
|
||||
private:
|
||||
void handleVFXItem();
|
||||
|
||||
private:
|
||||
Sapphire::Data::ItemActionPtr m_itemAction;
|
||||
|
||||
uint16_t m_itemSourceSlot;
|
||||
uint16_t m_itemSourceContainer;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //SAPPHIRE_ITEMACTION_H
|
|
@ -391,13 +391,13 @@ void Sapphire::Entity::Chara::sendStatusUpdate()
|
|||
}
|
||||
|
||||
/*! \return ActionPtr of the currently registered action, or nullptr */
|
||||
Sapphire::Action::ActionPtr Sapphire::Entity::Chara::getCurrentAction() const
|
||||
Sapphire::World::Action::ActionPtr Sapphire::Entity::Chara::getCurrentAction() const
|
||||
{
|
||||
return m_pCurrentAction;
|
||||
}
|
||||
|
||||
/*! \param ActionPtr of the action to be registered */
|
||||
void Sapphire::Entity::Chara::setCurrentAction( Sapphire::Action::ActionPtr pAction )
|
||||
void Sapphire::Entity::Chara::setCurrentAction( Sapphire::World::Action::ActionPtr pAction )
|
||||
{
|
||||
m_pCurrentAction = std::move( pAction );
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace Sapphire::Entity
|
|||
/*! Id of the currently selected target actor */
|
||||
uint64_t m_targetId;
|
||||
/*! Ptr to a queued action */
|
||||
Action::ActionPtr m_pCurrentAction;
|
||||
World::Action::ActionPtr m_pCurrentAction;
|
||||
/*! id of the director this chara is assigned to */
|
||||
uint32_t m_directorId;
|
||||
|
||||
|
@ -265,9 +265,9 @@ namespace Sapphire::Entity
|
|||
|
||||
virtual void update( uint64_t tickCount );
|
||||
|
||||
Action::ActionPtr getCurrentAction() const;
|
||||
World::Action::ActionPtr getCurrentAction() const;
|
||||
|
||||
void setCurrentAction( Action::ActionPtr pAction );
|
||||
void setCurrentAction( World::Action::ActionPtr pAction );
|
||||
|
||||
uint32_t getLastComboActionId() const;
|
||||
void setLastComboActionId( uint32_t actionId );
|
||||
|
|
|
@ -1621,7 +1621,7 @@ void Sapphire::Entity::Player::setCFPenaltyTimestamp( uint32_t timestamp )
|
|||
|
||||
uint32_t Sapphire::Entity::Player::getCFPenaltyMinutes() const
|
||||
{
|
||||
auto currentTimestamp = Sapphire::Util::getTimeSeconds();
|
||||
auto currentTimestamp = Common::Util::getTimeSeconds();
|
||||
auto endTimestamp = getCFPenaltyTimestamp();
|
||||
|
||||
// check if penalty timestamp already passed current time
|
||||
|
@ -1634,7 +1634,7 @@ uint32_t Sapphire::Entity::Player::getCFPenaltyMinutes() const
|
|||
|
||||
void Sapphire::Entity::Player::setCFPenaltyMinutes( uint32_t minutes )
|
||||
{
|
||||
auto currentTimestamp = Sapphire::Util::getTimeSeconds();
|
||||
auto currentTimestamp = Common::Util::getTimeSeconds();
|
||||
setCFPenaltyTimestamp( currentTimestamp + minutes * 60 );
|
||||
}
|
||||
|
||||
|
|
|
@ -53,12 +53,12 @@ namespace Sapphire::Entity
|
|||
// EventHandlers
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*! start an event action */
|
||||
void eventActionStart( uint32_t eventId, uint32_t action, Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback, uint64_t additional );
|
||||
void eventActionStart( uint32_t eventId, uint32_t action, World::Action::ActionCallback finishCallback,
|
||||
World::Action::ActionCallback interruptCallback, uint64_t additional );
|
||||
|
||||
/*! start an event item action */
|
||||
void eventItemActionStart( uint32_t eventId, uint32_t action, Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback, uint64_t additional );
|
||||
void eventItemActionStart( uint32_t eventId, uint32_t action, World::Action::ActionCallback finishCallback,
|
||||
World::Action::ActionCallback interruptCallback, uint64_t additional );
|
||||
|
||||
/*! start/register a normal event */
|
||||
void eventStart( uint64_t actorId, uint32_t eventId, Event::EventHandler::EventType eventParam, uint8_t eventParam1,
|
||||
|
@ -1107,8 +1107,8 @@ namespace Sapphire::Entity
|
|||
|
||||
Common::PlayerTeleportQuery m_teleportQuery;
|
||||
|
||||
Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator;
|
||||
Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator;
|
||||
Common::Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator;
|
||||
Common::Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator;
|
||||
|
||||
std::array< Common::HuntingLogEntry, 12 > m_huntingLogEntries;
|
||||
|
||||
|
|
|
@ -278,11 +278,11 @@ void Sapphire::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlaye
|
|||
|
||||
void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
||||
uint32_t action,
|
||||
Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback,
|
||||
World::Action::ActionCallback finishCallback,
|
||||
World::Action::ActionCallback interruptCallback,
|
||||
uint64_t additional )
|
||||
{
|
||||
auto pEventAction = Action::make_EventAction( getAsChara(), eventId, action,
|
||||
auto pEventAction = World::Action::make_EventAction( getAsChara(), eventId, action,
|
||||
finishCallback, interruptCallback, additional, m_pFw );
|
||||
|
||||
auto pEvent = getEvent( eventId );
|
||||
|
@ -309,8 +309,8 @@ void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
|||
|
||||
void Sapphire::Entity::Player::eventItemActionStart( uint32_t eventId,
|
||||
uint32_t action,
|
||||
Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback,
|
||||
World::Action::ActionCallback finishCallback,
|
||||
World::Action::ActionCallback interruptCallback,
|
||||
uint64_t additional )
|
||||
{
|
||||
// Action::ActionPtr pEventItemAction = Action::make_EventItemAction( getAsChara(), eventId, action,
|
||||
|
|
|
@ -82,10 +82,11 @@ TYPE_FORWARD( Director );
|
|||
TYPE_FORWARD( EventHandler );
|
||||
}
|
||||
|
||||
namespace Action
|
||||
namespace World::Action
|
||||
{
|
||||
TYPE_FORWARD( Action );
|
||||
TYPE_FORWARD( EventAction );
|
||||
TYPE_FORWARD( ItemAction );
|
||||
|
||||
using ActionCallback = std::function< void( Entity::Player&, uint32_t, uint64_t ) >;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "ActionMgr.h"
|
||||
|
||||
#include "Action/Action.h"
|
||||
#include "Action/ItemAction.h"
|
||||
#include "Script/ScriptMgr.h"
|
||||
#include "Actor/Player.h"
|
||||
|
||||
|
@ -66,31 +67,18 @@ void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& play
|
|||
{
|
||||
player.sendDebug( "got item act: {0}, slot: {1}, container: {2}", itemId, itemSourceSlot, itemSourceContainer );
|
||||
|
||||
// todo: check we have item & remove item from inventory
|
||||
auto action = Action::make_ItemAction( player.getAsChara(), itemId, itemActionData,
|
||||
itemSourceSlot, itemSourceContainer, framework() );
|
||||
|
||||
switch( itemActionData->type )
|
||||
{
|
||||
default:
|
||||
{
|
||||
player.sendDebug( "ItemAction type {0} not supported.", itemActionData->type );
|
||||
break;
|
||||
}
|
||||
|
||||
case Common::ItemActionType::ItemActionVFX:
|
||||
case Common::ItemActionType::ItemActionVFX2:
|
||||
{
|
||||
handleItemActionVFX( player, itemId, itemActionData->data[ 0 ] );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
// todo: item actions don't have cast times? if so we can just start it and we're good
|
||||
action->start();
|
||||
}
|
||||
|
||||
void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
||||
Action::ActionPtr currentAction,
|
||||
Data::Action& actionData )
|
||||
{
|
||||
if( !currentAction->precheck() )
|
||||
if( !currentAction->preCheck() )
|
||||
{
|
||||
// forcefully interrupt the action and reset the cooldown
|
||||
currentAction->interrupt();
|
||||
|
@ -105,19 +93,4 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
|||
|
||||
// todo: what do in cases of swiftcast/etc? script callback?
|
||||
currentAction->start();
|
||||
}
|
||||
|
||||
void World::Manager::ActionMgr::handleItemActionVFX( Sapphire::Entity::Player& player, uint32_t itemId, uint16_t vfxId )
|
||||
{
|
||||
Common::EffectEntry effect{};
|
||||
effect.effectType = Common::ActionEffectType::VFX;
|
||||
effect.value = vfxId;
|
||||
|
||||
auto effectPacket = std::make_shared< Network::Packets::Server::EffectPacket >( player.getId(), player.getId(), itemId );
|
||||
effectPacket->setTargetActor( player.getId() );
|
||||
effectPacket->setAnimationId( Common::ItemActionType::ItemActionVFX );
|
||||
effectPacket->setDisplayType( Common::ActionEffectDisplayType::ShowItemName );
|
||||
effectPacket->addEffect( effect );
|
||||
|
||||
player.sendToInRangeSet( effectPacket, true );
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
#include <cmath>
|
||||
#include <Network/PacketWrappers/EffectPacket.h>
|
||||
|
||||
#include "DebugCommand/DebugCommand.h"
|
||||
#include "DebugCommandMgr.h"
|
||||
|
@ -522,6 +523,29 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player&
|
|||
sscanf( params.c_str(), "%d", &id );
|
||||
player.learnAction( id );
|
||||
}
|
||||
else if ( subCommand == "effect")
|
||||
{
|
||||
uint16_t param1;
|
||||
sscanf( params.c_str(), "%hu", ¶m1 );
|
||||
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( player.getId(), player.getTargetId(), param1 );
|
||||
effectPacket->setRotation( Common::Util::floatToUInt16Rot( player.getRot() ) );
|
||||
|
||||
Common::EffectEntry entry{};
|
||||
entry.value = param1;
|
||||
entry.effectType = Common::ActionEffectType::Damage;
|
||||
entry.hitSeverity = Common::ActionHitSeverityType::NormalDamage;
|
||||
|
||||
effectPacket->addEffect( entry );
|
||||
|
||||
auto sequence = player.getCurrentZone()->getNextEffectSequence();
|
||||
effectPacket->setSequence( sequence );
|
||||
|
||||
// effectPacket->setAnimationId( param1 );
|
||||
// effectPacket->setEffectFlags( 0 );
|
||||
|
||||
player.queuePacket( effectPacket );
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendUrgent( "{0} is not a valid ADD command.", subCommand );
|
||||
|
@ -683,7 +707,7 @@ void Sapphire::World::Manager::DebugCommandMgr::nudge( char* data, Entity::Playe
|
|||
setActorPosPacket->data().x = player.getPos().x;
|
||||
setActorPosPacket->data().y = player.getPos().y;
|
||||
setActorPosPacket->data().z = player.getPos().z;
|
||||
setActorPosPacket->data().r16 = Util::floatToUInt16Rot( player.getRot() );
|
||||
setActorPosPacket->data().r16 = Common::Util::floatToUInt16Rot( player.getRot() );
|
||||
player.queuePacket( setActorPosPacket );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ void Sapphire::World::Manager::MarketMgr::requestItemListingInfo( Sapphire::Enti
|
|||
|
||||
listing.itemCatalogId = catalogId;
|
||||
listing.quantity = i + 1;
|
||||
listing.purchaseTime = Sapphire::Util::getTimeSeconds();
|
||||
listing.purchaseTime = Common::Util::getTimeSeconds();
|
||||
listing.salePrice = 69420420;
|
||||
listing.isHq = 1;
|
||||
listing.onMannequin = 1;
|
||||
|
|
|
@ -424,7 +424,7 @@ void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network::
|
|||
|
||||
auto pe = std::make_shared< FFXIVRawPacket >( 0x07, 0x18, 0, 0 );
|
||||
*( unsigned int* ) ( &pe->data()[ 0 ] ) = 0xE0037603;
|
||||
*( unsigned int* ) ( &pe->data()[ 4 ] ) = Sapphire::Util::getTimeSeconds();
|
||||
*( unsigned int* ) ( &pe->data()[ 4 ] ) = Common::Util::getTimeSeconds();
|
||||
sendSinglePacket( pe );
|
||||
|
||||
// main connection, assinging it to the session
|
||||
|
|
|
@ -28,12 +28,12 @@ namespace Sapphire::Network
|
|||
None
|
||||
};
|
||||
|
||||
class GameConnection : public Connection
|
||||
class GameConnection : public Network::Connection
|
||||
{
|
||||
|
||||
private:
|
||||
typedef void ( GameConnection::* Handler )( FrameworkPtr pFw,
|
||||
const Sapphire::Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
const Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player );
|
||||
|
||||
using HandlerMap = std::map< uint16_t, Handler >;
|
||||
|
@ -51,8 +51,8 @@ namespace Sapphire::Network
|
|||
|
||||
World::SessionPtr m_pSession;
|
||||
|
||||
LockedQueue< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
|
||||
LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
|
||||
Common::Util::LockedQueue< Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
|
||||
Common::Util::LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
|
||||
std::vector< uint8_t > m_packets;
|
||||
|
||||
public:
|
||||
|
@ -82,15 +82,15 @@ namespace Sapphire::Network
|
|||
|
||||
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 sendSinglePacket( Sapphire::Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||
void sendSinglePacket( Network::Packets::FFXIVPacketBasePtr pPacket );
|
||||
|
||||
void injectPacket( const std::string& packetpath, Entity::Player& player );
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue