AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
anonymous_namespace{AllMapScript.cpp} Namespace Reference

Functions

template<class ScriptName >
void ForeachMaps (Map *map, std::function< void(ScriptName *)> const &executeHook)
 

Function Documentation

◆ ForeachMaps()

template<class ScriptName >
void anonymous_namespace{AllMapScript.cpp}::ForeachMaps ( Map map,
std::function< void(ScriptName *)> const &  executeHook 
)
30 {
31 auto mapEntry = map->GetEntry();
32 if (!mapEntry)
33 {
34 return;
35 }
36
37 if constexpr (std::is_same_v<ScriptName, WorldMapScript>)
38 {
39 if (!mapEntry->IsWorldMap())
40 {
41 return;
42 }
43 }
44 else if constexpr (std::is_same_v<ScriptName, InstanceMapScript>)
45 {
46 if (!mapEntry->IsDungeon())
47 {
48 return;
49 }
50 }
51 else if constexpr (std::is_same_v<ScriptName, BattlegroundMapScript>)
52 {
53 if (!mapEntry->IsBattleground())
54 {
55 return;
56 }
57 }
58 else
59 {
60 static_assert(Acore::dependant_false_v<ScriptName>, "Unsupported type used for ForeachMaps");
61 }
62
64 {
65 return;
66 }
67
68 for (auto const& [scriptID, script] : ScriptRegistry<ScriptName>::ScriptPointerList)
69 {
70 auto const scriptEntry = script->GetEntry();
71 if (!scriptEntry)
72 {
73 continue;
74 }
75
76 if (scriptEntry->MapID != map->GetId())
77 {
78 continue;
79 }
80
81 executeHook(script);
82 return;
83 }
84 }
MapEntry const * GetEntry() const
Definition: Map.h:317
uint32 GetId() const
Definition: Map.h:377
Definition: ScriptMgr.h:713

References Map::GetEntry(), and Map::GetId().