1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 22:17:45 +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 3d5e794d6e
commit 19f7bf82c9
2 changed files with 14 additions and 9 deletions

View file

@ -324,7 +324,7 @@ public:
void unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem );
/*! equip a weapon, possibly forcing a job change */
void equipWeapon( ItemPtr pItem );
void equipWeapon( ItemPtr pItem, bool updateClass );
/*! get player ilvl */
uint16_t getItemLevel() const;
@ -356,7 +356,7 @@ public:
/*! return the current amount of crystals of type */
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 );

View file

@ -114,7 +114,7 @@ void Core::Entity::Player::sendItemLevel()
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 >();
if( !exdData )
@ -127,7 +127,12 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
auto newClassJob = static_cast< ClassJob >( itemClassJob );
if( ( isClassJobUnlocked( newClassJob ) ) && ( currentParentClass != newClassJob ) )
setClassJob( newClassJob );
{
if ( updateClass )
setClassJob( newClassJob );
else
return;
}
}
// 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 ) );
updateModels( equipSlotId, pItem );
if( sendUpdate )
{
updateModels( equipSlotId, pItem, true );
this->sendModel();
m_itemLevel = calculateEquippedGearItemLevel();
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 model2 = pItem->getModelId2();
@ -156,7 +161,7 @@ void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::It
case MainHand:
m_modelMainWeapon = model;
m_modelSubWeapon = model2;
equipWeapon( pItem );
equipWeapon( pItem, updateClass );
break;
case OffHand: