aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2011-05-23 23:43:05 +0200
committerShauren <shauren.trinity@gmail.com>2011-05-23 23:43:05 +0200
commit171065fc4b0716e7cf8b19582fae9711091c7fd3 (patch)
treefcbbc2e19e2780f5716af18dc2ad7c8781032ad5 /src
parente879e3ec473b35784e851f96fd90d7cebe94fb75 (diff)
Scripts/Spells: Fixed crash in Druid T10 4P Restoration set bonus
Closes #1399 Closes #1507
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index f61681a838a..c2805715afa 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -224,19 +224,38 @@ class spell_dru_t10_restoration_4p_bonus : public SpellScriptLoader
{
PrepareSpellScript(spell_dru_t10_restoration_4p_bonus_SpellScript);
+ bool Load()
+ {
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER;
+ }
+
void FilterTargets(std::list<Unit*>& unitList)
{
- unitList.remove(GetTargetUnit());
- std::list<Unit*> tempTargets;
- std::list<Unit*>::iterator end = unitList.end(), itr = unitList.begin();
- for (; itr != end; ++itr)
- if (GetCaster()->IsInRaidWith(*itr))
- tempTargets.push_back(*itr);
-
- itr = tempTargets.begin();
- std::advance(itr, urand(0, tempTargets.size()-1));
- unitList.clear();
- unitList.push_back(*itr);
+ if (!GetCaster()->ToPlayer()->GetGroup())
+ {
+ unitList.clear();
+ unitList.push_back(GetCaster());
+ }
+ else
+ {
+ unitList.remove(GetTargetUnit());
+ std::list<Unit*> tempTargets;
+ for (std::list<Unit*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
+ if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith(*itr))
+ tempTargets.push_back(*itr);
+
+ if (tempTargets.empty())
+ {
+ unitList.clear();
+ FinishCast(SPELL_FAILED_DONT_REPORT);
+ return;
+ }
+
+ std::list<Unit*>::const_iterator it2 = tempTargets.begin();
+ std::advance(it2, urand(0, tempTargets.size() - 1));
+ unitList.clear();
+ unitList.push_back(*it2);
+ }
}
void Register()