aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-02-24 15:52:09 -0300
committerariel- <ariel-@users.noreply.github.com>2018-02-24 15:52:09 -0300
commit98d6258efdc07b53808ba6177e5427c65163bc0d (patch)
tree4da8a6df66404242301889f66a544f3e9cca3f9b /src/server/game/Entities
parentbb04fbcbe85bb9f6f6c5262e9d39cf3f02a57127 (diff)
Core/Entities: kill unused return value from Unit::HandleSpellClick
- AI hook will now receive the result by copy, as modifying it had no effect - Some renaming: result->spellClickHandled, clickPair is actually clickBounds, the clickPair is the pair <creatureID, SpellClickInfo>
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Player/Player.cpp16
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp32
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp2
4 files changed, 25 insertions, 27 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 0eebe6d823a..d46f735713e 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -23284,12 +23284,12 @@ void Player::UpdateForQuestWorldObjects()
if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
continue;
- SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
- for (SpellClickInfoContainer::const_iterator _itr = clickPair.first; _itr != clickPair.second; ++_itr)
+ auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
+ for (auto const& clickPair : clickBounds)
{
//! This code doesn't look right, but it was logically converted to condition system to do the exact
//! same thing it did before. It definitely needs to be overlooked for intended functionality.
- if (ConditionContainer const* conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId))
+ if (ConditionContainer const* conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), clickPair.second.spellId))
{
bool buildUpdateBlock = false;
for (ConditionContainer::const_iterator jtr = conds->begin(); jtr != conds->end() && !buildUpdateBlock; ++jtr)
@@ -25225,16 +25225,16 @@ bool Player::CanSeeSpellClickOn(Creature const* c) const
if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
return false;
- SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(c->GetEntry());
- if (clickPair.first == clickPair.second)
+ auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(c->GetEntry());
+ if (clickBounds.begin() == clickBounds.end())
return true;
- for (SpellClickInfoContainer::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
+ for (auto const& clickPair : clickBounds)
{
- if (!itr->second.IsFitToRequirements(this, c))
+ if (!clickPair.second.IsFitToRequirements(this, c))
return false;
- if (sConditionMgr->IsObjectMeetingSpellClickConditions(c->GetEntry(), itr->second.spellId, const_cast<Player*>(this), const_cast<Creature*>(c)))
+ if (sConditionMgr->IsObjectMeetingSpellClickConditions(c->GetEntry(), clickPair.second.spellId, const_cast<Player*>(this), const_cast<Creature*>(c)))
return true;
}
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 63943db0a0e..ce611130ddc 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -13267,28 +13267,28 @@ void Unit::JumpTo(WorldObject* obj, float speedZ, bool withOrientation)
GetMotionMaster()->MoveJump(x, y, z, GetAngle(obj), speedXY, speedZ, EVENT_JUMP, withOrientation);
}
-bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
+void Unit::HandleSpellClick(Unit* clicker, int8 seatId /*= -1*/)
{
- bool result = false;
+ bool spellClickHandled = false;
uint32 spellClickEntry = GetVehicleKit() ? GetVehicleKit()->GetCreatureEntry() : GetEntry();
TriggerCastFlags const flags = GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE;
- SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(spellClickEntry);
- for (SpellClickInfoContainer::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
+ auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(spellClickEntry);
+ for (auto const& clickPair : clickBounds)
{
//! First check simple relations from clicker to clickee
- if (!itr->second.IsFitToRequirements(clicker, this))
+ if (!clickPair.second.IsFitToRequirements(clicker, this))
continue;
//! Check database conditions
- if (!sConditionMgr->IsObjectMeetingSpellClickConditions(spellClickEntry, itr->second.spellId, clicker, this))
+ if (!sConditionMgr->IsObjectMeetingSpellClickConditions(spellClickEntry, clickPair.second.spellId, clicker, this))
continue;
- Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this;
- Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this;
- ObjectGuid origCasterGUID = (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerGUID() : clicker->GetGUID();
+ Unit* caster = (clickPair.second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this;
+ Unit* target = (clickPair.second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this;
+ ObjectGuid origCasterGUID = (clickPair.second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerGUID() : clicker->GetGUID();
- SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->second.spellId);
+ SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(clickPair.second.spellId);
// if (!spellEntry) should be checked at npc_spellclick load
if (seatId > -1)
@@ -13307,7 +13307,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
if (!valid)
{
- TC_LOG_ERROR("sql.sql", "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", itr->second.spellId);
+ TC_LOG_ERROR("sql.sql", "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", clickPair.second.spellId);
continue;
}
@@ -13316,7 +13316,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
CastSpellExtraArgs args(flags);
args.OriginalCaster = origCasterGUID;
args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1);
- caster->CastSpell(target, itr->second.spellId, args);
+ caster->CastSpell(target, clickPair.second.spellId, args);
}
else // This can happen during Player::_LoadAuras
{
@@ -13336,17 +13336,15 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, nullptr, nullptr, origCasterGUID);
}
- result = true;
+ spellClickHandled = true;
}
Creature* creature = ToCreature();
if (creature && creature->IsAIEnabled)
- creature->AI()->OnSpellClick(clicker, result);
-
- return result;
+ creature->AI()->OnSpellClick(clicker, spellClickHandled);
}
-void Unit::EnterVehicle(Unit* base, int8 seatId)
+void Unit::EnterVehicle(Unit* base, int8 seatId /*= -1*/)
{
CastSpellExtraArgs args(TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE);
args.AddSpellBP0(seatId + 1);
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 2efa4aa0d87..f133013161f 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1654,7 +1654,7 @@ class TC_GAME_API Unit : public WorldObject
bool m_ControlledByPlayer;
- bool HandleSpellClick(Unit* clicker, int8 seatId = -1);
+ void HandleSpellClick(Unit* clicker, int8 seatId = -1);
void EnterVehicle(Unit* base, int8 seatId = -1);
void ExitVehicle(Position const* exitPosition = nullptr);
void ChangeSeat(int8 seatId, bool next = true);
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index af408b51422..b4fce815cc6 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -389,7 +389,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
if (minion)
accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY);
- (void)_me->HandleSpellClick(accessory, seatId);
+ _me->HandleSpellClick(accessory, seatId);
/// If for some reason adding accessory to vehicle fails it will unsummon in
/// @VehicleJoinEvent::Abort