Skip to content

Commit

Permalink
[Core/Packet] Split SMSG_CLEAR_TARGET to SpellPackets (#341)
Browse files Browse the repository at this point in the history

1

* cleanup
  • Loading branch information
leelf00 authored Sep 21, 2024
1 parent 80637c0 commit 30d1f4b
Show file tree
Hide file tree
Showing 17 changed files with 596 additions and 365 deletions.
2 changes: 1 addition & 1 deletion src/server/game/Entities/GameObject/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ void GameObject::Use(Unit* user)
}

if (spellCaster)
spellCaster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_USE);
spellCaster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LOOTING);

if (spellCaster)
spellCaster->CastSpell(user, spellInfo, triggered);
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2549,19 +2549,19 @@ namespace Trinity
};
} // namespace Trinity

void WorldObject::SendMessageToSet(WorldPacket* data, bool self)
void WorldObject::SendMessageToSet(WorldPacket const* data, bool self) const
{
if (IsInWorld())
SendMessageToSetInRange(data, GetVisibilityRange() + 2 * World::Visibility_RelocationLowerLimit, self);
}

void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/)
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/) const
{
Trinity::MessageDistDeliverer notifier(this, data, dist);
VisitNearbyWorldObject(dist, notifier, false, true);
}

void WorldObject::SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr)
void WorldObject::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const
{
Trinity::MessageDistDeliverer notifier(this, data, GetVisibilityRange() + 2 * World::Visibility_RelocationLowerLimit, false, skipped_rcvr);
VisitNearbyWorldObject(GetVisibilityRange() + 2 * World::Visibility_RelocationLowerLimit, notifier, false, true);
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/Entities/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,9 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation

virtual void CleanupsBeforeDelete(bool finalCleanup = true); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units

virtual void SendMessageToSet(WorldPacket* data, bool self);
virtual void SendMessageToSetInRange(WorldPacket* data, float dist, bool self);
virtual void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr);
virtual void SendMessageToSet(WorldPacket const* data, bool self) const;
virtual void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const;
virtual void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const;

virtual uint8 GetLevelForTarget(WorldObject const* /*target*/) const { return 1; }

Expand Down
13 changes: 7 additions & 6 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "SpellPackets.h"
#include "Transport.h"
#include "TradeData.h"
#include "UpdateData.h"
Expand Down Expand Up @@ -6740,28 +6741,28 @@ void Player::SaveRecallPosition()
m_recallO = GetOrientation();
}

void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self)
void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const
{
if (self)
GetSession()->SendPacket(data);
SendDirectMessage(data);

Trinity::MessageDistDeliverer notifier(this, data, dist);
VisitNearbyWorldObject(dist, notifier, false, true);
}

void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only)
void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only, bool required3dDist /*= false*/) const
{
if (self)
GetSession()->SendPacket(data);
SendDirectMessage(data);

Trinity::MessageDistDeliverer notifier(this, data, dist, own_team_only);
VisitNearbyWorldObject(dist, notifier, false, true);
}

void Player::SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr)
void Player::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const
{
if (skipped_rcvr != this)
GetSession()->SendPacket(data);
SendDirectMessage(data);

// we use World::GetMaxVisibleDistance() because i cannot see why not use a distance
// update: replaced by GetMap()->GetVisibilityDistance()
Expand Down
18 changes: 8 additions & 10 deletions src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of the Pandaria 5.4.8 Project. See THANKS file for Copyright information
* This file is part of the Legends of Azeroth Pandaria Project. See THANKS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand All @@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SF_PLAYER_H
#define SF_PLAYER_H
#ifndef _PLAYER_H
#define _PLAYER_H

#include "DBCStores.h"
#include "GroupReference.h"
Expand Down Expand Up @@ -2401,13 +2401,11 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override;
bool UpdatePosition(const Position &pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData) override;
void SendMessageToSet(WorldPacket* data, bool self)
{
SendMessageToSetInRange(data, GetVisibilityRange() + 2 * World::Visibility_RelocationLowerLimit, self);
};// overwrite Object::SendMessageToSet
void SendMessageToSetInRange(WorldPacket* data, float fist, bool self);// overwrite Object::SendMessageToSetInRange
void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only);
void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr);

void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange() + 2 * World::Visibility_RelocationLowerLimit, self); }
void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const override;
void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only, bool required3dDist = false) const;
void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const override;

Corpse* GetCorpse() const;
void SpawnCorpseBones(bool triggerSave = true);
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18251,7 +18251,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
creature->AI()->OnSpellClick(clicker, result);

if (result)
clicker->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_USE);
clicker->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LOOTING);

