1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Fixes logon crash when using weapon of another class.

This commit is contained in:
Squall Leonhart 2018-10-18 20:59:04 +03:00
parent 8d96779a8e
commit 17f342d86c
2 changed files with 14 additions and 9 deletions

View file

@ -324,7 +324,7 @@ public:
void unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem ); void unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem );
/*! equip a weapon, possibly forcing a job change */ /*! equip a weapon, possibly forcing a job change */
void equipWeapon( ItemPtr pItem ); void equipWeapon( ItemPtr pItem, bool updateClass );
/*! get player ilvl */ /*! get player ilvl */
uint16_t getItemLevel() const; uint16_t getItemLevel() const;
@ -356,7 +356,7 @@ public:
/*! return the current amount of crystals of type */ /*! return the current amount of crystals of type */
uint32_t getCrystal( uint8_t type ) const; uint32_t getCrystal( uint8_t type ) const;
void updateModels( Common::GearSetSlot equipSlotId, const Core::ItemPtr& pItem ); void updateModels( Common::GearSetSlot equipSlotId, const Core::ItemPtr& pItem, bool updateClass );
Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot ); Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot );

View file

@ -114,7 +114,7 @@ void Core::Entity::Player::sendItemLevel()
queuePacket( makeActorControl142( getId(), SetItemLevel, getItemLevel(), 0 ) ); queuePacket( makeActorControl142( getId(), SetItemLevel, getItemLevel(), 0 ) );
} }
void Core::Entity::Player::equipWeapon( ItemPtr pItem ) void Core::Entity::Player::equipWeapon( ItemPtr pItem, bool updateClass )
{ {
auto exdData = g_fw.get< Core::Data::ExdDataGenerated >(); auto exdData = g_fw.get< Core::Data::ExdDataGenerated >();
if( !exdData ) if( !exdData )
@ -127,7 +127,12 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
auto newClassJob = static_cast< ClassJob >( itemClassJob ); auto newClassJob = static_cast< ClassJob >( itemClassJob );
if( ( isClassJobUnlocked( newClassJob ) ) && ( currentParentClass != newClassJob ) ) if( ( isClassJobUnlocked( newClassJob ) ) && ( currentParentClass != newClassJob ) )
setClassJob( newClassJob ); {
if ( updateClass )
setClassJob( newClassJob );
else
return;
}
} }
// equip an item // equip an item
@ -135,18 +140,18 @@ void Core::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, ItemPtr p
{ {
//g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) ); //g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) );
updateModels( equipSlotId, pItem );
if( sendUpdate ) if( sendUpdate )
{ {
updateModels( equipSlotId, pItem, true );
this->sendModel(); this->sendModel();
m_itemLevel = calculateEquippedGearItemLevel(); m_itemLevel = calculateEquippedGearItemLevel();
sendItemLevel(); sendItemLevel();
} }
else
updateModels( equipSlotId, pItem, false );
} }
void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::ItemPtr& pItem ) void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::ItemPtr& pItem, bool updateClass )
{ {
uint64_t model = pItem->getModelId1(); uint64_t model = pItem->getModelId1();
uint64_t model2 = pItem->getModelId2(); uint64_t model2 = pItem->getModelId2();
@ -156,7 +161,7 @@ void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::It
case MainHand: case MainHand:
m_modelMainWeapon = model; m_modelMainWeapon = model;
m_modelSubWeapon = model2; m_modelSubWeapon = model2;
equipWeapon( pItem ); equipWeapon( pItem, updateClass );
break; break;
case OffHand: case OffHand: