-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
ObjectMgr.h
1027 lines (850 loc) · 38.9 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
/*
* Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
*
* 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 "Log.h"
#include "Object.h"
#include "Bag.h"
#include "Creature.h"
#include "Player.h"
#include "GameObject.h"
#include "Corpse.h"
#include "QuestDef.h"
#include "ItemPrototype.h"
#include "NPCHandler.h"
#include "Database/DatabaseEnv.h"
#include "Map.h"
#include "ObjectAccessor.h"
#include "ObjectGuid.h"
#include "Policies/Singleton.h"
#include "Database/SQLStorage.h"
#include <string>
#include <map>
#include <limits>
extern SQLStorage sCreatureStorage;
extern SQLStorage sCreatureDataAddonStorage;
extern SQLStorage sCreatureInfoAddonStorage;
extern SQLStorage sCreatureModelStorage;
extern SQLStorage sEquipmentStorage;
extern SQLStorage sGOStorage;
extern SQLStorage sPageTextStore;
extern SQLStorage sItemStorage;
extern SQLStorage sInstanceTemplate;
class Group;
class Guild;
class ArenaTeam;
class Item;
struct GameTele
{
float position_x;
float position_y;
float position_z;
float orientation;
uint32 mapId;
std::string name;
std::wstring wnameLow;
};
typedef UNORDERED_MAP<uint32, GameTele > GameTeleMap;
struct ScriptInfo
{
uint32 id;
uint32 delay;
uint32 command;
uint32 datalong;
uint32 datalong2;
uint32 datalong3;
uint32 datalong4;
uint32 data_flags;
int32 dataint;
float x;
float y;
float z;
float o;
};
typedef std::multimap<uint32, ScriptInfo> ScriptMap;
typedef std::map<uint32, ScriptMap > ScriptMapMap;
extern ScriptMapMap sQuestEndScripts;
extern ScriptMapMap sQuestStartScripts;
extern ScriptMapMap sSpellScripts;
extern ScriptMapMap sGameObjectScripts;
extern ScriptMapMap sEventScripts;
extern ScriptMapMap sGossipScripts;
extern ScriptMapMap sCreatureMovementScripts;
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;
// helpers
bool IsFitToRequirements(Player const* player) const;
};
typedef std::multimap<uint32, 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;
std::string requiredFailedText;
uint32 target_mapId;
float target_X;
float target_Y;
float target_Z;
float target_Orientation;
};
typedef std::set<uint32> CellGuidSet;
typedef std::map<uint32/*player guid*/,uint32/*instance*/> CellCorpseSet;
struct CellObjectGuids
{
CellGuidSet creatures;
CellGuidSet gameobjects;
CellCorpseSet corpses;
};
typedef UNORDERED_MAP<uint32/*cell_id*/,CellObjectGuids> CellObjectGuidsMap;
typedef UNORDERED_MAP<uint32/*(mapid,spawnMode) pair*/,CellObjectGuidsMap> MapObjectGuids;
typedef UNORDERED_MAP<uint64/*(instance,guid) pair*/,time_t> RespawnTimes;
// mangos string ranges
#define MIN_MANGOS_STRING_ID 1 // 'mangos_string'
#define MAX_MANGOS_STRING_ID 2000000000
#define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID // 'db_script_string'
#define MAX_DB_SCRIPT_STRING_ID 2000010000
#define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts'
#define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000)
struct MangosStringLocale
{
std::vector<std::string> Content; // 0 -> default, i -> i-1 locale index
};
typedef UNORDERED_MAP<uint32,CreatureData> CreatureDataMap;
typedef UNORDERED_MAP<uint32,GameObjectData> GameObjectDataMap;
typedef UNORDERED_MAP<uint32,CreatureLocale> CreatureLocaleMap;
typedef UNORDERED_MAP<uint32,GameObjectLocale> GameObjectLocaleMap;
typedef UNORDERED_MAP<uint32,ItemLocale> ItemLocaleMap;
typedef UNORDERED_MAP<uint32,QuestLocale> QuestLocaleMap;
typedef UNORDERED_MAP<uint32,NpcTextLocale> NpcTextLocaleMap;
typedef UNORDERED_MAP<uint32,PageTextLocale> PageTextLocaleMap;
typedef UNORDERED_MAP<int32,MangosStringLocale> MangosStringLocaleMap;
typedef UNORDERED_MAP<uint32,GossipMenuItemsLocale> GossipMenuItemsLocaleMap;
typedef UNORDERED_MAP<uint32,PointOfInterestLocale> PointOfInterestLocaleMap;
typedef std::multimap<uint32,uint32> QuestRelations;
typedef std::multimap<uint32,ItemRequiredTarget> ItemRequiredTargetMap;
typedef std::pair<ItemRequiredTargetMap::const_iterator, ItemRequiredTargetMap::const_iterator> ItemRequiredTargetMapBounds;
struct PetLevelInfo
{
PetLevelInfo() : health(0), mana(0) { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 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 UNORDERED_MAP<uint8,MailLevelRewardList> MailLevelRewardMap;
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 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_id;
uint32 npc_option_npcflag;
uint32 action_menu_id;
uint32 action_poi_id;
uint32 action_script_id;
bool box_coded;
uint32 box_money;
std::string box_text;
uint16 cond_1;
uint16 cond_2;
uint16 cond_3;
};
struct GossipMenus
{
uint32 entry;
uint32 text_id;
uint16 cond_1;
uint16 cond_2;
};
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 UNORDERED_MAP<uint32, QuestPOIVector> QuestPOIMap;
#define WEATHER_SEASONS 4
struct WeatherSeasonChances
{
uint32 rainChance;
uint32 snowChance;
uint32 stormChance;
};
struct WeatherZoneChances
{
WeatherSeasonChances data[WEATHER_SEASONS];
};
struct GraveYardData
{
uint32 safeLocId;
uint32 team;
};
typedef std::multimap<uint32,GraveYardData> GraveYardMap;
enum ConditionType
{ // value1 value2 for the Condition enumed
CONDITION_NONE = 0, // 0 0
CONDITION_AURA = 1, // spell_id effindex
CONDITION_ITEM = 2, // item_id count
CONDITION_ITEM_EQUIPPED = 3, // item_id 0
CONDITION_ZONEID = 4, // zone_id 0
CONDITION_REPUTATION_RANK = 5, // faction_id min_rank
CONDITION_TEAM = 6, // player_team 0, (469 - Alliance 67 - Horde)
CONDITION_SKILL = 7, // skill_id skill_value
CONDITION_QUESTREWARDED = 8, // quest_id 0
CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active.
CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD commission aura active
CONDITION_NO_AURA = 11, // spell_id effindex
CONDITION_ACTIVE_EVENT = 12, // event_id 0
CONDITION_AREA_FLAG = 13, // area_flag area_flag_not
CONDITION_RACE_CLASS = 14, // race_mask class_mask
CONDITION_LEVEL = 15, // player_level 0, 1 or 2 (0: equal to, 1: equal or higher than, 2: equal or less than)
CONDITION_NOITEM = 16, // item_id count
CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell)
CONDITION_INSTANCE_SCRIPT = 18, // map_id instance_condition_id (instance script specific enum)
};
#define MAX_CONDITION 19 // maximum value in ConditionType enum
struct PlayerCondition
{
ConditionType condition; // additional condition type
uint32 value1; // data for the condition - see ConditionType definition
uint32 value2;
PlayerCondition(uint8 _condition = 0, uint32 _value1 = 0, uint32 _value2 = 0)
: condition(ConditionType(_condition)), value1(_value1), value2(_value2) {}
static bool IsValid(ConditionType condition, uint32 value1, uint32 value2);
// Checks correctness of values
bool Meets(Player const * APlayer) const; // Checks if the player meets the condition
bool operator == (PlayerCondition const& lc) const
{
return (lc.condition == condition && lc.value1 == value1 && lc.value2 == value2);
}
};
// NPC gossip text id
typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap;
typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap;
typedef 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);
struct MANGOS_DLL_SPEC LanguageDesc
{
Language lang_id;
uint32 spell_id;
uint32 skill_id;
};
extern LanguageDesc lang_description[LANGUAGES_COUNT];
MANGOS_DLL_SPEC 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;
};
class ObjectMgr
{
friend class PlayerDumpReader;
public:
ObjectMgr();
~ObjectMgr();
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
typedef UNORDERED_MAP<uint32, Group*> GroupMap;
typedef UNORDERED_MAP<uint32, Guild*> GuildMap;
typedef UNORDERED_MAP<uint32, ArenaTeam*> ArenaTeamMap;
typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
typedef std::vector<std::string> ScriptNameMap;
Player* GetPlayer(const char* name) const { return ObjectAccessor::FindPlayerByName(name);}
Player* GetPlayer(ObjectGuid guid) const { return ObjectAccessor::FindPlayer(guid); }
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
void LoadGameobjectInfo();
void AddGameobjectInfo(GameObjectInfo *goinfo);
void PackGroupIds();
Group* GetGroupById(uint32 id) const;
void AddGroup(Group* group);
void RemoveGroup(Group* group);
Guild* GetGuildByLeader(uint64 const&guid) const;
Guild* GetGuildById(uint32 GuildId) const;
Guild* GetGuildByName(const std::string& guildname) const;
std::string GetGuildNameById(uint32 GuildId) const;
void AddGuild(Guild* guild);
void RemoveGuild(uint32 Id);
ArenaTeam* GetArenaTeamById(uint32 arenateamid) const;
ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const;
ArenaTeam* GetArenaTeamByCaptain(uint64 const& guid) const;
void AddArenaTeam(ArenaTeam* arenaTeam);
void RemoveArenaTeam(uint32 Id);
ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); }
ArenaTeamMap::iterator GetArenaTeamMapEnd() { return mArenaTeamMap.end(); }
static CreatureInfo const *GetCreatureTemplate( uint32 id );
CreatureModelInfo const *GetCreatureModelInfo( uint32 modelid );
CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id);
uint32 ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data = NULL);
EquipmentInfo const *GetEquipmentInfo( uint32 entry );
static CreatureDataAddon const *GetCreatureAddon( uint32 lowguid )
{
return sCreatureDataAddonStorage.LookupEntry<CreatureDataAddon>(lowguid);
}
static CreatureDataAddon const *GetCreatureTemplateAddon( uint32 entry )
{
return sCreatureInfoAddonStorage.LookupEntry<CreatureDataAddon>(entry);
}
static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry<ItemPrototype>(id); }
static InstanceTemplate const* GetInstanceTemplate(uint32 map)
{
return sInstanceTemplate.LookupEntry<InstanceTemplate>(map);
}
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const;
PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
{
if(class_ >= MAX_CLASSES) return NULL;
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 NULL;
if(class_ >= MAX_CLASSES) return NULL;
PlayerInfo const* info = &playerInfo[race][class_];
if(info->displayId_m==0 || info->displayId_f==0) return NULL;
return info;
}
void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const;
uint64 GetPlayerGUIDByName(std::string name) const;
bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const;
uint32 GetPlayerTeamByGUID(const uint64 &guid) const;
uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const;
uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const;
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid, uint32 team );
void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost);
uint32 GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_alt_team = false);
Quest const* GetQuestTemplate(uint32 quest_id) const
{
QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
return itr != mQuestTemplates.end() ? itr->second : NULL;
}
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;
WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team);
bool AddGraveYardLink(uint32 id, uint32 zone, uint32 team, bool inDB = true);
void LoadGraveyardZones();
GraveYardData const* FindGraveYardData(uint32 id, uint32 zone);
AreaTrigger const* GetAreaTrigger(uint32 trigger) const
{
AreaTriggerMap::const_iterator itr = mAreaTriggers.find( trigger );
if( itr != mAreaTriggers.end( ) )
return &itr->second;
return NULL;
}
AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
uint32 GetAreaTriggerScriptId(uint32 trigger_id);
ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
{
RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
if(itr != mRepOnKill.end())
return &itr->second;
return NULL;
}
PointOfInterest const* GetPointOfInterest(uint32 id) const
{
PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
if(itr != mPointsOfInterest.end())
return &itr->second;
return NULL;
}
QuestPOIVector const* GetQuestPOIVector(uint32 questId)
{
QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId);
if(itr != mQuestPOIMap.end())
return &itr->second;
return NULL;
}
void LoadGuilds();
void LoadArenaTeams();
void LoadGroups();
void LoadQuests();
void LoadQuestRelations()
{
LoadGameobjectQuestRelations();
LoadGameobjectInvolvedRelations();
LoadCreatureQuestRelations();
LoadCreatureInvolvedRelations();
}
void LoadGameobjectQuestRelations();
void LoadGameobjectInvolvedRelations();
void LoadCreatureQuestRelations();
void LoadCreatureInvolvedRelations();
QuestRelations mGOQuestRelations;
QuestRelations mGOQuestInvolvedRelations;
QuestRelations mCreatureQuestRelations;
QuestRelations mCreatureQuestInvolvedRelations;
void LoadGameObjectScripts();
void LoadQuestEndScripts();
void LoadQuestStartScripts();
void LoadEventScripts();
void LoadSpellScripts();
void LoadGossipScripts();
void LoadCreatureMovementScripts();
bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase,"mangos_string",MIN_MANGOS_STRING_ID,MAX_MANGOS_STRING_ID); }
void LoadDbScriptStrings();
void LoadCreatureLocales();
void LoadCreatureTemplates();
void LoadCreatures();
void LoadCreatureRespawnTimes();
void LoadCreatureAddons();
void LoadCreatureModelInfo();
void LoadEquipmentTemplates();
void LoadGameObjectLocales();
void LoadGameobjects();
void LoadGameobjectRespawnTimes();
void LoadItemPrototypes();
void LoadItemRequiredTarget();
void LoadItemLocales();
void LoadQuestLocales();
void LoadNpcTextLocales();
void LoadPageTextLocales();
void LoadGossipMenuItemsLocales();
void LoadPointOfInterestLocales();
void LoadInstanceTemplate();
void LoadMailLevelRewards();
void LoadGossipText();
void LoadAreaTriggerTeleports();
void LoadQuestAreaTriggers();
void LoadAreaTriggerScripts();
void LoadTavernAreaTriggers();
void LoadGameObjectForQuests();
void LoadPageTexts();
void LoadPlayerInfo();
void LoadPetLevelInfo();
void LoadExplorationBaseXP();
void LoadPetNames();
void LoadPetNumber();
void LoadCorpses();
void LoadFishingBaseSkillLevel();
void LoadReputationOnKill();
void LoadPointsOfInterest();
void LoadQuestPOI();
void LoadNPCSpellClickSpells();
void LoadWeatherZoneChances();
void LoadGameTele();
void LoadNpcTextId();
void LoadGossipMenu();
void LoadGossipMenuItems();
void LoadVendors();
void LoadTrainerSpell();
std::string GeneratePetName(uint32 entry);
uint32 GetBaseXP(uint32 level) const;
uint32 GetXPForLevel(uint32 level) const;
uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level)/20; }
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();
uint32 GenerateLowGuid(HighGuid guidhigh);
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 GenerateGroupId() { return m_GroupIds.Generate(); }
//uint32 GenerateItemTextID() { return m_ItemGuids.Generate(); }
uint32 GenerateMailID() { return m_MailIds.Generate(); }
uint32 GeneratePetNumber() { return m_PetNumbers.Generate(); }
typedef std::multimap<int32, uint32> ExclusiveQuestGroups;
ExclusiveQuestGroups mExclusiveQuestGroups;
MailLevelReward const* GetMailLevelReward(uint32 level,uint32 raceMask)
{
MailLevelRewardMap::const_iterator map_itr = m_mailLevelRewardMap.find(level);
if (map_itr == m_mailLevelRewardMap.end())
return NULL;
for(MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr)
if (set_itr->raceMask & raceMask)
return &*set_itr;
return NULL;
}
WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const
{
WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id);
if(itr != mWeatherZoneMap.end())
return &itr->second;
else
return NULL;
}
CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id)
{
return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id];
}
CreatureData const* GetCreatureData(uint32 guid) const
{
CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid);
if(itr==mCreatureDataMap.end()) return NULL;
return &itr->second;
}
CreatureData& NewOrExistCreatureData(uint32 guid) { return mCreatureDataMap[guid]; }
void DeleteCreatureData(uint32 guid);
CreatureLocale const* GetCreatureLocale(uint32 entry) const
{
CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry);
if(itr==mCreatureLocaleMap.end()) return NULL;
return &itr->second;
}
GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
{
GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry);
if(itr==mGameObjectLocaleMap.end()) return NULL;
return &itr->second;
}
ItemLocale const* GetItemLocale(uint32 entry) const
{
ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry);
if(itr==mItemLocaleMap.end()) return NULL;
return &itr->second;
}
QuestLocale const* GetQuestLocale(uint32 entry) const
{
QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry);
if(itr==mQuestLocaleMap.end()) return NULL;
return &itr->second;
}
NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
{
NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry);
if(itr==mNpcTextLocaleMap.end()) return NULL;
return &itr->second;
}
PageTextLocale const* GetPageTextLocale(uint32 entry) const
{
PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry);
if(itr==mPageTextLocaleMap.end()) return NULL;
return &itr->second;
}
GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const
{
GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry);
if(itr==mGossipMenuItemsLocaleMap.end()) return NULL;
return &itr->second;
}
PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const
{
PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id);
if(itr==mPointOfInterestLocaleMap.end()) return NULL;
return &itr->second;
}
GameObjectData const* GetGOData(uint32 guid) const
{
GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid);
if(itr==mGameObjectDataMap.end()) return NULL;
return &itr->second;
}
GameObjectData& NewGOData(uint32 guid) { return mGameObjectDataMap[guid]; }
void DeleteGOData(uint32 guid);
MangosStringLocale const* GetMangosStringLocale(int32 entry) const
{
MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry);
if(itr==mMangosStringLocaleMap.end()) return NULL;
return &itr->second;
}
const char *GetMangosString(int32 entry, int locale_idx) const;
const char *GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); }
int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); }
void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance);
void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid);
time_t GetCreatureRespawnTime(uint32 loguid, uint32 instance) { return mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)]; }
void SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t);
time_t GetGORespawnTime(uint32 loguid, uint32 instance) { return mGORespawnTimes[MAKE_PAIR64(loguid,instance)]; }
void SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t);
void DeleteRespawnTimeForInstance(uint32 instance);
// grid objects
void AddCreatureToGrid(uint32 guid, CreatureData const* data);
void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data);
void AddGameobjectToGrid(uint32 guid, GameObjectData const* data);
void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data);
// reserved names
void LoadReservedPlayersNames();
bool IsReservedName(const std::string& name) const;
// name with valid structure and symbols
static uint8 CheckPlayerName( const std::string& name, bool create = false );
static PetNameInvalidReason CheckPetName( const std::string& name );
static bool IsValidCharterName( const std::string& name );
static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names);
int GetIndexForLocale(LocaleConstant loc);
LocaleConstant GetLocaleForIndex(int i);
uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const
{
if(condition_id >= mConditions.size())
return false;
return mConditions[condition_id].Meets(player);
}
GameTele const* GetGameTele(uint32 id) const
{
GameTeleMap::const_iterator itr = m_GameTeleMap.find(id);
if(itr==m_GameTeleMap.end()) return NULL;
return &itr->second;
}
GameTele const* GetGameTele(const std::string& name) const;
GameTeleMap const& GetGameTeleMap() const { return m_GameTeleMap; }
bool AddGameTele(GameTele& data);
bool DeleteGameTele(const std::string& name);
uint32 GetNpcGossip(uint32 entry) const
{
CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry);
if(iter == m_mCacheNpcTextIdMap.end())
return 0;
return iter->second;
}
TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const
{
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry);
if(iter == m_mCacheTrainerSpellMap.end())
return NULL;
return &iter->second;
}
VendorItemData const* GetNpcVendorItemList(uint32 entry) const
{
CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry);
if(iter == m_mCacheVendorItemMap.end())
return NULL;
return &iter->second;
}
void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost);
bool RemoveVendorItem(uint32 entry,uint32 item);
bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const;
void LoadScriptNames();
ScriptNameMap &GetScriptNames() { return m_scriptNames; }
const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
uint32 GetScriptId(const char *name);
int GetOrNewIndexForLocale(LocaleConstant loc);
SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const
{
return SpellClickInfoMapBounds(mSpellClickInfoMap.lower_bound(creature_id),mSpellClickInfoMap.upper_bound(creature_id));
}
ItemRequiredTargetMapBounds GetItemRequiredTargetMapBounds(uint32 uiItemEntry) const
{
return ItemRequiredTargetMapBounds(m_ItemRequiredTarget.lower_bound(uiItemEntry),m_ItemRequiredTarget.upper_bound(uiItemEntry));
}
GossipMenusMapBounds GetGossipMenusMapBounds(uint32 uiMenuId) const
{
return GossipMenusMapBounds(m_mGossipMenusMap.lower_bound(uiMenuId),m_mGossipMenusMap.upper_bound(uiMenuId));
}
GossipMenuItemsMapBounds GetGossipMenuItemsMapBounds(uint32 uiMenuId) const
{
return GossipMenuItemsMapBounds(m_mGossipMenuItemsMap.lower_bound(uiMenuId),m_mGossipMenuItemsMap.upper_bound(uiMenuId));
}
protected:
// first free id for selected id type
IdGenerator<uint32> m_ArenaTeamIds;
IdGenerator<uint32> m_AuctionIds;
IdGenerator<uint64> m_EquipmentSetIds;
IdGenerator<uint32> m_GuildIds;
IdGenerator<uint32> m_MailIds;
IdGenerator<uint32> m_PetNumbers;
IdGenerator<uint32> m_GroupIds;
// first free low guid for selected guid type
ObjectGuidGenerator<HIGHGUID_PLAYER> m_CharGuids;
ObjectGuidGenerator<HIGHGUID_UNIT> m_CreatureGuids;
ObjectGuidGenerator<HIGHGUID_ITEM> m_ItemGuids;
ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_GameobjectGuids;
ObjectGuidGenerator<HIGHGUID_CORPSE> m_CorpseGuids;
QuestMap mQuestTemplates;
typedef UNORDERED_MAP<uint32, GossipText> GossipTextMap;
typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap;
typedef std::set<uint32> TavernAreaTriggerSet;
typedef std::set<uint32> GameObjectForQuestSet;
GroupMap mGroupMap;
GuildMap mGuildMap;
ArenaTeamMap mArenaTeamMap;
QuestAreaTriggerMap mQuestAreaTriggerMap;
TavernAreaTriggerSet mTavernAreaTriggerSet;
GameObjectForQuestSet mGameObjectForQuestSet;
GossipTextMap mGossipText;
AreaTriggerMap mAreaTriggers;
AreaTriggerScriptMap mAreaTriggerScripts;
RepOnKillMap mRepOnKill;
GossipMenusMap m_mGossipMenusMap;
GossipMenuItemsMap m_mGossipMenuItemsMap;
PointOfInterestMap mPointsOfInterest;
QuestPOIMap mQuestPOIMap;
WeatherZoneMap mWeatherZoneMap;
//character reserved names
typedef std::set<std::wstring> ReservedNamesMap;
ReservedNamesMap m_ReservedNames;
GraveYardMap mGraveYardMap;
GameTeleMap m_GameTeleMap;
ScriptNameMap m_scriptNames;
SpellClickInfoMap mSpellClickInfoMap;
ItemRequiredTargetMap m_ItemRequiredTarget;
typedef std::vector<LocaleConstant> LocalForIndex;
LocalForIndex m_LocalForIndex;
int DBCLocaleIndex;
private:
void LoadScripts(ScriptMapMap& scripts, char const* tablename);
void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids);
void LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment);
void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
void LoadQuestRelationsHelper(QuestRelations& map,char const* table);
MailLevelRewardMap m_mailLevelRewardMap;
typedef std::map<uint32,PetLevelInfo*> PetLevelInfoMap;
// PetLevelInfoMap[creature_id][level]
PetLevelInfoMap petInfo; // [creature_id][level]
PlayerClassInfo playerClassInfo[MAX_CLASSES];
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
PlayerInfo playerInfo[MAX_RACES][MAX_CLASSES];
typedef std::vector<uint32> PlayerXPperLevel; // [level]
PlayerXPperLevel mPlayerXPperLevel;
typedef std::map<uint32,uint32> BaseXPMap; // [area level][base xp]
BaseXPMap mBaseXPTable;
typedef std::map<uint32,int32> FishingBaseSkillMap; // [areaId][base skill level]
FishingBaseSkillMap mFishingBaseForArea;
typedef std::map<uint32,std::vector<std::string> > HalfNameMap;
HalfNameMap PetHalfName0;
HalfNameMap PetHalfName1;
MapObjectGuids mMapObjectGuids;
CreatureDataMap mCreatureDataMap;
CreatureLocaleMap mCreatureLocaleMap;
GameObjectDataMap mGameObjectDataMap;
GameObjectLocaleMap mGameObjectLocaleMap;
ItemLocaleMap mItemLocaleMap;
QuestLocaleMap mQuestLocaleMap;
NpcTextLocaleMap mNpcTextLocaleMap;