mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-21 20:27:46 +00:00
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
![]() |
#include "Util.h"
|
||
|
#include <chrono>
|
||
|
|
||
|
std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size )
|
||
|
{
|
||
|
|
||
|
std::string outStr;
|
||
|
|
||
|
for( unsigned int i = 0; i < size; i++ )
|
||
|
{
|
||
|
outStr += boost::str( boost::format( "%|02X|" ) % ( int ) ( pBinData[i] & 0xFF ) );
|
||
|
}
|
||
|
|
||
|
return outStr;
|
||
|
|
||
|
}
|
||
|
|
||
|
uint64_t Core::Util::getTimeMs()
|
||
|
{
|
||
|
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||
|
auto now_ms = std::chrono::time_point_cast< std::chrono::milliseconds >( t1 ).time_since_epoch().count();
|
||
|
|
||
|
return now_ms;
|
||
|
}
|
||
|
|
||
|
uint64_t Core::Util::getEorzeanTimeStamp()
|
||
|
{
|
||
|
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||
|
auto now = std::chrono::time_point_cast< std::chrono::seconds >( t1 ).time_since_epoch().count();
|
||
|
|
||
|
return static_cast< uint64_t >( now * 20.571428571428573f );
|
||
|
}
|
||
|
|
||
|
void Core::Util::valueToFlagByteIndexValue( uint32_t inVal, uint8_t& outVal, uint16_t& outIndex )
|
||
|
{
|
||
|
uint32_t id = inVal;
|
||
|
outIndex = id / 8;
|
||
|
uint8_t bitIndex = id % 8;
|
||
|
|
||
|
outVal = 1 << bitIndex;
|
||
|
}
|
||
|
|