From 0386d6eeb90ed92bf66a76adabbab9151fdc8fa1 Mon Sep 17 00:00:00 2001 From: mordred Date: Thu, 25 Oct 2018 23:50:18 +0200 Subject: [PATCH] Yet more boost gone --- src/common/Config/ConfigMgr.cpp | 33 ------------------- src/common/Logging/Logger.cpp | 11 +++---- src/common/Logging/Logger.h | 2 -- src/common/Network/PacketContainer.cpp | 5 ++- src/common/Util/Util.cpp | 13 ++++++-- src/common/Util/Util.h | 4 ++- src/servers/sapphire_lobby/RestConnector.cpp | 3 -- src/servers/sapphire_lobby/RestConnector.h | 1 - .../DebugCommand/DebugCommandHandler.cpp | 5 ++- .../sapphire_zone/Network/GameConnection.cpp | 14 +++----- .../sapphire_zone/Script/ScriptLoader.cpp | 16 ++++----- 11 files changed, 32 insertions(+), 75 deletions(-) diff --git a/src/common/Config/ConfigMgr.cpp b/src/common/Config/ConfigMgr.cpp index 437ee943..ca579e31 100644 --- a/src/common/Config/ConfigMgr.cpp +++ b/src/common/Config/ConfigMgr.cpp @@ -10,42 +10,9 @@ */ bool Core::ConfigMgr::loadConfig( const std::string& configName ) { - // std::stringstream configStream; - // get global config auto configDir = std::experimental::filesystem::path( m_configFolderRoot ); - // if( !std::experimental::filesystem::exists( configDir ) ) - // { - // return false; - // } - - // auto globalConfig = std::experimental::filesystem::path( configDir / m_globalConfigFile ); - // if( !std::experimental::filesystem::exists( globalConfig ) ) - // { - // if( !copyDefaultConfig( globalConfig.filename().string() ) ) - // return false; - // } - - // std::ifstream globalConfigFile( globalConfig.c_str() ); - // configStream << globalConfigFile.rdbuf(); - - // // add some newlines just in case there's no newline at the end of the global file - // configStream << "\n\n"; - - // // get local config - // auto localConfig = ; - // if( !std::experimental::filesystem::exists( localConfig ) ) - // { - // if( !copyDefaultConfig( localConfig.filename().string() ) ) - // return false; - // } - // std::ifstream configFile( localConfig.c_str() ); - // configStream << configFile.rdbuf(); - - // // parse the trxee and we're fuckin done - // //boost::property_tree::read_ini( configStream, m_propTree ); - m_pInih = std::unique_ptr< INIReader >( new INIReader( std::experimental::filesystem::path( configDir / configName ) ) ); diff --git a/src/common/Logging/Logger.cpp b/src/common/Logging/Logger.cpp index 354f38af..794f5c76 100644 --- a/src/common/Logging/Logger.cpp +++ b/src/common/Logging/Logger.cpp @@ -39,33 +39,32 @@ void Logger::init() // 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" ); + 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; } void Logger::error( const std::string& text ) { - spdlog::get( "logger" )->error( text ); + spdlog::get( "logger" )->error( text ); } void Logger::info( const std::string& text ) { - spdlog::get( "logger" )->info( text ); + spdlog::get( "logger" )->info( text ); } void Logger::debug( const std::string& text ) { - spdlog::get( "logger" )->debug( text ); + spdlog::get( "logger" )->debug( text ); } void Logger::fatal( const std::string& text ) { - spdlog::get( "logger" )->critical( text ); + spdlog::get( "logger" )->critical( text ); } diff --git a/src/common/Logging/Logger.h b/src/common/Logging/Logger.h index c176ddc9..2447ebfb 100644 --- a/src/common/Logging/Logger.h +++ b/src/common/Logging/Logger.h @@ -1,8 +1,6 @@ #ifndef _LOGGER_H #define _LOGGER_H -// #include - #include namespace Core { diff --git a/src/common/Network/PacketContainer.cpp b/src/common/Network/PacketContainer.cpp index a6ac4c4d..30aff769 100644 --- a/src/common/Network/PacketContainer.cpp +++ b/src/common/Network/PacketContainer.cpp @@ -1,5 +1,5 @@ #include "PacketContainer.h" - +#include "Util/Util.h" #include "Common.h" #include "Forwards.h" @@ -76,8 +76,7 @@ std::string Core::Network::Packets::PacketContainer::toString() std::string str = "\n"; for( uint32_t i = 0; i < m_ipcHdr.size; i++ ) { -// TODO: use std::hex -// str += boost::str( boost::format( "%|02X|" ) % static_cast< int32_t >( tmpBuffer[ i ] & 0xFF ) ) + " "; + str += Util::intToHexString( static_cast< int32_t >( tmpBuffer[ i ] & 0xFF ) ) + " "; if( ( i + 1 ) % 16 == 0 ) str += "\n"; diff --git a/src/common/Util/Util.cpp b/src/common/Util/Util.cpp index c1357dca..1bb70fd6 100644 --- a/src/common/Util/Util.cpp +++ b/src/common/Util/Util.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size ) { @@ -9,15 +11,20 @@ std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size ) for( uint32_t i = 0; i < size; i++ ) { -// TODO:: std::hex stream -// outStr += boost::str( boost::format( "%|02X|" ) % ( int32_t ) ( pBinData[ i ] & 0xFF ) ); + outStr += Util::intToHexString( static_cast< int8_t>( pBinData[ i ] & 0xFF ) ); } return outStr; } +std::string Core::Util::toLowerCopy( const std::string& inStr ) +{ + std::string out; + std::transform( inStr.begin(), inStr.end(), out.begin(), ::tolower ); + return out; +} -std::string intToHexString( uint64_t intValue, uint8_t width ) +std::string Core::Util::intToHexString( uint64_t intValue, uint8_t width ) { std::string hexStr; diff --git a/src/common/Util/Util.h b/src/common/Util/Util.h index 2b1e50bc..a580ee76 100644 --- a/src/common/Util/Util.h +++ b/src/common/Util/Util.h @@ -11,7 +11,9 @@ std::string binaryToHexString( uint8_t* pBinData, uint16_t size ); std::string binaryToHexDump( uint8_t* pBinData, uint16_t size ); -std::string intToHexString( uint32_t intValue, uint8_t width = 2 ); +std::string intToHexString( uint64_t intValue, uint8_t width = 2 ); + +std::string toLowerCopy( const std::string& inStr ); uint64_t getTimeMs(); diff --git a/src/servers/sapphire_lobby/RestConnector.cpp b/src/servers/sapphire_lobby/RestConnector.cpp index 5a9a5a3b..cd7c7f1d 100644 --- a/src/servers/sapphire_lobby/RestConnector.cpp +++ b/src/servers/sapphire_lobby/RestConnector.cpp @@ -11,9 +11,6 @@ #include #include #include -#include -#include -#include extern Core::Logger g_log; diff --git a/src/servers/sapphire_lobby/RestConnector.h b/src/servers/sapphire_lobby/RestConnector.h index aa8a3beb..9ff29c47 100644 --- a/src/servers/sapphire_lobby/RestConnector.h +++ b/src/servers/sapphire_lobby/RestConnector.h @@ -3,7 +3,6 @@ #include #include -#include #include "client_http.hpp" #include "Forwards.h" diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 2ffd6d27..5d87b0d3 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -1,9 +1,9 @@ -#include #include #include #include #include +#include #include #include #include @@ -727,8 +727,7 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player& player, std: for( auto it = scripts.begin(); it != scripts.end(); ++it ) { auto script = *it; - player.sendDebug( " - '" + script->library_name + "' loaded at @ 0x" + - boost::str( boost::format( "%|X|" ) % script->handle ) + + player.sendDebug( " - '" + script->library_name + ", num scripts: " + std::to_string( script->scripts.size() ) ); } } diff --git a/src/servers/sapphire_zone/Network/GameConnection.cpp b/src/servers/sapphire_zone/Network/GameConnection.cpp index 76159e0b..879c7751 100644 --- a/src/servers/sapphire_zone/Network/GameConnection.cpp +++ b/src/servers/sapphire_zone/Network/GameConnection.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -214,16 +212,14 @@ void Core::Network::GameConnection::handleZonePacket( Core::Network::Packets::FF opcode != UpdatePositionHandler ) pLog->debug( sessionStr + " Handling Zone IPC : " + name + "( " + - boost::str( boost::format( "%|04X|" ) % - static_cast< uint32_t >( opcode ) ) + " )" ); + Util::intToHexString( static_cast< uint32_t >( opcode ), 4 ) + " )" ); ( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() ); } else { pLog->debug( sessionStr + " Undefined Zone IPC : Unknown ( " + - boost::str( boost::format( "%|04X|" ) % - static_cast< uint32_t >( opcode ) ) + " )" ); + Util::intToHexString( static_cast< uint32_t >( opcode ), 4 ) + " )" ); pLog->debug( "Dump:\n" + Util::binaryToHexDump( const_cast< uint8_t* >( &pPacket.data[ 0 ] ), pPacket.segHdr.size ) ); } @@ -245,16 +241,14 @@ void Core::Network::GameConnection::handleChatPacket( Core::Network::Packets::FF // dont display packet notification if it is a ping or pos update, don't want the spam pLog->debug( sessionStr + " Handling Chat IPC : " + name + "( " + - boost::str( boost::format( "%|04X|" ) % - static_cast< uint32_t >( opcode ) ) + " )" ); + Util::intToHexString( static_cast< uint32_t >( opcode ), 4 ) + " )" ); ( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() ); } else { pLog->debug( sessionStr + " Undefined Chat IPC : Unknown ( " + - boost::str( boost::format( "%|04X|" ) % - static_cast< uint32_t >( opcode ) ) + " )" ); + Util::intToHexString( static_cast< uint32_t >( opcode ), 4 ) + " )" ); //pLog->debug( pPacket.toString() ); } } diff --git a/src/servers/sapphire_zone/Script/ScriptLoader.cpp b/src/servers/sapphire_zone/Script/ScriptLoader.cpp index 68799d5a..9805072d 100644 --- a/src/servers/sapphire_zone/Script/ScriptLoader.cpp +++ b/src/servers/sapphire_zone/Script/ScriptLoader.cpp @@ -2,11 +2,9 @@ #include #include - +#include #include "ServerZone.h" -#include -#include #include #include "Framework.h" @@ -38,12 +36,12 @@ bool Core::Scripting::ScriptLoader::unloadModule( ModuleHandle handle ) if( !success ) { - pLog->error( "Failed to unload module @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) ); + pLog->error( "Failed to unload module " ); return false; } - pLog->debug( "Unloaded module @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) ); + pLog->debug( "Unloaded module" ); return true; } @@ -90,8 +88,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st return nullptr; } - pLog->debug( - "Loaded module '" + f.filename().string() + "' @ 0x" + boost::str( boost::format( "%|08X|" ) % handle ) ); + pLog->debug( "Loaded module '" + f.filename().string() ); auto info = new ScriptInfo; info->handle = handle; @@ -119,8 +116,6 @@ ScriptObject** Core::Scripting::ScriptLoader::getScripts( ModuleHandle handle ) { auto ptr = func(); - pLog->debug( "got ScriptObject array @ 0x" + boost::str( boost::format( "%|08X|" ) % ptr ) ); - return ptr; } else @@ -166,7 +161,8 @@ bool Core::Scripting::ScriptLoader::isModuleLoaded( std::string name ) { for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it ) { - if( boost::iequals( it->second->library_name, name ) ) + + if( Util::toLowerCopy( it->second->library_name) == Util::toLowerCopy( name ) ) return true; }