From 8fcfabe784797fea46e25428492d9070adda1dc9 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Fri, 10 Jan 2014 22:39:08 +0100 Subject: 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 . --- src/server/game/Entities/Player/Player.h | 1 + src/server/game/Spells/Spell.cpp | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src/server') 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 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)) -- cgit v1.2.3 From 6f6ad952b907cdbb7d4b4e33f972d60ed2e9fdf2 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sat, 11 Jan 2014 15:23:52 +0100 Subject: Core/Wintergrasp: Fix typo in CMSG_HEARTH_AND_RESURRECT handler Fix CMSG_HEARTH_AND_RESURRECT handler trying to resurrect players with 100x hp/mana/energy ( SetHealth()/SetPower() were sanitizing the input anyway ) . --- src/server/game/Handlers/MiscHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 7405cbe538b..8b92706bd06 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -1721,7 +1721,7 @@ void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recvData*/) return; _player->BuildPlayerRepop(); - _player->ResurrectPlayer(100); + _player->ResurrectPlayer(1.0f); _player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation()); } -- cgit v1.2.3