1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00

Refactoring and modernizing

This commit is contained in:
Mordred 2018-10-28 21:53:21 +01:00
parent b7678a8cc9
commit 6d2c012cf2
425 changed files with 6922 additions and 6542 deletions

View file

@ -10,41 +10,41 @@
// The following enumerations are structures to require their type be included.
// They are also defined within the Core::Common namespace to avoid collisions.
// +---------------------------------------------------------------------------
namespace Core {
namespace Common {
// 99 is the last spawn id that seems to spawn any actor
const uint8_t MAX_DISPLAYED_ACTORS = 99;
const uint8_t MAX_DISPLAYED_EOBJS = 40;
const int32_t INVALID_GAME_OBJECT_ID = 0xE0000000;
struct FFXIVARR_POSITION3
namespace Core::Common
{
// 99 is the last spawn id that seems to spawn any actor
const uint8_t MAX_DISPLAYED_ACTORS = 99;
const uint8_t MAX_DISPLAYED_EOBJS = 40;
const int32_t INVALID_GAME_OBJECT_ID = 0xE0000000;
struct FFXIVARR_POSITION3
{
float x;
float y;
float z;
};
};
enum InventoryOperation : uint8_t
{
enum InventoryOperation : uint8_t
{
Discard = 0x07,
Move = 0x08,
Swap = 0x09,
Merge = 0x0C,
Split = 0x0A
};
};
enum ClientLanguage : uint8_t
{
enum ClientLanguage : uint8_t
{
Japanese = 1,
English = 2,
German = 4,
French = 8
};
};
enum ObjKind : uint8_t
{
enum ObjKind : uint8_t
{
None = 0x00,
Player = 0x01,
BattleNpc = 0x02,
@ -60,26 +60,26 @@ enum ObjKind : uint8_t
Housing = 0x0C,
Cutscene = 0x0D,
CardStand = 0x0E,
};
};
enum Stance : uint8_t
{
enum Stance : uint8_t
{
Passive = 0,
Active = 1,
};
};
enum class DisplayFlags : uint16_t
{
enum class DisplayFlags : uint16_t
{
ActiveStance = 0x001,
Invisible = 0x020,
HideHead = 0x040,
HideWeapon = 0x080,
Faded = 0x100,
Visor = 0x800,
};
};
enum struct ActorStatus : uint8_t
{
enum struct ActorStatus : uint8_t
{
Idle = 0x01,
Dead = 0x02,
Sitting = 0x03,
@ -90,10 +90,10 @@ enum struct ActorStatus : uint8_t
SMachine = 0x08,
Carry = 0x09,
EmoteMode = 0x0B
};
};
enum GearSetSlot : uint8_t
{
enum GearSetSlot : uint8_t
{
MainHand = 0,
OffHand = 1,
Head = 2,
@ -108,10 +108,10 @@ enum GearSetSlot : uint8_t
Ring1 = 11,
Ring2 = 12,
SoulCrystal = 13,
};
};
enum GearModelSlot : int8_t
{
enum GearModelSlot : int8_t
{
ModelInvalid = -1,
ModelHead = 0,
ModelBody = 1,
@ -123,10 +123,10 @@ enum GearModelSlot : int8_t
ModelWrist = 7,
ModelRing1 = 8,
ModelRing2 = 9
};
};
enum EquipSlotCategory : uint8_t
{
enum EquipSlotCategory : uint8_t
{
Unequippable = 0,
// main slots
@ -163,10 +163,10 @@ enum EquipSlotCategory : uint8_t
BodyDisallowHands = 20,
/*! Cannot equip gear to legs & feet slots */
BodyDisallowLegsFeet = 21,
};
};
enum InventoryType : uint16_t
{
enum InventoryType : uint16_t
{
Bag0 = 0,
Bag1 = 1,
Bag2 = 2,
@ -215,20 +215,20 @@ enum InventoryType : uint16_t
FreeCompanyBag2 = 20002,
FreeCompanyGil = 22000,
FreeCompanyCrystal = 22001
};
};
enum ContainerType : uint16_t
{
enum ContainerType : uint16_t
{
Unknown = 0,
Bag = 1,
GearSet = 2,
CurrencyCrystal = 3,
Armory = 4
};
};
enum CurrencyType : uint8_t
{
enum CurrencyType : uint8_t
{
Gil = 0x01,
StormSeal = 0x02,
SerpentSeal = 0x03,
@ -243,10 +243,10 @@ enum CurrencyType : uint8_t
TomestoneLaw = 0x0C,
TomestoneEso = 0x0D,
TomestoneLore = 0x0E
};
};
enum CrystalType : uint8_t
{
enum CrystalType : uint8_t
{
FireShard = 0x01,
IceShard = 0x02,
WindShard = 0x03,
@ -267,33 +267,33 @@ enum CrystalType : uint8_t
EarthCluster = 0x10,
LightningCluster = 0x11,
WaterCluster = 0x12
};
};
enum struct ZoneingType : uint8_t
{
enum struct ZoneingType : uint8_t
{
None = 1,
Teleport = 2,
Return = 3,
ReturnDead = 4,
FadeIn = 5,
};
};
enum struct ResurrectType : uint8_t
{
enum struct ResurrectType : uint8_t
{
None = 0,
RaiseSpell = 5,
Return = 8
};
};
enum Gender : uint8_t
{
enum Gender : uint8_t
{
Male = 0,
Female = 1,
};
};
enum struct GCRank : uint8_t
{
enum struct GCRank : uint8_t
{
None = 0,
PrivateThirdClass = 1,
PrivateSecondClass = 2,
@ -314,23 +314,23 @@ enum struct GCRank : uint8_t
Marshal = 17,
GrandMarshal = 18,
Champion = 19,
};
};
/**
* Structural representation of the packet sent by the server
* Send the entire StatusEffect list
*/
struct StatusEffect
{
/**
* Structural representation of the packet sent by the server
* Send the entire StatusEffect list
*/
struct StatusEffect
{
uint16_t effect_id;
uint16_t unknown1;
float duration;
uint32_t sourceActorId;
};
};
enum CharaLook :
enum CharaLook :
uint8_t
{
{
Race = 0x00,
Gender = 0x01,
Tribe = 0x04,
@ -358,28 +358,28 @@ enum CharaLook :
Facepaint = 0x18,
FacepaintColor = 0x19,
};
};
enum MoveType :
enum MoveType :
uint8_t
{
{
Running = 0x00,
Walking = 0x02,
Strafing = 0x04,
Jumping = 0x10,
BackWalk = 0x06,
};
};
enum MoveState :
enum MoveState :
uint8_t
{
{
No = 0x00,
Land = 0x02,
Fall = 0x04,
};
};
struct QuestActive
{
struct QuestActive
{
QuestActive()
{
c.questId = 0;
@ -469,11 +469,11 @@ struct QuestActive
};
};
};
enum struct ActionAspect :
enum struct ActionAspect :
uint8_t
{
{
None = 0, // Doesn't imply unaspected
Fire = 1,
Ice = 2,
@ -482,11 +482,11 @@ enum struct ActionAspect :
Lightning = 5,
Water = 6,
Unaspected = 7 // Doesn't imply magical unaspected damage - could be unaspected physical
};
};
enum class ActionType :
enum class ActionType :
int8_t
{
{
WeaponOverride = -1, // Needs more investigation (takes the damage type of the equipped weapon)?
Unknown_0 = 0,
Slashing = 1,
@ -497,11 +497,11 @@ enum class ActionType :
Darkness = 6,
Unknown_7 = 7,
LimitBreak = 8,
};
};
enum ActionEffectType :
enum ActionEffectType :
uint8_t
{
{
Nothing = 0,
Miss = 1,
FullResist = 2,
@ -519,30 +519,30 @@ enum ActionEffectType :
GpGain = 14,
Knockback = 33,
Mount = 38
};
};
enum class ActionHitSeverityType :
enum class ActionHitSeverityType :
uint8_t
{
{
NormalDamage = 0,
CritHeal = 0,
CritDamage = 1,
NormalHeal = 1,
DirectHitDamage = 2,
CritDirectHitDamage = 3
};
};
enum ActionEffectDisplayType :
enum ActionEffectDisplayType :
uint8_t
{
{
HideActionName = 0,
ShowActionName = 1,
ShowItemName = 2,
};
};
enum class ActionCollisionType :
enum class ActionCollisionType :
uint8_t
{
{
None,
SingleTarget,
Circle,
@ -552,35 +552,35 @@ enum class ActionCollisionType :
Unknown2,
PersistentArea, // for when you set aoe like asylum
Unknown3
};
};
enum HandleActionType :
enum HandleActionType :
uint8_t
{
{
Event,
Spell,
Teleport
};
};
enum HandleSkillType :
enum HandleSkillType :
uint8_t
{
{
StdDamage,
StdHeal,
StdDot,
};
};
enum InvincibilityType :
enum InvincibilityType :
uint8_t
{
{
InvincibilityNone,
InvincibilityRefill,
InvincibilityStayAlive,
};
};
enum PlayerStateFlag :
enum PlayerStateFlag :
uint8_t
{
{
HideUILockChar = 0, // as the name suggests, hides the ui and logs the char...
InCombat = 1, // in Combat, locks gearchange/return/teleport
Casting = 2,
@ -593,20 +593,20 @@ enum PlayerStateFlag :
WatchingCutscene = 50, // this is actually just a dummy, this id is different
};
};
enum struct FateStatus :
enum struct FateStatus :
uint8_t
{
{
Active = 2,
Inactive = 4,
Preparing = 7,
Completed = 8,
};
};
enum struct ChatType :
enum struct ChatType :
uint16_t
{
{
LogKindError,
ServerDebug,
ServerUrgent,
@ -708,11 +708,11 @@ enum struct ChatType :
Unused98,
Unused99,
Unused100
};
};
enum EquipDisplayFlags :
enum EquipDisplayFlags :
uint8_t
{
{
HideNothing = 0x0,
HideHead = 0x1,
HideWeapon = 0x2,
@ -722,18 +722,17 @@ enum EquipDisplayFlags :
StoreCraftedItemsInInventory = 0x20,
Visor = 0x40,
};
};
enum SkillType :
enum SkillType :
uint8_t
{
{
Normal = 0x1,
MountSkill = 0xD,
};
};
typedef std::vector< PlayerStateFlag > PlayerStateFlagList;
using PlayerStateFlagList = std::vector< PlayerStateFlag >;
} /* Common */
} /* Core */
}
#endif

