aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-01-10 22:39:08 +0100
committerjackpoz <giacomopoz@gmail.com>2014-01-10 22:39:08 +0100
commit8fcfabe784797fea46e25428492d9070adda1dc9 (patch)
treee1257c39ef71f38ed5be9f4ff8222833c393dbbe /src
parent41b613186e06e3f41549912f91e68bafa3e8c059 (diff)
Core/Spells: Fix potions cooldown in combat
Fix a cooldown issue related to potions allowing Players in combat to use more than 1 potion in a row, especially with high latency. This also fixes an exploit about using infinite potions in combat just by skipping the client-side check. The original implementation c064c2e2e1eebd43b273365583dd181293bafa22 was missing a check in Spell::CheckCast() about this particular case since Potion cooldown is added only after the Player goes out of combat. Fixes #1259 .
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.h1
-rw-r--r--src/server/game/Spells/Spell.cpp4
2 files changed, 5 insertions, 0 deletions
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 457f5af8361..f04f485fa1e 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1643,6 +1643,7 @@ class Player : public Unit, public GridObject<Player>
void RemoveAllSpellCooldown();
void _LoadSpellCooldowns(PreparedQueryResult result);
void _SaveSpellCooldowns(SQLTransaction& trans);
+ uint32 GetLastPotionId() { return m_lastPotionId; }
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
void UpdatePotionCooldown(Spell* spell = NULL);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 4aedc1a95eb..49eed70f57d 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4760,6 +4760,10 @@ SpellCastResult Spell::CheckCast(bool strict)
else
return SPELL_FAILED_NOT_READY;
}
+
+ // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
+ if (m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
+ return SPELL_FAILED_NOT_READY;
}
if (m_spellInfo->AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL && !m_caster->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS))