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
;
149 typedef UNORDERED_MAP
<uint32
,PointOfInterestLocale
> PointOfInterestLocaleMap
;
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 PointOfInterest
184 std::string icon_name
;
187 struct PetCreateSpellEntry
192 #define WEATHER_SEASONS 4
193 struct WeatherSeasonChances
200 struct WeatherZoneChances
202 WeatherSeasonChances data
[WEATHER_SEASONS
];
210 typedef std::multimap
<uint32
,GraveYardData
> GraveYardMap
;
213 { // value1 value2 for the Condition enumed
214 CONDITION_NONE
= 0, // 0 0
215 CONDITION_AURA
= 1, // spell_id effindex
216 CONDITION_ITEM
= 2, // item_id count
217 CONDITION_ITEM_EQUIPPED
= 3, // item_id 0
218 CONDITION_ZONEID
= 4, // zone_id 0
219 CONDITION_REPUTATION_RANK
= 5, // faction_id min_rank
220 CONDITION_TEAM
= 6, // player_team 0, (469 - Alliance 67 - Horde)
221 CONDITION_SKILL
= 7, // skill_id skill_value
222 CONDITION_QUESTREWARDED
= 8, // quest_id 0
223 CONDITION_QUESTTAKEN
= 9, // quest_id 0, for condition true while quest active.
224 CONDITION_AD_COMMISSION_AURA
= 10, // 0 0, for condition true while one from AD ñommission aura active
225 CONDITION_NO_AURA
= 11, // spell_id effindex
226 CONDITION_ACTIVE_EVENT
= 12, // event_id
229 #define MAX_CONDITION 13 // maximum value in ConditionType enum
231 struct PlayerCondition
233 ConditionType condition
; // additional condition type
234 uint32 value1
; // data for the condition - see ConditionType definition
237 PlayerCondition(uint8 _condition
= 0, uint32 _value1
= 0, uint32 _value2
= 0)
238 : condition(ConditionType(_condition
)), value1(_value1
), value2(_value2
) {}
240 static bool IsValid(ConditionType condition
, uint32 value1
, uint32 value2
);
241 // Checks correctness of values
242 bool Meets(Player
const * APlayer
) const; // Checks if the player meets the condition
243 bool operator == (PlayerCondition
const& lc
) const
245 return (lc
.condition
== condition
&& lc
.value1
== value1
&& lc
.value2
== value2
);
249 // NPC gossip text id
250 typedef UNORDERED_MAP
<uint32
, uint32
> CacheNpcTextIdMap
;
251 typedef std::list
<GossipOption
> CacheNpcOptionList
;
253 typedef UNORDERED_MAP
<uint32
, VendorItemData
> CacheVendorItemMap
;
254 typedef UNORDERED_MAP
<uint32
, TrainerSpellData
> CacheTrainerSpellMap
;
258 SKILL_RANGE_LANGUAGE
, // 300..300
259 SKILL_RANGE_LEVEL
, // 1..max skill for level
260 SKILL_RANGE_MONO
, // 1..1, grey monolite bar
261 SKILL_RANGE_RANK
, // 1..skill for known rank
262 SKILL_RANGE_NONE
, // 0..0 always
265 SkillRangeType
GetSkillRangeType(SkillLineEntry
const *pSkill
, bool racial
);
267 #define MAX_PLAYER_NAME 12 // max allowed by client name length
268 #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
270 bool normalizePlayerName(std::string
& name
);
272 struct MANGOS_DLL_SPEC LanguageDesc
279 extern LanguageDesc lang_description
[LANGUAGES_COUNT
];
280 MANGOS_DLL_SPEC LanguageDesc
const* GetLanguageDescByID(uint32 lang
);
282 class PlayerDumpReader
;
286 friend class PlayerDumpReader
;
292 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
294 typedef std::set
< Group
* > GroupSet
;
296 typedef UNORDERED_MAP
<uint32
, Guild
*> GuildMap
;
298 typedef UNORDERED_MAP
<uint32
, ArenaTeam
*> ArenaTeamMap
;
300 typedef UNORDERED_MAP
<uint32
, Quest
*> QuestMap
;
302 typedef UNORDERED_MAP
<uint32
, AreaTrigger
> AreaTriggerMap
;
304 typedef UNORDERED_MAP
<uint32
, uint32
> AreaTriggerScriptMap
;
306 typedef UNORDERED_MAP
<uint32
, ReputationOnKillEntry
> RepOnKillMap
;
307 typedef UNORDERED_MAP
<uint32
, PointOfInterest
> PointOfInterestMap
;
309 typedef UNORDERED_MAP
<uint32
, WeatherZoneChances
> WeatherZoneMap
;
311 typedef UNORDERED_MAP
<uint32
, PetCreateSpellEntry
> PetCreateSpellMap
;
313 typedef std::vector
<std::string
> ScriptNameMap
;
315 Player
* GetPlayer(const char* name
) const { return ObjectAccessor::Instance().FindPlayerByName(name
);}
316 Player
* GetPlayer(uint64 guid
) const { return ObjectAccessor::FindPlayer(guid
); }
318 static GameObjectInfo
const *GetGameObjectInfo(uint32 id
) { return sGOStorage
.LookupEntry
<GameObjectInfo
>(id
); }
320 void LoadGameobjectInfo();
321 void AddGameobjectInfo(GameObjectInfo
*goinfo
);
323 Group
* GetGroupByLeader(const uint64
&guid
) const;
324 void AddGroup(Group
* group
) { mGroupSet
.insert( group
); }
325 void RemoveGroup(Group
* group
) { mGroupSet
.erase( group
); }
327 Guild
* GetGuildByLeader(uint64
const&guid
) const;
328 Guild
* GetGuildById(uint32 GuildId
) const;
329 Guild
* GetGuildByName(const std::string
& guildname
) const;
330 std::string
GetGuildNameById(uint32 GuildId
) const;
331 void AddGuild(Guild
* guild
);
332 void RemoveGuild(uint32 Id
);
334 ArenaTeam
* GetArenaTeamById(uint32 arenateamid
) const;
335 ArenaTeam
* GetArenaTeamByName(const std::string
& arenateamname
) const;
336 ArenaTeam
* GetArenaTeamByCaptain(uint64
const& guid
) const;
337 void AddArenaTeam(ArenaTeam
* arenaTeam
);
338 void RemoveArenaTeam(uint32 Id
);
339 ArenaTeamMap::iterator
GetArenaTeamMapBegin() { return mArenaTeamMap
.begin(); }
340 ArenaTeamMap::iterator
GetArenaTeamMapEnd() { return mArenaTeamMap
.end(); }
342 static CreatureInfo
const *GetCreatureTemplate( uint32 id
);
343 CreatureModelInfo
const *GetCreatureModelInfo( uint32 modelid
);
344 CreatureModelInfo
const* GetCreatureModelRandomGender(uint32 display_id
);
345 uint32
ChooseDisplayId(uint32 team
, const CreatureInfo
*cinfo
, const CreatureData
*data
= NULL
);
346 EquipmentInfo
const *GetEquipmentInfo( uint32 entry
);
347 static CreatureDataAddon
const *GetCreatureAddon( uint32 lowguid
)
349 return sCreatureDataAddonStorage
.LookupEntry
<CreatureDataAddon
>(lowguid
);
352 static CreatureDataAddon
const *GetCreatureTemplateAddon( uint32 entry
)
354 return sCreatureInfoAddonStorage
.LookupEntry
<CreatureDataAddon
>(entry
);
357 static ItemPrototype
const* GetItemPrototype(uint32 id
) { return sItemStorage
.LookupEntry
<ItemPrototype
>(id
); }
359 static InstanceTemplate
const* GetInstanceTemplate(uint32 map
)
361 return sInstanceTemplate
.LookupEntry
<InstanceTemplate
>(map
);
364 PetLevelInfo
const* GetPetLevelInfo(uint32 creature_id
, uint32 level
) const;
366 PlayerClassInfo
const* GetPlayerClassInfo(uint32 class_
) const
368 if(class_
>= MAX_CLASSES
) return NULL
;
369 return &playerClassInfo
[class_
];
371 void GetPlayerClassLevelInfo(uint32 class_
,uint32 level
, PlayerClassLevelInfo
* info
) const;
373 PlayerInfo
const* GetPlayerInfo(uint32 race
, uint32 class_
) const
375 if(race
>= MAX_RACES
) return NULL
;
376 if(class_
>= MAX_CLASSES
) return NULL
;
377 PlayerInfo
const* info
= &playerInfo
[race
][class_
];
378 if(info
->displayId_m
==0 || info
->displayId_f
==0) return NULL
;
381 void GetPlayerLevelInfo(uint32 race
, uint32 class_
,uint32 level
, PlayerLevelInfo
* info
) const;
383 uint64
GetPlayerGUIDByName(std::string name
) const;
384 bool GetPlayerNameByGUID(const uint64
&guid
, std::string
&name
) const;
385 uint32
GetPlayerTeamByGUID(const uint64
&guid
) const;
386 uint32
GetPlayerAccountIdByGUID(const uint64
&guid
) const;
387 uint32
GetPlayerAccountIdByPlayerName(const std::string
& name
) const;
389 uint32
GetNearestTaxiNode( float x
, float y
, float z
, uint32 mapid
, uint32 team
);
390 void GetTaxiPath( uint32 source
, uint32 destination
, uint32
&path
, uint32
&cost
);
391 uint16
GetTaxiMount( uint32 id
, uint32 team
);
392 void GetTaxiPathNodes( uint32 path
, Path
&pathnodes
, std::vector
<uint32
>& mapIds
);
393 void GetTransportPathNodes( uint32 path
, TransportPath
&pathnodes
);
395 Quest
const* GetQuestTemplate(uint32 quest_id
) const
397 QuestMap::const_iterator itr
= mQuestTemplates
.find(quest_id
);
398 return itr
!= mQuestTemplates
.end() ? itr
->second
: NULL
;
400 QuestMap
const& GetQuestTemplates() const { return mQuestTemplates
; }
402 uint32
GetQuestForAreaTrigger(uint32 Trigger_ID
) const
404 QuestAreaTriggerMap::const_iterator itr
= mQuestAreaTriggerMap
.find(Trigger_ID
);
405 if(itr
!= mQuestAreaTriggerMap
.end())
409 bool IsTavernAreaTrigger(uint32 Trigger_ID
) const { return mTavernAreaTriggerSet
.count(Trigger_ID
) != 0; }
410 bool IsGameObjectForQuests(uint32 entry
) const { return mGameObjectForQuestSet
.count(entry
) != 0; }
411 bool IsGuildVaultGameObject(Player
*player
, uint64 guid
) const
413 if(GameObject
*go
= ObjectAccessor::GetGameObject(*player
, guid
))
414 if(go
->GetGoType() == GAMEOBJECT_TYPE_GUILD_BANK
)
419 GossipText
const* GetGossipText(uint32 Text_ID
) const;
421 WorldSafeLocsEntry
const *GetClosestGraveYard(float x
, float y
, float z
, uint32 MapId
, uint32 team
);
422 bool AddGraveYardLink(uint32 id
, uint32 zone
, uint32 team
, bool inDB
= true);
423 void LoadGraveyardZones();
424 GraveYardData
const* FindGraveYardData(uint32 id
, uint32 zone
);
426 AreaTrigger
const* GetAreaTrigger(uint32 trigger
) const
428 AreaTriggerMap::const_iterator itr
= mAreaTriggers
.find( trigger
);
429 if( itr
!= mAreaTriggers
.end( ) )
434 AreaTrigger
const* GetGoBackTrigger(uint32 Map
) const;
435 AreaTrigger
const* GetMapEntranceTrigger(uint32 Map
) const;
437 uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
439 ReputationOnKillEntry
const* GetReputationOnKilEntry(uint32 id
) const
441 RepOnKillMap::const_iterator itr
= mRepOnKill
.find(id
);
442 if(itr
!= mRepOnKill
.end())
447 PointOfInterest
const* GetPointOfInterest(uint32 id
) const
449 PointOfInterestMap::const_iterator itr
= mPointsOfInterest
.find(id
);
450 if(itr
!= mPointsOfInterest
.end())
455 PetCreateSpellEntry
const* GetPetCreateSpellEntry(uint32 id
) const
457 PetCreateSpellMap::const_iterator itr
= mPetCreateSpell
.find(id
);
458 if(itr
!= mPetCreateSpell
.end())
464 void LoadArenaTeams();
467 void LoadQuestRelations()
469 LoadGameobjectQuestRelations();
470 LoadGameobjectInvolvedRelations();
471 LoadCreatureQuestRelations();
472 LoadCreatureInvolvedRelations();
474 void LoadGameobjectQuestRelations();
475 void LoadGameobjectInvolvedRelations();
476 void LoadCreatureQuestRelations();
477 void LoadCreatureInvolvedRelations();
479 QuestRelations mGOQuestRelations
;
480 QuestRelations mGOQuestInvolvedRelations
;
481 QuestRelations mCreatureQuestRelations
;
482 QuestRelations mCreatureQuestInvolvedRelations
;
484 void LoadGameObjectScripts();
485 void LoadQuestEndScripts();
486 void LoadQuestStartScripts();
487 void LoadEventScripts();
488 void LoadSpellScripts();
490 bool LoadMangosStrings(DatabaseType
& db
, char const* table
, int32 min_value
, int32 max_value
);
491 bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase
,"mangos_string",MIN_MANGOS_STRING_ID
,MAX_MANGOS_STRING_ID
); }
492 void LoadDbScriptStrings();
493 void LoadPetCreateSpells();
494 void LoadCreatureLocales();
495 void LoadCreatureTemplates();
496 void LoadCreatures();
497 void LoadCreatureRespawnTimes();
498 void LoadCreatureAddons();
499 void LoadCreatureModelInfo();
500 void LoadEquipmentTemplates();
501 void LoadGameObjectLocales();
502 void LoadGameobjects();
503 void LoadGameobjectRespawnTimes();
504 void LoadItemPrototypes();
505 void LoadItemLocales();
506 void LoadQuestLocales();
507 void LoadNpcTextLocales();
508 void LoadPageTextLocales();
509 void LoadNpcOptionLocales();
510 void LoadPointOfInterestLocales();
511 void LoadInstanceTemplate();
513 void LoadGossipText();
515 void LoadAreaTriggerTeleports();
516 void LoadQuestAreaTriggers();
517 void LoadAreaTriggerScripts();
518 void LoadTavernAreaTriggers();
519 void LoadGameObjectForQuests();
521 void LoadItemTexts();
522 void LoadPageTexts();
524 void LoadPlayerInfo();
525 void LoadPetLevelInfo();
526 void LoadExplorationBaseXP();
528 void LoadPetNumber();
530 void LoadFishingBaseSkillLevel();
532 void LoadReputationOnKill();
533 void LoadPointsOfInterest();
535 void LoadWeatherZoneChances();
538 void LoadNpcOptions();
539 void LoadNpcTextId();
541 void LoadTrainerSpell();
543 std::string
GeneratePetName(uint32 entry
);
544 uint32
GetBaseXP(uint32 level
);
545 uint32
GetXPForLevel(uint32 level
);
547 int32
GetFishingBaseSkillLevel(uint32 entry
) const
549 FishingBaseSkillMap::const_iterator itr
= mFishingBaseForArea
.find(entry
);
550 return itr
!= mFishingBaseForArea
.end() ? itr
->second
: 0;
553 void ReturnOrDeleteOldMails(bool serverUp
);
555 void SetHighestGuids();
556 uint32
GenerateLowGuid(HighGuid guidhigh
);
557 uint32
GenerateArenaTeamId();
558 uint32
GenerateAuctionID();
559 uint32
GenerateGuildId();
560 uint32
GenerateItemTextID();
561 uint32
GenerateMailID();
562 uint32
GeneratePetNumber();
564 uint32
CreateItemText(std::string text
);
565 std::string
GetItemText( uint32 id
)
567 ItemTextMap::const_iterator itr
= mItemTexts
.find( id
);
568 if ( itr
!= mItemTexts
.end() )
571 return "There is no info for this item";
574 typedef std::multimap
<int32
, uint32
> ExclusiveQuestGroups
;
575 ExclusiveQuestGroups mExclusiveQuestGroups
;
577 WeatherZoneChances
const* GetWeatherChances(uint32 zone_id
) const
579 WeatherZoneMap::const_iterator itr
= mWeatherZoneMap
.find(zone_id
);
580 if(itr
!= mWeatherZoneMap
.end())
586 CellObjectGuids
const& GetCellObjectGuids(uint16 mapid
, uint8 spawnMode
, uint32 cell_id
)
588 return mMapObjectGuids
[MAKE_PAIR32(mapid
,spawnMode
)][cell_id
];
591 CreatureData
const* GetCreatureData(uint32 guid
) const
593 CreatureDataMap::const_iterator itr
= mCreatureDataMap
.find(guid
);
594 if(itr
==mCreatureDataMap
.end()) return NULL
;
597 CreatureData
& NewOrExistCreatureData(uint32 guid
) { return mCreatureDataMap
[guid
]; }
598 void DeleteCreatureData(uint32 guid
);
599 CreatureLocale
const* GetCreatureLocale(uint32 entry
) const
601 CreatureLocaleMap::const_iterator itr
= mCreatureLocaleMap
.find(entry
);
602 if(itr
==mCreatureLocaleMap
.end()) return NULL
;
605 GameObjectLocale
const* GetGameObjectLocale(uint32 entry
) const
607 GameObjectLocaleMap::const_iterator itr
= mGameObjectLocaleMap
.find(entry
);
608 if(itr
==mGameObjectLocaleMap
.end()) return NULL
;
611 ItemLocale
const* GetItemLocale(uint32 entry
) const
613 ItemLocaleMap::const_iterator itr
= mItemLocaleMap
.find(entry
);
614 if(itr
==mItemLocaleMap
.end()) return NULL
;
617 QuestLocale
const* GetQuestLocale(uint32 entry
) const
619 QuestLocaleMap::const_iterator itr
= mQuestLocaleMap
.find(entry
);
620 if(itr
==mQuestLocaleMap
.end()) return NULL
;
623 NpcTextLocale
const* GetNpcTextLocale(uint32 entry
) const
625 NpcTextLocaleMap::const_iterator itr
= mNpcTextLocaleMap
.find(entry
);
626 if(itr
==mNpcTextLocaleMap
.end()) return NULL
;
629 PageTextLocale
const* GetPageTextLocale(uint32 entry
) const
631 PageTextLocaleMap::const_iterator itr
= mPageTextLocaleMap
.find(entry
);
632 if(itr
==mPageTextLocaleMap
.end()) return NULL
;
635 NpcOptionLocale
const* GetNpcOptionLocale(uint32 entry
) const
637 NpcOptionLocaleMap::const_iterator itr
= mNpcOptionLocaleMap
.find(entry
);
638 if(itr
==mNpcOptionLocaleMap
.end()) return NULL
;
641 PointOfInterestLocale
const* GetPointOfInterestLocale(uint32 poi_id
) const
643 PointOfInterestLocaleMap::const_iterator itr
= mPointOfInterestLocaleMap
.find(poi_id
);
644 if(itr
==mPointOfInterestLocaleMap
.end()) return NULL
;
648 GameObjectData
const* GetGOData(uint32 guid
) const
650 GameObjectDataMap::const_iterator itr
= mGameObjectDataMap
.find(guid
);
651 if(itr
==mGameObjectDataMap
.end()) return NULL
;
654 GameObjectData
& NewGOData(uint32 guid
) { return mGameObjectDataMap
[guid
]; }
655 void DeleteGOData(uint32 guid
);
657 MangosStringLocale
const* GetMangosStringLocale(int32 entry
) const
659 MangosStringLocaleMap::const_iterator itr
= mMangosStringLocaleMap
.find(entry
);
660 if(itr
==mMangosStringLocaleMap
.end()) return NULL
;
663 const char *GetMangosString(int32 entry
, int locale_idx
) const;
664 const char *GetMangosStringForDBCLocale(int32 entry
) const { return GetMangosString(entry
,DBCLocaleIndex
); }
665 int32
GetDBCLocaleIndex() const { return DBCLocaleIndex
; }
666 void SetDBCLocaleIndex(uint32 lang
) { DBCLocaleIndex
= GetIndexForLocale(LocaleConstant(lang
)); }
668 void AddCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
, uint32 instance
);
669 void DeleteCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
);
671 time_t GetCreatureRespawnTime(uint32 loguid
, uint32 instance
) { return mCreatureRespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
672 void SaveCreatureRespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
673 time_t GetGORespawnTime(uint32 loguid
, uint32 instance
) { return mGORespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
674 void SaveGORespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
675 void DeleteRespawnTimeForInstance(uint32 instance
);
678 void AddCreatureToGrid(uint32 guid
, CreatureData
const* data
);
679 void RemoveCreatureFromGrid(uint32 guid
, CreatureData
const* data
);
680 void AddGameobjectToGrid(uint32 guid
, GameObjectData
const* data
);
681 void RemoveGameobjectFromGrid(uint32 guid
, GameObjectData
const* data
);
684 void LoadReservedPlayersNames();
685 bool IsReservedName(const std::string
& name
) const;
687 // name with valid structure and symbols
688 static bool IsValidName( const std::string
& name
, bool create
= false );
689 static bool IsValidCharterName( const std::string
& name
);
690 static bool IsValidPetName( const std::string
& name
);
692 static bool CheckDeclinedNames(std::wstring mainpart
, DeclinedName
const& names
);
694 int GetIndexForLocale(LocaleConstant loc
);
695 LocaleConstant
GetLocaleForIndex(int i
);
697 uint32
GetGuildBankTabPrice(uint8 Index
) const { return Index
< GUILD_BANK_MAX_TABS
? mGuildBankTabPrice
[Index
] : 0; }
699 uint16
GetConditionId(ConditionType condition
, uint32 value1
, uint32 value2
);
700 bool IsPlayerMeetToCondition(Player
const* player
, uint16 condition_id
) const
702 if(condition_id
>= mConditions
.size())
705 return mConditions
[condition_id
].Meets(player
);
708 GameTele
const* GetGameTele(uint32 id
) const
710 GameTeleMap::const_iterator itr
= m_GameTeleMap
.find(id
);
711 if(itr
==m_GameTeleMap
.end()) return NULL
;
714 GameTele
const* GetGameTele(const std::string
& name
) const;
715 GameTeleMap
const& GetGameTeleMap() const { return m_GameTeleMap
; }
716 bool AddGameTele(GameTele
& data
);
717 bool DeleteGameTele(const std::string
& name
);
719 CacheNpcOptionList
const& GetNpcOptions() const { return m_mCacheNpcOptionList
; }
721 uint32
GetNpcGossip(uint32 entry
) const
723 CacheNpcTextIdMap::const_iterator iter
= m_mCacheNpcTextIdMap
.find(entry
);
724 if(iter
== m_mCacheNpcTextIdMap
.end())
730 TrainerSpellData
const* GetNpcTrainerSpells(uint32 entry
) const
732 CacheTrainerSpellMap::const_iterator iter
= m_mCacheTrainerSpellMap
.find(entry
);
733 if(iter
== m_mCacheTrainerSpellMap
.end())
736 return &iter
->second
;
739 VendorItemData
const* GetNpcVendorItemList(uint32 entry
) const
741 CacheVendorItemMap::const_iterator iter
= m_mCacheVendorItemMap
.find(entry
);
742 if(iter
== m_mCacheVendorItemMap
.end())
745 return &iter
->second
;
747 void AddVendorItem(uint32 entry
,uint32 item
, uint32 maxcount
, uint32 incrtime
, uint32 ExtendedCost
);
748 bool RemoveVendorItem(uint32 entry
,uint32 item
);
749 bool IsVendorItemValid( uint32 vendor_entry
, uint32 item
, uint32 maxcount
, uint32 ptime
, uint32 ExtendedCost
, Player
* pl
= NULL
, std::set
<uint32
>* skip_vendors
= NULL
) const;
751 void LoadScriptNames();
752 ScriptNameMap
&GetScriptNames() { return m_scriptNames
; }
753 const char * GetScriptName(uint32 id
) { return id
< m_scriptNames
.size() ? m_scriptNames
[id
].c_str() : ""; }
754 uint32
GetScriptId(const char *name
);
756 int GetOrNewIndexForLocale(LocaleConstant loc
);
759 // first free id for selected id type
760 uint32 m_arenaTeamId
;
765 uint32 m_hiPetNumber
;
767 // first free low guid for seelcted guid type
769 uint32 m_hiCreatureGuid
;
771 uint32 m_hiVehicleGuid
;
775 uint32 m_hiCorpseGuid
;
777 QuestMap mQuestTemplates
;
779 typedef UNORDERED_MAP
<uint32
, GossipText
> GossipTextMap
;
780 typedef UNORDERED_MAP
<uint32
, uint32
> QuestAreaTriggerMap
;
781 typedef UNORDERED_MAP
<uint32
, std::string
> ItemTextMap
;
782 typedef std::set
<uint32
> TavernAreaTriggerSet
;
783 typedef std::set
<uint32
> GameObjectForQuestSet
;
787 ArenaTeamMap mArenaTeamMap
;
789 ItemTextMap mItemTexts
;
791 QuestAreaTriggerMap mQuestAreaTriggerMap
;
792 TavernAreaTriggerSet mTavernAreaTriggerSet
;
793 GameObjectForQuestSet mGameObjectForQuestSet
;
794 GossipTextMap mGossipText
;
795 AreaTriggerMap mAreaTriggers
;
796 AreaTriggerScriptMap mAreaTriggerScripts
;
798 RepOnKillMap mRepOnKill
;
800 PointOfInterestMap mPointsOfInterest
;
802 WeatherZoneMap mWeatherZoneMap
;
804 PetCreateSpellMap mPetCreateSpell
;
806 //character reserved names
807 typedef std::set
<std::wstring
> ReservedNamesMap
;
808 ReservedNamesMap m_ReservedNames
;
810 GraveYardMap mGraveYardMap
;
812 GameTeleMap m_GameTeleMap
;
814 ScriptNameMap m_scriptNames
;
816 typedef std::vector
<LocaleConstant
> LocalForIndex
;
817 LocalForIndex m_LocalForIndex
;
822 void LoadScripts(ScriptMapMap
& scripts
, char const* tablename
);
823 void CheckScripts(ScriptMapMap
const& scripts
,std::set
<int32
>& ids
);
824 void ConvertCreatureAddonAuras(CreatureDataAddon
* addon
, char const* table
, char const* guidEntryStr
);
825 void LoadQuestRelationsHelper(QuestRelations
& map
,char const* table
);
827 typedef std::map
<uint32
,PetLevelInfo
*> PetLevelInfoMap
;
828 // PetLevelInfoMap[creature_id][level]
829 PetLevelInfoMap petInfo
; // [creature_id][level]
831 PlayerClassInfo playerClassInfo
[MAX_CLASSES
];
833 void BuildPlayerLevelInfo(uint8 race
, uint8 class_
, uint8 level
, PlayerLevelInfo
* plinfo
) const;
834 PlayerInfo playerInfo
[MAX_RACES
][MAX_CLASSES
];
836 typedef std::vector
<uint32
> PlayerXPperLevel
; // [level]
837 PlayerXPperLevel mPlayerXPperLevel
;
839 typedef std::map
<uint32
,uint32
> BaseXPMap
; // [area level][base xp]
840 BaseXPMap mBaseXPTable
;
842 typedef std::map
<uint32
,int32
> FishingBaseSkillMap
; // [areaId][base skill level]
843 FishingBaseSkillMap mFishingBaseForArea
;
845 typedef std::map
<uint32
,std::vector
<std::string
> > HalfNameMap
;
846 HalfNameMap PetHalfName0
;
847 HalfNameMap PetHalfName1
;
849 MapObjectGuids mMapObjectGuids
;
850 CreatureDataMap mCreatureDataMap
;
851 CreatureLocaleMap mCreatureLocaleMap
;
852 GameObjectDataMap mGameObjectDataMap
;
853 GameObjectLocaleMap mGameObjectLocaleMap
;
854 ItemLocaleMap mItemLocaleMap
;
855 QuestLocaleMap mQuestLocaleMap
;
856 NpcTextLocaleMap mNpcTextLocaleMap
;
857 PageTextLocaleMap mPageTextLocaleMap
;
858 MangosStringLocaleMap mMangosStringLocaleMap
;
859 NpcOptionLocaleMap mNpcOptionLocaleMap
;
860 PointOfInterestLocaleMap mPointOfInterestLocaleMap
;
861 RespawnTimes mCreatureRespawnTimes
;
862 RespawnTimes mGORespawnTimes
;
864 typedef std::vector
<uint32
> GuildBankTabPriceMap
;
865 GuildBankTabPriceMap mGuildBankTabPrice
;
867 // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required)
868 typedef std::vector
<PlayerCondition
> ConditionStore
;
869 ConditionStore mConditions
;
871 CacheNpcOptionList m_mCacheNpcOptionList
;
872 CacheNpcTextIdMap m_mCacheNpcTextIdMap
;
873 CacheVendorItemMap m_mCacheVendorItemMap
;
874 CacheTrainerSpellMap m_mCacheTrainerSpellMap
;
877 #define objmgr MaNGOS::Singleton<ObjectMgr>::Instance()
879 // scripting access functions
880 MANGOS_DLL_SPEC
bool LoadMangosStrings(DatabaseType
& db
, char const* table
,int32 start_value
= -1, int32 end_value
= std::numeric_limits
<int32
>::min());
881 MANGOS_DLL_SPEC uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
882 MANGOS_DLL_SPEC uint32
GetScriptId(const char *name
);
883 MANGOS_DLL_SPEC
ObjectMgr::ScriptNameMap
& GetScriptNames();
884 MANGOS_DLL_SPEC CreatureInfo
const* GetCreatureTemplateStore(uint32 entry
);
885 MANGOS_DLL_SPEC Quest
const* GetQuestTemplateStore(uint32 entry
);