From 77717d29f345d29b231b1b3cbf30f27461cb7560 Mon Sep 17 00:00:00 2001 From: amibu Date: Wed, 18 Oct 2017 17:54:17 +0200 Subject: [PATCH] Cleanup, mount DB saving; --- src/servers/Server_Common/Common.h | 3 ++- .../Server_Zone/Action/ActionMount.cpp | 10 +++------- src/servers/Server_Zone/Action/ActionMount.h | 2 +- src/servers/Server_Zone/Actor/Player.cpp | 20 ++++++++++++++++++- src/servers/Server_Zone/Actor/Player.h | 8 ++++++-- src/servers/Server_Zone/Actor/PlayerSql.cpp | 7 ++++++- .../Network/Handlers/ActionHandler.cpp | 4 ++-- .../Network/Handlers/SkillHandler.cpp | 4 ++-- .../PacketWrappers/PlayerSpawnPacket.h | 2 ++ 9 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/servers/Server_Common/Common.h b/src/servers/Server_Common/Common.h index 2c584f18..1675c443 100644 --- a/src/servers/Server_Common/Common.h +++ b/src/servers/Server_Common/Common.h @@ -952,7 +952,8 @@ namespace Core { GearSetEquipMsg = 0x321, - ToggleOrchestrionUnlock = 0x396 + ToggleOrchestrionUnlock = 0x396, + Dismount = 0x3a0 }; enum struct ChatType : uint16_t diff --git a/src/servers/Server_Zone/Action/ActionMount.cpp b/src/servers/Server_Zone/Action/ActionMount.cpp index f42c1ae5..50462d19 100644 --- a/src/servers/Server_Zone/Action/ActionMount.cpp +++ b/src/servers/Server_Zone/Action/ActionMount.cpp @@ -26,14 +26,13 @@ Core::Action::ActionMount::ActionMount() m_handleActionType = Common::HandleActionType::Event; } -Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, Entity::ActorPtr pTarget, uint32_t actionId ) +Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, uint32_t mountId ) { m_startTime = 0; - m_id = actionId; + m_id = mountId; m_handleActionType = HandleActionType::Spell; m_castTime = 1000; m_pSource = pActor; - m_pTarget = pTarget; m_bInterrupt = false; } @@ -56,7 +55,7 @@ void Core::Action::ActionMount::onStart() castPacket.data().skillType = Common::SkillType::MountSkill; castPacket.data().unknown_1 = m_id; castPacket.data().cast_time = static_cast< float >( m_castTime / 1000 ); // This is used for the cast bar above the target bar of the caster. - castPacket.data().target_id = m_pTarget->getId(); + castPacket.data().target_id = m_pSource->getAsPlayer()->getId(); m_pSource->sendToInRangeSet( castPacket, true ); m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting ); @@ -89,9 +88,6 @@ void Core::Action::ActionMount::onFinish() pPlayer->sendToInRangeSet(effectPacket, true); - pPlayer->sendToInRangeSet(ActorControlPacket142(pPlayer->getId(), ActorControlType::SetStatus, 4), true); //? - pPlayer->sendToInRangeSet(ActorControlPacket143(pPlayer->getId(), 0x39e, 12), true); //? - pPlayer->mount( m_id ); } diff --git a/src/servers/Server_Zone/Action/ActionMount.h b/src/servers/Server_Zone/Action/ActionMount.h index fe12bdd9..cdd68e3d 100644 --- a/src/servers/Server_Zone/Action/ActionMount.h +++ b/src/servers/Server_Zone/Action/ActionMount.h @@ -14,7 +14,7 @@ namespace Core { namespace Action { ActionMount(); ~ActionMount(); - ActionMount( Entity::ActorPtr pActor, Entity::ActorPtr pTarget, uint32_t actionId ); + ActionMount( Entity::ActorPtr pActor, uint32_t mountId ); void onStart() override; void onFinish() override; diff --git a/src/servers/Server_Zone/Actor/Player.cpp b/src/servers/Server_Zone/Actor/Player.cpp index f9eca5b8..39d5d709 100644 --- a/src/servers/Server_Zone/Actor/Player.cpp +++ b/src/servers/Server_Zone/Actor/Player.cpp @@ -1488,9 +1488,27 @@ uint8_t Core::Entity::Player::getEquipDisplayFlags() const void Core::Entity::Player::mount( uint32_t id ) { + m_mount = id; + sendToInRangeSet( ActorControlPacket142( getId(), ActorControlType::SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Mounted )), true ); + sendToInRangeSet( ActorControlPacket143( getId(), 0x39e, 12 ), true ); //? + GamePacketNew< FFXIVIpcMount, ServerZoneIpcType > mountPacket( getId() ); - mountPacket.data().id = id; + mountPacket.data().id = m_mount; sendToInRangeSet( mountPacket, true ); + setSyncFlag( PlayerSyncFlags::Status ); +} + +void Core::Entity::Player::dismount() +{ + sendToInRangeSet( ActorControlPacket142( getId(), ActorControlType::SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle )), true ); + sendToInRangeSet( ActorControlPacket143( getId(), ActorControlType::Dismount, 1 ), true ); + m_mount = 0; + setSyncFlag( PlayerSyncFlags::Status ); +} + +uint8_t Core::Entity::Player::getCurrentMount() const +{ + return m_mount; } void Core::Entity::Player::autoAttack( ActorPtr pTarget ) diff --git a/src/servers/Server_Zone/Actor/Player.h b/src/servers/Server_Zone/Actor/Player.h index f9d471ea..95fd1b89 100644 --- a/src/servers/Server_Zone/Actor/Player.h +++ b/src/servers/Server_Zone/Actor/Player.h @@ -338,10 +338,14 @@ public: void setTitle( uint16_t titleId ); /*! change gear param state */ void setEquipDisplayFlags( uint8_t state ); - /*! get gear param state and send update to inRangeSet */ + /*! get gear param state */ uint8_t getEquipDisplayFlags() const; - /*! mount the specified mount and send the packet */ + /*! mount the specified mount and send the packets */ void mount( uint32_t id ); + /*! dismount the current mount and send the packets */ + void dismount(); + /*! get the current mount */ + uint8_t getCurrentMount() const; void calculateStats() override; void sendStats(); diff --git a/src/servers/Server_Zone/Actor/PlayerSql.cpp b/src/servers/Server_Zone/Actor/PlayerSql.cpp index 4ff24919..23ed16f0 100644 --- a/src/servers/Server_Zone/Actor/PlayerSql.cpp +++ b/src/servers/Server_Zone/Actor/PlayerSql.cpp @@ -85,7 +85,8 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession ) "cd.EquipDisplayFlags, " "cd.ActiveTitle, " "cd.TitleList, " // 40 - "cd.Orchestrion " + "cd.Orchestrion, " + "c.Mount " "FROM charabase AS c " " INNER JOIN charadetail AS cd " " ON c.CharacterId = cd.CharacterId " @@ -180,10 +181,13 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession ) m_equipDisplayFlags = field[38].get< uint8_t >(); m_title = field[39].get< uint8_t >(); + field[40].getBinary( reinterpret_cast< char* >( m_titleList ), sizeof( m_titleList ) ); field[41].getBinary( reinterpret_cast< char* >( m_orchestrion ), sizeof( m_orchestrion ) ); + m_mount = field[42].get< uint8_t >(); + m_pCell = nullptr; if( !loadActiveQuests() || !loadClassData() || !loadSearchInfo() ) @@ -371,6 +375,7 @@ void Core::Entity::Player::createUpdateSql() charaDetailSet.insert( " Class = " + std::to_string( static_cast< uint32_t >( getClass() ) ) ); charaDetailSet.insert( " Status = " + std::to_string( static_cast< uint8_t >( getStatus() ) ) ); charaDetailSet.insert( " EquipDisplayFlags = " + std::to_string( static_cast< uint8_t >( getEquipDisplayFlags() ) ) ); + charaBaseSet.insert( " Mount = " + std::to_string( getCurrentMount() ) ); } if( m_updateFlags & PlayerSyncFlags::OpeningSeq ) diff --git a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp index 65815e95..9a6dcd6a 100644 --- a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp @@ -108,8 +108,8 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in } case 0x65: { - pPlayer->sendToInRangeSet( ActorControlPacket142(pPlayer->getId(), ActorControlType::SetStatus, 1 ), true ); //? - pPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), 0x393, 1 ), true ); //? + pPlayer->dismount(); + break; } case 0x68: // Remove status (clicking it off) { diff --git a/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp b/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp index e7a003ef..e83219f0 100644 --- a/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp +++ b/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp @@ -118,8 +118,8 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP pPlayer->sendDebug( "Request mount " + std::to_string( action ) ); - Action::ActionMountPtr pActionMount(new Action::ActionMount(pPlayer, pPlayer, action)); - pPlayer->setCurrentAction(pActionMount); + Action::ActionMountPtr pActionMount( new Action::ActionMount(pPlayer, action) ); + pPlayer->setCurrentAction( pActionMount ); pPlayer->sendDebug("setCurrentAction()"); pPlayer->getCurrentAction()->onStart(); diff --git a/src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.h b/src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.h index f96160f6..1c3e8eed 100644 --- a/src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.h +++ b/src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.h @@ -111,6 +111,8 @@ namespace Server { m_data.displayFlags |= Entity::Actor::DisplayFlags::Visor; } + m_data.currentMount = pPlayer->getCurrentMount(); + m_data.targetId = pPlayer->getTargetId(); //m_data.type = 1; //m_data.unknown_33 = 4;