Updated Copyright year to 2013
[getmangos.git] / src / game / ObjectMgr.h
blob87b7b54bd462f3fd205fa56f8427aa0603012b18
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _OBJECTMGR_H
20 #define _OBJECTMGR_H
22 #include "Common.h"
23 #include "Log.h"
24 #include "Object.h"
25 #include "Bag.h"
26 #include "Creature.h"
27 #include "Player.h"
28 #include "GameObject.h"
29 #include "Corpse.h"
30 #include "QuestDef.h"
31 #include "ItemPrototype.h"
32 #include "NPCHandler.h"
33 #include "Database/DatabaseEnv.h"
34 #include "Map.h"
35 #include "MapPersistentStateMgr.h"
36 #include "ObjectAccessor.h"
37 #include "ObjectGuid.h"
38 #include "Policies/Singleton.h"
40 #include <string>
41 #include <map>
42 #include <limits>
44 class Group;
45 class ArenaTeam;
46 class Item;
47 class SQLStorage;
49 struct GameTele
51 float position_x;
52 float position_y;
53 float position_z;
54 float orientation;
55 uint32 mapId;
56 std::string name;
57 std::wstring wnameLow;
60 typedef UNORDERED_MAP<uint32, GameTele > GameTeleMap;
62 struct SpellClickInfo
64 uint32 spellId;
65 uint32 questStart; // quest start (quest must be active or rewarded for spell apply)
66 uint32 questEnd; // quest end (quest don't must be rewarded for spell apply)
67 bool questStartCanActive; // if true then quest start can be active (not only rewarded)
68 uint8 castFlags;
70 // helpers
71 bool IsFitToRequirements(Player const* player) const;
74 typedef std::multimap<uint32, SpellClickInfo> SpellClickInfoMap;
75 typedef std::pair<SpellClickInfoMap::const_iterator, SpellClickInfoMap::const_iterator> SpellClickInfoMapBounds;
77 struct AreaTrigger
79 uint8 requiredLevel;
80 uint32 requiredItem;
81 uint32 requiredItem2;
82 uint32 heroicKey;
83 uint32 heroicKey2;
84 uint32 requiredQuest;
85 uint32 requiredQuestHeroic;
86 uint32 target_mapId;
87 float target_X;
88 float target_Y;
89 float target_Z;
90 float target_Orientation;
92 // Operators
93 bool IsMinimal() const
95 return requiredLevel == 0 && requiredItem == 0 && requiredItem2 == 0 && heroicKey == 0 &&
96 heroicKey2 == 0 && requiredQuest == 0 && requiredQuestHeroic == 0;
99 bool IsLessOrEqualThan(AreaTrigger const* l) const // Expected to have same map
101 MANGOS_ASSERT(target_mapId == l->target_mapId);
102 return requiredLevel <= l->requiredLevel && requiredItem <= l->requiredItem && requiredItem2 <= l->requiredItem2
103 && heroicKey <= l->heroicKey && heroicKey2 <= l->heroicKey2 && requiredQuest <= l->requiredQuest && requiredQuestHeroic <= l->requiredQuestHeroic;
107 typedef std::map < uint32/*player guid*/, uint32/*instance*/ > CellCorpseSet;
108 struct CellObjectGuids
110 CellGuidSet creatures;
111 CellGuidSet gameobjects;
112 CellCorpseSet corpses;
114 typedef UNORDERED_MAP < uint32/*cell_id*/, CellObjectGuids > CellObjectGuidsMap;
115 typedef UNORDERED_MAP < uint32/*(mapid,spawnMode) pair*/, CellObjectGuidsMap > MapObjectGuids;
117 // mangos string ranges
118 #define MIN_MANGOS_STRING_ID 1 // 'mangos_string'
119 #define MAX_MANGOS_STRING_ID 2000000000
120 #define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID // 'db_script_string'
121 #define MAX_DB_SCRIPT_STRING_ID 2000010000
122 #define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts'
123 #define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000)
125 struct MangosStringLocale
127 std::vector<std::string> Content; // 0 -> default, i -> i-1 locale index
130 typedef UNORDERED_MAP<uint32, CreatureData> CreatureDataMap;
131 typedef CreatureDataMap::value_type CreatureDataPair;
133 class FindCreatureData
135 public:
136 FindCreatureData(uint32 id, Player* player) : i_id(id), i_player(player),
137 i_anyData(NULL), i_mapData(NULL), i_mapDist(0.0f), i_spawnedData(NULL), i_spawnedDist(0.0f) {}
139 bool operator()(CreatureDataPair const& dataPair);
140 CreatureDataPair const* GetResult() const;
142 private:
143 uint32 i_id;
144 Player* i_player;
146 CreatureDataPair const* i_anyData;
147 CreatureDataPair const* i_mapData;
148 float i_mapDist;
149 CreatureDataPair const* i_spawnedData;
150 float i_spawnedDist;
153 typedef UNORDERED_MAP<uint32, GameObjectData> GameObjectDataMap;
154 typedef GameObjectDataMap::value_type GameObjectDataPair;
156 class FindGOData
158 public:
159 FindGOData(uint32 id, Player* player) : i_id(id), i_player(player),
160 i_anyData(NULL), i_mapData(NULL), i_mapDist(0.0f), i_spawnedData(NULL), i_spawnedDist(0.0f) {}
162 bool operator()(GameObjectDataPair const& dataPair);
163 GameObjectDataPair const* GetResult() const;
165 private:
166 uint32 i_id;
167 Player* i_player;
169 GameObjectDataPair const* i_anyData;
170 GameObjectDataPair const* i_mapData;
171 float i_mapDist;
172 GameObjectDataPair const* i_spawnedData;
173 float i_spawnedDist;
176 typedef UNORDERED_MAP<uint32, CreatureLocale> CreatureLocaleMap;
177 typedef UNORDERED_MAP<uint32, GameObjectLocale> GameObjectLocaleMap;
178 typedef UNORDERED_MAP<uint32, ItemLocale> ItemLocaleMap;
179 typedef UNORDERED_MAP<uint32, QuestLocale> QuestLocaleMap;
180 typedef UNORDERED_MAP<uint32, NpcTextLocale> NpcTextLocaleMap;
181 typedef UNORDERED_MAP<uint32, PageTextLocale> PageTextLocaleMap;
182 typedef UNORDERED_MAP<int32, MangosStringLocale> MangosStringLocaleMap;
183 typedef UNORDERED_MAP<uint32, GossipMenuItemsLocale> GossipMenuItemsLocaleMap;
184 typedef UNORDERED_MAP<uint32, PointOfInterestLocale> PointOfInterestLocaleMap;
185 typedef UNORDERED_MAP<uint32, uint32> ItemConvertMap;
187 typedef std::multimap<int32, uint32> ExclusiveQuestGroupsMap;
188 typedef std::multimap<uint32, ItemRequiredTarget> ItemRequiredTargetMap;
189 typedef std::multimap<uint32, uint32> QuestRelationsMap;
190 typedef std::pair<ExclusiveQuestGroupsMap::const_iterator, ExclusiveQuestGroupsMap::const_iterator> ExclusiveQuestGroupsMapBounds;
191 typedef std::pair<ItemRequiredTargetMap::const_iterator, ItemRequiredTargetMap::const_iterator> ItemRequiredTargetMapBounds;
192 typedef std::pair<QuestRelationsMap::const_iterator, QuestRelationsMap::const_iterator> QuestRelationsMapBounds;
194 struct PetLevelInfo
196 PetLevelInfo() : health(0), mana(0) { for (int i = 0; i < MAX_STATS; ++i) stats[i] = 0; }
198 uint16 stats[MAX_STATS];
199 uint16 health;
200 uint16 mana;
201 uint16 armor;
204 struct MailLevelReward
206 MailLevelReward() : raceMask(0), mailTemplateId(0), senderEntry(0) {}
207 MailLevelReward(uint32 _raceMask, uint32 _mailTemplateId, uint32 _senderEntry) : raceMask(_raceMask), mailTemplateId(_mailTemplateId), senderEntry(_senderEntry) {}
209 uint32 raceMask;
210 uint32 mailTemplateId;
211 uint32 senderEntry;
214 typedef std::list<MailLevelReward> MailLevelRewardList;
215 typedef UNORDERED_MAP<uint8, MailLevelRewardList> MailLevelRewardMap;
217 // We assume the rate is in general the same for all three types below, but chose to keep three for scalability and customization
218 struct RepRewardRate
220 float quest_rate; // We allow rate = 0.0 in database. For this case,
221 float creature_rate; // it means that no reputation are given at all
222 float spell_rate; // for this faction/rate type.
225 struct ReputationOnKillEntry
227 uint32 repfaction1;
228 uint32 repfaction2;
229 bool is_teamaward1;
230 uint32 reputation_max_cap1;
231 int32 repvalue1;
232 bool is_teamaward2;
233 uint32 reputation_max_cap2;
234 int32 repvalue2;
235 bool team_dependent;
238 struct RepSpilloverTemplate
240 uint32 faction[MAX_SPILLOVER_FACTIONS];
241 float faction_rate[MAX_SPILLOVER_FACTIONS];
242 uint32 faction_rank[MAX_SPILLOVER_FACTIONS];
245 struct PointOfInterest
247 uint32 entry;
248 float x;
249 float y;
250 uint32 icon;
251 uint32 flags;
252 uint32 data;
253 std::string icon_name;
256 struct GossipMenuItems
258 uint32 menu_id;
259 uint32 id;
260 uint8 option_icon;
261 std::string option_text;
262 uint32 option_id;
263 uint32 npc_option_npcflag;
264 int32 action_menu_id;
265 uint32 action_poi_id;
266 uint32 action_script_id;
267 bool box_coded;
268 uint32 box_money;
269 std::string box_text;
270 uint16 conditionId;
273 struct GossipMenus
275 uint32 entry;
276 uint32 text_id;
277 uint32 script_id;
278 uint16 conditionId;
281 typedef std::multimap<uint32, GossipMenus> GossipMenusMap;
282 typedef std::pair<GossipMenusMap::const_iterator, GossipMenusMap::const_iterator> GossipMenusMapBounds;
283 typedef std::multimap<uint32, GossipMenuItems> GossipMenuItemsMap;
284 typedef std::pair<GossipMenuItemsMap::const_iterator, GossipMenuItemsMap::const_iterator> GossipMenuItemsMapBounds;
286 struct QuestPOIPoint
288 int32 x;
289 int32 y;
291 QuestPOIPoint() : x(0), y(0) {}
292 QuestPOIPoint(int32 _x, int32 _y) : x(_x), y(_y) {}
295 struct QuestPOI
297 uint32 PoiId;
298 int32 ObjectiveIndex;
299 uint32 MapId;
300 uint32 MapAreaId;
301 uint32 FloorId;
302 uint32 Unk3;
303 uint32 Unk4;
304 std::vector<QuestPOIPoint> points;
306 QuestPOI() : PoiId(0), ObjectiveIndex(0), MapId(0), MapAreaId(0), FloorId(0), Unk3(0), Unk4(0) {}
307 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) {}
310 typedef std::vector<QuestPOI> QuestPOIVector;
311 typedef UNORDERED_MAP<uint32, QuestPOIVector> QuestPOIMap;
313 struct QuestPhaseMaps
315 uint16 MapId;
316 uint32 PhaseMask;
318 QuestPhaseMaps(uint16 mapId, uint32 phaseMask) : MapId(mapId), PhaseMask(phaseMask) {}
321 typedef std::vector<QuestPhaseMaps> QuestPhaseMapsVector;
322 typedef UNORDERED_MAP<uint32, QuestPhaseMapsVector> QuestPhaseMapsMap;
324 #define WEATHER_SEASONS 4
325 struct WeatherSeasonChances
327 uint32 rainChance;
328 uint32 snowChance;
329 uint32 stormChance;
332 struct WeatherZoneChances
334 WeatherSeasonChances data[WEATHER_SEASONS];
337 struct DungeonEncounter
339 DungeonEncounter(DungeonEncounterEntry const* _dbcEntry, EncounterCreditType _creditType, uint32 _creditEntry, uint32 _lastEncounterDungeon)
340 : dbcEntry(_dbcEntry), creditType(_creditType), creditEntry(_creditEntry), lastEncounterDungeon(_lastEncounterDungeon) { }
341 DungeonEncounterEntry const* dbcEntry;
342 EncounterCreditType creditType;
343 uint32 creditEntry;
344 uint32 lastEncounterDungeon;
347 typedef std::multimap<uint32, DungeonEncounter const*> DungeonEncounterMap;
348 typedef std::pair<DungeonEncounterMap::const_iterator, DungeonEncounterMap::const_iterator> DungeonEncounterMapBounds;
350 struct GraveYardData
352 uint32 safeLocId;
353 Team team;
355 typedef std::multimap < uint32 /*zoneId*/, GraveYardData > GraveYardMap;
356 typedef std::pair<GraveYardMap::const_iterator, GraveYardMap::const_iterator> GraveYardMapBounds;
358 enum ConditionType
360 // // value1 value2 for the Condition enumed
361 CONDITION_NOT = -3, // cond-id-1 0 returns !cond-id-1
362 CONDITION_OR = -2, // cond-id-1 cond-id-2 returns cond-id-1 OR cond-id-2
363 CONDITION_AND = -1, // cond-id-1 cond-id-2 returns cond-id-1 AND cond-id-2
364 CONDITION_NONE = 0, // 0 0
365 CONDITION_AURA = 1, // spell_id effindex
366 CONDITION_ITEM = 2, // item_id count check present req. amount items in inventory
367 CONDITION_ITEM_EQUIPPED = 3, // item_id 0
368 CONDITION_AREAID = 4, // area_id 0, 1 (0: in (sub)area, 1: not in (sub)area)
369 CONDITION_REPUTATION_RANK_MIN = 5, // faction_id min_rank
370 CONDITION_TEAM = 6, // player_team 0, (469 - Alliance 67 - Horde)
371 CONDITION_SKILL = 7, // skill_id skill_value
372 CONDITION_QUESTREWARDED = 8, // quest_id 0
373 CONDITION_QUESTTAKEN = 9, // quest_id 0,1,2 for condition true while quest active (0 any state, 1 if quest incomplete, 2 if quest completed).
374 CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD commission aura active
375 CONDITION_NO_AURA = 11, // spell_id effindex
376 CONDITION_ACTIVE_GAME_EVENT = 12, // event_id 0
377 CONDITION_AREA_FLAG = 13, // area_flag area_flag_not
378 CONDITION_RACE_CLASS = 14, // race_mask class_mask
379 CONDITION_LEVEL = 15, // player_level 0, 1 or 2 (0: equal to, 1: equal or higher than, 2: equal or less than)
380 CONDITION_NOITEM = 16, // item_id count check not present req. amount items in inventory
381 CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell)
382 CONDITION_INSTANCE_SCRIPT = 18, // map_id instance_condition_id (instance script specific enum)
383 CONDITION_QUESTAVAILABLE = 19, // quest_id 0 for case when loot/gossip possible only if player can start quest
384 CONDITION_ACHIEVEMENT = 20, // ach_id 0, 1 (0: has achievement, 1: hasn't achievement) for player
385 CONDITION_ACHIEVEMENT_REALM = 21, // ach_id 0, 1 (0: has achievement, 1: hasn't achievement) for server
386 CONDITION_QUEST_NONE = 22, // quest_id 0 (quest did not take and not rewarded)
387 CONDITION_ITEM_WITH_BANK = 23, // item_id count check present req. amount items in inventory or bank
388 CONDITION_NOITEM_WITH_BANK = 24, // item_id count check not present req. amount items in inventory or bank
389 CONDITION_NOT_ACTIVE_GAME_EVENT = 25, // event_id 0
390 CONDITION_ACTIVE_HOLIDAY = 26, // holiday_id 0 preferred use instead CONDITION_ACTIVE_GAME_EVENT when possible
391 CONDITION_NOT_ACTIVE_HOLIDAY = 27, // holiday_id 0 preferred use instead CONDITION_NOT_ACTIVE_GAME_EVENT when possible
392 CONDITION_LEARNABLE_ABILITY = 28, // spell_id 0 or item_id
393 // True when player can learn ability (using min skill value from SkillLineAbility).
394 // Item_id can be defined in addition, to check if player has one (1) item in inventory or bank.
395 // When player has spell or has item (when defined), condition return false.
396 CONDITION_SKILL_BELOW = 29, // skill_id skill_value
397 // True if player has skill skill_id and skill less than (and not equal) skill_value (for skill_value > 1)
398 // If skill_value == 1, then true if player has not skill skill_id
399 CONDITION_REPUTATION_RANK_MAX = 30, // faction_id max_rank
400 CONDITION_COMPLETED_ENCOUNTER = 31, // encounter_id encounter_id2 encounter_id[2] = DungeonEncounter(dbc).id (if value2 provided it will return value1 OR value2)
403 class PlayerCondition
405 public:
406 // Default constructor, required for SQL Storage (Will give errors if used elsewise)
407 PlayerCondition() : m_entry(0), m_condition(CONDITION_AND), m_value1(0), m_value2(0) {}
409 PlayerCondition(uint16 _entry, int16 _condition, uint32 _value1, uint32 _value2)
410 : m_entry(_entry), m_condition(ConditionType(_condition)), m_value1(_value1), m_value2(_value2) {}
412 // Checks correctness of values
413 bool IsValid() const { return IsValid(m_entry, m_condition, m_value1, m_value2); }
414 static bool IsValid(uint16 entry, ConditionType condition, uint32 value1, uint32 value2);
416 bool Meets(Player const* pPlayer) const; // Checks if the player meets the condition
418 private:
419 uint16 m_entry; // entry of the condition
420 ConditionType m_condition; // additional condition type
421 uint32 m_value1; // data for the condition - see ConditionType definition
422 uint32 m_value2;
425 // NPC gossip text id
426 typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap;
428 typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap;
429 typedef UNORDERED_MAP<uint32, TrainerSpellData> CacheTrainerSpellMap;
431 enum SkillRangeType
433 SKILL_RANGE_LANGUAGE, // 300..300
434 SKILL_RANGE_LEVEL, // 1..max skill for level
435 SKILL_RANGE_MONO, // 1..1, grey monolite bar
436 SKILL_RANGE_RANK, // 1..skill for known rank
437 SKILL_RANGE_NONE, // 0..0 always
440 SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial);
442 #define MAX_PLAYER_NAME 12 // max allowed by client name length
443 #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
444 #define MAX_PET_NAME 12 // max allowed by client name length
445 #define MAX_CHARTER_NAME 24 // max allowed by client name length
447 bool normalizePlayerName(std::string& name);
449 struct MANGOS_DLL_SPEC LanguageDesc
451 Language lang_id;
452 uint32 spell_id;
453 uint32 skill_id;
456 extern LanguageDesc lang_description[LANGUAGES_COUNT];
457 MANGOS_DLL_SPEC LanguageDesc const* GetLanguageDescByID(uint32 lang);
459 class PlayerDumpReader;
461 template<typename T>
462 class IdGenerator
464 public: // constructors
465 explicit IdGenerator(char const* _name) : m_name(_name), m_nextGuid(1) {}
467 public: // modifiers
468 void Set(T val) { m_nextGuid = val; }
469 T Generate();
471 public: // accessors
472 T GetNextAfterMaxUsed() const { return m_nextGuid; }
474 private: // fields
475 char const* m_name;
476 T m_nextGuid;
479 class ObjectMgr
481 friend class PlayerDumpReader;
483 public:
484 ObjectMgr();
485 ~ObjectMgr();
487 typedef UNORDERED_MAP<uint32, Item*> ItemMap;
489 typedef UNORDERED_MAP<uint32, Group*> GroupMap;
491 typedef UNORDERED_MAP<uint32, ArenaTeam*> ArenaTeamMap;
493 typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
495 typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
497 typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateMap;
498 typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
499 typedef UNORDERED_MAP<uint32, RepSpilloverTemplate> RepSpilloverTemplateMap;
501 typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
503 typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
505 void LoadGameobjectInfo();
506 void AddGameobjectInfo(GameObjectInfo* goinfo);
508 void PackGroupIds();
509 Group* GetGroupById(uint32 id) const;
510 void AddGroup(Group* group);
511 void RemoveGroup(Group* group);
513 ArenaTeam* GetArenaTeamById(uint32 arenateamid) const;
514 ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const;
515 ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid) const;
516 void AddArenaTeam(ArenaTeam* arenaTeam);
517 void RemoveArenaTeam(uint32 Id);
518 ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); }
519 ArenaTeamMap::iterator GetArenaTeamMapEnd() { return mArenaTeamMap.end(); }
521 CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id) const;
522 uint32 GetCreatureModelAlternativeModel(uint32 modelId) const;
524 PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const;
526 void GetPlayerClassLevelInfo(uint32 class_, uint32 level, uint32& baseHP, uint32& baseMana) const;
528 PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
530 if (race >= MAX_RACES) return NULL;
531 if (class_ >= MAX_CLASSES) return NULL;
532 PlayerInfo const* info = &playerInfo[race][class_];
533 if (info->displayId_m == 0 || info->displayId_f == 0) return NULL;
534 return info;
536 void GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const;
538 ObjectGuid GetPlayerGuidByName(std::string name) const;
539 bool GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const;
540 Team GetPlayerTeamByGUID(ObjectGuid guid) const;
541 uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const;
542 uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const;
544 uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Team team);
545 void GetTaxiPath(uint32 source, uint32 destination, uint32& path, uint32& cost);
546 uint32 GetTaxiMountDisplayId(uint32 id, Team team, bool allowed_alt_team = false);
548 Quest const* GetQuestTemplate(uint32 quest_id) const
550 QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
551 return itr != mQuestTemplates.end() ? itr->second : NULL;
553 QuestMap const& GetQuestTemplates() const { return mQuestTemplates; }
555 uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
557 QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
558 if (itr != mQuestAreaTriggerMap.end())
559 return itr->second;
560 return 0;
562 bool IsTavernAreaTrigger(uint32 Trigger_ID) const
564 return mTavernAreaTriggerSet.find(Trigger_ID) != mTavernAreaTriggerSet.end();
567 bool IsGameObjectForQuests(uint32 entry) const
569 return mGameObjectForQuestSet.find(entry) != mGameObjectForQuestSet.end();
572 GossipText const* GetGossipText(uint32 Text_ID) const;
574 WorldSafeLocsEntry const* GetClosestGraveYard(float x, float y, float z, uint32 MapId, Team team);
575 bool AddGraveYardLink(uint32 id, uint32 zone, Team team, bool inDB = true);
576 void SetGraveYardLinkTeam(uint32 id, uint32 zoneId, Team team);
577 void LoadGraveyardZones();
578 GraveYardData const* FindGraveYardData(uint32 id, uint32 zone) const;
580 AreaTrigger const* GetAreaTrigger(uint32 trigger) const
582 AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger);
583 if (itr != mAreaTriggers.end())
584 return &itr->second;
585 return NULL;
588 AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
589 AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
591 RepRewardRate const* GetRepRewardRate(uint32 factionId) const
593 RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId);
594 if (itr != m_RepRewardRateMap.end())
595 return &itr->second;
597 return NULL;
600 ReputationOnKillEntry const* GetReputationOnKillEntry(uint32 id) const
602 RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
603 if (itr != mRepOnKill.end())
604 return &itr->second;
605 return NULL;
608 RepSpilloverTemplate const* GetRepSpilloverTemplate(uint32 factionId) const
610 RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId);
611 if (itr != m_RepSpilloverTemplateMap.end())
612 return &itr->second;
614 return NULL;
617 PointOfInterest const* GetPointOfInterest(uint32 id) const
619 PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
620 if (itr != mPointsOfInterest.end())
621 return &itr->second;
622 return NULL;
625 QuestPOIVector const* GetQuestPOIVector(uint32 questId)
627 QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId);
628 if (itr != mQuestPOIMap.end())
629 return &itr->second;
630 return NULL;
633 QuestPhaseMapsVector const* GetQuestPhaseMapVector(uint32 questId)
635 QuestPhaseMapsMap::const_iterator itr = mQuestPhaseMap.find(questId);
636 if(itr != mQuestPhaseMap.end())
637 return &itr->second;
639 return NULL;
642 // Static wrappers for various accessors
643 static GameObjectInfo const* GetGameObjectInfo(uint32 id); ///< Wrapper for sGOStorage.LookupEntry
644 static Player* GetPlayer(const char* name); ///< Wrapper for ObjectAccessor::FindPlayerByName
645 static Player* GetPlayer(ObjectGuid guid, bool inWorld = true); ///< Wrapper for ObjectAccessor::FindPlayer
646 static CreatureInfo const* GetCreatureTemplate(uint32 id); ///< Wrapper for sCreatureStorage.LookupEntry
647 static CreatureModelInfo const* GetCreatureModelInfo(uint32 modelid); ///< Wrapper for sCreatureModelStorage.LookupEntry
648 static EquipmentInfo const* GetEquipmentInfo(uint32 entry); ///< Wrapper for sEquipmentStorage.LookupEntry
649 static CreatureDataAddon const* GetCreatureAddon(uint32 lowguid); ///< Wrapper for sCreatureDataAddonStorage.LookupEntry
650 static CreatureDataAddon const* GetCreatureTemplateAddon(uint32 entry); ///< Wrapper for sCreatureInfoAddonStorage.LookupEntry
651 static ItemPrototype const* GetItemPrototype(uint32 id); ///< Wrapper for sItemStorage.LookupEntry
652 static InstanceTemplate const* GetInstanceTemplate(uint32 map); ///< Wrapper for sInstanceTemplate.LookupEntry
653 static WorldTemplate const* GetWorldTemplate(uint32 map); ///< Wrapper for sWorldTemplate.LookupEntry
655 // Loading functions
656 void LoadArenaTeams();
657 void LoadGroups();
658 void LoadQuests();
659 void LoadQuestRelations()
661 LoadGameobjectQuestRelations();
662 LoadGameobjectInvolvedRelations();
663 LoadCreatureQuestRelations();
664 LoadCreatureInvolvedRelations();
666 void LoadGameobjectQuestRelations();
667 void LoadGameobjectInvolvedRelations();
668 void LoadCreatureQuestRelations();
669 void LoadCreatureInvolvedRelations();
671 bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
672 bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase, "mangos_string", MIN_MANGOS_STRING_ID, MAX_MANGOS_STRING_ID); }
673 void LoadCreatureLocales();
674 void LoadCreatureTemplates();
675 void LoadCreatures();
676 void LoadCreatureAddons();
677 void LoadCreatureModelInfo();
678 void LoadCreatureModelRace();
679 void LoadEquipmentTemplates();
680 void LoadGameObjectLocales();
681 void LoadGameObjects();
682 void LoadGameObjectAddon();
683 void LoadItemPrototypes();
684 void LoadItemConverts();
685 void LoadItemExpireConverts();
686 void LoadItemRequiredTarget();
687 void LoadItemLocales();
688 void LoadQuestLocales();
689 void LoadGossipTextLocales();
690 void LoadPageTextLocales();
691 void LoadGossipMenuItemsLocales();
692 void LoadPointOfInterestLocales();
693 void LoadInstanceEncounters();
694 void LoadInstanceTemplate();
695 void LoadWorldTemplate();
696 void LoadConditions();
697 void LoadMailLevelRewards();
699 void LoadGossipText();
701 void LoadAreaTriggerTeleports();
702 void LoadQuestAreaTriggers();
703 void LoadTavernAreaTriggers();
704 void LoadGameObjectForQuests();
706 void LoadPageTexts();
708 void LoadPlayerInfo();
709 void LoadPetLevelInfo();
710 void LoadExplorationBaseXP();
711 void LoadPetNames();
712 void LoadPetNumber();
713 void LoadCorpses();
714 void LoadFishingBaseSkillLevel();
716 void LoadReputationRewardRate();
717 void LoadReputationOnKill();
718 void LoadReputationSpilloverTemplate();
720 void LoadPointsOfInterest();
721 void LoadQuestPOI();
722 void LoadQuestPhaseMaps();
724 void LoadNPCSpellClickSpells();
725 void LoadCreatureTemplateSpells();
727 void LoadWeatherZoneChances();
728 void LoadGameTele();
730 void LoadNpcGossips();
732 void LoadGossipMenus();
734 void LoadVendorTemplates();
735 void LoadVendors() { LoadVendors("npc_vendor", false); }
736 void LoadTrainerTemplates();
737 void LoadTrainers() { LoadTrainers("npc_trainer", false); }
739 void LoadVehicleAccessory();
741 std::string GeneratePetName(uint32 entry);
742 uint32 GetBaseXP(uint32 level) const;
743 uint32 GetXPForLevel(uint32 level) const;
744 uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level) / 20; }
746 int32 GetFishingBaseSkillLevel(uint32 entry) const
748 FishingBaseSkillMap::const_iterator itr = mFishingBaseForArea.find(entry);
749 return itr != mFishingBaseForArea.end() ? itr->second : 0;
752 void ReturnOrDeleteOldMails(bool serverUp);
754 void SetHighestGuids();
756 // used for set initial guid counter for map local guids
757 uint32 GetFirstTemporaryCreatureLowGuid() const { return m_FirstTemporaryCreatureGuid; }
758 uint32 GetFirstTemporaryGameObjectLowGuid() const { return m_FirstTemporaryGameObjectGuid; }
760 // used in .npc add/.gobject add commands for adding static spawns
761 uint32 GenerateStaticCreatureLowGuid() { if (m_StaticCreatureGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryCreatureGuid) return 0; return m_StaticCreatureGuids.Generate(); }
762 uint32 GenerateStaticGameObjectLowGuid() { if (m_StaticGameObjectGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryGameObjectGuid) return 0; return m_StaticGameObjectGuids.Generate(); }
764 uint32 GeneratePlayerLowGuid() { return m_CharGuids.Generate(); }
765 uint32 GenerateItemLowGuid() { return m_ItemGuids.Generate(); }
766 uint32 GenerateCorpseLowGuid() { return m_CorpseGuids.Generate(); }
767 uint32 GenerateInstanceLowGuid() { return m_InstanceGuids.Generate(); }
768 uint32 GenerateGroupLowGuid() { return m_GroupGuids.Generate(); }
770 uint32 GenerateArenaTeamId() { return m_ArenaTeamIds.Generate(); }
771 uint32 GenerateAuctionID() { return m_AuctionIds.Generate(); }
772 uint64 GenerateEquipmentSetGuid() { return m_EquipmentSetIds.Generate(); }
773 uint32 GenerateGuildId() { return m_GuildIds.Generate(); }
774 // uint32 GenerateItemTextID() { return m_ItemGuids.Generate(); }
775 uint32 GenerateMailID() { return m_MailIds.Generate(); }
776 uint32 GeneratePetNumber() { return m_PetNumbers.Generate(); }
778 MailLevelReward const* GetMailLevelReward(uint32 level, uint32 raceMask)
780 MailLevelRewardMap::const_iterator map_itr = m_mailLevelRewardMap.find(level);
781 if (map_itr == m_mailLevelRewardMap.end())
782 return NULL;
784 for (MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr)
785 if (set_itr->raceMask & raceMask)
786 return &*set_itr;
788 return NULL;
791 WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const
793 WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id);
794 if (itr != mWeatherZoneMap.end())
795 return &itr->second;
796 else
797 return NULL;
800 CreatureDataPair const* GetCreatureDataPair(uint32 guid) const
802 CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid);
803 if (itr == mCreatureDataMap.end()) return NULL;
804 return &*itr;
807 CreatureData const* GetCreatureData(uint32 guid) const
809 CreatureDataPair const* dataPair = GetCreatureDataPair(guid);
810 return dataPair ? &dataPair->second : NULL;
813 CreatureData& NewOrExistCreatureData(uint32 guid) { return mCreatureDataMap[guid]; }
814 void DeleteCreatureData(uint32 guid);
816 template<typename Worker>
817 void DoCreatureData(Worker& worker) const
819 for (CreatureDataMap::const_iterator itr = mCreatureDataMap.begin(); itr != mCreatureDataMap.end(); ++itr)
820 if (worker(*itr))
821 break;
824 CreatureLocale const* GetCreatureLocale(uint32 entry) const
826 CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry);
827 if (itr == mCreatureLocaleMap.end()) return NULL;
828 return &itr->second;
831 void GetCreatureLocaleStrings(uint32 entry, int32 loc_idx, char const** namePtr, char const** subnamePtr = NULL) const;
833 GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
835 GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry);
836 if (itr == mGameObjectLocaleMap.end()) return NULL;
837 return &itr->second;
840 ItemLocale const* GetItemLocale(uint32 entry) const
842 ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry);
843 if (itr == mItemLocaleMap.end()) return NULL;
844 return &itr->second;
847 void GetItemLocaleStrings(uint32 entry, int32 loc_idx, std::string* namePtr, std::string* descriptionPtr = NULL) const;
849 QuestLocale const* GetQuestLocale(uint32 entry) const
851 QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry);
852 if (itr == mQuestLocaleMap.end()) return NULL;
853 return &itr->second;
856 void GetQuestLocaleStrings(uint32 entry, int32 loc_idx, std::string* titlePtr) const;
858 NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
860 NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry);
861 if (itr == mNpcTextLocaleMap.end()) return NULL;
862 return &itr->second;
865 typedef std::string NpcTextArray[MAX_GOSSIP_TEXT_OPTIONS];
866 void GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, NpcTextArray* text0_Ptr, NpcTextArray* text1_Ptr) const;
867 void GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::string* text0_0_Ptr, std::string* text1_0_Ptr) const;
869 PageTextLocale const* GetPageTextLocale(uint32 entry) const
871 PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry);
872 if (itr == mPageTextLocaleMap.end()) return NULL;
873 return &itr->second;
876 GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const
878 GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry);
879 if (itr == mGossipMenuItemsLocaleMap.end()) return NULL;
880 return &itr->second;
883 PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const
885 PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id);
886 if (itr == mPointOfInterestLocaleMap.end()) return NULL;
887 return &itr->second;
890 GameObjectDataPair const* GetGODataPair(uint32 guid) const
892 GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid);
893 if (itr == mGameObjectDataMap.end()) return NULL;
894 return &*itr;
897 GameObjectData const* GetGOData(uint32 guid) const
899 GameObjectDataPair const* dataPair = GetGODataPair(guid);
900 return dataPair ? &dataPair->second : NULL;
903 GameObjectData& NewGOData(uint32 guid) { return mGameObjectDataMap[guid]; }
904 void DeleteGOData(uint32 guid);
906 template<typename Worker>
907 void DoGOData(Worker& worker) const
909 for (GameObjectDataMap::const_iterator itr = mGameObjectDataMap.begin(); itr != mGameObjectDataMap.end(); ++itr)
910 if (worker(*itr)) // arg = GameObjectDataPair
911 break;
914 MangosStringLocale const* GetMangosStringLocale(int32 entry) const
916 MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry);
917 if (itr == mMangosStringLocaleMap.end()) return NULL;
918 return &itr->second;
921 const char* GetMangosString(int32 entry, int locale_idx) const;
922 const char* GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry, DBCLocaleIndex); }
923 int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
924 void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); }
926 // global grid objects state (static DB spawns, global spawn mods from gameevent system)
927 CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id)
929 return mMapObjectGuids[MAKE_PAIR32(mapid, spawnMode)][cell_id];
932 // modifiers for global grid objects state (static DB spawns, global spawn mods from gameevent system)
933 // Don't must be used for modify instance specific spawn state modifications
934 void AddCreatureToGrid(uint32 guid, CreatureData const* data);
935 void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data);
936 void AddGameobjectToGrid(uint32 guid, GameObjectData const* data);
937 void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data);
938 void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance);
939 void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid);
941 // reserved names
942 void LoadReservedPlayersNames();
943 bool IsReservedName(const std::string& name) const;
945 // name with valid structure and symbols
946 static uint8 CheckPlayerName(const std::string& name, bool create = false);
947 static PetNameInvalidReason CheckPetName(const std::string& name);
948 static bool IsValidCharterName(const std::string& name);
950 static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names);
952 int GetIndexForLocale(LocaleConstant loc);
953 LocaleConstant GetLocaleForIndex(int i);
955 // Check if a player meets condition conditionId
956 bool IsPlayerMeetToCondition(Player const* pPlayer, uint16 conditionId) const;
958 GameTele const* GetGameTele(uint32 id) const
960 GameTeleMap::const_iterator itr = m_GameTeleMap.find(id);
961 if (itr == m_GameTeleMap.end()) return NULL;
962 return &itr->second;
965 GameTele const* GetGameTele(const std::string& name) const;
966 GameTeleMap const& GetGameTeleMap() const { return m_GameTeleMap; }
967 bool AddGameTele(GameTele& data);
968 bool DeleteGameTele(const std::string& name);
970 uint32 GetNpcGossip(uint32 entry) const
972 CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry);
973 if (iter == m_mCacheNpcTextIdMap.end())
974 return 0;
976 return iter->second;
979 TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const
981 CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry);
982 if (iter == m_mCacheTrainerSpellMap.end())
983 return NULL;
985 return &iter->second;
988 TrainerSpellData const* GetNpcTrainerTemplateSpells(uint32 entry) const
990 CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry);
991 if (iter == m_mCacheTrainerTemplateSpellMap.end())
992 return NULL;
994 return &iter->second;
997 VendorItemData const* GetNpcVendorItemList(uint32 entry) const
999 CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry);
1000 if (iter == m_mCacheVendorItemMap.end())
1001 return NULL;
1003 return &iter->second;
1006 VendorItemData const* GetNpcVendorTemplateItemList(uint32 entry) const
1008 CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry);
1009 if (iter == m_mCacheVendorTemplateItemMap.end())
1010 return NULL;
1012 return &iter->second;
1015 void AddVendorItem(uint32 entry, uint32 item, uint8 type, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost);
1016 bool RemoveVendorItem(uint32 entry, uint32 item, uint8 type);
1017 bool IsVendorItemValid(bool isTemplate, char const* tableName, uint32 vendor_entry, uint32 item, uint8 type, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL) const;
1019 int GetOrNewIndexForLocale(LocaleConstant loc);
1021 SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const
1023 return mSpellClickInfoMap.equal_range(creature_id);
1026 uint32 GetItemConvert(uint32 itemEntry, uint32 raceMask) const
1028 ItemConvertMap::const_iterator iter = m_ItemConvert.find(itemEntry);
1029 if (iter == m_ItemConvert.end())
1030 return 0;
1032 ItemPrototype const* proto = GetItemPrototype(iter->second);
1033 return (proto && proto->AllowableRace & raceMask) ? iter->second : 0;
1036 uint32 GetItemExpireConvert(uint32 itemEntry) const
1038 ItemConvertMap::const_iterator iter = m_ItemExpireConvert.find(itemEntry);
1039 return iter != m_ItemExpireConvert.end() ? iter->second : 0;
1042 ItemRequiredTargetMapBounds GetItemRequiredTargetMapBounds(uint32 uiItemEntry) const
1044 return m_ItemRequiredTarget.equal_range(uiItemEntry);
1047 DungeonEncounterMapBounds GetDungeonEncounterBounds(uint32 creditEntry) const
1049 return m_DungeonEncounters.equal_range(creditEntry);
1052 GossipMenusMapBounds GetGossipMenusMapBounds(uint32 uiMenuId) const
1054 return m_mGossipMenusMap.equal_range(uiMenuId);
1057 GossipMenuItemsMapBounds GetGossipMenuItemsMapBounds(uint32 uiMenuId) const
1059 return m_mGossipMenuItemsMap.equal_range(uiMenuId);
1062 ExclusiveQuestGroupsMapBounds GetExclusiveQuestGroupsMapBounds(int32 groupId) const
1064 return m_ExclusiveQuestGroups.equal_range(groupId);
1067 QuestRelationsMapBounds GetCreatureQuestRelationsMapBounds(uint32 entry) const
1069 return m_CreatureQuestRelations.equal_range(entry);
1072 QuestRelationsMapBounds GetCreatureQuestInvolvedRelationsMapBounds(uint32 entry) const
1074 return m_CreatureQuestInvolvedRelations.equal_range(entry);
1077 QuestRelationsMapBounds GetGOQuestRelationsMapBounds(uint32 entry) const
1079 return m_GOQuestRelations.equal_range(entry);
1082 QuestRelationsMapBounds GetGOQuestInvolvedRelationsMapBounds(uint32 entry) const
1084 return m_GOQuestInvolvedRelations.equal_range(entry);
1087 QuestRelationsMap& GetCreatureQuestRelationsMap() { return m_CreatureQuestRelations; }
1089 uint32 GetModelForRace(uint32 sourceModelId, uint32 racemask);
1090 protected:
1092 // first free id for selected id type
1093 IdGenerator<uint32> m_ArenaTeamIds;
1094 IdGenerator<uint32> m_AuctionIds;
1095 IdGenerator<uint64> m_EquipmentSetIds;
1096 IdGenerator<uint32> m_GuildIds;
1097 IdGenerator<uint32> m_MailIds;
1098 IdGenerator<uint32> m_PetNumbers;
1100 // initial free low guid for selected guid type for map local guids
1101 uint32 m_FirstTemporaryCreatureGuid;
1102 uint32 m_FirstTemporaryGameObjectGuid;
1104 // guids from reserved range for use in .npc add/.gobject add commands for adding new static spawns (saved in DB) from client.
1105 ObjectGuidGenerator<HIGHGUID_UNIT> m_StaticCreatureGuids;
1106 ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_StaticGameObjectGuids;
1108 // first free low guid for selected guid type
1109 ObjectGuidGenerator<HIGHGUID_PLAYER> m_CharGuids;
1110 ObjectGuidGenerator<HIGHGUID_ITEM> m_ItemGuids;
1111 ObjectGuidGenerator<HIGHGUID_CORPSE> m_CorpseGuids;
1112 ObjectGuidGenerator<HIGHGUID_INSTANCE> m_InstanceGuids;
1113 ObjectGuidGenerator<HIGHGUID_GROUP> m_GroupGuids;
1115 QuestMap mQuestTemplates;
1117 typedef UNORDERED_MAP<uint32, GossipText> GossipTextMap;
1118 typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap;
1119 typedef std::set<uint32> TavernAreaTriggerSet;
1120 typedef std::set<uint32> GameObjectForQuestSet;
1122 typedef std::multimap<uint32, CreatureModelRace> CreatureModelRaceMap;
1123 typedef std::pair<CreatureModelRaceMap::const_iterator, CreatureModelRaceMap::const_iterator> CreatureModelRaceMapBounds;
1125 GroupMap mGroupMap;
1126 ArenaTeamMap mArenaTeamMap;
1128 QuestAreaTriggerMap mQuestAreaTriggerMap;
1129 TavernAreaTriggerSet mTavernAreaTriggerSet;
1130 GameObjectForQuestSet mGameObjectForQuestSet;
1131 GossipTextMap mGossipText;
1132 AreaTriggerMap mAreaTriggers;
1134 RepRewardRateMap m_RepRewardRateMap;
1135 RepOnKillMap mRepOnKill;
1136 RepSpilloverTemplateMap m_RepSpilloverTemplateMap;
1138 GossipMenusMap m_mGossipMenusMap;
1139 GossipMenuItemsMap m_mGossipMenuItemsMap;
1140 PointOfInterestMap mPointsOfInterest;
1142 QuestPOIMap mQuestPOIMap;
1143 QuestPhaseMapsMap mQuestPhaseMap;
1145 WeatherZoneMap mWeatherZoneMap;
1147 // character reserved names
1148 typedef std::set<std::wstring> ReservedNamesMap;
1149 ReservedNamesMap m_ReservedNames;
1151 GraveYardMap mGraveYardMap;
1153 GameTeleMap m_GameTeleMap;
1155 SpellClickInfoMap mSpellClickInfoMap;
1157 ItemConvertMap m_ItemConvert;
1158 ItemConvertMap m_ItemExpireConvert;
1159 ItemRequiredTargetMap m_ItemRequiredTarget;
1161 typedef std::vector<LocaleConstant> LocalForIndex;
1162 LocalForIndex m_LocalForIndex;
1164 ExclusiveQuestGroupsMap m_ExclusiveQuestGroups;
1166 QuestRelationsMap m_CreatureQuestRelations;
1167 QuestRelationsMap m_CreatureQuestInvolvedRelations;
1168 QuestRelationsMap m_GOQuestRelations;
1169 QuestRelationsMap m_GOQuestInvolvedRelations;
1171 int DBCLocaleIndex;
1173 private:
1174 void LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment);
1175 void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
1176 void LoadQuestRelationsHelper(QuestRelationsMap& map, char const* table);
1177 void LoadVendors(char const* tableName, bool isTemplates);
1178 void LoadTrainers(char const* tableName, bool isTemplates);
1180 void LoadGossipMenu(std::set<uint32>& gossipScriptSet);
1181 void LoadGossipMenuItems(std::set<uint32>& gossipScriptSet);
1183 MailLevelRewardMap m_mailLevelRewardMap;
1185 typedef std::map<uint32, PetLevelInfo*> PetLevelInfoMap;
1186 // PetLevelInfoMap[creature_id][level]
1187 PetLevelInfoMap petInfo; // [creature_id][level]
1189 void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
1190 PlayerInfo playerInfo[MAX_RACES][MAX_CLASSES];
1192 typedef std::vector<uint32> PlayerXPperLevel; // [level]
1193 PlayerXPperLevel mPlayerXPperLevel;
1195 typedef std::map<uint32, uint32> BaseXPMap; // [area level][base xp]
1196 BaseXPMap mBaseXPTable;
1198 typedef std::map<uint32, int32> FishingBaseSkillMap;// [areaId][base skill level]
1199 FishingBaseSkillMap mFishingBaseForArea;
1201 typedef std::map<uint32, std::vector<std::string> > HalfNameMap;
1202 HalfNameMap PetHalfName0;
1203 HalfNameMap PetHalfName1;
1205 MapObjectGuids mMapObjectGuids;
1206 CreatureDataMap mCreatureDataMap;
1207 CreatureLocaleMap mCreatureLocaleMap;
1208 GameObjectDataMap mGameObjectDataMap;
1209 GameObjectLocaleMap mGameObjectLocaleMap;
1210 ItemLocaleMap mItemLocaleMap;
1211 QuestLocaleMap mQuestLocaleMap;
1212 NpcTextLocaleMap mNpcTextLocaleMap;
1213 PageTextLocaleMap mPageTextLocaleMap;
1214 MangosStringLocaleMap mMangosStringLocaleMap;
1215 GossipMenuItemsLocaleMap mGossipMenuItemsLocaleMap;
1216 PointOfInterestLocaleMap mPointOfInterestLocaleMap;
1217 DungeonEncounterMap m_DungeonEncounters;
1219 CreatureModelRaceMap m_mCreatureModelRaceMap;
1221 CacheNpcTextIdMap m_mCacheNpcTextIdMap;
1222 CacheVendorItemMap m_mCacheVendorTemplateItemMap;
1223 CacheVendorItemMap m_mCacheVendorItemMap;
1224 CacheTrainerSpellMap m_mCacheTrainerTemplateSpellMap;
1225 CacheTrainerSpellMap m_mCacheTrainerSpellMap;
1228 #define sObjectMgr MaNGOS::Singleton<ObjectMgr>::Instance()
1230 // scripting access functions
1231 MANGOS_DLL_SPEC bool LoadMangosStrings(DatabaseType& db, char const* table, int32 start_value = MAX_CREATURE_AI_TEXT_STRING_ID, int32 end_value = std::numeric_limits<int32>::min());
1232 MANGOS_DLL_SPEC CreatureInfo const* GetCreatureTemplateStore(uint32 entry);
1233 MANGOS_DLL_SPEC Quest const* GetQuestTemplateStore(uint32 entry);
1235 #endif