- Overload Item::SetState with player argument where possible to ensure updated data is saved to DB properly.
- Alter Item::SetEnchantmentDuration function, add parameter Player* because GetOwner() cannot be called in the function due to hashtable locking in the SaveAllPlayers process. - Remove a sanity check prior to Item::AddToUpdateQueueOf, so assertions can detect whenever a higher level function was not called properly. Please report any crashes related to these assertions to get them resolved asap. --HG-- branch : trunk
This commit is contained in:
+1
-1
@@ -2208,7 +2208,7 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
|
||||
|
||||
pl->ItemRemovedQuestCheck( pItemChar->GetEntry(), SplitedAmount );
|
||||
pItemChar->SetCount(pItemChar->GetCount()-SplitedAmount);
|
||||
pItemChar->SetState(ITEM_CHANGED);
|
||||
pItemChar->SetState(ITEM_CHANGED, pl);
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
StoreItem(BankTab, dest, pNewItem);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
+8
-8
@@ -598,7 +598,7 @@ void Item::SetItemRandomProperties(int32 randomPropId)
|
||||
{
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID,-int32(item_rand->ID));
|
||||
UpdateItemSuffixFactor();
|
||||
SetState(ITEM_CHANGED);
|
||||
SetState(ITEM_CHANGED, GetOwner());
|
||||
}
|
||||
|
||||
for (uint32 i = PROP_ENCHANTMENT_SLOT_0; i < PROP_ENCHANTMENT_SLOT_0 + 3; ++i)
|
||||
@@ -631,8 +631,7 @@ void Item::SetState(ItemUpdateState state, Player *forplayer)
|
||||
if (uState != ITEM_NEW)
|
||||
uState = state;
|
||||
|
||||
if (forplayer)
|
||||
AddToUpdateQueueOf(forplayer);
|
||||
AddToUpdateQueueOf(forplayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -818,16 +817,17 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET,id);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET,duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges);
|
||||
SetState(ITEM_CHANGED);
|
||||
SetState(ITEM_CHANGED, GetOwner());
|
||||
}
|
||||
|
||||
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
|
||||
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner)
|
||||
{
|
||||
if (GetEnchantmentDuration(slot) == duration)
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET,duration);
|
||||
SetState(ITEM_CHANGED);
|
||||
SetState(ITEM_CHANGED, owner);
|
||||
// Cannot use GetOwner() here, has to be passed as an argument to avoid freeze due to hashtable locking
|
||||
}
|
||||
|
||||
void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
||||
@@ -836,7 +836,7 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges);
|
||||
SetState(ITEM_CHANGED);
|
||||
SetState(ITEM_CHANGED, GetOwner());
|
||||
}
|
||||
|
||||
void Item::ClearEnchantment(EnchantmentSlot slot)
|
||||
@@ -846,7 +846,7 @@ void Item::ClearEnchantment(EnchantmentSlot slot)
|
||||
|
||||
for (uint8 x = 0; x < 3; ++x)
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + x, 0);
|
||||
SetState(ITEM_CHANGED);
|
||||
SetState(ITEM_CHANGED, GetOwner());
|
||||
}
|
||||
|
||||
bool Item::GemsFitSockets() const
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ class Item : public Object
|
||||
bool UpdateItemSuffixFactor();
|
||||
static int32 GenerateItemRandomPropertyId(uint32 item_id);
|
||||
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges);
|
||||
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration);
|
||||
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner);
|
||||
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
|
||||
void ClearEnchantment(EnchantmentSlot slot);
|
||||
uint32 GetEnchantmentId(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET);}
|
||||
|
||||
+3
-3
@@ -12558,7 +12558,7 @@ void Player::RemoveEnchantmentDurations(Item *item)
|
||||
if (itr->item == item)
|
||||
{
|
||||
// save duration in item
|
||||
item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration);
|
||||
item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration, this);
|
||||
itr = m_enchantDuration.erase(itr);
|
||||
}
|
||||
else
|
||||
@@ -12624,7 +12624,7 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat
|
||||
{
|
||||
if (itr->item == item && itr->slot == slot)
|
||||
{
|
||||
itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration);
|
||||
itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration, this);
|
||||
m_enchantDuration.erase(itr);
|
||||
break;
|
||||
}
|
||||
@@ -17456,7 +17456,7 @@ void Player::_SaveInventory()
|
||||
|
||||
// update enchantment durations
|
||||
for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr)
|
||||
itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration);
|
||||
itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration, this);
|
||||
|
||||
// if no changes
|
||||
if (m_itemUpdateQueue.empty())
|
||||
|
||||
Reference in New Issue
Block a user