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 uint32 requiredQuestHeroic
;
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
;
150 typedef UNORDERED_MAP
<uint32
,PointOfInterestLocale
> PointOfInterestLocaleMap
;
152 typedef std::multimap
<uint32
,uint32
> QuestRelations
;
156 PetLevelInfo() : health(0), mana(0) { for(int i
=0; i
< MAX_STATS
; ++i
) stats
[i
] = 0; }
158 uint16 stats
[MAX_STATS
];
164 struct ReputationOnKillEntry
169 uint32 reputation_max_cap1
;
172 uint32 reputation_max_cap2
;
177 struct PointOfInterest
185 std::string icon_name
;
188 struct PetCreateSpellEntry
193 #define WEATHER_SEASONS 4
194 struct WeatherSeasonChances
201 struct WeatherZoneChances
203 WeatherSeasonChances data
[WEATHER_SEASONS
];
211 typedef std::multimap
<uint32
,GraveYardData
> GraveYardMap
;
214 { // value1 value2 for the Condition enumed
215 CONDITION_NONE
= 0, // 0 0
216 CONDITION_AURA
= 1, // spell_id effindex
217 CONDITION_ITEM
= 2, // item_id count
218 CONDITION_ITEM_EQUIPPED
= 3, // item_id 0
219 CONDITION_ZONEID
= 4, // zone_id 0
220 CONDITION_REPUTATION_RANK
= 5, // faction_id min_rank
221 CONDITION_TEAM
= 6, // player_team 0, (469 - Alliance 67 - Horde)
222 CONDITION_SKILL
= 7, // skill_id skill_value
223 CONDITION_QUESTREWARDED
= 8, // quest_id 0
224 CONDITION_QUESTTAKEN
= 9, // quest_id 0, for condition true while quest active.
225 CONDITION_AD_COMMISSION_AURA
= 10, // 0 0, for condition true while one from AD ñommission aura active
226 CONDITION_NO_AURA
= 11, // spell_id effindex
227 CONDITION_ACTIVE_EVENT
= 12, // event_id
230 #define MAX_CONDITION 13 // maximum value in ConditionType enum
232 struct PlayerCondition
234 ConditionType condition
; // additional condition type
235 uint32 value1
; // data for the condition - see ConditionType definition
238 PlayerCondition(uint8 _condition
= 0, uint32 _value1
= 0, uint32 _value2
= 0)
239 : condition(ConditionType(_condition
)), value1(_value1
), value2(_value2
) {}
241 static bool IsValid(ConditionType condition
, uint32 value1
, uint32 value2
);
242 // Checks correctness of values
243 bool Meets(Player
const * APlayer
) const; // Checks if the player meets the condition
244 bool operator == (PlayerCondition
const& lc
) const
246 return (lc
.condition
== condition
&& lc
.value1
== value1
&& lc
.value2
== value2
);
250 // NPC gossip text id
251 typedef UNORDERED_MAP
<uint32
, uint32
> CacheNpcTextIdMap
;
252 typedef std::list
<GossipOption
> CacheNpcOptionList
;
254 typedef UNORDERED_MAP
<uint32
, VendorItemData
> CacheVendorItemMap
;
255 typedef UNORDERED_MAP
<uint32
, TrainerSpellData
> CacheTrainerSpellMap
;
259 SKILL_RANGE_LANGUAGE
, // 300..300
260 SKILL_RANGE_LEVEL
, // 1..max skill for level
261 SKILL_RANGE_MONO
, // 1..1, grey monolite bar
262 SKILL_RANGE_RANK
, // 1..skill for known rank
263 SKILL_RANGE_NONE
, // 0..0 always
266 SkillRangeType
GetSkillRangeType(SkillLineEntry
const *pSkill
, bool racial
);
268 #define MAX_PLAYER_NAME 12 // max allowed by client name length
269 #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
271 bool normalizePlayerName(std::string
& name
);
273 struct MANGOS_DLL_SPEC LanguageDesc
280 extern LanguageDesc lang_description
[LANGUAGES_COUNT
];
281 MANGOS_DLL_SPEC LanguageDesc
const* GetLanguageDescByID(uint32 lang
);
283 class PlayerDumpReader
;
287 friend class PlayerDumpReader
;
293 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
295 typedef std::set
< Group
* > GroupSet
;
297 typedef UNORDERED_MAP
<uint32
, Guild
*> GuildMap
;
299 typedef UNORDERED_MAP
<uint32
, ArenaTeam
*> ArenaTeamMap
;
301 typedef UNORDERED_MAP
<uint32
, Quest
*> QuestMap
;
303 typedef UNORDERED_MAP
<uint32
, AreaTrigger
> AreaTriggerMap
;
305 typedef UNORDERED_MAP
<uint32
, uint32
> AreaTriggerScriptMap
;
307 typedef UNORDERED_MAP
<uint32
, ReputationOnKillEntry
> RepOnKillMap
;
308 typedef UNORDERED_MAP
<uint32
, PointOfInterest
> PointOfInterestMap
;
310 typedef UNORDERED_MAP
<uint32
, WeatherZoneChances
> WeatherZoneMap
;
312 typedef UNORDERED_MAP
<uint32
, PetCreateSpellEntry
> PetCreateSpellMap
;
314 typedef std::vector
<std::string
> ScriptNameMap
;
316 Player
* GetPlayer(const char* name
) const { return ObjectAccessor::Instance().FindPlayerByName(name
);}
317 Player
* GetPlayer(uint64 guid
) const { return ObjectAccessor::FindPlayer(guid
); }
319 static GameObjectInfo
const *GetGameObjectInfo(uint32 id
) { return sGOStorage
.LookupEntry
<GameObjectInfo
>(id
); }
321 void LoadGameobjectInfo();
322 void AddGameobjectInfo(GameObjectInfo
*goinfo
);
324 Group
* GetGroupByLeader(const uint64
&guid
) const;
325 void AddGroup(Group
* group
) { mGroupSet
.insert( group
); }
326 void RemoveGroup(Group
* group
) { mGroupSet
.erase( group
); }
328 Guild
* GetGuildByLeader(uint64
const&guid
) const;
329 Guild
* GetGuildById(uint32 GuildId
) const;
330 Guild
* GetGuildByName(const std::string
& guildname
) const;
331 std::string
GetGuildNameById(uint32 GuildId
) const;
332 void AddGuild(Guild
* guild
);
333 void RemoveGuild(uint32 Id
);
335 ArenaTeam
* GetArenaTeamById(uint32 arenateamid
) const;
336 ArenaTeam
* GetArenaTeamByName(const std::string
& arenateamname
) const;
337 ArenaTeam
* GetArenaTeamByCaptain(uint64
const& guid
) const;
338 void AddArenaTeam(ArenaTeam
* arenaTeam
);
339 void RemoveArenaTeam(uint32 Id
);
340 ArenaTeamMap::iterator
GetArenaTeamMapBegin() { return mArenaTeamMap
.begin(); }
341 ArenaTeamMap::iterator
GetArenaTeamMapEnd() { return mArenaTeamMap
.end(); }
343 static CreatureInfo
const *GetCreatureTemplate( uint32 id
);
344 CreatureModelInfo
const *GetCreatureModelInfo( uint32 modelid
);
345 CreatureModelInfo
const* GetCreatureModelRandomGender(uint32 display_id
);
346 uint32
ChooseDisplayId(uint32 team
, const CreatureInfo
*cinfo
, const CreatureData
*data
= NULL
);
347 EquipmentInfo
const *GetEquipmentInfo( uint32 entry
);
348 static CreatureDataAddon
const *GetCreatureAddon( uint32 lowguid
)
350 return sCreatureDataAddonStorage
.LookupEntry
<CreatureDataAddon
>(lowguid
);
353 static CreatureDataAddon
const *GetCreatureTemplateAddon( uint32 entry
)
355 return sCreatureInfoAddonStorage
.LookupEntry
<CreatureDataAddon
>(entry
);
358 static ItemPrototype
const* GetItemPrototype(uint32 id
) { return sItemStorage
.LookupEntry
<ItemPrototype
>(id
); }
360 static InstanceTemplate
const* GetInstanceTemplate(uint32 map
)
362 return sInstanceTemplate
.LookupEntry
<InstanceTemplate
>(map
);
365 PetLevelInfo
const* GetPetLevelInfo(uint32 creature_id
, uint32 level
) const;
367 PlayerClassInfo
const* GetPlayerClassInfo(uint32 class_
) const
369 if(class_
>= MAX_CLASSES
) return NULL
;
370 return &playerClassInfo
[class_
];
372 void GetPlayerClassLevelInfo(uint32 class_
,uint32 level
, PlayerClassLevelInfo
* info
) const;
374 PlayerInfo
const* GetPlayerInfo(uint32 race
, uint32 class_
) const
376 if(race
>= MAX_RACES
) return NULL
;
377 if(class_
>= MAX_CLASSES
) return NULL
;
378 PlayerInfo
const* info
= &playerInfo
[race
][class_
];
379 if(info
->displayId_m
==0 || info
->displayId_f
==0) return NULL
;
382 void GetPlayerLevelInfo(uint32 race
, uint32 class_
,uint32 level
, PlayerLevelInfo
* info
) const;
384 uint64
GetPlayerGUIDByName(std::string name
) const;
385 bool GetPlayerNameByGUID(const uint64
&guid
, std::string
&name
) const;
386 uint32
GetPlayerTeamByGUID(const uint64
&guid
) const;
387 uint32
GetPlayerAccountIdByGUID(const uint64
&guid
) const;
388 uint32
GetPlayerAccountIdByPlayerName(const std::string
& name
) const;
390 uint32
GetNearestTaxiNode( float x
, float y
, float z
, uint32 mapid
, uint32 team
);
391 void GetTaxiPath( uint32 source
, uint32 destination
, uint32
&path
, uint32
&cost
);
392 uint16
GetTaxiMount( uint32 id
, uint32 team
);
393 void GetTaxiPathNodes( uint32 path
, Path
&pathnodes
, std::vector
<uint32
>& mapIds
);
394 void GetTransportPathNodes( uint32 path
, TransportPath
&pathnodes
);
396 Quest
const* GetQuestTemplate(uint32 quest_id
) const
398 QuestMap::const_iterator itr
= mQuestTemplates
.find(quest_id
);
399 return itr
!= mQuestTemplates
.end() ? itr
->second
: NULL
;
401 QuestMap
const& GetQuestTemplates() const { return mQuestTemplates
; }
403 uint32
GetQuestForAreaTrigger(uint32 Trigger_ID
) const
405 QuestAreaTriggerMap::const_iterator itr
= mQuestAreaTriggerMap
.find(Trigger_ID
);
406 if(itr
!= mQuestAreaTriggerMap
.end())
410 bool IsTavernAreaTrigger(uint32 Trigger_ID
) const
412 return mTavernAreaTriggerSet
.find(Trigger_ID
) != mTavernAreaTriggerSet
.end();
415 bool IsGameObjectForQuests(uint32 entry
) const
417 return mGameObjectForQuestSet
.find(entry
) != mGameObjectForQuestSet
.end();
420 bool IsGuildVaultGameObject(Player
*player
, uint64 guid
) const
422 if(GameObject
*go
= ObjectAccessor::GetGameObject(*player
, guid
))
423 if(go
->GetGoType() == GAMEOBJECT_TYPE_GUILD_BANK
)
428 GossipText
const* GetGossipText(uint32 Text_ID
) const;
430 WorldSafeLocsEntry
const *GetClosestGraveYard(float x
, float y
, float z
, uint32 MapId
, uint32 team
);
431 bool AddGraveYardLink(uint32 id
, uint32 zone
, uint32 team
, bool inDB
= true);
432 void LoadGraveyardZones();
433 GraveYardData
const* FindGraveYardData(uint32 id
, uint32 zone
);
435 AreaTrigger
const* GetAreaTrigger(uint32 trigger
) const
437 AreaTriggerMap::const_iterator itr
= mAreaTriggers
.find( trigger
);
438 if( itr
!= mAreaTriggers
.end( ) )
443 AreaTrigger
const* GetGoBackTrigger(uint32 Map
) const;
444 AreaTrigger
const* GetMapEntranceTrigger(uint32 Map
) const;
446 uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
448 ReputationOnKillEntry
const* GetReputationOnKilEntry(uint32 id
) const
450 RepOnKillMap::const_iterator itr
= mRepOnKill
.find(id
);
451 if(itr
!= mRepOnKill
.end())
456 PointOfInterest
const* GetPointOfInterest(uint32 id
) const
458 PointOfInterestMap::const_iterator itr
= mPointsOfInterest
.find(id
);
459 if(itr
!= mPointsOfInterest
.end())
464 PetCreateSpellEntry
const* GetPetCreateSpellEntry(uint32 id
) const
466 PetCreateSpellMap::const_iterator itr
= mPetCreateSpell
.find(id
);
467 if(itr
!= mPetCreateSpell
.end())
473 void LoadArenaTeams();
476 void LoadQuestRelations()
478 LoadGameobjectQuestRelations();
479 LoadGameobjectInvolvedRelations();
480 LoadCreatureQuestRelations();
481 LoadCreatureInvolvedRelations();
483 void LoadGameobjectQuestRelations();
484 void LoadGameobjectInvolvedRelations();
485 void LoadCreatureQuestRelations();
486 void LoadCreatureInvolvedRelations();
488 QuestRelations mGOQuestRelations
;
489 QuestRelations mGOQuestInvolvedRelations
;
490 QuestRelations mCreatureQuestRelations
;
491 QuestRelations mCreatureQuestInvolvedRelations
;
493 void LoadGameObjectScripts();
494 void LoadQuestEndScripts();
495 void LoadQuestStartScripts();
496 void LoadEventScripts();
497 void LoadSpellScripts();
499 bool LoadMangosStrings(DatabaseType
& db
, char const* table
, int32 min_value
, int32 max_value
);
500 bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase
,"mangos_string",MIN_MANGOS_STRING_ID
,MAX_MANGOS_STRING_ID
); }
501 void LoadDbScriptStrings();
502 void LoadPetCreateSpells();
503 void LoadCreatureLocales();
504 void LoadCreatureTemplates();
505 void LoadCreatures();
506 void LoadCreatureRespawnTimes();
507 void LoadCreatureAddons();
508 void LoadCreatureModelInfo();
509 void LoadEquipmentTemplates();
510 void LoadGameObjectLocales();
511 void LoadGameobjects();
512 void LoadGameobjectRespawnTimes();
513 void LoadItemPrototypes();
514 void LoadItemLocales();
515 void LoadQuestLocales();
516 void LoadNpcTextLocales();
517 void LoadPageTextLocales();
518 void LoadNpcOptionLocales();
519 void LoadPointOfInterestLocales();
520 void LoadInstanceTemplate();
522 void LoadGossipText();
524 void LoadAreaTriggerTeleports();
525 void LoadQuestAreaTriggers();
526 void LoadAreaTriggerScripts();
527 void LoadTavernAreaTriggers();
528 void LoadGameObjectForQuests();
530 void LoadItemTexts();
531 void LoadPageTexts();
533 void LoadPlayerInfo();
534 void LoadPetLevelInfo();
535 void LoadExplorationBaseXP();
537 void LoadPetNumber();
539 void LoadFishingBaseSkillLevel();
541 void LoadReputationOnKill();
542 void LoadPointsOfInterest();
544 void LoadWeatherZoneChances();
547 void LoadNpcOptions();
548 void LoadNpcTextId();
550 void LoadTrainerSpell();
552 std::string
GeneratePetName(uint32 entry
);
553 uint32
GetBaseXP(uint32 level
);
554 uint32
GetXPForLevel(uint32 level
);
556 int32
GetFishingBaseSkillLevel(uint32 entry
) const
558 FishingBaseSkillMap::const_iterator itr
= mFishingBaseForArea
.find(entry
);
559 return itr
!= mFishingBaseForArea
.end() ? itr
->second
: 0;
562 void ReturnOrDeleteOldMails(bool serverUp
);
564 void SetHighestGuids();
565 uint32
GenerateLowGuid(HighGuid guidhigh
);
566 uint32
GenerateArenaTeamId();
567 uint32
GenerateAuctionID();
568 uint32
GenerateGuildId();
569 uint32
GenerateItemTextID();
570 uint32
GenerateMailID();
571 uint32
GeneratePetNumber();
573 uint32
CreateItemText(std::string text
);
574 std::string
GetItemText( uint32 id
)
576 ItemTextMap::const_iterator itr
= mItemTexts
.find( id
);
577 if ( itr
!= mItemTexts
.end() )
580 return "There is no info for this item";
583 typedef std::multimap
<int32
, uint32
> ExclusiveQuestGroups
;
584 ExclusiveQuestGroups mExclusiveQuestGroups
;
586 WeatherZoneChances
const* GetWeatherChances(uint32 zone_id
) const
588 WeatherZoneMap::const_iterator itr
= mWeatherZoneMap
.find(zone_id
);
589 if(itr
!= mWeatherZoneMap
.end())
595 CellObjectGuids
const& GetCellObjectGuids(uint16 mapid
, uint8 spawnMode
, uint32 cell_id
)
597 return mMapObjectGuids
[MAKE_PAIR32(mapid
,spawnMode
)][cell_id
];
600 CreatureData
const* GetCreatureData(uint32 guid
) const
602 CreatureDataMap::const_iterator itr
= mCreatureDataMap
.find(guid
);
603 if(itr
==mCreatureDataMap
.end()) return NULL
;
606 CreatureData
& NewOrExistCreatureData(uint32 guid
) { return mCreatureDataMap
[guid
]; }
607 void DeleteCreatureData(uint32 guid
);
608 CreatureLocale
const* GetCreatureLocale(uint32 entry
) const
610 CreatureLocaleMap::const_iterator itr
= mCreatureLocaleMap
.find(entry
);
611 if(itr
==mCreatureLocaleMap
.end()) return NULL
;
614 GameObjectLocale
const* GetGameObjectLocale(uint32 entry
) const
616 GameObjectLocaleMap::const_iterator itr
= mGameObjectLocaleMap
.find(entry
);
617 if(itr
==mGameObjectLocaleMap
.end()) return NULL
;
620 ItemLocale
const* GetItemLocale(uint32 entry
) const
622 ItemLocaleMap::const_iterator itr
= mItemLocaleMap
.find(entry
);
623 if(itr
==mItemLocaleMap
.end()) return NULL
;
626 QuestLocale
const* GetQuestLocale(uint32 entry
) const
628 QuestLocaleMap::const_iterator itr
= mQuestLocaleMap
.find(entry
);
629 if(itr
==mQuestLocaleMap
.end()) return NULL
;
632 NpcTextLocale
const* GetNpcTextLocale(uint32 entry
) const
634 NpcTextLocaleMap::const_iterator itr
= mNpcTextLocaleMap
.find(entry
);
635 if(itr
==mNpcTextLocaleMap
.end()) return NULL
;
638 PageTextLocale
const* GetPageTextLocale(uint32 entry
) const
640 PageTextLocaleMap::const_iterator itr
= mPageTextLocaleMap
.find(entry
);
641 if(itr
==mPageTextLocaleMap
.end()) return NULL
;
644 NpcOptionLocale
const* GetNpcOptionLocale(uint32 entry
) const
646 NpcOptionLocaleMap::const_iterator itr
= mNpcOptionLocaleMap
.find(entry
);
647 if(itr
==mNpcOptionLocaleMap
.end()) return NULL
;
650 PointOfInterestLocale
const* GetPointOfInterestLocale(uint32 poi_id
) const
652 PointOfInterestLocaleMap::const_iterator itr
= mPointOfInterestLocaleMap
.find(poi_id
);
653 if(itr
==mPointOfInterestLocaleMap
.end()) return NULL
;
657 GameObjectData
const* GetGOData(uint32 guid
) const
659 GameObjectDataMap::const_iterator itr
= mGameObjectDataMap
.find(guid
);
660 if(itr
==mGameObjectDataMap
.end()) return NULL
;
663 GameObjectData
& NewGOData(uint32 guid
) { return mGameObjectDataMap
[guid
]; }
664 void DeleteGOData(uint32 guid
);
666 MangosStringLocale
const* GetMangosStringLocale(int32 entry
) const
668 MangosStringLocaleMap::const_iterator itr
= mMangosStringLocaleMap
.find(entry
);
669 if(itr
==mMangosStringLocaleMap
.end()) return NULL
;
672 const char *GetMangosString(int32 entry
, int locale_idx
) const;
673 const char *GetMangosStringForDBCLocale(int32 entry
) const { return GetMangosString(entry
,DBCLocaleIndex
); }
674 int32
GetDBCLocaleIndex() const { return DBCLocaleIndex
; }
675 void SetDBCLocaleIndex(uint32 lang
) { DBCLocaleIndex
= GetIndexForLocale(LocaleConstant(lang
)); }
677 void AddCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
, uint32 instance
);
678 void DeleteCorpseCellData(uint32 mapid
, uint32 cellid
, uint32 player_guid
);
680 time_t GetCreatureRespawnTime(uint32 loguid
, uint32 instance
) { return mCreatureRespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
681 void SaveCreatureRespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
682 time_t GetGORespawnTime(uint32 loguid
, uint32 instance
) { return mGORespawnTimes
[MAKE_PAIR64(loguid
,instance
)]; }
683 void SaveGORespawnTime(uint32 loguid
, uint32 instance
, time_t t
);
684 void DeleteRespawnTimeForInstance(uint32 instance
);
687 void AddCreatureToGrid(uint32 guid
, CreatureData
const* data
);
688 void RemoveCreatureFromGrid(uint32 guid
, CreatureData
const* data
);
689 void AddGameobjectToGrid(uint32 guid
, GameObjectData
const* data
);
690 void RemoveGameobjectFromGrid(uint32 guid
, GameObjectData
const* data
);
693 void LoadReservedPlayersNames();
694 bool IsReservedName(const std::string
& name
) const;
696 // name with valid structure and symbols
697 static bool IsValidName( const std::string
& name
, bool create
= false );
698 static bool IsValidCharterName( const std::string
& name
);
699 static bool IsValidPetName( const std::string
& name
);
701 static bool CheckDeclinedNames(std::wstring mainpart
, DeclinedName
const& names
);
703 int GetIndexForLocale(LocaleConstant loc
);
704 LocaleConstant
GetLocaleForIndex(int i
);
706 uint32
GetGuildBankTabPrice(uint8 Index
) const { return Index
< GUILD_BANK_MAX_TABS
? mGuildBankTabPrice
[Index
] : 0; }
708 uint16
GetConditionId(ConditionType condition
, uint32 value1
, uint32 value2
);
709 bool IsPlayerMeetToCondition(Player
const* player
, uint16 condition_id
) const
711 if(condition_id
>= mConditions
.size())
714 return mConditions
[condition_id
].Meets(player
);
717 GameTele
const* GetGameTele(uint32 id
) const
719 GameTeleMap::const_iterator itr
= m_GameTeleMap
.find(id
);
720 if(itr
==m_GameTeleMap
.end()) return NULL
;
723 GameTele
const* GetGameTele(const std::string
& name
) const;
724 GameTeleMap
const& GetGameTeleMap() const { return m_GameTeleMap
; }
725 bool AddGameTele(GameTele
& data
);
726 bool DeleteGameTele(const std::string
& name
);
728 CacheNpcOptionList
const& GetNpcOptions() const { return m_mCacheNpcOptionList
; }
730 uint32
GetNpcGossip(uint32 entry
) const
732 CacheNpcTextIdMap::const_iterator iter
= m_mCacheNpcTextIdMap
.find(entry
);
733 if(iter
== m_mCacheNpcTextIdMap
.end())
739 TrainerSpellData
const* GetNpcTrainerSpells(uint32 entry
) const
741 CacheTrainerSpellMap::const_iterator iter
= m_mCacheTrainerSpellMap
.find(entry
);
742 if(iter
== m_mCacheTrainerSpellMap
.end())
745 return &iter
->second
;
748 VendorItemData
const* GetNpcVendorItemList(uint32 entry
) const
750 CacheVendorItemMap::const_iterator iter
= m_mCacheVendorItemMap
.find(entry
);
751 if(iter
== m_mCacheVendorItemMap
.end())
754 return &iter
->second
;
756 void AddVendorItem(uint32 entry
,uint32 item
, uint32 maxcount
, uint32 incrtime
, uint32 ExtendedCost
);
757 bool RemoveVendorItem(uint32 entry
,uint32 item
);
758 bool IsVendorItemValid( uint32 vendor_entry
, uint32 item
, uint32 maxcount
, uint32 ptime
, uint32 ExtendedCost
, Player
* pl
= NULL
, std::set
<uint32
>* skip_vendors
= NULL
) const;
760 void LoadScriptNames();
761 ScriptNameMap
&GetScriptNames() { return m_scriptNames
; }
762 const char * GetScriptName(uint32 id
) { return id
< m_scriptNames
.size() ? m_scriptNames
[id
].c_str() : ""; }
763 uint32
GetScriptId(const char *name
);
765 int GetOrNewIndexForLocale(LocaleConstant loc
);
768 // first free id for selected id type
769 uint32 m_arenaTeamId
;
774 uint32 m_hiPetNumber
;
776 // first free low guid for seelcted guid type
778 uint32 m_hiCreatureGuid
;
780 uint32 m_hiVehicleGuid
;
784 uint32 m_hiCorpseGuid
;
786 QuestMap mQuestTemplates
;
788 typedef UNORDERED_MAP
<uint32
, GossipText
> GossipTextMap
;
789 typedef UNORDERED_MAP
<uint32
, uint32
> QuestAreaTriggerMap
;
790 typedef UNORDERED_MAP
<uint32
, std::string
> ItemTextMap
;
791 typedef std::set
<uint32
> TavernAreaTriggerSet
;
792 typedef std::set
<uint32
> GameObjectForQuestSet
;
796 ArenaTeamMap mArenaTeamMap
;
798 ItemTextMap mItemTexts
;
800 QuestAreaTriggerMap mQuestAreaTriggerMap
;
801 TavernAreaTriggerSet mTavernAreaTriggerSet
;
802 GameObjectForQuestSet mGameObjectForQuestSet
;
803 GossipTextMap mGossipText
;
804 AreaTriggerMap mAreaTriggers
;
805 AreaTriggerScriptMap mAreaTriggerScripts
;
807 RepOnKillMap mRepOnKill
;
809 PointOfInterestMap mPointsOfInterest
;
811 WeatherZoneMap mWeatherZoneMap
;
813 PetCreateSpellMap mPetCreateSpell
;
815 //character reserved names
816 typedef std::set
<std::wstring
> ReservedNamesMap
;
817 ReservedNamesMap m_ReservedNames
;
819 GraveYardMap mGraveYardMap
;
821 GameTeleMap m_GameTeleMap
;
823 ScriptNameMap m_scriptNames
;
825 typedef std::vector
<LocaleConstant
> LocalForIndex
;
826 LocalForIndex m_LocalForIndex
;
831 void LoadScripts(ScriptMapMap
& scripts
, char const* tablename
);
832 void CheckScripts(ScriptMapMap
const& scripts
,std::set
<int32
>& ids
);
833 void ConvertCreatureAddonAuras(CreatureDataAddon
* addon
, char const* table
, char const* guidEntryStr
);
834 void LoadQuestRelationsHelper(QuestRelations
& map
,char const* table
);
836 typedef std::map
<uint32
,PetLevelInfo
*> PetLevelInfoMap
;
837 // PetLevelInfoMap[creature_id][level]
838 PetLevelInfoMap petInfo
; // [creature_id][level]
840 PlayerClassInfo playerClassInfo
[MAX_CLASSES
];
842 void BuildPlayerLevelInfo(uint8 race
, uint8 class_
, uint8 level
, PlayerLevelInfo
* plinfo
) const;
843 PlayerInfo playerInfo
[MAX_RACES
][MAX_CLASSES
];
845 typedef std::vector
<uint32
> PlayerXPperLevel
; // [level]
846 PlayerXPperLevel mPlayerXPperLevel
;
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 PointOfInterestLocaleMap mPointOfInterestLocaleMap
;
870 RespawnTimes mCreatureRespawnTimes
;
871 RespawnTimes mGORespawnTimes
;
873 typedef std::vector
<uint32
> GuildBankTabPriceMap
;
874 GuildBankTabPriceMap mGuildBankTabPrice
;
876 // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required)
877 typedef std::vector
<PlayerCondition
> ConditionStore
;
878 ConditionStore mConditions
;
880 CacheNpcOptionList m_mCacheNpcOptionList
;
881 CacheNpcTextIdMap m_mCacheNpcTextIdMap
;
882 CacheVendorItemMap m_mCacheVendorItemMap
;
883 CacheTrainerSpellMap m_mCacheTrainerSpellMap
;
886 #define objmgr MaNGOS::Singleton<ObjectMgr>::Instance()
888 // scripting access functions
889 MANGOS_DLL_SPEC
bool LoadMangosStrings(DatabaseType
& db
, char const* table
,int32 start_value
= -1, int32 end_value
= std::numeric_limits
<int32
>::min());
890 MANGOS_DLL_SPEC uint32
GetAreaTriggerScriptId(uint32 trigger_id
);
891 MANGOS_DLL_SPEC uint32
GetScriptId(const char *name
);
892 MANGOS_DLL_SPEC
ObjectMgr::ScriptNameMap
& GetScriptNames();
893 MANGOS_DLL_SPEC CreatureInfo
const* GetCreatureTemplateStore(uint32 entry
);
894 MANGOS_DLL_SPEC Quest
const* GetQuestTemplateStore(uint32 entry
);