1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

Various small cleanups

This commit is contained in:
root 2018-09-26 08:47:22 -04:00
parent 94b111ee85
commit d1efbe6307
13 changed files with 51 additions and 77 deletions

View file

@ -4,7 +4,6 @@
#include <cstdint>
#include <vector>
#include <boost/make_shared.hpp>
#include "CommonGen.h"
// +---------------------------------------------------------------------------
@ -27,8 +26,7 @@ struct FFXIVARR_POSITION3
float z;
};
enum InventoryOperation :
uint8_t
enum InventoryOperation : uint8_t
{
Discard = 0x07,
Move = 0x08,
@ -37,8 +35,7 @@ enum InventoryOperation :
Split = 0x0A
};
enum ClientLanguage :
uint8_t
enum ClientLanguage : uint8_t
{
Japanese = 1,
English = 2,
@ -46,8 +43,7 @@ enum ClientLanguage :
French = 8
};
enum ObjKind :
uint8_t
enum ObjKind : uint8_t
{
None = 0x00,
Player = 0x01,
@ -66,15 +62,13 @@ enum ObjKind :
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,
@ -84,8 +78,7 @@ enum class DisplayFlags :
Visor = 0x800,
};
enum struct ActorStatus :
uint8_t
enum struct ActorStatus : uint8_t
{
Idle = 0x01,
Dead = 0x02,
@ -99,8 +92,7 @@ enum struct ActorStatus :
EmoteMode = 0x0B
};
enum GearSetSlot :
uint8_t
enum GearSetSlot : uint8_t
{
MainHand = 0,
OffHand = 1,
@ -173,8 +165,7 @@ enum EquipSlotCategory : uint8_t
BodyDisallowLegsFeet = 21,
};
enum InventoryType :
uint16_t
enum InventoryType : uint16_t
{
Bag0 = 0,
Bag1 = 1,
@ -226,8 +217,7 @@ enum InventoryType :
FreeCompanyCrystal = 22001
};
enum ContainerType :
uint16_t
enum ContainerType : uint16_t
{
Unknown = 0,
Bag = 1,
@ -237,8 +227,7 @@ enum ContainerType :
};
enum CurrencyType :
uint8_t
enum CurrencyType : uint8_t
{
Gil = 0x01,
StormSeal = 0x02,
@ -256,8 +245,7 @@ enum CurrencyType :
TomestoneLore = 0x0E
};
enum CrystalType :
uint8_t
enum CrystalType : uint8_t
{
FireShard = 0x01,
IceShard = 0x02,
@ -281,8 +269,7 @@ enum CrystalType :
WaterCluster = 0x12
};
enum struct ZoneingType :
uint8_t
enum struct ZoneingType : uint8_t
{
None = 1,
Teleport = 2,
@ -291,24 +278,21 @@ enum struct ZoneingType :
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,

View file

@ -5,9 +5,7 @@
namespace Core {
enum struct LoggingSeverity :
uint8_t
enum struct LoggingSeverity : uint8_t
{
trace = 0,
debug = 1,
@ -50,4 +48,4 @@ public:
}
#endif
#endif

View file

@ -2,7 +2,6 @@
#define ACCEPTOR_H_
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include "Forwards.h"

View file

@ -5,8 +5,6 @@
#include <vector>
#include "PacketDef/Ipcs.h"
using namespace std;
namespace Core {
namespace Network {
namespace Packets {
@ -70,12 +68,12 @@ struct FFXIVARR_PACKET_HEADER
uint32_t unknown_24;
};
inline ostream& operator<<( 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 istream& operator>>( 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 );
}
@ -108,12 +106,12 @@ struct FFXIVARR_PACKET_SEGMENT_HEADER
uint16_t padding;
};
inline ostream& operator<<( 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 istream& operator>>( 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 );
}
@ -145,7 +143,7 @@ enum FFXIVARR_SEGMENT_TYPE
SEGMENTTYPE_IPC = 3,
SEGMENTTYPE_KEEPALIVE = 7,
//SEGMENTTYPE_RESPONSE = 8,
SEGMENTTYPE_ENCRYPTIONINIT = 9,
SEGMENTTYPE_ENCRYPTIONINIT = 9,
};
/**
@ -171,12 +169,12 @@ struct FFXIVARR_IPC_HEADER
uint32_t padding1;
};
inline ostream& operator<<( 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 istream& operator>>( 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 );
}

View file

@ -1,6 +1,7 @@
#include "Util.h"
#include <chrono>
#include <boost/variant/detail/substitute.hpp>
#include <boost/format.hpp>
std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size )
{

View file

@ -2,7 +2,7 @@
#define _UTIL_H
#include <stdint.h>
#include <boost/format.hpp>
#include <string>
namespace Core {
namespace Util {

View file

@ -27,22 +27,18 @@ uint16_t floatToUInt16Rot( float val );
uint8_t floatToUInt8Rot( float val );
template
< typename T >
template < typename T >
T clamp( T val, T minimum, T maximum )
{
if( val > maximum )
{
return maximum;
}
if( val < minimum )
{
return minimum;
}
return val;
}
}
}
}

View file

@ -6,7 +6,7 @@
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Logging/Logger.h>
#include <Config/ConfigMgr.h>

View file

@ -160,13 +160,13 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
memset( &details, 0, sizeof( FFXIVIpcCharList::CharaDetails ) );
auto& charEntry = charList[ charIndex ];
details.uniqueId = get< 1 >( charEntry );
details.contentId = get< 2 >( charEntry );
details.uniqueId = std::get< 1 >( charEntry );
details.contentId = std::get< 2 >( charEntry );
details.serverId = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 );
details.serverId1 = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 );
details.index = charIndex;
strcpy( details.charDetailJson, get< 3 >( charEntry ).c_str() );
strcpy( details.nameChara, get< 0 >( charEntry ).c_str() );
strcpy( details.charDetailJson, std::get< 3 >( charEntry ).c_str() );
strcpy( details.nameChara, std::get< 0 >( charEntry ).c_str() );
strcpy( details.nameServer,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
strcpy( details.nameServer1,
@ -175,10 +175,10 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
charListPacket->data().charaDetails[ j ] = details;
g_log.debug( "[" + std::to_string( charIndex ) + "] " + std::to_string( details.index ) + " - "
+ get< 0 >( charEntry ) + " - " +
std::to_string( get< 1 >( charEntry ) ) + " - " +
std::to_string( get< 2 >( charEntry ) ) + " - " +
get< 3 >( charEntry ) );
+ std::get< 0 >( charEntry ) + " - " +
std::to_string( std::get< 1 >( charEntry ) ) + " - " +
std::to_string( std::get< 2 >( charEntry ) ) + " - " +
std::get< 3 >( charEntry ) );
}
charIndex++;
}
@ -215,12 +215,12 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin
auto charList = g_restConnector.getCharList( ( char* ) m_pSession->getSessionId() );
for( uint32_t i = 0; i < charList.size(); i++ )
{
uint64_t thisContentId = get< 2 >( charList[ i ] );
uint64_t thisContentId = std::get< 2 >( charList[ i ] );
if( thisContentId == lookupId )
{
logInCharId = get< 1 >( charList[ i ] );
logInCharName = get< 0 >( charList[ i ] );
logInCharId = std::get< 1 >( charList[ i ] );
logInCharName = std::get< 0 >( charList[ i ] );
break;
}
}

View file

@ -502,7 +502,7 @@ void Core::Entity::Player::updateDbSearchInfo() const
pDb->execute( stmtS1 );
auto stmtS2 = pDb->getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SEARCHCOMMENT );
stmtS2->setString( 1, string( m_searchMessage ) );
stmtS2->setString( 1, std::string( m_searchMessage ) );
stmtS2->setInt( 2, m_id );
pDb->execute( stmtS2 );
}

View file

@ -141,13 +141,13 @@ bool Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set<
boost::filesystem::directory_iterator iter( targetDir );
boost::filesystem::directory_iterator eod;
BOOST_FOREACH( boost::filesystem::path const& i, make_pair( iter, eod ) )
{
if( is_regular_file( i ) && boost::filesystem::extension( i.string() ) == ext )
{
files.insert( i.string() );
}
}
BOOST_FOREACH( boost::filesystem::path const& i, std::make_pair( iter, eod ) )
{
if( is_regular_file( i ) && boost::filesystem::extension( i.string() ) == ext )
{
files.insert( i.string() );
}
}
if( files.size() )
return true;

View file

@ -216,7 +216,7 @@ void Core::ServerZone::mainLoop()
while( isRunning() )
{
this_thread::sleep_for( chrono::milliseconds( 50 ) );
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
auto currTime = Util::getTimeSeconds();
@ -224,7 +224,7 @@ void Core::ServerZone::mainLoop()
pScriptMgr->update();
lock_guard< std::mutex > lock( m_sessionMutex );
std::lock_guard< std::mutex > lock( m_sessionMutex );
for( auto sessionIt : m_sessionMapById )
{
auto session = sessionIt.second;
@ -423,4 +423,4 @@ Core::Entity::BNpcTemplatePtr Core::ServerZone::getBNpcTemplate( uint32_t id )
}
return nullptr;
}
}

View file

@ -9,8 +9,6 @@
#include "ForwardsZone.h"
#include "Actor/BNpcTemplate.h"
namespace Core {
class ServerZone