From f5258bfd925587c37e1e8a2235917f54b4f37d3a Mon Sep 17 00:00:00 2001 From: Mordred Date: Thu, 27 Jan 2022 21:08:43 +0100 Subject: [PATCH] Improving code consistency and readability in manager classes --- deps/datReader/Exd/Common.h | 1 + deps/datReader/Exd/Structs.h | 2 + src/world/Actor/BNpc.cpp | 4 +- src/world/Manager/ActionMgr.cpp | 37 ++- src/world/Manager/BlacklistMgr.cpp | 29 +-- src/world/Manager/ChatChannelMgr.cpp | 13 +- src/world/Manager/DebugCommandMgr.cpp | 51 ++-- src/world/Manager/EventMgr.cpp | 63 ++--- src/world/Manager/FriendListMgr.cpp | 17 +- src/world/Manager/HousingMgr.cpp | 340 ++++++++++++-------------- src/world/Manager/InventoryMgr.cpp | 28 +-- src/world/Manager/ItemMgr.cpp | 17 +- src/world/Manager/LinkshellMgr.cpp | 34 +-- src/world/Manager/MarketMgr.cpp | 21 +- src/world/Manager/NaviMgr.cpp | 10 +- src/world/Manager/PartyMgr.cpp | 58 ++--- src/world/Manager/PlayerMgr.cpp | 51 ++-- src/world/Manager/QuestMgr.cpp | 13 +- src/world/Manager/ShopMgr.cpp | 11 +- src/world/Manager/TerritoryMgr.cpp | 70 +++--- src/world/Manager/TerritoryMgr.h | 2 +- src/world/Manager/WarpMgr.h | 10 + src/world/Territory/Territory.cpp | 17 +- src/world/Territory/Territory.h | 2 + 24 files changed, 447 insertions(+), 454 deletions(-) diff --git a/deps/datReader/Exd/Common.h b/deps/datReader/Exd/Common.h index bc4344af..754d7392 100644 --- a/deps/datReader/Exd/Common.h +++ b/deps/datReader/Exd/Common.h @@ -1,4 +1,5 @@ #pragma once + namespace Component::Excel { diff --git a/deps/datReader/Exd/Structs.h b/deps/datReader/Exd/Structs.h index 3eb20130..4ffa0a1a 100644 --- a/deps/datReader/Exd/Structs.h +++ b/deps/datReader/Exd/Structs.h @@ -29,6 +29,8 @@ namespace Component::Excel }; }; + template< class T > + using ExcelStructPtr = std::shared_ptr< Component::Excel::ExcelStruct< T > >; ///////////////////////////////////////////////////////// diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index f60f8299..411b39fd 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -579,9 +579,9 @@ void Sapphire::Entity::BNpc::deaggro( const Sapphire::Entity::CharaPtr& pChara ) if( getTriggerOwnerId() == pChara->getId() ) { auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); - scriptMgr.onTriggerOwnerDeaggro( *pChara->getAsPlayer(), *getAsBNpc() ); + auto bnpc = *getAsBNpc(); + scriptMgr.onTriggerOwnerDeaggro( *tmpPlayer, bnpc ); } - } } diff --git a/src/world/Manager/ActionMgr.cpp b/src/world/Manager/ActionMgr.cpp index 071f467e..2fa90198 100644 --- a/src/world/Manager/ActionMgr.cpp +++ b/src/world/Manager/ActionMgr.cpp @@ -14,10 +14,11 @@ #include using namespace Sapphire; +using namespace Sapphire::World::Manager; -void World::Manager::ActionMgr::handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId, - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::Action > > actionData, Common::FFXIVARR_POSITION3 pos, - uint16_t sequence ) +void ActionMgr::handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId, + Component::Excel::ExcelStructPtr< Component::Excel::Action > actionData, Common::FFXIVARR_POSITION3 pos, + uint16_t sequence ) { PlayerMgr::sendDebug( player, "got aoe act: {0}", actionData->getString( actionData->data().Text.Name ) ); @@ -38,9 +39,8 @@ void World::Manager::ActionMgr::handlePlacedPlayerAction( Entity::Player& player bootstrapAction( player, action, actionData ); } -void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId, - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::Action > > actionData, uint64_t targetId, - uint16_t sequence ) +void ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId, + Component::Excel::ExcelStructPtr< Component::Excel::Action > actionData, uint64_t targetId, uint16_t sequence ) { auto action = Action::make_Action( player.getAsPlayer(), actionId, sequence, actionData ); @@ -61,9 +61,9 @@ void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& play bootstrapAction( player, action, actionData ); } -void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& player, uint32_t itemId, - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::ItemAction > > itemActionData, - uint16_t itemSourceSlot, uint16_t itemSourceContainer ) +void ActionMgr::handleItemAction( Sapphire::Entity::Player& player, uint32_t itemId, + Component::Excel::ExcelStructPtr< Component::Excel::ItemAction > itemActionData, + uint16_t itemSourceSlot, uint16_t itemSourceContainer ) { PlayerMgr::sendDebug( player, "got item act: {0}, slot: {1}, container: {2}", itemId, itemSourceSlot, itemSourceContainer ); @@ -74,9 +74,9 @@ void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& play action->start(); } -void World::Manager::ActionMgr::handleEventItemAction( Sapphire::Entity::Player& player, uint32_t itemId, - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::EventItem > > itemActionData, - uint32_t sequence, uint64_t targetId ) +void ActionMgr::handleEventItemAction( Sapphire::Entity::Player& player, uint32_t itemId, + Component::Excel::ExcelStructPtr< Component::Excel::EventItem > itemActionData, + uint32_t sequence, uint64_t targetId ) { auto action = Action::make_EventItemAction( player.getAsChara(), itemId, itemActionData, sequence, targetId ); action->init(); @@ -89,9 +89,9 @@ void World::Manager::ActionMgr::handleEventItemAction( Sapphire::Entity::Player& action->start(); } -void World::Manager::ActionMgr::handleMountAction( Entity::Player& player, uint16_t mountId, - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::Action > > actionData, uint64_t targetId, - uint16_t sequence ) +void ActionMgr::handleMountAction( Entity::Player& player, uint16_t mountId, + Component::Excel::ExcelStructPtr< Component::Excel::Action > actionData, uint64_t targetId, + uint16_t sequence ) { PlayerMgr::sendDebug( player, "setMount: {0}", mountId ); @@ -105,9 +105,8 @@ void World::Manager::ActionMgr::handleMountAction( Entity::Player& player, uint1 bootstrapAction( player, action, actionData ); } -void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player, - Action::ActionPtr currentAction, - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::Action > > actionData ) +void ActionMgr::bootstrapAction( Entity::Player& player, Action::ActionPtr currentAction, + Component::Excel::ExcelStructPtr< Component::Excel::Action > actionData ) { /* //TODO: need to be fixed @@ -138,7 +137,7 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player, } } -bool World::Manager::ActionMgr::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases +bool ActionMgr::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases { auto& exdData = Common::Service< Data::ExdData >::ref(); auto actionInfoPtr = exdData.getRow< Component::Excel::Action >( actionId ); diff --git a/src/world/Manager/BlacklistMgr.cpp b/src/world/Manager/BlacklistMgr.cpp index d46d3a33..5356d3bb 100644 --- a/src/world/Manager/BlacklistMgr.cpp +++ b/src/world/Manager/BlacklistMgr.cpp @@ -14,15 +14,16 @@ #include "WorldServer.h" -using namespace Sapphire::Common; +using namespace Sapphire; +using namespace Sapphire::World::Manager; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets; -bool Sapphire::World::Manager::BlacklistMgr::onAddCharacter( Entity::Player& source, const std::string& targetName ) +bool BlacklistMgr::onAddCharacter( Entity::Player& source, const std::string& targetName ) { // add target to blacklist - auto& server = Common::Service< Sapphire::World::WorldServer >::ref(); + auto& server = Common::Service< World::WorldServer >::ref(); auto pTarget = server.getPlayer( targetName ); if( !pTarget ) @@ -66,18 +67,18 @@ bool Sapphire::World::Manager::BlacklistMgr::onAddCharacter( Entity::Player& sou sendAddResultPacket( source, pTarget, 0 ); // check if player is friends with target - auto& flMgr = Common::Service< Sapphire::World::Manager::FriendListMgr >::ref(); + auto& flMgr = Common::Service< FriendListMgr >::ref(); if( flMgr.isFriend( source, target ) ) flMgr.onRemoveFriend( source, target ); return true; } -bool Sapphire::World::Manager::BlacklistMgr::onRemoveCharacter( Entity::Player& source, const std::string& targetName ) +bool BlacklistMgr::onRemoveCharacter( Entity::Player& source, const std::string& targetName ) { // remove target from blacklist - auto& server = Common::Service< Sapphire::World::WorldServer >::ref(); + auto& server = Common::Service< World::WorldServer >::ref(); auto pTarget = server.getPlayer( targetName ); if( !pTarget ) @@ -108,12 +109,12 @@ bool Sapphire::World::Manager::BlacklistMgr::onRemoveCharacter( Entity::Player& return true; } -bool Sapphire::World::Manager::BlacklistMgr::onGetBlacklistPage( Entity::Player& source, uint8_t key, uint8_t nextIdx ) +bool BlacklistMgr::onGetBlacklistPage( Entity::Player& source, uint8_t key, uint8_t nextIdx ) { // this function will handle client side indexing and paginate blacklist entries // it'll also be called multiple times sequentially until there are no more entries left (id == 0) - auto& server = Common::Service< Sapphire::World::WorldServer >::ref(); + auto& server = Common::Service< World::WorldServer >::ref(); std::vector< Server::BlacklistCharacter > entries; @@ -164,12 +165,12 @@ bool Sapphire::World::Manager::BlacklistMgr::onGetBlacklistPage( Entity::Player& return true; } -bool Sapphire::World::Manager::BlacklistMgr::isBlacklisted( Entity::Player& source, const Entity::Player& target ) const +bool BlacklistMgr::isBlacklisted( Entity::Player& source, const Entity::Player& target ) const { return getEntryIndex( source, target.getCharacterId() ) != -1; } -ptrdiff_t Sapphire::World::Manager::BlacklistMgr::getEntryIndex( Entity::Player& source, uint64_t characterId ) const +ptrdiff_t BlacklistMgr::getEntryIndex( Entity::Player& source, uint64_t characterId ) const { auto& sourceBL = source.getBlacklistID(); auto sourceBlIt = std::find( std::begin( sourceBL ), std::end( sourceBL ), characterId ); @@ -181,9 +182,9 @@ ptrdiff_t Sapphire::World::Manager::BlacklistMgr::getEntryIndex( Entity::Player& return sourceBlIt - std::begin( sourceBL ); } -void Sapphire::World::Manager::BlacklistMgr::sendAddResultPacket( Entity::Player& source, const Entity::PlayerPtr pTarget, uint32_t result ) +void BlacklistMgr::sendAddResultPacket( Entity::Player& source, const Entity::PlayerPtr pTarget, uint32_t result ) { - auto& server = Common::Service< Sapphire::World::WorldServer >::ref(); + auto& server = Common::Service< World::WorldServer >::ref(); auto resultPacket = makeZonePacket< Server::FFXIVIpcBlacklistAddResult >( source.getId() ); @@ -202,9 +203,9 @@ void Sapphire::World::Manager::BlacklistMgr::sendAddResultPacket( Entity::Player server.queueForPlayer( source.getCharacterId(), resultPacket ); } -void Sapphire::World::Manager::BlacklistMgr::sendRemoveResultPacket( Entity::Player& source, const Entity::PlayerPtr pTarget, uint32_t result ) +void BlacklistMgr::sendRemoveResultPacket( Entity::Player& source, const Entity::PlayerPtr pTarget, uint32_t result ) { - auto& server = Common::Service< Sapphire::World::WorldServer >::ref(); + auto& server = Common::Service< World::WorldServer >::ref(); auto resultPacket = makeZonePacket< Server::FFXIVIpcBlacklistRemoveResult >( source.getId() ); diff --git a/src/world/Manager/ChatChannelMgr.cpp b/src/world/Manager/ChatChannelMgr.cpp index 4cbe7da2..ccd6668a 100644 --- a/src/world/Manager/ChatChannelMgr.cpp +++ b/src/world/Manager/ChatChannelMgr.cpp @@ -16,7 +16,7 @@ using namespace Sapphire::Network; using namespace Sapphire::Network::Packets; using namespace Sapphire::World::Manager; -const uint64_t World::Manager::ChatChannelMgr::createChatChannel( Common::ChatChannelType type ) +const uint64_t ChatChannelMgr::createChatChannel( Common::ChatChannelType type ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -49,7 +49,7 @@ const uint64_t World::Manager::ChatChannelMgr::createChatChannel( Common::ChatCh return cId.ChannelID; } -void World::Manager::ChatChannelMgr::addToChannel( uint64_t channelId, Entity::Player& player ) +void ChatChannelMgr::addToChannel( uint64_t channelId, Entity::Player& player ) { if( !isChannelValid( channelId ) ) { @@ -71,7 +71,7 @@ void World::Manager::ChatChannelMgr::addToChannel( uint64_t channelId, Entity::P m_channels[ channelId ].emplace_back( player.getAsPlayer() ); } -void World::Manager::ChatChannelMgr::removeFromChannel( uint64_t channelId, Entity::Player& player ) +void ChatChannelMgr::removeFromChannel( uint64_t channelId, Entity::Player& player ) { if( !isChannelValid( channelId ) ) { @@ -94,8 +94,7 @@ void World::Manager::ChatChannelMgr::removeFromChannel( uint64_t channelId, Enti channelMembers.erase( it ); } -void World::Manager::ChatChannelMgr::sendMessageToChannel( uint64_t channelId, - Entity::Player& sender, const std::string& message ) +void ChatChannelMgr::sendMessageToChannel( uint64_t channelId, Entity::Player& sender, const std::string& message ) { if( !isChannelValid( channelId ) ) { @@ -145,12 +144,12 @@ void World::Manager::ChatChannelMgr::sendMessageToChannel( uint64_t channelId, } } -bool World::Manager::ChatChannelMgr::isChannelValid( uint64_t channelId ) const +bool ChatChannelMgr::isChannelValid( uint64_t channelId ) const { return !( m_channels.find( channelId ) == m_channels.end() ); } -const Data::ChatChannelMembers& World::Manager::ChatChannelMgr::getChatChannel( uint64_t channelId ) +const Data::ChatChannelMembers& ChatChannelMgr::getChatChannel( uint64_t channelId ) { bool channelValid = isChannelValid( channelId ); assert( channelValid ); diff --git a/src/world/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index 1ce595e4..274b601f 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -50,7 +50,7 @@ using namespace Sapphire::Network::Packets::WorldPackets::Server; using namespace Sapphire::World::Manager; // instanciate and initialize commands -Sapphire::World::Manager::DebugCommandMgr::DebugCommandMgr() +DebugCommandMgr::DebugCommandMgr() { // Push all commands onto the register map ( command name - function - description - required GM level ) registerCommand( "set", &DebugCommandMgr::set, "Executes SET commands.", 1 ); @@ -72,21 +72,20 @@ Sapphire::World::Manager::DebugCommandMgr::DebugCommandMgr() } // clear all loaded commands -Sapphire::World::Manager::DebugCommandMgr::~DebugCommandMgr() +DebugCommandMgr::~DebugCommandMgr() { for( auto it = m_commandMap.begin(); it != m_commandMap.end(); ++it ) ( *it ).second.reset(); } // add a command set to the register map -void Sapphire::World::Manager::DebugCommandMgr::registerCommand( const std::string& n, DebugCommand::pFunc functionPtr, - const std::string& hText, uint8_t uLevel ) +void DebugCommandMgr::registerCommand( const std::string& n, DebugCommand::pFunc functionPtr, const std::string& hText, uint8_t uLevel ) { m_commandMap[ std::string( n ) ] = std::make_shared< DebugCommand >( n, functionPtr, hText, uLevel ); } // try to retrieve the command in question, execute if found -void Sapphire::World::Manager::DebugCommandMgr::execCommand( char* data, Entity::Player& player ) +void DebugCommandMgr::execCommand( char* data, Entity::Player& player ) { // define callback pointer @@ -133,8 +132,7 @@ void Sapphire::World::Manager::DebugCommandMgr::execCommand( char* data, Entity: // Definition of the commands /////////////////////////////////////////////////////////////////////////////////////// -void Sapphire::World::Manager::DebugCommandMgr::help( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::help( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { PlayerMgr::sendDebug( player, "Registered debug commands:" ); for( auto cmd : m_commandMap ) @@ -146,8 +144,7 @@ void Sapphire::World::Manager::DebugCommandMgr::help( char* data, Entity::Player } } -void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::set( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Sapphire::Common::Service< Sapphire::World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -383,8 +380,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& } -void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::add( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -562,7 +558,7 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player& } -void Sapphire::World::Manager::DebugCommandMgr::get( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::get( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& exdData = Common::Service< Data::ExdData >::ref(); std::string subCommand; @@ -601,8 +597,7 @@ void Sapphire::World::Manager::DebugCommandMgr::get( char* data, Entity::Player& } -void -Sapphire::World::Manager::DebugCommandMgr::injectPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::injectPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -611,8 +606,7 @@ Sapphire::World::Manager::DebugCommandMgr::injectPacket( char* data, Entity::Pla pSession->getZoneConnection()->injectPacket( data + 7, player ); } -void Sapphire::World::Manager::DebugCommandMgr::injectChatPacket( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::injectChatPacket( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -621,8 +615,7 @@ void Sapphire::World::Manager::DebugCommandMgr::injectChatPacket( char* data, En pSession->getChatConnection()->injectPacket( data + 8, player ); } -void Sapphire::World::Manager::DebugCommandMgr::replay( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::replay( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -674,8 +667,7 @@ void Sapphire::World::Manager::DebugCommandMgr::replay( char* data, Entity::Play } -void Sapphire::World::Manager::DebugCommandMgr::nudge( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::nudge( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Sapphire::Common::Service< Sapphire::World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -724,9 +716,7 @@ void Sapphire::World::Manager::DebugCommandMgr::nudge( char* data, Entity::Playe } } -void -Sapphire::World::Manager::DebugCommandMgr::serverInfo( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::serverInfo( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -735,8 +725,7 @@ Sapphire::World::Manager::DebugCommandMgr::serverInfo( char* data, Entity::Playe PlayerMgr::sendDebug( player, "Sessions: {0}", server.getSessionCount() ); } -void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::script( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); std::string subCommand; @@ -821,8 +810,7 @@ void Sapphire::World::Manager::DebugCommandMgr::script( char* data, Entity::Play } } -void Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::instance( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& terriMgr = Common::Service< TerritoryMgr >::ref(); auto pCurrentZone = terriMgr.getTerritoryByGuId( player.getTerritoryId() ); @@ -1090,8 +1078,7 @@ void Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Pl } } -void Sapphire::World::Manager::DebugCommandMgr::questBattle( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::questBattle( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& terriMgr = Common::Service< TerritoryMgr >::ref(); auto pCurrentZone = terriMgr.getTerritoryByGuId( player.getTerritoryId() ); @@ -1286,8 +1273,7 @@ void Sapphire::World::Manager::DebugCommandMgr::questBattle( char* data, Entity: } } -void Sapphire::World::Manager::DebugCommandMgr::housing( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::housing( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& terriMgr = Common::Service< TerritoryMgr >::ref(); std::string cmd( data ), params, subCommand; @@ -1342,8 +1328,7 @@ void Sapphire::World::Manager::DebugCommandMgr::housing( char* data, Entity::Pla } } -void Sapphire::World::Manager::DebugCommandMgr::linkshell( char* data, Entity::Player& player, - std::shared_ptr< DebugCommand > command ) +void DebugCommandMgr::linkshell( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) { auto& terriMgr = Common::Service< TerritoryMgr >::ref(); std::string cmd( data ), params, subCommand; diff --git a/src/world/Manager/EventMgr.cpp b/src/world/Manager/EventMgr.cpp index 23ffff80..d91e0772 100644 --- a/src/world/Manager/EventMgr.cpp +++ b/src/world/Manager/EventMgr.cpp @@ -32,12 +32,12 @@ #include "WorldServer.h" #include "Actor/Player.h" -using namespace Sapphire::Common; +using namespace Sapphire; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; using namespace Sapphire::World::Manager; -std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId ) +std::string EventMgr::getEventName( uint32_t eventId ) { auto& exdData = Common::Service< Data::ExdData >::ref(); uint16_t eventType = eventId >> 16; @@ -133,83 +133,83 @@ std::string Sapphire::World::Manager::EventMgr::getEventName( uint32_t eventId ) } } -std::string Sapphire::World::Manager::EventMgr::getErrorCodeName( uint8_t errorCode ) +std::string EventMgr::getErrorCodeName( uint8_t errorCode ) { switch ( errorCode ) { - case EventSceneError::EVENT_SCENE_SUCCESS: + case Common::EventSceneError::EVENT_SCENE_SUCCESS: { return "SUCCESS"; } - case EventSceneError::EVENT_SCENE_ERROR_LUA_ERRRUN: + case Common::EventSceneError::EVENT_SCENE_ERROR_LUA_ERRRUN: { return "LUA_ERRRUN"; } - case EventSceneError::EVENT_SCENE_ERROR_LUA_ERRSYNTAX: + case Common::EventSceneError::EVENT_SCENE_ERROR_LUA_ERRSYNTAX: { return "LUA_ERRSYNTAX"; } - case EventSceneError::EVENT_SCENE_ERROR_LUA_ERRMEM: + case Common::EventSceneError::EVENT_SCENE_ERROR_LUA_ERRMEM: { return "LUA_ERRMEM"; } - case EventSceneError::EVENT_SCENE_ERROR_LUA_ERRERR: + case Common::EventSceneError::EVENT_SCENE_ERROR_LUA_ERRERR: { return "LUA_ERRERR"; } - case EventSceneError::EVENT_SCENE_ERROR_USER_CANCEL: + case Common::EventSceneError::EVENT_SCENE_ERROR_USER_CANCEL: { return "USER_CANCEL"; } - case EventSceneError::EVENT_SCENE_ERROR_SERVER_ABORT: + case Common::EventSceneError::EVENT_SCENE_ERROR_SERVER_ABORT: { return "SERVER_ABORT"; } - case EventSceneError::EVENT_SCENE_ERROR_RELOAD: + case Common::EventSceneError::EVENT_SCENE_ERROR_RELOAD: { return "RELOAD"; } - case EventSceneError::EVENT_SCENE_ERROR_LUA_THREAD_BUSY: + case Common::EventSceneError::EVENT_SCENE_ERROR_LUA_THREAD_BUSY: { return "LUA_THREAD_BUSY"; } - case EventSceneError::EVENT_SCENE_ERROR_TARGET_CHANGED: + case Common::EventSceneError::EVENT_SCENE_ERROR_TARGET_CHANGED: { return "TARGET_CHANGED"; } - case EventSceneError::EVENT_SCENE_ERROR_CLIENT_ABORT: + case Common::EventSceneError::EVENT_SCENE_ERROR_CLIENT_ABORT: { return "CLIENT_ABORT"; } - case EventSceneError::EVENT_SCENE_ERROR_TARGET_LOST: + case Common::EventSceneError::EVENT_SCENE_ERROR_TARGET_LOST: { return "TARGET_LOST"; } - case EventSceneError::EVENT_SCENE_ERROR_BEFORE_PLAY: + case Common::EventSceneError::EVENT_SCENE_ERROR_BEFORE_PLAY: { return "BEFORE_PLAY"; } - case EventSceneError::EVENT_SCENE_ERROR_BIND_CHARACTER: + case Common::EventSceneError::EVENT_SCENE_ERROR_BIND_CHARACTER: { return "BIND_CHARACTER"; } - case EventSceneError::EVENT_SCENE_ERROR_TARGET_MOVE: + case Common::EventSceneError::EVENT_SCENE_ERROR_TARGET_MOVE: { return "TARGET_MOVE"; } - case EventSceneError::EVENT_SCENE_ERROR_SCRIPT_NOT_READY: + case Common::EventSceneError::EVENT_SCENE_ERROR_SCRIPT_NOT_READY: { return "SCRIPT_NOT_READY"; } - case EventSceneError::EVENT_SCENE_ERROR_TARGET_WARP: + case Common::EventSceneError::EVENT_SCENE_ERROR_TARGET_WARP: { return "TARGET_WARP"; } - case EventSceneError::EVENT_SCENE_ERROR_BIND_OBJECT: + case Common::EventSceneError::EVENT_SCENE_ERROR_BIND_OBJECT: { return "BIND_OBJECT"; } - case EventSceneError::EVENT_SCENE_ERROR_MAX: + case Common::EventSceneError::EVENT_SCENE_ERROR_MAX: { return "MAX"; } @@ -220,7 +220,7 @@ std::string Sapphire::World::Manager::EventMgr::getErrorCodeName( uint8_t errorC } } -uint32_t Sapphire::World::Manager::EventMgr::mapEventActorToRealActor( uint32_t eventActorId ) +uint32_t EventMgr::mapEventActorToRealActor( uint32_t eventActorId ) { auto& instanceObjectCache = Common::Service< InstanceObjectCache >::ref(); auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -235,8 +235,8 @@ uint32_t Sapphire::World::Manager::EventMgr::mapEventActorToRealActor( uint32_t return 0; } -void Sapphire::World::Manager::EventMgr::handleReturnEventScene( Entity::Player& player, uint32_t eventId, uint16_t sceneId, uint8_t errorCode, - uint8_t numOfResults, const std::vector< uint32_t >& results ) +void EventMgr::handleReturnEventScene( Entity::Player& player, uint32_t eventId, uint16_t sceneId, uint8_t errorCode, + uint8_t numOfResults, const std::vector< uint32_t >& results ) { std::string eventName = getEventName( eventId ); @@ -456,13 +456,13 @@ void EventMgr::eventFinish( Sapphire::Entity::Player& player, uint32_t eventId, } } - if( player.hasStateFlag( PlayerStateFlag::WatchingCutscene ) ) - player.unsetStateFlag( PlayerStateFlag::WatchingCutscene ); + if( player.hasStateFlag( Common::PlayerStateFlag::WatchingCutscene ) ) + player.unsetStateFlag( Common::PlayerStateFlag::WatchingCutscene ); player.removeEvent( pEvent->getId() ); if( freePlayer == 1 ) - player.unsetStateFlag( PlayerStateFlag::InNpcEvent ); + player.unsetStateFlag( Common::PlayerStateFlag::InNpcEvent ); } void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t eventId, Event::EventHandler::EventType eventType, uint8_t eventParam1, @@ -473,9 +473,10 @@ void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t ev newEvent->setEventFinishCallback( std::move( callback ) ); player.addEvent( newEvent ); - player.setStateFlag( PlayerStateFlag::InNpcEvent ); + player.setStateFlag( Common::PlayerStateFlag::InNpcEvent ); - server.queueForPlayer( player.getCharacterId(), std::make_shared< EventStartPacket >( player.getId(), actorId, eventId, eventType, eventParam1, eventParam2 ) ); + server.queueForPlayer( player.getCharacterId(), std::make_shared< EventStartPacket >( player.getId(), actorId, + eventId, eventType, eventParam1, eventParam2 ) ); } @@ -746,7 +747,7 @@ Sapphire::Event::EventHandlerPtr EventMgr::bootstrapSceneEvent( Entity::Player& } if( flags & CONDITION_CUTSCENE ) - player.setStateFlag( PlayerStateFlag::WatchingCutscene ); + player.setStateFlag( Common::PlayerStateFlag::WatchingCutscene ); return pEvent; } diff --git a/src/world/Manager/FriendListMgr.cpp b/src/world/Manager/FriendListMgr.cpp index 0ef87c5a..e711d9b1 100644 --- a/src/world/Manager/FriendListMgr.cpp +++ b/src/world/Manager/FriendListMgr.cpp @@ -8,7 +8,10 @@ #include "Actor/Player.h" #include "FriendListMgr.h" -bool Sapphire::World::Manager::FriendListMgr::onInviteCreate( Entity::Player& source, Entity::Player& target ) +using namespace Sapphire; +using namespace Sapphire::World::Manager; + +bool FriendListMgr::onInviteCreate( Entity::Player& source, Entity::Player& target ) { auto& sourceFL = source.getFriendListID(); auto& targetFL = target.getFriendListID(); @@ -58,7 +61,7 @@ bool Sapphire::World::Manager::FriendListMgr::onInviteCreate( Entity::Player& so return true; } -bool Sapphire::World::Manager::FriendListMgr::onInviteAccept( Entity::Player& source, Entity::Player& target ) +bool FriendListMgr::onInviteAccept( Entity::Player& source, Entity::Player& target ) { // accept friend invite auto sourceIdx = getEntryIndex( source, target.getCharacterId() ); @@ -84,7 +87,7 @@ bool Sapphire::World::Manager::FriendListMgr::onInviteAccept( Entity::Player& so return true; } -bool Sapphire::World::Manager::FriendListMgr::onInviteDecline( Entity::Player& source, Entity::Player& target ) +bool FriendListMgr::onInviteDecline( Entity::Player& source, Entity::Player& target ) { // decline friend invite auto sourceIdx = getEntryIndex( source, target.getCharacterId() ); @@ -113,7 +116,7 @@ bool Sapphire::World::Manager::FriendListMgr::onInviteDecline( Entity::Player& s return true; } -bool Sapphire::World::Manager::FriendListMgr::onRemoveFriend( Entity::Player& source, Entity::Player& target ) +bool FriendListMgr::onRemoveFriend( Entity::Player& source, Entity::Player& target ) { // remove friend // this not retail accurate - retail only removes source friendlist, but that also makes it more complicated for readding friend @@ -122,7 +125,7 @@ bool Sapphire::World::Manager::FriendListMgr::onRemoveFriend( Entity::Player& so return onInviteDecline( source, target ); } -bool Sapphire::World::Manager::FriendListMgr::onAssignGroup( Entity::Player& source, Entity::Player& target, uint8_t group ) +bool FriendListMgr::onAssignGroup( Entity::Player& source, Entity::Player& target, uint8_t group ) { // assign group to friend entry (to source only) auto sourceIdx = getEntryIndex( source, target.getCharacterId() ); @@ -142,12 +145,12 @@ bool Sapphire::World::Manager::FriendListMgr::onAssignGroup( Entity::Player& sou return true; } -bool Sapphire::World::Manager::FriendListMgr::isFriend( Entity::Player& source, Entity::Player& target ) const +bool FriendListMgr::isFriend( Entity::Player& source, Entity::Player& target ) const { return getEntryIndex( source, target.getCharacterId() ) != -1; } -ptrdiff_t Sapphire::World::Manager::FriendListMgr::getEntryIndex( Entity::Player& source, uint64_t characterId ) const +ptrdiff_t FriendListMgr::getEntryIndex( Entity::Player& source, uint64_t characterId ) const { auto& sourceFL = source.getFriendListID(); auto sourceInvIt = std::find( std::begin( sourceFL ), std::end( sourceFL ), characterId ); diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index c329bd7f..61fd4e53 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -34,50 +34,51 @@ #include "Inventory/ItemContainer.h" #include "Util/UtilMath.h" -using namespace Sapphire::Common; +using namespace Sapphire; +using namespace Sapphire::World::Manager; using namespace Sapphire::Network; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; -Sapphire::World::Manager::HousingMgr::HousingMgr() +HousingMgr::HousingMgr() { - m_containerMap[ 0 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems1, InventoryType::HousingInteriorStoreroom1 ); - m_containerMap[ 1 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems2, InventoryType::HousingInteriorStoreroom2 ); - m_containerMap[ 2 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems3, InventoryType::HousingInteriorStoreroom3 ); - m_containerMap[ 3 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems4, InventoryType::HousingInteriorStoreroom4 ); - m_containerMap[ 4 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems5, InventoryType::HousingInteriorStoreroom5 ); - m_containerMap[ 5 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems6, InventoryType::HousingInteriorStoreroom6 ); - m_containerMap[ 6 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems7, InventoryType::HousingInteriorStoreroom7 ); - m_containerMap[ 7 ] = std::make_pair( InventoryType::HousingInteriorPlacedItems8, InventoryType::HousingInteriorStoreroom8 ); + m_containerMap[ 0 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems1, Common::InventoryType::HousingInteriorStoreroom1 ); + m_containerMap[ 1 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems2, Common::InventoryType::HousingInteriorStoreroom2 ); + m_containerMap[ 2 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems3, Common::InventoryType::HousingInteriorStoreroom3 ); + m_containerMap[ 3 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems4, Common::InventoryType::HousingInteriorStoreroom4 ); + m_containerMap[ 4 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems5, Common::InventoryType::HousingInteriorStoreroom5 ); + m_containerMap[ 5 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems6, Common::InventoryType::HousingInteriorStoreroom6 ); + m_containerMap[ 6 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems7, Common::InventoryType::HousingInteriorStoreroom7 ); + m_containerMap[ 7 ] = std::make_pair( Common::InventoryType::HousingInteriorPlacedItems8, Common::InventoryType::HousingInteriorStoreroom8 ); m_internalPlacedItemContainers = { - InventoryType::HousingInteriorPlacedItems1, - InventoryType::HousingInteriorPlacedItems2, - InventoryType::HousingInteriorPlacedItems3, - InventoryType::HousingInteriorPlacedItems4, - InventoryType::HousingInteriorPlacedItems5, - InventoryType::HousingInteriorPlacedItems6, - InventoryType::HousingInteriorPlacedItems7, - InventoryType::HousingInteriorPlacedItems8, + Common::InventoryType::HousingInteriorPlacedItems1, + Common::InventoryType::HousingInteriorPlacedItems2, + Common::InventoryType::HousingInteriorPlacedItems3, + Common::InventoryType::HousingInteriorPlacedItems4, + Common::InventoryType::HousingInteriorPlacedItems5, + Common::InventoryType::HousingInteriorPlacedItems6, + Common::InventoryType::HousingInteriorPlacedItems7, + Common::InventoryType::HousingInteriorPlacedItems8, }; m_internalStoreroomContainers = { - InventoryType::HousingInteriorStoreroom1, - InventoryType::HousingInteriorStoreroom2, - InventoryType::HousingInteriorStoreroom3, - InventoryType::HousingInteriorStoreroom4, - InventoryType::HousingInteriorStoreroom5, - InventoryType::HousingInteriorStoreroom6, - InventoryType::HousingInteriorStoreroom7, - InventoryType::HousingInteriorStoreroom8, + Common::InventoryType::HousingInteriorStoreroom1, + Common::InventoryType::HousingInteriorStoreroom2, + Common::InventoryType::HousingInteriorStoreroom3, + Common::InventoryType::HousingInteriorStoreroom4, + Common::InventoryType::HousingInteriorStoreroom5, + Common::InventoryType::HousingInteriorStoreroom6, + Common::InventoryType::HousingInteriorStoreroom7, + Common::InventoryType::HousingInteriorStoreroom8, }; } -Sapphire::World::Manager::HousingMgr::~HousingMgr() = default; +HousingMgr::~HousingMgr() = default; -bool Sapphire::World::Manager::HousingMgr::init() +bool HousingMgr::init() { Logger::info( "HousingMgr: Caching housing land init data" ); //LAND_SEL_ALL @@ -113,7 +114,7 @@ bool Sapphire::World::Manager::HousingMgr::init() return true; } -bool Sapphire::World::Manager::HousingMgr::loadEstateInventories() +bool HousingMgr::loadEstateInventories() { Logger::info( "HousingMgr: Loading inventories for estates" ); @@ -173,7 +174,7 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories() return true; } -void Sapphire::World::Manager::HousingMgr::initLandCache() +void HousingMgr::initLandCache() { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -213,15 +214,15 @@ void Sapphire::World::Manager::HousingMgr::initLandCache() // init inventory containers switch( entry.m_size ) { - case HouseSize::HOUSE_SIZE_S: + case Common::HouseSize::HOUSE_SIZE_S: entry.m_maxPlacedExternalItems = 20; entry.m_maxPlacedInternalItems = 100; break; - case HouseSize::HOUSE_SIZE_M: + case Common::HouseSize::HOUSE_SIZE_M: entry.m_maxPlacedExternalItems = 30; entry.m_maxPlacedInternalItems = 150; break; - case HouseSize::HOUSE_SIZE_L: + case Common::HouseSize::HOUSE_SIZE_L: entry.m_maxPlacedExternalItems = 40; entry.m_maxPlacedInternalItems = 200; break; @@ -264,17 +265,17 @@ void Sapphire::World::Manager::HousingMgr::initLandCache() } // exterior - makeContainer( InventoryType::HousingExteriorPlacedItems, entry.m_maxPlacedExternalItems ); - makeContainer( InventoryType::HousingExteriorStoreroom, entry.m_maxPlacedExternalItems ); + makeContainer( Common::InventoryType::HousingExteriorPlacedItems, entry.m_maxPlacedExternalItems ); + makeContainer( Common::InventoryType::HousingExteriorStoreroom, entry.m_maxPlacedExternalItems ); // fixed containers - makeContainer( InventoryType::HousingInteriorAppearance, 10 ); - makeContainer( InventoryType::HousingExteriorAppearance, 9 ); + makeContainer( Common::InventoryType::HousingInteriorAppearance, 10 ); + makeContainer( Common::InventoryType::HousingExteriorAppearance, 9 ); } } -uint64_t Sapphire::World::Manager::HousingMgr::getNextHouseId() +uint64_t HousingMgr::getNextHouseId() { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); auto pQR = db.query( "SELECT MAX( HouseId ) FROM house" ); @@ -285,13 +286,13 @@ uint64_t Sapphire::World::Manager::HousingMgr::getNextHouseId() return pQR->getUInt64( 1 ) + 1; } -uint32_t Sapphire::World::Manager::HousingMgr::toLandSetId( int16_t territoryTypeId, int16_t wardId ) const +uint32_t HousingMgr::toLandSetId( int16_t territoryTypeId, int16_t wardId ) const { return ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardId; } -Sapphire::LandPtr Sapphire::World::Manager::HousingMgr::getLandByOwnerId( uint64_t id ) +LandPtr HousingMgr::getLandByOwnerId( uint64_t id ) { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -309,7 +310,7 @@ Sapphire::LandPtr Sapphire::World::Manager::HousingMgr::getLandByOwnerId( uint64 return hZone->getLand( static_cast< uint8_t >( res->getUInt( 2 ) ) ); } -void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident ) +void HousingMgr::sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -351,7 +352,7 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl pSession->getZoneConnection()->queueOutPacket( landInfoSignPacket ); } -void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& player, const Common::LandIdent ident ) +void HousingMgr::sendLandSignFree( Entity::Player& player, const Common::LandIdent ident ) { auto& server = Common::Service< World::WorldServer >::ref(); player.setActiveLand( static_cast< uint8_t >( ident.landId ), static_cast< uint8_t >( ident.wardNum ) ); @@ -373,17 +374,17 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& pla pSession->getZoneConnection()->queueOutPacket( plotPricePacket ); } -Sapphire::LandPurchaseResult Sapphire::World::Manager::HousingMgr::purchaseLand( Entity::Player& player, HousingZone& zone, uint8_t plot, uint8_t state ) +LandPurchaseResult HousingMgr::purchaseLand( Entity::Player& player, HousingZone& zone, uint8_t plot, uint8_t state ) { auto plotPrice = zone.getLand( plot )->getCurrentPrice(); - auto gilAvailable = player.getCurrency( CurrencyType::Gil ); + auto gilAvailable = player.getCurrency( Common::CurrencyType::Gil ); auto pLand = zone.getLand( plot ); if( !pLand ) return LandPurchaseResult::ERR_INTERNAL; - if( pLand->getStatus() != HouseStatus::ForSale ) + if( pLand->getStatus() != Common::HouseStatus::ForSale ) return LandPurchaseResult::ERR_NOT_AVAILABLE; if( gilAvailable < plotPrice ) @@ -403,14 +404,14 @@ Sapphire::LandPurchaseResult Sapphire::World::Manager::HousingMgr::purchaseLand( if( pOldLand ) return LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR; - player.removeCurrency( CurrencyType::Gil, plotPrice ); + player.removeCurrency( Common::CurrencyType::Gil, plotPrice ); pLand->setOwnerId( player.getCharacterId() ); - pLand->setStatus( HouseStatus::Sold ); + pLand->setStatus( Common::HouseStatus::Sold ); pLand->setLandType( Common::LandType::Private ); - player.setLandFlags( LandFlagsSlot::Private, 0x00, pLand->getLandIdent() ); + player.setLandFlags( Common::LandFlagsSlot::Private, 0x00, pLand->getLandIdent() ); - player.sendLandFlagsSlot( LandFlagsSlot::Private ); + player.sendLandFlagsSlot( Common::LandFlagsSlot::Private ); //pLand->setLandName( "Private Estate" + std::to_string( pHousing->getWardNum() ) + "-" + std::to_string( plot ) ); pLand->updateLandDb(); @@ -425,7 +426,7 @@ Sapphire::LandPurchaseResult Sapphire::World::Manager::HousingMgr::purchaseLand( } -bool Sapphire::World::Manager::HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint8_t plot ) +bool HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint8_t plot ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -456,15 +457,15 @@ bool Sapphire::World::Manager::HousingMgr::relinquishLand( Entity::Player& playe pLand->setCurrentPrice( pLand->getMaxPrice() ); pLand->setOwnerId( 0 ); - pLand->setStatus( HouseStatus::ForSale ); + pLand->setStatus( Common::HouseStatus::ForSale ); pLand->setLandType( Common::LandType::none ); pLand->updateLandDb(); Common::LandIdent ident { 0xFF, 0xFF, 0xFF, 0xFF }; - player.setLandFlags( LandFlagsSlot::Private, 0x00, ident ); + player.setLandFlags( Common::LandFlagsSlot::Private, 0x00, ident ); - player.sendLandFlagsSlot( LandFlagsSlot::Private ); + player.sendLandFlagsSlot( Common::LandFlagsSlot::Private ); auto screenMsgPkt2 = makeActorControlSelf( player.getId(), ActorControl::LogMsg, 3351, 0x1AA, pLand->getLandIdent().wardNum + 1, plot + 1 ); @@ -474,7 +475,7 @@ bool Sapphire::World::Manager::HousingMgr::relinquishLand( Entity::Player& playe return true; } -void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& player, uint8_t wardId, uint16_t territoryTypeId ) +void HousingMgr::sendWardLandInfo( Entity::Player& player, uint8_t wardId, uint16_t territoryTypeId ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -513,19 +514,19 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla if( auto house = land->getHouse() ) { if( !house->getHouseGreeting().empty() ) - entry.status |= WardlandFlags::HasEstateGreeting; + entry.status |= Common::WardlandFlags::HasEstateGreeting; } switch( land->getLandType() ) { - case LandType::FreeCompany: + case Common::LandType::FreeCompany: entry.status |= Common::WardlandFlags::IsEstateOwned | Common::WardlandFlags::IsFreeCompanyEstate; // todo: send FC name break; - case LandType::Private: + case Common::LandType::Private: entry.status |= Common::WardlandFlags::IsEstateOwned; /* //Disabled. No more name in Info auto owner = land->getOwnerId(); @@ -542,7 +543,7 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla pSession->getZoneConnection()->queueOutPacket( wardInfoPacket ); } -void Sapphire::World::Manager::HousingMgr::sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident ) +void HousingMgr::sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident ) { auto& server = Common::Service< World::WorldServer >::ref(); auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); @@ -572,7 +573,7 @@ void Sapphire::World::Manager::HousingMgr::sendEstateGreeting( Entity::Player& p pSession->getZoneConnection()->queueOutPacket( greetingPacket ); } -bool Sapphire::World::Manager::HousingMgr::initHouseModels( Entity::Player& player, LandPtr land, uint32_t presetCatalogId ) +bool HousingMgr::initHouseModels( Entity::Player& player, LandPtr land, uint32_t presetCatalogId ) { auto house = land->getHouse(); assert( house ); @@ -580,13 +581,13 @@ bool Sapphire::World::Manager::HousingMgr::initHouseModels( Entity::Player& play auto itemMax = land->getInventoryItemMax(); // type, maxSize, tableName, isMultiStorage - auto intContainer = make_ItemContainer( InventoryType::HousingInteriorAppearance, itemMax.second, "houseiteminventory", true ); - auto extContainer = make_ItemContainer( InventoryType::HousingExteriorAppearance, itemMax.first, "houseiteminventory", true ); + auto intContainer = make_ItemContainer( Common::InventoryType::HousingInteriorAppearance, itemMax.second, "houseiteminventory", true ); + auto extContainer = make_ItemContainer( Common::InventoryType::HousingExteriorAppearance, itemMax.first, "houseiteminventory", true ); // add containers to inv collection auto& houseInventory = getEstateInventory( house->getLandIdent() ); - houseInventory[ InventoryType::HousingInteriorAppearance ] = intContainer; - houseInventory[ InventoryType::HousingExteriorAppearance ] = extContainer; + houseInventory[ Common::InventoryType::HousingInteriorAppearance ] = intContainer; + houseInventory[ Common::InventoryType::HousingExteriorAppearance ] = extContainer; auto& exdData = Common::Service< Sapphire::Data::ExdData >::ref(); auto preset = exdData.getRow< Component::Excel::HousingPreset >( getItemAdditionalData( presetCatalogId ) ); @@ -603,45 +604,45 @@ bool Sapphire::World::Manager::HousingMgr::initHouseModels( Entity::Player& play return false; // move preset item into ext appearance container - houseInventory[ InventoryType::HousingExteriorAppearance ]->setItem( HouseExteriorSlot::HousePermit, item ); + houseInventory[ Common::InventoryType::HousingExteriorAppearance ]->setItem( Common::HouseExteriorSlot::HousePermit, item ); // high iq shit auto invMap = std::map< uint16_t, std::map< uint32_t, int32_t > > { // external { - InventoryType::HousingExteriorAppearance, + Common::InventoryType::HousingExteriorAppearance, { - { HouseExteriorSlot::ExteriorRoof, preset->data().Roof }, - { HouseExteriorSlot::ExteriorWall, preset->data().Wall }, - { HouseExteriorSlot::ExteriorWindow, preset->data().Window }, - { HouseExteriorSlot::ExteriorDoor, preset->data().Door } + { Common::HouseExteriorSlot::ExteriorRoof, preset->data().Roof }, + { Common::HouseExteriorSlot::ExteriorWall, preset->data().Wall }, + { Common::HouseExteriorSlot::ExteriorWindow, preset->data().Window }, + { Common::HouseExteriorSlot::ExteriorDoor, preset->data().Door } } }, // internal { - InventoryType::HousingInteriorAppearance, + Common::InventoryType::HousingInteriorAppearance, { // lobby/middle floor - { HouseInteriorSlot::InteriorWall, preset->data().Interior[ 0 ] }, - { HouseInteriorSlot::InteriorFloor, preset->data().Interior[ 1 ] }, - { HouseInteriorSlot::InteriorLight, preset->data().Interior[ 2 ] }, + { Common::HouseInteriorSlot::InteriorWall, preset->data().Interior[ 0 ] }, + { Common::HouseInteriorSlot::InteriorFloor, preset->data().Interior[ 1 ] }, + { Common::HouseInteriorSlot::InteriorLight, preset->data().Interior[ 2 ] }, // attic - { HouseInteriorSlot::InteriorWall_Attic, preset->data().Interior[ 3 ] }, - { HouseInteriorSlot::InteriorFloor_Attic, preset->data().Interior[ 4 ] }, - { HouseInteriorSlot::InteriorLight_Attic, preset->data().Interior[ 5 ] }, + { Common::HouseInteriorSlot::InteriorWall_Attic, preset->data().Interior[ 3 ] }, + { Common::HouseInteriorSlot::InteriorFloor_Attic, preset->data().Interior[ 4 ] }, + { Common::HouseInteriorSlot::InteriorLight_Attic, preset->data().Interior[ 5 ] }, // basement - { HouseInteriorSlot::InteriorWall_Basement, preset->data().Interior[ 6 ] }, - { HouseInteriorSlot::InteriorFloor_Basement, preset->data().Interior[ 7 ] }, - { HouseInteriorSlot::InteriorLight_Basement, preset->data().Interior[ 8 ] }, + { Common::HouseInteriorSlot::InteriorWall_Basement, preset->data().Interior[ 6 ] }, + { Common::HouseInteriorSlot::InteriorFloor_Basement, preset->data().Interior[ 7 ] }, + { Common::HouseInteriorSlot::InteriorLight_Basement, preset->data().Interior[ 8 ] }, } } }; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); // create and link items for( auto& destContainer : invMap ) @@ -668,9 +669,9 @@ bool Sapphire::World::Manager::HousingMgr::initHouseModels( Entity::Player& play return true; } -void Sapphire::World::Manager::HousingMgr::createHouse( Sapphire::HousePtr house ) const +void HousingMgr::createHouse( Sapphire::HousePtr house ) const { - auto& db = Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); + auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); auto stmt = db.getPreparedStatement( Db::HOUSING_HOUSE_INS ); // LandSetId, HouseId, HouseName @@ -682,7 +683,7 @@ void Sapphire::World::Manager::HousingMgr::createHouse( Sapphire::HousePtr house db.execute( stmt ); } -void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& player, HousingZone& zone, uint8_t plotNum, uint32_t presetCatalogId ) +void HousingMgr::buildPresetEstate( Entity::Player& player, HousingZone& zone, uint8_t plotNum, uint32_t presetCatalogId ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -711,8 +712,8 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl createHouse( house ); - pLand->setStatus( HouseStatus::PrivateEstate ); - pLand->setLandType( LandType::Private ); + pLand->setStatus( Common::HouseStatus::PrivateEstate ); + pLand->setLandType( Common::LandType::Private ); zone.sendLandUpdate( plotNum ); auto pSuccessBuildingPacket = makeActorControl( player.getId(), ActorControl::BuildPresetResponse, plotNum ); @@ -726,13 +727,13 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl eventMgr.eventStart( player, player.getId(), 0x000B0095, Event::EventHandler::EventType::Housing, 1, 1 ); eventMgr.playScene( player, 0x000B0095, 0, static_cast< uint32_t >( SET_BASE | HIDE_HOTBAR ), { 1, plotNum } ); - player.setLandFlags( LandFlagsSlot::Private, HOUSING_LAND_STATUS::HOUSING_LAND_STATUS_BUILDHOUSE, ident ); - player.sendLandFlagsSlot( LandFlagsSlot::Private ); + player.setLandFlags( Common::LandFlagsSlot::Private, Common::HOUSING_LAND_STATUS::HOUSING_LAND_STATUS_BUILDHOUSE, ident ); + player.sendLandFlagsSlot( Common::LandFlagsSlot::Private ); zone.registerEstateEntranceEObj( plotNum ); } -void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& player, const Common::LandIdent ident ) +void HousingMgr::requestEstateRename( Entity::Player& player, const Common::LandIdent ident ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -759,7 +760,7 @@ void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& pSession->getZoneConnection()->queueOutPacket( landRenamePacket ); } -void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident ) +void HousingMgr::requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -788,7 +789,7 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Pl pSession->getZoneConnection()->queueOutPacket( estateGreetingPacket ); } -void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting ) +void HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting ) { auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); auto& teriMgr = Common::Service< TerritoryMgr >::ref(); @@ -815,7 +816,7 @@ void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& PlayerMgr::sendLogMessage( player, 3381 ); } -void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident ) +void HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -842,7 +843,7 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity: pSession->getZoneConnection()->queueOutPacket( packet ); } -Sapphire::Common::LandIdent Sapphire::World::Manager::HousingMgr::clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12, bool use16bits ) const +Common::LandIdent HousingMgr::clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12, bool use16bits ) const { Common::LandIdent ident{}; ident.worldId = static_cast< int16_t >( param11 >> 16 ); @@ -862,7 +863,7 @@ Sapphire::Common::LandIdent Sapphire::World::Manager::HousingMgr::clientTriggerP return ident; } -void Sapphire::World::Manager::HousingMgr::sendEstateInventory( Entity::Player& player, uint16_t inventoryType, uint8_t plotNum ) +void HousingMgr::sendEstateInventory( Entity::Player& player, uint16_t inventoryType, uint8_t plotNum ) { Sapphire::LandPtr targetLand; auto& teriMgr = Common::Service< TerritoryMgr >::ref(); @@ -912,35 +913,35 @@ void Sapphire::World::Manager::HousingMgr::sendEstateInventory( Entity::Player& invMgr.sendInventoryContainer( player, it->second ); } -const Sapphire::World::Manager::HousingMgr::LandSetLandCacheMap& Sapphire::World::Manager::HousingMgr::getLandCacheMap() +const HousingMgr::LandSetLandCacheMap& HousingMgr::getLandCacheMap() { return m_landCache; } -Sapphire::World::Manager::HousingMgr::LandIdentToInventoryContainerMap& Sapphire::World::Manager::HousingMgr::getEstateInventories() +HousingMgr::LandIdentToInventoryContainerMap& HousingMgr::getEstateInventories() { return m_estateInventories; } -Sapphire::World::Manager::HousingMgr::ContainerIdToContainerMap& Sapphire::World::Manager::HousingMgr::getEstateInventory( uint64_t ident ) +HousingMgr::ContainerIdToContainerMap& HousingMgr::getEstateInventory( uint64_t ident ) { return m_estateInventories[ ident ]; } -Sapphire::World::Manager::HousingMgr::ContainerIdToContainerMap& Sapphire::World::Manager::HousingMgr::getEstateInventory( Sapphire::Common::LandIdent ident ) +HousingMgr::ContainerIdToContainerMap& HousingMgr::getEstateInventory( Sapphire::Common::LandIdent ident ) { auto u64ident = *reinterpret_cast< uint64_t* >( &ident ); return getEstateInventory( u64ident ); } -void Sapphire::World::Manager::HousingMgr::updateHouseModels( Sapphire::HousePtr house ) +void HousingMgr::updateHouseModels( HousePtr house ) { assert( house ); auto& containers = getEstateInventory( house->getLandIdent() ); - auto extContainer = containers.find( static_cast< uint16_t >( InventoryType::HousingExteriorAppearance ) ); + auto extContainer = containers.find( static_cast< uint16_t >( Common::InventoryType::HousingExteriorAppearance ) ); if( extContainer != containers.end() ) { for( auto& item : extContainer->second->getItemMap() ) @@ -962,7 +963,7 @@ void Sapphire::World::Manager::HousingMgr::updateHouseModels( Sapphire::HousePtr Logger::error( "Plot {0} has an invalid inventory configuration for outdoor appearance.", house->getLandIdent().landId ); } - auto intContainer = containers.find( static_cast< uint16_t >( InventoryType::HousingInteriorAppearance ) ); + auto intContainer = containers.find( static_cast< uint16_t >( Common::InventoryType::HousingInteriorAppearance ) ); if( intContainer != containers.end() ) { for( auto& item : intContainer->second->getItemMap() ) @@ -976,32 +977,30 @@ void Sapphire::World::Manager::HousingMgr::updateHouseModels( Sapphire::HousePtr } } -uint32_t Sapphire::World::Manager::HousingMgr::getItemAdditionalData( uint32_t catalogId ) +uint32_t HousingMgr::getItemAdditionalData( uint32_t catalogId ) { auto& pExdData = Common::Service< Data::ExdData >::ref(); auto info = pExdData.getRow< Component::Excel::Item >( catalogId ); return info->data().CategoryArg; } -bool Sapphire::World::Manager::HousingMgr::isPlacedItemsInventory( Sapphire::Common::InventoryType type ) +bool HousingMgr::isPlacedItemsInventory( Sapphire::Common::InventoryType type ) { - return type == InventoryType::HousingExteriorPlacedItems || - type == InventoryType::HousingInteriorPlacedItems1 || - type == InventoryType::HousingInteriorPlacedItems2 || - type == InventoryType::HousingInteriorPlacedItems3 || - type == InventoryType::HousingInteriorPlacedItems4 || - type == InventoryType::HousingInteriorPlacedItems5 || - type == InventoryType::HousingInteriorPlacedItems6; + return type == Common::InventoryType::HousingExteriorPlacedItems || + type == Common::InventoryType::HousingInteriorPlacedItems1 || + type == Common::InventoryType::HousingInteriorPlacedItems2 || + type == Common::InventoryType::HousingInteriorPlacedItems3 || + type == Common::InventoryType::HousingInteriorPlacedItems4 || + type == Common::InventoryType::HousingInteriorPlacedItems5 || + type == Common::InventoryType::HousingInteriorPlacedItems6; } -void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity::Player& player, uint16_t landId, - uint16_t containerId, uint8_t slotId, - Sapphire::Common::FFXIVARR_POSITION3 pos, - float rotation ) +void HousingMgr::reqPlaceHousingItem( Entity::Player& player, uint16_t landId, uint16_t containerId, uint8_t slotId, + Common::FFXIVARR_POSITION3 pos, float rotation ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); // retail process is: @@ -1029,7 +1028,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity auto ident = zone->getLandIdent(); auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pTeri = teriMgr.getTerritoryByGuId( landSetId ); auto hZone = std::dynamic_pointer_cast< HousingZone >( pTeri ); @@ -1051,10 +1050,10 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity // unlink item Inventory::HousingItemPtr item; - if( containerId == InventoryType::Bag0 || - containerId == InventoryType::Bag1 || - containerId == InventoryType::Bag2 || - containerId == InventoryType::Bag3 ) + if( containerId == Common::InventoryType::Bag0 || + containerId == Common::InventoryType::Bag1 || + containerId == Common::InventoryType::Bag2 || + containerId == Common::InventoryType::Bag3 ) { item = getHousingItemFromPlayer( player, static_cast< Common::InventoryType >( containerId ), slotId ); if( !item ) @@ -1085,7 +1084,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity PlayerMgr::sendUrgent( player, "An internal error occurred when placing the item." ); } -void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity::Player& player, uint16_t landId, uint16_t containerId, uint8_t slotId ) +void HousingMgr::reqPlaceItemInStore( Entity::Player& player, uint16_t landId, uint16_t containerId, uint8_t slotId ) { LandPtr land; bool isOutside = false; @@ -1105,7 +1104,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity auto ident = zone->getLandIdent(); auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pTeri = teriMgr.getTerritoryByGuId( landSetId ); auto hZone = std::dynamic_pointer_cast< HousingZone >( pTeri ); @@ -1121,7 +1120,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity if( isOutside ) { - auto& container = containers[ InventoryType::HousingExteriorStoreroom ]; + auto& container = containers[ Common::InventoryType::HousingExteriorStoreroom ]; auto freeSlot = container->getFreeSlot(); if( freeSlot == -1 ) @@ -1161,11 +1160,11 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity } } -bool Sapphire::World::Manager::HousingMgr::placeExternalItem( Entity::Player& player, Inventory::HousingItemPtr item, Common::LandIdent ident ) +bool HousingMgr::placeExternalItem( Entity::Player& player, Inventory::HousingItemPtr item, Common::LandIdent ident ) { - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); - auto& container = getEstateInventory( ident )[ InventoryType::HousingExteriorPlacedItems ]; + auto& container = getEstateInventory( ident )[ Common::InventoryType::HousingExteriorPlacedItems ]; auto freeSlot = container->getFreeSlot(); @@ -1184,7 +1183,7 @@ bool Sapphire::World::Manager::HousingMgr::placeExternalItem( Entity::Player& pl invMgr.saveHousingContainer( ident, container ); invMgr.updateHousingItemPosition( item ); - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); // add to zone and spawn @@ -1196,10 +1195,9 @@ bool Sapphire::World::Manager::HousingMgr::placeExternalItem( Entity::Player& pl return true; } -bool Sapphire::World::Manager::HousingMgr::placeInteriorItem( Entity::Player& player, - Inventory::HousingItemPtr item ) +bool HousingMgr::placeInteriorItem( Entity::Player& player, Inventory::HousingItemPtr item ) { - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); @@ -1245,9 +1243,9 @@ bool Sapphire::World::Manager::HousingMgr::placeInteriorItem( Entity::Player& pl return false; } -Sapphire::Common::Furniture Sapphire::World::Manager::HousingMgr::getYardObjectForItem( Inventory::HousingItemPtr item ) const +Common::Furniture HousingMgr::getYardObjectForItem( Inventory::HousingItemPtr item ) const { - Sapphire::Common::Furniture obj {}; + Common::Furniture obj {}; obj.pos[ 0 ] = Common::Util::floatToUInt16( item->getPos().x ); obj.pos[ 1 ] = Common::Util::floatToUInt16( item->getPos().y ); @@ -1258,9 +1256,9 @@ Sapphire::Common::Furniture Sapphire::World::Manager::HousingMgr::getYardObjectF return obj; } -void Sapphire::World::Manager::HousingMgr::sendInternalEstateInventoryBatch( Sapphire::Entity::Player& player, bool storeroom ) +void HousingMgr::sendInternalEstateInventoryBatch( Entity::Player& player, bool storeroom ) { - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); auto zone = std::dynamic_pointer_cast< Territory::Housing::HousingInteriorTerritory >( pZone ); @@ -1276,7 +1274,7 @@ void Sapphire::World::Manager::HousingMgr::sendInternalEstateInventoryBatch( Sap else containerIds = m_internalPlacedItemContainers; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); auto& containers = getEstateInventory( zone->getLandIdent() ); for( auto containerId : containerIds ) @@ -1289,12 +1287,11 @@ void Sapphire::World::Manager::HousingMgr::sendInternalEstateInventoryBatch( Sap } } -void Sapphire::World::Manager::HousingMgr::reqMoveHousingItem( Entity::Player& player, Common::LandIdent ident, - uint8_t slot, Common::FFXIVARR_POSITION3 pos, float rot ) +void HousingMgr::reqMoveHousingItem( Entity::Player& player, Common::LandIdent ident, uint8_t slot, Common::FFXIVARR_POSITION3 pos, float rot ) { auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pTeri = teriMgr.getTerritoryByGuId( landSetId ); auto hZone = std::dynamic_pointer_cast< HousingZone >( pTeri ); auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) ); @@ -1319,9 +1316,8 @@ void Sapphire::World::Manager::HousingMgr::reqMoveHousingItem( Entity::Player& p } } -bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& player, Common::LandIdent ident, - Territory::Housing::HousingInteriorTerritory& terri, uint8_t slot, - Common::FFXIVARR_POSITION3 pos, float rot ) +bool HousingMgr::moveInternalItem( Entity::Player& player, Common::LandIdent ident, Territory::Housing::HousingInteriorTerritory& terri, uint8_t slot, + Common::FFXIVARR_POSITION3 pos, float rot ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -1355,7 +1351,7 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla item->setRot( rot ); // save - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); invMgr.updateHousingItemPosition( item ); terri.updateHousingObjectPosition( player, slot, item->getPos(), static_cast< uint16_t >( item->getRot() ) ); @@ -1368,10 +1364,7 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla return true; } -bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& player, - Common::LandIdent ident, uint8_t slot, - Sapphire::HousingZone& terri, Common::FFXIVARR_POSITION3 pos, - float rot ) +bool HousingMgr::moveExternalItem( Entity::Player& player, Common::LandIdent ident, uint8_t slot, HousingZone& terri, Common::FFXIVARR_POSITION3 pos, float rot ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -1382,7 +1375,7 @@ bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& pla return false; auto& containers = getEstateInventory( ident ); - auto it = containers.find( InventoryType::HousingExteriorPlacedItems ); + auto it = containers.find( Common::InventoryType::HousingExteriorPlacedItems ); if( it == containers.end() ) return false; @@ -1395,23 +1388,21 @@ bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& pla item->setPos( pos ); item->setRot( rot ); - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); invMgr.updateHousingItemPosition( item ); terri.updateYardObjectPos( player, slot, static_cast< uint16_t >( ident.landId ), *item ); - uint32_t param1 = static_cast< uint32_t >( ( ident.landId << 16 ) | InventoryType::HousingExteriorPlacedItems ); + uint32_t param1 = static_cast< uint32_t >( ( ident.landId << 16 ) | Common::InventoryType::HousingExteriorPlacedItems ); pSession->getZoneConnection()->queueOutPacket( makeActorControlSelf( player.getId(), ActorControl::HousingItemMoveConfirm, param1, slot ) ); return true; } -void Sapphire::World::Manager::HousingMgr::reqRemoveHousingItem( Sapphire::Entity::Player& player, uint16_t plot, - uint16_t containerId, uint8_t slot, - bool sendToStoreroom ) +void HousingMgr::reqRemoveHousingItem( Entity::Player& player, uint16_t plot, uint16_t containerId, uint8_t slot, bool sendToStoreroom ) { - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); if( auto terri = std::dynamic_pointer_cast< Territory::Housing::HousingInteriorTerritory >( pZone ) ) @@ -1448,10 +1439,8 @@ void Sapphire::World::Manager::HousingMgr::reqRemoveHousingItem( Sapphire::Entit } } -bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& player, - Territory::Housing::HousingInteriorTerritory& terri, - uint16_t containerId, uint16_t slotId, - bool sendToStoreroom ) +bool HousingMgr::removeInternalItem( Entity::Player& player, Territory::Housing::HousingInteriorTerritory& terri, uint16_t containerId, uint16_t slotId, + bool sendToStoreroom ) { auto& containers = getEstateInventory( terri.getLandIdent() ); @@ -1491,7 +1480,7 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p if( !player.getFreeInventoryContainerSlot( containerPair ) ) return false; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); // remove it from housing inventory container->removeItem( static_cast< uint8_t >( slotId ) ); @@ -1513,7 +1502,7 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p if( !freeContainer ) return false; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); container->removeItem( static_cast< uint8_t >( slotId ) ); invMgr.sendInventoryContainer( player, container ); @@ -1535,9 +1524,8 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p return true; } -bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& player, HousingZone& terri, Land& land, - Common::InventoryType containerType, uint8_t slotId, - bool sendToStoreroom ) +bool HousingMgr::removeExternalItem( Entity::Player& player, HousingZone& terri, Land& land, Common::InventoryType containerType, uint8_t slotId, + bool sendToStoreroom ) { auto& containers = getEstateInventory( land.getLandIdent() ); @@ -1551,9 +1539,9 @@ bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& p if( !item ) return false; - bool shouldDespawnItem = containerType != InventoryType::HousingExteriorStoreroom; + bool shouldDespawnItem = containerType != Common::InventoryType::HousingExteriorStoreroom; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); if( sendToStoreroom ) { @@ -1594,9 +1582,7 @@ bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& p return true; } -Sapphire::ItemContainerPtr Sapphire::World::Manager::HousingMgr::getFreeEstateInventorySlot( Common::LandIdent ident, - Inventory::InventoryContainerPair& pair, - Inventory::InventoryTypeList bagList ) +ItemContainerPtr HousingMgr::getFreeEstateInventorySlot( Common::LandIdent ident, Inventory::InventoryContainerPair& pair, Inventory::InventoryTypeList bagList ) { auto& estateContainers = getEstateInventory( ident ); @@ -1620,12 +1606,12 @@ Sapphire::ItemContainerPtr Sapphire::World::Manager::HousingMgr::getFreeEstateIn return nullptr; } -void Sapphire::World::Manager::HousingMgr::reqEstateExteriorRemodel( Sapphire::Entity::Player& player, uint16_t plot ) +void HousingMgr::reqEstateExteriorRemodel( Entity::Player& player, uint16_t plot ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); auto terri = std::dynamic_pointer_cast< HousingZone >( pZone ); @@ -1640,11 +1626,11 @@ void Sapphire::World::Manager::HousingMgr::reqEstateExteriorRemodel( Sapphire::E return; auto& inv = getEstateInventory( land->getLandIdent() ); - auto it = inv.find( InventoryType::HousingExteriorAppearance ); + auto it = inv.find( Common::InventoryType::HousingExteriorAppearance ); if( it == inv.end() ) return; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); invMgr.sendInventoryContainer( player, it->second ); @@ -1653,9 +1639,9 @@ void Sapphire::World::Manager::HousingMgr::reqEstateExteriorRemodel( Sapphire::E } -void Sapphire::World::Manager::HousingMgr::reqEstateInteriorRemodel( Sapphire::Entity::Player& player ) +void HousingMgr::reqEstateInteriorRemodel( Entity::Player& player ) { - auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); auto& server = Common::Service< World::WorldServer >::ref(); @@ -1680,11 +1666,11 @@ void Sapphire::World::Manager::HousingMgr::reqEstateInteriorRemodel( Sapphire::E return; auto& inv = getEstateInventory( land->getLandIdent() ); - auto it = inv.find( InventoryType::HousingInteriorAppearance ); + auto it = inv.find( Common::InventoryType::HousingInteriorAppearance ); if( it == inv.end() ) return; - auto& invMgr = Service< InventoryMgr >::ref(); + auto& invMgr = Common::Service< InventoryMgr >::ref(); invMgr.sendInventoryContainer( player, it->second ); @@ -1692,8 +1678,7 @@ void Sapphire::World::Manager::HousingMgr::reqEstateInteriorRemodel( Sapphire::E pSession->getZoneConnection()->queueOutPacket( pkt ); } -bool Sapphire::World::Manager::HousingMgr::hasPermission( Sapphire::Entity::Player& player, Sapphire::Land& land, - uint32_t permission ) +bool HousingMgr::hasPermission( Entity::Player& player, Sapphire::Land& land, uint32_t permission ) { // todo: proper perms checks pls if( land.getOwnerId() == player.getCharacterId() ) @@ -1704,8 +1689,7 @@ bool Sapphire::World::Manager::HousingMgr::hasPermission( Sapphire::Entity::Play return false; } -Sapphire::Inventory::HousingItemPtr Sapphire::World::Manager::HousingMgr::getHousingItemFromPlayer( - Entity::Player& player, Common::InventoryType type, uint8_t slot ) +Inventory::HousingItemPtr HousingMgr::getHousingItemFromPlayer( Entity::Player& player, Common::InventoryType type, uint8_t slot ) { auto tmpItem = player.dropInventoryItem( type, slot ); if( !tmpItem ) diff --git a/src/world/Manager/InventoryMgr.cpp b/src/world/Manager/InventoryMgr.cpp index 3226c525..349623bd 100644 --- a/src/world/Manager/InventoryMgr.cpp +++ b/src/world/Manager/InventoryMgr.cpp @@ -16,13 +16,13 @@ #include "Session.h" #include "Network/GameConnection.h" -using namespace Sapphire::Common; +using namespace Sapphire; +using namespace Sapphire::World::Manager; using namespace Sapphire::Network; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; -void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::Entity::Player& player, - Sapphire::ItemContainerPtr container ) +void InventoryMgr::sendInventoryContainer( Entity::Player& player, ItemContainerPtr container ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -74,11 +74,10 @@ void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::E server.queueForPlayer( player.getCharacterId(), itemSizePacket ); } -Sapphire::ItemPtr Sapphire::World::Manager::InventoryMgr::createItem( Entity::Player& player, - uint32_t catalogId, uint32_t quantity ) +ItemPtr InventoryMgr::createItem( Entity::Player& player, uint32_t catalogId, uint32_t quantity ) { auto& pExdData = Common::Service< Data::ExdData >::ref(); - auto& itemMgr = Common::Service< Manager::ItemMgr >::ref(); + auto& itemMgr = Common::Service< ItemMgr >::ref(); auto itemInfo = pExdData.getRow< Component::Excel::Item >( catalogId ); if( !itemInfo ) @@ -93,8 +92,7 @@ Sapphire::ItemPtr Sapphire::World::Manager::InventoryMgr::createItem( Entity::Pl return item; } -void Sapphire::World::Manager::InventoryMgr::saveHousingContainer( Common::LandIdent ident, - Sapphire::ItemContainerPtr container ) +void InventoryMgr::saveHousingContainer( Common::LandIdent ident, ItemContainerPtr container ) { auto u64ident = *reinterpret_cast< uint64_t* >( &ident ); @@ -104,9 +102,7 @@ void Sapphire::World::Manager::InventoryMgr::saveHousingContainer( Common::LandI } } -void Sapphire::World::Manager::InventoryMgr::removeItemFromHousingContainer( Sapphire::Common::LandIdent ident, - uint16_t containerId, - uint16_t slotId ) +void InventoryMgr::removeItemFromHousingContainer( Common::LandIdent ident, uint16_t containerId, uint16_t slotId ) { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -121,9 +117,7 @@ void Sapphire::World::Manager::InventoryMgr::removeItemFromHousingContainer( Sap db.directExecute( stmt ); } -void Sapphire::World::Manager::InventoryMgr::saveHousingContainerItem( uint64_t ident, - uint16_t containerId, uint16_t slotId, - uint64_t itemId ) +void InventoryMgr::saveHousingContainerItem( uint64_t ident, uint16_t containerId, uint16_t slotId, uint64_t itemId ) { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -142,7 +136,7 @@ void Sapphire::World::Manager::InventoryMgr::saveHousingContainerItem( uint64_t db.directExecute( stmt ); } -void Sapphire::World::Manager::InventoryMgr::updateHousingItemPosition( Sapphire::Inventory::HousingItemPtr item ) +void InventoryMgr::updateHousingItemPosition( Inventory::HousingItemPtr item ) { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -167,7 +161,7 @@ void Sapphire::World::Manager::InventoryMgr::updateHousingItemPosition( Sapphire db.execute( stmt ); } -void Sapphire::World::Manager::InventoryMgr::removeHousingItemPosition( Sapphire::Inventory::HousingItem& item ) +void InventoryMgr::removeHousingItemPosition( Inventory::HousingItem& item ) { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -178,7 +172,7 @@ void Sapphire::World::Manager::InventoryMgr::removeHousingItemPosition( Sapphire db.directExecute( stmt ); } -void Sapphire::World::Manager::InventoryMgr::saveItem( Sapphire::Entity::Player& player, Sapphire::ItemPtr item ) +void InventoryMgr::saveItem( Entity::Player& player, ItemPtr item ) { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); auto stmt = db.getPreparedStatement( Db::CHARA_ITEMGLOBAL_INS ); diff --git a/src/world/Manager/ItemMgr.cpp b/src/world/Manager/ItemMgr.cpp index 8438326a..14311212 100644 --- a/src/world/Manager/ItemMgr.cpp +++ b/src/world/Manager/ItemMgr.cpp @@ -9,7 +9,10 @@ #include #include -bool Sapphire::World::Manager::ItemMgr::isArmory( uint16_t containerId ) +using namespace Sapphire; +using namespace Sapphire::World::Manager; + +bool ItemMgr::isArmory( uint16_t containerId ) { return containerId == Common::ArmoryBody || @@ -27,7 +30,7 @@ bool Sapphire::World::Manager::ItemMgr::isArmory( uint16_t containerId ) } -uint16_t Sapphire::World::Manager::ItemMgr::getCharaEquipSlotCategoryToArmoryId( uint8_t slotId ) +uint16_t ItemMgr::getCharaEquipSlotCategoryToArmoryId( uint8_t slotId ) { switch( slotId ) @@ -85,12 +88,12 @@ uint16_t Sapphire::World::Manager::ItemMgr::getCharaEquipSlotCategoryToArmoryId( } -bool Sapphire::World::Manager::ItemMgr::isEquipment( uint16_t containerId ) +bool ItemMgr::isEquipment( uint16_t containerId ) { return containerId == Common::GearSet0; } -bool Sapphire::World::Manager::ItemMgr::isOneHandedWeapon( Common::ItemUICategory weaponCategory ) +bool ItemMgr::isOneHandedWeapon( Common::ItemUICategory weaponCategory ) { switch( weaponCategory ) { @@ -114,7 +117,7 @@ bool Sapphire::World::Manager::ItemMgr::isOneHandedWeapon( Common::ItemUICategor } } -Sapphire::ItemPtr Sapphire::World::Manager::ItemMgr::loadItem( uint64_t uId ) +ItemPtr ItemMgr::loadItem( uint64_t uId ) { auto& exdData = Common::Service< Data::ExdData >::ref(); auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); @@ -151,7 +154,7 @@ Sapphire::ItemPtr Sapphire::World::Manager::ItemMgr::loadItem( uint64_t uId ) } -Sapphire::Common::ContainerType Sapphire::World::Manager::ItemMgr::getContainerType( uint32_t containerId ) +Common::ContainerType ItemMgr::getContainerType( uint32_t containerId ) { if( containerId < 5 ) { @@ -175,7 +178,7 @@ Sapphire::Common::ContainerType Sapphire::World::Manager::ItemMgr::getContainerT } } -uint32_t Sapphire::World::Manager::ItemMgr::getNextUId() +uint32_t ItemMgr::getNextUId() { uint32_t charId = 0; diff --git a/src/world/Manager/LinkshellMgr.cpp b/src/world/Manager/LinkshellMgr.cpp index 34af1808..99063983 100644 --- a/src/world/Manager/LinkshellMgr.cpp +++ b/src/world/Manager/LinkshellMgr.cpp @@ -27,12 +27,12 @@ #include "Session.h" -using namespace Sapphire::Common; +using namespace Sapphire; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; using namespace Sapphire::World::Manager; -bool Sapphire::World::Manager::LinkshellMgr::loadLinkshells() +bool LinkshellMgr::loadLinkshells() { auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref(); auto& chatChannelMgr = Common::Service< Manager::ChatChannelMgr >::ref(); @@ -133,7 +133,7 @@ void LinkshellMgr::writeLinkshell( uint64_t lsId ) } -Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellByName( const std::string& name ) +LinkshellPtr LinkshellMgr::getLinkshellByName( const std::string& name ) { auto it = m_linkshellNameMap.find( name ); if( it == m_linkshellNameMap.end() ) @@ -142,7 +142,7 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellByNam return it->second; } -Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellById( uint64_t lsId ) +LinkshellPtr LinkshellMgr::getLinkshellById( uint64_t lsId ) { auto it = m_linkshellIdMap.find( lsId ); if( it == m_linkshellIdMap.end() ) @@ -151,7 +151,7 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellById( return it->second; } -Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell( const std::string& name, Entity::Player& player ) +LinkshellPtr LinkshellMgr::createLinkshell( const std::string& name, Entity::Player& player ) { uint64_t linkshellId = 1; @@ -218,7 +218,7 @@ Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::createLinkshell( return lsPtr; } -void Sapphire::World::Manager::LinkshellMgr::finishLinkshellAction( const std::string& name, uint32_t result, Entity::Player& player, uint8_t action ) +void LinkshellMgr::finishLinkshellAction( const std::string& name, uint32_t result, Entity::Player& player, uint8_t action ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -227,9 +227,9 @@ void Sapphire::World::Manager::LinkshellMgr::finishLinkshellAction( const std::s } -const std::vector< Sapphire::LinkshellPtr > Sapphire::World::Manager::LinkshellMgr::getPlayerLinkshells( Entity::Player& player ) const +const std::vector< LinkshellPtr > LinkshellMgr::getPlayerLinkshells( Entity::Player& player ) const { - std::vector< Sapphire::LinkshellPtr > lsVec; + std::vector< LinkshellPtr > lsVec; for( const auto &[ key, value ] : m_linkshellIdMap ) { @@ -324,13 +324,13 @@ void LinkshellMgr::sendLinkshellList( Entity::Player& player ) uint32_t hierarchy = 0; if( pLs->getMasterId() == player.getCharacterId() ) - hierarchy = Ls::LinkshellHierarchy::Master << 8; + hierarchy = Common::Ls::LinkshellHierarchy::Master << 8; else if( pLs->getLeaderIdList().count( player.getCharacterId() ) ) - hierarchy = Ls::LinkshellHierarchy::Leader << 8; + hierarchy = Common::Ls::LinkshellHierarchy::Leader << 8; else if( pLs->getInviteIdList().count( player.getCharacterId() ) ) - hierarchy = Ls::LinkshellHierarchy::Invite << 8; + hierarchy = Common::Ls::LinkshellHierarchy::Invite << 8; else - hierarchy = Ls::LinkshellHierarchy::Member << 8; + hierarchy = Common::Ls::LinkshellHierarchy::Member << 8; hierarchy |= chatFlag; @@ -377,7 +377,7 @@ void LinkshellMgr::joinLinkshell( uint64_t lsId, uint64_t characterId ) sendLinkshellList( *joiningPlayer ); } -void LinkshellMgr::addLeader( Sapphire::Entity::Player &sourcePlayer, Sapphire::Entity::Player &newLeaderPlayer, uint64_t linkshellId ) +void LinkshellMgr::addLeader( Entity::Player &sourcePlayer, Entity::Player &newLeaderPlayer, uint64_t linkshellId ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -405,7 +405,7 @@ void LinkshellMgr::addLeader( Sapphire::Entity::Player &sourcePlayer, Sapphire:: server.queueForPlayer( sourcePlayer.getCharacterId(), linkshellResult1 ); } -void LinkshellMgr::declineLeader( Sapphire::Entity::Player &sourcePlayer, uint64_t linkshellId ) +void LinkshellMgr::declineLeader( Entity::Player &sourcePlayer, uint64_t linkshellId ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -427,7 +427,7 @@ void LinkshellMgr::declineLeader( Sapphire::Entity::Player &sourcePlayer, uint64 } -void LinkshellMgr::removeLeader( Sapphire::Entity::Player &sourcePlayer, Sapphire::Entity::Player &leaderPlayer, uint64_t linkshellId ) +void LinkshellMgr::removeLeader( Entity::Player &sourcePlayer, Entity::Player &leaderPlayer, uint64_t linkshellId ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -455,7 +455,7 @@ void LinkshellMgr::removeLeader( Sapphire::Entity::Player &sourcePlayer, Sapphir server.queueForPlayer( sourcePlayer.getCharacterId(), linkshellResult1 ); } -void LinkshellMgr::changeMaster( Sapphire::Entity::Player &sourcePlayer, Sapphire::Entity::Player &nextMasterPlayer, uint64_t linkshellId ) +void LinkshellMgr::changeMaster( Entity::Player &sourcePlayer, Entity::Player &nextMasterPlayer, uint64_t linkshellId ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -484,7 +484,7 @@ void LinkshellMgr::changeMaster( Sapphire::Entity::Player &sourcePlayer, Sapphir server.queueForPlayer( sourcePlayer.getCharacterId(), linkshellResult1 ); } -bool LinkshellMgr::renameLinkshell( uint64_t linkshellId, const std::string &name, Sapphire::Entity::Player &player ) +bool LinkshellMgr::renameLinkshell( uint64_t linkshellId, const std::string &name, Entity::Player &player ) { auto& server = Common::Service< World::WorldServer >::ref(); diff --git a/src/world/Manager/MarketMgr.cpp b/src/world/Manager/MarketMgr.cpp index a5ff8d05..9578ea9a 100644 --- a/src/world/Manager/MarketMgr.cpp +++ b/src/world/Manager/MarketMgr.cpp @@ -16,12 +16,13 @@ #include "Session.h" #include "Network/GameConnection.h" -using namespace Sapphire::Common; +using namespace Sapphire; +using namespace Sapphire::World::Manager; using namespace Sapphire::Network; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; -bool Sapphire::World::Manager::MarketMgr::init() +bool MarketMgr::init() { // Logger::info( "MarketMgr: warming up marketable item cache..." ); // @@ -62,8 +63,7 @@ bool Sapphire::World::Manager::MarketMgr::init() return true; } -void Sapphire::World::Manager::MarketMgr::requestItemListingInfo( Sapphire::Entity::Player& player, uint32_t catalogId, - uint32_t requestId ) +void MarketMgr::requestItemListingInfo( Entity::Player& player, uint32_t catalogId, uint32_t requestId ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -98,10 +98,8 @@ void Sapphire::World::Manager::MarketMgr::requestItemListingInfo( Sapphire::Enti } -void Sapphire::World::Manager::MarketMgr::searchMarketboard( Entity::Player& player, uint8_t itemSearchCategory, - uint8_t maxEquipLevel, uint8_t classJob, - const std::string_view& searchStr, uint32_t requestId, - uint32_t startIdx ) +void MarketMgr::searchMarketboard( Entity::Player& player, uint8_t itemSearchCategory, uint8_t maxEquipLevel, uint8_t classJob, + const std::string_view& searchStr, uint32_t requestId, uint32_t startIdx ) { auto& server = Common::Service< World::WorldServer >::ref(); auto pSession = server.getSession( player.getCharacterId() ); @@ -139,14 +137,13 @@ void Sapphire::World::Manager::MarketMgr::searchMarketboard( Entity::Player& pla pSession->getZoneConnection()->queueOutPacket( resultPkt ); } -void Sapphire::World::Manager::MarketMgr::requestItemListings( Sapphire::Entity::Player& player, uint16_t catalogId ) +void MarketMgr::requestItemListings( Sapphire::Entity::Player& player, uint16_t catalogId ) { } -void Sapphire::World::Manager::MarketMgr::findItems( const std::string_view& searchStr, uint8_t itemSearchCat, - uint8_t maxEquipLevel, uint8_t classJob, - Sapphire::World::Manager::MarketMgr::ItemSearchResultList& resultList ) +void MarketMgr::findItems( const std::string_view& searchStr, uint8_t itemSearchCat, uint8_t maxEquipLevel, uint8_t classJob, + MarketMgr::ItemSearchResultList& resultList ) { for( const auto& item : m_marketItemCache ) { diff --git a/src/world/Manager/NaviMgr.cpp b/src/world/Manager/NaviMgr.cpp index 68e1ce65..23b2a076 100644 --- a/src/world/Manager/NaviMgr.cpp +++ b/src/world/Manager/NaviMgr.cpp @@ -2,7 +2,11 @@ #include "Navi/NaviProvider.h" #include -bool Sapphire::World::Manager::NaviMgr::setupTerritory( const std::string& bgPath, uint32_t guid ) +using namespace Sapphire; +using namespace Sapphire::World; +using namespace Sapphire::World::Manager; + +bool NaviMgr::setupTerritory( const std::string& bgPath, uint32_t guid ) { std::string bg = getBgName( bgPath ); @@ -21,7 +25,7 @@ bool Sapphire::World::Manager::NaviMgr::setupTerritory( const std::string& bgPat return false; } -Sapphire::World::Navi::NaviProviderPtr Sapphire::World::Manager::NaviMgr::getNaviProvider( const std::string& bgPath, uint32_t guid ) +Navi::NaviProviderPtr NaviMgr::getNaviProvider( const std::string& bgPath, uint32_t guid ) { std::string bg = getBgName( bgPath ); @@ -31,7 +35,7 @@ Sapphire::World::Navi::NaviProviderPtr Sapphire::World::Manager::NaviMgr::getNav return nullptr; } -std::string Sapphire::World::Manager::NaviMgr::getBgName( const std::string& bgPath ) +std::string NaviMgr::getBgName( const std::string& bgPath ) { auto findPos = bgPath.find_last_of( '/' ); if( findPos != std::string::npos ) diff --git a/src/world/Manager/PartyMgr.cpp b/src/world/Manager/PartyMgr.cpp index 03ba36bf..1eda6510 100644 --- a/src/world/Manager/PartyMgr.cpp +++ b/src/world/Manager/PartyMgr.cpp @@ -18,11 +18,12 @@ #include "Network/PacketWrappers/PcPartyUpdatePacket.h" -using namespace Sapphire::Common; +using namespace Sapphire; +using namespace Sapphire::World::Manager; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; -void Sapphire::World::Manager::PartyMgr::onJoin( uint32_t joinerId, uint32_t inviterId ) +void PartyMgr::onJoin( uint32_t joinerId, uint32_t inviterId ) { auto& server = Common::Service< World::WorldServer >::ref(); auto& ccMgr = Common::Service< World::Manager::ChatChannelMgr >::ref(); @@ -90,7 +91,7 @@ void Sapphire::World::Manager::PartyMgr::onJoin( uint32_t joinerId, uint32_t inv } } -void Sapphire::World::Manager::PartyMgr::onLeave( Sapphire::Entity::Player &leavingPlayer ) +void PartyMgr::onLeave( Sapphire::Entity::Player &leavingPlayer ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -117,7 +118,8 @@ void Sapphire::World::Manager::PartyMgr::onLeave( Sapphire::Entity::Player &leav { if( member->getId() == leavingPlayer.getId() ) { - member->removeOnlineStatus( { OnlineStatus::PartyMember, OnlineStatus::PartyLeader } ); + member->removeOnlineStatus( { Common::OnlineStatus::PartyMember, + Common::OnlineStatus::PartyLeader } ); server.queueForPlayer( leavingPlayer.getCharacterId() , makeZonePacket< FFXIVIpcUpdateParty >( leavingPlayer.getId() ) ); server.queueForPlayer( member->getCharacterId(), makePcPartyUpdate( leadingPlayer, nullptr, @@ -131,7 +133,7 @@ void Sapphire::World::Manager::PartyMgr::onLeave( Sapphire::Entity::Player &leav auto pSession = server.getSession( newLeaderId ); if( !pSession ) continue; - pSession->getPlayer()->addOnlineStatus( OnlineStatus::PartyLeader ); + pSession->getPlayer()->addOnlineStatus( Common::OnlineStatus::PartyLeader ); server.queueForPlayer( member->getCharacterId(), makePcPartyUpdate( leavingPlayer.getAsPlayer(), pSession->getPlayer(), UpdateStatus::LEAVELEADER_LEAVED_MEMBER, party->PartyCount ) ); } @@ -150,7 +152,7 @@ void Sapphire::World::Manager::PartyMgr::onLeave( Sapphire::Entity::Player &leav } } -void Sapphire::World::Manager::PartyMgr::onDisband( Entity::Player& disbandingPlayer ) +void PartyMgr::onDisband( Entity::Player& disbandingPlayer ) { auto& server = Common::Service< World::WorldServer >::ref(); auto party = getParty( disbandingPlayer.getPartyId() ); @@ -160,7 +162,7 @@ void Sapphire::World::Manager::PartyMgr::onDisband( Entity::Player& disbandingPl for( const auto& member : members ) { removeMember( *party, member ); - member->removeOnlineStatus( { OnlineStatus::PartyMember, OnlineStatus::PartyLeader } ); + member->removeOnlineStatus( { Common::OnlineStatus::PartyMember, Common::OnlineStatus::PartyLeader } ); server.queueForPlayer( member->getCharacterId(), { makePcPartyUpdate( disbandingPlayer, disbandingPlayer, UpdateStatus::DISBAND, party->PartyCount ), makeZonePacket< FFXIVIpcUpdateParty >( member->getId() ) } ); } @@ -168,14 +170,14 @@ void Sapphire::World::Manager::PartyMgr::onDisband( Entity::Player& disbandingPl removeParty( party->PartyID ); } -void Sapphire::World::Manager::PartyMgr::onMoveZone( Sapphire::Entity::Player &movingPlayer ) +void PartyMgr::onMoveZone( Sapphire::Entity::Player &movingPlayer ) { auto party = getParty( movingPlayer.getPartyId() ); assert( party ); sendPartyUpdate( *party ); } -void Sapphire::World::Manager::PartyMgr::onMemberDisconnect( Entity::Player& disconnectingPlayer ) +void PartyMgr::onMemberDisconnect( Entity::Player& disconnectingPlayer ) { auto& server = Common::Service< World::WorldServer >::ref(); auto party = getParty( disconnectingPlayer.getPartyId() ); @@ -209,7 +211,7 @@ void Sapphire::World::Manager::PartyMgr::onMemberDisconnect( Entity::Player& dis sendPartyUpdate( *party ); } -void Sapphire::World::Manager::PartyMgr::onMemberRejoin( Entity::Player& joiningPlayer ) +void PartyMgr::onMemberRejoin( Entity::Player& joiningPlayer ) { auto party = getParty( joiningPlayer.getPartyId() ); assert( party ); @@ -217,7 +219,7 @@ void Sapphire::World::Manager::PartyMgr::onMemberRejoin( Entity::Player& joining // TODO: do we need a party update here? move zone handler already handles it } -void Sapphire::World::Manager::PartyMgr::onKick( const std::string& kickPlayerName, Entity::Player& leader ) +void PartyMgr::onKick( const std::string& kickPlayerName, Entity::Player& leader ) { auto& server = Common::Service< World::WorldServer >::ref(); auto party = getParty( leader.getPartyId() ); @@ -242,7 +244,7 @@ void Sapphire::World::Manager::PartyMgr::onKick( const std::string& kickPlayerNa if( kickPlayerName == member->getName() ) { removeMember( *party, member ); - member->removeOnlineStatus( OnlineStatus::PartyMember ); + member->removeOnlineStatus( Common::OnlineStatus::PartyMember ); server.queueForPlayer( member->getCharacterId(), { makePcPartyUpdate( *pLeader, *member, UpdateStatus::KICK_SELF, party->PartyCount ), makeZonePacket< FFXIVIpcUpdateParty >( member->getId() ) } ); @@ -257,7 +259,7 @@ void Sapphire::World::Manager::PartyMgr::onKick( const std::string& kickPlayerNa } } -void Sapphire::World::Manager::PartyMgr::onChangeLeader( const std::string& newLeaderName, Entity::Player& oldLeader ) +void PartyMgr::onChangeLeader( const std::string& newLeaderName, Entity::Player& oldLeader ) { auto& server = Common::Service< World::WorldServer >::ref(); auto party = getParty( oldLeader.getPartyId() ); @@ -274,11 +276,11 @@ void Sapphire::World::Manager::PartyMgr::onChangeLeader( const std::string& newL { if( memberId == pNewLeader->getId() ) { - pNewLeader->addOnlineStatus( OnlineStatus::PartyLeader ); + pNewLeader->addOnlineStatus( Common::OnlineStatus::PartyLeader ); // this is not ideal, probably better to have a function which can add // and remove at the same time so packets are only triggered once - oldLeader.addOnlineStatus( OnlineStatus::PartyMember ); - oldLeader.removeOnlineStatus( OnlineStatus::PartyLeader ); + oldLeader.addOnlineStatus( Common::OnlineStatus::PartyMember ); + oldLeader.removeOnlineStatus( Common::OnlineStatus::PartyLeader ); party->LeaderId = pNewLeader->getId(); break; @@ -297,7 +299,7 @@ void Sapphire::World::Manager::PartyMgr::onChangeLeader( const std::string& newL /////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint64_t Sapphire::World::Manager::PartyMgr::createParty() +uint64_t PartyMgr::createParty() { auto& chatChannelMgr = Common::Service< ChatChannelMgr >::ref(); auto party = std::make_shared< Party >(); @@ -307,12 +309,12 @@ uint64_t Sapphire::World::Manager::PartyMgr::createParty() return party->PartyID; } -uint64_t Sapphire::World::Manager::PartyMgr::getNextPartyId() +uint64_t PartyMgr::getNextPartyId() { return ++m_maxPartyId; } -Sapphire::World::Manager::PartyPtr Sapphire::World::Manager::PartyMgr::getParty( uint64_t partyId ) +PartyPtr PartyMgr::getParty( uint64_t partyId ) { auto it = m_partyIdMap.find( partyId ); if( it != m_partyIdMap.end() ) @@ -321,9 +323,9 @@ Sapphire::World::Manager::PartyPtr Sapphire::World::Manager::PartyMgr::getParty( return nullptr; } -std::vector< Sapphire::Entity::PlayerPtr > Sapphire::World::Manager::PartyMgr::getPartyMembers( Party& party ) +std::vector< Entity::PlayerPtr > PartyMgr::getPartyMembers( Party& party ) { - std::vector< Sapphire::Entity::PlayerPtr > members; + std::vector< Entity::PlayerPtr > members; auto& server = Common::Service< World::WorldServer >::ref(); for( auto& memberId : party.MemberId ) @@ -338,7 +340,7 @@ std::vector< Sapphire::Entity::PlayerPtr > Sapphire::World::Manager::PartyMgr::g return members; } -Sapphire::Entity::PlayerPtr Sapphire::World::Manager::PartyMgr::getPartyLeader( Party& party ) +Entity::PlayerPtr PartyMgr::getPartyLeader( Party& party ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -350,7 +352,7 @@ Sapphire::Entity::PlayerPtr Sapphire::World::Manager::PartyMgr::getPartyLeader( return pLeader; } -void Sapphire::World::Manager::PartyMgr::sendPartyUpdate( Party& party ) +void PartyMgr::sendPartyUpdate( Party& party ) { auto& exdData = Common::Service< Data::ExdData >::ref(); auto partyMembers = getPartyMembers( party ); @@ -365,8 +367,8 @@ void Sapphire::World::Manager::PartyMgr::sendPartyUpdate( Party& party ) ZoneProtoDownPartyMember memberEntry; - memberEntry.ParentEntityId = INVALID_GAME_OBJECT_ID; - memberEntry.PetEntityId = INVALID_GAME_OBJECT_ID; + memberEntry.ParentEntityId = Common::INVALID_GAME_OBJECT_ID; + memberEntry.PetEntityId = Common::INVALID_GAME_OBJECT_ID; memberEntry.Hp = member->getHp(); memberEntry.HpMax = member->getMaxHp(); memberEntry.Mp = member->getMp(); @@ -419,12 +421,12 @@ void Sapphire::World::Manager::PartyMgr::sendPartyUpdate( Party& party ) } } -void Sapphire::World::Manager::PartyMgr::removeParty( uint64_t partyId ) +void PartyMgr::removeParty( uint64_t partyId ) { m_partyIdMap.erase( partyId ); } -int8_t Sapphire::World::Manager::PartyMgr::getPartyLeaderIndex( const Sapphire::World::Manager::Party &party ) +int8_t PartyMgr::getPartyLeaderIndex( const Party &party ) { size_t idx = 0; for( const auto& memberId : party.MemberId ) @@ -436,7 +438,7 @@ int8_t Sapphire::World::Manager::PartyMgr::getPartyLeaderIndex( const Sapphire:: return -1; } -void Sapphire::World::Manager::PartyMgr::removeMember( Sapphire::World::Manager::Party &party, const Entity::PlayerPtr& pMember ) +void PartyMgr::removeMember( Party &party, const Entity::PlayerPtr& pMember ) { auto& ccMgr = Common::Service< World::Manager::ChatChannelMgr >::ref(); pMember->setPartyId( 0 ); diff --git a/src/world/Manager/PlayerMgr.cpp b/src/world/Manager/PlayerMgr.cpp index 3efa62b3..d9f53df3 100644 --- a/src/world/Manager/PlayerMgr.cpp +++ b/src/world/Manager/PlayerMgr.cpp @@ -31,13 +31,14 @@ #include #include "Territory/InstanceObjectCache.h" +using namespace Sapphire; using namespace Sapphire::World::Manager; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; using namespace Sapphire::Network::ActorControl; -using namespace Sapphire::Common; -void PlayerMgr::onOnlineStatusChanged( Sapphire::Entity::Player& player, bool updateProfile ) + +void PlayerMgr::onOnlineStatusChanged( Entity::Player& player, bool updateProfile ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -57,7 +58,7 @@ void PlayerMgr::onOnlineStatusChanged( Sapphire::Entity::Player& player, bool up player.sendToInRangeSet( makeActorControl( player.getId(), SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) ), true ); } -void PlayerMgr::onEquipDisplayFlagsChanged( Sapphire::Entity::Player& player ) +void PlayerMgr::onEquipDisplayFlagsChanged( Entity::Player& player ) { auto& server = Common::Service< World::WorldServer >::ref(); PlayerMgr::sendDebug( player, "EquipDisplayFlag CHANGE: {0}", player.getEquipDisplayFlags() ); @@ -66,7 +67,7 @@ void PlayerMgr::onEquipDisplayFlagsChanged( Sapphire::Entity::Player& player ) player.sendToInRangeSet( paramPacket, true ); } -void PlayerMgr::onSendStateFlags( Sapphire::Entity::Player& player, bool updateInRange ) +void PlayerMgr::onSendStateFlags( Entity::Player& player, bool updateInRange ) { auto& server = Common::Service< World::WorldServer >::ref(); server.queueForPlayer( player.getCharacterId(), std::make_shared< PlayerStateFlagsPacket >( player ) ); @@ -76,7 +77,7 @@ void PlayerMgr::onSendStateFlags( Sapphire::Entity::Player& player, bool updateI static_cast< uint8_t >( player.getOnlineStatus() ) ), true ); } -void PlayerMgr::onSendStats( Sapphire::Entity::Player& player ) +void PlayerMgr::onSendStats( Entity::Player& player ) { std::array< uint32_t, 50 > statParams; @@ -109,7 +110,7 @@ void PlayerMgr::onSendStats( Sapphire::Entity::Player& player ) server.queueForPlayer( player.getCharacterId(), statPacket ); } -void PlayerMgr::onPlayerStatusUpdate( Sapphire::Entity::Player& player ) +void PlayerMgr::onPlayerStatusUpdate( Entity::Player& player ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -122,22 +123,22 @@ void PlayerMgr::onPlayerStatusUpdate( Sapphire::Entity::Player& player ) server.queueForPlayer( player.getCharacterId(), playerStatusUpdate ); } -void PlayerMgr::onPlayerHpMpTpChanged( Sapphire::Entity::Player& player ) +void PlayerMgr::onPlayerHpMpTpChanged( Entity::Player& player ) { player.sendToInRangeSet( std::make_shared< UpdateHpMpTpPacket >( player ), true ); } -void PlayerMgr::onPlayerItemLevelUpdate( Sapphire::Entity::Player& player ) +void PlayerMgr::onPlayerItemLevelUpdate( Entity::Player& player ) { auto& server = Common::Service< World::WorldServer >::ref(); server.queueForPlayer( player.getCharacterId(), makeActorControl( player.getId(), SetItemLevel, player.getItemLevel(), 0 ) ); } -void PlayerMgr::onLevelUp( Sapphire::Entity::Player& player ) +void PlayerMgr::onLevelUp( Entity::Player& player ) { player.calculateStats(); player.sendStats(); - Service< World::Manager::PlayerMgr >::ref().onPlayerHpMpTpChanged( player ); + onPlayerHpMpTpChanged( player ); player.sendToInRangeSet( makeHudParam( player ), true ); @@ -145,7 +146,7 @@ void PlayerMgr::onLevelUp( Sapphire::Entity::Player& player ) player.getLevel(), player.getLevel() - 1 ), true ); } -void PlayerMgr::onGainExp( Sapphire::Entity::Player& player, uint32_t exp ) +void PlayerMgr::onGainExp( Entity::Player& player, uint32_t exp ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -155,18 +156,18 @@ void PlayerMgr::onGainExp( Sapphire::Entity::Player& player, uint32_t exp ) server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), UpdateUiExp, static_cast< uint8_t >( player.getClass() ), player.getExp() ) ); } -void PlayerMgr::onUnlockOrchestrion( Sapphire::Entity::Player& player, uint8_t songId, uint32_t itemId ) +void PlayerMgr::onUnlockOrchestrion( Entity::Player& player, uint8_t songId, uint32_t itemId ) { auto& server = Common::Service< World::WorldServer >::ref(); server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), ToggleOrchestrionUnlock, songId, 1, itemId ) ); } -void PlayerMgr::onChangeGear( Sapphire::Entity::Player& player ) +void PlayerMgr::onChangeGear( Entity::Player& player ) { player.sendToInRangeSet( std::make_shared< ModelEquipPacket >( player ), true ); } -void PlayerMgr::onGcUpdate( Sapphire::Entity::Player& player ) +void PlayerMgr::onGcUpdate( Entity::Player& player ) { auto& server = Common::Service< World::WorldServer >::ref(); auto gcAffPacket = makeZonePacket< FFXIVGCAffiliation >( player.getId() ); @@ -177,7 +178,7 @@ void PlayerMgr::onGcUpdate( Sapphire::Entity::Player& player ) server.queueForPlayer( player.getCharacterId(), gcAffPacket ); } -void PlayerMgr::onMountUpdate( Sapphire::Entity::Player& player, uint32_t mountId ) +void PlayerMgr::onMountUpdate( Entity::Player& player, uint32_t mountId ) { if( mountId != 0 ) { @@ -197,7 +198,7 @@ void PlayerMgr::onMountUpdate( Sapphire::Entity::Player& player, uint32_t mountI } } -void PlayerMgr::onMobKill( Sapphire::Entity::Player& player, uint16_t nameId, uint32_t layoutId ) +void PlayerMgr::onMobKill( Entity::Player& player, uint16_t nameId, uint32_t layoutId ) { auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); scriptMgr.onBNpcKill( player, nameId, layoutId ); @@ -208,7 +209,7 @@ void PlayerMgr::onMobKill( Sapphire::Entity::Player& player, uint16_t nameId, ui } } -void PlayerMgr::onHateListChanged( Sapphire::Entity::Player& player ) +void PlayerMgr::onHateListChanged( Entity::Player& player ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -234,13 +235,13 @@ void PlayerMgr::onHateListChanged( Sapphire::Entity::Player& player ) server.queueForPlayer( player.getCharacterId(), { hateListPacket, hateRankPacket } ); } -void PlayerMgr::onChangeClass( Sapphire::Entity::Player &player ) +void PlayerMgr::onChangeClass( Entity::Player &player ) { player.sendToInRangeSet( makeActorControl( player.getId(), ClassJobChange, 0x04 ), true ); player.sendStatusUpdate(); } -void PlayerMgr::onLogin( Sapphire::Entity::Player &player ) +void PlayerMgr::onLogin( Entity::Player &player ) { auto& server = Common::Service< World::WorldServer >::ref(); @@ -261,26 +262,26 @@ void PlayerMgr::onLogin( Sapphire::Entity::Player &player ) -void PlayerMgr::sendServerNotice( Sapphire::Entity::Player& player, const std::string& message ) //Purple Text +void PlayerMgr::sendServerNotice( Entity::Player& player, const std::string& message ) //Purple Text { auto& server = Common::Service< World::WorldServer >::ref(); server.queueForPlayer( player.getCharacterId(), std::make_shared< ServerNoticePacket >( player.getId(), message ) ); } -void PlayerMgr::sendUrgent( Sapphire::Entity::Player& player, const std::string& message ) //Red Text +void PlayerMgr::sendUrgent( Entity::Player& player, const std::string& message ) //Red Text { auto& server = Common::Service< World::WorldServer >::ref(); - server.queueForPlayer( player.getCharacterId(), std::make_shared< ChatPacket >( player, ChatType::ServerUrgent, message ) ); + server.queueForPlayer( player.getCharacterId(), std::make_shared< ChatPacket >( player, Common::ChatType::ServerUrgent, message ) ); } -void PlayerMgr::sendDebug( Sapphire::Entity::Player& player, const std::string& message ) //Grey Text +void PlayerMgr::sendDebug( Entity::Player& player, const std::string& message ) //Grey Text { auto& server = Common::Service< World::WorldServer >::ref(); - server.queueForPlayer( player.getCharacterId(), std::make_shared< ChatPacket >( player, ChatType::SystemMessage, message ) ); + server.queueForPlayer( player.getCharacterId(), std::make_shared< ChatPacket >( player, Common::ChatType::SystemMessage, message ) ); } -void PlayerMgr::sendLogMessage( Sapphire::Entity::Player& player, uint32_t messageId, uint32_t param2, uint32_t param3, +void PlayerMgr::sendLogMessage( Entity::Player& player, uint32_t messageId, uint32_t param2, uint32_t param3, uint32_t param4, uint32_t param5, uint32_t param6 ) { auto& server = Common::Service< World::WorldServer >::ref(); diff --git a/src/world/Manager/QuestMgr.cpp b/src/world/Manager/QuestMgr.cpp index 98f9263e..9582cfb3 100644 --- a/src/world/Manager/QuestMgr.cpp +++ b/src/world/Manager/QuestMgr.cpp @@ -17,10 +17,11 @@ #include "Actor/Player.h" using namespace Sapphire::Common; +using namespace Sapphire::World::Manager; using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets::WorldPackets::Server; -void Sapphire::World::Manager::QuestMgr::onUpdateQuest( Entity::Player& player, uint8_t questIndex ) +void QuestMgr::onUpdateQuest( Entity::Player& player, uint8_t questIndex ) { auto& server = Common::Service< World::WorldServer >::ref(); auto quests = player.getQuestArrayRef(); @@ -32,7 +33,7 @@ void Sapphire::World::Manager::QuestMgr::onUpdateQuest( Entity::Player& player, sendQuestTracker( player ); } -void Sapphire::World::Manager::QuestMgr::onCompleteQuest( Entity::Player& player, uint16_t questId, uint32_t optionalChoice ) +void QuestMgr::onCompleteQuest( Entity::Player& player, uint16_t questId, uint32_t optionalChoice ) { auto& server = Common::Service< World::WorldServer >::ref(); auto questFinishPacket = makeZonePacket< FFXIVIpcQuestFinish >( player.getId() ); @@ -44,7 +45,7 @@ void Sapphire::World::Manager::QuestMgr::onCompleteQuest( Entity::Player& player giveQuestRewards( player, questId, optionalChoice ); } -void Sapphire::World::Manager::QuestMgr::onRemoveQuest( Entity::Player &player, uint8_t questIndex ) +void QuestMgr::onRemoveQuest( Entity::Player &player, uint8_t questIndex ) { auto& server = Common::Service< World::WorldServer >::ref(); auto questUpdatePacket = makeZonePacket< FFXIVIpcQuest >( player.getId() ); @@ -56,7 +57,7 @@ void Sapphire::World::Manager::QuestMgr::onRemoveQuest( Entity::Player &player, sendQuestTracker( player ); } -bool Sapphire::World::Manager::QuestMgr::giveQuestRewards( Entity::Player& player, uint16_t questId, uint32_t optionalChoice ) +bool QuestMgr::giveQuestRewards( Entity::Player& player, uint16_t questId, uint32_t optionalChoice ) { auto& exdData = Common::Service< Data::ExdData >::ref(); uint32_t playerLevel = player.getLevel(); @@ -96,7 +97,7 @@ bool Sapphire::World::Manager::QuestMgr::giveQuestRewards( Entity::Player& playe /////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Sapphire::World::Manager::QuestMgr::sendQuestTracker( Entity::Player& player ) +void QuestMgr::sendQuestTracker( Entity::Player& player ) { auto& server = Common::Service< World::WorldServer >::ref(); auto trackerPacket = makeZonePacket< FFXIVIpcQuestTracker >( player.getId() ); @@ -113,7 +114,7 @@ void Sapphire::World::Manager::QuestMgr::sendQuestTracker( Entity::Player& playe server.queueForPlayer( player.getCharacterId(), trackerPacket ); } -void Sapphire::World::Manager::QuestMgr::sendQuestsInfo( Sapphire::Entity::Player &player ) +void QuestMgr::sendQuestsInfo( Entity::Player &player ) { auto& server = Common::Service< World::WorldServer >::ref(); auto activeQuestListPacket = makeZonePacket< FFXIVIpcQuests >( player.getId() ); diff --git a/src/world/Manager/ShopMgr.cpp b/src/world/Manager/ShopMgr.cpp index 50a395b4..3e5c1684 100644 --- a/src/world/Manager/ShopMgr.cpp +++ b/src/world/Manager/ShopMgr.cpp @@ -7,8 +7,9 @@ #include using namespace Sapphire; +using namespace Sapphire::World::Manager; -void Sapphire::World::Manager::ShopMgr::cacheShop( uint32_t shopId ) +void ShopMgr::cacheShop( uint32_t shopId ) { auto& exdData = Common::Service< Data::ExdData >::ref(); auto itemShopList = exdData.getIdList< Component::Excel::Shop >(); @@ -37,7 +38,7 @@ void Sapphire::World::Manager::ShopMgr::cacheShop( uint32_t shopId ) } } -uint32_t Sapphire::World::Manager::ShopMgr::getShopItemPrices( uint32_t shopId, uint8_t index ) +uint32_t ShopMgr::getShopItemPrices( uint32_t shopId, uint8_t index ) { if( index > 40 ) return 0; @@ -56,7 +57,7 @@ uint32_t Sapphire::World::Manager::ShopMgr::getShopItemPrices( uint32_t shopId, return 0; } -bool Sapphire::World::Manager::ShopMgr::purchaseGilShopItem( Entity::Player& player, uint32_t shopId, uint16_t itemId, uint32_t quantity ) +bool ShopMgr::purchaseGilShopItem( Entity::Player& player, uint32_t shopId, uint16_t itemId, uint32_t quantity ) { auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -77,7 +78,7 @@ bool Sapphire::World::Manager::ShopMgr::purchaseGilShopItem( Entity::Player& pla return true; } -bool Sapphire::World::Manager::ShopMgr::sellGilShopItem( Sapphire::Entity::Player& player, uint16_t container, uint8_t fromSlot, uint16_t itemId, uint32_t quantity ) +bool ShopMgr::sellGilShopItem( Entity::Player& player, uint16_t container, uint8_t fromSlot, uint16_t itemId, uint32_t quantity ) { auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -93,7 +94,7 @@ bool Sapphire::World::Manager::ShopMgr::sellGilShopItem( Sapphire::Entity::Playe if( quantity > 1 ) return false; - player.discardItem( ( Sapphire::Common::InventoryType )container, fromSlot ); + player.discardItem( ( Common::InventoryType )container, fromSlot ); player.addSoldItem( itemId, quantity ); player.addCurrency( Common::CurrencyType::Gil, payback ); diff --git a/src/world/Manager/TerritoryMgr.cpp b/src/world/Manager/TerritoryMgr.cpp index dcdc0e05..fe1fc5a5 100644 --- a/src/world/Manager/TerritoryMgr.cpp +++ b/src/world/Manager/TerritoryMgr.cpp @@ -15,24 +15,23 @@ #include "Territory/QuestBattle.h" #include "TerritoryMgr.h" #include "HousingMgr.h" -#include "ChatChannelMgr.h" -#include "LinkshellMgr.h" #include "Linkshell/Linkshell.h" #include "Territory/Land.h" #include "Territory/House.h" #include "Territory/Housing/HousingInteriorTerritory.h" -#include "NaviMgr.h" +using namespace Sapphire; +using namespace Sapphire::World::Manager; -Sapphire::World::Manager::TerritoryMgr::TerritoryMgr() : +TerritoryMgr::TerritoryMgr() : m_lastInstanceId( 10000 ) { } -void Sapphire::World::Manager::TerritoryMgr::loadTerritoryTypeDetailCache() +void TerritoryMgr::loadTerritoryTypeDetailCache() { auto& exdData = Common::Service< Data::ExdData >::ref(); auto idList = exdData.getIdList< Component::Excel::TerritoryType >(); @@ -47,12 +46,12 @@ void Sapphire::World::Manager::TerritoryMgr::loadTerritoryTypeDetailCache() } -bool Sapphire::World::Manager::TerritoryMgr::isValidTerritory( uint32_t territoryTypeId ) const +bool TerritoryMgr::isValidTerritory( uint32_t territoryTypeId ) const { return !( m_territoryTypeDetailCacheMap.find( territoryTypeId ) == m_territoryTypeDetailCacheMap.end() ); } -bool Sapphire::World::Manager::TerritoryMgr::init() +bool TerritoryMgr::init() { try { @@ -75,12 +74,12 @@ bool Sapphire::World::Manager::TerritoryMgr::init() return true; } -uint32_t Sapphire::World::Manager::TerritoryMgr::getNextInstanceId() +uint32_t TerritoryMgr::getNextInstanceId() { return ++m_lastInstanceId; } -std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::TerritoryType > > Sapphire::World::Manager::TerritoryMgr::getTerritoryDetail( uint32_t territoryTypeId ) const +Component::Excel::ExcelStructPtr< Component::Excel::TerritoryType > TerritoryMgr::getTerritoryDetail( uint32_t territoryTypeId ) const { auto& exdData = Common::Service< Data::ExdData >::ref(); auto teri1 = exdData.getRow< Component::Excel::TerritoryType >( territoryTypeId ); @@ -90,7 +89,7 @@ std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::TerritoryType return teri1; } -bool Sapphire::World::Manager::TerritoryMgr::isInstanceContentTerritory( uint32_t territoryTypeId ) const +bool TerritoryMgr::isInstanceContentTerritory( uint32_t territoryTypeId ) const { auto pTeri = getTerritoryDetail( territoryTypeId ); @@ -111,7 +110,7 @@ bool Sapphire::World::Manager::TerritoryMgr::isInstanceContentTerritory( uint32_ intendedUse == TerritoryIntendedUse::EventTrial; } -bool Sapphire::World::Manager::TerritoryMgr::isPrivateTerritory( uint32_t territoryTypeId ) const +bool TerritoryMgr::isPrivateTerritory( uint32_t territoryTypeId ) const { auto pTeri = getTerritoryDetail( territoryTypeId ); @@ -124,7 +123,7 @@ bool Sapphire::World::Manager::TerritoryMgr::isPrivateTerritory( uint32_t territ pTeri->data().IntendedUse == TerritoryIntendedUse::MSQPrivateArea; } -bool Sapphire::World::Manager::TerritoryMgr::isInternalEstateTerritory( uint32_t territoryTypeId ) const +bool TerritoryMgr::isInternalEstateTerritory( uint32_t territoryTypeId ) const { auto pTeri = getTerritoryDetail( territoryTypeId ); @@ -134,7 +133,7 @@ bool Sapphire::World::Manager::TerritoryMgr::isInternalEstateTerritory( uint32_t return pTeri->data().IntendedUse == TerritoryIntendedUse::HousingPrivateArea; } -bool Sapphire::World::Manager::TerritoryMgr::isDefaultTerritory( uint32_t territoryTypeId ) const +bool TerritoryMgr::isDefaultTerritory( uint32_t territoryTypeId ) const { auto pTeri = getTerritoryDetail( territoryTypeId ); @@ -148,7 +147,7 @@ bool Sapphire::World::Manager::TerritoryMgr::isDefaultTerritory( uint32_t territ } -bool Sapphire::World::Manager::TerritoryMgr::isHousingTerritory( uint32_t territoryTypeId ) const +bool TerritoryMgr::isHousingTerritory( uint32_t territoryTypeId ) const { auto pTeri = getTerritoryDetail( territoryTypeId ); @@ -158,7 +157,7 @@ bool Sapphire::World::Manager::TerritoryMgr::isHousingTerritory( uint32_t territ return pTeri->data().IntendedUse == TerritoryIntendedUse::HousingArea; } -uint32_t Sapphire::World::Manager::TerritoryMgr::getInstanceContentId( uint32_t territoryTypeId ) const +uint32_t TerritoryMgr::getInstanceContentId( uint32_t territoryTypeId ) const { auto& exdData = Common::Service< Data::ExdData >::ref(); auto contentListIds = exdData.getIdList< Component::Excel::InstanceContent >(); @@ -175,7 +174,7 @@ uint32_t Sapphire::World::Manager::TerritoryMgr::getInstanceContentId( uint32_t return 0; } -bool Sapphire::World::Manager::TerritoryMgr::createDefaultTerritories() +bool TerritoryMgr::createDefaultTerritories() { auto& exdData = Common::Service< Data::ExdData >::ref(); // for each entry in territoryTypeExd, check if it is a normal and if so, add the zone object @@ -205,7 +204,7 @@ bool Sapphire::World::Manager::TerritoryMgr::createDefaultTerritories() bool hasNaviMesh = pZone->getNaviProvider() != nullptr; Logger::info( "{0}\t{1}\t{2}\t{3:<10}\t{4}\t{5}\t{6}", - territoryTypeId < 10 ? std::to_string( territoryTypeId ) + "\t" : std::to_string( territoryTypeId ), + std::to_string( territoryTypeId ), guid, territoryData.IntendedUse, territoryInfo->getString( territoryData.Name ), @@ -224,7 +223,7 @@ bool Sapphire::World::Manager::TerritoryMgr::createDefaultTerritories() return true; } -bool Sapphire::World::Manager::TerritoryMgr::createHousingTerritories() +bool TerritoryMgr::createHousingTerritories() { //separate housing zones from default auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -270,7 +269,7 @@ bool Sapphire::World::Manager::TerritoryMgr::createHousingTerritories() return true; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::createTerritoryInstance( uint32_t territoryTypeId ) +TerritoryPtr TerritoryMgr::createTerritoryInstance( uint32_t territoryTypeId ) { if( !isValidTerritory( territoryTypeId ) ) return nullptr; @@ -299,7 +298,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::createTerritoryIn return pZone; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::createQuestBattle( uint32_t questBattleId ) +TerritoryPtr TerritoryMgr::createQuestBattle( uint32_t questBattleId ) { auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -341,7 +340,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::createQuestBattle return nullptr; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::createInstanceContent( uint32_t instanceContentId ) +TerritoryPtr TerritoryMgr::createInstanceContent( uint32_t instanceContentId ) { auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -371,7 +370,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::createInstanceCon return pZone; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousingInterior( const Common::LandIdent landIdent ) +TerritoryPtr TerritoryMgr::findOrCreateHousingInterior( const Common::LandIdent landIdent ) { // check if zone already spawned first auto ident = *reinterpret_cast< const uint64_t* >( &landIdent ); @@ -443,7 +442,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousi return zone; } -bool Sapphire::World::Manager::TerritoryMgr::removeTerritoryInstance( uint32_t guId ) +bool TerritoryMgr::removeTerritoryInstance( uint32_t guId ) { TerritoryPtr pZone; if( ( pZone = getTerritoryByGuId( guId ) ) == nullptr ) @@ -464,7 +463,7 @@ bool Sapphire::World::Manager::TerritoryMgr::removeTerritoryInstance( uint32_t g return true; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::getTerritoryByGuId( uint32_t guId ) const +TerritoryPtr TerritoryMgr::getTerritoryByGuId( uint32_t guId ) const { auto it = m_guIdToTerritoryPtrMap.find( guId ); if( it == m_guIdToTerritoryPtrMap.end() ) @@ -473,7 +472,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::getTerritoryByGuI return it->second; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::getZoneByTerritoryTypeId( uint32_t territoryTypeId ) const +TerritoryPtr TerritoryMgr::getZoneByTerritoryTypeId( uint32_t territoryTypeId ) const { auto zoneMap = m_territoryTypeIdToInstanceGuidMap.find( territoryTypeId ); if( zoneMap == m_territoryTypeIdToInstanceGuidMap.end() ) @@ -484,7 +483,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::getZoneByTerritor } -void Sapphire::World::Manager::TerritoryMgr::updateTerritoryInstances( uint64_t tickCount ) +void TerritoryMgr::updateTerritoryInstances( uint64_t tickCount ) { for( auto& zone : m_territorySet ) @@ -567,8 +566,7 @@ void Sapphire::World::Manager::TerritoryMgr::updateTerritoryInstances( uint64_t } } -Sapphire::World::Manager::TerritoryMgr::InstanceIdList - Sapphire::World::Manager::TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const +TerritoryMgr::InstanceIdList TerritoryMgr::getInstanceContentIdList( uint16_t instanceContentId ) const { std::vector< uint32_t > idList; auto zoneMap = m_instanceContentIdToInstanceMap.find( instanceContentId ); @@ -583,7 +581,7 @@ Sapphire::World::Manager::TerritoryMgr::InstanceIdList return idList; } -bool Sapphire::World::Manager::TerritoryMgr::movePlayer( const TerritoryPtr& pZone, Sapphire::Entity::Player& player ) +bool TerritoryMgr::movePlayer( const TerritoryPtr& pZone, Entity::Player& player ) { if( !pZone ) { @@ -619,7 +617,7 @@ bool Sapphire::World::Manager::TerritoryMgr::movePlayer( const TerritoryPtr& pZo return true; } -Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::getLinkedInstance( uint32_t playerId ) const +TerritoryPtr TerritoryMgr::getLinkedInstance( uint32_t playerId ) const { auto it = m_playerIdToInstanceMap.find( playerId ); if( it != m_playerIdToInstanceMap.end() ) @@ -629,12 +627,12 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::getLinkedInstance return nullptr; } -const std::pair< uint16_t, uint16_t >& Sapphire::World::Manager::TerritoryMgr::getCurrentFestival() const +const std::pair< uint16_t, uint16_t >& TerritoryMgr::getCurrentFestival() const { return m_currentFestival; } -void Sapphire::World::Manager::TerritoryMgr::setCurrentFestival( uint16_t festivalId, uint16_t additionalFestival ) +void TerritoryMgr::setCurrentFestival( uint16_t festivalId, uint16_t additionalFestival ) { m_currentFestival = { festivalId, additionalFestival }; @@ -644,17 +642,17 @@ void Sapphire::World::Manager::TerritoryMgr::setCurrentFestival( uint16_t festiv } } -void Sapphire::World::Manager::TerritoryMgr::disableCurrentFestival() +void TerritoryMgr::disableCurrentFestival() { setCurrentFestival( 0 ); } -float Sapphire::World::Manager::TerritoryMgr::getInRangeDistance() const +float TerritoryMgr::getInRangeDistance() const { return m_inRangeDistance; } -void Sapphire::World::Manager::TerritoryMgr::createAndJoinQuestBattle( Entity::Player& player, uint16_t questBattleId ) +void TerritoryMgr::createAndJoinQuestBattle( Entity::Player& player, uint16_t questBattleId ) { auto qb = createQuestBattle( questBattleId ); if( !qb ) @@ -664,7 +662,7 @@ void Sapphire::World::Manager::TerritoryMgr::createAndJoinQuestBattle( Entity::P } -bool Sapphire::World::Manager::TerritoryMgr::joinWorld( Sapphire::Entity::Player& player ) +bool TerritoryMgr::joinWorld( Entity::Player& player ) { TerritoryPtr pCurrZone = nullptr; diff --git a/src/world/Manager/TerritoryMgr.h b/src/world/Manager/TerritoryMgr.h index 031717a2..97761965 100644 --- a/src/world/Manager/TerritoryMgr.h +++ b/src/world/Manager/TerritoryMgr.h @@ -118,7 +118,7 @@ namespace Sapphire::World::Manager TerritoryPtr getTerritoryByGuId( uint32_t guId ) const; /*! returns the cached detail of a territory, nullptr if not found */ - std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::TerritoryType > > getTerritoryDetail( uint32_t territoryTypeId ) const; + Component::Excel::ExcelStructPtr< Component::Excel::TerritoryType > getTerritoryDetail( uint32_t territoryTypeId ) const; /*! loop for processing territory logic, iterating all existing instances */ void updateTerritoryInstances( uint64_t tickCount ); diff --git a/src/world/Manager/WarpMgr.h b/src/world/Manager/WarpMgr.h index 1a353a36..5964dac6 100644 --- a/src/world/Manager/WarpMgr.h +++ b/src/world/Manager/WarpMgr.h @@ -4,15 +4,25 @@ #include #include #include +#include namespace Sapphire::World::Manager { + struct WarpInfo + { + uint32_t targetTerritoryId; + Common::WarpType m_warpType; + }; + class WarpMgr { public: WarpMgr() = default; + private: + std::unordered_map< uint32_t, std::shared_ptr< WarpInfo > > m_entityIdToWarpInfoMap; + }; } diff --git a/src/world/Territory/Territory.cpp b/src/world/Territory/Territory.cpp index 2d460d57..daa713b0 100644 --- a/src/world/Territory/Territory.cpp +++ b/src/world/Territory/Territory.cpp @@ -98,7 +98,6 @@ void Sapphire::Territory::loadWeatherRates() auto& exdData = Common::Service< Data::ExdData >::ref(); - // EXD TODO: this must be different in 2.3 uint8_t weatherRateId = m_territoryTypeInfo->data().WeatherRate > exdData.getIdList< Component::Excel::WeatherRate >().size() ? uint8_t{ 0 } : m_territoryTypeInfo->data().WeatherRate; @@ -331,11 +330,7 @@ void Sapphire::Territory::queuePacketForRange( Entity::Player& sourcePlayer, flo if( ( distance < range ) && sourcePlayer.getId() != player->getId() ) { - - auto pSession = server.getSession( player->getId() ); - //pPacketEntry->setValAt< uint32_t >( 0x08, player->getId() ); - if( pSession ) - pSession->getZoneConnection()->queueOutPacket( pPacketEntry ); + server.queueForPlayer( player->getCharacterId(), pPacketEntry ); } } } @@ -855,6 +850,16 @@ Sapphire::Entity::BNpcPtr Sapphire::Territory::getActiveBNpcByInstanceId( uint32 return nullptr; } +Sapphire::Entity::BNpcPtr Sapphire::Territory::getActiveBNpcByInstanceIdAndTriggerOwner( uint32_t instanceId, uint32_t triggerOwnerId ) +{ + for( const auto& bnpcIt : m_bNpcMap ) + { + if( bnpcIt.second->getLayoutId() == instanceId && bnpcIt.second->getTriggerOwnerId() == triggerOwnerId ) + return bnpcIt.second; + } + return nullptr; +} + std::shared_ptr< Sapphire::World::Navi::NaviProvider > Sapphire::Territory::getNaviProvider() { return m_pNaviProvider; diff --git a/src/world/Territory/Territory.h b/src/world/Territory/Territory.h index ebe84910..ee62cadf 100644 --- a/src/world/Territory/Territory.h +++ b/src/world/Territory/Territory.h @@ -177,6 +177,8 @@ namespace Sapphire Entity::BNpcPtr getActiveBNpcByInstanceId( uint32_t instanceId ); + Entity::BNpcPtr getActiveBNpcByInstanceIdAndTriggerOwner( uint32_t instanceId, uint32_t triggerOwnerId ); + Entity::EventObjectPtr getEObj( uint32_t objId ); InstanceContentPtr getAsInstanceContent();