diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 2fb1fb4c..9fe0abf7 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -45,14 +45,14 @@ Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t seq Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t sequence, Data::ActionPtr actionData, FrameworkPtr fw ) : - m_pSource( std::move( caster ) ), - m_pFw( std::move( fw ) ), - m_actionData( std::move( actionData ) ), m_id( actionId ), - m_targetId( 0 ), + m_sequence( sequence ), m_startTime( 0 ), + m_pSource( std::move( caster ) ), + m_targetId( 0 ), m_interruptType( Common::ActionInterruptType::None ), - m_sequence( sequence ) + m_pFw( std::move( fw ) ), + m_actionData( std::move( actionData ) ) { } @@ -101,10 +101,11 @@ bool Action::Action::init() case Common::ClassJob::Bard: case Common::ClassJob::Archer: m_range = 25; - + break; // anything that isnt ranged default: m_range = 3; + break; } } @@ -206,7 +207,7 @@ bool Action::Action::update() uint64_t tickCount = Common::Util::getTimeMs(); - if( !hasCastTime() || std::difftime( tickCount, m_startTime ) > m_castTimeMs ) + if( !hasCastTime() || std::difftime( static_cast(tickCount), static_cast(m_startTime) ) > m_castTimeMs ) { execute(); return true; @@ -257,7 +258,7 @@ void Action::Action::start() auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); // check the lut too and see if we have something usable, otherwise cancel the cast - if( !pScriptMgr->onStart( *this ) && !ActionLut::validEntryExists( getId() ) ) + if( !pScriptMgr->onStart( *this ) && !ActionLut::validEntryExists( static_cast( getId() ) ) ) { // script not implemented and insufficient lut data (no potencies) interrupt(); @@ -392,7 +393,7 @@ void Action::Action::buildEffects() auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); - if( !pScriptMgr->onExecute( *this ) && !ActionLut::validEntryExists( getId() ) ) + if( !pScriptMgr->onExecute( *this ) && !ActionLut::validEntryExists( static_cast( getId() ) ) ) { if( auto player = m_pSource->getAsPlayer() ) { @@ -405,7 +406,7 @@ void Action::Action::buildEffects() if( m_hitActors.empty() ) return; - auto lutEntry = ActionLut::getEntry( getId() ); + auto lutEntry = ActionLut::getEntry( static_cast( getId() ) ); // no script exists but we have a valid lut entry if( auto player = getSourceChara()->getAsPlayer() ) @@ -545,11 +546,11 @@ bool Action::Action::primaryCostCheck( bool subtractCosts ) auto cost = m_primaryCost * 100; - if( curMp < cost ) + if( curMp < static_cast(cost) ) return false; if( subtractCosts ) - m_pSource->setMp( curMp - cost ); + m_pSource->setMp( curMp - static_cast(cost) ); return true; } @@ -565,7 +566,7 @@ bool Action::Action::primaryCostCheck( bool subtractCosts ) } } -bool Action::Action::secondaryCostCheck( bool subtractCosts ) +bool Action::Action::secondaryCostCheck( bool /*subtractCosts*/ ) { // todo: these need to be mapped return true; @@ -679,4 +680,4 @@ Sapphire::Entity::CharaPtr Action::Action::getHitChara() } return nullptr; -} \ No newline at end of file +} diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index d133766e..e59852fe 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -269,7 +269,6 @@ void Sapphire::Entity::BNpc::sendPositionUpdate() void Sapphire::Entity::BNpc::hateListClear() { - auto it = m_hateList.begin(); for( auto& listEntry : m_hateList ) { if( isInRangeSet( listEntry->m_pChara ) ) @@ -301,7 +300,7 @@ Sapphire::Entity::CharaPtr Sapphire::Entity::BNpc::hateListGetHighest() void Sapphire::Entity::BNpc::hateListAdd( Sapphire::Entity::CharaPtr pChara, int32_t hateAmount ) { auto hateEntry = std::make_shared< HateListEntry >(); - hateEntry->m_hateAmount = hateAmount; + hateEntry->m_hateAmount = static_cast(hateAmount); hateEntry->m_pChara = pChara; m_hateList.insert( hateEntry ); @@ -318,13 +317,13 @@ void Sapphire::Entity::BNpc::hateListUpdate( Sapphire::Entity::CharaPtr pChara, { if( listEntry->m_pChara == pChara ) { - listEntry->m_hateAmount += hateAmount; + listEntry->m_hateAmount += static_cast(hateAmount); return; } } auto hateEntry = std::make_shared< HateListEntry >(); - hateEntry->m_hateAmount = hateAmount; + hateEntry->m_hateAmount = static_cast(hateAmount); hateEntry->m_pChara = pChara; m_hateList.insert( hateEntry ); } @@ -482,6 +481,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount ) checkAggro(); } + break; case BNpcState::Combat: { @@ -590,7 +590,7 @@ void Sapphire::Entity::BNpc::onDeath() // TODO: handle drops auto pPlayer = pHateEntry->m_pChara->getAsPlayer(); if( pPlayer ) - pPlayer->onMobKill( m_bNpcNameId ); + pPlayer->onMobKill( static_cast(m_bNpcNameId) ); } hateListClear(); } @@ -654,7 +654,7 @@ void Sapphire::Entity::BNpc::setOwner( Sapphire::Entity::CharaPtr m_pChara ) { auto setOwnerPacket = makeZonePacket< FFXIVIpcActorOwner >( getId() ); setOwnerPacket->data().type = 0x01; - setOwnerPacket->data().actorId = INVALID_GAME_OBJECT_ID; + setOwnerPacket->data().actorId = static_cast(INVALID_GAME_OBJECT_ID); sendToInRangeSet( setOwnerPacket ); } } @@ -697,7 +697,7 @@ void Sapphire::Entity::BNpc::autoAttack( CharaPtr pTarget ) auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 7 ); effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) ); Common::EffectEntry effectEntry{}; - effectEntry.value = damage; + effectEntry.value = static_cast(damage); effectEntry.effectType = ActionEffectType::Damage; effectEntry.hitSeverity = ActionHitSeverityType::NormalDamage; effectEntry.param = 0x71; @@ -705,7 +705,7 @@ void Sapphire::Entity::BNpc::autoAttack( CharaPtr pTarget ) sendToInRangeSet( effectPacket ); - pTarget->takeDamage( damage ); + pTarget->takeDamage( static_cast(damage) ); } } @@ -731,15 +731,15 @@ void Sapphire::Entity::BNpc::calculateStats() m_baseStats.determination = static_cast< uint32_t >( base ); m_baseStats.pie = static_cast< uint32_t >( base ); - m_baseStats.skillSpeed = paramGrowthInfo->baseSpeed; - m_baseStats.spellSpeed = paramGrowthInfo->baseSpeed; - m_baseStats.accuracy = paramGrowthInfo->baseSpeed; - m_baseStats.critHitRate = paramGrowthInfo->baseSpeed; - m_baseStats.attackPotMagic = paramGrowthInfo->baseSpeed; - m_baseStats.healingPotMagic = paramGrowthInfo->baseSpeed; - m_baseStats.tenacity = paramGrowthInfo->baseSpeed; + m_baseStats.skillSpeed = static_cast(paramGrowthInfo->baseSpeed); + m_baseStats.spellSpeed = static_cast(paramGrowthInfo->baseSpeed); + m_baseStats.accuracy = static_cast(paramGrowthInfo->baseSpeed); + m_baseStats.critHitRate = static_cast(paramGrowthInfo->baseSpeed); + m_baseStats.attackPotMagic = static_cast(paramGrowthInfo->baseSpeed); + m_baseStats.healingPotMagic = static_cast(paramGrowthInfo->baseSpeed); + m_baseStats.tenacity = static_cast(paramGrowthInfo->baseSpeed); m_baseStats.attack = m_baseStats.str; m_baseStats.attackPotMagic = m_baseStats.inte; m_baseStats.healingPotMagic = m_baseStats.mnd; -} \ No newline at end of file +} diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 70656675..036f29d8 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -35,10 +35,10 @@ using namespace Sapphire::Network::ActorControl; Sapphire::Entity::Chara::Chara( ObjKind type, FrameworkPtr pFw ) : Actor( type ), - m_pose( 0 ), m_targetId( INVALID_GAME_OBJECT_ID64 ), - m_pFw( std::move( std::move( pFw ) ) ), m_directorId( 0 ), + m_pose( 0 ), + m_pFw( std::move( std::move( pFw ) ) ), m_radius( 1.f ) { @@ -245,14 +245,14 @@ void Sapphire::Entity::Chara::setMp( uint32_t mp ) /*! \param gp amount to set*/ void Sapphire::Entity::Chara::setGp( uint32_t gp ) { - m_gp = gp; + m_gp = static_cast(gp); sendStatusUpdate(); } /*! \param tp amount to set*/ void Sapphire::Entity::Chara::setTp( uint32_t tp ) { - m_tp = tp; + m_tp = static_cast(tp); sendStatusUpdate(); } @@ -308,7 +308,7 @@ position \param Position to look towards */ -bool Sapphire::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p ) +bool Sapphire::Entity::Chara::face(const Common::FFXIVARR_POSITION3& p , float epsilon) { float oldRot = getRot(); float rot = Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z ); @@ -316,7 +316,7 @@ bool Sapphire::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p ) setRot( newRot ); - return oldRot != newRot; + return (fabs(oldRot - newRot) < epsilon); } /*! @@ -354,14 +354,14 @@ bool Sapphire::Entity::Chara::checkAction() void Sapphire::Entity::Chara::update( uint64_t tickCount ) { - if( std::difftime( tickCount, m_lastTickTime ) > 3000 ) + if( std::difftime( static_cast(tickCount), m_lastTickTime ) > 3000 ) { onTick(); - m_lastTickTime = tickCount; + m_lastTickTime = static_cast(tickCount); } - m_lastUpdate = tickCount; + m_lastUpdate = static_cast(tickCount); } /*! @@ -494,7 +494,7 @@ void Sapphire::Entity::Chara::autoAttack( CharaPtr pTarget ) auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 7 ); effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) ); Common::EffectEntry effectEntry{}; - effectEntry.value = damage; + effectEntry.value = static_cast(damage); effectEntry.effectType = ActionEffectType::Damage; effectEntry.hitSeverity = ActionHitSeverityType::NormalDamage; effectEntry.param = 0x71; @@ -929,4 +929,4 @@ uint32_t Sapphire::Entity::Chara::getStatValue( Sapphire::Common::BaseParam base } return value + getBonusStat( baseParam ); -} \ No newline at end of file +} diff --git a/src/world/Actor/Chara.h b/src/world/Actor/Chara.h index d9fea85b..3e9a1f09 100644 --- a/src/world/Actor/Chara.h +++ b/src/world/Actor/Chara.h @@ -183,7 +183,7 @@ namespace Sapphire::Entity std::string getName() const; - bool face( const Common::FFXIVARR_POSITION3& p ); + bool face( const Common::FFXIVARR_POSITION3& p , float epsilon = 0.005f); Common::Stance getStance() const; diff --git a/src/world/Manager/ActionMgr.cpp b/src/world/Manager/ActionMgr.cpp index 43d14170..5677be55 100644 --- a/src/world/Manager/ActionMgr.cpp +++ b/src/world/Manager/ActionMgr.cpp @@ -78,7 +78,7 @@ void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& play void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player, Action::ActionPtr currentAction, - Data::Action& actionData ) + Data::Action& /*actionData*/ ) { if( !currentAction->preCheck() ) { @@ -95,4 +95,4 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player, // todo: what do in cases of swiftcast/etc? script callback? currentAction->start(); -} \ No newline at end of file +} diff --git a/src/world/Math/CalcStats.cpp b/src/world/Math/CalcStats.cpp index d9c6d143..3fd2c6a0 100644 --- a/src/world/Math/CalcStats.cpp +++ b/src/world/Math/CalcStats.cpp @@ -154,7 +154,7 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer, Sapphire::FrameworkPtr pF auto vitMod = pPlayer->getBonusStat( Common::BaseParam::Vitality ); float baseStat = calculateBaseStat( *pPlayer ); - uint16_t vitStat = pPlayer->getStats().vit + static_cast< uint16_t >( vitMod ); + uint16_t vitStat = static_cast< uint16_t >( pPlayer->getStats().vit ) + static_cast< uint16_t >( vitMod ); uint16_t hpMod = paramGrowthInfo->hpModifier; uint16_t jobModHp = classInfo->modifierHitPoints; float approxBaseHp = 0.0f; // Read above @@ -483,7 +483,7 @@ float CalcStats::calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_ // D = ⌊ f(pot) × f(wd) × f(ap) × f(det) × f(tnc) × traits ⌋ // × f(chr) ⌋ × f(dhr) ⌋ × rand[ 0.95, 1.05 ] ⌋ buff_1 ⌋ × buff_1 ⌋ × buff... ⌋ - auto pot = potency( ptc ); + auto pot = potency( static_cast(ptc) ); auto wd = weaponDamage( chara, wepDmg ); auto ap = getPrimaryAttackPower( chara ); auto det = determination( chara ); @@ -513,4 +513,4 @@ float CalcStats::calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_ uint32_t CalcStats::primaryStatValue( const Sapphire::Entity::Chara& chara ) { return chara.getStatValue( chara.getPrimaryStat() ); -} \ No newline at end of file +} diff --git a/src/world/Network/Handlers/ActionHandler.cpp b/src/world/Network/Handlers/ActionHandler.cpp index dd365b9b..10924bcf 100644 --- a/src/world/Network/Handlers/ActionHandler.cpp +++ b/src/world/Network/Handlers/ActionHandler.cpp @@ -38,7 +38,7 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw, { default: { - player.sendDebug( "Skill type {0} not supported. Defaulting to normal action", type ); + player.sendDebug( "Skill type {0} not supported. Defaulting to normal action", type ); break; } case Common::SkillType::Normal: { diff --git a/src/world/Network/Handlers/CFHandlers.cpp b/src/world/Network/Handlers/CFHandlers.cpp index d51b6327..996deb18 100644 --- a/src/world/Network/Handlers/CFHandlers.cpp +++ b/src/world/Network/Handlers/CFHandlers.cpp @@ -32,7 +32,7 @@ void Sapphire::Network::GameConnection::cfDutyInfoRequest( FrameworkPtr pFw, // cap it since it's uint8_t in packets penaltyMinutes = 255; } - dutyInfoPacket->data().penaltyTime = penaltyMinutes; + dutyInfoPacket->data().penaltyTime = static_cast(penaltyMinutes); queueOutPacket( dutyInfoPacket ); auto inNeedsPacket = makeZonePacket< FFXIVIpcCFPlayerInNeed >( player.getId() ); @@ -62,7 +62,7 @@ void Sapphire::Network::GameConnection::cfRegisterDuty( FrameworkPtr pFw, } // todo: rand bias problem, will do for now tho - auto index = std::rand() % selectedContent.size(); + auto index = static_cast(std::rand()) % selectedContent.size(); auto contentId = selectedContent.at( index ); player.sendDebug( "Duty register request for contentid#{0}", contentId ); diff --git a/src/world/Territory/Cell.cpp b/src/world/Territory/Cell.cpp index ff495c90..e212a4de 100644 --- a/src/world/Territory/Cell.cpp +++ b/src/world/Territory/Cell.cpp @@ -11,10 +11,10 @@ Sapphire::Cell::Cell() : m_bActive( false ), m_bLoaded( false ), - m_playerCount( 0 ), - m_bUnloadPending( false ) + m_bUnloadPending( false ), + m_playerCount( 0 ) { - m_bForcedActive = false; + m_bForcedActive = false; } Sapphire::Cell::~Cell() @@ -25,8 +25,8 @@ Sapphire::Cell::~Cell() void Sapphire::Cell::init( uint32_t x, uint32_t y, TerritoryPtr pZone ) { m_pZone = pZone; - m_posX = x; - m_posY = y; + m_posX = static_cast(x); + m_posY = static_cast(y); m_actors.clear(); }