server/src/game/GridNotifiers.h
Schmoozerd ae7348f6b0 [12774] Merged cmangos last changes, special thanks for xfurry, Dramacydal, cala, Schmoozerd,
I'm not taking any credits of this commit.

Implement spell effects 62042, 62278 and 64767
Also limit the targets for 62577 and 62603
----------
Update git_id to reflect recent sql formatting changes
----------
Update to a safer code version and also add GO caster scenarios
----------
Allow aura 62038 to stack at every 3 seconds
----------
Improve handling of TargetMMGen
This will have impact on Chase and Follow Movement.
----------
* Refactor code to check if a new position is required for the MMGen into the new function RequiresNewPosition
* Refactor code to get the current targeted distance into function GetDynamicTargetDistance
* Change ChaseMMGen (angle = 0.0f case) chase to best contact point, not zero angle.

Thanks to Cala and X-Savior for testing. Special thanks to cala for also suggesting improved values for the magic numbers
----------
Improve ObjectPosSelector
Now a spot already occupied by the searcher will be prefered
----------
Get rid of bounding radius in GetNearPoint[2D] and ObjectPosSelector
----------
This changes how ObjectPosSelector is used.
It changes the way how the functions Object::GetNearPoint and Object::GetNearPoint2d behave.
----------
So you need to check all places where these functions are used if they are still used correctly.
----------
Especially check your scripts!
----------
Remove not required duplicate indexes
----------
Implement TARGET_92 as TARGET_SUMMONER
This target is used only as TargetA and the related spells are used only by temporary summoned creatures
----------
Implement some spell effects used by Hodir in Ulduar
Dummy spells 62797, 63499, 63545 and 64543
Periodic dummy auras: 61968, 62038, 62039 and 65272
Limit targets for spells: 62797, 63545, 64543, 62476 and 62477
----------
Implement some spells used at Algalon encounter
Spell aura entries 64345, 62018 and 64412
Positive target exception for spell 64996
Aura stacking exception for spells 62169, 62168, 65250 and 64417
----------
Implement effect for spell 63633
----------
EventAI - Ingame output of script state
----------
With this the command .npc aiinfo will give more output about the current state.
Remark that this output is only given if the LogFilter for EventAIDev mode is disabled
----------
FindGit.cmake already ships with CMake
No reason for us to ship it too. Also, we had an outdated version which
had not been used anyway, because we set the include path in such a way,
that the CMake delivered version is always found first.
----------
FindOpenSSL.cmake already ships with CMake
No reason for us to ship it too. Also, we had an outdated version which
had not been used anyway, because we set the include path in such a way,
that the CMake delivered version is always found first.
----------
EventAI - Add more developing error output
----------
Fix some target-type handling for EventAI
Also increase log-output for bad target-types
----------
Fix crash due to bad compiler (author Xfurry)
----------
Add special condition id for Ulduar
Will be used to check the availability of the siege vehicles for players
----------
Update spells 62374 and 62907
* limit spell targets of spell 62374
* implement spell effect for spell 62907
----------
Remove effect for spell 64503
Will be handled in script library. For details please check 8502cdfa64
----------
Implement spells 64489 and 64673
Both are used by Auriaya (Ulduar)
----------
Implement some spells for Ignis the Furnace Master
Spell entries: 62717, 62381, 62488, 62707, 64475 and 64503
----------
Implement spells 61187 and 61190
----------
CMake: generic way to build a script library
Added new parameter INCLUDE_BINDINGS_DIR which can be set to the name of a
folder inside src/bindings/.

Includes the script library in src/bindings/ with the defined name.
The name must correspond to the name of the folder and the folder must contain
a valid CMakeLists.txt

Note: if you currently use a script library, you will probably get a merge
problem on src/bindings/CMakeLists.txt as you will have modified this file
manually. Please use the new version of this file and rerun CMake once with the
parameter -DINCLUDE_BINDINGS_DIR=ScriptDev2 (if you are not using SD2 but
another script library, replace ScriptDev2 with the name of the folder in
src/bindings/).

If you do not use a script library you should not have any merge problems
and you don't need to do anything.
----------
Add CMake source groups to target 'game'
This is the exact same grouping as it is currently in the VC 2012 files.
These groupings will have to be refactored at some point as they are not
very logical.
----------
Add CMake source groups to target 'framework'
This is the exact same grouping as it is currently in the VC 2012 files.
This is part of cmangos/issues#67
----------
Add CMake source groups to target 'shared'
This is the exact same grouping as it is currently in the VC 2012 files.
----------
Add new parameter 'expansion' to command 'account create'
----------
Update some Sunwell Plateau spells

