From 05e5221f2ec52cf37a1d514ded6fc4438e18eb59 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 20:51:25 -0700 Subject: [PATCH] More static_cast - expand some types - gnarly std::pair issue with short to int8_t - getLinkshellById now uses uint32_t --- src/servers/Server_Zone/Actor/PlayerQuest.cpp | 8 ++++---- src/servers/Server_Zone/Inventory/Inventory.cpp | 6 +++--- src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp | 2 +- src/servers/Server_Zone/Linkshell/LinkshellMgr.h | 2 +- .../Server_Zone/Network/Handlers/EventHandlers.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/servers/Server_Zone/Actor/PlayerQuest.cpp b/src/servers/Server_Zone/Actor/PlayerQuest.cpp index ab617d2e..579a0fe1 100644 --- a/src/servers/Server_Zone/Actor/PlayerQuest.cpp +++ b/src/servers/Server_Zone/Actor/PlayerQuest.cpp @@ -74,7 +74,7 @@ bool Core::Entity::Player::loadActiveQuests() void Core::Entity::Player::finishQuest( uint16_t questId ) { - int16_t idx = getQuestIndex( questId ); + auto idx = static_cast< uint8_t >( getQuestIndex( questId ) ); if( ( idx != -1 ) && ( m_activeQuests[idx] != nullptr ) ) { @@ -123,7 +123,7 @@ void Core::Entity::Player::unfinishQuest( uint16_t questId ) void Core::Entity::Player::removeQuest( uint16_t questId ) { - int16_t idx = getQuestIndex( questId ); + auto idx = static_cast< uint8_t >( getQuestIndex( questId ) ); if( ( idx != -1 ) && ( m_activeQuests[idx] != nullptr ) ) { @@ -978,7 +978,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence ) if( hasQuest( questId ) ) { GamePacketNew< FFXIVIpcQuestUpdate, ServerZoneIpcType > pe_qa( getId() ); - int16_t index = getQuestIndex( questId ); + auto index = static_cast< uint8_t >( getQuestIndex( questId ) ); auto pNewQuest = m_activeQuests[index]; pe_qa.data().slot = index; pNewQuest->c.sequence = sequence; @@ -1038,7 +1038,7 @@ void Core::Entity::Player::sendQuestTracker() if( m_questTracking[ii] >= 0 ) { trackerPacket.data().entry[ii].active = 1; - trackerPacket.data().entry[ii].questIndex = m_questTracking[ii]; + trackerPacket.data().entry[ii].questIndex = static_cast< uint8_t >( m_questTracking[ii] ); } } queuePacket( trackerPacket ); diff --git a/src/servers/Server_Zone/Inventory/Inventory.cpp b/src/servers/Server_Zone/Inventory/Inventory.cpp index 2b552583..2a859076 100644 --- a/src/servers/Server_Zone/Inventory/Inventory.cpp +++ b/src/servers/Server_Zone/Inventory/Inventory.cpp @@ -108,7 +108,7 @@ Core::Inventory::InvSlotPairVec Core::Inventory::getSlotsOfItemsInInventory( uin for( auto item : inv->getItemMap() ) { if( item.second && item.second->getId() == catalogId ) - outVec.push_back( std::make_pair( i, item.first ) ); + outVec.push_back( std::make_pair( i, static_cast< int8_t >( item.first ) ) ); } } return outVec; @@ -118,7 +118,7 @@ Core::Inventory::InvSlotPair Core::Inventory::getFreeBagSlot() { for( auto i : { Bag0, Bag1, Bag2, Bag3 } ) { - int16_t freeSlot = m_inventoryMap[i]->getFreeSlot(); + auto freeSlot = static_cast< int8_t >( m_inventoryMap[i]->getFreeSlot() ); if( freeSlot != -1 ) return std::make_pair( i, freeSlot ); @@ -457,7 +457,7 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t return -1; } - int16_t rSlotId = -1; + int8_t rSlotId = -1; //if( itemInfo->stack_size > 1 ) //{ diff --git a/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp b/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp index 077f42d0..ab95f728 100644 --- a/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp +++ b/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp @@ -71,7 +71,7 @@ Core::LinkshellPtr Core::LinkshellMgr::getLinkshellByName( const std::string& na return it->second; } -Core::LinkshellPtr Core::LinkshellMgr::getLinkshellById( uint64_t lsId ) +Core::LinkshellPtr Core::LinkshellMgr::getLinkshellById( uint32_t lsId ) { auto it = m_linkshellIdMap.find( lsId ); if( it == m_linkshellIdMap.end() ) diff --git a/src/servers/Server_Zone/Linkshell/LinkshellMgr.h b/src/servers/Server_Zone/Linkshell/LinkshellMgr.h index d5083506..887b1f4b 100644 --- a/src/servers/Server_Zone/Linkshell/LinkshellMgr.h +++ b/src/servers/Server_Zone/Linkshell/LinkshellMgr.h @@ -16,7 +16,7 @@ private: std::map< std::string, LinkshellPtr > m_linkshellNameMap; LinkshellPtr getLinkshellByName( const std::string& name ); - LinkshellPtr getLinkshellById( uint64_t lsId ); + LinkshellPtr getLinkshellById( uint32_t lsId ); public: LinkshellMgr(); diff --git a/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp b/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp index d310ffc4..e8c8ced0 100644 --- a/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp +++ b/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp @@ -141,7 +141,7 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP GamePacketNew< FFXIVIpcEventLinkshell, ServerZoneIpcType > linkshellEvent( pPlayer->getId() ); linkshellEvent.data().eventId = eventId; - linkshellEvent.data().scene = subEvent; + linkshellEvent.data().scene = static_cast< uint8_t >(subEvent); linkshellEvent.data().param3 = 1; linkshellEvent.data().unknown1 = 0x15a; pPlayer->queuePacket( linkshellEvent );