View file

@ -7,10 +7,11 @@
#include <string>
#include <stdint.h>
namespace Core {
class ConfigMgr
namespace Core
{
public:
class ConfigMgr
{
public:
ConfigMgr() = default;
~ConfigMgr() = default;
@ -55,7 +56,7 @@ public:
//m_propTree.put( name, defaultValue );
}
private:
private:
bool copyDefaultConfig( const std::string& configName );
std::unique_ptr< INIReader > m_pInih;
@ -63,7 +64,7 @@ private:
const std::string m_globalConfigFile = "global.ini";
const std::string m_configFolderRoot = "./config/";
const std::string m_configDefaultSuffix = ".default";
};
};
}
#endif //SAPPHIRE_CONFIGMGR_H

View file

@ -1,10 +1,10 @@
#include <string>
namespace Core {
namespace Util {
std::string base64_encode( uint8_t const*, uint32_t len );
namespace Core::Util
{
std::string base64_encode( uint8_t const*, uint32_t len );
std::string base64_decode( std::string const& s );
}
std::string base64_decode( const std::string& s );
}

View file

@ -3,25 +3,25 @@
#include <stdint.h>
namespace Core {
namespace Util {
using md5_context = struct
namespace Core::Util
{
using md5_context = struct
{
uint32_t total[2];
uint32_t state[4];
uint8_t buffer[64];
};
};
void md5( uint8_t* text, uint8_t* hash, int32_t size );
void md5( uint8_t* text, uint8_t* hash, int32_t size );
void md5_starts( md5_context* ctx );
void md5_starts( md5_context* ctx );
void md5_update( md5_context* ctx, uint8_t* input, uint32_t length );
void md5_update( md5_context* ctx, uint8_t* input, uint32_t length );
void md5_finish( md5_context* ctx, uint8_t digest[16] );
void md5_finish( md5_context* ctx, uint8_t digest[16] );
static const char* msg[] =
static const char* msg[] =
{
"",
"a",
@ -33,7 +33,7 @@ static const char* msg[] =
"345678901234567890"
};
static const char* val[] =
static const char* val[] =
{
"d41d8cd98f00b204e9800998ecf8427e",
"0cc175b9c0f1b6a831c399e269772661",
@ -45,7 +45,7 @@ static const char* val[] =
};
}
}
#endif /* md5.h */

View file

@ -8,37 +8,31 @@
#include <vector>
#include "Util/LockedWaitQueue.h"
namespace Mysql {
class Connection;
class ResultSet;
class PreparedResultSet;
class PreparedStatement;
namespace Mysql
{
class Connection;
class ResultSet;
class PreparedResultSet;
class PreparedStatement;
}
namespace Core {
namespace Db {
class DatabaseWorker;
class PreparedStatement;
class Operation;
class DbWorker;
using PreparedStmtScopedPtr = std::unique_ptr< PreparedStatement >;
enum ConnectionFlags
namespace Core::Db
{
class DatabaseWorker;
class PreparedStatement;
class Operation;
class DbWorker;
using PreparedStmtScopedPtr = std::unique_ptr< PreparedStatement >;
enum ConnectionFlags
{
CONNECTION_ASYNC = 0x1,
CONNECTION_SYNC = 0x2,
CONNECTION_BOTH = CONNECTION_ASYNC | CONNECTION_SYNC
};
};
struct ConnectionInfo
{
struct ConnectionInfo
{
std::string user;
std::string password;
std::string database;
@ -46,14 +40,14 @@ struct ConnectionInfo
uint16_t port;
uint8_t syncThreads;
uint8_t asyncThreads;
};
};
using PreparedStatementMap = std::map< uint32_t, std::pair< std::string, ConnectionFlags > >;
using PreparedStatementMap = std::map< uint32_t, std::pair< std::string, ConnectionFlags > >;
class DbConnection :
class DbConnection :
public std::enable_shared_from_this< DbConnection >
{
public:
{
public:
// Constructor for synchronous connections.
DbConnection( ConnectionInfo& connInfo );
@ -101,13 +95,13 @@ public:
virtual void doPrepareStatements() = 0;
protected:
protected:
std::vector< std::shared_ptr< Mysql::PreparedStatement > > m_stmts;
PreparedStatementMap m_queries;
bool m_reconnecting;
bool m_prepareError;
private:
private:
LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
std::shared_ptr< DbWorker > m_worker;
std::shared_ptr< Mysql::Connection > m_pConnection;
@ -118,10 +112,8 @@ private:
DbConnection( DbConnection const& right ) = delete;
DbConnection& operator=( DbConnection const& right ) = delete;
};
};
}
}
#endif

View file

@ -8,15 +8,15 @@
#include <string>
#include "DbConnection.h"
namespace Core {
namespace Db {
template< class T >
class DbWorkerPool;
class DbLoader
namespace Core::Db
{
public:
template< class T >
class DbWorkerPool;
class DbLoader
{
public:
DbLoader();
template< class T >
@ -31,7 +31,7 @@ public:
DATABASE_MASK_ALL = DATABASE_CHARACTER
};
private:
private:
bool openDatabases();
bool prepareStatements();
@ -44,8 +44,7 @@ private:
std::queue< Predicate > m_open;
std::queue< Predicate > m_prepare;
std::stack< Closer > m_close;
};
}
};
}
#endif //SAPPHIRE_DBLOADER_H

View file

@ -6,20 +6,19 @@
#include "Util/LockedWaitQueue.h"
#include <memory>
namespace Core {
namespace Db {
class DbConnection;
class Operation;
class DbWorker
namespace Core::Db
{
public:
class DbConnection;
class Operation;
class DbWorker
{
public:
DbWorker( LockedWaitQueue< std::shared_ptr< Operation > >* newQueue, DbConnection* connection );
~DbWorker();
private:
private:
LockedWaitQueue< std::shared_ptr< Operation > >* m_queue;
DbConnection* m_pConn;
@ -32,9 +31,7 @@ private:
DbWorker( DbWorker const& right ) = delete;
DbWorker& operator=( DbWorker const& right ) = delete;
};
};
}
}
#endif //SAPPHIRE_DBWORKER_H

View file

@ -8,22 +8,22 @@
#include "Util/LockedWaitQueue.h"
#include "DbConnection.h"
namespace Core {
namespace Db {
template< typename T >
class LockedWaitQueue;
class Operation;
class PreparedStatement;
struct ConnectionInfo;
template< class T >
class DbWorkerPool
namespace Core::Db
{
private:
template< typename T >
class LockedWaitQueue;
class Operation;
class PreparedStatement;
struct ConnectionInfo;
template< class T >
class DbWorkerPool
{
private:
enum InternalIndex
{
IDX_ASYNC,
@ -31,7 +31,7 @@ private:
IDX_SIZE
};
public:
public:
DbWorkerPool();
~DbWorkerPool();
@ -72,7 +72,7 @@ public:
void keepAlive();
private:
private:
uint32_t openConnections( InternalIndex type, uint8_t numConnections );
unsigned long escapeString( char* to, const char* from, unsigned long length );
@ -88,9 +88,8 @@ private:
ConnectionInfo m_connectionInfo;
uint8_t m_asyncThreads;
uint8_t m_synchThreads;
};
};
}
}
#endif //SAPPHIRE_DBWORKERPOOL_H

View file

@ -1,19 +1,20 @@
#ifndef SAPPHIRE_OPERATION_H
#define SAPPHIRE_OPERATION_H
namespace Mysql {
class Connection;
namespace Mysql
{
class Connection;
}
namespace Core {
namespace Db {
class DbConnection;
class PreparedStatement;
class Operation
namespace Core::Db
{
public:
class DbConnection;
class PreparedStatement;
class Operation
{
public:
Operation() :
m_pConn( nullptr )
{
@ -38,14 +39,11 @@ public:
DbConnection* m_pConn;
private:
private:
Operation( Operation const& right ) = delete;
Operation& operator=( Operation const& right ) = delete;
};
}
};
}
#endif //SAPPHIRE_OPERATION_H

View file

@ -7,24 +7,25 @@
#include <memory>
#include "Operation.h"
namespace Mysql {
class PreparedStatement;
namespace Mysql
{
class PreparedStatement;
}
namespace Core {
namespace Db {
union PreparedStatementDataUnion
namespace Core::Db
{
union PreparedStatementDataUnion
{
bool boolean;
uint32_t ui32;
int32_t i32;
uint64_t ui64;
int64_t i64;
double d;
};
};
enum PreparedStatementValueType
{
enum PreparedStatementValueType
{
TYPE_BOOL,
TYPE_UI,
TYPE_UI64,
@ -34,18 +35,18 @@ enum PreparedStatementValueType
TYPE_STRING,
TYPE_BINARY,
TYPE_NULL
};
};
struct PreparedStatementData
{
struct PreparedStatementData
{
PreparedStatementDataUnion data;
PreparedStatementValueType type;
std::vector< uint8_t > binary;
};
};
class PreparedStatement
{
public:
class PreparedStatement
{
public:
explicit PreparedStatement( uint32_t index );
~PreparedStatement();
@ -74,7 +75,7 @@ public:
void bindParameters();
protected:
protected:
std::shared_ptr< Mysql::PreparedStatement > m_stmt;
uint32_t m_index;
std::vector< PreparedStatementData > m_statementData;
@ -82,10 +83,7 @@ protected:
PreparedStatement( PreparedStatement const& right ) = delete;
PreparedStatement& operator=( PreparedStatement const& right ) = delete;
};
}
};
}

View file

@ -5,14 +5,14 @@
#include "Operation.h"
#include <memory>
namespace Core {
namespace Db {
class PreparedStatement;
class StatementTask :
public Operation
namespace Core::Db
{
public:
class PreparedStatement;
class StatementTask :
public Operation
{
public:
StatementTask( const std::string& sql, bool async = false );
@ -25,16 +25,16 @@ public:
// return m_result->get_future();
// }
private:
private:
std::string m_sql;
bool m_hasResult;
// QueryResultPromise *m_result;
};
// QueryResultPromise *m_result;
};
class PreparedStatementTask :
class PreparedStatementTask :
public Operation
{
public:
{
public:
PreparedStatementTask( std::shared_ptr< PreparedStatement > stmt, bool async = false );
~PreparedStatementTask();
@ -42,14 +42,13 @@ public:
bool execute() override;
//PreparedQueryResultFuture getFuture() { return m_result->get_future(); }
protected:
protected:
std::shared_ptr< PreparedStatement > m_stmt;
bool m_hasResult;
//PreparedQueryResultPromise* m_result;
};
};
}
}
#endif //SAPPHIRE_STATEMENTTASK_H

View file

@ -3,12 +3,12 @@
#include "DbConnection.h"
namespace Core {
namespace Db {
class DbConnectionInfo;
enum ZoneDbStatements : uint32_t
namespace Core::Db
{
class DbConnectionInfo;
enum ZoneDbStatements : uint32_t
{
CHARA_SEL,
CHARA_SEL_MINIMAL,
CHARA_SEL_SEARCHINFO,
@ -79,11 +79,11 @@ enum ZoneDbStatements : uint32_t
ZONE_SEL_BNPCTEMPLATES,
MAX_STATEMENTS
};
};
class ZoneDbConnection : public DbConnection
{
public:
class ZoneDbConnection : public DbConnection
{
public:
using Statements = ZoneDbStatements;
ZoneDbConnection( ConnectionInfo& connInfo );
@ -94,9 +94,8 @@ public:
void doPrepareStatements() override;
};
};
}
}
#endif //SAPPHIRE_CHARACONNECTION_H

View file

@ -13,8 +13,8 @@
#include <set>
#include <variant>
namespace Core {
namespace Data {
namespace Core::Data
{
class ExdDataGenerated;
@ -8694,7 +8694,6 @@ const std::set< uint32_t >& getZoneSharedGroupIdList()
};
}
}
#endif

View file

@ -3,34 +3,30 @@
#include <memory>
namespace Core {
namespace Core
{
class ConfigMgr;
class ConfigMgr;
using ConfigMgrPtr = std::shared_ptr< ConfigMgr >;
typedef std::shared_ptr< ConfigMgr > ConfigMgrPtr;
namespace Network
{
class Hive;
class Acceptor;
class Connection;
using HivePtr = std::shared_ptr< Hive >;
using AcceptorPtr = std::shared_ptr< Acceptor >;
using ConnectionPtr = std::shared_ptr< Connection >;
namespace Packets
{
class GamePacket;
class FFXIVPacketBase;
using GamePacketPtr = std::shared_ptr< GamePacket >;
using FFXIVPacketBasePtr = std::shared_ptr< FFXIVPacketBase >;
}
namespace Network {
class Hive;
class Acceptor;
class Connection;
typedef std::shared_ptr< Hive > HivePtr;
typedef std::shared_ptr< Acceptor > AcceptorPtr;
typedef std::shared_ptr< Connection > ConnectionPtr;
namespace Packets {
class GamePacket;
class FFXIVPacketBase;
typedef std::shared_ptr< GamePacket > GamePacketPtr;
typedef std::shared_ptr< FFXIVPacketBase > FFXIVPacketBasePtr;
}
}
}
}

View file

@ -7,14 +7,15 @@
#include <memory>
#include <cassert>
namespace Core {
class Framework
namespace Core
{
class Framework
{
using TypenameToObject = std::map< std::type_index, std::shared_ptr< void > >;
TypenameToObject ObjectMap;
public:
public:
template< typename T >
std::shared_ptr< T > get()
{
@ -29,7 +30,7 @@ public:
assert( value ); // why would anyone store nullptrs....
ObjectMap[ typeid( T ) ] = value;
}
};
};
}

View file

@ -48,11 +48,6 @@ void Logger::init()
spdlog::flush_on( spdlog::level::critical );
}
void Logger::Log( LoggingSeverity logSev, const std::string& text )
{
}
void Logger::error( const std::string& text )
{
spdlog::get( "logger" )->error( text );

View file

@ -3,33 +3,22 @@
#include <string>
namespace Core {
enum struct LoggingSeverity : uint8_t
{
trace = 0,
debug = 1,
info = 2,
warning = 3,
error = 4,
fatal = 5
};
class Logger
namespace Core
{
private:
class Logger
{
private:
std::string m_logFile;
public:
public:
Logger();
~Logger();
void init();
void Log( LoggingSeverity logSev, const std::string& text );
void error( const std::string& text );
void info( const std::string& text );
@ -40,8 +29,7 @@ public:
void setLogPath( const std::string& logPath );
};
};
}

View file

@ -13,22 +13,22 @@
#include <vector>
namespace Core {
namespace Network {
class Connection;
class Acceptor : public std::enable_shared_from_this< Acceptor >
namespace Core::Network
{
class Connection;
class Acceptor : public std::enable_shared_from_this< Acceptor >
{
friend class Hive;
private:
private:
HivePtr m_hive;
asio::ip::tcp::acceptor m_acceptor;
asio::strand m_io_strand;
std::atomic< uint32_t > m_error_state;
private:
private:
Acceptor( const Acceptor& rhs );
Acceptor& operator=( const Acceptor& rhs );
@ -39,7 +39,7 @@ private:
void HandleAccept( const asio::error_code& error, ConnectionPtr connection );
private:
private:
// Called when a connection has connected to the server. This function
// should return true to invoke the connection's OnAccept function if the
// connection will be kept. If the connection will not be kept, the
@ -52,7 +52,7 @@ private:
// called on an address that is not available.
virtual void OnError( const asio::error_code& error );
public:
public:
Acceptor( HivePtr hive );
virtual ~Acceptor();
@ -69,7 +69,7 @@ public:
// Returns true if this object has an error associated with it.
bool HasError();
public:
public:
// Begin listening on the specific network interface.
void Listen( const std::string& host, const uint16_t& port );
@ -80,8 +80,7 @@ public:
// Stop the Acceptor from listening.
void Stop();
};
};
}
}
#endif

View file

@ -5,52 +5,51 @@
#include <vector>
#include "PacketDef/Ipcs.h"
namespace Core {
namespace Network {
namespace Packets {
/**
* Anticipated usage:
* ==================
* Set up a stream buffer to collect the bytes to be transmitted as a packet.
* Now, you can do the following (given you have the structs filled out already).
*
* FFXIVARR_PACKET_HEADER pkt_hdr = { . . . };
* FFXIVARR_PACKET_SEGMENT_HEADER pkt_seg_hdr[n] = { . . . };
*
* std::stringstream buf;
* buf << pkt_hdr;
* for( int i = 0; i < n; i++ )
* {
* buf << pkt_seg_hdr[i];
* buf << {pkt_seg_data[i]};
* }
*
* The reverse can be done parsing a packet. Remember to validate the packet
* type before parsing the headers.
*
* Compression and Encryption:
* ===========================
* By using std::iostream's, you can support stream filters. Simply create a
* stream that performs the compression or encryption, and use that stream to
* read and write.
*/
/**
* Structure representing the common header for all FFXIVARR packets.
*
* 0 4 8 12 14 16
* +-------------------------------+---------------+-------+-------+
* | unknown_0 | unknown_8 |
* +-------------------------------+---------------+-------+-------+
* | timestamp | size | cType | count |
* +---+---+-------+---------------+---------------+-------+-------+
* | ? |CMP| ? | ? |
* +---+---+-------+---------------+
* (followed by /count/ FFXIVARR_PACKET_SEGMENTs)
*/
struct FFXIVARR_PACKET_HEADER
namespace Core::Network::Packets
{
/**
* Anticipated usage:
* ==================
* Set up a stream buffer to collect the bytes to be transmitted as a packet.
* Now, you can do the following (given you have the structs filled out already).
*
* FFXIVARR_PACKET_HEADER pkt_hdr = { . . . };
* FFXIVARR_PACKET_SEGMENT_HEADER pkt_seg_hdr[n] = { . . . };
*
* std::stringstream buf;
* buf << pkt_hdr;
* for( int i = 0; i < n; i++ )
* {
* buf << pkt_seg_hdr[i];
* buf << {pkt_seg_data[i]};
* }
*
* The reverse can be done parsing a packet. Remember to validate the packet
* type before parsing the headers.
*
* Compression and Encryption:
* ===========================
* By using std::iostream's, you can support stream filters. Simply create a
* stream that performs the compression or encryption, and use that stream to
* read and write.
*/
/**
* Structure representing the common header for all FFXIVARR packets.
*
* 0 4 8 12 14 16
* +-------------------------------+---------------+-------+-------+
* | unknown_0 | unknown_8 |
* +-------------------------------+---------------+-------+-------+
* | timestamp | size | cType | count |
* +---+---+-------+---------------+---------------+-------+-------+
* | ? |CMP| ? | ? |
* +---+---+-------+---------------+
* (followed by /count/ FFXIVARR_PACKET_SEGMENTs)
*/
struct FFXIVARR_PACKET_HEADER
{
/** Unknown data, no actual use has been determined */
uint64_t unknown_0;
uint64_t unknown_8;
@ -66,35 +65,35 @@ struct FFXIVARR_PACKET_HEADER
/** Indicates if the data segments of this packet are compressed. */
uint8_t isCompressed;
uint32_t unknown_24;
};
};
inline std::ostream& operator<<( std::ostream& os, const FFXIVARR_PACKET_HEADER& hdr )
{
inline std::ostream& operator<<( std::ostream& os, const FFXIVARR_PACKET_HEADER& hdr )
{
return os.write( reinterpret_cast< const char* >( &hdr ), sizeof hdr );
}
}
inline std::istream& operator>>( std::istream& is, FFXIVARR_PACKET_HEADER& hdr )
{
inline std::istream& operator>>( std::istream& is, FFXIVARR_PACKET_HEADER& hdr )
{
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
}
}
/**
* Structure representing the header portion of a packet segment.
*
* NOTE: If the main packet header indicated the packet is compressed, this
* header will be compressed as well! The header will NOT ever be encrypted.
*
* 0 4 8 12 16
* +---------------+---------------+---------------+-------+-------+
* | size | source_actor | target_actor | type | pad |
* +---------------+---------------+---------------+-------+-------+
* | |
* : type-specific data of length, size, follows :
* | (NOTE: Some segments MAY be encrypted) |
* +---------------------------------------------------------------+
*/
struct FFXIVARR_PACKET_SEGMENT_HEADER
{
/**
* Structure representing the header portion of a packet segment.
*
* NOTE: If the main packet header indicated the packet is compressed, this
* header will be compressed as well! The header will NOT ever be encrypted.
*
* 0 4 8 12 16
* +---------------+---------------+---------------+-------+-------+
* | size | source_actor | target_actor | type | pad |
* +---------------+---------------+---------------+-------+-------+
* | |
* : type-specific data of length, size, follows :
* | (NOTE: Some segments MAY be encrypted) |
* +---------------------------------------------------------------+
*/
struct FFXIVARR_PACKET_SEGMENT_HEADER
{
/** The size of the segment header and its data. */
uint32_t size;
/** The session ID this segment describes. */
@ -104,83 +103,81 @@ struct FFXIVARR_PACKET_SEGMENT_HEADER
/** The segment type. (1, 2, 3, 7, 8, 9, 10) */
uint16_t type;
uint16_t padding;
};
};
inline std::ostream& operator<<( std::ostream& os, const FFXIVARR_PACKET_SEGMENT_HEADER& hdr )
{
inline std::ostream& operator<<( std::ostream& os, const FFXIVARR_PACKET_SEGMENT_HEADER& hdr )
{
return os.write( reinterpret_cast< const char* >( &hdr ), sizeof hdr );
}
}
inline std::istream& operator>>( std::istream& is, FFXIVARR_PACKET_SEGMENT_HEADER& hdr )
{
inline std::istream& operator>>( std::istream& is, FFXIVARR_PACKET_SEGMENT_HEADER& hdr )
{
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
}
}
template< int T >
struct FFXIVIpcBasePacket
{
template< int T >
struct FFXIVIpcBasePacket
{
/** Creates a constant representing the IPC type */
enum
{
_ServerIpcType = T
};
};
};
struct FFXIVARR_PACKET_RAW
{
struct FFXIVARR_PACKET_RAW
{
FFXIVARR_PACKET_SEGMENT_HEADER segHdr;
std::vector< uint8_t > data;
};
};
/**
/**
* Indicates the type of the segment
* IPC type will contain an additional header: FFXIVARR_PACKET_SEGMENT_HEADER + FFXIVARR_IPC_HEADER + data
* The remaining types don't contain an additonal header, FFXIVARR_PACKET_SEGMENT_HEADER + data
*/
enum FFXIVARR_SEGMENT_TYPE
{
enum FFXIVARR_SEGMENT_TYPE
{
SEGMENTTYPE_SESSIONINIT = 1,
SEGMENTTYPE_IPC = 3,
SEGMENTTYPE_KEEPALIVE = 7,
//SEGMENTTYPE_RESPONSE = 8,
SEGMENTTYPE_ENCRYPTIONINIT = 9,
};
};
/**
* Structural representation of the common header for IPC packet segments.
* NOTE: This is packet segment type 3.
*
* 0 4 6 8 12 16
* +-------+-------+------+----------+---------------+---------------+
* | 14 00 | type | pad | serverId | timestamp | pad1 |
* +-------+-------+------+----------+---------------+---------------+
* | |
* : data :
* | |
* +-----------------------------------------------------------------+
*/
struct FFXIVARR_IPC_HEADER
{
/**
* Structural representation of the common header for IPC packet segments.
* NOTE: This is packet segment type 3.
*
* 0 4 6 8 12 16
* +-------+-------+------+----------+---------------+---------------+
* | 14 00 | type | pad | serverId | timestamp | pad1 |
* +-------+-------+------+----------+---------------+---------------+
* | |
* : data :
* | |
* +-----------------------------------------------------------------+
*/
struct FFXIVARR_IPC_HEADER
{
uint16_t reserved;
uint16_t type;
uint16_t padding;
uint16_t serverId;
uint32_t timestamp;
uint32_t padding1;
};
};
inline std::ostream& operator<<( std::ostream& os, const FFXIVARR_IPC_HEADER& hdr )
{
inline std::ostream& operator<<( std::ostream& os, const FFXIVARR_IPC_HEADER& hdr )
{
return os.write( reinterpret_cast< const char* >( &hdr ), sizeof hdr );
}
}
inline std::istream& operator>>( std::istream& is, FFXIVARR_IPC_HEADER& hdr )
{
inline std::istream& operator>>( std::istream& is, FFXIVARR_IPC_HEADER& hdr )
{
return is.read( reinterpret_cast< char* >( &hdr ), sizeof hdr );
}
}
} /* Packets */
} /* Network */
} /* Core */
}
#endif /*_CORE_NETWORK_PACKETS_COMMON_H*/

View file

@ -12,25 +12,24 @@
#include "Acceptor.h"
#include <memory>
namespace Core {
namespace Network {
//-----------------------------------------------------------------------------
class Hive;
class Acceptor;
class Connection;
//-----------------------------------------------------------------------------
class Connection : public std::enable_shared_from_this< Connection >
namespace Core::Network
{
class Hive;
class Acceptor;
class Connection;
//-----------------------------------------------------------------------------
class Connection : public std::enable_shared_from_this< Connection >
{
friend class Acceptor;
friend class Hive;
protected:
protected:
HivePtr m_hive;
asio::ip::tcp::socket m_socket;
asio::strand m_io_strand;
@ -45,7 +44,7 @@ protected:
virtual ~Connection();
private:
private:
Connection( const Connection& rhs );
Connection& operator=( const Connection& rhs );
@ -67,7 +66,7 @@ private:
void HandleRecv( const asio::error_code& error, int32_t actual_bytes );
private:
private:
// Called when the connection has successfully connected to the local host.
virtual void OnAccept( const std::string& host, uint16_t port )
{
@ -98,7 +97,7 @@ private:
{
};
public:
public:
// Returns the Hive object.
HivePtr GetHive();
@ -138,15 +137,15 @@ public:
// Posts an asynchronous disconnect event for the object to process.
void Disconnect();
};
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
template< class T >
std::shared_ptr< T > addServerToHive( const std::string& listenIp, uint32_t port, HivePtr pHive )
{
template< class T >
std::shared_ptr< T > addServerToHive( const std::string& listenIp, uint32_t port, HivePtr pHive )
{
try
{
AcceptorPtr acceptor( new Acceptor( pHive ) );
@ -159,10 +158,7 @@ std::shared_ptr< T > addServerToHive( const std::string& listenIp, uint32_t port
{
throw;
}
}
}
}
}
#endif

View file

@ -14,57 +14,56 @@
#include "CommonNetwork.h"
#include "PacketDef/Ipcs.h"
namespace Core {
namespace Network {
namespace Packets {
// Must forward define these in order to enable the compiler to produce the
// correct template functions.
template< typename T, typename T1 >
class FFXIVIpcPacket;
template< class T >
using ZoneChannelPacket = FFXIVIpcPacket< T, ServerZoneIpcType >;
template< class T >
using ChatChannelPacket = FFXIVIpcPacket< T, ServerChatIpcType >;
template< class T >
using LobbyChannelPacket = FFXIVIpcPacket< T, ServerLobbyIpcType >;
template< class T, typename... Args >
std::shared_ptr< ZoneChannelPacket< T > > makeZonePacket( Args... args )
namespace Core::Network::Packets
{
// Must forward define these in order to enable the compiler to produce the
// correct template functions.
template< typename T, typename T1 >
class FFXIVIpcPacket;
template< class T >
using ZoneChannelPacket = FFXIVIpcPacket< T, ServerZoneIpcType >;
template< class T >
using ChatChannelPacket = FFXIVIpcPacket< T, ServerChatIpcType >;
template< class T >
using LobbyChannelPacket = FFXIVIpcPacket< T, ServerLobbyIpcType >;
template< class T, typename... Args >
std::shared_ptr< ZoneChannelPacket< T > > makeZonePacket( Args... args )
{
return std::make_shared< ZoneChannelPacket< T > >( args... );
}
}
template< class T, typename... Args >
std::shared_ptr< T > makeWrappedPacket( Args... args )
{
template< class T, typename... Args >
std::shared_ptr< T > makeWrappedPacket( Args... args )
{
return std::make_shared< T >( args... );
}
}
template< class T, typename... Args >
std::shared_ptr< ChatChannelPacket< T > > makeChatPacket( Args... args )
{
template< class T, typename... Args >
std::shared_ptr< ChatChannelPacket< T > > makeChatPacket( Args... args )
{
return std::make_shared< ChatChannelPacket< T > >( args... );
}
}
template< class T, typename... Args >
std::shared_ptr< LobbyChannelPacket< T > > makeLobbyPacket( Args... args )
{
template< class T, typename... Args >
std::shared_ptr< LobbyChannelPacket< T > > makeLobbyPacket( Args... args )
{
return std::make_shared< LobbyChannelPacket< T > >( args... );
}
}
/**
* The base implementation of a game packet. Needed for parsing packets.
*/
template< typename T1 >
class FFXIVIpcPacketBase
{
public:
/**
* The base implementation of a game packet. Needed for parsing packets.
*/
template< typename T1 >
class FFXIVIpcPacketBase
{
public:
virtual ~FFXIVIpcPacketBase() = default;
/**
@ -72,13 +71,13 @@ public:
* type of a parsed packet.)
*/
virtual T1 ipcType() = 0;
};
};
////////////////////////////////////////////////7
////////////////////////////////////////////////7
class FFXIVPacketBase
{
public:
class FFXIVPacketBase
{
public:
FFXIVPacketBase() :
m_segmentType( 0 )
{
@ -103,12 +102,12 @@ public:
return {};
}
protected:
protected:
/** The segment header */
FFXIVARR_PACKET_SEGMENT_HEADER m_segHdr;
uint16_t m_segmentType;
public:
public:
virtual uint32_t getContentSize()
{
return 0;
@ -174,13 +173,13 @@ public:
m_segHdr.type = getSegmentType();
}
};
};
template< typename T, typename T1 >
class FFXIVIpcPacket :
template< typename T, typename T1 >
class FFXIVIpcPacket :
public FFXIVIpcPacketBase< T1 >, public FFXIVPacketBase
{
public:
{
public:
FFXIVIpcPacket< T, T1 >( uint32_t sourceActorId, uint32_t targetActorId ) :
FFXIVPacketBase( 3, sourceActorId, targetActorId )
{
@ -249,7 +248,7 @@ public:
return m_data;
}
protected:
protected:
/** Initializes the fields of the header structures */
virtual void initialize()
{
@ -263,18 +262,18 @@ protected:
m_segHdr.size = sizeof( T ) + sizeof( FFXIVARR_IPC_HEADER ) + sizeof( FFXIVARR_PACKET_SEGMENT_HEADER );
};
protected:
protected:
/** The IPC packet header */
FFXIVARR_IPC_HEADER m_ipcHdr;
/** The underlying data portion of the packet as a structure */
T m_data;
};
};
class FFXIVRawPacket :
class FFXIVRawPacket :
public FFXIVPacketBase
{
public:
{
public:
FFXIVRawPacket( uint16_t type, uint32_t size, uint32_t sourceActorId, uint32_t targetActorId ) :
m_data( std::vector< uint8_t >( size - sizeof( FFXIVARR_PACKET_SEGMENT_HEADER ) ) ),
FFXIVPacketBase( type, sourceActorId, targetActorId )
@ -318,7 +317,7 @@ public:
return m_data;
};
protected:
protected:
/** Initializes the fields of the header structures */
virtual void initialize()
{
@ -326,14 +325,12 @@ protected:
memset( &m_data[ 0 ], 0, m_data.size() );
};
protected:
protected:
/** The underlying data portion of the packet as a structure */
std::vector< uint8_t > m_data;
};
};
} /* Packets */
} /* Network */
} /* Core */
}
#endif /*_CORE_NETWORK_PACKETS_CGAMEPACKETNEW_H*/

View file

@ -3,12 +3,11 @@
#include "CommonNetwork.h"
namespace Core {
namespace Network {
namespace Packets {
enum PacketParseResult
namespace Core::Network::Packets
{
enum PacketParseResult
{
/// Dissected game packet successfully
Success,
@ -17,37 +16,34 @@ enum PacketParseResult
/// Invalid data detected.
Malformed
};
};
/// Read packet header from buffer with given offset.
/// Buffer with given offset must be pointing to start of the new FFXIV packet.
PacketParseResult getHeader( const std::vector< uint8_t >& buffer, const uint32_t offset,
/// Read packet header from buffer with given offset.
/// Buffer with given offset must be pointing to start of the new FFXIV packet.
PacketParseResult getHeader( const std::vector< uint8_t >& buffer, const uint32_t offset,
FFXIVARR_PACKET_HEADER& header );
/// Read packet header from buffer with given offset.
/// Buffer with given offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data.
/// Keep in mind that this function does check for data validity. Call checkSegmentHeader() if that's needed.
PacketParseResult getSegmentHeader( const std::vector< uint8_t >& buffer, const uint32_t offset,
/// Read packet header from buffer with given offset.
/// Buffer with given offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data.
/// Keep in mind that this function does check for data validity. Call checkSegmentHeader() if that's needed.
PacketParseResult getSegmentHeader( const std::vector< uint8_t >& buffer, const uint32_t offset,
FFXIVARR_PACKET_SEGMENT_HEADER& header );
/// Read packets from the buffer with given offset.
/// Buffer with given offset must be pointing to end of FFXIVARR_PACKET_HEADER data.
PacketParseResult getPackets( const std::vector< uint8_t >& buffer, const uint32_t offset,
/// Read packets from the buffer with given offset.
/// Buffer with given offset must be pointing to end of FFXIVARR_PACKET_HEADER data.
PacketParseResult getPackets( const std::vector< uint8_t >& buffer, const uint32_t offset,
const FFXIVARR_PACKET_HEADER& header,
std::vector< Packets::FFXIVARR_PACKET_RAW >& packets );
/// Read single packet from the buffer with given offset.
/// Buffer with an offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data.
PacketParseResult getPacket( const std::vector< uint8_t >& buffer, const uint32_t offset,
/// Read single packet from the buffer with given offset.
/// Buffer with an offset must be pointing to start of FFXIVARR_PACKET_SEGMENT_HEADER data.
PacketParseResult getPacket( const std::vector< uint8_t >& buffer, const uint32_t offset,
FFXIVARR_PACKET_RAW& packet );
bool checkHeader( const FFXIVARR_PACKET_HEADER& header );
bool checkHeader( const FFXIVARR_PACKET_HEADER& header );
bool checkSegmentHeader( const FFXIVARR_PACKET_SEGMENT_HEADER& header );
bool checkSegmentHeader( const FFXIVARR_PACKET_SEGMENT_HEADER& header );
}
}
}
#endif

View file

@ -5,22 +5,22 @@
#include <atomic>
#include <memory>
namespace Core {
namespace Network {
class Hive : public std::enable_shared_from_this< Hive >
namespace Core:: Network
{
private:
class Hive : public std::enable_shared_from_this< Hive >
{
private:
asio::io_service m_io_service;
std::shared_ptr< asio::io_service::work > m_work_ptr;
std::atomic< uint32_t > m_shutdown;
private:
private:
Hive( const Hive& rhs );
Hive& operator=( const Hive& rhs );
public:
public:
Hive();
virtual ~Hive();
@ -48,9 +48,7 @@ public:
// Restarts the networking system after Stop as been called. A new work
// object is created ad the shutdown flag is cleared.
void Reset();
};
};
}
}
//-----------------------------------------------------------------------------
#endif

View file

@ -8,15 +8,14 @@
#include "GamePacketNew.h"
#include "Forwards.h"
namespace Core {
namespace Network {
namespace Packets {
typedef std::shared_ptr< FFXIVPacketBase > FFXIVPacketBasePtr;
class PacketContainer
namespace Core::Network::Packets
{
public:
using FFXIVPacketBasePtr = std::shared_ptr< FFXIVPacketBase >;
class PacketContainer
{
public:
PacketContainer( uint32_t segmentTargetOverride = 0 );
~PacketContainer();
@ -31,13 +30,11 @@ public:
void fillSendBuffer( std::vector< uint8_t >& sendBuffer );
private:
private:
uint32_t m_segmentTargetOverride;
};
};
}
}
}
#endif

View file

@ -7,12 +7,13 @@
#include <algorithm>
#include <utility>
namespace Core {
template< class T >
class LockedQueue
namespace Core
{
public:
template< class T >
class LockedQueue
{
public:
LockedQueue();
~LockedQueue();
@ -33,37 +34,37 @@ public:
std::size_t size();
protected:
protected:
std::queue< T > m_queue;
std::mutex m_mutex;
};
};
template< class T >
LockedQueue< T >::LockedQueue()
{
template< class T >
LockedQueue< T >::LockedQueue()
{
}
}
template< class T >
std::size_t LockedQueue< T >::size()
{
template< class T >
std::size_t LockedQueue< T >::size()
{
std::lock_guard< std::mutex > lock( m_mutex );
return m_queue.size();
}
}
template< class T >
LockedQueue< T >::~LockedQueue()
{
template< class T >
LockedQueue< T >::~LockedQueue()
{
}
}
template< class T >
T LockedQueue< T >::pop()
{
template< class T >
T LockedQueue< T >::pop()
{
std::lock_guard< std::mutex > lock( m_mutex );
if( m_queue.empty() )
@ -76,18 +77,18 @@ T LockedQueue< T >::pop()
m_queue.pop();
return result;
}
}
template< class T >
void LockedQueue< T >::push( const T object )
{
template< class T >
void LockedQueue< T >::push( const T object )
{
std::lock_guard< std::mutex > lock( m_mutex );
m_queue.push( object );
}
}
template< class T >
void LockedQueue< T >::push_swap( T& object )
{
template< class T >
void LockedQueue< T >::push_swap( T& object )
{
std::lock_guard< std::mutex > lock( m_mutex );
m_queue.push( object );
@ -105,11 +106,11 @@ void LockedQueue< T >::push_swap( T& object )
// this will allow that the object on the queue is the *last* shared_ptr
// in existance by the time this function returns.
}
}
template< class T >
void LockedQueue< T >::push_reset( T& object )
{
template< class T >
void LockedQueue< T >::push_reset( T& object )
{
std::lock_guard< std::mutex > lock( m_mutex );
m_queue.push( object );
@ -123,6 +124,6 @@ void LockedQueue< T >::push_reset( T& object )
// this will allow that the object on the queue is the *last* shared_ptr
// in existance by the time this function returns.
}
}
}

View file

@ -8,18 +8,19 @@
#include <type_traits>
#include <utility>
namespace Core {
template< typename T >
class LockedWaitQueue
namespace Core
{
private:
template< typename T >
class LockedWaitQueue
{
private:
std::mutex m_queueLock;
std::queue< T > m_queue;
std::condition_variable m_condition;
std::atomic< bool > m_shutdown;
public:
public:
LockedWaitQueue< T >() :
m_shutdown( false )
@ -88,7 +89,7 @@ public:
m_condition.notify_all();
}
private:
private:
template< typename E = T >
typename std::enable_if< std::is_pointer< E >::value >::type deleteQueuedObject( E& obj )
{
@ -99,7 +100,7 @@ private:
typename std::enable_if< !std::is_pointer< E >::value >::type deleteQueuedObject( E const& )
{
}
};
};
}
#endif

View file

@ -5,12 +5,14 @@
#include <unordered_map>
#include <type_traits>
namespace Core {
namespace Util {
template< typename T, typename ActorIdType = uint32_t >
class SpawnIndexAllocator
namespace Core::Util
{
public:
template< typename T, typename ActorIdType = uint32_t >
class SpawnIndexAllocator
{
public:
static_assert( std::is_same< T, uint8_t >::value || std::is_same< T, uint16_t >::value ||
std::is_same< T, uint32_t >::value || std::is_same< T, uint64_t >::value,
"T must be uint8_t, uint16_t, uint32_t, uint64_t" );
@ -76,7 +78,7 @@ public:
return static_cast< T >( -1 );
}
protected:
protected:
void setupQueue()
{
assert( m_maxSlotId != 0 );
@ -100,9 +102,7 @@ protected:
T m_maxSlotId;
bool m_reserveFirstSlot;
};
};
}
}
#endif //SAPPHIRE_SPAWNINDEXALLOCATOR_H

View file

@ -5,33 +5,34 @@
#include <string>
#include <functional>
namespace Core::Util {
std::string binaryToHexString( uint8_t* pBinData, uint16_t size );
std::string binaryToHexDump( uint8_t* pBinData, uint16_t size );
std::string intToHexString( uint64_t intValue, uint8_t width = 2 );
void eraseAll( std::string& inOutStr, char remove );
void eraseAllIn( std::string& inOutStr, std::string& remove );
std::string toLowerCopy( const std::string& inStr );
uint64_t getTimeMs();
int64_t getTimeSeconds();
uint64_t getEorzeanTimeStamp();
void valueToFlagByteIndexValue( uint32_t inVal, uint8_t& outVal, uint16_t& outIndex );
template <class T>
inline void hashCombine( std::size_t& seed, const T& v )
namespace Core::Util
{
std::hash<T> hasher;
std::string binaryToHexString( uint8_t* pBinData, uint16_t size );
std::string binaryToHexDump( uint8_t* pBinData, uint16_t size );
std::string intToHexString( uint64_t intValue, uint8_t width = 2 );
void eraseAll( std::string& inOutStr, char remove );
void eraseAllIn( std::string& inOutStr, std::string& remove );
std::string toLowerCopy( const std::string& inStr );
uint64_t getTimeMs();
int64_t getTimeSeconds();
uint64_t getEorzeanTimeStamp();
void valueToFlagByteIndexValue( uint32_t inVal, uint8_t& outVal, uint16_t& outIndex );
template <class T>
inline void hashCombine( std::size_t& seed, const T& v )
{
std::hash< T > hasher;
seed ^= hasher( v ) + 0x9e3779b9 + ( seed << 6 ) + ( seed >> 2 );
}
}
}

View file

@ -5,31 +5,30 @@
#define PI 3.14159265358979323846f
namespace Core {
namespace Math {
namespace Util {
float distanceSq( float x, float y, float z, float x1, float y1, float z1 );
float distance( float x, float y, float z, float x1, float y1, float z1 );
float distance2DSq( float x, float y, float x1, float y1 );
float distance2D( float x, float y, float x1, float y1 );
float calcAngTo( float x, float y, float x1, float y1 );
float calcAngFrom( float x, float y, float x1, float y1 );
uint16_t floatToUInt16( float val );
uint16_t floatToUInt16Rot( float val );
uint8_t floatToUInt8Rot( float val );
template < typename T >
T clamp( T val, T minimum, T maximum )
namespace Core::Math::Util
{
float distanceSq( float x, float y, float z, float x1, float y1, float z1 );
float distance( float x, float y, float z, float x1, float y1, float z1 );
float distance2DSq( float x, float y, float x1, float y1 );
float distance2D( float x, float y, float x1, float y1 );
float calcAngTo( float x, float y, float x1, float y1 );
float calcAngFrom( float x, float y, float x1, float y1 );
uint16_t floatToUInt16( float val );
uint16_t floatToUInt16Rot( float val );
uint8_t floatToUInt8Rot( float val );
template < typename T >
T clamp( T val, T minimum, T maximum )
{
if( val > maximum )
return maximum;
@ -37,10 +36,8 @@ T clamp( T val, T minimum, T maximum )
return minimum;
return val;
}
}
}
}
}
#endif

View file

@ -3,13 +3,10 @@
#include <string>
namespace Core {
namespace Version {
extern const std::string GIT_HASH;
extern const std::string VERSION;
} /* Version */
} /* Core */
namespace Core::Version
{
extern const std::string GIT_HASH;
extern const std::string VERSION;
}
#endif

View file

@ -56,7 +56,7 @@ foreach(_scriptDir ${children})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ScriptLoader.cpp.in" "${_scriptDir}/ScriptLoader.cpp")
cotire("script_${_name}")
#cotire("script_${_name}")
if(MSVC)
add_custom_command(TARGET "script_${_name}" POST_BUILD

View file

@ -10,6 +10,8 @@
#define AETHERYTE_MENU_FAVORITE_POINT 4
#define AETHERYTE_MENU_FAVORITE_POINT_SECURITY_TOKEN 5
using namespace Core;
class Aethernet :
public EventScript
{

View file

@ -12,6 +12,8 @@
#define AETHERYTE_MENU_FAVORITE_POINT 4
#define AETHERYTE_MENU_FAVORITE_POINT_SECURITY_TOKEN 5
using namespace Core;
class Aetheryte :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefCutSceneReplay :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefHousingSignboard :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefInnBed :
public EventScript
{

View file

@ -5,6 +5,8 @@
#define ACTION_RENAME 3
#define ACTION_REMOVE 4
using namespace Core;
class CmnDefLinkShell :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefMarketBoardGridania :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefMogLetter :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefNpcRepair :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class CmnDefWeatherForeCast :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class ComDefMobHuntBoard :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class GilShop :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
using namespace Core;
class HouFurOrchestrion :
public EventScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors101110 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors110 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors111120 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors1120 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors121130 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors131140 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors141150 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors151160 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors161170 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors171180 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors181190 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors191200 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors2130 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors3140 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors4150 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors5160 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors6170 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors7180 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors8190 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ThePalaceoftheDeadFloors91100 :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class AlaMhigo :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class AmdaporKeep :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class AmdaporKeepHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class BaelsarsWall :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class BardamsMettle :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class BrayfloxsLongstop :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class BrayfloxsLongstopHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class CastrumAbania :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class CastrumMeridianum :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class CopperbellMines :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class CopperbellMinesHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class CuttersCry :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class DomaCastle :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class DzemaelDarkhold :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class Halatali :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class HalataliHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class HaukkeManor :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class HaukkeManorHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class HellsLid :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class HullbreakerIsle :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class HullbreakerIsleHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class KuganeCastle :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class Neverreap :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class PharosSirius :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class PharosSiriusHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class SaintMociannesArboretum :
public InstanceContentScript
{

View file

@ -2,6 +2,8 @@
#include <Zone/InstanceContent.h>
#include <Actor/Player.h>
using namespace Core;
class Sastasha :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class SastashaHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class ShisuioftheVioletTides :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class Snowcloak :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class SohmAl :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class SohmAlHard :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class SohrKhai :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class TheAery :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class TheAetherochemicalResearchFacility :
public InstanceContentScript
{

View file

@ -1,6 +1,8 @@
#include <ScriptObject.h>
#include <Zone/InstanceContent.h>
using namespace Core;
class TheAntitower :
public InstanceContentScript
{

Some files were not shown because too many files have changed in this diff Show more