2 * Copyright (C) 2005-2008 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"
35 #include "AuctionHouseObject.h"
38 #include "ObjectAccessor.h"
39 #include "ObjectDefines.h"
40 #include "Policies/Singleton.h"
41 #include "Database/SQLStorage.h"
47 extern SQLStorage sCreatureStorage
;
48 extern SQLStorage sCreatureDataAddonStorage
;
49 extern SQLStorage sCreatureInfoAddonStorage
;
50 extern SQLStorage sCreatureModelStorage
;
51 extern SQLStorage sEquipmentStorage
;
52 extern SQLStorage sGOStorage
;
53 extern SQLStorage sPageTextStore
;
54 extern SQLStorage sItemStorage
;
55 extern SQLStorage sInstanceTemplate
;
72 std::wstring wnameLow
;
75 typedef UNORDERED_MAP
<uint32
, GameTele
> GameTeleMap
;
91 typedef std::multimap
<uint32
, ScriptInfo
> ScriptMap
;
92 typedef std::map
<uint32
, ScriptMap
> ScriptMapMap
;
93 extern ScriptMapMap sQuestEndScripts
;
94 extern ScriptMapMap sQuestStartScripts
;
95 extern ScriptMapMap sSpellScripts
;
96 extern ScriptMapMap sGameObjectScripts
;
97 extern ScriptMapMap sEventScripts
;
103 uint32 requiredItem2
;
106 uint32 requiredQuest
;
107 std::string requiredFailedText
;
112 float target_Orientation
;
115 typedef std::set
<uint32
> CellGuidSet
;
116 typedef std::map
<uint32
/*player guid*/,uint32
/*instance*/> CellCorpseSet
;
117 struct CellObjectGuids
119 CellGuidSet creatures
;
120 CellGuidSet gameobjects
;
121 CellCorpseSet corpses
;
123 typedef UNORDERED_MAP
<uint32
/*cell_id*/,CellObjectGuids
> CellObjectGuidsMap
;
124 typedef UNORDERED_MAP
<uint32
/*(mapid,spawnMode) pair*/,CellObjectGuidsMap
> MapObjectGuids
;
126 typedef UNORDERED_MAP
<uint64
/*(instance,guid) pair*/,time_t> RespawnTimes
;
129 // mangos string ranges
130 #define MIN_MANGOS_STRING_ID 1
131 #define MAX_MANGOS_STRING_ID 2000000000
132 #define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID
133 #define MAX_DB_SCRIPT_STRING_ID 2000010000
135 struct MangosStringLocale
137 std::vector
<std::string
> Content
; // 0 -> default, i -> i-1 locale index
140 typedef UNORDERED_MAP
<uint32
,CreatureData
> CreatureDataMap
;
141 typedef UNORDERED_MAP
<uint32
,GameObjectData
> GameObjectDataMap
;
142 typedef UNORDERED_MAP
<uint32
,CreatureLocale
> CreatureLocaleMap
;
143 typedef UNORDERED_MAP
<uint32
,GameObjectLocale
> GameObjectLocaleMap
;
144 typedef UNORDERED_MAP
<uint32
,ItemLocale
> ItemLocaleMap
;
145 typedef UNORDERED_MAP
<uint32
,QuestLocale
> QuestLocaleMap
;
146 typedef UNORDERED_MAP
<uint32
,NpcTextLocale
> NpcTextLocaleMap
;
147 typedef UNORDERED_MAP
<uint32
,PageTextLocale
> PageTextLocaleMap
;
148 typedef UNORDERED_MAP
<uint32
,MangosStringLocale
> MangosStringLocaleMap
;
149 typedef UNORDERED_MAP
<uint32
,NpcOptionLocale
> NpcOptionLocaleMap
;
151 typedef std::multimap
<uint32
,uint32
> QuestRelations
;
155 PetLevelInfo() : health(0), mana(0) { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
157 uint16 stats
[MAX_STATS
];
163 struct ReputationOnKillEntry
168 uint32 reputation_max_cap1
;
171 uint32 reputation_max_cap2
;
176 struct PetCreateSpellEntry
181 #define WEATHER_SEASONS 4
182 struct WeatherSeasonChances
189 struct WeatherZoneChances
191 WeatherSeasonChances data
[WEATHER_SEASONS
];
199 typedef std::multimap
<uint32
,GraveYardData
> GraveYardMap
;
202 { // value1 value2 for the Condition enumed
203 CONDITION_NONE
= 0, // 0 0
204 CONDITION_AURA
= 1, // spell_id effindex
205 CONDITION_ITEM
= 2, // item_id count
206 CONDITION_ITEM_EQUIPPED
= 3, // item_id 0
207 CONDITION_ZONEID
= 4, // zone_id 0
208 CONDITION_REPUTATION_RANK
= 5, // faction_id min_rank
209 CONDITION_TEAM
= 6, // player_team 0, (469 - Alliance 67 - Horde)
210 CONDITION_SKILL
= 7, // skill_id skill_value
211 CONDITION_QUESTREWARDED
= 8, // quest_id 0
212 CONDITION_QUESTTAKEN
= 9, // quest_id 0, for condition true while quest active.
213 CONDITION_AD_COMMISSION_AURA
= 10, // 0 0, for condition true while one from AD ñommission aura active
214 CONDITION_NO_AURA
= 11, // spell_id effindex
215 CONDITION_ACTIVE_EVENT
= 12, // event_id
218 #define MAX_CONDITION 13 // maximum value in ConditionType enum
220 struct PlayerCondition
222 ConditionType condition
; // additional condition type
223 uint32 value1
; // data for the condition - see ConditionType definition
226 PlayerCondition(uint8 _condition
= 0, uint32 _value1
= 0, uint32 _value2
= 0)
227 : condition(ConditionType(_condition
)), value1(_value1
), value2(_value2
) {}
229 static bool IsValid(ConditionType condition
, uint32 value1
, uint32 value2
);
230 // Checks correctness of values
231 bool Meets(Player
const * APlayer
) const; // Checks if the player meets the condition
232 bool operator == (PlayerCondition
const& lc
) const
234 return (lc
.condition
== condition
&& lc
.value1
== value1
&& lc
.value2
== value2
);
238 // NPC gossip text id
239 typedef UNORDERED_MAP
<uint32
, uint32
> CacheNpcTextIdMap
;
240 typedef std::list
<GossipOption
> CacheNpcOptionList
;
242 typedef UNORDERED_MAP
<uint32
, VendorItemData
> CacheVendorItemMap
;
243 typedef UNORDERED_MAP
<uint32
, TrainerSpellData
> CacheTrainerSpellMap
;
247 SKILL_RANGE_LANGUAGE
, // 300..300
248 SKILL_RANGE_LEVEL
, // 1..max skill for level
249 SKILL_RANGE_MONO
, // 1..1, grey monolite bar
250 SKILL_RANGE_RANK
, // 1..skill for known rank
251 SKILL_RANGE_NONE
, // 0..0 always
254 SkillRangeType
GetSkillRangeType(SkillLineEntry
const *pSkill
, bool racial
);
256 #define MAX_PLAYER_NAME 12 // max allowed by client name length
257 #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
259 bool normalizePlayerName(std::string
& name
);
261 struct MANGOS_DLL_SPEC LanguageDesc
268 extern LanguageDesc lang_description
[LANGUAGES_COUNT
];
269 MANGOS_DLL_SPEC LanguageDesc
const* GetLanguageDescByID(uint32 lang
);
271 class PlayerDumpReader
;
275 friend class PlayerDumpReader
;
281 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
283 typedef std::set
< Group
* > GroupSet
;
284 typedef std::set
< Guild
* > GuildSet
;
285 typedef std::set
< ArenaTeam
* > ArenaTeamSet
;
287 typedef UNORDERED_MAP
<uint32
, Quest
*> QuestMap
;
289 typedef UNORDERED_MAP
<uint32
, AreaTrigger
> AreaTriggerMap
;
291 typedef UNORDERED_MAP
<uint32
, std::string
> AreaTriggerScriptMap
;
293 typedef UNORDERED_MAP
<uint32
, ReputationOnKillEntry
> RepOnKillMap
;
295 typedef UNORDERED_MAP
<uint32
, WeatherZoneChances
> WeatherZoneMap
;
297 typedef UNORDERED_MAP
<uint32
, PetCreateSpellEntry
> PetCreateSpellMap
;
299 Player
* GetPlayer(const char* name
) const { return ObjectAccessor::Instance().FindPlayerByName(name
);}
300 Player
* GetPlayer(uint64 guid
) const { return ObjectAccessor::FindPlayer(guid
); }
302 static GameObjectInfo
const *GetGameObjectInfo(uint32 id
) { return sGOStorage
.LookupEntry
<GameObjectInfo
>(id
); }
304 void LoadGameobjectInfo();
305 void AddGameobjectInfo(GameObjectInfo
*goinfo
);
307 Group
* GetGroupByLeader(const uint64
&guid
) const;
308 void AddGroup(Group
* group
) { mGroupSet
.insert( group
); }
309 void RemoveGroup(Group
* group
) { mGroupSet
.erase( group
); }
311 Guild
* GetGuildByLeader(uint64
const&guid
) const;
312 Guild
* GetGuildById(const uint32 GuildId
) const;
313 Guild
* GetGuildByName(std::string guildname
) const;
314 std::string
GetGuildNameById(const uint32 GuildId
) const;
315 void AddGuild(Guild
* guild
) { mGuildSet
.insert( guild
); }
316 void RemoveGuild(Guild
* guild
) { mGuildSet
.erase( guild
); }
318 ArenaTeam
* GetArenaTeamById(const uint32 ArenaTeamId
) const;
319 ArenaTeam
* GetArenaTeamByName(std::string ArenaTeamName
) const;
320 ArenaTeam
* GetArenaTeamByCapitan(uint64
const& guid
) const;
321 void AddArenaTeam(ArenaTeam
* arenateam
) { mArenaTeamSet
.insert( arenateam
); }
322 void RemoveArenaTeam(ArenaTeam
* arenateam
) { mArenaTeamSet
.erase( arenateam
); }
324 static CreatureInfo
const *GetCreatureTemplate( uint32 id
);
325 CreatureModelInfo
const *GetCreatureModelInfo( uint32 modelid
);
326 CreatureModelInfo
const* GetCreatureModelRandomGender(uint32 display_id
);
327 uint32
ChooseDisplayId(uint32 team
, const CreatureInfo
*cinfo
, const CreatureData
*data
= NULL
);
328 EquipmentInfo
const *GetEquipmentInfo( uint32 entry
);
329 static CreatureDataAddon
const *GetCreatureAddon( uint32 lowguid
)
331 return sCreatureDataAddonStorage
.LookupEntry
<CreatureDataAddon
>(lowguid
);
334 static CreatureDataAddon
const *GetCreatureTemplateAddon( uint32 entry
)
336 return sCreatureInfoAddonStorage
.LookupEntry
<CreatureDataAddon
>(entry
);
339 static ItemPrototype
const* GetItemPrototype(uint32 id
) { return sItemStorage
.LookupEntry
<ItemPrototype
>(id
); }
341 static InstanceTemplate
const* GetInstanceTemplate(uint32 map
)
343 return sInstanceTemplate
.LookupEntry
<InstanceTemplate
>(map
);
346 Item
* GetAItem(uint32 id
)
348 ItemMap::const_iterator itr
= mAitems
.find(id
);
349 if (itr
!= mAitems
.end())
355 void AddAItem(Item
* it
)
358 ASSERT( mAitems
.find(it
->GetGUIDLow()) == mAitems
.end());
359 mAitems
[it
->GetGUIDLow()] = it
;
361 bool RemoveAItem(uint32 id
)
363 ItemMap::iterator i
= mAitems
.find(id
);
364 if (i
== mAitems
.end())
371 AuctionHouseObject
* GetAuctionsMap( uint32 location
);
374 void SendAuctionWonMail( AuctionEntry
* auction
);
375 void SendAuctionSalePendingMail( AuctionEntry
* auction
);
376 void SendAuctionSuccessfulMail( AuctionEntry
* auction
);
377 void SendAuctionExpiredMail( AuctionEntry
* auction
);
378 static uint32
GetAuctionCut( uint32 location
, uint32 highBid
);
379 static uint32
GetAuctionDeposit(uint32 location
, uint32 time
, Item
*pItem
);
380 static uint32
GetAuctionOutBid(uint32 currentBid
);
382 PetLevelInfo
const* GetPetLevelInfo(uint32 creature_id
, uint32 level
) const;
384 PlayerClassInfo
const* GetPlayerClassInfo(uint32 class_
) const
386 if(class_
>= MAX_CLASSES
) return NULL
;
387 return &playerClassInfo
[class_
];
389 void GetPlayerClassLevelInfo(uint32 class_
,uint32 level
, PlayerClassLevelInfo
* info
) const;
391 PlayerInfo
const* GetPlayerInfo(uint32 race
, uint32 class_
) const
393 if(race
>= MAX_RACES
) return NULL
;
394 if(class_
>= MAX_CLASSES
) return NULL
;
395 PlayerInfo
const* info
= &playerInfo
[race
][class_
];
396 if(info
->displayId_m
==0 || info
->displayId_f
==0) return NULL
;
399 void GetPlayerLevelInfo(uint32 race
, uint32 class_
,uint32 level
, PlayerLevelInfo
* info
) const;
401 uint64
GetPlayerGUIDByName(std::string name
) const;
402 bool GetPlayerNameByGUID(const uint64
&guid
, std::string
&name
) const;
403 uint32
GetPlayerTeamByGUID(const uint64
&guid
) const;
404 uint32
GetPlayerAccountIdByGUID(const uint64
&guid
) const;
405 uint32
GetPlayerAccountIdByPlayerName(std::string name
) const;
407 uint32
GetNearestTaxiNode( float x
, float y
, float z
, uint32 mapid
);
408 void GetTaxiPath( uint32 source
, uint32 destination
, uint32
&path
, uint32
&cost
);
409 uint16
GetTaxiMount( uint32 id
, uint32 team
);
410 void GetTaxiPathNodes( uint32 path
, Path
&pathnodes
, std::vector
<uint32
>& mapIds
);
411 void GetTransportPathNodes( uint32 path
, TransportPath
&pathnodes
);
413 Quest
const* GetQuestTemplate(uint32 quest_id
) const
415 QuestMap::const_iterator itr
= mQuestTemplates
.find(quest_id
);
416 return itr
!= mQuestTemplates
.end() ? itr
->second
: NULL
;
418 QuestMap
const& GetQuestTemplates() const { return mQuestTemplates
; }
420 uint32
GetQuestForAreaTrigger(uint32 Trigger_ID
) const
422 QuestAreaTriggerMap::const_iterator itr
= mQuestAreaTriggerMap
.find(Trigger_ID
);
423 if(itr
!= mQuestAreaTriggerMap
.end())
427 bool IsTavernAreaTrigger(uint32 Trigger_ID
) const { return mTavernAreaTriggerSet
.count(Trigger_ID
) != 0; }
428 bool IsGameObjectForQuests(uint32 entry
) const { return mGameObjectForQuestSet
.count(entry
) != 0; }
429 bool IsGuildVaultGameObject(Player
*player
, uint64 guid
) const
431 if(GameObject
*go
= ObjectAccessor::GetGameObject(*player
, guid
))
432 if(go
->GetGoType() == GAMEOBJECT_TYPE_GUILD_BANK
)
437 uint32
GetBattleMasterBG(uint32 entry
) const
439 BattleMastersMap::const_iterator itr
= mBattleMastersMap
.find(entry
);
440 if(itr
!= mBattleMastersMap
.end())
442 return 2; //BATTLEGROUND_WS - i will not add include only for constant usage!
445 void AddGossipText(GossipText
*pGText
);
446 GossipText
*GetGossipText(uint32 Text_ID
);
448 WorldSafeLocsEntry
const *GetClosestGraveYard(float x
, float y
, float z
, uint32 MapId
, uint32 team
);
449 bool AddGraveYardLink(uint32 id
, uint32 zone
, uint32 team
, bool inDB
= true);
450 void LoadGraveyardZones();
451 GraveYardData
const* FindGraveYardData(uint32 id
, uint32 zone
);
453 AreaTrigger
const* GetAreaTrigger(uint32 trigger
) const
455 AreaTriggerMap::const_iterator itr
= mAreaTriggers
.find( trigger
);
456 if( itr
!= mAreaTriggers
.end( ) )
461 AreaTrigger
const* GetGoBackTrigger(uint32 Map
) const;
463 const char* GetAreaTriggerScriptName(uint32 id
);
465 ReputationOnKillEntry
const* GetReputationOnKilEntry(uint32 id
) const
467 RepOnKillMap::const_iterator itr
= mRepOnKill
.find(id
);
468 if(itr
!= mRepOnKill
.end())
473 PetCreateSpellEntry
const* GetPetCreateSpellEntry(uint32 id
) const
475 PetCreateSpellMap::const_iterator itr
= mPetCreateSpell
.find(id
);
476 if(itr
!= mPetCreateSpell
.end())
482 void LoadArenaTeams();
485 void LoadQuestRelations()
487 LoadGameobjectQuestRelations();
488 LoadGameobjectInvolvedRelations();
489 LoadCreatureQuestRelations();
490 LoadCreatureInvolvedRelations();
492 void LoadGameobjectQuestRelations();
493 void LoadGameobjectInvolvedRelations();
494 void LoadCreatureQuestRelations();
495 void LoadCreatureInvolvedRelations();
497 QuestRelations mGOQuestRelations
;
498 QuestRelations mGOQuestInvolvedRelations
;
499 QuestRelations mCreatureQuestRelations
;
500 QuestRelations mCreatureQuestInvolvedRelations
;
502 void LoadGameObjectScripts();
503 void LoadQuestEndScripts();
504 void LoadQuestStartScripts();
505 void LoadEventScripts();
506 void LoadSpellScripts();
508 bool LoadMangosStrings(DatabaseType
& db
, char const* table
, int32 min_value
, int32 max_value
);
509 bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase
,"mangos_string",MIN_MANGOS_STRING_ID
,MAX_MANGOS_STRING_ID
); }
510 void LoadDbScriptStrings();
511 void LoadPetCreateSpells();
512 void LoadCreatureLocales();
513 void LoadCreatureTemplates();
514 void LoadCreatures();
515 void LoadCreatureRespawnTimes();
516 void LoadCreatureAddons();
517 void LoadCreatureModelInfo();
518 void LoadEquipmentTemplates();
519 void LoadGameObjectLocales();
520 void LoadGameobjects();
521 void LoadGameobjectRespawnTimes();
522 void LoadItemPrototypes();
523 void LoadItemLocales();
524 void LoadQuestLocales();
525 void LoadNpcTextLocales();
526 void LoadPageTextLocales();
527 void LoadNpcOptionLocales();
528 void LoadInstanceTemplate();
530 void LoadGossipText();
532 void LoadAreaTriggerTeleports();
533 void LoadQuestAreaTriggers();
534 void LoadAreaTriggerScripts();
535 void LoadTavernAreaTriggers();
536 void LoadBattleMastersEntry();
537 void LoadGameObjectForQuests();
539 void LoadItemTexts();
540 void LoadPageTexts();
542 //load first auction items, because of check if item exists, when loading
543 void LoadAuctionItems();
545 void LoadPlayerInfo();
546 void LoadPetLevelInfo();
547 void LoadExplorationBaseXP();
549 void LoadPetNumber();
551 void LoadFishingBaseSkillLevel();
553 void LoadReputationOnKill();
555 void LoadWeatherZoneChances();
558 void LoadNpcOptions();
559 void LoadNpcTextId();
561 void LoadTrainerSpell();
563 std::string
GeneratePetName(uint32 entry
);
564 uint32
GetBaseXP(uint32 level
);
566 int32
GetFishingBaseSkillLevel(uint32 entry
) const
568 FishingBaseSkillMap::const_iterator itr
= mFishingBaseForArea
.find(entry
);
569 return itr
!= mFishingBaseForArea
.end() ? itr
->second
: 0;
572 void ReturnOrDeleteOldMails(bool serverUp
);
574 void SetHighestGuids();
575 uint32
GenerateLowGuid(HighGuid guidhigh
);
576 uint32
GenerateAuctionID();
577 uint32
GenerateMailID();
578 uint32
GenerateItemTextID();
579 uint32
GeneratePetNumber();
580 uint32
GenerateArenaTeamId();
581 uint32
GenerateGuildId();
583 uint32
CreateItemText(std::string text
);
584 std::string
GetItemText( uint32 id
)
586 ItemTextMap::const_iterator itr
= mItemTexts
.find( id
);
587 if ( itr
!= mItemTexts
.end() )
590 return "There is no info for this item";
593 typedef std::multimap
<int32
, uint32
> ExclusiveQuestGroups
;
594 ExclusiveQuestGroups mExclusiveQuestGroups
;
596 WeatherZoneChances
const* GetWeatherChances(uint32 zone_id
) const
598 WeatherZoneMap::const_iterator itr
= mWeatherZoneMap
.find(zone_id
);
599 if(itr
!= mWeatherZoneMap
.end())
605 CellObjectGuids
const& GetCellObjectGuids(uint16 mapid
, uint8 spawnMode
, uint32 cell_id
)
607 return mMapObjectGuids
[MAKE_PAIR32(mapid
,spawnMode
)][cell_id
];
610 CreatureData
const* GetCreatureData(uint32 guid
) const
612 CreatureDataMap::const_iterator itr
= mCreatureDataMap
.find(guid
);
613 if(itr
==mCreatureDataMap
.end()) return NULL
;
616 CreatureData
& NewOrExistCreatureData(uint32 guid
) { return mCreatureDataMap
[guid
]; }
617 void DeleteCreatureData(uint32 guid
);
618 CreatureLocale
const* GetCreatureLocale(uint32 entry
) const
620 CreatureLocaleMap::const_iterator itr
= mCreatureLocaleMap
.find(entry
);
621 if(itr
==mCreatureLocaleMap
.end()) return NULL
;
624 GameObjectLocale
const* GetGameObjectLocale(uint32 entry
) const
626 GameObjectLocaleMap::const_iterator itr
= mGameObjectLocaleMap
.find(entry
);
627 if(itr
==mGameObjectLocaleMap
.end()) return NULL
;
630 ItemLocale
const* GetItemLocale(uint32 entry
) const
632 ItemLocaleMap::const_iterator itr
= mItemLocaleMap
.find(entry
);
633 if(itr
==mItemLocaleMap
.end()) return NULL
;
636 QuestLocale
const* GetQuestLocale(uint32 entry
) const
638 QuestLocaleMap::const_iterator itr
= mQuestLocaleMap
.find(entry
);
639 if(itr
==mQuestLocaleMap
.end()) return NULL
;
642 NpcTextLocale
const* GetNpcTextLocale(uint32 entry
) const
644 NpcTextLocaleMap::const_iterator itr
= mNpcTextLocaleMap
.find(entry
);
645 if(itr
==mNpcTextLocaleMap
.end()) return NULL
;
648 PageTextLocale
const* GetPageTextLocale(uint32 entry
) const
650 PageTextLocaleMap::const_iterator itr
= mPageTextLocaleMap
.find(entry
);
651 if(itr
==mPageTextLocaleMap
.end()) return NULL
;
654 NpcOptionLocale
const* GetNpcOptionLocale(uint32 entry
) const
656 NpcOptionLocaleMap::const_iterator itr
= mNpcOptionLocaleMap
.find(entry
);
657 if(itr
==mNpcOptionLocaleMap
.end()) return NULL
;
661 GameObjectData
const* GetGOData(uint32 guid
) const
663 GameObjectDataMap::const_iterator itr
= mGameObjectDataMap
.find(guid
);
664 if(itr
==mGameObjectDataMap
.end()) return NULL
;
667 GameObjectData
& NewGOData(uint32 guid
) { return mGameObjectDataMap
[guid
]; }
668 void DeleteGOData(uint32 guid
);
670 MangosStringLocale
const* GetMangosStringLocale(int32 entry
) const
672 MangosStringLocaleMap::const_iterator itr
= mMangosStringLocaleMap
.find(entry
);
673 if(itr
==mMangosStringLocaleMap
.end()) return NULL
;
676 const char *GetMangosString(int32 entry
, int locale_idx
) const;
677 const char *GetMangosStringForDBCLocale(int32 entry
) const { return GetMangosString(entry
,DBCLocaleIndex
); }
678 int32
GetDBCLocaleIndex() const { return DBCLocaleIndex
; }
679 void SetDBCLocaleIndex(uint32 lang
) { DBCLocaleIndex
= GetIndexForLocale(LocaleConstant(lang
)); }
681 void AddCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
, uint32 instance
);
682 void DeleteCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
);
684 time_t GetCreatureRespawnTime(uint32 loguid
, uint32 instance
) { return mCreatureRespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
685 void SaveCreatureRespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
686 time_t GetGORespawnTime(uint32 loguid
, uint32 instance
) { return mGORespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
687 void SaveGORespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
688 void DeleteRespawnTimeForInstance(uint32 instance
);
691 void AddCreatureToGrid(uint32 guid
, CreatureData
const* data
);
692 void RemoveCreatureFromGrid(uint32 guid
, CreatureData
const* data
);
693 void AddGameobjectToGrid(uint32 guid
, GameObjectData
const* data
);
694 void RemoveGameobjectFromGrid(uint32 guid
, GameObjectData
const* data
);
697 void LoadReservedPlayersNames();
698 bool IsReservedName(std::string name
) const
700 return m_ReservedNames
.find(name
) != m_ReservedNames
.end();
703 // name with valid structure and symbols
704 static bool IsValidName( std::string name
, bool create
= false );
705 static bool IsValidCharterName( std::string name
);
706 static bool IsValidPetName( std::string name
);
708 static bool CheckDeclinedNames(std::wstring mainpart
, DeclinedName
const& names
);
710 int GetIndexForLocale(LocaleConstant loc
);
711 LocaleConstant
GetLocaleForIndex(int i
);
713 uint32
GetGuildBankTabPrice(uint8 Index
) const { return Index
< GUILD_BANK_MAX_TABS
? mGuildBankTabPrice
[Index
] : 0; }
715 uint16
GetConditionId(ConditionType condition
, uint32 value1
, uint32 value2
);
716 bool IsPlayerMeetToCondition(Player
const* player
, uint16 condition_id
) const
718 if(condition_id
>= mConditions
.size())
721 return mConditions
[condition_id
].Meets(player
);
724 GameTele
const* GetGameTele(uint32 id
) const
726 GameTeleMap::const_iterator itr
= m_GameTeleMap
.find(id
);
727 if(itr
==m_GameTeleMap
.end()) return NULL
;
730 GameTele
const* GetGameTele(std::string name
) const;
731 GameTeleMap
const& GetGameTeleMap() const { return m_GameTeleMap
; }
732 bool AddGameTele(GameTele
& data
);
733 bool DeleteGameTele(std::string name
);
735 CacheNpcOptionList
const& GetNpcOptions() const { return m_mCacheNpcOptionList
; }
737 uint32
GetNpcGossip(uint32 entry
) const
739 CacheNpcTextIdMap::const_iterator iter
= m_mCacheNpcTextIdMap
.find(entry
);
740 if(iter
== m_mCacheNpcTextIdMap
.end())
746 TrainerSpellData
const* GetNpcTrainerSpells(uint32 entry
) const
748 CacheTrainerSpellMap::const_iterator iter
= m_mCacheTrainerSpellMap
.find(entry
);
749 if(iter
== m_mCacheTrainerSpellMap
.end())
752 return &iter
->second
;
755 VendorItemData
const* GetNpcVendorItemList(uint32 entry
) const
757 CacheVendorItemMap::const_iterator iter
= m_mCacheVendorItemMap
.find(entry
);
758 if(iter
== m_mCacheVendorItemMap
.end())
761 return &iter
->second
;
763 void AddVendorItem(uint32 entry
,uint32 item
, uint32 maxcount
, uint32 incrtime
, uint32 ExtendedCost
);
764 bool RemoveVendorItem(uint32 entry
,uint32 item
);
765 bool IsVendorItemValid( uint32 vendor_entry
, uint32 item
, uint32 maxcount
, uint32 ptime
, uint32 ExtendedCost
, Player
* pl
= NULL
, std::set
<uint32
>* skip_vendors
= NULL
) const;
771 uint32 m_arenaTeamId
;
775 uint32 m_hiCreatureGuid
;
780 uint32 m_hiCorpseGuid
;
782 uint32 m_hiPetNumber
;
784 QuestMap mQuestTemplates
;
786 typedef UNORDERED_MAP
<uint32
, GossipText
*> GossipTextMap
;
787 typedef UNORDERED_MAP
<uint32
, uint32
> QuestAreaTriggerMap
;
788 typedef UNORDERED_MAP
<uint32
, uint32
> BattleMastersMap
;
789 typedef UNORDERED_MAP
<uint32
, std::string
> ItemTextMap
;
790 typedef std::set
<uint32
> TavernAreaTriggerSet
;
791 typedef std::set
<uint32
> GameObjectForQuestSet
;
795 ArenaTeamSet mArenaTeamSet
;
800 ItemTextMap mItemTexts
;
802 AuctionHouseObject mHordeAuctions
;
803 AuctionHouseObject mAllianceAuctions
;
804 AuctionHouseObject mNeutralAuctions
;
806 QuestAreaTriggerMap mQuestAreaTriggerMap
;
807 BattleMastersMap mBattleMastersMap
;
808 TavernAreaTriggerSet mTavernAreaTriggerSet
;
809 GameObjectForQuestSet mGameObjectForQuestSet
;
810 GossipTextMap mGossipText
;
811 AreaTriggerMap mAreaTriggers
;
812 AreaTriggerScriptMap mAreaTriggerScripts
;
814 RepOnKillMap mRepOnKill
;
816 WeatherZoneMap mWeatherZoneMap
;
818 PetCreateSpellMap mPetCreateSpell
;
820 //character reserved names
821 typedef std::set
<std::string
> ReservedNamesMap
;
822 ReservedNamesMap m_ReservedNames
;
824 GraveYardMap mGraveYardMap
;
826 GameTeleMap m_GameTeleMap
;
828 typedef std::vector
<LocaleConstant
> LocalForIndex
;
829 LocalForIndex m_LocalForIndex
;
830 int GetOrNewIndexForLocale(LocaleConstant loc
);
834 void LoadScripts(ScriptMapMap
& scripts
, char const* tablename
);
835 void CheckScripts(ScriptMapMap
const& scripts
,std::set
<int32
>& ids
);
836 void ConvertCreatureAddonAuras(CreatureDataAddon
* addon
, char const* table
, char const* guidEntryStr
);
837 void LoadQuestRelationsHelper(QuestRelations
& map
,char const* table
);
839 typedef std::map
<uint32
,PetLevelInfo
*> PetLevelInfoMap
;
840 // PetLevelInfoMap[creature_id][level]
841 PetLevelInfoMap petInfo
; // [creature_id][level]
843 PlayerClassInfo playerClassInfo
[MAX_CLASSES
];
845 void BuildPlayerLevelInfo(uint8 race
, uint8 class_
, uint8 level
, PlayerLevelInfo
* plinfo
) const;
846 PlayerInfo playerInfo
[MAX_RACES
][MAX_CLASSES
];
848 typedef std::map
<uint32
,uint32
> BaseXPMap
; // [area level][base xp]
849 BaseXPMap mBaseXPTable
;
851 typedef std::map
<uint32
,int32
> FishingBaseSkillMap
; // [areaId][base skill level]
852 FishingBaseSkillMap mFishingBaseForArea
;
854 typedef std::map
<uint32
,std::vector
<std::string
> > HalfNameMap
;
855 HalfNameMap PetHalfName0
;
856 HalfNameMap PetHalfName1
;
858 MapObjectGuids mMapObjectGuids
;
859 CreatureDataMap mCreatureDataMap
;
860 CreatureLocaleMap mCreatureLocaleMap
;
861 GameObjectDataMap mGameObjectDataMap
;
862 GameObjectLocaleMap mGameObjectLocaleMap
;
863 ItemLocaleMap mItemLocaleMap
;
864 QuestLocaleMap mQuestLocaleMap
;
865 NpcTextLocaleMap mNpcTextLocaleMap
;
866 PageTextLocaleMap mPageTextLocaleMap
;
867 MangosStringLocaleMap mMangosStringLocaleMap
;
868 NpcOptionLocaleMap mNpcOptionLocaleMap
;
869 RespawnTimes mCreatureRespawnTimes
;
870 RespawnTimes mGORespawnTimes
;
872 typedef std::vector
<uint32
> GuildBankTabPriceMap
;
873 GuildBankTabPriceMap mGuildBankTabPrice
;
875 // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required)
876 typedef std::vector
<PlayerCondition
> ConditionStore
;
877 ConditionStore mConditions
;
879 CacheNpcOptionList m_mCacheNpcOptionList
;
880 CacheNpcTextIdMap m_mCacheNpcTextIdMap
;
881 CacheVendorItemMap m_mCacheVendorItemMap
;
882 CacheTrainerSpellMap m_mCacheTrainerSpellMap
;
885 #define objmgr MaNGOS::Singleton<ObjectMgr>::Instance()
887 // scripting access functions
888 bool MANGOS_DLL_SPEC
LoadMangosStrings(DatabaseType
& db
, char const* table
,int32 start_value
= -1, int32 end_value
= std::numeric_limits
<int32
>::min());
889 MANGOS_DLL_SPEC
const char* GetAreaTriggerScriptNameById(uint32 id
);