return result;
}
Expand Down
93 changes: 1 addition & 92 deletions src/server/game/Entities/Unit/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "MotionMaster.h"
#include "Object.h"
#include "SpellAuraDefines.h"
#include "SpellDefines.h"
#include "ThreatManager.h"
#include "MoveSplineInit.h"
#include "SpellMgr.h"
Expand All @@ -37,59 +38,6 @@

#define WORLD_TRIGGER 12999

enum SpellModOp
{
SPELLMOD_DAMAGE = 0,
SPELLMOD_DURATION = 1,
SPELLMOD_THREAT = 2,
SPELLMOD_EFFECT1 = 3,
SPELLMOD_CHARGES = 4,
SPELLMOD_RANGE = 5,
SPELLMOD_RADIUS = 6,
SPELLMOD_CRITICAL_CHANCE = 7,
SPELLMOD_ALL_EFFECTS = 8,
SPELLMOD_NOT_LOSE_CASTING_TIME = 9,
SPELLMOD_CASTING_TIME = 10,
SPELLMOD_COOLDOWN = 11,
SPELLMOD_EFFECT2 = 12,
SPELLMOD_IGNORE_ARMOR = 13,
SPELLMOD_COST = 14,
SPELLMOD_CRIT_DAMAGE_BONUS = 15,
SPELLMOD_RESIST_MISS_CHANCE = 16,
SPELLMOD_JUMP_TARGETS = 17,
SPELLMOD_CHANCE_OF_SUCCESS = 18,
SPELLMOD_ACTIVATION_TIME = 19,
SPELLMOD_DAMAGE_MULTIPLIER = 20,
SPELLMOD_GLOBAL_COOLDOWN = 21,
SPELLMOD_DOT = 22,
SPELLMOD_EFFECT3 = 23,
SPELLMOD_BONUS_MULTIPLIER = 24,
// spellmod 25
SPELLMOD_PROC_PER_MINUTE = 26,
SPELLMOD_VALUE_MULTIPLIER = 27,
SPELLMOD_RESIST_DISPEL_CHANCE = 28,
SPELLMOD_CRIT_DAMAGE_BONUS_2 = 29, //one not used spell
SPELLMOD_SPELL_COST_REFUND_ON_FAIL = 30,
SPELLMOD_STACK_AMOUNT = 31,
SPELLMOD_EFFECT4 = 32,
SPELLMOD_EFFECT5 = 33,
SPELLMOD_COST2 = 34,
SPELLMOD_UNK_35 = 35 // Bodyguard Visual
};

#define MAX_SPELLMOD 36

enum SpellValueMod
{
SPELLVALUE_BASE_POINT0,
SPELLVALUE_BASE_POINT1,
SPELLVALUE_BASE_POINT2,
SPELLVALUE_RADIUS_MOD,
SPELLVALUE_MAX_TARGETS,
SPELLVALUE_AURA_STACK,
SPELLVALUE_SPELL_GO_GLAGS,
};

class CustomSpellValues
{
friend class Spell;
Expand Down Expand Up @@ -121,18 +69,6 @@ class CustomSpellValues
};


enum SpellFacingFlags
{
SPELL_FACING_FLAG_INFRONT = 0x0001
};








// high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
enum ShapeshiftForm
{
Expand Down Expand Up @@ -323,33 +259,6 @@ enum AuraRemoveMode
AURA_REMOVE_BY_INTERRUPT, // interrupt flags
};

enum TriggerCastFlags
{
TRIGGERED_NONE = 0x00000000, //! Not triggered
TRIGGERED_IGNORE_GCD = 0x00000001, //! Will ignore GCD
TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD = 0x00000002, //! Will ignore Spell and Category cooldowns
TRIGGERED_IGNORE_POWER_AND_REAGENT_COST = 0x00000004, //! Will ignore power and reagent cost
TRIGGERED_IGNORE_CAST_ITEM = 0x00000008, //! Will not take away cast item or update related achievement criteria
TRIGGERED_IGNORE_AURA_SCALING = 0x00000010, //! Will ignore aura scaling
TRIGGERED_IGNORE_CAST_IN_PROGRESS = 0x00000020, //! Will not check if a current cast is in progress
TRIGGERED_IGNORE_COMBO_POINTS = 0x00000040, //! Will ignore combo point requirement
TRIGGERED_CAST_DIRECTLY = 0x00000080, //! In Spell::prepare, will be cast directly without setting containers for executed spell
TRIGGERED_IGNORE_AURA_INTERRUPT_FLAGS = 0x00000100, //! Will ignore interruptible aura's at cast
TRIGGERED_IGNORE_SET_FACING = 0x00000200, //! Will not adjust facing to target (if any)
TRIGGERED_IGNORE_SHAPESHIFT = 0x00000400, //! Will ignore shapeshift checks
TRIGGERED_IGNORE_CASTER_AURASTATE = 0x00000800, //! Will ignore caster aura states including combat requirements and death state
TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE = 0x00002000, //! Will ignore mounted/on vehicle restrictions
TRIGGERED_IGNORE_CASTER_AURAS = 0x00010000, //! Will ignore caster aura restrictions or requirements
TRIGGERED_DISALLOW_PROC_EVENTS = 0x00020000, //! Disallows proc events from triggered spell (default)
TRIGGERED_DONT_REPORT_CAST_ERROR = 0x00040000, //! Will return SPELL_FAILED_DONT_REPORT in CheckCast functions
TRIGGERED_FULL_MASK = 0x0007FFFF, //! Used when doing CastSpell with triggered == true TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT = 0x00080000, //! Will ignore equipped item requirements
TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT = 0x00080000, //! Will ignore equipped item requirements
TRIGGERED_IGNORE_TARGET_CHECK = 0x00100000, //! Will ignore most target checks (mostly DBC target checks)
TRIGGERED_IGNORE_CASTER_DEATH_STATE = 0x00200000,
TRIGGERED_FULL_DEBUG_MASK = 0xFFFFFFFF,
TRIGGERED_WITH_SPELL_START = (TRIGGERED_FULL_MASK & ~TRIGGERED_CAST_DIRECTLY),
};

