diff options
author | Machiavelli <none@none> | 2010-03-16 01:05:56 +0100 |
---|---|---|
committer | Machiavelli <none@none> | 2010-03-16 01:05:56 +0100 |
commit | b0b17e56de08e563a7b5f15d4f19a4070c8d0dbb (patch) | |
tree | 70aebf1c4181b21a0b4e30b95f4b6b490c64a947 /src/game/Item.cpp | |
parent | 5b277b11a7d419ef2f59b7eb8220571fb4c502b4 (diff) |
- 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
Diffstat (limited to 'src/game/Item.cpp')
-rw-r--r-- | src/game/Item.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 7c2a49e10af..e08f2e2e5dc 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -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 |