Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
GridNotifiersImpl.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SKYFIRE_GRIDNOTIFIERSIMPL_H
7#define SKYFIRE_GRIDNOTIFIERSIMPL_H
8
9#include "Corpse.h"
10#include "CreatureAI.h"
11#include "GridNotifiers.h"
12#include "Opcodes.h"
13#include "Player.h"
14#include "SpellAuras.h"
15#include "UpdateData.h"
16#include "WorldPacket.h"
17
18template<class T>
20{
21 for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
22 {
23 vis_guids.erase(iter->GetSource()->GetGUID());
24 i_player.UpdateVisibilityOf(iter->GetSource(), i_data, i_visibleNow);
25 }
26}
27
28// SEARCHERS & LIST SEARCHERS & WORKERS
29
30// WorldObject searchers & workers
31
32template<class Check>
34{
36 return;
37
38 // already found
39 if (i_object)
40 return;
41
42 for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
43 {
44 if (!itr->GetSource()->InSamePhase(i_phaseMask))
45 continue;
46
47 if (i_check(itr->GetSource()))
48 {
49 i_object = itr->GetSource();
50 return;
51 }
52 }
53}
54
55template<class Check>
57{
59 return;
60
61 // already found
62 if (i_object)
63 return;
64
65 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
66 {
67 if (!itr->GetSource()->InSamePhase(i_phaseMask))
68 continue;
69
70 if (i_check(itr->GetSource()))
71 {
72 i_object = itr->GetSource();
73 return;
74 }
75 }
76}
77
78template<class Check>
80{
82 return;
83
84 // already found
85 if (i_object)
86 return;
87
88 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
89 {
90 if (!itr->GetSource()->InSamePhase(i_phaseMask))
91 continue;
92
93 if (i_check(itr->GetSource()))
94 {
95 i_object = itr->GetSource();
96 return;
97 }
98 }
99}
100
101template<class Check>
103{
105 return;
106
107 // already found
108 if (i_object)
109 return;
110
111 for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
112 {
113 if (!itr->GetSource()->InSamePhase(i_phaseMask))
114 continue;
115
116 if (i_check(itr->GetSource()))
117 {
118 i_object = itr->GetSource();
119 return;
120 }
121 }
122}
123
124template<class Check>
126{
128 return;
129
130 // already found
131 if (i_object)
132 return;
133
134 for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
135 {
136 if (!itr->GetSource()->InSamePhase(i_phaseMask))
137 continue;
138
139 if (i_check(itr->GetSource()))
140 {
141 i_object = itr->GetSource();
142 return;
143 }
144 }
145}
146
147template<class Check>
149{
151 return;
152
153 // already found
154 if (i_object)
155 return;
156
157 for (AreaTriggerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
158 {
159 if (!itr->GetSource()->InSamePhase(i_phaseMask))
160 continue;
161
162 if (i_check(itr->GetSource()))
163 {
164 i_object = itr->GetSource();
165 return;
166 }
167 }
168}
169
170template<class Check>
172{
174 return;
175
176 for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
177 {
178 if (!itr->GetSource()->InSamePhase(i_phaseMask))
179 continue;
180
181 if (i_check(itr->GetSource()))
182 i_object = itr->GetSource();
183 }
184}
185
186template<class Check>
188{
190 return;
191
192 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
193 {
194 if (!itr->GetSource()->InSamePhase(i_phaseMask))
195 continue;
196
197 if (i_check(itr->GetSource()))
198 i_object = itr->GetSource();
199 }
200}
201
202template<class Check>
204{
206 return;
207
208 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
209 {
210 if (!itr->GetSource()->InSamePhase(i_phaseMask))
211 continue;
212
213 if (i_check(itr->GetSource()))
214 i_object = itr->GetSource();
215 }
216}
217
218template<class Check>
220{
222 return;
223
224 for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
225 {
226 if (!itr->GetSource()->InSamePhase(i_phaseMask))
227 continue;
228
229 if (i_check(itr->GetSource()))
230 i_object = itr->GetSource();
231 }
232}
233
234template<class Check>
236{
238 return;
239
240 for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
241 {
242 if (!itr->GetSource()->InSamePhase(i_phaseMask))
243 continue;
244
245 if (i_check(itr->GetSource()))
246 i_object = itr->GetSource();
247 }
248}
249
250template<class Check>
252{
254 return;
255
256 for (AreaTriggerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
257 {
258 if (!itr->GetSource()->InSamePhase(i_phaseMask))
259 continue;
260
261 if (i_check(itr->GetSource()))
262 i_object = itr->GetSource();
263 }
264}
265
266template<class Check>
268{
270 return;
271
272 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
273 if (i_check(itr->GetSource()))
274 i_objects.push_back(itr->GetSource());
275}
276
277template<class Check>
279{
281 return;
282
283 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
284 if (i_check(itr->GetSource()))
285 i_objects.push_back(itr->GetSource());
286}
287
288template<class Check>
290{
292 return;
293
294 for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
295 if (i_check(itr->GetSource()))
296 i_objects.push_back(itr->GetSource());
297}
298
299template<class Check>
301{
303 return;
304
305 for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
306 if (i_check(itr->GetSource()))
307 i_objects.push_back(itr->GetSource());
308}
309
310template<class Check>
312{
314 return;
315
316 for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
317 if (i_check(itr->GetSource()))
318 i_objects.push_back(itr->GetSource());
319}
320
321template<class Check>
323{
325 return;
326
327 for (AreaTriggerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
328 if (i_check(itr->GetSource()))
329 i_objects.push_back(itr->GetSource());
330}
331
332// Gameobject searchers
333
334template<class Check>
336{
337 // already found
338 if (i_object)
339 return;
340
341 for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
342 {
343 if (!itr->GetSource()->InSamePhase(i_phaseMask))
344 continue;
345
346 if (i_check(itr->GetSource()))
347 {
348 i_object = itr->GetSource();
349 return;
350 }
351 }
352}
353
354template<class Check>
356{
357 for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
358 {
359 if (!itr->GetSource()->InSamePhase(i_phaseMask))
360 continue;
361
362 if (i_check(itr->GetSource()))
363 i_object = itr->GetSource();
364 }
365}
366
367template<class Check>
369{
370 for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
371 if (itr->GetSource()->InSamePhase(i_phaseMask))
372 if (i_check(itr->GetSource()))
373 i_objects.push_back(itr->GetSource());
374}
375
376// Unit searchers
377
378template<class Check>
380{
381 // already found
382 if (i_object)
383 return;
384
385 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
386 {
387 if (!itr->GetSource()->InSamePhase(i_phaseMask))
388 continue;
389
390 if (i_check(itr->GetSource()))
391 {
392 i_object = itr->GetSource();
393 return;
394 }
395 }
396}
397
398template<class Check>
400{
401 // already found
402 if (i_object)
403 return;
404
405 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
406 {
407 if (!itr->GetSource()->InSamePhase(i_phaseMask))
408 continue;
409
410 if (i_check(itr->GetSource()))
411 {
412 i_object = itr->GetSource();
413 return;
414 }
415 }
416}
417
418template<class Check>
420{
421 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
422 {
423 if (!itr->GetSource()->InSamePhase(i_phaseMask))
424 continue;
425
426 if (i_check(itr->GetSource()))
427 i_object = itr->GetSource();
428 }
429}
430
431template<class Check>
433{
434 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
435 {
436 if (!itr->GetSource()->InSamePhase(i_phaseMask))
437 continue;
438
439 if (i_check(itr->GetSource()))
440 i_object = itr->GetSource();
441 }
442}
443
444template<class Check>
446{
447 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
448 if (itr->GetSource()->InSamePhase(i_phaseMask))
449 if (i_check(itr->GetSource()))
450 i_objects.push_back(itr->GetSource());
451}
452
453template<class Check>
455{
456 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
457 if (itr->GetSource()->InSamePhase(i_phaseMask))
458 if (i_check(itr->GetSource()))
459 i_objects.push_back(itr->GetSource());
460}
461
462// Creature searchers
463
464template<class Check>
466{
467 // already found
468 if (i_object)
469 return;
470
471 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
472 {
473 if (!itr->GetSource()->InSamePhase(i_phaseMask))
474 continue;
475
476 if (i_check(itr->GetSource()))
477 {
478 i_object = itr->GetSource();
479 return;
480 }
481 }
482}
483
484template<class Check>
486{
487 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
488 {
489 if (!itr->GetSource()->InSamePhase(i_phaseMask))
490 continue;
491
492 if (i_check(itr->GetSource()))
493 i_object = itr->GetSource();
494 }
495}
496
497template<class Check>
499{
500 for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
501 if (itr->GetSource()->InSamePhase(i_phaseMask))
502 if (i_check(itr->GetSource()))
503 i_objects.push_back(itr->GetSource());
504}
505
506template<class Check>
508{
509 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
510 if (itr->GetSource()->InSamePhase(i_phaseMask))
511 if (i_check(itr->GetSource()))
512 i_objects.push_back(itr->GetSource());
513}
514
515template<class Check>
517{
518 // already found
519 if (i_object)
520 return;
521
522 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
523 {
524 if (!itr->GetSource()->InSamePhase(i_phaseMask))
525 continue;
526
527 if (i_check(itr->GetSource()))
528 {
529 i_object = itr->GetSource();
530 return;
531 }
532 }
533}
534
535template<class Check>
537{
538 for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
539 {
540 if (!itr->GetSource()->InSamePhase(i_phaseMask))
541 continue;
542
543 if (i_check(itr->GetSource()))
544 i_object = itr->GetSource();
545 }
546}
547
548template<class Builder>
550{
552 uint32 cache_idx = loc_idx + 1;
553 WorldPacket* data;
554
555 // create if not cached yet
556 if (i_data_cache.size() < cache_idx + 1 || !i_data_cache[cache_idx])
557 {
558 if (i_data_cache.size() < cache_idx + 1)
559 i_data_cache.resize(cache_idx + 1);
560
561 data = new WorldPacket();
562
563 i_builder(*data, loc_idx);
564
565 //ASSERT(data->GetOpcode() != MSG_NULL_ACTION); // ???
566
567 i_data_cache[cache_idx] = data;
568 }
569 else
570 data = i_data_cache[cache_idx];
571
572 p->SendDirectMessage(data);
573}
574
575template<class Builder>
577{
579 uint32 cache_idx = loc_idx + 1;
580 WorldPacketList* data_list;
581
582 // create if not cached yet
583 if (i_data_cache.size() < cache_idx + 1 || i_data_cache[cache_idx].empty())
584 {
585 if (i_data_cache.size() < cache_idx + 1)
586 i_data_cache.resize(cache_idx + 1);
587
588 data_list = &i_data_cache[cache_idx];
589
590 i_builder(*data_list, loc_idx);
591 }
592 else
593 data_list = &i_data_cache[cache_idx];
594
595 for (size_t i = 0; i < data_list->size(); ++i)
596 p->SendDirectMessage((*data_list)[i]);
597}
598
599#endif // SKYFIRE_GRIDNOTIFIERSIMPL_H
LocaleConstant
Definition Common.h:138
std::uint32_t uint32
Definition Define.h:77
GridRefManager< Corpse > CorpseMapType
Definition GridDefines.h:50
GridRefManager< DynamicObject > DynamicObjectMapType
Definition GridDefines.h:52
GridRefManager< Creature > CreatureMapType
Definition GridDefines.h:51
GridRefManager< Player > PlayerMapType
Definition GridDefines.h:54
GridRefManager< AreaTrigger > AreaTriggerMapType
Definition GridDefines.h:55
@ GRID_MAP_TYPE_MASK_PLAYER
Definition GridDefines.h:63
@ GRID_MAP_TYPE_MASK_CREATURE
Definition GridDefines.h:60
@ GRID_MAP_TYPE_MASK_GAMEOBJECT
Definition GridDefines.h:62
@ GRID_MAP_TYPE_MASK_DYNAMICOBJECT
Definition GridDefines.h:61
@ GRID_MAP_TYPE_MASK_CORPSE
Definition GridDefines.h:59
@ GRID_MAP_TYPE_MASK_AREATRIGGER
Definition GridDefines.h:64
GridRefManager< GameObject > GameObjectMapType
Definition GridDefines.h:53
LinkedListHead::Iterator< GridReference< OBJECT > > iterator
iterator begin()
void SendDirectMessage(WorldPacket *data)
Definition Player.cpp:6904
WorldSession * GetSession() const
Definition Player.h:2417
std::vector< WorldPacket * > i_data_cache
std::vector< WorldPacket * > WorldPacketList
std::vector< WorldPacketList > i_data_cache
LocaleConstant GetSessionDbLocaleIndex() const
void Visit(CreatureMapType &m)
std::list< Creature * > & i_objects
void Visit(CreatureMapType &m)
void Visit(CreatureMapType &m)
void Visit(GameObjectMapType &m)
std::list< GameObject * > & i_objects
void Visit(GameObjectMapType &m)
void Visit(GameObjectMapType &m)
void Visit(PlayerMapType &m)
void Visit(PlayerMapType &m)
std::list< Player * > & i_objects
void Visit(PlayerMapType &m)
void Visit(CreatureMapType &m)
void Visit(PlayerMapType &m)
std::list< Unit * > & i_objects
void Visit(CreatureMapType &m)
void Visit(GridRefManager< T > &m)
std::set< Unit * > i_visibleNow
Player::ClientGUIDs vis_guids
void Visit(GameObjectMapType &m)
std::list< WorldObject * > & i_objects
void Visit(GameObjectMapType &m)