From 4b013b5b0b9c78f1ec38d67a6028928236516705 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 12:21:22 +1100 Subject: [PATCH 1/6] add spdlog, remove boost is gone from common --- .gitmodules | 3 ++ cmake/compiler.cmake | 2 +- deps/spdlog | 1 + src/common/CMakeLists.txt | 6 +-- src/common/Config/ConfigMgr.cpp | 4 +- src/common/Logging/Logger.cpp | 54 ++++++-------------- src/common/Logging/Logger.h | 8 +-- src/servers/Scripts/CMakeLists.txt | 2 +- src/servers/sapphire_api/CMakeLists.txt | 2 +- src/servers/sapphire_api/Forwards.h | 46 ++++++++--------- src/servers/sapphire_api/main.cpp | 7 ++- src/servers/sapphire_zone/CMakeLists.txt | 2 +- src/tools/discovery_parser/CMakeLists.txt | 2 +- src/tools/event_object_parser/CMakeLists.txt | 2 +- src/tools/exd_common_gen/CMakeLists.txt | 2 +- src/tools/exd_common_gen/main.cpp | 11 ++-- src/tools/exd_struct_gen/CMakeLists.txt | 2 +- src/tools/exd_struct_test/CMakeLists.txt | 2 +- src/tools/mob_parse/CMakeLists.txt | 2 +- src/tools/pcb_reader/CMakeLists.txt | 2 +- src/tools/quest_parser/CMakeLists.txt | 2 +- 21 files changed, 73 insertions(+), 91 deletions(-) create mode 160000 deps/spdlog diff --git a/.gitmodules b/.gitmodules index d1faa1ae..69f7a3a6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "deps/asio"] path = deps/asio url = https://github.com/chriskohlhoff/asio.git +[submodule "deps/spdlog"] + path = deps/spdlog + url = https://github.com/gabime/spdlog.git diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index c614329e..7acc50e5 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -1,6 +1,6 @@ if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") else() add_definitions(-D_WIN32_WINNT=0x601) diff --git a/deps/spdlog b/deps/spdlog new file mode 160000 index 00000000..240a58fd --- /dev/null +++ b/deps/spdlog @@ -0,0 +1 @@ +Subproject commit 240a58fd6e8bfe8fa62dd3ea777d1909f6d89a72 diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 05512b9e..dfce49d8 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -27,7 +27,6 @@ set_target_properties( common PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/" ) -target_link_libraries( common PUBLIC ${Boost_LIBRARIES} ) target_link_libraries( common PUBLIC xivdat ) target_link_libraries( common PUBLIC mysqlConnector ) @@ -45,8 +44,9 @@ endif() target_include_directories( common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/" - "${CMAKE_CURRENT_SOURCE_DIR}/../../deps/asio/asio/include/" - "${CMAKE_CURRENT_SOURCE_DIR}/../../deps/" + "${CMAKE_CURRENT_SOURCE_DIR}/../../deps/" + "${CMAKE_CURRENT_SOURCE_DIR}/../../deps/asio/asio/include/" + "${CMAKE_CURRENT_SOURCE_DIR}/../../deps/spdlog/include/" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/libraries/external/") diff --git a/src/common/Config/ConfigMgr.cpp b/src/common/Config/ConfigMgr.cpp index c4550f18..c60c226e 100644 --- a/src/common/Config/ConfigMgr.cpp +++ b/src/common/Config/ConfigMgr.cpp @@ -43,10 +43,10 @@ bool Core::ConfigMgr::loadConfig( const std::string& configName ) std::ifstream configFile( localConfig.c_str() ); configStream << configFile.rdbuf(); - // parse the tree and we're fuckin done + // parse the trxee and we're fuckin done //boost::property_tree::read_ini( configStream, m_propTree ); - m_pInih = std::unique_ptr< INIReader >(new INIReader( localConfig ) ); + m_pInih = std::unique_ptr< INIReader >( new INIReader( localConfig ) ); if( m_pInih->ParseError() < 0 ) return false; diff --git a/src/common/Logging/Logger.cpp b/src/common/Logging/Logger.cpp index 4e00701e..213a6ea8 100644 --- a/src/common/Logging/Logger.cpp +++ b/src/common/Logging/Logger.cpp @@ -1,18 +1,10 @@ #include "Logger.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +// #include namespace Core { @@ -35,56 +27,40 @@ void Logger::setLogPath( const std::string& logPath ) void Logger::init() { - auto format = ( - boost::log::expressions::stream << - boost::log::expressions::format_date_time< boost::posix_time::ptime >( - "TimeStamp", "[%H:%M:%S]" ) << - "[" << boost::log::trivial::severity << "] " << - boost::log::expressions::smessage - ); + std::vector< spdlog::sink_ptr > sinks; - boost::log::add_file_log - ( - boost::log::keywords::file_name = - m_logFile + "%Y-%m-%d.log", /*< file name pattern >*/ - boost::log::keywords::rotation_size = - 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/ - boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point( 0, 0, - 0 ), /*< ...or at midnight >*/ - boost::log::keywords::open_mode = std::ios::app, - boost::log::keywords::format = format, - boost::log::keywords::auto_flush = true - ); + sinks.push_back( std::make_shared< spdlog::sinks::stdout_color_sink_mt >() ); + sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile, 0, 0 ) ); - boost::log::add_console_log( std::cout, boost::log::keywords::format = format ); + m_logger = std::make_shared< spdlog::logger >( "logger", std::begin( sinks ), std::end( sinks ) ); - boost::log::add_common_attributes(); + //spdlog::set_pattern( "[%H:%M:%S] [%l] %v" ); } void Logger::Log( LoggingSeverity logSev, const std::string& text ) { - BOOST_LOG_SEV( m_lg, ( boost::log::trivial::severity_level ) logSev ) << text; + // BOOST_LOG_SEV( m_lg, ( boost::log::trivial::severity_level ) logSev ) << text; } void Logger::error( const std::string& text ) { - BOOST_LOG_SEV( m_lg, boost::log::trivial::severity_level::error ) << text; + m_logger->error( text ); } void Logger::info( const std::string& text ) { - BOOST_LOG_SEV( m_lg, boost::log::trivial::severity_level::info ) << text; + m_logger->info( text ); } void Logger::debug( const std::string& text ) { - BOOST_LOG_SEV( m_lg, boost::log::trivial::severity_level::debug ) << text; + m_logger->debug( text ); } void Logger::fatal( const std::string& text ) { - BOOST_LOG_SEV( m_lg, boost::log::trivial::severity_level::fatal ) << text; + m_logger->critical( text ); } diff --git a/src/common/Logging/Logger.h b/src/common/Logging/Logger.h index 28384f16..c176ddc9 100644 --- a/src/common/Logging/Logger.h +++ b/src/common/Logging/Logger.h @@ -1,7 +1,9 @@ #ifndef _LOGGER_H #define _LOGGER_H -#include +// #include + +#include namespace Core { @@ -19,10 +21,10 @@ class Logger { private: - boost::log::sources::severity_logger_mt< boost::log::trivial::severity_level > m_lg; - std::string m_logFile; + std::shared_ptr< spdlog::logger > m_logger; + public: Logger(); diff --git a/src/servers/Scripts/CMakeLists.txt b/src/servers/Scripts/CMakeLists.txt index 4d2f9fa1..314f33f9 100644 --- a/src/servers/Scripts/CMakeLists.txt +++ b/src/servers/Scripts/CMakeLists.txt @@ -41,7 +41,7 @@ foreach(_scriptDir ${children}) if(MSVC) #target_link_libraries( "script_${_name}" ${Boost_LIBRARIES}) set_target_properties( "script_${_name}" PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON LIBRARY_OUTPUT_DIRECTORY_DEBUG "${SCRIPT_LIB_DIR}" diff --git a/src/servers/sapphire_api/CMakeLists.txt b/src/servers/sapphire_api/CMakeLists.txt index 2f83716a..0c975b41 100644 --- a/src/servers/sapphire_api/CMakeLists.txt +++ b/src/servers/sapphire_api/CMakeLists.txt @@ -8,7 +8,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(sapphire_api ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(sapphire_api PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" diff --git a/src/servers/sapphire_api/Forwards.h b/src/servers/sapphire_api/Forwards.h index ece38f18..7788db1b 100644 --- a/src/servers/sapphire_api/Forwards.h +++ b/src/servers/sapphire_api/Forwards.h @@ -1,7 +1,7 @@ #ifndef _FORWARDS_H #define _FORWARDS_H -#include +#include namespace Core { @@ -19,20 +19,20 @@ class Session; class ZonePosition; -typedef boost::shared_ptr< Zone > ZonePtr; -typedef boost::shared_ptr< Item > ItemPtr; -typedef boost::shared_ptr< ItemContainer > ItemContainerPtr; -typedef boost::shared_ptr< Inventory > InventoryPtr; -typedef boost::shared_ptr< Session > SessionPtr; -typedef boost::shared_ptr< ZonePosition > ZonePositionPtr; +typedef std::shared_ptr< Zone > ZonePtr; +typedef std::shared_ptr< Item > ItemPtr; +typedef std::shared_ptr< ItemContainer > ItemContainerPtr; +typedef std::shared_ptr< Inventory > InventoryPtr; +typedef std::shared_ptr< Session > SessionPtr; +typedef std::shared_ptr< ZonePosition > ZonePositionPtr; namespace StatusEffect { class StatusEffect; class StatusEffectContainer; -typedef boost::shared_ptr< StatusEffect > StatusEffectPtr; -typedef boost::shared_ptr< StatusEffectContainer > StatusEffectContainerPtr; +typedef std::shared_ptr< StatusEffect > StatusEffectPtr; +typedef std::shared_ptr< StatusEffectContainer > StatusEffectContainerPtr; } namespace Entity { @@ -42,15 +42,15 @@ class Player; class BattleNpc; -typedef boost::shared_ptr< Chara > ActorPtr; -typedef boost::shared_ptr< Player > PlayerPtr; -typedef boost::shared_ptr< BattleNpc > BattleNpcPtr; +typedef std::shared_ptr< Chara > ActorPtr; +typedef std::shared_ptr< Player > PlayerPtr; +typedef std::shared_ptr< BattleNpc > BattleNpcPtr; } namespace Event { class EventHandler; -typedef boost::shared_ptr< EventHandler > EventPtr; +typedef std::shared_ptr< EventHandler > EventPtr; } namespace Action { @@ -60,9 +60,9 @@ class ActionTeleport; class EventAction; -typedef boost::shared_ptr< Action > ActionPtr; -typedef boost::shared_ptr< ActionTeleport > ActionTeleportPtr; -typedef boost::shared_ptr< EventAction > EventActionPtr; +typedef std::shared_ptr< Action > ActionPtr; +typedef std::shared_ptr< ActionTeleport > ActionTeleportPtr; +typedef std::shared_ptr< EventAction > EventActionPtr; } @@ -79,18 +79,18 @@ class SessionConnection; class ZoneConnection; -typedef boost::shared_ptr< Hive > HivePtr; -typedef boost::shared_ptr< Acceptor > AcceptorPtr; -typedef boost::shared_ptr< Connection > ConnectionPtr; -typedef boost::shared_ptr< WorldConnection > WorldConnectionPtr; -typedef boost::shared_ptr< ZoneConnection > ZoneConnectionPtr; -typedef boost::shared_ptr< SessionConnection > SessionConnectionPtr; +typedef std::shared_ptr< Hive > HivePtr; +typedef std::shared_ptr< Acceptor > AcceptorPtr; +typedef std::shared_ptr< Connection > ConnectionPtr; +typedef std::shared_ptr< WorldConnection > WorldConnectionPtr; +typedef std::shared_ptr< ZoneConnection > ZoneConnectionPtr; +typedef std::shared_ptr< SessionConnection > SessionConnectionPtr; namespace Packets { class GamePacket; -typedef boost::shared_ptr< GamePacket > GamePacketPtr; +typedef std::shared_ptr< GamePacket > GamePacketPtr; } diff --git a/src/servers/sapphire_api/main.cpp b/src/servers/sapphire_api/main.cpp index 609a2d84..0f49f096 100644 --- a/src/servers/sapphire_api/main.cpp +++ b/src/servers/sapphire_api/main.cpp @@ -43,7 +43,6 @@ Core::Data::ExdDataGenerated g_exdDataGen; Core::Network::SapphireAPI g_sapphireAPI; using namespace std; -using namespace boost::property_tree; using HttpServer = SimpleWeb::Server< SimpleWeb::HTTP >; using HttpClient = SimpleWeb::Client< SimpleWeb::HTTP >; @@ -53,13 +52,13 @@ void default_resource_send( const HttpServer& server, const shared_ptr< HttpServ const shared_ptr< ifstream >& ifs ); -auto m_pConfig = boost::make_shared< Core::ConfigMgr >(); +auto m_pConfig = std::make_shared< Core::ConfigMgr >(); HttpServer server; std::string configPath( "rest.ini" ); void reloadConfig() { - m_pConfig = boost::make_shared< Core::ConfigMgr >(); + m_pConfig = std::make_shared< Core::ConfigMgr >(); if( !m_pConfig->loadConfig( configPath ) ) throw "Error loading config "; @@ -747,7 +746,7 @@ void defaultGet( shared_ptr< HttpServer::Response > response, shared_ptr< HttpSe int main( int argc, char* argv[] ) { - auto pLog = boost::shared_ptr< Core::Logger >( new Core::Logger() ); + auto pLog = std::shared_ptr< Core::Logger >( new Core::Logger() ); g_fw.set< Core::Logger >( pLog ); g_log.setLogPath( "log/SapphireAPI" ); g_log.init(); diff --git a/src/servers/sapphire_zone/CMakeLists.txt b/src/servers/sapphire_zone/CMakeLists.txt index 292ffcc3..1c61dd00 100644 --- a/src/servers/sapphire_zone/CMakeLists.txt +++ b/src/servers/sapphire_zone/CMakeLists.txt @@ -23,7 +23,7 @@ file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} add_executable( sapphire_zone ${SERVER_SOURCE_FILES} ) set_target_properties(sapphire_zone PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON ENABLE_EXPORTS ON diff --git a/src/tools/discovery_parser/CMakeLists.txt b/src/tools/discovery_parser/CMakeLists.txt index ac6f5744..8aab97d5 100644 --- a/src/tools/discovery_parser/CMakeLists.txt +++ b/src/tools/discovery_parser/CMakeLists.txt @@ -20,7 +20,7 @@ file(GLOB SERVER_SOURCE_FILES add_executable(discovery_parser ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(discovery_parser PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/event_object_parser/CMakeLists.txt b/src/tools/event_object_parser/CMakeLists.txt index 3af2ac6b..b3d39c4e 100644 --- a/src/tools/event_object_parser/CMakeLists.txt +++ b/src/tools/event_object_parser/CMakeLists.txt @@ -14,7 +14,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(event_object_parser ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(event_object_parser PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/exd_common_gen/CMakeLists.txt b/src/tools/exd_common_gen/CMakeLists.txt index ee45df8a..b65aaa9b 100644 --- a/src/tools/exd_common_gen/CMakeLists.txt +++ b/src/tools/exd_common_gen/CMakeLists.txt @@ -14,7 +14,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(exd_common_gen ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(exd_common_gen PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/exd_common_gen/main.cpp b/src/tools/exd_common_gen/main.cpp index feca65d3..7eef7ead 100644 --- a/src/tools/exd_common_gen/main.cpp +++ b/src/tools/exd_common_gen/main.cpp @@ -8,16 +8,17 @@ #include #include #include -#include +#include #include #include -#include +#include + #include Core::Logger g_log; -Core::Data::ExdData g_exdData; +Core::Data::ExdDataGenerated g_exdData; //const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" ); @@ -44,11 +45,11 @@ std::string generateEnum( const std::string& exd, int8_t nameIndex, const std::s { auto& fields = row.second; uint32_t id = row.first; - auto test = boost::get< std::string >( &fields.at( nameIndex ) ); + auto test = std::get< std::string >( fields.at( nameIndex ) ); if( !test ) continue; auto str = *test; - str.erase( boost::remove_if( str, boost::is_any_of( ",_-':!(){} \x02\x1f\x01\x03" ) ), str.end() ); + str.erase( std::remove_if( str.begin(), str.end(), std::is_any_of( ",_-':!(){} \x02\x1f\x01\x03" ) ) ); if( str.empty() ) continue; str[ 0 ] = std::toupper( str[ 0 ] ); diff --git a/src/tools/exd_struct_gen/CMakeLists.txt b/src/tools/exd_struct_gen/CMakeLists.txt index 55a4f094..cc490615 100644 --- a/src/tools/exd_struct_gen/CMakeLists.txt +++ b/src/tools/exd_struct_gen/CMakeLists.txt @@ -14,7 +14,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(exd_struct_gen ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(exd_struct_gen PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/exd_struct_test/CMakeLists.txt b/src/tools/exd_struct_test/CMakeLists.txt index 817c85a4..24eb5045 100644 --- a/src/tools/exd_struct_test/CMakeLists.txt +++ b/src/tools/exd_struct_test/CMakeLists.txt @@ -14,7 +14,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(exd_struct_test ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(exd_struct_test PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/mob_parse/CMakeLists.txt b/src/tools/mob_parse/CMakeLists.txt index a2a8a440..42647570 100644 --- a/src/tools/mob_parse/CMakeLists.txt +++ b/src/tools/mob_parse/CMakeLists.txt @@ -14,7 +14,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(mob_parse ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(mob_parse PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/pcb_reader/CMakeLists.txt b/src/tools/pcb_reader/CMakeLists.txt index 8417673f..c01d6c42 100644 --- a/src/tools/pcb_reader/CMakeLists.txt +++ b/src/tools/pcb_reader/CMakeLists.txt @@ -14,7 +14,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(pcb_reader2 ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(pcb_reader2 PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" diff --git a/src/tools/quest_parser/CMakeLists.txt b/src/tools/quest_parser/CMakeLists.txt index 9dc1c308..386495a5 100644 --- a/src/tools/quest_parser/CMakeLists.txt +++ b/src/tools/quest_parser/CMakeLists.txt @@ -20,7 +20,7 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*") add_executable(quest_parse ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES}) set_target_properties(quest_parse PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/" From 4e3edbbcd244814ac5cb5e76ecc940e1fa39e365 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 12:44:51 +1100 Subject: [PATCH 2/6] remove more boost --- src/servers/sapphire_api/SapphireAPI.cpp | 4 +- src/servers/sapphire_api/SapphireAPI.h | 2 +- .../sapphire_zone/Action/ActionMount.cpp | 2 +- .../sapphire_zone/Action/ActionTeleport.cpp | 2 +- .../sapphire_zone/Action/EventItemAction.cpp | 2 +- src/servers/sapphire_zone/Actor/Actor.cpp | 8 +- src/servers/sapphire_zone/Actor/Actor.h | 4 +- src/servers/sapphire_zone/Actor/BNpc.cpp | 2 +- src/servers/sapphire_zone/Actor/Chara.cpp | 6 +- src/servers/sapphire_zone/Actor/Player.cpp | 26 ++-- src/servers/sapphire_zone/Actor/Player.h | 6 +- .../sapphire_zone/Actor/PlayerEvent.cpp | 14 +- .../sapphire_zone/Actor/PlayerInventory.cpp | 12 +- .../sapphire_zone/Actor/PlayerQuest.cpp | 122 +++++++++--------- src/servers/sapphire_zone/Actor/PlayerSql.cpp | 2 +- .../sapphire_zone/DebugCommand/DebugCommand.h | 2 +- .../DebugCommand/DebugCommandHandler.cpp | 46 +++---- .../DebugCommand/DebugCommandHandler.h | 28 ++-- src/servers/sapphire_zone/ForwardsZone.h | 6 +- .../sapphire_zone/Linkshell/LinkshellMgr.cpp | 2 +- .../sapphire_zone/Linkshell/LinkshellMgr.h | 4 +- .../sapphire_zone/Network/GameConnection.cpp | 12 +- .../Network/Handlers/ClientTriggerHandler.cpp | 2 +- .../Network/Handlers/GMCommandHandlers.cpp | 2 +- .../Network/Handlers/PacketHandlers.cpp | 6 +- .../PacketWrappers/ActorControlPacket142.h | 4 +- .../PacketWrappers/ActorControlPacket143.h | 4 +- .../PacketWrappers/ActorControlPacket144.h | 4 +- .../sapphire_zone/Script/NativeScriptMgr.cpp | 4 +- .../sapphire_zone/Script/NativeScriptMgr.h | 2 +- src/servers/sapphire_zone/Script/ScriptMgr.h | 4 +- src/servers/sapphire_zone/ServerZone.cpp | 4 +- src/servers/sapphire_zone/Session.h | 5 +- .../sapphire_zone/Zone/TerritoryMgr.cpp | 2 +- src/servers/sapphire_zone/Zone/Zone.cpp | 2 +- src/servers/sapphire_zone/Zone/Zone.h | 4 +- src/servers/sapphire_zone/mainGameServer.cpp | 18 +-- 37 files changed, 189 insertions(+), 192 deletions(-) diff --git a/src/servers/sapphire_api/SapphireAPI.cpp b/src/servers/sapphire_api/SapphireAPI.cpp index 28338026..b1851c77 100644 --- a/src/servers/sapphire_api/SapphireAPI.cpp +++ b/src/servers/sapphire_api/SapphireAPI.cpp @@ -50,7 +50,7 @@ bool Core::Network::SapphireAPI::login( const std::string& username, const std:: } // create session for the new sessionid and store to sessionlist - auto pSession = boost::make_shared< Session >(); + auto pSession = std::make_shared< Session >(); pSession->setAccountId( accountId ); pSession->setSessionId( sid ); @@ -75,7 +75,7 @@ bool Core::Network::SapphireAPI::login( const std::string& username, const std:: bool Core::Network::SapphireAPI::insertSession( const uint32_t& accountId, std::string& sId ) { // create session for the new sessionid and store to sessionlist - auto pSession = boost::make_shared< Session >(); + auto pSession = std::make_shared< Session >(); pSession->setAccountId( accountId ); pSession->setSessionId( ( uint8_t* ) sId.c_str() ); diff --git a/src/servers/sapphire_api/SapphireAPI.h b/src/servers/sapphire_api/SapphireAPI.h index 6d367a21..00b0f610 100644 --- a/src/servers/sapphire_api/SapphireAPI.h +++ b/src/servers/sapphire_api/SapphireAPI.h @@ -20,7 +20,7 @@ public: ~SapphireAPI(); - using SessionMap = std::map< std::string, boost::shared_ptr< Session > >; + using SessionMap = std::map< std::string, std::shared_ptr< Session > >; bool login( const std::string& username, const std::string& pass, std::string& sId ); diff --git a/src/servers/sapphire_zone/Action/ActionMount.cpp b/src/servers/sapphire_zone/Action/ActionMount.cpp index d5e75422..2b86f592 100644 --- a/src/servers/sapphire_zone/Action/ActionMount.cpp +++ b/src/servers/sapphire_zone/Action/ActionMount.cpp @@ -74,7 +74,7 @@ void Core::Action::ActionMount::onFinish() pPlayer->unsetStateFlag( PlayerStateFlag::Casting ); - auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 4 ); + auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 4 ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) ); Server::EffectEntry effectEntry{}; diff --git a/src/servers/sapphire_zone/Action/ActionTeleport.cpp b/src/servers/sapphire_zone/Action/ActionTeleport.cpp index 968b174b..012107c4 100644 --- a/src/servers/sapphire_zone/Action/ActionTeleport.cpp +++ b/src/servers/sapphire_zone/Action/ActionTeleport.cpp @@ -86,7 +86,7 @@ void Core::Action::ActionTeleport::onFinish() pPlayer->setZoningType( ZoneingType::Teleport ); - auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 5 ); + auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 5 ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) ); diff --git a/src/servers/sapphire_zone/Action/EventItemAction.cpp b/src/servers/sapphire_zone/Action/EventItemAction.cpp index 637d5573..4c4d96e7 100644 --- a/src/servers/sapphire_zone/Action/EventItemAction.cpp +++ b/src/servers/sapphire_zone/Action/EventItemAction.cpp @@ -71,7 +71,7 @@ void Core::Action::EventItemAction::onFinish() try { - auto effectPacket = boost::make_shared< Server::EffectPacket >( m_pSource->getId(), m_additional, m_id ); + auto effectPacket = std::make_shared< Server::EffectPacket >( m_pSource->getId(), m_additional, m_id ); effectPacket->setAnimationId( 1 ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( m_pSource->getRot() ) ); diff --git a/src/servers/sapphire_zone/Actor/Actor.cpp b/src/servers/sapphire_zone/Actor/Actor.cpp index c6644876..5cac36f5 100644 --- a/src/servers/sapphire_zone/Actor/Actor.cpp +++ b/src/servers/sapphire_zone/Actor/Actor.cpp @@ -136,7 +136,7 @@ Core::Entity::CharaPtr Core::Entity::Actor::getAsChara() { if( !isChara() ) return nullptr; - return boost::dynamic_pointer_cast< Entity::Chara, Entity::Actor >( shared_from_this() ); + return std::dynamic_pointer_cast< Entity::Chara, Entity::Actor >( shared_from_this() ); } /*! \return pointer to this instance as PlayerPtr */ @@ -144,7 +144,7 @@ Core::Entity::PlayerPtr Core::Entity::Actor::getAsPlayer() { if( !isPlayer() ) return nullptr; - return boost::dynamic_pointer_cast< Entity::Player, Entity::Actor >( shared_from_this() ); + return std::dynamic_pointer_cast< Entity::Player, Entity::Actor >( shared_from_this() ); } /*! \return pointer to this instance as EventObjPtr */ @@ -152,7 +152,7 @@ Core::Entity::EventObjectPtr Core::Entity::Actor::getAsEventObj() { if( !isEventObj() ) return nullptr; - return boost::dynamic_pointer_cast< Entity::EventObject, Entity::Actor >( shared_from_this() ); + return std::dynamic_pointer_cast< Entity::EventObject, Entity::Actor >( shared_from_this() ); } /*! \return pointer to this instance as BNpcPtr */ @@ -160,7 +160,7 @@ Core::Entity::BNpcPtr Core::Entity::Actor::getAsBNpc() { if( !isBattleNpc() ) return nullptr; - return boost::dynamic_pointer_cast< Entity::BNpc, Entity::Actor >( shared_from_this() ); + return std::dynamic_pointer_cast< Entity::BNpc, Entity::Actor >( shared_from_this() ); } /*! diff --git a/src/servers/sapphire_zone/Actor/Actor.h b/src/servers/sapphire_zone/Actor/Actor.h index f57bdb03..fcc47a7b 100644 --- a/src/servers/sapphire_zone/Actor/Actor.h +++ b/src/servers/sapphire_zone/Actor/Actor.h @@ -2,7 +2,7 @@ #define _GAME_OBJECT_H_ #include -#include +#include #include "ForwardsZone.h" #include @@ -17,7 +17,7 @@ namespace Entity { \brief Base class for all actor/objects */ -class Actor : public boost::enable_shared_from_this< Actor > +class Actor : public std::enable_shared_from_this< Actor > { protected: diff --git a/src/servers/sapphire_zone/Actor/BNpc.cpp b/src/servers/sapphire_zone/Actor/BNpc.cpp index b712ac55..c3218505 100644 --- a/src/servers/sapphire_zone/Actor/BNpc.cpp +++ b/src/servers/sapphire_zone/Actor/BNpc.cpp @@ -117,5 +117,5 @@ uint32_t Core::Entity::BNpc::getBNpcNameId() const void Core::Entity::BNpc::spawn( PlayerPtr pTarget ) { - pTarget->queuePacket( boost::make_shared< NpcSpawnPacket >( *getAsBNpc(), *pTarget ) ); + pTarget->queuePacket( std::make_shared< NpcSpawnPacket >( *getAsBNpc(), *pTarget ) ); } diff --git a/src/servers/sapphire_zone/Actor/Chara.cpp b/src/servers/sapphire_zone/Actor/Chara.cpp index 7e3165c9..5b90a3cd 100644 --- a/src/servers/sapphire_zone/Actor/Chara.cpp +++ b/src/servers/sapphire_zone/Actor/Chara.cpp @@ -363,7 +363,7 @@ so players can have their own version and we can abolish the param. */ void Core::Entity::Chara::sendStatusUpdate( bool toSelf ) { - FFXIVPacketBasePtr packet = boost::make_shared< UpdateHpMpTpPacket >( *this ); + FFXIVPacketBasePtr packet = std::make_shared< UpdateHpMpTpPacket >( *this ); sendToInRangeSet( packet ); } @@ -402,7 +402,7 @@ void Core::Entity::Chara::autoAttack( CharaPtr pTarget ) uint16_t damage = static_cast< uint16_t >( 10 + rand() % 12 ); uint32_t variation = static_cast< uint32_t >( 0 + rand() % 4 ); - auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 0x336 ); + auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 0x336 ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); Server::EffectEntry effectEntry{}; @@ -442,7 +442,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u // Todo: Effect packet generator. 90% of this is basically setting params and it's basically unreadable. // Prepare packet. This is seemingly common for all packets in the action handler. - auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), target.getId(), actionId ); + auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), target.getId(), actionId ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); // Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index e9b06529..f43be36e 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -369,14 +369,14 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type ) setZoningType( Common::ZoneingType::Return ); } - m_queuedZoneing = boost::make_shared< QueuedZoning >( data->territory, pos, Util::getTimeMs(), rot ); + m_queuedZoneing = std::make_shared< QueuedZoning >( data->territory, pos, Util::getTimeMs(), rot ); } void Core::Entity::Player::forceZoneing( uint32_t zoneId ) { - m_queuedZoneing = boost::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f ); + m_queuedZoneing = std::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f ); //performZoning( zoneId, Common::ZoneingType::None, getPos() ); } @@ -571,7 +571,7 @@ void Core::Entity::Player::changePosition( float x, float y, float z, float o ) pos.x = x; pos.y = y; pos.z = z; - m_queuedZoneing = boost::make_shared< QueuedZoning >( getZoneId(), pos, Util::getTimeMs(), o ); + m_queuedZoneing = std::make_shared< QueuedZoning >( getZoneId(), pos, Util::getTimeMs(), o ); } void Core::Entity::Player::learnAction( uint16_t actionId ) @@ -683,7 +683,7 @@ void Core::Entity::Player::gainLevel() void Core::Entity::Player::sendStatusUpdate( bool toSelf ) { - sendToInRangeSet( boost::make_shared< UpdateHpMpTpPacket >( *this ), true ); + sendToInRangeSet( std::make_shared< UpdateHpMpTpPacket >( *this ), true ); } uint8_t Core::Entity::Player::getLevel() const @@ -775,7 +775,7 @@ void Core::Entity::Player::setLevelForClass( uint8_t level, Common::ClassJob cla void Core::Entity::Player::sendModel() { - sendToInRangeSet( boost::make_shared< ModelEquipPacket >( *getAsPlayer() ), true ); + sendToInRangeSet( std::make_shared< ModelEquipPacket >( *getAsPlayer() ), true ); } uint32_t Core::Entity::Player::getModelForSlot( Common::GearModelSlot slot ) @@ -838,7 +838,7 @@ void Core::Entity::Player::spawn( Entity::PlayerPtr pTarget ) getName() + " for " + pTarget->getName() ); - pTarget->queuePacket( boost::make_shared< PlayerSpawnPacket >( *getAsPlayer(), *pTarget ) ); + pTarget->queuePacket( std::make_shared< PlayerSpawnPacket >( *getAsPlayer(), *pTarget ) ); } // despawn @@ -961,7 +961,7 @@ void Core::Entity::Player::setStateFlags( std::vector< Common::PlayerStateFlag > void Core::Entity::Player::sendStateFlags() { - queuePacket( boost::make_shared< PlayerStateFlagsPacket >( *getAsPlayer() ) ); + queuePacket( std::make_shared< PlayerStateFlagsPacket >( *getAsPlayer() ) ); } void Core::Entity::Player::unsetStateFlag( Common::PlayerStateFlag flag ) @@ -1259,17 +1259,17 @@ uint8_t Core::Entity::Player::getSearchSelectClass() const void Core::Entity::Player::sendNotice( const std::string& message ) //Purple Text { - queuePacket( boost::make_shared< ServerNoticePacket >( getId(), message ) ); + queuePacket( std::make_shared< ServerNoticePacket >( getId(), message ) ); } void Core::Entity::Player::sendUrgent( const std::string& message ) //Red Text { - queuePacket( boost::make_shared< ChatPacket >( *getAsPlayer(), ChatType::ServerUrgent, message ) ); + queuePacket( std::make_shared< ChatPacket >( *getAsPlayer(), ChatType::ServerUrgent, message ) ); } void Core::Entity::Player::sendDebug( const std::string& message ) //Grey Text { - queuePacket( boost::make_shared< ChatPacket >( *getAsPlayer(), ChatType::ServerDebug, message ) ); + queuePacket( std::make_shared< ChatPacket >( *getAsPlayer(), ChatType::ServerDebug, message ) ); } void Core::Entity::Player::updateHowtosSeen( uint32_t howToId ) @@ -1412,7 +1412,7 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget ) if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer ) { - auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 8 ); + auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 8 ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); Server::EffectEntry entry; @@ -1426,7 +1426,7 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget ) } else { - auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 7 ); + auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 7 ); effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); Server::EffectEntry entry; @@ -1546,7 +1546,7 @@ void Core::Entity::Player::sendZonePackets() } queuePacket( contentFinderList ); - queuePacket( boost::make_shared< InitUIPacket >( *this ) ); + queuePacket( std::make_shared< InitUIPacket >( *this ) ); auto classInfoPacket = makeZonePacket< FFXIVIpcPlayerClassInfo >( getId() ); classInfoPacket->data().classId = static_cast< uint8_t >( getClass() ); diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index bb17af0a..4f62b976 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -200,7 +200,7 @@ public: bool giveQuestRewards( uint32_t questId, uint32_t optionalChoice ); - boost::shared_ptr< Common::QuestActive > getQuestActive( uint16_t index ); + std::shared_ptr< Common::QuestActive > getQuestActive( uint16_t index ); uint8_t getQuestUI8A( uint16_t questId ); @@ -984,7 +984,7 @@ private: std::map< uint32_t, uint8_t > m_questIdToQuestIdx; // quest mapping, quest id to quest container index std::map< uint8_t, uint32_t > m_questIdxToQuestId; // quest mapping, quest container index to questId - boost::shared_ptr< Common::QuestActive > m_activeQuests[30]; + std::shared_ptr< Common::QuestActive > m_activeQuests[30]; int16_t m_questTracking[5]; uint8_t m_stateFlags[12]; @@ -1003,7 +1003,7 @@ private: bool m_bMarkedForZoning; bool m_bNewAdventurer; uint64_t m_onlineStatus; - boost::shared_ptr< QueuedZoning > m_queuedZoneing; + std::shared_ptr< QueuedZoning > m_queuedZoneing; // search info char m_searchMessage[193]; // searchmessage to show in profile diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index 44ceead9..d113fe5d 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -84,7 +84,7 @@ void Core::Entity::Player::directorPlayScene( uint32_t eventId, uint32_t scene, pEvent->setPlayedScene( true ); pEvent->setEventReturnCallback( nullptr ); - auto eventPlay = boost::make_shared< DirectorPlayScenePacket >( getId(), getId(), pEvent->getId(), + auto eventPlay = std::make_shared< DirectorPlayScenePacket >( getId(), getId(), pEvent->getId(), scene, flags, eventParam3, eventParam4, eventParam5 ); queuePacket( eventPlay ); @@ -101,7 +101,7 @@ void Core::Entity::Player::eventStart( uint64_t actorId, uint32_t eventId, setStateFlag( PlayerStateFlag::InNpcEvent ); - auto eventStart = boost::make_shared< EventStartPacket >( getId(), actorId, eventId, + auto eventStart = std::make_shared< EventStartPacket >( getId(), actorId, eventId, eventType, eventParam1, eventParam2 ); queuePacket( eventStart ); @@ -188,7 +188,7 @@ void Core::Entity::Player::playScene( uint32_t eventId, uint32_t scene, pEvent->setPlayedScene( true ); pEvent->setEventReturnCallback( eventCallback ); pEvent->setSceneChainCallback( nullptr ); - auto eventPlay = boost::make_shared< EventPlayPacket >( getId(), pEvent->getActorId(), pEvent->getId(), + auto eventPlay = std::make_shared< EventPlayPacket >( getId(), pEvent->getActorId(), pEvent->getId(), scene, flags, eventParam2, eventParam3, eventParam4 ); queuePacket( eventPlay ); @@ -205,7 +205,7 @@ void Core::Entity::Player::playSceneChain( uint32_t eventId, uint32_t scene, uin pEvent->setPlayedScene( true ); pEvent->setSceneChainCallback( sceneChainCallback ); pEvent->setEventReturnCallback( nullptr ); - auto eventPlay = boost::make_shared< EventPlayPacket >( getId(), pEvent->getActorId(), pEvent->getId(), + auto eventPlay = std::make_shared< EventPlayPacket >( getId(), pEvent->getActorId(), pEvent->getId(), scene, flags, eventParam2, eventParam3, eventParam4 ); queuePacket( eventPlay ); @@ -245,7 +245,7 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer ) { case Event::EventHandler::Nest: { - queuePacket( boost::make_shared< EventFinishPacket >( getId(), pEvent->getId(), + queuePacket( std::make_shared< EventFinishPacket >( getId(), pEvent->getId(), pEvent->getEventType(), pEvent->getEventParam() ) ); removeEvent( pEvent->getId() ); @@ -257,7 +257,7 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer ) if( it.second->hasPlayedScene() == false ) { // TODO: not happy with this, this is also prone to break wit more than one remaining event in there - queuePacket( boost::make_shared< EventFinishPacket >( getId(), it.second->getId(), + queuePacket( std::make_shared< EventFinishPacket >( getId(), it.second->getId(), it.second->getEventType(), it.second->getEventParam() ) ); removeEvent( it.second->getId() ); @@ -268,7 +268,7 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer ) } default: { - queuePacket( boost::make_shared< EventFinishPacket >( getId(), pEvent->getId(), + queuePacket( std::make_shared< EventFinishPacket >( getId(), pEvent->getId(), pEvent->getEventType(), pEvent->getEventParam() ) ); break; } diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index 6589a9b1..aa4768f3 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -276,7 +276,7 @@ void Core::Entity::Player::addCurrency( CurrencyType type, uint32_t amount ) updateContainer( Currency, slot, currItem ); - auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), + auto invUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), static_cast< uint8_t >( type ) - 1, Common::InventoryType::Currency, *currItem ); @@ -298,7 +298,7 @@ void Core::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t a currItem->setStackSize( currentAmount - amount ); writeItem( currItem ); - auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), + auto invUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), static_cast< uint8_t >( type ) - 1, Common::InventoryType::Currency, *currItem ); @@ -326,7 +326,7 @@ void Core::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount writeInventory( Crystal ); - auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), + auto invUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), static_cast< uint8_t >( type ) - 1, Common::InventoryType::Crystal, *currItem ); @@ -349,7 +349,7 @@ void Core::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t amo writeItem( currItem ); - auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), + auto invUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), static_cast< uint8_t >( type ) - 1, Common::InventoryType::Crystal, *currItem ); @@ -595,7 +595,7 @@ Core::ItemPtr Core::Entity::Player::addItem( uint32_t catalogId, uint32_t quanti item->setStackSize( newStackSize ); writeItem( item ); - auto slotUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), slot, bag, *item ); + auto slotUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), slot, bag, *item ); queuePacket( slotUpdate ); // return existing stack if we have no overflow - items fit into a preexisting stack @@ -629,7 +629,7 @@ Core::ItemPtr Core::Entity::Player::addItem( uint32_t catalogId, uint32_t quanti if( !silent ) { - auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), freeBagSlot.second, freeBagSlot.first, + auto invUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), freeBagSlot.second, freeBagSlot.first, *item ); queuePacket( invUpdate ); diff --git a/src/servers/sapphire_zone/Actor/PlayerQuest.cpp b/src/servers/sapphire_zone/Actor/PlayerQuest.cpp index e193cb9e..94ef38c4 100644 --- a/src/servers/sapphire_zone/Actor/PlayerQuest.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerQuest.cpp @@ -59,7 +59,7 @@ void Core::Entity::Player::removeQuest( uint16_t questId ) m_questTracking[ ii ] = -1; } - boost::shared_ptr< QuestActive > pQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pQuest = m_activeQuests[ idx ]; m_activeQuests[ idx ].reset(); m_questIdToQuestIdx.erase( questId ); @@ -92,7 +92,7 @@ bool Core::Entity::Player::getQuestBitFlag8( uint16_t questId, uint8_t index ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->a.BitFlag8 & ( 1 << index ); } @@ -105,7 +105,7 @@ bool Core::Entity::Player::getQuestBitFlag16( uint16_t questId, uint8_t index ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->a.BitFlag16 & ( 1 << index ); } @@ -118,7 +118,7 @@ bool Core::Entity::Player::getQuestBitFlag24( uint16_t questId, uint8_t index ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->a.BitFlag24 & ( 1 << index ); } @@ -131,7 +131,7 @@ bool Core::Entity::Player::getQuestBitFlag32( uint16_t questId, uint8_t index ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->a.BitFlag32 & ( 1 << index ); } @@ -144,7 +144,7 @@ bool Core::Entity::Player::getQuestBitFlag40( uint16_t questId, uint8_t index ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->a.BitFlag40 & ( 1 << index ); } @@ -157,7 +157,7 @@ bool Core::Entity::Player::getQuestBitFlag48( uint16_t questId, uint8_t index ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->a.BitFlag48 & ( 1 << index ); } @@ -170,7 +170,7 @@ uint8_t Core::Entity::Player::getQuestUI8A( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->c.UI8A; } @@ -183,7 +183,7 @@ uint8_t Core::Entity::Player::getQuestUI8B( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->c.UI8B; } @@ -196,7 +196,7 @@ uint8_t Core::Entity::Player::getQuestUI8C( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->c.UI8C; } @@ -209,7 +209,7 @@ uint8_t Core::Entity::Player::getQuestUI8D( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->c.UI8D; } @@ -222,7 +222,7 @@ uint8_t Core::Entity::Player::getQuestUI8E( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->c.UI8E; } @@ -235,7 +235,7 @@ uint8_t Core::Entity::Player::getQuestUI8F( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->c.UI8F; } @@ -248,7 +248,7 @@ uint8_t Core::Entity::Player::getQuestUI8AH( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8AH; } @@ -261,7 +261,7 @@ uint8_t Core::Entity::Player::getQuestUI8BH( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8BH; } @@ -274,7 +274,7 @@ uint8_t Core::Entity::Player::getQuestUI8CH( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8CH; } @@ -287,7 +287,7 @@ uint8_t Core::Entity::Player::getQuestUI8DH( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8DH; } @@ -300,7 +300,7 @@ uint8_t Core::Entity::Player::getQuestUI8EH( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8EH; } @@ -313,7 +313,7 @@ uint8_t Core::Entity::Player::getQuestUI8FH( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8FH; } @@ -326,7 +326,7 @@ uint8_t Core::Entity::Player::getQuestUI8AL( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8AL; } @@ -339,7 +339,7 @@ uint8_t Core::Entity::Player::getQuestUI8BL( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8BL; } @@ -352,7 +352,7 @@ uint8_t Core::Entity::Player::getQuestUI8CL( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8CL; } @@ -365,7 +365,7 @@ uint8_t Core::Entity::Player::getQuestUI8DL( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8DL; } @@ -378,7 +378,7 @@ uint8_t Core::Entity::Player::getQuestUI8EL( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8EL; } @@ -391,7 +391,7 @@ uint8_t Core::Entity::Player::getQuestUI8FL( uint16_t questId ) uint8_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; value = pNewQuest->b.UI8FL; } @@ -404,7 +404,7 @@ uint16_t Core::Entity::Player::getQuestUI16A( uint16_t questId ) uint16_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // value = pNewQuest->d.UI16A; } @@ -417,7 +417,7 @@ uint16_t Core::Entity::Player::getQuestUI16B( uint16_t questId ) uint16_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // value = pNewQuest->d.UI16B; } @@ -430,7 +430,7 @@ uint16_t Core::Entity::Player::getQuestUI16C( uint16_t questId ) uint16_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // value = pNewQuest->d.UI16C; } @@ -443,7 +443,7 @@ uint32_t Core::Entity::Player::getQuestUI32A( uint16_t questId ) uint32_t value = 0; if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // value = pNewQuest->e.UI32A; } @@ -456,7 +456,7 @@ void Core::Entity::Player::setQuestUI8A( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->c.UI8A = val; @@ -470,7 +470,7 @@ void Core::Entity::Player::setQuestUI8B( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->c.UI8B = val; @@ -484,7 +484,7 @@ void Core::Entity::Player::setQuestUI8C( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->c.UI8C = val; @@ -498,7 +498,7 @@ void Core::Entity::Player::setQuestUI8D( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->c.UI8D = val; @@ -512,7 +512,7 @@ void Core::Entity::Player::setQuestUI8E( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->c.UI8E = val; @@ -526,7 +526,7 @@ void Core::Entity::Player::setQuestUI8F( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->c.UI8F = val; @@ -540,7 +540,7 @@ void Core::Entity::Player::setQuestUI8AH( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8AH = val; @@ -554,7 +554,7 @@ void Core::Entity::Player::setQuestUI8BH( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8BH = val; @@ -568,7 +568,7 @@ void Core::Entity::Player::setQuestUI8CH( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8CH = val; @@ -582,7 +582,7 @@ void Core::Entity::Player::setQuestUI8DH( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8DH = val; @@ -596,7 +596,7 @@ void Core::Entity::Player::setQuestUI8EH( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8EH = val; @@ -610,7 +610,7 @@ void Core::Entity::Player::setQuestUI8FH( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8FH = val; @@ -624,7 +624,7 @@ void Core::Entity::Player::setQuestUI8AL( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8AL = val; @@ -638,7 +638,7 @@ void Core::Entity::Player::setQuestUI8BL( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8BL = val; @@ -652,7 +652,7 @@ void Core::Entity::Player::setQuestUI8CL( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8CL = val; @@ -666,7 +666,7 @@ void Core::Entity::Player::setQuestUI8DL( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8DL = val; @@ -680,7 +680,7 @@ void Core::Entity::Player::setQuestUI8EL( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8EL = val; @@ -694,7 +694,7 @@ void Core::Entity::Player::setQuestUI8FL( uint16_t questId, uint8_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; pNewQuest->b.UI8FL = val; @@ -708,7 +708,7 @@ void Core::Entity::Player::setQuestUI16A( uint16_t questId, uint16_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // pNewQuest->d.UI16A = val; @@ -722,7 +722,7 @@ void Core::Entity::Player::setQuestUI16B( uint16_t questId, uint16_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // pNewQuest->d.UI16B = val; @@ -736,7 +736,7 @@ void Core::Entity::Player::setQuestUI16C( uint16_t questId, uint16_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // pNewQuest->d.UI16C = val; @@ -750,7 +750,7 @@ void Core::Entity::Player::setQuestUI32A( uint16_t questId, uint32_t val ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; // pNewQuest->e.UI32A = val; @@ -764,7 +764,7 @@ void Core::Entity::Player::setQuestBitFlag8( uint16_t questId, uint8_t index, bo if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; if( val ) pNewQuest->a.BitFlag8 |= ( 1 << index ); @@ -781,7 +781,7 @@ void Core::Entity::Player::setQuestBitFlag16( uint16_t questId, uint8_t index, b if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; if( val ) pNewQuest->a.BitFlag16 |= ( 1 << index ); @@ -798,7 +798,7 @@ void Core::Entity::Player::setQuestBitFlag24( uint16_t questId, uint8_t index, b if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; if( val ) pNewQuest->a.BitFlag24 |= ( 1 << index ); @@ -815,7 +815,7 @@ void Core::Entity::Player::setQuestBitFlag32( uint16_t questId, uint8_t index, b if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; if( val ) pNewQuest->a.BitFlag32 |= ( 1 << index ); @@ -832,7 +832,7 @@ void Core::Entity::Player::setQuestBitFlag40( uint16_t questId, uint8_t index, b if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; if( val ) pNewQuest->a.BitFlag40 |= ( 1 << index ); @@ -849,7 +849,7 @@ void Core::Entity::Player::setQuestBitFlag48( uint16_t questId, uint8_t index, b if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; if( val ) pNewQuest->a.BitFlag48 |= ( 1 << index ); @@ -867,7 +867,7 @@ uint8_t Core::Entity::Player::getQuestSeq( uint16_t questId ) if( idx != -1 ) { - boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; + std::shared_ptr< QuestActive > pNewQuest = m_activeQuests[ idx ]; return pNewQuest->c.sequence; } return 0; @@ -902,7 +902,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence ) if( !hasFreeSlot ) return; - boost::shared_ptr< QuestActive > pNewQuest( new QuestActive() ); + std::shared_ptr< QuestActive > pNewQuest( new QuestActive() ); pNewQuest->c.questId = questId; pNewQuest->c.sequence = sequence; pNewQuest->c.padding = 0; @@ -1003,7 +1003,7 @@ void Core::Entity::Player::sendQuestInfo() void Core::Entity::Player::sendQuestMessage( uint32_t questId, int8_t msgId, uint8_t type, uint32_t var1, uint32_t var2 ) { - queuePacket( boost::make_shared< QuestMessagePacket >( getAsPlayer(), questId, msgId, type, var1, var2 ) ); + queuePacket( std::make_shared< QuestMessagePacket >( getAsPlayer(), questId, msgId, type, var1, var2 ) ); } @@ -1076,7 +1076,7 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional return true; } -boost::shared_ptr< QuestActive > Core::Entity::Player::getQuestActive( uint16_t index ) +std::shared_ptr< QuestActive > Core::Entity::Player::getQuestActive( uint16_t index ) { return m_activeQuests[ index ]; } diff --git a/src/servers/sapphire_zone/Actor/PlayerSql.cpp b/src/servers/sapphire_zone/Actor/PlayerSql.cpp index 1f98fa7b..40a006ba 100644 --- a/src/servers/sapphire_zone/Actor/PlayerSql.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerSql.cpp @@ -254,7 +254,7 @@ bool Core::Entity::Player::loadActiveQuests() auto slotId = res->getUInt8( 2 ); - boost::shared_ptr< QuestActive > pActiveQuest( new QuestActive() ); + std::shared_ptr< QuestActive > pActiveQuest( new QuestActive() ); pActiveQuest->c.questId = res->getUInt16( 3 ); pActiveQuest->c.sequence = res->getUInt8( 4 ); pActiveQuest->c.flags = res->getUInt8( 5 ); diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommand.h b/src/servers/sapphire_zone/DebugCommand/DebugCommand.h index da7a2dcf..98ead02c 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommand.h +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommand.h @@ -13,7 +13,7 @@ class DebugCommand { public: - using pFunc = void ( DebugCommandHandler::* )( char*, Entity::Player&, boost::shared_ptr< DebugCommand > ); + using pFunc = void ( DebugCommandHandler::* )( char*, Entity::Player&, std::shared_ptr< DebugCommand > ); // String for the command std::string m_commandName; diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 13089f02..30455f68 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -71,7 +71,7 @@ Core::DebugCommandHandler::~DebugCommandHandler() void Core::DebugCommandHandler::registerCommand( const std::string& n, DebugCommand::pFunc functionPtr, const std::string& hText, uint8_t uLevel ) { - m_commandMap[ std::string( n ) ] = boost::make_shared< DebugCommand >( n, functionPtr, hText, uLevel ); + m_commandMap[ std::string( n ) ] = std::make_shared< DebugCommand >( n, functionPtr, hText, uLevel ); } // try to retrieve the command in question, execute if found @@ -79,7 +79,7 @@ void Core::DebugCommandHandler::execCommand( char* data, Entity::Player& player { // define callback pointer - void ( DebugCommandHandler::*pf )( char*, Entity::Player&, boost::shared_ptr< DebugCommand > ); + void ( DebugCommandHandler::*pf )( char*, Entity::Player&, std::shared_ptr< DebugCommand > ); std::string commandString; @@ -122,7 +122,7 @@ void Core::DebugCommandHandler::execCommand( char* data, Entity::Player& player // Definition of the commands /////////////////////////////////////////////////////////////////////////////////////// -void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::help( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { player.sendDebug( "Registered debug commands:" ); for( auto cmd : m_commandMap ) @@ -134,7 +134,7 @@ void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost: } } -void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::set( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pLog = g_fw.get< Logger >(); auto pTerriMgr = g_fw.get< TerritoryMgr >(); @@ -232,7 +232,7 @@ void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost:: else if( subCommand == "discovery_reset" ) { player.resetDiscovery(); - player.queuePacket( boost::make_shared< InitUIPacket >( player ) ); + player.queuePacket( std::make_shared< InitUIPacket >( player ) ); } else if( subCommand == "classjob" ) { @@ -373,7 +373,7 @@ void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost:: } -void Core::DebugCommandHandler::add( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::add( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pLog = g_fw.get< Logger >(); std::string subCommand; @@ -428,7 +428,7 @@ void Core::DebugCommandHandler::add( char* data, Entity::Player& player, boost:: if( !bNpcTemplate ) player.sendNotice( "Template " + params + " not found in cache!" ); - auto pBNpc = boost::make_shared< Entity::BNpc >( bNpcTemplate, + auto pBNpc = std::make_shared< Entity::BNpc >( bNpcTemplate, player.getPos().x, player.getPos().y, player.getPos().z, 1 ); @@ -507,7 +507,7 @@ void Core::DebugCommandHandler::add( char* data, Entity::Player& player, boost:: } -void Core::DebugCommandHandler::get( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::get( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pLog = g_fw.get< Logger >(); auto pExdData = g_fw.get< Data::ExdDataGenerated >(); @@ -554,7 +554,7 @@ void Core::DebugCommandHandler::get( char* data, Entity::Player& player, boost:: } void -Core::DebugCommandHandler::injectPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +Core::DebugCommandHandler::injectPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pServerZone = g_fw.get< ServerZone >(); auto pSession = pServerZone->getSession( player.getId() ); @@ -563,7 +563,7 @@ Core::DebugCommandHandler::injectPacket( char* data, Entity::Player& player, boo } void Core::DebugCommandHandler::injectChatPacket( char* data, Entity::Player& player, - boost::shared_ptr< DebugCommand > command ) + std::shared_ptr< DebugCommand > command ) { auto pServerZone = g_fw.get< ServerZone >(); auto pSession = pServerZone->getSession( player.getId() ); @@ -571,7 +571,7 @@ void Core::DebugCommandHandler::injectChatPacket( char* data, Entity::Player& pl pSession->getChatConnection()->injectPacket( data + 8, player ); } -void Core::DebugCommandHandler::replay( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::replay( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pLog = g_fw.get< Logger >(); auto pServerZone = g_fw.get< ServerZone >(); @@ -623,7 +623,7 @@ void Core::DebugCommandHandler::replay( char* data, Entity::Player& player, boos } -void Core::DebugCommandHandler::nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::nudge( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { std::string subCommand; @@ -670,7 +670,7 @@ void Core::DebugCommandHandler::nudge( char* data, Entity::Player& player, boost } void -Core::DebugCommandHandler::serverInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +Core::DebugCommandHandler::serverInfo( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pServerZone = g_fw.get< ServerZone >(); player.sendDebug( "SapphireZone " + Version::VERSION + "\nRev: " + Version::GIT_HASH ); @@ -678,7 +678,7 @@ Core::DebugCommandHandler::serverInfo( char* data, Entity::Player& player, boost player.sendDebug( "Sessions: " + std::to_string( pServerZone->getSessionCount() ) ); } -void Core::DebugCommandHandler::script( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +void Core::DebugCommandHandler::script( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pLog = g_fw.get< Logger >(); auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >(); @@ -768,7 +768,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player& player, boos } void -Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) +Core::DebugCommandHandler::instance( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto pTeriMgr = g_fw.get< TerritoryMgr >(); std::string cmd( data ), params, subCommand; @@ -875,7 +875,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: sscanf( params.c_str(), "%d %d", &index, &value ); - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -888,7 +888,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: sscanf( params.c_str(), "%s %hhu", objName, &state ); - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -906,7 +906,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: sscanf( params.c_str(), "%s %i %i", objName, &state1, &state2 ); - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -925,7 +925,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: sscanf( params.c_str(), "%hhu", &seq ); - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -937,7 +937,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: sscanf( params.c_str(), "%hhu", &branch ); - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -945,7 +945,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: } else if( subCommand == "qte_start" ) { - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -954,7 +954,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: } else if( subCommand == "event_start" ) { - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; @@ -963,7 +963,7 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, boost:: } else if( subCommand == "event_end" ) { - auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); if( !instance ) return; diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h index 1cc6c72f..d7894646 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h @@ -15,7 +15,7 @@ class DebugCommandHandler { private: // container mapping command string to command object - std::map< std::string, boost::shared_ptr< DebugCommand > > m_commandMap; + std::map< std::string, std::shared_ptr< DebugCommand > > m_commandMap; public: DebugCommandHandler(); @@ -29,31 +29,31 @@ public: void execCommand( char* data, Entity::Player& player ); // help command - void help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void help( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); // command handler callbacks - void set( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void set( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void get( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void get( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void add( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); - //void debug( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void add( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); + //void debug( char * data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void injectPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void injectPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void injectChatPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void injectChatPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void replay( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void replay( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void nudge( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void serverInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void serverInfo( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void unlockCharacter( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void instance( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void instance( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); - void script( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ); + void script( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); }; diff --git a/src/servers/sapphire_zone/ForwardsZone.h b/src/servers/sapphire_zone/ForwardsZone.h index 64356f45..95c22a84 100644 --- a/src/servers/sapphire_zone/ForwardsZone.h +++ b/src/servers/sapphire_zone/ForwardsZone.h @@ -2,19 +2,17 @@ #define _FORWARDS_H #include -#include #include -#include #include #include "Common.h" #define TYPE_FORWARD( x ) \ class x; \ -typedef boost::shared_ptr< x > x ## Ptr; \ +typedef std::shared_ptr< x > x ## Ptr; \ typedef std::unique_ptr< x > x ## UPtr; \ template< typename...Args > \ x ## Ptr make_ ## x( Args &&...args ) { \ -return boost::make_shared< x >( std::forward< Args >( args ) ... ); }\ +return std::make_shared< x >( std::forward< Args >( args ) ... ); }\ typedef std::vector< x > x ## PtrList; namespace Core { diff --git a/src/servers/sapphire_zone/Linkshell/LinkshellMgr.cpp b/src/servers/sapphire_zone/Linkshell/LinkshellMgr.cpp index 53272bb8..10882952 100644 --- a/src/servers/sapphire_zone/Linkshell/LinkshellMgr.cpp +++ b/src/servers/sapphire_zone/Linkshell/LinkshellMgr.cpp @@ -53,7 +53,7 @@ bool Core::LinkshellMgr::loadLinkshells() invitesBin = res->getBlobVector( 6 ); func( members, invitesBin ); - auto lsPtr = boost::make_shared< Linkshell >( linkshellId, name, masterId, members, leaders, invites ); + auto lsPtr = std::make_shared< Linkshell >( linkshellId, name, masterId, members, leaders, invites ); m_linkshellIdMap[ linkshellId ] = lsPtr; m_linkshellNameMap[ name ] = lsPtr; diff --git a/src/servers/sapphire_zone/Linkshell/LinkshellMgr.h b/src/servers/sapphire_zone/Linkshell/LinkshellMgr.h index 63e8c299..f9fba3da 100644 --- a/src/servers/sapphire_zone/Linkshell/LinkshellMgr.h +++ b/src/servers/sapphire_zone/Linkshell/LinkshellMgr.h @@ -1,13 +1,13 @@ #ifndef CORE_LINKSHELLMGR_H #define CORE_LINKSHELLMGR_H -#include +#include #include namespace Core { class Linkshell; -using LinkshellPtr = boost::shared_ptr< Linkshell >; +using LinkshellPtr = std::shared_ptr< Linkshell >; class LinkshellMgr { diff --git a/src/servers/sapphire_zone/Network/GameConnection.cpp b/src/servers/sapphire_zone/Network/GameConnection.cpp index 1acf1ac3..c04b2de2 100644 --- a/src/servers/sapphire_zone/Network/GameConnection.cpp +++ b/src/servers/sapphire_zone/Network/GameConnection.cpp @@ -402,7 +402,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets: { char* id = ( char* ) &( inPacket.data[ 4 ] ); uint32_t playerId = std::stoi( id ); - auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() ); + auto pCon = std::static_pointer_cast< GameConnection, Connection >( shared_from_this() ); // try to retrieve the session for this id auto session = pServerZone->getSession( playerId ); @@ -430,7 +430,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets: if( !m_pSession && session ) m_pSession = session; - auto pe = boost::make_shared< FFXIVRawPacket >( 0x07, 0x18, 0, 0 ); + auto pe = std::make_shared< FFXIVRawPacket >( 0x07, 0x18, 0, 0 ); *( unsigned int* ) ( &pe->data()[ 0 ] ) = 0xE0037603; *( unsigned int* ) ( &pe->data()[ 4 ] ) = static_cast< uint32_t >( time( nullptr ) ); sendSinglePacket( pe ); @@ -438,7 +438,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets: // main connection, assinging it to the session if( ipcHeader.connectionType == ConnectionType::Zone ) { - auto pe1 = boost::make_shared< FFXIVRawPacket >( 0x02, 0x38, 0, 0 ); + auto pe1 = std::make_shared< FFXIVRawPacket >( 0x02, 0x38, 0, 0 ); *( unsigned int* ) ( &pe1->data()[ 0 ] ) = playerId; sendSinglePacket( pe1 ); pLog->info( "[" + std::string( id ) + "] Setting session for zone connection" ); @@ -447,11 +447,11 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets: // chat connection, assinging it to the session else if( ipcHeader.connectionType == ConnectionType::Chat ) { - auto pe2 = boost::make_shared< FFXIVRawPacket >( 0x02, 0x38, 0, 0 ); + auto pe2 = std::make_shared< FFXIVRawPacket >( 0x02, 0x38, 0, 0 ); *( unsigned int* ) ( &pe2->data()[ 0 ] ) = playerId; sendSinglePacket( pe2 ); - auto pe3 = boost::make_shared< FFXIVRawPacket >( 0x03, 0x28, playerId, playerId ); + auto pe3 = std::make_shared< FFXIVRawPacket >( 0x03, 0x28, playerId, playerId ); *( unsigned short* ) ( &pe3->data()[ 2 ] ) = 0x02; sendSinglePacket( pe3 ); @@ -472,7 +472,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets: uint32_t id = *( uint32_t* ) &inPacket.data[ 0 ]; uint32_t timeStamp = *( uint32_t* ) &inPacket.data[ 4 ]; - auto pe4 = boost::make_shared< FFXIVRawPacket >( 0x08, 0x18, 0, 0 ); + auto pe4 = std::make_shared< FFXIVRawPacket >( 0x08, 0x18, 0, 0 ); *( unsigned int* ) ( &pe4->data()[ 0 ] ) = id; *( unsigned int* ) ( &pe4->data()[ 4 ] ) = timeStamp; sendSinglePacket( pe4 ); diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index d9e76d73..943ca926 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -59,7 +59,7 @@ void examineHandler( Core::Entity::Player& player, uint32_t targetId ) } else { - player.queuePacket( boost::make_shared< ExaminePacket >( player, pTarget ) ); + player.queuePacket( std::make_shared< ExaminePacket >( player, pTarget ) ); } } } diff --git a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp index 49ecec27..d1c46fab 100644 --- a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp @@ -421,7 +421,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R case GmCommand::Wireframe: { player.queuePacket( - boost::make_shared< ActorControlPacket143 >( player.getId(), ActorControlType::ToggleWireframeRendering ) ); + std::make_shared< ActorControlPacket143 >( player.getId(), ActorControlType::ToggleWireframeRendering ) ); player.sendNotice( "Wireframe Rendering for " + player.getName() + " was toggled" ); break; } diff --git a/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp index 03089004..6e9f5475 100644 --- a/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp @@ -297,7 +297,7 @@ void Core::Network::GameConnection::updatePositionHandler( const Core::Network:: player.m_lastMoveTime = currentTime; player.m_lastMoveflag = moveState; - auto movePacket = boost::make_shared< MoveActorPacket >( player, unk1, unk2, moveState, unk4 ); + auto movePacket = std::make_shared< MoveActorPacket >( player, unk1, unk2, moveState, unk4 ); player.sendToInRangeSet( movePacket ); } @@ -426,7 +426,7 @@ void Core::Network::GameConnection::pingHandler( const Core::Network::Packets::F { const auto packet = ZoneChannelPacket< Client::FFXIVIpcPingHandler >( inPacket ); - queueOutPacket( boost::make_shared< Server::PingPacket >( player, packet.data().timestamp ) ); + queueOutPacket( std::make_shared< Server::PingPacket >( player, packet.data().timestamp ) ); player.setLastPing( static_cast< uint32_t >( time( nullptr ) ) ); } @@ -529,7 +529,7 @@ void Core::Network::GameConnection::chatHandler( const Core::Network::Packets::F auto chatType = packet.data().chatType; //ToDo, need to implement sending GM chat types. - auto chatPacket = boost::make_shared< Server::ChatPacket >( player, chatType, packet.data().message ); + auto chatPacket = std::make_shared< Server::ChatPacket >( player, chatType, packet.data().message ); switch( chatType ) { diff --git a/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket142.h b/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket142.h index 6feca68e..36e195fe 100644 --- a/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket142.h +++ b/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket142.h @@ -42,9 +42,9 @@ private: }; template< typename... Args > -boost::shared_ptr< ActorControlPacket142 > makeActorControl142( Args... args ) +std::shared_ptr< ActorControlPacket142 > makeActorControl142( Args... args ) { - return boost::make_shared< ActorControlPacket142 >( args... ); + return std::make_shared< ActorControlPacket142 >( args... ); } } diff --git a/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket143.h b/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket143.h index 9d7be33b..3c306e6a 100644 --- a/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket143.h +++ b/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket143.h @@ -46,9 +46,9 @@ private: }; template< typename... Args > -boost::shared_ptr< ActorControlPacket143 > makeActorControl143( Args... args ) +std::shared_ptr< ActorControlPacket143 > makeActorControl143( Args... args ) { - return boost::make_shared< ActorControlPacket143 >( args... ); + return std::make_shared< ActorControlPacket143 >( args... ); } } diff --git a/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket144.h b/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket144.h index 9696e2e5..00673945 100644 --- a/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket144.h +++ b/src/servers/sapphire_zone/Network/PacketWrappers/ActorControlPacket144.h @@ -44,9 +44,9 @@ private: }; template< typename... Args > -boost::shared_ptr< ActorControlPacket144 > makeActorControl144( Args... args ) +std::shared_ptr< ActorControlPacket144 > makeActorControl144( Args... args ) { - return boost::make_shared< ActorControlPacket144 >( args... ); + return std::make_shared< ActorControlPacket144 >( args... ); } } diff --git a/src/servers/sapphire_zone/Script/NativeScriptMgr.cpp b/src/servers/sapphire_zone/Script/NativeScriptMgr.cpp index f6bb65c5..2f39a3a7 100644 --- a/src/servers/sapphire_zone/Script/NativeScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/NativeScriptMgr.cpp @@ -118,9 +118,9 @@ bool NativeScriptMgr::isModuleLoaded( const std::string& name ) } -boost::shared_ptr< NativeScriptMgr > createNativeScriptMgr() +std::shared_ptr< NativeScriptMgr > createNativeScriptMgr() { - return boost::make_shared< NativeScriptMgr >(); + return std::make_shared< NativeScriptMgr >(); } } } diff --git a/src/servers/sapphire_zone/Script/NativeScriptMgr.h b/src/servers/sapphire_zone/Script/NativeScriptMgr.h index a4d3f6f0..9652ff8f 100644 --- a/src/servers/sapphire_zone/Script/NativeScriptMgr.h +++ b/src/servers/sapphire_zone/Script/NativeScriptMgr.h @@ -127,7 +127,7 @@ public: * * @return a boost::shared_ptr to NativeScriptMgr */ -boost::shared_ptr< NativeScriptMgr > createNativeScriptMgr(); +std::shared_ptr< NativeScriptMgr > createNativeScriptMgr(); } } diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.h b/src/servers/sapphire_zone/Script/ScriptMgr.h index 885a7221..112843f6 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.h +++ b/src/servers/sapphire_zone/Script/ScriptMgr.h @@ -1,7 +1,7 @@ #ifndef _ScriptMgr_H_ #define _ScriptMgr_H_ -#include +#include #include #include @@ -17,7 +17,7 @@ private: /*! * @brief A shared ptr to NativeScriptMgr, used for accessing and managing the native script system. */ - boost::shared_ptr< NativeScriptMgr > m_nativeScriptMgr; + std::shared_ptr< NativeScriptMgr > m_nativeScriptMgr; std::function< std::string( Entity::Player & ) > m_onFirstEnterWorld; diff --git a/src/servers/sapphire_zone/ServerZone.cpp b/src/servers/sapphire_zone/ServerZone.cpp index ac9658c4..37443b39 100644 --- a/src/servers/sapphire_zone/ServerZone.cpp +++ b/src/servers/sapphire_zone/ServerZone.cpp @@ -308,7 +308,7 @@ bool Core::ServerZone::createSession( uint32_t sessionId ) pLog->info( "[" + session_id_str + "] Creating new session" ); - boost::shared_ptr< Session > newSession( new Session( sessionId ) ); + std::shared_ptr< Session > newSession( new Session( sessionId ) ); m_sessionMapById[ sessionId ] = newSession; if( !newSession->loadPlayer() ) @@ -393,7 +393,7 @@ void Core::ServerZone::loadBNpcTemplates() auto look = res->getBlobVector( 12 ); auto models = res->getBlobVector( 13 ); - auto bnpcTemplate = boost::make_shared< Entity::BNpcTemplate >( + auto bnpcTemplate = std::make_shared< Entity::BNpcTemplate >( id, bNPCBaseId, bNPCNameId, mainWeaponModel, secWeaponModel, aggressionMode, enemyType, 0, pose, modelChara, displayFlags, reinterpret_cast< uint32_t* >( &models[ 0 ] ), diff --git a/src/servers/sapphire_zone/Session.h b/src/servers/sapphire_zone/Session.h index 6cd0027d..6be6ef82 100644 --- a/src/servers/sapphire_zone/Session.h +++ b/src/servers/sapphire_zone/Session.h @@ -1,15 +1,14 @@ #ifndef _SESSION_H_ #define _SESSION_H_ -#include -#include +#include #include "ForwardsZone.h" namespace Core { class Session : - public boost::enable_shared_from_this< Session > + public std::enable_shared_from_this< Session > { public: Session( uint32_t sessionId ); diff --git a/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp b/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp index 773a00b9..502cc106 100644 --- a/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp +++ b/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp @@ -267,7 +267,7 @@ bool Core::TerritoryMgr::removeTerritoryInstance( uint32_t instanceId ) if( isInstanceContentTerritory( pZone->getTerritoryId() ) ) { - auto instance = boost::dynamic_pointer_cast< InstanceContent >( pZone ); + auto instance = std::dynamic_pointer_cast< InstanceContent >( pZone ); m_instanceContentToInstanceMap[ instance->getInstanceContentId() ].erase( pZone->getGuId() ); } else diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index 259d84ba..e1fec325 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -719,7 +719,7 @@ Core::Entity::EventObjectPtr Core::Zone::getEObj( uint32_t objId ) Core::InstanceContentPtr Core::Zone::getAsInstanceContent() { - return boost::dynamic_pointer_cast< InstanceContent, Zone >( shared_from_this() ); + return std::dynamic_pointer_cast< InstanceContent, Zone >( shared_from_this() ); } uint32_t Core::Zone::getNextEObjId() diff --git a/src/servers/sapphire_zone/Zone/Zone.h b/src/servers/sapphire_zone/Zone/Zone.h index e903871e..ddc1e57b 100644 --- a/src/servers/sapphire_zone/Zone/Zone.h +++ b/src/servers/sapphire_zone/Zone/Zone.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -31,7 +31,7 @@ struct TerritoryType; } class Zone : - public CellHandler< Cell >, public boost::enable_shared_from_this< Zone > + public CellHandler< Cell >, public std::enable_shared_from_this< Zone > { protected: uint32_t m_territoryId; diff --git a/src/servers/sapphire_zone/mainGameServer.cpp b/src/servers/sapphire_zone/mainGameServer.cpp index 5637307f..a06a801f 100644 --- a/src/servers/sapphire_zone/mainGameServer.cpp +++ b/src/servers/sapphire_zone/mainGameServer.cpp @@ -19,15 +19,15 @@ using namespace Core; bool setupFramework() { - auto pServer = boost::make_shared< ServerZone >( "zone.ini" ); - auto pLogger = boost::make_shared< Logger >(); - auto pExdData = boost::make_shared< Data::ExdDataGenerated >(); - auto pScript = boost::make_shared< Scripting::ScriptMgr >(); - auto pDb = boost::make_shared< Db::DbWorkerPool< Db::ZoneDbConnection > >(); - auto pLsMgr = boost::make_shared< LinkshellMgr >(); - auto pTeriMgr = boost::make_shared< TerritoryMgr >(); - auto pDebugCom = boost::make_shared< DebugCommandHandler >(); - auto pConfig = boost::make_shared< ConfigMgr >(); + auto pServer = std::make_shared< ServerZone >( "zone.ini" ); + auto pLogger = std::make_shared< Logger >(); + auto pExdData = std::make_shared< Data::ExdDataGenerated >(); + auto pScript = std::make_shared< Scripting::ScriptMgr >(); + auto pDb = std::make_shared< Db::DbWorkerPool< Db::ZoneDbConnection > >(); + auto pLsMgr = std::make_shared< LinkshellMgr >(); + auto pTeriMgr = std::make_shared< TerritoryMgr >(); + auto pDebugCom = std::make_shared< DebugCommandHandler >(); + auto pConfig = std::make_shared< ConfigMgr >(); pLogger->setLogPath( "log/SapphireZone_" ); pLogger->init(); From daf8fbfdb6357b50a325bf320c3603df11315a1b Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 13:38:06 +1100 Subject: [PATCH 3/6] more boost gone & remove duplicated watchdog lib --- cmake/compiler.cmake | 2 +- deps/watchdog/Watchdog.h | 16 +- src/servers/sapphire_api/CMakeLists.txt | 2 +- src/servers/sapphire_api/main.cpp | 25 +- .../sapphire_zone/Action/ActionCollision.cpp | 2 +- .../sapphire_zone/Action/ActionCollision.h | 2 +- src/servers/sapphire_zone/CMakeLists.txt | 2 +- .../sapphire_zone/Network/GameConnection.cpp | 2 +- .../sapphire_zone/Network/GameConnection.h | 2 +- .../sapphire_zone/Script/ScriptLoader.cpp | 12 +- .../sapphire_zone/Script/ScriptMgr.cpp | 16 +- src/servers/sapphire_zone/Session.cpp | 9 +- src/servers/sapphire_zone/Watchdog.h | 322 ------------------ .../sapphire_zone/Zone/InstanceContent.cpp | 2 +- .../sapphire_zone/Zone/InstanceContent.h | 6 +- src/servers/sapphire_zone/Zone/TerritoryMgr.h | 6 +- src/servers/sapphire_zone/Zone/Zone.cpp | 4 +- src/servers/sapphire_zone/Zone/Zone.h | 2 +- src/tools/event_object_parser/main.cpp | 10 +- src/tools/mob_parse/main.cpp | 11 +- src/tools/quest_parser/main.cpp | 7 +- 21 files changed, 75 insertions(+), 387 deletions(-) delete mode 100644 src/servers/sapphire_zone/Watchdog.h diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 7acc50e5..c614329e 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -1,6 +1,6 @@ if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") else() add_definitions(-D_WIN32_WINNT=0x601) diff --git a/deps/watchdog/Watchdog.h b/deps/watchdog/Watchdog.h index a9e2de2d..20f90f10 100644 --- a/deps/watchdog/Watchdog.h +++ b/deps/watchdog/Watchdog.h @@ -30,8 +30,8 @@ #include #include -#include -namespace ci { namespace fs = boost::filesystem; } +#include +namespace ci { namespace fs = std::experimental::filesystem; } //! Exception for when Watchdog can't locate a file or parse the wildcard class WatchedFileSystemExc : public std::exception { @@ -72,7 +72,7 @@ public: watchImpl( ci::fs::path() ); } //! Sets the last modification time of a file or directory. by default sets the time to the current time - static void touch( const ci::fs::path &path, std::time_t time = std::time( nullptr ) ) + static void touch( const ci::fs::path &path, ci::fs::file_time_type time = ci::fs::file_time_type::clock::now() ) { // if the file or directory exists change its last write time @@ -308,11 +308,11 @@ protected: }; protected: - ci::fs::path mPath; - std::string mFilter; - std::function mCallback; - std::function&)> mListCallback; - std::map< std::string, std::time_t > mModificationTimes; + ci::fs::path mPath; + std::string mFilter; + std::function mCallback; + std::function&)> mListCallback; + std::map< std::string, std::experimental::filesystem::file_time_type > mModificationTimes; }; std::mutex mMutex; diff --git a/src/servers/sapphire_api/CMakeLists.txt b/src/servers/sapphire_api/CMakeLists.txt index 0c975b41..22a2a294 100644 --- a/src/servers/sapphire_api/CMakeLists.txt +++ b/src/servers/sapphire_api/CMakeLists.txt @@ -18,5 +18,5 @@ set_target_properties(sapphire_api PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" ) -target_link_libraries (sapphire_api common) +target_link_libraries (sapphire_api common stdc++fs) diff --git a/src/servers/sapphire_api/main.cpp b/src/servers/sapphire_api/main.cpp index 0f49f096..c02c5b8a 100644 --- a/src/servers/sapphire_api/main.cpp +++ b/src/servers/sapphire_api/main.cpp @@ -25,8 +25,7 @@ //Added for the default_resource example #include #include -#include -#include +#include #include #include @@ -42,6 +41,8 @@ Core::Db::DbWorkerPool< Core::Db::ZoneDbConnection > g_charaDb; Core::Data::ExdDataGenerated g_exdDataGen; Core::Network::SapphireAPI g_sapphireAPI; +namespace fs = std::experimental::filesystem; + using namespace std; using HttpServer = SimpleWeb::Server< SimpleWeb::HTTP >; @@ -643,13 +644,13 @@ void get_init( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServ print_request_info( request ); try { - auto web_root_path = boost::filesystem::canonical( "web" ); - auto path = boost::filesystem::canonical( web_root_path / "news.xml" ); + auto web_root_path = fs::canonical( "web" ); + auto path = fs::canonical( web_root_path / "news.xml" ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || !std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) throw invalid_argument( "path must be within root path" ); - if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) + if( !( fs::exists( path ) && fs::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); auto ifs = make_shared< ifstream >(); @@ -678,13 +679,13 @@ void get_headline_all( shared_ptr< HttpServer::Response > response, shared_ptr< print_request_info( request ); try { - auto web_root_path = boost::filesystem::canonical( "web" ); - auto path = boost::filesystem::canonical( web_root_path / "headlines.xml" ); + auto web_root_path = fs::canonical( "web" ); + auto path = fs::canonical( web_root_path / "headlines.xml" ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || !std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) throw invalid_argument( "path must be within root path" ); - if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) + if( !( fs::exists( path ) && fs::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); auto ifs = make_shared< ifstream >(); @@ -712,15 +713,15 @@ void defaultGet( shared_ptr< HttpServer::Response > response, shared_ptr< HttpSe print_request_info( request ); try { - auto web_root_path = boost::filesystem::canonical( "web" ); - auto path = boost::filesystem::canonical( web_root_path / request->path ); + auto web_root_path = fs::canonical( "web" ); + auto path = fs::canonical( web_root_path / request->path ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || !std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) throw invalid_argument( "path must be within root path" ); - if( boost::filesystem::is_directory( path ) ) + if( fs::is_directory( path ) ) path /= "index.html"; - if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) + if( !( fs::exists( path ) && fs::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); auto ifs = make_shared< ifstream >(); diff --git a/src/servers/sapphire_zone/Action/ActionCollision.cpp b/src/servers/sapphire_zone/Action/ActionCollision.cpp index f7f3bb89..34d342d0 100644 --- a/src/servers/sapphire_zone/Action/ActionCollision.cpp +++ b/src/servers/sapphire_zone/Action/ActionCollision.cpp @@ -54,7 +54,7 @@ bool ActionCollision::isActorApplicable( Actor& actor, TargetFilter targetFilter std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange, - boost::shared_ptr< Core::Data::Action > actionInfo, + std::shared_ptr< Core::Data::Action > actionInfo, TargetFilter targetFilter ) { std::set< ActorPtr > actorsCollided; diff --git a/src/servers/sapphire_zone/Action/ActionCollision.h b/src/servers/sapphire_zone/Action/ActionCollision.h index e11ff2c9..1232b58f 100644 --- a/src/servers/sapphire_zone/Action/ActionCollision.h +++ b/src/servers/sapphire_zone/Action/ActionCollision.h @@ -28,7 +28,7 @@ public: static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange, - boost::shared_ptr< Data::Action > actionInfo, + std::shared_ptr< Data::Action > actionInfo, TargetFilter targetFilter ); private: diff --git a/src/servers/sapphire_zone/CMakeLists.txt b/src/servers/sapphire_zone/CMakeLists.txt index 1c61dd00..20a19b66 100644 --- a/src/servers/sapphire_zone/CMakeLists.txt +++ b/src/servers/sapphire_zone/CMakeLists.txt @@ -35,7 +35,7 @@ set_target_properties(sapphire_zone PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" ) -target_link_libraries( sapphire_zone PUBLIC common ) +target_link_libraries( sapphire_zone PUBLIC common stdc++fs ) target_include_directories( sapphire_zone PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ) diff --git a/src/servers/sapphire_zone/Network/GameConnection.cpp b/src/servers/sapphire_zone/Network/GameConnection.cpp index c04b2de2..76159e0b 100644 --- a/src/servers/sapphire_zone/Network/GameConnection.cpp +++ b/src/servers/sapphire_zone/Network/GameConnection.cpp @@ -181,7 +181,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t >& buffer ) handlePackets( packetHeader, packetList ); } -void Core::Network::GameConnection::OnError( const boost::system::error_code& error ) +void Core::Network::GameConnection::OnError( const asio::error_code& error ) { auto pLog = g_fw.get< Logger >(); pLog->debug( "GameConnection ERROR: " + error.message() ); diff --git a/src/servers/sapphire_zone/Network/GameConnection.h b/src/servers/sapphire_zone/Network/GameConnection.h index e493ee96..462889ca 100644 --- a/src/servers/sapphire_zone/Network/GameConnection.h +++ b/src/servers/sapphire_zone/Network/GameConnection.h @@ -64,7 +64,7 @@ public: void OnRecv( std::vector< uint8_t >& buffer ) override; - void OnError( const boost::system::error_code& error ) override; + void OnError( const asio::error_code& error ) override; void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader, const std::vector< Packets::FFXIVARR_PACKET_RAW >& packetData ); diff --git a/src/servers/sapphire_zone/Script/ScriptLoader.cpp b/src/servers/sapphire_zone/Script/ScriptLoader.cpp index 0b4c3810..35cc7fb9 100644 --- a/src/servers/sapphire_zone/Script/ScriptLoader.cpp +++ b/src/servers/sapphire_zone/Script/ScriptLoader.cpp @@ -7,13 +7,13 @@ #include #include -#include +#include #include "Framework.h" extern Core::Framework g_fw; -namespace fs = boost::filesystem; +namespace fs = std::experimental::filesystem; const std::string Core::Scripting::ScriptLoader::getModuleExtension() { @@ -67,9 +67,9 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st try { - fs::copy_file( f, dest, fs::copy_option::overwrite_if_exists ); + fs::copy_file( f, dest, fs::copy_options::overwrite_existing ); } - catch( const boost::filesystem::filesystem_error& err ) + catch( const fs::filesystem_error& err ) { pLog->error( "Error copying file to cache: " + err.code().message() ); @@ -78,9 +78,9 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st #ifdef _WIN32 - ModuleHandle handle = LoadLibrary( dest.string().c_str() ); + ModuleHandle handle = LoadLibrary( dest.c_str() ); #else - ModuleHandle handle = dlopen( dest.string().c_str(), RTLD_LAZY ); + ModuleHandle handle = dlopen( dest.c_str(), RTLD_LAZY ); #endif if( !handle ) diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.cpp b/src/servers/sapphire_zone/Script/ScriptMgr.cpp index 7bc9b216..e46160cb 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/ScriptMgr.cpp @@ -8,7 +8,7 @@ #include #include -#include "Watchdog.h" +#include #include "Zone/Zone.h" #include "Zone/InstanceContent.h" @@ -32,6 +32,8 @@ extern Core::Framework g_fw; +namespace fs = std::experimental::filesystem; + Core::Scripting::ScriptMgr::ScriptMgr() : m_firstScriptChangeNotificiation( false ) { @@ -130,20 +132,20 @@ bool Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set< auto pLog = g_fw.get< Logger >(); pLog->info( "ScriptMgr: loading scripts from " + dirname ); - if( !boost::filesystem::exists( dirname ) ) + if( !fs::exists( dirname ) ) { pLog->error( "ScriptMgr: scripts directory doesn't exist" ); return false; } - boost::filesystem::path targetDir( dirname ); + fs::path targetDir( dirname ); - boost::filesystem::directory_iterator iter( targetDir ); - boost::filesystem::directory_iterator eod; + fs::directory_iterator iter( targetDir ); + fs::directory_iterator eod; - BOOST_FOREACH( boost::filesystem::path const& i, std::make_pair( iter, eod ) ) + BOOST_FOREACH( fs::path const& i, std::make_pair( iter, eod ) ) { - if( is_regular_file( i ) && boost::filesystem::extension( i.string() ) == ext ) + if( fs::is_regular_file( i ) && fs::path( i.string() ).extension() == ext ) { files.insert( i.string() ); } diff --git a/src/servers/sapphire_zone/Session.cpp b/src/servers/sapphire_zone/Session.cpp index 642f8bb2..66e0b06b 100644 --- a/src/servers/sapphire_zone/Session.cpp +++ b/src/servers/sapphire_zone/Session.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -13,6 +13,7 @@ extern Core::Framework g_fw; +namespace fs = std::experimental::filesystem; Core::Session::Session( uint32_t sessionId ) : m_sessionId( sessionId ), @@ -113,7 +114,7 @@ void Core::Session::updateLastSqlTime() void Core::Session::startReplay( const std::string& path ) { auto pLog = g_fw.get< Logger >(); - if( !boost::filesystem::exists( path ) ) + if( !fs::exists( path ) ) { getPlayer()->sendDebug( "Couldn't find folder." ); return; @@ -123,8 +124,8 @@ void Core::Session::startReplay( const std::string& path ) std::vector< std::tuple< uint64_t, std::string > > loadedSets; - for( auto it = boost::filesystem::directory_iterator( boost::filesystem::path( path ) ); - it != boost::filesystem::directory_iterator(); ++it ) + for( auto it = fs::directory_iterator( fs::path( path ) ); + it != fs::directory_iterator(); ++it ) { // Get the filename of the current element auto fileName = it->path().filename().string(); diff --git a/src/servers/sapphire_zone/Watchdog.h b/src/servers/sapphire_zone/Watchdog.h deleted file mode 100644 index a9e2de2d..00000000 --- a/src/servers/sapphire_zone/Watchdog.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - - Watchdog - - Copyright (c) 2014, Simon Geilfus - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that - the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and - the following disclaimer. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include -namespace ci { namespace fs = boost::filesystem; } - -//! Exception for when Watchdog can't locate a file or parse the wildcard -class WatchedFileSystemExc : public std::exception { -public: - WatchedFileSystemExc( const ci::fs::path &path ) - { - m_message = "Failed to find the file or directory at: " + path.string(); - } - - virtual const char* what() const throw() { return m_message.c_str(); } - - std::string m_message; -}; - -//! Watchdog class. -class Watchdog { -public: - - //! Watches a file or directory for modification and call back the specified std::function. The path specified is passed as argument of the callback even if there is multiple files. Use the second watch method if you want to receive a list of all the files that have been modified. - static void watch( const ci::fs::path &path, const std::function &callback ) - { - watchImpl( path, callback, std::function&)>() ); - } - - //! Watches a file or directory for modification and call back the specified std::function. A list of modified files or directory is passed as argument of the callback. Use this version only if you are watching multiple files or a directory. - static void watchMany( const ci::fs::path &path, const std::function&)> &callback ) - { - watchImpl( path, std::function(), callback ); - } - //! Unwatches a previously registrated file or directory - static void unwatch( const ci::fs::path &path ) - { - watchImpl( path ); - } - //! Unwatches all previously registrated file or directory - static void unwatchAll() - { - watchImpl( ci::fs::path() ); - } - //! Sets the last modification time of a file or directory. by default sets the time to the current time - static void touch( const ci::fs::path &path, std::time_t time = std::time( nullptr ) ) - { - - // if the file or directory exists change its last write time - if( ci::fs::exists( path ) ){ - ci::fs::last_write_time( path, time ); - return; - } - // if not, visit each path if there's a wildcard - if( path.string().find( "*" ) != std::string::npos ){ - visitWildCardPath( path, [time]( const ci::fs::path &p ){ - ci::fs::last_write_time( p, time ); - return false; - } ); - } - // otherwise throw an exception - else { - throw WatchedFileSystemExc( path ); - } - } - -protected: - - Watchdog() - : mWatching(false) - { - } - - void close() - { - // remove all watchers - unwatchAll(); - - // stop the thread - mWatching = false; - if( mThread->joinable() ) mThread->join(); - } - - - void start() - { - mWatching = true; - mThread = std::unique_ptr( new std::thread( [this](){ - // keep watching for modifications every ms milliseconds - auto ms = std::chrono::milliseconds( 500 ); - while( mWatching ) { - do { - // iterate through each watcher and check for modification - std::lock_guard lock( mMutex ); - auto end = mFileWatchers.end(); - for( auto it = mFileWatchers.begin(); it != end; ++it ) { - it->second.watch(); - } - // lock will be released before this thread goes to sleep - } while( false ); - - // make this thread sleep for a while - std::this_thread::sleep_for( ms ); - } - } ) ); - } - static void watchImpl( const ci::fs::path &path, const std::function &callback = std::function(), const std::function&)> &listCallback = std::function&)>() ) - { - // create the static Watchdog instance - static Watchdog wd; - // and start its thread - if( !wd.mWatching ) { - wd.start(); - } - - const std::string key = path.string(); - - // add a new watcher - if( callback || listCallback ){ - - std::string filter; - ci::fs::path p = path; - // try to see if there's a match for the wildcard - if( path.string().find( "*" ) != std::string::npos ){ - bool found = false; - std::pair pathFilter = visitWildCardPath( path, [&found]( const ci::fs::path &p ){ - found = true; - return true; - } ); - if( !found ){ - throw WatchedFileSystemExc( path ); - } - else { - p = pathFilter.first; - filter = pathFilter.second; - } - } - - std::lock_guard lock( wd.mMutex ); - if( wd.mFileWatchers.find( key ) == wd.mFileWatchers.end() ){ - wd.mFileWatchers.emplace( make_pair( key, Watcher( p, filter, callback, listCallback ) ) ); - } - } - // if there is no callback that means that we are unwatching - else { - // if the path is empty we unwatch all files - if( path.empty() ){ - std::lock_guard lock( wd.mMutex ); - for( auto it = wd.mFileWatchers.begin(); it != wd.mFileWatchers.end(); ) { - it = wd.mFileWatchers.erase( it ); - } - } - // or the specified file or directory - else { - std::lock_guard lock( wd.mMutex ); - auto watcher = wd.mFileWatchers.find( key ); - if( watcher != wd.mFileWatchers.end() ){ - wd.mFileWatchers.erase( watcher ); - } - } - } - } - - static std::pair getPathFilterPair( const ci::fs::path &path ) - { - // extract wildcard and parent path - std::string key = path.string(); - ci::fs::path p = path; - size_t wildCardPos = key.find( "*" ); - std::string filter; - if( wildCardPos != std::string::npos ){ - filter = path.filename().string(); - p = path.parent_path(); - } - - // throw an exception if the file doesn't exist - if( filter.empty() && !ci::fs::exists( p ) ){ - throw WatchedFileSystemExc( path ); - } - - return std::make_pair( p, filter ); - - } - - static std::pair visitWildCardPath( const ci::fs::path &path, const std::function &visitor ){ - std::pair pathFilter = getPathFilterPair( path ); - if( !pathFilter.second.empty() ){ - std::string full = ( pathFilter.first / pathFilter.second ).string(); - size_t wildcardPos = full.find( "*" ); - std::string before = full.substr( 0, wildcardPos ); - std::string after = full.substr( wildcardPos + 1 ); - ci::fs::directory_iterator end; - for( ci::fs::directory_iterator it( pathFilter.first ); it != end; ++it ){ - std::string current = it->path().string(); - size_t beforePos = current.find( before ); - size_t afterPos = current.find( after ); - if( ( beforePos != std::string::npos || before.empty() ) - && ( afterPos != std::string::npos || after.empty() ) ) { - if( visitor( it->path() ) ){ - break; - } - } - } - } - return pathFilter; - } - - class Watcher { - public: - Watcher( const ci::fs::path &path, const std::string &filter, const std::function &callback, const std::function&)> &listCallback ) - : mPath(path), mFilter(filter), mCallback(callback), mListCallback(listCallback) - { - // make sure we store all initial write time - if( !mFilter.empty() ) { - std::vector paths; - visitWildCardPath( path / filter, [this,&paths]( const ci::fs::path &p ){ - hasChanged( p ); - paths.push_back( p ); - return false; - } ); - // this means that the first watch won't call the callback function - // so we have to manually call it here - if( mCallback ){ - mCallback( mPath / mFilter ); - } - else { - mListCallback( paths ); - } - } - } - - void watch() - { - // if there's no filter we just check for one item - if( mFilter.empty() && hasChanged( mPath ) && mCallback ){ - mCallback( mPath ); - //#error TODO: still have to figure out an elegant way to do this without cinder - } - // otherwise we check the whole parent directory - else if( !mFilter.empty() ){ - - std::vector paths; - visitWildCardPath( mPath / mFilter, [this,&paths]( const ci::fs::path &p ){ - bool pathHasChanged = hasChanged( p ); - if( pathHasChanged && mCallback ){ - mCallback( mPath / mFilter ); - //#error TODO: still have to figure out an elegant way to do this without cinder - return true; - } - else if( pathHasChanged && mListCallback ){ - paths.push_back( p ); - } - return false; - } ); - if( paths.size() && mListCallback ){ - mListCallback( paths ); - } - } - - } - - bool hasChanged( const ci::fs::path &path ) - { - // get the last modification time - auto time = ci::fs::last_write_time( path ); - // add a new modification time to the map - std::string key = path.string(); - if( mModificationTimes.find( key ) == mModificationTimes.end() ) { - mModificationTimes[ key ] = time; - return true; - } - // or compare with an older one - auto &prev = mModificationTimes[ key ]; - if( prev < time ) { - prev = time; - return true; - } - return false; - }; - - protected: - ci::fs::path mPath; - std::string mFilter; - std::function mCallback; - std::function&)> mListCallback; - std::map< std::string, std::time_t > mModificationTimes; - }; - - std::mutex mMutex; - std::atomic mWatching; - std::unique_ptr mThread; - std::map mFileWatchers; -}; \ No newline at end of file diff --git a/src/servers/sapphire_zone/Zone/InstanceContent.cpp b/src/servers/sapphire_zone/Zone/InstanceContent.cpp index 5e04a430..6f0040e8 100644 --- a/src/servers/sapphire_zone/Zone/InstanceContent.cpp +++ b/src/servers/sapphire_zone/Zone/InstanceContent.cpp @@ -29,7 +29,7 @@ using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; using namespace Core::Network::ActorControl; -Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration, +Core::InstanceContent::InstanceContent( std::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration, uint16_t territoryType, uint32_t guId, const std::string& internalName, diff --git a/src/servers/sapphire_zone/Zone/InstanceContent.h b/src/servers/sapphire_zone/Zone/InstanceContent.h index eb97e553..c8834d82 100644 --- a/src/servers/sapphire_zone/Zone/InstanceContent.h +++ b/src/servers/sapphire_zone/Zone/InstanceContent.h @@ -20,7 +20,7 @@ public: DutyFinished }; - InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration, + InstanceContent( std::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration, uint16_t territoryType, uint32_t guId, const std::string& internalName, @@ -76,7 +76,7 @@ public: InstanceContentState getState() const; - boost::shared_ptr< Core::Data::InstanceContent > getInstanceConfiguration() const; + std::shared_ptr< Core::Data::InstanceContent > getInstanceConfiguration() const; uint32_t getInstanceContentId() const; @@ -95,7 +95,7 @@ public: const uint32_t instanceStartDelay = 1250; private: - boost::shared_ptr< Core::Data::InstanceContent > m_instanceConfiguration; + std::shared_ptr< Core::Data::InstanceContent > m_instanceConfiguration; uint32_t m_instanceContentId; InstanceContentState m_state; uint16_t m_currentBgm; diff --git a/src/servers/sapphire_zone/Zone/TerritoryMgr.h b/src/servers/sapphire_zone/Zone/TerritoryMgr.h index 8519ad48..3ecebdfd 100644 --- a/src/servers/sapphire_zone/Zone/TerritoryMgr.h +++ b/src/servers/sapphire_zone/Zone/TerritoryMgr.h @@ -12,9 +12,9 @@ struct PlaceName; struct TerritoryType; struct InstanceContent; -using PlaceNamePtr = boost::shared_ptr< PlaceName >; -using TerritoryTypePtr = boost::shared_ptr< TerritoryType >; -using InstanceContentPtr = boost::shared_ptr< InstanceContent >; +using PlaceNamePtr = std::shared_ptr< PlaceName >; +using TerritoryTypePtr = std::shared_ptr< TerritoryType >; +using InstanceContentPtr = std::shared_ptr< InstanceContent >; } /*! diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index e1fec325..5cc83a2f 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -91,12 +91,12 @@ void Core::Zone::loadWeatherRates() auto weatherRateFields = pExdData->m_WeatherRateDat.get_row( weatherRateId ); for( size_t i = 0; i < 16; ) { - int32_t weatherId = boost::get< int32_t >( weatherRateFields[ i ] ); + int32_t weatherId = std::get< int32_t >( weatherRateFields[ i ] ); if( weatherId == 0 ) break; - sumPc += boost::get< uint8_t >( weatherRateFields[ i + 1 ] ); + sumPc += std::get< uint8_t >( weatherRateFields[ i + 1 ] ); m_weatherRateMap[ sumPc ] = weatherId; i += 2; } diff --git a/src/servers/sapphire_zone/Zone/Zone.h b/src/servers/sapphire_zone/Zone/Zone.h index ddc1e57b..b171c9b0 100644 --- a/src/servers/sapphire_zone/Zone/Zone.h +++ b/src/servers/sapphire_zone/Zone/Zone.h @@ -53,7 +53,7 @@ protected: FestivalPair m_currentFestival; - boost::shared_ptr< Data::TerritoryType > m_territoryTypeInfo; + std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo; std::map< uint8_t, int32_t > m_weatherRateMap; diff --git a/src/tools/event_object_parser/main.cpp b/src/tools/event_object_parser/main.cpp index bd672fdf..1368d76c 100644 --- a/src/tools/event_object_parser/main.cpp +++ b/src/tools/event_object_parser/main.cpp @@ -25,8 +25,12 @@ #include #include +#include + #endif +namespace fs = std::experimental::filesystem; + // garbage to ignore models bool ignoreModels = false; @@ -390,7 +394,7 @@ int main( int argc, char* argv[] ) contentTypeMap[ 11 ] = "events"; contentTypeMap[ 12 ] = "pvp"; - if( !boost::filesystem::exists( "instance.tmpl" ) ) + if( !fs::exists( "instance.tmpl" ) ) throw std::runtime_error( "instance.tmpl is missing in working directory" ); initExd( gamePath ); @@ -663,8 +667,8 @@ int main( int argc, char* argv[] ) if( subdirIt != contentTypeMap.end() ) subdir = subdirIt->second + "/"; - boost::filesystem::path outDir( "instances/" + subdir ); - boost::filesystem::create_directories( outDir ); + fs::path outDir( "instances/" + subdir ); + fs::create_directories( outDir ); std::ofstream outH( outDir.string() + entry.name + ".cpp" ); outH << result; diff --git a/src/tools/mob_parse/main.cpp b/src/tools/mob_parse/main.cpp index 052af653..119e4e67 100644 --- a/src/tools/mob_parse/main.cpp +++ b/src/tools/mob_parse/main.cpp @@ -11,16 +11,17 @@ #include #include #include + #include #include #include #include -#include #include #include -using namespace boost::system; -namespace filesys = boost::filesystem; +#include + +namespace filesys = std::experimental::filesystem; #include #include @@ -171,8 +172,8 @@ std::vector< std::string > getAllFilesInDir( const std::string& dirPath, // Add the name in vector listOfFiles.push_back( iter->path().string() ); } - - error_code ec; + + std::error_code ec; // Increment the iterator to point to next entry in recursive iteration iter.increment( ec ); if( ec ) diff --git a/src/tools/quest_parser/main.cpp b/src/tools/quest_parser/main.cpp index af195a96..99f1c44d 100644 --- a/src/tools/quest_parser/main.cpp +++ b/src/tools/quest_parser/main.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -22,6 +22,7 @@ Core::Logger g_log; Core::Data::ExdDataGenerated g_exdDataGen; +namespace fs = std::experimental::filesystem; const std::string onTalkStr( " void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n" @@ -345,8 +346,8 @@ int main( int argc, char** argv ) auto rows = g_exdDataGen.getQuestIdList(); - if( !boost::filesystem::exists( "./generated" ) ) - boost::filesystem::create_directory( "./generated" ); + if( !fs::exists( "./generated" ) ) + fs::create_directory( "./generated" ); g_log.info( "Export in progress" ); From fced452f880b5f09960416fea0f9b8f462e63115 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 14:16:47 +1100 Subject: [PATCH 4/6] remove more boost from api --- src/servers/sapphire_api/client_http.hpp | 98 ++++++++++----------- src/servers/sapphire_api/main.cpp | 2 +- src/servers/sapphire_api/server_http.hpp | 76 ++++++++--------- src/servers/sapphire_lobby/client_http.hpp | 99 +++++++++++----------- 4 files changed, 138 insertions(+), 137 deletions(-) diff --git a/src/servers/sapphire_api/client_http.hpp b/src/servers/sapphire_api/client_http.hpp index 077cb0fe..74ea5f86 100644 --- a/src/servers/sapphire_api/client_http.hpp +++ b/src/servers/sapphire_api/client_http.hpp @@ -1,7 +1,7 @@ #ifndef CLIENT_HTTP_HPP #define CLIENT_HTTP_HPP -#include +#include #include #include #include @@ -33,7 +33,7 @@ namespace SimpleWeb { std::unordered_multimap header; private: - boost::asio::streambuf content_buffer; + asio::streambuf content_buffer; Response(): content(&content_buffer) {} }; @@ -57,10 +57,10 @@ namespace SimpleWeb { auto corrected_path=path; if(corrected_path=="") corrected_path="/"; - if(!config.proxy_server.empty() && std::is_same::value) + if(!config.proxy_server.empty() && std::is_same::value) corrected_path="http://"+host+':'+std::to_string(port)+corrected_path; - boost::asio::streambuf write_buffer; + asio::streambuf write_buffer; std::ostream write_stream(&write_buffer); write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n"; write_stream << "Host: " << host << "\r\n"; @@ -74,21 +74,21 @@ namespace SimpleWeb { connect(); auto timer=get_timeout_timer(); - boost::asio::async_write(*socket, write_buffer, - [this, &content, timer](const boost::system::error_code &ec, size_t /*bytes_transferred*/) { + asio::async_write(*socket, write_buffer, + [this, &content, timer](const std::error_code &ec, size_t /*bytes_transferred*/) { if(timer) timer->cancel(); if(!ec) { if(!content.empty()) { auto timer=get_timeout_timer(); - boost::asio::async_write(*socket, boost::asio::buffer(content.data(), content.size()), - [this, timer](const boost::system::error_code &ec, size_t /*bytes_transferred*/) { + asio::async_write(*socket, asio::buffer(content.data(), content.size()), + [this, timer](const std::error_code &ec, size_t /*bytes_transferred*/) { if(timer) timer->cancel(); if(ec) { std::lock_guard lock(socket_mutex); this->socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); } @@ -96,7 +96,7 @@ namespace SimpleWeb { else { std::lock_guard lock(socket_mutex); socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); io_service.reset(); @@ -110,14 +110,14 @@ namespace SimpleWeb { auto corrected_path=path; if(corrected_path=="") corrected_path="/"; - if(!config.proxy_server.empty() && std::is_same::value) + if(!config.proxy_server.empty() && std::is_same::value) corrected_path="http://"+host+':'+std::to_string(port)+corrected_path; content.seekp(0, std::ios::end); auto content_length=content.tellp(); content.seekp(0, std::ios::beg); - boost::asio::streambuf write_buffer; + asio::streambuf write_buffer; std::ostream write_stream(&write_buffer); write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n"; write_stream << "Host: " << host << "\r\n"; @@ -133,14 +133,14 @@ namespace SimpleWeb { connect(); auto timer=get_timeout_timer(); - boost::asio::async_write(*socket, write_buffer, - [this, timer](const boost::system::error_code &ec, size_t /*bytes_transferred*/) { + asio::async_write(*socket, write_buffer, + [this, timer](const std::error_code &ec, size_t /*bytes_transferred*/) { if(timer) timer->cancel(); if(ec) { std::lock_guard lock(socket_mutex); socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); io_service.reset(); @@ -152,15 +152,15 @@ namespace SimpleWeb { void close() { std::lock_guard lock(socket_mutex); if(socket) { - boost::system::error_code ec; - socket->lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); + std::error_code ec; + socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); socket->lowest_layer().close(); } } protected: - boost::asio::io_service io_service; - boost::asio::ip::tcp::resolver resolver; + asio::io_service io_service; + asio::ip::tcp::resolver resolver; std::unique_ptr socket; std::mutex socket_mutex; @@ -190,13 +190,13 @@ namespace SimpleWeb { virtual void connect()=0; - std::shared_ptr get_timeout_timer() { + std::shared_ptr get_timeout_timer() { if(config.timeout==0) return nullptr; - auto timer=std::make_shared(io_service); + auto timer=std::make_shared(io_service); timer->expires_from_now(boost::posix_time::seconds(config.timeout)); - timer->async_wait([this](const boost::system::error_code& ec) { + timer->async_wait([this](const std::error_code& ec) { if(!ec) { close(); } @@ -233,11 +233,11 @@ namespace SimpleWeb { std::shared_ptr request_read() { std::shared_ptr response(new Response()); - boost::asio::streambuf chunked_streambuf; + asio::streambuf chunked_streambuf; auto timer=get_timeout_timer(); - boost::asio::async_read_until(*socket, response->content_buffer, "\r\n\r\n", - [this, &response, &chunked_streambuf, timer](const boost::system::error_code& ec, size_t bytes_transferred) { + asio::async_read_until(*socket, response->content_buffer, "\r\n\r\n", + [this, &response, &chunked_streambuf, timer](const std::error_code& ec, size_t bytes_transferred) { if(timer) timer->cancel(); if(!ec) { @@ -250,15 +250,15 @@ namespace SimpleWeb { auto content_length=stoull(header_it->second); if(content_length>num_additional_bytes) { auto timer=get_timeout_timer(); - boost::asio::async_read(*socket, response->content_buffer, - boost::asio::transfer_exactly(content_length-num_additional_bytes), - [this, timer](const boost::system::error_code& ec, size_t /*bytes_transferred*/) { + asio::async_read(*socket, response->content_buffer, + asio::transfer_exactly(content_length-num_additional_bytes), + [this, timer](const std::error_code& ec, size_t /*bytes_transferred*/) { if(timer) timer->cancel(); if(ec) { std::lock_guard lock(socket_mutex); this->socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); } @@ -270,7 +270,7 @@ namespace SimpleWeb { else { std::lock_guard lock(socket_mutex); socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); io_service.reset(); @@ -279,10 +279,10 @@ namespace SimpleWeb { return response; } - void request_read_chunked(const std::shared_ptr &response, boost::asio::streambuf &streambuf) { + void request_read_chunked(const std::shared_ptr &response, asio::streambuf &streambuf) { auto timer=get_timeout_timer(); - boost::asio::async_read_until(*socket, response->content_buffer, "\r\n", - [this, &response, &streambuf, timer](const boost::system::error_code& ec, size_t bytes_transferred) { + asio::async_read_until(*socket, response->content_buffer, "\r\n", + [this, &response, &streambuf, timer](const std::error_code& ec, size_t bytes_transferred) { if(timer) timer->cancel(); if(!ec) { @@ -316,9 +316,9 @@ namespace SimpleWeb { if((2+length)>num_additional_bytes) { auto timer=get_timeout_timer(); - boost::asio::async_read(*socket, response->content_buffer, - boost::asio::transfer_exactly(2+length-num_additional_bytes), - [this, post_process, timer](const boost::system::error_code& ec, size_t /*bytes_transferred*/) { + asio::async_read(*socket, response->content_buffer, + asio::transfer_exactly(2+length-num_additional_bytes), + [this, post_process, timer](const std::error_code& ec, size_t /*bytes_transferred*/) { if(timer) timer->cancel(); if(!ec) { @@ -327,7 +327,7 @@ namespace SimpleWeb { else { std::lock_guard lock(socket_mutex); this->socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); } @@ -337,7 +337,7 @@ namespace SimpleWeb { else { std::lock_guard lock(socket_mutex); socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); } @@ -346,7 +346,7 @@ namespace SimpleWeb { template class Client : public ClientBase {}; - typedef boost::asio::ip::tcp::socket HTTP; + typedef asio::ip::tcp::socket HTTP; template<> class Client : public ClientBase { @@ -356,15 +356,15 @@ namespace SimpleWeb { protected: void connect() { if(!socket || !socket->is_open()) { - std::unique_ptr query; + std::unique_ptr query; if(config.proxy_server.empty()) - query=std::unique_ptr(new boost::asio::ip::tcp::resolver::query(host, std::to_string(port))); + query=std::unique_ptr(new asio::ip::tcp::resolver::query(host, std::to_string(port))); else { auto proxy_host_port=parse_host_port(config.proxy_server, 8080); - query=std::unique_ptr(new boost::asio::ip::tcp::resolver::query(proxy_host_port.first, std::to_string(proxy_host_port.second))); + query=std::unique_ptr(new asio::ip::tcp::resolver::query(proxy_host_port.first, std::to_string(proxy_host_port.second))); } - resolver.async_resolve(*query, [this](const boost::system::error_code &ec, - boost::asio::ip::tcp::resolver::iterator it){ + resolver.async_resolve(*query, [this](const std::error_code &ec, + asio::ip::tcp::resolver::iterator it){ if(!ec) { { std::lock_guard lock(socket_mutex); @@ -372,25 +372,25 @@ namespace SimpleWeb { } auto timer=get_timeout_timer(); - boost::asio::async_connect(*socket, it, [this, timer] - (const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator /*it*/){ + asio::async_connect(*socket, it, [this, timer] + (const std::error_code &ec, asio::ip::tcp::resolver::iterator /*it*/){ if(timer) timer->cancel(); if(!ec) { - boost::asio::ip::tcp::no_delay option(true); + asio::ip::tcp::no_delay option(true); this->socket->set_option(option); } else { std::lock_guard lock(socket_mutex); this->socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); } else { std::lock_guard lock(socket_mutex); socket=nullptr; - throw boost::system::system_error(ec); + throw std::system_error(ec); } }); io_service.reset(); diff --git a/src/servers/sapphire_api/main.cpp b/src/servers/sapphire_api/main.cpp index c02c5b8a..1d552f58 100644 --- a/src/servers/sapphire_api/main.cpp +++ b/src/servers/sapphire_api/main.cpp @@ -804,7 +804,7 @@ void default_resource_send( const HttpServer& server, const shared_ptr< HttpServ response->write( &buffer[ 0 ], read_length ); if( read_length == static_cast< streamsize >( buffer.size() ) ) { - server.send( response, [ &server, response, ifs ]( const boost::system::error_code& ec ) + server.send( response, [ &server, response, ifs ]( const std::error_code& ec ) { if( !ec ) default_resource_send( server, response, ifs ); diff --git a/src/servers/sapphire_api/server_http.hpp b/src/servers/sapphire_api/server_http.hpp index b8e8e8a9..d8676f1f 100644 --- a/src/servers/sapphire_api/server_http.hpp +++ b/src/servers/sapphire_api/server_http.hpp @@ -1,7 +1,7 @@ #ifndef SERVER_HTTP_HPP #define SERVER_HTTP_HPP -#include +#include #include #include @@ -64,7 +64,7 @@ namespace SimpleWeb { class Response : public std::ostream { friend class ServerBase; - boost::asio::streambuf streambuf; + asio::streambuf streambuf; std::shared_ptr socket; @@ -88,8 +88,8 @@ namespace SimpleWeb { return ss.str(); } private: - boost::asio::streambuf &streambuf; - Content(boost::asio::streambuf &streambuf): std::istream(&streambuf), streambuf(streambuf) {} + asio::streambuf &streambuf; + Content(asio::streambuf &streambuf): std::istream(&streambuf), streambuf(streambuf) {} }; class Request { @@ -116,7 +116,7 @@ namespace SimpleWeb { catch(...) {} } - boost::asio::streambuf streambuf; + asio::streambuf streambuf; }; class Config { @@ -159,27 +159,27 @@ namespace SimpleWeb { std::map::Response>, std::shared_ptr::Request>)> > default_resource; - std::function::Request>, const boost::system::error_code&)> on_error; + std::function::Request>, const std::error_code&)> on_error; std::function socket, std::shared_ptr::Request>)> on_upgrade; virtual void start() { if(!io_service) - io_service=std::make_shared(); + io_service=std::make_shared(); if(io_service->stopped()) io_service->reset(); - boost::asio::ip::tcp::endpoint endpoint; + asio::ip::tcp::endpoint endpoint; if(config.address.size()>0) - endpoint=boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(config.address), config.port); + endpoint=asio::ip::tcp::endpoint(asio::ip::address::from_string(config.address), config.port); else - endpoint=boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), config.port); + endpoint=asio::ip::tcp::endpoint(asio::ip::tcp::v4(), config.port); if(!acceptor) - acceptor=std::unique_ptr(new boost::asio::ip::tcp::acceptor(*io_service)); + acceptor=std::unique_ptr(new asio::ip::tcp::acceptor(*io_service)); acceptor->open(endpoint.protocol()); - acceptor->set_option(boost::asio::socket_base::reuse_address(config.reuse_address)); + acceptor->set_option(asio::socket_base::reuse_address(config.reuse_address)); acceptor->bind(endpoint); acceptor->listen(); @@ -210,34 +210,34 @@ namespace SimpleWeb { } ///Use this function if you need to recursively send parts of a longer message - void send(const std::shared_ptr &response, const std::function& callback=nullptr) const { - boost::asio::async_write(*response->socket, response->streambuf, [this, response, callback](const boost::system::error_code& ec, size_t /*bytes_transferred*/) { + void send(const std::shared_ptr &response, const std::function& callback=nullptr) const { + asio::async_write(*response->socket, response->streambuf, [this, response, callback](const std::error_code& ec, size_t /*bytes_transferred*/) { if(callback) callback(ec); }); } - /// If you have your own boost::asio::io_service, store its pointer here before running start(). + /// If you have your own asio::io_service, store its pointer here before running start(). /// You might also want to set config.thread_pool_size to 0. - std::shared_ptr io_service; + std::shared_ptr io_service; protected: - std::unique_ptr acceptor; + std::unique_ptr acceptor; std::vector threads; ServerBase(unsigned short port) : config(port) {} virtual void accept()=0; - std::shared_ptr get_timeout_timer(const std::shared_ptr &socket, long seconds) { + std::shared_ptr get_timeout_timer(const std::shared_ptr &socket, long seconds) { if(seconds==0) return nullptr; - auto timer=std::make_shared(*io_service); + auto timer=std::make_shared(*io_service); timer->expires_from_now(boost::posix_time::seconds(seconds)); - timer->async_wait([socket](const boost::system::error_code& ec){ + timer->async_wait([socket](const std::error_code& ec){ if(!ec) { - boost::system::error_code ec; - socket->lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); + std::error_code ec; + socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); socket->lowest_layer().close(); } }); @@ -249,11 +249,11 @@ namespace SimpleWeb { //shared_ptr is used to pass temporary objects to the asynchronous functions std::shared_ptr request(new Request(*socket)); - //Set timeout on the following boost::asio::async-read or write function + //Set timeout on the following asio::async-read or write function auto timer=this->get_timeout_timer(socket, config.timeout_request); - boost::asio::async_read_until(*socket, request->streambuf, "\r\n\r\n", - [this, socket, request, timer](const boost::system::error_code& ec, size_t bytes_transferred) { + asio::async_read_until(*socket, request->streambuf, "\r\n\r\n", + [this, socket, request, timer](const std::error_code& ec, size_t bytes_transferred) { if(timer) timer->cancel(); if(!ec) { @@ -275,16 +275,16 @@ namespace SimpleWeb { } catch( const std::exception & ) { if(on_error) - on_error(request, boost::system::error_code(boost::system::errc::protocol_error, boost::system::generic_category())); + on_error( request, std::error_code( std::errc::protocol_error, std::generic_category() ) ); return; } if(content_length>num_additional_bytes) { - //Set timeout on the following boost::asio::async-read or write function + //Set timeout on the following asio::async-read or write function auto timer=this->get_timeout_timer(socket, config.timeout_content); - boost::asio::async_read(*socket, request->streambuf, - boost::asio::transfer_exactly(static_cast< size_t >(content_length-num_additional_bytes)), + asio::async_read(*socket, request->streambuf, + asio::transfer_exactly(static_cast< size_t >(content_length-num_additional_bytes)), [this, socket, request, timer] - (const boost::system::error_code& ec, size_t /*bytes_transferred*/) { + (const std::error_code& ec, size_t /*bytes_transferred*/) { if(timer) timer->cancel(); if(!ec) @@ -375,12 +375,12 @@ namespace SimpleWeb { void write_response(const std::shared_ptr &socket, const std::shared_ptr &request, std::function::Response>, std::shared_ptr::Request>)>& resource_function) { - //Set timeout on the following boost::asio::async-read or write function + //Set timeout on the following asio::async-read or write function auto timer=this->get_timeout_timer(socket, config.timeout_content); auto response=std::shared_ptr(new Response(socket), [this, request, timer](Response *response_ptr) { auto response=std::shared_ptr(response_ptr); - this->send(response, [this, response, request, timer](const boost::system::error_code& ec) { + this->send(response, [this, response, request, timer](const std::error_code& ec) { if(timer) timer->cancel(); if(!ec) { @@ -390,7 +390,7 @@ namespace SimpleWeb { } catch( const std::exception & ){ if(on_error) - on_error(request, boost::system::error_code(boost::system::errc::protocol_error, boost::system::generic_category())); + on_error( request, std::error_code( std::errc::protocol_error, std::generic_category() ) ); return; } @@ -412,7 +412,7 @@ namespace SimpleWeb { } catch( const std::exception & ) { if(on_error) - on_error(request, boost::system::error_code(boost::system::errc::operation_canceled, boost::system::generic_category())); + on_error( request, std::error_code( std::errc::protocol_error, std::generic_category() ) ); return; } } @@ -421,7 +421,7 @@ namespace SimpleWeb { template class Server : public ServerBase {}; - typedef boost::asio::ip::tcp::socket HTTP; + typedef asio::ip::tcp::socket HTTP; template<> class Server : public ServerBase { @@ -442,13 +442,13 @@ namespace SimpleWeb { //Shared_ptr is used to pass temporary objects to the asynchronous functions auto socket=std::make_shared(*io_service); - acceptor->async_accept(*socket, [this, socket](const boost::system::error_code& ec){ + acceptor->async_accept(*socket, [this, socket](const std::error_code& ec){ //Immediately start accepting a new connection (if io_service hasn't been stopped) - if (ec != boost::asio::error::operation_aborted) + if (ec != asio::error::operation_aborted) accept(); if(!ec) { - boost::asio::ip::tcp::no_delay option(true); + asio::ip::tcp::no_delay option(true); socket->set_option(option); this->read_request_and_content(socket); diff --git a/src/servers/sapphire_lobby/client_http.hpp b/src/servers/sapphire_lobby/client_http.hpp index 656b8d01..0d02d814 100644 --- a/src/servers/sapphire_lobby/client_http.hpp +++ b/src/servers/sapphire_lobby/client_http.hpp @@ -1,11 +1,12 @@ #ifndef CLIENT_HTTP_HPP #define CLIENT_HTTP_HPP -#include #include #include #include +#include + #include #include #include @@ -48,7 +49,7 @@ namespace SimpleWeb { std::unordered_multimap header; private: - boost::asio::streambuf content_buffer; + asio::streambuf content_buffer; Response() : content( &content_buffer ) {} }; @@ -72,10 +73,10 @@ namespace SimpleWeb { auto corrected_path = path; if( corrected_path == "" ) corrected_path = "/"; - if( !config.proxy_server.empty() && std::is_same::value ) + if( !config.proxy_server.empty() && std::is_same::value ) corrected_path = "http://" + host + ':' + std::to_string( port ) + corrected_path; - boost::asio::streambuf write_buffer; + asio::streambuf write_buffer; std::ostream write_stream( &write_buffer ); write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n"; write_stream << "Host: " << host << "\r\n"; @@ -89,21 +90,21 @@ namespace SimpleWeb { connect(); auto timer = get_timeout_timer(); - boost::asio::async_write( *socket, write_buffer, - [this, &content, timer]( const boost::system::error_code &ec, size_t /*bytes_transferred*/ ) { + asio::async_write( *socket, write_buffer, + [this, &content, timer]( const std::error_code &ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); if( !ec ) { if( !content.empty() ) { auto timer = get_timeout_timer(); - boost::asio::async_write( *socket, boost::asio::buffer( content.data(), content.size() ), - [this, timer]( const boost::system::error_code &ec, size_t /*bytes_transferred*/ ) { + asio::async_write( *socket, asio::buffer( content.data(), content.size() ), + [this, timer]( const std::error_code &ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); if( ec ) { std::lock_guard lock( socket_mutex ); this->socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); } @@ -111,7 +112,7 @@ namespace SimpleWeb { else { std::lock_guard lock( socket_mutex ); socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); io_service.reset(); @@ -125,14 +126,14 @@ namespace SimpleWeb { auto corrected_path = path; if( corrected_path == "" ) corrected_path = "/"; - if( !config.proxy_server.empty() && std::is_same::value ) + if( !config.proxy_server.empty() && std::is_same::value ) corrected_path = "http://" + host + ':' + std::to_string( port ) + corrected_path; content.seekp( 0, std::ios::end ); auto content_length = content.tellp(); content.seekp( 0, std::ios::beg ); - boost::asio::streambuf write_buffer; + asio::streambuf write_buffer; std::ostream write_stream( &write_buffer ); write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n"; write_stream << "Host: " << host << "\r\n"; @@ -148,14 +149,14 @@ namespace SimpleWeb { connect(); auto timer = get_timeout_timer(); - boost::asio::async_write( *socket, write_buffer, - [this, timer]( const boost::system::error_code &ec, size_t /*bytes_transferred*/ ) { + asio::async_write( *socket, write_buffer, + [this, timer]( const std::error_code &ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); if( ec ) { std::lock_guard lock( socket_mutex ); socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); io_service.reset(); @@ -167,15 +168,15 @@ namespace SimpleWeb { void close() { std::lock_guard lock( socket_mutex ); if( socket ) { - boost::system::error_code ec; - socket->lowest_layer().shutdown( boost::asio::ip::tcp::socket::shutdown_both, ec ); + std::error_code ec; + socket->lowest_layer().shutdown( asio::ip::tcp::socket::shutdown_both, ec ); socket->lowest_layer().close(); } } protected: - boost::asio::io_service io_service; - boost::asio::ip::tcp::resolver resolver; + asio::io_service io_service; + asio::ip::tcp::resolver resolver; std::unique_ptr socket; std::mutex socket_mutex; @@ -205,13 +206,13 @@ namespace SimpleWeb { virtual void connect() = 0; - std::shared_ptr get_timeout_timer() { + std::shared_ptr< asio::deadline_timer > get_timeout_timer() { if( config.timeout == 0 ) return nullptr; - auto timer = std::make_shared( io_service ); + auto timer = std::make_shared< asio::deadline_timer >( io_service ); timer->expires_from_now( boost::posix_time::seconds( config.timeout ) ); - timer->async_wait( [this]( const boost::system::error_code& ec ) { + timer->async_wait( [this]( const std::error_code& ec ) { if( !ec ) { close(); } @@ -248,11 +249,11 @@ namespace SimpleWeb { std::shared_ptr request_read() { std::shared_ptr response( new Response() ); - boost::asio::streambuf chunked_streambuf; + asio::streambuf chunked_streambuf; auto timer = get_timeout_timer(); - boost::asio::async_read_until( *socket, response->content_buffer, "\r\n\r\n", - [this, &response, &chunked_streambuf, timer]( const boost::system::error_code& ec, size_t bytes_transferred ) { + asio::async_read_until( *socket, response->content_buffer, "\r\n\r\n", + [this, &response, &chunked_streambuf, timer]( const std::error_code& ec, size_t bytes_transferred ) { if( timer ) timer->cancel(); if( !ec ) { @@ -265,15 +266,15 @@ namespace SimpleWeb { auto content_length = stoull( header_it->second ); if( content_length>num_additional_bytes ) { auto timer = get_timeout_timer(); - boost::asio::async_read( *socket, response->content_buffer, - boost::asio::transfer_exactly( static_cast< size_t >( content_length - num_additional_bytes ) ), - [this, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) { + asio::async_read( *socket, response->content_buffer, + asio::transfer_exactly( static_cast< size_t >( content_length - num_additional_bytes ) ), + [this, timer]( const std::error_code& ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); if( ec ) { std::lock_guard lock( socket_mutex ); this->socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); } @@ -285,7 +286,7 @@ namespace SimpleWeb { else { std::lock_guard lock( socket_mutex ); socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); io_service.reset(); @@ -294,10 +295,10 @@ namespace SimpleWeb { return response; } - void request_read_chunked( const std::shared_ptr &response, boost::asio::streambuf &streambuf ) { + void request_read_chunked( const std::shared_ptr &response, asio::streambuf &streambuf ) { auto timer = get_timeout_timer(); - boost::asio::async_read_until( *socket, response->content_buffer, "\r\n", - [this, &response, &streambuf, timer]( const boost::system::error_code& ec, size_t bytes_transferred ) { + asio::async_read_until( *socket, response->content_buffer, "\r\n", + [this, &response, &streambuf, timer]( const std::error_code& ec, size_t bytes_transferred ) { if( timer ) timer->cancel(); if( !ec ) { @@ -331,9 +332,9 @@ namespace SimpleWeb { if( ( 2 + length )>num_additional_bytes ) { auto timer = get_timeout_timer(); - boost::asio::async_read( *socket, response->content_buffer, - boost::asio::transfer_exactly( static_cast< size_t >( 2 + length - num_additional_bytes ) ), - [this, post_process, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) { + asio::async_read( *socket, response->content_buffer, + asio::transfer_exactly( static_cast< size_t >( 2 + length - num_additional_bytes ) ), + [this, post_process, timer]( const std::error_code& ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); if( !ec ) { @@ -342,7 +343,7 @@ namespace SimpleWeb { else { std::lock_guard lock( socket_mutex ); this->socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); } @@ -352,7 +353,7 @@ namespace SimpleWeb { else { std::lock_guard lock( socket_mutex ); socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); } @@ -361,7 +362,7 @@ namespace SimpleWeb { template class Client : public ClientBase {}; - typedef boost::asio::ip::tcp::socket HTTP; + typedef asio::ip::tcp::socket HTTP; template<> class Client : public ClientBase { @@ -371,15 +372,15 @@ namespace SimpleWeb { protected: void connect() { if( !socket || !socket->is_open() ) { - std::unique_ptr query; + std::unique_ptr query; if( config.proxy_server.empty() ) - query = std::unique_ptr( new boost::asio::ip::tcp::resolver::query( host, std::to_string( port ) ) ); + query = std::unique_ptr( new asio::ip::tcp::resolver::query( host, std::to_string( port ) ) ); else { auto proxy_host_port = parse_host_port( config.proxy_server, 8080 ); - query = std::unique_ptr( new boost::asio::ip::tcp::resolver::query( proxy_host_port.first, std::to_string( proxy_host_port.second ) ) ); + query = std::unique_ptr( new asio::ip::tcp::resolver::query( proxy_host_port.first, std::to_string( proxy_host_port.second ) ) ); } - resolver.async_resolve( *query, [this]( const boost::system::error_code &ec, - boost::asio::ip::tcp::resolver::iterator it ) { + resolver.async_resolve( *query, [this]( const std::error_code &ec, + asio::ip::tcp::resolver::iterator it ) { if( !ec ) { { std::lock_guard lock( socket_mutex ); @@ -387,25 +388,25 @@ namespace SimpleWeb { } auto timer = get_timeout_timer(); - boost::asio::async_connect( *socket, it, [this, timer] - ( const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator /*it*/ ) { + asio::async_connect( *socket, it, [this, timer] + ( const std::error_code &ec, asio::ip::tcp::resolver::iterator /*it*/ ) { if( timer ) timer->cancel(); if( !ec ) { - boost::asio::ip::tcp::no_delay option( true ); + asio::ip::tcp::no_delay option( true ); this->socket->set_option( option ); } else { std::lock_guard lock( socket_mutex ); this->socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); } else { std::lock_guard lock( socket_mutex ); socket = nullptr; - throw boost::system::system_error( ec ); + throw std::system_error( ec ); } } ); io_service.reset(); From 4da3e375fffe6e73308e37e24089c70fe8c05934 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 15:25:55 +1100 Subject: [PATCH 5/6] api now links successfully --- src/servers/sapphire_api/server_http.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/servers/sapphire_api/server_http.hpp b/src/servers/sapphire_api/server_http.hpp index d8676f1f..e5d3fffa 100644 --- a/src/servers/sapphire_api/server_http.hpp +++ b/src/servers/sapphire_api/server_http.hpp @@ -275,7 +275,7 @@ namespace SimpleWeb { } catch( const std::exception & ) { if(on_error) - on_error( request, std::error_code( std::errc::protocol_error, std::generic_category() ) ); + on_error( request, std::make_error_code( std::errc::protocol_error ) ); return; } if(content_length>num_additional_bytes) { @@ -390,7 +390,7 @@ namespace SimpleWeb { } catch( const std::exception & ){ if(on_error) - on_error( request, std::error_code( std::errc::protocol_error, std::generic_category() ) ); + on_error( request, std::make_error_code( std::errc::protocol_error ) ); return; } @@ -412,7 +412,7 @@ namespace SimpleWeb { } catch( const std::exception & ) { if(on_error) - on_error( request, std::error_code( std::errc::protocol_error, std::generic_category() ) ); + on_error( request, std::make_error_code( std::errc::protocol_error ) ); return; } } From cc8c720f17d2b1f69cfaebc74fa4a951ad2a842e Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 15:39:36 +1100 Subject: [PATCH 6/6] fix file extension for log files & always flush log on critical messages --- src/common/Logging/Logger.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/Logging/Logger.cpp b/src/common/Logging/Logger.cpp index 213a6ea8..3261a4e7 100644 --- a/src/common/Logging/Logger.cpp +++ b/src/common/Logging/Logger.cpp @@ -30,10 +30,15 @@ void Logger::init() std::vector< spdlog::sink_ptr > sinks; sinks.push_back( std::make_shared< spdlog::sinks::stdout_color_sink_mt >() ); - sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile, 0, 0 ) ); + sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile + ".log", 0, 0 ) ); m_logger = std::make_shared< spdlog::logger >( "logger", std::begin( sinks ), std::end( sinks ) ); + // always flush the log on criticial messages, otherwise it's done by libc + // see: https://github.com/gabime/spdlog/wiki/7.-Flush-policy + // nb: if the server crashes, log data can be missing from the file unless something logs critical just before it does + m_logger->flush_on( spdlog::level::critical ); + //spdlog::set_pattern( "[%H:%M:%S] [%l] %v" ); }