1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

refactor Util -> Common::Util & Action to World::Action

This commit is contained in:
NotAdam 2019-06-02 00:34:22 +10:00
parent 33d83fa1e4
commit f892257aa5
68 changed files with 200 additions and 181 deletions

View file

@ -106,7 +106,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

View file

@ -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)

View file

@ -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 ),

View file

@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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 )
{

View file

@ -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;

View file

@ -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 )
{

View file

@ -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();

View file

@ -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 );
};

View file

@ -76,7 +76,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";

View file

@ -7,7 +7,7 @@
#include <algorithm>
#include <utility>
namespace Sapphire
namespace Sapphire::Common::Util
{
template< class T >

View file

@ -8,7 +8,7 @@
#include <type_traits>
#include <utility>
namespace Sapphire
namespace Sapphire::Common::Util
{
template< typename T >

View file

@ -5,7 +5,7 @@
#include <unordered_map>
#include <type_traits>
namespace Sapphire::Util
namespace Sapphire::Common::Util
{
template< typename T, typename ActorIdType = uint32_t >

View file

@ -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;

View file

@ -5,7 +5,7 @@
#include <string>
#include <functional>
namespace Sapphire::Util
namespace Sapphire::Common::Util
{
std::string binaryToHexString( uint8_t* pBinData, uint16_t size );

View file

@ -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,29 @@ 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 Common::FFXIVARR_POSITION3& pos1, const 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 +48,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 +62,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 );
}

View file

@ -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 );

View file

@ -36,8 +36,8 @@ namespace Sapphire::Network
LobbySessionPtr m_pSession;
LockedQueue< Packets::GamePacketPtr > m_inQueue;
LockedQueue< Packets::GamePacketPtr > m_outQueue;
Common::Util::LockedQueue< Packets::GamePacketPtr > m_inQueue;
Common::Util::LockedQueue< Packets::GamePacketPtr > m_outQueue;
std::vector< uint8_t > m_packets;
public:

View file

@ -48,7 +48,7 @@ uint8_t* Sapphire::Network::Packets::LobbyPacketContainer::getRawData( bool adds
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;

View file

@ -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;
}
};

View file

@ -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;

View file

@ -11,7 +11,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
auto sourceChara = action.getSourceChara();

View file

@ -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();

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
if( auto player = action.getSourceChara()->getAsPlayer() )
player->sendDebug( "Imagine you just hit an enemy for 150 potency. Incredible, right?" );

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
}

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
for( auto& chara : action.getHitCharas() )
{

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
auto chara = action.getHitChara();
chara->takeDamage( chara->getMaxHp() * 0.34f );

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
}

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
}

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
}

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
for( auto& chara : action.getHitCharas() )
{

View file

@ -12,7 +12,7 @@ public:
{
}
void onExecute( Sapphire::Action::Action& action ) override
void onExecute( Sapphire::World::Action::Action& action ) override
{
}

View file

@ -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();

View file

@ -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;

View file

@ -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() )

View file