Limit targets and allow positive effect for spell 46650
Implement effect for spells 46289 and 46637
Remove effect for spell 44845 - will be handled in script library
----------
Implement some custom use for Effect Activate Object spells
This will fix the summoning events for the Wind Stones, Ice Stones, Skettis bosses and quest 11865
----------
Sync mangos.sql with other versions
----------
Redump sql databases to unify formatting
The main reason for this was because classic/cata has updated the sql formatting and manually syncing would be a pain so redumping from master->tbc->classic->cata is easier.

Only the formatting was changed. The values were not changed at all.

mysqldump was used however manual modifications had to be done.

Dump the database:
C:/mysql/bin/mysqldump.exe mangos > sql/mangos.sql

Split insert values into multiple rows:
Replace "),(" with "),\n("
Replace "VALUES (" with "VALUES\n("

Remove the character sets by replacing them with an empty string

Custom formatting of mangos.sql:
Move db_version to the very top
Create all dbscripts_on_* tables based on dbscripts_on_creature_movement
Preserve our custom insert formatting of spell_affect (tbc/classic), spell_bonus_data, spell_chain, spell_elixir, spell_proc_event, spell_proc_item_enchant, spell_template, spell_threat
Remove autoincrement values from insert values of pet_name_generation and remove AUTO_INCREMENT=261 value from its table structure

Custom formatting of characters.sql:
Move character_db_version to the very top

Custom formatting of realmd.sql:
Move realmd_db_version to the very top
----------
Immediately remove corpses when ForcedDespawn is used
Thanks to Neotmiren for pointing, special thanks to cala for testing!
----------
Fix use of config values related to quest-status and level
This fixes use of negative value in config values Quests.LowLevelHideDiff and Quests.HighLevelHideDiff
Also add some documentation around the related code
Thanks to Neotmiren for pointing and to cala for testing.
----------
Loot-System: Fix reference loading check
This fixes a false error output for loot references that are only used with spell loot.
Thanks to X-Savior for properly reporting both error messages and use case
----------
Add missing spell 61437 to playercreate spells for bloodelves
Thanks to NeatElves for porting from TC and pointing to this
----------
Fix load bar step for alendarMgr::LoadCalendarsFromDB
----------
Cody Style Improvements
Also remove an unused variable (thanks to Den for this!)
----------
Implement the spells used in the Chess Event encounter
Combat spell entries: 37775, 37824, 39338, 39342, 39341, 39344, 45260
Melee spells: 37142, 37143, 37147, 37149, 37150, 37220, 37227, 37228, 37337, 37339, 37345, 37348
Chess movement spells: 30012, 32312, 37388, 30284, 37144, 37146, 37148, 37151, 37152, 37153
Aura stacking exception: 32261 and 39400
----------
And more hotfixes with these format strings
----------
Hotfix to recent text loading functions
----------
Use possible changed model names with vmap extraction
----------
Fix some warnings
----------
Store how many texts are loaded for validity checks. Use this with EventAI
----------
EventAI: Use generic DoDisplayText and loading of additional text data
----------
Add generic DoDisplayText function and use additional data of dbscripts table
----------
Add const-correctness to Text related functions
----------
Add database changes to support more data for DB Script texts
----------
Add stacking exception for spells 39993 and 40041
----------
Allow spell effect 86 - Activate Object to use the misc value
----------
Allow player pets to swim
----------
Enable resummoning of warlock pets
----------
Do not remove FLY auras on Evade
Also consider npcs which have SPELL_AURA_FLY as being able to fly
----------
EventAI: Improve code
* Drop rather pointless bool to check if the number of assigned events is empty
* Before the phase was resetted on death if and only if the npc has Events defined
* DoMeleeAttackIfReady could have been called even though combat state could have changed while processing events
----------
EventAI: Implement ACTION_T_SET_THROW_MASK (46)
This Action can be used to set which AIEvents should be thrown automatically, if you need more flexibility, you can always use the manual ACTION_TH_THROW_AI_EVENT version.
* Also clean some error-log output a bit.
----------
Forward original caster GUID to script library
----------
Fixup commit 12511 Thanks to Zakamurite for pointing
Also thanks to him for giving a helping hand in correcting the commit
----------
Implement some spells for Felmyst encounter
Spell entries: 45714, 45717 and 45918. Limit targets of spell 45391
Also add stacking exception for auras 45068 and 45582
----------
Fix invisible spirit healers & such on death near them
This fixes an issue that occurs if you die close to a spirit healer/guide.
----------
Fix take ammo for most ranged spells
Fix spells like Arcane Shot not taking ammo while they should
----------
Check cast spell 51690
----------
Fix SpellDamage modifier of SPELL_AURA_MOD_DAMAGE_DONE_CREATURE
This aura modifies a flat value, not a percent value.
----------
Implement proc effect of spells 67712, 67758
related to items 47316, 47477.
----------
Improve proc of spell 50421
----------
Add and implement server-side spell 23770
----------
EventAI: Improve TargetSelection related ErrorLog output
----------
DBScripts Engine: Change behaviour to search for a different npc when using buddy-search
With this an npc buddy will be interpreted as "another npc with entry"
Also toggle command 31 - TERMINATE_SCRIPT to also look only for other npcs of entry
----------
DBScripts Engine: Allow pets as buddy
Add new flag SCRIPT_FLAG_BUDDY_IS_PET (0x20) that will search not for a normal npc with buddy-search, but also for pets
----------
DBScripts Engine: Support buddy search by guid
* Add new `data_flags` flag SCRIPT_FLAG_BUDDY_BY_GUID (0x10)
If this flag is set, the content of `search_distance` is interpreted as db-guid of the requested buddy
* Also switch most error log output to DB-error log output (though this will include false positives)
----------
2020-02-17 09:20:48 +00:00

