2 * Copyright (C) 2005-2009 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
27 #include "GameObject.h"
31 #include "ItemPrototype.h"
32 #include "NPCHandler.h"
33 #include "Database/DatabaseEnv.h"
36 #include "ObjectAccessor.h"
37 #include "ObjectDefines.h"
38 #include "Policies/Singleton.h"
39 #include "Database/SQLStorage.h"
45 extern SQLStorage sCreatureStorage
;
46 extern SQLStorage sCreatureDataAddonStorage
;
47 extern SQLStorage sCreatureInfoAddonStorage
;
48 extern SQLStorage sCreatureModelStorage
;
49 extern SQLStorage sEquipmentStorage
;
50 extern SQLStorage sGOStorage
;
51 extern SQLStorage sPageTextStore
;
52 extern SQLStorage sItemStorage
;
53 extern SQLStorage sInstanceTemplate
;
70 std::wstring wnameLow
;
73 typedef UNORDERED_MAP
<uint32
, GameTele
> GameTeleMap
;
89 typedef std::multimap
<uint32
, ScriptInfo
> ScriptMap
;
90 typedef std::map
<uint32
, ScriptMap
> ScriptMapMap
;
91 extern ScriptMapMap sQuestEndScripts
;
92 extern ScriptMapMap sQuestStartScripts
;
93 extern ScriptMapMap sSpellScripts
;
94 extern ScriptMapMap sGameObjectScripts
;
95 extern ScriptMapMap sEventScripts
;
100 uint32 questStart
; // quest start (quest must be active or rewarded for spell apply)
101 uint32 questEnd
; // quest end (quest don't must be rewarded for spell apply)
102 bool questStartCanActive
; // if true then quest start can be active (not only rewarded)
106 bool IsFitToRequirements(Player
const* player
) const;
109 typedef std::multimap
<uint32
, SpellClickInfo
> SpellClickInfoMap
;
110 typedef std::pair
<SpellClickInfoMap::const_iterator
,SpellClickInfoMap::const_iterator
> SpellClickInfoMapBounds
;
116 uint32 requiredItem2
;
119 uint32 requiredQuest
;
120 uint32 requiredQuestHeroic
;
121 std::string requiredFailedText
;
126 float target_Orientation
;
129 typedef std::set
<uint32
> CellGuidSet
;
130 typedef std::map
<uint32
/*player guid*/,uint32
/*instance*/> CellCorpseSet
;
131 struct CellObjectGuids
133 CellGuidSet creatures
;
134 CellGuidSet gameobjects
;
135 CellCorpseSet corpses
;
137 typedef UNORDERED_MAP
<uint32
/*cell_id*/,CellObjectGuids
> CellObjectGuidsMap
;
138 typedef UNORDERED_MAP
<uint32
/*(mapid,spawnMode) pair*/,CellObjectGuidsMap
> MapObjectGuids
;
140 typedef UNORDERED_MAP
<uint64
/*(instance,guid) pair*/,time_t> RespawnTimes
;
143 // mangos string ranges
144 #define MIN_MANGOS_STRING_ID 1 // 'mangos_string'
145 #define MAX_MANGOS_STRING_ID 2000000000
146 #define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID // 'db_script_string'
147 #define MAX_DB_SCRIPT_STRING_ID 2000010000
148 #define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts'
149 #define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000)
151 struct MangosStringLocale
153 std::vector
<std::string
> Content
; // 0 -> default, i -> i-1 locale index
156 typedef UNORDERED_MAP
<uint32
,CreatureData
> CreatureDataMap
;
157 typedef UNORDERED_MAP
<uint32
,GameObjectData
> GameObjectDataMap
;
158 typedef UNORDERED_MAP
<uint32
,CreatureLocale
> CreatureLocaleMap
;
159 typedef UNORDERED_MAP
<uint32
,GameObjectLocale
> GameObjectLocaleMap
;
160 typedef UNORDERED_MAP
<uint32
,ItemLocale
> ItemLocaleMap
;
161 typedef UNORDERED_MAP
<uint32
,QuestLocale
> QuestLocaleMap
;
162 typedef UNORDERED_MAP
<uint32
,NpcTextLocale
> NpcTextLocaleMap
;
163 typedef UNORDERED_MAP
<uint32
,PageTextLocale
> PageTextLocaleMap
;
164 typedef UNORDERED_MAP
<int32
,MangosStringLocale
> MangosStringLocaleMap
;
165 typedef UNORDERED_MAP
<uint32
,NpcOptionLocale
> NpcOptionLocaleMap
;
166 typedef UNORDERED_MAP
<uint32
,PointOfInterestLocale
> PointOfInterestLocaleMap
;
168 typedef std::multimap
<uint32
,uint32
> QuestRelations
;
169 typedef std::multimap
<uint32
,ItemRequiredTarget
> ItemRequiredTargetMap
;
170 typedef std::pair
<ItemRequiredTargetMap::const_iterator
, ItemRequiredTargetMap::const_iterator
> ItemRequiredTargetMapBounds
;
174 PetLevelInfo() : health(0), mana(0) { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
176 uint16 stats
[MAX_STATS
];
182 struct ReputationOnKillEntry
187 uint32 reputation_max_cap1
;
190 uint32 reputation_max_cap2
;
195 struct PointOfInterest
203 std::string icon_name
;
206 #define WEATHER_SEASONS 4
207 struct WeatherSeasonChances
214 struct WeatherZoneChances
216 WeatherSeasonChances data
[WEATHER_SEASONS
];
224 typedef std::multimap
<uint32
,GraveYardData
> GraveYardMap
;
227 { // value1 value2 for the Condition enumed
228 CONDITION_NONE
= 0, // 0 0
229 CONDITION_AURA
= 1, // spell_id effindex
230 CONDITION_ITEM
= 2, // item_id count
231 CONDITION_ITEM_EQUIPPED
= 3, // item_id 0
232 CONDITION_ZONEID
= 4, // zone_id 0
233 CONDITION_REPUTATION_RANK
= 5, // faction_id min_rank
234 CONDITION_TEAM
= 6, // player_team 0, (469 - Alliance 67 - Horde)
235 CONDITION_SKILL
= 7, // skill_id skill_value
236 CONDITION_QUESTREWARDED
= 8, // quest_id 0
237 CONDITION_QUESTTAKEN
= 9, // quest_id 0, for condition true while quest active.
238 CONDITION_AD_COMMISSION_AURA
= 10, // 0 0, for condition true while one from AD commission aura active
239 CONDITION_NO_AURA
= 11, // spell_id effindex
240 CONDITION_ACTIVE_EVENT
= 12, // event_id
243 #define MAX_CONDITION 13 // maximum value in ConditionType enum
245 struct PlayerCondition
247 ConditionType condition
; // additional condition type
248 uint32 value1
; // data for the condition - see ConditionType definition
251 PlayerCondition(uint8 _condition
= 0, uint32 _value1
= 0, uint32 _value2
= 0)
252 : condition(ConditionType(_condition
)), value1(_value1
), value2(_value2
) {}
254 static bool IsValid(ConditionType condition
, uint32 value1
, uint32 value2
);
255 // Checks correctness of values
256 bool Meets(Player
const * APlayer
) const; // Checks if the player meets the condition
257 bool operator == (PlayerCondition
const& lc
) const
259 return (lc
.condition
== condition
&& lc
.value1
== value1
&& lc
.value2
== value2
);
263 // NPC gossip text id
264 typedef UNORDERED_MAP
<uint32
, uint32
> CacheNpcTextIdMap
;
265 typedef std::list
<GossipOption
> CacheNpcOptionList
;
267 typedef UNORDERED_MAP
<uint32
, VendorItemData
> CacheVendorItemMap
;
268 typedef UNORDERED_MAP
<uint32
, TrainerSpellData
> CacheTrainerSpellMap
;
272 SKILL_RANGE_LANGUAGE
, // 300..300
273 SKILL_RANGE_LEVEL
, // 1..max skill for level
274 SKILL_RANGE_MONO
, // 1..1, grey monolite bar
275 SKILL_RANGE_RANK
, // 1..skill for known rank
276 SKILL_RANGE_NONE
, // 0..0 always
279 SkillRangeType
GetSkillRangeType(SkillLineEntry
const *pSkill
, bool racial
);
281 #define MAX_PLAYER_NAME 12 // max allowed by client name length
282 #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
283 #define MAX_PET_NAME 12 // max allowed by client name length
284 #define MAX_CHARTER_NAME 24 // max allowed by client name length
286 bool normalizePlayerName(std::string
& name
);
288 struct MANGOS_DLL_SPEC LanguageDesc
295 extern LanguageDesc lang_description
[LANGUAGES_COUNT
];
296 MANGOS_DLL_SPEC LanguageDesc
const* GetLanguageDescByID(uint32 lang
);
298 class PlayerDumpReader
;
302 friend class PlayerDumpReader
;
308 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
310 typedef std::set
< Group
* > GroupSet
;
312 typedef UNORDERED_MAP
<uint32
, Guild
*> GuildMap
;
314 typedef UNORDERED_MAP
<uint32
, ArenaTeam
*> ArenaTeamMap
;
316 typedef UNORDERED_MAP
<uint32
, Quest
*> QuestMap
;
318 typedef UNORDERED_MAP
<uint32
, AreaTrigger
> AreaTriggerMap
;
320 typedef UNORDERED_MAP
<uint32
, uint32
> AreaTriggerScriptMap
;
322 typedef UNORDERED_MAP
<uint32
, ReputationOnKillEntry
> RepOnKillMap
;
323 typedef UNORDERED_MAP
<uint32
, PointOfInterest
> PointOfInterestMap
;
325 typedef UNORDERED_MAP
<uint32
, WeatherZoneChances
> WeatherZoneMap
;
327 typedef std::vector
<std::string
> ScriptNameMap
;
329 Player
* GetPlayer(const char* name
) const { return ObjectAccessor::Instance().FindPlayerByName(name
);}
330 Player
* GetPlayer(uint64 guid
) const { return ObjectAccessor::FindPlayer(guid
); }
332 static GameObjectInfo
const *GetGameObjectInfo(uint32 id
) { return sGOStorage
.LookupEntry
<GameObjectInfo
>(id
); }
334 void LoadGameobjectInfo();
335 void AddGameobjectInfo(GameObjectInfo
*goinfo
);
337 Group
* GetGroupByLeader(const uint64
&guid
) const;
338 void AddGroup(Group
* group
) { mGroupSet
.insert( group
); }
339 void RemoveGroup(Group
* group
) { mGroupSet
.erase( group
); }
341 Guild
* GetGuildByLeader(uint64
const&guid
) const;
342 Guild
* GetGuildById(uint32 GuildId
) const;
343 Guild
* GetGuildByName(const std::string
& guildname
) const;
344 std::string
GetGuildNameById(uint32 GuildId
) const;
345 void AddGuild(Guild
* guild
);
346 void RemoveGuild(uint32 Id
);
348 ArenaTeam
* GetArenaTeamById(uint32 arenateamid
) const;
349 ArenaTeam
* GetArenaTeamByName(const std::string
& arenateamname
) const;
350 ArenaTeam
* GetArenaTeamByCaptain(uint64
const& guid
) const;
351 void AddArenaTeam(ArenaTeam
* arenaTeam
);
352 void RemoveArenaTeam(uint32 Id
);
353 ArenaTeamMap::iterator
GetArenaTeamMapBegin() { return mArenaTeamMap
.begin(); }
354 ArenaTeamMap::iterator
GetArenaTeamMapEnd() { return mArenaTeamMap
.end(); }
356 static CreatureInfo
const *GetCreatureTemplate( uint32 id
);
357 CreatureModelInfo
const *GetCreatureModelInfo( uint32 modelid
);
358 CreatureModelInfo
const* GetCreatureModelRandomGender(uint32 display_id
);
359 uint32
ChooseDisplayId(uint32 team
, const CreatureInfo
*cinfo
, const CreatureData
*data
= NULL
);
360 EquipmentInfo
const *GetEquipmentInfo( uint32 entry
);
361 static CreatureDataAddon
const *GetCreatureAddon( uint32 lowguid
)
363 return sCreatureDataAddonStorage
.LookupEntry
<CreatureDataAddon
>(lowguid
);
366 static CreatureDataAddon
const *GetCreatureTemplateAddon( uint32 entry
)
368 return sCreatureInfoAddonStorage
.LookupEntry
<CreatureDataAddon
>(entry
);
371 static ItemPrototype
const* GetItemPrototype(uint32 id
) { return sItemStorage
.LookupEntry
<ItemPrototype
>(id
); }
373 static InstanceTemplate
const* GetInstanceTemplate(uint32 map
)
375 return sInstanceTemplate
.LookupEntry
<InstanceTemplate
>(map
);
378 PetLevelInfo
const* GetPetLevelInfo(uint32 creature_id
, uint32 level
) const;
380 PlayerClassInfo
const* GetPlayerClassInfo(uint32 class_
) const
382 if(class_
>= MAX_CLASSES
) return NULL
;
383 return &playerClassInfo
[class_
];
385 void GetPlayerClassLevelInfo(uint32 class_
,uint32 level
, PlayerClassLevelInfo
* info
) const;
387 PlayerInfo
const* GetPlayerInfo(uint32 race
, uint32 class_
) const
389 if(race
>= MAX_RACES
) return NULL
;
390 if(class_
>= MAX_CLASSES
) return NULL
;
391 PlayerInfo
const* info
= &playerInfo
[race
][class_
];
392 if(info
->displayId_m
==0 || info
->displayId_f
==0) return NULL
;
395 void GetPlayerLevelInfo(uint32 race
, uint32 class_
,uint32 level
, PlayerLevelInfo
* info
) const;
397 uint64
GetPlayerGUIDByName(std::string name
) const;
398 bool GetPlayerNameByGUID(const uint64
&guid
, std::string
&name
) const;
399 uint32
GetPlayerTeamByGUID(const uint64
&guid
) const;
400 uint32
GetPlayerAccountIdByGUID(const uint64
&guid
) const;
401 uint32
GetPlayerAccountIdByPlayerName(const std::string
& name
) const;
403 uint32
GetNearestTaxiNode( float x
, float y
, float z
, uint32 mapid
, uint32 team
);
404 void GetTaxiPath( uint32 source
, uint32 destination
, uint32
&path
, uint32
&cost
);
405 uint32
GetTaxiMountDisplayId( uint32 id
, uint32 team
, bool allowed_alt_team
= false);
406 void GetTaxiPathNodes( uint32 path
, Path
&pathnodes
, std::vector
<uint32
>& mapIds
);
407 void GetTransportPathNodes( uint32 path
, TransportPath
&pathnodes
);
409 Quest
const* GetQuestTemplate(uint32 quest_id
) const
411 QuestMap::const_iterator itr
= mQuestTemplates
.find(quest_id
);
412 return itr
!= mQuestTemplates
.end() ? itr
->second
: NULL
;
414 QuestMap
const& GetQuestTemplates() const { return mQuestTemplates
; }
416 uint32
GetQuestForAreaTrigger(uint32 Trigger_ID
) const
418 QuestAreaTriggerMap::const_iterator itr
= mQuestAreaTriggerMap
.find(Trigger_ID
);
419 if(itr
!= mQuestAreaTriggerMap
.end())
423 bool IsTavernAreaTrigger(uint32 Trigger_ID
) const
425 return mTavernAreaTriggerSet
.find(Trigger_ID
) != mTavernAreaTriggerSet
.end();
428 bool IsGameObjectForQuests(uint32 entry
) const
430 return mGameObjectForQuestSet
.find(entry
) != mGameObjectForQuestSet
.end();
433 GossipText
const* GetGossipText(uint32 Text_ID
) const;
435 WorldSafeLocsEntry
const *GetClosestGraveYard(float x
, float y
, float z
, uint32 MapId
, uint32 team
);
436 bool AddGraveYardLink(uint32 id
, uint32 zone
, uint32 team
, bool inDB
= true);
437 void LoadGraveyardZones();
438 GraveYardData
const* FindGraveYardData(uint32 id
, uint32 zone
);
440 AreaTrigger
const* GetAreaTrigger(uint32 trigger
) const
442 AreaTriggerMap::const_iterator itr
= mAreaTriggers
.find( trigger
);
443 if( itr
!= mAreaTriggers
.end( ) )
448 AreaTrigger
const* GetGoBackTrigger(uint32 Map
) const;
449 AreaTrigger
const* GetMapEntranceTrigger(uint32 Map
) const;
451 uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
453 ReputationOnKillEntry
const* GetReputationOnKilEntry(uint32 id
) const
455 RepOnKillMap::const_iterator itr
= mRepOnKill
.find(id
);
456 if(itr
!= mRepOnKill
.end())
461 PointOfInterest
const* GetPointOfInterest(uint32 id
) const
463 PointOfInterestMap::const_iterator itr
= mPointsOfInterest
.find(id
);
464 if(itr
!= mPointsOfInterest
.end())
470 void LoadArenaTeams();
473 void LoadQuestRelations()
475 LoadGameobjectQuestRelations();
476 LoadGameobjectInvolvedRelations();
477 LoadCreatureQuestRelations();
478 LoadCreatureInvolvedRelations();
480 void LoadGameobjectQuestRelations();
481 void LoadGameobjectInvolvedRelations();
482 void LoadCreatureQuestRelations();
483 void LoadCreatureInvolvedRelations();
485 QuestRelations mGOQuestRelations
;
486 QuestRelations mGOQuestInvolvedRelations
;
487 QuestRelations mCreatureQuestRelations
;
488 QuestRelations mCreatureQuestInvolvedRelations
;
490 void LoadGameObjectScripts();
491 void LoadQuestEndScripts();
492 void LoadQuestStartScripts();
493 void LoadEventScripts();
494 void LoadSpellScripts();
496 bool LoadMangosStrings(DatabaseType
& db
, char const* table
, int32 min_value
, int32 max_value
);
497 bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase
,"mangos_string",MIN_MANGOS_STRING_ID
,MAX_MANGOS_STRING_ID
); }
498 void LoadDbScriptStrings();
499 void LoadCreatureLocales();
500 void LoadCreatureTemplates();
501 void LoadCreatures();
502 void LoadCreatureRespawnTimes();
503 void LoadCreatureAddons();
504 void LoadCreatureModelInfo();
505 void LoadEquipmentTemplates();
506 void LoadGameObjectLocales();
507 void LoadGameobjects();
508 void LoadGameobjectRespawnTimes();
509 void LoadItemPrototypes();
510 void LoadItemRequiredTarget();
511 void LoadItemLocales();
512 void LoadQuestLocales();
513 void LoadNpcTextLocales();
514 void LoadPageTextLocales();
515 void LoadNpcOptionLocales();
516 void LoadPointOfInterestLocales();
517 void LoadInstanceTemplate();
519 void LoadGossipText();
521 void LoadAreaTriggerTeleports();
522 void LoadQuestAreaTriggers();
523 void LoadAreaTriggerScripts();
524 void LoadTavernAreaTriggers();
525 void LoadGameObjectForQuests();
527 void LoadItemTexts();
528 void LoadPageTexts();
530 void LoadPlayerInfo();
531 void LoadPetLevelInfo();
532 void LoadExplorationBaseXP();
534 void LoadPetNumber();
536 void LoadFishingBaseSkillLevel();
538 void LoadReputationOnKill();
539 void LoadPointsOfInterest();
541 void LoadNPCSpellClickSpells();
543 void LoadWeatherZoneChances();
546 void LoadNpcOptions();
547 void LoadNpcTextId();
549 void LoadTrainerSpell();
551 std::string
GeneratePetName(uint32 entry
);
552 uint32
GetBaseXP(uint32 level
);
553 uint32
GetXPForLevel(uint32 level
);
555 int32
GetFishingBaseSkillLevel(uint32 entry
) const
557 FishingBaseSkillMap::const_iterator itr
= mFishingBaseForArea
.find(entry
);
558 return itr
!= mFishingBaseForArea
.end() ? itr
->second
: 0;
561 void ReturnOrDeleteOldMails(bool serverUp
);
563 void SetHighestGuids();
564 uint32
GenerateLowGuid(HighGuid guidhigh
);
565 uint32
GenerateArenaTeamId();
566 uint32
GenerateAuctionID();
567 uint64
GenerateEquipmentSetGuid();
568 uint32
GenerateGuildId();
569 uint32
GenerateItemTextID();
570 uint32
GenerateMailID();
571 uint32
GeneratePetNumber();
573 uint32
CreateItemText(std::string text
);
574 void AddItemText(uint32 itemTextId
, std::string text
) { mItemTexts
[itemTextId
] = text
; }
575 std::string
GetItemText( uint32 id
)
577 ItemTextMap::const_iterator itr
= mItemTexts
.find( id
);
578 if ( itr
!= mItemTexts
.end() )
581 return "There is no info for this item";
584 typedef std::multimap
<int32
, uint32
> ExclusiveQuestGroups
;
585 ExclusiveQuestGroups mExclusiveQuestGroups
;
587 WeatherZoneChances
const* GetWeatherChances(uint32 zone_id
) const
589 WeatherZoneMap::const_iterator itr
= mWeatherZoneMap
.find(zone_id
);
590 if(itr
!= mWeatherZoneMap
.end())
596 CellObjectGuids
const& GetCellObjectGuids(uint16 mapid
, uint8 spawnMode
, uint32 cell_id
)
598 return mMapObjectGuids
[MAKE_PAIR32(mapid
,spawnMode
)][cell_id
];
601 CreatureData
const* GetCreatureData(uint32 guid
) const
603 CreatureDataMap::const_iterator itr
= mCreatureDataMap
.find(guid
);
604 if(itr
==mCreatureDataMap
.end()) return NULL
;
607 CreatureData
& NewOrExistCreatureData(uint32 guid
) { return mCreatureDataMap
[guid
]; }
608 void DeleteCreatureData(uint32 guid
);
609 CreatureLocale
const* GetCreatureLocale(uint32 entry
) const
611 CreatureLocaleMap::const_iterator itr
= mCreatureLocaleMap
.find(entry
);
612 if(itr
==mCreatureLocaleMap
.end()) return NULL
;
615 GameObjectLocale
const* GetGameObjectLocale(uint32 entry
) const
617 GameObjectLocaleMap::const_iterator itr
= mGameObjectLocaleMap
.find(entry
);
618 if(itr
==mGameObjectLocaleMap
.end()) return NULL
;
621 ItemLocale
const* GetItemLocale(uint32 entry
) const
623 ItemLocaleMap::const_iterator itr
= mItemLocaleMap
.find(entry
);
624 if(itr
==mItemLocaleMap
.end()) return NULL
;
627 QuestLocale
const* GetQuestLocale(uint32 entry
) const
629 QuestLocaleMap::const_iterator itr
= mQuestLocaleMap
.find(entry
);
630 if(itr
==mQuestLocaleMap
.end()) return NULL
;
633 NpcTextLocale
const* GetNpcTextLocale(uint32 entry
) const
635 NpcTextLocaleMap::const_iterator itr
= mNpcTextLocaleMap
.find(entry
);
636 if(itr
==mNpcTextLocaleMap
.end()) return NULL
;
639 PageTextLocale
const* GetPageTextLocale(uint32 entry
) const
641 PageTextLocaleMap::const_iterator itr
= mPageTextLocaleMap
.find(entry
);
642 if(itr
==mPageTextLocaleMap
.end()) return NULL
;
645 NpcOptionLocale
const* GetNpcOptionLocale(uint32 entry
) const
647 NpcOptionLocaleMap::const_iterator itr
= mNpcOptionLocaleMap
.find(entry
);
648 if(itr
==mNpcOptionLocaleMap
.end()) return NULL
;
651 PointOfInterestLocale
const* GetPointOfInterestLocale(uint32 poi_id
) const
653 PointOfInterestLocaleMap::const_iterator itr
= mPointOfInterestLocaleMap
.find(poi_id
);
654 if(itr
==mPointOfInterestLocaleMap
.end()) return NULL
;
658 GameObjectData
const* GetGOData(uint32 guid
) const
660 GameObjectDataMap::const_iterator itr
= mGameObjectDataMap
.find(guid
);
661 if(itr
==mGameObjectDataMap
.end()) return NULL
;
664 GameObjectData
& NewGOData(uint32 guid
) { return mGameObjectDataMap
[guid
]; }
665 void DeleteGOData(uint32 guid
);
667 MangosStringLocale
const* GetMangosStringLocale(int32 entry
) const
669 MangosStringLocaleMap::const_iterator itr
= mMangosStringLocaleMap
.find(entry
);
670 if(itr
==mMangosStringLocaleMap
.end()) return NULL
;
673 const char *GetMangosString(int32 entry
, int locale_idx
) const;
674 const char *GetMangosStringForDBCLocale(int32 entry
) const { return GetMangosString(entry
,DBCLocaleIndex
); }
675 int32
GetDBCLocaleIndex() const { return DBCLocaleIndex
; }
676 void SetDBCLocaleIndex(uint32 lang
) { DBCLocaleIndex
= GetIndexForLocale(LocaleConstant(lang
)); }
678 void AddCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
, uint32 instance
);
679 void DeleteCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
);
681 time_t GetCreatureRespawnTime(uint32 loguid
, uint32 instance
) { return mCreatureRespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
682 void SaveCreatureRespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
683 time_t GetGORespawnTime(uint32 loguid
, uint32 instance
) { return mGORespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
684 void SaveGORespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
685 void DeleteRespawnTimeForInstance(uint32 instance
);
688 void AddCreatureToGrid(uint32 guid
, CreatureData
const* data
);
689 void RemoveCreatureFromGrid(uint32 guid
, CreatureData
const* data
);
690 void AddGameobjectToGrid(uint32 guid
, GameObjectData
const* data
);
691 void RemoveGameobjectFromGrid(uint32 guid
, GameObjectData
const* data
);
694 void LoadReservedPlayersNames();
695 bool IsReservedName(const std::string
& name
) const;
697 // name with valid structure and symbols
698 static uint8
CheckPlayerName( const std::string
& name
, bool create
= false );
699 static PetNameInvalidReason
CheckPetName( const std::string
& name
);
700 static bool IsValidCharterName( const std::string
& name
);
702 static bool CheckDeclinedNames(std::wstring mainpart
, DeclinedName
const& names
);
704 int GetIndexForLocale(LocaleConstant loc
);
705 LocaleConstant
GetLocaleForIndex(int i
);
707 uint16
GetConditionId(ConditionType condition
, uint32 value1
, uint32 value2
);
708 bool IsPlayerMeetToCondition(Player
const* player
, uint16 condition_id
) const
710 if(condition_id
>= mConditions
.size())
713 return mConditions
[condition_id
].Meets(player
);
716 GameTele
const* GetGameTele(uint32 id
) const
718 GameTeleMap::const_iterator itr
= m_GameTeleMap
.find(id
);
719 if(itr
==m_GameTeleMap
.end()) return NULL
;
722 GameTele
const* GetGameTele(const std::string
& name
) const;
723 GameTeleMap
const& GetGameTeleMap() const { return m_GameTeleMap
; }
724 bool AddGameTele(GameTele
& data
);
725 bool DeleteGameTele(const std::string
& name
);
727 CacheNpcOptionList
const& GetNpcOptions() const { return m_mCacheNpcOptionList
; }
729 uint32
GetNpcGossip(uint32 entry
) const
731 CacheNpcTextIdMap::const_iterator iter
= m_mCacheNpcTextIdMap
.find(entry
);
732 if(iter
== m_mCacheNpcTextIdMap
.end())
738 TrainerSpellData
const* GetNpcTrainerSpells(uint32 entry
) const
740 CacheTrainerSpellMap::const_iterator iter
= m_mCacheTrainerSpellMap
.find(entry
);
741 if(iter
== m_mCacheTrainerSpellMap
.end())
744 return &iter
->second
;
747 VendorItemData
const* GetNpcVendorItemList(uint32 entry
) const
749 CacheVendorItemMap::const_iterator iter
= m_mCacheVendorItemMap
.find(entry
);
750 if(iter
== m_mCacheVendorItemMap
.end())
753 return &iter
->second
;
755 void AddVendorItem(uint32 entry
,uint32 item
, uint32 maxcount
, uint32 incrtime
, uint32 ExtendedCost
);
756 bool RemoveVendorItem(uint32 entry
,uint32 item
);
757 bool IsVendorItemValid( uint32 vendor_entry
, uint32 item
, uint32 maxcount
, uint32 ptime
, uint32 ExtendedCost
, Player
* pl
= NULL
, std::set
<uint32
>* skip_vendors
= NULL
) const;
759 void LoadScriptNames();
760 ScriptNameMap
&GetScriptNames() { return m_scriptNames
; }
761 const char * GetScriptName(uint32 id
) { return id
< m_scriptNames
.size() ? m_scriptNames
[id
].c_str() : ""; }
762 uint32
GetScriptId(const char *name
);
764 int GetOrNewIndexForLocale(LocaleConstant loc
);
766 SpellClickInfoMapBounds
GetSpellClickInfoMapBounds(uint32 creature_id
) const
768 return SpellClickInfoMapBounds(mSpellClickInfoMap
.lower_bound(creature_id
),mSpellClickInfoMap
.upper_bound(creature_id
));
771 ItemRequiredTargetMapBounds
GetItemRequiredTargetMapBounds(uint32 uiItemEntry
) const
773 return ItemRequiredTargetMapBounds(m_ItemRequiredTarget
.lower_bound(uiItemEntry
),m_ItemRequiredTarget
.upper_bound(uiItemEntry
));
778 // first free id for selected id type
779 uint32 m_arenaTeamId
;
781 uint64 m_equipmentSetGuid
;
785 uint32 m_hiPetNumber
;
787 // first free low guid for seelcted guid type
789 uint32 m_hiCreatureGuid
;
792 uint32 m_hiCorpseGuid
;
794 QuestMap mQuestTemplates
;
796 typedef UNORDERED_MAP
<uint32
, GossipText
> GossipTextMap
;
797 typedef UNORDERED_MAP
<uint32
, uint32
> QuestAreaTriggerMap
;
798 typedef UNORDERED_MAP
<uint32
, std::string
> ItemTextMap
;
799 typedef std::set
<uint32
> TavernAreaTriggerSet
;
800 typedef std::set
<uint32
> GameObjectForQuestSet
;
804 ArenaTeamMap mArenaTeamMap
;
806 ItemTextMap mItemTexts
;
808 QuestAreaTriggerMap mQuestAreaTriggerMap
;
809 TavernAreaTriggerSet mTavernAreaTriggerSet
;
810 GameObjectForQuestSet mGameObjectForQuestSet
;
811 GossipTextMap mGossipText
;
812 AreaTriggerMap mAreaTriggers
;
813 AreaTriggerScriptMap mAreaTriggerScripts
;
815 RepOnKillMap mRepOnKill
;
817 PointOfInterestMap mPointsOfInterest
;
819 WeatherZoneMap mWeatherZoneMap
;
821 //character reserved names
822 typedef std::set
<std::wstring
> ReservedNamesMap
;
823 ReservedNamesMap m_ReservedNames
;
825 GraveYardMap mGraveYardMap
;
827 GameTeleMap m_GameTeleMap
;
829 ScriptNameMap m_scriptNames
;
831 SpellClickInfoMap mSpellClickInfoMap
;
833 ItemRequiredTargetMap m_ItemRequiredTarget
;
835 typedef std::vector
<LocaleConstant
> LocalForIndex
;
836 LocalForIndex m_LocalForIndex
;
841 void LoadScripts(ScriptMapMap
& scripts
, char const* tablename
);
842 void CheckScripts(ScriptMapMap
const& scripts
,std::set
<int32
>& ids
);
843 void LoadCreatureAddons(SQLStorage
& creatureaddons
, char const* entryName
, char const* comment
);
844 void ConvertCreatureAddonAuras(CreatureDataAddon
* addon
, char const* table
, char const* guidEntryStr
);
845 void LoadQuestRelationsHelper(QuestRelations
& map
,char const* table
);
847 typedef std::map
<uint32
,PetLevelInfo
*> PetLevelInfoMap
;
848 // PetLevelInfoMap[creature_id][level]
849 PetLevelInfoMap petInfo
; // [creature_id][level]
851 PlayerClassInfo playerClassInfo
[MAX_CLASSES
];
853 void BuildPlayerLevelInfo(uint8 race
, uint8 class_
, uint8 level
, PlayerLevelInfo
* plinfo
) const;
854 PlayerInfo playerInfo
[MAX_RACES
][MAX_CLASSES
];
856 typedef std::vector
<uint32
> PlayerXPperLevel
; // [level]
857 PlayerXPperLevel mPlayerXPperLevel
;
859 typedef std::map
<uint32
,uint32
> BaseXPMap
; // [area level][base xp]
860 BaseXPMap mBaseXPTable
;
862 typedef std::map
<uint32
,int32
> FishingBaseSkillMap
; // [areaId][base skill level]
863 FishingBaseSkillMap mFishingBaseForArea
;
865 typedef std::map
<uint32
,std::vector
<std::string
> > HalfNameMap
;
866 HalfNameMap PetHalfName0
;
867 HalfNameMap PetHalfName1
;
869 MapObjectGuids mMapObjectGuids
;
870 CreatureDataMap mCreatureDataMap
;
871 CreatureLocaleMap mCreatureLocaleMap
;
872 GameObjectDataMap mGameObjectDataMap
;
873 GameObjectLocaleMap mGameObjectLocaleMap
;
874 ItemLocaleMap mItemLocaleMap
;
875 QuestLocaleMap mQuestLocaleMap
;
876 NpcTextLocaleMap mNpcTextLocaleMap
;
877 PageTextLocaleMap mPageTextLocaleMap
;
878 MangosStringLocaleMap mMangosStringLocaleMap
;
879 NpcOptionLocaleMap mNpcOptionLocaleMap
;
880 PointOfInterestLocaleMap mPointOfInterestLocaleMap
;
881 RespawnTimes mCreatureRespawnTimes
;
882 RespawnTimes mGORespawnTimes
;
884 // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required)
885 typedef std::vector
<PlayerCondition
> ConditionStore
;
886 ConditionStore mConditions
;
888 CacheNpcOptionList m_mCacheNpcOptionList
;
889 CacheNpcTextIdMap m_mCacheNpcTextIdMap
;
890 CacheVendorItemMap m_mCacheVendorItemMap
;
891 CacheTrainerSpellMap m_mCacheTrainerSpellMap
;
894 #define objmgr MaNGOS::Singleton<ObjectMgr>::Instance()
896 // scripting access functions
897 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());
898 MANGOS_DLL_SPEC uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
899 MANGOS_DLL_SPEC uint32
GetScriptId(const char *name
);
900 MANGOS_DLL_SPEC
ObjectMgr::ScriptNameMap
& GetScriptNames();
901 MANGOS_DLL_SPEC CreatureInfo
const* GetCreatureTemplateStore(uint32 entry
);
902 MANGOS_DLL_SPEC Quest
const* GetQuestTemplateStore(uint32 entry
);