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 "DynamicObject.h"
28 #include "GameObject.h"
32 #include "ItemPrototype.h"
33 #include "NPCHandler.h"
34 #include "Database/DatabaseEnv.h"
37 #include "ObjectAccessor.h"
38 #include "ObjectDefines.h"
39 #include "Policies/Singleton.h"
40 #include "Database/SQLStorage.h"
46 extern SQLStorage sCreatureStorage
;
47 extern SQLStorage sCreatureDataAddonStorage
;
48 extern SQLStorage sCreatureInfoAddonStorage
;
49 extern SQLStorage sCreatureModelStorage
;
50 extern SQLStorage sEquipmentStorage
;
51 extern SQLStorage sGOStorage
;
52 extern SQLStorage sPageTextStore
;
53 extern SQLStorage sItemStorage
;
54 extern SQLStorage sInstanceTemplate
;
71 std::wstring wnameLow
;
74 typedef UNORDERED_MAP
<uint32
, GameTele
> GameTeleMap
;
90 typedef std::multimap
<uint32
, ScriptInfo
> ScriptMap
;
91 typedef std::map
<uint32
, ScriptMap
> ScriptMapMap
;
92 extern ScriptMapMap sQuestEndScripts
;
93 extern ScriptMapMap sQuestStartScripts
;
94 extern ScriptMapMap sSpellScripts
;
95 extern ScriptMapMap sGameObjectScripts
;
96 extern ScriptMapMap sEventScripts
;
102 uint32 requiredItem2
;
105 uint32 requiredQuest
;
106 std::string requiredFailedText
;
111 float target_Orientation
;
114 typedef std::set
<uint32
> CellGuidSet
;
115 typedef std::map
<uint32
/*player guid*/,uint32
/*instance*/> CellCorpseSet
;
116 struct CellObjectGuids
118 CellGuidSet creatures
;
119 CellGuidSet gameobjects
;
120 CellCorpseSet corpses
;
122 typedef UNORDERED_MAP
<uint32
/*cell_id*/,CellObjectGuids
> CellObjectGuidsMap
;
123 typedef UNORDERED_MAP
<uint32
/*(mapid,spawnMode) pair*/,CellObjectGuidsMap
> MapObjectGuids
;
125 typedef UNORDERED_MAP
<uint64
/*(instance,guid) pair*/,time_t> RespawnTimes
;
128 // mangos string ranges
129 #define MIN_MANGOS_STRING_ID 1
130 #define MAX_MANGOS_STRING_ID 2000000000
131 #define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID
132 #define MAX_DB_SCRIPT_STRING_ID 2000010000
134 struct MangosStringLocale
136 std::vector
<std::string
> Content
; // 0 -> default, i -> i-1 locale index
139 typedef UNORDERED_MAP
<uint32
,CreatureData
> CreatureDataMap
;
140 typedef UNORDERED_MAP
<uint32
,GameObjectData
> GameObjectDataMap
;
141 typedef UNORDERED_MAP
<uint32
,CreatureLocale
> CreatureLocaleMap
;
142 typedef UNORDERED_MAP
<uint32
,GameObjectLocale
> GameObjectLocaleMap
;
143 typedef UNORDERED_MAP
<uint32
,ItemLocale
> ItemLocaleMap
;
144 typedef UNORDERED_MAP
<uint32
,QuestLocale
> QuestLocaleMap
;
145 typedef UNORDERED_MAP
<uint32
,NpcTextLocale
> NpcTextLocaleMap
;
146 typedef UNORDERED_MAP
<uint32
,PageTextLocale
> PageTextLocaleMap
;
147 typedef UNORDERED_MAP
<uint32
,MangosStringLocale
> MangosStringLocaleMap
;
148 typedef UNORDERED_MAP
<uint32
,NpcOptionLocale
> NpcOptionLocaleMap
;
150 typedef std::multimap
<uint32
,uint32
> QuestRelations
;
154 PetLevelInfo() : health(0), mana(0) { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
156 uint16 stats
[MAX_STATS
];
162 struct ReputationOnKillEntry
167 uint32 reputation_max_cap1
;
170 uint32 reputation_max_cap2
;
175 struct PetCreateSpellEntry
180 #define WEATHER_SEASONS 4
181 struct WeatherSeasonChances
188 struct WeatherZoneChances
190 WeatherSeasonChances data
[WEATHER_SEASONS
];
198 typedef std::multimap
<uint32
,GraveYardData
> GraveYardMap
;
201 { // value1 value2 for the Condition enumed
202 CONDITION_NONE
= 0, // 0 0
203 CONDITION_AURA
= 1, // spell_id effindex
204 CONDITION_ITEM
= 2, // item_id count
205 CONDITION_ITEM_EQUIPPED
= 3, // item_id 0
206 CONDITION_ZONEID
= 4, // zone_id 0
207 CONDITION_REPUTATION_RANK
= 5, // faction_id min_rank
208 CONDITION_TEAM
= 6, // player_team 0, (469 - Alliance 67 - Horde)
209 CONDITION_SKILL
= 7, // skill_id skill_value
210 CONDITION_QUESTREWARDED
= 8, // quest_id 0
211 CONDITION_QUESTTAKEN
= 9, // quest_id 0, for condition true while quest active.
212 CONDITION_AD_COMMISSION_AURA
= 10, // 0 0, for condition true while one from AD ñommission aura active
213 CONDITION_NO_AURA
= 11, // spell_id effindex
214 CONDITION_ACTIVE_EVENT
= 12, // event_id
217 #define MAX_CONDITION 13 // maximum value in ConditionType enum
219 struct PlayerCondition
221 ConditionType condition
; // additional condition type
222 uint32 value1
; // data for the condition - see ConditionType definition
225 PlayerCondition(uint8 _condition
= 0, uint32 _value1
= 0, uint32 _value2
= 0)
226 : condition(ConditionType(_condition
)), value1(_value1
), value2(_value2
) {}
228 static bool IsValid(ConditionType condition
, uint32 value1
, uint32 value2
);
229 // Checks correctness of values
230 bool Meets(Player
const * APlayer
) const; // Checks if the player meets the condition
231 bool operator == (PlayerCondition
const& lc
) const
233 return (lc
.condition
== condition
&& lc
.value1
== value1
&& lc
.value2
== value2
);
237 // NPC gossip text id
238 typedef UNORDERED_MAP
<uint32
, uint32
> CacheNpcTextIdMap
;
239 typedef std::list
<GossipOption
> CacheNpcOptionList
;
241 typedef UNORDERED_MAP
<uint32
, VendorItemData
> CacheVendorItemMap
;
242 typedef UNORDERED_MAP
<uint32
, TrainerSpellData
> CacheTrainerSpellMap
;
246 SKILL_RANGE_LANGUAGE
, // 300..300
247 SKILL_RANGE_LEVEL
, // 1..max skill for level
248 SKILL_RANGE_MONO
, // 1..1, grey monolite bar
249 SKILL_RANGE_RANK
, // 1..skill for known rank
250 SKILL_RANGE_NONE
, // 0..0 always
253 SkillRangeType
GetSkillRangeType(SkillLineEntry
const *pSkill
, bool racial
);
255 #define MAX_PLAYER_NAME 12 // max allowed by client name length
256 #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
258 bool normalizePlayerName(std::string
& name
);
260 struct MANGOS_DLL_SPEC LanguageDesc
267 extern LanguageDesc lang_description
[LANGUAGES_COUNT
];
268 MANGOS_DLL_SPEC LanguageDesc
const* GetLanguageDescByID(uint32 lang
);
270 class PlayerDumpReader
;
274 friend class PlayerDumpReader
;
280 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
282 typedef std::set
< Group
* > GroupSet
;
283 typedef std::set
< Guild
* > GuildSet
;
285 typedef UNORDERED_MAP
<uint32
, ArenaTeam
* > ArenaTeamMap
;
287 typedef UNORDERED_MAP
<uint32
, Quest
*> QuestMap
;
289 typedef UNORDERED_MAP
<uint32
, AreaTrigger
> AreaTriggerMap
;
291 typedef UNORDERED_MAP
<uint32
, uint32
> AreaTriggerScriptMap
;
293 typedef UNORDERED_MAP
<uint32
, ReputationOnKillEntry
> RepOnKillMap
;
295 typedef UNORDERED_MAP
<uint32
, WeatherZoneChances
> WeatherZoneMap
;
297 typedef UNORDERED_MAP
<uint32
, PetCreateSpellEntry
> PetCreateSpellMap
;
299 typedef std::vector
<std::string
> ScriptNameMap
;
301 Player
* GetPlayer(const char* name
) const { return ObjectAccessor::Instance().FindPlayerByName(name
);}
302 Player
* GetPlayer(uint64 guid
) const { return ObjectAccessor::FindPlayer(guid
); }
304 static GameObjectInfo
const *GetGameObjectInfo(uint32 id
) { return sGOStorage
.LookupEntry
<GameObjectInfo
>(id
); }
306 void LoadGameobjectInfo();
307 void AddGameobjectInfo(GameObjectInfo
*goinfo
);
309 Group
* GetGroupByLeader(const uint64
&guid
) const;
310 void AddGroup(Group
* group
) { mGroupSet
.insert( group
); }
311 void RemoveGroup(Group
* group
) { mGroupSet
.erase( group
); }
313 Guild
* GetGuildByLeader(uint64
const&guid
) const;
314 Guild
* GetGuildById(const uint32 GuildId
) const;
315 Guild
* GetGuildByName(const std::string
& guildname
) const;
316 std::string
GetGuildNameById(const uint32 GuildId
) const;
317 void AddGuild(Guild
* guild
) { mGuildSet
.insert( guild
); }
318 void RemoveGuild(Guild
* guild
) { mGuildSet
.erase( guild
); }
320 ArenaTeam
* GetArenaTeamById(const uint32 arenateamid
) const;
321 ArenaTeam
* GetArenaTeamByName(const std::string
& arenateamname
) const;
322 ArenaTeam
* GetArenaTeamByCaptain(uint64
const& guid
) const;
323 void AddArenaTeam(ArenaTeam
* arenaTeam
);
324 void RemoveArenaTeam(ArenaTeam
* arenaTeam
);
325 ArenaTeamMap::iterator
GetArenaTeamMapBegin() { return mArenaTeamMap
.begin(); }
326 ArenaTeamMap::iterator
GetArenaTeamMapEnd() { return mArenaTeamMap
.end(); }
328 static CreatureInfo
const *GetCreatureTemplate( uint32 id
);
329 CreatureModelInfo
const *GetCreatureModelInfo( uint32 modelid
);
330 CreatureModelInfo
const* GetCreatureModelRandomGender(uint32 display_id
);
331 uint32
ChooseDisplayId(uint32 team
, const CreatureInfo
*cinfo
, const CreatureData
*data
= NULL
);
332 EquipmentInfo
const *GetEquipmentInfo( uint32 entry
);
333 static CreatureDataAddon
const *GetCreatureAddon( uint32 lowguid
)
335 return sCreatureDataAddonStorage
.LookupEntry
<CreatureDataAddon
>(lowguid
);
338 static CreatureDataAddon
const *GetCreatureTemplateAddon( uint32 entry
)
340 return sCreatureInfoAddonStorage
.LookupEntry
<CreatureDataAddon
>(entry
);
343 static ItemPrototype
const* GetItemPrototype(uint32 id
) { return sItemStorage
.LookupEntry
<ItemPrototype
>(id
); }
345 static InstanceTemplate
const* GetInstanceTemplate(uint32 map
)
347 return sInstanceTemplate
.LookupEntry
<InstanceTemplate
>(map
);
350 PetLevelInfo
const* GetPetLevelInfo(uint32 creature_id
, uint32 level
) const;
352 PlayerClassInfo
const* GetPlayerClassInfo(uint32 class_
) const
354 if(class_
>= MAX_CLASSES
) return NULL
;
355 return &playerClassInfo
[class_
];
357 void GetPlayerClassLevelInfo(uint32 class_
,uint32 level
, PlayerClassLevelInfo
* info
) const;
359 PlayerInfo
const* GetPlayerInfo(uint32 race
, uint32 class_
) const
361 if(race
>= MAX_RACES
) return NULL
;
362 if(class_
>= MAX_CLASSES
) return NULL
;
363 PlayerInfo
const* info
= &playerInfo
[race
][class_
];
364 if(info
->displayId_m
==0 || info
->displayId_f
==0) return NULL
;
367 void GetPlayerLevelInfo(uint32 race
, uint32 class_
,uint32 level
, PlayerLevelInfo
* info
) const;
369 uint64
GetPlayerGUIDByName(std::string name
) const;
370 bool GetPlayerNameByGUID(const uint64
&guid
, std::string
&name
) const;
371 uint32
GetPlayerTeamByGUID(const uint64
&guid
) const;
372 uint32
GetPlayerAccountIdByGUID(const uint64
&guid
) const;
373 uint32
GetPlayerAccountIdByPlayerName(const std::string
& name
) const;
375 uint32
GetNearestTaxiNode( float x
, float y
, float z
, uint32 mapid
, uint32 team
);
376 void GetTaxiPath( uint32 source
, uint32 destination
, uint32
&path
, uint32
&cost
);
377 uint16
GetTaxiMount( uint32 id
, uint32 team
);
378 void GetTaxiPathNodes( uint32 path
, Path
&pathnodes
, std::vector
<uint32
>& mapIds
);
379 void GetTransportPathNodes( uint32 path
, TransportPath
&pathnodes
);
381 Quest
const* GetQuestTemplate(uint32 quest_id
) const
383 QuestMap::const_iterator itr
= mQuestTemplates
.find(quest_id
);
384 return itr
!= mQuestTemplates
.end() ? itr
->second
: NULL
;
386 QuestMap
const& GetQuestTemplates() const { return mQuestTemplates
; }
388 uint32
GetQuestForAreaTrigger(uint32 Trigger_ID
) const
390 QuestAreaTriggerMap::const_iterator itr
= mQuestAreaTriggerMap
.find(Trigger_ID
);
391 if(itr
!= mQuestAreaTriggerMap
.end())
395 bool IsTavernAreaTrigger(uint32 Trigger_ID
) const { return mTavernAreaTriggerSet
.count(Trigger_ID
) != 0; }
396 bool IsGameObjectForQuests(uint32 entry
) const { return mGameObjectForQuestSet
.count(entry
) != 0; }
397 bool IsGuildVaultGameObject(Player
*player
, uint64 guid
) const
399 if(GameObject
*go
= ObjectAccessor::GetGameObject(*player
, guid
))
400 if(go
->GetGoType() == GAMEOBJECT_TYPE_GUILD_BANK
)
405 void AddGossipText(GossipText
*pGText
);
406 GossipText
*GetGossipText(uint32 Text_ID
);
408 WorldSafeLocsEntry
const *GetClosestGraveYard(float x
, float y
, float z
, uint32 MapId
, uint32 team
);
409 bool AddGraveYardLink(uint32 id
, uint32 zone
, uint32 team
, bool inDB
= true);
410 void LoadGraveyardZones();
411 GraveYardData
const* FindGraveYardData(uint32 id
, uint32 zone
);
413 AreaTrigger
const* GetAreaTrigger(uint32 trigger
) const
415 AreaTriggerMap::const_iterator itr
= mAreaTriggers
.find( trigger
);
416 if( itr
!= mAreaTriggers
.end( ) )
421 AreaTrigger
const* GetGoBackTrigger(uint32 Map
) const;
422 AreaTrigger
const* GetMapEntranceTrigger(uint32 Map
) const;
424 uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
426 ReputationOnKillEntry
const* GetReputationOnKilEntry(uint32 id
) const
428 RepOnKillMap::const_iterator itr
= mRepOnKill
.find(id
);
429 if(itr
!= mRepOnKill
.end())
434 PetCreateSpellEntry
const* GetPetCreateSpellEntry(uint32 id
) const
436 PetCreateSpellMap::const_iterator itr
= mPetCreateSpell
.find(id
);
437 if(itr
!= mPetCreateSpell
.end())
443 void LoadArenaTeams();
446 void LoadQuestRelations()
448 LoadGameobjectQuestRelations();
449 LoadGameobjectInvolvedRelations();
450 LoadCreatureQuestRelations();
451 LoadCreatureInvolvedRelations();
453 void LoadGameobjectQuestRelations();
454 void LoadGameobjectInvolvedRelations();
455 void LoadCreatureQuestRelations();
456 void LoadCreatureInvolvedRelations();
458 QuestRelations mGOQuestRelations
;
459 QuestRelations mGOQuestInvolvedRelations
;
460 QuestRelations mCreatureQuestRelations
;
461 QuestRelations mCreatureQuestInvolvedRelations
;
463 void LoadGameObjectScripts();
464 void LoadQuestEndScripts();
465 void LoadQuestStartScripts();
466 void LoadEventScripts();
467 void LoadSpellScripts();
469 bool LoadMangosStrings(DatabaseType
& db
, char const* table
, int32 min_value
, int32 max_value
);
470 bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase
,"mangos_string",MIN_MANGOS_STRING_ID
,MAX_MANGOS_STRING_ID
); }
471 void LoadDbScriptStrings();
472 void LoadPetCreateSpells();
473 void LoadCreatureLocales();
474 void LoadCreatureTemplates();
475 void LoadCreatures();
476 void LoadCreatureRespawnTimes();
477 void LoadCreatureAddons();
478 void LoadCreatureModelInfo();
479 void LoadEquipmentTemplates();
480 void LoadGameObjectLocales();
481 void LoadGameobjects();
482 void LoadGameobjectRespawnTimes();
483 void LoadItemPrototypes();
484 void LoadItemLocales();
485 void LoadQuestLocales();
486 void LoadNpcTextLocales();
487 void LoadPageTextLocales();
488 void LoadNpcOptionLocales();
489 void LoadInstanceTemplate();
491 void LoadGossipText();
493 void LoadAreaTriggerTeleports();
494 void LoadQuestAreaTriggers();
495 void LoadAreaTriggerScripts();
496 void LoadTavernAreaTriggers();
497 void LoadGameObjectForQuests();
499 void LoadItemTexts();
500 void LoadPageTexts();
502 void LoadPlayerInfo();
503 void LoadPetLevelInfo();
504 void LoadExplorationBaseXP();
506 void LoadPetNumber();
508 void LoadFishingBaseSkillLevel();
510 void LoadReputationOnKill();
512 void LoadWeatherZoneChances();
515 void LoadNpcOptions();
516 void LoadNpcTextId();
518 void LoadTrainerSpell();
520 std::string
GeneratePetName(uint32 entry
);
521 uint32
GetBaseXP(uint32 level
);
522 uint32
GetXPForLevel(uint32 level
);
524 int32
GetFishingBaseSkillLevel(uint32 entry
) const
526 FishingBaseSkillMap::const_iterator itr
= mFishingBaseForArea
.find(entry
);
527 return itr
!= mFishingBaseForArea
.end() ? itr
->second
: 0;
530 void ReturnOrDeleteOldMails(bool serverUp
);
532 void SetHighestGuids();
533 uint32
GenerateLowGuid(HighGuid guidhigh
);
534 uint32
GenerateArenaTeamId();
535 uint32
GenerateAuctionID();
536 uint32
GenerateGuildId();
537 uint32
GenerateItemTextID();
538 uint32
GenerateMailID();
539 uint32
GeneratePetNumber();
541 uint32
CreateItemText(std::string text
);
542 std::string
GetItemText( uint32 id
)
544 ItemTextMap::const_iterator itr
= mItemTexts
.find( id
);
545 if ( itr
!= mItemTexts
.end() )
548 return "There is no info for this item";
551 typedef std::multimap
<int32
, uint32
> ExclusiveQuestGroups
;
552 ExclusiveQuestGroups mExclusiveQuestGroups
;
554 WeatherZoneChances
const* GetWeatherChances(uint32 zone_id
) const
556 WeatherZoneMap::const_iterator itr
= mWeatherZoneMap
.find(zone_id
);
557 if(itr
!= mWeatherZoneMap
.end())
563 CellObjectGuids
const& GetCellObjectGuids(uint16 mapid
, uint8 spawnMode
, uint32 cell_id
)
565 return mMapObjectGuids
[MAKE_PAIR32(mapid
,spawnMode
)][cell_id
];
568 CreatureData
const* GetCreatureData(uint32 guid
) const
570 CreatureDataMap::const_iterator itr
= mCreatureDataMap
.find(guid
);
571 if(itr
==mCreatureDataMap
.end()) return NULL
;
574 CreatureData
& NewOrExistCreatureData(uint32 guid
) { return mCreatureDataMap
[guid
]; }
575 void DeleteCreatureData(uint32 guid
);
576 CreatureLocale
const* GetCreatureLocale(uint32 entry
) const
578 CreatureLocaleMap::const_iterator itr
= mCreatureLocaleMap
.find(entry
);
579 if(itr
==mCreatureLocaleMap
.end()) return NULL
;
582 GameObjectLocale
const* GetGameObjectLocale(uint32 entry
) const
584 GameObjectLocaleMap::const_iterator itr
= mGameObjectLocaleMap
.find(entry
);
585 if(itr
==mGameObjectLocaleMap
.end()) return NULL
;
588 ItemLocale
const* GetItemLocale(uint32 entry
) const
590 ItemLocaleMap::const_iterator itr
= mItemLocaleMap
.find(entry
);
591 if(itr
==mItemLocaleMap
.end()) return NULL
;
594 QuestLocale
const* GetQuestLocale(uint32 entry
) const
596 QuestLocaleMap::const_iterator itr
= mQuestLocaleMap
.find(entry
);
597 if(itr
==mQuestLocaleMap
.end()) return NULL
;
600 NpcTextLocale
const* GetNpcTextLocale(uint32 entry
) const
602 NpcTextLocaleMap::const_iterator itr
= mNpcTextLocaleMap
.find(entry
);
603 if(itr
==mNpcTextLocaleMap
.end()) return NULL
;
606 PageTextLocale
const* GetPageTextLocale(uint32 entry
) const
608 PageTextLocaleMap::const_iterator itr
= mPageTextLocaleMap
.find(entry
);
609 if(itr
==mPageTextLocaleMap
.end()) return NULL
;
612 NpcOptionLocale
const* GetNpcOptionLocale(uint32 entry
) const
614 NpcOptionLocaleMap::const_iterator itr
= mNpcOptionLocaleMap
.find(entry
);
615 if(itr
==mNpcOptionLocaleMap
.end()) return NULL
;
619 GameObjectData
const* GetGOData(uint32 guid
) const
621 GameObjectDataMap::const_iterator itr
= mGameObjectDataMap
.find(guid
);
622 if(itr
==mGameObjectDataMap
.end()) return NULL
;
625 GameObjectData
& NewGOData(uint32 guid
) { return mGameObjectDataMap
[guid
]; }
626 void DeleteGOData(uint32 guid
);
628 MangosStringLocale
const* GetMangosStringLocale(int32 entry
) const
630 MangosStringLocaleMap::const_iterator itr
= mMangosStringLocaleMap
.find(entry
);
631 if(itr
==mMangosStringLocaleMap
.end()) return NULL
;
634 const char *GetMangosString(int32 entry
, int locale_idx
) const;
635 const char *GetMangosStringForDBCLocale(int32 entry
) const { return GetMangosString(entry
,DBCLocaleIndex
); }
636 int32
GetDBCLocaleIndex() const { return DBCLocaleIndex
; }
637 void SetDBCLocaleIndex(uint32 lang
) { DBCLocaleIndex
= GetIndexForLocale(LocaleConstant(lang
)); }
639 void AddCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
, uint32 instance
);
640 void DeleteCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
);
642 time_t GetCreatureRespawnTime(uint32 loguid
, uint32 instance
) { return mCreatureRespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
643 void SaveCreatureRespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
644 time_t GetGORespawnTime(uint32 loguid
, uint32 instance
) { return mGORespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
645 void SaveGORespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
646 void DeleteRespawnTimeForInstance(uint32 instance
);
649 void AddCreatureToGrid(uint32 guid
, CreatureData
const* data
);
650 void RemoveCreatureFromGrid(uint32 guid
, CreatureData
const* data
);
651 void AddGameobjectToGrid(uint32 guid
, GameObjectData
const* data
);
652 void RemoveGameobjectFromGrid(uint32 guid
, GameObjectData
const* data
);
655 void LoadReservedPlayersNames();
656 bool IsReservedName(const std::string
& name
) const;
658 // name with valid structure and symbols
659 static bool IsValidName( const std::string
& name
, bool create
= false );
660 static bool IsValidCharterName( const std::string
& name
);
661 static bool IsValidPetName( const std::string
& name
);
663 static bool CheckDeclinedNames(std::wstring mainpart
, DeclinedName
const& names
);
665 int GetIndexForLocale(LocaleConstant loc
);
666 LocaleConstant
GetLocaleForIndex(int i
);
668 uint32
GetGuildBankTabPrice(uint8 Index
) const { return Index
< GUILD_BANK_MAX_TABS
? mGuildBankTabPrice
[Index
] : 0; }
670 uint16
GetConditionId(ConditionType condition
, uint32 value1
, uint32 value2
);
671 bool IsPlayerMeetToCondition(Player
const* player
, uint16 condition_id
) const
673 if(condition_id
>= mConditions
.size())
676 return mConditions
[condition_id
].Meets(player
);
679 GameTele
const* GetGameTele(uint32 id
) const
681 GameTeleMap::const_iterator itr
= m_GameTeleMap
.find(id
);
682 if(itr
==m_GameTeleMap
.end()) return NULL
;
685 GameTele
const* GetGameTele(const std::string
& name
) const;
686 GameTeleMap
const& GetGameTeleMap() const { return m_GameTeleMap
; }
687 bool AddGameTele(GameTele
& data
);
688 bool DeleteGameTele(const std::string
& name
);
690 CacheNpcOptionList
const& GetNpcOptions() const { return m_mCacheNpcOptionList
; }
692 uint32
GetNpcGossip(uint32 entry
) const
694 CacheNpcTextIdMap::const_iterator iter
= m_mCacheNpcTextIdMap
.find(entry
);
695 if(iter
== m_mCacheNpcTextIdMap
.end())
701 TrainerSpellData
const* GetNpcTrainerSpells(uint32 entry
) const
703 CacheTrainerSpellMap::const_iterator iter
= m_mCacheTrainerSpellMap
.find(entry
);
704 if(iter
== m_mCacheTrainerSpellMap
.end())
707 return &iter
->second
;
710 VendorItemData
const* GetNpcVendorItemList(uint32 entry
) const
712 CacheVendorItemMap::const_iterator iter
= m_mCacheVendorItemMap
.find(entry
);
713 if(iter
== m_mCacheVendorItemMap
.end())
716 return &iter
->second
;
718 void AddVendorItem(uint32 entry
,uint32 item
, uint32 maxcount
, uint32 incrtime
, uint32 ExtendedCost
);
719 bool RemoveVendorItem(uint32 entry
,uint32 item
);
720 bool IsVendorItemValid( uint32 vendor_entry
, uint32 item
, uint32 maxcount
, uint32 ptime
, uint32 ExtendedCost
, Player
* pl
= NULL
, std::set
<uint32
>* skip_vendors
= NULL
) const;
722 void LoadScriptNames();
723 ScriptNameMap
&GetScriptNames() { return m_scriptNames
; }
724 const char * GetScriptName(uint32 id
) { return id
< m_scriptNames
.size() ? m_scriptNames
[id
].c_str() : ""; }
725 uint32
GetScriptId(const char *name
);
727 int GetOrNewIndexForLocale(LocaleConstant loc
);
730 // first free id for selected id type
731 uint32 m_arenaTeamId
;
736 uint32 m_hiPetNumber
;
738 // first free low guid for seelcted guid type
740 uint32 m_hiCreatureGuid
;
742 uint32 m_hiVehicleGuid
;
746 uint32 m_hiCorpseGuid
;
748 QuestMap mQuestTemplates
;
750 typedef UNORDERED_MAP
<uint32
, GossipText
*> GossipTextMap
;
751 typedef UNORDERED_MAP
<uint32
, uint32
> QuestAreaTriggerMap
;
752 typedef UNORDERED_MAP
<uint32
, std::string
> ItemTextMap
;
753 typedef std::set
<uint32
> TavernAreaTriggerSet
;
754 typedef std::set
<uint32
> GameObjectForQuestSet
;
758 ArenaTeamMap mArenaTeamMap
;
762 ItemTextMap mItemTexts
;
764 QuestAreaTriggerMap mQuestAreaTriggerMap
;
765 TavernAreaTriggerSet mTavernAreaTriggerSet
;
766 GameObjectForQuestSet mGameObjectForQuestSet
;
767 GossipTextMap mGossipText
;
768 AreaTriggerMap mAreaTriggers
;
769 AreaTriggerScriptMap mAreaTriggerScripts
;
771 RepOnKillMap mRepOnKill
;
773 WeatherZoneMap mWeatherZoneMap
;
775 PetCreateSpellMap mPetCreateSpell
;
777 //character reserved names
778 typedef std::set
<std::wstring
> ReservedNamesMap
;
779 ReservedNamesMap m_ReservedNames
;
781 GraveYardMap mGraveYardMap
;
783 GameTeleMap m_GameTeleMap
;
785 ScriptNameMap m_scriptNames
;
787 typedef std::vector
<LocaleConstant
> LocalForIndex
;
788 LocalForIndex m_LocalForIndex
;
793 void LoadScripts(ScriptMapMap
& scripts
, char const* tablename
);
794 void CheckScripts(ScriptMapMap
const& scripts
,std::set
<int32
>& ids
);
795 void ConvertCreatureAddonAuras(CreatureDataAddon
* addon
, char const* table
, char const* guidEntryStr
);
796 void LoadQuestRelationsHelper(QuestRelations
& map
,char const* table
);
798 typedef std::map
<uint32
,PetLevelInfo
*> PetLevelInfoMap
;
799 // PetLevelInfoMap[creature_id][level]
800 PetLevelInfoMap petInfo
; // [creature_id][level]
802 PlayerClassInfo playerClassInfo
[MAX_CLASSES
];
804 void BuildPlayerLevelInfo(uint8 race
, uint8 class_
, uint8 level
, PlayerLevelInfo
* plinfo
) const;
805 PlayerInfo playerInfo
[MAX_RACES
][MAX_CLASSES
];
807 typedef std::vector
<uint32
> PlayerXPperLevel
; // [level]
808 PlayerXPperLevel mPlayerXPperLevel
;
810 typedef std::map
<uint32
,uint32
> BaseXPMap
; // [area level][base xp]
811 BaseXPMap mBaseXPTable
;
813 typedef std::map
<uint32
,int32
> FishingBaseSkillMap
; // [areaId][base skill level]
814 FishingBaseSkillMap mFishingBaseForArea
;
816 typedef std::map
<uint32
,std::vector
<std::string
> > HalfNameMap
;
817 HalfNameMap PetHalfName0
;
818 HalfNameMap PetHalfName1
;
820 MapObjectGuids mMapObjectGuids
;
821 CreatureDataMap mCreatureDataMap
;
822 CreatureLocaleMap mCreatureLocaleMap
;
823 GameObjectDataMap mGameObjectDataMap
;
824 GameObjectLocaleMap mGameObjectLocaleMap
;
825 ItemLocaleMap mItemLocaleMap
;
826 QuestLocaleMap mQuestLocaleMap
;
827 NpcTextLocaleMap mNpcTextLocaleMap
;
828 PageTextLocaleMap mPageTextLocaleMap
;
829 MangosStringLocaleMap mMangosStringLocaleMap
;
830 NpcOptionLocaleMap mNpcOptionLocaleMap
;
831 RespawnTimes mCreatureRespawnTimes
;
832 RespawnTimes mGORespawnTimes
;
834 typedef std::vector
<uint32
> GuildBankTabPriceMap
;
835 GuildBankTabPriceMap mGuildBankTabPrice
;
837 // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required)
838 typedef std::vector
<PlayerCondition
> ConditionStore
;
839 ConditionStore mConditions
;
841 CacheNpcOptionList m_mCacheNpcOptionList
;
842 CacheNpcTextIdMap m_mCacheNpcTextIdMap
;
843 CacheVendorItemMap m_mCacheVendorItemMap
;
844 CacheTrainerSpellMap m_mCacheTrainerSpellMap
;
847 #define objmgr MaNGOS::Singleton<ObjectMgr>::Instance()
849 // scripting access functions
850 MANGOS_DLL_SPEC
bool LoadMangosStrings(DatabaseType
& db
, char const* table
,int32 start_value
= -1, int32 end_value
= std::numeric_limits
<int32
>::min());
851 MANGOS_DLL_SPEC uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
852 MANGOS_DLL_SPEC uint32
GetScriptId(const char *name
);
853 MANGOS_DLL_SPEC
ObjectMgr::ScriptNameMap
& GetScriptNames();