From 4c4fff58ce81c9e41b9ac9e49a60e6759ceb442a Mon Sep 17 00:00:00 2001 From: kbasikhin Date: Thu, 26 Dec 2019 11:09:15 +0300 Subject: [PATCH 1/6] using static and reinterpret casts instead of old style casts --- src/world/Action/Action.cpp | 12 +- src/world/Actor/BNpc.cpp | 28 ++-- src/world/Actor/Chara.cpp | 24 ++-- src/world/Manager/DebugCommandMgr.cpp | 34 ++--- src/world/Manager/HousingMgr.cpp | 134 +++++++++--------- src/world/Math/CalcStats.cpp | 4 +- src/world/Network/GameConnection.cpp | 22 +-- src/world/Network/Handlers/CFHandlers.cpp | 4 +- .../Network/Handlers/ClientTriggerHandler.cpp | 16 +-- .../Network/Handlers/GMCommandHandlers.cpp | 32 ++--- src/world/Territory/Cell.cpp | 4 +- src/world/Territory/House.cpp | 4 +- .../Housing/HousingInteriorTerritory.cpp | 12 +- 13 files changed, 165 insertions(+), 165 deletions(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 2fb1fb4c..550a7be3 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -206,7 +206,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< time_t >( tickCount ), static_cast< time_t >( m_startTime ) ) > m_castTimeMs ) { execute(); return true; @@ -257,7 +257,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< uint16_t >( getId() ) ) ) { // script not implemented and insufficient lut data (no potencies) interrupt(); @@ -392,7 +392,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< uint16_t >( getId() ) ) ) { if( auto player = m_pSource->getAsPlayer() ) { @@ -405,7 +405,7 @@ void Action::Action::buildEffects() if( m_hitActors.empty() ) return; - auto lutEntry = ActionLut::getEntry( getId() ); + auto lutEntry = ActionLut::getEntry( static_cast< uint16_t >( getId() ) ); // no script exists but we have a valid lut entry if( auto player = getSourceChara()->getAsPlayer() ) @@ -545,11 +545,11 @@ bool Action::Action::primaryCostCheck( bool subtractCosts ) auto cost = m_primaryCost * 100; - if( curMp < cost ) + if( curMp < static_cast< uint32_t >( cost ) ) return false; if( subtractCosts ) - m_pSource->setMp( curMp - cost ); + m_pSource->setMp( curMp - static_cast< uint32_t >( cost ) ); return true; } diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index d133766e..7dafc83c 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -301,7 +301,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< uint32_t >( hateAmount ); hateEntry->m_pChara = pChara; m_hateList.insert( hateEntry ); @@ -318,13 +318,13 @@ void Sapphire::Entity::BNpc::hateListUpdate( Sapphire::Entity::CharaPtr pChara, { if( listEntry->m_pChara == pChara ) { - listEntry->m_hateAmount += hateAmount; + listEntry->m_hateAmount += static_cast< uint32_t >( hateAmount ); return; } } auto hateEntry = std::make_shared< HateListEntry >(); - hateEntry->m_hateAmount = hateAmount; + hateEntry->m_hateAmount = static_cast< uint32_t >( hateAmount ); hateEntry->m_pChara = pChara; m_hateList.insert( hateEntry ); } @@ -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< uint16_t >( 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< uint32_t >( 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< int16_t >( 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< uint16_t >( damage ) ); } } @@ -731,13 +731,13 @@ 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< uint32_t >( paramGrowthInfo->baseSpeed ); + m_baseStats.spellSpeed = static_cast< uint32_t >( paramGrowthInfo->baseSpeed ); + m_baseStats.accuracy = static_cast< uint32_t >( paramGrowthInfo->baseSpeed ); + m_baseStats.critHitRate = static_cast< uint32_t >( paramGrowthInfo->baseSpeed ); + m_baseStats.attackPotMagic = static_cast< uint32_t >( paramGrowthInfo->baseSpeed ); + m_baseStats.healingPotMagic = static_cast< uint32_t >( paramGrowthInfo->baseSpeed ); + m_baseStats.tenacity = static_cast< uint32_t >( paramGrowthInfo->baseSpeed ); m_baseStats.attack = m_baseStats.str; m_baseStats.attackPotMagic = m_baseStats.inte; diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 70656675..c8cef7b1 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -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< uint16_t >( gp ); sendStatusUpdate(); } /*! \param tp amount to set*/ void Sapphire::Entity::Chara::setTp( uint32_t tp ) { - m_tp = tp; + m_tp = static_cast< uint16_t >( tp ); sendStatusUpdate(); } @@ -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< time_t >( tickCount ), m_lastTickTime ) > 3000 ) { onTick(); - m_lastTickTime = tickCount; + m_lastTickTime = static_cast< time_t >( tickCount ); } - m_lastUpdate = tickCount; + m_lastUpdate = static_cast< time_t >( 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< int16_t >( damage ); effectEntry.effectType = ActionEffectType::Damage; effectEntry.hitSeverity = ActionHitSeverityType::NormalDamage; effectEntry.param = 0x71; @@ -522,10 +522,10 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf statusEffectAdd->data().actor_id = pEffect->getTargetActorId(); statusEffectAdd->data().current_hp = getHp(); - statusEffectAdd->data().current_mp = getMp(); + statusEffectAdd->data().current_mp = static_cast< uint16_t >( getMp() ); statusEffectAdd->data().current_tp = getTp(); statusEffectAdd->data().max_hp = getMaxHp(); - statusEffectAdd->data().max_mp = getMaxMp(); + statusEffectAdd->data().max_mp = static_cast< uint16_t >( getMaxMp() ); statusEffectAdd->data().max_something = 1; //statusEffectAdd->data().unknown2 = 28; @@ -533,8 +533,8 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf status.sourceActorId = pEffect->getSrcActorId(); status.duration = static_cast< float >( pEffect->getDuration() ) / 1000; - status.id = pEffect->getId(); - status.index = nextSlot; + status.id = static_cast< uint16_t >( pEffect->getId() ); + status.index = static_cast< uint8_t >( nextSlot ); status.param = pEffect->getParam(); sendToInRangeSet( statusEffectAdd, isPlayer() ); @@ -568,7 +568,7 @@ int8_t Sapphire::Entity::Chara::getStatusEffectFreeSlot() if( m_statusEffectFreeSlotQueue.empty() ) return freeEffectSlot; - freeEffectSlot = m_statusEffectFreeSlotQueue.front(); + freeEffectSlot = static_cast< int8_t >( m_statusEffectFreeSlotQueue.front() ); m_statusEffectFreeSlotQueue.pop(); return freeEffectSlot; @@ -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/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index 9fef637d..a434446d 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -200,7 +200,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& int32_t aetheryteId; sscanf( params.c_str(), "%i", &aetheryteId ); - player.teleport( aetheryteId ); + player.teleport( static_cast< uint16_t >( aetheryteId ) ); } else if( ( subCommand == "discovery" ) && ( params != "" ) ) { @@ -209,8 +209,8 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& sscanf( params.c_str(), "%i %i", &map_id, &discover_id ); auto discoveryPacket = makeZonePacket< FFXIVIpcDiscovery >( player.getId() ); - discoveryPacket->data().map_id = map_id; - discoveryPacket->data().map_part_id = discover_id; + discoveryPacket->data().map_id = static_cast< uint32_t >( map_id ); + discoveryPacket->data().map_part_id = static_cast< uint32_t >( discover_id ); player.queuePacket( discoveryPacket ); } @@ -258,7 +258,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& int32_t minutes; sscanf( params.c_str(), "%d", &minutes ); - player.setCFPenaltyMinutes( minutes ); + player.setCFPenaltyMinutes( static_cast< uint32_t >( minutes ) ); } else if( subCommand == "eorzeatime" ) { @@ -274,7 +274,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& sscanf( params.c_str(), "%d", &id ); player.dismount(); - player.mount( id ); + player.mount( static_cast< uint32_t >( id ) ); } else if( subCommand == "msqguide" ) { @@ -282,7 +282,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& sscanf( params.c_str(), "%d", &id ); auto msqPacket = makeZonePacket< FFXIVIpcMSQTrackerProgress >( player.getId() ); - msqPacket->data().id = id; + msqPacket->data().id = static_cast< uint32_t >( id ); player.queuePacket( msqPacket ); player.sendDebug( "MSQ Guide updated " ); @@ -293,7 +293,7 @@ void Sapphire::World::Manager::DebugCommandMgr::set( char* data, Entity::Player& sscanf( params.c_str(), "%d", &id ); auto msqPacket = makeZonePacket< FFXIVIpcMSQTrackerComplete >( player.getId() ); - msqPacket->data().id = id; + msqPacket->data().id = static_cast< uint32_t >( id ); player.queuePacket( msqPacket ); player.sendDebug( "MSQ Guide updated " ); @@ -434,7 +434,7 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player& uint32_t titleId; sscanf( params.c_str(), "%u", &titleId ); - player.addTitle( titleId ); + player.addTitle( static_cast< uint16_t >( titleId ) ); player.sendNotice( "Added title (id#{0})", titleId ); } else if( subCommand == "bnpc" ) @@ -495,13 +495,13 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player& player.sendNotice( "Injecting ACTOR_CONTROL {0}", opcode ); auto actorControl = makeZonePacket< FFXIVIpcActorControlSelf >( playerId, player.getId() ); - actorControl->data().category = opcode; - actorControl->data().param1 = param1; - actorControl->data().param2 = param2; - actorControl->data().param3 = param3; - actorControl->data().param4 = param4; - actorControl->data().param5 = param5; - actorControl->data().param6 = param6; + actorControl->data().category = static_cast< uint16_t >( opcode ); + actorControl->data().param1 = static_cast< uint16_t >( param1 ); + actorControl->data().param2 = static_cast< uint16_t >( param2 ); + actorControl->data().param3 = static_cast< uint16_t >( param3 ); + actorControl->data().param4 = static_cast< uint16_t >( param4 ); + actorControl->data().param5 = static_cast< uint16_t >( param5 ); + actorControl->data().param6 = static_cast< uint16_t >( param6 ); player.queuePacket( actorControl ); @@ -521,7 +521,7 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player& uint32_t id; sscanf( params.c_str(), "%d", &id ); - player.learnAction( id ); + player.learnAction( static_cast< uint16_t >( id ) ); } else if ( subCommand == "effect") { @@ -532,7 +532,7 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player& effectPacket->setRotation( Common::Util::floatToUInt16Rot( player.getRot() ) ); Common::EffectEntry entry{}; - entry.value = param1; + entry.value = static_cast< int16_t >( param1 ); entry.effectType = Common::ActionEffectType::Damage; entry.hitSeverity = Common::ActionHitSeverityType::NormalDamage; diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index 028d25cc..43d697ee 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -159,7 +159,7 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories() continue; } - container->second->setItem( slot, item ); + container->second->setItem( static_cast< uint8_t >( slot ), item ); itemCount++; } @@ -182,7 +182,7 @@ void Sapphire::World::Manager::HousingMgr::initLandCache() // land stuff entry.m_landSetId = res->getUInt64( "LandSetId" ); - entry.m_landId = res->getUInt( "LandId" ); + entry.m_landId = static_cast< uint16_t >( res->getUInt( "LandId" ) ); entry.m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) ); entry.m_size = static_cast< Common::HouseSize >( res->getUInt8( "Size" ) ); @@ -233,9 +233,9 @@ void Sapphire::World::Manager::HousingMgr::initLandCache() // setup containers // todo: this is pretty garbage Common::LandIdent ident; - ident.territoryTypeId = entry.m_landSetId >> 16; - ident.wardNum = entry.m_landSetId & 0xFFFF; - ident.landId = entry.m_landId; + ident.territoryTypeId = static_cast< int16_t >( entry.m_landSetId >> 16 ); + ident.wardNum = static_cast< int16_t >( entry.m_landSetId & 0xFFFF ); + ident.landId = static_cast< int16_t >( entry.m_landId ); ident.worldId = 67; auto& containers = getEstateInventory( ident ); @@ -305,20 +305,20 @@ Sapphire::LandPtr Sapphire::World::Manager::HousingMgr::getLandByOwnerId( uint32 if( !hZone ) return nullptr; - return hZone->getLand( res->getUInt( 2 ) ); + return hZone->getLand( static_cast< uint8_t >( res->getUInt( 2 ) ) ); } void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& player, const Common::LandIdent ident ) { - player.setActiveLand( ident.landId, ident.wardNum ); + player.setActiveLand( static_cast< uint8_t >( ident.landId ), static_cast< uint8_t >( ident.wardNum ) ); - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto hZone = getHousingZoneByLandSetId( landSetId ); if( !hZone ) return; - auto land = hZone->getLand( ident.landId ); + auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -335,7 +335,7 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl std::strcpy( landInfoSignPacket->data().estateGreeting, house->getHouseGreeting().c_str() ); } - uint32_t playerId = land->getOwnerId(); + uint32_t playerId = static_cast< uint32_t >( land->getOwnerId() ); std::string playerName = framework()->get< World::ServerMgr >()->getPlayerNameFromDb( playerId ); memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() ); @@ -345,15 +345,15 @@ void Sapphire::World::Manager::HousingMgr::sendLandSignOwned( Entity::Player& pl void Sapphire::World::Manager::HousingMgr::sendLandSignFree( Entity::Player& player, const Common::LandIdent ident ) { - player.setActiveLand( ident.landId, ident.wardNum ); + player.setActiveLand( static_cast< uint8_t >( ident.landId ), static_cast< uint8_t >( ident.wardNum ) ); - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto hZone = getHousingZoneByLandSetId( landSetId ); if( !hZone ) return; - auto land = hZone->getLand( ident.landId ); + auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) ); auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() ); plotPricePacket->data().price = land->getCurrentPrice(); plotPricePacket->data().timeLeft = land->getDevaluationTime(); @@ -471,7 +471,7 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla auto wardInfoPacket = makeZonePacket< Server::FFXIVIpcHousingWardInfo >( player.getId() ); wardInfoPacket->data().landIdent.wardNum = wardId; - wardInfoPacket->data().landIdent.territoryTypeId = territoryTypeId; + wardInfoPacket->data().landIdent.territoryTypeId = static_cast< int16_t >( territoryTypeId ); // todo: properly get worldId wardInfoPacket->data().landIdent.worldId = 67; @@ -509,7 +509,7 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla entry.infoFlags |= Common::WardlandFlags::IsEstateOwned; auto owner = land->getOwnerId(); - auto playerName = framework()->get< World::ServerMgr >()->getPlayerNameFromDb( owner ); + auto playerName = framework()->get< World::ServerMgr >()->getPlayerNameFromDb( static_cast< uint32_t >( owner ) ); memcpy( &entry.estateOwnerName, playerName.c_str(), playerName.size() ); break; @@ -524,13 +524,13 @@ void Sapphire::World::Manager::HousingMgr::sendWardLandInfo( Entity::Player& pla void Sapphire::World::Manager::HousingMgr::sendEstateGreeting( Entity::Player& player, const Common::LandIdent ident ) { - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto hZone = getHousingZoneByLandSetId( landSetId ); if( !hZone ) return; - auto land = hZone->getLand( ident.landId ); + auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -630,9 +630,9 @@ bool Sapphire::World::Manager::HousingMgr::initHouseModels( Entity::Player& play if( item.second == 0 ) continue; - auto pItem = invMgr->createItem( player, item.second ); + auto pItem = invMgr->createItem( player, static_cast< uint32_t >( item.second ) ); - container->setItem( item.first, pItem ); + container->setItem( static_cast< uint8_t >( item.first ), pItem ); } invMgr->saveHousingContainer( land->getLandIdent(), container ); @@ -701,7 +701,7 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl // start house built event // CmnDefHousingBuildHouse_00149 player.eventStart( player.getId(), 0x000B0095, Event::EventHandler::EventType::Housing, 1, 1 ); - player.playScene( 0x000B0095, 0, SET_BASE | HIDE_HOTBAR , 0, 1, plotNum, nullptr ); + player.playScene( 0x000B0095, 0, static_cast< uint32_t >( SET_BASE | HIDE_HOTBAR ) , 0, 1, plotNum, nullptr ); player.setLandFlags( LandFlagsSlot::Private, EstateBuilt, ident ); player.sendLandFlagsSlot( LandFlagsSlot::Private ); @@ -711,13 +711,13 @@ void Sapphire::World::Manager::HousingMgr::buildPresetEstate( Entity::Player& pl void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& player, const Common::LandIdent ident ) { - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto hZone = getHousingZoneByLandSetId( landSetId ); if( !hZone ) return; - auto land = hZone->getLand( ident.landId ); + auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) ); auto house = land->getHouse(); if( !house ) @@ -733,13 +733,13 @@ void Sapphire::World::Manager::HousingMgr::requestEstateRename( Entity::Player& void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Player& player, const Common::LandIdent ident ) { - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto hZone = getHousingZoneByLandSetId( landSetId ); if( !hZone ) return; - auto land = hZone->getLand( ident.landId ); + auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -757,13 +757,13 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGreeting( Entity::Pl void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::LandIdent ident, const std::string& greeting ) { - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto zone = getHousingZoneByLandSetId( landSetId ); if( !zone ) return; - auto land = zone->getLand( ident.landId ); + auto land = zone->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -782,7 +782,7 @@ void Sapphire::World::Manager::HousingMgr::updateEstateGreeting( Entity::Player& void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, const Common::LandIdent ident ) { - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto hZone = getHousingZoneByLandSetId( landSetId ); if( !hZone ) @@ -804,13 +804,13 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity: Sapphire::Common::LandIdent Sapphire::World::Manager::HousingMgr::clientTriggerParamsToLandIdent( uint32_t param11, uint32_t param12, bool use16bits ) const { Common::LandIdent ident; - ident.worldId = param11 >> 16; - ident.territoryTypeId = param11 & 0xFFFF; + ident.worldId = static_cast< int16_t >( param11 >> 16 ); + ident.territoryTypeId = static_cast< int16_t >( param11 & 0xFFFF ); if( use16bits ) { - ident.wardNum = param12 >> 16; - ident.landId = param12 & 0xFFFF; + ident.wardNum = static_cast< int16_t >( param12 >> 16 ); + ident.landId = static_cast< int16_t >( param12 & 0xFFFF ); } else { @@ -837,13 +837,13 @@ void Sapphire::World::Manager::HousingMgr::sendEstateInventory( Entity::Player& auto ident = internalZone->getLandIdent(); - auto landSetId = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSetId = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); auto exteriorZone = getHousingZoneByLandSetId( landSetId ); if( !exteriorZone ) return; - targetLand = exteriorZone->getLand( ident.landId ); + targetLand = exteriorZone->getLand( static_cast< uint8_t >( ident.landId ) ); } else { @@ -974,7 +974,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity // inside housing territory if( auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() ) ) { - land = zone->getLand( landId ); + land = zone->getLand( static_cast< uint8_t >( landId ) ); isOutside = true; } @@ -985,9 +985,9 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity // todo: this whole process is retarded and needs to be fixed // perhaps maintain a list of estates by ident inside housingmgr? auto ident = zone->getLandIdent(); - auto landSet = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSet = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); - land = getHousingZoneByLandSetId( landSet )->getLand( ident.landId ); + land = getHousingZoneByLandSetId( landSet )->getLand( static_cast< uint8_t >( ident.landId ) ); } // wtf? else @@ -1047,7 +1047,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity if( auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() ) ) { - land = zone->getLand( landId ); + land = zone->getLand( static_cast< uint8_t >( landId ) ); isOutside = true; } else if( auto zone = std::dynamic_pointer_cast< Territory::Housing::HousingInteriorTerritory >( @@ -1056,9 +1056,9 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity // todo: this whole process is retarded and needs to be fixed // perhaps maintain a list of estates by ident inside housingmgr? auto ident = zone->getLandIdent(); - auto landSet = toLandSetId( ident.territoryTypeId, ident.wardNum ); + auto landSet = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); - land = getHousingZoneByLandSetId( landSet )->getLand( ident.landId ); + land = getHousingZoneByLandSetId( landSet )->getLand( static_cast< uint8_t >( ident.landId ) ); } if( !hasPermission( player, *land, 0 ) ) @@ -1080,7 +1080,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity if( !item ) return; - container->setItem( freeSlot, item ); + container->setItem( static_cast< uint8_t >( freeSlot ), item ); invMgr->sendInventoryContainer( player, container ); invMgr->saveHousingContainer( ident, container ); } @@ -1103,7 +1103,7 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity if( !item ) return; - container->setItem( freeSlot, item ); + container->setItem( static_cast< uint8_t >( freeSlot ), item ); invMgr->sendInventoryContainer( player, container ); invMgr->saveHousingContainer( ident, container ); } @@ -1125,7 +1125,7 @@ bool Sapphire::World::Manager::HousingMgr::placeExternalItem( Entity::Player& pl return false; // add item to inv - container->setItem( freeSlot, item ); + container->setItem( static_cast< uint8_t >( freeSlot ), item ); // we need to save the item again as removing it from the container on the player will remove it from charaglobalitem // todo: this needs to be handled a bit better as it might be possible to overwrite another item that is created in the meantime @@ -1139,7 +1139,7 @@ bool Sapphire::World::Manager::HousingMgr::placeExternalItem( Entity::Player& pl auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() ); assert( zone ); - zone->spawnYardObject( ident.landId, freeSlot, *item ); + zone->spawnYardObject( static_cast< uint8_t >( ident.landId ), static_cast< uint16_t >( freeSlot ), *item ); return true; } @@ -1173,7 +1173,7 @@ bool Sapphire::World::Manager::HousingMgr::placeInteriorItem( Entity::Player& pl } // have a free slot - container->setItem( freeSlot, item ); + container->setItem( static_cast< uint8_t >( freeSlot ), item ); // resend container invMgr->sendInventoryContainer( player, container ); @@ -1183,7 +1183,7 @@ bool Sapphire::World::Manager::HousingMgr::placeInteriorItem( Entity::Player& pl auto zone = std::dynamic_pointer_cast< Territory::Housing::HousingInteriorTerritory >( player.getCurrentTerritory() ); assert( zone ); - zone->spawnHousingObject( containerIdx, freeSlot, containerId, item ); + zone->spawnHousingObject( containerIdx, static_cast< uint16_t >( freeSlot ), containerId, item ); return true; } @@ -1235,8 +1235,8 @@ void Sapphire::World::Manager::HousingMgr::reqMoveHousingItem( Entity::Player& p Common::LandIdent ident, uint8_t slot, Common::FFXIVARR_POSITION3 pos, float rot ) { - auto landSet = toLandSetId( ident.territoryTypeId, ident.wardNum ); - auto land = getHousingZoneByLandSetId( landSet )->getLand( ident.landId ); + auto landSet = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); + auto land = getHousingZoneByLandSetId( landSet )->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -1282,7 +1282,7 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla auto container = it->second; - auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slotIdx ) ); + auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( static_cast< uint8_t >( slotIdx ) ) ); if( !item ) return false; @@ -1293,10 +1293,10 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla auto invMgr = framework()->get< InventoryMgr >(); invMgr->updateHousingItemPosition( item ); - terri.updateHousingObjectPosition( player, slot, item->getPos(), item->getRot() ); + terri.updateHousingObjectPosition( player, slot, item->getPos(), static_cast< uint16_t >( item->getRot() ) ); // send confirmation to player - uint32_t param1 = ( ident.landId << 16 ) | containerId; + uint32_t param1 = static_cast< uint32_t >( ( ident.landId << 16 ) | containerId ); player.queuePacket( Server::makeActorControlSelf( player.getId(), ActorControl::HousingItemMoveConfirm, param1, slotIdx ) ); @@ -1309,7 +1309,7 @@ bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& pla Sapphire::HousingZone& terri, Common::FFXIVARR_POSITION3 pos, float rot ) { - auto land = terri.getLand( ident.landId ); + auto land = terri.getLand( static_cast< uint8_t >( ident.landId ) ); if( !hasPermission( player, *land, 0 ) ) return false; @@ -1331,9 +1331,9 @@ bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& pla auto invMgr = framework()->get< InventoryMgr >(); invMgr->updateHousingItemPosition( item ); - terri.updateYardObjectPos( player, slot, ident.landId, *item ); + terri.updateYardObjectPos( player, slot, static_cast< uint16_t >( ident.landId ), *item ); - uint32_t param1 = ( ident.landId << 16 ) | InventoryType::HousingExteriorPlacedItems; + uint32_t param1 = static_cast< uint32_t >( ( ident.landId << 16 ) | InventoryType::HousingExteriorPlacedItems ); player.queuePacket( Server::makeActorControlSelf( player.getId(), ActorControl::HousingItemMoveConfirm, param1, slot ) ); @@ -1348,8 +1348,8 @@ void Sapphire::World::Manager::HousingMgr::reqRemoveHousingItem( Sapphire::Entit player.getCurrentTerritory() ) ) { auto ident = terri->getLandIdent(); - auto landSet = toLandSetId( ident.territoryTypeId, ident.wardNum ); - auto land = getHousingZoneByLandSetId( landSet )->getLand( ident.landId ); + auto landSet = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); + auto land = getHousingZoneByLandSetId( landSet )->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -1361,7 +1361,7 @@ void Sapphire::World::Manager::HousingMgr::reqRemoveHousingItem( Sapphire::Entit } else if( auto terri = std::dynamic_pointer_cast< HousingZone >( player.getCurrentTerritory() ) ) { - auto land = terri->getLand( plot ); + auto land = terri->getLand( static_cast< uint8_t >( plot ) ); if( !land ) return; @@ -1406,7 +1406,7 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p auto container = it->second; - auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slotId ) ); + auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( static_cast< uint8_t >( slotId ) ) ); if( !item ) return false; @@ -1420,7 +1420,7 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p auto invMgr = framework()->get< InventoryMgr >(); // remove it from housing inventory - container->removeItem( slotId ); + container->removeItem( static_cast< uint8_t >( slotId ) ); invMgr->sendInventoryContainer( player, container ); invMgr->removeHousingItemPosition( *item ); invMgr->removeItemFromHousingContainer( terri.getLandIdent(), containerId, slotId ); @@ -1441,12 +1441,12 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p auto invMgr = framework()->get< InventoryMgr >(); - container->removeItem( slotId ); + container->removeItem( static_cast< uint8_t >( slotId ) ); invMgr->sendInventoryContainer( player, container ); invMgr->removeHousingItemPosition( *item ); invMgr->removeItemFromHousingContainer( terri.getLandIdent(), containerId, slotId ); - freeContainer->setItem( slotId, item ); + freeContainer->setItem( static_cast< uint8_t >( slotId ), item ); invMgr->sendInventoryContainer( player, freeContainer ); invMgr->saveHousingContainer( terri.getLandIdent(), freeContainer ); } @@ -1455,7 +1455,7 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p if( containerIdx != -1 ) { auto arraySlot = ( containerIdx * 50 ) + slotId; - terri.removeHousingObject( arraySlot ); + terri.removeHousingObject( static_cast< uint16_t >( arraySlot ) ); } return true; @@ -1494,7 +1494,7 @@ bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& p invMgr->removeItemFromHousingContainer( land.getLandIdent(), sourceContainer->getId(), slotId ); invMgr->removeHousingItemPosition( *item ); - storeroomContainer->setItem( freeSlot, item ); + storeroomContainer->setItem( static_cast< uint8_t >( freeSlot ), item ); invMgr->sendInventoryContainer( player, storeroomContainer ); invMgr->saveHousingContainer( land.getLandIdent(), storeroomContainer ); } @@ -1515,7 +1515,7 @@ bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& p } if( shouldDespawnItem ) - terri.despawnYardObject( land.getLandIdent().landId, slotId ); + terri.despawnYardObject( static_cast< uint16_t >( land.getLandIdent().landId ), slotId ); return true; } @@ -1552,7 +1552,7 @@ void Sapphire::World::Manager::HousingMgr::reqEstateExteriorRemodel( Sapphire::E if( !terri ) return; - auto land = terri->getLand( plot ); + auto land = terri->getLand( static_cast< uint8_t >( plot ) ); if( !land ) return; @@ -1580,8 +1580,8 @@ void Sapphire::World::Manager::HousingMgr::reqEstateInteriorRemodel( Sapphire::E return; auto ident = terri->getLandIdent(); - auto landSet = toLandSetId( ident.territoryTypeId, ident.wardNum ); - auto land = getHousingZoneByLandSetId( landSet )->getLand( ident.landId ); + auto landSet = toLandSetId( static_cast< uint16_t >( ident.territoryTypeId ), static_cast< uint8_t >( ident.wardNum ) ); + auto land = getHousingZoneByLandSetId( landSet )->getLand( static_cast< uint8_t >( ident.landId ) ); if( !land ) return; @@ -1622,4 +1622,4 @@ Sapphire::Inventory::HousingItemPtr Sapphire::World::Manager::HousingMgr::getHou return nullptr; return Inventory::make_HousingItem( tmpItem->getUId(), tmpItem->getId(), framework() ); -} \ No newline at end of file +} diff --git a/src/world/Math/CalcStats.cpp b/src/world/Math/CalcStats.cpp index d9c6d143..72d45fff 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< uint16_t >( ptc ) ); auto wd = weaponDamage( chara, wepDmg ); auto ap = getPrimaryAttackPower( chara ); auto det = determination( chara ); diff --git a/src/world/Network/GameConnection.cpp b/src/world/Network/GameConnection.cpp index 12489297..fd8fa095 100644 --- a/src/world/Network/GameConnection.cpp +++ b/src/world/Network/GameConnection.cpp @@ -224,7 +224,7 @@ void Sapphire::Network::GameConnection::handleZonePacket( Sapphire::Network::Pac Logger::debug( "[{0}] Undefined World IPC : Unknown ( {1:04X} )", m_pSession->getId(), opcode ); Logger::debug( "Dump:\n{0}", Util::binaryToHexDump( const_cast< uint8_t* >( &pPacket.data[ 0 ] ), - pPacket.segHdr.size ) ); + static_cast< uint16_t >( pPacket.segHdr.size) ) ); } } @@ -392,7 +392,7 @@ void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network:: { case SEGMENTTYPE_SESSIONINIT: { - char* id = ( char* ) &( inPacket.data[ 4 ] ); + char* id = reinterpret_cast< char* >( &( inPacket.data[ 4 ] ) ); uint32_t playerId = std::stoul( id ); auto pCon = std::static_pointer_cast< GameConnection, Connection >( shared_from_this() ); @@ -423,15 +423,15 @@ void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network:: m_pSession = session; auto pe = std::make_shared< FFXIVRawPacket >( 0x07, 0x18, 0, 0 ); - *( unsigned int* ) ( &pe->data()[ 0 ] ) = 0xE0037603; - *( unsigned int* ) ( &pe->data()[ 4 ] ) = Common::Util::getTimeSeconds(); + *reinterpret_cast< unsigned int* >( &pe->data()[ 0 ] ) = 0xE0037603; + *reinterpret_cast< unsigned int* >( &pe->data()[ 4 ] ) = Common::Util::getTimeSeconds(); sendSinglePacket( pe ); // main connection, assinging it to the session if( ipcHeader.connectionType == ConnectionType::Zone ) { auto pe1 = std::make_shared< FFXIVRawPacket >( 0x02, 0x38, 0, 0 ); - *( unsigned int* ) ( &pe1->data()[ 0 ] ) = playerId; + *reinterpret_cast< unsigned int* >( &pe1->data()[ 0 ] ) = playerId; sendSinglePacket( pe1 ); Logger::info( "[{0}] Setting session for world connection", id ); session->setZoneConnection( pCon ); @@ -440,11 +440,11 @@ void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network:: else if( ipcHeader.connectionType == ConnectionType::Chat ) { auto pe2 = std::make_shared< FFXIVRawPacket >( 0x02, 0x38, 0, 0 ); - *( unsigned int* ) ( &pe2->data()[ 0 ] ) = playerId; + *reinterpret_cast< unsigned int* >( &pe2->data()[ 0 ] ) = playerId; sendSinglePacket( pe2 ); auto pe3 = std::make_shared< FFXIVRawPacket >( 0x03, 0x28, playerId, playerId ); - *( unsigned short* ) ( &pe3->data()[ 2 ] ) = 0x02; + *reinterpret_cast< unsigned short* >( &pe3->data()[ 2 ] ) = 0x02; sendSinglePacket( pe3 ); Logger::info( "[{0}] Setting session for chat connection", id ); @@ -461,12 +461,12 @@ void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network:: } case SEGMENTTYPE_KEEPALIVE: // keep alive { - uint32_t id = *( uint32_t* ) &inPacket.data[ 0 ]; - uint32_t timeStamp = *( uint32_t* ) &inPacket.data[ 4 ]; + uint32_t id = *reinterpret_cast< uint32_t* >( &inPacket.data[ 0 ] ); + uint32_t timeStamp = *reinterpret_cast< uint32_t* >( &inPacket.data[ 4 ] ); auto pe4 = std::make_shared< FFXIVRawPacket >( 0x08, 0x18, 0, 0 ); - *( unsigned int* ) ( &pe4->data()[ 0 ] ) = id; - *( unsigned int* ) ( &pe4->data()[ 4 ] ) = timeStamp; + *reinterpret_cast< unsigned int* >( &pe4->data()[ 0 ] ) = id; + *reinterpret_cast< unsigned int* >( &pe4->data()[ 4 ] ) = timeStamp; sendSinglePacket( pe4 ); break; diff --git a/src/world/Network/Handlers/CFHandlers.cpp b/src/world/Network/Handlers/CFHandlers.cpp index d51b6327..9f3660fb 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< uint8_t >( 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< uint32_t >( std::rand() ) % selectedContent.size(); auto contentId = selectedContent.at( index ); player.sendDebug( "Duty register request for contentid#{0}", contentId ); diff --git a/src/world/Network/Handlers/ClientTriggerHandler.cpp b/src/world/Network/Handlers/ClientTriggerHandler.cpp index 08d44118..d75ed879 100644 --- a/src/world/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/world/Network/Handlers/ClientTriggerHandler.cpp @@ -127,7 +127,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, } case ClientTriggerType::SpawnCompanionReq: { - player.spawnCompanion( param1 ); + player.spawnCompanion( static_cast< uint16_t >( param1 ) ); break; } case ClientTriggerType::RemoveStatusEffect: // Remove status (clicking it off) @@ -236,14 +236,14 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, case ClientTriggerType::PoseChange: // change pose case ClientTriggerType::PoseReapply: // reapply pose { - player.setPose( param12 ); + player.setPose( static_cast< uint8_t >( param12 ) ); auto pSetStatusPacket = makeActorControl( player.getId(), SetPose, param11, param12 ); player.sendToInRangeSet( pSetStatusPacket, true ); break; } case ClientTriggerType::PoseCancel: // cancel pose { - player.setPose( param12 ); + player.setPose( static_cast< uint8_t >( param12 ) ); auto pSetStatusPacket = makeActorControl( player.getId(), SetPose, param11, param12 ); player.sendToInRangeSet( pSetStatusPacket, true ); break; @@ -273,7 +273,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, case ClientTriggerType::Teleport: // Teleport { - player.teleportQuery( param11 ); + player.teleportQuery( static_cast< uint16_t >( param11 ) ); break; } case ClientTriggerType::DyeItem: // Dye item @@ -317,7 +317,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, if (!hZone) return; - player.setActiveLand( param11, hZone->getWardNum() ); + player.setActiveLand( static_cast< uint8_t >( param11 ), hZone->getWardNum() ); auto pShowBuildPresetUIPacket = makeActorControl( player.getId(), ShowBuildPresetUI, param11 ); player.queuePacket( pShowBuildPresetUIPacket ); @@ -348,7 +348,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, if( !pHousingMgr ) break; - pHousingMgr->sendWardLandInfo( player, param12, param11 ); + pHousingMgr->sendWardLandInfo( player, static_cast< uint8_t >( param12 ), static_cast< uint8_t >( param11 ) ); break; } @@ -462,7 +462,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, auto sendToStoreroom = ( param4 >> 16 ) != 0; //player, plot, containerId, slot, sendToStoreroom - housingMgr->reqRemoveHousingItem( player, param12, param2, slot, sendToStoreroom ); + housingMgr->reqRemoveHousingItem( player, static_cast< uint16_t >( param12 ), static_cast< uint16_t >( param2 ), static_cast< uint8_t >( slot ), sendToStoreroom ); break; } @@ -470,7 +470,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, { auto housingMgr = m_pFw->get< HousingMgr >(); - housingMgr->reqEstateExteriorRemodel( player, param11 ); + housingMgr->reqEstateExteriorRemodel( player, static_cast< uint16_t >( param11 ) ); break; } diff --git a/src/world/Network/Handlers/GMCommandHandlers.cpp b/src/world/Network/Handlers/GMCommandHandlers.cpp index 252bb313..77bd4380 100644 --- a/src/world/Network/Handlers/GMCommandHandlers.cpp +++ b/src/world/Network/Handlers/GMCommandHandlers.cpp @@ -130,13 +130,13 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, { case GmCommand::Lv: { - targetPlayer->setLevel( param1 ); + targetPlayer->setLevel( static_cast< uint8_t >( param1 ) ); player.sendNotice( "Level for {0} was set to {1}", targetPlayer->getName(), param1 ); break; } case GmCommand::Race: { - targetPlayer->setLookAt( CharaLook::Race, param1 ); + targetPlayer->setLookAt( CharaLook::Race, static_cast< uint8_t >( param1 ) ); player.sendNotice( "Race for {0} was set to {1}", targetPlayer->getName(), param1 ); targetPlayer->spawn( targetPlayer ); auto inRange = targetPlayer->getInRangeActors(); @@ -152,7 +152,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, } case GmCommand::Tribe: { - targetPlayer->setLookAt( CharaLook::Tribe, param1 ); + targetPlayer->setLookAt( CharaLook::Tribe, static_cast< uint8_t >( param1 ) ); player.sendNotice( "Tribe for {0} was set to ", targetPlayer->getName(), param1 ); targetPlayer->spawn( targetPlayer ); auto inRange = targetPlayer->getInRangeActors(); @@ -168,7 +168,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, } case GmCommand::Sex: { - targetPlayer->setLookAt( CharaLook::Gender, param1 ); + targetPlayer->setLookAt( CharaLook::Gender, static_cast< uint8_t >( param1 ) ); player.sendNotice( "Sex for {0} was set to ", targetPlayer->getName(), param1 ); targetPlayer->spawn( targetPlayer ); auto inRange = targetActor->getInRangeActors(); @@ -325,7 +325,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, } else { - targetActor->getAsPlayer()->learnSong( param2, 0 ); + targetActor->getAsPlayer()->learnSong( static_cast< uint8_t >( param2 ), 0 ); player.sendNotice( "Song {0} for {1} was turned on.", param2, targetPlayer->getName() ); } } @@ -374,27 +374,27 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, } case GmCommand::QuestAccept: { - targetPlayer->updateQuest( param1, 1 ); + targetPlayer->updateQuest( static_cast< uint16_t >( param1 ), 1 ); break; } case GmCommand::QuestCancel: { - targetPlayer->removeQuest( param1 ); + targetPlayer->removeQuest( static_cast< uint16_t >( param1 ) ); break; } case GmCommand::QuestComplete: { - targetPlayer->finishQuest( param1 ); + targetPlayer->finishQuest( static_cast< uint16_t >( param1 ) ); break; } case GmCommand::QuestIncomplete: { - targetPlayer->unfinishQuest( param1 ); + targetPlayer->unfinishQuest( static_cast< uint16_t >( param1 ) ); break; } case GmCommand::QuestSequence: { - targetPlayer->updateQuest( param1, param2 ); + targetPlayer->updateQuest( static_cast< uint16_t >( param1 ), static_cast< uint8_t >( param2 ) ); break; } case GmCommand::GC: @@ -405,7 +405,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, return; } - targetPlayer->setGc( param1 ); + targetPlayer->setGc( static_cast< uint8_t >( param1 ) ); // if we're changing them to a GC, check if they have a rank and if not, set it to the lowest rank if( param1 > 0 ) @@ -413,7 +413,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, auto gcRankIdx = static_cast< uint8_t >( param1 ) - 1; if( targetPlayer->getGcRankArray()[ gcRankIdx ] == 0 ) { - player.setGcRankAt( gcRankIdx, 1 ); + player.setGcRankAt( static_cast< uint8_t >( gcRankIdx ), 1 ); } } @@ -430,7 +430,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, return; } - targetPlayer->setGcRankAt( gcId, param1 ); + targetPlayer->setGcRankAt( static_cast< uint8_t >( gcId ), static_cast< uint8_t >( param1 ) ); player.sendNotice( "GC Rank for {0} for GC {1} was set to {2}", targetPlayer->getName(), targetPlayer->getGc(), targetPlayer->getGcRankArray()[ targetPlayer->getGc() - 1 ] ); break; @@ -448,7 +448,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, } else { - targetActor->getAsPlayer()->registerAetheryte( param2 ); + targetActor->getAsPlayer()->registerAetheryte( static_cast< uint8_t >( param2 ) ); player.sendNotice( "Aetheryte {0} for {1} was turned on.", param2, targetPlayer->getName() ); } } @@ -521,7 +521,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, if( data->isAetheryte ) { doTeleport = true; - teleport = i; + teleport = static_cast< uint16_t >( i ); break; } } @@ -533,7 +533,7 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw, else { targetPlayer->setPos( targetPlayer->getPos() ); - targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 ); + targetPlayer->performZoning( static_cast< uint16_t >( param1 ), targetPlayer->getPos(), 0 ); } player.sendNotice( "{0} was warped to zone {1}", targetPlayer->getName(), param1, pZone->getName() ); diff --git a/src/world/Territory/Cell.cpp b/src/world/Territory/Cell.cpp index ff495c90..bbcfdd79 100644 --- a/src/world/Territory/Cell.cpp +++ b/src/world/Territory/Cell.cpp @@ -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< uint16_t >( x ); + m_posY = static_cast< uint16_t >( y ); m_actors.clear(); } diff --git a/src/world/Territory/House.cpp b/src/world/Territory/House.cpp index def91bc6..4d4544ff 100644 --- a/src/world/Territory/House.cpp +++ b/src/world/Territory/House.cpp @@ -34,7 +34,7 @@ void Sapphire::House::updateHouseDb() auto stmt = pDB->getPreparedStatement( Db::HOUSING_HOUSE_UP ); stmt->setUInt( 6, m_houseId ); - stmt->setInt64( 1, m_buildTime ); + stmt->setInt64( 1, static_cast< int64_t >( m_buildTime ) ); stmt->setBool( 2, m_hasAetheryte ); stmt->setString( 3, m_estateComment ); @@ -117,4 +117,4 @@ bool Sapphire::House::getHasAetheryte() const void Sapphire::House::setHasAetheryte( bool hasAetheryte ) { m_hasAetheryte = hasAetheryte; -} \ No newline at end of file +} diff --git a/src/world/Territory/Housing/HousingInteriorTerritory.cpp b/src/world/Territory/Housing/HousingInteriorTerritory.cpp index a3ccf34e..ade7acfc 100644 --- a/src/world/Territory/Housing/HousingInteriorTerritory.cpp +++ b/src/world/Territory/Housing/HousingInteriorTerritory.cpp @@ -63,8 +63,8 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::onPlayerZone indoorInitPacket->data().u3 = 0; indoorInitPacket->data().u4 = 0; - auto landSetId = pHousingMgr->toLandSetId( m_landIdent.territoryTypeId, m_landIdent.wardNum ); - auto pLand = pHousingMgr->getHousingZoneByLandSetId( landSetId )->getLand( m_landIdent.landId ); + auto landSetId = pHousingMgr->toLandSetId( static_cast< uint16_t >( m_landIdent.territoryTypeId ), static_cast< uint8_t >( m_landIdent.wardNum ) ); + auto pLand = pHousingMgr->getHousingZoneByLandSetId( landSetId )->getLand( static_cast< uint8_t >( m_landIdent.landId ) ); auto pHouse = pLand->getHouse(); for( auto i = 0; i < 10; i++ ) @@ -154,7 +154,7 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::updateHousin auto obj = housingMgr->getYardObjectForItem( housingItem ); - m_housingObjects[ offset ] = obj; + m_housingObjects[static_cast< size_t >( offset ) ] = obj; } containerIdx++; @@ -171,14 +171,14 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::spawnHousing auto offset = ( containerIdx * 50 ) + slot; auto obj = housingMgr->getYardObjectForItem( item ); - m_housingObjects[ offset ] = obj; + m_housingObjects[ static_cast< size_t >( offset ) ] = obj; for( const auto& player : m_playerMap ) { auto objectSpawnPkt = makeZonePacket< Server::FFXIVIpcHousingInternalObjectSpawn >( player.second->getId() ); objectSpawnPkt->data().containerId = containerType; - objectSpawnPkt->data().containerOffset = slot; + objectSpawnPkt->data().containerOffset = static_cast< uint8_t >( slot ); objectSpawnPkt->data().object.itemId = item->getAdditionalData() & 0xFFFF; objectSpawnPkt->data().object.rotation = item->getRot(); @@ -207,7 +207,7 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::updateHousin auto moveObjPkt = makeZonePacket< Server::FFXIVIpcHousingObjectMove >( player.second->getId() ); - moveObjPkt->data().itemRotation = obj.rotation; + moveObjPkt->data().itemRotation = static_cast< uint16_t >( obj.rotation ); moveObjPkt->data().pos = obj.pos; // todo: how does this work when an item is in a slot >50 or u8 max? my guess is landid is the container index, but not sure... From a98a7eccc87e3785a1b5b8b3b9b24497b5405460 Mon Sep 17 00:00:00 2001 From: kbasikhin Date: Mon, 30 Dec 2019 13:59:57 +0300 Subject: [PATCH 2/6] comparing floating point with "==" or "!=" is not correct (Chara.cpp) --- src/world/Actor/Chara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index c8cef7b1..98915ab8 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -316,7 +316,7 @@ bool Sapphire::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p ) setRot( newRot ); - return oldRot != newRot; + return ( fabs( oldRot - newRot ) <= std::numeric_limits< float >::epsilon() * fmax( fabs( oldRot ), fabs( newRot ) ) ); } /*! From b93dbbbaca6b858aadb18b3fa82c4723824cde5d Mon Sep 17 00:00:00 2001 From: collett Date: Wed, 1 Jan 2020 22:05:49 +0900 Subject: [PATCH 3/6] Update 5.18 opcodes and packets. --- src/common/Network/PacketDef/Ipcs.h | 202 +++++++++--------- .../Network/PacketDef/Zone/ServerZoneDef.h | 32 ++- src/world/Actor/Chara.cpp | 6 +- 3 files changed, 128 insertions(+), 112 deletions(-) diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index c49b0a5a..57de2993 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -45,27 +45,27 @@ namespace Sapphire::Network::Packets { // static opcode ( the ones that rarely, if ever, change ) - Ping = 0x0065, - Init = 0x0066, + Ping = 0x0200, // updated 5.18 + Init = 0x018E, - ActorFreeSpawn = 0x0249, // updated 5.11 - InitZone = 0x01D8, // updated 5.11 + ActorFreeSpawn = 0x009B, // updated 5.18 + InitZone = 0x007C, // updated 5.18 - EffectResult = 0x00B9, // updated 5.11 - ActorControl = 0x008D, // updated 5.11 - ActorControlSelf = 0x00EB, // updated 5.11 - ActorControlTarget = 0x01F5, // updated 5.11 + EffectResult = 0x0267, // updated 5.18 + ActorControl = 0x03BE, // updated 5.18 + ActorControlSelf = 0x00E3, // updated 5.18 + ActorControlTarget = 0x24d, // updated 5.18 /*! * @brief Used when resting */ - UpdateHpMpTp = 0x012D, // updated 5.11 + UpdateHpMpTp = 0x0125, // updated 5.18 /////////////////////////////////////////////////// ChatBanned = 0x006B, - Playtime = 0x01DB, // updated 5.1 - Logout = 0x011D, // updated 5.1 + Playtime = 0x00E7, // updated 5.18 + Logout = 0x142, // updated 5.18 CFNotify = 0x0078, CFMemberStatus = 0x0079, CFDutyInfo = 0x007A, @@ -79,29 +79,29 @@ namespace Sapphire::Network::Packets LogMessage = 0x00D0, - Chat = 0x02DC, // updated 5.1 + Chat = 0x02A3, // updated 5.18 WorldVisitList = 0x00FE, // added 4.5 - SocialList = 0x007A, // updated 5.1 + SocialList = 0x01F1, // updated 5.18 - ExamineSearchInfo = 0x03D7, // updated 5.1 - UpdateSearchInfo = 0x0358, // updated 5.1 - InitSearchInfo = 0x03A1, // updated 5.1 + ExamineSearchInfo = 0x012B, // updated 5.18 + UpdateSearchInfo = 0x01E5, // updated 5.18 + InitSearchInfo = 0x01D0, // updated 5.18 ExamineSearchComment = 0x0102, // updated 4.1 ServerNoticeShort = 0x0115, // updated 5.0 - ServerNotice = 0x0116, // updated 5.0 + ServerNotice = 0x0088, // updated 5.18 SetOnlineStatus = 0x015E, // updated 5.1 CountdownInitiate = 0x0309, // updated 5.11 - CountdownCancel = 0x013C, // updated 5.11 + CountdownCancel = 0x00D9, // updated 5.18 PlayerAddedToBlacklist = 0x033F, // updated 5.1 PlayerRemovedFromBlacklist = 0x0385, // updated 5.1 - BlackList = 0x031F, // updated 5.1 + BlackList = 0x0253, // updated 5.18 - LinkshellList = 0x012A, // updated 5.0 + LinkshellList = 0x00AC, // updated 5.18 MailDeleteRequest = 0x012B, // updated 5.0 @@ -110,12 +110,12 @@ namespace Sapphire::Network::Packets ReqMoogleMailLetter = 0x0139, // updated 5.0 MailLetterNotification = 0x013A, // updated 5.0 - MarketTaxRates = 0x039F, // updated 5.11 + MarketTaxRates = 0x025E, // updated 5.18 - MarketBoardItemListingCount = 0x00F2, // updated 5.11 - MarketBoardItemListing = 0x01E2, // updated 5.11 - MarketBoardItemListingHistory = 0x0123, // updated 5.11 - MarketBoardSearchResult = 0x00B7, // updated 5.11 + MarketBoardItemListingCount = 0x0328, // updated 5.18 + MarketBoardItemListing = 0x015F, // updated 5.18 + MarketBoardItemListingHistory = 0x0113, // updated 5.18 + MarketBoardSearchResult = 0x01EA, // updated 5.18 CharaFreeCompanyTag = 0x013B, // updated 4.5 FreeCompanyBoardMsg = 0x013C, // updated 4.5 @@ -124,83 +124,86 @@ namespace Sapphire::Network::Packets FreeCompanyUpdateShortMessage = 0x0157, // added 5.0 - StatusEffectList = 0x0399, // updated 5.11 - EurekaStatusEffectList = 0x01C2, // updated 5.11 - BossStatusEffectList = 0x00E6, // added 5.1 - Effect = 0x0165, // updated 5.11 - AoeEffect8 = 0x00E9, // updated 5.11 - AoeEffect16 = 0x007F, // updated 5.11 - AoeEffect24 = 0x0299, // updated 5.11 - AoeEffect32 = 0x01DF, // updated 5.11 - PersistantEffect = 0x0165, // updated 5.0 + StatusEffectList = 0x0183, // updated 5.18 + EurekaStatusEffectList = 0x0167, // updated 5.18 + BossStatusEffectList = 0x0312, // added 5.1 + Effect = 0x026B, // updated 5.18 + AoeEffect8 = 0x033E, // updated 5.18 + AoeEffect16 = 0x0305, // updated 5.18 + AoeEffect24 = 0x023F, // updated 5.18 + AoeEffect32 = 0x0352, // updated 5.18 + PersistantEffect = 0x019C, // updated 5.18 GCAffiliation = 0x016F, // updated 5.0 - PlayerSpawn = 0x0243, // updated 5.11 - NpcSpawn = 0x021B, // updated 5.11 - NpcSpawn2 = 0x0137, // ( Bigger statuseffectlist? ) updated 5.11 - ActorMove = 0x00DD, // updated 5.11 + PlayerSpawn = 0x0262, // updated 5.18 + NpcSpawn = 0x0186, // updated 5.18 + NpcSpawn2 = 0x010C, // ( Bigger statuseffectlist? ) updated 5.18 + ActorMove = 0x021B, // updated 5.18 - ActorSetPos = 0x0092, // updated 5.11 + ActorSetPos = 0x0068, // updated 5.18 - ActorCast = 0x028E, // updated 5.11 - SomeCustomiseChangePacketProbably = 0x0187, // added 5.0 + ActorCast = 0x03B1, // updated 5.18 + SomeCustomiseChangePacketProbably = 0x00CD, // added 5.18 - PartyList = 0x022B, // updated 5.11 - HateRank = 0x00B8, // updated 5.11 - HateList = 0x03C5, // updated 5.11 - ObjectSpawn = 0x02A0, // updated 5.11 - ObjectDespawn = 0x036B, // updated 5.11 - UpdateClassInfo = 0x00FC, // updated 5.11 + PartyList = 0x0287, // updated 5.18 + HateRank = 0x0226, // updated 5.18 + HateList = 0x0361, // updated 5.18 + ObjectSpawn = 0x027F, // updated 5.18 + ObjectDespawn = 0x034B, // updated 5.18 + UpdateClassInfo = 0x0362, // updated 5.18 SilentSetClassJob = 0x018E, // updated 5.0 - seems to be the case, not sure if it's actually used for anything - PlayerSetup = 0x01A1, // updated 5.11 - PlayerStats = 0x0324, // updated 5.11 + PlayerSetup = 0x0295, // updated 5.18 + PlayerStats = 0x017A, // updated 5.18 ActorOwner = 0x0322, // updated 5.11 - PlayerStateFlags = 0x019F, // updated 5.1 - PlayerClassInfo = 0x02D4, // updated 5.1 + PlayerStateFlags = 0x02C6, // updated 5.18 + PlayerClassInfo = 0x01B0, // updated 5.18 ModelEquip = 0x0170, // updated 5.11 - Examine = 0x00EA, // updated 5.1 - CharaNameReq = 0x006C, // updated 5.11 + Examine = 0x0366, // updated 5.18 + CharaNameReq = 0x0116, // updated 5.18 // nb: see #565 on github UpdateRetainerItemSalePrice = 0x019F, // updated 5.0 SetLevelSync = 0x1186, // not updated for 4.4, not sure what it is anymore - ItemInfo = 0x01D4, // updated 5.11 - ContainerInfo = 0x0145, // updated 5.1 + ItemInfo = 0x00F2, // updated 5.18 + ContainerInfo = 0x01F2, // updated 5.18 InventoryTransactionFinish = 0x01AB, // updated 5.1 InventoryTransaction = 0x023E, // updated 5.1 - CurrencyCrystalInfo = 0x02CA, // updated 5.11 + CurrencyCrystalInfo = 0x02BF, // updated 5.18 InventoryActionAck = 0x0084, // updated 5.1 - UpdateInventorySlot = 0x0112, // updated 5.11 + UpdateInventorySlot = 0x0370, // updated 5.18 HuntingLogEntry = 0x01B3, // updated 5.0 - EventPlay = 0x0386, // updated 5.11 + EventPlay = 0x0279, // updated 5.18 DirectorPlayScene = 0x01B9, // updated 5.0 - EventOpenGilShop = 0x01BC, // updated 5.0 + EventOpenGilShop = 0x01B1, // updated 5.18 - EventStart = 0x00C9, // updated 5.11 - EventFinish = 0x0387, // updated 5.11 + EventStart = 0x0230, // updated 5.18 + EventFinish = 0x01E4, // updated 5.18 + EventUnk0 = 0x02F7, // updated 5.18 + EventUnk1 = 0x0100, // updated 5.18 + UseMooch = 0x0233, // updated 5.18 EventLinkshell = 0x1169, - QuestActiveList = 0x01D2, // updated 5.0 - QuestUpdate = 0x01D3, // updated 5.0 - QuestCompleteList = 0x01D4, // updated 5.0 + QuestActiveList = 0x031E, // updated 5.18 + QuestUpdate = 0x0066, // updated 5.18 + QuestCompleteList = 0x025D, // updated 5.18 - QuestFinish = 0x01D5, // updated 5.0 + QuestFinish = 0x013A, // updated 5.18 MSQTrackerComplete = 0x01D6, // updated 5.0 MSQTrackerProgress = 0xF1CD, // updated 4.5 ? this actually looks like the two opcodes have been combined, see #474 - QuestMessage = 0x01DE, // updated 5.0 + QuestMessage = 0x00BF, // updated 5.18 - QuestTracker = 0x01E3, // updated 5.0 + QuestTracker = 0x0289, // updated 5.18 - Mount = 0x01F3, // updated 5.0 + Mount = 0x02F0, // updated 5.18 DirectorVars = 0x01F5, // updated 5.0 DirectorPopUp = 0x0200, // updated 5.0 - display dialogue pop-ups in duties and FATEs, for example, Teraflare's countdown @@ -209,11 +212,11 @@ namespace Sapphire::Network::Packets WeatherChange = 0x02FB, // updated 5.11 PlayerTitleList = 0x037D, // updated 5.1 - Discovery = 0x0094, // updated 5.1 + Discovery = 0x02E7, // updated 5.18 EorzeaTimeOffset = 0x03B8, // updated 5.1 - EquipDisplayFlags = 0x011D, // updated 5.11 + EquipDisplayFlags = 0x00FF, // updated 5.18 /// Housing ////////////////////////////////////// @@ -226,7 +229,7 @@ namespace Sapphire::Network::Packets LandRename = 0x023A, // updated 5.0 HousingEstateGreeting = 0x023B, // updated 5.0 HousingUpdateLandFlagsSlot = 0x023C, // updated 5.0 - HousingLandFlags = 0x023D, // updated 5.0 + HousingLandFlags = 0x01F3, // updated 5.18 HousingShowEstateGuestAccess = 0x023E, // updated 5.0 HousingObjectInitialize = 0x0240, // updated 5.0 @@ -247,11 +250,11 @@ namespace Sapphire::Network::Packets PerformNote = 0x0286, // updated 4.3 PrepareZoning = 0x02A4, // updated 5.0 - ActorGauge = 0x0292, // updated 4.3 + ActorGauge = 0x016D, // updated 5.18 // daily quest info -> without them sent, login will take longer... - DailyQuests = 0x02B6, // updated 5.1 - DailyQuestRepeatFlags = 0x0124, // updated 5.1 + DailyQuests = 0x02D8, // updated 5.18 + DailyQuestRepeatFlags = 0x03A3, // updated 5.18 /// Doman Mahjong ////////////////////////////////////// MahjongOpenGui = 0x02A4, // only available in mahjong instance @@ -272,10 +275,10 @@ namespace Sapphire::Network::Packets enum ClientZoneIpcType : uint16_t { - PingHandler = 0x0065, // unchanged 5.0 - InitHandler = 0x03D2, // updated 5.1 + PingHandler = 0x0200, // updated 5.18 + InitHandler = 0x018E, // updated 5.18 - FinishLoadingHandler = 0x01DC, // updated 5.1 + FinishLoadingHandler = 0x01F5, // updated 5.18 CFCommenceHandler = 0x006F, @@ -283,7 +286,7 @@ namespace Sapphire::Network::Packets CFRegisterDuty = 0x0071, CFRegisterRoulette = 0x0072, PlayTimeHandler = 0x0276, // updated 5.1 - LogoutHandler = 0x02D6, // updated 5.1 + LogoutHandler = 0x015D, // updated 5.18 CancelLogout = 0x008F, // updated 5.1 CFDutyInfoHandler = 0x0078, // updated 4.2 @@ -291,18 +294,18 @@ namespace Sapphire::Network::Packets SocialReqSendHandler = 0x00AE, // updated 4.1 CreateCrossWorldLS = 0x00AF, // updated 4.3 - ChatHandler = 0x02FF, // updated 5.1 + ChatHandler = 0x0130, // updated 5.18 - SocialListHandler = 0x01F6, // updated 5.1 - SetSearchInfoHandler = 0x00E4, // updated 5.0 - ReqSearchInfoHandler = 0x024D, // updated 5.1 + SocialListHandler = 0x0090, // updated 5.18 + SetSearchInfoHandler = 0x0320, // updated 5.18 + ReqSearchInfoHandler = 0x0374, // updated 5.18 ReqExamineSearchCommentHandler = 0x00E7, // updated 5.0 ReqRemovePlayerFromBlacklist = 0x00F1, // updated 5.0 - BlackListHandler = 0x0167, // updated 5.1 + BlackListHandler = 0x01EB, // updated 5.18 PlayerSearchHandler = 0x00F4, // updated 5.0 - LinkshellListHandler = 0x00D3, // updated 5.1 + LinkshellListHandler = 0x014A, // updated 5.18 MarketBoardRequestItemListingInfo = 0x0102, // updated 4.5 MarketBoardRequestItemListings = 0x0103, // updated 4.5 @@ -321,40 +324,39 @@ namespace Sapphire::Network::Packets ReqCountdownInitiate = 0x0135, // updated 5.0 ReqCountdownCancel = 0x0136, // updated 5.0 - ZoneLineHandler = 0x02E0, // updated 5.1 - ClientTrigger = 0x01F2, // updated 5.11 - DiscoveryHandler = 0x0177, // updated 5.1 + ZoneLineHandler = 0x0174, // updated 5.18 + ClientTrigger = 0x03C0, // updated 5.18 + DiscoveryHandler = 0x017B, // updated 5.18 PlaceFieldMarker = 0x013C, // updated 5.0 - - SkillHandler = 0x013D, // updated 5.0 + SkillHandler = 0x01BE, // updated 5.18 GMCommand1 = 0x00A4, // updated 5.1 GMCommand2 = 0x013F, // updated 5.0 AoESkillHandler = 0x140, // updated 5.0 - UpdatePositionHandler = 0x01BF, // updated 5.11 + UpdatePositionHandler = 0x0318, // updated 5.18 - InventoryModifyHandler = 0x029B, // updated 5.11 + InventoryModifyHandler = 0x03C5, // updated 5.18 InventoryEquipRecommendedItems = 0x0149, // updated 5.0 ReqPlaceHousingItem = 0x014B, // updated 5.0 BuildPresetHandler = 0x014F, // updated 5.0 - TalkEventHandler = 0x0151, // updated 5.0 - EmoteEventHandler = 0x0152, // updated 5.0 - WithinRangeEventHandler = 0x0165, // updated 5.11 - OutOfRangeEventHandler = 0x0154, // updated 5.0 - EnterTeriEventHandler = 0x0155, // updated 5.0 + TalkEventHandler = 0x02FD, // updated 5.18 + EmoteEventHandler = 0x0183, // updated 5.18 + WithinRangeEventHandler = 0x0167, // updated 5.18 + OutOfRangeEventHandler = 0x02B5, // updated 5.18 + EnterTeriEventHandler = 0x0267, // updated 5.18 ShopEventHandler = 0x0156, // updated 5.0 - ReturnEventHandler = 0x015A, // updated 5.0? - TradeReturnEventHandler = 0x015B, // updated 5.0? + ReturnEventHandler = 0x026B, // updated 5.18 + TradeReturnEventHandler = 0x02DD, // updated 5.18 LinkshellEventHandler = 0x016B, // updated 4.5 LinkshellEventHandler1 = 0x016C, // updated 4.5 - ReqEquipDisplayFlagsChange = 0x0175, // updated 5.0 + ReqEquipDisplayFlagsChange = 0x01FE, // updated 5.18 LandRenameHandler = 0xF177, // updated 5.0 HousingUpdateHouseGreeting = 0x0178, // updated 5.0 @@ -366,8 +368,6 @@ namespace Sapphire::Network::Packets PerformNoteHandler = 0x029B, // updated 4.3 - - }; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 9dc959b9..33915278 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -244,6 +244,7 @@ namespace Sapphire::Network::Packets::Server uint8_t rank; uint16_t padding; uint8_t lsName[20]; + uint8_t unk[16]; } entry[8]; }; @@ -440,15 +441,25 @@ namespace Sapphire::Network::Packets::Server { uint32_t unknown; uint32_t actor_id; - uint8_t unknown1; - uint8_t unknown2; - uint16_t padding1; + //uint8_t unknown1; + //uint8_t unknown2; + //uint16_t padding1; + //uint32_t current_hp; + //uint16_t current_mp; + //uint16_t current_tp; + //uint32_t max_hp; + //uint16_t max_mp; + //uint16_t max_something; uint32_t current_hp; - uint16_t current_mp; - uint16_t current_tp; uint32_t max_hp; + uint16_t current_mp; + uint16_t unknown1; uint16_t max_mp; - uint16_t max_something; + uint8_t unknown2; + uint8_t classId; + uint8_t unknown4; + uint8_t unkFlag; + uint16_t unknown6; struct StatusEntry { @@ -461,7 +472,7 @@ namespace Sapphire::Network::Packets::Server uint32_t sourceActorId; } statusEntries[4]; - uint32_t unknown4; + uint32_t unknown7; }; /** @@ -930,8 +941,10 @@ namespace Sapphire::Network::Packets::Server uint32_t unknown10; uint32_t unknown11; uint32_t unknown12[4]; + uint32_t unknown13[3]; Common::FFXIVARR_POSITION3 pos; - uint32_t unknown13; + uint32_t unknown14[3]; + uint32_t unknown15; }; @@ -1028,6 +1041,7 @@ namespace Sapphire::Network::Packets::Server unsigned char companionHealRank; unsigned char u19[2]; unsigned char mountGuideMask[19]; + uint8_t unk1[9]; char name[32]; unsigned char unknownOword[16]; unsigned char unknownOw; @@ -1496,7 +1510,7 @@ namespace Sapphire::Network::Packets::Server struct FFXIVIpcQuestCompleteList : FFXIVIpcBasePacket< QuestCompleteList > { uint8_t questCompleteMask[480]; - uint8_t unknownCompleteMask[32]; + uint8_t unknownCompleteMask[80]; }; /** diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 70656675..7cbc3dde 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -523,11 +523,13 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf statusEffectAdd->data().actor_id = pEffect->getTargetActorId(); statusEffectAdd->data().current_hp = getHp(); statusEffectAdd->data().current_mp = getMp(); - statusEffectAdd->data().current_tp = getTp(); + //statusEffectAdd->data().current_tp = getTp(); statusEffectAdd->data().max_hp = getMaxHp(); statusEffectAdd->data().max_mp = getMaxMp(); - statusEffectAdd->data().max_something = 1; + //statusEffectAdd->data().max_something = 1; //statusEffectAdd->data().unknown2 = 28; + statusEffectAdd->data().classId = static_cast< uint8_t >(getClass()); + statusEffectAdd->data().unkFlag = 1; auto& status = statusEffectAdd->data().statusEntries[0]; From 0d3e73e53138664458f4d5dcf9316419be376a5e Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 2 Jan 2020 14:42:58 +1100 Subject: [PATCH 4/6] fix eventplay opcodes/names --- src/common/Network/PacketDef/Ipcs.h | 9 +++++-- .../Network/PacketDef/Zone/ServerZoneDef.h | 26 ++++++++++++------- src/world/Actor/PlayerEvent.cpp | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index 57de2993..25bfd914 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -180,8 +180,13 @@ namespace Sapphire::Network::Packets HuntingLogEntry = 0x01B3, // updated 5.0 EventPlay = 0x0279, // updated 5.18 - DirectorPlayScene = 0x01B9, // updated 5.0 - EventOpenGilShop = 0x01B1, // updated 5.18 + EventPlay4 = 0x02F7, // updated 5.18 + EventPlay8 = 0x0119, // updated 5.18 + EventPlay16 = 0x01FB, // updated 5.18 + EventPlay32 = 0x0364, // updated 5.18 + EventPlay64 = 0x00E5, // updated 5.18 + EventPlay128 = 0x02BE, // updated 5.18 + EventPlay255 = 0x01B1, // updated 5.18 EventStart = 0x0230, // updated 5.18 EventFinish = 0x01E4, // updated 5.18 diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 33915278..f2075f74 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -1421,11 +1421,24 @@ namespace Sapphire::Network::Packets::Server uint8_t unknown[8]; }; + template< int ArgCount > + struct FFXIVIpcEventPlayN + { + uint64_t actorId; + uint32_t eventId; + uint16_t scene; + uint16_t padding; + uint32_t sceneFlags; + uint8_t paramCount; + uint8_t padding2[3]; + uint32_t params[ArgCount]; + }; + /** * Structural representation of the packet sent by the server * to play an event */ - struct FFXIVIpcDirectorPlayScene : FFXIVIpcBasePacket< DirectorPlayScene > + struct FFXIVIpcDirectorPlayScene : FFXIVIpcBasePacket< EventPlay32 > { uint64_t actorId; uint32_t eventId; @@ -1454,15 +1467,10 @@ namespace Sapphire::Network::Packets::Server /* 000C */ uint32_t padding1; }; - struct FFXIVIpcEventOpenGilShop : FFXIVIpcBasePacket< EventOpenGilShop > + struct FFXIVIpcEventPlay255 : + FFXIVIpcBasePacket< EventPlay255 >, + FFXIVIpcEventPlayN< 255 > { - uint64_t actorId; - uint32_t eventId; - uint16_t scene; - uint16_t padding; - uint32_t sceneFlags; - - uint32_t unknown_wtf[0x101]; }; diff --git a/src/world/Actor/PlayerEvent.cpp b/src/world/Actor/PlayerEvent.cpp index b4fb05a1..15c84470 100644 --- a/src/world/Actor/PlayerEvent.cpp +++ b/src/world/Actor/PlayerEvent.cpp @@ -141,7 +141,7 @@ void Sapphire::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags, pEvent->setEventReturnCallback( eventCallback ); pEvent->setSceneChainCallback( nullptr ); - auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() ); + auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventPlay255 >( getId() ); openGilShopPacket->data().eventId = eventId; openGilShopPacket->data().sceneFlags = flags; openGilShopPacket->data().actorId = getId(); From 7deae36146ed9ba732ae154da1ae05483afa6812 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 2 Jan 2020 15:10:04 +1100 Subject: [PATCH 5/6] more 5.18 opcodes --- src/common/Network/PacketDef/Ipcs.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index 25bfd914..88e219b6 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -190,8 +190,6 @@ namespace Sapphire::Network::Packets EventStart = 0x0230, // updated 5.18 EventFinish = 0x01E4, // updated 5.18 - EventUnk0 = 0x02F7, // updated 5.18 - EventUnk1 = 0x0100, // updated 5.18 UseMooch = 0x0233, // updated 5.18 EventLinkshell = 0x1169, @@ -210,8 +208,15 @@ namespace Sapphire::Network::Packets Mount = 0x02F0, // updated 5.18 - DirectorVars = 0x01F5, // updated 5.0 - DirectorPopUp = 0x0200, // updated 5.0 - display dialogue pop-ups in duties and FATEs, for example, Teraflare's countdown + DirectorVars = 0x00E6, // updated 5.18 + SomeDirectorUnk1 = 0x0084, // updated 5.18 + SomeDirectorUnk2 = 0x00C1, // updated 5.18 + SomeDirectorUnk4 = 0x0100, // updated 5.18 + SomeDirectorUnk8 = 0x028A, // updated 5.18 + SomeDirectorUnk16 = 0x028C, // updated 5.18 + DirectorPopUp = 0x0162, // updated 5.18 - display dialogue pop-ups in duties and FATEs, for example, Teraflare's countdown + DirectorPopUp4 = 0x0214, // updated 5.18 + DirectorPopUp8 = 0x00F8, // updated 5.18 CFAvailableContents = 0xF1FD, // updated 4.2 From 1ff69bcce0e4e5520f3e60165829f0428217558c Mon Sep 17 00:00:00 2001 From: collett Date: Thu, 2 Jan 2020 01:52:20 +0900 Subject: [PATCH 6/6] Fix non-existing lut entry being executed. --- src/world/Action/Action.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 550a7be3..871473e6 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -391,8 +391,9 @@ void Action::Action::buildEffects() snapshotAffectedActors( m_hitActors ); auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); + auto hasLutEntry = ActionLut::validEntryExists( static_cast< uint16_t >( getId() ) ); - if( !pScriptMgr->onExecute( *this ) && !ActionLut::validEntryExists( static_cast< uint16_t >( getId() ) ) ) + if( !pScriptMgr->onExecute( *this ) && !hasLutEntry ) { if( auto player = m_pSource->getAsPlayer() ) { @@ -402,7 +403,7 @@ void Action::Action::buildEffects() return; } - if( m_hitActors.empty() ) + if( !hasLutEntry || m_hitActors.empty() ) return; auto lutEntry = ActionLut::getEntry( static_cast< uint16_t >( getId() ) );