diff --git a/src/scripts/quest/ManSea001.cpp b/src/scripts/quest/ManSea001.cpp index 571cf385..710c845e 100644 --- a/src/scripts/quest/ManSea001.cpp +++ b/src/scripts/quest/ManSea001.cpp @@ -91,7 +91,7 @@ private: if( !pQuest ) return; pQuest->setSeq( SEQ_FINISH ); - player.prepareZoning( player.getZoneId(), true, 1, 0 ); + player.prepareZoning( player.getTerritoryTypeId(), true, 1, 0 ); player.changePosition( 9, 40, 14, 2 ); } } ); diff --git a/src/world/Actor/GameObject.cpp b/src/world/Actor/GameObject.cpp index 38ab6c78..3d4fcc01 100644 --- a/src/world/Actor/GameObject.cpp +++ b/src/world/Actor/GameObject.cpp @@ -373,24 +373,6 @@ void Sapphire::Entity::GameObject::setTerritoryId( uint32_t territoryId ) m_territoryId = territoryId; } -/*! \return InstanceContentPtr to the current instance, nullptr if not an instance or not set */ -Sapphire::InstanceContentPtr Sapphire::Entity::GameObject::getCurrentInstance() const -{ - if( m_pCurrentTerritory ) - return m_pCurrentTerritory->getAsInstanceContent(); - - return nullptr; -} - -/*! \return QuestBattlePtr to the current instance, nullptr if not an instance or not set */ -Sapphire::QuestBattlePtr Sapphire::Entity::GameObject::getCurrentQuestBattle() const -{ - if( m_pCurrentTerritory ) - return m_pCurrentTerritory->getAsQuestBattle(); - - return nullptr; -} - /*! Get the current cellId of a region the actor is in diff --git a/src/world/Actor/GameObject.h b/src/world/Actor/GameObject.h index 8f23f68a..c07770f1 100644 --- a/src/world/Actor/GameObject.h +++ b/src/world/Actor/GameObject.h @@ -133,10 +133,6 @@ namespace Sapphire::Entity void setCurrentZone( TerritoryPtr currZone ); - InstanceContentPtr getCurrentInstance() const; - - QuestBattlePtr getCurrentQuestBattle() const; - // get the current cell of a region the actor is in Common::CellId getCellId() const; // set the current cell diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 7752dd30..3310647a 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -151,11 +151,6 @@ uint32_t Sapphire::Entity::Player::getMaxMp() return max_mp; } -uint16_t Sapphire::Entity::Player::getZoneId() const -{ - return m_territoryTypeId; -} - uint32_t Sapphire::Entity::Player::getPrevTerritoryId() const { return m_prevTerritoryId; @@ -754,7 +749,7 @@ void Sapphire::Entity::Player::resetDiscovery() void Sapphire::Entity::Player::changePosition( float x, float y, float z, float o ) { Common::FFXIVARR_POSITION3 pos{ x, y, z }; - m_queuedZoneing = std::make_shared< QueuedZoning >( getZoneId(), pos, Util::getTimeMs(), o ); + m_queuedZoneing = std::make_shared< QueuedZoning >( getTerritoryTypeId(), pos, Util::getTimeMs(), o ); } void Sapphire::Entity::Player::learnAction( Common::UnlockEntry unlockId ) @@ -1750,7 +1745,7 @@ void Sapphire::Entity::Player::teleportQuery( uint16_t aetheryteId ) if( targetAetheryte ) { auto fromAetheryte = exdData.getRow< Component::Excel::Aetheryte >( - exdData.getRow< Component::Excel::TerritoryType >( getZoneId() )->data().Aetheryte ); + exdData.getRow< Component::Excel::TerritoryType >( getTerritoryTypeId() )->data().Aetheryte ); // calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets auto cost = static_cast< uint16_t > ( diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 93600445..7155fca4 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -638,8 +638,6 @@ namespace Sapphire::Entity void setIsLogin( bool bIsLogin ); - uint16_t getZoneId() const; - uint32_t getPrevTerritoryId() const; uint8_t getGmRank() const; diff --git a/src/world/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index 64357c0b..db055b18 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -1043,7 +1043,7 @@ void Sapphire::World::Manager::DebugCommandMgr::instance( char* data, Entity::Pl uint16_t bgmId; sscanf( params.c_str(), "%hd", &bgmId ); - if( auto instance = player.getCurrentInstance() ) + if( auto instance = pCurrentZone->getAsInstanceContent() ) instance->setCurrentBGM( bgmId ); } else @@ -1239,7 +1239,7 @@ void Sapphire::World::Manager::DebugCommandMgr::questBattle( char* data, Entity: uint16_t bgmId; sscanf( params.c_str(), "%hd", &bgmId ); - if( auto instance = player.getCurrentInstance() ) + if( auto instance = pCurrentZone->getAsInstanceContent() ) instance->setCurrentBGM( bgmId ); } else diff --git a/src/world/Manager/PartyMgr.cpp b/src/world/Manager/PartyMgr.cpp index ed4e1787..24fef682 100644 --- a/src/world/Manager/PartyMgr.cpp +++ b/src/world/Manager/PartyMgr.cpp @@ -401,7 +401,7 @@ void Sapphire::World::Manager::PartyMgr::sendPartyUpdate( Party& party ) { bool isConnected = server.getSession( member->getCharacterId() ) != nullptr; // if player is online and in the same zone as current member in party, display more data in partylist - bool hasInfo = isConnected && member->getZoneId() == pMember->getZoneId(); + bool hasInfo = isConnected && member->getTerritoryTypeId() == pMember->getTerritoryTypeId(); if( hasInfo ) { diff --git a/src/world/Network/Handlers/EventHandlers.cpp b/src/world/Network/Handlers/EventHandlers.cpp index b52d1e86..39e26d41 100644 --- a/src/world/Network/Handlers/EventHandlers.cpp +++ b/src/world/Network/Handlers/EventHandlers.cpp @@ -16,6 +16,7 @@ #include "Manager/EventMgr.h" #include "Manager/PlayerMgr.h" +#include "Manager/TerritoryMgr.h" #include "WorldServer.h" #include "Territory/InstanceContent.h" @@ -52,7 +53,9 @@ void Sapphire::Network::GameConnection::eventHandlerTalk( const Packets::FFXIVAR World::Manager::PlayerMgr::sendDebug( player, "Calling: {0}.{1}", objName, eventName ); eventMgr.eventStart( player, actorId, eventId, Event::EventHandler::Talk, 0, 0 ); - if( auto instance = player.getCurrentInstance() ) + auto teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); + auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); + if( auto instance = pZone->getAsInstanceContent() ) { instance->onTalk( player, eventId, actorId ); } @@ -147,6 +150,8 @@ void Sapphire::Network::GameConnection::eventHandlerEnterTerritory( const Packet { auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref(); + auto& teriMgr = Service< World::Manager::TerritoryMgr >::ref(); + auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); const auto packet = ZoneChannelPacket< FFXIVIpcEnterTerritoryHandler >( inPacket ); @@ -160,19 +165,19 @@ void Sapphire::Network::GameConnection::eventHandlerEnterTerritory( const Packet World::Manager::PlayerMgr::sendDebug( player, "Calling: {0}.{1} - {2}", objName, eventName, eventId & 0xFFFF ); - if( auto instance = player.getCurrentInstance() ) + if( auto instance = pZone->getAsInstanceContent() ) { - eventMgr.eventStart( player, player.getId(), eventId, Event::EventHandler::EnterTerritory, 1, player.getZoneId() ); + eventMgr.eventStart( player, player.getId(), eventId, Event::EventHandler::EnterTerritory, 1, player.getTerritoryTypeId() ); instance->onEnterTerritory( player, eventId, param1, param2 ); } - else if( auto instance = player.getCurrentQuestBattle() ) + else if( auto qb = pZone->getAsQuestBattle() ) { - eventMgr.eventStart( player, player.getId(), eventId, Event::EventHandler::EnterTerritory, 1, player.getZoneId() ); - instance->onEnterTerritory( player, eventId, param1, param2 ); + eventMgr.eventStart( player, player.getId(), eventId, Event::EventHandler::EnterTerritory, 1, player.getTerritoryTypeId() ); + qb->onEnterTerritory( player, eventId, param1, param2 ); } else { - eventMgr.eventStart( player, player.getId(), eventId, Event::EventHandler::EnterTerritory, 0, player.getZoneId() ); + eventMgr.eventStart( player, player.getId(), eventId, Event::EventHandler::EnterTerritory, 0, player.getTerritoryTypeId() ); scriptMgr.onEnterTerritory( player, eventId, param1, param2 ); } diff --git a/src/world/Network/Handlers/GMCommandHandlers.cpp b/src/world/Network/Handlers/GMCommandHandlers.cpp index 55535b5e..0da7c4f6 100644 --- a/src/world/Network/Handlers/GMCommandHandlers.cpp +++ b/src/world/Network/Handlers/GMCommandHandlers.cpp @@ -192,8 +192,8 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR } case GmCommand::Call: { - if( targetPlayer->getZoneId() != player.getZoneId() ) - targetPlayer->setZone( player.getZoneId() ); + if( targetPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() ) + targetPlayer->setZone( player.getTerritoryTypeId() ); targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() ); PlayerMgr::sendServerNotice( player, "Calling {0}", targetPlayer->getName() ); @@ -213,7 +213,7 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR targetPlayer->getName(), targetPlayer->getCurrency( CurrencyType::Gil ), pTargetZone->getName(), - targetPlayer->getZoneId(), + targetPlayer->getTerritoryTypeId(), static_cast< uint8_t >( targetPlayer->getClass() ), targetPlayer->getLevel(), targetPlayer->getExp(), @@ -563,7 +563,7 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR "\nPopCount: {4}" "\nCurrentWeather: {5}" "\nNextWeather: {6}", - player.getZoneId(), + player.getTerritoryTypeId(), pTargetZone->getName(), pTargetZone->getInternalName(), pTargetZone->getGuId(), @@ -597,6 +597,7 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX return; auto& server = Common::Service< World::WorldServer >::ref(); + auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref(); const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommandName >( inPacket ); @@ -633,6 +634,9 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX if( !targetActor ) return; + auto pTargetActorTerri = teriMgr.getTerritoryByGuId( targetActor->getTerritoryId() ); + auto pPlayerTerri = teriMgr.getTerritoryByGuId( player.getTerritoryId() ); + auto targetPlayer = targetActor->getAsPlayer(); switch( commandId ) @@ -654,17 +658,17 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX } case GmCommand::Jump: { - player.prepareZoning( targetPlayer->getZoneId(), true, 1, 0 ); - if( player.getCurrentInstance() ) + player.prepareZoning( targetPlayer->getTerritoryTypeId(), true, 1, 0 ); + if( pPlayerTerri->getAsInstanceContent() ) { player.exitInstance(); } if( targetPlayer->getTerritoryId() != player.getTerritoryId() ) { // Checks if the target player is in an InstanceContent to avoid binding to a Territory or PublicContent - if( targetPlayer->getCurrentInstance() ) + auto pInstanceContent = pTargetActorTerri->getAsInstanceContent(); + if( pInstanceContent ) { - auto pInstanceContent = targetPlayer->getCurrentInstance(); // Not sure if GMs actually get bound to an instance they jump to on retail. It's mostly here to avoid a crash for now pInstanceContent->bindPlayer( player.getId() ); } @@ -678,13 +682,13 @@ void Sapphire::Network::GameConnection::gmCommandNameHandler( const Packets::FFX case GmCommand::Call: { // We shouldn't be able to call a player into an instance, only call them out of one - if( player.getCurrentInstance() ) + if( pPlayerTerri->getAsInstanceContent() ) { PlayerMgr::sendUrgent( player, "You are unable to call a player while bound to a battle instance." ); return; } - targetPlayer->prepareZoning( player.getZoneId(), true, 1, 0 ); - if( targetPlayer->getCurrentInstance() ) + targetPlayer->prepareZoning( player.getTerritoryTypeId(), true, 1, 0 ); + if( pTargetActorTerri->getAsInstanceContent() ) { targetPlayer->exitInstance(); } diff --git a/src/world/Network/Handlers/PacketCommandHandler.cpp b/src/world/Network/Handlers/PacketCommandHandler.cpp index 017aa1e4..a7cf662b 100644 --- a/src/world/Network/Handlers/PacketCommandHandler.cpp +++ b/src/world/Network/Handlers/PacketCommandHandler.cpp @@ -43,7 +43,7 @@ void examineHandler( Sapphire::Entity::Player& player, uint32_t targetId ) auto pTarget = pSession->getPlayer(); if( pTarget ) { - if( pTarget->isActingAsGm() || pTarget->getZoneId() != player.getZoneId() ) + if( pTarget->isActingAsGm() || pTarget->getTerritoryTypeId() != player.getTerritoryTypeId() ) { server.queueForPlayer( player.getCharacterId(), makeActorControl( player.getId(), ActorControlType::ExamineError ) ); } diff --git a/src/world/Network/Handlers/PacketHandlers.cpp b/src/world/Network/Handlers/PacketHandlers.cpp index 7f1881c0..b2599573 100644 --- a/src/world/Network/Handlers/PacketHandlers.cpp +++ b/src/world/Network/Handlers/PacketHandlers.cpp @@ -126,7 +126,7 @@ void Sapphire::Network::GameConnection::getSearchCommentHandler( const Packets:: if( pPlayer ) { - if( pPlayer->isActingAsGm() || pPlayer->getZoneId() != player.getZoneId() ) + if( pPlayer->isActingAsGm() || pPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() ) return; // retail sends the requester's id as both (isForSelf) @@ -155,7 +155,7 @@ void Sapphire::Network::GameConnection::reqExamineFcInfo( const Packets::FFXIVAR if( pPlayer ) { - if( pPlayer->isActingAsGm() || pPlayer->getZoneId() != player.getZoneId() ) + if( pPlayer->isActingAsGm() || pPlayer->getTerritoryTypeId() != player.getTerritoryTypeId() ) return; // retail sends the requester's id as both (isForSelf) @@ -360,7 +360,7 @@ void Sapphire::Network::GameConnection::zoneJumpHandler( const Packets::FFXIVARR auto moveTerritoryPacket = makeZonePacket< FFXIVIpcMoveTerritory >( player.getId() ); moveTerritoryPacket->data().index = -1; moveTerritoryPacket->data().territoryType = targetZone; - moveTerritoryPacket->data().zoneId = player.getZoneId(); + moveTerritoryPacket->data().zoneId = player.getTerritoryTypeId(); moveTerritoryPacket->data().worldId = server.getWorldId(); moveTerritoryPacket->data().worldId1 = server.getWorldId(); moveTerritoryPacket->data().landId = -1;