From bb37911480995e432daf1c6dad31ccd4616c23ae Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 3 May 2009 22:27:39 -0500 Subject: [PATCH] [7751] Use more safe code to prevent DB errors at pet spells save and avoid unneded data save. Author: VladimirMangos --HG-- branch : trunk --- src/game/Pet.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 8985d648cf..0c7e3970a9 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1623,8 +1623,13 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) if (i == m_autospells.size()) { m_autospells.push_back(spellid); - itr->second->active = ACT_ENABLED; - itr->second->state = PETSPELL_CHANGED; + + if(itr->second->active != ACT_ENABLED) + { + itr->second->active = ACT_ENABLED; + if(itr->second->state != PETSPELL_NEW) + itr->second->state = PETSPELL_CHANGED; + } } } else @@ -1636,8 +1641,12 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) if (i < m_autospells.size()) { m_autospells.erase(itr2); - itr->second->active = ACT_DISABLED; - itr->second->state = PETSPELL_CHANGED; + if(itr->second->active != ACT_DISABLED) + { + itr->second->active = ACT_DISABLED; + if(itr->second->state != PETSPELL_NEW) + itr->second->state = PETSPELL_CHANGED; + } } } }