1280 lines
45 KiB
C++

/**
* This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
*
* 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 Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MANGOS_GRIDNOTIFIERS_H
#define MANGOS_GRIDNOTIFIERS_H
#include "ObjectGridLoader.h"
#include "UpdateData.h"
#include <iostream>
#include "Corpse.h"
#include "Object.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "Player.h"
#include "Unit.h"
namespace MaNGOS
{
struct MANGOS_DLL_DECL VisibleNotifier
{
Camera& i_camera;
UpdateData i_data;
GuidSet i_clientGUIDs;
std::set<WorldObject*> i_visibleNow;
explicit VisibleNotifier(Camera &c) : i_camera(c), i_clientGUIDs(c.GetOwner()->m_clientGUIDs), i_data(c.GetOwner()->GetMapId()) {}
template<class T> void Visit(GridRefManager<T>& m);
void Visit(CameraMapType& /*m*/) {}
void Notify(void);
};
struct MANGOS_DLL_DECL VisibleChangesNotifier
{
WorldObject& i_object;
explicit VisibleChangesNotifier(WorldObject& object) : i_object(object) {}
template<class T> void Visit(GridRefManager<T> &) {}
void Visit(CameraMapType&);
};
struct MANGOS_DLL_DECL MessageDeliverer
{
Player const& i_player;
WorldPacket* i_message;
bool i_toSelf;
MessageDeliverer(Player const& pl, WorldPacket* msg, bool to_self) : i_player(pl), i_message(msg), i_toSelf(to_self) {}
void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
};
struct MessageDelivererExcept
{
uint32 i_phaseMask;
WorldPacket* i_message;
Player const* i_skipped_receiver;
MessageDelivererExcept(WorldObject const* obj, WorldPacket* msg, Player const* skipped)
: i_phaseMask(obj->GetPhaseMask()), i_message(msg), i_skipped_receiver(skipped) {}
void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
};
struct MANGOS_DLL_DECL ObjectMessageDeliverer
{
uint32 i_phaseMask;
WorldPacket* i_message;
explicit ObjectMessageDeliverer(WorldObject const& obj, WorldPacket* msg)
: i_phaseMask(obj.GetPhaseMask()), i_message(msg) {}
void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
};
struct MANGOS_DLL_DECL MessageDistDeliverer
{
Player const& i_player;
WorldPacket* i_message;
bool i_toSelf;
bool i_ownTeamOnly;
float i_dist;
MessageDistDeliverer(Player const& pl, WorldPacket* msg, float dist, bool to_self, bool ownTeamOnly)
: i_player(pl), i_message(msg), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly), i_dist(dist) {}
void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
};
struct MANGOS_DLL_DECL ObjectMessageDistDeliverer
{
WorldObject const& i_object;
WorldPacket* i_message;
float i_dist;
ObjectMessageDistDeliverer(WorldObject const& obj, WorldPacket* msg, float dist) : i_object(obj), i_message(msg), i_dist(dist) {}
void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
};
struct MANGOS_DLL_DECL ObjectUpdater
{
uint32 i_timeDiff;
explicit ObjectUpdater(const uint32& diff) : i_timeDiff(diff) {}
template<class T> void Visit(GridRefManager<T> &m);
void Visit(PlayerMapType&) {}
void Visit(CorpseMapType&) {}
void Visit(CameraMapType&) {}
void Visit(CreatureMapType&);
};
struct MANGOS_DLL_DECL PlayerRelocationNotifier
{
Player& i_player;
PlayerRelocationNotifier(Player& pl) : i_player(pl) {}
template<class T> void Visit(GridRefManager<T> &) {}
void Visit(CreatureMapType&);
};
struct MANGOS_DLL_DECL CreatureRelocationNotifier
{
Creature& i_creature;
CreatureRelocationNotifier(Creature& c) : i_creature(c) {}
template<class T> void Visit(GridRefManager<T> &) {}
#ifdef WIN32
template<> void Visit(PlayerMapType&);
#endif
};
struct MANGOS_DLL_DECL DynamicObjectUpdater
{
DynamicObject& i_dynobject;
Unit* i_check;
bool i_positive;
DynamicObjectUpdater(DynamicObject& dynobject, Unit* caster, bool positive) : i_dynobject(dynobject), i_positive(positive)
{
i_check = caster;
Unit* owner = i_check->GetOwner();
if (owner)
i_check = owner;
}
template<class T> inline void Visit(GridRefManager<T> &) {}
#ifdef WIN32
template<> inline void Visit<Player>(PlayerMapType&);
template<> inline void Visit<Creature>(CreatureMapType&);
#endif
void VisitHelper(Unit* target);
};
// SEARCHERS & LIST SEARCHERS & WORKERS
/* Model Searcher class:
template<class Check>
struct MANGOS_DLL_DECL SomeSearcher
{
ResultType& i_result;
Check & i_check;
SomeSearcher(ResultType& result, Check & check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_result(result), i_check(check) {}
void Visit(CreatureMapType &m);
{
..some code fast return if result found
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{
if (!itr->getSource()->InSamePhase(i_phaseMask))
continue;
if (!i_check(itr->getSource()))
continue;
..some code for update result and possible stop search
}
}
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
*/
// WorldObject searchers & workers
template<class Check>
struct MANGOS_DLL_DECL WorldObjectSearcher
{
uint32 i_phaseMask;
WorldObject* &i_object;
Check& i_check;
WorldObjectSearcher(WorldObject*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(GameObjectMapType& m);
void Visit(PlayerMapType& m);
void Visit(CreatureMapType& m);
void Visit(CorpseMapType& m);
void Visit(DynamicObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Check>
struct MANGOS_DLL_DECL WorldObjectListSearcher
{
uint32 i_phaseMask;
std::list<WorldObject*> &i_objects;
Check& i_check;
WorldObjectListSearcher(std::list<WorldObject*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {}
void Visit(PlayerMapType& m);
void Visit(CreatureMapType& m);
void Visit(CorpseMapType& m);
void Visit(GameObjectMapType& m);
void Visit(DynamicObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Do>
struct MANGOS_DLL_DECL WorldObjectWorker
{
uint32 i_phaseMask;
Do const& i_do;
WorldObjectWorker(WorldObject const* searcher, Do const& _do)
: i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {}
void Visit(GameObjectMapType& m)
{
for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
void Visit(PlayerMapType& m)
{
for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
void Visit(CreatureMapType& m)
{
for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
void Visit(CorpseMapType& m)
{
for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
void Visit(DynamicObjectMapType& m)
{
for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Gameobject searchers
template<class Check>
struct MANGOS_DLL_DECL GameObjectSearcher
{
uint32 i_phaseMask;
GameObject* &i_object;
Check& i_check;
GameObjectSearcher(GameObject*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(GameObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Last accepted by Check GO if any (Check can change requirements at each call)
template<class Check>
struct MANGOS_DLL_DECL GameObjectLastSearcher
{
uint32 i_phaseMask;
GameObject* &i_object;
Check& i_check;
GameObjectLastSearcher(GameObject*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(GameObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Check>
struct MANGOS_DLL_DECL GameObjectListSearcher
{
uint32 i_phaseMask;
std::list<GameObject*> &i_objects;
Check& i_check;
GameObjectListSearcher(std::list<GameObject*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {}
void Visit(GameObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Unit searchers
// First accepted by Check Unit if any
template<class Check>
struct MANGOS_DLL_DECL UnitSearcher
{
uint32 i_phaseMask;
Unit* &i_object;
Check& i_check;
UnitSearcher(Unit*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(CreatureMapType& m);
void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Last accepted by Check Unit if any (Check can change requirements at each call)
template<class Check>
struct MANGOS_DLL_DECL UnitLastSearcher
{
uint32 i_phaseMask;
Unit* &i_object;
Check& i_check;
UnitLastSearcher(Unit*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(CreatureMapType& m);
void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// All accepted by Check units if any
template<class Check>
struct MANGOS_DLL_DECL UnitListSearcher
{
uint32 i_phaseMask;
std::list<Unit*> &i_objects;
Check& i_check;
UnitListSearcher(std::list<Unit*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {}
void Visit(PlayerMapType& m);
void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Creature searchers
template<class Check>
struct MANGOS_DLL_DECL CreatureSearcher
{
uint32 i_phaseMask;
Creature* &i_object;
Check& i_check;
CreatureSearcher(Creature*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Last accepted by Check Creature if any (Check can change requirements at each call)
template<class Check>
struct MANGOS_DLL_DECL CreatureLastSearcher
{
uint32 i_phaseMask;
Creature* &i_object;
Check& i_check;
CreatureLastSearcher(Creature*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Check>
struct MANGOS_DLL_DECL CreatureListSearcher
{
uint32 i_phaseMask;
std::list<Creature*> &i_objects;
Check& i_check;
CreatureListSearcher(std::list<Creature*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {}
void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Do>
struct MANGOS_DLL_DECL CreatureWorker
{
uint32 i_phaseMask;
Do& i_do;
CreatureWorker(WorldObject const* searcher, Do& _do)
: i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {}
void Visit(CreatureMapType& m)
{
for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// Player searchers
template<class Check>
struct MANGOS_DLL_DECL PlayerSearcher
{
uint32 i_phaseMask;
Player* &i_object;
Check& i_check;
PlayerSearcher(Player*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Check>
struct MANGOS_DLL_DECL PlayerListSearcher
{
uint32 i_phaseMask;
std::list<Player*> &i_objects;
Check& i_check;
PlayerListSearcher(std::list<Player*> &objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {}
void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Do>
struct MANGOS_DLL_DECL PlayerWorker
{
uint32 i_phaseMask;
Do& i_do;
PlayerWorker(WorldObject const* searcher, Do& _do)
: i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {}
void Visit(PlayerMapType& m)
{
for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource());
}
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Do>
struct MANGOS_DLL_DECL CameraDistWorker
{
WorldObject const* i_searcher;
float i_dist;
Do& i_do;
CameraDistWorker(WorldObject const* searcher, float _dist, Do& _do)
: i_searcher(searcher), i_dist(_dist), i_do(_do) {}
void Visit(CameraMapType& m)
{
for (CameraMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->GetBody()->InSamePhase(i_searcher) && itr->getSource()->GetBody()->IsWithinDist(i_searcher, i_dist))
i_do(itr->getSource()->GetOwner());
}
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
// CHECKS && DO classes
/* Model Check class:
class SomeCheck
{
public:
SomeCheck(SomeObjecType const* fobj, ..some other args) : i_fobj(fobj), ...other inits {}
WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Creature* u) and for other intresting typs (Player/GameObject/Camera
{
return ..(code return true if Object fit to requirenment);
}
template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
private:
SomeObjecType const* i_fobj; // Focus object used for check distance from, phase, so place in world
..other values need for check
};
*/
// WorldObject check classes
class RaiseDeadObjectCheck
{
public:
RaiseDeadObjectCheck(Player const* fobj, float range) : i_fobj(fobj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Creature* u)
{
if (i_fobj->isHonorOrXPTarget(u) ||
u->getDeathState() != CORPSE || u->IsDeadByDefault() || u->IsTaxiFlying() ||
(u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID - 1))) == 0 ||
(u->GetDisplayId() != u->GetNativeDisplayId()))
return false;
return i_fobj->IsWithinDistInMap(u, i_range);
}
template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
private:
Player const* i_fobj;
float i_range;
};
class ExplodeCorpseObjectCheck
{
public:
ExplodeCorpseObjectCheck(WorldObject const* fobj, float range) : i_fobj(fobj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Player* u)
{
if (u->getDeathState() != CORPSE || u->IsTaxiFlying() ||
u->HasAuraType(SPELL_AURA_GHOST) || (u->GetDisplayId() != u->GetNativeDisplayId()))
return false;
return i_fobj->IsWithinDistInMap(u, i_range);
}
bool operator()(Creature* u)
{
if (u->getDeathState() != CORPSE || u->IsTaxiFlying() || u->IsDeadByDefault() ||
(u->GetDisplayId() != u->GetNativeDisplayId()) ||
(u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL) != 0)
return false;
return i_fobj->IsWithinDistInMap(u, i_range);
}
template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
private:
WorldObject const* i_fobj;
float i_range;
};
class CannibalizeObjectCheck
{
public:
CannibalizeObjectCheck(WorldObject const* fobj, float range) : i_fobj(fobj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Player* u)
{
if (i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying())
return false;
return i_fobj->IsWithinDistInMap(u, i_range);
}
bool operator()(Corpse* u);
bool operator()(Creature* u)
{
if (i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying() ||
(u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0)
return false;
return i_fobj->IsWithinDistInMap(u, i_range);
}
template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; }
private:
WorldObject const* i_fobj;
float i_range;
};
// WorldObject do classes
class RespawnDo
{
public:
RespawnDo() {}
void operator()(Creature* u) const;
void operator()(GameObject* u) const;
void operator()(WorldObject*) const {}
void operator()(Corpse*) const {}
};
// GameObject checks
class GameObjectFocusCheck
{
public:
GameObjectFocusCheck(Unit const* unit, uint32 focusId) : i_unit(unit), i_focusId(focusId) {}
WorldObject const& GetFocusObject() const { return *i_unit; }
bool operator()(GameObject* go) const
{
if (go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS)
return false;
if (go->GetGOInfo()->spellFocus.focusId != i_focusId)
return false;
float dist = (float)go->GetGOInfo()->spellFocus.dist;
return go->IsWithinDistInMap(i_unit, dist);
}
private:
Unit const* i_unit;
uint32 i_focusId;
};
// Find the nearest Fishing hole and return true only if source object is in range of hole
class NearestGameObjectFishingHoleCheck
{
public:
NearestGameObjectFishingHoleCheck(WorldObject const& obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go)
{
if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, (float)go->GetGOInfo()->fishinghole.radius))
{
i_range = i_obj.GetDistance(go);
return true;
}
return false;
}
float GetLastRange() const { return i_range; }
private:
WorldObject const& i_obj;
float i_range;
// prevent clone
NearestGameObjectFishingHoleCheck(NearestGameObjectFishingHoleCheck const&);
};
// Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO)
class NearestGameObjectEntryInObjectRangeCheck
{
public:
NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go)
{
if (go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range))
{
i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
return true;
}
return false;
}
float GetLastRange() const { return i_range; }
private:
WorldObject const& i_obj;
uint32 i_entry;
float i_range;
// prevent clone this object
NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&);
};
// Success at gameobject in range of xyz, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO)
class NearestGameObjectEntryInPosRangeCheck
{
public:
NearestGameObjectEntryInPosRangeCheck(WorldObject const& obj, uint32 entry, float x, float y, float z, float range)
: i_obj(obj), i_entry(entry), i_x(x), i_y(y), i_z(z), i_range(range) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go)
{
if (go->GetEntry() == i_entry && go->IsWithinDist3d(i_x, i_y, i_z, i_range))
{
// use found GO range as new range limit for next check
i_range = go->GetDistance(i_x, i_y, i_z);
return true;
}
return false;
}
float GetLastRange() const { return i_range; }
private:
WorldObject const& i_obj;
uint32 i_entry;
float i_x, i_y, i_z;
float i_range;
// prevent clone this object
NearestGameObjectEntryInPosRangeCheck(NearestGameObjectEntryInPosRangeCheck const&);
};
// Success at gameobject with entry in range of provided xyz
class GameObjectEntryInPosRangeCheck
{
public:
GameObjectEntryInPosRangeCheck(WorldObject const& obj, uint32 entry, float x, float y, float z, float range)
: i_obj(obj), i_entry(entry), i_x(x), i_y(y), i_z(z), i_range(range) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go)
{
if (go->GetEntry() == i_entry && go->IsWithinDist3d(i_x, i_y, i_z, i_range))
return true;
return false;
}
float GetLastRange() const { return i_range; }
private:
WorldObject const& i_obj;
uint32 i_entry;
float i_x, i_y, i_z;
float i_range;
// prevent clone this object
GameObjectEntryInPosRangeCheck(GameObjectEntryInPosRangeCheck const&);
};
// Success at gameobject of type in range of provided xyz
class GameObjectTypeInPosRangeCheck
{
public:
GameObjectTypeInPosRangeCheck(Unit const& obj, GameobjectTypes type, float x, float y, float z, float range, bool onlyHostile, bool onlyFriendly)
: i_obj(obj), i_type(type), i_x(x), i_y(y), i_z(z), i_range(range), i_onlyHostile(onlyHostile), i_onlyFriendly(onlyFriendly) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go)
{
if (go->GetGoType() == i_type
&& (!i_onlyHostile || go->IsHostileTo(&i_obj)) && (!i_onlyFriendly || go->IsFriendlyTo(&i_obj))
&& go->IsWithinDist3d(i_x, i_y, i_z, i_range))
return true;
return false;
}
float GetLastRange() const { return i_range; }
private:
Unit const& i_obj;
GameobjectTypes i_type;
float i_x, i_y, i_z;
float i_range;
bool i_onlyHostile, i_onlyFriendly;
// prevent clone this object
GameObjectTypeInPosRangeCheck(GameObjectTypeInPosRangeCheck const&);
};
// Unit checks
class MostHPMissingInRangeCheck
{
public:
MostHPMissingInRangeCheck(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
{
i_hp = u->GetMaxHealth() - u->GetHealth();
return true;
}
return false;
}
private:
Unit const* i_obj;
float i_range;
uint32 i_hp;
};
class FriendlyCCedInRangeCheck
{
public:
FriendlyCCedInRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
(u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_CAN_NOT_REACT)))
{
return true;
}
return false;
}
private:
WorldObject const* i_obj;
float i_range;
};
class FriendlyMissingBuffInRangeCheck
{
public:
FriendlyMissingBuffInRangeCheck(WorldObject const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
!(u->HasAura(i_spell, EFFECT_INDEX_0) || u->HasAura(i_spell, EFFECT_INDEX_1) || u->HasAura(i_spell, EFFECT_INDEX_2)))
{
return true;
}
return false;
}
private:
WorldObject const* i_obj;
float i_range;
uint32 i_spell;
};
class AnyUnfriendlyUnitInObjectRangeCheck
{
public:
AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range)
{
i_controlledByPlayer = obj->IsControlledByPlayer();
}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isAlive() && (i_controlledByPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u))
&& i_obj->IsWithinDistInMap(u, i_range))
return true;
else
return false;
}
private:
WorldObject const* i_obj;
bool i_controlledByPlayer;
float i_range;
};
class AnyUnfriendlyVisibleUnitInObjectRangeCheck
{
public:
AnyUnfriendlyVisibleUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range)
: i_obj(obj), i_funit(funit), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
return u->isAlive()
&& i_obj->IsWithinDistInMap(u, i_range)
&& !i_funit->IsFriendlyTo(u)
&& u->isVisibleForOrDetect(i_funit, i_funit, false);
}
private:
WorldObject const* i_obj;
Unit const* i_funit;
float i_range;
};
class AnyFriendlyUnitInObjectRangeCheck
{
public:
AnyFriendlyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsFriendlyTo(u))
return true;
else
return false;
}
private:
WorldObject const* i_obj;
float i_range;
};
class AnyUnitInObjectRangeCheck
{
public:
AnyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range))
return true;
return false;
}
private:
WorldObject const* i_obj;
float i_range;
};
// Success at unit in range, range update for next check (this can be use with UnitLastSearcher to find nearest unit)
class NearestAttackableUnitInObjectRangeCheck
{
public:
NearestAttackableUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
if (u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) &&
!i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit, i_funit, false))
{
i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
return true;
}
return false;
}
private:
WorldObject const* i_obj;
Unit const* i_funit;
float i_range;
// prevent clone this object
NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&);
};
class AnyAoEVisibleTargetUnitInObjectRangeCheck
{
public:
AnyAoEVisibleTargetUnitInObjectRangeCheck(WorldObject const* obj, WorldObject const* originalCaster, float range)
: i_obj(obj), i_originalCaster(originalCaster), i_range(range)
{
i_targetForUnit = i_originalCaster->isType(TYPEMASK_UNIT);
i_targetForPlayer = (i_originalCaster->GetTypeId() == TYPEID_PLAYER);
}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
// Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems
if (!u->isTargetableForAttack())
return false;
// ignore totems as AoE targets
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem())
return false;
// check visibility only for unit-like original casters
if (i_targetForUnit && !u->isVisibleForOrDetect((Unit const*)i_originalCaster, i_originalCaster, false))
return false;
if ((i_targetForPlayer ? !i_originalCaster->IsFriendlyTo(u) : i_originalCaster->IsHostileTo(u)) && i_obj->IsWithinDistInMap(u, i_range))
return true;
return false;
}
private:
WorldObject const* i_obj;
WorldObject const* i_originalCaster;
float i_range;
bool i_targetForUnit;
bool i_targetForPlayer;
};
class AnyAoETargetUnitInObjectRangeCheck
{
public:
AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, float range)
: i_obj(obj), i_range(range)
{
i_targetForPlayer = i_obj->IsControlledByPlayer();
}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
// Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems
if (!u->isTargetableForAttack())
return false;
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem())
return false;
if ((i_targetForPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u)) && i_obj->IsWithinDistInMap(u, i_range))
return true;
return false;
}
private:
WorldObject const* i_obj;
float i_range;
bool i_targetForPlayer;
};
// do attack at call of help to friendly crearture
class CallOfHelpCreatureInRangeDo
{
public:
CallOfHelpCreatureInRangeDo(Unit* funit, Unit* enemy, float range)
: i_funit(funit), i_enemy(enemy), i_range(range)
{}
void operator()(Creature* u);
private:
Unit* const i_funit;
Unit* const i_enemy;
float i_range;
};
class AnyDeadUnitCheck
{
public:
explicit AnyDeadUnitCheck(WorldObject const* fobj) : i_fobj(fobj) {}
WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Unit* u) { return !u->isAlive(); }
private:
WorldObject const* i_fobj;
};
class AnyStealthedCheck
{
public:
explicit AnyStealthedCheck(WorldObject const* fobj) : i_fobj(fobj) {}
WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Unit* u) { return u->GetVisibility() == VISIBILITY_GROUP_STEALTH; }
private:
WorldObject const* i_fobj;
};
// Creature checks
class InAttackDistanceFromAnyHostileCreatureCheck
{
public:
explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {}
WorldObject const& GetFocusObject() const { return *i_funit; }
bool operator()(Creature* u)
{
if (u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit)))
return true;
return false;
}
private:
Unit* const i_funit;
};
class AnyAssistCreatureInRangeCheck
{
public:
AnyAssistCreatureInRangeCheck(Unit* funit, Unit* enemy, float range)
: i_funit(funit), i_enemy(enemy), i_range(range)
{
}
WorldObject const& GetFocusObject() const { return *i_funit; }
bool operator()(Creature* u);
private:
Unit* const i_funit;
Unit* const i_enemy;
float i_range;
};
class NearestAssistCreatureInCreatureRangeCheck
{
public:
NearestAssistCreatureInCreatureRangeCheck(Creature* obj, Unit* enemy, float range)
: i_obj(obj), i_enemy(enemy), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Creature* u)
{
if (u == i_obj)
return false;
if (!u->CanAssistTo(i_obj, i_enemy))
return false;
if (!i_obj->IsWithinDistInMap(u, i_range))
return false;
if (!i_obj->IsWithinLOSInMap(u))
return false;
i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
return true;
}
float GetLastRange() const { return i_range; }
private:
Creature* const i_obj;
Unit* const i_enemy;
float i_range;
// prevent clone this object
NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&);
};
// Success at unit in range, range update for next check (this can be use with CreatureLastSearcher to find nearest creature)
class NearestCreatureEntryWithLiveStateInObjectRangeCheck
{
public:
NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj, uint32 entry, bool onlyAlive, bool onlyDead, float range, bool excludeSelf = false)
: i_obj(obj), i_entry(entry), i_onlyAlive(onlyAlive), i_onlyDead(onlyDead), i_excludeSelf(excludeSelf), i_range(range) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(Creature* u)
{
if (u->GetEntry() == i_entry && ((i_onlyAlive && u->isAlive()) || (i_onlyDead && u->IsCorpse()) || (!i_onlyAlive && !i_onlyDead))
&& (!i_excludeSelf || &i_obj != u) && i_obj.IsWithinDistInMap(u, i_range))
{
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
return true;
}
return false;
}
float GetLastRange() const { return i_range; }
private:
WorldObject const& i_obj;
uint32 i_entry;
bool i_onlyAlive;
bool i_onlyDead;
bool i_excludeSelf;
float i_range;
// prevent clone this object
NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&);
};
class AllCreaturesOfEntryInRangeCheck
{
public:
AllCreaturesOfEntryInRangeCheck(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
WorldObject const& GetFocusObject() const { return *m_pObject; }
bool operator()(Unit* pUnit)
{
if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit, m_fRange, false))
return true;
return false;
}
private:
const WorldObject* m_pObject;
uint32 m_uiEntry;
float m_fRange;
// prevent clone this object
AllCreaturesOfEntryInRangeCheck(AllCreaturesOfEntryInRangeCheck const&);
};
// Player checks and do
class AnyPlayerInObjectRangeCheck
{
public:
AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Player* u)
{
if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range))
return true;
return false;
}
private:
WorldObject const* i_obj;
float i_range;
};
class AnyPlayerInObjectRangeWithAuraCheck
{
public:
AnyPlayerInObjectRangeWithAuraCheck(WorldObject const* obj, float range, uint32 spellId)
: i_obj(obj), i_range(range), i_spellId(spellId) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Player* u)
{
return u->isAlive()
&& i_obj->IsWithinDistInMap(u, i_range)
&& u->HasAura(i_spellId);
}
private:
WorldObject const* i_obj;
float i_range;
uint32 i_spellId;
};
class AnyPlayerInCapturePointRange
{
public:
AnyPlayerInCapturePointRange(WorldObject const* obj, float range)
: i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Player* u)
{
return u->CanUseCapturePoint() &&
i_obj->IsWithinDistInMap(u, i_range);
}
private:
WorldObject const* i_obj;
float i_range;
};
// Prepare using Builder localized packets with caching and send to player
template<class Builder>
class LocalizedPacketDo
{
public:
explicit LocalizedPacketDo(Builder& builder) : i_builder(builder) {}
~LocalizedPacketDo()
{
for (size_t i = 0; i < i_data_cache.size(); ++i)
delete i_data_cache[i];
}
void operator()(Player* p);
private:
Builder& i_builder;
std::vector<WorldPacket*> i_data_cache; // 0 = default, i => i-1 locale index
};
// Prepare using Builder localized packets with caching and send to player
template<class Builder>
class LocalizedPacketListDo
{
public:
typedef std::vector<WorldPacket*> WorldPacketList;
explicit LocalizedPacketListDo(Builder& builder) : i_builder(builder) {}
~LocalizedPacketListDo()
{
for (size_t i = 0; i < i_data_cache.size(); ++i)
for (size_t j = 0; j < i_data_cache[i].size(); ++j)
delete i_data_cache[i][j];
}
void operator()(Player* p);
private:
Builder& i_builder;
std::vector<WorldPacketList> i_data_cache;
// 0 = default, i => i-1 locale index
};
#ifndef WIN32
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType&);
template<> void CreatureRelocationNotifier::Visit<Player>(PlayerMapType&);
template<> void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType&);
template<> inline void DynamicObjectUpdater::Visit<Creature>(CreatureMapType&);
template<> inline void DynamicObjectUpdater::Visit<Player>(PlayerMapType&);
#endif
}
#endif