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

Yet more boost gone

This commit is contained in:
mordred 2018-10-25 23:50:18 +02:00
parent b62b060f9f
commit 0386d6eeb9
11 changed files with 32 additions and 75 deletions

View file

@ -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 ) ) );

View file

@ -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 );
}

View file

@ -1,8 +1,6 @@
#ifndef _LOGGER_H
#define _LOGGER_H
// #include <boost/log/trivial.hpp>
#include <spdlog/spdlog.h>
namespace Core {

View file

@ -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";

View file

@ -2,6 +2,8 @@
#include <chrono>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
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;

View file

@ -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();

View file

@ -11,9 +11,6 @@
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>
extern Core::Logger g_log;

View file

@ -3,7 +3,6 @@
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
#include "client_http.hpp"
#include "Forwards.h"

View file

@ -1,9 +1,9 @@
#include <boost/format.hpp>
#include <cinttypes>
#include <Common.h>
#include <Version.h>
#include <Network/GamePacketNew.h>
#include <Util/Util.h>
#include <Util/UtilMath.h>
#include <Network/PacketContainer.h>
#include <Logging/Logger.h>
@ -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() ) );
}
}

View file

@ -1,5 +1,3 @@
#include <boost/format.hpp>
#include <Common.h>
#include <Network/CommonNetwork.h>
#include <Util/Util.h>
@ -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() );
}
}

View file

@ -2,11 +2,9 @@
#include <Logging/Logger.h>
#include <Config/ConfigMgr.h>
#include <Util/Util.h>
#include "ServerZone.h"
#include <boost/format.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <experimental/filesystem>
#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;
}