-
Notifications
You must be signed in to change notification settings - Fork 294
/
ObjectMgr.h
1456 lines (1180 loc) · 56.6 KB
/
ObjectMgr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of the CMaNGOS Project. See AUTHORS 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 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 _OBJECTMGR_H
#define _OBJECTMGR_H
#include "Common.h"
#include "Entities/Object.h"
#include "Entities/Bag.h"
#include "Entities/Creature.h"
#include "Entities/Player.h"
#include "Entities/GameObject.h"
#include "Quests/QuestDef.h"
#include "Entities/ItemPrototype.h"
#include "Entities/NPCHandler.h"
#include "Database/DatabaseEnv.h"
#include "Maps/Map.h"
#include "Maps/MapPersistentStateMgr.h"
#include "Globals/ObjectAccessor.h"
#include "Entities/ObjectGuid.h"
#include "Globals/Conditions.h"
#include "Maps/SpawnGroupDefines.h"
#include "Entities/Vehicle.h"
#include <map>
#include <climits>
class Group;
class ArenaTeam;
class Item;
class SQLStorage;
struct GameTele
{
float position_x;
float position_y;
float position_z;
float orientation;
uint32 mapId;
std::string name;
std::wstring wnameLow;
};
typedef std::unordered_map<uint32, GameTele > GameTeleMap;
struct SpellClickInfo
{
uint32 spellId;
uint32 questStart; // quest start (quest must be active or rewarded for spell apply)
uint32 questEnd; // quest end (quest don't must be rewarded for spell apply)
bool questStartCanActive; // if true then quest start can be active (not only rewarded)
uint8 castFlags;
uint16 conditionId; // intends to replace questStart, questEnd, questStartCanActive
// helpers
bool IsFitToRequirements(Player const* player, Creature const* clickedCreature) const;
};
typedef std::multimap<uint32 /*npcEntry*/, SpellClickInfo> SpellClickInfoMap;
typedef std::pair<SpellClickInfoMap::const_iterator, SpellClickInfoMap::const_iterator> SpellClickInfoMapBounds;
struct AreaTrigger
{
uint8 requiredLevel;
uint32 requiredItem;
uint32 requiredItem2;
uint32 heroicKey;
uint32 heroicKey2;
uint32 requiredQuest;
uint32 requiredQuestHeroic;
uint32 target_mapId;
float target_X;
float target_Y;
float target_Z;
float target_Orientation;
uint32 conditionId;
// Operators
bool IsMinimal() const
{
return requiredLevel == 0 && requiredItem == 0 && requiredItem2 == 0 && heroicKey == 0 &&
heroicKey2 == 0 && requiredQuest == 0 && requiredQuestHeroic == 0;
}
bool IsLessOrEqualThan(AreaTrigger const* l) const // Expected to have same map
{
MANGOS_ASSERT(target_mapId == l->target_mapId);
return requiredLevel <= l->requiredLevel && requiredItem <= l->requiredItem && requiredItem2 <= l->requiredItem2
&& heroicKey <= l->heroicKey && heroicKey2 <= l->heroicKey2 && requiredQuest <= l->requiredQuest && requiredQuestHeroic <= l->requiredQuestHeroic;
}
};
struct AccessRequirement
{
uint8 levelMin;
uint8 levelMax;
uint16 item_level;
uint32 item;
uint32 item2;
uint32 quest_A;
uint32 quest_H;
uint32 achievement;
std::string questFailedText;
};
struct BroadcastText
{
uint32 Id;
std::vector<std::string> maleText;
std::vector<std::string> femaleText;
ChatType chatTypeId; // not contained in SMSG_DB_REPLY, but added here for ease of use
Language languageId;
// uint32 conditionId;
// uint32 emotesId;
// uint32 flags;
uint32 soundId1;
// uint32 soundId2;
uint32 emoteIds[3];
uint32 emoteDelays[3];
// uint32 verifiedBuild;
std::string const& GetText(int32 locIdx, uint8 gender = GENDER_MALE, bool forceGender = false) const
{
++locIdx; // broadcast text has default at position 0
if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || !femaleText[DEFAULT_LOCALE].empty()))
{
if (locIdx >= 0 && femaleText.size() > size_t(locIdx) && !femaleText[locIdx].empty())
return femaleText[locIdx];
return femaleText[DEFAULT_LOCALE];
}
// else if (gender == GENDER_MALE)
{
if (locIdx >= 0 && maleText.size() > size_t(locIdx) && !maleText[locIdx].empty())
return maleText[locIdx];
return maleText[DEFAULT_LOCALE];
}
}
BroadcastText() : maleText(DEFAULT_LOCALE + 1), femaleText(DEFAULT_LOCALE + 1) {}
};
typedef std::map<uint32, BroadcastText> BroadcastTextMap;
typedef std::map < uint32/*player guid*/, uint32/*instance*/ > CellCorpseSet;
struct CellObjectGuids
{
CellGuidSet creatures;
CellGuidSet gameobjects;
CellCorpseSet corpses;
};
typedef std::unordered_map<uint32/*cell_id*/, CellObjectGuids> CellObjectGuidsMap;
typedef std::unordered_map<uint32/*(mapid,spawnMode) pair*/, CellObjectGuidsMap> MapObjectGuids;
// mangos string ranges
#define MIN_MANGOS_STRING_ID 1 // 'mangos_string'
#define MAX_MANGOS_STRING_ID 2000000000
struct MangosStringLocale
{
MangosStringLocale() : SoundId(0), Type(0), LanguageId(LANG_UNIVERSAL), Emote(0), broadcastText(nullptr) { }
std::vector<std::string> Content; // 0 -> default, i -> i-1 locale index
uint32 SoundId;
uint8 Type;
Language LanguageId;
uint32 Emote;
BroadcastText const* broadcastText;
};
typedef std::unordered_map<uint32, CreatureSpawnTemplate> CreatureSpawnTemplateMap;
typedef std::unordered_map<uint32 /*guid*/, CreatureData> CreatureDataMap;
typedef CreatureDataMap::value_type CreatureDataPair;
class FindCreatureData
{
public:
FindCreatureData(uint32 id, Player* player) : i_id(id), i_player(player),
i_anyData(nullptr), i_mapData(nullptr), i_mapDist(0.0f), i_spawnedData(nullptr), i_spawnedDist(0.0f) {}
bool operator()(CreatureDataPair const& dataPair);
CreatureDataPair const* GetResult() const;
private:
uint32 i_id;
Player* i_player;
CreatureDataPair const* i_anyData;
CreatureDataPair const* i_mapData;
float i_mapDist;
CreatureDataPair const* i_spawnedData;
float i_spawnedDist;
};
typedef std::unordered_map<uint32, GameObjectData> GameObjectDataMap;
typedef GameObjectDataMap::value_type GameObjectDataPair;
class FindGOData
{
public:
FindGOData(uint32 id, Player* player) : i_id(id), i_player(player),
i_anyData(nullptr), i_mapData(nullptr), i_mapDist(0.0f), i_spawnedData(nullptr), i_spawnedDist(0.0f) {}
bool operator()(GameObjectDataPair const& dataPair);
GameObjectDataPair const* GetResult() const;
private:
uint32 i_id;
Player* i_player;
GameObjectDataPair const* i_anyData;
GameObjectDataPair const* i_mapData;
float i_mapDist;
GameObjectDataPair const* i_spawnedData;
float i_spawnedDist;
};
typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleMap;
typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleMap;
typedef std::unordered_map<uint32, ItemLocale> ItemLocaleMap;
typedef std::unordered_map<uint32, QuestLocale> QuestLocaleMap;
typedef std::unordered_map<uint32, NpcTextLocale> NpcTextLocaleMap;
typedef std::unordered_map<uint32, PageTextLocale> PageTextLocaleMap;
typedef std::unordered_map<int32, MangosStringLocale> MangosStringLocaleMap;
typedef std::unordered_map<uint32, GossipMenuItemsLocale> GossipMenuItemsLocaleMap;
typedef std::unordered_map<uint32, PointOfInterestLocale> PointOfInterestLocaleMap;
typedef std::unordered_map<uint32, uint32> ItemConvertMap;
typedef std::multimap<int32, uint32> ExclusiveQuestGroupsMap;
typedef std::multimap<uint32, ItemRequiredTarget> ItemRequiredTargetMap;
typedef std::multimap<uint32, uint32> QuestRelationsMap;
typedef std::pair<ExclusiveQuestGroupsMap::const_iterator, ExclusiveQuestGroupsMap::const_iterator> ExclusiveQuestGroupsMapBounds;
typedef std::pair<ItemRequiredTargetMap::const_iterator, ItemRequiredTargetMap::const_iterator> ItemRequiredTargetMapBounds;
typedef std::pair<QuestRelationsMap::const_iterator, QuestRelationsMap::const_iterator> QuestRelationsMapBounds;
struct PetLevelInfo
{
PetLevelInfo() : health(0), mana(0), armor(0) { for (unsigned short& stat : stats) stat = 0; }
uint16 stats[MAX_STATS];
uint16 health;
uint16 mana;
uint16 armor;
};
struct MailLevelReward
{
MailLevelReward() : raceMask(0), mailTemplateId(0), senderEntry(0) {}
MailLevelReward(uint32 _raceMask, uint32 _mailTemplateId, uint32 _senderEntry) : raceMask(_raceMask), mailTemplateId(_mailTemplateId), senderEntry(_senderEntry) {}
uint32 raceMask;
uint32 mailTemplateId;
uint32 senderEntry;
};
typedef std::list<MailLevelReward> MailLevelRewardList;
typedef std::unordered_map<uint8, MailLevelRewardList> MailLevelRewardMap;
// We assume the rate is in general the same for all three types below, but chose to keep three for scalability and customization
struct RepRewardRate
{
float quest_rate; // We allow rate = 0.0 in database. For this case,
float creature_rate; // it means that no reputation are given at all
float spell_rate; // for this faction/rate type.
};
struct ReputationOnKillEntry
{
uint32 repfaction1;
uint32 repfaction2;
bool is_teamaward1;
uint32 reputation_max_cap1;
int32 repvalue1;
bool is_teamaward2;
uint32 reputation_max_cap2;
int32 repvalue2;
bool team_dependent;
};
struct RepSpilloverTemplate
{
uint32 faction[MAX_SPILLOVER_FACTIONS];
float faction_rate[MAX_SPILLOVER_FACTIONS];
uint32 faction_rank[MAX_SPILLOVER_FACTIONS];
};
struct PointOfInterest
{
uint32 entry;
float x;
float y;
uint32 icon;
uint32 flags;
uint32 data;
std::string icon_name;
};
struct GossipMenuItems
{
uint32 menu_id;
uint32 id;
uint8 option_icon;
std::string option_text;
uint32 option_broadcast_text;
uint32 option_id;
uint32 npc_option_npcflag;
int32 action_menu_id;
uint32 action_poi_id;
uint32 action_script_id;
bool box_coded;
uint32 box_money;
std::string box_text;
uint32 box_broadcast_text;
uint16 conditionId;
};
struct GossipMenus
{
uint32 entry;
uint32 text_id;
uint32 script_id;
uint16 conditionId;
};
typedef std::multimap<uint32, GossipMenus> GossipMenusMap;
typedef std::pair<GossipMenusMap::const_iterator, GossipMenusMap::const_iterator> GossipMenusMapBounds;
typedef std::multimap<uint32, GossipMenuItems> GossipMenuItemsMap;
typedef std::pair<GossipMenuItemsMap::const_iterator, GossipMenuItemsMap::const_iterator> GossipMenuItemsMapBounds;
struct QuestPOIPoint
{
int32 x;
int32 y;
QuestPOIPoint() : x(0), y(0) {}
QuestPOIPoint(int32 _x, int32 _y) : x(_x), y(_y) {}
};
struct QuestPOI
{
uint32 PoiId;
int32 ObjectiveIndex;
uint32 MapId;
uint32 MapAreaId;
uint32 FloorId;
uint32 Unk3;
uint32 Unk4;
std::vector<QuestPOIPoint> points;
QuestPOI() : PoiId(0), ObjectiveIndex(0), MapId(0), MapAreaId(0), FloorId(0), Unk3(0), Unk4(0) {}
QuestPOI(uint32 poiId, int32 objIndex, uint32 mapId, uint32 mapAreaId, uint32 floorId, uint32 unk3, uint32 unk4) : PoiId(poiId), ObjectiveIndex(objIndex), MapId(mapId), MapAreaId(mapAreaId), FloorId(floorId), Unk3(unk3), Unk4(unk4) {}
};
typedef std::vector<QuestPOI> QuestPOIVector;
typedef std::unordered_map<uint32, QuestPOIVector> QuestPOIMap;
struct DungeonEncounter
{
DungeonEncounter(DungeonEncounterEntry const* _dbcEntry, EncounterCreditType _creditType, uint32 _creditEntry, uint32 _lastEncounterDungeon)
: dbcEntry(_dbcEntry), creditType(_creditType), creditEntry(_creditEntry), lastEncounterDungeon(_lastEncounterDungeon) { }
DungeonEncounterEntry const* dbcEntry;
EncounterCreditType creditType;
uint32 creditEntry;
uint32 lastEncounterDungeon;
};
typedef std::multimap<uint32, DungeonEncounter const*> DungeonEncounterMap;
typedef std::pair<DungeonEncounterMap::const_iterator, DungeonEncounterMap::const_iterator> DungeonEncounterMapBounds;
struct TaxiShortcutData
{
uint32 lengthTakeoff;
uint32 lengthLanding;
};
typedef std::unordered_multimap <uint32 /*nodeid*/, TaxiShortcutData> TaxiShortcutMap;
struct QuestgiverGreeting
{
std::string text;
uint32 emoteId;
uint32 emoteDelay;
};
struct QuestgiverGreetingLocale
{
std::vector<std::string> localeText;
};
typedef std::map<uint32, QuestgiverGreeting> QuestgiverGreetingMap;
typedef std::map<uint32, QuestgiverGreetingLocale> QuestgiverGreetingLocaleMap;
enum
{
QUESTGIVER_CREATURE = 0,
QUESTGIVER_GAMEOBJECT = 1,
QUESTGIVER_TYPE_MAX = 2,
};
struct TrainerGreeting
{
std::string text;
};
struct TrainerGreetingLocale
{
std::vector<std::string> localeText;
};
typedef std::map<uint32, TrainerGreeting> TrainerGreetingMap;
typedef std::map<uint32, TrainerGreetingLocale> TrainerGreetingLocaleMap;
// NPC gossip text id
typedef std::unordered_map<uint32, uint32> CacheNpcTextIdMap;
typedef std::unordered_map<uint32, VendorItemData> CacheVendorItemMap;
typedef std::unordered_map<uint32, TrainerSpellData> CacheTrainerSpellMap;
enum SkillRangeType
{
SKILL_RANGE_LANGUAGE, // 300..300
SKILL_RANGE_LEVEL, // 1..max skill for level
SKILL_RANGE_MONO, // 1..1, grey monolite bar
SKILL_RANGE_RANK, // 1..skill for known rank
SKILL_RANGE_NONE, // 0..0 always
};
SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial);
#define MAX_PLAYER_NAME 12 // max allowed by client name length
#define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
#define MAX_PET_NAME 12 // max allowed by client name length
#define MAX_CHARTER_NAME 24 // max allowed by client name length
bool normalizePlayerName(std::string& name, size_t max_len = MAX_INTERNAL_PLAYER_NAME);
struct LanguageDesc
{
Language lang_id;
uint32 spell_id;
uint32 skill_id;
};
extern LanguageDesc lang_description[LANGUAGES_COUNT];
LanguageDesc const* GetLanguageDescByID(uint32 lang);
class PlayerDumpReader;
template<typename T>
class IdGenerator
{
public: // constructors
explicit IdGenerator(char const* _name) : m_name(_name), m_nextGuid(1) {}
public: // modifiers
void Set(T val) { m_nextGuid = val; }
T Generate();
public: // accessors
T GetNextAfterMaxUsed() const { return m_nextGuid; }
private: // fields
char const* m_name;
T m_nextGuid;
};
struct CreatureImmunity
{
uint32 type;
uint32 value;
};
typedef std::vector<CreatureImmunity> CreatureImmunityVector;
typedef std::map<uint32, CreatureImmunityVector> CreatureImmunitySetMap;
typedef std::map<uint32, CreatureImmunitySetMap> CreatureImmunityContainer;
struct WorldStateName
{
int32 Id;
std::string Name;
};
class ObjectMgr
{
friend class PlayerDumpReader;
public:
ObjectMgr();
~ObjectMgr();
typedef std::unordered_map<uint32, Item*> ItemMap;
typedef std::unordered_map<uint32, Group*> GroupMap;
typedef std::unordered_map<uint32, ArenaTeam*> ArenaTeamMap;
typedef std::unordered_map<uint32, Quest*> QuestMap;
typedef std::unordered_map<uint32, AreaTrigger> AreaTriggerMap;
typedef std::unordered_map<uint32, RepRewardRate > RepRewardRateMap;
typedef std::unordered_map<uint32, ReputationOnKillEntry> RepOnKillMap;
typedef std::unordered_map<uint32, RepSpilloverTemplate> RepSpilloverTemplateMap;
typedef std::unordered_map<uint32, PointOfInterest> PointOfInterestMap;
std::unordered_map<uint32, std::vector<uint32>> const& GetCreatureSpawnEntry() const { return m_creatureSpawnEntryMap; }
std::vector<uint32> LoadGameobjectInfo();
void PackGroupIds();
Group* GetGroupById(uint32 id) const;
void AddGroup(Group* group);
void RemoveGroup(Group* group);
GroupMap::iterator GetGroupMapBegin() { return mGroupMap.begin(); }
GroupMap::iterator GetGroupMapEnd() { return mGroupMap.end(); }
ArenaTeam* GetArenaTeamById(uint32 arenateamid) const;
ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const;
ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid) const;
void AddArenaTeam(ArenaTeam* arenaTeam);
void RemoveArenaTeam(uint32 Id);
ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); }
ArenaTeamMap::iterator GetArenaTeamMapEnd() { return mArenaTeamMap.end(); }
CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id) const;
uint32 GetCreatureModelAlternativeModel(uint32 modelId) const;
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const;
PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
{
if (class_ >= MAX_CLASSES) return nullptr;
return &playerClassInfo[class_];
}
void GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const;
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
{
if (race >= MAX_RACES) return nullptr;
if (class_ >= MAX_CLASSES) return nullptr;
PlayerInfo const* info = &playerInfo[race][class_];
if (info->displayId_m == 0 || info->displayId_f == 0) return nullptr;
return info;
}
void GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const;
ObjectGuid GetPlayerGuidByName(std::string name) const;
int32 GetPlayerMapIdByGUID(ObjectGuid const& guid) const;
bool GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const;
Team GetPlayerTeamByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const;
bool AddTaxiShortcut(const TaxiPathEntry* path, uint32 lengthTakeoff, uint32 lengthLanding);
bool GetTaxiShortcut(uint32 pathid, TaxiShortcutData& data);
void LoadTaxiShortcuts();
uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Team team) const;
void GetTaxiPath(uint32 source, uint32 destination, uint32& path, uint32& cost) const;
uint32 GetTaxiMountDisplayId(uint32 id, Team team) const;
Quest const* GetQuestTemplate(uint32 quest_id) const
{
QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
return itr != mQuestTemplates.end() ? itr->second : nullptr;
}
QuestMap const& GetQuestTemplates() const { return mQuestTemplates; }
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
{
QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
if (itr != mQuestAreaTriggerMap.end())
return itr->second;
return 0;
}
bool IsTavernAreaTrigger(uint32 Trigger_ID) const
{
return mTavernAreaTriggerSet.find(Trigger_ID) != mTavernAreaTriggerSet.end();
}
bool IsGameObjectForQuests(uint32 entry) const
{
return mGameObjectForQuestSet.find(entry) != mGameObjectForQuestSet.end();
}
GossipText const* GetGossipText(uint32 Text_ID) const;
QuestgiverGreeting const* GetQuestgiverGreetingData(uint32 entry, uint32 type) const;
TrainerGreeting const* GetTrainerGreetingData(uint32 entry) const;
AreaTrigger const* GetAreaTrigger(uint32 trigger) const
{
AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger);
if (itr != mAreaTriggers.end())
return &itr->second;
return nullptr;
}
AccessRequirement const* GetAccessRequirement(uint32 mapid, Difficulty difficulty) const;
std::vector<uint32> const* GetAllRandomEntries(std::unordered_map<uint32, std::vector<uint32>> const& map, uint32 dbguid) const
{
auto itr = map.find(dbguid);
if (itr != map.end())
return &(*itr).second;
return nullptr;
}
uint32 GetRandomEntry(std::unordered_map<uint32, std::vector<uint32>> const& map, uint32 dbguid) const
{
if (auto spawnList = GetAllRandomEntries(map, dbguid))
return (*spawnList)[irand(0, spawnList->size() - 1)];
return 0;
}
uint32 GetRandomGameObjectEntry(uint32 dbguid) const { return GetRandomEntry(m_gameobjectSpawnEntryMap, dbguid); }
std::vector<uint32> const* GetAllRandomGameObjectEntries(uint32 dbguid) const { return GetAllRandomEntries(m_gameobjectSpawnEntryMap, dbguid); }
uint32 GetRandomCreatureEntry(uint32 dbguid) const { return GetRandomEntry(m_creatureSpawnEntryMap, dbguid); }
std::vector<uint32> const* GetAllRandomCreatureEntries(uint32 dbguid) const { return GetAllRandomEntries(m_creatureSpawnEntryMap, dbguid); }
AreaTrigger const* GetGoBackTrigger(uint32 map_id) const;
AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
RepRewardRate const* GetRepRewardRate(uint32 factionId) const
{
RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId);
if (itr != m_RepRewardRateMap.end())
return &itr->second;
return nullptr;
}
ReputationOnKillEntry const* GetReputationOnKillEntry(uint32 id) const
{
RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
if (itr != mRepOnKill.end())
return &itr->second;
return nullptr;
}
RepSpilloverTemplate const* GetRepSpilloverTemplate(uint32 factionId) const
{
RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId);
if (itr != m_RepSpilloverTemplateMap.end())
return &itr->second;
return nullptr;
}
PointOfInterest const* GetPointOfInterest(uint32 id) const
{
PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
if (itr != mPointsOfInterest.end())
return &itr->second;
return nullptr;
}
QuestPOIVector const* GetQuestPOIVector(uint32 questId)
{
QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId);
if (itr != mQuestPOIMap.end())
return &itr->second;
return nullptr;
}
// Static wrappers for various accessors
static GameObjectInfo const* GetGameObjectInfo(uint32 id); ///< Wrapper for sGOStorage.LookupEntry
static Player* GetPlayer(const char* name); ///< Wrapper for ObjectAccessor::FindPlayerByName
static Player* GetPlayer(ObjectGuid guid, bool inWorld = true); ///< Wrapper for ObjectAccessor::FindPlayer
static CreatureInfo const* GetCreatureTemplate(uint32 id); ///< Wrapper for sCreatureStorage.LookupEntry
static CreatureModelInfo const* GetCreatureModelInfo(uint32 modelid); ///< Wrapper for sCreatureModelStorage.LookupEntry
static EquipmentInfo const* GetEquipmentInfo(uint32 entry); ///< Wrapper for sEquipmentStorage.LookupEntry
static CreatureDataAddon const* GetCreatureAddon(uint32 lowguid); ///< Wrapper for sCreatureDataAddonStorage.LookupEntry
static CreatureDataAddon const* GetCreatureTemplateAddon(uint32 entry); ///< Wrapper for sCreatureInfoAddonStorage.LookupEntry
static ItemPrototype const* GetItemPrototype(uint32 id); ///< Wrapper for sItemStorage.LookupEntry
static InstanceTemplate const* GetInstanceTemplate(uint32 map); ///< Wrapper for sInstanceTemplate.LookupEntry
static WorldTemplate const* GetWorldTemplate(uint32 map); ///< Wrapper for sWorldTemplate.LookupEntry
static CreatureConditionalSpawn const* GetCreatureConditionalSpawn(uint32 lowguid); ///< Wrapper for sCreatureConditionalSpawnStore.LookupEntry
// Loading functions
void LoadArenaTeams();
void LoadGroups();
void LoadQuests();
void LoadQuestRelations()
{
LoadGameobjectQuestRelations();
LoadGameobjectInvolvedRelations();
LoadCreatureQuestRelations();
LoadCreatureInvolvedRelations();
}
void LoadGameobjectQuestRelations();
void LoadGameobjectInvolvedRelations();
void LoadCreatureQuestRelations();
void LoadCreatureInvolvedRelations();
bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value, bool extra_content);
bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase, "mangos_string", MIN_MANGOS_STRING_ID, MAX_MANGOS_STRING_ID, false); }
void LoadCreatureLocales();
void LoadCreatureTemplates();
void LoadCreatures();
void LoadCreatureAddons();
void LoadCreatureClassLvlStats();
void LoadCreatureConditionalSpawn();
void LoadCreatureSpawnDataTemplates();
void LoadCreatureSpawnEntry();
void LoadCreatureModelInfo();
void LoadCreatureModelRace();
void LoadEquipmentTemplates();
void LoadGameObjectLocales();
void LoadGameObjects();
void LoadGameObjectAddon();
void LoadGameObjectSpawnEntry();
void LoadGameObjectTemplateAddons();
void LoadItemPrototypes();
void LoadItemConverts();
void LoadItemExpireConverts();
void LoadItemRequiredTarget();
void LoadItemLocales();
void LoadQuestLocales();
void LoadGossipTextLocales();
void LoadQuestgiverGreeting();
void LoadQuestgiverGreetingLocales();
void LoadTrainerGreetings();
void LoadTrainerGreetingLocales();
void LoadPageTextLocales();
void LoadGossipMenuItemsLocales();
void LoadPointOfInterestLocales();
void LoadInstanceEncounters();
void LoadInstanceTemplate();
void LoadWorldTemplate();
void LoadWorldStateNames();
void LoadConditions();
void LoadMailLevelRewards();
void LoadGossipText();
void LoadAreaTriggerTeleports();
void LoadAccessRequirements();
void LoadQuestAreaTriggers();
void LoadTavernAreaTriggers();
void LoadGameObjectForQuests();
void LoadPageTexts();
void LoadPlayerInfo();
void LoadPetLevelInfo();
void LoadExplorationBaseXP();
void LoadPetNames();
void LoadPetNumber();
void LoadCorpses();
void LoadFishingBaseSkillLevel();
void LoadReputationRewardRate();
void LoadReputationOnKill();
void LoadReputationSpilloverTemplate();
void LoadPointsOfInterest();
void LoadQuestPOI();
void LoadNPCSpellClickSpells();
void LoadSpellTemplate();
void CheckSpellCones();
void LoadCreatureTemplateSpells();
void LoadCreatureCooldowns();
void LoadCreatureImmunities();
std::shared_ptr<CreatureSpellListContainer> LoadCreatureSpellLists();
void LoadSpawnGroups();
void LoadGameTele();
void LoadNpcGossips();
void LoadGossipMenus();
void LoadDungeonEncounters();
void LoadAreaGroups();
void LoadSQLDBCs();
void LoadVendorTemplates();
void LoadVendors() { LoadVendors("npc_vendor", false); }
void LoadTrainerTemplates();
void LoadTrainers() { LoadTrainers("npc_trainer", false); }
void LoadBroadcastText();
void LoadBroadcastTextLocales();
/// @param _map Map* of the map for which to load active entities. If nullptr active entities on continents are loaded
void LoadActiveEntities(Map* _map);
void LoadVehicleAccessory();
void LoadVehicleSeatParameters();
std::string GeneratePetName(uint32 entry);
uint32 GetBaseXP(uint32 level) const;
uint32 GetXPForLevel(uint32 level) const;
uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level) / 20; }
uint32 GetMaxLevelForExpansion(uint32 expansion) const;
int32 GetFishingBaseSkillLevel(uint32 entry) const
{
FishingBaseSkillMap::const_iterator itr = mFishingBaseForArea.find(entry);
return itr != mFishingBaseForArea.end() ? itr->second : 0;
}
void ReturnOrDeleteOldMails(bool serverUp);
void SetHighestGuids();
// used for set initial guid counter for map local guids
uint32 GetFirstTemporaryCreatureLowGuid() const { return m_FirstTemporaryCreatureGuid; }
uint32 GetFirstTemporaryGameObjectLowGuid() const { return m_FirstTemporaryGameObjectGuid; }
// used in .npc add/.gobject add commands for adding static spawns
uint32 GenerateStaticCreatureLowGuid() { if (m_StaticCreatureGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryCreatureGuid) return 0; return m_StaticCreatureGuids.Generate(); }
uint32 GenerateStaticGameObjectLowGuid() { if (m_StaticGameObjectGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryGameObjectGuid) return 0; return m_StaticGameObjectGuids.Generate(); }
uint32 GeneratePlayerLowGuid() { return m_CharGuids.Generate(); }
uint32 GenerateItemLowGuid() { return m_ItemGuids.Generate(); }
uint32 GenerateCorpseLowGuid() { return m_CorpseGuids.Generate(); }
uint32 GenerateInstanceLowGuid() { return m_InstanceGuids.Generate(); }
uint32 GenerateGroupLowGuid() { return m_GroupGuids.Generate(); }
uint32 GenerateArenaTeamId() { return m_ArenaTeamIds.Generate(); }
uint32 GenerateAuctionID() { return m_AuctionIds.Generate(); }
uint64 GenerateEquipmentSetGuid() { return m_EquipmentSetIds.Generate(); }
uint32 GenerateGuildId() { return m_GuildIds.Generate(); }
// uint32 GenerateItemTextID() { return m_ItemTextIds.Generate(); }Id
uint32 GenerateMailID() { return m_MailIds.Generate(); }
uint32 GeneratePetNumber() { return m_PetNumbers.Generate(); }
MailLevelReward const* GetMailLevelReward(uint32 level, uint32 raceMask)
{
MailLevelRewardMap::const_iterator map_itr = m_mailLevelRewardMap.find(level);
if (map_itr == m_mailLevelRewardMap.end())
return nullptr;
for (const auto& set_itr : map_itr->second)
if (set_itr.raceMask & raceMask)
return &set_itr;
return nullptr;
}
CreatureDataPair const* GetCreatureDataPair(uint32 guid) const
{
CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid);
if (itr == mCreatureDataMap.end()) return nullptr;
return &*itr;
}
CreatureData const* GetCreatureData(uint32 guid) const
{
CreatureDataPair const* dataPair = GetCreatureDataPair(guid);
return dataPair ? &dataPair->second : nullptr;
}
CreatureSpawnTemplate const* GetCreatureSpawnTemplate(uint32 entry) const
{
auto itr = m_creatureSpawnTemplateMap.find(entry);
return itr != m_creatureSpawnTemplateMap.end() ? &(*itr).second : nullptr;
}
CreatureData* GetCreatureData(uint32 guid)
{
auto dataItr = mCreatureDataMap.find(guid);
if (dataItr != mCreatureDataMap.end())
return &dataItr->second;
return nullptr;
}
CreatureData& NewOrExistCreatureData(uint32 guid) { return mCreatureDataMap[guid]; }
void DeleteCreatureData(uint32 guid);
template<typename Worker>
void DoCreatureData(Worker& worker) const
{
for (CreatureDataMap::const_iterator itr = mCreatureDataMap.begin(); itr != mCreatureDataMap.end(); ++itr)
if (worker(*itr))
break;
}
CreatureLocale const* GetCreatureLocale(uint32 entry) const
{
CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry);
if (itr == mCreatureLocaleMap.end()) return nullptr;
return &itr->second;
}
void GetCreatureLocaleStrings(uint32 entry, int32 loc_idx, char const** namePtr, char const** subnamePtr = nullptr) const;
GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
{
GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry);
if (itr == mGameObjectLocaleMap.end()) return nullptr;
return &itr->second;
}
ItemLocale const* GetItemLocale(uint32 entry) const
{
ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry);
if (itr == mItemLocaleMap.end()) return nullptr;
return &itr->second;
}
void GetItemLocaleStrings(uint32 entry, int32 loc_idx, std::string* namePtr, std::string* descriptionPtr = nullptr) const;
QuestLocale const* GetQuestLocale(uint32 entry) const
{
QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry);
if (itr == mQuestLocaleMap.end()) return nullptr;
return &itr->second;
}
void GetQuestLocaleStrings(uint32 entry, int32 loc_idx, std::string* titlePtr) const;
NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
{
NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry);
if (itr == mNpcTextLocaleMap.end()) return nullptr;
return &itr->second;
}
BroadcastText const* GetBroadcastText(uint32 entry) const
{
auto itr = m_broadcastTextMap.find(entry);
if (itr == m_broadcastTextMap.end()) return nullptr;
return &itr->second;
}
typedef std::string NpcTextArray[MAX_GOSSIP_TEXT_OPTIONS];
void GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, NpcTextArray* text0_Ptr, NpcTextArray* text1_Ptr) const;
void GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::string* text0_0_Ptr, std::string* text1_0_Ptr) const;
void GetQuestgiverGreetingLocales(uint32 entry, uint32 type, int32 loc_idx, std::string* titlePtr) const;
QuestgiverGreetingLocale const* GetQuestgiverGreetingLocale(uint32 entry, uint32 type) const
{
auto itr = m_questgiverGreetingLocaleMap[type].find(entry);
if (itr == m_questgiverGreetingLocaleMap[type].end()) return nullptr;
return &itr->second;
}
void GetTrainerGreetingLocales(uint32 entry, int32 loc_idx, std::string* titlePtr) const;
TrainerGreetingLocale const* GetTrainerGreetingLocale(uint32 entry) const
{
auto itr = m_trainerGreetingLocaleMap.find(entry);
if (itr == m_trainerGreetingLocaleMap.end()) return nullptr;
return &itr->second;
}
PageTextLocale const* GetPageTextLocale(uint32 entry) const
{
PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry);
if (itr == mPageTextLocaleMap.end()) return nullptr;
return &itr->second;
}
GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const
{
GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry);
if (itr == mGossipMenuItemsLocaleMap.end()) return nullptr;
return &itr->second;
}
PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const
{
PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id);
if (itr == mPointOfInterestLocaleMap.end()) return nullptr;
return &itr->second;
}
GameObjectDataPair const* GetGODataPair(uint32 guid) const
{
GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid);
if (itr == mGameObjectDataMap.end()) return nullptr;
return &*itr;
}
GameObjectData const* GetGOData(uint32 guid) const
{
GameObjectDataPair const* dataPair = GetGODataPair(guid);
return dataPair ? &dataPair->second : nullptr;
}