@ -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 ] );

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1,4 +1,5 @@
#include "Action.h"
#include "ActionLut.h"
#include <Exd/ExdDataGenerated.h>
#include <Util/Util.h>
@ -26,16 +27,18 @@ using namespace Sapphire::Network::Packets;
using namespace Sapphire::Network::Packets::Server;
using namespace Sapphire::Network::ActorControl;
using namespace Sapphire::World::Action;
Sapphire::Action::Action::Action() = default;
Sapphire::Action::Action::~Action() = default;
Sapphire::Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, FrameworkPtr fw ) :
Action::Action() = default;
Action::~Action() = default;
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,
Action::Action( Entity::CharaPtr caster, uint32_t actionId,
Data::ActionPtr actionData, FrameworkPtr fw ) :
m_pSource( std::move( caster ) ),
m_pFw( std::move( fw ) ),
@ -47,12 +50,12 @@ Sapphire::Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId,
{
}
uint32_t Sapphire::Action::Action::getId() const
uint32_t Action::getId() const
{
return m_id;
}
bool Sapphire::Action::Action::init()
bool Action::init()
{
if( !m_actionData )
{
@ -121,62 +124,62 @@ bool Sapphire::Action::Action::init()
return true;
}
void Sapphire::Action::Action::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
void Action::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
{
m_pos = pos;
}
Sapphire::Common::FFXIVARR_POSITION3 Sapphire::Action::Action::getPos() const
Sapphire::Common::FFXIVARR_POSITION3 Action::getPos() const
{
return m_pos;
}
void Sapphire::Action::Action::setTargetId( uint64_t targetId )
void Action::setTargetId( uint64_t targetId )
{
m_targetId = targetId;
}
uint64_t Sapphire::Action::Action::getTargetId() const
uint64_t Action::getTargetId() const
{
return m_targetId;
}
bool Sapphire::Action::Action::hasClientsideTarget() const
bool Action::hasClientsideTarget() const
{
return m_targetId > 0xFFFFFFFF;
}
bool Sapphire::Action::Action::isInterrupted() const
bool Action::isInterrupted() const
{
return m_interruptType != Common::ActionInterruptType::None;
}
void Sapphire::Action::Action::setInterrupted( Common::ActionInterruptType type )
void Action::setInterrupted( Common::ActionInterruptType type )
{
m_interruptType = type;
}
uint32_t Sapphire::Action::Action::getCastTime() const
uint32_t Action::getCastTime() const
{
return m_castTimeMs;
}
void Sapphire::Action::Action::setCastTime( uint32_t castTime )
void Action::setCastTime( uint32_t castTime )
{
m_castTimeMs = castTime;
}
bool Sapphire::Action::Action::hasCastTime() const
bool Action::hasCastTime() const
{
return m_castTimeMs > 0;
}
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getSourceChara() const
Sapphire::Entity::CharaPtr Action::getSourceChara() const
{
return m_pSource;
}
bool Sapphire::Action::Action::update()
bool Action::update()
{
// action has not been started yet
if( m_startTime == 0 )
@ -193,7 +196,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 +207,11 @@ bool Sapphire::Action::Action::update()
return false;
}
void Sapphire::Action::Action::start()
void Action::start()
{
assert( m_pSource );
m_startTime = Util::getTimeMs();
m_startTime = Common::Util::getTimeMs();
auto player = m_pSource->getAsPlayer();
@ -238,6 +241,9 @@ void Sapphire::Action::Action::start()
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
if( !pScriptMgr->onStart( *this ) )
{
// check the lut initially and see if we have something usable, otherwise cancel the cast
// Sapphire::World::Action::ActionLut::validEntryExists( getId() );
// script not implemented
interrupt();
@ -255,7 +261,7 @@ void Sapphire::Action::Action::start()
execute();
}
void Sapphire::Action::Action::interrupt()
void Action::interrupt()
{
assert( m_pSource );
@ -289,7 +295,7 @@ void Sapphire::Action::Action::interrupt()
pScriptMgr->onInterrupt( *this );
}
void Sapphire::Action::Action::execute()
void Action::execute()
{
assert( m_pSource );
@ -346,7 +352,7 @@ void Sapphire::Action::Action::execute()
}
}
bool Sapphire::Action::Action::precheck()
bool Action::precheck()
{
if( auto player = m_pSource->getAsPlayer() )
{
@ -357,7 +363,7 @@ bool Sapphire::Action::Action::precheck()
return true;
}
bool Sapphire::Action::Action::playerPrecheck( Entity::Player& player )
bool Action::playerPrecheck( Entity::Player& player )
{
// lol
if( !player.isAlive() )
@ -408,17 +414,17 @@ bool Sapphire::Action::Action::playerPrecheck( Entity::Player& player )
return true;
}
uint32_t Sapphire::Action::Action::getAdditionalData() const
uint32_t Action::getAdditionalData() const
{
return m_additionalData;
}
void Sapphire::Action::Action::setAdditionalData( uint32_t data )
void Action::setAdditionalData( uint32_t data )
{
m_additionalData = data;
}
bool Sapphire::Action::Action::isComboAction() const
bool Action::isComboAction() const
{
auto lastActionId = m_pSource->getLastComboActionId();
@ -430,7 +436,7 @@ bool Sapphire::Action::Action::isComboAction() const
return m_actionData->actionCombo == lastActionId;
}
bool Sapphire::Action::Action::primaryCostCheck( bool subtractCosts )
bool Action::primaryCostCheck( bool subtractCosts )
{
switch( m_primaryCostType )
{
@ -473,23 +479,23 @@ bool Sapphire::Action::Action::primaryCostCheck( bool subtractCosts )
}
}
bool Sapphire::Action::Action::secondaryCostCheck( bool subtractCosts )
bool Action::secondaryCostCheck( bool subtractCosts )
{
// todo: these need to be mapped
return true;
}
bool Sapphire::Action::Action::hasResources()
bool Action::hasResources()
{
return primaryCostCheck( false ) && secondaryCostCheck( false );
}
bool Sapphire::Action::Action::consumeResources()
bool Action::consumeResources()
{
return primaryCostCheck( true ) && secondaryCostCheck( true );
}
bool Sapphire::Action::Action::snapshotAffectedActors( std::vector< Entity::CharaPtr >& actors )
bool Action::snapshotAffectedActors( std::vector< Entity::CharaPtr >& actors )
{
for( const auto& actor : m_pSource->getInRangeActors( true ) )
{
@ -519,12 +525,12 @@ bool Sapphire::Action::Action::snapshotAffectedActors( std::vector< Entity::Char
return !actors.empty();
}
void Sapphire::Action::Action::addActorFilter( World::Util::ActorFilterPtr filter )
void Action::addActorFilter( World::Util::ActorFilterPtr filter )
{
m_actorFilters.push_back( std::move( filter ) );
}
void Sapphire::Action::Action::addDefaultActorFilters()
void Action::addDefaultActorFilters()
{
switch( m_castType )
{
@ -561,7 +567,7 @@ void Sapphire::Action::Action::addDefaultActorFilters()
}
}
bool Sapphire::Action::Action::preFilterActor( Sapphire::Entity::Actor& actor ) const
bool Action::preFilterActor( Sapphire::Entity::Actor& actor ) const
{
auto kind = actor.getObjKind();
@ -574,12 +580,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::getHitCharas()
{
return m_hitActors;
}
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getHitChara()
Sapphire::Entity::CharaPtr Action::getHitChara()
{
if( !m_hitActors.empty() )
{

View file

@ -11,7 +11,7 @@ namespace Sapphire::Data
using ActionPtr = std::shared_ptr< Action >;
}
namespace Sapphire::Action
namespace Sapphire::World::Action
{
class Action

View file

@ -11,15 +11,16 @@
#include "EventAction.h"
#include "Framework.h"
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 +34,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 +55,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 +91,7 @@ void Sapphire::Action::EventAction::execute()
}
void Sapphire::Action::EventAction::interrupt()
void Action::EventAction::interrupt()
{
if( !m_pSource )
return;

View file

@ -6,7 +6,7 @@
#include "ForwardsZone.h"
#include "Action.h"
namespace Sapphire::Action
namespace Sapphire::World::Action
{
class EventAction : public Action

View file

@ -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 );
}

View file

@ -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 );

View file

@ -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 );
}

View file

@ -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;

View file

@ -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,

View file

@ -82,7 +82,7 @@ TYPE_FORWARD( Director );
TYPE_FORWARD( EventHandler );
}
namespace Action
namespace World::Action
{
TYPE_FORWARD( Action );
TYPE_FORWARD( EventAction );

View file

@ -683,7 +683,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 );
}
}

