diff --git a/src/common/Util/Util.cpp b/src/common/Util/Util.cpp index 1bb70fd6..bd6622a7 100644 --- a/src/common/Util/Util.cpp +++ b/src/common/Util/Util.cpp @@ -24,6 +24,12 @@ std::string Core::Util::toLowerCopy( const std::string& inStr ) return out; } +void Core::Util::eraseAll( std::string& inOutStr, char remove ) +{ + inOutStr.erase( std::remove( inOutStr.begin(), inOutStr.end(), remove ), inOutStr.end() ); +} + + std::string Core::Util::intToHexString( uint64_t intValue, uint8_t width ) { std::string hexStr; diff --git a/src/common/Util/Util.h b/src/common/Util/Util.h index a580ee76..8f9d27c3 100644 --- a/src/common/Util/Util.h +++ b/src/common/Util/Util.h @@ -13,6 +13,8 @@ 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 ); + std::string toLowerCopy( const std::string& inStr ); uint64_t getTimeMs(); diff --git a/src/servers/sapphire_api/SapphireAPI.cpp b/src/servers/sapphire_api/SapphireAPI.cpp index b1851c77..7e1225b4 100644 --- a/src/servers/sapphire_api/SapphireAPI.cpp +++ b/src/servers/sapphire_api/SapphireAPI.cpp @@ -10,10 +10,8 @@ #include #include #include -#include #include -#include Core::Network::SapphireAPI::SapphireAPI() { diff --git a/src/servers/sapphire_api/main.cpp b/src/servers/sapphire_api/main.cpp index ea06f167..20894025 100644 --- a/src/servers/sapphire_api/main.cpp +++ b/src/servers/sapphire_api/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include //Added for the default_resource example #include @@ -88,7 +89,7 @@ bool loadSettings( int32_t argc, char* argv[] ) try { - arg = boost::to_lower_copy( std::string( args[ i ] ) ); + arg = Util::toLowerCopy( std::string( args[ i ] ) ); val = std::string( args[ i + 1 ] ); // trim '-' from start of arg diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index aa4768f3..e713a610 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -15,9 +15,6 @@ #include "Player.h" #include "Framework.h" -#include -#include - #include #include @@ -850,7 +847,7 @@ uint16_t Core::Entity::Player::calculateEquippedGearItemLevel() it++; } - return boost::algorithm::clamp( iLvlResult / 13, 0, 9999 ); + return std::max( iLvlResult / 13, 9999 ); } diff --git a/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp index fd7bb69f..dab257f2 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -8,6 +6,7 @@ #include #include #include +#include #include "Network/GameConnection.h" #include "Network/PacketWrappers/ServerNoticePacket.h" @@ -57,7 +56,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::FFXIVARR_PACKE if( action < 1000000 ) // normal action { - std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action ); + std::string actionIdStr = Util::intToHexString( action, 4 ); player.sendDebug( "---------------------------------------" ); player.sendDebug( "ActionHandler ( " + actionIdStr + " | " + pExdData->get< Core::Data::Action >( action )->name + diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index 943ca926..4137c521 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -8,6 +6,7 @@ #include #include #include +#include #include "Zone/Zone.h" #include "Zone/ZonePosition.h" @@ -80,10 +79,10 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR const auto param3 = packet.data().param3; pLog->debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " + - boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) + - "\nparam1: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t ) ( param1 & 0xFFFFFFFFFFFFFFF ) ) + - "\nparam2: " + boost::str( boost::format( "%|08X|" ) % ( uint32_t ) ( param2 & 0xFFFFFFFF ) ) + - "\nparam3: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t ) ( param3 & 0xFFFFFFFFFFFFFFF ) ) + Util::intToHexString( static_cast< uint32_t >( commandId & 0xFFFF ), 4 ) + + "\nparam1: " + Util::intToHexString( static_cast< uint64_t >( param1 & 0xFFFFFFFFFFFFFFF ), 16 ) + + "\nparam2: " + Util::intToHexString( static_cast< uint32_t >( param2 & 0xFFFFFFFF ), 8 ) + + "\nparam3: " + Util::intToHexString( static_cast< uint64_t >( param3 & 0xFFFFFFFFFFFFFFF ), 16 ) ); @@ -313,7 +312,7 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR default: { pLog->debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " + - boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) ); + Util::intToHexString( static_cast< uint32_t >( commandId & 0xFFFF ), 4 ) ); break; } } diff --git a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp index 7a2b349a..1fd26f15 100644 --- a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -16,6 +14,8 @@ #include "Script/ScriptMgr.h" +#include + #include "Event/EventHandler.h" #include "Event/EventHelper.h" @@ -52,8 +52,7 @@ void Core::Network::GameConnection::eventHandlerTalk( const Packets::FFXIVARR_PA std::to_string( Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) + " \neventId: " + std::to_string( eventId ) + - " (0x" + boost::str( boost::format( "%|08X|" ) - % static_cast< uint64_t >( eventId & 0xFFFFFFF ) ) + ")" ); + " (0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + ")" ); player.sendDebug( "Calling: " + objName + "." + eventName ); @@ -97,8 +96,7 @@ void Core::Network::GameConnection::eventHandlerEmote( const Packets::FFXIVARR_P std::to_string( Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) + " \neventId: " + std::to_string( eventId ) + - " (0x" + boost::str( boost::format( "%|08X|" ) - % static_cast< uint64_t >( eventId & 0xFFFFFFF ) ) + ")" ); + " (0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + ")" ); player.sendDebug( "Calling: " + objName + "." + eventName ); @@ -206,7 +204,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_ player.sendDebug( "eventId: " + std::to_string( eventId ) + - " ( 0x" + boost::str( boost::format( "%|08X|" ) % ( uint64_t ) ( eventId & 0xFFFFFFF ) ) + " ) " + + " ( 0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + " ) " + " scene: " + std::to_string( scene ) + " p1: " + std::to_string( param1 ) + " p2: " + std::to_string( param2 ) + diff --git a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp index d1c46fab..50ed43d8 100644 --- a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include diff --git a/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp index 68018fe2..08790fd2 100644 --- a/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include diff --git a/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp index 6e9f5475..cc9e9f3d 100644 --- a/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include diff --git a/src/servers/sapphire_zone/ServerZone.cpp b/src/servers/sapphire_zone/ServerZone.cpp index 643a3343..60e4b2bf 100644 --- a/src/servers/sapphire_zone/ServerZone.cpp +++ b/src/servers/sapphire_zone/ServerZone.cpp @@ -28,8 +28,7 @@ #include "ForwardsZone.h" -#include -#include +#include #include #include "Framework.h" @@ -75,7 +74,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) try { - arg = boost::to_lower_copy( std::string( args[ i ] ) ); + arg = Util::toLowerCopy( std::string( args[ i ] ) ); val = std::string( args[ i + 1 ] ); // trim '-' from start of arg diff --git a/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp b/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp index 1bd37adb..c8b06efa 100644 --- a/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp +++ b/src/servers/sapphire_zone/StatusEffect/StatusEffect.cpp @@ -1,12 +1,8 @@ -#include -#include - #include #include #include #include -#include #include #include "Actor/Chara.h" @@ -37,11 +33,11 @@ Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::CharaPtr so std::replace( m_name.begin(), m_name.end(), ':', '_' ); std::replace( m_name.begin(), m_name.end(), '&', '_' ); std::replace( m_name.begin(), m_name.end(), '+', 'p' ); - boost::erase_all( m_name, "\'" ); - boost::erase_all( m_name, "&" ); - boost::erase_all( m_name, "-" ); - boost::erase_all( m_name, "(" ); - boost::erase_all( m_name, ")" ); + Util::eraseAll( m_name, '\'' ); + Util::eraseAll( m_name, '&' ); + Util::eraseAll( m_name, '-' ); + Util::eraseAll( m_name, '(' ); + Util::eraseAll( m_name, ')' ); }