From b0ab052bd4c9fd047ceb79e02210d1fb1f017d6e Mon Sep 17 00:00:00 2001 From: Mordred Date: Sat, 5 Jan 2019 12:32:10 +0100 Subject: [PATCH] Changed sendDebug to use fmt aswell --- src/common/Logging/Logger.h | 24 +++++----- .../common/aethernet/HousingAethernet.cpp | 2 +- src/world/Actor/Chara.cpp | 14 +++--- src/world/Actor/Player.cpp | 7 +-- src/world/Actor/Player.h | 7 +++ src/world/Manager/DebugCommandMgr.cpp | 46 +++++++++---------- src/world/Network/GameConnection.cpp | 4 +- src/world/Network/Handlers/ActionHandler.cpp | 9 ++-- src/world/Network/Handlers/CFHandlers.cpp | 6 +-- .../Network/Handlers/ClientTriggerHandler.cpp | 5 +- src/world/Network/Handlers/EventHandlers.cpp | 45 ++++++------------ .../Network/Handlers/GMCommandHandlers.cpp | 2 +- src/world/Network/Handlers/PacketHandlers.cpp | 10 ++-- src/world/Script/ScriptMgr.cpp | 10 ++-- src/world/ServerMgr.cpp | 4 +- src/world/Session.cpp | 2 +- src/world/Territory/InstanceContent.cpp | 4 +- 17 files changed, 93 insertions(+), 108 deletions(-) diff --git a/src/common/Logging/Logger.h b/src/common/Logging/Logger.h index 3ed95035..5151eb1d 100644 --- a/src/common/Logging/Logger.h +++ b/src/common/Logging/Logger.h @@ -24,48 +24,48 @@ namespace Sapphire static void error( const std::string& text ); template< typename... Args > - static void error( const std::string& fmt, const Args&... args ) + static void error( const std::string& text, const Args&... args ) { - error( fmt::format( fmt, args... ) ); + error( fmt::format( text, args... ) ); } static void warn( const std::string& text ); template< typename... Args > - static void warn( const std::string& fmt, const Args&... args ) + static void warn( const std::string& text, const Args&... args ) { - warn( fmt::format( fmt, args... ) ); + warn( fmt::format( text, args... ) ); } static void info( const std::string& text ); template< typename... Args > - static void info( const std::string& fmt, const Args&... args ) + static void info( const std::string& text, const Args&... args ) { - info( fmt::format( fmt, args... ) ); + info( fmt::format( text, args... ) ); } static void debug( const std::string& text ); template< typename... Args > - static void debug( const std::string& fmt, const Args&... args ) + static void debug( const std::string& text, const Args&... args ) { - debug( fmt::format( fmt, args... ) ); + debug( fmt::format( text, args... ) ); } static void fatal( const std::string& text ); template< typename... Args > - static void fatal( const std::string& fmt, const Args&... args ) + static void fatal( const std::string& text, const Args&... args ) { - fatal( fmt::format( fmt, args... ) ); + fatal( fmt::format( text, args... ) ); } static void trace( const std::string& text ); template< typename... Args > - static void trace( const std::string& fmt, const Args&... args ) + static void trace( const std::string& text, const Args&... args ) { - trace( fmt::format( fmt, args... ) ); + trace( fmt::format( text, args... ) ); } diff --git a/src/scripts/common/aethernet/HousingAethernet.cpp b/src/scripts/common/aethernet/HousingAethernet.cpp index 012bf5ee..272065b8 100644 --- a/src/scripts/common/aethernet/HousingAethernet.cpp +++ b/src/scripts/common/aethernet/HousingAethernet.cpp @@ -36,7 +36,7 @@ public: if( player.getCurrentZone()->getTerritoryTypeId() != pHousingAethernet->territoryType ) return; - player.sendDebug( "got level entry: " + std::to_string( pHousingAethernet->level ) ); + player.sendDebug( "got level entry: {0}", pHousingAethernet->level ); } ); } }; \ No newline at end of file diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 10e78b21..868cfe3b 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -432,8 +432,8 @@ void Sapphire::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionI auto pExdData = m_pFw->get< Data::ExdDataGenerated >(); if( isPlayer() ) { - getAsPlayer()->sendDebug( std::to_string( target.getId() ) ); - getAsPlayer()->sendDebug( "Handle script skill type: " + std::to_string( type ) ); + getAsPlayer()->sendDebug( "{0}", target.getId() ); + getAsPlayer()->sendDebug( "Handle script skill type: {0}", type ); } auto actionInfoPtr = pExdData->get< Sapphire::Data::Action >( actionId ); @@ -495,10 +495,9 @@ void Sapphire::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionI if( isPlayer() ) { if( pHitActor->isPlayer() ) - getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + - " (" + pHitActor->getAsChara()->getName() + ")" ); + getAsPlayer()->sendDebug( "AoE hit actor#{0} ({1})", pHitActor->getId(), pHitActor->getAsChara()->getName() ); else - getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) ); + getAsPlayer()->sendDebug( "AoE hit actor#{0}", pHitActor->getId() ); } } } @@ -546,10 +545,9 @@ void Sapphire::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionI if( isPlayer() ) { if( pHitActor->isPlayer() ) - getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + - " (" + pHitActor->getAsChara()->getName() + ")" ); + getAsPlayer()->sendDebug( "AoE hit actor#{0} ({1})", pHitActor->getId(), pHitActor->getAsChara()->getName() ); else - getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) ); + getAsPlayer()->sendDebug( "AoE hit actor#{0}", pHitActor->getId() ); } } } diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index ce9f478d..c5f70e4b 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -362,9 +362,10 @@ void Sapphire::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type ) rot = targetPos->getTargetRotation(); } - sendDebug( "Teleport: " + pExdData->get< Sapphire::Data::PlaceName >( data->placeName )->name + " " + - pExdData->get< Sapphire::Data::PlaceName >( data->aethernetName )->name + - "(" + std::to_string( data->territory ) + ")" ); + sendDebug( "Teleport: {0} {1} ({2})", + pExdData->get< Sapphire::Data::PlaceName >( data->placeName )->name, + pExdData->get< Sapphire::Data::PlaceName >( data->aethernetName )->name, + data->territory ); // TODO: this should be simplified and a type created in server_common/common.h. if( type == 1 ) // teleport diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 218b27f9..ce12545c 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -5,6 +5,7 @@ #include #include +#include #include "Chara.h" #include "Event/EventHandler.h" @@ -764,6 +765,12 @@ namespace Sapphire::Entity void sendDebug( const std::string& message ); + template< typename... Args > + void sendDebug( const std::string& message, const Args&... args ) + { + sendDebug( fmt::format( message, args... ) ); + } + void sendLogMessage( uint32_t messageId, uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0, uint32_t param5 = 0, uint32_t param6 = 0 ); bool isDirectorInitialized() const; diff --git a/src/world/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index 25cb092c..7685a327 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -131,7 +131,7 @@ void Sapphire::World::Manager::DebugCommandMgr::help( char* data, Entity::Player { if( player.getGmRank() >= cmd.second->m_gmLevel ) { - player.sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText() ); + player.sendDebug( " - {0} - {1}", cmd.first, cmd.second->getHelpText() ); } } } @@ -324,7 +324,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& if( !player.hasQuest( questId ) ) { - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + player.sendDebug( "Player doesn't have the quest with ID#: {0}", questId ); return; } if( questBit == 0 || questId == 0 ) @@ -679,9 +679,9 @@ Sapphire::World::Manager::DebugCommandMgr::serverInfo( char* data, Entity::Playe std::shared_ptr< DebugCommand > command ) { auto pServerZone = framework()->get< World::ServerMgr >(); - player.sendDebug( "SapphireZone " + Version::VERSION + "\nRev: " + Version::GIT_HASH ); + player.sendDebug( "SapphireZone {0} \nRev: {1}", Version::VERSION, Version::GIT_HASH ); player.sendDebug( "Compiled: " __DATE__ " " __TIME__ ); - player.sendDebug( "Sessions: " + std::to_string( pServerZone->getSessionCount() ) ); + player.sendDebug( "Sessions: {0}", pServerZone->getSessionCount() ); } void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Player& player, @@ -716,7 +716,7 @@ void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Play else if( pScriptMgr->getNativeScriptHandler().unloadScript( params ) ) player.sendDebug( "Unloaded script successfully." ); else - player.sendDebug( "Failed to unload script: " + params ); + player.sendDebug( "Failed to unload script: {0}", params ); } else if( subCommand == "find" || subCommand == "f" ) { @@ -729,17 +729,16 @@ void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Play if( !scripts.empty() ) { - player.sendDebug( "Found " + std::to_string( scripts.size() ) + " scripts" ); + player.sendDebug( "Found {0} scripts", scripts.size() ); for( auto it = scripts.begin(); it != scripts.end(); ++it ) { auto script = *it; - player.sendDebug( " - '" + script->library_name + - ", num scripts: " + std::to_string( script->scripts.size() ) ); + player.sendDebug( " - '{0}', num scripts: {1}", script->library_name, script->scripts.size() ); } } else - player.sendDebug( "No scripts found with search term: " + params ); + player.sendDebug( "No scripts found with search term: {0}", params ); } } else if( subCommand == "load" || subCommand == "l" ) @@ -749,9 +748,9 @@ void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Play else { if( pScriptMgr->getNativeScriptHandler().loadScript( params ) ) - player.sendDebug( "Loaded '" + params + "' successfully" ); + player.sendDebug( "Loaded '{0}' successfully", params ); else - player.sendDebug( "Failed to load '" + params + "'" ); + player.sendDebug( "Failed to load '{0}'", params ); } } @@ -762,12 +761,12 @@ void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Play else { pScriptMgr->getNativeScriptHandler().queueScriptReload( params ); - player.sendDebug( "Queued script reload for script: " + params ); + player.sendDebug( "Queued script reload for script: {0}", params ); } } else { - player.sendDebug( "Unknown script subcommand: " + subCommand ); + player.sendDebug( "Unknown script subcommand: {0}", subCommand ); } } @@ -801,10 +800,9 @@ Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& auto instance = pTeriMgr->createInstanceContent( instanceContentId ); if( instance ) - player.sendDebug( - "Created instance with id: " + std::to_string( instance->getGuId() ) + " -> " + instance->getName() ); + player.sendDebug( "Created instance with id#{0} -> {1}", instance->getGuId(), instance->getName() ); else - player.sendDebug( "Failed to create instance with id: " + std::to_string( instanceContentId ) ); + player.sendDebug( "Failed to create instance with id#{0}", instanceContentId ); } else if( subCommand == "bind" ) { @@ -821,7 +819,7 @@ Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& " -> " + pInstanceContent->getName() ); } else - player.sendDebug( "Unknown instance with id: " + std::to_string( instanceId ) ); + player.sendDebug( "Unknown instance with id#{0}", instanceId ); } else if( subCommand == "unbind" ) { @@ -831,7 +829,7 @@ Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& auto instance = pTeriMgr->getInstanceZonePtr( instanceId ); if( !instance ) { - player.sendDebug( "Unknown instance with id: " + std::to_string( instanceId ) ); + player.sendDebug( "Unknown instance with id#{0} ", instanceId ); return; } @@ -839,12 +837,10 @@ Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& if( pInstanceContent->isPlayerBound( player.getId() ) ) { pInstanceContent->unbindPlayer( player.getId() ); - player.sendDebug( - "Now unbound from instance with id: " + std::to_string( pInstanceContent->getGuId() ) + - " -> " + pInstanceContent->getName() ); + player.sendDebug( "Now unbound from instance with id#{0} -> {1}", pInstanceContent->getGuId(), pInstanceContent->getName() ); } else - player.sendDebug( "Player not bound to instance with id: " + std::to_string( instanceId ) ); + player.sendDebug( "Player not bound to instance with id#{0}", instanceId ); } else if( subCommand == "createzone" || subCommand == "crz" ) @@ -857,7 +853,7 @@ Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& player.sendDebug( "Created instance with id: " + std::to_string( instance->getGuId() ) + " -> " + instance->getName() ); else - player.sendDebug( "Failed to create instance with id: " + std::to_string( zoneId ) ); + player.sendDebug( "Failed to create instance with id#{0}", zoneId ); } else if( subCommand == "remove" || subCommand == "rm" ) { @@ -865,9 +861,9 @@ Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& sscanf( params.c_str(), "%d", &terriId ); if( pTeriMgr->removeTerritoryInstance( terriId ) ) - player.sendDebug( "Removed instance with id: " + std::to_string( terriId ) ); + player.sendDebug( "Removed instance with id#{0}", terriId ); else - player.sendDebug( "Failed to remove instance with id: " + std::to_string( terriId ) ); + player.sendDebug( "Failed to remove instance with id#{0}", terriId ); } else if( subCommand == "return" || subCommand == "ret" ) { diff --git a/src/world/Network/GameConnection.cpp b/src/world/Network/GameConnection.cpp index cbf470b8..0bacd53a 100644 --- a/src/world/Network/GameConnection.cpp +++ b/src/world/Network/GameConnection.cpp @@ -343,7 +343,7 @@ void Sapphire::Network::GameConnection::injectPacket( const std::string& packetp fp = fopen( packetpath.c_str(), "rb" ); if( fp == nullptr ) { - player.sendDebug( "Packet " + packetpath + " not found!" ); + player.sendDebug( "Packet {0} not found!", packetpath ); return; } @@ -353,7 +353,7 @@ void Sapphire::Network::GameConnection::injectPacket( const std::string& packetp rewind( fp ); if( fread( packet, sizeof( char ), size, fp ) != size ) { - player.sendDebug( "Packet " + packetpath + " did not read full size: " + std::to_string( size ) ); + player.sendDebug( "Packet {0} did not read full size: {1}", packetpath, size ); return; } fclose( fp ); diff --git a/src/world/Network/Handlers/ActionHandler.cpp b/src/world/Network/Handlers/ActionHandler.cpp index 2f572578..3ee00e6f 100644 --- a/src/world/Network/Handlers/ActionHandler.cpp +++ b/src/world/Network/Handlers/ActionHandler.cpp @@ -44,7 +44,7 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw, const auto useCount = packet.data().useCount; const auto targetId = packet.data().targetId; - player.sendDebug( "Skill type:" + std::to_string( type ) ); + player.sendDebug( "Skill type: {0}", type ); auto pExdData = pFw->get< Data::ExdDataGenerated >(); auto pScriptMgr = pFw->get< Scripting::ScriptMgr >(); @@ -57,9 +57,8 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw, { std::string actionIdStr = Util::intToHexString( action, 4 ); player.sendDebug( "---------------------------------------" ); - player.sendDebug( "ActionHandler ( " + actionIdStr + " | " + - pExdData->get< Sapphire::Data::Action >( action )->name + - " | " + std::to_string( targetId ) + " )" ); + player.sendDebug( "ActionHandler ( {0} | {1} | {2} )", + actionIdStr, pExdData->get< Sapphire::Data::Action >( action )->name, targetId ); player.queuePacket( makeActorControl142( player.getId(), ActorControlType::ActionStart, 0x01, action ) ); @@ -122,7 +121,7 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw, case Common::SkillType::MountSkill: - player.sendDebug( "Request mount " + std::to_string( action ) ); + player.sendDebug( "Request mount {0}", action ); auto pActionMount = Action::make_ActionMount( player.getAsPlayer(), action ); player.setCurrentAction( pActionMount ); diff --git a/src/world/Network/Handlers/CFHandlers.cpp b/src/world/Network/Handlers/CFHandlers.cpp index bc289634..1a87a371 100644 --- a/src/world/Network/Handlers/CFHandlers.cpp +++ b/src/world/Network/Handlers/CFHandlers.cpp @@ -56,7 +56,7 @@ void Sapphire::Network::GameConnection::cfRegisterDuty( FrameworkPtr pFw, if( id == 0 ) break; - player.sendDebug( "got contentId: " + std::to_string( id ) ); + player.sendDebug( "got contentId#{0}", id ); selectedContent.push_back( id ); } @@ -65,7 +65,7 @@ void Sapphire::Network::GameConnection::cfRegisterDuty( FrameworkPtr pFw, auto index = std::rand() % selectedContent.size(); auto contentId = selectedContent.at( index ); - player.sendDebug( "Duty register request for contentid: " + std::to_string( contentId ) ); + player.sendDebug( "Duty register request for contentid#{0}", contentId ); // let's cancel it because otherwise you can't register it again auto cfCancelPacket = makeZonePacket< FFXIVIpcCFNotify >( player.getId() ); @@ -84,7 +84,7 @@ void Sapphire::Network::GameConnection::cfRegisterDuty( FrameworkPtr pFw, auto pInstance = instance->getAsInstanceContent(); pInstance->bindPlayer( player.getId() ); - player.sendDebug( "Created instance with id: " + std::to_string( instance->getGuId() ) ); + player.sendDebug( "Created instance with id#", instance->getGuId() ); player.setInstance( instance ); } diff --git a/src/world/Network/Handlers/ClientTriggerHandler.cpp b/src/world/Network/Handlers/ClientTriggerHandler.cpp index 278be951..30c68fa5 100644 --- a/src/world/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/world/Network/Handlers/ClientTriggerHandler.cpp @@ -482,9 +482,8 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, auto privateEstateAccess = ( param2 >> 16 & 0xFF ) == 1; auto unk = ( param2 >> 24 & 0xFF ) == 1; // todo: related to fc? or unused? - player.sendDebug( "can teleport: " + std::to_string( canTeleport ) + ", unk: " + std::to_string( unk1 ) + - ", privateEstateAccess: " + std::to_string( privateEstateAccess ) + - ", unk: " + std::to_string( unk ) ); + player.sendDebug( "can teleport: {0}, unk: {1}, privateEstateAccess: {2}, unk: {3}", + canTeleport, unk1, privateEstateAccess, unk ); break; } diff --git a/src/world/Network/Handlers/EventHandlers.cpp b/src/world/Network/Handlers/EventHandlers.cpp index b3124529..1dd0d060 100644 --- a/src/world/Network/Handlers/EventHandlers.cpp +++ b/src/world/Network/Handlers/EventHandlers.cpp @@ -48,15 +48,12 @@ void Sapphire::Network::GameConnection::eventHandlerTalk( FrameworkPtr pFw, std::string eventName = "onTalk"; std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "Chara: " + - std::to_string( actorId ) + " -> " + - std::to_string( pEventMgr->mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) + - " \neventId: " + - std::to_string( eventId ) + - " (0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + ")" ); + player.sendDebug( "Chara: {0} -> {1} \neventId: {2} ({3:08X}", + actorId, pEventMgr->mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ), + eventId, eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName ); + player.sendDebug( "Calling: {0}.{1}", objName, eventName ); player.eventStart( actorId, eventId, Event::EventHandler::Talk, 0, 0 ); if( auto instance = player.getCurrentInstance() ) @@ -93,14 +90,11 @@ void Sapphire::Network::GameConnection::eventHandlerEmote( FrameworkPtr pFw, std::string eventName = "onEmote"; std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "Chara: " + - std::to_string( actorId ) + " -> " + - std::to_string( pEventMgr->mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) + - " \neventId: " + - std::to_string( eventId ) + - " (0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + ")" ); + player.sendDebug( "Chara: {0} -> {1} \neventId: {2} ({3:08X}", + actorId, pEventMgr->mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ), + eventId, eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName ); + player.sendDebug( "Calling: {0}.{1}", objName, eventName ); player.eventStart( actorId, eventId, Event::EventHandler::Emote, 0, emoteId ); @@ -130,8 +124,7 @@ void Sapphire::Network::GameConnection::eventHandlerWithinRange( FrameworkPtr pF std::string eventName = "onWithinRange"; std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName + " - " + std::to_string( eventId ) + - " p1: " + std::to_string( param1 ) ); + player.sendDebug( "Calling: {0}.{1} - {2} p1: {3}", objName, eventName, eventId, param1 ); player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 ); @@ -154,8 +147,7 @@ void Sapphire::Network::GameConnection::eventHandlerOutsideRange( FrameworkPtr p std::string eventName = "onOutsideRange"; std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName + " - " + std::to_string( eventId ) + - " p1: " + std::to_string( param1 ) ); + player.sendDebug( "Calling: {0}.{1} - {2} p1: {3}", objName, eventName, eventId, param1 ); player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 ); @@ -181,7 +173,7 @@ void Sapphire::Network::GameConnection::eventHandlerEnterTerritory( FrameworkPtr std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName + " - " + std::to_string( eventId ) ); + player.sendDebug( "Calling: {0}.{1} - {2}", objName, eventName, eventId ); if( auto instance = player.getCurrentInstance() ) { @@ -213,13 +205,8 @@ void Sapphire::Network::GameConnection::eventHandlerReturn( FrameworkPtr pFw, std::string eventName = pEventMgr->getEventName( eventId ); - player.sendDebug( "eventId: " + - std::to_string( eventId ) + - " ( 0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + " ) " + - " scene: " + std::to_string( scene ) + - " p1: " + std::to_string( param1 ) + - " p2: " + std::to_string( param2 ) + - " p3: " + std::to_string( param3 ) ); + player.sendDebug( "eventId: {0} ({0:08X}) scene: {1}, p1: {2}, p2: {3}, p3: {4}", + eventId, scene, param1, param2, param3 ); auto pEvent = player.getEvent( eventId ); if( pEvent ) @@ -282,11 +269,9 @@ void Sapphire::Network::GameConnection::eventHandlerShop( FrameworkPtr pFw, std::string eventName = "onOpen"; std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "EventId: " + - std::to_string( eventId ) + - " (0x" + Util::intToHexString( static_cast< uint64_t >( eventId & 0xFFFFFFF ), 8 ) + ")" ); + player.sendDebug( "EventId: {0} ({0:08X}", eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName ); + player.sendDebug( "Calling: {0}.{1}", objName, eventName ); player.eventStart( player.getId(), eventId, Event::EventHandler::UI, 0, packet.data().param ); pScriptMgr->onTalk( player, player.getId(), eventId ); diff --git a/src/world/Network/Handlers/GMCommandHandlers.cpp b/src/world/Network/Handlers/GMCommandHandlers.cpp index 980f3008..a31d5a74 100644 --- a/src/world/Network/Handlers/GMCommandHandlers.cpp +++ b/src/world/Network/Handlers/GMCommandHandlers.cpp @@ -427,7 +427,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, auto pTeriMgr = pFw->get< TerritoryMgr >(); if( auto instance = pTeriMgr->getInstanceZonePtr( param1 ) ) { - player.sendDebug( "Found instance: " + instance->getName() + ", id: " + std::to_string( param1 ) ); + player.sendDebug( "Found instance: {0}, id#{1}", instance->getName(), param1 ); // if the zone is an instanceContent instance, make sure the player is actually bound to it auto pInstance = instance->getAsInstanceContent(); diff --git a/src/world/Network/Handlers/PacketHandlers.cpp b/src/world/Network/Handlers/PacketHandlers.cpp index c87002b5..3875bef2 100644 --- a/src/world/Network/Handlers/PacketHandlers.cpp +++ b/src/world/Network/Handlers/PacketHandlers.cpp @@ -314,7 +314,7 @@ Sapphire::Network::GameConnection::reqEquipDisplayFlagsHandler( FrameworkPtr pFw { player.setEquipDisplayFlags( inPacket.data[ 0x10 ] ); - player.sendDebug( "EquipDisplayFlag CHANGE: " + std::to_string( player.getEquipDisplayFlags() ) ); + player.sendDebug( "EquipDisplayFlag CHANGE: {0}", player.getEquipDisplayFlags() ); } void Sapphire::Network::GameConnection::zoneLineHandler( FrameworkPtr pFw, @@ -326,7 +326,7 @@ void Sapphire::Network::GameConnection::zoneLineHandler( FrameworkPtr pFw, const auto packet = ZoneChannelPacket< Client::FFXIVIpcZoneLineHandler >( inPacket ); const auto zoneLineId = packet.data().zoneLineId; - player.sendDebug( "Walking ZoneLine " + std::to_string( zoneLineId ) ); + player.sendDebug( "Walking ZoneLine#{0}", zoneLineId ); auto pZone = player.getCurrentZone(); @@ -338,7 +338,7 @@ void Sapphire::Network::GameConnection::zoneLineHandler( FrameworkPtr pFw, if( pLine != nullptr ) { - player.sendDebug( "ZoneLine " + std::to_string( zoneLineId ) + " found." ); + player.sendDebug( "ZoneLine #{0} found.", zoneLineId ); targetPos = pLine->getTargetPosition(); targetZone = pLine->getTargetZoneId(); rotation = pLine->getTargetRotation(); @@ -379,7 +379,7 @@ void Sapphire::Network::GameConnection::discoveryHandler( FrameworkPtr pFw, if( !pQR->next() ) { - player.sendDebug( "Discovery ref pos ID: " + std::to_string( positionRef ) + " not found. " ); + player.sendDebug( "Discovery ref pos id#{0} not found!", positionRef ); return; } @@ -388,7 +388,7 @@ void Sapphire::Network::GameConnection::discoveryHandler( FrameworkPtr pFw, discoveryPacket->data().map_part_id = pQR->getUInt( 3 ); player.queuePacket( discoveryPacket ); - player.sendDebug( "Discovery ref pos ID: " + std::to_string( positionRef ) ); + player.sendDebug( "Discovery ref pos id#{0}", positionRef ); player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) ); diff --git a/src/world/Script/ScriptMgr.cpp b/src/world/Script/ScriptMgr.cpp index c3088cad..408c51d9 100644 --- a/src/world/Script/ScriptMgr.cpp +++ b/src/world/Script/ScriptMgr.cpp @@ -261,7 +261,7 @@ bool Sapphire::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32 std::string eventName = "onEventItem"; std::string objName = pEventMgr->getEventName( eventId ); - player.sendDebug( "Calling: " + objName + "." + eventName + " - " + std::to_string( eventId ) ); + player.sendDebug( "Calling: {0}.{1} - {2}", objName, eventName, eventId ); auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId ); if( script ) @@ -295,7 +295,7 @@ bool Sapphire::Scripting::ScriptMgr::onMobKill( Entity::Player& player, uint16_t { std::string objName = pEventMgr->getEventName( 0x00010000 | questId ); - player.sendDebug( "Calling: " + objName + "." + eventName ); + player.sendDebug( "Calling: {0}.{1}", objName, eventName ); script->onNpcKill( nameId, player ); } @@ -320,7 +320,7 @@ bool Sapphire::Scripting::ScriptMgr::onStatusReceive( Entity::CharaPtr pActor, u if( script ) { if( pActor->isPlayer() ) - pActor->getAsPlayer()->sendDebug( "Calling status receive for statusid: " + std::to_string( effectId ) ); + pActor->getAsPlayer()->sendDebug( "Calling status receive for statusid#{0}", effectId ); script->onApply( *pActor ); return true; @@ -335,7 +335,7 @@ bool Sapphire::Scripting::ScriptMgr::onStatusTick( Entity::CharaPtr pChara, Sapp if( script ) { if( pChara->isPlayer() ) - pChara->getAsPlayer()->sendDebug( "Calling status tick for statusid: " + std::to_string( effect.getId() ) ); + pChara->getAsPlayer()->sendDebug( "Calling status tick for statusid#{0}", effect.getId() ); script->onTick( *pChara ); return true; @@ -350,7 +350,7 @@ bool Sapphire::Scripting::ScriptMgr::onStatusTimeOut( Entity::CharaPtr pChara, u if( script ) { if( pChara->isPlayer() ) - pChara->getAsPlayer()->sendDebug( "Calling status timeout for statusid: " + std::to_string( effectId ) ); + pChara->getAsPlayer()->sendDebug( "Calling status timeout for statusid#{0}", effectId ); script->onExpire( *pChara ); return true; diff --git a/src/world/ServerMgr.cpp b/src/world/ServerMgr.cpp index 458d6aa2..70f452f4 100644 --- a/src/world/ServerMgr.cpp +++ b/src/world/ServerMgr.cpp @@ -217,8 +217,8 @@ void Sapphire::World::ServerMgr::printBanner() const { Logger::info( "===========================================================" ); Logger::info( "Sapphire Server Project " ); - Logger::info( "Version: " + Version::VERSION ); - Logger::info( "Git Hash: " + Version::GIT_HASH ); + Logger::info( "Version: {0}", Version::VERSION ); + Logger::info( "Git Hash: {0}", Version::GIT_HASH ); Logger::info( "Compiled: " __DATE__ " " __TIME__ ); Logger::info( "===========================================================" ); } diff --git a/src/world/Session.cpp b/src/world/Session.cpp index 14e87d48..682fdb45 100644 --- a/src/world/Session.cpp +++ b/src/world/Session.cpp @@ -154,7 +154,7 @@ void Sapphire::World::Session::startReplay( const std::string& path ) Logger::info( "Registering {0} for {1}", std::get< 1 >( set ), std::get< 0 >( set ) - startTime ); } - getPlayer()->sendDebug( "Registered " + std::to_string( m_replayCache.size() ) + " sets for replay" ); + getPlayer()->sendDebug( "Registered {0} sets for replay" ), m_replayCache.size(); m_isReplaying = true; } diff --git a/src/world/Territory/InstanceContent.cpp b/src/world/Territory/InstanceContent.cpp index 6d636219..6c9a2db6 100644 --- a/src/world/Territory/InstanceContent.cpp +++ b/src/world/Territory/InstanceContent.cpp @@ -375,8 +375,8 @@ void Sapphire::InstanceContent::onTalk( Sapphire::Entity::Player& player, uint32 if( auto onTalk = it->second->getOnTalkHandler() ) onTalk( player, it->second, getAsInstanceContent(), actorId ); else - player.sendDebug( "No onTalk handler found for interactable eobj with EObjID: " + - std::to_string( it->second->getObjectId() ) + ", eventId: " + std::to_string( eventId ) ); + player.sendDebug( "No onTalk handler found for interactable eobj with EObjID#{0}, eventId#{1} ", + it->second->getObjectId(), eventId ); } void