enum UnitMods
{
UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existed order, it's accessed by index values of Stats enum.
Expand Down
38 changes: 31 additions & 7 deletions src/server/game/Grids/Notifiers/GridNotifiers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of the Pandaria 5.4.8 Project. See THANKS file for Copyright information
* This file is part of the Legends of Azeroth Pandaria Project. See THANKS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand Down Expand Up @@ -157,8 +157,16 @@ void MessageDistDeliverer::Visit(PlayerMapType &m)
if (!target->InSamePhase(i_phaseMask))
continue;

if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
if (required3dDist)
{
if (target->GetExactDistSq(i_source) > i_distSq)
continue;
}
else
{
if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
}

// Send packet to all who are sharing the player's vision
if (target->HasSharedVision())
Expand All @@ -182,8 +190,16 @@ void MessageDistDeliverer::Visit(CreatureMapType &m)
if (!target->InSamePhase(i_phaseMask))
continue;

if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
if (required3dDist)
{
if (target->GetExactDistSq(i_source) > i_distSq)
continue;
}
else
{
if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
}

// Send packet to all who are sharing the creature's vision
if (target->HasSharedVision())
Expand All @@ -204,8 +220,16 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m)
if (!target->InSamePhase(i_phaseMask))
continue;

if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
if (required3dDist)
{
if (target->GetExactDistSq(i_source) > i_distSq)
continue;
}
else
{
if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
}

if (Unit* caster = target->GetCaster())
{
Expand Down
22 changes: 12 additions & 10 deletions src/server/game/Grids/Notifiers/GridNotifiers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of the Pandaria 5.4.8 Project. See THANKS file for Copyright information
* This file is part of the Legends of Azeroth Pandaria Project. See THANKS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand Down Expand Up @@ -91,20 +91,23 @@ namespace Trinity
void Visit(AreaTriggerMapType &m) { updateObjects<AreaTrigger>(m); }
};

struct MessageDistDeliverer
struct TC_GAME_API MessageDistDeliverer
{
WorldObject* i_source;
WorldPacket* i_message;
WorldObject const* i_source;
WorldPacket const* i_message;
uint32 i_phaseMask;
float i_distSq;
uint32 team;
Player const* skipped_receiver;
MessageDistDeliverer(WorldObject* src, WorldPacket* msg, float dist, bool own_team_only = false, Player const* skipped = NULL)
: i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist),
team(0), skipped_receiver(skipped)
bool required3dDist;
MessageDistDeliverer(WorldObject const* src, WorldPacket const* msg, float dist, bool own_team_only = false, Player const* skipped = nullptr, bool req3dDist = false)
: i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist)
, team(0)
, skipped_receiver(skipped)
, required3dDist(req3dDist)
{
if (own_team_only)
if (Player* player = src->ToPlayer())
if (Player const* player = src->ToPlayer())
team = player->GetTeam();
}

Expand All @@ -122,8 +125,7 @@ namespace Trinity
if (!player->HaveAtClient(i_source))
return;

if (WorldSession* session = player->GetSession())
session->SendPacket(i_message);
player->SendDirectMessage(i_message);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/server/game/Server/Packets/AllPackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
#include "MiscPackets.h"
#include "QueryPackets.h"
#include "QuestPackets.h"
#include "SpellPackets.h"

#endif // AllPackets_h__
Loading

0 comments on commit 30d1f4b

Please sign in to comment.