View file

@ -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;

View file

@ -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

View file

@ -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< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
Common::Util::LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
std::vector< uint8_t > m_packets;
public:

View file

@ -393,7 +393,7 @@ void Sapphire::Network::GameConnection::pingHandler( FrameworkPtr pFw,
queueOutPacket( std::make_shared< Server::PingPacket >( player, packet.data().timestamp ) );
player.setLastPing( Sapphire::Util::getTimeSeconds() );
player.setLastPing( Common::Util::getTimeSeconds() );
}

View file

@ -28,15 +28,15 @@ namespace Sapphire::Network::Packets::Server
void initialize( Entity::Chara& actor, uint8_t headRotation, uint8_t animationType, uint8_t state, uint16_t animationSpeed, uint8_t unknownRotation )
{
m_data.rotation = Util::floatToUInt8Rot( actor.getRot() );
m_data.rotation = Common::Util::floatToUInt8Rot( actor.getRot() );
m_data.headRotation = headRotation;
m_data.animationType = animationType;
m_data.animationState = state;
m_data.animationSpeed = animationSpeed;
m_data.unknownRotation = unknownRotation;
m_data.posX = Util::floatToUInt16( actor.getPos().x );
m_data.posY = Util::floatToUInt16( actor.getPos().y );
m_data.posZ = Util::floatToUInt16( actor.getPos().z );
m_data.posX = Common::Util::floatToUInt16( actor.getPos().x );
m_data.posY = Common::Util::floatToUInt16( actor.getPos().y );
m_data.posZ = Common::Util::floatToUInt16( actor.getPos().z );
};
};

View file

