diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index ca4e933f..b5c17591 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -521,6 +521,7 @@ void Action::Action::buildEffects() return; } + Service< World::Manager::PlayerMgr >::ref().onHudParamChanged( *m_pSource->getAsPlayer() ); if( !hasLutEntry || m_hitActors.empty() ) { diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index a2df0874..90f89489 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -627,7 +627,7 @@ void Sapphire::Entity::BNpc::onTick() Chara::onTick(); if( m_state == BNpcState::Retreat ) { - regainHp(); + restHp(); } } @@ -792,19 +792,19 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount ) Chara::update( tickCount ); } -void Sapphire::Entity::BNpc::regainHp() +void Sapphire::Entity::BNpc::restHp() { - if( this->m_hp < this->getMaxHp() ) + if( m_hp < getMaxHp() ) { auto addHp = static_cast< uint32_t >( getMaxHp() * 0.1f + 1 ); - if( this->m_hp + addHp < this->getMaxHp() ) - this->m_hp += addHp; + if( m_hp + addHp < getMaxHp() ) + m_hp += addHp; else - this->m_hp = this->getMaxHp(); + m_hp = getMaxHp(); } - this->sendStatusUpdate(); + sendHudParam(); } void Sapphire::Entity::BNpc::onActionHostile( Sapphire::Entity::CharaPtr pSource ) diff --git a/src/world/Actor/BNpc.h b/src/world/Actor/BNpc.h index 21445229..867f18f3 100644 --- a/src/world/Actor/BNpc.h +++ b/src/world/Actor/BNpc.h @@ -127,7 +127,7 @@ namespace Sapphire::Entity uint32_t getTimeOfDeath() const; void setTimeOfDeath( uint32_t timeOfDeath ); - void regainHp(); + void restHp(); void checkAggro(); diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index fac42d99..23f652b5 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -13,7 +13,7 @@ #include "Network/GameConnection.h" #include "Network/PacketWrappers/ActorControlPacket.h" #include "Network/PacketWrappers/ActorControlTargetPacket.h" -#include "Network/PacketWrappers/UpdateHpMpTpPacket.h" +#include "Network/PacketWrappers/RestingPacket.h" #include "Network/PacketWrappers/EffectPacket1.h" #include "Network/PacketWrappers/HudParamPacket.h" @@ -214,42 +214,36 @@ uint32_t Sapphire::Entity::Chara::getMaxMp() const void Sapphire::Entity::Chara::resetHp() { m_hp = getMaxHp(); - sendStatusUpdate(); } /*! \return reset mp to current max mp */ void Sapphire::Entity::Chara::resetMp() { m_mp = getMaxMp(); - sendStatusUpdate(); } /*! \param hp amount to set ( caps to maxHp ) */ void Sapphire::Entity::Chara::setHp( uint32_t hp ) { m_hp = hp < getMaxHp() ? hp : getMaxHp(); - sendStatusUpdate(); } /*! \param mp amount to set ( caps to maxMp ) */ void Sapphire::Entity::Chara::setMp( uint32_t mp ) { m_mp = mp < getMaxMp() ? mp : getMaxMp(); - sendStatusUpdate(); } /*! \param gp amount to set*/ void Sapphire::Entity::Chara::setGp( uint32_t gp ) { m_gp = static_cast< uint16_t >( gp ); - sendStatusUpdate(); } /*! \param tp amount to set*/ void Sapphire::Entity::Chara::setTp( uint32_t tp ) { m_tp = static_cast< uint16_t >( tp ); - sendStatusUpdate(); } /*! \param type invincibility type to set */ @@ -427,8 +421,6 @@ void Sapphire::Entity::Chara::heal( uint32_t amount ) } else m_hp += amount; - - sendStatusUpdate(); } void Sapphire::Entity::Chara::restoreMP( uint32_t amount ) @@ -439,8 +431,6 @@ void Sapphire::Entity::Chara::restoreMP( uint32_t amount ) } else m_mp += amount; - - sendStatusUpdate(); } /*! @@ -450,10 +440,10 @@ so players can have their own version and we can abolish the param. \param true if the update should also be sent to the actor ( player ) himself */ -void Sapphire::Entity::Chara::sendStatusUpdate() +void Sapphire::Entity::Chara::sendHudParam() { - FFXIVPacketBasePtr packet = std::make_shared< UpdateHpMpTpPacket >( *this ); - server().queueForPlayers( getInRangePlayerIds(), packet ); + FFXIVPacketBasePtr packet = makeHudParam( *this ); + server().queueForPlayers( getInRangePlayerIds( isPlayer() ), packet ); } /*! \return ActionPtr of the currently registered action, or nullptr */ diff --git a/src/world/Actor/Chara.h b/src/world/Actor/Chara.h index 35e4235f..20449f16 100644 --- a/src/world/Actor/Chara.h +++ b/src/world/Actor/Chara.h @@ -223,7 +223,7 @@ namespace Sapphire::Entity virtual uint8_t getLevel() const; - virtual void sendStatusUpdate(); + virtual void sendHudParam(); virtual void takeDamage( uint32_t damage ); diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index c3ea4e20..00ff1bda 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -119,8 +119,6 @@ Player::~Player() = default; void Player::unload() { - auto& partyMgr = Common::Service< World::Manager::PartyMgr >::ref(); - auto& fcMgr = Common::Service< World::Manager::FreeCompanyMgr >::ref(); // do one last update to db updateSql(); // reset isLogin and loading sequences just in case @@ -655,10 +653,10 @@ void Player::levelUp() Service< World::Manager::MapMgr >::ref().updateQuests( *this ); } -void Player::sendStatusUpdate() +void Player::sendHudParam() { // todo: overrides are funky - Service< World::Manager::PlayerMgr >::ref().onPlayerHpMpTpChanged( *this ); + Service< World::Manager::PlayerMgr >::ref().onHudParamChanged( *this ); } uint8_t Player::getLevel() const @@ -729,7 +727,7 @@ void Player::setClassJob( Common::ClassJob classJob ) m_tp = 0; - Service< World::Manager::PlayerMgr >::ref().onPlayerStatusUpdate( *this ); + Service< World::Manager::PlayerMgr >::ref().sendStatusUpdate( *this ); Service< World::Manager::PlayerMgr >::ref().onClassChanged( *this ); Service< World::Manager::MapMgr >::ref().updateQuests( *this ); } diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 74977910..3f87d1eb 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -581,7 +581,7 @@ namespace Sapphire::Entity void sendModel(); /*! send status update */ - void sendStatusUpdate() override; + void sendHudParam() override; /*! send the entire inventory sequence */ void sendInventory(); @@ -749,7 +749,7 @@ namespace Sapphire::Entity bool updateContainer( uint16_t storageId, uint16_t slotId, ItemPtr pItem ); /*! calculate and return player ilvl based off equipped gear */ - uint16_t calculateEquippedGearItemLevel(); + uint16_t calculateItemLevel(); /*! calculate bonus stats from gear */ @@ -1003,6 +1003,7 @@ namespace Sapphire::Entity int8_t getFreeQuestSlot(); + bool performResting(); }; } \ No newline at end of file diff --git a/src/world/Actor/PlayerEvent.cpp b/src/world/Actor/PlayerEvent.cpp index b5664318..aaf2bbc0 100644 --- a/src/world/Actor/PlayerEvent.cpp +++ b/src/world/Actor/PlayerEvent.cpp @@ -11,6 +11,7 @@ #include "Action/EventAction.h" #include "Manager/PlayerMgr.h" #include "Service.h" +#include using namespace Sapphire::Common; using namespace Sapphire::Network::Packets; @@ -64,11 +65,18 @@ void Sapphire::Entity::Player::onTick() // add 3 seconds to total play time m_playTime += 3; - bool sendUpdate = false; - if( !isAlive() || !isLoadingComplete() ) return; + bool sendUpdate = performResting(); + + if( sendUpdate ) + server().queueForPlayers( getInRangePlayerIds( true ), std::make_shared< RestingPacket >( *this ) ); +} + +bool Sapphire::Entity::Player::performResting() +{ + bool sendUpdate = false; auto addHp = static_cast< uint32_t >( static_cast< float >( getMaxHp() ) * 0.1f + 1 ); auto addMp = static_cast< uint32_t >( static_cast< float >( getMaxMp() ) * 0.06f + 1 ); uint32_t addTp = 100; @@ -111,7 +119,5 @@ void Sapphire::Entity::Player::onTick() sendUpdate = true; } - - if( sendUpdate ) - sendStatusUpdate(); + return sendUpdate; } diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index 2d89da1a..ca5bcdf7 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -99,13 +99,12 @@ void Sapphire::Entity::Player::initInventory() setupContainer( HandIn, 10, "", true, false ); loadInventory(); - + calculateItemLevel(); } void Sapphire::Entity::Player::sendItemLevel() { - calculateEquippedGearItemLevel(); - Service< World::Manager::PlayerMgr >::ref().onPlayerItemLevelUpdate( *this ); + Service< World::Manager::PlayerMgr >::ref().sendItemLevel( *this ); } void Sapphire::Entity::Player::equipWeapon( const Item& item ) @@ -227,12 +226,13 @@ void Sapphire::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, Item& updateModels( equipSlotId, item ); calculateStats(); + calculateItemLevel(); if( sendUpdate ) { sendModel(); sendItemLevel(); sendStats(); - sendStatusUpdate(); + sendHudParam(); } } @@ -247,13 +247,14 @@ void Sapphire::Entity::Player::unequipItem( Common::GearSetSlot equipSlotId, Ite unequipSoulCrystal(); calculateStats(); + calculateItemLevel(); if( sendUpdate ) { sendModel(); sendItemLevel(); sendStats(); - sendStatusUpdate(); + sendHudParam(); } } @@ -991,7 +992,7 @@ void Sapphire::Entity::Player::discardItem( uint16_t fromInventoryId, uint16_t f server().queueForPlayer( getCharacterId(), invTransFinPacket ); } -uint16_t Sapphire::Entity::Player::calculateEquippedGearItemLevel() +uint16_t Sapphire::Entity::Player::calculateItemLevel() { uint32_t iLvlResult = 0; diff --git a/src/world/FreeCompany/FreeCompany.h b/src/world/FreeCompany/FreeCompany.h index d6d99eab..0df6a8c3 100644 --- a/src/world/FreeCompany/FreeCompany.h +++ b/src/world/FreeCompany/FreeCompany.h @@ -142,8 +142,6 @@ namespace Sapphire void addMember( uint64_t memberId, uint8_t hierarchyId, uint32_t lastLogout ); void removeMember( uint64_t memberId ); - - }; } \ No newline at end of file diff --git a/src/world/Manager/FreeCompanyMgr.h b/src/world/Manager/FreeCompanyMgr.h index 0ab7dd16..b3f6341c 100644 --- a/src/world/Manager/FreeCompanyMgr.h +++ b/src/world/Manager/FreeCompanyMgr.h @@ -38,20 +38,9 @@ namespace Sapphire::World::Manager void addMember( uint64_t fcId, uint64_t memberId ); - //void sendFreeCompanyResult( Entity::Player& player, uint64_t fcId, ResultType resultType, uint64_t target, - // uint32_t result, UpdateStatus updateStatus, std::string targetName ); - void sendFcInviteList( Entity::Player& player ); void sendFcStatus( Entity::Player& player ); - /* void invitePlayer( Entity::Player& sourcePlayer, Entity::Player& invitedPlayer, uint64_t linkshellId ); - void kickPlayer( Entity::Player& sourcePlayer, Entity::Player& kickedPlayer, uint64_t linkshellId ); - - void addLeader( Entity::Player& sourcePlayer, Entity::Player& newLeaderPlayer, uint64_t linkshellId ); - void removeLeader( Entity::Player& sourcePlayer, Entity::Player& leaderPlayer, uint64_t linkshellId ); - void declineLeader( Entity::Player& sourcePlayer, uint64_t linkshellId ); - void changeMaster( Entity::Player& sourcePlayer, Entity::Player& nextMasterPlayer, uint64_t linkshellId ); */ - void sendFreeCompanyStatus( Entity::Player& player ); void dbInsertMember( uint64_t fcId, uint64_t characterId, uint8_t hierarchyId ); @@ -65,9 +54,6 @@ namespace Sapphire::World::Manager FreeCompanyPtr getFreeCompanyById( uint64_t fcId ); FreeCompanyPtr getFreeCompanyByName( const std::string& name ); - // void leaveLinkshell( uint64_t lsId, uint64_t characterId ); - // void joinLinkshell( uint64_t lsId, uint64_t characterId ); - void onFcLogin( uint64_t characterId ); void onFcLogout( uint64_t characterId ); void onSignPetition( Entity::Player& source, Entity::Player& target ); diff --git a/src/world/Manager/PlayerMgr.cpp b/src/world/Manager/PlayerMgr.cpp index b6dbe3e4..6c4c26d6 100644 --- a/src/world/Manager/PlayerMgr.cpp +++ b/src/world/Manager/PlayerMgr.cpp @@ -4,21 +4,17 @@ #include -#include #include #include #include #include #include -#include #include #include