@ -49,7 +49,7 @@ namespace Sapphire::Network::Packets::Server
m_data.pos.x = bnpc.getPos().x;
m_data.pos.y = bnpc.getPos().y;
m_data.pos.z = bnpc.getPos().z;
m_data.rotation = Util::floatToUInt16Rot( bnpc.getRot() );
m_data.rotation = Common::Util::floatToUInt16Rot( bnpc.getRot() );
m_data.levelId = bnpc.getLevelId();
m_data.enemyType = bnpc.getEnemyType();
@ -87,7 +87,7 @@ namespace Sapphire::Network::Packets::Server
m_data.targetId = static_cast< uint64_t >( bnpc.getTargetId() );
uint64_t currentTimeMs = Sapphire::Util::getTimeMs();
uint64_t currentTimeMs = Common::Util::getTimeMs();
for( auto const& effect : bnpc.getStatusEffectMap() )
{

View file

@ -69,7 +69,7 @@ namespace Sapphire::Network::Packets::Server
m_data.pos.x = player.getPos().x;
m_data.pos.y = player.getPos().y;
m_data.pos.z = player.getPos().z;
m_data.rotation = Util::floatToUInt16Rot( player.getRot() );
m_data.rotation = Common::Util::floatToUInt16Rot( player.getRot() );
m_data.title = player.getTitle();
@ -133,7 +133,7 @@ namespace Sapphire::Network::Packets::Server
//m_data.unknown_60 = 3;
//m_data.unknown_61 = 7;
uint64_t currentTimeMs = Sapphire::Util::getTimeMs();
uint64_t currentTimeMs = Common::Util::getTimeMs();
for( auto const& effect : player.getStatusEffectMap() )
{

View file

@ -83,20 +83,20 @@ namespace Sapphire::ScriptAPI
///////////////////////////////////////////////////////////////////
ActionScript::ActionScript( uint32_t abilityId ) :
ScriptObject( abilityId, typeid( ActionScript ).hash_code() )
ActionScript::ActionScript( uint32_t actionId ) :
ScriptObject( actionId, typeid( ActionScript ).hash_code() )
{
}
void ActionScript::onStart( Sapphire::Action::Action& action )
void ActionScript::onStart( Sapphire::World::Action::Action& action )
{
}
void ActionScript::onExecute( Sapphire::Action::Action& action )
void ActionScript::onExecute( Sapphire::World::Action::Action& action )
{
}
void ActionScript::onInterrupt( Sapphire::Action::Action& action )
void ActionScript::onInterrupt( Sapphire::World::Action::Action& action )
{
}

View file

@ -138,13 +138,13 @@ namespace Sapphire::ScriptAPI
class ActionScript : public ScriptObject
{
public:
explicit ActionScript( uint32_t abilityId );
explicit ActionScript( uint32_t actionId );
virtual void onStart( Sapphire::Action::Action& action );
virtual void onStart( Sapphire::World::Action::Action& action );
virtual void onExecute( Sapphire::Action::Action& action );
virtual void onExecute( Sapphire::World::Action::Action& action );
virtual void onInterrupt( Sapphire::Action::Action& action );
virtual void onInterrupt( Sapphire::World::Action::Action& action );
};
/*!

View file

@ -154,7 +154,7 @@ bool Sapphire::Scripting::ScriptLoader::isModuleLoaded( std::string name )
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
{
if( Util::toLowerCopy( it->second->library_name ) == Util::toLowerCopy( name ) )
if( Common::Util::toLowerCopy( it->second->library_name ) == Common::Util::toLowerCopy( name ) )
return true;
}

View file

@ -329,7 +329,7 @@ bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player
return didCallScript;
}
bool Sapphire::Scripting::ScriptMgr::onExecute( Action::Action& action )
bool Sapphire::Scripting::ScriptMgr::onExecute( World::Action::Action& action )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( action.getId() );
@ -341,7 +341,7 @@ bool Sapphire::Scripting::ScriptMgr::onExecute( Action::Action& action )
return false;
}
bool Sapphire::Scripting::ScriptMgr::onInterrupt( Action::Action& action )
bool Sapphire::Scripting::ScriptMgr::onInterrupt( World::Action::Action& action )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( action.getId() );
@ -353,7 +353,7 @@ bool Sapphire::Scripting::ScriptMgr::onInterrupt( Action::Action& action )
return false;
}
bool Sapphire::Scripting::ScriptMgr::onStart( Action::Action& action )
bool Sapphire::Scripting::ScriptMgr::onStart( World::Action::Action& action )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( action.getId() );

View file

@ -72,11 +72,11 @@ namespace Sapphire::Scripting
bool onEObjHit( Entity::Player& player, uint64_t actorId, uint32_t actionId );
bool onStart( Action::Action& action );
bool onStart( World::Action::Action& action );
bool onInterrupt( Action::Action& action );
bool onInterrupt( World::Action::Action& action );
bool onExecute( Action::Action& action );
bool onExecute( World::Action::Action& action );
bool onStatusReceive( Entity::CharaPtr pActor, uint32_t effectId );

View file

@ -270,8 +270,8 @@ void Sapphire::World::ServerMgr::mainLoop()
{
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
auto currTime = Util::getTimeSeconds();
auto tickCount = Util::getTimeMs();
auto currTime = Common::Util::getTimeSeconds();
auto tickCount = Common::Util::getTimeMs();
pTeriMgr->updateTerritoryInstances( tickCount );

View file

@ -14,8 +14,8 @@ namespace fs = std::experimental::filesystem;
Sapphire::World::Session::Session( uint32_t sessionId, FrameworkPtr pFw ) :
m_sessionId( sessionId ),
m_lastDataTime( Util::getTimeSeconds() ),
m_lastSqlTime( Util::getTimeSeconds() ),
m_lastDataTime( Common::Util::getTimeSeconds() ),
m_lastSqlTime( Common::Util::getTimeSeconds() ),
m_isValid( false ),
m_pFw( std::move( pFw ) ),
m_isReplaying( false )
@ -102,12 +102,12 @@ bool Sapphire::World::Session::isValid() const
void Sapphire::World::Session::updateLastDataTime()
{
m_lastDataTime = Util::getTimeSeconds();
m_lastDataTime = Common::Util::getTimeSeconds();
}
void Sapphire::World::Session::updateLastSqlTime()
{
m_lastSqlTime = Util::getTimeSeconds();
m_lastSqlTime = Common::Util::getTimeSeconds();
}
void Sapphire::World::Session::startReplay( const std::string& path )
@ -146,7 +146,7 @@ void Sapphire::World::Session::startReplay( const std::string& path )
for( auto set : loadedSets )
{
m_replayCache.push_back( std::tuple< uint64_t, std::string >(
Util::getTimeMs() + ( std::get< 0 >( set ) - startTime ), std::get< 1 >( set ) ) );
Common::Util::getTimeMs() + ( std::get< 0 >( set ) - startTime ), std::get< 1 >( set ) ) );
Logger::info( "Registering {0} for {1}", std::get< 1 >( set ), std::get< 0 >( set ) - startTime );
}
@ -166,7 +166,7 @@ void Sapphire::World::Session::processReplay()
int at = 0;
for( const auto& set : m_replayCache )
{
if( std::get< 0 >( set ) <= Util::getTimeMs() )
if( std::get< 0 >( set ) <= Common::Util::getTimeMs() )
{
m_pZoneConnection->injectPacket( std::get< 1 >( set ), *getPlayer().get() );
m_replayCache.erase( m_replayCache.begin() + at );
@ -201,9 +201,9 @@ void Sapphire::World::Session::update()
m_pZoneConnection->processInQueue();
// SESSION LOGIC
m_pPlayer->update( Util::getTimeMs() );
m_pPlayer->update( Common::Util::getTimeMs() );
if( Util::getTimeSeconds() - static_cast< uint32_t >( getLastSqlTime() ) > 10 )
if( Common::Util::getTimeSeconds() - static_cast< uint32_t >( getLastSqlTime() ) > 10 )
{
updateLastSqlTime();
m_pPlayer->updateSql();

View file

@ -419,7 +419,7 @@ void Sapphire::Zone::updateBNpcs( uint64_t tickCount )
return;
m_lastMobUpdate = tickCount;
uint64_t currTime = Sapphire::Util::getTimeSeconds();
uint64_t currTime = Common::Util::getTimeSeconds();
for( const auto& entry : m_bNpcMap )
{

View file

@ -13,7 +13,7 @@ Sapphire::World::Util::ActorFilterInRange::ActorFilterInRange( Common::FFXIVARR_
bool Sapphire::World::Util::ActorFilterInRange::conditionApplies( const Entity::Actor& actor )
{
return Sapphire::Util::distance( m_startPos, actor.getPos() ) <= m_range;
return Sapphire::Common::Util::distance( m_startPos, actor.getPos() ) <= m_range;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////