AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ObjectMgr Class Reference

#include "ObjectMgr.h"

Classes

struct  GameobjectInstanceSavedState
 

Public Types

typedef std::unordered_map< uint32, Item * > ItemMap
 
typedef std::unordered_map< uint32, Quest * > QuestMap
 
typedef std::unordered_map< uint32, AreaTriggerAreaTriggerContainer
 
typedef std::unordered_map< uint32, AreaTriggerTeleportAreaTriggerTeleportContainer
 
typedef std::unordered_map< uint32, uint32AreaTriggerScriptContainer
 
typedef std::unordered_map< uint32, std::unordered_map< uint8, DungeonProgressionRequirements * > > DungeonProgressionRequirementsContainer
 
typedef std::unordered_map< uint32, RepRewardRateRepRewardRateContainer
 
typedef std::unordered_map< uint32, ReputationOnKillEntryRepOnKillContainer
 
typedef std::unordered_map< uint32, RepSpilloverTemplateRepSpilloverTemplateContainer
 
typedef std::unordered_map< uint32, PointOfInterestPointOfInterestContainer
 
typedef std::vector< std::string > ScriptNameContainer
 
typedef std::map< uint32, uint32CharacterConversionMap
 
typedef std::multimap< int32, uint32ExclusiveQuestGroups
 
typedef std::pair< ExclusiveQuestGroups::const_iterator, ExclusiveQuestGroups::const_iterator > ExclusiveQuestGroupsBounds
 

Public Member Functions

GameObjectTemplate const * GetGameObjectTemplate (uint32 entry)
 
bool IsGameObjectStaticTransport (uint32 entry)
 
GameObjectTemplateContainer const * GetGameObjectTemplates () const
 
int LoadReferenceVendor (int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
 
void LoadGameObjectTemplate ()
 
void LoadGameObjectTemplateAddons ()
 
void AddGameobjectInfo (GameObjectTemplate *goinfo)
 
CreatureTemplate const * GetCreatureTemplate (uint32 entry)
 
CreatureTemplateContainer const * GetCreatureTemplates () const
 
CreatureModelInfo const * GetCreatureModelInfo (uint32 modelId) const
 
CreatureModelInfo const * GetCreatureModelRandomGender (CreatureModel *model, CreatureTemplate const *creatureTemplate) const
 
EquipmentInfo const * GetEquipmentInfo (uint32 entry, int8 &id)
 
CreatureAddon const * GetCreatureAddon (ObjectGuid::LowType lowguid)
 
GameObjectAddon const * GetGameObjectAddon (ObjectGuid::LowType lowguid)
 
GameObjectTemplateAddon const * GetGameObjectTemplateAddon (uint32 entry) const
 
CreatureAddon const * GetCreatureTemplateAddon (uint32 entry)
 
CreatureMovementData const * GetCreatureMovementOverride (ObjectGuid::LowType spawnId) const
 
ItemTemplate const * GetItemTemplate (uint32 entry)
 
ItemTemplateContainer const * GetItemTemplateStore () const
 
std::vector< ItemTemplate * > const * GetItemTemplateStoreFast () const
 
ItemSetNameEntry const * GetItemSetNameEntry (uint32 itemId)
 
InstanceTemplate const * GetInstanceTemplate (uint32 mapId)
 
PetLevelInfo const * GetPetLevelInfo (uint32 creature_id, uint8 level) const
 
PlayerClassInfo const * GetPlayerClassInfo (uint32 class_) const
 
void GetPlayerClassLevelInfo (uint32 class_, uint8 level, PlayerClassLevelInfo *info) const
 
PlayerInfo const * GetPlayerInfo (uint32 race, uint32 class_) const
 
void GetPlayerLevelInfo (uint32 race, uint32 class_, uint8 level, PlayerLevelInfo *info) const
 
uint32 GetNearestTaxiNode (float x, float y, float z, uint32 mapid, uint32 teamId)
 
void GetTaxiPath (uint32 source, uint32 destination, uint32 &path, uint32 &cost)
 
uint32 GetTaxiMountDisplayId (uint32 id, TeamId teamId, bool allowed_alt_team=false)
 
GameObjectQuestItemList const * GetGameObjectQuestItemList (uint32 id) const
 
GameObjectQuestItemMap const * GetGameObjectQuestItemMap () const
 
CreatureQuestItemList const * GetCreatureQuestItemList (uint32 id) const
 
CreatureQuestItemMap const * GetCreatureQuestItemMap () const
 
Quest const * GetQuestTemplate (uint32 quest_id) const
 
QuestMap const & GetQuestTemplates () const
 
uint32 GetQuestForAreaTrigger (uint32 Trigger_ID) const
 
bool IsTavernAreaTrigger (uint32 triggerID, uint32 faction) const
 
GossipText const * GetGossipText (uint32 Text_ID) const
 
AreaTrigger const * GetAreaTrigger (uint32 trigger) const
 
AreaTriggerTeleport const * GetAreaTriggerTeleport (uint32 trigger) const
 
DungeonProgressionRequirements const * GetAccessRequirement (uint32 mapid, Difficulty difficulty) const
 
AreaTriggerTeleport const * GetGoBackTrigger (uint32 Map) const
 
AreaTriggerTeleport const * GetMapEntranceTrigger (uint32 Map) const
 
uint32 GetAreaTriggerScriptId (uint32 trigger_id)
 
SpellScriptsBounds GetSpellScriptsBounds (uint32 spell_id)
 
RepRewardRate const * GetRepRewardRate (uint32 factionId) const
 
ReputationOnKillEntry const * GetReputationOnKilEntry (uint32 id) const
 
int32 GetBaseReputationOf (FactionEntry const *factionEntry, uint8 race, uint8 playerClass)
 
RepSpilloverTemplate const * GetRepSpilloverTemplate (uint32 factionId) const
 
PointOfInterest const * GetPointOfInterest (uint32 id) const
 
QuestPOIVector const * GetQuestPOIVector (uint32 questId)
 
VehicleAccessoryList const * GetVehicleAccessoryList (Vehicle *veh) const
 
DungeonEncounterList const * GetDungeonEncounterList (uint32 mapId, Difficulty difficulty)
 
void LoadQuests ()
 
void LoadQuestMoneyRewards ()
 
void LoadQuestStartersAndEnders ()
 
void LoadGameobjectQuestStarters ()
 
void LoadGameobjectQuestEnders ()
 
void LoadCreatureQuestStarters ()
 
void LoadCreatureQuestEnders ()
 
QuestRelationsGetGOQuestRelationMap ()
 
QuestRelationsGetGOQuestInvolvedRelationMap ()
 
QuestRelationBounds GetGOQuestRelationBounds (uint32 go_entry)
 
QuestRelationBounds GetGOQuestInvolvedRelationBounds (uint32 go_entry)
 
QuestRelationsGetCreatureQuestRelationMap ()
 
QuestRelationsGetCreatureQuestInvolvedRelationMap ()
 
QuestRelationBounds GetCreatureQuestRelationBounds (uint32 creature_entry)
 
QuestRelationBounds GetCreatureQuestInvolvedRelationBounds (uint32 creature_entry)
 
void LoadEventScripts ()
 
void LoadSpellScripts ()
 
void LoadWaypointScripts ()
 
void LoadSpellScriptNames ()
 
void ValidateSpellScripts ()
 
void InitializeSpellInfoPrecomputedData ()
 
bool LoadModuleStrings ()
 
bool LoadModuleStringsLocale ()
 
bool LoadAcoreStrings ()
 
void LoadBroadcastTexts ()
 
void LoadBroadcastTextLocales ()
 
void LoadCreatureClassLevelStats ()
 
void LoadCreatureLocales ()
 
void LoadCreatureTemplates ()
 
void LoadCreatureTemplate (Field *fields, bool triggerHook=false)
 Loads a creature template from a database result. More...
 
void LoadCreatureTemplateModels ()
 
void LoadCreatureTemplateAddons ()
 
void LoadCreatureTemplateResistances ()
 
void LoadCreatureTemplateSpells ()
 
void LoadCreatureCustomIDs ()
 Load config option Creatures.CustomIDs into Store. More...
 
void CheckCreatureTemplate (CreatureTemplate const *cInfo)
 
void CheckCreatureMovement (char const *table, uint64 id, CreatureMovementData &creatureMovement)
 
void LoadGameObjectQuestItems ()
 
void LoadCreatureQuestItems ()
 
void LoadTempSummons ()
 
void LoadCreatures ()
 
void LoadLinkedRespawn ()
 
bool SetCreatureLinkedRespawn (ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid)
 
void LoadCreatureAddons ()
 
void LoadGameObjectAddons ()
 
void LoadCreatureModelInfo ()
 
void LoadEquipmentTemplates ()
 
void LoadCreatureMovementOverrides ()
 
void LoadGameObjectLocales ()
 
void LoadGameobjects ()
 
void LoadItemTemplates ()
 
void LoadItemLocales ()
 
void LoadItemSetNames ()
 
void LoadItemSetNameLocales ()
 
void LoadQuestLocales ()
 
void LoadNpcTextLocales ()
 
void LoadQuestOfferRewardLocale ()
 
void LoadQuestRequestItemsLocale ()
 
void LoadPageTextLocales ()
 
void LoadGossipMenuItemsLocales ()
 
void LoadPointOfInterestLocales ()
 
void LoadQuestGreetingsLocales ()
 
void LoadInstanceTemplate ()
 
void LoadInstanceEncounters ()
 
void LoadMailLevelRewards ()
 
void LoadMailServerTemplates ()
 
void LoadVehicleTemplateAccessories ()
 
void LoadVehicleAccessories ()
 
void LoadGossipText ()
 
void LoadAreaTriggers ()
 
void LoadAreaTriggerTeleports ()
 
void LoadAccessRequirements ()
 
void LoadQuestAreaTriggers ()
 
void LoadQuestGreetings ()
 
void LoadAreaTriggerScripts ()
 
void LoadTavernAreaTriggers ()
 
void LoadGameObjectForQuests ()
 
void LoadPageTexts ()
 
PageText const * GetPageText (uint32 pageEntry)
 
void LoadPlayerInfo ()
 
void LoadPetLevelInfo ()
 
void LoadExplorationBaseXP ()
 
void LoadPetNames ()
 
void LoadPetNamesLocales ()
 
void LoadPetNumber ()
 
void LoadFishingBaseSkillLevel ()
 
void ChangeFishingBaseSkillLevel (uint32 entry, int32 skill)
 
void LoadReputationRewardRate ()
 
void LoadReputationOnKill ()
 
void LoadReputationSpilloverTemplate ()
 
void LoadPointsOfInterest ()
 
void LoadQuestPOI ()
 
void LoadNPCSpellClickSpells ()
 
void LoadGameTele ()
 
void LoadGossipMenu ()
 
void LoadGossipMenuItems ()
 
void LoadVendors ()
 
void LoadTrainerSpell ()
 
void AddSpellToTrainer (uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
 
std::string GeneratePetName (uint32 entry)
 
std::string GeneratePetNameLocale (uint32 entry, LocaleConstant locale)
 
uint32 GetBaseXP (uint8 level)
 
uint32 GetXPForLevel (uint8 level) const
 
int32 GetFishingBaseSkillLevel (uint32 entry) const
 
void ReturnOrDeleteOldMails (bool serverUp)
 
CreatureBaseStats const * GetCreatureBaseStats (uint8 level, uint8 unitClass)
 
void SetHighestGuids ()
 
template<HighGuid type>
ObjectGuidGeneratorBaseGetGenerator ()
 
uint32 GenerateAuctionID ()
 
uint64 GenerateEquipmentSetGuid ()
 
uint32 GenerateMailID ()
 
uint32 GeneratePetNumber ()
 
ObjectGuid::LowType GenerateCreatureSpawnId ()
 
ObjectGuid::LowType GenerateGameObjectSpawnId ()
 
MailLevelReward const * GetMailLevelReward (uint32 level, uint32 raceMask)
 
CellObjectGuids const & GetCellObjectGuids (uint16 mapid, uint8 spawnMode, uint32 cell_id)
 
CellObjectGuidsMap const & GetMapObjectGuids (uint16 mapid, uint8 spawnMode)
 
std::vector< TempSummonData > const * GetSummonGroup (uint32 summonerId, SummonerType summonerType, uint8 group) const
 
ServerMailContainer const & GetAllServerMailStore () const
 
BroadcastText const * GetBroadcastText (uint32 id) const
 
CreatureDataContainer const & GetAllCreatureData () const
 
CreatureData const * GetCreatureData (ObjectGuid::LowType spawnId) const
 
CreatureDataNewOrExistCreatureData (ObjectGuid::LowType spawnId)
 
void DeleteCreatureData (ObjectGuid::LowType spawnId)
 
ObjectGuid GetLinkedRespawnGuid (ObjectGuid guid) const
 
GameObjectDataContainer const & GetAllGOData () const
 
GameObjectData const * GetGameObjectData (ObjectGuid::LowType spawnId) const
 
CreatureLocale const * GetCreatureLocale (uint32 entry) const
 
GameObjectLocale const * GetGameObjectLocale (uint32 entry) const
 
ItemLocale const * GetItemLocale (uint32 entry) const
 
ItemSetNameLocale const * GetItemSetNameLocale (uint32 entry) const
 
PageTextLocale const * GetPageTextLocale (uint32 entry) const
 
QuestLocale const * GetQuestLocale (uint32 entry) const
 
GossipMenuItemsLocale const * GetGossipMenuItemsLocale (uint32 entry) const
 
PointOfInterestLocale const * GetPointOfInterestLocale (uint32 poi_id) const
 
QuestOfferRewardLocale const * GetQuestOfferRewardLocale (uint32 entry) const
 
QuestRequestItemsLocale const * GetQuestRequestItemsLocale (uint32 entry) const
 
NpcTextLocale const * GetNpcTextLocale (uint32 entry) const
 
QuestGreeting const * GetQuestGreeting (TypeID type, uint32 id) const
 
GameObjectDataNewGOData (ObjectGuid::LowType guid)
 
void DeleteGOData (ObjectGuid::LowType guid)
 
ModuleString const * GetModuleString (std::string module, uint32 id) const
 
std::string const * GetModuleString (std::string module, uint32 id, LocaleConstant locale) const
 
AcoreString const * GetAcoreString (uint32 entry) const
 
char const * GetAcoreString (uint32 entry, LocaleConstant locale) const
 
char const * GetAcoreStringForDBCLocale (uint32 entry) const
 
LocaleConstant GetDBCLocaleIndex () const
 
void SetDBCLocaleIndex (LocaleConstant locale)
 
void AddCreatureToGrid (ObjectGuid::LowType guid, CreatureData const *data)
 
void RemoveCreatureFromGrid (ObjectGuid::LowType guid, CreatureData const *data)
 
void AddGameobjectToGrid (ObjectGuid::LowType guid, GameObjectData const *data)
 
void RemoveGameobjectFromGrid (ObjectGuid::LowType guid, GameObjectData const *data)
 
uint32 AddGOData (uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0, float rotation0=0, float rotation1=0, float rotation2=0, float rotation3=0)
 
uint32 AddCreData (uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0)
 
void LoadReservedPlayerNamesDB ()
 
void LoadReservedPlayerNamesDBC ()
 
bool IsReservedName (std::string_view name) const
 
void AddReservedPlayerName (std::string const &name)
 
void LoadProfanityNamesFromDB ()
 
void LoadProfanityNamesFromDBC ()
 
bool IsProfanityName (std::string_view name) const
 
void AddProfanityPlayerName (std::string const &name)
 
GameTele const * GetGameTele (uint32 id) const
 
GameTele const * GetGameTele (std::string_view name) const
 
GameTeleContainer const & GetGameTeleMap () const
 
bool AddGameTele (GameTele &data)
 
bool DeleteGameTele (std::string_view name)
 
TrainerSpellData const * GetNpcTrainerSpells (uint32 entry) const
 
VendorItemData const * GetNpcVendorItemList (uint32 entry) const
 
void AddVendorItem (uint32 entry, uint32 item, int32 maxcount, uint32 incrtime, uint32 extendedCost, bool persist=true)
 
bool RemoveVendorItem (uint32 entry, uint32 item, bool persist=true)
 
bool IsVendorItemValid (uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player *player=nullptr, std::set< uint32 > *skip_vendors=nullptr, uint32 ORnpcflag=0) const
 
void LoadScriptNames ()
 
ScriptNameContainerGetScriptNames ()
 
std::string const & GetScriptName (uint32 id) const
 
uint32 GetScriptId (std::string const &name)
 
SpellClickInfoMapBounds GetSpellClickInfoMapBounds (uint32 creature_id) const
 
GossipMenusMapBounds GetGossipMenusMapBounds (uint32 uiMenuId) const
 
GossipMenusMapBoundsNonConst GetGossipMenusMapBoundsNonConst (uint32 uiMenuId)
 
GossipMenuItemsMapBounds GetGossipMenuItemsMapBounds (uint32 uiMenuId) const
 
GossipMenuItemsMapBoundsNonConst GetGossipMenuItemsMapBoundsNonConst (uint32 uiMenuId)
 
void LoadFactionChangeAchievements ()
 
void LoadFactionChangeItems ()
 
void LoadFactionChangeQuests ()
 
void LoadFactionChangeReputations ()
 
void LoadFactionChangeSpells ()
 
void LoadFactionChangeTitles ()
 
bool IsTransportMap (uint32 mapId) const
 
uint32 GetQuestMoneyReward (uint8 level, uint32 questMoneyDifficulty) const
 
void SendServerMail (Player *player, uint32 id, uint32 reqLevel, uint32 reqPlayTime, uint32 rewardMoneyA, uint32 rewardMoneyH, uint32 rewardItemA, uint32 rewardItemCountA, uint32 rewardItemH, uint32 rewardItemCountH, std::string subject, std::string body, uint8 active) const
 

Static Public Member Functions

static ObjectMgrinstance ()
 
static CreatureModel const * ChooseDisplayId (CreatureTemplate const *cinfo, CreatureData const *data=nullptr)
 
static void ChooseCreatureFlags (CreatureTemplate const *cinfo, uint32 &npcflag, uint32 &unit_flags, uint32 &dynamicflags, CreatureData const *data=nullptr)
 
static uint8 CheckPlayerName (std::string_view name, bool create=false)
 
static PetNameInvalidReason CheckPetName (std::string_view name)
 
static bool IsValidCharterName (std::string_view name)
 
static bool IsValidChannelName (std::string const &name)
 
static bool CheckDeclinedNames (std::wstring w_ownname, DeclinedName const &names)
 
static void AddLocaleString (std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
 
static std::string_view GetLocaleString (std::vector< std::string > const &data, std::size_t locale)
 
static void GetLocaleString (const std::vector< std::string > &data, int loc_idx, std::string &value)
 

Public Attributes

ExclusiveQuestGroups mExclusiveQuestGroups
 
CharacterConversionMap FactionChangeAchievements
 
CharacterConversionMap FactionChangeItems
 
CharacterConversionMap FactionChangeQuests
 
CharacterConversionMap FactionChangeReputation
 
CharacterConversionMap FactionChangeSpells
 
CharacterConversionMap FactionChangeTitles
 

Private Types

enum  CreatureLinkedRespawnType {
  CREATURE_TO_CREATURE ,
  CREATURE_TO_GO ,
  GO_TO_GO ,
  GO_TO_CREATURE
}
 
typedef std::unordered_map< uint32, GossipTextGossipTextContainer
 
typedef std::unordered_map< uint32, uint32QuestAreaTriggerContainer
 
typedef std::unordered_map< uint32, uint32TavernAreaTriggerContainer
 
typedef std::set< std::wstring > ReservedNamesContainer
 
typedef std::set< std::wstring > ProfanityNamesContainer
 
typedef std::map< uint32, PetLevelInfo * > PetLevelInfoContainer
 
typedef std::vector< uint32PlayerXPperLevel
 
typedef std::map< uint32, uint32BaseXPContainer
 
typedef std::map< uint32, int32FishingBaseSkillContainer
 
typedef std::map< uint32, std::vector< std::string > > HalfNameContainer
 
typedef std::map< std::pair< uint32, LocaleConstant >, std::vector< std::string > > HalfNameContainerLocale
 
typedef std::unordered_map< uint32, ItemSetNameEntryItemSetNameContainer
 

Private Member Functions

 ObjectMgr ()
 
 ~ObjectMgr ()
 
template<HighGuid high>
ObjectGuidGeneratorBaseGetGuidSequenceGenerator ()
 
void LoadScripts (ScriptsType type)
 
void LoadQuestRelationsHelper (QuestRelations &map, std::string const &table, bool starter, bool go)
 
void PlayerCreateInfoAddItemHelper (uint32 race_, uint32 class_, uint32 itemId, int32 count)
 
void BuildPlayerLevelInfo (uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
 

Private Attributes

uint32 _auctionId
 
uint64 _equipmentSetGuid
 
uint32 _mailId
 
std::mutex _mailIdMutex
 
uint32 _hiPetNumber
 
std::mutex _hiPetNumberMutex
 
ObjectGuid::LowType _creatureSpawnId
 
ObjectGuid::LowType _gameObjectSpawnId
 
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
 
QuestMap _questTemplates
 
std::vector< Quest * > _questTemplatesFast
 
QuestAreaTriggerContainer _questAreaTriggerStore
 
TavernAreaTriggerContainer _tavernAreaTriggerStore
 
GossipTextContainer _gossipTextStore
 
QuestGreetingContainer _questGreetingStore
 
AreaTriggerContainer _areaTriggerStore
 
AreaTriggerTeleportContainer _areaTriggerTeleportStore
 
AreaTriggerScriptContainer _areaTriggerScriptStore
 
DungeonProgressionRequirementsContainer _accessRequirementStore
 
DungeonEncounterContainer _dungeonEncounterStore
 
RepRewardRateContainer _repRewardRateStore
 
RepOnKillContainer _repOnKillStore
 
RepSpilloverTemplateContainer _repSpilloverTemplateStore
 
GossipMenusContainer _gossipMenusStore
 
GossipMenuItemsContainer _gossipMenuItemsStore
 
PointOfInterestContainer _pointsOfInterestStore
 
QuestPOIContainer _questPOIStore
 
QuestRelations _goQuestRelations
 
QuestRelations _goQuestInvolvedRelations
 
QuestRelations _creatureQuestRelations
 
QuestRelations _creatureQuestInvolvedRelations
 
ReservedNamesContainer _reservedNamesStore
 
ProfanityNamesContainer _profanityNamesStore
 
GameTeleContainer _gameTeleStore
 
ScriptNameContainer _scriptNamesStore
 
SpellClickInfoContainer _spellClickInfoStore
 
SpellScriptsContainer _spellScriptsStore
 
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
 
VehicleAccessoryContainer _vehicleAccessoryStore
 
LocaleConstant DBCLocaleIndex
 
PageTextContainer _pageTextStore
 
InstanceTemplateContainer _instanceTemplateStore
 
MailLevelRewardContainer _mailLevelRewardStore
 
CreatureBaseStatsContainer _creatureBaseStatsStore
 
PetLevelInfoContainer _petInfoStore
 
PlayerClassInfo_playerClassInfo [MAX_CLASSES]
 
PlayerInfo_playerInfo [MAX_RACES][MAX_CLASSES]
 
PlayerXPperLevel _playerXPperLevel
 
BaseXPContainer _baseXPTable
 
FishingBaseSkillContainer _fishingBaseForAreaStore
 
HalfNameContainer _petHalfName0
 
HalfNameContainer _petHalfName1
 
HalfNameContainerLocale _petHalfLocaleName0
 
HalfNameContainerLocale _petHalfLocaleName1
 
ItemSetNameContainer _itemSetNameStore
 
MapObjectGuids _mapObjectGuidsStore
 
CellObjectGuidsMap _emptyCellObjectGuidsMap
 
CellObjectGuids _emptyCellObjectGuids
 
CreatureDataContainer _creatureDataStore
 
CreatureTemplateContainer _creatureTemplateStore
 
CreatureCustomIDsContainer _creatureCustomIDsStore
 
std::vector< CreatureTemplate * > _creatureTemplateStoreFast
 
CreatureModelContainer _creatureModelStore
 
CreatureAddonContainer _creatureAddonStore
 
CreatureAddonContainer _creatureTemplateAddonStore
 
std::unordered_map< ObjectGuid::LowType, CreatureMovementData_creatureMovementOverrides
 
GameObjectAddonContainer _gameObjectAddonStore
 
GameObjectQuestItemMap _gameObjectQuestItemStore
 
CreatureQuestItemMap _creatureQuestItemStore
 
EquipmentInfoContainer _equipmentInfoStore
 
LinkedRespawnContainer _linkedRespawnStore
 
CreatureLocaleContainer _creatureLocaleStore
 
GameObjectDataContainer _gameObjectDataStore
 
GameObjectLocaleContainer _gameObjectLocaleStore
 
GameObjectTemplateContainer _gameObjectTemplateStore
 
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
 
TempSummonDataContainer _tempSummonDataStore
 Stores temp summon data grouped by summoner's entry, summoner's type and group id. More...
 
BroadcastTextContainer _broadcastTextStore
 
ItemTemplateContainer _itemTemplateStore
 
std::vector< ItemTemplate * > _itemTemplateStoreFast
 
ItemLocaleContainer _itemLocaleStore
 
ItemSetNameLocaleContainer _itemSetNameLocaleStore
 
QuestLocaleContainer _questLocaleStore
 
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
 
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
 
NpcTextLocaleContainer _npcTextLocaleStore
 
PageTextLocaleContainer _pageTextLocaleStore
 
ModuleStringContainer _moduleStringStore
 
AcoreStringContainer _acoreStringStore
 
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore
 
PointOfInterestLocaleContainer _pointOfInterestLocaleStore
 
CacheVendorItemContainer _cacheVendorItemStore
 
CacheTrainerSpellContainer _cacheTrainerSpellStore
 
ServerMailContainer _serverMailStore
 
std::set< uint32_difficultyEntries [MAX_DIFFICULTY - 1]
 
std::set< uint32_hasDifficultyEntries [MAX_DIFFICULTY - 1]
 
std::set< uint32_transportMaps
 
QuestMoneyRewardStore _questMoneyRewards
 
std::vector< GameobjectInstanceSavedStateGameobjectInstanceSavedStateList
 

Friends

class PlayerDumpReader
 

Detailed Description

Member Typedef Documentation

◆ AreaTriggerContainer

typedef std::unordered_map<uint32, AreaTrigger> ObjectMgr::AreaTriggerContainer

◆ AreaTriggerScriptContainer

typedef std::unordered_map<uint32, uint32> ObjectMgr::AreaTriggerScriptContainer

◆ AreaTriggerTeleportContainer

◆ BaseXPContainer

typedef std::map<uint32, uint32> ObjectMgr::BaseXPContainer
private

◆ CharacterConversionMap

◆ DungeonProgressionRequirementsContainer

◆ ExclusiveQuestGroups

typedef std::multimap<int32, uint32> ObjectMgr::ExclusiveQuestGroups

◆ ExclusiveQuestGroupsBounds

typedef std::pair<ExclusiveQuestGroups::const_iterator, ExclusiveQuestGroups::const_iterator> ObjectMgr::ExclusiveQuestGroupsBounds

◆ FishingBaseSkillContainer

◆ GossipTextContainer

typedef std::unordered_map<uint32, GossipText> ObjectMgr::GossipTextContainer
private

◆ HalfNameContainer

typedef std::map<uint32, std::vector<std::string> > ObjectMgr::HalfNameContainer
private

◆ HalfNameContainerLocale

typedef std::map<std::pair<uint32, LocaleConstant>, std::vector<std::string> > ObjectMgr::HalfNameContainerLocale
private

◆ ItemMap

typedef std::unordered_map<uint32, Item*> ObjectMgr::ItemMap

◆ ItemSetNameContainer

typedef std::unordered_map<uint32, ItemSetNameEntry> ObjectMgr::ItemSetNameContainer
private

◆ PetLevelInfoContainer

◆ PlayerXPperLevel

typedef std::vector<uint32> ObjectMgr::PlayerXPperLevel
private

◆ PointOfInterestContainer

◆ ProfanityNamesContainer

typedef std::set<std::wstring> ObjectMgr::ProfanityNamesContainer
private

◆ QuestAreaTriggerContainer

typedef std::unordered_map<uint32, uint32> ObjectMgr::QuestAreaTriggerContainer
private

◆ QuestMap

typedef std::unordered_map<uint32, Quest*> ObjectMgr::QuestMap

◆ RepOnKillContainer

◆ RepRewardRateContainer

◆ RepSpilloverTemplateContainer

◆ ReservedNamesContainer

typedef std::set<std::wstring> ObjectMgr::ReservedNamesContainer
private

◆ ScriptNameContainer

typedef std::vector<std::string> ObjectMgr::ScriptNameContainer

◆ TavernAreaTriggerContainer

typedef std::unordered_map<uint32, uint32> ObjectMgr::TavernAreaTriggerContainer
private

Member Enumeration Documentation

◆ CreatureLinkedRespawnType

Enumerator
CREATURE_TO_CREATURE 
CREATURE_TO_GO 
GO_TO_GO 
GO_TO_CREATURE 
1603 {
1605 CREATURE_TO_GO, // Creature is dependant on GO
1606 GO_TO_GO,
1607 GO_TO_CREATURE, // GO is dependant on creature
1608 };
@ CREATURE_TO_GO
Definition: ObjectMgr.h:1605
@ CREATURE_TO_CREATURE
Definition: ObjectMgr.h:1604
@ GO_TO_GO
Definition: ObjectMgr.h:1606
@ GO_TO_CREATURE
Definition: ObjectMgr.h:1607

Constructor & Destructor Documentation

◆ ObjectMgr()

ObjectMgr::ObjectMgr ( )
private
297 :
298 _auctionId(1),
300 _mailId(1),
301 _hiPetNumber(1),
305{
306 for (uint8 i = 0; i < MAX_CLASSES; ++i)
307 {
308 _playerClassInfo[i] = nullptr;
309 for (uint8 j = 0; j < MAX_RACES; ++j)
310 _playerInfo[j][i] = nullptr;
311 }
312}
@ LOCALE_enUS
Definition: Common.h:66
std::uint8_t uint8
Definition: Define.h:109
#define MAX_RACES
Definition: SharedDefines.h:95
#define MAX_CLASSES
Definition: SharedDefines.h:155
PlayerInfo * _playerInfo[MAX_RACES][MAX_CLASSES]
Definition: ObjectMgr.h:1534
ObjectGuid::LowType _gameObjectSpawnId
Definition: ObjectMgr.h:1446
uint32 _mailId
Definition: ObjectMgr.h:1440
ObjectGuid::LowType _creatureSpawnId
Definition: ObjectMgr.h:1445
LocaleConstant DBCLocaleIndex
Definition: ObjectMgr.h:1512
PlayerClassInfo * _playerClassInfo[MAX_CLASSES]
Definition: ObjectMgr.h:1530
uint64 _equipmentSetGuid
Definition: ObjectMgr.h:1439
uint32 _auctionId
Definition: ObjectMgr.h:1438
uint32 _hiPetNumber
Definition: ObjectMgr.h:1442

References _playerClassInfo, _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ ~ObjectMgr()

ObjectMgr::~ObjectMgr ( )
private
315{
316 for (QuestMap::iterator i = _questTemplates.begin(); i != _questTemplates.end(); ++i)
317 delete i->second;
318
319 for (PetLevelInfoContainer::iterator i = _petInfoStore.begin(); i != _petInfoStore.end(); ++i)
320 delete[] i->second;
321
322 // free only if loaded
323 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
324 {
325 if (_playerClassInfo[class_])
326 delete[] _playerClassInfo[class_]->levelInfo;
327 delete _playerClassInfo[class_];
328 }
329
330 for (int race = 0; race < MAX_RACES; ++race)
331 {
332 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
333 {
334 if (_playerInfo[race][class_])
335 delete[] _playerInfo[race][class_]->levelInfo;
336 delete _playerInfo[race][class_];
337 }
338 }
339
340 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
341 itr->second.Clear();
342
344
345 for (DungeonEncounterContainer::iterator itr = _dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr)
346 for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr)
347 delete *encounterItr;
348
349 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
350 {
351 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
352 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
353 {
354 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
355 {
356 delete* questItr;
357 }
358
359 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
360 {
361 delete* achievementItr;
362 }
363
364 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
365 {
366 delete* itemsItr;
367 }
368
369 delete difficultiesItr->second;
370 }
371 }
372}
PlayerClassLevelInfo * levelInfo
Definition: Player.h:299
PlayerLevelInfo * levelInfo
Definition: Player.h:353
CacheTrainerSpellContainer _cacheTrainerSpellStore
Definition: ObjectMgr.h:1595
PetLevelInfoContainer _petInfoStore
Definition: ObjectMgr.h:1528
QuestMap _questTemplates
Definition: ObjectMgr.h:1461
DungeonProgressionRequirementsContainer _accessRequirementStore
Definition: ObjectMgr.h:1475
DungeonEncounterContainer _dungeonEncounterStore
Definition: ObjectMgr.h:1476
CacheVendorItemContainer _cacheVendorItemStore
Definition: ObjectMgr.h:1594

References _accessRequirementStore, _cacheTrainerSpellStore, _cacheVendorItemStore, _dungeonEncounterStore, _petInfoStore, _playerClassInfo, _playerInfo, _questTemplates, PlayerClassInfo::levelInfo, PlayerInfo::levelInfo, MAX_CLASSES, and MAX_RACES.

Member Function Documentation

◆ AddCreatureToGrid()

void ObjectMgr::AddCreatureToGrid ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)
2300{
2301 uint8 mask = data->spawnMask;
2302 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2303 {
2304 if (mask & 1)
2305 {
2306 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2307 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2308 cell_guids.creatures.insert(guid);
2309 }
2310 }
2311}
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition: ObjectDefines.h:87
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:191
Definition: ObjectMgr.h:479
CellGuidSet creatures
Definition: ObjectMgr.h:480
MapObjectGuids _mapObjectGuidsStore
Definition: ObjectMgr.h:1555
uint32 GetId() const
Definition: GridDefines.h:148

References _mapObjectGuidsStore, Acore::ComputeCellCoord(), CellObjectGuids::creatures, CoordPair< LIMIT >::GetId(), MAKE_PAIR32(), CreatureData::mapid, CreatureData::posX, CreatureData::posY, and CreatureData::spawnMask.

Referenced by AddCreData(), and LoadCreatures().

◆ AddCreData()

uint32 ObjectMgr::AddCreData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0 
)
2379{
2380 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2381 if (!cInfo)
2382 return 0;
2383
2384 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2385 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2386 Map* map = sMapMgr->CreateBaseMap(mapId);
2387 if (!map)
2388 return 0;
2389
2391 CreatureData& data = NewOrExistCreatureData(spawnId);
2392 data.spawnMask = spawnId;
2393 data.id1 = entry;
2394 data.id2 = 0;
2395 data.id3 = 0;
2396 data.mapid = mapId;
2397 data.displayid = 0;
2398 data.equipmentId = 0;
2399 data.posX = x;
2400 data.posY = y;
2401 data.posZ = z;
2402 data.orientation = o;
2403 data.spawntimesecs = spawntimedelay;
2404 data.wander_distance = 0;
2405 data.currentwaypoint = 0;
2406 data.curhealth = stats->GenerateHealth(cInfo);
2407 data.curmana = stats->GenerateMana(cInfo);
2408 data.movementType = cInfo->MovementType;
2409 data.spawnMask = 1;
2411 data.dbData = false;
2412 data.npcflag = cInfo->npcflag;
2413 data.unit_flags = cInfo->unit_flags;
2414 data.dynamicflags = cInfo->dynamicflags;
2415
2416 AddCreatureToGrid(spawnId, &data);
2417
2418 // Spawn if necessary (loaded grids only)
2419 if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
2420 {
2421 Creature* creature = new Creature();
2422 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
2423 {
2424 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2425 delete creature;
2426 return 0;
2427 }
2428 }
2429
2430 return spawnId;
2431}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
std::uint32_t uint32
Definition: Define.h:107
#define sMapMgr
Definition: MapMgr.h:221
@ PHASEMASK_NORMAL
Definition: Object.h:59
Definition: Creature.h:46
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition: Creature.cpp:1687
Definition: CreatureData.h:189
uint32 unit_flags
Definition: CreatureData.h:217
uint8 minlevel
Definition: CreatureData.h:198
uint8 maxlevel
Definition: CreatureData.h:199
uint32 MovementType
Definition: CreatureData.h:237
uint32 npcflag
Definition: CreatureData.h:202
uint32 unit_class
Definition: CreatureData.h:216
uint32 dynamicflags
Definition: CreatureData.h:219
Definition: CreatureData.h:306
uint32 GenerateMana(CreatureTemplate const *info) const
Definition: CreatureData.h:321
uint32 GenerateHealth(CreatureTemplate const *info) const
Definition: CreatureData.h:316
Definition: CreatureData.h:373
float wander_distance
Definition: CreatureData.h:387
uint32 phaseMask
Definition: CreatureData.h:379
uint32 spawntimesecs
Definition: CreatureData.h:386
uint32 dynamicflags
Definition: CreatureData.h:395
uint32 npcflag
Definition: CreatureData.h:393
bool dbData
Definition: CreatureData.h:397
uint32 displayid
Definition: CreatureData.h:380
uint8 movementType
Definition: CreatureData.h:391
uint8 spawnMask
Definition: CreatureData.h:392
uint32 unit_flags
Definition: CreatureData.h:394
uint32 id2
Definition: CreatureData.h:376
uint32 curhealth
Definition: CreatureData.h:389
float orientation
Definition: CreatureData.h:385
uint32 curmana
Definition: CreatureData.h:390
uint32 id3
Definition: CreatureData.h:377
float posY
Definition: CreatureData.h:383
float posX
Definition: CreatureData.h:382
int8 equipmentId
Definition: CreatureData.h:381
uint32 currentwaypoint
Definition: CreatureData.h:388
uint16 mapid
Definition: CreatureData.h:378
float posZ
Definition: CreatureData.h:384
uint32 id1
Definition: CreatureData.h:375
uint32 LowType
Definition: ObjectGuid.h:122
CreatureBaseStats const * GetCreatureBaseStats(uint8 level, uint8 unitClass)
Definition: ObjectMgr.cpp:9682
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition: ObjectMgr.cpp:2299
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition: ObjectMgr.cpp:6997
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition: ObjectMgr.h:1202
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition: ObjectMgr.cpp:10030
Definition: Map.h:313
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:363
bool Instanceable() const
Definition: Map.h:447

References AddCreatureToGrid(), CreatureData::curhealth, CreatureData::curmana, CreatureData::currentwaypoint, CreatureData::dbData, CreatureData::displayid, CreatureTemplate::dynamicflags, CreatureData::dynamicflags, CreatureData::equipmentId, GenerateCreatureSpawnId(), CreatureBaseStats::GenerateHealth(), CreatureBaseStats::GenerateMana(), GetCreatureBaseStats(), GetCreatureTemplate(), CreatureData::id1, CreatureData::id2, CreatureData::id3, Map::Instanceable(), Map::IsRemovalGrid(), Creature::LoadCreatureFromDB(), LOG_ERROR, CreatureData::mapid, CreatureTemplate::maxlevel, CreatureTemplate::minlevel, CreatureTemplate::MovementType, CreatureData::movementType, NewOrExistCreatureData(), CreatureTemplate::npcflag, CreatureData::npcflag, CreatureData::orientation, CreatureData::phaseMask, PHASEMASK_NORMAL, CreatureData::posX, CreatureData::posY, CreatureData::posZ, sMapMgr, CreatureData::spawnMask, CreatureData::spawntimesecs, CreatureTemplate::unit_class, CreatureTemplate::unit_flags, CreatureData::unit_flags, urand(), and CreatureData::wander_distance.

◆ AddGameobjectInfo()

void ObjectMgr::AddGameobjectInfo ( GameObjectTemplate goinfo)

◆ AddGameobjectToGrid()

void ObjectMgr::AddGameobjectToGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2603{
2604 uint8 mask = data->spawnMask;
2605 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2606 {
2607 if (mask & 1)
2608 {
2609 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2610 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2611 cell_guids.gameobjects.insert(guid);
2612 }
2613 }
2614}
CellGuidSet gameobjects
Definition: ObjectMgr.h:481

References _mapObjectGuidsStore, Acore::ComputeCellCoord(), CellObjectGuids::gameobjects, CoordPair< LIMIT >::GetId(), MAKE_PAIR32(), GameObjectData::mapid, GameObjectData::posX, GameObjectData::posY, and GameObjectData::spawnMask.

Referenced by AddGOData(), and LoadGameobjects().

◆ AddGameTele()

bool ObjectMgr::AddGameTele ( GameTele data)
8914{
8915 // find max id
8916 uint32 new_id = 0;
8917 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8918 if (itr->first > new_id)
8919 new_id = itr->first;
8920
8921 // use next
8922 ++new_id;
8923
8924 if (!Utf8toWStr(tele.name, tele.wnameLow))
8925 return false;
8926
8927 wstrToLower(tele.wnameLow);
8928
8929 _gameTeleStore[new_id] = tele;
8930
8932
8933 stmt->SetData(0, new_id);
8934 stmt->SetData(1, tele.position_x);
8935 stmt->SetData(2, tele.position_y);
8936 stmt->SetData(3, tele.position_z);
8937 stmt->SetData(4, tele.orientation);
8938 stmt->SetData(5, uint16(tele.mapId));
8939 stmt->SetData(6, tele.name);
8940
8941 WorldDatabase.Execute(stmt);
8942
8943 return true;
8944}
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.cpp:382
std::uint16_t uint16
Definition: Define.h:108
@ WORLD_INS_GAME_TELE
Definition: WorldDatabase.h:41
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
GameTeleContainer _gameTeleStore
Definition: ObjectMgr.h:1501

References _gameTeleStore, GameTele::mapId, GameTele::name, GameTele::orientation, GameTele::position_x, GameTele::position_y, GameTele::position_z, PreparedStatementBase::SetData(), Utf8toWStr(), GameTele::wnameLow, WORLD_INS_GAME_TELE, WorldDatabase, and wstrToLower().

◆ AddGOData()

uint32 ObjectMgr::AddGOData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0,
float  rotation0 = 0,
float  rotation1 = 0,
float  rotation2 = 0,
float  rotation3 = 0 
)
2328{
2329 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2330 if (!goinfo)
2331 return 0;
2332
2333 Map* map = sMapMgr->CreateBaseMap(mapId);
2334 if (!map)
2335 return 0;
2336
2338
2339 GameObjectData& data = NewGOData(spawnId);
2340 data.id = entry;
2341 data.mapid = mapId;
2342 data.posX = x;
2343 data.posY = y;
2344 data.posZ = z;
2345 data.orientation = o;
2346 data.rotation.x = rotation0;
2347 data.rotation.y = rotation1;
2348 data.rotation.z = rotation2;
2349 data.rotation.w = rotation3;
2350 data.spawntimesecs = spawntimedelay;
2351 data.animprogress = 100;
2352 data.spawnMask = 1;
2353 data.go_state = GO_STATE_READY;
2355 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2356 data.dbData = false;
2357
2358 AddGameobjectToGrid(spawnId, &data);
2359
2360 // Spawn if necessary (loaded grids only)
2361 // We use spawn coords to spawn
2362 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2363 {
2364 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(data.id) ? new StaticTransport() : new GameObject();
2365 if (!go->LoadGameObjectFromDB(spawnId, map))
2366 {
2367 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2368 delete go;
2369 return 0;
2370 }
2371 }
2372
2373 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2374
2375 return spawnId;
2376}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ GO_STATE_READY
Definition: GameObjectData.h:691
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition: SharedDefines.h:1589
Definition: GameObject.h:121
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition: GameObject.cpp:1123
Definition: GameObjectData.h:32
uint32 type
Definition: GameObjectData.h:34
Definition: GameObjectData.h:697
bool dbData
Definition: GameObjectData.h:713
float orientation
Definition: GameObjectData.h:705
float posZ
Definition: GameObjectData.h:704
uint8 artKit
Definition: GameObjectData.h:712
int32 spawntimesecs
Definition: GameObjectData.h:707
uint8 spawnMask
Definition: GameObjectData.h:711
G3D::Quat rotation
Definition: GameObjectData.h:706
uint32 animprogress
Definition: GameObjectData.h:709
uint16 mapid
Definition: GameObjectData.h:700
float posX
Definition: GameObjectData.h:702
uint32 phaseMask
Definition: GameObjectData.h:701
float posY
Definition: GameObjectData.h:703
uint32 id
Definition: GameObjectData.h:699
GOState go_state
Definition: GameObjectData.h:710
Definition: Transport.h:112
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition: ObjectMgr.cpp:2602
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition: ObjectMgr.cpp:10006
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition: ObjectMgr.cpp:7007
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition: ObjectMgr.h:1287
bool IsGridLoaded(float x, float y) const
Definition: Map.h:369

References AddGameobjectToGrid(), GameObjectData::animprogress, GameObjectData::artKit, GameObjectData::dbData, GAMEOBJECT_TYPE_CAPTURE_POINT, GenerateGameObjectSpawnId(), GetGameObjectTemplate(), GameObjectData::go_state, GO_STATE_READY, GameObjectData::id, Map::Instanceable(), Map::IsGridLoaded(), GameObject::LoadGameObjectFromDB(), LOG_DEBUG, LOG_ERROR, GameObjectData::mapid, NewGOData(), GameObjectData::orientation, GameObjectData::phaseMask, PHASEMASK_NORMAL, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, GameObjectData::rotation, sMapMgr, sObjectMgr, GameObjectData::spawnMask, GameObjectData::spawntimesecs, and GameObjectTemplate::type.

◆ AddLocaleString()

◆ AddProfanityPlayerName()

void ObjectMgr::AddProfanityPlayerName ( std::string const &  name)
8282{
8283 if (!IsProfanityName(name))
8284 {
8285 std::wstring wstr;
8286 if (!Utf8toWStr(name, wstr))
8287 {
8288 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
8289 return;
8290 }
8291 wstrToLower(wstr);
8292
8293 _profanityNamesStore.insert(wstr);
8294
8296 stmt->SetData(0, name);
8297 CharacterDatabase.Execute(stmt);
8298 }
8299}
@ CHAR_INS_PROFANITY_PLAYER_NAME
Definition: CharacterDatabase.h:518
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
ProfanityNamesContainer _profanityNamesStore
Definition: ObjectMgr.h:1499
bool IsProfanityName(std::string_view name) const
Definition: ObjectMgr.cpp:8266

References _profanityNamesStore, CHAR_INS_PROFANITY_PLAYER_NAME, CharacterDatabase, IsProfanityName(), LOG_ERROR, PreparedStatementBase::SetData(), Utf8toWStr(), and wstrToLower().

◆ AddReservedPlayerName()

void ObjectMgr::AddReservedPlayerName ( std::string const &  name)
8179{
8180 if (!IsReservedName(name))
8181 {
8182 std::wstring wstr;
8183 if (!Utf8toWStr(name, wstr))
8184 {
8185 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
8186 return;
8187 }
8188 wstrToLower(wstr);
8189
8190 _reservedNamesStore.insert(wstr);
8191
8193 stmt->SetData(0, name);
8194 CharacterDatabase.Execute(stmt);
8195 }
8196}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition: CharacterDatabase.h:517
bool IsReservedName(std::string_view name) const
Definition: ObjectMgr.cpp:8163
ReservedNamesContainer _reservedNamesStore
Definition: ObjectMgr.h:1495

References _reservedNamesStore, CHAR_INS_RESERVED_PLAYER_NAME, CharacterDatabase, IsReservedName(), LOG_ERROR, PreparedStatementBase::SetData(), Utf8toWStr(), and wstrToLower().

◆ AddSpellToTrainer()

void ObjectMgr::AddSpellToTrainer ( uint32  entry,
uint32  spell,
uint32  spellCost,
uint32  reqSkill,
uint32  reqSkillValue,
uint32  reqLevel,
uint32  reqSpell 
)
9035{
9036 if (entry >= ACORE_TRAINER_START_REF)
9037 return;
9038
9039 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
9040 if (!cInfo)
9041 {
9042 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a non-existing creature template (Entry: {}), ignoring", entry);
9043 return;
9044 }
9045
9046 if (!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
9047 {
9048 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a creature template (Entry: {}) without trainer flag, ignoring", entry);
9049 return;
9050 }
9051
9052 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spell);
9053 if (!spellinfo)
9054 {
9055 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}), ignoring", entry, spell);
9056 return;
9057 }
9058
9059 if (!SpellMgr::ComputeIsSpellValid(spellinfo))
9060 {
9061 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a broken spell (Spell: {}), ignoring", entry, spell);
9062 return;
9063 }
9064
9065 if (GetTalentSpellCost(spell))
9066 {
9067 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}) which is a talent, ignoring", entry, spell);
9068 return;
9069 }
9070
9071 if (reqSpell && !sSpellMgr->GetSpellInfo(reqSpell))
9072 {
9073 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing reqSpell (Spell: {}), ignoring", entry, reqSpell);
9074 return;
9075 }
9076
9078
9079 TrainerSpell& trainerSpell = data.spellList[spell];
9080 trainerSpell.spell = spell;
9081 trainerSpell.spellCost = spellCost;
9082 trainerSpell.reqSkill = reqSkill;
9083 trainerSpell.reqSkillValue = reqSkillValue;
9084 trainerSpell.reqLevel = reqLevel;
9085 trainerSpell.reqSpell = reqSpell;
9086
9087 if (!trainerSpell.reqLevel)
9088 trainerSpell.reqLevel = spellinfo->SpellLevel;
9089
9090 // calculate learned spell for profession case when stored cast-spell
9091 trainerSpell.learnedSpell[0] = spell;
9092 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
9093 {
9094 if (spellinfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
9095 continue;
9096 if (trainerSpell.learnedSpell[0] == spell)
9097 trainerSpell.learnedSpell[0] = 0;
9098 // player must be able to cast spell on himself
9099 if (spellinfo->Effects[i].TargetA.GetTarget() != 0 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ALLY
9100 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_CASTER)
9101 {
9102 LOG_ERROR("sql.sql", "Table `npc_trainer` has spell {} for trainer entry {} with learn effect which has incorrect target type, ignoring learn effect!", spell, entry);
9103 continue;
9104 }
9105
9106 trainerSpell.learnedSpell[i] = spellinfo->Effects[i].TriggerSpell;
9107
9108 if (trainerSpell.learnedSpell[i])
9109 {
9110 SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.learnedSpell[i]);
9111 if (learnedSpellInfo && learnedSpellInfo->IsProfession())
9112 data.trainerType = 2;
9113 }
9114 }
9115
9116 return;
9117}
#define ACORE_TRAINER_START_REF
Definition: ObjectMgr.h:494
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:686
@ UNIT_NPC_FLAG_TRAINER
Definition: UnitDefines.h:298
#define sSpellMgr
Definition: SpellMgr.h:825
@ SPELL_EFFECT_LEARN_SPELL
Definition: SharedDefines.h:814
@ TARGET_UNIT_TARGET_ALLY
Definition: SharedDefines.h:1425
@ TARGET_UNIT_TARGET_ANY
Definition: SharedDefines.h:1429
@ TARGET_UNIT_CASTER
Definition: SharedDefines.h:1410
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1637
Definition: CreatureData.h:510
uint32 reqSkillValue
Definition: CreatureData.h:520
uint32 learnedSpell[3]
Definition: CreatureData.h:522
uint32 reqSpell
Definition: CreatureData.h:523
uint32 spellCost
Definition: CreatureData.h:518
uint32 reqSkill
Definition: CreatureData.h:519
uint32 reqLevel
Definition: CreatureData.h:521
uint32 spell
Definition: CreatureData.h:517
Definition: CreatureData.h:532
TrainerSpellMap spellList
Definition: CreatureData.h:536
uint32 trainerType
Definition: CreatureData.h:537
Definition: SpellInfo.h:316
uint32 SpellLevel
Definition: SpellInfo.h:360
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393
bool IsProfession() const
Definition: SpellInfo.cpp:952
static bool ComputeIsSpellValid(SpellInfo const *spellInfo, bool msg=true)
Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book,...
Definition: SpellMgr.cpp:371

References _cacheTrainerSpellStore, ACORE_TRAINER_START_REF, SpellMgr::ComputeIsSpellValid(), SpellInfo::Effects, GetCreatureTemplate(), GetTalentSpellCost(), SpellInfo::IsProfession(), TrainerSpell::learnedSpell, LOG_ERROR, MAX_SPELL_EFFECTS, CreatureTemplate::npcflag, TrainerSpell::reqLevel, TrainerSpell::reqSkill, TrainerSpell::reqSkillValue, TrainerSpell::reqSpell, TrainerSpell::spell, SPELL_EFFECT_LEARN_SPELL, TrainerSpell::spellCost, SpellInfo::SpellLevel, TrainerSpellData::spellList, sSpellMgr, TARGET_UNIT_CASTER, TARGET_UNIT_TARGET_ALLY, TARGET_UNIT_TARGET_ANY, TrainerSpellData::trainerType, and UNIT_NPC_FLAG_TRAINER.

Referenced by LoadTrainerSpell().

◆ AddVendorItem()

void ObjectMgr::AddVendorItem ( uint32  entry,
uint32  item,
int32  maxcount,
uint32  incrtime,
uint32  extendedCost,
bool  persist = true 
)
9360{
9361 VendorItemData& vList = _cacheVendorItemStore[entry];
9362 vList.AddItem(item, maxcount, incrtime, extendedCost);
9363
9364 if (persist)
9365 {
9367
9368 stmt->SetData(0, entry);
9369 stmt->SetData(1, item);
9370 stmt->SetData(2, maxcount);
9371 stmt->SetData(3, incrtime);
9372 stmt->SetData(4, extendedCost);
9373
9374 WorldDatabase.Execute(stmt);
9375 }
9376}
@ WORLD_INS_NPC_VENDOR
Definition: WorldDatabase.h:43
Definition: CreatureData.h:472
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition: CreatureData.h:484

References _cacheVendorItemStore, VendorItemData::AddItem(), PreparedStatementBase::SetData(), WORLD_INS_NPC_VENDOR, and WorldDatabase.

◆ BuildPlayerLevelInfo()

void ObjectMgr::BuildPlayerLevelInfo ( uint8  race,
uint8  class_,
uint8  level,
PlayerLevelInfo plinfo 
) const
private
4275{
4276 // base data (last known level)
4277 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
4278
4279 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
4280 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
4281 {
4282 switch (_class)
4283 {
4284 case CLASS_WARRIOR:
4285 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4286 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4287 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4288 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4289 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4290 break;
4291 case CLASS_PALADIN:
4292 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
4293 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4294 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
4295 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
4296 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
4297 break;
4298 case CLASS_HUNTER:
4299 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
4300 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4301 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4302 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
4303 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4304 break;
4305 case CLASS_ROGUE:
4306 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
4307 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4308 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
4309 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
4310 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4311 break;
4312 case CLASS_PRIEST:
4313 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4314 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4315 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4316 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
4317 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
4318 break;
4319 case CLASS_SHAMAN:
4320 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4321 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4322 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
4323 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
4324 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
4325 break;
4326 case CLASS_MAGE:
4327 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4328 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4329 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4330 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
4331 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4332 break;
4333 case CLASS_WARLOCK:
4334 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4335 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4336 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4337 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4338 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4339 break;
4340 case CLASS_DRUID:
4341 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4342 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
4343 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4344 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
4345 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
4346 }
4347 }
4348}
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:240
@ CLASS_HUNTER
Definition: SharedDefines.h:143
@ CLASS_DRUID
Definition: SharedDefines.h:151
@ CLASS_SHAMAN
Definition: SharedDefines.h:147
@ CLASS_PRIEST
Definition: SharedDefines.h:145
@ CLASS_WARRIOR
Definition: SharedDefines.h:141
@ CLASS_WARLOCK
Definition: SharedDefines.h:149
@ CLASS_MAGE
Definition: SharedDefines.h:148
@ CLASS_PALADIN
Definition: SharedDefines.h:142
@ CLASS_ROGUE
Definition: SharedDefines.h:144
@ STAT_SPIRIT
Definition: SharedDefines.h:262
@ STAT_INTELLECT
Definition: SharedDefines.h:261
@ STAT_AGILITY
Definition: SharedDefines.h:259
@ STAT_STRENGTH
Definition: SharedDefines.h:258
@ STAT_STAMINA
Definition: SharedDefines.h:260
#define sWorld
Definition: World.h:444

References _playerInfo, CLASS_DRUID, CLASS_HUNTER, CLASS_MAGE, CLASS_PALADIN, CLASS_PRIEST, CLASS_ROGUE, CLASS_SHAMAN, CLASS_WARLOCK, CLASS_WARRIOR, CONFIG_MAX_PLAYER_LEVEL, PlayerInfo::levelInfo, STAT_AGILITY, STAT_INTELLECT, STAT_SPIRIT, STAT_STAMINA, STAT_STRENGTH, PlayerLevelInfo::stats, and sWorld.

Referenced by GetPlayerLevelInfo().

◆ ChangeFishingBaseSkillLevel()

void ObjectMgr::ChangeFishingBaseSkillLevel ( uint32  entry,
int32  skill 
)
8733{
8734 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8735 if (!fArea)
8736 {
8737 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8738 return;
8739 }
8740
8741 _fishingBaseForAreaStore[entry] = skill;
8742
8743 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
8744 LOG_INFO("server.loading", " ");
8745}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
FishingBaseSkillContainer _fishingBaseForAreaStore
Definition: ObjectMgr.h:1543
Definition: DBCStructure.h:519

References _fishingBaseForAreaStore, LOG_ERROR, LOG_INFO, and sAreaTableStore.

◆ CheckCreatureMovement()

void ObjectMgr::CheckCreatureMovement ( char const *  table,
uint64  id,
CreatureMovementData creatureMovement 
)
1244{
1245 if (creatureMovement.Ground >= CreatureGroundMovementType::Max)
1246 {
1247 LOG_ERROR("sql.sql", "`{}`.`Ground` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Ground), id);
1248 creatureMovement.Ground = CreatureGroundMovementType::Run;
1249 }
1250
1251 if (creatureMovement.Flight >= CreatureFlightMovementType::Max)
1252 {
1253 LOG_ERROR("sql.sql", "`{}`.`Flight` wrong value ({}) for Id {}, setting to None.", table, uint32(creatureMovement.Flight), id);
1254 creatureMovement.Flight = CreatureFlightMovementType::None;
1255 }
1256
1257 if (creatureMovement.Chase >= CreatureChaseMovementType::Max)
1258 {
1259 LOG_ERROR("sql.sql", "`{}`.`Chase` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Chase), id);
1260 creatureMovement.Chase = CreatureChaseMovementType::Run;
1261 }
1262
1263 if (creatureMovement.Random >= CreatureRandomMovementType::Max)
1264 {
1265 LOG_ERROR("sql.sql", "`{}`.`Random` wrong value ({}) for Id {}, setting to Walk.", table, uint32(creatureMovement.Random), id);
1266 creatureMovement.Random = CreatureRandomMovementType::Walk;
1267 }
1268}
CreatureRandomMovementType Random
Definition: CreatureData.h:130
CreatureFlightMovementType Flight
Definition: CreatureData.h:126
CreatureChaseMovementType Chase
Definition: CreatureData.h:129
CreatureGroundMovementType Ground
Definition: CreatureData.h:125

References CreatureMovementData::Chase, CreatureMovementData::Flight, CreatureMovementData::Ground, LOG_ERROR, and CreatureMovementData::Random.

Referenced by CheckCreatureTemplate(), and LoadCreatureMovementOverrides().

◆ CheckCreatureTemplate()

void ObjectMgr::CheckCreatureTemplate ( CreatureTemplate const *  cInfo)
960{
961 if (!cInfo)
962 return;
963
964 bool ok = true; // bool to allow continue outside this loop
965 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
966 {
967 if (!cInfo->DifficultyEntry[diff])
968 continue;
969 ok = false; // will be set to true at the end of this loop again
970
971 CreatureTemplate const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
972 if (!difficultyInfo)
973 {
974 LOG_ERROR("sql.sql", "Creature (Entry: {}) has `difficulty_entry_{}`={} but creature entry {} does not exist.",
975 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]);
976 continue;
977 }
978
979 bool ok2 = true;
980 for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2)
981 {
982 ok2 = false;
983 if (_difficultyEntries[diff2].find(cInfo->Entry) != _difficultyEntries[diff2].end())
984 {
985 LOG_ERROR("sql.sql", "Creature (Entry: {}) is listed as `difficulty_entry_{}` of another creature, but itself lists {} in `difficulty_entry_{}`.",
986 cInfo->Entry, diff2 + 1, cInfo->DifficultyEntry[diff], diff + 1);
987 continue;
988 }
989
990 if (_difficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != _difficultyEntries[diff2].end())
991 {
992 LOG_ERROR("sql.sql", "Creature (Entry: {}) already listed as `difficulty_entry_{}` for another entry.", cInfo->DifficultyEntry[diff], diff2 + 1);
993 continue;
994 }
995
996 if (_hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != _hasDifficultyEntries[diff2].end())
997 {
998 LOG_ERROR("sql.sql", "Creature (Entry: {}) has `difficulty_entry_{}`={} but creature entry {} has itself a value in `difficulty_entry_{}`.",
999 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1);
1000 continue;
1001 }
1002 ok2 = true;
1003 }
1004 if (!ok2)
1005 continue;
1006
1007 if (cInfo->expansion > difficultyInfo->expansion)
1008 {
1009 LOG_ERROR("sql.sql", "Creature (Entry: {}, expansion {}) has different `expansion` in difficulty {} mode (Entry: {}, expansion {}).",
1010 cInfo->Entry, cInfo->expansion, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->expansion);
1011 }
1012
1013 if (cInfo->faction != difficultyInfo->faction)
1014 {
1015 LOG_ERROR("sql.sql", "Creature (Entry: {}, faction {}) has different `faction` in difficulty {} mode (Entry: {}, faction {}).",
1016 cInfo->Entry, cInfo->faction, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->faction);
1017 }
1018
1019 if (cInfo->unit_class != difficultyInfo->unit_class)
1020 {
1021 LOG_ERROR("sql.sql", "Creature (Entry: {}, class {}) has different `unit_class` in difficulty {} mode (Entry: {}, class {}).",
1022 cInfo->Entry, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class);
1023 continue;
1024 }
1025
1026 if (cInfo->npcflag != difficultyInfo->npcflag)
1027 {
1028 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `npcflag` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1029 continue;
1030 }
1031
1032 if (cInfo->family != difficultyInfo->family)
1033 {
1034 LOG_ERROR("sql.sql", "Creature (Entry: {}, family {}) has different `family` in difficulty {} mode (Entry: {}, family {}).",
1035 cInfo->Entry, cInfo->family, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->family);
1036 }
1037
1038 if (cInfo->trainer_class != difficultyInfo->trainer_class)
1039 {
1040 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_class` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1041 continue;
1042 }
1043
1044 if (cInfo->trainer_race != difficultyInfo->trainer_race)
1045 {
1046 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_race` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1047 continue;
1048 }
1049
1050 if (cInfo->trainer_type != difficultyInfo->trainer_type)
1051 {
1052 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_type` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1053 continue;
1054 }
1055
1056 if (cInfo->trainer_spell != difficultyInfo->trainer_spell)
1057 {
1058 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_spell` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1059 continue;
1060 }
1061
1062 if (cInfo->type != difficultyInfo->type)
1063 {
1064 LOG_ERROR("sql.sql", "Creature (Entry: {}, type {}) has different `type` in difficulty {} mode (Entry: {}, type {}).",
1065 cInfo->Entry, cInfo->type, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->type);
1066 }
1067
1068 if (!cInfo->VehicleId && difficultyInfo->VehicleId)
1069 {
1070 LOG_ERROR("sql.sql", "Creature (Entry: {}, VehicleId {}) has different `VehicleId` in difficulty {} mode (Entry: {}, VehicleId {}).",
1071 cInfo->Entry, cInfo->VehicleId, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->VehicleId);
1072 }
1073
1074 // Xinef: check dmg school
1075 if (cInfo->dmgschool != difficultyInfo->dmgschool)
1076 {
1077 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `dmgschool` in difficulty {} mode (Entry: {})", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1078 }
1079
1080 if (!difficultyInfo->AIName.empty())
1081 {
1082 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists difficulty {} mode entry {} with `AIName` filled in. `AIName` of difficulty 0 mode creature is always used instead.",
1083 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1084 continue;
1085 }
1086
1087 if (difficultyInfo->ScriptID)
1088 {
1089 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists difficulty {} mode entry {} with `ScriptName` filled in. `ScriptName` of difficulty 0 mode creature is always used instead.",
1090 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1091 continue;
1092 }
1093
1094 _hasDifficultyEntries[diff].insert(cInfo->Entry);
1095 _difficultyEntries[diff].insert(cInfo->DifficultyEntry[diff]);
1096 ok = true;
1097 }
1098
1099 if (!cInfo->AIName.empty() && !sCreatureAIRegistry->HasItem(cInfo->AIName))
1100 {
1101 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-registered `AIName` '{}' set, removing", cInfo->Entry, cInfo->AIName);
1102 const_cast<CreatureTemplate*>(cInfo)->AIName.clear();
1103 }
1104
1105 FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction);
1106 if (!factionTemplate)
1107 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing faction template ({}).", cInfo->Entry, cInfo->faction);
1108
1109 for (int k = 0; k < MAX_KILL_CREDIT; ++k)
1110 {
1111 if (cInfo->KillCredit[k])
1112 {
1113 if (!GetCreatureTemplate(cInfo->KillCredit[k]))
1114 {
1115 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing creature entry {} in `KillCredit{}`.", cInfo->Entry, cInfo->KillCredit[k], k + 1);
1116 const_cast<CreatureTemplate*>(cInfo)->KillCredit[k] = 0;
1117 }
1118 }
1119 }
1120
1121 if (!cInfo->Models.size())
1122 LOG_ERROR("sql.sql", "Creature (Entry: {}) does not have any existing display id in creature_template_model.", cInfo->Entry);
1123 else if (std::accumulate(cInfo->Models.begin(), cInfo->Models.end(), 0.0f, [](float sum, CreatureModel const& model) { return sum + model.Probability; }) <= 0.0f)
1124 LOG_ERROR("sql.sql", "Creature (Entry: {}) has zero total chance for all models in creature_template_model.", cInfo->Entry);
1125
1126 if (!cInfo->unit_class || ((1 << (cInfo->unit_class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
1127 {
1128 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid unit_class ({}) in creature_template. Set to 1 (UNIT_CLASS_WARRIOR).", cInfo->Entry, cInfo->unit_class);
1129 const_cast<CreatureTemplate*>(cInfo)->unit_class = UNIT_CLASS_WARRIOR;
1130 }
1131
1132 if (cInfo->dmgschool >= MAX_SPELL_SCHOOL)
1133 {
1134 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid spell school value ({}) in `dmgschool`.", cInfo->Entry, cInfo->dmgschool);
1135 const_cast<CreatureTemplate*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL;
1136 }
1137
1138 if (cInfo->BaseAttackTime == 0)
1139 const_cast<CreatureTemplate*>(cInfo)->BaseAttackTime = BASE_ATTACK_TIME;
1140
1141 if (cInfo->RangeAttackTime == 0)
1142 const_cast<CreatureTemplate*>(cInfo)->RangeAttackTime = BASE_ATTACK_TIME;
1143
1144 if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE)
1145 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong trainer type {}.", cInfo->Entry, cInfo->trainer_type);
1146
1147 if (cInfo->speed_walk == 0.0f)
1148 {
1149 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in speed_walk, set to 1.", cInfo->Entry, cInfo->speed_walk);
1150 const_cast<CreatureTemplate*>(cInfo)->speed_walk = 1.0f;
1151 }
1152
1153 if (cInfo->speed_run == 0.0f)
1154 {
1155 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in speed_run, set to 1.14286.", cInfo->Entry, cInfo->speed_run);
1156 const_cast<CreatureTemplate*>(cInfo)->speed_run = 1.14286f;
1157 }
1158
1159 if (cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type))
1160 {
1161 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid creature type ({}) in `type`.", cInfo->Entry, cInfo->type);
1162 const_cast<CreatureTemplate*>(cInfo)->type = CREATURE_TYPE_HUMANOID;
1163 }
1164
1165 // must exist or used hidden but used in data horse case
1166 if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM)
1167 {
1168 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid creature family ({}) in `family`.", cInfo->Entry, cInfo->family);
1169 const_cast<CreatureTemplate*>(cInfo)->family = 0;
1170 }
1171
1172 CheckCreatureMovement("creature_template_movement", cInfo->Entry, const_cast<CreatureTemplate*>(cInfo)->Movement);
1173
1174 if (cInfo->HoverHeight < 0.0f)
1175 {
1176 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in `HoverHeight`", cInfo->Entry, cInfo->HoverHeight);
1177 const_cast<CreatureTemplate*>(cInfo)->HoverHeight = 1.0f;
1178 }
1179
1180 if (cInfo->VehicleId)
1181 {
1182 VehicleEntry const* vehId = sVehicleStore.LookupEntry(cInfo->VehicleId);
1183 if (!vehId)
1184 {
1185 LOG_ERROR("sql.sql", "Creature (Entry: {}) has a non-existing VehicleId ({}). This *WILL* cause the client to freeze!", cInfo->Entry, cInfo->VehicleId);
1186 const_cast<CreatureTemplate*>(cInfo)->VehicleId = 0;
1187 }
1188 }
1189
1190 if (cInfo->PetSpellDataId)
1191 {
1192 CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
1193 if (!spellDataId)
1194 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing PetSpellDataId ({}).", cInfo->Entry, cInfo->PetSpellDataId);
1195 }
1196
1197 for (uint8 j = 0; j < MAX_CREATURE_SPELLS; ++j)
1198 {
1199 if (cInfo->spells[j] && !sSpellMgr->GetSpellInfo(cInfo->spells[j]))
1200 {
1201 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing Spell{} ({}), set to 0.", cInfo->Entry, j + 1, cInfo->spells[j]);
1202 const_cast<CreatureTemplate*>(cInfo)->spells[j] = 0;
1203 }
1204 }
1205
1206 if (cInfo->MovementType >= MAX_DB_MOTION_TYPE)
1207 {
1208 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong movement generator type ({}), ignored and set to IDLE.", cInfo->Entry, cInfo->MovementType);
1209 const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
1210 }
1211
1212 if (cInfo->expansion > (MAX_EXPANSIONS - 1))
1213 {
1214 LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: {}) with expansion {}. Ignored and set to 0.", cInfo->Entry, cInfo->expansion);
1215 const_cast<CreatureTemplate*>(cInfo)->expansion = 0;
1216 }
1217
1218 if (uint32 badFlags = (cInfo->flags_extra & ~CREATURE_FLAG_EXTRA_DB_ALLOWED))
1219 {
1220 LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: {}) with disallowed `flags_extra` {}, removing incorrect flag.", cInfo->Entry, badFlags);
1221 const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
1222 }
1223
1224 const_cast<CreatureTemplate*>(cInfo)->DamageModifier *= Creature::_GetDamageMod(cInfo->rank);
1225
1226 // Hack for modules
1227 for (auto& itr : _creatureCustomIDsStore)
1228 {
1229 if (cInfo->Entry == itr)
1230 return;
1231 }
1232
1233 if ((cInfo->GossipMenuId && !(cInfo->npcflag & UNIT_NPC_FLAG_GOSSIP)) && !(cInfo->flags_extra & CREATURE_FLAG_EXTRA_MODULE))
1234 {
1235 LOG_ERROR("sql.sql", "Creature (Entry: {}) has assigned gossip menu {}, but npcflag does not include UNIT_NPC_FLAG_GOSSIP (1).", cInfo->Entry, cInfo->GossipMenuId);
1236 }
1237 else if ((!cInfo->GossipMenuId && (cInfo->npcflag & UNIT_NPC_FLAG_GOSSIP)) && !(cInfo->flags_extra & CREATURE_FLAG_EXTRA_MODULE))
1238 {
1239 LOG_INFO("sql.sql", "Creature (Entry: {}) has npcflag UNIT_NPC_FLAG_GOSSIP (1), but gossip menu is unassigned.", cInfo->Entry);
1240 }
1241}
#define sCreatureAIRegistry
Definition: CreatureAIFactory.h:48
@ MAX_DB_MOTION_TYPE
Definition: MotionMaster.h:40
@ IDLE_MOTION_TYPE
Definition: MotionMaster.h:37
DBCStorage< VehicleEntry > sVehicleStore(VehicleEntryfmt)
DBCStorage< CreatureSpellDataEntry > sCreatureSpellDataStore(CreatureSpellDatafmt)
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
DBCStorage< CreatureTypeEntry > sCreatureTypeStore(CreatureTypefmt)
#define BASE_ATTACK_TIME
Definition: Unit.h:41
static constexpr uint32 MAX_CREATURE_SPELLS
Definition: Unit.h:45
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:294
@ CREATURE_FLAG_EXTRA_DB_ALLOWED
Definition: CreatureData.h:82
@ CREATURE_FLAG_EXTRA_MODULE
Definition: CreatureData.h:70
#define MAX_KILL_CREDIT
Definition: CreatureData.h:31
spells
Definition: boss_krystallus.cpp:26
@ SPELL_SCHOOL_NORMAL
Definition: SharedDefines.h:283
constexpr auto MAX_SPELL_SCHOOL
Definition: SharedDefines.h:292
@ CREATURE_FAMILY_HORSE_CUSTOM
Definition: SharedDefines.h:2659
@ UNIT_CLASS_WARRIOR
Definition: SharedDefines.h:166
@ CREATURE_TYPE_HUMANOID
Definition: SharedDefines.h:2634
#define CLASSMASK_ALL_CREATURES
Definition: SharedDefines.h:172
@ MAX_EXPANSIONS
Definition: SharedDefines.h:56
#define MAX_TRAINER_TYPE
Definition: SharedDefines.h:2623
#define MAX_DIFFICULTY
Definition: DBCEnums.h:283
static float _GetDamageMod(int32 Rank)
Definition: Creature.cpp:1587
Definition: CreatureData.h:172
uint32 trainer_spell
Definition: CreatureData.h:222
uint32 trainer_class
Definition: CreatureData.h:223
uint32 type
Definition: CreatureData.h:225
uint32 trainer_race
Definition: CreatureData.h:224
uint32 ScriptID
Definition: CreatureData.h:250
uint32 VehicleId
Definition: CreatureData.h:233
CreatureMovementData Movement
Definition: CreatureData.h:238
uint32 faction
Definition: CreatureData.h:201
uint32 dmgschool
Definition: CreatureData.h:210
uint32 expansion
Definition: CreatureData.h:200
uint32 trainer_type
Definition: CreatureData.h:221
std::string AIName
Definition: CreatureData.h:236
uint32 family
Definition: CreatureData.h:220
std::set< uint32 > _difficultyEntries[MAX_DIFFICULTY - 1]
Definition: ObjectMgr.h:1599
CreatureCustomIDsContainer _creatureCustomIDsStore
Definition: ObjectMgr.h:1560
std::set< uint32 > _hasDifficultyEntries[MAX_DIFFICULTY - 1]
Definition: ObjectMgr.h:1600
void CheckCreatureMovement(char const *table, uint64 id, CreatureMovementData &creatureMovement)
Definition: ObjectMgr.cpp:1243
Definition: DBCStructure.h:810
Definition: DBCStructure.h:939
Definition: DBCStructure.h:2027

References _creatureCustomIDsStore, _difficultyEntries, Creature::_GetDamageMod(), _hasDifficultyEntries, CreatureTemplate::AIName, BASE_ATTACK_TIME, CreatureTemplate::BaseAttackTime, CheckCreatureMovement(), CLASSMASK_ALL_CREATURES, CREATURE_FAMILY_HORSE_CUSTOM, CREATURE_FLAG_EXTRA_DB_ALLOWED, CREATURE_FLAG_EXTRA_MODULE, CREATURE_TYPE_HUMANOID, CreatureTemplate::DifficultyEntry, CreatureTemplate::dmgschool, CreatureTemplate::Entry, CreatureTemplate::expansion, CreatureTemplate::faction, CreatureTemplate::family, CreatureTemplate::flags_extra, GetCreatureTemplate(), CreatureTemplate::GossipMenuId, CreatureTemplate::HoverHeight, IDLE_MOTION_TYPE, CreatureTemplate::KillCredit, LOG_ERROR, LOG_INFO, MAX_CREATURE_SPELLS, MAX_DB_MOTION_TYPE, MAX_DIFFICULTY, MAX_EXPANSIONS, MAX_KILL_CREDIT, MAX_SPELL_SCHOOL, MAX_TRAINER_TYPE, CreatureTemplate::Models, CreatureTemplate::Movement, CreatureTemplate::MovementType, CreatureTemplate::npcflag, CreatureTemplate::PetSpellDataId, CreatureTemplate::RangeAttackTime, CreatureTemplate::rank, sCreatureAIRegistry, sCreatureFamilyStore, sCreatureSpellDataStore, sCreatureTypeStore, CreatureTemplate::ScriptID, sFactionTemplateStore, CreatureTemplate::speed_run, CreatureTemplate::speed_walk, SPELL_SCHOOL_NORMAL, CreatureTemplate::spells, sSpellMgr, sVehicleStore, CreatureTemplate::trainer_class, CreatureTemplate::trainer_race, CreatureTemplate::trainer_spell, CreatureTemplate::trainer_type, CreatureTemplate::type, CreatureTemplate::unit_class, UNIT_CLASS_WARRIOR, UNIT_NPC_FLAG_GOSSIP, UNIT_NPC_FLAG_TRAINER, and CreatureTemplate::VehicleId.

Referenced by LoadCreatureTemplates().

◆ CheckDeclinedNames()

bool ObjectMgr::CheckDeclinedNames ( std::wstring  w_ownname,
DeclinedName const &  names 
)
static
8748{
8749 // get main part of the name
8750 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
8751 // prepare flags
8752 bool x = true;
8753 bool y = true;
8754
8755 // check declined names
8756 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
8757 {
8758 std::wstring wname;
8759 if (!Utf8toWStr(names.name[i], wname))
8760 return false;
8761
8762 if (mainpart != GetMainPartOfName(wname, i + 1))
8763 x = false;
8764
8765 if (w_ownname != wname)
8766 y = false;
8767 }
8768 return (x || y);
8769}
std::wstring GetMainPartOfName(std::wstring const &wname, uint32_t declension)
Definition: Util.cpp:386
#define MAX_DECLINED_NAME_CASES
Definition: Unit.h:528

References GetMainPartOfName(), MAX_DECLINED_NAME_CASES, DeclinedName::name, and Utf8toWStr().

Referenced by WorldSession::HandlePetRename(), and WorldSession::HandleSetPlayerDeclinedNames().

◆ CheckPetName()

PetNameInvalidReason ObjectMgr::CheckPetName ( std::string_view  name)
static
8454{
8455 std::wstring wname;
8456 if (!Utf8toWStr(name, wname))
8457 return PET_NAME_INVALID;
8458
8459 if (wname.size() > MAX_PET_NAME)
8460 return PET_NAME_TOO_LONG;
8461
8462 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
8463 if (wname.size() < minName)
8464 return PET_NAME_TOO_SHORT;
8465
8466 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
8467 if (!isValidString(wname, strictMask, false))
8469
8470 // Check Reserved Name
8471 if (sObjectMgr->IsReservedName(name))
8472 return PET_NAME_RESERVED;
8473
8474 // Check Profanity Name
8475 if (sObjectMgr->IsProfanityName(name))
8476 return PET_NAME_PROFANE;
8477
8478 return PET_NAME_SUCCESS;
8479}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition: ObjectMgr.cpp:8338
#define MAX_PET_NAME
Definition: ObjectMgr.h:685
@ CONFIG_STRICT_PET_NAMES
Definition: IWorld.h:227
@ CONFIG_MIN_PET_NAME
Definition: IWorld.h:230
@ PET_NAME_INVALID
Definition: SharedDefines.h:3660
@ PET_NAME_RESERVED
Definition: SharedDefines.h:3666
@ PET_NAME_SUCCESS
Definition: SharedDefines.h:3658
@ PET_NAME_MIXED_LANGUAGES
Definition: SharedDefines.h:3664
@ PET_NAME_TOO_SHORT
Definition: SharedDefines.h:3662
@ PET_NAME_TOO_LONG
Definition: SharedDefines.h:3663
@ PET_NAME_PROFANE
Definition: SharedDefines.h:3665

References CONFIG_MIN_PET_NAME, CONFIG_STRICT_PET_NAMES, isValidString(), MAX_PET_NAME, PET_NAME_INVALID, PET_NAME_MIXED_LANGUAGES, PET_NAME_PROFANE, PET_NAME_RESERVED, PET_NAME_SUCCESS, PET_NAME_TOO_LONG, PET_NAME_TOO_SHORT, sObjectMgr, sWorld, and Utf8toWStr().

Referenced by WorldSession::HandlePetRename().

◆ CheckPlayerName()

uint8 ObjectMgr::CheckPlayerName ( std::string_view  name,
bool  create = false 
)
static
8375{
8376 std::wstring wname;
8377
8378 // Check for invalid characters
8379 if (!Utf8toWStr(name, wname))
8381
8382 // Check for too long name
8383 if (wname.size() > MAX_PLAYER_NAME)
8384 return CHAR_NAME_TOO_LONG;
8385
8386 // Check for too short name
8387 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
8388 if (wname.size() < minName)
8389 return CHAR_NAME_TOO_SHORT;
8390
8391 // Check for mixed languages
8392 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
8393 if (!isValidString(wname, strictMask, false, create))
8395
8396 // Check for three consecutive letters
8397 wstrToLower(wname);
8398 for (std::size_t i = 2; i < wname.size(); ++i)
8399 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
8401
8402 // Check Reserved Name
8403 if (sObjectMgr->IsReservedName(name))
8404 return CHAR_NAME_RESERVED;
8405
8406 // Check Profanity Name
8407 if (sObjectMgr->IsProfanityName(name))
8408 return CHAR_NAME_PROFANE;
8409
8410 return CHAR_NAME_SUCCESS;
8411}
#define MAX_PLAYER_NAME
Definition: ObjectMgr.h:683
@ CONFIG_STRICT_PLAYER_NAMES
Definition: IWorld.h:224
@ CONFIG_MIN_PLAYER_NAME
Definition: IWorld.h:228
@ CHAR_NAME_TOO_SHORT
Definition: SharedDefines.h:3422
@ CHAR_NAME_THREE_CONSECUTIVE
Definition: SharedDefines.h:3430
@ CHAR_NAME_INVALID_CHARACTER
Definition: SharedDefines.h:3424
@ CHAR_NAME_TOO_LONG
Definition: SharedDefines.h:3423
@ CHAR_NAME_RESERVED
Definition: SharedDefines.h:3427
@ CHAR_NAME_MIXED_LANGUAGES
Definition: SharedDefines.h:3425
@ CHAR_NAME_PROFANE
Definition: SharedDefines.h:3426
@ CHAR_NAME_SUCCESS
Definition: SharedDefines.h:3419

References CHAR_NAME_INVALID_CHARACTER, CHAR_NAME_MIXED_LANGUAGES, CHAR_NAME_PROFANE, CHAR_NAME_RESERVED, CHAR_NAME_SUCCESS, CHAR_NAME_THREE_CONSECUTIVE, CHAR_NAME_TOO_LONG, CHAR_NAME_TOO_SHORT, CONFIG_MIN_PLAYER_NAME, CONFIG_STRICT_PLAYER_NAMES, isValidString(), MAX_PLAYER_NAME, sObjectMgr, sWorld, Utf8toWStr(), and wstrToLower().

Referenced by character_commandscript::HandleCharacterRenameCommand(), WorldSession::HandleCharCreateOpcode(), WorldSession::HandleCharCustomizeCallback(), WorldSession::HandleCharFactionOrRaceChangeCallback(), WorldSession::HandleCharRenameOpcode(), PlayerDumpReader::LoadDump(), Player::LoadFromDB(), and character_commandscript::ValidatePDumpTarget().

◆ ChooseCreatureFlags()

void ObjectMgr::ChooseCreatureFlags ( CreatureTemplate const *  cinfo,
uint32 npcflag,
uint32 unit_flags,
uint32 dynamicflags,
CreatureData const *  data = nullptr 
)
static
1661{
1662 npcflag = cinfo->npcflag;
1663 unit_flags = cinfo->unit_flags;
1664 dynamicflags = cinfo->dynamicflags;
1665
1666 if (data)
1667 {
1668 if (data->npcflag)
1669 npcflag = data->npcflag;
1670
1671 if (data->unit_flags)
1672 unit_flags = data->unit_flags;
1673
1674 if (data->dynamicflags)
1675 dynamicflags = data->dynamicflags;
1676 }
1677}

References CreatureTemplate::dynamicflags, CreatureData::dynamicflags, CreatureTemplate::npcflag, CreatureData::npcflag, CreatureTemplate::unit_flags, and CreatureData::unit_flags.

Referenced by Creature::UpdateEntry().

◆ ChooseDisplayId()

CreatureModel const * ObjectMgr::ChooseDisplayId ( CreatureTemplate const *  cinfo,
CreatureData const *  data = nullptr 
)
static
1646{
1647 // Load creature model (display id)
1648 if (data && data->displayid)
1649 if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid))
1650 return model;
1651
1652 if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER))
1653 if (CreatureModel const* model = cinfo->GetRandomValidModel())
1654 return model;
1655
1656 // Triggers by default receive the invisible model
1657 return cinfo->GetFirstInvisibleModel();
1658}
@ CREATURE_FLAG_EXTRA_TRIGGER
Definition: CreatureData.h:53

References CREATURE_FLAG_EXTRA_TRIGGER, CreatureData::displayid, CreatureTemplate::flags_extra, CreatureTemplate::GetFirstInvisibleModel(), CreatureTemplate::GetModelWithDisplayId(), and CreatureTemplate::GetRandomValidModel().

Referenced by npc_shattrath_daily_quest::DoAction(), Creature::GetNativeObjectScale(), AuraEffect::HandleAuraDummy(), AuraEffect::HandleAuraMounted(), AuraEffect::HandleAuraTransform(), Creature::InitEntry(), and SmartScript::ProcessAction().

◆ DeleteCreatureData()

void ObjectMgr::DeleteCreatureData ( ObjectGuid::LowType  spawnId)
7975{
7976 // remove mapid*cellid -> guid_set map
7977 CreatureData const* data = GetCreatureData(guid);
7978 if (data)
7979 RemoveCreatureFromGrid(guid, data);
7980
7981 _creatureDataStore.erase(guid);
7982}
CreatureDataContainer _creatureDataStore
Definition: ObjectMgr.h:1558
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition: ObjectMgr.cpp:2313
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition: ObjectMgr.h:1196

References _creatureDataStore, GetCreatureData(), and RemoveCreatureFromGrid().

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
8947{
8948 // explicit name case
8949 std::wstring wname;
8950 if (!Utf8toWStr(name, wname))
8951 return false;
8952
8953 // converting string that we try to find to lower case
8954 wstrToLower(wname);
8955
8956 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8957 {
8958 if (itr->second.wnameLow == wname)
8959 {
8961
8962 stmt->SetData(0, itr->second.name);
8963
8964 WorldDatabase.Execute(stmt);
8965
8966 _gameTeleStore.erase(itr);
8967 return true;
8968 }
8969 }
8970
8971 return false;
8972}
@ WORLD_DEL_GAME_TELE
Definition: WorldDatabase.h:42

References _gameTeleStore, PreparedStatementBase::SetData(), Utf8toWStr(), WORLD_DEL_GAME_TELE, WorldDatabase, and wstrToLower().

◆ DeleteGOData()

void ObjectMgr::DeleteGOData ( ObjectGuid::LowType  guid)
7985{
7986 // remove mapid*cellid -> guid_set map
7987 GameObjectData const* data = GetGameObjectData(guid);
7988 if (data)
7989 RemoveGameobjectFromGrid(guid, data);
7990
7991 _gameObjectDataStore.erase(guid);
7992}
GameObjectData const * GetGameObjectData(ObjectGuid::LowType spawnId) const
Definition: ObjectMgr.h:1213
GameObjectDataContainer _gameObjectDataStore
Definition: ObjectMgr.h:1572
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition: ObjectMgr.cpp:2616

References _gameObjectDataStore, GetGameObjectData(), and RemoveGameobjectFromGrid().

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
6967{
6968 if (_auctionId >= 0xFFFFFFFE)
6969 {
6970 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
6972 }
6973 return _auctionId++;
6974}
@ ERROR_EXIT_CODE
Definition: World.h:55
static void StopNow(uint8 exitcode)
Definition: World.h:254

References _auctionId, ERROR_EXIT_CODE, LOG_ERROR, and World::StopNow().

◆ GenerateCreatureSpawnId()

uint32 ObjectMgr::GenerateCreatureSpawnId ( )
6998{
6999 if (_creatureSpawnId >= uint32(0xFFFFFF))
7000 {
7001 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7003 }
7004 return _creatureSpawnId++;
7005}

References _creatureSpawnId, ERROR_EXIT_CODE, LOG_ERROR, and World::StopNow().

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
6977{
6978 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
6979 {
6980 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
6982 }
6983 return _equipmentSetGuid++;
6984}
std::uint64_t uint64
Definition: Define.h:106

References _equipmentSetGuid, ERROR_EXIT_CODE, LOG_ERROR, and World::StopNow().

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7008{
7009 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7010 {
7011 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7013 }
7014 return _gameObjectSpawnId++;
7015}

References _gameObjectSpawnId, ERROR_EXIT_CODE, LOG_ERROR, and World::StopNow().

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
6987{
6988 if (_mailId >= 0xFFFFFFFE)
6989 {
6990 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
6992 }
6993 std::lock_guard<std::mutex> guard(_mailIdMutex);
6994 return _mailId++;
6995}
std::mutex _mailIdMutex
Definition: ObjectMgr.h:1441

References _mailId, _mailIdMutex, ERROR_EXIT_CODE, LOG_ERROR, and World::StopNow().

◆ GeneratePetName()

std::string ObjectMgr::GeneratePetName ( uint32  entry)
7474{
7475 std::vector<std::string>& list0 = _petHalfName0[entry];
7476 std::vector<std::string>& list1 = _petHalfName1[entry];
7477
7478 if (list0.empty() || list1.empty())
7479 {
7480 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
7481 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
7482 if (!petname)
7483 return cinfo->Name;
7484
7485 return std::string(petname);
7486 }
7487
7488 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7489}
char const * GetPetName(uint32 petfamily, uint32 dbclang)
Definition: DBCStores.cpp:665
std::string Name
Definition: CreatureData.h:194
HalfNameContainer _petHalfName1
Definition: ObjectMgr.h:1547
HalfNameContainer _petHalfName0
Definition: ObjectMgr.h:1546

References _petHalfName0, _petHalfName1, CreatureTemplate::family, GetCreatureTemplate(), GetPetName(), CreatureTemplate::Name, sWorld, and urand().

Referenced by GeneratePetNameLocale().

◆ GeneratePetNameLocale()

std::string ObjectMgr::GeneratePetNameLocale ( uint32  entry,
LocaleConstant  locale 
)
7461{
7462 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
7463 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
7464
7465 if (list0.empty() || list1.empty())
7466 {
7467 return GeneratePetName(entry);
7468 }
7469
7470 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7471}
HalfNameContainerLocale _petHalfLocaleName0
Definition: ObjectMgr.h:1549
HalfNameContainerLocale _petHalfLocaleName1
Definition: ObjectMgr.h:1550
std::string GeneratePetName(uint32 entry)
Definition: ObjectMgr.cpp:7473

References _petHalfLocaleName0, _petHalfLocaleName1, GeneratePetName(), and urand().

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
7492{
7493 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
7494 return ++_hiPetNumber;
7495}
std::mutex _hiPetNumberMutex
Definition: ObjectMgr.h:1443

References _hiPetNumber, and _hiPetNumberMutex.

◆ GetAccessRequirement()

DungeonProgressionRequirements const * ObjectMgr::GetAccessRequirement ( uint32  mapid,
Difficulty  difficulty 
) const
inline
870 {
871 DungeonProgressionRequirementsContainer::const_iterator itr = _accessRequirementStore.find(mapid);
872 if (itr != _accessRequirementStore.end())
873 {
874 std::unordered_map<uint8, DungeonProgressionRequirements*> difficultiesProgressionRequirements = itr->second;
875 auto difficultiesItr = difficultiesProgressionRequirements.find(difficulty);
876 if (difficultiesItr != difficultiesProgressionRequirements.end())
877 {
878 return difficultiesItr->second;
879 }
880 }
881 return nullptr;
882 }

References _accessRequirementStore.

◆ GetAcoreString() [1/2]

AcoreString const * ObjectMgr::GetAcoreString ( uint32  entry) const
inline
1302 {
1303 AcoreStringContainer::const_iterator itr = _acoreStringStore.find(entry);
1304 if (itr == _acoreStringStore.end())
1305 return nullptr;
1306
1307 return &itr->second;
1308 }
AcoreStringContainer _acoreStringStore
Definition: ObjectMgr.h:1590

References _acoreStringStore.

Referenced by GetAcoreString(), and GetAcoreStringForDBCLocale().

◆ GetAcoreString() [2/2]

char const * ObjectMgr::GetAcoreString ( uint32  entry,
LocaleConstant  locale 
) const
8680{
8681 if (AcoreString const* ts = GetAcoreString(entry))
8682 {
8683 if (ts->Content.size() > std::size_t(locale) && !ts->Content[locale].empty())
8684 return ts->Content[locale].c_str();
8685
8686 return ts->Content[DEFAULT_LOCALE].c_str();
8687 }
8688
8689 LOG_ERROR("sql.sql", "Acore string entry {} not found in DB.", entry);
8690
8691 return "<error>";
8692}
#define DEFAULT_LOCALE
Definition: Common.h:79
Definition: ObjectMgr.h:502
AcoreString const * GetAcoreString(uint32 entry) const
Definition: ObjectMgr.h:1301

References AcoreString::Content, DEFAULT_LOCALE, GetAcoreString(), and LOG_ERROR.

◆ GetAcoreStringForDBCLocale()

char const * ObjectMgr::GetAcoreStringForDBCLocale ( uint32  entry) const
inline
1310{ return GetAcoreString(entry, DBCLocaleIndex); }

References DBCLocaleIndex, and GetAcoreString().

◆ GetAllCreatureData()

CreatureDataContainer const & ObjectMgr::GetAllCreatureData ( ) const
inline
1195{ return _creatureDataStore; }

References _creatureDataStore.

◆ GetAllGOData()

GameObjectDataContainer const & ObjectMgr::GetAllGOData ( ) const
inline
1212{ return _gameObjectDataStore; }

References _gameObjectDataStore.

◆ GetAllServerMailStore()

ServerMailContainer const & ObjectMgr::GetAllServerMailStore ( ) const
inline
1186{ return _serverMailStore; }
ServerMailContainer _serverMailStore
Definition: ObjectMgr.h:1597

References _serverMailStore.

◆ GetAreaTrigger()

AreaTrigger const * ObjectMgr::GetAreaTrigger ( uint32  trigger) const
inline
854 {
855 AreaTriggerContainer::const_iterator itr = _areaTriggerStore.find(trigger);
856 if (itr != _areaTriggerStore.end())
857 return &itr->second;
858 return nullptr;
859 }
AreaTriggerContainer _areaTriggerStore
Definition: ObjectMgr.h:1472

References _areaTriggerStore.

Referenced by GetGoBackTrigger(), LoadAreaTriggerScripts(), LoadAreaTriggerTeleports(), LoadQuestAreaTriggers(), and LoadTavernAreaTriggers().

◆ GetAreaTriggerScriptId()

uint32 ObjectMgr::GetAreaTriggerScriptId ( uint32  trigger_id)
8772{
8773 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
8774 if (i != _areaTriggerScriptStore.end())
8775 return i->second;
8776 return 0;
8777}
AreaTriggerScriptContainer _areaTriggerScriptStore
Definition: ObjectMgr.h:1474

References _areaTriggerScriptStore.

◆ GetAreaTriggerTeleport()

AreaTriggerTeleport const * ObjectMgr::GetAreaTriggerTeleport ( uint32  trigger) const
inline
862 {
863 AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.find(trigger);
864 if (itr != _areaTriggerTeleportStore.end())
865 return &itr->second;
866 return nullptr;
867 }
AreaTriggerTeleportContainer _areaTriggerTeleportStore
Definition: ObjectMgr.h:1473

References _areaTriggerTeleportStore.

◆ GetBaseReputationOf()

int32 ObjectMgr::GetBaseReputationOf ( FactionEntry const *  factionEntry,
uint8  race,
uint8  playerClass 
)
8786{
8787 if (!factionEntry)
8788 return 0;
8789
8790 uint32 raceMask = (1 << (race - 1));
8791 uint32 classMask = (1 << (playerClass - 1));
8792
8793 for (int i = 0; i < 4; i++)
8794 {
8795 if ((!factionEntry->BaseRepClassMask[i] ||
8796 factionEntry->BaseRepClassMask[i] & classMask) &&
8797 (!factionEntry->BaseRepRaceMask[i] ||
8798 factionEntry->BaseRepRaceMask[i] & raceMask))
8799 return factionEntry->BaseRepValue[i];
8800 }
8801
8802 return 0;
8803}

References FactionEntry::BaseRepClassMask, FactionEntry::BaseRepRaceMask, and FactionEntry::BaseRepValue.

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
7402{
7403 return _baseXPTable[level] ? _baseXPTable[level] : 0;
7404}
BaseXPContainer _baseXPTable
Definition: ObjectMgr.h:1540

References _baseXPTable.

◆ GetBroadcastText()

BroadcastText const * ObjectMgr::GetBroadcastText ( uint32  id) const
inline
1189 {
1190 BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id);
1191 if (itr != _broadcastTextStore.end())
1192 return &itr->second;
1193 return nullptr;
1194 }
BroadcastTextContainer _broadcastTextStore
Definition: ObjectMgr.h:1579

References _broadcastTextStore.

Referenced by LoadGossipMenuItems(), LoadGossipText(), and LoadScripts().

◆ GetCellObjectGuids()

CellObjectGuids const & ObjectMgr::GetCellObjectGuids ( uint16  mapid,
uint8  spawnMode,
uint32  cell_id 
)
inline
1149 {
1150 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1151 if (itr1 != _mapObjectGuidsStore.end())
1152 {
1153 CellObjectGuidsMap::const_iterator itr2 = itr1->second.find(cell_id);
1154 if (itr2 != itr1->second.end())
1155 return itr2->second;
1156 }
1157 return _emptyCellObjectGuids;
1158 }
CellObjectGuids _emptyCellObjectGuids
Definition: ObjectMgr.h:1557

References _emptyCellObjectGuids, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetCreatureAddon()

CreatureAddon const * ObjectMgr::GetCreatureAddon ( ObjectGuid::LowType  lowguid)
1433{
1434 CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid);
1435 if (itr != _creatureAddonStore.end())
1436 return &(itr->second);
1437
1438 return nullptr;
1439}
CreatureAddonContainer _creatureAddonStore
Definition: ObjectMgr.h:1563

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
9683{
9684 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
9685
9686 if (it != _creatureBaseStatsStore.end())
9687 return &(it->second);
9688
9689 struct DefaultCreatureBaseStats : public CreatureBaseStats
9690 {
9691 DefaultCreatureBaseStats()
9692 {
9693 BaseArmor = 1;
9694 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
9695 {
9696 BaseHealth[j] = 1;
9697 BaseDamage[j] = 0.0f;
9698 }
9699 BaseMana = 0;
9700 AttackPower = 0;
9701 RangedAttackPower = 0;
9702 }
9703 };
9704 static const DefaultCreatureBaseStats defStats;
9705 return &defStats;
9706}
uint16 MAKE_PAIR16(uint8 l, uint8 h)
Definition: ObjectDefines.h:82
CreatureBaseStatsContainer _creatureBaseStatsStore
Definition: ObjectMgr.h:1524

References _creatureBaseStatsStore, MAKE_PAIR16(), and MAX_EXPANSIONS.

Referenced by AddCreData().

◆ GetCreatureData()

CreatureData const * ObjectMgr::GetCreatureData ( ObjectGuid::LowType  spawnId) const
inline
1197 {
1198 CreatureDataContainer::const_iterator itr = _creatureDataStore.find(spawnId);
1199 if (itr == _creatureDataStore.end()) return nullptr;
1200 return &itr->second;
1201 }

References _creatureDataStore.

Referenced by DeleteCreatureData(), LoadCreatureAddons(), LoadCreatureMovementOverrides(), LoadLinkedRespawn(), and SetCreatureLinkedRespawn().

◆ GetCreatureLocale()

CreatureLocale const * ObjectMgr::GetCreatureLocale ( uint32  entry) const
inline
1220 {
1221 CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry);
1222 if (itr == _creatureLocaleStore.end()) return nullptr;
1223 return &itr->second;
1224 }
CreatureLocaleContainer _creatureLocaleStore
Definition: ObjectMgr.h:1571

References _creatureLocaleStore.

◆ GetCreatureModelInfo()

CreatureModelInfo const * ObjectMgr::GetCreatureModelInfo ( uint32  modelId) const
1637{
1638 CreatureModelContainer::const_iterator itr = _creatureModelStore.find(modelId);
1639 if (itr != _creatureModelStore.end())
1640 return &(itr->second);
1641
1642 return nullptr;
1643}
CreatureModelContainer _creatureModelStore
Definition: ObjectMgr.h:1562

References _creatureModelStore.

Referenced by GetCreatureModelRandomGender(), and LoadCreatureTemplateModels().

◆ GetCreatureModelRandomGender()

CreatureModelInfo const * ObjectMgr::GetCreatureModelRandomGender ( CreatureModel model,
CreatureTemplate const *  creatureTemplate 
) const
1680{
1681 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(model->CreatureDisplayID);
1682 if (!modelInfo)
1683 return nullptr;
1684
1685 // If a model for another gender exists, 50% chance to use it
1686 if (modelInfo->modelid_other_gender != 0 && urand(0, 1) == 0)
1687 {
1688 CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender);
1689 if (!minfo_tmp)
1690 LOG_ERROR("sql.sql", "Model (Entry: {}) has modelid_other_gender {} not found in table `creature_model_info`. ", model->CreatureDisplayID, modelInfo->modelid_other_gender);
1691 else
1692 {
1693 // Model ID changed
1694 model->CreatureDisplayID = modelInfo->modelid_other_gender;
1695 if (creatureTemplate)
1696 {
1697 auto itr = std::find_if(creatureTemplate->Models.begin(), creatureTemplate->Models.end(), [&](CreatureModel const& templateModel)
1698 {
1699 return templateModel.CreatureDisplayID == modelInfo->modelid_other_gender;
1700 });
1701 if (itr != creatureTemplate->Models.end())
1702 *model = *itr;
1703 }
1704 return minfo_tmp;
1705 }
1706 }
1707
1708 return modelInfo;
1709}
uint32 CreatureDisplayID
Definition: CreatureData.h:182
Definition: CreatureData.h:401
uint32 modelid_other_gender
Definition: CreatureData.h:405
CreatureModelInfo const * GetCreatureModelInfo(uint32 modelId) const
Definition: ObjectMgr.cpp:1636

References CreatureModel::CreatureDisplayID, GetCreatureModelInfo(), LOG_ERROR, CreatureModelInfo::modelid_other_gender, CreatureTemplate::Models, and urand().

Referenced by GetTaxiMountDisplayId().

◆ GetCreatureMovementOverride()

CreatureMovementData const * ObjectMgr::GetCreatureMovementOverride ( ObjectGuid::LowType  spawnId) const
1451{
1453}
auto MapGetValuePtr(M &map, typename M::key_type const &key) -> decltype(AddressOrSelf(map.find(key) ->second))
Definition: Containers.h:206
std::unordered_map< ObjectGuid::LowType, CreatureMovementData > _creatureMovementOverrides
Definition: ObjectMgr.h:1565

References _creatureMovementOverrides, and Acore::Containers::MapGetValuePtr().

◆ GetCreatureQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestInvolvedRelationBounds ( uint32  creature_entry)
inline
998 {
999 return _creatureQuestInvolvedRelations.equal_range(creature_entry);
1000 }
QuestRelations _creatureQuestInvolvedRelations
Definition: ObjectMgr.h:1491

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestInvolvedRelationMap ( )
inline

◆ GetCreatureQuestItemList()

CreatureQuestItemList const * ObjectMgr::GetCreatureQuestItemList ( uint32  id) const
inline
817 {
818 CreatureQuestItemMap::const_iterator itr = _creatureQuestItemStore.find(id);
819 if (itr != _creatureQuestItemStore.end())
820 return &itr->second;
821 return nullptr;
822 }
CreatureQuestItemMap _creatureQuestItemStore
Definition: ObjectMgr.h:1568

References _creatureQuestItemStore.

◆ GetCreatureQuestItemMap()

CreatureQuestItemMap const * ObjectMgr::GetCreatureQuestItemMap ( ) const
inline
823{ return &_creatureQuestItemStore; }

References _creatureQuestItemStore.

◆ GetCreatureQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestRelationBounds ( uint32  creature_entry)
inline
993 {
994 return _creatureQuestRelations.equal_range(creature_entry);
995 }
QuestRelations _creatureQuestRelations
Definition: ObjectMgr.h:1490

References _creatureQuestRelations.

◆ GetCreatureQuestRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestRelationMap ( )
inline
983 {
985 }

References _creatureQuestRelations.

◆ GetCreatureTemplate()

◆ GetCreatureTemplateAddon()

CreatureAddon const * ObjectMgr::GetCreatureTemplateAddon ( uint32  entry)
1442{
1443 CreatureAddonContainer::const_iterator itr = _creatureTemplateAddonStore.find(entry);
1444 if (itr != _creatureTemplateAddonStore.end())
1445 return &(itr->second);
1446
1447 return nullptr;
1448}
CreatureAddonContainer _creatureTemplateAddonStore
Definition: ObjectMgr.h:1564

References _creatureTemplateAddonStore.

◆ GetCreatureTemplates()

CreatureTemplateContainer const * ObjectMgr::GetCreatureTemplates ( ) const
inline
764{ return &_creatureTemplateStore; }
CreatureTemplateContainer _creatureTemplateStore
Definition: ObjectMgr.h:1559

References _creatureTemplateStore.

◆ GetDBCLocaleIndex()

LocaleConstant ObjectMgr::GetDBCLocaleIndex ( ) const
inline
1311{ return DBCLocaleIndex; }

References DBCLocaleIndex.

◆ GetDungeonEncounterList()

DungeonEncounterList const * ObjectMgr::GetDungeonEncounterList ( uint32  mapId,
Difficulty  difficulty 
)
inline
937 {
938 std::unordered_map<uint32, DungeonEncounterList>::const_iterator itr = _dungeonEncounterStore.find(MAKE_PAIR32(mapId, difficulty));
939 if (itr != _dungeonEncounterStore.end())
940 return &itr->second;
941 return nullptr;
942 }

References _dungeonEncounterStore, and MAKE_PAIR32().

◆ GetEquipmentInfo()

EquipmentInfo const * ObjectMgr::GetEquipmentInfo ( uint32  entry,
int8 id 
)
1456{
1457 EquipmentInfoContainer::const_iterator itr = _equipmentInfoStore.find(entry);
1458 if (itr == _equipmentInfoStore.end())
1459 return nullptr;
1460
1461 if (itr->second.empty())
1462 return nullptr;
1463
1464 if (id == -1) // select a random element
1465 {
1466 EquipmentInfoContainerInternal::const_iterator ritr = itr->second.begin();
1467 std::advance(ritr, urand(0u, itr->second.size() - 1));
1468 id = std::distance(itr->second.begin(), ritr) + 1;
1469 return &ritr->second;
1470 }
1471 else
1472 {
1473 EquipmentInfoContainerInternal::const_iterator itr2 = itr->second.find(id);
1474 if (itr2 != itr->second.end())
1475 return &itr2->second;
1476 }
1477
1478 return nullptr;
1479}
EquipmentInfoContainer _equipmentInfoStore
Definition: ObjectMgr.h:1569

References _equipmentInfoStore, and urand().

Referenced by LoadCreatures().

◆ GetFishingBaseSkillLevel()

int32 ObjectMgr::GetFishingBaseSkillLevel ( uint32  entry) const
inline
1105 {
1106 FishingBaseSkillContainer::const_iterator itr = _fishingBaseForAreaStore.find(entry);
1107 return itr != _fishingBaseForAreaStore.end() ? itr->second : 0;
1108 }

References _fishingBaseForAreaStore.

◆ GetGameObjectAddon()

GameObjectAddon const * ObjectMgr::GetGameObjectAddon ( ObjectGuid::LowType  lowguid)
1424{
1425 GameObjectAddonContainer::const_iterator itr = _gameObjectAddonStore.find(lowguid);
1426 if (itr != _gameObjectAddonStore.end())
1427 return &(itr->second);
1428
1429 return nullptr;
1430}
GameObjectAddonContainer _gameObjectAddonStore
Definition: ObjectMgr.h:1566

References _gameObjectAddonStore.

◆ GetGameObjectData()

GameObjectData const * ObjectMgr::GetGameObjectData ( ObjectGuid::LowType  spawnId) const
inline
1214 {
1215 GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(spawnId);
1216 if (itr == _gameObjectDataStore.end()) return nullptr;
1217 return &itr->second;
1218 }

References _gameObjectDataStore.

Referenced by DeleteGOData(), LoadGameObjectAddons(), LoadLinkedRespawn(), and LoadScripts().

◆ GetGameObjectLocale()

GameObjectLocale const * ObjectMgr::GetGameObjectLocale ( uint32  entry) const
inline
1226 {
1227 GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
1228 if (itr == _gameObjectLocaleStore.end()) return nullptr;
1229 return &itr->second;
1230 }
GameObjectLocaleContainer _gameObjectLocaleStore
Definition: ObjectMgr.h:1573

References _gameObjectLocaleStore.

◆ GetGameObjectQuestItemList()

GameObjectQuestItemList const * ObjectMgr::GetGameObjectQuestItemList ( uint32  id) const
inline
808 {
809 GameObjectQuestItemMap::const_iterator itr = _gameObjectQuestItemStore.find(id);
810 if (itr != _gameObjectQuestItemStore.end())
811 return &itr->second;
812 return nullptr;
813 }
GameObjectQuestItemMap _gameObjectQuestItemStore
Definition: ObjectMgr.h:1567

References _gameObjectQuestItemStore.

◆ GetGameObjectQuestItemMap()

GameObjectQuestItemMap const * ObjectMgr::GetGameObjectQuestItemMap ( ) const
inline

◆ GetGameObjectTemplate()

GameObjectTemplate const * ObjectMgr::GetGameObjectTemplate ( uint32  entry)
10007{
10008 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
10009 if (itr != _gameObjectTemplateStore.end())
10010 return &(itr->second);
10011
10012 return nullptr;
10013}
GameObjectTemplateContainer _gameObjectTemplateStore
Definition: ObjectMgr.h:1574

References _gameObjectTemplateStore.

Referenced by AddGOData(), IsGameObjectStaticTransport(), LoadGameobjectQuestEnders(), LoadGameObjectQuestItems(), LoadGameobjectQuestStarters(), LoadGameobjects(), LoadQuests(), LoadScripts(), and LoadTempSummons().

◆ GetGameObjectTemplateAddon()

GameObjectTemplateAddon const * ObjectMgr::GetGameObjectTemplateAddon ( uint32  entry) const
10022{
10023 auto itr = _gameObjectTemplateAddonStore.find(entry);
10024 if (itr != _gameObjectTemplateAddonStore.end())
10025 return &itr->second;
10026
10027 return nullptr;
10028}
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
Definition: ObjectMgr.h:1575

References _gameObjectTemplateAddonStore.

◆ GetGameObjectTemplates()

GameObjectTemplateContainer const * ObjectMgr::GetGameObjectTemplates ( ) const
inline

◆ GetGameTele() [1/2]

GameTele const * ObjectMgr::GetGameTele ( std::string_view  name) const
8891{
8892 // explicit name case
8893 std::wstring wname;
8894 if (!Utf8toWStr(name, wname))
8895 return nullptr;
8896
8897 // converting string that we try to find to lower case
8898 wstrToLower(wname);
8899
8900 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
8901 const GameTele* alt = nullptr;
8902 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8903 {
8904 if (itr->second.wnameLow == wname)
8905 return &itr->second;
8906 else if (!alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
8907 alt = &itr->second;
8908 }
8909
8910 return alt;
8911}
Definition: ObjectMgr.h:135

References _gameTeleStore, Utf8toWStr(), GameTele::wnameLow, and wstrToLower().

◆ GetGameTele() [2/2]

GameTele const * ObjectMgr::GetGameTele ( uint32  id) const
inline
1343 {
1344 GameTeleContainer::const_iterator itr = _gameTeleStore.find(id);
1345 if (itr == _gameTeleStore.end()) return nullptr;
1346 return &itr->second;
1347 }

References _gameTeleStore.

◆ GetGameTeleMap()

GameTeleContainer const & ObjectMgr::GetGameTeleMap ( ) const
inline
1349{ return _gameTeleStore; }

References _gameTeleStore.

◆ GetGenerator()

template<HighGuid type>
ObjectGuidGeneratorBase & ObjectMgr::GetGenerator ( )
inline
1118 {
1119 static_assert(ObjectGuidTraits<type>::Global, "Only global guid can be generated in ObjectMgr context");
1120 return GetGuidSequenceGenerator<type>();
1121 }
Definition: ObjectGuid.h:76

◆ GetGoBackTrigger()

AreaTriggerTeleport const * ObjectMgr::GetGoBackTrigger ( uint32  Map) const
6866{
6867 bool useParentDbValue = false;
6868 uint32 parentId = 0;
6869 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
6870 if (!mapEntry || mapEntry->entrance_map < 0)
6871 return nullptr;
6872
6873 if (mapEntry->IsDungeon())
6874 {
6875 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
6876
6877 if (!iTemplate)
6878 return nullptr;
6879
6880 parentId = iTemplate->Parent;
6881 useParentDbValue = true;
6882 }
6883
6884 uint32 entrance_map = uint32(mapEntry->entrance_map);
6885 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6886 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
6887 {
6888 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
6889 if (atEntry && atEntry->map == Map)
6890 return &itr->second;
6891 }
6892 return nullptr;
6893}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
Definition: ObjectMgr.h:421
uint32 map
Definition: ObjectMgr.h:423
AreaTrigger const * GetAreaTrigger(uint32 trigger) const
Definition: ObjectMgr.h:853
Definition: Map.h:274
uint32 Parent
Definition: Map.h:275
Definition: DBCStructure.h:1325
int32 entrance_map
Definition: DBCStructure.h:1340
bool IsDungeon() const
Definition: DBCStructure.h:1351

References _areaTriggerTeleportStore, MapEntry::entrance_map, GetAreaTrigger(), MapEntry::IsDungeon(), AreaTrigger::map, InstanceTemplate::Parent, sMapStore, and sObjectMgr.

◆ GetGOQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestInvolvedRelationBounds ( uint32  go_entry)
inline
978 {
979 return _goQuestInvolvedRelations.equal_range(go_entry);
980 }
QuestRelations _goQuestInvolvedRelations
Definition: ObjectMgr.h:1489

References _goQuestInvolvedRelations.

◆ GetGOQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetGOQuestInvolvedRelationMap ( )
inline
968 {
970 }

References _goQuestInvolvedRelations.

◆ GetGOQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestRelationBounds ( uint32  go_entry)
inline
973 {
974 return _goQuestRelations.equal_range(go_entry);
975 }
QuestRelations _goQuestRelations
Definition: ObjectMgr.h:1488

References _goQuestRelations.

◆ GetGOQuestRelationMap()

QuestRelations * ObjectMgr::GetGOQuestRelationMap ( )
inline
963 {
964 return &_goQuestRelations;
965 }

References _goQuestRelations.

◆ GetGossipMenuItemsLocale()

GossipMenuItemsLocale const * ObjectMgr::GetGossipMenuItemsLocale ( uint32  entry) const
inline
1256 {
1257 GossipMenuItemsLocaleContainer::const_iterator itr = _gossipMenuItemsLocaleStore.find(entry);
1258 if (itr == _gossipMenuItemsLocaleStore.end()) return nullptr;
1259 return &itr->second;
1260 }
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore
Definition: ObjectMgr.h:1591

References _gossipMenuItemsLocaleStore.

◆ GetGossipMenuItemsMapBounds()

GossipMenuItemsMapBounds ObjectMgr::GetGossipMenuItemsMapBounds ( uint32  uiMenuId) const
inline
1396 {
1397 return _gossipMenuItemsStore.equal_range(uiMenuId);
1398 }
GossipMenuItemsContainer _gossipMenuItemsStore
Definition: ObjectMgr.h:1483

References _gossipMenuItemsStore.

◆ GetGossipMenuItemsMapBoundsNonConst()

GossipMenuItemsMapBoundsNonConst ObjectMgr::GetGossipMenuItemsMapBoundsNonConst ( uint32  uiMenuId)
inline
1400 {
1401 return _gossipMenuItemsStore.equal_range(uiMenuId);
1402 }

References _gossipMenuItemsStore.

◆ GetGossipMenusMapBounds()

GossipMenusMapBounds ObjectMgr::GetGossipMenusMapBounds ( uint32  uiMenuId) const
inline
1386 {
1387 return _gossipMenusStore.equal_range(uiMenuId);
1388 }
GossipMenusContainer _gossipMenusStore
Definition: ObjectMgr.h:1482

References _gossipMenusStore.

◆ GetGossipMenusMapBoundsNonConst()

GossipMenusMapBoundsNonConst ObjectMgr::GetGossipMenusMapBoundsNonConst ( uint32  uiMenuId)
inline
1391 {
1392 return _gossipMenusStore.equal_range(uiMenuId);
1393 }

References _gossipMenusStore.

◆ GetGossipText()

GossipText const * ObjectMgr::GetGossipText ( uint32  Text_ID) const
5913{
5914 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
5915 if (itr != _gossipTextStore.end())
5916 return &itr->second;
5917 return nullptr;
5918}
GossipTextContainer _gossipTextStore
Definition: ObjectMgr.h:1470

References _gossipTextStore.

Referenced by LoadGossipMenu().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & ObjectMgr::GetGuidSequenceGenerator ( )
inlineprivate
1451 {
1452 auto itr = _guidGenerators.find(high);
1453 if (itr == _guidGenerators.end())
1454 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
1455
1456 return *itr->second;
1457 }
Definition: ObjectGuid.h:297
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition: ObjectMgr.h:1459

References _guidGenerators.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
5819{
5820 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
5821 if (itr != _instanceTemplateStore.end())
5822 return &(itr->second);
5823
5824 return nullptr;
5825}
InstanceTemplateContainer _instanceTemplateStore
Definition: ObjectMgr.h:1515

References _instanceTemplateStore.

◆ GetItemLocale()

ItemLocale const * ObjectMgr::GetItemLocale ( uint32  entry) const
inline
1232 {
1233 ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
1234 if (itr == _itemLocaleStore.end()) return nullptr;
1235 return &itr->second;
1236 }
ItemLocaleContainer _itemLocaleStore
Definition: ObjectMgr.h:1582

References _itemLocaleStore.

◆ GetItemSetNameEntry()

ItemSetNameEntry const * ObjectMgr::GetItemSetNameEntry ( uint32  itemId)
inline
780 {
781 ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
782 if (itr != _itemSetNameStore.end())
783 return &itr->second;
784 return nullptr;
785 }
ItemSetNameContainer _itemSetNameStore
Definition: ObjectMgr.h:1553

References _itemSetNameStore.

◆ GetItemSetNameLocale()

ItemSetNameLocale const * ObjectMgr::GetItemSetNameLocale ( uint32  entry) const
inline
1238 {
1239 ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
1240 if (itr == _itemSetNameLocaleStore.end())return nullptr;
1241 return &itr->second;
1242 }
ItemSetNameLocaleContainer _itemSetNameLocaleStore
Definition: ObjectMgr.h:1583

References _itemSetNameLocaleStore.

◆ GetItemTemplate()

ItemTemplate const * ObjectMgr::GetItemTemplate ( uint32  entry)
3270{
3271 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3272}
std::vector< ItemTemplate * > _itemTemplateStoreFast
Definition: ObjectMgr.h:1581

References _itemTemplateStoreFast.

Referenced by LoadAccessRequirements(), LoadFactionChangeItems(), LoadItemTemplates(), LoadPlayerInfo(), and LoadScripts().

◆ GetItemTemplateStore()

ItemTemplateContainer const * ObjectMgr::GetItemTemplateStore ( ) const
inline
776{ return &_itemTemplateStore; }
ItemTemplateContainer _itemTemplateStore
Definition: ObjectMgr.h:1580

References _itemTemplateStore.

◆ GetItemTemplateStoreFast()

std::vector< ItemTemplate * > const * ObjectMgr::GetItemTemplateStoreFast ( ) const
inline
777{ return &_itemTemplateStoreFast; }

References _itemTemplateStoreFast.

◆ GetLinkedRespawnGuid()

ObjectGuid ObjectMgr::GetLinkedRespawnGuid ( ObjectGuid  guid) const
inline
1205 {
1206 LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid);
1207 if (itr == _linkedRespawnStore.end())
1208 return ObjectGuid::Empty;
1209 return itr->second;
1210 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
LinkedRespawnContainer _linkedRespawnStore
Definition: ObjectMgr.h:1570

References _linkedRespawnStore, and ObjectGuid::Empty.

◆ GetLocaleString() [1/2]

static void ObjectMgr::GetLocaleString ( const std::vector< std::string > &  data,
int  loc_idx,
std::string &  value 
)
inlinestatic
1413 {
1414 if (data.size() > std::size_t(loc_idx) && !data[loc_idx].empty())
1415 value = data[loc_idx];
1416 }

◆ GetLocaleString() [2/2]

◆ GetMailLevelReward()

MailLevelReward const * ObjectMgr::GetMailLevelReward ( uint32  level,
uint32  raceMask 
)
inline
1136 {
1137 MailLevelRewardContainer::const_iterator map_itr = _mailLevelRewardStore.find(level);
1138 if (map_itr == _mailLevelRewardStore.end())
1139 return nullptr;
1140
1141 for (const auto & set_itr : map_itr->second)
1142 if (set_itr.raceMask & raceMask)
1143 return &set_itr;
1144
1145 return nullptr;
1146 }
MailLevelRewardContainer _mailLevelRewardStore
Definition: ObjectMgr.h:1522

References _mailLevelRewardStore.

◆ GetMapEntranceTrigger()

AreaTriggerTeleport const * ObjectMgr::GetMapEntranceTrigger ( uint32  Map) const

Searches for the areatrigger which teleports players to the given map

6899{
6900 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6901 {
6902 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
6903 {
6904 // xinef: no need to check, already done at loading
6905 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
6906 //if (atEntry)
6907 return &itr->second;
6908 }
6909 }
6910 return nullptr;
6911}

References _areaTriggerTeleportStore.

◆ GetMapObjectGuids()

CellObjectGuidsMap const & ObjectMgr::GetMapObjectGuids ( uint16  mapid,
uint8  spawnMode 
)
inline
1161 {
1162 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1163 if (itr1 != _mapObjectGuidsStore.end())
1164 return itr1->second;
1166 }
CellObjectGuidsMap _emptyCellObjectGuidsMap
Definition: ObjectMgr.h:1556

References _emptyCellObjectGuidsMap, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetModuleString() [1/2]

ModuleString const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id 
) const
inline
1291 {
1292 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
1293 ModuleStringContainer::const_iterator itr = _moduleStringStore.find(pairKey);
1294 if (itr == _moduleStringStore.end())
1295 return nullptr;
1296
1297 return &itr->second;
1298 }
ModuleStringContainer _moduleStringStore
Definition: ObjectMgr.h:1589

References _moduleStringStore.

Referenced by GetModuleString().

◆ GetModuleString() [2/2]

std::string const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id,
LocaleConstant  locale 
) const
8631{
8632 ModuleString const* ms = GetModuleString(module, id);
8633 if (ms->Content.size())
8634 {
8635 if (ms->Content.size() > size_t(locale) && !ms->Content[locale].empty())
8636 return &ms->Content[locale];
8637
8638 return &ms->Content[DEFAULT_LOCALE];
8639 }
8640
8641 LOG_ERROR("sql.sql", "Module string module {} id {} not found in DB.", module, id);
8642
8643 return (std::string*)"error";
8644}
Definition: ObjectMgr.h:497
std::vector< std::string > Content
Definition: ObjectMgr.h:498
ModuleString const * GetModuleString(std::string module, uint32 id) const
Definition: ObjectMgr.h:1290

References ModuleString::Content, DEFAULT_LOCALE, GetModuleString(), and LOG_ERROR.

◆ GetNearestTaxiNode()

uint32 ObjectMgr::GetNearestTaxiNode ( float  x,
float  y,
float  z,
uint32  mapid,
uint32  teamId 
)
6483{
6484 bool found = false;
6485 float dist = 10000;
6486 uint32 id = 0;
6487
6488 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
6489 {
6490 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
6491
6492 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
6493 continue;
6494
6495 uint8 field = (uint8)((i - 1) / 32);
6496 uint32 submask = 1 << ((i - 1) % 32);
6497
6498 // skip not taxi network nodes
6499 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
6500 {
6501 continue;
6502 }
6503
6504 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
6505 if (found)
6506 {
6507 if (dist2 < dist)
6508 {
6509 dist = dist2;
6510 id = i;
6511 }
6512 }
6513 else
6514 {
6515 found = true;
6516 dist = dist2;
6517 id = i;
6518 }
6519 }
6520
6521 return id;
6522}
TaxiMask sTaxiNodesMask
Definition: DBCStores.cpp:176
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
static constexpr std::size_t TaxiMaskSize
Definition: DBCStructure.h:2248
Definition: DBCStructure.h:1953
float z
Definition: DBCStructure.h:1958
uint32 map_id
Definition: DBCStructure.h:1955
float x
Definition: DBCStructure.h:1956
float y
Definition: DBCStructure.h:1957
uint32 MountCreatureID[2]
Definition: DBCStructure.h:1961

References TaxiNodesEntry::map_id, TaxiNodesEntry::MountCreatureID, sTaxiNodesMask, sTaxiNodesStore, TaxiMaskSize, TEAM_ALLIANCE, TaxiNodesEntry::x, TaxiNodesEntry::y, and TaxiNodesEntry::z.

◆ GetNpcTextLocale()

NpcTextLocale const * ObjectMgr::GetNpcTextLocale ( uint32  entry) const
inline
1280 {
1281 NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
1282 if (itr == _npcTextLocaleStore.end()) return nullptr;
1283 return &itr->second;
1284 }
NpcTextLocaleContainer _npcTextLocaleStore
Definition: ObjectMgr.h:1587

References _npcTextLocaleStore.

◆ GetNpcTrainerSpells()

TrainerSpellData const * ObjectMgr::GetNpcTrainerSpells ( uint32  entry) const
inline
1354 {
1355 CacheTrainerSpellContainer::const_iterator iter = _cacheTrainerSpellStore.find(entry);
1356 if (iter == _cacheTrainerSpellStore.end())
1357 return nullptr;
1358
1359 return &iter->second;
1360 }

References _cacheTrainerSpellStore.

◆ GetNpcVendorItemList()

VendorItemData const * ObjectMgr::GetNpcVendorItemList ( uint32  entry) const
inline
1363 {
1364 CacheVendorItemContainer::const_iterator iter = _cacheVendorItemStore.find(entry);
1365 if (iter == _cacheVendorItemStore.end())
1366 return nullptr;
1367
1368 return &iter->second;
1369 }

References _cacheVendorItemStore.

Referenced by IsVendorItemValid().

◆ GetPageText()

PageText const * ObjectMgr::GetPageText ( uint32  pageEntry)
5739{
5740 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
5741 if (itr != _pageTextStore.end())
5742 return &(itr->second);
5743
5744 return nullptr;
5745}
PageTextContainer _pageTextStore
Definition: ObjectMgr.h:1514

References _pageTextStore.

Referenced by LoadGameObjectTemplate(), and LoadItemTemplates().

◆ GetPageTextLocale()

PageTextLocale const * ObjectMgr::GetPageTextLocale ( uint32  entry) const
inline
1244 {
1245 PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
1246 if (itr == _pageTextLocaleStore.end()) return nullptr;
1247 return &itr->second;
1248 }
PageTextLocaleContainer _pageTextLocaleStore
Definition: ObjectMgr.h:1588

References _pageTextLocaleStore.

◆ GetPetLevelInfo()

PetLevelInfo const * ObjectMgr::GetPetLevelInfo ( uint32  creature_id,
uint8  level 
) const
3580{
3581 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3582 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
3583
3584 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
3585 if (itr == _petInfoStore.end())
3586 return nullptr;
3587
3588 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
3589}

References _petInfoStore, CONFIG_MAX_PLAYER_LEVEL, and sWorld.

◆ GetPlayerClassInfo()

PlayerClassInfo const * ObjectMgr::GetPlayerClassInfo ( uint32  class_) const
inline
792 {
793 if (class_ >= MAX_CLASSES)
794 return nullptr;
795 return _playerClassInfo[class_];
796 }

References _playerClassInfo, and MAX_CLASSES.

◆ GetPlayerClassLevelInfo()

void ObjectMgr::GetPlayerClassLevelInfo ( uint32  class_,
uint8  level,
PlayerClassLevelInfo info 
) const
4247{
4248 if (level < 1 || class_ >= MAX_CLASSES)
4249 return;
4250
4251 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4252
4253 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4254 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4255
4256 *info = pInfo->levelInfo[level - 1];
4257}
Definition: Player.h:296

References _playerClassInfo, CONFIG_MAX_PLAYER_LEVEL, PlayerClassInfo::levelInfo, MAX_CLASSES, and sWorld.

◆ GetPlayerInfo()

PlayerInfo const * ObjectMgr::GetPlayerInfo ( uint32  race,
uint32  class_ 
) const
10053{
10054 if (race >= MAX_RACES)
10055 return nullptr;
10056 if (class_ >= MAX_CLASSES)
10057 return nullptr;
10058 PlayerInfo const* info = _playerInfo[race][class_];
10059 if (!info)
10060 return nullptr;
10061 return info;
10062}
Definition: Player.h:335

References _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ GetPlayerLevelInfo()

void ObjectMgr::GetPlayerLevelInfo ( uint32  race,
uint32  class_,
uint8  level,
PlayerLevelInfo info 
) const
4260{
4261 if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
4262 return;
4263
4264 PlayerInfo const* pInfo = _playerInfo[race][class_];
4265 if (!pInfo)
4266 return;
4267
4268 if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4269 *info = pInfo->levelInfo[level - 1];
4270 else
4271 BuildPlayerLevelInfo(race, class_, level, info);
4272}
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
Definition: ObjectMgr.cpp:4274

References _playerInfo, BuildPlayerLevelInfo(), CONFIG_MAX_PLAYER_LEVEL, PlayerInfo::levelInfo, MAX_CLASSES, and MAX_RACES.

◆ GetPointOfInterest()

PointOfInterest const * ObjectMgr::GetPointOfInterest ( uint32  id) const
inline
919 {
920 PointOfInterestContainer::const_iterator itr = _pointsOfInterestStore.find(id);
921 if (itr != _pointsOfInterestStore.end())
922 return &itr->second;
923 return nullptr;
924 }
PointOfInterestContainer _pointsOfInterestStore
Definition: ObjectMgr.h:1484

References _pointsOfInterestStore.

Referenced by LoadGossipMenuItems().

◆ GetPointOfInterestLocale()

PointOfInterestLocale const * ObjectMgr::GetPointOfInterestLocale ( uint32  poi_id) const
inline
1262 {
1263 PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id);
1264 if (itr == _pointOfInterestLocaleStore.end()) return nullptr;
1265 return &itr->second;
1266 }
PointOfInterestLocaleContainer _pointOfInterestLocaleStore
Definition: ObjectMgr.h:1592

References _pointOfInterestLocaleStore.

◆ GetQuestForAreaTrigger()

uint32 ObjectMgr::GetQuestForAreaTrigger ( uint32  Trigger_ID) const
inline
833 {
834 QuestAreaTriggerContainer::const_iterator itr = _questAreaTriggerStore.find(Trigger_ID);
835 if (itr != _questAreaTriggerStore.end())
836 return itr->second;
837 return 0;
838 }
QuestAreaTriggerContainer _questAreaTriggerStore
Definition: ObjectMgr.h:1468

References _questAreaTriggerStore.

◆ GetQuestGreeting()

QuestGreeting const * ObjectMgr::GetQuestGreeting ( TypeID  type,
uint32  id 
) const
6213{
6214 uint8 typeIndex;
6215 if (type == TYPEID_UNIT)
6216 typeIndex = 0;
6217 else if (type == TYPEID_GAMEOBJECT)
6218 typeIndex = 1;
6219 else
6220 return nullptr;
6221
6222 std::pair<uint32, uint8> pairKey = std::make_pair(id, typeIndex);
6223 QuestGreetingContainer::const_iterator itr = _questGreetingStore.find(pairKey);
6224 if (itr == _questGreetingStore.end())
6225 return nullptr;
6226
6227 return &itr->second;
6228}
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
QuestGreetingContainer _questGreetingStore
Definition: ObjectMgr.h:1471

References _questGreetingStore, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

◆ GetQuestLocale()

QuestLocale const * ObjectMgr::GetQuestLocale ( uint32  entry) const
inline
1250 {
1251 QuestLocaleContainer::const_iterator itr = _questLocaleStore.find(entry);
1252 if (itr == _questLocaleStore.end()) return nullptr;
1253 return &itr->second;
1254 }
QuestLocaleContainer _questLocaleStore
Definition: ObjectMgr.h:1584

References _questLocaleStore.

◆ GetQuestMoneyReward()

uint32 ObjectMgr::GetQuestMoneyReward ( uint8  level,
uint32  questMoneyDifficulty 
) const
10189{
10190 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
10191 {
10192 auto const& itr = _questMoneyRewards.find(level);
10193 if (itr != _questMoneyRewards.end())
10194 {
10195 return itr->second.at(questMoneyDifficulty);
10196 }
10197 }
10198
10199 return 0;
10200}
static constexpr uint32 MAX_QUEST_MONEY_REWARDS
Definition: ObjectMgr.h:715
QuestMoneyRewardStore _questMoneyRewards
Definition: ObjectMgr.h:1612

References _questMoneyRewards, and MAX_QUEST_MONEY_REWARDS.

◆ GetQuestOfferRewardLocale()

QuestOfferRewardLocale const * ObjectMgr::GetQuestOfferRewardLocale ( uint32  entry) const
inline
1268 {
1269 auto itr = _questOfferRewardLocaleStore.find(entry);
1270 if (itr == _questOfferRewardLocaleStore.end()) return nullptr;
1271 return &itr->second;
1272 }
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
Definition: ObjectMgr.h:1585

References _questOfferRewardLocaleStore.

◆ GetQuestPOIVector()

QuestPOIVector const * ObjectMgr::GetQuestPOIVector ( uint32  questId)
inline
927 {
928 QuestPOIContainer::const_iterator itr = _questPOIStore.find(questId);
929 if (itr != _questPOIStore.end())
930 return &itr->second;
931 return nullptr;
932 }
QuestPOIContainer _questPOIStore
Definition: ObjectMgr.h:1486

References _questPOIStore.

◆ GetQuestRequestItemsLocale()

QuestRequestItemsLocale const * ObjectMgr::GetQuestRequestItemsLocale ( uint32  entry) const
inline
1274 {
1275 auto itr = _questRequestItemsLocaleStore.find(entry);
1276 if (itr == _questRequestItemsLocaleStore.end()) return nullptr;
1277 return &itr->second;
1278 }
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
Definition: ObjectMgr.h:1586

References _questRequestItemsLocaleStore.

◆ GetQuestTemplate()

Quest const * ObjectMgr::GetQuestTemplate ( uint32  quest_id) const
inline
826 {
827 return quest_id < _questTemplatesFast.size() ? _questTemplatesFast[quest_id] : nullptr;
828 }
std::vector< Quest * > _questTemplatesFast
Definition: ObjectMgr.h:1462

References _questTemplatesFast.

Referenced by LoadAccessRequirements(), LoadQuestAreaTriggers(), LoadQuests(), and LoadScripts().

◆ GetQuestTemplates()

QuestMap const & ObjectMgr::GetQuestTemplates ( ) const
inline
830{ return _questTemplates; }

References _questTemplates.

◆ GetRepRewardRate()

RepRewardRate const * ObjectMgr::GetRepRewardRate ( uint32  factionId) const
inline
891 {
892 RepRewardRateContainer::const_iterator itr = _repRewardRateStore.find(factionId);
893 if (itr != _repRewardRateStore.end())
894 return &itr->second;
895
896 return nullptr;
897 }
RepRewardRateContainer _repRewardRateStore
Definition: ObjectMgr.h:1478

References _repRewardRateStore.

◆ GetRepSpilloverTemplate()

RepSpilloverTemplate const * ObjectMgr::GetRepSpilloverTemplate ( uint32  factionId) const
inline
910 {
911 RepSpilloverTemplateContainer::const_iterator itr = _repSpilloverTemplateStore.find(factionId);
912 if (itr != _repSpilloverTemplateStore.end())
913 return &itr->second;
914
915 return nullptr;
916 }
RepSpilloverTemplateContainer _repSpilloverTemplateStore
Definition: ObjectMgr.h:1480

References _repSpilloverTemplateStore.

◆ GetReputationOnKilEntry()

ReputationOnKillEntry const * ObjectMgr::GetReputationOnKilEntry ( uint32  id) const
inline
900 {
901 RepOnKillContainer::const_iterator itr = _repOnKillStore.find(id);
902 if (itr != _repOnKillStore.end())
903 return &itr->second;
904 return nullptr;
905 }
RepOnKillContainer _repOnKillStore
Definition: ObjectMgr.h:1479

References _repOnKillStore.

◆ GetScriptId()

uint32 ObjectMgr::GetScriptId ( std::string const &  name)
9543{
9544 // use binary search to find the script name in the sorted vector
9545 // assume "" is the first element
9546 if (name.empty())
9547 return 0;
9548
9549 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
9550 if (itr == _scriptNamesStore.end() || (*itr != name))
9551 return 0;
9552
9553 return uint32(itr - _scriptNamesStore.begin());
9554}
ScriptNameContainer _scriptNamesStore
Definition: ObjectMgr.h:1503

References _scriptNamesStore.

Referenced by LoadAreaTriggerScripts(), LoadCreatures(), LoadCreatureTemplate(), LoadGameobjects(), LoadGameObjectTemplate(), and LoadSpellScriptNames().

◆ GetScriptName()

std::string const & ObjectMgr::GetScriptName ( uint32  id) const
9537{
9538 static std::string const empty = "";
9539 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
9540}

References _scriptNamesStore.

Referenced by ValidateSpellScripts().

◆ GetScriptNames()

ScriptNameContainer & ObjectMgr::GetScriptNames ( )
inline
1376{ return _scriptNamesStore; }

References _scriptNamesStore.

◆ GetSpellClickInfoMapBounds()

SpellClickInfoMapBounds ObjectMgr::GetSpellClickInfoMapBounds ( uint32  creature_id) const
inline
1381 {
1382 return _spellClickInfoStore.equal_range(creature_id);
1383 }
SpellClickInfoContainer _spellClickInfoStore
Definition: ObjectMgr.h:1505

References _spellClickInfoStore.

◆ GetSpellScriptsBounds()

SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds ( uint32  spell_id)
8780{
8781 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
8782}
std::pair< SpellScriptsContainer::iterator, SpellScriptsContainer::iterator > SpellScriptsBounds
Definition: ObjectMgr.h:389
SpellScriptsContainer _spellScriptsStore
Definition: ObjectMgr.h:1507

References _spellScriptsStore.

◆ GetSummonGroup()

std::vector< TempSummonData > const * ObjectMgr::GetSummonGroup ( uint32  summonerId,
SummonerType  summonerType,
uint8  group 
) const
inline

Gets temp summon data for all creatures of specified group.

Parameters
summonerIdSummoner's entry.
summonerTypeSummoner's type, see SummonerType for available types.
groupId of required group.
Returns
null if group was not found, otherwise reference to the creature group data
1178 {
1179 TempSummonDataContainer::const_iterator itr = _tempSummonDataStore.find(TempSummonGroupKey(summonerId, summonerType, group));
1180 if (itr != _tempSummonDataStore.end())
1181 return &itr->second;
1182
1183 return nullptr;
1184 }
Key for storing temp summon data in TempSummonDataContainer.
Definition: ObjectMgr.h:67
TempSummonDataContainer _tempSummonDataStore
Stores temp summon data grouped by summoner's entry, summoner's type and group id.
Definition: ObjectMgr.h:1577

References _tempSummonDataStore.

◆ GetTaxiMountDisplayId()

uint32 ObjectMgr::GetTaxiMountDisplayId ( uint32  id,
TeamId  teamId,
bool  allowed_alt_team = false 
)
6549{
6550 CreatureModel mountModel;
6551 CreatureTemplate const* mount_info = nullptr;
6552
6553 // select mount creature id
6554 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
6555 if (node)
6556 {
6557 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
6558
6559 // Fix for Alliance not being able to use Acherus taxi
6560 // only one mount type for both sides
6561 if (mount_entry == 0 && allowed_alt_team)
6562 {
6563 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
6564 mount_entry = node->MountCreatureID[teamId];
6565 }
6566
6567 mount_info = GetCreatureTemplate(mount_entry);
6568 if (mount_info)
6569 {
6570 CreatureModel const* model = mount_info->GetRandomValidModel();
6571 if (!model)
6572 {
6573 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
6574 return 0;
6575 }
6576 mountModel = *model;
6577 }
6578 }
6579
6580 // minfo is not actually used but the mount_id was updated
6581 GetCreatureModelRandomGender(&mountModel, mount_info);
6582
6583 return mountModel.CreatureDisplayID;
6584}
CreatureModel const * GetRandomValidModel() const
Definition: Creature.cpp:127
CreatureModelInfo const * GetCreatureModelRandomGender(CreatureModel *model, CreatureTemplate const *creatureTemplate) const
Definition: ObjectMgr.cpp:1679

References CreatureModel::CreatureDisplayID, GetCreatureModelRandomGender(), GetCreatureTemplate(), CreatureTemplate::GetRandomValidModel(), LOG_ERROR, TaxiNodesEntry::MountCreatureID, sTaxiNodesStore, and TEAM_ALLIANCE.

◆ GetTaxiPath()

void ObjectMgr::GetTaxiPath ( uint32  source,
uint32  destination,
uint32 path,
uint32 cost 
)
6525{
6526 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
6527 if (src_i == sTaxiPathSetBySource.end())
6528 {
6529 path = 0;
6530 cost = 0;
6531 return;
6532 }
6533
6534 TaxiPathSetForSource& pathSet = src_i->second;
6535
6536 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
6537 if (dest_i == pathSet.end())
6538 {
6539 path = 0;
6540 cost = 0;
6541 return;
6542 }
6543
6544 cost = dest_i->second->price;
6545 path = dest_i->second->ID;
6546}
TaxiPathSetBySource sTaxiPathSetBySource
Definition: DBCStores.cpp:183
std::map< uint32, TaxiPathEntry const * > TaxiPathSetForSource
Definition: DBCStructure.h:2242

References sTaxiPathSetBySource.

◆ GetVehicleAccessoryList()

VehicleAccessoryList const * ObjectMgr::GetVehicleAccessoryList ( Vehicle veh) const
10036{
10037 if (Creature* cre = veh->GetBase()->ToCreature())
10038 {
10039 // Give preference to GUID-based accessories
10040 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
10041 if (itr != _vehicleAccessoryStore.end())
10042 return &itr->second;
10043 }
10044
10045 // Otherwise return entry-based
10046 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
10047 if (itr != _vehicleTemplateAccessoryStore.end())
10048 return &itr->second;
10049 return nullptr;
10050}
Creature * ToCreature()
Definition: Object.h:202
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:37
uint32 GetCreatureEntry() const
Definition: Vehicle.h:39
VehicleAccessoryContainer _vehicleAccessoryStore
Definition: ObjectMgr.h:1510
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
Definition: ObjectMgr.h:1509

References _vehicleAccessoryStore, _vehicleTemplateAccessoryStore, Vehicle::GetBase(), Vehicle::GetCreatureEntry(), and Object::ToCreature().

◆ GetXPForLevel()

uint32 ObjectMgr::GetXPForLevel ( uint8  level) const
7407{
7408 if (level < _playerXPperLevel.size())
7409 return _playerXPperLevel[level];
7410 return 0;
7411}
PlayerXPperLevel _playerXPperLevel
Definition: ObjectMgr.h:1537

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
5686{
5687 uint32 limit = sSpellStore.GetNumRows();
5688 for(uint32 i = 0; i <= limit; ++i)
5689 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
5690 {
5691 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
5692 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
5693 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
5694 }
5695}
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)

References SpellMgr::ComputeIsSpellValid(), sSpellMgr, and sSpellStore.

◆ instance()

ObjectMgr * ObjectMgr::instance ( )
static
375{
376 static ObjectMgr instance;
377 return &instance;
378}
Definition: ObjectMgr.h:722
static ObjectMgr * instance()
Definition: ObjectMgr.cpp:374

References instance().

Referenced by instance().

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
10016{
10017 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
10018 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
10019}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition: SharedDefines.h:1571

References GAMEOBJECT_TYPE_TRANSPORT, GetGameObjectTemplate(), and GameObjectTemplate::type.

◆ IsProfanityName()

bool ObjectMgr::IsProfanityName ( std::string_view  name) const
8267{
8268 // pussywizard
8269 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8270 return true;
8271
8272 std::wstring wstr;
8273 if (!Utf8toWStr (name, wstr))
8274 return false;
8275
8276 wstrToLower(wstr);
8277
8278 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
8279}

References _profanityNamesStore, Utf8toWStr(), and wstrToLower().

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
8164{
8165 // pussywizard
8166 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8167 return true;
8168
8169 std::wstring wstr;
8170 if (!Utf8toWStr (name, wstr))
8171 return false;
8172
8173 wstrToLower(wstr);
8174
8175 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
8176}

References _reservedNamesStore, Utf8toWStr(), and wstrToLower().

Referenced by AddReservedPlayerName().

◆ IsTavernAreaTrigger()

bool ObjectMgr::IsTavernAreaTrigger ( uint32  triggerID,
uint32  faction 
) const
inline
841 {
842 auto itr = _tavernAreaTriggerStore.find(triggerID);
843 if (itr != _tavernAreaTriggerStore.end())
844 {
845 return (itr->second & faction) != 0;
846 }
847
848 return false;
849 }
TavernAreaTriggerContainer _tavernAreaTriggerStore
Definition: ObjectMgr.h:1469

References _tavernAreaTriggerStore.

◆ IsTransportMap()

bool ObjectMgr::IsTransportMap ( uint32  mapId) const
inline
1432{ return _transportMaps.count(mapId) != 0; }
std::set< uint32 > _transportMaps
Definition: ObjectMgr.h:1610

References _transportMaps.

◆ IsValidChannelName()

bool ObjectMgr::IsValidChannelName ( std::string const &  name)
static
8440{
8441 std::wstring wname;
8442 if (!Utf8toWStr(name, wname))
8443 return false;
8444
8445 if (wname.size() > MAX_CHANNEL_NAME)
8446 return false;
8447
8448 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
8449
8450 return isValidString(wname, strictMask, true);
8451}
#define MAX_CHANNEL_NAME
Definition: ObjectMgr.h:687
@ CONFIG_STRICT_CHANNEL_NAMES
Definition: IWorld.h:226

References CONFIG_STRICT_CHANNEL_NAMES, isValidString(), MAX_CHANNEL_NAME, sWorld, and Utf8toWStr().

◆ IsValidCharterName()

bool ObjectMgr::IsValidCharterName ( std::string_view  name)
static
8414{
8415 std::wstring wname;
8416 if (!Utf8toWStr(name, wname))
8417 return false;
8418
8419 if (wname.size() > MAX_CHARTER_NAME)
8420 return false;
8421
8422 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
8423 if (wname.size() < minName)
8424 return false;
8425
8426 // Check Reserved Name
8427 if (sObjectMgr->IsReservedName(name))
8428 return false;
8429
8430 // Check Profanity Name
8431 if (sObjectMgr->IsProfanityName(name))
8432 return false;
8433
8434 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
8435
8436 return isValidString(wname, strictMask, true);
8437}
#define MAX_CHARTER_NAME
Definition: ObjectMgr.h:686
@ CONFIG_MIN_CHARTER_NAME
Definition: IWorld.h:229
@ CONFIG_STRICT_CHARTER_NAMES
Definition: IWorld.h:225

References CONFIG_MIN_CHARTER_NAME, CONFIG_STRICT_CHARTER_NAMES, isValidString(), MAX_CHARTER_NAME, sObjectMgr, sWorld, and Utf8toWStr().

Referenced by WorldSession::HandlePetitionBuyOpcode(), WorldSession::HandlePetitionRenameOpcode(), ArenaTeam::SetName(), and Guild::SetName().

◆ IsVendorItemValid()

bool ObjectMgr::IsVendorItemValid ( uint32  vendor_entry,
uint32  item,
int32  maxcount,
uint32  ptime,
uint32  ExtendedCost,
Player player = nullptr,
std::set< uint32 > *  skip_vendors = nullptr,
uint32  ORnpcflag = 0 
) const
9401{
9402 /*
9403 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry);
9404 if (!cInfo)
9405 {
9406 if (player)
9407 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9408 else
9409 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
9410 return false;
9411 }
9412
9413 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
9414 {
9415 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
9416 {
9417 if (player)
9418 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9419 else
9420 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
9421
9422 if (skip_vendors)
9423 skip_vendors->insert(vendor_entry);
9424 }
9425 return false;
9426 }
9427 */
9428
9429 if (!sObjectMgr->GetItemTemplate(item_id))
9430 {
9431 if (player)
9433 else
9434 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
9435 return false;
9436 }
9437
9438 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
9439 {
9440 if (player)
9442 else
9443 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
9444 return false;
9445 }
9446
9447 if (maxcount > 0 && incrtime == 0)
9448 {
9449 if (player)
9450 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 ({}) but IncrTime == 0", maxcount);
9451 else
9452 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has `maxcount` ({}) for item {} of vendor (Entry: {}) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry);
9453 return false;
9454 }
9455 else if (maxcount == 0 && incrtime > 0)
9456 {
9457 if (player)
9458 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
9459 else
9460 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has `maxcount`=0 for item {} of vendor (Entry: {}) but `incrtime`<>0, ignore", item_id, vendor_entry);
9461 return false;
9462 }
9463
9464 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
9465 if (!vItems)
9466 return true; // later checks for non-empty lists
9467
9468 if (vItems->FindItemCostPair(item_id, ExtendedCost))
9469 {
9470 if (player)
9471 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
9472 else
9473 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
9474 return false;
9475 }
9476
9477 return true;
9478}
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
@ LANG_ITEM_ALREADY_IN_LIST
Definition: Language.h:248
@ LANG_ITEM_NOT_FOUND
Definition: Language.h:245
@ LANG_EXTENDED_COST_NOT_EXIST
Definition: Language.h:372
Definition: Chat.h:39
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost) const
Definition: Creature.cpp:111
WorldSession * GetSession() const
Definition: Player.h:1978
VendorItemData const * GetNpcVendorItemList(uint32 entry) const
Definition: ObjectMgr.h:1362

References VendorItemData::FindItemCostPair(), GetNpcVendorItemList(), Player::GetSession(), LANG_EXTENDED_COST_NOT_EXIST, LANG_ITEM_ALREADY_IN_LIST, LANG_ITEM_NOT_FOUND, LOG_ERROR, ChatHandler::PSendSysMessage(), sItemExtendedCostStore, and sObjectMgr.

Referenced by LoadReferenceVendor(), and LoadVendors().

◆ LoadAccessRequirements()

void ObjectMgr::LoadAccessRequirements ( )
6698{
6699 uint32 oldMSTime = getMSTime();
6700
6701 if (!_accessRequirementStore.empty())
6702 {
6703 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
6704 {
6705 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
6706 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
6707 {
6708 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
6709 {
6710 delete* questItr;
6711 }
6712
6713 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
6714 {
6715 delete* achievementItr;
6716 }
6717
6718 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
6719 {
6720 delete* itemsItr;
6721 }
6722
6723 delete difficultiesItr->second;
6724 }
6725 }
6726
6727 _accessRequirementStore.clear(); // need for reload case
6728 }
6729 // 0 1 2 3 4 5
6730 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
6731 if (!access_template_result)
6732 {
6733 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
6734 LOG_INFO("server.loading", " ");
6735 return;
6736 }
6737
6738 uint32 count = 0;
6739 uint32 countProgressionRequirements = 0;
6740
6741 do
6742 {
6743 Field* fields = access_template_result->Fetch();
6744
6745 //Get the common variables for the access requirements
6746 uint8 dungeon_access_id = fields[0].Get<uint8>();
6747 uint32 mapid = fields[1].Get<uint32>();
6748 uint8 difficulty = fields[2].Get<uint8>();
6749
6750 //Set up the access requirements
6752 ar->levelMin = fields[3].Get<uint8>();
6753 ar->levelMax = fields[4].Get<uint8>();
6754 ar->reqItemLevel = fields[5].Get<uint16>();
6755
6756 // 0 1 2 3 4 6
6757 QueryResult progression_requirements_results = WorldDatabase.Query("SELECT requirement_type, requirement_id, requirement_note, faction, priority, leader_only FROM dungeon_access_requirements where dungeon_access_id = {}", dungeon_access_id);
6758 if (progression_requirements_results)
6759 {
6760 do
6761 {
6762 Field* progression_requirement_row = progression_requirements_results->Fetch();
6763
6764 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
6765 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
6766 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
6767 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
6768 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
6769 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
6770
6771 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
6772 progression_requirement->id = requirement_id;
6773 progression_requirement->note = requirement_note;
6774 progression_requirement->faction = (TeamId)requirement_faction;
6775 progression_requirement->priority = requirement_priority;
6776 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
6777
6778 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
6779
6780 switch (requirement_type)
6781 {
6782 case 0:
6783 {
6784 //Achievement
6785 if (!sAchievementStore.LookupEntry(progression_requirement->id))
6786 {
6787 LOG_ERROR("sql.sql", "Required achievement {} for faction {} does not exist for map {} difficulty {}, remove or fix this achievement requirement.", progression_requirement->id, requirement_faction, mapid, difficulty);
6788 break;
6789 }
6790
6791 currentRequirementsList = &ar->achievements;
6792 break;
6793 }
6794 case 1:
6795 {
6796 //Quest
6797 if (!GetQuestTemplate(progression_requirement->id))
6798 {
6799 LOG_ERROR("sql.sql", "Required quest {} for faction {} does not exist for map {} difficulty {}, remove or fix this quest requirement.", progression_requirement->id, requirement_faction, mapid, difficulty);
6800 break;
6801 }
6802
6803 currentRequirementsList = &ar->quests;
6804 break;
6805 }
6806 case 2:
6807 {
6808 //Item
6809 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
6810 if (!pProto)
6811 {
6812 LOG_ERROR("sql.sql", "Required item {} for faction {} does not exist for map {} difficulty {}, remove or fix this item requirement.", progression_requirement->id, requirement_faction, mapid, difficulty);
6813 break;
6814 }
6815
6816 currentRequirementsList = &ar->items;
6817 break;
6818 }
6819 default:
6820 LOG_ERROR("sql.sql", "requirement_type of {} is not valid for map {} difficulty {}. Please use 0 for achievements, 1 for quest, 2 for items or remove this entry from the db.", requirement_type, mapid, difficulty);
6821 break;
6822 }
6823
6824 //Check if array is valid and delete the progression requirement
6825 if (!currentRequirementsList)
6826 {
6827 delete progression_requirement;
6828 continue;
6829 }
6830
6831 //Insert into the array
6832 if (currentRequirementsList->size() > requirement_priority)
6833 {
6834 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
6835 }
6836 else
6837 {
6838 currentRequirementsList->push_back(progression_requirement);
6839 }
6840
6841 } while (progression_requirements_results->NextRow());
6842 }
6843
6844 //Sort all arrays for priority
6845 auto sortFunction = [](const ProgressionRequirement* const a, const ProgressionRequirement* const b) {return a->priority > b->priority; };
6846 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
6847 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
6848 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
6849
6850 countProgressionRequirements += ar->achievements.size();
6851 countProgressionRequirements += ar->quests.size();
6852 countProgressionRequirements += ar->items.size();
6853 count++;
6854
6855 _accessRequirementStore[mapid][difficulty] = ar;
6856 } while (access_template_result->NextRow());
6857
6858 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
6859 LOG_INFO("server.loading", " ");
6860}
#define LOG_WARN(filterType__,...)
Definition: Log.h:160
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
TeamId
Definition: SharedDefines.h:759
Class used to access individual fields of database query result.
Definition: Field.h:99
bool IsNull() const
Definition: Field.h:107
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: ItemTemplate.h:619
Definition: Player.h:933
uint32 priority
Definition: Player.h:937
Definition: Player.h:942
ItemTemplate const * GetItemTemplate(uint32 entry)
Definition: ObjectMgr.cpp:3269
Quest const * GetQuestTemplate(uint32 quest_id) const
Definition: ObjectMgr.h:825

References _accessRequirementStore, Field::Get(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), GetQuestTemplate(), Field::IsNull(), LOG_ERROR, LOG_INFO, LOG_WARN, ProgressionRequirement::priority, sAchievementStore, and WorldDatabase.

◆ LoadAcoreStrings()

bool ObjectMgr::LoadAcoreStrings ( )
8647{
8648 uint32 oldMSTime = getMSTime();
8649
8650 _acoreStringStore.clear(); // for reload case
8651 QueryResult result = WorldDatabase.Query("SELECT entry, content_default, locale_koKR, locale_frFR, locale_deDE, locale_zhCN, locale_zhTW, locale_esES, locale_esMX, locale_ruRU FROM acore_string");
8652 if (!result)
8653 {
8654 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty.");
8655 LOG_INFO("server.loading", " ");
8656 return false;
8657 }
8658
8659 do
8660 {
8661 Field* fields = result->Fetch();
8662
8663 uint32 entry = fields[0].Get<uint32>();
8664
8665 AcoreString& data = _acoreStringStore[entry];
8666
8667 data.Content.resize(DEFAULT_LOCALE + 1);
8668
8669 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
8670 AddLocaleString(fields[i + 1].Get<std::string>(), LocaleConstant(i), data.Content);
8671 } while (result->NextRow());
8672
8673 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8674 LOG_INFO("server.loading", " ");
8675
8676 return true;
8677}
LocaleConstant
Definition: Common.h:65
@ TOTAL_LOCALES
Definition: Common.h:76
static void AddLocaleString(std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
Definition: ObjectMgr.cpp:380

References _acoreStringStore, AddLocaleString(), DEFAULT_LOCALE, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, TOTAL_LOCALES, and WorldDatabase.

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
6587{
6588 uint32 oldMSTime = getMSTime();
6589
6590 _areaTriggerStore.clear();
6591
6592 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
6593
6594 if (!result)
6595 {
6596 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
6597 LOG_INFO("server.loading", " ");
6598 return;
6599 }
6600
6601 uint32 count = 0;
6602
6603 do
6604 {
6605 Field* fields = result->Fetch();
6606
6607 ++count;
6608
6609 AreaTrigger at;
6610
6611 at.entry = fields[0].Get<uint32>();
6612 at.map = fields[1].Get<uint32>();
6613 at.x = fields[2].Get<float>();
6614 at.y = fields[3].Get<float>();
6615 at.z = fields[4].Get<float>();
6616 at.radius = fields[5].Get<float>();
6617 at.length = fields[6].Get<float>();
6618 at.width = fields[7].Get<float>();
6619 at.height = fields[8].Get<float>();
6620 at.orientation = fields[9].Get<float>();
6621
6622 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
6623 if (!mapEntry)
6624 {
6625 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
6626 continue;
6627 }
6628
6629 _areaTriggerStore[at.entry] = at;
6630 } while (result->NextRow());
6631
6632 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6633 LOG_INFO("server.loading", " ");
6634}
float height
Definition: ObjectMgr.h:430
float x
Definition: ObjectMgr.h:424
float y
Definition: ObjectMgr.h:425
float orientation
Definition: ObjectMgr.h:431
float length
Definition: ObjectMgr.h:428
uint32 entry
Definition: ObjectMgr.h:422
float radius
Definition: ObjectMgr.h:427
float z
Definition: ObjectMgr.h:426
float width
Definition: ObjectMgr.h:429

References _areaTriggerStore, AreaTrigger::entry, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), AreaTrigger::height, AreaTrigger::length, LOG_ERROR, LOG_INFO, LOG_WARN, AreaTrigger::map, AreaTrigger::orientation, AreaTrigger::radius, sMapStore, AreaTrigger::width, WorldDatabase, AreaTrigger::x, AreaTrigger::y, and AreaTrigger::z.

◆ LoadAreaTriggerScripts()

void ObjectMgr::LoadAreaTriggerScripts ( )
6445{
6446 uint32 oldMSTime = getMSTime();
6447
6448 _areaTriggerScriptStore.clear(); // need for reload case
6449 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
6450
6451 if (!result)
6452 {
6453 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
6454 LOG_INFO("server.loading", " ");
6455 return;
6456 }
6457
6458 uint32 count = 0;
6459
6460 do
6461 {
6462 ++count;
6463
6464 Field* fields = result->Fetch();
6465
6466 uint32 Trigger_ID = fields[0].Get<uint32>();
6467 std::string scriptName = fields[1].Get<std::string>();
6468
6469 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6470 if (!atEntry)
6471 {
6472 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6473 continue;
6474 }
6475 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
6476 } while (result->NextRow());
6477
6478 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6479 LOG_INFO("server.loading", " ");
6480}
uint32 GetScriptId(std::string const &name)
Definition: ObjectMgr.cpp:9542

References _areaTriggerScriptStore, Field::Get(), GetAreaTrigger(), getMSTime(), GetMSTimeDiffToNow(), GetScriptId(), LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
6637{
6638 uint32 oldMSTime = getMSTime();
6639
6640 _areaTriggerTeleportStore.clear(); // need for reload case
6641
6642 // 0 1 2 3 4 5
6643 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
6644
6645 if (!result)
6646 {
6647 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
6648 LOG_INFO("server.loading", " ");
6649 return;
6650 }
6651
6652 uint32 count = 0;
6653
6654 do
6655 {
6656 Field* fields = result->Fetch();
6657
6658 ++count;
6659
6660 uint32 Trigger_ID = fields[0].Get<uint32>();
6661
6663
6664 at.target_mapId = fields[1].Get<uint16>();
6665 at.target_X = fields[2].Get<float>();
6666 at.target_Y = fields[3].Get<float>();
6667 at.target_Z = fields[4].Get<float>();
6668 at.target_Orientation = fields[5].Get<float>();
6669
6670 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6671 if (!atEntry)
6672 {
6673 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6674 continue;
6675 }
6676
6677 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
6678 if (!mapEntry)
6679 {
6680 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
6681 continue;
6682 }
6683
6684 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
6685 {
6686 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
6687 continue;
6688 }
6689
6690 _areaTriggerTeleportStore[Trigger_ID] = at;
6691 } while (result->NextRow());
6692
6693 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6694 LOG_INFO("server.loading", " ");
6695}
Definition: ObjectMgr.h:412
uint32 target_mapId
Definition: ObjectMgr.h:413

References _areaTriggerTeleportStore, Field::Get(), GetAreaTrigger(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sMapStore, AreaTriggerTeleport::target_mapId, and WorldDatabase.

◆ LoadBroadcastTextLocales()

void ObjectMgr::LoadBroadcastTextLocales ( )
9642{
9643 uint32 oldMSTime = getMSTime();
9644
9645 // 0 1 2 3
9646 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
9647
9648 if (!result)
9649 {
9650 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
9651 LOG_INFO("server.loading", " ");
9652 return;
9653 }
9654
9655 uint32 locales_count = 0;
9656 do
9657 {
9658 Field* fields = result->Fetch();
9659
9660 uint32 id = fields[0].Get<uint32>();
9661
9662 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
9663 if (bct == _broadcastTextStore.end())
9664 {
9665 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
9666 continue;
9667 }
9668
9669 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
9670 if (locale == LOCALE_enUS)
9671 continue;
9672
9673 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
9674 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
9675 locales_count++;
9676 } while (result->NextRow());
9677
9678 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
9679 LOG_INFO("server.loading", " ");
9680}
LocaleConstant GetLocaleByName(const std::string &name)
Definition: Common.cpp:33

References _broadcastTextStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadBroadcastTexts()

void ObjectMgr::LoadBroadcastTexts ( )
9557{
9558 uint32 oldMSTime = getMSTime();
9559
9560 _broadcastTextStore.clear(); // for reload case
9561
9562 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9563 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
9564 if (!result)
9565 {
9566 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
9567 LOG_INFO("server.loading", " ");
9568 return;
9569 }
9570
9571 _broadcastTextStore.rehash(result->GetRowCount());
9572
9573 do
9574 {
9575 Field* fields = result->Fetch();
9576
9577 BroadcastText bct;
9578
9579 bct.Id = fields[0].Get<uint32>();
9580 bct.LanguageID = fields[1].Get<uint32>();
9581 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
9582 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
9583 bct.EmoteId1 = fields[4].Get<uint32>();
9584 bct.EmoteId2 = fields[5].Get<uint32>();
9585 bct.EmoteId3 = fields[6].Get<uint32>();
9586 bct.EmoteDelay1 = fields[7].Get<uint32>();
9587 bct.EmoteDelay2 = fields[8].Get<uint32>();
9588 bct.EmoteDelay3 = fields[9].Get<uint32>();
9589 bct.SoundEntriesId = fields[10].Get<uint32>();
9590 bct.EmotesID = fields[11].Get<uint32>();
9591 bct.Flags = fields[12].Get<uint32>();
9592
9593 if (bct.SoundEntriesId)
9594 {
9595 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
9596 {
9597 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
9598 bct.SoundEntriesId = 0;
9599 }
9600 }
9601
9603 {
9604 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
9606 }
9607
9608 if (bct.EmoteId1)
9609 {
9610 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
9611 {
9612 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
9613 bct.EmoteId1 = 0;
9614 }
9615 }
9616
9617 if (bct.EmoteId2)
9618 {
9619 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
9620 {
9621 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
9622 bct.EmoteId2 = 0;
9623 }
9624 }
9625
9626 if (bct.EmoteId3)
9627 {
9628 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
9629 {
9630 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
9631 bct.EmoteId3 = 0;
9632 }
9633 }
9634
9635 _broadcastTextStore[bct.Id] = bct;
9636 } while (result->NextRow());
9637
9638 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
9639}
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition: ObjectMgr.cpp:251
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
Definition: ObjectMgr.h:435
uint32 EmoteDelay2
Definition: ObjectMgr.h:450
uint32 Id
Definition: ObjectMgr.h:442
std::vector< std::string > FemaleText
Definition: ObjectMgr.h:445
uint32 EmotesID
Definition: ObjectMgr.h:453
uint32 LanguageID
Definition: ObjectMgr.h:443
uint32 EmoteId2
Definition: ObjectMgr.h:447
uint32 EmoteDelay1
Definition: ObjectMgr.h:449
uint32 SoundEntriesId
Definition: ObjectMgr.h:452
std::vector< std::string > MaleText
Definition: ObjectMgr.h:444
uint32 EmoteId3
Definition: ObjectMgr.h:448
uint32 EmoteId1
Definition: ObjectMgr.h:446
uint32 EmoteDelay3
Definition: ObjectMgr.h:451
uint32 Flags
Definition: ObjectMgr.h:454

References _broadcastTextStore, DEFAULT_LOCALE, BroadcastText::EmoteDelay1, BroadcastText::EmoteDelay2, BroadcastText::EmoteDelay3, BroadcastText::EmoteId1, BroadcastText::EmoteId2, BroadcastText::EmoteId3, BroadcastText::EmotesID, BroadcastText::FemaleText, BroadcastText::Flags, Field::Get(), GetLanguageDescByID(), getMSTime(), GetMSTimeDiffToNow(), BroadcastText::Id, LANG_UNIVERSAL, BroadcastText::LanguageID, LOG_DEBUG, LOG_INFO, LOG_WARN, BroadcastText::MaleText, sEmotesStore, BroadcastText::SoundEntriesId, sSoundEntriesStore, and WorldDatabase.

◆ LoadCreatureAddons()

void ObjectMgr::LoadCreatureAddons ( )
1271{
1272 uint32 oldMSTime = getMSTime();
1273
1274 // 0 1 2 3 4 5 6 7
1275 QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_addon");
1276
1277 if (!result)
1278 {
1279 LOG_WARN("server.loading", ">> Loaded 0 creature addon definitions. DB table `creature_addon` is empty.");
1280 LOG_INFO("server.loading", " ");
1281 return;
1282 }
1283
1284 uint32 count = 0;
1285 do
1286 {
1287 Field* fields = result->Fetch();
1288
1289 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1290
1291 CreatureData const* creData = GetCreatureData(guid);
1292 if (!creData)
1293 {
1294 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_addon`", guid);
1295 continue;
1296 }
1297
1298 CreatureAddon& creatureAddon = _creatureAddonStore[guid];
1299
1300 creatureAddon.path_id = fields[1].Get<uint32>();
1301 if (creData->movementType == WAYPOINT_MOTION_TYPE && !creatureAddon.path_id)
1302 {
1303 const_cast<CreatureData*>(creData)->movementType = IDLE_MOTION_TYPE;
1304 LOG_ERROR("sql.sql", "Creature (GUID {}) has movement type set to WAYPOINT_MOTION_TYPE but no path assigned", guid);
1305 }
1306
1307 creatureAddon.mount = fields[2].Get<uint32>();
1308 creatureAddon.bytes1 = fields[3].Get<uint32>();
1309 creatureAddon.bytes2 = fields[4].Get<uint32>();
1310 creatureAddon.emote = fields[5].Get<uint32>();
1311 creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].Get<uint8>());
1312
1313 for (std::string_view aura : Acore::Tokenize(fields[7].Get<std::string_view>(), ' ', false))
1314 {
1315 SpellInfo const* spellInfo = nullptr;
1316
1317 if (Optional<uint32> spellId = Acore::StringTo<uint32>(aura))
1318 {
1319 spellInfo = sSpellMgr->GetSpellInfo(*spellId);
1320 }
1321
1322 if (!spellInfo)
1323 {
1324 LOG_ERROR("sql.sql", "Creature (GUID: {}) has wrong spell '{}' defined in `auras` field in `creature_addon`.", guid, aura);
1325 continue;
1326 }
1327
1328 if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
1329 {
1330 LOG_ERROR("sql.sql", "Creature (GUID: {}) has duplicate aura (spell {}) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
1331 continue;
1332 }
1333
1334 if (spellInfo->GetDuration() > 0)
1335 {
1336 LOG_DEBUG/*ERROR*/("sql.sql", "Creature (Entry: {}) has temporary aura (spell {}) in `auras` field in `creature_template_addon`.", guid, spellInfo->Id);
1337 // continue;
1338 }
1339
1340 creatureAddon.auras.push_back(spellInfo->Id);
1341 }
1342
1343 if (creatureAddon.mount)
1344 {
1345 if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
1346 {
1347 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid displayInfoId ({}) for mount defined in `creature_addon`", guid, creatureAddon.mount);
1348 creatureAddon.mount = 0;
1349 }
1350 }
1351
1352 if (!sEmotesStore.LookupEntry(creatureAddon.emote))
1353 {
1354 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid emote ({}) defined in `creature_addon`.", guid, creatureAddon.emote);
1355 creatureAddon.emote = 0;
1356 }
1357
1358 if (creatureAddon.visibilityDistanceType >= VisibilityDistanceType::Max)
1359 {
1360 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid visibilityDistanceType ({}) defined in `creature_addon`.", guid, AsUnderlyingType(creatureAddon.visibilityDistanceType));
1361 creatureAddon.visibilityDistanceType = VisibilityDistanceType::Normal;
1362 }
1363
1364 ++count;
1365 } while (result->NextRow());
1366
1367 LOG_INFO("server.loading", ">> Loaded {} Creature Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1368 LOG_INFO("server.loading", " ");
1369}
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:619
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
VisibilityDistanceType
Definition: ObjectDefines.h:61
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Tokenize.cpp:20
Definition: CreatureData.h:443
std::vector< uint32 > auras
Definition: CreatureData.h:449
uint32 mount
Definition: CreatureData.h:445
uint32 emote
Definition: CreatureData.h:448
uint32 path_id
Definition: CreatureData.h:444
VisibilityDistanceType visibilityDistanceType
Definition: CreatureData.h:450
uint32 bytes1
Definition: CreatureData.h:446
uint32 bytes2
Definition: CreatureData.h:447
uint32 Id
Definition: SpellInfo.h:320
int32 GetDuration() const
Definition: SpellInfo.cpp:2337

References _creatureAddonStore, AsUnderlyingType(), CreatureAddon::auras, CreatureAddon::bytes1, CreatureAddon::bytes2, CreatureAddon::emote, Field::Get(), GetCreatureData(), SpellInfo::GetDuration(), getMSTime(), GetMSTimeDiffToNow(), SpellInfo::Id, IDLE_MOTION_TYPE, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARN, CreatureAddon::mount, CreatureAddon::path_id, sCreatureDisplayInfoStore, sEmotesStore, sSpellMgr, Acore::Tokenize(), CreatureAddon::visibilityDistanceType, WAYPOINT_MOTION_TYPE, and WorldDatabase.

◆ LoadCreatureClassLevelStats()

void ObjectMgr::LoadCreatureClassLevelStats ( )
9709{
9710 uint32 oldMSTime = getMSTime();
9711
9712 QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2 FROM creature_classlevelstats");
9713
9714 if (!result)
9715 {
9716 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
9717 LOG_INFO("server.loading", " ");
9718 return;
9719 }
9720
9721 uint32 count = 0;
9722 do
9723 {
9724 Field* fields = result->Fetch();
9725
9726 uint8 Level = fields[0].Get<uint8>();
9727 uint8 Class = fields[1].Get<uint8>();
9728
9729 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
9730 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
9731
9732 CreatureBaseStats stats;
9733
9734 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
9735 {
9736 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
9737
9738 if (stats.BaseHealth[i] == 0)
9739 {
9740 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
9741 stats.BaseHealth[i] = 1;
9742 }
9743
9744 // xinef: if no data is available, get them from lower expansions
9745 if (stats.BaseHealth[i] <= 1)
9746 {
9747 for (uint8 j = i; j > 0;)
9748 {
9749 --j;
9750 if (stats.BaseHealth[j] > 1)
9751 {
9752 stats.BaseHealth[i] = stats.BaseHealth[j];
9753 break;
9754 }
9755 }
9756 }
9757
9758 stats.BaseDamage[i] = fields[9 + i].Get<float>();
9759 if (stats.BaseDamage[i] < 0.0f)
9760 {
9761 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
9762 stats.BaseDamage[i] = 0.0f;
9763 }
9764 }
9765
9766 stats.BaseMana = fields[5].Get<uint32>();
9767 stats.BaseArmor = fields[6].Get<uint32>();
9768
9769 stats.AttackPower = fields[7].Get<uint32>();
9770 stats.RangedAttackPower = fields[8].Get<uint32>();
9771
9772 _creatureBaseStatsStore[MAKE_PAIR16(Level, Class)] = stats;
9773
9774 ++count;
9775 } while (result->NextRow());
9776
9777 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
9778 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
9779 {
9780 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
9781 {
9782 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
9783 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
9784 }
9785 }
9786
9787 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9788 LOG_INFO("server.loading", " ");
9789}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: CreatureData.h:295
uint32 BaseMana
Definition: CreatureData.h:308
float BaseDamage[MAX_EXPANSIONS]
Definition: CreatureData.h:312
uint32 RangedAttackPower
Definition: CreatureData.h:311
uint32 AttackPower
Definition: CreatureData.h:310
uint32 BaseHealth[MAX_EXPANSIONS]
Definition: CreatureData.h:307
float BaseArmor
Definition: CreatureData.h:309

References _creatureBaseStatsStore, CreatureBaseStats::AttackPower, CreatureBaseStats::BaseArmor, CreatureBaseStats::BaseDamage, CreatureBaseStats::BaseHealth, CreatureBaseStats::BaseMana, CLASSMASK_ALL_CREATURES, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAKE_PAIR16(), MAX_EXPANSIONS, CreatureBaseStats::RangedAttackPower, sObjectMgr, and WorldDatabase.

◆ LoadCreatureCustomIDs()

void ObjectMgr::LoadCreatureCustomIDs ( )

Load config option Creatures.CustomIDs into Store.

948{
949 // Hack for modules
950 std::string stringCreatureIds = sConfigMgr->GetOption<std::string>("Creatures.CustomIDs", "190010,55005,999991,25462,98888,601014,34567,34568");
951 std::vector<std::string_view> CustomCreatures = Acore::Tokenize(stringCreatureIds, ',', false);
952
953 for (auto& itr : CustomCreatures)
954 {
955 _creatureCustomIDsStore.push_back(Acore::StringTo<uint32>(itr).value());
956 }
957}
#define sConfigMgr
Definition: Config.h:74

References _creatureCustomIDsStore, sConfigMgr, and Acore::Tokenize().

◆ LoadCreatureLocales()

void ObjectMgr::LoadCreatureLocales ( )
392{
393 uint32 oldMSTime = getMSTime();
394
395 _creatureLocaleStore.clear(); // need for reload case
396
397 // 0 1 2 3
398 QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale");
399 if (!result)
400 return;
401
402 do
403 {
404 Field* fields = result->Fetch();
405
406 uint32 ID = fields[0].Get<uint32>();
407
408 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
409 if (locale == LOCALE_enUS)
410 continue;
411
413 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
414 AddLocaleString(fields[3].Get<std::string>(), locale, data.Title);
415 } while (result->NextRow());
416
417 LOG_INFO("server.loading", ">> Loaded {} Creature Locale Strings in {} ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
418}
Definition: CreatureData.h:346
std::vector< std::string > Title
Definition: CreatureData.h:348
std::vector< std::string > Name
Definition: CreatureData.h:347

References _creatureLocaleStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, CreatureLocale::Name, CreatureLocale::Title, and WorldDatabase.

◆ LoadCreatureModelInfo()

void ObjectMgr::LoadCreatureModelInfo ( )
1712{
1713 uint32 oldMSTime = getMSTime();
1714
1715 // 0 1 2 3 4
1716 QueryResult result = WorldDatabase.Query("SELECT DisplayID, BoundingRadius, CombatReach, Gender, DisplayID_Other_Gender FROM creature_model_info");
1717
1718 if (!result)
1719 {
1720 LOG_WARN("server.loading", ">> Loaded 0 creature model definitions. DB table `creature_model_info` is empty.");
1721 LOG_INFO("server.loading", " ");
1722 return;
1723 }
1724
1725 _creatureModelStore.rehash(result->GetRowCount());
1726 uint32 count = 0;
1727
1728 // List of ModelDataIDs that use Invisible models
1729 uint32 triggerCreatureModelDataID[14] = { 1731, 1752, 2206, 2296, 2372, 2382, 2481, 2512, 2513, 2611, 2636, 2790, 3230, 3274 };
1730
1731 do
1732 {
1733 Field* fields = result->Fetch();
1734
1735 uint32 displayId = fields[0].Get<uint32>();
1736 CreatureDisplayInfoEntry const* creatureDisplay = sCreatureDisplayInfoStore.LookupEntry(displayId);
1737 uint32 modelId = fields[0].Get<uint32>();
1738
1739 CreatureModelInfo& modelInfo = _creatureModelStore[modelId];
1740
1741 modelInfo.bounding_radius = fields[1].Get<float>();
1742 modelInfo.combat_reach = fields[2].Get<float>();
1743 modelInfo.gender = fields[3].Get<uint8>();
1744 modelInfo.modelid_other_gender = fields[4].Get<uint32>();
1745 modelInfo.is_trigger = false;
1746
1747 // Checks
1748
1749 if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
1750 LOG_ERROR("sql.sql", "Table `creature_model_info` has model for not existed display id ({}).", modelId);
1751
1752 if (modelInfo.gender > GENDER_NONE)
1753 {
1754 LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender ({}) for display id ({}).", uint32(modelInfo.gender), modelId);
1755 modelInfo.gender = GENDER_MALE;
1756 }
1757
1758 if (modelInfo.modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.modelid_other_gender))
1759 {
1760 LOG_ERROR("sql.sql", "Table `creature_model_info` has not existed alt.gender model ({}) for existed display id ({}).", modelInfo.modelid_other_gender, modelId);
1761 modelInfo.modelid_other_gender = 0;
1762 }
1763
1764 if (modelInfo.combat_reach < 0.1f)
1765 modelInfo.combat_reach = DEFAULT_COMBAT_REACH;
1766
1767 if (CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(creatureDisplay->ModelId))
1768 {
1769 for (uint32 i = 0; i < 14; i++)
1770 {
1771 if (modelData->Id == triggerCreatureModelDataID[i])
1772 {
1773 modelInfo.is_trigger = true;
1774 break;
1775 }
1776 }
1777 }
1778
1779 ++count;
1780 } while (result->NextRow());
1781
1782 LOG_INFO("server.loading", ">> Loaded {} Creature Model Based Info in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1783 LOG_INFO("server.loading", " ");
1784}
DBCStorage< CreatureModelDataEntry > sCreatureModelDataStore(CreatureModelDatafmt)
#define DEFAULT_COMBAT_REACH
Definition: ObjectDefines.h:46
@ GENDER_MALE
Definition: SharedDefines.h:61
@ GENDER_NONE
Definition: SharedDefines.h:63
Definition: DBCStructure.h:721
Definition: DBCStructure.h:775

References _creatureModelStore, DEFAULT_COMBAT_REACH, GENDER_MALE, GENDER_NONE, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sCreatureDisplayInfoStore, sCreatureModelDataStore, and WorldDatabase.

◆ LoadCreatureMovementOverrides()

void ObjectMgr::LoadCreatureMovementOverrides ( )
1560{
1561 uint32 oldMSTime = getMSTime();
1562
1564
1565 // Load the data from creature_movement_override and if NULL fallback to creature_template_movement
1566 QueryResult result = WorldDatabase.Query("SELECT cmo.SpawnId,"
1567 "COALESCE(cmo.Ground, ctm.Ground),"
1568 "COALESCE(cmo.Swim, ctm.Swim),"
1569 "COALESCE(cmo.Flight, ctm.Flight),"
1570 "COALESCE(cmo.Rooted, ctm.Rooted),"
1571 "COALESCE(cmo.Chase, ctm.Chase),"
1572 "COALESCE(cmo.Random, ctm.Random),"
1573 "COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) "
1574 "FROM creature_movement_override AS cmo "
1575 "LEFT JOIN creature AS c ON c.guid = cmo.SpawnId "
1576 "LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id1");
1577 if (!result)
1578 {
1579 LOG_WARN("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
1580 return;
1581 }
1582
1583 do
1584 {
1585 Field* fields = result->Fetch();
1586 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
1587 if (!GetCreatureData(spawnId))
1588 {
1589 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_movement_override`", spawnId);
1590 continue;
1591 }
1592
1594 if (!fields[1].IsNull())
1595 {
1596 movement.Ground = static_cast<CreatureGroundMovementType>(fields[1].Get<uint8>());
1597 }
1598
1599 if (!fields[2].IsNull())
1600 {
1601 movement.Swim = fields[2].Get<bool>();
1602 }
1603
1604 if (!fields[3].IsNull())
1605 {
1606 movement.Flight = static_cast<CreatureFlightMovementType>(fields[3].Get<uint8>());
1607 }
1608
1609 if (!fields[4].IsNull())
1610 {
1611 movement.Rooted = fields[4].Get<bool>();
1612 }
1613
1614 if (!fields[5].IsNull())
1615 {
1616 movement.Chase = static_cast<CreatureChaseMovementType>(fields[5].Get<uint8>());
1617 }
1618
1619 if (!fields[6].IsNull())
1620 {
1621 movement.Random = static_cast<CreatureRandomMovementType>(fields[6].Get<uint8>());
1622 }
1623
1624 if (!fields[7].IsNull())
1625 {
1626 movement.InteractionPauseTimer = fields[7].Get<uint32>();
1627 }
1628
1629 CheckCreatureMovement("creature_movement_override", spawnId, movement);
1630 } while (result->NextRow());
1631
1632 LOG_INFO("server.loading", ">> Loaded {} Movement Overrides in {} ms", _creatureMovementOverrides.size(), GetMSTimeDiffToNow(oldMSTime));
1633 LOG_INFO("server.loading", " ");
1634}
CreatureFlightMovementType
Definition: CreatureData.h:95
CreatureChaseMovementType
Definition: CreatureData.h:104
CreatureGroundMovementType
Definition: CreatureData.h:86
CreatureRandomMovementType
Definition: CreatureData.h:113
Definition: CreatureData.h:122
bool Swim
Definition: CreatureData.h:127
bool Rooted
Definition: CreatureData.h:128
uint32 InteractionPauseTimer
Definition: CreatureData.h:131

References _creatureMovementOverrides, CreatureMovementData::Chase, CheckCreatureMovement(), CreatureMovementData::Flight, Field::Get(), GetCreatureData(), getMSTime(), GetMSTimeDiffToNow(), CreatureMovementData::Ground, CreatureMovementData::InteractionPauseTimer, LOG_ERROR, LOG_INFO, LOG_WARN, CreatureMovementData::Random, CreatureMovementData::Rooted, CreatureMovementData::Swim, and WorldDatabase.

◆ LoadCreatureQuestEnders()

void ObjectMgr::LoadCreatureQuestEnders ( )
8082{
8083 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8084
8085 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8086 {
8087 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8088 if (!cInfo)
8089 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8090 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8091 LOG_ERROR("sql.sql", "Table `creature_questender` has creature entry ({}) for quest {}, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second);
8092 }
8093}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition: UnitDefines.h:295
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition: ObjectMgr.cpp:7994

References _creatureQuestInvolvedRelations, GetCreatureTemplate(), LoadQuestRelationsHelper(), LOG_ERROR, CreatureTemplate::npcflag, and UNIT_NPC_FLAG_QUESTGIVER.

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
10110{
10111 uint32 oldMSTime = getMSTime();
10112
10113 // 0 1 2
10114 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
10115
10116 if (!result)
10117 {
10118 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
10119 return;
10120 }
10121
10122 uint32 count = 0;
10123 do
10124 {
10125 Field* fields = result->Fetch();
10126
10127 uint32 entry = fields[0].Get<uint32>();
10128 uint32 item = fields[1].Get<uint32>();
10129 uint32 idx = fields[2].Get<uint32>();
10130
10131 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
10132 if (!creatureInfo)
10133 {
10134 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
10135 continue;
10136 };
10137
10138 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10139 if (!dbcData)
10140 {
10141 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
10142 continue;
10143 };
10144
10145 _creatureQuestItemStore[entry].push_back(item);
10146
10147 ++count;
10148 } while (result->NextRow());
10149
10150 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10151 LOG_INFO("server.loading", " ");
10152}
DBCStorage< ItemEntry > sItemStore(Itemfmt)
Definition: DBCStructure.h:1140

References _creatureQuestItemStore, Field::Get(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sItemStore, and WorldDatabase.

◆ LoadCreatureQuestStarters()

void ObjectMgr::LoadCreatureQuestStarters ( )
8068{
8069 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8070
8071 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8072 {
8073 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8074 if (!cInfo)
8075 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8076 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8077 LOG_ERROR("sql.sql", "Table `creature_queststarter` has creature entry ({}) for quest {}, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second);
8078 }
8079}

References _creatureQuestRelations, GetCreatureTemplate(), LoadQuestRelationsHelper(), LOG_ERROR, CreatureTemplate::npcflag, and UNIT_NPC_FLAG_QUESTGIVER.

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

void ObjectMgr::LoadCreatures ( )
2105{
2106 uint32 oldMSTime = getMSTime();
2107
2108 // 0 1 2 3 4 5 6 7 8 9 10 11
2109 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2110 // 12 13 14 15 16 17 18 19 20 21 22
2111 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
2112 // 23
2113 "creature.ScriptName "
2114 "FROM creature "
2115 "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
2116 "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
2117
2118 if (!result)
2119 {
2120 LOG_WARN("server.loading", ">> Loaded 0 creatures. DB table `creature` is empty.");
2121 LOG_INFO("server.loading", " ");
2122 return;
2123 }
2124
2125 // Build single time for check spawnmask
2126 std::map<uint32, uint32> spawnMasks;
2127 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2128 if (sMapStore.LookupEntry(i))
2129 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2131 spawnMasks[i] |= (1 << k);
2132
2133 _creatureDataStore.rehash(result->GetRowCount());
2134 uint32 count = 0;
2135 do
2136 {
2137 Field* fields = result->Fetch();
2138
2139 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2140 uint32 id1 = fields[1].Get<uint32>();
2141 uint32 id2 = fields[2].Get<uint32>();
2142 uint32 id3 = fields[3].Get<uint32>();
2143
2144 CreatureTemplate const* cInfo = GetCreatureTemplate(id1);
2145 if (!cInfo)
2146 {
2147 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id1 field, skipped.", spawnId, id1);
2148 continue;
2149 }
2150 CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2);
2151 if (!cInfo2 && id2)
2152 {
2153 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id2 field, skipped.", spawnId, id2);
2154 continue;
2155 }
2156 CreatureTemplate const* cInfo3 = GetCreatureTemplate(id3);
2157 if (!cInfo3 && id3)
2158 {
2159 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id3 field, skipped.", spawnId, id3);
2160 continue;
2161 }
2162 if (!id2 && id3)
2163 {
2164 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3);
2165 continue;
2166 }
2167 CreatureData& data = _creatureDataStore[spawnId];
2168 data.id1 = id1;
2169 data.id2 = id2;
2170 data.id3 = id3;
2171 data.mapid = fields[4].Get<uint16>();
2172 data.equipmentId = fields[5].Get<int8>();
2173 data.posX = fields[6].Get<float>();
2174 data.posY = fields[7].Get<float>();
2175 data.posZ = fields[8].Get<float>();
2176 data.orientation = fields[9].Get<float>();
2177 data.spawntimesecs = fields[10].Get<uint32>();
2178 data.wander_distance = fields[11].Get<float>();
2179 data.currentwaypoint = fields[12].Get<uint32>();
2180 data.curhealth = fields[13].Get<uint32>();
2181 data.curmana = fields[14].Get<uint32>();
2182 data.movementType = fields[15].Get<uint8>();
2183 data.spawnMask = fields[16].Get<uint8>();
2184 data.phaseMask = fields[17].Get<uint32>();
2185 int16 gameEvent = fields[18].Get<int8>();
2186 uint32 PoolId = fields[19].Get<uint32>();
2187 data.npcflag = fields[20].Get<uint32>();
2188 data.unit_flags = fields[21].Get<uint32>();
2189 data.dynamicflags = fields[22].Get<uint32>();
2190 data.ScriptId = GetScriptId(fields[23].Get<std::string>());
2191
2192 if (!data.ScriptId)
2193 data.ScriptId = cInfo->ScriptID;
2194
2195 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2196 if (!mapEntry)
2197 {
2198 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that spawned at not existed map (Id: {}), skipped.", spawnId, data.mapid);
2199 continue;
2200 }
2201
2202 // pussywizard: 7 days means no reaspawn, so set it to 14 days, because manual id reset may be late
2203 if (mapEntry->IsRaid() && data.spawntimesecs >= 7 * DAY && data.spawntimesecs < 14 * DAY)
2204 data.spawntimesecs = 14 * DAY;
2205
2206 // Skip spawnMask check for transport maps
2207 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2208 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that have wrong spawn mask {} including not supported difficulty modes for map (Id: {}).",
2209 spawnId, data.spawnMask, data.mapid);
2210
2211 bool ok = true;
2212 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2213 {
2214 if ((_difficultyEntries[diff].find(data.id1) != _difficultyEntries[diff].end()) || (_difficultyEntries[diff].find(data.id2) != _difficultyEntries[diff].end()) || (_difficultyEntries[diff].find(data.id3) != _difficultyEntries[diff].end()))
2215 {
2216 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.",
2217 spawnId, diff + 1, data.id1, data.id2, data.id3);
2218 ok = false;
2219 }
2220 }
2221 if (!ok)
2222 continue;
2223
2224 // -1 random, 0 no equipment,
2225 if (data.equipmentId != 0)
2226 {
2227 if ((!GetEquipmentInfo(data.id1, data.equipmentId)) || (data.id2 && !GetEquipmentInfo(data.id2, data.equipmentId)) || (data.id3 && !GetEquipmentInfo(data.id3, data.equipmentId)))
2228 {
2229 LOG_ERROR("sql.sql", "Table `creature` have creature (Entries: {}, {}, {}) one or more with equipment_id {} not found in table `creature_equip_template`, set to no equipment.",
2230 data.id1, data.id2, data.id3, data.equipmentId);
2231 data.equipmentId = 0;
2232 }
2233 }
2234 if ((cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id3 && cInfo3->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND))
2235 {
2236 if (!mapEntry->IsDungeon())
2237 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with a `creature_template`.`flags_extra` in one or more entries including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",
2238 spawnId, data.id1, data.id2, data.id3);
2239 }
2240 if (data.movementType >= MAX_DB_MOTION_TYPE)
2241 {
2242 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with wrong movement generator type ({}), ignored and set to IDLE.", spawnId, data.id1, data.id2, data.id3, data.movementType);
2244 }
2245 if (data.wander_distance < 0.0f)
2246 {
2247 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", spawnId, data.id1, data.id2, data.id3);
2248 data.wander_distance = 0.0f;
2249 }
2250 else if (data.movementType == RANDOM_MOTION_TYPE)
2251 {
2252 if (data.wander_distance == 0.0f)
2253 {
2254 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).",
2255 spawnId, data.id1, data.id2, data.id3);
2257 }
2258 }
2259 else if (data.movementType == IDLE_MOTION_TYPE)
2260 {
2261 if (data.wander_distance != 0.0f)
2262 {
2263 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", spawnId, data.id1, data.id2, data.id3);
2264 data.wander_distance = 0.0f;
2265 }
2266 }
2267
2268 if (data.phaseMask == 0)
2269 {
2270 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, data.id1, data.id2, data.id3);
2271 data.phaseMask = 1;
2272 }
2273
2275 {
2276 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2277 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2278
2280
2281 stmt->SetData(0, zoneId);
2282 stmt->SetData(1, areaId);
2283 stmt->SetData(2, spawnId);
2284
2285 WorldDatabase.Execute(stmt);
2286 }
2287
2288 // Add to grid if not managed by the game event or pool system
2289 if (gameEvent == 0 && PoolId == 0)
2290 AddCreatureToGrid(spawnId, &data);
2291
2292 ++count;
2293 } while (result->NextRow());
2294
2295 LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2296 LOG_INFO("server.loading", " ");
2297}
constexpr auto DAY
Definition: Common.h:49
std::int8_t int8
Definition: Define.h:105
std::int16_t int16
Definition: Define.h:104
@ RANDOM_MOTION_TYPE
Definition: MotionMaster.h:38
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition: DBCStores.cpp:761
@ CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA
Definition: IWorld.h:158
@ CREATURE_FLAG_EXTRA_INSTANCE_BIND
Definition: CreatureData.h:46
@ WORLD_UPD_CREATURE_ZONE_AREA_DATA
Definition: WorldDatabase.h:99
Difficulty
Definition: DBCEnums.h:266
uint32 flags_extra
Definition: CreatureData.h:249
uint32 ScriptId
Definition: CreatureData.h:396
EquipmentInfo const * GetEquipmentInfo(uint32 entry, int8 &id)
Definition: ObjectMgr.cpp:1455
bool IsRaid() const
Definition: DBCStructure.h:1354

References _creatureDataStore, _difficultyEntries, _transportMaps, AddCreatureToGrid(), CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA, CREATURE_FLAG_EXTRA_INSTANCE_BIND, CreatureData::curhealth, CreatureData::curmana, CreatureData::currentwaypoint, DAY, CreatureData::dynamicflags, CreatureData::equipmentId, CreatureTemplate::flags_extra, Field::Get(), GetCreatureTemplate(), GetEquipmentInfo(), GetMapDifficultyData(), getMSTime(), GetMSTimeDiffToNow(), GetScriptId(), CreatureData::id1, CreatureData::id2, CreatureData::id3, IDLE_MOTION_TYPE, MapEntry::IsDungeon(), MapEntry::IsRaid(), LOG_ERROR, LOG_INFO, LOG_WARN, CreatureData::mapid, MAX_DB_MOTION_TYPE, MAX_DIFFICULTY, CreatureData::movementType, CreatureData::npcflag, CreatureData::orientation, CreatureData::phaseMask, CreatureData::posX, CreatureData::posY, CreatureData::posZ, RANDOM_MOTION_TYPE, CreatureData::ScriptId, PreparedStatementBase::SetData(), sMapMgr, sMapStore, CreatureData::spawnMask, CreatureData::spawntimesecs, sWorld, CreatureData::unit_flags, CreatureData::wander_distance, WORLD_UPD_CREATURE_ZONE_AREA_DATA, and WorldDatabase.

◆ LoadCreatureTemplate()

void ObjectMgr::LoadCreatureTemplate ( Field fields,
bool  triggerHook = false 
)

Loads a creature template from a database result.

Parameters
fieldsDatabase result
triggerHookIf true, will trigger the OnAfterDatabaseLoadCreatureTemplates hook. Useful if you are not calling the hook yourself.
583{
584 uint32 entry = fields[0].Get<uint32>();
585
586 CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry];
587
588 // enlarge the fast cache as necessary
589 if (_creatureTemplateStoreFast.size() < entry + 1)
590 {
591 _creatureTemplateStoreFast.resize(entry + 1, nullptr);
592 }
593
594 // load a pointer to this creatureTemplate into the fast cache
595 _creatureTemplateStoreFast[entry] = &creatureTemplate;
596
597 // build the creatureTemplate
598 creatureTemplate.Entry = entry;
599
600 for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
601 {
602 creatureTemplate.DifficultyEntry[i] = fields[1 + i].Get<uint32>();
603 }
604
605 for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
606 {
607 creatureTemplate.KillCredit[i] = fields[4 + i].Get<uint32>();
608 }
609 creatureTemplate.Name = fields[6].Get<std::string>();
610 creatureTemplate.SubName = fields[7].Get<std::string>();
611 creatureTemplate.IconName = fields[8].Get<std::string>();
612 creatureTemplate.GossipMenuId = fields[9].Get<uint32>();
613 creatureTemplate.minlevel = fields[10].Get<uint8>();
614 creatureTemplate.maxlevel = fields[11].Get<uint8>();
615 creatureTemplate.expansion = uint32(fields[12].Get<int16>());
616 creatureTemplate.faction = uint32(fields[13].Get<uint16>());
617 creatureTemplate.npcflag = fields[14].Get<uint32>();
618 creatureTemplate.speed_walk = fields[15].Get<float>();
619 creatureTemplate.speed_run = fields[16].Get<float>();
620 creatureTemplate.speed_swim = fields[17].Get<float>();
621 creatureTemplate.speed_flight = fields[18].Get<float>();
622 creatureTemplate.detection_range = fields[19].Get<float>();
623 creatureTemplate.scale = fields[20].Get<float>();
624 creatureTemplate.rank = uint32(fields[21].Get<uint8>());
625 creatureTemplate.dmgschool = uint32(fields[22].Get<int8>());
626 creatureTemplate.DamageModifier = fields[23].Get<float>();
627 creatureTemplate.BaseAttackTime = fields[24].Get<uint32>();
628 creatureTemplate.RangeAttackTime = fields[25].Get<uint32>();
629 creatureTemplate.BaseVariance = fields[26].Get<float>();
630 creatureTemplate.RangeVariance = fields[27].Get<float>();
631 creatureTemplate.unit_class = uint32(fields[28].Get<uint8>());
632 creatureTemplate.unit_flags = fields[29].Get<uint32>();
633 creatureTemplate.unit_flags2 = fields[30].Get<uint32>();
634 creatureTemplate.dynamicflags = fields[31].Get<uint32>();
635 creatureTemplate.family = uint32(fields[32].Get<uint8>());
636 creatureTemplate.trainer_type = uint32(fields[33].Get<uint8>());
637 creatureTemplate.trainer_spell = fields[34].Get<uint32>();
638 creatureTemplate.trainer_class = uint32(fields[35].Get<uint8>());
639 creatureTemplate.trainer_race = uint32(fields[36].Get<uint8>());
640 creatureTemplate.type = uint32(fields[37].Get<uint8>());
641 creatureTemplate.type_flags = fields[38].Get<uint32>();
642 creatureTemplate.lootid = fields[39].Get<uint32>();
643 creatureTemplate.pickpocketLootId = fields[40].Get<uint32>();
644 creatureTemplate.SkinLootId = fields[41].Get<uint32>();
645
646 for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
647 {
648 creatureTemplate.resistance[i] = 0;
649 }
650
651 for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i)
652 {
653 creatureTemplate.spells[i] = 0;
654 }
655
656 creatureTemplate.PetSpellDataId = fields[42].Get<uint32>();
657 creatureTemplate.VehicleId = fields[43].Get<uint32>();
658 creatureTemplate.mingold = fields[44].Get<uint32>();
659 creatureTemplate.maxgold = fields[45].Get<uint32>();
660 creatureTemplate.AIName = fields[46].Get<std::string>(); // stopped here, fix it
661 creatureTemplate.MovementType = uint32(fields[47].Get<uint8>());
662 if (!fields[48].IsNull())
663 {
664 creatureTemplate.Movement.Ground = static_cast<CreatureGroundMovementType>(fields[48].Get<uint8>());
665 }
666
667 creatureTemplate.Movement.Swim = fields[49].Get<bool>();
668 if (!fields[50].IsNull())
669 {
670 creatureTemplate.Movement.Flight = static_cast<CreatureFlightMovementType>(fields[50].Get<uint8>());
671 }
672
673 creatureTemplate.Movement.Rooted = fields[51].Get<bool>();
674 if (!fields[52].IsNull())
675 {
676 creatureTemplate.Movement.Chase = static_cast<CreatureChaseMovementType>(fields[52].Get<uint8>());
677 }
678 if (!fields[53].IsNull())
679 {
680 creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[53].Get<uint8>());
681 }
682 if (!fields[54].IsNull())
683 {
684 creatureTemplate.Movement.InteractionPauseTimer = fields[54].Get<uint32>();
685 }
686
687 creatureTemplate.HoverHeight = fields[55].Get<float>();
688 creatureTemplate.ModHealth = fields[56].Get<float>();
689 creatureTemplate.ModMana = fields[57].Get<float>();
690 creatureTemplate.ModArmor = fields[58].Get<float>();
691 creatureTemplate.ModExperience = fields[59].Get<float>();
692 creatureTemplate.RacialLeader = fields[60].Get<bool>();
693 creatureTemplate.movementId = fields[61].Get<uint32>();
694 creatureTemplate.RegenHealth = fields[62].Get<bool>();
695 creatureTemplate.MechanicImmuneMask = fields[63].Get<uint32>();
696 creatureTemplate.SpellSchoolImmuneMask = fields[64].Get<uint8>();
697 creatureTemplate.flags_extra = fields[65].Get<uint32>();
698 creatureTemplate.ScriptID = GetScriptId(fields[66].Get<std::string>());
699
700 // useful if the creature template load is being triggered from outside this class
701 if (triggerHook)
702 {
703 sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
704 }
705}
#define sScriptMgr
Definition: ScriptMgr.h:708
@ SPELL_SCHOOL_HOLY
Definition: SharedDefines.h:284

References _creatureTemplateStore, _creatureTemplateStoreFast, Field::Get(), GetScriptId(), MAX_CREATURE_SPELLS, MAX_DIFFICULTY, MAX_KILL_CREDIT, MAX_SPELL_SCHOOL, SPELL_SCHOOL_HOLY, and sScriptMgr.

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateAddons()

void ObjectMgr::LoadCreatureTemplateAddons ( )
852{
853 uint32 oldMSTime = getMSTime();
854
855 // 0 1 2 3 4 5 6 7
856 QueryResult result = WorldDatabase.Query("SELECT entry, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_template_addon");
857
858 if (!result)
859 {
860 LOG_WARN("server.loading", ">> Loaded 0 creature template addon definitions. DB table `creature_template_addon` is empty.");
861 LOG_INFO("server.loading", " ");
862 return;
863 }
864
865 uint32 count = 0;
866 do
867 {
868 Field* fields = result->Fetch();
869
870 uint32 entry = fields[0].Get<uint32>();
871
872 if (!sObjectMgr->GetCreatureTemplate(entry))
873 {
874 LOG_ERROR("sql.sql", "Creature template (Entry: {}) does not exist but has a record in `creature_template_addon`", entry);
875 continue;
876 }
877
878 CreatureAddon& creatureAddon = _creatureTemplateAddonStore[entry];
879
880 creatureAddon.path_id = fields[1].Get<uint32>();
881 creatureAddon.mount = fields[2].Get<uint32>();
882 creatureAddon.bytes1 = fields[3].Get<uint32>();
883 creatureAddon.bytes2 = fields[4].Get<uint32>();
884 creatureAddon.emote = fields[5].Get<uint32>();
885 creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].Get<uint8>());
886
887 for (std::string_view aura : Acore::Tokenize(fields[7].Get<std::string_view>(), ' ', false))
888 {
889 SpellInfo const* spellInfo = nullptr;
890
891 if (Optional<uint32> spellId = Acore::StringTo<uint32>(aura))
892 {
893 spellInfo = sSpellMgr->GetSpellInfo(*spellId);
894 }
895
896 if (!spellInfo)
897 {
898 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong spell '{}' defined in `auras` field in `creature_template_addon`.", entry, aura);
899 continue;
900 }
901
902 if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
903 {
904 LOG_ERROR("sql.sql", "Creature (Entry: {}) has duplicate aura (spell {}) in `auras` field in `creature_template_addon`.", entry, spellInfo->Id);
905 continue;
906 }
907
908 if (spellInfo->GetDuration() > 0)
909 {
910 LOG_DEBUG/*ERROR*/("sql.sql", "Creature (Entry: {}) has temporary aura (spell {}) in `auras` field in `creature_template_addon`.", entry, spellInfo->Id);
911 // continue;
912 }
913
914 creatureAddon.auras.push_back(spellInfo->Id);
915 }
916
917 if (creatureAddon.mount)
918 {
919 if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
920 {
921 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid displayInfoId ({}) for mount defined in `creature_template_addon`", entry, creatureAddon.mount);
922 creatureAddon.mount = 0;
923 }
924 }
925
926 if (!sEmotesStore.LookupEntry(creatureAddon.emote))
927 {
928 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid emote ({}) defined in `creature_addon`.", entry, creatureAddon.emote);
929 creatureAddon.emote = 0;
930 }
931
932 if (creatureAddon.visibilityDistanceType >= VisibilityDistanceType::Max)
933 {
934 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid visibilityDistanceType ({}) defined in `creature_template_addon`.", entry, AsUnderlyingType(creatureAddon.visibilityDistanceType));
935 creatureAddon.visibilityDistanceType = VisibilityDistanceType::Normal;
936 }
937 ++count;
938 } while (result->NextRow());
939
940 LOG_INFO("server.loading", ">> Loaded {} Creature Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
941 LOG_INFO("server.loading", " ");
942}

References _creatureTemplateAddonStore, AsUnderlyingType(), CreatureAddon::auras, CreatureAddon::bytes1, CreatureAddon::bytes2, CreatureAddon::emote, Field::Get(), SpellInfo::GetDuration(), getMSTime(), GetMSTimeDiffToNow(), SpellInfo::Id, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARN, CreatureAddon::mount, CreatureAddon::path_id, sCreatureDisplayInfoStore, sEmotesStore, sObjectMgr, sSpellMgr, Acore::Tokenize(), CreatureAddon::visibilityDistanceType, and WorldDatabase.

◆ LoadCreatureTemplateModels()

void ObjectMgr::LoadCreatureTemplateModels ( )
708{
709 uint32 oldMSTime = getMSTime();
710
711 // 0 1 2 3
712 QueryResult result = WorldDatabase.Query("SELECT CreatureID, CreatureDisplayID, DisplayScale, Probability FROM creature_template_model ORDER BY Idx ASC");
713
714 if (!result)
715 {
716 LOG_INFO("server.loading", ">> Loaded 0 creature template model definitions. DB table `creature_template_model` is empty.");
717 return;
718 }
719
720 uint32 count = 0;
721 do
722 {
723 Field* fields = result->Fetch();
724
725 uint32 creatureId = fields[0].Get<uint32>();
726 uint32 creatureDisplayId = fields[1].Get<uint32>();
727 float displayScale = fields[2].Get<float>();
728 float probability = fields[3].Get<float>();
729
730 CreatureTemplate const* cInfo = GetCreatureTemplate(creatureId);
731 if (!cInfo)
732 {
733 LOG_ERROR("sql.sql", "Creature template (Entry: {}) does not exist but has a record in `creature_template_model`", creatureId);
734 continue;
735 }
736
737 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(creatureDisplayId);
738 if (!displayEntry)
739 {
740 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing CreatureDisplayID id ({}), this can crash the client.", creatureId, creatureDisplayId);
741 continue;
742 }
743
744 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(creatureDisplayId);
745 if (!modelInfo)
746 LOG_ERROR("sql.sql", "No model data exist for `CreatureDisplayID` = {} listed by creature (Entry: {}).", creatureDisplayId, creatureId);
747
748 if (displayScale <= 0.0f)
749 displayScale = 1.0f;
750
751 const_cast<CreatureTemplate*>(cInfo)->Models.emplace_back(creatureDisplayId, displayScale, probability);
752
753 ++count;
754 } while (result->NextRow());
755
756 LOG_INFO("server.loading", ">> Loaded {} creature template models in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
757}
Models
Definition: boss_black_knight.cpp:95

References Field::Get(), GetCreatureModelInfo(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, sCreatureDisplayInfoStore, and WorldDatabase.

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateResistances()

void ObjectMgr::LoadCreatureTemplateResistances ( )
760{
761 uint32 oldMSTime = getMSTime();
762
763 // 0 1 2
764 QueryResult result = WorldDatabase.Query("SELECT CreatureID, School, Resistance FROM creature_template_resistance");
765
766 if (!result)
767 {
768 LOG_WARN("server.loading", ">> Loaded 0 creature template resistance definitions. DB table `creature_template_resistance` is empty.");
769 LOG_INFO("server.loading", " ");
770 return;
771 }
772
773 uint32 count = 0;
774
775 do
776 {
777 Field* fields = result->Fetch();
778
779 uint32 creatureID = fields[0].Get<uint32>();
780 uint8 school = fields[1].Get<uint8>();
781
782 if (school == SPELL_SCHOOL_NORMAL || school >= MAX_SPELL_SCHOOL)
783 {
784 LOG_ERROR("sql.sql", "creature_template_resistance has resistance definitions for creature {} but this school {} doesn't exist", creatureID, school);
785 continue;
786 }
787
788 CreatureTemplateContainer::iterator itr = _creatureTemplateStore.find(creatureID);
789 if (itr == _creatureTemplateStore.end())
790 {
791 LOG_ERROR("sql.sql", "creature_template_resistance has resistance definitions for creature {} but this creature doesn't exist", creatureID);
792 continue;
793 }
794
795 CreatureTemplate& creatureTemplate = itr->second;
796 creatureTemplate.resistance[school] = fields[2].Get<int16>();
797
798 ++count;
799 } while (result->NextRow());
800
801 LOG_INFO("server.loading", ">> Loaded {} Creature Template Resistances in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
802 LOG_INFO("server.loading", " ");
803}
int32 resistance[MAX_SPELL_SCHOOL]
Definition: CreatureData.h:230

References _creatureTemplateStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_SPELL_SCHOOL, CreatureTemplate::resistance, SPELL_SCHOOL_NORMAL, and WorldDatabase.

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplates()

void ObjectMgr::LoadCreatureTemplates ( )
521{
522 uint32 oldMSTime = getMSTime();
523
524// 0 1 2 3 4 5 6 7 8
525 QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, name, subname, IconName, "
526// 9 10 11 12 13 14 15 16 17 18 19 20 21 22
527 "gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, speed_swim, speed_flight, detection_range, scale, `rank`, dmgschool, "
528// 23 24 25 26 27 28 29 30 31 32 33 34
529 "DamageModifier, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, "
530// 35 36 37 38 39 40 41
531 "trainer_class, trainer_race, type, type_flags, lootid, pickpocketloot, skinloot, "
532// 42 43 44 45 46 47 48 49 50 51
533 "PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, "
534// 52 53 54 55 56 57 58 59 60 61 62 63
535 "ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, "
536// 64 65 66
537 "spell_school_immune_mask, flags_extra, ScriptName "
538 "FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId ORDER BY entry DESC;");
539
540 if (!result)
541 {
542 LOG_WARN("server.loading", ">> Loaded 0 creature template definitions. DB table `creature_template` is empty.");
543 return;
544 }
545
546 _creatureTemplateStore.rehash(result->GetRowCount());
548
549 uint32 count = 0;
550 do
551 {
552 Field* fields = result->Fetch();
553 LoadCreatureTemplate(fields);
554 ++count;
555 } while (result->NextRow());
556
557 // We load the creature models after loading but before checking
559
560 sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
561
564
565 // Checking needs to be done after loading because of the difficulty self referencing
566 for (CreatureTemplateContainer::iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
567 {
568 CheckCreatureTemplate(&itr->second);
569 itr->second.InitializeQueryData();
570 }
571
572 LOG_INFO("server.loading", ">> Loaded {} Creature Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
573 LOG_INFO("server.loading", " ");
574}
void LoadCreatureTemplateResistances()
Definition: ObjectMgr.cpp:759
void LoadCreatureTemplateSpells()
Definition: ObjectMgr.cpp:805
void CheckCreatureTemplate(CreatureTemplate const *cInfo)
Definition: ObjectMgr.cpp:959
void LoadCreatureTemplate(Field *fields, bool triggerHook=false)
Loads a creature template from a database result.
Definition: ObjectMgr.cpp:582
void LoadCreatureTemplateModels()
Definition: ObjectMgr.cpp:707

References _creatureTemplateStore, _creatureTemplateStoreFast, CheckCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LoadCreatureTemplate(), LoadCreatureTemplateModels(), LoadCreatureTemplateResistances(), LoadCreatureTemplateSpells(), LOG_INFO, LOG_WARN, sScriptMgr, and WorldDatabase.

◆ LoadCreatureTemplateSpells()

void ObjectMgr::LoadCreatureTemplateSpells ( )
806{
807 uint32 oldMSTime = getMSTime();
808
809 // 0 1 2
810 QueryResult result = WorldDatabase.Query("SELECT CreatureID, `Index`, Spell FROM creature_template_spell");
811
812 if (!result)
813 {
814 LOG_WARN("server.loading", ">> Loaded 0 creature template spell definitions. DB table `creature_template_spell` is empty.");
815 LOG_INFO("server.loading", " ");
816 return;
817 }
818
819 uint32 count = 0;
820
821 do
822 {
823 Field* fields = result->Fetch();
824
825 uint32 creatureID = fields[0].Get<uint32>();
826 uint8 index = fields[1].Get<uint8>();
827
828 if (index >= MAX_CREATURE_SPELLS)
829 {
830 LOG_ERROR("sql.sql", "creature_template_spell has spell definitions for creature {} with a incorrect index {}", creatureID, index);
831 continue;
832 }
833
834 CreatureTemplateContainer::iterator itr = _creatureTemplateStore.find(creatureID);
835 if (itr == _creatureTemplateStore.end())
836 {
837 LOG_ERROR("sql.sql", "creature_template_spell has spell definitions for creature {} but this creature doesn't exist", creatureID);
838 continue;
839 }
840
841 CreatureTemplate& creatureTemplate = itr->second;
842 creatureTemplate.spells[index] = fields[2].Get<uint32>();
843
844 ++count;
845 } while (result->NextRow());
846
847 LOG_INFO("server.loading", ">> Loaded {} Creature Template Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
848 LOG_INFO("server.loading", " ");
849}
uint32 spells[MAX_CREATURE_SPELLS]
Definition: CreatureData.h:231

References _creatureTemplateStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_CREATURE_SPELLS, CreatureTemplate::spells, and WorldDatabase.

Referenced by LoadCreatureTemplates().

◆ LoadEquipmentTemplates()

void ObjectMgr::LoadEquipmentTemplates ( )
1482{
1483 uint32 oldMSTime = getMSTime();
1484
1485 // 0 1 2 3 4
1486 QueryResult result = WorldDatabase.Query("SELECT CreatureID, ID, ItemID1, ItemID2, ItemID3 FROM creature_equip_template");
1487
1488 if (!result)
1489 {
1490 LOG_WARN("server.loading", ">> Loaded 0 creature equipment templates. DB table `creature_equip_template` is empty!");
1491 LOG_INFO("server.loading", " ");
1492 return;
1493 }
1494
1495 uint32 count = 0;
1496 do
1497 {
1498 Field* fields = result->Fetch();
1499
1500 uint32 entry = fields[0].Get<uint32>();
1501
1502 if (!sObjectMgr->GetCreatureTemplate(entry))
1503 {
1504 LOG_ERROR("sql.sql", "Creature template (CreatureID: {}) does not exist but has a record in `creature_equip_template`", entry);
1505 continue;
1506 }
1507
1508 uint8 id = fields[1].Get<uint8>();
1509 if (!id)
1510 {
1511 LOG_ERROR("sql.sql", "Creature equipment template with id 0 found for creature {}, skipped.", entry);
1512 continue;
1513 }
1514
1515 EquipmentInfo& equipmentInfo = _equipmentInfoStore[entry][id];
1516
1517 equipmentInfo.ItemEntry[0] = fields[2].Get<uint32>();
1518 equipmentInfo.ItemEntry[1] = fields[3].Get<uint32>();
1519 equipmentInfo.ItemEntry[2] = fields[4].Get<uint32>();
1520
1521 for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1522 {
1523 if (!equipmentInfo.ItemEntry[i])
1524 continue;
1525
1526 ItemEntry const* dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]);
1527
1528 if (!dbcItem)
1529 {
1530 LOG_ERROR("sql.sql", "Unknown item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {}, forced to 0.",
1531 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1532 equipmentInfo.ItemEntry[i] = 0;
1533 continue;
1534 }
1535
1536 if (dbcItem->InventoryType != INVTYPE_WEAPON &&
1537 dbcItem->InventoryType != INVTYPE_SHIELD &&
1538 dbcItem->InventoryType != INVTYPE_RANGED &&
1539 dbcItem->InventoryType != INVTYPE_2HWEAPON &&
1542 dbcItem->InventoryType != INVTYPE_HOLDABLE &&
1543 dbcItem->InventoryType != INVTYPE_THROWN &&
1545 {
1546 LOG_ERROR("sql.sql", "Item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {} is not equipable in a hand, forced to 0.",
1547 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1548 equipmentInfo.ItemEntry[i] = 0;
1549 }
1550 }
1551
1552 ++count;
1553 } while (result->NextRow());
1554
1555 LOG_INFO("server.loading", ">> Loaded {} Equipment Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1556 LOG_INFO("server.loading", " ");
1557}
#define MAX_EQUIPMENT_ITEMS
Definition: CreatureData.h:36
@ INVTYPE_HOLDABLE
Definition: ItemTemplate.h:279
@ INVTYPE_RANGED
Definition: ItemTemplate.h:271
@ INVTYPE_THROWN
Definition: ItemTemplate.h:281
@ INVTYPE_RANGEDRIGHT
Definition: ItemTemplate.h:282
@ INVTYPE_WEAPON
Definition: ItemTemplate.h:269
@ INVTYPE_WEAPONMAINHAND
Definition: ItemTemplate.h:277
@ INVTYPE_WEAPONOFFHAND
Definition: ItemTemplate.h:278
@ INVTYPE_2HWEAPON
Definition: ItemTemplate.h:273
@ INVTYPE_SHIELD
Definition: ItemTemplate.h:270
Definition: CreatureData.h:363
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition: CreatureData.h:364
uint32 InventoryType
Definition: DBCStructure.h:1147

References _equipmentInfoStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), ItemEntry::InventoryType, INVTYPE_2HWEAPON, INVTYPE_HOLDABLE, INVTYPE_RANGED, INVTYPE_RANGEDRIGHT, INVTYPE_SHIELD, INVTYPE_THROWN, INVTYPE_WEAPON, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPONOFFHAND, EquipmentInfo::ItemEntry, LOG_ERROR, LOG_INFO, LOG_WARN, MAX_EQUIPMENT_ITEMS, sItemStore, sObjectMgr, and WorldDatabase.

◆ LoadEventScripts()

void ObjectMgr::LoadEventScripts ( )
5497{
5499
5500 std::set<uint32> evt_scripts;
5501 // Load all possible script entries from gameobjects
5502 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
5503 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
5504 if (uint32 eventId = itr->second.GetEventScriptId())
5505 evt_scripts.insert(eventId);
5506
5507 // Load all possible script entries from spells
5508 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5509 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
5510 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5511 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
5512 if (spell->Effects[j].MiscValue)
5513 evt_scripts.insert(spell->Effects[j].MiscValue);
5514
5515 for (std::size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
5516 {
5517 for (std::size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
5518 {
5519 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
5520
5521 if (node->arrivalEventID)
5522 evt_scripts.insert(node->arrivalEventID);
5523
5524 if (node->departureEventID)
5525 evt_scripts.insert(node->departureEventID);
5526 }
5527 }
5528
5529 // Then check if all scripts are in above list of possible script entries
5530 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
5531 {
5532 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
5533 if (itr2 == evt_scripts.end())
5534 LOG_ERROR("sql.sql", "Table `event_scripts` has script (Id: {}) not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field or any spell effect {}",
5535 itr->first, SPELL_EFFECT_SEND_EVENT);
5536 }
5537}
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:58
@ SCRIPTS_EVENT
Definition: ObjectMgr.h:152
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DBCStores.cpp:187
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition: GameObject.h:43
@ SPELL_EFFECT_SEND_EVENT
Definition: SharedDefines.h:839
void LoadScripts(ScriptsType type)
Definition: ObjectMgr.cpp:5154
Definition: DBCStructure.h:1973
uint32 arrivalEventID
Definition: DBCStructure.h:1983
uint32 departureEventID
Definition: DBCStructure.h:1984

References TaxiPathNodeEntry::arrivalEventID, TaxiPathNodeEntry::departureEventID, LoadScripts(), LOG_ERROR, MAX_SPELL_EFFECTS, SCRIPTS_EVENT, sEventScripts, sObjectMgr, SPELL_EFFECT_SEND_EVENT, sSpellMgr, and sTaxiPathNodesByPath.

◆ LoadExplorationBaseXP()

void ObjectMgr::LoadExplorationBaseXP ( )
7374{
7375 uint32 oldMSTime = getMSTime();
7376
7377 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
7378
7379 if (!result)
7380 {
7381 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
7382 LOG_INFO("server.loading", " ");
7383 return;
7384 }
7385
7386 uint32 count = 0;
7387
7388 do
7389 {
7390 Field* fields = result->Fetch();
7391 uint8 level = fields[0].Get<uint8>();
7392 uint32 basexp = fields[1].Get<int32>();
7393 _baseXPTable[level] = basexp;
7394 ++count;
7395 } while (result->NextRow());
7396
7397 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7398 LOG_INFO("server.loading", " ");
7399}
std::int32_t int32
Definition: Define.h:103

References _baseXPTable, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadFactionChangeAchievements()

void ObjectMgr::LoadFactionChangeAchievements ( )
9792{
9793 uint32 oldMSTime = getMSTime();
9794
9795 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_achievement");
9796
9797 if (!result)
9798 {
9799 LOG_WARN("server.loading", ">> Loaded 0 faction change achievement pairs. DB table `player_factionchange_achievement` is empty.");
9800 LOG_INFO("server.loading", " ");
9801 return;
9802 }
9803
9804 uint32 count = 0;
9805
9806 do
9807 {
9808 Field* fields = result->Fetch();
9809
9810 uint32 alliance = fields[0].Get<uint32>();
9811 uint32 horde = fields[1].Get<uint32>();
9812
9813 if (!sAchievementStore.LookupEntry(alliance))
9814 LOG_ERROR("sql.sql", "Achievement {} (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance);
9815 else if (!sAchievementStore.LookupEntry(horde))
9816 LOG_ERROR("sql.sql", "Achievement {} (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde);
9817 else
9818 FactionChangeAchievements[alliance] = horde;
9819
9820 ++count;
9821 } while (result->NextRow());
9822
9823 LOG_INFO("server.loading", ">> Loaded {} faction change achievement pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9824 LOG_INFO("server.loading", " ");
9825}
CharacterConversionMap FactionChangeAchievements
Definition: ObjectMgr.h:1418

References FactionChangeAchievements, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sAchievementStore, and WorldDatabase.

◆ LoadFactionChangeItems()

void ObjectMgr::LoadFactionChangeItems ( )
9828{
9829 uint32 oldMSTime = getMSTime();
9830
9831 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
9832
9833 if (!result)
9834 {
9835 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
9836 LOG_INFO("server.loading", " ");
9837 return;
9838 }
9839
9840 uint32 count = 0;
9841
9842 do
9843 {
9844 Field* fields = result->Fetch();
9845
9846 uint32 alliance = fields[0].Get<uint32>();
9847 uint32 horde = fields[1].Get<uint32>();
9848
9849 if (!GetItemTemplate(alliance))
9850 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
9851 else if (!GetItemTemplate(horde))
9852 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
9853 else
9854 FactionChangeItems[alliance] = horde;
9855
9856 ++count;
9857 } while (result->NextRow());
9858
9859 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9860 LOG_INFO("server.loading", " ");
9861}
CharacterConversionMap FactionChangeItems
Definition: ObjectMgr.h:1419

References FactionChangeItems, Field::Get(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadFactionChangeQuests()

void ObjectMgr::LoadFactionChangeQuests ( )
9864{
9865 uint32 oldMSTime = getMSTime();
9866
9867 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
9868
9869 if (!result)
9870 {
9871 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
9872 LOG_INFO("server.loading", " ");
9873 return;
9874 }
9875
9876 uint32 count = 0;
9877
9878 do
9879 {
9880 Field* fields = result->Fetch();
9881
9882 uint32 alliance = fields[0].Get<uint32>();
9883 uint32 horde = fields[1].Get<uint32>();
9884
9885 if (!sObjectMgr->GetQuestTemplate(alliance))
9886 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
9887 else if (!sObjectMgr->GetQuestTemplate(horde))
9888 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
9889 else
9890 FactionChangeQuests[alliance] = horde;
9891
9892 ++count;
9893 } while (result->NextRow());
9894
9895 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9896 LOG_INFO("server.loading", " ");
9897}
CharacterConversionMap FactionChangeQuests
Definition: ObjectMgr.h:1420

References FactionChangeQuests, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sObjectMgr, and WorldDatabase.

◆ LoadFactionChangeReputations()

void ObjectMgr::LoadFactionChangeReputations ( )
9900{
9901 uint32 oldMSTime = getMSTime();
9902
9903 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
9904
9905 if (!result)
9906 {
9907 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
9908 LOG_INFO("server.loading", " ");
9909 return;
9910 }
9911
9912 uint32 count = 0;
9913
9914 do
9915 {
9916 Field* fields = result->Fetch();
9917
9918 uint32 alliance = fields[0].Get<uint32>();
9919 uint32 horde = fields[1].Get<uint32>();
9920
9921 if (!sFactionStore.LookupEntry(alliance))
9922 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
9923 else if (!sFactionStore.LookupEntry(horde))
9924 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
9925 else
9926 FactionChangeReputation[alliance] = horde;
9927
9928 ++count;
9929 } while (result->NextRow());
9930
9931 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9932 LOG_INFO("server.loading", " ");
9933}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
CharacterConversionMap FactionChangeReputation
Definition: ObjectMgr.h:1421

References FactionChangeReputation, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sFactionStore, and WorldDatabase.

◆ LoadFactionChangeSpells()

void ObjectMgr::LoadFactionChangeSpells ( )
9936{
9937 uint32 oldMSTime = getMSTime();
9938
9939 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
9940
9941 if (!result)
9942 {
9943 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
9944 LOG_INFO("server.loading", " ");
9945 return;
9946 }
9947
9948 uint32 count = 0;
9949
9950 do
9951 {
9952 Field* fields = result->Fetch();
9953
9954 uint32 alliance = fields[0].Get<uint32>();
9955 uint32 horde = fields[1].Get<uint32>();
9956
9957 if (!sSpellMgr->GetSpellInfo(alliance))
9958 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
9959 else if (!sSpellMgr->GetSpellInfo(horde))
9960 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
9961 else
9962 FactionChangeSpells[alliance] = horde;
9963
9964 ++count;
9965 } while (result->NextRow());
9966
9967 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9968 LOG_INFO("server.loading", " ");
9969}
CharacterConversionMap FactionChangeSpells
Definition: ObjectMgr.h:1422

References FactionChangeSpells, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sSpellMgr, and WorldDatabase.

◆ LoadFactionChangeTitles()

void ObjectMgr::LoadFactionChangeTitles ( )
9972{
9973 uint32 oldMSTime = getMSTime();
9974
9975 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
9976
9977 if (!result)
9978 {
9979 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
9980 return;
9981 }
9982
9983 uint32 count = 0;
9984
9985 do
9986 {
9987 Field* fields = result->Fetch();
9988
9989 uint32 alliance = fields[0].Get<uint32>();
9990 uint32 horde = fields[1].Get<uint32>();
9991
9992 if (!sCharTitlesStore.LookupEntry(alliance))
9993 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
9994 else if (!sCharTitlesStore.LookupEntry(horde))
9995 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
9996 else
9997 FactionChangeTitles[alliance] = horde;
9998
9999 ++count;
10000 } while (result->NextRow());
10001
10002 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10003 LOG_INFO("server.loading", " ");
10004}
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
CharacterConversionMap FactionChangeTitles
Definition: ObjectMgr.h:1423

References FactionChangeTitles, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sCharTitlesStore, and WorldDatabase.

◆ LoadFishingBaseSkillLevel()

void ObjectMgr::LoadFishingBaseSkillLevel ( )
8695{
8696 uint32 oldMSTime = getMSTime();
8697
8698 _fishingBaseForAreaStore.clear(); // for reload case
8699
8700 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
8701
8702 if (!result)
8703 {
8704 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
8705 LOG_INFO("server.loading", " ");
8706 return;
8707 }
8708
8709 uint32 count = 0;
8710
8711 do
8712 {
8713 Field* fields = result->Fetch();
8714 uint32 entry = fields[0].Get<uint32>();
8715 int32 skill = fields[1].Get<int16>();
8716
8717 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8718 if (!fArea)
8719 {
8720 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8721 continue;
8722 }
8723
8724 _fishingBaseForAreaStore[entry] = skill;
8725 ++count;
8726 } while (result->NextRow());
8727
8728 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8729 LOG_INFO("server.loading", " ");
8730}

References _fishingBaseForAreaStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sAreaTableStore, and WorldDatabase.

◆ LoadGameObjectAddons()

void ObjectMgr::LoadGameObjectAddons ( )
1372{
1373 uint32 oldMSTime = getMSTime();
1374
1375 // 0 1 2
1376 QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon");
1377
1378 if (!result)
1379 {
1380 LOG_WARN("server.loading", ">> Loaded 0 gameobject addon definitions. DB table `gameobject_addon` is empty.");
1381 LOG_INFO("server.loading", " ");
1382 return;
1383 }
1384
1385 uint32 count = 0;
1386 do
1387 {
1388 Field* fields = result->Fetch();
1389
1390 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1391
1392 const GameObjectData* goData = GetGameObjectData(guid);
1393 if (!goData)
1394 {
1395 LOG_ERROR("sql.sql", "GameObject (GUID: {}) does not exist but has a record in `gameobject_addon`", guid);
1396 continue;
1397 }
1398
1399 GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
1400 gameObjectAddon.invisibilityType = InvisibilityType(fields[1].Get<uint8>());
1401 gameObjectAddon.InvisibilityValue = fields[2].Get<uint32>();
1402
1403 if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
1404 {
1405 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid InvisibilityType in `gameobject_addon`", guid);
1406 gameObjectAddon.invisibilityType = INVISIBILITY_GENERAL;
1407 gameObjectAddon.InvisibilityValue = 0;
1408 }
1409
1410 if (gameObjectAddon.invisibilityType && !gameObjectAddon.InvisibilityValue)
1411 {
1412 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid);
1413 gameObjectAddon.InvisibilityValue = 1;
1414 }
1415
1416 ++count;
1417 } while (result->NextRow());
1418
1419 LOG_INFO("server.loading", ">> Loaded {} Gameobject Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1420 LOG_INFO("server.loading", " ");
1421}
InvisibilityType
Definition: SharedDefines.h:1254
@ TOTAL_INVISIBILITY_TYPES
Definition: SharedDefines.h:1268
@ INVISIBILITY_GENERAL
Definition: SharedDefines.h:1255
Definition: GameObjectData.h:682
uint32 InvisibilityValue
Definition: GameObjectData.h:684
InvisibilityType invisibilityType
Definition: GameObjectData.h:683

References _gameObjectAddonStore, Field::Get(), GetGameObjectData(), getMSTime(), GetMSTimeDiffToNow(), INVISIBILITY_GENERAL, GameObjectAddon::invisibilityType, GameObjectAddon::InvisibilityValue, LOG_ERROR, LOG_INFO, LOG_WARN, TOTAL_INVISIBILITY_TYPES, and WorldDatabase.

◆ LoadGameObjectForQuests()

void ObjectMgr::LoadGameObjectForQuests ( )
8482{
8483 uint32 oldMSTime = getMSTime();
8484
8485 if (sObjectMgr->GetGameObjectTemplates()->empty())
8486 {
8487 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
8488 LOG_INFO("server.loading", " ");
8489 return;
8490 }
8491
8492 uint32 count = 0;
8493
8494 // collect GO entries for GO that must activated
8495 GameObjectTemplateContainer* gotc = const_cast<GameObjectTemplateContainer*>(sObjectMgr->GetGameObjectTemplates());
8496 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
8497 {
8498 itr->second.IsForQuests = false;
8499 switch (itr->second.type)
8500 {
8502 itr->second.IsForQuests = true;
8503 ++count;
8504 break;
8506 {
8507 // scan GO chest with loot including quest items
8508 uint32 loot_id = (itr->second.GetLootId());
8509
8510 // find quest loot for GO
8511 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
8512 {
8513 itr->second.IsForQuests = true;
8514 ++count;
8515 }
8516 break;
8517 }
8519 {
8520 if (itr->second._generic.questID > 0) //quests objects
8521 {
8522 itr->second.IsForQuests = true;
8523 ++count;
8524 }
8525 break;
8526 }
8528 {
8529 if (itr->second.spellFocus.questID > 0) //quests objects
8530 {
8531 itr->second.IsForQuests = true;
8532 ++count;
8533 }
8534 break;
8535 }
8537 {
8538 if (itr->second.goober.questId > 0) //quests objects
8539 {
8540 itr->second.IsForQuests = true;
8541 ++count;
8542 }
8543 break;
8544 }
8545 default:
8546 break;
8547 }
8548 }
8549
8550 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8551 LOG_INFO("server.loading", " ");
8552}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition: SharedDefines.h:1568
@ GAMEOBJECT_TYPE_GENERIC
Definition: SharedDefines.h:1565
@ GAMEOBJECT_TYPE_CHEST
Definition: SharedDefines.h:1563
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition: SharedDefines.h:1562
@ GAMEOBJECT_TYPE_GOOBER
Definition: SharedDefines.h:1570
bool HaveQuestLootFor(uint32 loot_id) const
Definition: LootMgr.cpp:217

References GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_GENERIC, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_SPELL_FOCUS, getMSTime(), GetMSTimeDiffToNow(), LootStore::HaveQuestLootFor(), LOG_INFO, LOG_WARN, LootTemplates_Gameobject, and sObjectMgr.

◆ LoadGameObjectLocales()

void ObjectMgr::LoadGameObjectLocales ( )
7018{
7019 uint32 oldMSTime = getMSTime();
7020
7021 _gameObjectLocaleStore.clear(); // need for reload case
7022
7023 // 0 1 2 3
7024 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7025 if (!result)
7026 return;
7027
7028 do
7029 {
7030 Field* fields = result->Fetch();
7031
7032 uint32 ID = fields[0].Get<uint32>();
7033
7034 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7035 if (locale == LOCALE_enUS)
7036 continue;
7037
7039 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7040 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7041 } while (result->NextRow());
7042
7043 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7044}
Definition: GameObjectData.h:675
std::vector< std::string > Name
Definition: GameObjectData.h:676
std::vector< std::string > CastBarCaption
Definition: GameObjectData.h:677

References _gameObjectLocaleStore, AddLocaleString(), GameObjectLocale::CastBarCaption, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, GameObjectLocale::Name, and WorldDatabase.

◆ LoadGameobjectQuestEnders()

void ObjectMgr::LoadGameobjectQuestEnders ( )
8054{
8055 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8056
8057 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8058 {
8059 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8060 if (!goInfo)
8061 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8062 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8063 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8064 }
8065}

References _goQuestInvolvedRelations, GAMEOBJECT_TYPE_QUESTGIVER, GetGameObjectTemplate(), LoadQuestRelationsHelper(), LOG_ERROR, and GameObjectTemplate::type.

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
10065{
10066 uint32 oldMSTime = getMSTime();
10067
10068 // 0 1 2
10069 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
10070
10071 if (!result)
10072 {
10073 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
10074 return;
10075 }
10076
10077 uint32 count = 0;
10078 do
10079 {
10080 Field* fields = result->Fetch();
10081
10082 uint32 entry = fields[0].Get<uint32>();
10083 uint32 item = fields[1].Get<uint32>();
10084 uint32 idx = fields[2].Get<uint32>();
10085
10086 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
10087 if (!goInfo)
10088 {
10089 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
10090 continue;
10091 };
10092
10093 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10094 if (!dbcData)
10095 {
10096 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
10097 continue;
10098 };
10099
10100 _gameObjectQuestItemStore[entry].push_back(item);
10101
10102 ++count;
10103 } while (result->NextRow());
10104
10105 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10106 LOG_INFO("server.loading", " ");
10107}

References _gameObjectQuestItemStore, Field::Get(), GetGameObjectTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sItemStore, and WorldDatabase.

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8040{
8041 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8042
8043 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8044 {
8045 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8046 if (!goInfo)
8047 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8048 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8049 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8050 }
8051}

References _goQuestRelations, GAMEOBJECT_TYPE_QUESTGIVER, GetGameObjectTemplate(), LoadQuestRelationsHelper(), LOG_ERROR, and GameObjectTemplate::type.

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

void ObjectMgr::LoadGameobjects ( )
2434{
2435 uint32 oldMSTime = getMSTime();
2436
2437 // 0 1 2 3 4 5 6
2438 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
2439 // 7 8 9 10 11 12 13 14 15 16 17
2440 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, "
2441 // 18
2442 "ScriptName "
2443 "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
2444 "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
2445
2446 if (!result)
2447 {
2448 LOG_WARN("server.loading", ">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
2449 LOG_INFO("server.loading", " ");
2450 return;
2451 }
2452
2453 // build single time for check spawnmask
2454 std::map<uint32, uint32> spawnMasks;
2455 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2456 if (sMapStore.LookupEntry(i))
2457 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2459 spawnMasks[i] |= (1 << k);
2460
2461 _gameObjectDataStore.rehash(result->GetRowCount());
2462 do
2463 {
2464 Field* fields = result->Fetch();
2465
2466 ObjectGuid::LowType guid = fields[0].Get<uint32>();
2467 uint32 entry = fields[1].Get<uint32>();
2468
2469 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
2470 if (!gInfo)
2471 {
2472 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non existing gameobject entry {}, skipped.", guid, entry);
2473 continue;
2474 }
2475
2476 if (!gInfo->displayId)
2477 {
2478 switch (gInfo->type)
2479 {
2482 break;
2483 default:
2484 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) doesn't have a displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2485 break;
2486 }
2487 }
2488
2489 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
2490 {
2491 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) has an invalid displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2492 continue;
2493 }
2494
2496
2497 data.id = entry;
2498 data.mapid = fields[2].Get<uint16>();
2499 data.posX = fields[3].Get<float>();
2500 data.posY = fields[4].Get<float>();
2501 data.posZ = fields[5].Get<float>();
2502 data.orientation = fields[6].Get<float>();
2503 data.rotation.x = fields[7].Get<float>();
2504 data.rotation.y = fields[8].Get<float>();
2505 data.rotation.z = fields[9].Get<float>();
2506 data.rotation.w = fields[10].Get<float>();
2507 data.spawntimesecs = fields[11].Get<int32>();
2508 data.ScriptId = GetScriptId(fields[18].Get<std::string>());
2509 if (!data.ScriptId)
2510 data.ScriptId = gInfo->ScriptId;
2511
2512 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2513 if (!mapEntry)
2514 {
2515 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existed map (Id: {}), skip", guid, data.id, data.mapid);
2516 continue;
2517 }
2518
2519 if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
2520 {
2521 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `spawntimesecs` (0) value, but the gameobejct is marked as despawnable at action.", guid, data.id);
2522 }
2523
2524 data.animprogress = fields[12].Get<uint8>();
2525 data.artKit = 0;
2526
2527 uint32 go_state = fields[13].Get<uint8>();
2528 if (go_state >= MAX_GO_STATE)
2529 {
2530 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skip", guid, data.id, go_state);
2531 continue;
2532 }
2533 data.go_state = GOState(go_state);
2534
2535 data.spawnMask = fields[14].Get<uint8>();
2536
2537 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2538 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) that has wrong spawn mask {} including not supported difficulty modes for map (Id: {}), skip", guid, data.id, data.spawnMask, data.mapid);
2539
2540 data.phaseMask = fields[15].Get<uint32>();
2541 int16 gameEvent = fields[16].Get<int8>();
2542 uint32 PoolId = fields[17].Get<uint32>();
2543
2544 if (data.rotation.x < -1.0f || data.rotation.x > 1.0f)
2545 {
2546 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skip", guid, data.id, data.rotation.x);
2547 continue;
2548 }
2549
2550 if (data.rotation.y < -1.0f || data.rotation.y > 1.0f)
2551 {
2552 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skip", guid, data.id, data.rotation.y);
2553 continue;
2554 }
2555
2556 if (data.rotation.z < -1.0f || data.rotation.z > 1.0f)
2557 {
2558 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skip", guid, data.id, data.rotation.z);
2559 continue;
2560 }
2561
2562 if (data.rotation.w < -1.0f || data.rotation.w > 1.0f)
2563 {
2564 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skip", guid, data.id, data.rotation.w);
2565 continue;
2566 }
2567
2568 if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
2569 {
2570 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
2571 continue;
2572 }
2573
2574 if (data.phaseMask == 0)
2575 {
2576 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
2577 data.phaseMask = 1;
2578 }
2579
2581 {
2582 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2583 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2584
2586
2587 stmt->SetData(0, zoneId);
2588 stmt->SetData(1, areaId);
2589 stmt->SetData(2, guid);
2590
2591 WorldDatabase.Execute(stmt);
2592 }
2593
2594 if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
2595 AddGameobjectToGrid(guid, &data);
2596 } while (result->NextRow());
2597
2598 LOG_INFO("server.loading", ">> Loaded {} Gameobjects in {} ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
2599 LOG_INFO("server.loading", " ");
2600}
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
@ CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA
Definition: IWorld.h:159
#define MAX_GO_STATE
Definition: GameObjectData.h:28
GOState
Definition: GameObjectData.h:689
@ WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA
Definition: WorldDatabase.h:100
@ GAMEOBJECT_TYPE_TRAP
Definition: SharedDefines.h:1566
uint32 ScriptId
Definition: GameObjectData.h:708
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition: MapMgr.h:91

References _gameObjectDataStore, _transportMaps, AddGameobjectToGrid(), GameObjectData::animprogress, GameObjectData::artKit, CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA, GAMEOBJECT_TYPE_SPELL_FOCUS, GAMEOBJECT_TYPE_TRAP, Field::Get(), GetGameObjectTemplate(), GetMapDifficultyData(), getMSTime(), GetMSTimeDiffToNow(), GetScriptId(), GameObjectData::go_state, GameObjectData::id, MapMgr::IsValidMapCoord(), LOG_ERROR, LOG_INFO, LOG_WARN, GameObjectData::mapid, MAX_DIFFICULTY, MAX_GO_STATE, GameObjectData::orientation, GameObjectData::phaseMask, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, GameObjectData::rotation, GameObjectData::ScriptId, PreparedStatementBase::SetData(), sGameObjectDisplayInfoStore, sMapMgr, sMapStore, GameObjectData::spawnMask, GameObjectData::spawntimesecs, sWorld, WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA, and WorldDatabase.

◆ LoadGameObjectTemplate()

void ObjectMgr::LoadGameObjectTemplate ( )
7106{
7107 uint32 oldMSTime = getMSTime();
7108
7109 // 0 1 2 3 4 5 6 7
7110 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7111 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7112 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7113 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7114 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7115 "FROM gameobject_template");
7116
7117 if (!result)
7118 {
7119 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7120 LOG_INFO("server.loading", " ");
7121 return;
7122 }
7123
7124 _gameObjectTemplateStore.rehash(result->GetRowCount());
7125 uint32 count = 0;
7126 do
7127 {
7128 Field* fields = result->Fetch();
7129
7130 uint32 entry = fields[0].Get<uint32>();
7131
7133
7134 got.entry = entry;
7135 got.type = uint32(fields[1].Get<uint8>());
7136 got.displayId = fields[2].Get<uint32>();
7137 got.name = fields[3].Get<std::string>();
7138 got.IconName = fields[4].Get<std::string>();
7139 got.castBarCaption = fields[5].Get<std::string>();
7140 got.unk1 = fields[6].Get<std::string>();
7141 got.size = fields[7].Get<float>();
7142
7143 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7144 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7145
7146 got.AIName = fields[32].Get<std::string>();
7147 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7148 got.IsForQuests = false;
7149
7150 // Checks
7151 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7152 {
7153 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7154 }
7155
7156 switch (got.type)
7157 {
7158 case GAMEOBJECT_TYPE_DOOR: //0
7159 {
7160 if (got.door.lockId)
7161 CheckGOLockId(&got, got.door.lockId, 1);
7162 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7163 break;
7164 }
7165 case GAMEOBJECT_TYPE_BUTTON: //1
7166 {
7167 if (got.button.lockId)
7168 CheckGOLockId(&got, got.button.lockId, 1);
7169 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7170 break;
7171 }
7173 {
7174 if (got.questgiver.lockId)
7175 CheckGOLockId(&got, got.questgiver.lockId, 0);
7176 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7177 break;
7178 }
7179 case GAMEOBJECT_TYPE_CHEST: //3
7180 {
7181 if (got.chest.lockId)
7182 CheckGOLockId(&got, got.chest.lockId, 0);
7183
7184 CheckGOConsumable(&got, got.chest.consumable, 3);
7185
7186 if (got.chest.linkedTrapId) // linked trap
7187 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7188 break;
7189 }
7190 case GAMEOBJECT_TYPE_TRAP: //6
7191 {
7192 if (got.trap.lockId)
7193 CheckGOLockId(&got, got.trap.lockId, 0);
7194 break;
7195 }
7196 case GAMEOBJECT_TYPE_CHAIR: //7
7197 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7198 break;
7200 {
7201 if (got.spellFocus.focusId)
7202 {
7203 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7204 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7205 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7206 }
7207
7208 if (got.spellFocus.linkedTrapId) // linked trap
7209 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7210 break;
7211 }
7212 case GAMEOBJECT_TYPE_GOOBER: //10
7213 {
7214 if (got.goober.lockId)
7215 CheckGOLockId(&got, got.goober.lockId, 0);
7216
7217 CheckGOConsumable(&got, got.goober.consumable, 3);
7218
7219 if (got.goober.pageId) // pageId
7220 {
7221 if (!GetPageText(got.goober.pageId))
7222 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7223 entry, got.type, got.goober.pageId, got.goober.pageId);
7224 }
7225 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7226 if (got.goober.linkedTrapId) // linked trap
7227 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7228 break;
7229 }
7231 {
7232 if (got.areadamage.lockId)
7233 CheckGOLockId(&got, got.areadamage.lockId, 0);
7234 break;
7235 }
7236 case GAMEOBJECT_TYPE_CAMERA: //13
7237 {
7238 if (got.camera.lockId)
7239 CheckGOLockId(&got, got.camera.lockId, 0);
7240 break;
7241 }
7243 {
7244 if (got.moTransport.taxiPathId)
7245 {
7246 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7247 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7248 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7249 }
7250 if (uint32 transportMap = got.moTransport.mapID)
7251 _transportMaps.insert(transportMap);
7252 break;
7253 }
7255 break;
7257 {
7258 // always must have spell
7259 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7260 break;
7261 }
7262 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7263 {
7264 if (got.flagstand.lockId)
7265 CheckGOLockId(&got, got.flagstand.lockId, 0);
7266 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7267 break;
7268 }
7270 {
7271 if (got.fishinghole.lockId)
7272 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7273 break;
7274 }
7275 case GAMEOBJECT_TYPE_FLAGDROP: //26
7276 {
7277 if (got.flagdrop.lockId)
7278 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7279 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7280 break;
7281 }
7283 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7284 break;
7285 }
7286
7287 ++count;
7288 } while (result->NextRow());
7289
7290 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7291 LOG_INFO("server.loading", " ");
7292}
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7086
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7065
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition: ObjectMgr.cpp:7074
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7095
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7055
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7046
#define sGameObjectAIRegistry
Definition: GameObjectAIFactory.h:50
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
@ GAMEOBJECT_TYPE_CAMERA
Definition: SharedDefines.h:1573
@ GAMEOBJECT_TYPE_BUTTON
Definition: SharedDefines.h:1561
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition: SharedDefines.h:1575
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition: SharedDefines.h:1578
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition: SharedDefines.h:1585
@ GAMEOBJECT_TYPE_FLAGDROP
Definition: SharedDefines.h:1586
@ GAMEOBJECT_TYPE_SPELLCASTER
Definition: SharedDefines.h:1582
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition: SharedDefines.h:1584
@ GAMEOBJECT_TYPE_CHAIR
Definition: SharedDefines.h:1567
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition: SharedDefines.h:1572
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition: SharedDefines.h:1592
@ GAMEOBJECT_TYPE_DOOR
Definition: SharedDefines.h:1560
#define MAX_GAMEOBJECT_DATA
Definition: SharedDefines.h:1599
PageText const * GetPageText(uint32 pageEntry)
Definition: ObjectMgr.cpp:5738

References _gameObjectTemplateStore, _transportMaps, CheckAndFixGOChairHeightId(), CheckGOConsumable(), CheckGOLinkedTrapId(), CheckGOLockId(), CheckGONoDamageImmuneId(), CheckGOSpellId(), GAMEOBJECT_TYPE_AREADAMAGE, GAMEOBJECT_TYPE_BARBER_CHAIR, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_CAMERA, GAMEOBJECT_TYPE_CHAIR, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FLAGDROP, GAMEOBJECT_TYPE_FLAGSTAND, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_MO_TRANSPORT, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_SPELL_FOCUS, GAMEOBJECT_TYPE_SPELLCASTER, GAMEOBJECT_TYPE_SUMMONING_RITUAL, GAMEOBJECT_TYPE_TRAP, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), GetPageText(), GetScriptId(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_GAMEOBJECT_DATA, sGameObjectAIRegistry, sSpellFocusObjectStore, sTaxiPathNodesByPath, and WorldDatabase.

◆ LoadGameObjectTemplateAddons()

void ObjectMgr::LoadGameObjectTemplateAddons ( )
7295{
7296 uint32 oldMSTime = getMSTime();
7297
7298 // 0 1 2 3 4 5 6 7 8
7299 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
7300
7301 if (!result)
7302 {
7303 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
7304 LOG_INFO("server.loading", " ");
7305 return;
7306 }
7307
7308 uint32 count = 0;
7309 do
7310 {
7311 Field* fields = result->Fetch();
7312
7313 uint32 entry = fields[0].Get<uint32>();
7314
7315 GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(entry);
7316 if (!got)
7317 {
7318 LOG_ERROR("sql.sql",
7319 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
7320 entry);
7321 continue;
7322 }
7323
7325 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
7326 gameObjectAddon.flags = fields[2].Get<uint32>();
7327 gameObjectAddon.mingold = fields[3].Get<uint32>();
7328 gameObjectAddon.maxgold = fields[4].Get<uint32>();
7329
7330 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
7331 {
7332 uint32 artKitID = fields[5 + i].Get<uint32>();
7333 if (!artKitID)
7334 continue;
7335
7336 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
7337 {
7338 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
7339 continue;
7340 }
7341
7342 gameObjectAddon.artKits[i] = artKitID;
7343 }
7344
7345 // checks
7346 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
7347 LOG_ERROR("sql.sql",
7348 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
7349 entry, gameObjectAddon.faction);
7350
7351 if (gameObjectAddon.maxgold > 0)
7352 {
7353 switch (got->type)
7354 {
7357 break;
7358 default:
7359 LOG_ERROR("sql.sql",
7360 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
7361 entry, got->type);
7362 break;
7363 }
7364 }
7365
7366 ++count;
7367 } while (result->NextRow());
7368
7369 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7370 LOG_INFO("server.loading", " ");
7371}
DBCStorage< GameObjectArtKitEntry > sGameObjectArtKitStore(GameObjectArtKitfmt)
Definition: GameObjectData.h:665
uint32 mingold
Definition: GameObjectData.h:669
uint32 flags
Definition: GameObjectData.h:668
uint32 faction
Definition: GameObjectData.h:667
std::array< uint32, 4 > artKits
Definition: GameObjectData.h:671
uint32 maxgold
Definition: GameObjectData.h:670

References _gameObjectTemplateAddonStore, GameObjectTemplateAddon::artKits, GameObjectTemplateAddon::faction, GameObjectTemplateAddon::flags, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_FISHINGHOLE, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, GameObjectTemplateAddon::maxgold, GameObjectTemplateAddon::mingold, sFactionTemplateStore, sGameObjectArtKitStore, sObjectMgr, and WorldDatabase.

◆ LoadGameTele()

void ObjectMgr::LoadGameTele ( )
8835{
8836 uint32 oldMSTime = getMSTime();
8837
8838 _gameTeleStore.clear(); // for reload case
8839
8840 // 0 1 2 3 4 5 6
8841 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
8842
8843 if (!result)
8844 {
8845 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
8846 LOG_INFO("server.loading", " ");
8847 return;
8848 }
8849
8850 uint32 count = 0;
8851
8852 do
8853 {
8854 Field* fields = result->Fetch();
8855
8856 uint32 id = fields[0].Get<uint32>();
8857
8858 GameTele gt;
8859
8860 gt.position_x = fields[1].Get<float>();
8861 gt.position_y = fields[2].Get<float>();
8862 gt.position_z = fields[3].Get<float>();
8863 gt.orientation = fields[4].Get<float>();
8864 gt.mapId = fields[5].Get<uint16>();
8865 gt.name = fields[6].Get<std::string>();
8866
8867 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
8868 {
8869 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
8870 continue;
8871 }
8872
8873 if (!Utf8toWStr(gt.name, gt.wnameLow))
8874 {
8875 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
8876 continue;
8877 }
8878
8879 wstrToLower(gt.wnameLow);
8880
8881 _gameTeleStore[id] = gt;
8882
8883 ++count;
8884 } while (result->NextRow());
8885
8886 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8887 LOG_INFO("server.loading", " ");
8888}
float position_x
Definition: ObjectMgr.h:136

References _gameTeleStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), MapMgr::IsValidMapCoord(), LOG_ERROR, LOG_INFO, LOG_WARN, GameTele::position_x, Utf8toWStr(), WorldDatabase, and wstrToLower().

◆ LoadGossipMenu()

void ObjectMgr::LoadGossipMenu ( )
9251{
9252 uint32 oldMSTime = getMSTime();
9253
9254 _gossipMenusStore.clear();
9255
9256 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
9257
9258 if (!result)
9259 {
9260 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
9261 LOG_INFO("server.loading", " ");
9262 return;
9263 }
9264
9265 do
9266 {
9267 Field* fields = result->Fetch();
9268
9269 GossipMenus gMenu;
9270
9271 gMenu.MenuID = fields[0].Get<uint32>();
9272 gMenu.TextID = fields[1].Get<uint32>();
9273
9274 if (!GetGossipText(gMenu.TextID))
9275 {
9276 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
9277 continue;
9278 }
9279
9280 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
9281 } while (result->NextRow());
9282
9283 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
9284 LOG_INFO("server.loading", " ");
9285}
Definition: ObjectMgr.h:624
uint32 TextID
Definition: ObjectMgr.h:626
uint32 MenuID
Definition: ObjectMgr.h:625
GossipText const * GetGossipText(uint32 Text_ID) const
Definition: ObjectMgr.cpp:5912

References _gossipMenusStore, Field::Get(), GetGossipText(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, GossipMenus::MenuID, GossipMenus::TextID, and WorldDatabase.

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
9288{
9289 uint32 oldMSTime = getMSTime();
9290
9291 _gossipMenuItemsStore.clear();
9292
9293 QueryResult result = WorldDatabase.Query(
9294 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9295 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
9296 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
9297
9298 if (!result)
9299 {
9300 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
9301 LOG_INFO("server.loading", " ");
9302 return;
9303 }
9304
9305 do
9306 {
9307 Field* fields = result->Fetch();
9308
9309 GossipMenuItems gMenuItem;
9310
9311 gMenuItem.MenuID = fields[0].Get<uint32>();
9312 gMenuItem.OptionID = fields[1].Get<uint16>();
9313 gMenuItem.OptionIcon = fields[2].Get<uint32>();
9314 gMenuItem.OptionText = fields[3].Get<std::string>();
9315 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
9316 gMenuItem.OptionType = fields[5].Get<uint8>();
9317 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
9318 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
9319 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
9320 gMenuItem.BoxCoded = fields[9].Get<bool>();
9321 gMenuItem.BoxMoney = fields[10].Get<uint32>();
9322 gMenuItem.BoxText = fields[11].Get<std::string>();
9323 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
9324
9325 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
9326 {
9327 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has unknown icon id {}. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionIcon);
9328 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
9329 }
9330
9332 {
9333 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
9334 gMenuItem.OptionBroadcastTextID = 0;
9335 }
9336
9337 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
9338 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has unknown option id {}. Option will not be used", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionType);
9339
9340 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
9341 {
9342 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
9343 gMenuItem.ActionPoiID = 0;
9344 }
9345
9346 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
9347 {
9348 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
9349 gMenuItem.BoxBroadcastTextID = 0;
9350 }
9351
9352 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
9353 } while (result->NextRow());
9354
9355 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
9356 LOG_INFO("server.loading", " ");
9357}
@ GOSSIP_ICON_CHAT
Definition: GossipDef.h:60
@ GOSSIP_ICON_MAX
Definition: GossipDef.h:81
@ GOSSIP_OPTION_MAX
Definition: GossipDef.h:55
Definition: ObjectMgr.h:606
uint8 OptionIcon
Definition: ObjectMgr.h:609
uint32 BoxBroadcastTextID
Definition: ObjectMgr.h:620
std::string OptionText
Definition: ObjectMgr.h:610
uint32 ActionMenuID
Definition: ObjectMgr.h:614
bool BoxCoded
Definition: ObjectMgr.h:616
uint32 MenuID
Definition: ObjectMgr.h:607
uint32 OptionNpcFlag
Definition: ObjectMgr.h:613
uint32 ActionPoiID
Definition: ObjectMgr.h:615
uint32 BoxMoney
Definition: ObjectMgr.h:617
std::string BoxText
Definition: ObjectMgr.h:618
uint32 OptionID
Definition: ObjectMgr.h:608
uint32 OptionType
Definition: ObjectMgr.h:612
uint32 OptionBroadcastTextID
Definition: ObjectMgr.h:611
PointOfInterest const * GetPointOfInterest(uint32 id) const
Definition: ObjectMgr.h:918
BroadcastText const * GetBroadcastText(uint32 id) const
Definition: ObjectMgr.h:1188

References _gossipMenuItemsStore, GossipMenuItems::ActionMenuID, GossipMenuItems::ActionPoiID, GossipMenuItems::BoxBroadcastTextID, GossipMenuItems::BoxCoded, GossipMenuItems::BoxMoney, GossipMenuItems::BoxText, Field::Get(), GetBroadcastText(), getMSTime(), GetMSTimeDiffToNow(), GetPointOfInterest(), GOSSIP_ICON_CHAT, GOSSIP_ICON_MAX, GOSSIP_OPTION_MAX, LOG_ERROR, LOG_INFO, LOG_WARN, GossipMenuItems::MenuID, GossipMenuItems::OptionBroadcastTextID, GossipMenuItems::OptionIcon, GossipMenuItems::OptionID, GossipMenuItems::OptionNpcFlag, GossipMenuItems::OptionText, GossipMenuItems::OptionType, and WorldDatabase.

◆ LoadGossipMenuItemsLocales()

void ObjectMgr::LoadGossipMenuItemsLocales ( )
421{
422 uint32 oldMSTime = getMSTime();
423
424 _gossipMenuItemsLocaleStore.clear(); // need for reload case
425
426 // 0 1 2 3 4
427 QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale");
428
429 if (!result)
430 return;
431
432 do
433 {
434 Field* fields = result->Fetch();
435
436 uint32 MenuID = fields[0].Get<uint32>();
437 uint16 OptionID = fields[1].Get<uint16>();
438
439 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
440 if (locale == LOCALE_enUS)
441 continue;
442
444 AddLocaleString(fields[3].Get<std::string>(), locale, data.OptionText);
445 AddLocaleString(fields[4].Get<std::string>(), locale, data.BoxText);
446 } while (result->NextRow());
447
448 LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale Strings in {} ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
449}
Definition: CreatureData.h:352
std::vector< std::string > BoxText
Definition: CreatureData.h:354
std::vector< std::string > OptionText
Definition: CreatureData.h:353

References _gossipMenuItemsLocaleStore, AddLocaleString(), GossipMenuItemsLocale::BoxText, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, MAKE_PAIR32(), GossipMenuItemsLocale::OptionText, and WorldDatabase.

◆ LoadGossipText()

void ObjectMgr::LoadGossipText ( )
5921{
5922 uint32 oldMSTime = getMSTime();
5923
5924 QueryResult result = WorldDatabase.Query("SELECT ID, "
5925 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
5926 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
5927 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
5928 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
5929 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
5930 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
5931 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
5932 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
5933 "FROM npc_text");
5934
5935 if (!result)
5936 {
5937 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
5938 LOG_INFO("server.loading", " ");
5939 return;
5940 }
5941
5942 _gossipTextStore.rehash(result->GetRowCount());
5943
5944 uint32 count = 0;
5945 uint8 cic;
5946
5947 do
5948 {
5949 cic = 0;
5950
5951 Field* fields = result->Fetch();
5952
5953 uint32 id = fields[cic++].Get<uint32>();
5954 if (!id)
5955 {
5956 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
5957 continue;
5958 }
5959
5960 GossipText& gText = _gossipTextStore[id];
5961
5962 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
5963 {
5964 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
5965 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
5966 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
5967 gText.Options[i].Language = fields[cic++].Get<uint8>();
5968 gText.Options[i].Probability = fields[cic++].Get<float>();
5969
5970 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
5971 {
5972 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
5973 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
5974 }
5975 }
5976
5977 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
5978 {
5979 if (gText.Options[i].BroadcastTextID)
5980 {
5982 {
5983 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
5984 gText.Options[i].BroadcastTextID = 0;
5985 }
5986 }
5987 }
5988
5989 count++;
5990 } while (result->NextRow());
5991
5992 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5993 LOG_INFO("server.loading", " ");
5994}
#define MAX_GOSSIP_TEXT_OPTIONS
Definition: NPCHandler.h:42
#define MAX_GOSSIP_TEXT_EMOTES
Definition: NPCHandler.h:30
uint32 _Emote
Definition: NPCHandler.h:26
uint32 _Delay
Definition: NPCHandler.h:27
std::string Text_0
Definition: NPCHandler.h:34
QEmote Emotes[MAX_GOSSIP_TEXT_EMOTES]
Definition: NPCHandler.h:39
uint32 Language
Definition: NPCHandler.h:37
float Probability
Definition: NPCHandler.h:38
uint32 BroadcastTextID
Definition: NPCHandler.h:36
std::string Text_1
Definition: NPCHandler.h:35
Definition: NPCHandler.h:45
GossipTextOption Options[MAX_GOSSIP_TEXT_OPTIONS]
Definition: NPCHandler.h:46

References QEmote::_Delay, QEmote::_Emote, _gossipTextStore, GossipTextOption::BroadcastTextID, GossipTextOption::Emotes, Field::Get(), GetBroadcastText(), getMSTime(), GetMSTimeDiffToNow(), GossipTextOption::Language, LOG_ERROR, LOG_INFO, LOG_WARN, MAX_GOSSIP_TEXT_EMOTES, MAX_GOSSIP_TEXT_OPTIONS, GossipText::Options, GossipTextOption::Probability, GossipTextOption::Text_0, GossipTextOption::Text_1, and WorldDatabase.

◆ LoadInstanceEncounters()

void ObjectMgr::LoadInstanceEncounters ( )
5828{
5829 uint32 oldMSTime = getMSTime();
5830
5831 // 0 1 2 3
5832 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
5833 if (!result)
5834 {
5835 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
5836 LOG_INFO("server.loading", " ");
5837 return;
5838 }
5839
5840 uint32 count = 0;
5841 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
5842 do
5843 {
5844 Field* fields = result->Fetch();
5845 uint32 entry = fields[0].Get<uint32>();
5846 uint8 creditType = fields[1].Get<uint8>();
5847 uint32 creditEntry = fields[2].Get<uint32>();
5848 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
5849 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
5850 if (!dungeonEncounter)
5851 {
5852 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
5853 continue;
5854 }
5855
5856 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
5857 {
5858 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
5859 continue;
5860 }
5861
5862 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
5863 if (lastEncounterDungeon)
5864 {
5865 if (itr != dungeonLastBosses.end())
5866 {
5867 LOG_ERROR("sql.sql", "Table `instance_encounters` specified encounter {} ({}) as last encounter but {} ({}) is already marked as one, skipped!", entry, dungeonEncounter->encounterName[0], itr->second->id, itr->second->encounterName[0]);
5868 continue;
5869 }
5870
5871 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
5872 }
5873
5874 switch (creditType)
5875 {
5877 {
5878 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
5879 if (!creatureInfo)
5880 {
5881 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5882 continue;
5883 }
5884 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
5885 break;
5886 }
5888 {
5889 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
5890 if (!spellInfo)
5891 {
5892 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5893 continue;
5894 }
5895 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
5896 break;
5897 }
5898 default:
5899 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
5900 continue;
5901 }
5902
5903 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
5904 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
5905 ++count;
5906 } while (result->NextRow());
5907
5908 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5909 LOG_INFO("server.loading", " ");
5910}
EncounterCreditType
Definition: Map.h:307
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition: Map.h:308
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition: Map.h:309
std::list< DungeonEncounter const * > DungeonEncounterList
Definition: ObjectMgr.h:712
#define sLFGMgr
Definition: LFGMgr.h:641
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition: CreatureData.h:74
@ SPELL_ATTR0_CU_ENCOUNTER_REWARD
Definition: SpellInfo.h:207
Definition: ObjectMgr.h:702
Definition: DBCStructure.h:866

References _dungeonEncounterStore, CREATURE_FLAG_EXTRA_DUNGEON_BOSS, ENCOUNTER_CREDIT_CAST_SPELL, ENCOUNTER_CREDIT_KILL_CREATURE, Field::Get(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAKE_PAIR32(), sDungeonEncounterStore, sLFGMgr, SPELL_ATTR0_CU_ENCOUNTER_REWARD, sSpellMgr, and WorldDatabase.

◆ LoadInstanceTemplate()

void ObjectMgr::LoadInstanceTemplate ( )
5777{
5778 uint32 oldMSTime = getMSTime();
5779
5780 // 0 1 2 4
5781 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
5782
5783 if (!result)
5784 {
5785 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `page_text` is empty!");
5786 LOG_INFO("server.loading", " ");
5787 return;
5788 }
5789
5790 uint32 count = 0;
5791 do
5792 {
5793 Field* fields = result->Fetch();
5794
5795 uint16 mapID = fields[0].Get<uint16>();
5796
5797 if (!MapMgr::IsValidMAP(mapID, true))
5798 {
5799 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
5800 continue;
5801 }
5802
5803 InstanceTemplate instanceTemplate;
5804
5805 instanceTemplate.AllowMount = fields[3].Get<bool>();
5806 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
5807 instanceTemplate.ScriptId = sObjectMgr->GetScriptId(fields[2].Get<std::string>());
5808
5809 _instanceTemplateStore[mapID] = instanceTemplate;
5810
5811 ++count;
5812 } while (result->NextRow());
5813
5814 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5815 LOG_INFO("server.loading", " ");
5816}
bool AllowMount
Definition: Map.h:277
uint32 ScriptId
Definition: Map.h:276
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition: MapMgr.cpp:309

References _instanceTemplateStore, InstanceTemplate::AllowMount, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), MapMgr::IsValidMAP(), LOG_ERROR, LOG_INFO, LOG_WARN, InstanceTemplate::Parent, InstanceTemplate::ScriptId, sObjectMgr, and WorldDatabase.

◆ LoadItemLocales()

void ObjectMgr::LoadItemLocales ( )
2631{
2632 uint32 oldMSTime = getMSTime();
2633
2634 _itemLocaleStore.clear(); // need for reload case
2635
2636 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
2637 if (!result)
2638 return;
2639
2640 do
2641 {
2642 Field* fields = result->Fetch();
2643
2644 uint32 ID = fields[0].Get<uint32>();
2645
2646 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
2647 if (locale == LOCALE_enUS)
2648 continue;
2649
2650 ItemLocale& data = _itemLocaleStore[ID];
2651 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
2652 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
2653 } while (result->NextRow());
2654
2655 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
2656}
Definition: ItemTemplate.h:838
std::vector< std::string > Description
Definition: ItemTemplate.h:840
std::vector< std::string > Name
Definition: ItemTemplate.h:839

References _itemLocaleStore, AddLocaleString(), ItemLocale::Description, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, ItemLocale::Name, and WorldDatabase.

◆ LoadItemSetNameLocales()

void ObjectMgr::LoadItemSetNameLocales ( )
3275{
3276 uint32 oldMSTime = getMSTime();
3277
3278 _itemSetNameLocaleStore.clear(); // need for reload case
3279
3280 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3281
3282 if (!result)
3283 return;
3284
3285 do
3286 {
3287 Field* fields = result->Fetch();
3288
3289 uint32 ID = fields[0].Get<uint32>();
3290
3291 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3292 if (locale == LOCALE_enUS)
3293 continue;
3294
3296 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3297 } while (result->NextRow());
3298
3299 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3300}
Definition: ItemTemplate.h:850
std::vector< std::string > Name
Definition: ItemTemplate.h:851

References _itemSetNameLocaleStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, ItemSetNameLocale::Name, and WorldDatabase.

◆ LoadItemSetNames()

void ObjectMgr::LoadItemSetNames ( )
3303{
3304 uint32 oldMSTime = getMSTime();
3305
3306 _itemSetNameStore.clear(); // needed for reload case
3307
3308 std::set<uint32> itemSetItems;
3309
3310 // fill item set member ids
3311 for (uint32 entryId = 0; entryId < sItemSetStore.GetNumRows(); ++entryId)
3312 {
3313 ItemSetEntry const* setEntry = sItemSetStore.LookupEntry(entryId);
3314 if (!setEntry)
3315 continue;
3316
3317 for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
3318 if (setEntry->itemId[i])
3319 itemSetItems.insert(setEntry->itemId[i]);
3320 }
3321
3322 // 0 1 2
3323 QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
3324
3325 if (!result)
3326 {
3327 LOG_WARN("server.loading", ">> Loaded 0 item set names. DB table `item_set_names` is empty.");
3328 LOG_INFO("server.loading", " ");
3329 return;
3330 }
3331
3332 _itemSetNameStore.rehash(result->GetRowCount());
3333 uint32 count = 0;
3334
3335 do
3336 {
3337 Field* fields = result->Fetch();
3338
3339 uint32 entry = fields[0].Get<uint32>();
3340 if (itemSetItems.find(entry) == itemSetItems.end())
3341 {
3342 LOG_ERROR("sql.sql", "Item set name (Entry: {}) not found in ItemSet.dbc, data useless.", entry);
3343 continue;
3344 }
3345
3346 ItemSetNameEntry& data = _itemSetNameStore[entry];
3347 data.name = fields[1].Get<std::string>();
3348
3349 uint32 invType = fields[2].Get<uint8>();
3350 if (invType >= MAX_INVTYPE)
3351 {
3352 LOG_ERROR("sql.sql", "Item set name (Entry: {}) has wrong InventoryType value ({})", entry, invType);
3353 invType = INVTYPE_NON_EQUIP;
3354 }
3355
3356 data.InventoryType = invType;
3357 itemSetItems.erase(entry);
3358 ++count;
3359 } while (result->NextRow());
3360
3361 if (!itemSetItems.empty())
3362 {
3363 ItemTemplate const* pProto;
3364 for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr)
3365 {
3366 uint32 entry = *itr;
3367 // add data from item_template if available
3368 pProto = sObjectMgr->GetItemTemplate(entry);
3369 if (pProto)
3370 {
3371 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, adding data from `item_template`.", entry);
3372 ItemSetNameEntry& data = _itemSetNameStore[entry];
3373 data.name = pProto->Name1;
3374 data.InventoryType = pProto->InventoryType;
3375 ++count;
3376 }
3377 else
3378 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, set will not display properly.", entry);
3379 }
3380 }
3381
3382 LOG_INFO("server.loading", ">> Loaded {} Item Set Names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3383 LOG_INFO("server.loading", " ");
3384}
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
@ INVTYPE_NON_EQUIP
Definition: ItemTemplate.h:256
#define MAX_INVTYPE
Definition: ItemTemplate.h:287
#define MAX_ITEM_SET_ITEMS
Definition: DBCStructure.h:1228
std::string Name1
Definition: ItemTemplate.h:624
uint32 InventoryType
Definition: ItemTemplate.h:632
Definition: ItemTemplate.h:844
uint32 InventoryType
Definition: ItemTemplate.h:846
std::string name
Definition: ItemTemplate.h:845
Definition: DBCStructure.h:1232
uint32 itemId[MAX_ITEM_SET_ITEMS]
Definition: DBCStructure.h:1236

References _itemSetNameStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), ItemTemplate::InventoryType, ItemSetNameEntry::InventoryType, INVTYPE_NON_EQUIP, ItemSetEntry::itemId, LOG_ERROR, LOG_INFO, LOG_WARN, MAX_INVTYPE, MAX_ITEM_SET_ITEMS, ItemSetNameEntry::name, ItemTemplate::Name1, sItemSetStore, sObjectMgr, and WorldDatabase.

◆ LoadItemTemplates()

void ObjectMgr::LoadItemTemplates ( )
2659{
2660 uint32 oldMSTime = getMSTime();
2661
2662 // 0 1 2 3 4 5 6 7 8 9 10 11 12
2663 QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, "
2664 // 13 14 15 16 17 18 19 20
2665 "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, "
2666 // 21 22 23 24 25 26 27 28
2667 "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, StatsCount, stat_type1, "
2668 // 29 30 31 32 33 34 35 36 37 38
2669 "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, "
2670 // 39 40 41 42 43 44 45 46 47
2671 "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, "
2672 // 48 49 50 51 52 53 54 55 56 57 58
2673 "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, "
2674 // 59 60 61 62 63 64 65 66 67 68
2675 "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, "
2676 // 69 70 71 72 73 74 75
2677 "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, "
2678 // 76 77 78 79 80 81 82
2679 "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, "
2680 // 83 84 85 86 87 88 89
2681 "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, "
2682 // 90 91 92 93 94 95 96
2683 "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, "
2684 // 97 98 99 100 101 102 103 104 105
2685 "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, "
2686 // 106 107 108 109 110 111 112 113 114 115 116 117
2687 "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, "
2688 // 118 119 120 121 122 123 124 125
2689 "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
2690 // 126 127 128 129 130 131 132 133
2691 "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
2692 // 134 135 136
2693 "FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
2694
2695 if (!result)
2696 {
2697 LOG_WARN("server.loading", ">> Loaded 0 item templates. DB table `item_template` is empty.");
2698 LOG_INFO("server.loading", " ");
2699 return;
2700 }
2701
2702 _itemTemplateStore.reserve(result->GetRowCount());
2703 uint32 count = 0;
2704 // original inspiration https://github.com/TrinityCore/TrinityCore/commit/0c44bd33ee7b42c924859139a9f4b04cf2b91261
2705 bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
2706
2707 do
2708 {
2709 Field* fields = result->Fetch();
2710
2711 uint32 entry = fields[0].Get<uint32>();
2712
2713 ItemTemplate& itemTemplate = _itemTemplateStore[entry];
2714
2715 itemTemplate.ItemId = entry;
2716 itemTemplate.Class = uint32(fields[1].Get<uint8>());
2717 itemTemplate.SubClass = uint32(fields[2].Get<uint8>());
2718 itemTemplate.SoundOverrideSubclass = int32(fields[3].Get<int8>());
2719 itemTemplate.Name1 = fields[4].Get<std::string>();
2720 itemTemplate.DisplayInfoID = fields[5].Get<uint32>();
2721 itemTemplate.Quality = uint32(fields[6].Get<uint8>());
2722 itemTemplate.Flags = ItemFlags(fields[7].Get<uint32>());
2723 itemTemplate.Flags2 = ItemFlags2(fields[8].Get<uint32>());
2724 itemTemplate.BuyCount = uint32(fields[9].Get<uint8>());
2725 itemTemplate.BuyPrice = int32(fields[10].Get<int64>() * sWorld->getRate((Rates)(RATE_BUYVALUE_ITEM_POOR + itemTemplate.Quality)));
2726 itemTemplate.SellPrice = uint32(fields[11].Get<uint32>() * sWorld->getRate((Rates)(RATE_SELLVALUE_ITEM_POOR + itemTemplate.Quality)));
2727 itemTemplate.InventoryType = uint32(fields[12].Get<uint8>());
2728 itemTemplate.AllowableClass = fields[13].Get<int32>();
2729 itemTemplate.AllowableRace = fields[14].Get<int32>();
2730 itemTemplate.ItemLevel = uint32(fields[15].Get<uint16>());
2731 itemTemplate.RequiredLevel = uint32(fields[16].Get<uint8>());
2732 itemTemplate.RequiredSkill = uint32(fields[17].Get<uint16>());
2733 itemTemplate.RequiredSkillRank = uint32(fields[18].Get<uint16>());
2734 itemTemplate.RequiredSpell = fields[19].Get<uint32>();
2735 itemTemplate.RequiredHonorRank = fields[20].Get<uint32>();
2736 itemTemplate.RequiredCityRank = fields[21].Get<uint32>();
2737 itemTemplate.RequiredReputationFaction = uint32(fields[22].Get<uint16>());
2738 itemTemplate.RequiredReputationRank = uint32(fields[23].Get<uint16>());
2739 itemTemplate.MaxCount = fields[24].Get<int32>();
2740 itemTemplate.Stackable = fields[25].Get<int32>();
2741 itemTemplate.ContainerSlots = uint32(fields[26].Get<uint8>());
2742 itemTemplate.StatsCount = uint32(fields[27].Get<uint8>());
2743
2744 for (uint8 i = 0; i < itemTemplate.StatsCount; ++i)
2745 {
2746 itemTemplate.ItemStat[i].ItemStatType = uint32(fields[28 + i * 2].Get<uint8>());
2747 itemTemplate.ItemStat[i].ItemStatValue = fields[29 + i * 2].Get<int32>();
2748 }
2749
2750 itemTemplate.ScalingStatDistribution = uint32(fields[48].Get<uint16>());
2751 itemTemplate.ScalingStatValue = fields[49].Get<int32>();
2752
2753 for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
2754 {
2755 itemTemplate.Damage[i].DamageMin = fields[50 + i * 3].Get<float>();
2756 itemTemplate.Damage[i].DamageMax = fields[51 + i * 3].Get<float>();
2757 itemTemplate.Damage[i].DamageType = uint32(fields[52 + i * 3].Get<uint8>());
2758 }
2759
2760 itemTemplate.Armor = fields[56].Get<uint32>();
2761 itemTemplate.HolyRes = fields[57].Get<int32>();
2762 itemTemplate.FireRes = fields[58].Get<int32>();
2763 itemTemplate.NatureRes = fields[59].Get<int32>();
2764 itemTemplate.FrostRes = fields[60].Get<int32>();
2765 itemTemplate.ShadowRes = fields[61].Get<int32>();
2766 itemTemplate.ArcaneRes = fields[62].Get<int32>();
2767 itemTemplate.Delay = uint32(fields[63].Get<uint16>());
2768 itemTemplate.AmmoType = uint32(fields[64].Get<uint8>());
2769 itemTemplate.RangedModRange = fields[65].Get<float>();
2770
2771 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
2772 {
2773 itemTemplate.Spells[i].SpellId = fields[66 + i * 7 ].Get<int32>();
2774 itemTemplate.Spells[i].SpellTrigger = uint32(fields[67 + i * 7].Get<uint8>());
2775 itemTemplate.Spells[i].SpellCharges = int32(fields[68 + i * 7].Get<int16>());
2776 itemTemplate.Spells[i].SpellPPMRate = fields[69 + i * 7].Get<float>();
2777 itemTemplate.Spells[i].SpellCooldown = fields[70 + i * 7].Get<int32>();
2778 itemTemplate.Spells[i].SpellCategory = uint32(fields[71 + i * 7].Get<uint16>());
2779 itemTemplate.Spells[i].SpellCategoryCooldown = fields[72 + i * 7].Get<int32>();
2780 }
2781
2782 itemTemplate.Bonding = uint32(fields[101].Get<uint8>());
2783 itemTemplate.Description = fields[102].Get<std::string>();
2784 itemTemplate.PageText = fields[103].Get<uint32>();
2785 itemTemplate.LanguageID = uint32(fields[104].Get<uint8>());
2786 itemTemplate.PageMaterial = uint32(fields[105].Get<uint8>());
2787 itemTemplate.StartQuest = fields[106].Get<uint32>();
2788 itemTemplate.LockID = fields[107].Get<uint32>();
2789 itemTemplate.Material = int32(fields[108].Get<int8>());
2790 itemTemplate.Sheath = uint32(fields[109].Get<uint8>());
2791 itemTemplate.RandomProperty = fields[110].Get<int32>();
2792 itemTemplate.RandomSuffix = fields[111].Get<int32>();
2793 itemTemplate.Block = fields[112].Get<uint32>();
2794 itemTemplate.ItemSet = fields[113].Get<uint32>();
2795 itemTemplate.MaxDurability = uint32(fields[114].Get<uint16>());
2796 itemTemplate.Area = fields[115].Get<uint32>();
2797 itemTemplate.Map = uint32(fields[116].Get<uint16>());
2798 itemTemplate.BagFamily = fields[117].Get<uint32>();
2799 itemTemplate.TotemCategory = fields[118].Get<uint32>();
2800
2801 for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
2802 {
2803 itemTemplate.Socket[i].Color = uint32(fields[119 + i * 2].Get<uint8>());
2804 itemTemplate.Socket[i].Content = fields[120 + i * 2].Get<uint32>();
2805 }
2806
2807 itemTemplate.socketBonus = fields[125].Get<uint32>();
2808 itemTemplate.GemProperties = fields[126].Get<uint32>();
2809 itemTemplate.RequiredDisenchantSkill = uint32(fields[127].Get<int16>());
2810 itemTemplate.ArmorDamageModifier = fields[128].Get<float>();
2811 itemTemplate.Duration = fields[129].Get<uint32>();
2812 itemTemplate.ItemLimitCategory = uint32(fields[130].Get<int16>());
2813 itemTemplate.HolidayId = fields[131].Get<uint32>();
2814 itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].Get<std::string>());
2815 itemTemplate.DisenchantID = fields[133].Get<uint32>();
2816 itemTemplate.FoodType = uint32(fields[134].Get<uint8>());
2817 itemTemplate.MinMoneyLoot = fields[135].Get<uint32>();
2818 itemTemplate.MaxMoneyLoot = fields[136].Get<uint32>();
2819 itemTemplate.FlagsCu = ItemFlagsCustom(fields[137].Get<uint32>());
2820
2821 // Checks
2822 ItemEntry const* dbcitem = sItemStore.LookupEntry(entry);
2823
2824 if (!dbcitem)
2825 {
2826 LOG_DEBUG("sql.sql", "Item (Entry: {}) does not exist in item.dbc! (not correct id?).", entry);
2827 continue;
2828 }
2829
2830 if (enforceDBCAttributes)
2831 {
2832 if (itemTemplate.Class != dbcitem->ClassID)
2833 {
2834 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Class value ({}), must be ({}).", entry, itemTemplate.Class, dbcitem->ClassID);
2835 itemTemplate.Class = dbcitem->ClassID;
2836 }
2837 if (itemTemplate.SubClass != dbcitem->SubclassID)
2838 {
2839 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Subclass value ({}) for class {}, must be ({}).", entry, itemTemplate.SubClass, itemTemplate.Class, dbcitem->SubclassID);
2840 itemTemplate.SubClass = dbcitem->SubclassID;
2841 }
2842 if (itemTemplate.SoundOverrideSubclass != dbcitem->SoundOverrideSubclassID)
2843 {
2844 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct SoundOverrideSubclass ({}), must be {}.", entry, itemTemplate.SoundOverrideSubclass, dbcitem->SoundOverrideSubclassID);
2845 itemTemplate.SoundOverrideSubclass = dbcitem->SoundOverrideSubclassID;
2846 }
2847 if (itemTemplate.Material != dbcitem->Material)
2848 {
2849 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct material ({}), must be {}.", entry, itemTemplate.Material, dbcitem->Material);
2850 itemTemplate.Material = dbcitem->Material;
2851 }
2852 if (itemTemplate.InventoryType != dbcitem->InventoryType)
2853 {
2854 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong InventoryType value ({}), must be {}.", entry, itemTemplate.InventoryType, dbcitem->InventoryType);
2855 itemTemplate.InventoryType = dbcitem->InventoryType;
2856 }
2857 if (itemTemplate.DisplayInfoID != dbcitem->DisplayInfoID)
2858 {
2859 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct display id ({}), must be {}.", entry, itemTemplate.DisplayInfoID, dbcitem->DisplayInfoID);
2860 itemTemplate.DisplayInfoID = dbcitem->DisplayInfoID;
2861 }
2862 if (itemTemplate.Sheath != dbcitem->SheatheType)
2863 {
2864 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Sheath ({}), must be {}.", entry, itemTemplate.Sheath, dbcitem->SheatheType);
2865 itemTemplate.Sheath = dbcitem->SheatheType;
2866 }
2867 }
2868
2869 if (itemTemplate.Quality >= MAX_ITEM_QUALITY)
2870 {
2871 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Quality value ({})", entry, itemTemplate.Quality);
2872 itemTemplate.Quality = ITEM_QUALITY_NORMAL;
2873 }
2874
2875 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_HORDE))
2876 {
2877 if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
2878 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
2879 LOG_ERROR("sql.sql", "Item (Entry: {}) has value ({}) in `AllowableRace` races, not compatible with ITEM_FLAG2_FACTION_HORDE ({}) in Flags field, item cannot be equipped or used by these races.",
2880 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_HORDE);
2881
2882 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
2883 LOG_ERROR("sql.sql", "Item (Entry: {}) has value ({}) in `Flags2` flags (ITEM_FLAG2_FACTION_ALLIANCE) and ITEM_FLAG2_FACTION_HORDE ({}) in Flags field, this is a wrong combination.",
2885 }
2886 else if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
2887 {
2888 if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
2889 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
2890 LOG_ERROR("sql.sql", "Item (Entry: {}) has value ({}) in `AllowableRace` races, not compatible with ITEM_FLAG2_FACTION_ALLIANCE ({}) in Flags field, item cannot be equipped or used by these races.",
2891 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_ALLIANCE);
2892 }
2893
2894 if (itemTemplate.BuyCount <= 0)
2895 {
2896 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong BuyCount value ({}), set to default(1).", entry, itemTemplate.BuyCount);
2897 itemTemplate.BuyCount = 1;
2898 }
2899
2900 if (itemTemplate.RequiredSkill >= MAX_SKILL_TYPE)
2901 {
2902 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RequiredSkill value ({})", entry, itemTemplate.RequiredSkill);
2903 itemTemplate.RequiredSkill = 0;
2904 }
2905
2906 {
2907 // can be used in equip slot, as page read use in inventory, or spell casting at use
2908 bool req = itemTemplate.InventoryType != INVTYPE_NON_EQUIP || itemTemplate.PageText;
2909 if (!req)
2910 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
2911 {
2912 if (itemTemplate.Spells[j].SpellId)
2913 {
2914 req = true;
2915 break;
2916 }
2917 }
2918
2919 if (req)
2920 {
2921 if (!(itemTemplate.AllowableClass & CLASSMASK_ALL_PLAYABLE))
2922 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable classes ({}) in `AllowableClass` and can't be equipped or used.", entry, itemTemplate.AllowableClass);
2923
2924 if (!(itemTemplate.AllowableRace & RACEMASK_ALL_PLAYABLE))
2925 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable races ({}) in `AllowableRace` and can't be equipped or used.", entry, itemTemplate.AllowableRace);
2926 }
2927 }
2928
2929 if (itemTemplate.RequiredSpell && !sSpellMgr->GetSpellInfo(itemTemplate.RequiredSpell))
2930 {
2931 LOG_ERROR("sql.sql", "Item (Entry: {}) has a wrong (non-existing) spell in RequiredSpell ({})", entry, itemTemplate.RequiredSpell);
2932 itemTemplate.RequiredSpell = 0;
2933 }
2934
2935 if (itemTemplate.RequiredReputationRank >= MAX_REPUTATION_RANK)
2936 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong reputation rank in RequiredReputationRank ({}), item can't be used.", entry, itemTemplate.RequiredReputationRank);
2937
2938 if (itemTemplate.RequiredReputationFaction)
2939 {
2940 if (!sFactionStore.LookupEntry(itemTemplate.RequiredReputationFaction))
2941 {
2942 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) faction in RequiredReputationFaction ({})", entry, itemTemplate.RequiredReputationFaction);
2943 itemTemplate.RequiredReputationFaction = 0;
2944 }
2945
2946 if (itemTemplate.RequiredReputationRank == MIN_REPUTATION_RANK)
2947 LOG_ERROR("sql.sql", "Item (Entry: {}) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", entry);
2948 }
2949
2950 if (itemTemplate.MaxCount < -1)
2951 {
2952 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in maxcount ({}), replace by value (-1) no storing limits.", entry, itemTemplate.MaxCount);
2953 itemTemplate.MaxCount = -1;
2954 }
2955
2956 if (itemTemplate.Stackable == 0)
2957 {
2958 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong value in stackable ({}), replace by default 1.", entry, itemTemplate.Stackable);
2959 itemTemplate.Stackable = 1;
2960 }
2961 else if (itemTemplate.Stackable < -1)
2962 {
2963 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in stackable ({}), replace by value (-1) no stacking limits.", entry, itemTemplate.Stackable);
2964 itemTemplate.Stackable = -1;
2965 }
2966
2967 if (itemTemplate.ContainerSlots > MAX_BAG_SIZE)
2968 {
2969 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in ContainerSlots ({}), replace by hardcoded limit ({}).", entry, itemTemplate.ContainerSlots, MAX_BAG_SIZE);
2970 itemTemplate.ContainerSlots = MAX_BAG_SIZE;
2971 }
2972
2973 if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS)
2974 {
2975 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in statscount ({}), replace by hardcoded limit ({}).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS);
2976 itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS;
2977 }
2978
2979 for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
2980 {
2981 // for ItemStatValue != 0
2982 if (itemTemplate.ItemStat[j].ItemStatValue && itemTemplate.ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
2983 {
2984 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (non-existing?) stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
2985 itemTemplate.ItemStat[j].ItemStatType = 0;
2986 }
2987
2988 switch (itemTemplate.ItemStat[j].ItemStatType)
2989 {
2991 LOG_ERROR("sql.sql", "Item (Entry: {}) has deprecated stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
2992 break;
2993 default:
2994 break;
2995 }
2996 }
2997
2998 for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
2999 {
3000 if (itemTemplate.Damage[j].DamageType >= MAX_SPELL_SCHOOL)
3001 {
3002 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong dmg_type{} ({})", entry, j + 1, itemTemplate.Damage[j].DamageType);
3003 itemTemplate.Damage[j].DamageType = 0;
3004 }
3005 }
3006
3007 // special format
3008 if ((itemTemplate.Spells[0].SpellId == 483) || (itemTemplate.Spells[0].SpellId == 55884))
3009 {
3010 // spell_1
3011 if (itemTemplate.Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3012 {
3013 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({}) for special learning format", entry, 0 + 1, itemTemplate.Spells[0].SpellTrigger);
3014 itemTemplate.Spells[0].SpellId = 0;
3015 itemTemplate.Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3016 itemTemplate.Spells[1].SpellId = 0;
3017 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3018 }
3019
3020 // spell_2 have learning spell
3021 if (itemTemplate.Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3022 {
3023 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({}) for special learning format.", entry, 1 + 1, itemTemplate.Spells[1].SpellTrigger);
3024 itemTemplate.Spells[0].SpellId = 0;
3025 itemTemplate.Spells[1].SpellId = 0;
3026 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3027 }
3028 else if (!itemTemplate.Spells[1].SpellId)
3029 {
3030 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have an expected spell in spellid_{} in special learning format.", entry, 1 + 1);
3031 itemTemplate.Spells[0].SpellId = 0;
3032 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3033 }
3034 else if (itemTemplate.Spells[1].SpellId != -1)
3035 {
3036 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
3037 if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
3038 {
3039 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3040 itemTemplate.Spells[0].SpellId = 0;
3041 itemTemplate.Spells[1].SpellId = 0;
3042 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3043 }
3044 // allowed only in special format
3045 else if ((itemTemplate.Spells[1].SpellId == 483) || (itemTemplate.Spells[1].SpellId == 55884))
3046 {
3047 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3048 itemTemplate.Spells[0].SpellId = 0;
3049 itemTemplate.Spells[1].SpellId = 0;
3050 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3051 }
3052 }
3053
3054 // spell_3*, spell_4*, spell_5* is empty
3055 for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
3056 {
3057 if (itemTemplate.Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3058 {
3059 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3060 itemTemplate.Spells[j].SpellId = 0;
3061 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3062 }
3063 else if (itemTemplate.Spells[j].SpellId != 0)
3064 {
3065 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong spell in spellid_{} ({}) for learning special format", entry, j + 1, itemTemplate.Spells[j].SpellId);
3066 itemTemplate.Spells[j].SpellId = 0;
3067 }
3068 }
3069 }
3070 // normal spell list
3071 else
3072 {
3073 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3074 {
3075 if (itemTemplate.Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || itemTemplate.Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3076 {
3077 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3078 itemTemplate.Spells[j].SpellId = 0;
3079 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3080 }
3081
3082 if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
3083 {
3084 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
3085 if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
3086 {
3087 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3088 itemTemplate.Spells[j].SpellId = 0;
3089 }
3090 // allowed only in special format
3091 else if ((itemTemplate.Spells[j].SpellId == 483) || (itemTemplate.Spells[j].SpellId == 55884))
3092 {
3093 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3094 itemTemplate.Spells[j].SpellId = 0;
3095 }
3096 }
3097 }
3098 }
3099
3100 if (itemTemplate.Bonding >= MAX_BIND_TYPE)
3101 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Bonding value ({})", entry, itemTemplate.Bonding);
3102
3103 if (itemTemplate.PageText && !GetPageText(itemTemplate.PageText))
3104 LOG_ERROR("sql.sql", "Item (Entry: {}) has non existing first page (Id:{})", entry, itemTemplate.PageText);
3105
3106 if (itemTemplate.LockID && !sLockStore.LookupEntry(itemTemplate.LockID))
3107 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LockID ({})", entry, itemTemplate.LockID);
3108
3109 if (itemTemplate.RandomProperty)
3110 {
3111 // To be implemented later
3112 if (itemTemplate.RandomProperty == -1)
3113 itemTemplate.RandomProperty = 0;
3114
3115 else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomProperty)))
3116 {
3117 LOG_ERROR("sql.sql", "Item (Entry: {}) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty ({})", entry, itemTemplate.RandomProperty);
3118 itemTemplate.RandomProperty = 0;
3119 }
3120 }
3121
3122 if (itemTemplate.RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomSuffix)))
3123 {
3124 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RandomSuffix ({})", entry, itemTemplate.RandomSuffix);
3125 itemTemplate.RandomSuffix = 0;
3126 }
3127
3128 if (itemTemplate.ItemSet && !sItemSetStore.LookupEntry(itemTemplate.ItemSet))
3129 {
3130 LOG_ERROR("sql.sql", "Item (Entry: {}) have wrong ItemSet ({})", entry, itemTemplate.ItemSet);
3131 itemTemplate.ItemSet = 0;
3132 }
3133
3134 if (itemTemplate.Area && !sAreaTableStore.LookupEntry(itemTemplate.Area))
3135 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Area ({})", entry, itemTemplate.Area);
3136
3137 if (itemTemplate.Map && !sMapStore.LookupEntry(itemTemplate.Map))
3138 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Map ({})", entry, itemTemplate.Map);
3139
3140 if (itemTemplate.BagFamily)
3141 {
3142 // check bits
3143 for (uint32 j = 0; j < sizeof(itemTemplate.BagFamily) * 8; ++j)
3144 {
3145 uint32 mask = 1 << j;
3146 if ((itemTemplate.BagFamily & mask) == 0)
3147 continue;
3148
3149 ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j + 1);
3150 if (!bf)
3151 {
3152 LOG_ERROR("sql.sql", "Item (Entry: {}) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", entry);
3153 itemTemplate.BagFamily &= ~mask;
3154 continue;
3155 }
3156
3158 {
3159 CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemTemplate.ItemId);
3160 if (!ctEntry)
3161 {
3162 LOG_ERROR("sql.sql", "Item (Entry: {}) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit", entry);
3163 itemTemplate.BagFamily &= ~mask;
3164 }
3165 }
3166 }
3167 }
3168
3169 if (itemTemplate.TotemCategory && !sTotemCategoryStore.LookupEntry(itemTemplate.TotemCategory))
3170 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong TotemCategory ({})", entry, itemTemplate.TotemCategory);
3171
3172 for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
3173 {
3174 if (itemTemplate.Socket[j].Color && (itemTemplate.Socket[j].Color & SOCKET_COLOR_ALL) != itemTemplate.Socket[j].Color)
3175 {
3176 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong socketColor_{} ({})", entry, j + 1, itemTemplate.Socket[j].Color);
3177 itemTemplate.Socket[j].Color = 0;
3178 }
3179 }
3180
3181 if (itemTemplate.GemProperties && !sGemPropertiesStore.LookupEntry(itemTemplate.GemProperties))
3182 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong GemProperties ({})", entry, itemTemplate.GemProperties);
3183
3184 if (itemTemplate.FoodType >= MAX_PET_DIET)
3185 {
3186 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong FoodType value ({})", entry, itemTemplate.FoodType);
3187 itemTemplate.FoodType = 0;
3188 }
3189
3190 if (itemTemplate.ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(itemTemplate.ItemLimitCategory))
3191 {
3192 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LimitCategory value ({})", entry, itemTemplate.ItemLimitCategory);
3193 itemTemplate.ItemLimitCategory = 0;
3194 }
3195
3196 if (itemTemplate.HolidayId && !sHolidaysStore.LookupEntry(itemTemplate.HolidayId))
3197 {
3198 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong HolidayId value ({})", entry, itemTemplate.HolidayId);
3199 itemTemplate.HolidayId = 0;
3200 }
3201
3202 if (itemTemplate.HasFlagCu(ITEM_FLAGS_CU_DURATION_REAL_TIME) && !itemTemplate.Duration)
3203 {
3204 LOG_ERROR("sql.sql", "Item (Entry {}) has flag ITEM_FLAGS_CU_DURATION_REAL_TIME but it does not have duration limit", entry);
3205 itemTemplate.FlagsCu = static_cast<ItemFlagsCustom>(static_cast<uint32>(itemTemplate.FlagsCu) & ~ITEM_FLAGS_CU_DURATION_REAL_TIME);
3206 }
3207
3208 // Fill categories map
3209 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3210 if (itemTemplate.Spells[i].SpellId && itemTemplate.Spells[i].SpellCategory && itemTemplate.Spells[i].SpellCategoryCooldown)
3211 {
3212 SpellCategoryStore::iterator ct = sSpellsByCategoryStore.find(itemTemplate.Spells[i].SpellCategory);
3213 if (ct != sSpellsByCategoryStore.end())
3214 {
3215 ct->second.emplace(true, itemTemplate.Spells[i].SpellId);
3216 }
3217 else
3218 sSpellsByCategoryStore[itemTemplate.Spells[i].SpellCategory].emplace(true, itemTemplate.Spells[i].SpellId);
3219 }
3220
3221 ++count;
3222 } while (result->NextRow());
3223
3224 // pussywizard:
3225 {
3226 uint32 max = 0;
3227 for (ItemTemplateContainer::const_iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3228 if (itr->first > max)
3229 max = itr->first;
3230 if (max)
3231 {
3232 _itemTemplateStoreFast.clear();
3233 _itemTemplateStoreFast.resize(max + 1, nullptr);
3234 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3235 _itemTemplateStoreFast[itr->first] = &(itr->second);
3236 }
3237 }
3238
3239 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3240 itr->second.InitializeQueryData();
3241
3242 // Check if item templates for DBC referenced character start outfit are present
3243 std::set<uint32> notFoundOutfit;
3244 for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i)
3245 {
3246 CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i);
3247 if (!entry)
3248 continue;
3249
3250 for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
3251 {
3252 if (entry->ItemId[j] <= 0)
3253 continue;
3254
3255 uint32 item_id = entry->ItemId[j];
3256
3257 if (!GetItemTemplate(item_id))
3258 notFoundOutfit.insert(item_id);
3259 }
3260 }
3261
3262 for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr)
3263 LOG_ERROR("sql.sql", "Item (Entry: {}) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr);
3264
3265 LOG_INFO("server.loading", ">> Loaded {} Item Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3266 LOG_INFO("server.loading", " ");
3267}
@ DISABLE_TYPE_SPELL
Definition: DisableMgr.h:29
DBCStorage< ItemLimitCategoryEntry > sItemLimitCategoryStore(ItemLimitCategoryEntryfmt)
SpellCategoryStore sSpellsByCategoryStore
Definition: DBCStores.cpp:152
DBCStorage< CharStartOutfitEntry > sCharStartOutfitStore(CharStartOutfitEntryfmt)
DBCStorage< LockEntry > sLockStore(LockEntryfmt)
DBCStorage< ItemBagFamilyEntry > sItemBagFamilyStore(ItemBagFamilyfmt)
DBCStorage< HolidaysEntry > sHolidaysStore(Holidaysfmt)
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< TotemCategoryEntry > sTotemCategoryStore(TotemCategoryEntryfmt)
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
DBCStorage< CurrencyTypesEntry > sCurrencyTypesStore(CurrencyTypesfmt)
@ CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES
Definition: IWorld.h:143
Rates
Server rates.
Definition: IWorld.h:431
@ RATE_BUYVALUE_ITEM_POOR
Definition: IWorld.h:459
@ RATE_SELLVALUE_ITEM_POOR
Definition: IWorld.h:451
ItemFlags2
Definition: ItemTemplate.h:182
@ ITEM_FLAG2_FACTION_HORDE
Definition: ItemTemplate.h:183
@ ITEM_FLAG2_FACTION_ALLIANCE
Definition: ItemTemplate.h:184
@ ITEM_SPELLTRIGGER_LEARN_SPELL_ID
Definition: ItemTemplate.h:88
@ ITEM_SPELLTRIGGER_ON_USE
Definition: ItemTemplate.h:77
@ BAG_FAMILY_MASK_CURRENCY_TOKENS
Definition: ItemTemplate.h:240
ItemFlags
Definition: ItemTemplate.h:146
@ ITEM_MOD_SPELL_HEALING_DONE
Definition: ItemTemplate.h:63
#define MAX_ITEM_PROTO_SOCKETS
Definition: ItemTemplate.h:614
#define MAX_ITEM_PROTO_DAMAGES
Definition: ItemTemplate.h:613
#define MAX_ITEM_PROTO_SPELLS
Definition: ItemTemplate.h:615
ItemFlagsCustom
Definition: ItemTemplate.h:218
@ ITEM_FLAGS_CU_DURATION_REAL_TIME
Definition: ItemTemplate.h:219
#define SOCKET_COLOR_ALL
Definition: ItemTemplate.h:252
#define MAX_BIND_TYPE
Definition: ItemTemplate.h:103
#define MAX_ITEM_SPELLTRIGGER
Definition: ItemTemplate.h:91
#define MAX_ITEM_PROTO_STATS
Definition: ItemTemplate.h:616
#define MAX_ITEM_MOD
Definition: ItemTemplate.h:73
#define MAX_BAG_SIZE
Definition: Bag.h:22
uint32 GetItemEnchantMod(int32 entry)
Definition: ItemEnchantmentMgr.cpp:82
#define MAX_REPUTATION_RANK
Definition: SharedDefines.h:245
#define MIN_REPUTATION_RANK
Definition: SharedDefines.h:244
#define MAX_PET_DIET
Definition: SharedDefines.h:3231
@ ITEM_QUALITY_NORMAL
Definition: SharedDefines.h:330
#define MAX_ITEM_QUALITY
Definition: SharedDefines.h:339
#define MAX_SKILL_TYPE
Definition: SharedDefines.h:3018
@ ALLIANCE
Definition: SharedDefines.h:768
@ HORDE
Definition: SharedDefines.h:767
#define CLASSMASK_ALL_PLAYABLE
Definition: SharedDefines.h:157
#define RACEMASK_ALL_PLAYABLE
Definition: SharedDefines.h:97
#define MAX_OUTFIT_ITEMS
Definition: DBCStructure.h:617
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:306
Definition: DBCStructure.h:620
int32 ItemId[MAX_OUTFIT_ITEMS]
Definition: DBCStructure.h:626
Definition: DBCStructure.h:835
Definition: DBCStructure.h:907
int32 SoundOverrideSubclassID
Definition: DBCStructure.h:1144
uint32 SheatheType
Definition: DBCStructure.h:1148
uint32 DisplayInfoID
Definition: DBCStructure.h:1146
uint32 ClassID
Definition: DBCStructure.h:1142
int32 Material
Definition: DBCStructure.h:1145
uint32 SubclassID
Definition: DBCStructure.h:1143
Definition: DBCStructure.h:1152

References _itemTemplateStore, _itemTemplateStoreFast, ALLIANCE, BAG_FAMILY_MASK_CURRENCY_TOKENS, ItemEntry::ClassID, CLASSMASK_ALL_PLAYABLE, CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES, DISABLE_TYPE_SPELL, ItemEntry::DisplayInfoID, Field::Get(), GetItemEnchantMod(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), GetPageText(), HORDE, ItemEntry::InventoryType, INVTYPE_NON_EQUIP, DisableMgr::IsDisabledFor(), ITEM_FLAG2_FACTION_ALLIANCE, ITEM_FLAG2_FACTION_HORDE, ITEM_FLAGS_CU_DURATION_REAL_TIME, ITEM_MOD_SPELL_HEALING_DONE, ITEM_QUALITY_NORMAL, ITEM_SPELLTRIGGER_LEARN_SPELL_ID, ITEM_SPELLTRIGGER_ON_USE, CharStartOutfitEntry::ItemId, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARN, ItemEntry::Material, MAX_BAG_SIZE, MAX_BIND_TYPE, MAX_ITEM_MOD, MAX_ITEM_PROTO_DAMAGES, MAX_ITEM_PROTO_SOCKETS, MAX_ITEM_PROTO_SPELLS, MAX_ITEM_PROTO_STATS, MAX_ITEM_QUALITY, MAX_ITEM_SPELLTRIGGER, MAX_OUTFIT_ITEMS, MAX_PET_DIET, MAX_REPUTATION_RANK, MAX_SKILL_TYPE, MAX_SPELL_SCHOOL, MIN_REPUTATION_RANK, RACEMASK_ALL_PLAYABLE, RATE_BUYVALUE_ITEM_POOR, RATE_SELLVALUE_ITEM_POOR, sAreaTableStore, sCharStartOutfitStore, sCurrencyTypesStore, sFactionStore, sGemPropertiesStore, ItemEntry::SheatheType, sHolidaysStore, sItemBagFamilyStore, sItemLimitCategoryStore, sItemRandomPropertiesStore, sItemRandomSuffixStore, sItemSetStore, sItemStore, sLockStore, sMapStore, sObjectMgr, SOCKET_COLOR_ALL, ItemEntry::SoundOverrideSubclassID, sSpellMgr, sSpellsByCategoryStore, sTotemCategoryStore, ItemEntry::SubclassID, sWorld, and WorldDatabase.

◆ LoadLinkedRespawn()

void ObjectMgr::LoadLinkedRespawn ( )
1787{
1788 uint32 oldMSTime = getMSTime();
1789
1790 _linkedRespawnStore.clear();
1791 // 0 1 2
1792 QueryResult result = WorldDatabase.Query("SELECT guid, linkedGuid, linkType FROM linked_respawn ORDER BY guid ASC");
1793
1794 if (!result)
1795 {
1796 LOG_WARN("server.loading", ">> Loaded 0 linked respawns. DB table `linked_respawn` is empty.");
1797 LOG_INFO("server.loading", " ");
1798 return;
1799 }
1800
1801 do
1802 {
1803 Field* fields = result->Fetch();
1804
1805 ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
1806 ObjectGuid::LowType linkedGuidLow = fields[1].Get<uint32>();
1807 uint8 linkType = fields[2].Get<uint8>();
1808
1809 ObjectGuid guid, linkedGuid;
1810 bool error = false;
1811 switch (linkType)
1812 {
1814 {
1815 const CreatureData* slave = GetCreatureData(guidLow);
1816 if (!slave)
1817 {
1818 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1819 error = true;
1820 break;
1821 }
1822
1823 const CreatureData* master = GetCreatureData(linkedGuidLow);
1824 if (!master)
1825 {
1826 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1827 error = true;
1828 break;
1829 }
1830
1831 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1832 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1833 {
1834 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1835 error = true;
1836 break;
1837 }
1838
1839 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1840 {
1841 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1842 error = true;
1843 break;
1844 }
1845
1846 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1847 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1848 break;
1849 }
1850 case CREATURE_TO_GO:
1851 {
1852 const CreatureData* slave = GetCreatureData(guidLow);
1853 if (!slave)
1854 {
1855 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1856 error = true;
1857 break;
1858 }
1859
1860 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1861 if (!master)
1862 {
1863 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1864 error = true;
1865 break;
1866 }
1867
1868 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1869 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1870 {
1871 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1872 error = true;
1873 break;
1874 }
1875
1876 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1877 {
1878 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1879 error = true;
1880 break;
1881 }
1882
1883 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1884 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
1885 break;
1886 }
1887 case GO_TO_GO:
1888 {
1889 const GameObjectData* slave = GetGameObjectData(guidLow);
1890 if (!slave)
1891 {
1892 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
1893 error = true;
1894 break;
1895 }
1896
1897 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1898 if (!master)
1899 {
1900 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1901 error = true;
1902 break;
1903 }
1904
1905 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1906 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1907 {
1908 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1909 error = true;
1910 break;
1911 }
1912
1913 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1914 {
1915 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1916 error = true;
1917 break;
1918 }
1919
1920 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
1921 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
1922 break;
1923 }
1924 case GO_TO_CREATURE:
1925 {
1926 const GameObjectData* slave = GetGameObjectData(guidLow);
1927 if (!slave)
1928 {
1929 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
1930 error = true;
1931 break;
1932 }
1933
1934 const CreatureData* master = GetCreatureData(linkedGuidLow);
1935 if (!master)
1936 {
1937 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1938 error = true;
1939 break;
1940 }
1941
1942 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1943 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1944 {
1945 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1946 error = true;
1947 break;
1948 }
1949
1950 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1951 {
1952 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1953 error = true;
1954 break;
1955 }
1956
1957 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
1958 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1959 break;
1960 }
1961 }
1962
1963 if (!error)
1964 _linkedRespawnStore[guid] = linkedGuid;
1965 } while (result->NextRow());
1966
1967 LOG_INFO("server.loading", ">> Loaded {} Linked Respawns In {} ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime));
1968 LOG_INFO("server.loading", " ");
1969}
Definition: ObjectGuid.h:118
bool Instanceable() const
Definition: DBCStructure.h:1353

References _linkedRespawnStore, CREATURE_TO_CREATURE, CREATURE_TO_GO, Field::Get(), GetCreatureData(), GetGameObjectData(), getMSTime(), GetMSTimeDiffToNow(), GO_TO_CREATURE, GO_TO_GO, GameObjectData::id, CreatureData::id1, MapEntry::Instanceable(), LOG_ERROR, LOG_INFO, LOG_WARN, CreatureData::mapid, GameObjectData::mapid, sMapStore, CreatureData::spawnMask, GameObjectData::spawnMask, and WorldDatabase.

◆ LoadMailLevelRewards()

void ObjectMgr::LoadMailLevelRewards ( )
8975{
8976 uint32 oldMSTime = getMSTime();
8977
8978 _mailLevelRewardStore.clear(); // for reload case
8979
8980 // 0 1 2 3
8981 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
8982
8983 if (!result)
8984 {
8985 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
8986 LOG_INFO("server.loading", " ");
8987 return;
8988 }
8989
8990 uint32 count = 0;
8991
8992 do
8993 {
8994 Field* fields = result->Fetch();
8995
8996 uint8 level = fields[0].Get<uint8>();
8997 uint32 raceMask = fields[1].Get<uint32>();
8998 uint32 mailTemplateId = fields[2].Get<uint32>();
8999 uint32 senderEntry = fields[3].Get<uint32>();
9000
9001 if (level > MAX_LEVEL)
9002 {
9003 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
9004 continue;
9005 }
9006
9007 if (!(raceMask & RACEMASK_ALL_PLAYABLE))
9008 {
9009 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
9010 continue;
9011 }
9012
9013 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
9014 {
9015 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
9016 continue;
9017 }
9018
9019 if (!GetCreatureTemplate(senderEntry))
9020 {
9021 LOG_ERROR("sql.sql", "Table `mail_level_reward` have not existed sender creature entry ({}) for level {} that invalid not include any player races, ignoring.", senderEntry, level);
9022 continue;
9023 }
9024
9025 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
9026
9027 ++count;
9028 } while (result->NextRow());
9029
9030 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9031 LOG_INFO("server.loading", " ");
9032}
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
#define MAX_LEVEL
Definition: DBCEnums.h:39
Definition: ObjectMgr.h:543

References _mailLevelRewardStore, Field::Get(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_LEVEL, RACEMASK_ALL_PLAYABLE, sMailTemplateStore, and WorldDatabase.

◆ LoadMailServerTemplates()

void ObjectMgr::LoadMailServerTemplates ( )
10237{
10238 uint32 oldMSTime = getMSTime();
10239
10240 _serverMailStore.clear(); // for reload case
10241
10242 // 0 1 2 3 4 5 6 7 8 9 10 11
10243 QueryResult result = CharacterDatabase.Query("SELECT `id`, `reqLevel`, `reqPlayTime`, `moneyA`, `moneyH`, `itemA`, `itemCountA`, `itemH`,`itemCountH`, `subject`, `body`, `active` FROM `mail_server_template`");
10244 if (!result)
10245 {
10246 LOG_INFO("sql.sql", ">> Loaded 0 server mail rewards. DB table `mail_server_template` is empty.");
10247 LOG_INFO("server.loading", " ");
10248 return;
10249 }
10250
10251 _serverMailStore.rehash(result->GetRowCount());
10252
10253 do
10254 {
10255 Field* fields = result->Fetch();
10256
10257 uint32 id = fields[0].Get<uint32>();
10258
10259 ServerMail& servMail = _serverMailStore[id];
10260
10261 servMail.id = id;
10262 servMail.reqLevel = fields[1].Get<uint8>();
10263 servMail.reqPlayTime = fields[2].Get<uint32>();
10264 servMail.moneyA = fields[3].Get<uint32>();
10265 servMail.moneyH = fields[4].Get<uint32>();
10266 servMail.itemA = fields[5].Get<uint32>();
10267 servMail.itemCountA = fields[6].Get<uint32>();
10268 servMail.itemH = fields[7].Get<uint32>();
10269 servMail.itemCountH = fields[8].Get<uint32>();
10270 servMail.subject = fields[9].Get<std::string>();
10271 servMail.body = fields[10].Get<std::string>();
10272 servMail.active = fields[11].Get<uint8>();
10273
10274 if (servMail.reqLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
10275 {
10276 LOG_ERROR("sql.sql", "Table `mail_server_template` has reqLevel {} but max level is {} for id {}, skipped.", servMail.reqLevel, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL), servMail.id);
10277 return;
10278 }
10279
10280 if (servMail.moneyA > MAX_MONEY_AMOUNT || servMail.moneyH > MAX_MONEY_AMOUNT)
10281 {
10282 LOG_ERROR("sql.sql", "Table `mail_server_template` has moneyA {} or moneyH {} larger than MAX_MONEY_AMOUNT {} for id {}, skipped.", servMail.moneyA, servMail.moneyH, MAX_MONEY_AMOUNT, servMail.id);
10283 return;
10284 }
10285
10286 ItemTemplate const* itemTemplateA = sObjectMgr->GetItemTemplate(servMail.itemA);
10287 if (!itemTemplateA && servMail.itemA)
10288 {
10289 LOG_ERROR("sql.sql", "Table `mail_server_template` has invalid item in itemA {} for id {}, skipped.", servMail.itemA, servMail.id);
10290 return;
10291 }
10292 ItemTemplate const* itemTemplateH = sObjectMgr->GetItemTemplate(servMail.itemH);
10293 if (!itemTemplateH && servMail.itemH)
10294 {
10295 LOG_ERROR("sql.sql", "Table `mail_server_template` has invalid item in itemH {} for id {}, skipped.", servMail.itemH, servMail.id);
10296 return;
10297 }
10298
10299 if (!servMail.itemA && servMail.itemCountA)
10300 {
10301 LOG_ERROR("sql.sql", "Table `mail_server_template` has itemCountA {} with no ItemA, set to 0", servMail.itemCountA);
10302 servMail.itemCountA = 0;
10303 }
10304 if (!servMail.itemH && servMail.itemCountH)
10305 {
10306 LOG_ERROR("sql.sql", "Table `mail_server_template` has itemCountH {} with no ItemH, set to 0", servMail.itemCountH);
10307 servMail.itemCountH = 0;
10308 }
10309 } while (result->NextRow());
10310
10311 LOG_INFO("server.loading", ">> Loaded {} Mail Server Template in {} ms", _serverMailStore.size(), GetMSTimeDiffToNow(oldMSTime));
10312 LOG_INFO("server.loading", " ");
10313}
#define MAX_MONEY_AMOUNT
Definition: Player.h:930
Definition: Mail.h:215

References _serverMailStore, CharacterDatabase, CONFIG_MAX_PLAYER_LEVEL, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, MAX_MONEY_AMOUNT, sObjectMgr, and sWorld.

◆ LoadModuleStrings()

bool ObjectMgr::LoadModuleStrings ( )
8555{
8556 uint32 oldMSTime = getMSTime();
8557
8558 _moduleStringStore.clear(); // for reload case
8559 QueryResult result = WorldDatabase.Query("SELECT module, id, string FROM module_string");
8560 if (!result)
8561 {
8562 LOG_WARN("server.loading", ">> Loaded 0 module strings. DB table `module_string` is empty.");
8563 LOG_INFO("server.loading", " ");
8564 return false;
8565 }
8566
8567 do
8568 {
8569 Field* fields = result->Fetch();
8570
8571 std::string module = fields[0].Get<std::string>();
8572 uint32 id = fields[1].Get<uint32>();
8573
8574 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
8575 ModuleString& data = _moduleStringStore[pairKey];
8576
8577 AddLocaleString(fields[2].Get<std::string>(), LOCALE_enUS, data.Content);
8578 } while (result->NextRow());
8579
8580 LOG_INFO("server.loading", ">> Loaded {} Module Strings in {} ms", _moduleStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8581 LOG_INFO("server.loading", " ");
8582
8583 return true;
8584}

References _moduleStringStore, AddLocaleString(), ModuleString::Content, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadModuleStringsLocale()

bool ObjectMgr::LoadModuleStringsLocale ( )
8587{
8588 uint32 oldMSTime = getMSTime();
8589
8590 QueryResult result = WorldDatabase.Query("SELECT module, id, locale, string FROM module_string_locale");
8591 if (!result)
8592 {
8593 LOG_WARN("server.loading", ">> Loaded 0 module strings locale. DB table `module_string_locale` is empty.");
8594 LOG_INFO("server.loading", " ");
8595 return false;
8596 }
8597
8598 uint32 localeCount = 0;
8599 do
8600 {
8601 Field* fields = result->Fetch();
8602
8603 std::string module = fields[0].Get<std::string>();
8604 uint32 id = fields[1].Get<uint32>();
8605
8606 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
8607 ModuleString& data = _moduleStringStore[pairKey];
8608
8609 ModuleStringContainer::iterator ms = _moduleStringStore.find(pairKey);
8610 if (ms == _moduleStringStore.end())
8611 {
8612 LOG_ERROR("sql.sql", "ModuleString (Module: {} Id: {}) found in table `module_string_locale` but does not exist in `module_string`. Skipped!", module, id);
8613 continue;
8614 }
8615
8616 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
8617 if (locale == LOCALE_enUS)
8618 continue;
8619
8620 AddLocaleString(fields[3].Get<std::string>(), locale, data.Content);
8621 localeCount++;
8622 } while (result->NextRow());
8623
8624 LOG_INFO("server.loading", ">> Loaded {} Module Strings Locales in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
8625 LOG_INFO("server.loading", " ");
8626
8627 return true;
8628}

References _moduleStringStore, AddLocaleString(), ModuleString::Content, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadNPCSpellClickSpells()

void ObjectMgr::LoadNPCSpellClickSpells ( )
7908{
7909 uint32 oldMSTime = getMSTime();
7910
7911 _spellClickInfoStore.clear();
7912 // 0 1 2 3
7913 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
7914
7915 if (!result)
7916 {
7917 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
7918 LOG_INFO("server.loading", " ");
7919 return;
7920 }
7921
7922 uint32 count = 0;
7923
7924 do
7925 {
7926 Field* fields = result->Fetch();
7927
7928 uint32 npc_entry = fields[0].Get<uint32>();
7929 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
7930 if (!cInfo)
7931 {
7932 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
7933 continue;
7934 }
7935
7936 uint32 spellid = fields[1].Get<uint32>();
7937 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
7938 if (!spellinfo)
7939 {
7940 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
7941 continue;
7942 }
7943
7944 uint8 userType = fields[3].Get<uint16>();
7945 if (userType >= SPELL_CLICK_USER_MAX)
7946 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
7947
7948 uint8 castFlags = fields[2].Get<uint8>();
7949 SpellClickInfo info;
7950 info.spellId = spellid;
7951 info.castFlags = castFlags;
7952 info.userType = SpellClickUserTypes(userType);
7953 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
7954
7955 ++count;
7956 } while (result->NextRow());
7957
7958 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
7959 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
7960 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
7961 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
7962 {
7963 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
7964 {
7965 LOG_ERROR("sql.sql", "npc_spellclick_spells: Creature template {} has UNIT_NPC_FLAG_SPELLCLICK but no data in spellclick table! Removing flag", itr->second.Entry);
7966 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
7967 }
7968 }
7969
7970 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7971 LOG_INFO("server.loading", " ");
7972}
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: UnitDefines.h:318
SpellClickUserTypes
Definition: SharedDefines.h:680
@ SPELL_CLICK_USER_MAX
Definition: SharedDefines.h:685
Definition: ObjectMgr.h:399
uint32 spellId
Definition: ObjectMgr.h:400

References _spellClickInfoStore, Field::Get(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sObjectMgr, SPELL_CLICK_USER_MAX, SpellClickInfo::spellId, sSpellMgr, UNIT_NPC_FLAG_SPELLCLICK, and WorldDatabase.

◆ LoadNpcTextLocales()

void ObjectMgr::LoadNpcTextLocales ( )
5997{
5998 uint32 oldMSTime = getMSTime();
5999
6000 _npcTextLocaleStore.clear(); // need for reload case
6001
6002 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6003 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6004 "Text0_0, Text0_1, Text1_0, Text1_1, Text2_0, Text2_1, Text3_0, Text3_1, Text4_0, Text4_1, Text5_0, Text5_1, Text6_0, Text6_1, Text7_0, Text7_1 "
6005 "FROM npc_text_locale");
6006
6007 if (!result)
6008 return;
6009
6010 do
6011 {
6012 Field* fields = result->Fetch();
6013
6014 uint32 ID = fields[0].Get<uint32>();
6015
6016 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6017 if (locale == LOCALE_enUS)
6018 continue;
6019
6021 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6022 {
6023 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6024 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6025 }
6026 } while (result->NextRow());
6027
6028 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6029}
Definition: NPCHandler.h:55
std::vector< std::vector< std::string > > Text_1
Definition: NPCHandler.h:59
std::vector< std::vector< std::string > > Text_0
Definition: NPCHandler.h:58

References _npcTextLocaleStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, MAX_GOSSIP_TEXT_OPTIONS, NpcTextLocale::Text_0, NpcTextLocale::Text_1, and WorldDatabase.

◆ LoadPageTextLocales()

void ObjectMgr::LoadPageTextLocales ( )
5748{
5749 uint32 oldMSTime = getMSTime();
5750
5751 _pageTextLocaleStore.clear(); // need for reload case
5752
5753 // 0 1 2
5754 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
5755
5756 if (!result)
5757 return;
5758
5759 do
5760 {
5761 Field* fields = result->Fetch();
5762
5763 uint32 ID = fields[0].Get<uint32>();
5764
5765 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5766 if (locale == LOCALE_enUS)
5767 continue;
5768
5770 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
5771 } while (result->NextRow());
5772
5773 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5774}
Definition: NPCHandler.h:50
std::vector< std::string > Text
Definition: NPCHandler.h:51

References _pageTextLocaleStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, PageTextLocale::Text, and WorldDatabase.

◆ LoadPageTexts()

void ObjectMgr::LoadPageTexts ( )
5698{
5699 uint32 oldMSTime = getMSTime();
5700
5701 // 0 1 2
5702 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
5703
5704 if (!result)
5705 {
5706 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
5707 LOG_INFO("server.loading", " ");
5708 return;
5709 }
5710
5711 uint32 count = 0;
5712 do
5713 {
5714 Field* fields = result->Fetch();
5715
5716 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
5717
5718 pageText.Text = fields[1].Get<std::string>();
5719 pageText.NextPage = fields[2].Get<uint32>();
5720
5721 ++count;
5722 } while (result->NextRow());
5723
5724 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
5725 {
5726 if (itr->second.NextPage)
5727 {
5728 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
5729 if (itr2 == _pageTextStore.end())
5730 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
5731 }
5732 }
5733
5734 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5735 LOG_INFO("server.loading", " ");
5736}
Definition: ObjectMgr.h:60
uint16 NextPage
Definition: ObjectMgr.h:62
std::string Text
Definition: ObjectMgr.h:61

References _pageTextStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, PageText::NextPage, PageText::Text, and WorldDatabase.

◆ LoadPetLevelInfo()

void ObjectMgr::LoadPetLevelInfo ( )
3487{
3488 uint32 oldMSTime = getMSTime();
3489
3490 // 0 1 2 3 4 5 6 7 8 9 10 11
3491 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
3492
3493 if (!result)
3494 {
3495 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
3496 LOG_INFO("server.loading", " ");
3497 return;
3498 }
3499
3500 uint32 count = 0;
3501
3502 do
3503 {
3504 Field* fields = result->Fetch();
3505
3506 uint32 creature_id = fields[0].Get<uint32>();
3507 if (!sObjectMgr->GetCreatureTemplate(creature_id))
3508 {
3509 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
3510 continue;
3511 }
3512
3513 uint32 current_level = fields[1].Get<uint8>();
3514 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3515 {
3516 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
3517 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
3518 else
3519 {
3520 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
3521 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
3522 }
3523 continue;
3524 }
3525 else if (current_level < 1)
3526 {
3527 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
3528 continue;
3529 }
3530
3531 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
3532
3533 if (!pInfoMapEntry)
3534 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
3535
3536 // data for level 1 stored in [0] array element, ...
3537 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
3538
3539 pLevelInfo->health = fields[2].Get<uint32>();
3540 pLevelInfo->mana = fields[3].Get<uint32>();
3541 pLevelInfo->armor = fields[9].Get<uint32>();
3542 pLevelInfo->min_dmg = fields[10].Get<uint32>();
3543 pLevelInfo->max_dmg = fields[11].Get<uint32>();
3544 for (uint8 i = 0; i < MAX_STATS; i++)
3545 {
3546 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
3547 }
3548
3549 ++count;
3550 } while (result->NextRow());
3551
3552 // Fill gaps and check integrity
3553 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
3554 {
3555 PetLevelInfo* pInfo = itr->second;
3556
3557 // fatal error if no level 1 data
3558 if (!pInfo || pInfo[0].health == 0)
3559 {
3560 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
3561 exit(1);
3562 }
3563
3564 // fill level gaps
3565 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
3566 {
3567 if (pInfo[level].health == 0)
3568 {
3569 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
3570 pInfo[level] = pInfo[level - 1];
3571 }
3572 }
3573 }
3574
3575 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3576 LOG_INFO("server.loading", " ");
3577}
#define MAX_STATS
Definition: SharedDefines.h:265
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:43
Definition: ObjectMgr.h:528
uint32 max_dmg
Definition: ObjectMgr.h:539
uint32 mana
Definition: ObjectMgr.h:536
uint32 min_dmg
Definition: ObjectMgr.h:538
uint32 health
Definition: ObjectMgr.h:535
std::array< uint32, MAX_STATS > stats
Definition: ObjectMgr.h:534
uint32 armor
Definition: ObjectMgr.h:537

References _petInfoStore, PetLevelInfo::armor, CONFIG_MAX_PLAYER_LEVEL, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), PetLevelInfo::health, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARN, PetLevelInfo::mana, PetLevelInfo::max_dmg, MAX_STATS, PetLevelInfo::min_dmg, sObjectMgr, PetLevelInfo::stats, STRONG_MAX_LEVEL, sWorld, and WorldDatabase.

◆ LoadPetNames()

void ObjectMgr::LoadPetNames ( )
7414{
7415 uint32 oldMSTime = getMSTime();
7416 // 0 1 2
7417 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
7418
7419 if (!result)
7420 {
7421 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
7422 LOG_INFO("server.loading", " ");
7423 return;
7424 }
7425
7426 uint32 count = 0;
7427
7428 do
7429 {
7430 Field* fields = result->Fetch();
7431 std::string word = fields[0].Get<std::string>();
7432 uint32 entry = fields[1].Get<uint32>();
7433 bool half = fields[2].Get<bool>();
7434 if (half)
7435 _petHalfName1[entry].push_back(word);
7436 else
7437 _petHalfName0[entry].push_back(word);
7438 ++count;
7439 } while (result->NextRow());
7440
7441 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7442 LOG_INFO("server.loading", " ");
7443}

References _petHalfName0, _petHalfName1, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadPetNamesLocales()

void ObjectMgr::LoadPetNamesLocales ( )
452{
453 uint32 oldMSTime = getMSTime();
454
455 // 0 1 2 3
456 QueryResult result = WorldDatabase.Query("SELECT Locale, Word, Entry, Half FROM pet_name_generation_locale");
457
458 if (!result)
459 {
460 LOG_WARN("server.loading", ">> Loaded 0 pet name locales parts. DB table `pet_name_generation_locale` is empty!");
461 LOG_INFO("server.loading", " ");
462 return;
463 }
464
465 uint32 count = 0;
466
467 do
468 {
469 Field* fields = result->Fetch();
470 LocaleConstant locale = GetLocaleByName(fields[0].Get<std::string>());
471 std::string word = fields[1].Get<std::string>();
472
473 uint32 entry = fields[2].Get<uint32>();
474 bool half = fields[3].Get<bool>();
475 std::pair<uint32, LocaleConstant> pairkey = std::make_pair(entry, locale);
476 if (half)
477 {
478 _petHalfLocaleName1[pairkey].push_back(word);
479 }
480 else
481 {
482 _petHalfLocaleName0[pairkey].push_back(word);
483 }
484 ++count;
485 } while (result->NextRow());
486
487 LOG_INFO("server.loading", ">> Loaded {} Pet Name Locales Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
488 LOG_INFO("server.loading", " ");
489}

References _petHalfLocaleName0, _petHalfLocaleName1, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadPetNumber()

void ObjectMgr::LoadPetNumber ( )
7446{
7447 uint32 oldMSTime = getMSTime();
7448
7449 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
7450 if (result)
7451 {
7452 Field* fields = result->Fetch();
7453 _hiPetNumber = fields[0].Get<uint32>() + 1;
7454 }
7455
7456 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
7457 LOG_INFO("server.loading", " ");
7458}

References _hiPetNumber, CharacterDatabase, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), and LOG_INFO.

◆ LoadPlayerInfo()

void ObjectMgr::LoadPlayerInfo ( )
3626{
3627 // Load playercreate
3628 {
3629 uint32 oldMSTime = getMSTime();
3630 // 0 1 2 3 4 5 6
3631 QueryResult result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
3632
3633 if (!result)
3634 {
3635 LOG_INFO("server.loading", " ");
3636 LOG_WARN("server.loading", ">> Loaded 0 player create definitions. DB table `playercreateinfo` is empty.");
3637 exit(1);
3638 }
3639 else
3640 {
3641 uint32 count = 0;
3642
3643 do
3644 {
3645 Field* fields = result->Fetch();
3646
3647 uint32 current_race = fields[0].Get<uint8>();
3648 uint32 current_class = fields[1].Get<uint8>();
3649 uint32 mapId = fields[2].Get<uint16>();
3650 uint32 areaId = fields[3].Get<uint32>(); // zone
3651 float positionX = fields[4].Get<float>();
3652 float positionY = fields[5].Get<float>();
3653 float positionZ = fields[6].Get<float>();
3654 float orientation = fields[7].Get<float>();
3655
3656 if (current_race >= MAX_RACES)
3657 {
3658 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3659 continue;
3660 }
3661
3662 ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
3663 if (!rEntry)
3664 {
3665 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3666 continue;
3667 }
3668
3669 if (current_class >= MAX_CLASSES)
3670 {
3671 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3672 continue;
3673 }
3674
3675 if (!sChrClassesStore.LookupEntry(current_class))
3676 {
3677 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3678 continue;
3679 }
3680
3681 // accept DB data only for valid position (and non instanceable)
3682 if (!MapMgr::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation))
3683 {
3684 LOG_ERROR("sql.sql", "Wrong home position for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3685 continue;
3686 }
3687
3688 if (sMapStore.LookupEntry(mapId)->Instanceable())
3689 {
3690 LOG_ERROR("sql.sql", "Home position in instanceable map for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3691 continue;
3692 }
3693
3694 PlayerInfo* info = new PlayerInfo();
3695 info->mapId = mapId;
3696 info->areaId = areaId;
3697 info->positionX = positionX;
3698 info->positionY = positionY;
3699 info->positionZ = positionZ;
3700 info->orientation = orientation;
3701 info->displayId_m = rEntry->model_m;
3702 info->displayId_f = rEntry->model_f;
3703 _playerInfo[current_race][current_class] = info;
3704
3705 ++count;
3706 } while (result->NextRow());
3707
3708 LOG_INFO("server.loading", ">> Loaded {} Player Create Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3709 LOG_INFO("server.loading", " ");
3710 }
3711 }
3712
3713 // Load playercreate items
3714 LOG_INFO("server.loading", "Loading Player Create Items Data...");
3715 {
3716 uint32 oldMSTime = getMSTime();
3717 // 0 1 2 3
3718 QueryResult result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
3719
3720 if (!result)
3721 {
3722 LOG_WARN("server.loading", ">> Loaded 0 Custom Player Create Items. DB Table `playercreateinfo_item` Is Empty.");
3723 LOG_INFO("server.loading", " ");
3724 }
3725 else
3726 {
3727 uint32 count = 0;
3728
3729 do
3730 {
3731 Field* fields = result->Fetch();
3732
3733 uint32 current_race = fields[0].Get<uint8>();
3734 if (current_race >= MAX_RACES)
3735 {
3736 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_item` table, ignoring.", current_race);
3737 continue;
3738 }
3739
3740 uint32 current_class = fields[1].Get<uint8>();
3741 if (current_class >= MAX_CLASSES)
3742 {
3743 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_item` table, ignoring.", current_class);
3744 continue;
3745 }
3746
3747 uint32 item_id = fields[2].Get<uint32>();
3748
3749 if (!GetItemTemplate(item_id))
3750 {
3751 LOG_ERROR("sql.sql", "Item id {} (race {} class {}) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.", item_id, current_race, current_class);
3752 continue;
3753 }
3754
3755 int32 amount = fields[3].Get<int32>();
3756
3757 if (!amount)
3758 {
3759 LOG_ERROR("sql.sql", "Item id {} (class {} race {}) have amount == 0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class);
3760 continue;
3761 }
3762
3763 if (!current_race || !current_class)
3764 {
3765 uint32 min_race = current_race ? current_race : 1;
3766 uint32 max_race = current_race ? current_race + 1 : MAX_RACES;
3767 uint32 min_class = current_class ? current_class : 1;
3768 uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
3769 for (uint32 r = min_race; r < max_race; ++r)
3770 for (uint32 c = min_class; c < max_class; ++c)
3771 PlayerCreateInfoAddItemHelper(r, c, item_id, amount);
3772 }
3773 else
3774 PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount);
3775
3776 ++count;
3777 } while (result->NextRow());
3778
3779 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3780 LOG_INFO("server.loading", " ");
3781 }
3782 }
3783
3784 // Load playercreate skills
3785 LOG_INFO("server.loading", "Loading Player Create Skill Data...");
3786 {
3787 uint32 oldMSTime = getMSTime();
3788
3789 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, skill, `rank` FROM playercreateinfo_skills");
3790
3791 if (!result)
3792 {
3793 LOG_WARN("server.loading", ">> Loaded 0 Player Create Skills. DB Table `playercreateinfo_skills` Is Empty.");
3794 }
3795 else
3796 {
3797 uint32 count = 0;
3798
3799 do
3800 {
3801 Field* fields = result->Fetch();
3802 uint32 raceMask = fields[0].Get<uint32>();
3803 uint32 classMask = fields[1].Get<uint32>();
3805 skill.SkillId = fields[2].Get<uint16>();
3806 skill.Rank = fields[3].Get<uint16>();
3807
3808 if (skill.Rank >= MAX_SKILL_STEP)
3809 {
3810 LOG_ERROR("sql.sql", "Skill rank value {} set for skill {} raceMask {} classMask {} is too high, max allowed value is {}", skill.Rank, skill.SkillId, raceMask, classMask, MAX_SKILL_STEP);
3811 continue;
3812 }
3813
3814 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3815 {
3816 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_skills` table, ignoring.", raceMask);
3817 continue;
3818 }
3819
3820 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3821 {
3822 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_skills` table, ignoring.", classMask);
3823 continue;
3824 }
3825
3826 if (!sSkillLineStore.LookupEntry(skill.SkillId))
3827 {
3828 LOG_ERROR("sql.sql", "Wrong skill id {} in `playercreateinfo_skills` table, ignoring.", skill.SkillId);
3829 continue;
3830 }
3831
3832 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3833 {
3834 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3835 {
3836 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3837 {
3838 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3839 {
3840 if (!GetSkillRaceClassInfo(skill.SkillId, raceIndex, classIndex))
3841 continue;
3842
3843 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3844 {
3845 info->skills.push_back(skill);
3846 ++count;
3847 }
3848 }
3849 }
3850 }
3851 }
3852 } while (result->NextRow());
3853
3854 LOG_INFO("server.loading", ">> Loaded {} Player Create Skills in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3855 LOG_INFO("server.loading", " ");
3856 }
3857 }
3858
3859 // Load playercreate spells
3860 LOG_INFO("server.loading", "Loading Player Create Spell Data...");
3861 {
3862 uint32 oldMSTime = getMSTime();
3863
3864 QueryResult result = WorldDatabase.Query("SELECT racemask, classmask, Spell FROM playercreateinfo_spell_custom");
3865
3866 if (!result)
3867 {
3868 LOG_WARN("server.loading", ">> Loaded 0 player create spells. DB table `playercreateinfo_spell_custom` is empty.");
3869 }
3870 else
3871 {
3872 uint32 count = 0;
3873
3874 do
3875 {
3876 Field* fields = result->Fetch();
3877 uint32 raceMask = fields[0].Get<uint32>();
3878 uint32 classMask = fields[1].Get<uint32>();
3879 uint32 spellId = fields[2].Get<uint32>();
3880
3881 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3882 {
3883 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_spell_custom` table, ignoring.", raceMask);
3884 continue;
3885 }
3886
3887 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3888 {
3889 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_spell_custom` table, ignoring.", classMask);
3890 continue;
3891 }
3892
3893 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3894 {
3895 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3896 {
3897 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3898 {
3899 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3900 {
3901 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3902 {
3903 info->customSpells.push_back(spellId);
3904 ++count;
3905 }
3906 }
3907 }
3908 }
3909 }
3910 } while (result->NextRow());
3911
3912 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3913 LOG_INFO("server.loading", " ");
3914 }
3915 }
3916
3917 // Load playercreate cast spell
3918 LOG_INFO("server.loading", "Loading Player Create Cast Spell Data...");
3919 {
3920 uint32 oldMSTime = getMSTime();
3921
3922 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
3923
3924 if (!result)
3925 {
3926 LOG_WARN("server.loading", ">> Loaded 0 Player Create Cast Spells. DB Table `playercreateinfo_cast_spell` Is Empty.");
3927 }
3928 else
3929 {
3930 uint32 count = 0;
3931
3932 do
3933 {
3934 Field* fields = result->Fetch();
3935 uint32 raceMask = fields[0].Get<uint32>();
3936 uint32 classMask = fields[1].Get<uint32>();
3937 uint32 spellId = fields[2].Get<uint32>();
3938
3939 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3940 {
3941 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
3942 continue;
3943 }
3944
3945 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3946 {
3947 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
3948 continue;
3949 }
3950
3951 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3952 {
3953 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3954 {
3955 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3956 {
3957 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3958 {
3959 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3960 {
3961 info->castSpells.push_back(spellId);
3962 ++count;
3963 }
3964 }
3965 }
3966 }
3967 }
3968 } while (result->NextRow());
3969
3970 LOG_INFO("server.loading", ">> Loaded {} Player Create Cast Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3971 LOG_INFO("server.loading", " ");
3972 }
3973 }
3974
3975 // Load playercreate actions
3976 LOG_INFO("server.loading", "Loading Player Create Action Data...");
3977 {
3978 uint32 oldMSTime = getMSTime();
3979
3980 // 0 1 2 3 4
3981 QueryResult result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
3982
3983 if (!result)
3984 {
3985 LOG_WARN("server.loading", ">> Loaded 0 Player Create Actions. DB Table `playercreateinfo_action` Is Empty.");
3986 LOG_INFO("server.loading", " ");
3987 }
3988 else
3989 {
3990 uint32 count = 0;
3991
3992 do
3993 {
3994 Field* fields = result->Fetch();
3995
3996 uint32 current_race = fields[0].Get<uint8>();
3997 if (current_race >= MAX_RACES)
3998 {
3999 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_action` table, ignoring.", current_race);
4000 continue;
4001 }
4002
4003 uint32 current_class = fields[1].Get<uint8>();
4004 if (current_class >= MAX_CLASSES)
4005 {
4006 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_action` table, ignoring.", current_class);
4007 continue;
4008 }
4009
4010 if (PlayerInfo* info = _playerInfo[current_race][current_class])
4011 info->action.push_back(PlayerCreateInfoAction(fields[2].Get<uint16>(), fields[3].Get<uint32>(), fields[4].Get<uint16>()));
4012
4013 ++count;
4014 } while (result->NextRow());
4015
4016 LOG_INFO("server.loading", ">> Loaded {} Player Create Actions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4017 LOG_INFO("server.loading", " ");
4018 }
4019 }
4020
4021 // Loading levels data (class/race dependent)
4022 LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
4023 {
4024 struct RaceStats
4025 {
4026 int16 StatModifier[MAX_STATS];
4027 };
4028
4029 std::array<RaceStats, MAX_RACES> raceStatModifiers;
4030
4031 uint32 oldMSTime = getMSTime();
4032
4033 // 0 1 2 3 4 5
4034 QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
4035
4036 if (!raceStatsResult)
4037 {
4038 LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
4039 LOG_INFO("server.loading", " ");
4040 exit(1);
4041 }
4042
4043 do
4044 {
4045 Field* fields = raceStatsResult->Fetch();
4046
4047 uint32 current_race = fields[0].Get<uint8>();
4048 if (current_race >= MAX_RACES)
4049 {
4050 LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
4051 continue;
4052 }
4053
4054 for (uint32 i = 0; i < MAX_STATS; ++i)
4055 raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
4056
4057 } while (raceStatsResult->NextRow());
4058
4059 // 0 1 2 3 4 5 6 7 8
4060 QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit, BaseHP, BaseMana FROM player_class_stats");
4061
4062 if (!result)
4063 {
4064 LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
4065 exit(1);
4066 }
4067
4068 uint32 count = 0;
4069
4070 do
4071 {
4072 Field* fields = result->Fetch();
4073
4074 uint32 current_class = fields[0].Get<uint8>();
4075 if (current_class >= MAX_CLASSES)
4076 {
4077 LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
4078 continue;
4079 }
4080
4081 uint32 current_level = fields[1].Get<uint8>();
4082 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4083 {
4084 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4085 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4086 else
4087 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
4088
4089 continue;
4090 }
4091
4092 for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
4093 {
4094 if (PlayerInfo* info = _playerInfo[race][current_class])
4095 {
4096 if (!info->levelInfo)
4097 info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4098
4099 PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4100 for (int i = 0; i < MAX_STATS; ++i)
4101 levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
4102 }
4103 }
4104
4105 PlayerClassInfo* info = _playerClassInfo[current_class];
4106 if (!info)
4107 {
4108 info = new PlayerClassInfo();
4110 _playerClassInfo[current_class] = info;
4111 }
4112
4113 PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4114
4115 levelInfo.basehealth = fields[7].Get<uint32>();
4116 levelInfo.basemana = fields[8].Get<uint32>();
4117
4118 ++count;
4119 } while (result->NextRow());
4120
4121 // Fill gaps and check integrity
4122 for (int race = 0; race < MAX_RACES; ++race)
4123 {
4124 // skip non existed races
4125 if (!sChrRacesStore.LookupEntry(race))
4126 continue;
4127
4128 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4129 {
4130 // skip non existed classes
4131 if (!sChrClassesStore.LookupEntry(class_))
4132 continue;
4133
4134 PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
4135 PlayerInfo* info = _playerInfo[race][class_];
4136 if (!info)
4137 continue;
4138
4139 // skip expansion races if not playing with expansion
4140 if (sWorld->getIntConfig(CONFIG_EXPANSION) < EXPANSION_THE_BURNING_CRUSADE && (race == RACE_BLOODELF || race == RACE_DRAENEI))
4141 continue;
4142
4143 // skip expansion classes if not playing with expansion
4145 continue;
4146
4147 // fatal error if no initial stats data
4148 if (!info->levelInfo || (info->levelInfo[sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL) - 1].stats[0] == 0 && class_ != CLASS_DEATH_KNIGHT) || (info->levelInfo[sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL) - 1].stats[0] == 0 && class_ == CLASS_DEATH_KNIGHT))
4149 {
4150 LOG_ERROR("sql.sql", "Race {} class {} initial level does not have stats data!", race, class_);
4151 exit(1);
4152 }
4153
4154 // fatal error if no initial health/mana data
4155 if (!pClassInfo->levelInfo || (pClassInfo->levelInfo[sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL) - 1].basehealth == 0 && class_ != CLASS_DEATH_KNIGHT) || (pClassInfo->levelInfo[sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL) - 1].basehealth == 0 && class_ == CLASS_DEATH_KNIGHT))
4156 {
4157 LOG_ERROR("sql.sql", "Class {} initial level does not have health/mana data!", class_);
4158 exit(1);
4159 }
4160
4161 // fill level gaps for stats
4162 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4163 {
4164 if ((info->levelInfo[level].stats[0] == 0 && class_ != CLASS_DEATH_KNIGHT) || (level >= sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL) && info->levelInfo[level].stats[0] == 0 && class_ == CLASS_DEATH_KNIGHT))
4165 {
4166 LOG_ERROR("sql.sql", "Race {} class {} level {} does not have stats data. Using stats data of level {}.", race, class_, level + 1, level);
4167 info->levelInfo[level] = info->levelInfo[level - 1];
4168 }
4169 }
4170
4171 // fill level gaps for health/mana
4172 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4173 {
4174 if ((pClassInfo->levelInfo[level].basehealth == 0 && class_ != CLASS_DEATH_KNIGHT) || (level >= sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL) && pClassInfo->levelInfo[level].basehealth == 0 && class_ == CLASS_DEATH_KNIGHT))
4175 {
4176 LOG_ERROR("sql.sql", "Class {} level {} does not have health/mana data. Using stats data of level {}.", class_, level + 1, level);
4177 pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1];
4178 }
4179 }
4180 }
4181 }
4182
4183 LOG_INFO("server.loading", ">> Loaded {} Level Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4184 LOG_INFO("server.loading", " ");
4185 }
4186
4187 // Loading xp per level data
4188 LOG_INFO("server.loading", "Loading Player Create XP Data...");
4189 {
4190 uint32 oldMSTime = getMSTime();
4191
4192 _playerXPperLevel.resize(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
4193 for (uint8 level = 0; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4194 _playerXPperLevel[level] = 0;
4195
4196 // 0 1
4197 QueryResult result = WorldDatabase.Query("SELECT Level, Experience FROM player_xp_for_level");
4198
4199 if (!result)
4200 {
4201 LOG_WARN("server.loading", ">> Loaded 0 xp for level definitions. DB table `player_xp_for_level` is empty.");
4202 LOG_INFO("server.loading", " ");
4203 exit(1);
4204 }
4205
4206 uint32 count = 0;
4207
4208 do
4209 {
4210 Field* fields = result->Fetch();
4211
4212 uint32 current_level = fields[0].Get<uint8>();
4213 uint32 current_xp = fields[1].Get<uint32>();
4214
4215 if (current_level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4216 {
4217 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4218 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4219 else
4220 {
4221 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_xp_for_levels` table, ignoring.", current_level);
4222 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4223 }
4224 continue;
4225 }
4226 //PlayerXPperLevel
4227 _playerXPperLevel[current_level] = current_xp;
4228 ++count;
4229 } while (result->NextRow());
4230
4231 // fill level gaps
4232 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4233 {
4234 if (_playerXPperLevel[level] == 0)
4235 {
4236 LOG_ERROR("sql.sql", "Level {} does not have XP for level data. Using data of level [{}] + 100.", level + 1, level);
4237 _playerXPperLevel[level] = _playerXPperLevel[level - 1] + 100;
4238 }
4239 }
4240
4241 LOG_INFO("server.loading", ">> Loaded {} XP For Level Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4242 LOG_INFO("server.loading", " ");
4243 }
4244}
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition: DBCStores.cpp:895
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
@ CONFIG_START_HEROIC_PLAYER_LEVEL
Definition: IWorld.h:243
@ CONFIG_START_PLAYER_LEVEL
Definition: IWorld.h:242
@ CONFIG_EXPANSION
Definition: IWorld.h:280
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:146
@ RACE_DRAENEI
Definition: SharedDefines.h:81
@ RACE_BLOODELF
Definition: SharedDefines.h:80
@ RACE_HUMAN
Definition: SharedDefines.h:71
@ EXPANSION_THE_BURNING_CRUSADE
Definition: SharedDefines.h:54
@ EXPANSION_WRATH_OF_THE_LICH_KING
Definition: SharedDefines.h:55
#define MAX_SKILL_STEP
Definition: DBCStructure.h:1580
Definition: Player.h:289
uint32 basehealth
Definition: Player.h:291
uint32 basemana
Definition: Player.h:292
Definition: Player.h:303
std::array< uint32, MAX_STATS > stats
Definition: Player.h:309
Definition: Player.h:315
Definition: Player.h:327
uint16 SkillId
Definition: Player.h:328
float orientation
Definition: Player.h:344
uint16 displayId_m
Definition: Player.h:345
float positionX
Definition: Player.h:341
uint32 areaId
Definition: Player.h:340
float positionY
Definition: Player.h:342
float positionZ
Definition: Player.h:343
uint32 mapId
Definition: Player.h:339
uint16 displayId_f
Definition: Player.h:346
void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count)
Definition: ObjectMgr.cpp:3591
Definition: DBCStructure.h:679
uint32 model_f
Definition: DBCStructure.h:685
uint32 model_m
Definition: DBCStructure.h:684

References _playerClassInfo, _playerInfo, _playerXPperLevel, PlayerInfo::areaId, PlayerClassLevelInfo::basehealth, PlayerClassLevelInfo::basemana, CLASS_DEATH_KNIGHT, CLASS_WARRIOR, CLASSMASK_ALL_PLAYABLE, CONFIG_EXPANSION, CONFIG_MAX_PLAYER_LEVEL, CONFIG_START_HEROIC_PLAYER_LEVEL, CONFIG_START_PLAYER_LEVEL, PlayerInfo::displayId_f, PlayerInfo::displayId_m, EXPANSION_THE_BURNING_CRUSADE, EXPANSION_WRATH_OF_THE_LICH_KING, Field::Get(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), GetSkillRaceClassInfo(), MapMgr::IsValidMapCoord(), PlayerClassInfo::levelInfo, PlayerInfo::levelInfo, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARN, PlayerInfo::mapId, MAX_CLASSES, MAX_RACES, MAX_SKILL_STEP, MAX_STATS, ChrRacesEntry::model_f, ChrRacesEntry::model_m, PlayerInfo::orientation, PlayerCreateInfoAddItemHelper(), PlayerInfo::positionX, PlayerInfo::positionY, PlayerInfo::positionZ, RACE_BLOODELF, RACE_DRAENEI, RACE_HUMAN, RACEMASK_ALL_PLAYABLE, sChrClassesStore, sChrRacesStore, PlayerCreateInfoSkill::SkillId, sMapStore, sSkillLineStore, PlayerLevelInfo::stats, STRONG_MAX_LEVEL, sWorld, and WorldDatabase.

◆ LoadPointOfInterestLocales()

void ObjectMgr::LoadPointOfInterestLocales ( )
492{
493 uint32 oldMSTime = getMSTime();
494
495 _pointOfInterestLocaleStore.clear(); // need for reload case
496
497 // 0 1 2
498 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale");
499
500 if (!result)
501 return;
502
503 do
504 {
505 Field* fields = result->Fetch();
506
507 uint32 ID = fields[0].Get<uint32>();
508
509 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
510 if (locale == LOCALE_enUS)
511 continue;
512
514 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
515 } while (result->NextRow());
516
517 LOG_INFO("server.loading", ">> Loaded {} Points Of Interest Locale Strings in {} ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
518}
Definition: CreatureData.h:358
std::vector< std::string > Name
Definition: CreatureData.h:359

References _pointOfInterestLocaleStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, PointOfInterestLocale::Name, and WorldDatabase.

◆ LoadPointsOfInterest()

void ObjectMgr::LoadPointsOfInterest ( )
7777{
7778 uint32 oldMSTime = getMSTime();
7779
7780 _pointsOfInterestStore.clear(); // need for reload case
7781
7782 uint32 count = 0;
7783
7784 // 0 1 2 3 4 5 6
7785 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
7786
7787 if (!result)
7788 {
7789 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
7790 LOG_INFO("server.loading", " ");
7791 return;
7792 }
7793
7794 do
7795 {
7796 Field* fields = result->Fetch();
7797
7798 uint32 point_id = fields[0].Get<uint32>();
7799
7800 PointOfInterest POI;
7801 POI.ID = point_id;
7802 POI.PositionX = fields[1].Get<float>();
7803 POI.PositionY = fields[2].Get<float>();
7804 POI.Icon = fields[3].Get<uint32>();
7805 POI.Flags = fields[4].Get<uint32>();
7806 POI.Importance = fields[5].Get<uint32>();
7807 POI.Name = fields[6].Get<std::string>();
7808
7809 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
7810 {
7811 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
7812 continue;
7813 }
7814
7815 _pointsOfInterestStore[point_id] = POI;
7816
7817 ++count;
7818 } while (result->NextRow());
7819
7820 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7821 LOG_INFO("server.loading", " ");
7822}
bool IsValidMapCoord(float c)
Definition: GridDefines.h:216
Definition: ObjectMgr.h:588
uint32 ID
Definition: ObjectMgr.h:589

References _pointsOfInterestStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), PointOfInterest::ID, Acore::IsValidMapCoord(), LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadProfanityNamesFromDB()

void ObjectMgr::LoadProfanityNamesFromDB ( )
8199{
8200 uint32 oldMSTime = getMSTime();
8201
8202 _profanityNamesStore.clear(); // need for reload case
8203
8204 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
8205
8206 if (!result)
8207 {
8208 LOG_WARN("server.loading", ">> Loaded 0 profanity names. DB table `profanity_name` is empty!");
8209 return;
8210 }
8211
8212 uint32 count = 0;
8213
8214 Field* fields;
8215 do
8216 {
8217 fields = result->Fetch();
8218 std::string name = fields[0].Get<std::string>();
8219
8220 std::wstring wstr;
8221 if (!Utf8toWStr (name, wstr))
8222 {
8223 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
8224 continue;
8225 }
8226
8227 wstrToLower(wstr);
8228
8229 _profanityNamesStore.insert(wstr);
8230 ++count;
8231 } while (result->NextRow());
8232
8233 LOG_INFO("server.loading", ">> Loaded {} profanity names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8234}

References _profanityNamesStore, CharacterDatabase, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, Utf8toWStr(), and wstrToLower().

◆ LoadProfanityNamesFromDBC()

void ObjectMgr::LoadProfanityNamesFromDBC ( )
8237{
8238 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8239 {
8240 LOG_WARN("server.loading", ">> Loaded 0 profanity names from DBC. Config option disabled.");
8241 return;
8242 }
8243
8244 uint32 oldMSTime = getMSTime();
8245
8246 uint32 count = 0;
8247
8248 for (NamesProfanityEntry const* profanityStore : sNamesProfanityStore)
8249 {
8250 std::wstring wstr;
8251
8252 Utf8toWStr(profanityStore->Pattern, wstr);
8253
8254 // DBC does not have clean entries, remove the junk.
8255 boost::algorithm::replace_all(wstr, "\\<", "");
8256 boost::algorithm::replace_all(wstr, "\\>", "");
8257
8258 _profanityNamesStore.insert(wstr);
8259 count++;
8260 }
8261
8262 LOG_INFO("server.loading", ">> Loaded {} profanity names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8263 LOG_INFO("server.loading", " ");
8264}
DBCStorage< NamesProfanityEntry > sNamesProfanityStore(NamesProfanityfmt)
@ CONFIG_STRICT_NAMES_PROFANITY
Definition: IWorld.h:187
Definition: DBCStructure.h:1405

References _profanityNamesStore, CONFIG_STRICT_NAMES_PROFANITY, getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, sNamesProfanityStore, sWorld, and Utf8toWStr().

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6155{
6156 uint32 oldMSTime = getMSTime();
6157
6158 _questAreaTriggerStore.clear(); // need for reload case
6159
6160 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6161
6162 if (!result)
6163 {
6164 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6165 LOG_INFO("server.loading", " ");
6166 return;
6167 }
6168
6169 uint32 count = 0;
6170
6171 do
6172 {
6173 ++count;
6174
6175 Field* fields = result->Fetch();
6176
6177 uint32 trigger_ID = fields[0].Get<uint32>();
6178 uint32 quest_ID = fields[1].Get<uint32>();
6179
6180 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6181 if (!atEntry)
6182 {
6183 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6184 continue;
6185 }
6186
6187 Quest const* quest = GetQuestTemplate(quest_ID);
6188
6189 if (!quest)
6190 {
6191 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6192 continue;
6193 }
6194
6196 {
6197 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not quest {}, but quest not have specialflag QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.", trigger_ID, quest_ID);
6198
6199 // this will prevent quest completing without objective
6200 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6201
6202 // continue; - quest modified to required objective and trigger can be allowed.
6203 }
6204
6205 _questAreaTriggerStore[trigger_ID] = quest_ID;
6206 } while (result->NextRow());
6207
6208 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6209 LOG_INFO("server.loading", " ");
6210}
@ QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT
Definition: QuestDef.h:161
Definition: QuestDef.h:210
bool HasSpecialFlag(uint32 flag) const
Definition: QuestDef.h:224

References _questAreaTriggerStore, Field::Get(), GetAreaTrigger(), getMSTime(), GetMSTimeDiffToNow(), GetQuestTemplate(), Quest::HasSpecialFlag(), LOG_ERROR, LOG_INFO, LOG_WARN, QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT, and WorldDatabase.

◆ LoadQuestGreetings()

void ObjectMgr::LoadQuestGreetings ( )
6231{
6232 uint32 oldMSTime = getMSTime();
6233
6234 _questGreetingStore.clear(); // For reload case
6235
6236 // 0 1 2 3 4
6237 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6238 if (!result)
6239 {
6240 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6241 return;
6242 }
6243
6244 do
6245 {
6246 Field* fields = result->Fetch();
6247
6248 uint32 id = fields[0].Get<uint32>();
6249 uint8 type = fields[1].Get<uint8>();
6250 switch (type)
6251 {
6252 case 0: // Creature
6253 if (!sObjectMgr->GetCreatureTemplate(id))
6254 {
6255 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6256 continue;
6257 }
6258 break;
6259 case 1: // GameObject
6260 if (!sObjectMgr->GetGameObjectTemplate(id))
6261 {
6262 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6263 continue;
6264 }
6265 break;
6266 default:
6267 LOG_ERROR("sql.sql", "Table `quest_greeting` has unknown type {} for id {}, skipped.", type, id);
6268 continue;
6269 }
6270
6271 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6272 QuestGreeting& data = _questGreetingStore[pairKey];
6273
6274 data.EmoteType = fields[2].Get<uint16>();
6275 data.EmoteDelay = fields[3].Get<uint32>();
6276 AddLocaleString(fields[4].Get<std::string>(), LOCALE_enUS, data.Greeting);
6277 }
6278 while (result->NextRow());
6279
6280 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", _questGreetingStore.size(), GetMSTimeDiffToNow(oldMSTime));
6281 LOG_INFO("server.loading", " ");
6282}
Definition: ObjectMgr.h:599
uint32 EmoteDelay
Definition: ObjectMgr.h:601
std::vector< std::string > Greeting
Definition: ObjectMgr.h:602
uint16 EmoteType
Definition: ObjectMgr.h:600

References _questGreetingStore, AddLocaleString(), QuestGreeting::EmoteDelay, QuestGreeting::EmoteType, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), QuestGreeting::Greeting, LOCALE_enUS, LOG_ERROR, LOG_INFO, LOG_WARN, sObjectMgr, and WorldDatabase.

◆ LoadQuestGreetingsLocales()

void ObjectMgr::LoadQuestGreetingsLocales ( )
6285{
6286 uint32 oldMSTime = getMSTime();
6287
6288 // 0 1 2 3
6289 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6290 if (!result)
6291 {
6292 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
6293 return;
6294 }
6295
6296 uint32 localeCount = 0;
6297 do
6298 {
6299 Field* fields = result->Fetch();
6300
6301 uint32 id = fields[0].Get<uint32>();
6302 uint8 type = fields[1].Get<uint8>();
6303 switch (type)
6304 {
6305 case 0: // Creature
6306 if (!sObjectMgr->GetCreatureTemplate(id))
6307 {
6308 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
6309 continue;
6310 }
6311 break;
6312 case 1: // GameObject
6313 if (!sObjectMgr->GetGameObjectTemplate(id))
6314 {
6315 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
6316 continue;
6317 }
6318 break;
6319 default:
6320 continue;
6321 }
6322
6323 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6324 QuestGreeting& data = _questGreetingStore[pairKey];
6325
6326 QuestGreetingContainer::iterator qgc = _questGreetingStore.find(pairKey);
6327 if (qgc == _questGreetingStore.end())
6328 {
6329 LOG_ERROR("sql.sql", "QuestGreeting (Id: {} Type: {}) found in table `quest_greeting_locale` but does not exist in `quest_greeting`. Skipped!", id, type);
6330 continue;
6331 }
6332
6333 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
6334 if (locale == LOCALE_enUS)
6335 continue;
6336
6337 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
6338 localeCount++;
6339 } while (result->NextRow());
6340
6341 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
6342 LOG_INFO("server.loading", " ");
6343}

References _questGreetingStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), QuestGreeting::Greeting, LOCALE_enUS, LOG_ERROR, LOG_INFO, LOG_WARN, sObjectMgr, and WorldDatabase.

◆ LoadQuestLocales()

void ObjectMgr::LoadQuestLocales ( )
5119{
5120 uint32 oldMSTime = getMSTime();
5121
5122 _questLocaleStore.clear(); // need for reload case
5123
5124 // 0 1 2 3 4 5 6 7 8 9 10
5125 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5126
5127 if (!result)
5128 return;
5129
5130 do
5131 {
5132 Field* fields = result->Fetch();
5133
5134 uint32 ID = fields[0].Get<uint32>();
5135
5136 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5137 if (locale == LOCALE_enUS)
5138 continue;
5139
5140 QuestLocale& data = _questLocaleStore[ID];
5141 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5142 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5143 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5144 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5145 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5146
5147 for (uint8 i = 0; i < 4; ++i)
5148 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5149 } while (result->NextRow());
5150
5151 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5152}
Definition: QuestDef.h:183
std::vector< std::string > AreaDescription
Definition: QuestDef.h:191
std::vector< std::string > CompletedText
Definition: QuestDef.h:192
std::vector< std::string > Title
Definition: QuestDef.h:186
std::vector< std::string > Objectives
Definition: QuestDef.h:188
std::vector< std::vector< std::string > > ObjectiveText
Definition: QuestDef.h:193
std::vector< std::string > Details
Definition: QuestDef.h:187

References _questLocaleStore, AddLocaleString(), QuestLocale::AreaDescription, QuestLocale::CompletedText, QuestLocale::Details, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, QuestLocale::Objectives, QuestLocale::ObjectiveText, QuestLocale::Title, and WorldDatabase.

◆ LoadQuestMoneyRewards()

void ObjectMgr::LoadQuestMoneyRewards ( )
10155{
10156 uint32 oldMSTime = getMSTime();
10157
10158 _questMoneyRewards.clear();
10159
10160 // 0 1 2 3 4 5 6 7 8 9 10
10161 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
10162 if (!result)
10163 {
10164 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
10165 return;
10166 }
10167
10168 uint32 count = 0;
10169 do
10170 {
10171 Field* fields = result->Fetch();
10172 uint32 Level = fields[0].Get<uint32>();
10173
10174 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
10175 questMoneyReward.fill(0);
10176
10177 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
10178 {
10179 questMoneyReward[i] = fields[1 + i].Get<uint32>();
10180 ++count;
10181 }
10182 } while (result->NextRow());
10183
10184 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10185 LOG_INFO("server.loading", " ");
10186}
std::array< uint32, MAX_QUEST_MONEY_REWARDS > QuestMoneyRewardArray
Definition: ObjectMgr.h:716

References _questMoneyRewards, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, MAX_QUEST_MONEY_REWARDS, and WorldDatabase.

◆ LoadQuestOfferRewardLocale()

void ObjectMgr::LoadQuestOfferRewardLocale ( )
6346{
6347 uint32 oldMSTime = getMSTime();
6348
6349 _questOfferRewardLocaleStore.clear(); // need for reload case
6350
6351 // 0 1 2
6352 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
6353 if (!result)
6354 return;
6355
6356 do
6357 {
6358 Field* fields = result->Fetch();
6359
6360 uint32 id = fields[0].Get<uint32>();
6361 std::string localeName = fields[1].Get<std::string>();
6362
6363 LocaleConstant locale = GetLocaleByName(localeName);
6364 if (locale == LOCALE_enUS)
6365 continue;
6366
6368 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
6369 } while (result->NextRow());
6370
6371 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6372}
Definition: QuestDef.h:202
std::vector< std::string > RewardText
Definition: QuestDef.h:203

References _questOfferRewardLocaleStore, AddLocaleString(), Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, QuestOfferRewardLocale::RewardText, and WorldDatabase.

◆ LoadQuestPOI()

void ObjectMgr::LoadQuestPOI ( )
7825{
7826 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
7827 {
7828 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
7829 LOG_INFO("server.loading", " ");
7830 return;
7831 }
7832
7833 uint32 oldMSTime = getMSTime();
7834
7835 _questPOIStore.clear(); // need for reload case
7836
7837 uint32 count = 0;
7838
7839 // 0 1 2 3 4 5 6 7
7840 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
7841
7842 if (!result)
7843 {
7844 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
7845 LOG_INFO("server.loading", " ");
7846 return;
7847 }
7848
7849 // 0 1 2 3
7850 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
7851
7852 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
7853
7854 if (points)
7855 {
7856 // The first result should have the highest questId
7857 Field* fields = points->Fetch();
7858 uint32 questIdMax = fields[0].Get<uint32>();
7859 POIs.resize(questIdMax + 1);
7860
7861 do
7862 {
7863 fields = points->Fetch();
7864
7865 uint32 questId = fields[0].Get<uint32>();
7866 uint32 id = fields[1].Get<uint32>();
7867 int32 x = fields[2].Get<int32>();
7868 int32 y = fields[3].Get<int32>();
7869
7870 if (POIs[questId].size() <= id + 1)
7871 POIs[questId].resize(id + 10);
7872
7873 QuestPOIPoint point(x, y);
7874 POIs[questId][id].push_back(point);
7875 } while (points->NextRow());
7876 }
7877
7878 do
7879 {
7880 Field* fields = result->Fetch();
7881
7882 uint32 questId = fields[0].Get<uint32>();
7883 uint32 id = fields[1].Get<uint32>();
7884 int32 objIndex = fields[2].Get<int32>();
7885 uint32 mapId = fields[3].Get<uint32>();
7886 uint32 WorldMapAreaId = fields[4].Get<uint32>();
7887 uint32 FloorId = fields[5].Get<uint32>();
7888 uint32 unk3 = fields[6].Get<uint32>();
7889 uint32 unk4 = fields[7].Get<uint32>();
7890
7891 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
7892 if (questId < POIs.size() && id < POIs[questId].size())
7893 {
7894 POI.points = POIs[questId][id];
7895 _questPOIStore[questId].push_back(POI);
7896 }
7897 else
7898 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
7899
7900 ++count;
7901 } while (result->NextRow());
7902
7903 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7904 LOG_INFO("server.loading", " ");
7905}
@ CONFIG_QUEST_POI_ENABLED
Definition: IWorld.h:180
Definition: ObjectMgr.h:638
Definition: ObjectMgr.h:647

References _questPOIStore, CONFIG_QUEST_POI_ENABLED, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sWorld, and WorldDatabase.

◆ LoadQuestRelationsHelper()

void ObjectMgr::LoadQuestRelationsHelper ( QuestRelations map,
std::string const &  table,
bool  starter,
bool  go 
)
private
7995{
7996 uint32 oldMSTime = getMSTime();
7997
7998 map.clear(); // need for reload case
7999
8000 uint32 count = 0;
8001
8002 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8003
8004 if (!result)
8005 {
8006 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8007 LOG_INFO("server.loading", " ");
8008 return;
8009 }
8010
8011 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8012 if (starter)
8013 poolRelationMap->clear();
8014
8015 do
8016 {
8017 uint32 id = result->Fetch()[0].Get<uint32>();
8018 uint32 quest = result->Fetch()[1].Get<uint32>();
8019 uint32 poolId = result->Fetch()[2].Get<uint32>();
8020
8021 if (_questTemplates.find(quest) == _questTemplates.end())
8022 {
8023 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8024 continue;
8025 }
8026
8027 if (!poolId || !starter)
8028 map.insert(QuestRelations::value_type(id, quest));
8029 else if (starter)
8030 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8031
8032 ++count;
8033 } while (result->NextRow());
8034
8035 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8036 LOG_INFO("server.loading", " ");
8037}
#define sPoolMgr
Definition: PoolMgr.h:163
std::multimap< uint32, uint32 > PooledQuestRelation
Definition: PoolMgr.h:98

References _questTemplates, getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sPoolMgr, and WorldDatabase.

Referenced by LoadCreatureQuestEnders(), LoadCreatureQuestStarters(), LoadGameobjectQuestEnders(), and LoadGameobjectQuestStarters().

◆ LoadQuestRequestItemsLocale()

void ObjectMgr::LoadQuestRequestItemsLocale ( )
6375{
6376 uint32 oldMSTime = getMSTime();
6377
6378 _questRequestItemsLocaleStore.clear(); // need for reload case
6379
6380 // 0 1 2
6381 QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale");
6382 if (!result)
6383 return;
6384
6385 do
6386 {
6387 Field* fields = result->Fetch();
6388
6389 uint32 id = fields[0].Get<uint32>();
6390 std::string localeName = fields[1].Get<std::string>();
6391
6392 LocaleConstant locale = GetLocaleByName(localeName);
6393 if (locale == LOCALE_enUS)
6394 continue;
6395
6397 AddLocaleString(fields[2].Get<std::string>(), locale, data.CompletionText);
6398 } while (result->NextRow());
6399
6400 LOG_INFO("server.loading", ">> Loaded {} Quest Request Items Locale Strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6401}
Definition: QuestDef.h:197
std::vector< std::string > CompletionText
Definition: QuestDef.h:198

References _questRequestItemsLocaleStore, AddLocaleString(), QuestRequestItemsLocale::CompletionText, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, and WorldDatabase.

◆ LoadQuests()

void ObjectMgr::LoadQuests ( )
4351{
4352 uint32 oldMSTime = getMSTime();
4353
4354 // For reload case
4355 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4356 delete itr->second;
4357 _questTemplates.clear();
4358
4359 mExclusiveQuestGroups.clear();
4360
4361 QueryResult result = WorldDatabase.Query("SELECT "
4362 //0 1 2 3 4 5 6 7 8
4363 "ID, QuestType, QuestLevel, MinLevel, QuestSortID, QuestInfoID, SuggestedGroupNum, TimeAllowed, AllowableRaces,"
4364 // 9 10 11 12
4365 "RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2, "
4366 // 13 14 15 16 17 18 19 20
4367 "RewardNextQuest, RewardXPDifficulty, RewardMoney, RewardMoneyDifficulty, RewardDisplaySpell, RewardSpell, RewardHonor, RewardKillHonor, "
4368 // 21 22 23 24 25 26
4369 "StartItem, Flags, RewardTitle, RequiredPlayerKills, RewardTalents, RewardArenaPoints, "
4370 // 27 28 29 30 31 32 33 34
4371 "RewardItem1, RewardAmount1, RewardItem2, RewardAmount2, RewardItem3, RewardAmount3, RewardItem4, RewardAmount4, "
4372 // 35 36 37 38 39 40 41 42 43 44 45 46
4373 "RewardChoiceItemID1, RewardChoiceItemQuantity1, RewardChoiceItemID2, RewardChoiceItemQuantity2, RewardChoiceItemID3, RewardChoiceItemQuantity3, RewardChoiceItemID4, RewardChoiceItemQuantity4, RewardChoiceItemID5, RewardChoiceItemQuantity5, RewardChoiceItemID6, RewardChoiceItemQuantity6, "
4374 // 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
4375 "RewardFactionID1, RewardFactionValue1, RewardFactionOverride1, RewardFactionID2, RewardFactionValue2, RewardFactionOverride2, RewardFactionID3, RewardFactionValue3, RewardFactionOverride3, RewardFactionID4, RewardFactionValue4, RewardFactionOverride4, RewardFactionID5, RewardFactionValue5, RewardFactionOverride5,"
4376 // 61 63 64 65
4377 "POIContinent, POIx, POIy, POIPriority, "
4378 // 66 67 68 69 70
4379 "LogTitle, LogDescription, QuestDescription, AreaDescription, QuestCompletionLog, "
4380 // 71 72 73 74 75 76 77 78
4381 "RequiredNpcOrGo1, RequiredNpcOrGo2, RequiredNpcOrGo3, RequiredNpcOrGo4, RequiredNpcOrGoCount1, RequiredNpcOrGoCount2, RequiredNpcOrGoCount3, RequiredNpcOrGoCount4, "
4382 // 79 80 81 82 83 84 85 86
4383 "ItemDrop1, ItemDrop2, ItemDrop3, ItemDrop4, ItemDropQuantity1, ItemDropQuantity2, ItemDropQuantity3, ItemDropQuantity4, "
4384 // 87 88 89 90 91 92 93 94 95 96 97 98
4385 "RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
4386 // 99 100 101 102 103
4387 "Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4"
4388 " FROM quest_template");
4389 if (!result)
4390 {
4391 LOG_WARN("server.loading", ">> Loaded 0 quests definitions. DB table `quest_template` is empty.");
4392 LOG_INFO("server.loading", " ");
4393 return;
4394 }
4395
4396 // create multimap previous quest for each existed quest
4397 // some quests can have many previous maps set by NextQuestId in previous quest
4398 // for example set of race quests can lead to single not race specific quest
4399 do
4400 {
4401 Field* fields = result->Fetch();
4402
4403 Quest* newQuest = new Quest(fields);
4404 _questTemplates[newQuest->GetQuestId()] = newQuest;
4405 } while (result->NextRow());
4406
4407 // pussywizard:
4408 {
4409 uint32 max = 0;
4410 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4411 if (itr->first > max)
4412 max = itr->first;
4413 if (max)
4414 {
4415 _questTemplatesFast.clear();
4416 _questTemplatesFast.resize(max + 1, nullptr);
4417 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4418 _questTemplatesFast[itr->first] = itr->second;
4419 }
4420 }
4421
4422 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4423 itr->second->InitializeQueryData();
4424
4425 std::map<uint32, uint32> usedMailTemplates;
4426
4427 // Load `quest_details`
4428 // 0 1 2 3 4 5 6 7 8
4429 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4 FROM quest_details");
4430
4431 if (!result)
4432 {
4433 LOG_WARN("server.loading", ">> Loaded 0 quest details. DB table `quest_details` is empty.");
4434 }
4435 else
4436 {
4437 do
4438 {
4439 Field* fields = result->Fetch();
4440 uint32 questId = fields[0].Get<uint32>();
4441
4442 auto itr = _questTemplates.find(questId);
4443 if (itr != _questTemplates.end())
4444 itr->second->LoadQuestDetails(fields);
4445 else
4446 LOG_ERROR("sql.sql", "Table `quest_details` has data for quest {} but such quest does not exist", questId);
4447 } while (result->NextRow());
4448 }
4449
4450 // Load `quest_request_items`
4451 // 0 1 2 3
4452 result = WorldDatabase.Query("SELECT ID, EmoteOnComplete, EmoteOnIncomplete, CompletionText FROM quest_request_items");
4453
4454 if (!result)
4455 {
4456 LOG_WARN("server.loading", ">> Loaded 0 quest request items. DB table `quest_request_items` is empty.");
4457 }
4458 else
4459 {
4460 do
4461 {
4462 Field* fields = result->Fetch();
4463 uint32 questId = fields[0].Get<uint32>();
4464
4465 auto itr = _questTemplates.find(questId);
4466 if (itr != _questTemplates.end())
4467 itr->second->LoadQuestRequestItems(fields);
4468 else
4469 LOG_ERROR("sql.sql", "Table `quest_request_items` has data for quest {} but such quest does not exist", questId);
4470 } while (result->NextRow());
4471 }
4472
4473 // Load `quest_offer_reward`
4474 // 0 1 2 3 4 5 6 7 8 9
4475 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4, RewardText FROM quest_offer_reward");
4476
4477 if (!result)
4478 {
4479 LOG_WARN("server.loading", ">> Loaded 0 quest reward emotes. DB table `quest_offer_reward` is empty.");
4480 }
4481 else
4482 {
4483 do
4484 {
4485 Field* fields = result->Fetch();
4486 uint32 questId = fields[0].Get<uint32>();
4487
4488 auto itr = _questTemplates.find(questId);
4489 if (itr != _questTemplates.end())
4490 itr->second->LoadQuestOfferReward(fields);
4491 else
4492 LOG_ERROR("sql.sql", "Table `quest_offer_reward` has data for quest {} but such quest does not exist", questId);
4493 } while (result->NextRow());
4494 }
4495
4496 // Load `quest_template_addon`
4497 // 0 1 2 3 4 5 6 7 8
4498 result = WorldDatabase.Query("SELECT ID, MaxLevel, AllowableClasses, SourceSpellID, PrevQuestID, NextQuestID, ExclusiveGroup, RewardMailTemplateID, RewardMailDelay, "
4499 //9 10 11 12 13 14 15 16 17
4500 "RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, RewardMailSenderEntry, SpecialFlags FROM quest_template_addon LEFT JOIN quest_mail_sender ON Id=QuestId");
4501
4502 if (!result)
4503 {
4504 LOG_WARN("server.loading", ">> Loaded 0 quest template addons. DB table `quest_template_addon` is empty.");
4505 }
4506 else
4507 {
4508 do
4509 {
4510 Field* fields = result->Fetch();
4511 uint32 questId = fields[0].Get<uint32>();
4512
4513 auto itr = _questTemplates.find(questId);
4514 if (itr != _questTemplates.end())
4515 itr->second->LoadQuestTemplateAddon(fields);
4516 else
4517 LOG_ERROR("sql.sql", "Table `quest_template_addon` has data for quest {} but such quest does not exist", questId);
4518 } while (result->NextRow());
4519 }
4520
4521 // Post processing
4522 for (QuestMap::iterator iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter)
4523 {
4524 // skip post-loading checks for disabled quests
4525 if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr))
4526 continue;
4527
4528 Quest* qinfo = iter->second;
4529
4530 // additional quest integrity checks (GO, creature_template and item_template must be loaded already)
4531
4532 if (qinfo->GetQuestMethod() >= 3)
4533 LOG_ERROR("sql.sql", "Quest {} has `Method` = {}, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod());
4534
4536 {
4537 LOG_ERROR("sql.sql", "Quest {} has `SpecialFlags` = {} > max allowed value. Correct `SpecialFlags` to value <= {}",
4540 }
4541
4542 if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY)
4543 {
4544 LOG_ERROR("sql.sql", "Weekly Quest {} is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId());
4545 qinfo->Flags &= ~QUEST_FLAGS_DAILY;
4546 }
4547
4548 if (qinfo->Flags & QUEST_FLAGS_DAILY)
4549 {
4551 {
4552 LOG_ERROR("sql.sql", "Daily Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4554 }
4555 }
4556
4557 if (qinfo->Flags & QUEST_FLAGS_WEEKLY)
4558 {
4560 {
4561 LOG_ERROR("sql.sql", "Weekly Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4563 }
4564 }
4565
4567 {
4569 {
4570 LOG_ERROR("sql.sql", "Monthly quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4572 }
4573 }
4574
4575 if (qinfo->Flags & QUEST_FLAGS_TRACKING)
4576 {
4577 // at auto-reward can be rewarded only RewardChoiceItemId[0]
4578 for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j )
4579 {
4580 if (uint32 id = qinfo->RewardChoiceItemId[j])
4581 {
4582 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item from `RewardChoiceItemId{}` can't be rewarded with quest flag QUEST_FLAGS_TRACKING.",
4583 qinfo->GetQuestId(), j + 1, id, j + 1);
4584 // no changes, quest ignore this data
4585 }
4586 }
4587 }
4588
4589 // client quest log visual (area case)
4590 if (qinfo->ZoneOrSort > 0)
4591 {
4592 if (!sAreaTableStore.LookupEntry(qinfo->ZoneOrSort))
4593 {
4594 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (zone case) but zone with this id does not exist.",
4595 qinfo->GetQuestId(), qinfo->ZoneOrSort);
4596 // no changes, quest not dependent from this value but can have problems at client
4597 }
4598 }
4599 // client quest log visual (sort case)
4600 if (qinfo->ZoneOrSort < 0)
4601 {
4602 QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort));
4603 if (!qSort)
4604 {
4605 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (sort case) but quest sort with this id does not exist.",
4606 qinfo->GetQuestId(), qinfo->ZoneOrSort);
4607 // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check)
4608 }
4609 //check for proper RequiredSkillId value (skill case)
4610 if (uint32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
4611 {
4612 if (qinfo->RequiredSkillId != skill_id)
4613 {
4614 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} but `RequiredSkillId` does not have a corresponding value ({}).",
4615 qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id);
4616 //override, and force proper value here?
4617 }
4618 }
4619 }
4620
4621 // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class
4622 if (qinfo->RequiredClasses)
4623 {
4625 {
4626 LOG_ERROR("sql.sql", "Quest {} does not contain any playable classes in `RequiredClasses` ({}), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses);
4627 qinfo->RequiredClasses = 0;
4628 }
4629 }
4630 // AllowableRaces, can be 0/RACEMASK_ALL_PLAYABLE to allow any race
4631 if (qinfo->AllowableRaces)
4632 {
4633 if (!(qinfo->AllowableRaces & RACEMASK_ALL_PLAYABLE))
4634 {
4635 LOG_ERROR("sql.sql", "Quest {} does not contain any playable races in `AllowableRaces` ({}), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->AllowableRaces);
4636 qinfo->AllowableRaces = 0;
4637 }
4638 }
4639 // RequiredSkillId, can be 0
4640 if (qinfo->RequiredSkillId)
4641 {
4642 if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId))
4643 {
4644 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillId` = {} but this skill does not exist",
4645 qinfo->GetQuestId(), qinfo->RequiredSkillId);
4646 }
4647 }
4648
4649 if (qinfo->RequiredSkillPoints)
4650 {
4651 if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue())
4652 {
4653 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillPoints` = {} but max possible skill is {}, quest can't be done.",
4654 qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue());
4655 // no changes, quest can't be done for this requirement
4656 }
4657 }
4658 // else Skill quests can have 0 skill level, this is ok
4659
4660 if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2))
4661 {
4662 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId2` = {} but faction template {} does not exist, quest can't be done.",
4663 qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2);
4664 // no changes, quest can't be done for this requirement
4665 }
4666
4667 if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1))
4668 {
4669 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId1` = {} but faction template {} does not exist, quest can't be done.",
4670 qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1);
4671 // no changes, quest can't be done for this requirement
4672 }
4673
4674 if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction))
4675 {
4676 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepFaction` = {} but faction template {} does not exist, quest can't be done.",
4677 qinfo->GetQuestId(), qinfo->RequiredMinRepFaction, qinfo->RequiredMinRepFaction);
4678 // no changes, quest can't be done for this requirement
4679 }
4680
4681 if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction))
4682 {
4683 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepFaction` = {} but faction template {} does not exist, quest can't be done.",
4684 qinfo->GetQuestId(), qinfo->RequiredMaxRepFaction, qinfo->RequiredMaxRepFaction);
4685 // no changes, quest can't be done for this requirement
4686 }
4687
4689 {
4690 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but max reputation is {}, quest can't be done.",
4692 // no changes, quest can't be done for this requirement
4693 }
4694
4695 if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue)
4696 {
4697 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} and `RequiredMinRepValue` = {}, quest can't be done.",
4698 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue, qinfo->RequiredMinRepValue);
4699 // no changes, quest can't be done for this requirement
4700 }
4701
4702 if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0)
4703 {
4704 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue1` = {} but `RequiredFactionId1` is 0, value has no effect",
4705 qinfo->GetQuestId(), qinfo->RequiredFactionValue1);
4706 // warning
4707 }
4708
4709 if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0)
4710 {
4711 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue2` = {} but `RequiredFactionId2` is 0, value has no effect",
4712 qinfo->GetQuestId(), qinfo->RequiredFactionValue2);
4713 // warning
4714 }
4715
4716 if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue != 0)
4717 {
4718 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but `RequiredMinRepFaction` is 0, value has no effect",
4719 qinfo->GetQuestId(), qinfo->RequiredMinRepValue);
4720 // warning
4721 }
4722
4723 if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue != 0)
4724 {
4725 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} but `RequiredMaxRepFaction` is 0, value has no effect",
4726 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue);
4727 // warning
4728 }
4729
4730 if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId))
4731 {
4732 LOG_ERROR("sql.sql", "Quest {} has `RewardTitleId` = {} but CharTitle Id {} does not exist, quest can't be rewarded with title.",
4733 qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId());
4734 qinfo->RewardTitleId = 0;
4735 // quest can't reward this title
4736 }
4737
4738 if (qinfo->StartItem)
4739 {
4740 if (!sObjectMgr->GetItemTemplate(qinfo->StartItem))
4741 {
4742 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but item with entry {} does not exist, quest can't be done.",
4743 qinfo->GetQuestId(), qinfo->StartItem, qinfo->StartItem);
4744 qinfo->StartItem = 0; // quest can't be done for this requirement
4745 }
4746 else if (qinfo->StartItemCount == 0)
4747 {
4748 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but `StartItemCount` = 0, set to 1 but need fix in DB.",
4749 qinfo->GetQuestId(), qinfo->StartItem);
4750 qinfo->StartItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB
4751 }
4752 }
4753 else if (qinfo->StartItemCount > 0)
4754 {
4755 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = 0 but `StartItemCount` = {}, useless value.",
4756 qinfo->GetQuestId(), qinfo->StartItemCount);
4757 qinfo->StartItemCount = 0; // no quest work changes in fact
4758 }
4759
4760 if (qinfo->SourceSpellid)
4761 {
4762 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid);
4763 if (!spellInfo)
4764 {
4765 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} doesn't exist, quest can't be done.",
4766 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
4767 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
4768 }
4769 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
4770 {
4771 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} is broken, quest can't be done.",
4772 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
4773 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
4774 }
4775 }
4776
4777 for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
4778 {
4779 uint32 id = qinfo->RequiredItemId[j];
4780 if (id)
4781 {
4782 if (qinfo->RequiredItemCount[j] == 0)
4783 {
4784 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but `RequiredItemCount{}` = 0, quest can't be done.",
4785 qinfo->GetQuestId(), j + 1, id, j + 1);
4786 // no changes, quest can't be done for this requirement
4787 }
4788
4790
4791 if (!sObjectMgr->GetItemTemplate(id))
4792 {
4793 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but item with entry {} does not exist, quest can't be done.",
4794 qinfo->GetQuestId(), j + 1, id, id);
4795 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
4796 }
4797 }
4798 else if (qinfo->RequiredItemCount[j] > 0)
4799 {
4800 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = 0 but `RequiredItemCount{}` = {}, quest can't be done.",
4801 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredItemCount[j]);
4802 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
4803 }
4804 }
4805
4806 for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
4807 {
4808 uint32 id = qinfo->ItemDrop[j];
4809 if (id)
4810 {
4811 if (!sObjectMgr->GetItemTemplate(id))
4812 {
4813 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = {} but item with entry {} does not exist, quest can't be done.",
4814 qinfo->GetQuestId(), j + 1, id, id);
4815 // no changes, quest can't be done for this requirement
4816 }
4817 }
4818 else
4819 {
4820 if (qinfo->ItemDropQuantity[j] > 0)
4821 {
4822 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = 0 but `ItemDropQuantity{}` = {}.",
4823 qinfo->GetQuestId(), j + 1, j + 1, qinfo->ItemDropQuantity[j]);
4824 // no changes, quest ignore this data
4825 }
4826 }
4827 }
4828
4829 for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
4830 {
4831 int32 id = qinfo->RequiredNpcOrGo[j];
4832 if (id < 0 && !sObjectMgr->GetGameObjectTemplate(-id))
4833 {
4834 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but gameobject {} does not exist, quest can't be done.",
4835 qinfo->GetQuestId(), j + 1, id, uint32(-id));
4836 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
4837 }
4838
4839 if (id > 0 && !sObjectMgr->GetCreatureTemplate(id))
4840 {
4841 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but creature with entry {} does not exist, quest can't be done.",
4842 qinfo->GetQuestId(), j + 1, id, uint32(id));
4843 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
4844 }
4845
4846 if (id)
4847 {
4848 // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast
4849
4851
4852 if (!qinfo->RequiredNpcOrGoCount[j])
4853 {
4854 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but `RequiredNpcOrGoCount{}` = 0, quest can't be done.",
4855 qinfo->GetQuestId(), j + 1, id, j + 1);
4856 // no changes, quest can be incorrectly done, but we already report this
4857 }
4858 }
4859 else if (qinfo->RequiredNpcOrGoCount[j] > 0)
4860 {
4861 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = 0 but `RequiredNpcOrGoCount{}` = {}.",
4862 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredNpcOrGoCount[j]);
4863 // no changes, quest ignore this data
4864 }
4865 }
4866
4867 for (uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j)
4868 {
4869 uint32 id = qinfo->RewardChoiceItemId[j];
4870 if (id)
4871 {
4872 if (!sObjectMgr->GetItemTemplate(id))
4873 {
4874 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
4875 qinfo->GetQuestId(), j + 1, id, id);
4876 qinfo->RewardChoiceItemId[j] = 0; // no changes, quest will not reward this
4877 }
4878
4879 if (!qinfo->RewardChoiceItemCount[j])
4880 {
4881 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but `RewardChoiceItemCount{}` = 0, quest can't be done.",
4882 qinfo->GetQuestId(), j + 1, id, j + 1);
4883 // no changes, quest can't be done
4884 }
4885 }
4886 else if (qinfo->RewardChoiceItemCount[j] > 0)
4887 {
4888 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = 0 but `RewardChoiceItemCount{}` = {}.",
4889 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardChoiceItemCount[j]);
4890 // no changes, quest ignore this data
4891 }
4892 }
4893
4894 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
4895 {
4896 if (!qinfo->RewardItemId[0] && qinfo->RewardItemId[j])
4897 {
4898 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId1` but has `RewardItem{}`. Reward item will not be loaded.",
4899 qinfo->GetQuestId(), j + 1);
4900 }
4901 if (!qinfo->RewardItemId[1] && j > 1 && qinfo->RewardItemId[j])
4902 {
4903 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId2` but has `RewardItem{}`. Reward item will not be loaded.",
4904 qinfo->GetQuestId(), j + 1);
4905 }
4906 if (!qinfo->RewardItemId[2] && j > 2 && qinfo->RewardItemId[j])
4907 {
4908 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId3` but has `RewardItem{}`. Reward item will not be loaded.",
4909 qinfo->GetQuestId(), j + 1);
4910 }
4911 }
4912
4913 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
4914 {
4915 uint32 id = qinfo->RewardItemId[j];
4916 if (id)
4917 {
4918 if (!sObjectMgr->GetItemTemplate(id))
4919 {
4920 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
4921 qinfo->GetQuestId(), j + 1, id, id);
4922 qinfo->RewardItemId[j] = 0; // no changes, quest will not reward this item
4923 }
4924
4925 if (!qinfo->RewardItemIdCount[j])
4926 {
4927 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but `RewardItemIdCount{}` = 0, quest will not reward this item.",
4928 qinfo->GetQuestId(), j + 1, id, j + 1);
4929 // no changes
4930 }
4931 }
4932 else if (qinfo->RewardItemIdCount[j] > 0)
4933 {
4934 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = 0 but `RewardItemIdCount{}` = {}.",
4935 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardItemIdCount[j]);
4936 // no changes, quest ignore this data
4937 }
4938 }
4939
4940 for (uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j)
4941 {
4942 if (qinfo->RewardFactionId[j])
4943 {
4944 if (std::abs(qinfo->RewardFactionValueId[j]) > 9)
4945 {
4946 LOG_ERROR("sql.sql", "Quest {} has RewardFactionValueId{} = {}. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j + 1, qinfo->RewardFactionValueId[j]);
4947 }
4948 if (!sFactionStore.LookupEntry(qinfo->RewardFactionId[j]))
4949 {
4950 LOG_ERROR("sql.sql", "Quest {} has `RewardFactionId{}` = {} but raw faction (faction.dbc) {} does not exist, quest will not reward reputation for this faction.", qinfo->GetQuestId(), j + 1, qinfo->RewardFactionId[j], qinfo->RewardFactionId[j]);
4951 qinfo->RewardFactionId[j] = 0; // quest will not reward this
4952 }
4953 }
4954
4955 else if (qinfo->RewardFactionValueIdOverride[j] != 0)
4956 {
4957 LOG_ERROR("sql.sql", "Quest {} has `RewardFactionId{}` = 0 but `RewardFactionValueIdOverride{}` = {}.",
4958 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardFactionValueIdOverride[j]);
4959 // no changes, quest ignore this data
4960 }
4961 }
4962
4963 if (qinfo->RewardDisplaySpell)
4964 {
4965 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell);
4966
4967 if (!spellInfo)
4968 {
4969 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} does not exist, spell removed as display reward.",
4970 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
4971 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
4972 }
4973
4974 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
4975 {
4976 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is broken, quest will not have a spell reward.",
4977 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
4978 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
4979 }
4980
4981 else if (GetTalentSpellCost(qinfo->RewardDisplaySpell))
4982 {
4983 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
4984 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
4985 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
4986 }
4987 }
4988
4989 if (qinfo->RewardSpell > 0)
4990 {
4991 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell);
4992
4993 if (!spellInfo)
4994 {
4995 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} does not exist, quest will not have a spell reward.",
4996 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
4997 qinfo->RewardSpell = 0; // no spell will be casted on player
4998 }
4999
5000 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5001 {
5002 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} is broken, quest will not have a spell reward.",
5003 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5004 qinfo->RewardSpell = 0; // no spell will be casted on player
5005 }
5006
5007 else if (GetTalentSpellCost(qinfo->RewardSpell))
5008 {
5009 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5010 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5011 qinfo->RewardSpell = 0; // no spell will be casted on player
5012 }
5013 }
5014
5015 if (qinfo->RewardMailTemplateId)
5016 {
5017 if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId))
5018 {
5019 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} does not exist, quest will not have a mail reward.",
5020 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId);
5021 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5022 qinfo->RewardMailDelay = 0; // no mail will send to player
5023 qinfo->RewardMailSenderEntry = 0;
5024 }
5025 else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end())
5026 {
5027 std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId);
5028 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} already used for quest {}, quest will not have a mail reward.",
5029 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second);
5030 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5031 qinfo->RewardMailDelay = 0; // no mail will send to player
5032 qinfo->RewardMailSenderEntry = 0;
5033 }
5034 else
5035 usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId();
5036 }
5037
5038 if (qinfo->RewardNextQuest)
5039 {
5040 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->RewardNextQuest);
5041 if (qNextItr == _questTemplates.end())
5042 {
5043 LOG_ERROR("sql.sql", "Quest {} has `RewardNextQuest` = {} but quest {} does not exist, quest chain will not work.",
5044 qinfo->GetQuestId(), qinfo->RewardNextQuest, qinfo->RewardNextQuest);
5045 qinfo->RewardNextQuest = 0;
5046 }
5047 else
5048 qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId());
5049 }
5050
5051 // fill additional data stores
5052 if (qinfo->PrevQuestId)
5053 {
5054 if (_questTemplates.find(std::abs(qinfo->GetPrevQuestId())) == _questTemplates.end())
5055 {
5056 LOG_ERROR("sql.sql", "Quest {} has PrevQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId());
5057 }
5058 else
5059 {
5060 qinfo->prevQuests.push_back(qinfo->PrevQuestId);
5061 }
5062 }
5063
5064 if (qinfo->NextQuestId)
5065 {
5066 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->GetNextQuestId());
5067 if (qNextItr == _questTemplates.end())
5068 {
5069 LOG_ERROR("sql.sql", "Quest {} has NextQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId());
5070 }
5071 else
5072 qNextItr->second->prevQuests.push_back(static_cast<int32>(qinfo->GetQuestId()));
5073 }
5074
5075 if (qinfo->ExclusiveGroup)
5076 mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
5077 if (qinfo->TimeAllowed)
5079 if (qinfo->RequiredPlayerKills)
5081 }
5082
5083 // check QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
5084 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5085 {
5086 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
5087 if (!spellInfo)
5088 continue;
5089
5090 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5091 {
5092 if (spellInfo->Effects[j].Effect != SPELL_EFFECT_QUEST_COMPLETE)
5093 continue;
5094
5095 uint32 quest_id = spellInfo->Effects[j].MiscValue;
5096
5097 Quest const* quest = GetQuestTemplate(quest_id);
5098
5099 // some quest referenced in spells not exist (outdated spells)
5100 if (!quest)
5101 continue;
5102
5104 {
5105 LOG_ERROR("sql.sql", "Spell (id: {}) have SPELL_EFFECT_QUEST_COMPLETE for quest {}, but quest not have specialflag QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT. Quest flags must be fixed, quest modified to enable objective.", spellInfo->Id, quest_id);
5106
5107 // this will prevent quest completing without objective
5108 // xinef: remove this, leave error but do not break the quest
5109 // const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5110 }
5111 }
5112 }
5113
5114 LOG_INFO("server.loading", ">> Loaded {} Quests Definitions in {} ms", (unsigned long)_questTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
5115 LOG_INFO("server.loading", " ");
5116}
@ DISABLE_TYPE_QUEST
Definition: DisableMgr.h:30
#define QUEST_REWARDS_COUNT
Definition: QuestDef.h:39
#define QUEST_ITEM_OBJECTIVES_COUNT
Definition: QuestDef.h:36
#define QUEST_OBJECTIVES_COUNT
Definition: QuestDef.h:35
@ QUEST_FLAGS_TRACKING
Definition: QuestDef.h:142
@ QUEST_FLAGS_DAILY
Definition: QuestDef.h:144
@ QUEST_FLAGS_WEEKLY
Definition: QuestDef.h:147
#define QUEST_REPUTATIONS_COUNT
Definition: QuestDef.h:41
#define QUEST_SOURCE_ITEM_IDS_COUNT
Definition: QuestDef.h:37
#define QUEST_REWARD_CHOICES_COUNT
Definition: QuestDef.h:38
@ QUEST_SPECIAL_FLAGS_CAST
Definition: QuestDef.h:165
@ QUEST_SPECIAL_FLAGS_TIMED
Definition: QuestDef.h:178
@ QUEST_SPECIAL_FLAGS_DELIVER
Definition: QuestDef.h:175
@ QUEST_SPECIAL_FLAGS_REPEATABLE
Definition: QuestDef.h:160
@ QUEST_SPECIAL_FLAGS_KILL
Definition: QuestDef.h:177
@ QUEST_SPECIAL_FLAGS_DB_ALLOWED
Definition: QuestDef.h:171
@ QUEST_SPECIAL_FLAGS_SPEAKTO
Definition: QuestDef.h:176
@ QUEST_SPECIAL_FLAGS_MONTHLY
Definition: QuestDef.h:164
@ QUEST_SPECIAL_FLAGS_PLAYER_KILL
Definition: QuestDef.h:179
DBCStorage< QuestSortEntry > sQuestSortStore(QuestSortEntryfmt)
@ SPELL_EFFECT_QUEST_COMPLETE
Definition: SharedDefines.h:794
uint32 SkillByQuestSort(int32 QuestSort)
Definition: SharedDefines.h:3040
ExclusiveQuestGroups mExclusiveQuestGroups
Definition: ObjectMgr.h:1133
uint32 ItemDropQuantity[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition: QuestDef.h:303
uint32 RewardMailDelay
Definition: QuestDef.h:394
uint32 RewardMailSenderEntry
Definition: QuestDef.h:402
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:304
uint32 RequiredMaxRepFaction
Definition: QuestDef.h:399
uint32 SourceSpellid
Definition: QuestDef.h:389
uint32 RequiredMinRepFaction
Definition: QuestDef.h:397
int32 RequiredFactionValue2
Definition: QuestDef.h:355
int32 RequiredFactionValue1
Definition: QuestDef.h:353
int32 ZoneOrSort
Definition: QuestDef.h:347
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:305
uint32 StartItemCount
Definition: QuestDef.h:401
void SetSpecialFlag(uint32 flag)
Definition: QuestDef.h:225
uint32 GetCharTitleId() const
Definition: QuestDef.h:253
uint32 RewardTitleId
Definition: QuestDef.h:359
uint32 RewardItemIdCount[QUEST_REWARDS_COUNT]
Definition: QuestDef.h:309
uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT]
Definition: QuestDef.h:306
uint32 NextQuestId
Definition: QuestDef.h:391
uint32 RewardMailTemplateId
Definition: QuestDef.h:393
uint32 ItemDrop[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition: QuestDef.h:302
int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:312
uint32 RequiredSkillPoints
Definition: QuestDef.h:396
int32 RewardSpell
Definition: QuestDef.h:378
uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]
Definition: QuestDef.h:307
uint32 AllowableRaces
Definition: QuestDef.h:351
uint32 RewardNextQuest
Definition: QuestDef.h:363
uint32 RequiredPlayerKills
Definition: QuestDef.h:360
int32 GetPrevQuestId() const
Definition: QuestDef.h:249
uint32 StartItem
Definition: QuestDef.h:365
uint32 GetQuestId() const
Definition: QuestDef.h:228
int32 RequiredMaxRepValue
Definition: QuestDef.h:400
uint32 RequiredClasses
Definition: QuestDef.h:388
uint32 Flags
Definition: QuestDef.h:358
uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]
Definition: QuestDef.h:301
uint32 TimeAllowed
Definition: QuestDef.h:357
uint32 RequiredFactionId1
Definition: QuestDef.h:352
uint32 RequiredFactionId2
Definition: QuestDef.h:354
PrevQuests prevQuests
Definition: QuestDef.h:324
uint32 RewardDisplaySpell
Definition: QuestDef.h:377
uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]
Definition: QuestDef.h:300
int32 PrevQuestId
Definition: QuestDef.h:390
uint32 GetNextQuestId() const
Definition: QuestDef.h:250
uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:310
int32 ExclusiveGroup
Definition: QuestDef.h:392
uint32 RequiredSkillId
Definition: QuestDef.h:395
int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:311
uint32 RewardItemId[QUEST_REWARDS_COUNT]
Definition: QuestDef.h:308
uint32 GetQuestMethod() const
Definition: QuestDef.h:229
int32 RequiredMinRepValue
Definition: QuestDef.h:398
uint32 SpecialFlags
Definition: QuestDef.h:403
static const int32 Reputation_Cap
Definition: ReputationMgr.h:68
Definition: DBCStructure.h:1445

References _questTemplates, _questTemplatesFast, Quest::AllowableRaces, CLASSMASK_ALL_PLAYABLE, SpellMgr::ComputeIsSpellValid(), DISABLE_TYPE_QUEST, SpellInfo::Effects, Quest::ExclusiveGroup, Quest::Flags, Field::Get(), Quest::GetCharTitleId(), GetGameObjectTemplate(), getMSTime(), GetMSTimeDiffToNow(), Quest::GetNextQuestId(), Quest::GetPrevQuestId(), Quest::GetQuestId(), Quest::GetQuestMethod(), GetQuestTemplate(), GetTalentSpellCost(), Quest::HasSpecialFlag(), SpellInfo::Id, DisableMgr::IsDisabledFor(), Quest::ItemDrop, Quest::ItemDropQuantity, LOG_ERROR, LOG_INFO, LOG_WARN, MAX_SPELL_EFFECTS, mExclusiveQuestGroups, Quest::NextQuestId, Quest::PrevQuestId, Quest::prevQuests, QUEST_FLAGS_DAILY, QUEST_FLAGS_TRACKING, QUEST_FLAGS_WEEKLY, QUEST_ITEM_OBJECTIVES_COUNT, QUEST_OBJECTIVES_COUNT, QUEST_REPUTATIONS_COUNT, QUEST_REWARD_CHOICES_COUNT, QUEST_REWARDS_COUNT, QUEST_SOURCE_ITEM_IDS_COUNT, QUEST_SPECIAL_FLAGS_CAST, QUEST_SPECIAL_FLAGS_DB_ALLOWED, QUEST_SPECIAL_FLAGS_DELIVER, QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT, QUEST_SPECIAL_FLAGS_KILL, QUEST_SPECIAL_FLAGS_MONTHLY, QUEST_SPECIAL_FLAGS_PLAYER_KILL, QUEST_SPECIAL_FLAGS_REPEATABLE, QUEST_SPECIAL_FLAGS_SPEAKTO, QUEST_SPECIAL_FLAGS_TIMED, RACEMASK_ALL_PLAYABLE, ReputationMgr::Reputation_Cap, Quest::RequiredClasses, Quest::RequiredFactionId1, Quest::RequiredFactionId2, Quest::RequiredFactionValue1, Quest::RequiredFactionValue2, Quest::RequiredItemCount, Quest::RequiredItemId, Quest::RequiredMaxRepFaction, Quest::RequiredMaxRepValue, Quest::RequiredMinRepFaction, Quest::RequiredMinRepValue, Quest::RequiredNpcOrGo, Quest::RequiredNpcOrGoCount, Quest::RequiredPlayerKills, Quest::RequiredSkillId, Quest::RequiredSkillPoints, Quest::RewardChoiceItemCount, Quest::RewardChoiceItemId, Quest::RewardDisplaySpell, Quest::RewardFactionId, Quest::RewardFactionValueId, Quest::RewardFactionValueIdOverride, Quest::RewardItemId, Quest::RewardItemIdCount, Quest::RewardMailDelay, Quest::RewardMailSenderEntry, Quest::RewardMailTemplateId, Quest::RewardNextQuest, Quest::RewardSpell, Quest::RewardTitleId, sAreaTableStore, sCharTitlesStore, Quest::SetSpecialFlag(), sFactionStore, SkillByQuestSort(), sMailTemplateStore, sObjectMgr, Quest::SourceSpellid, Quest::SpecialFlags, SPELL_EFFECT_QUEST_COMPLETE, sQuestSortStore, sSkillLineStore, sSpellMgr, Quest::StartItem, Quest::StartItemCount, sWorld, Quest::TimeAllowed, WorldDatabase, and Quest::ZoneOrSort.

◆ LoadQuestStartersAndEnders()

void ObjectMgr::LoadQuestStartersAndEnders ( )
inline
947 {
948 LOG_INFO("server.loading", "Loading GO Start Quest Data...");
950 LOG_INFO("server.loading", "Loading GO End Quest Data...");
952 LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
954 LOG_INFO("server.loading", "Loading Creature End Quest Data...");
956 }
void LoadCreatureQuestEnders()
Definition: ObjectMgr.cpp:8081
void LoadGameobjectQuestEnders()
Definition: ObjectMgr.cpp:8053
void LoadGameobjectQuestStarters()
Definition: ObjectMgr.cpp:8039
void LoadCreatureQuestStarters()
Definition: ObjectMgr.cpp:8067

References LoadCreatureQuestEnders(), LoadCreatureQuestStarters(), LoadGameobjectQuestEnders(), LoadGameobjectQuestStarters(), and LOG_INFO.

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
9161{
9162 // find all items from the reference vendor
9164 stmt->SetData(0, uint32(item));
9165 PreparedQueryResult result = WorldDatabase.Query(stmt);
9166
9167 if (!result)
9168 return 0;
9169
9170 uint32 count = 0;
9171 do
9172 {
9173 Field* fields = result->Fetch();
9174
9175 int32 item_id = fields[0].Get<int32>();
9176
9177 // if item is a negative, its a reference
9178 if (item_id < 0)
9179 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
9180 else
9181 {
9182 int32 maxcount = fields[1].Get<uint8>();
9183 uint32 incrtime = fields[2].Get<uint32>();
9184 uint32 ExtendedCost = fields[3].Get<uint32>();
9185
9186 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
9187 continue;
9188
9189 VendorItemData& vList = _cacheVendorItemStore[vendor];
9190
9191 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9192 ++count;
9193 }
9194 } while (result->NextRow());
9195
9196 return count;
9197}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ WORLD_SEL_NPC_VENDOR_REF
Definition: WorldDatabase.h:45
bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player *player=nullptr, std::set< uint32 > *skip_vendors=nullptr, uint32 ORnpcflag=0) const
Definition: ObjectMgr.cpp:9400
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition: ObjectMgr.cpp:9160

References _cacheVendorItemStore, VendorItemData::AddItem(), Field::Get(), IsVendorItemValid(), LoadReferenceVendor(), PreparedStatementBase::SetData(), WORLD_SEL_NPC_VENDOR_REF, and WorldDatabase.

Referenced by LoadReferenceVendor(), and LoadVendors().

◆ LoadReputationOnKill()

void ObjectMgr::LoadReputationOnKill ( )
7586{
7587 uint32 oldMSTime = getMSTime();
7588
7589 // For reload case
7590 _repOnKillStore.clear();
7591
7592 uint32 count = 0;
7593
7594 // 0 1 2
7595 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
7596 // 3 4 5 6 7 8 9
7597 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
7598 "FROM creature_onkill_reputation");
7599
7600 if (!result)
7601 {
7602 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
7603 LOG_INFO("server.loading", " ");
7604 return;
7605 }
7606
7607 do
7608 {
7609 Field* fields = result->Fetch();
7610
7611 uint32 creature_id = fields[0].Get<uint32>();
7612
7613 ReputationOnKillEntry repOnKill;
7614 repOnKill.RepFaction1 = fields[1].Get<int16>();
7615 repOnKill.RepFaction2 = fields[2].Get<int16>();
7616 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
7617 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
7618 repOnKill.RepValue1 = fields[5].Get<float>();
7619 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
7620 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
7621 repOnKill.RepValue2 = fields[8].Get<float>();
7622 repOnKill.TeamDependent = fields[9].Get<uint8>();
7623
7624 if (!GetCreatureTemplate(creature_id))
7625 {
7626 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
7627 continue;
7628 }
7629
7630 if (repOnKill.RepFaction1)
7631 {
7632 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
7633 if (!factionEntry1)
7634 {
7635 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
7636 continue;
7637 }
7638 }
7639
7640 if (repOnKill.RepFaction2)
7641 {
7642 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
7643 if (!factionEntry2)
7644 {
7645 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
7646 continue;
7647 }
7648 }
7649
7650 _repOnKillStore[creature_id] = repOnKill;
7651
7652 ++count;
7653 } while (result->NextRow());
7654
7655 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7656 LOG_INFO("server.loading", " ");
7657}
Definition: ObjectMgr.h:568
uint32 RepFaction1
Definition: ObjectMgr.h:569

References _repOnKillStore, Field::Get(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, ReputationOnKillEntry::RepFaction1, sFactionStore, and WorldDatabase.

◆ LoadReputationRewardRate()

void ObjectMgr::LoadReputationRewardRate ( )
7498{
7499 uint32 oldMSTime = getMSTime();
7500
7501 _repRewardRateStore.clear(); // for reload case
7502
7503 uint32 count = 0; // 0 1 2 3 4 5 6 7
7504 QueryResult result = WorldDatabase.Query("SELECT faction, quest_rate, quest_daily_rate, quest_weekly_rate, quest_monthly_rate, quest_repeatable_rate, creature_rate, spell_rate FROM reputation_reward_rate");
7505 if (!result)
7506 {
7507 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
7508 return;
7509 }
7510
7511 do
7512 {
7513 Field* fields = result->Fetch();
7514
7515 uint32 factionId = fields[0].Get<uint32>();
7516
7517 RepRewardRate repRate;
7518
7519 repRate.questRate = fields[1].Get<float>();
7520 repRate.questDailyRate = fields[2].Get<float>();
7521 repRate.questWeeklyRate = fields[3].Get<float>();
7522 repRate.questMonthlyRate = fields[4].Get<float>();
7523 repRate.questRepeatableRate = fields[5].Get<float>();
7524 repRate.creatureRate = fields[6].Get<float>();
7525 repRate.spellRate = fields[7].Get<float>();
7526
7527 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7528 if (!factionEntry)
7529 {
7530 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
7531 continue;
7532 }
7533
7534 if (repRate.questRate < 0.0f)
7535 {
7536 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
7537 continue;
7538 }
7539
7540 if (repRate.questDailyRate < 0.0f)
7541 {
7542 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
7543 continue;
7544 }
7545
7546 if (repRate.questWeeklyRate < 0.0f)
7547 {
7548 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
7549 continue;
7550 }
7551
7552 if (repRate.questMonthlyRate < 0.0f)
7553 {
7554 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
7555 continue;
7556 }
7557
7558 if (repRate.questRepeatableRate < 0.0f)
7559 {
7560 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
7561 continue;
7562 }
7563
7564 if (repRate.creatureRate < 0.0f)
7565 {
7566 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
7567 continue;
7568 }
7569
7570 if (repRate.spellRate < 0.0f)
7571 {
7572 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
7573 continue;
7574 }
7575
7576 _repRewardRateStore[factionId] = repRate;
7577
7578 ++count;
7579 } while (result->NextRow());
7580
7581 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7582 LOG_INFO("server.loading", " ");
7583}
Definition: ObjectMgr.h:557
float questRate
Definition: ObjectMgr.h:558

References _repRewardRateStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, RepRewardRate::questRate, sFactionStore, and WorldDatabase.

◆ LoadReputationSpilloverTemplate()

void ObjectMgr::LoadReputationSpilloverTemplate ( )
7660{
7661 uint32 oldMSTime = getMSTime();
7662
7663 _repSpilloverTemplateStore.clear(); // for reload case
7664
7665 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
7666 QueryResult result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4, faction5, rate_5, rank_5, faction6, rate_6, rank_6 FROM reputation_spillover_template");
7667
7668 if (!result)
7669 {
7670 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
7671 LOG_INFO("server.loading", " ");
7672 return;
7673 }
7674
7675 do
7676 {
7677 Field* fields = result->Fetch();
7678
7679 uint32 factionId = fields[0].Get<uint16>();
7680
7681 RepSpilloverTemplate repTemplate;
7682
7683 repTemplate.faction[0] = fields[1].Get<uint16>();
7684 repTemplate.faction_rate[0] = fields[2].Get<float>();
7685 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
7686 repTemplate.faction[1] = fields[4].Get<uint16>();
7687 repTemplate.faction_rate[1] = fields[5].Get<float>();
7688 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
7689 repTemplate.faction[2] = fields[7].Get<uint16>();
7690 repTemplate.faction_rate[2] = fields[8].Get<float>();
7691 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
7692 repTemplate.faction[3] = fields[10].Get<uint16>();
7693 repTemplate.faction_rate[3] = fields[11].Get<float>();
7694 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
7695 repTemplate.faction[4] = fields[13].Get<uint16>();
7696 repTemplate.faction_rate[4] = fields[14].Get<float>();
7697 repTemplate.faction_rank[4] = fields[15].Get<uint8>();
7698 repTemplate.faction[5] = fields[16].Get<uint16>();
7699 repTemplate.faction_rate[5] = fields[17].Get<float>();
7700 repTemplate.faction_rank[5] = fields[18].Get<uint8>();
7701
7702 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7703
7704 if (!factionEntry)
7705 {
7706 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
7707 continue;
7708 }
7709
7710 if (factionEntry->team == 0)
7711 {
7712 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
7713 continue;
7714 }
7715
7716 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
7717 {
7718 if (repTemplate.faction[i])
7719 {
7720 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
7721
7722 if (!factionSpillover)
7723 {
7724 LOG_ERROR("sql.sql", "Spillover faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template` for faction {}, skipping", repTemplate.faction[i], factionId);
7725 continue;
7726 }
7727
7728 if (factionSpillover->reputationListID < 0)
7729 {
7730 LOG_ERROR("sql.sql", "Spillover faction (faction.dbc) {} for faction {} in `reputation_spillover_template` can not be listed for client, and then useless, skipping", repTemplate.faction[i], factionId);
7731 continue;
7732 }
7733
7734 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
7735 {
7736 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
7737 continue;
7738 }
7739 }
7740 }
7741
7742 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
7743 if (repTemplate.faction[0] && !factionEntry0)
7744 {
7745 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
7746 continue;
7747 }
7748 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
7749 if (repTemplate.faction[1] && !factionEntry1)
7750 {
7751 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
7752 continue;
7753 }
7754 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
7755 if (repTemplate.faction[2] && !factionEntry2)
7756 {
7757 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
7758 continue;
7759 }
7760 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
7761 if (repTemplate.faction[3] && !factionEntry3)
7762 {
7763 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
7764 continue;
7765 }
7766
7767 _repSpilloverTemplateStore[factionId] = repTemplate;
7768
7769 ++count;
7770 } while (result->NextRow());
7771
7772 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7773 LOG_INFO("server.loading", " ");
7774}
#define MAX_SPILLOVER_FACTIONS
Definition: SharedDefines.h:247
Definition: ObjectMgr.h:581
uint32 faction[MAX_SPILLOVER_FACTIONS]
Definition: ObjectMgr.h:582
int32 reputationListID
Definition: DBCStructure.h:909

References _repSpilloverTemplateStore, RepSpilloverTemplate::faction, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, MAX_REPUTATION_RANK, MAX_SPILLOVER_FACTIONS, FactionEntry::reputationListID, sFactionStore, and WorldDatabase.

◆ LoadReservedPlayerNamesDB()

void ObjectMgr::LoadReservedPlayerNamesDB ( )
8096{
8097 uint32 oldMSTime = getMSTime();
8098
8099 _reservedNamesStore.clear(); // need for reload case
8100
8101 QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
8102
8103 if (!result)
8104 {
8105 LOG_WARN("server.loading", ">> Loaded 0 reserved names. DB table `reserved_name` is empty!");
8106 return;
8107 }
8108
8109 uint32 count = 0;
8110
8111 Field* fields;
8112 do
8113 {
8114 fields = result->Fetch();
8115 std::string name = fields[0].Get<std::string>();
8116
8117 std::wstring wstr;
8118 if (!Utf8toWStr (name, wstr))
8119 {
8120 LOG_ERROR("sql.sql", "Table `reserved_name` have invalid name: {}", name);
8121 continue;
8122 }
8123
8124 wstrToLower(wstr);
8125
8126 _reservedNamesStore.insert(wstr);
8127 ++count;
8128 } while (result->NextRow());
8129
8130 LOG_INFO("server.loading", ">> Loaded {} reserved names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8131}

References _reservedNamesStore, CharacterDatabase, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, Utf8toWStr(), and wstrToLower().

◆ LoadReservedPlayerNamesDBC()

void ObjectMgr::LoadReservedPlayerNamesDBC ( )
8134{
8135 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8136 {
8137 LOG_WARN("server.loading", ">> Loaded 0 reserved names from DBC. Config option disabled.");
8138 return;
8139 }
8140
8141 uint32 oldMSTime = getMSTime();
8142
8143 uint32 count = 0;
8144
8145 for (NamesReservedEntry const* reservedStore : sNamesReservedStore)
8146 {
8147 std::wstring wstr;
8148
8149 Utf8toWStr(reservedStore->Pattern, wstr);
8150
8151 // DBC does not have clean entries, remove the junk.
8152 boost::algorithm::replace_all(wstr, "\\<", "");
8153 boost::algorithm::replace_all(wstr, "\\>", "");
8154
8155 _reservedNamesStore.insert(wstr);
8156 count++;
8157 }
8158
8159 LOG_INFO("server.loading", ">> Loaded {} reserved names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8160 LOG_INFO("server.loading", " ");
8161}
DBCStorage< NamesReservedEntry > sNamesReservedStore(NamesReservedfmt)
@ CONFIG_STRICT_NAMES_RESERVED
Definition: IWorld.h:186
Definition: DBCStructure.h:1398

References _reservedNamesStore, CONFIG_STRICT_NAMES_RESERVED, getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, sNamesReservedStore, sWorld, and Utf8toWStr().

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
9481{
9482 uint32 oldMSTime = getMSTime();
9483
9484 // We insert an empty placeholder here so we can use the
9485 // script id 0 as dummy for "no script found".
9486 _scriptNamesStore.emplace_back("");
9487
9488 QueryResult result = WorldDatabase.Query(
9489 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
9490 "UNION "
9491 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
9492 "UNION "
9493 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
9494 "UNION "
9495 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
9496 "UNION "
9497 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
9498 "UNION "
9499 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
9500 "UNION "
9501 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
9502 "UNION "
9503 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
9504 "UNION "
9505 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
9506 "UNION "
9507 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
9508 "UNION "
9509 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
9510 "UNION "
9511 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
9512 "UNION "
9513 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
9514 "UNION "
9515 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
9516
9517 if (!result)
9518 {
9519 LOG_INFO("server.loading", " ");
9520 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
9521 return;
9522 }
9523
9524 _scriptNamesStore.reserve(result->GetRowCount() + 1);
9525
9526 do
9527 {
9528 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
9529 } while (result->NextRow());
9530
9531 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
9532 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
9533 LOG_INFO("server.loading", " ");
9534}

References _scriptNamesStore, getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, and WorldDatabase.

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5155{
5156 uint32 oldMSTime = getMSTime();
5157
5158 ScriptMapMap* scripts = GetScriptsMapByType(type);
5159 if (!scripts)
5160 return;
5161
5162 std::string tableName = GetScriptsTableNameByType(type);
5163 if (tableName.empty())
5164 return;
5165
5166 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5167 return;
5168
5169 LOG_INFO("server.loading", "Loading {}...", tableName);
5170
5171 scripts->clear(); // need for reload support
5172
5173 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5174 // 0 1 2 3 4 5 6 7 8 9
5175 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5176
5177 if (!result)
5178 {
5179 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5180 LOG_INFO("server.loading", " ");
5181 return;
5182 }
5183
5184 uint32 count = 0;
5185
5186 do
5187 {
5188 Field* fields = result->Fetch();
5189 ScriptInfo tmp;
5190 tmp.type = type;
5191 tmp.id = fields[0].Get<uint32>();
5192 if (isSpellScriptTable)
5193 tmp.id |= fields[10].Get<uint8>() << 24;
5194 tmp.delay = fields[1].Get<uint32>();
5195 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5196 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5197 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5198 tmp.Raw.nData[2] = fields[5].Get<int32>();
5199 tmp.Raw.fData[0] = fields[6].Get<float>();
5200 tmp.Raw.fData[1] = fields[7].Get<float>();
5201 tmp.Raw.fData[2] = fields[8].Get<float>();
5202 tmp.Raw.fData[3] = fields[9].Get<float>();
5203
5204 // generic command args check
5205 switch (tmp.command)
5206 {
5208 {
5210 {
5211 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5212 tableName, tmp.Talk.ChatType, tmp.id);
5213 continue;
5214 }
5216 {
5217 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
5218 tableName, tmp.Talk.TextID, tmp.id);
5219 continue;
5220 }
5221 break;
5222 }
5223
5225 {
5226 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
5227 {
5228 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
5229 tableName, tmp.Emote.EmoteID, tmp.id);
5230 continue;
5231 }
5232 break;
5233 }
5234
5236 {
5237 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
5238 {
5239 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5240 tableName, tmp.TeleportTo.MapID, tmp.id);
5241 continue;
5242 }
5243
5245 {
5246 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5247 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
5248 continue;
5249 }
5250 break;
5251 }
5252
5254 {
5255 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
5256 if (!quest)
5257 {
5258 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5259 tableName, tmp.QuestExplored.QuestID, tmp.id);
5260 continue;
5261 }
5262
5264 {
5265 LOG_ERROR("sql.sql", "Table `{}` has quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}, but quest not have specialflag QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT in quest flags. Script command or quest flags wrong. Quest modified to require objective.",
5266 tableName, tmp.QuestExplored.QuestID, tmp.id);
5267
5268 // this will prevent quest completing without objective
5269 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5270
5271 // continue; - quest objective requirement set and command can be allowed
5272 }
5273
5275 {
5276 LOG_ERROR("sql.sql", "Table `{}` has too large distance ({}) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5277 tableName, tmp.QuestExplored.Distance, tmp.id);
5278 continue;
5279 }
5280
5282 {
5283 LOG_ERROR("sql.sql", "Table `{}` has too large distance ({}) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}, max distance is {} or 0 for disable distance check",
5285 continue;
5286 }
5287
5289 {
5290 LOG_ERROR("sql.sql", "Table `{}` has too small distance ({}) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}, min distance is {} or 0 for disable distance check",
5291 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
5292 continue;
5293 }
5294
5295 break;
5296 }
5297
5299 {
5301 {
5302 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
5303 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
5304 continue;
5305 }
5306 break;
5307 }
5308
5310 {
5312 if (!data)
5313 {
5314 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5315 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
5316 continue;
5317 }
5318
5319 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5320 if (!info)
5321 {
5322 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5323 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
5324 continue;
5325 }
5326
5327 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
5329 info->type == GAMEOBJECT_TYPE_DOOR ||
5330 info->type == GAMEOBJECT_TYPE_BUTTON ||
5331 info->type == GAMEOBJECT_TYPE_TRAP)
5332 {
5333 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5334 tableName, info->entry, tmp.id);
5335 continue;
5336 }
5337 break;
5338 }
5339
5341 {
5343 {
5344 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5346 continue;
5347 }
5348
5350 if (!GetCreatureTemplate(entry))
5351 {
5352 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5353 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
5354 continue;
5355 }
5356 break;
5357 }
5358
5361 {
5363 if (!data)
5364 {
5365 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
5366 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
5367 continue;
5368 }
5369
5370 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5371 if (!info)
5372 {
5373 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
5374 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
5375 continue;
5376 }
5377
5378 if (info->type != GAMEOBJECT_TYPE_DOOR)
5379 {
5380 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
5381 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
5382 continue;
5383 }
5384
5385 break;
5386 }
5387
5389 {
5390 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
5391 {
5392 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5393 tableName, tmp.RemoveAura.SpellID, tmp.id);
5394 continue;
5395 }
5396 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
5397 {
5398 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5399 tableName, tmp.RemoveAura.Flags, tmp.id);
5400 continue;
5401 }
5402 break;
5403 }
5404
5406 {
5407 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
5408 {
5409 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5410 tableName, tmp.CastSpell.SpellID, tmp.id);
5411 continue;
5412 }
5413 if (tmp.CastSpell.Flags > 4) // targeting type
5414 {
5415 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5416 tableName, tmp.CastSpell.Flags, tmp.id);
5417 continue;
5418 }
5419 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
5420 {
5421 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5422 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5423 continue;
5424 }
5425 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
5426 {
5427 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5428 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5429 continue;
5430 }
5431 break;
5432 }
5433
5435 {
5437 {
5438 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
5439 tableName, tmp.CreateItem.ItemEntry, tmp.id);
5440 continue;
5441 }
5442 if (!tmp.CreateItem.Amount)
5443 {
5444 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
5445 tableName, tmp.CreateItem.Amount, tmp.id);
5446 continue;
5447 }
5448 break;
5449 }
5450 default:
5451 break;
5452 }
5453
5454 if (scripts->find(tmp.id) == scripts->end())
5455 {
5456 ScriptMap emptyMap;
5457 (*scripts)[tmp.id] = emptyMap;
5458 }
5459 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
5460
5461 ++count;
5462 } while (result->NextRow());
5463
5464 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5465 LOG_INFO("server.loading", " ");
5466}
std::multimap< uint32, ScriptInfo > ScriptMap
Definition: ObjectMgr.h:386
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition: ObjectMgr.cpp:81
ScriptCommands
Definition: ObjectMgr.h:94
@ SCRIPT_COMMAND_EMOTE
Definition: ObjectMgr.h:96
@ SCRIPT_COMMAND_CREATE_ITEM
Definition: ObjectMgr.h:112
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition: ObjectMgr.h:107
@ SCRIPT_COMMAND_CAST_SPELL
Definition: ObjectMgr.h:110
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition: ObjectMgr.h:104
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition: ObjectMgr.h:102
@ SCRIPT_COMMAND_TALK
Definition: ObjectMgr.h:95
@ SCRIPT_COMMAND_OPEN_DOOR
Definition: ObjectMgr.h:106
@ SCRIPT_COMMAND_TELEPORT_TO
Definition: ObjectMgr.h:101
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition: ObjectMgr.h:105
@ SCRIPT_COMMAND_KILL_CREDIT
Definition: ObjectMgr.h:103
@ SCRIPT_COMMAND_REMOVE_AURA
Definition: ObjectMgr.h:109
std::string GetScriptCommandName(ScriptCommands command)
Definition: ObjectMgr.cpp:101
std::map< uint32, ScriptMap > ScriptMapMap
Definition: ObjectMgr.h:387
std::string GetScriptsTableNameByType(ScriptsType type)
Definition: ObjectMgr.cpp:61
@ SCRIPTS_SPELL
Definition: ObjectMgr.h:151
#define DEFAULT_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:40
#define INTERACTION_DISTANCE
Definition: ObjectDefines.h:24
@ CHAT_TYPE_WHISPER
Definition: CreatureData.h:428
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition: SharedDefines.h:1577
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition: SharedDefines.h:3194
uint32 entry
Definition: GameObjectData.h:33
Definition: ObjectMgr.h:192
float Orientation
Definition: ObjectMgr.h:252
uint32 Flags
Definition: ObjectMgr.h:209
struct ScriptInfo::@262::@270 TeleportTo
ScriptsType type
Definition: ObjectMgr.h:193
struct ScriptInfo::@262::@277 CastSpell
uint32 QuestID
Definition: ObjectMgr.h:257
int32 TextID
Definition: ObjectMgr.h:210
float DestX
Definition: ObjectMgr.h:231
uint32 ItemEntry
Definition: ObjectMgr.h:317
uint32 ChatType
Definition: ObjectMgr.h:208
uint32 id
Definition: ObjectMgr.h:194
uint32 delay
Definition: ObjectMgr.h:195
float fData[4]
Definition: ObjectMgr.h:203
struct ScriptInfo::@262::@264 Raw
struct ScriptInfo::@262::@265 Talk
float PosY
Definition: ObjectMgr.h:280
struct ScriptInfo::@262::@279 CreateItem
ScriptCommands command
Definition: ObjectMgr.h:196
float DestY
Definition: ObjectMgr.h:232
struct ScriptInfo::@262::@266 Emote
uint32 MapID
Definition: ObjectMgr.h:245
struct ScriptInfo::@262::@276 RemoveAura
uint32 nData[3]
Definition: ObjectMgr.h:202
struct ScriptInfo::@262::@271 QuestExplored
float PosZ
Definition: ObjectMgr.h:281
struct ScriptInfo::@262::@274 TempSummonCreature
float PosX
Definition: ObjectMgr.h:279
struct ScriptInfo::@262::@275 ToggleDoor
uint32 Distance
Definition: ObjectMgr.h:258
uint32 SpellID
Definition: ObjectMgr.h:296
struct ScriptInfo::@262::@272 KillCredit
float DestZ
Definition: ObjectMgr.h:233
uint32 GOGuid
Definition: ObjectMgr.h:269
uint32 CreatureEntry
Definition: ObjectMgr.h:263
uint32 Amount
Definition: ObjectMgr.h:318
struct ScriptInfo::@262::@273 RespawnGameobject
uint32 EmoteID
Definition: ObjectMgr.h:215

References ScriptInfo::Amount, ScriptInfo::CastSpell, CHAT_MSG_RAID_BOSS_WHISPER, CHAT_TYPE_WHISPER, ScriptInfo::ChatType, ScriptInfo::command, ScriptInfo::CreateItem, ScriptInfo::CreatureEntry, DEFAULT_VISIBILITY_DISTANCE, ScriptInfo::delay, ScriptInfo::DestX, ScriptInfo::DestY, ScriptInfo::DestZ, ScriptInfo::Distance, ScriptInfo::Emote, ScriptInfo::EmoteID, GameObjectTemplate::entry, ScriptInfo::fData, ScriptInfo::Flags, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_TRAP, Field::Get(), GetBroadcastText(), GetCreatureTemplate(), GetGameObjectData(), GetGameObjectTemplate(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), GetQuestTemplate(), GetScriptCommandName(), GetScriptsMapByType(), GetScriptsTableNameByType(), ScriptInfo::GOGuid, Quest::HasSpecialFlag(), GameObjectData::id, ScriptInfo::id, INTERACTION_DISTANCE, Acore::IsValidMapCoord(), ScriptInfo::ItemEntry, ScriptInfo::KillCredit, LOG_ERROR, LOG_INFO, LOG_WARN, ScriptInfo::MapID, ScriptInfo::nData, ScriptInfo::Orientation, ScriptInfo::PosX, ScriptInfo::PosY, ScriptInfo::PosZ, QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT, ScriptInfo::QuestExplored, ScriptInfo::QuestID, ScriptInfo::Raw, ScriptInfo::RemoveAura, ScriptInfo::RespawnGameobject, SCRIPT_COMMAND_CAST_SPELL, SCRIPT_COMMAND_CLOSE_DOOR, SCRIPT_COMMAND_CREATE_ITEM, SCRIPT_COMMAND_EMOTE, SCRIPT_COMMAND_KILL_CREDIT, SCRIPT_COMMAND_OPEN_DOOR, SCRIPT_COMMAND_QUEST_EXPLORED, SCRIPT_COMMAND_REMOVE_AURA, SCRIPT_COMMAND_RESPAWN_GAMEOBJECT, SCRIPT_COMMAND_TALK, SCRIPT_COMMAND_TELEPORT_TO, SCRIPT_COMMAND_TEMP_SUMMON_CREATURE, SCRIPTS_SPELL, sEmotesStore, sMapStore, ScriptInfo::SpellID, sScriptMgr, sSpellMgr, ScriptInfo::Talk, ScriptInfo::TeleportTo, ScriptInfo::TempSummonCreature, ScriptInfo::TextID, ScriptInfo::ToggleDoor, GameObjectTemplate::type, ScriptInfo::type, and WorldDatabase.

Referenced by LoadEventScripts(), LoadSpellScripts(), and LoadWaypointScripts().

◆ LoadSpellScriptNames()

void ObjectMgr::LoadSpellScriptNames ( )
5568{
5569 uint32 oldMSTime = getMSTime();
5570
5571 _spellScriptsStore.clear(); // need for reload case
5572
5573 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
5574
5575 if (!result)
5576 {
5577 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
5578 LOG_INFO("server.loading", " ");
5579 return;
5580 }
5581
5582 uint32 count = 0;
5583
5584 do
5585 {
5586 Field* fields = result->Fetch();
5587
5588 int32 spellId = fields[0].Get<int32>();
5589 std::string scriptName = fields[1].Get<std::string>();
5590
5591 bool allRanks = false;
5592 if (spellId <= 0)
5593 {
5594 allRanks = true;
5595 spellId = -spellId;
5596 }
5597
5598 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5599 if (!spellInfo)
5600 {
5601 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
5602 continue;
5603 }
5604
5605 if (allRanks)
5606 {
5607 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
5608 {
5609 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
5610 continue;
5611 }
5612 while (spellInfo)
5613 {
5614 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5615 spellInfo = spellInfo->GetNextRankSpell();
5616 }
5617 }
5618 else
5619 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5620 ++count;
5621 } while (result->NextRow());
5622
5623 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5624 LOG_INFO("server.loading", " ");
5625}
SpellInfo const * GetNextRankSpell() const
Definition: SpellInfo.cpp:2512

References _spellScriptsStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), SpellInfo::GetNextRankSpell(), GetScriptId(), SpellInfo::Id, LOG_ERROR, LOG_INFO, LOG_WARN, sSpellMgr, and WorldDatabase.

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
5469{
5471
5472 // check ids
5473 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
5474 {
5475 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
5476 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5477
5478 if (!spellInfo)
5479 {
5480 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
5481 continue;
5482 }
5483
5484 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
5485 if (uint32(i) >= MAX_SPELL_EFFECTS)
5486 {
5487 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
5488 }
5489
5490 //check for correct spellEffect
5491 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
5492 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
5493 }
5494}
ScriptMapMap sSpellScripts
Definition: ObjectMgr.cpp:57
SpellEffIndex
Definition: SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:781
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:855

References SpellInfo::Effects, LoadScripts(), LOG_ERROR, MAX_SPELL_EFFECTS, SCRIPTS_SPELL, SPELL_EFFECT_DUMMY, SPELL_EFFECT_SCRIPT_EFFECT, sSpellMgr, and sSpellScripts.

◆ LoadTavernAreaTriggers()

void ObjectMgr::LoadTavernAreaTriggers ( )
6404{
6405 uint32 oldMSTime = getMSTime();
6406
6407 _tavernAreaTriggerStore.clear(); // need for reload case
6408
6409 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
6410
6411 if (!result)
6412 {
6413 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
6414 LOG_INFO("server.loading", " ");
6415 return;
6416 }
6417
6418 uint32 count = 0;
6419
6420 do
6421 {
6422 ++count;
6423
6424 Field* fields = result->Fetch();
6425
6426 uint32 Trigger_ID = fields[0].Get<uint32>();
6427
6428 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6429 if (!atEntry)
6430 {
6431 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6432 continue;
6433 }
6434
6435 uint32 faction = fields[1].Get<uint32>();
6436
6437 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
6438 } while (result->NextRow());
6439
6440 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6441 LOG_INFO("server.loading", " ");
6442}

References _tavernAreaTriggerStore, Field::Get(), GetAreaTrigger(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadTempSummons()

void ObjectMgr::LoadTempSummons ( )
2019{
2020 uint32 oldMSTime = getMSTime();
2021
2022 // 0 1 2 3 4 5 6 7 8 9
2023 QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, summonType, summonTime FROM creature_summon_groups");
2024
2025 if (!result)
2026 {
2027 LOG_WARN("server.loading", ">> Loaded 0 temp summons. DB table `creature_summon_groups` is empty.");
2028 return;
2029 }
2030
2031 uint32 count = 0;
2032 do
2033 {
2034 Field* fields = result->Fetch();
2035
2036 uint32 summonerId = fields[0].Get<uint32>();
2037 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2038 uint8 group = fields[2].Get<uint8>();
2039
2040 switch (summonerType)
2041 {
2043 if (!GetCreatureTemplate(summonerId))
2044 {
2045 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2046 continue;
2047 }
2048 break;
2050 if (!GetGameObjectTemplate(summonerId))
2051 {
2052 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2053 continue;
2054 }
2055 break;
2056 case SUMMONER_TYPE_MAP:
2057 if (!sMapStore.LookupEntry(summonerId))
2058 {
2059 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2060 continue;
2061 }
2062 break;
2063 default:
2064 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2065 continue;
2066 }
2067
2068 TempSummonData data;
2069 data.entry = fields[3].Get<uint32>();
2070
2071 if (!GetCreatureTemplate(data.entry))
2072 {
2073 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has creature in group [Summoner ID: {}, Summoner Type: {}, Group ID: {}] with non existing creature entry {}, skipped.", summonerId, summonerType, group, data.entry);
2074 continue;
2075 }
2076
2077 float posX = fields[4].Get<float>();
2078 float posY = fields[5].Get<float>();
2079 float posZ = fields[6].Get<float>();
2080 float orientation = fields[7].Get<float>();
2081
2082 data.pos.Relocate(posX, posY, posZ, orientation);
2083
2084 data.type = TempSummonType(fields[8].Get<uint8>());
2085
2087 {
2088 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has unhandled temp summon type {} in group [Summoner ID: {}, Summoner Type: {}, Group ID: {}] for creature entry {}, skipped.", data.type, summonerId, summonerType, group, data.entry);
2089 continue;
2090 }
2091
2092 data.time = fields[9].Get<uint32>();
2093
2094 TempSummonGroupKey key(summonerId, summonerType, group);
2095 _tempSummonDataStore[key].push_back(data);
2096
2097 ++count;
2098 } while (result->NextRow());
2099
2100 LOG_INFO("server.loading", ">> Loaded {} Temporary Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2101 LOG_INFO("server.loading", " ");
2102}
TempSummonType
Definition: Object.h:44
@ TEMPSUMMON_MANUAL_DESPAWN
Definition: Object.h:52
SummonerType
Definition: TemporarySummon.h:24
@ SUMMONER_TYPE_MAP
Definition: TemporarySummon.h:27
@ SUMMONER_TYPE_CREATURE
Definition: TemporarySummon.h:25
@ SUMMONER_TYPE_GAMEOBJECT
Definition: TemporarySummon.h:26
Stores data for temp summons.
Definition: TemporarySummon.h:32
TempSummonType type
Summon type, see TempSummonType for available types.
Definition: TemporarySummon.h:35
uint32 time
Despawn time, usable only with certain temp summon types.
Definition: TemporarySummon.h:36
uint32 entry
Entry of summoned creature.
Definition: TemporarySummon.h:33
Position pos
Position, where should be creature spawned.
Definition: TemporarySummon.h:34
void Relocate(float x, float y)
Definition: Position.h:73

References _tempSummonDataStore, TempSummonData::entry, Field::Get(), GetCreatureTemplate(), GetGameObjectTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, TempSummonData::pos, Position::Relocate(), sMapStore, SUMMONER_TYPE_CREATURE, SUMMONER_TYPE_GAMEOBJECT, SUMMONER_TYPE_MAP, TEMPSUMMON_MANUAL_DESPAWN, TempSummonData::time, TempSummonData::type, and WorldDatabase.

◆ LoadTrainerSpell()

void ObjectMgr::LoadTrainerSpell ( )
9120{
9121 uint32 oldMSTime = getMSTime();
9122
9123 // For reload case
9125
9126 QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.ReqLevel, a.ReqSpell FROM npc_trainer AS a "
9127 "INNER JOIN npc_trainer AS b ON a.ID = -(b.SpellID) "
9128 "UNION SELECT * FROM npc_trainer WHERE SpellID > 0");
9129
9130 if (!result)
9131 {
9132 LOG_WARN("server.loading", ">> Loaded 0 Trainers. DB table `npc_trainer` is empty!");
9133 LOG_INFO("server.loading", " ");
9134 return;
9135 }
9136
9137 uint32 count = 0;
9138
9139 do
9140 {
9141 Field* fields = result->Fetch();
9142
9143 uint32 entry = fields[0].Get<uint32>();
9144 uint32 spell = fields[1].Get<uint32>();
9145 uint32 spellCost = fields[2].Get<uint32>();
9146 uint32 reqSkill = fields[3].Get<uint16>();
9147 uint32 reqSkillValue = fields[4].Get<uint16>();
9148 uint32 reqLevel = fields[5].Get<uint8>();
9149 uint32 reqSpell = fields[6].Get<uint32>();
9150
9151 AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel, reqSpell);
9152
9153 ++count;
9154 } while (result->NextRow());
9155
9156 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9157 LOG_INFO("server.loading", " ");
9158}
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
Definition: ObjectMgr.cpp:9034

References _cacheTrainerSpellStore, AddSpellToTrainer(), Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadVehicleAccessories()

void ObjectMgr::LoadVehicleAccessories ( )
3443{
3444 uint32 oldMSTime = getMSTime();
3445
3446 _vehicleAccessoryStore.clear(); // needed for reload case
3447
3448 uint32 count = 0;
3449
3450 // 0 1 2 3 4 5
3451 QueryResult result = WorldDatabase.Query("SELECT `guid`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_accessory`");
3452
3453 if (!result)
3454 {
3455 LOG_WARN("server.loading", ">> Loaded 0 Vehicle Accessories in {} ms", GetMSTimeDiffToNow(oldMSTime));
3456 LOG_INFO("server.loading", " ");
3457 return;
3458 }
3459
3460 do
3461 {
3462 Field* fields = result->Fetch();
3463
3464 uint32 uiGUID = fields[0].Get<uint32>();
3465 uint32 uiAccessory = fields[1].Get<uint32>();
3466 int8 uiSeat = int8(fields[2].Get<int16>());
3467 bool bMinion = fields[3].Get<bool>();
3468 uint8 uiSummonType = fields[4].Get<uint8>();
3469 uint32 uiSummonTimer = fields[5].Get<uint32>();
3470
3471 if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
3472 {
3473 LOG_ERROR("sql.sql", "Table `vehicle_accessory`: Accessory {} does not exist.", uiAccessory);
3474 continue;
3475 }
3476
3477 _vehicleAccessoryStore[uiGUID].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3478
3479 ++count;
3480 } while (result->NextRow());
3481
3482 LOG_INFO("server.loading", ">> Loaded {} Vehicle Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3483 LOG_INFO("server.loading", " ");
3484}
Definition: VehicleDefines.h:91

References _vehicleAccessoryStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sObjectMgr, and WorldDatabase.

◆ LoadVehicleTemplateAccessories()

void ObjectMgr::LoadVehicleTemplateAccessories ( )
3387{
3388 uint32 oldMSTime = getMSTime();
3389
3390 _vehicleTemplateAccessoryStore.clear(); // needed for reload case
3391
3392 uint32 count = 0;
3393
3394 // 0 1 2 3 4 5
3395 QueryResult result = WorldDatabase.Query("SELECT `entry`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_template_accessory`");
3396
3397 if (!result)
3398 {
3399 LOG_WARN("server.loading", ">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
3400 LOG_INFO("server.loading", " ");
3401 return;
3402 }
3403
3404 do
3405 {
3406 Field* fields = result->Fetch();
3407
3408 uint32 uiEntry = fields[0].Get<uint32>();
3409 uint32 uiAccessory = fields[1].Get<uint32>();
3410 int8 uiSeat = int8(fields[2].Get<int8>());
3411 bool bMinion = fields[3].Get<bool>();
3412 uint8 uiSummonType = fields[4].Get<uint8>();
3413 uint32 uiSummonTimer = fields[5].Get<uint32>();
3414
3415 if (!sObjectMgr->GetCreatureTemplate(uiEntry))
3416 {
3417 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} does not exist.", uiEntry);
3418 continue;
3419 }
3420
3421 if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
3422 {
3423 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: Accessory {} does not exist.", uiAccessory);
3424 continue;
3425 }
3426
3427 if (_spellClickInfoStore.find(uiEntry) == _spellClickInfoStore.end())
3428 {
3429 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} has no data in npc_spellclick_spells", uiEntry);
3430 continue;
3431 }
3432
3433 _vehicleTemplateAccessoryStore[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3434
3435 ++count;
3436 } while (result->NextRow());
3437
3438 LOG_INFO("server.loading", ">> Loaded {} Vehicle Template Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3439 LOG_INFO("server.loading", " ");
3440}

References _spellClickInfoStore, _vehicleTemplateAccessoryStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, sObjectMgr, and WorldDatabase.

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
9200{
9201 uint32 oldMSTime = getMSTime();
9202
9203 // For reload case
9204 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
9205 itr->second.Clear();
9206 _cacheVendorItemStore.clear();
9207
9208 std::set<uint32> skip_vendors;
9209
9210 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
9211 if (!result)
9212 {
9213 LOG_INFO("server.loading", " ");
9214 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
9215 return;
9216 }
9217
9218 uint32 count = 0;
9219
9220 do
9221 {
9222 Field* fields = result->Fetch();
9223
9224 uint32 entry = fields[0].Get<uint32>();
9225 int32 item_id = fields[1].Get<int32>();
9226
9227 // if item is a negative, its a reference
9228 if (item_id < 0)
9229 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
9230 else
9231 {
9232 uint32 maxcount = fields[2].Get<uint8>();
9233 uint32 incrtime = fields[3].Get<uint32>();
9234 uint32 ExtendedCost = fields[4].Get<uint32>();
9235
9236 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
9237 continue;
9238
9239 VendorItemData& vList = _cacheVendorItemStore[entry];
9240
9241 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9242 ++count;
9243 }
9244 } while (result->NextRow());
9245
9246 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9247 LOG_INFO("server.loading", " ");
9248}

References _cacheVendorItemStore, VendorItemData::AddItem(), Field::Get(), getMSTime(), GetMSTimeDiffToNow(), IsVendorItemValid(), LoadReferenceVendor(), LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
5541{
5543
5544 std::set<uint32> actionSet;
5545
5546 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
5547 actionSet.insert(itr->first);
5548
5550 PreparedQueryResult result = WorldDatabase.Query(stmt);
5551
5552 if (result)
5553 {
5554 do
5555 {
5556 Field* fields = result->Fetch();
5557 uint32 action = fields[0].Get<uint32>();
5558
5559 actionSet.erase(action);
5560 } while (result->NextRow());
5561 }
5562
5563 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
5564 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
5565}
ScriptMapMap sWaypointScripts
Definition: ObjectMgr.cpp:59
@ SCRIPTS_WAYPOINT
Definition: ObjectMgr.h:153
@ WORLD_SEL_WAYPOINT_DATA_ACTION
Definition: WorldDatabase.h:69

References Field::Get(), LoadScripts(), LOG_ERROR, SCRIPTS_WAYPOINT, sWaypointScripts, WORLD_SEL_WAYPOINT_DATA_ACTION, and WorldDatabase.

◆ NewGOData()

GameObjectData & ObjectMgr::NewGOData ( ObjectGuid::LowType  guid)
inline
1287{ return _gameObjectDataStore[guid]; }

References _gameObjectDataStore.

Referenced by AddGOData().

◆ NewOrExistCreatureData()

CreatureData & ObjectMgr::NewOrExistCreatureData ( ObjectGuid::LowType  spawnId)
inline
1202{ return _creatureDataStore[spawnId]; }

References _creatureDataStore.

Referenced by AddCreData().

◆ PlayerCreateInfoAddItemHelper()

void ObjectMgr::PlayerCreateInfoAddItemHelper ( uint32  race_,
uint32  class_,
uint32  itemId,
int32  count 
)
private
3592{
3593 if (!_playerInfo[race_][class_])
3594 return;
3595
3596 if (count > 0)
3597 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
3598 else
3599 {
3600 if (count < -1)
3601 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
3602
3603 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
3604 {
3605 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
3606 {
3607 bool found = false;
3608 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
3609 {
3610 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
3611 {
3612 found = true;
3613 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
3614 break;
3615 }
3616 }
3617
3618 if (!found)
3619 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
3620 }
3621 }
3622 }
3623}
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition: DBCStores.cpp:842
Definition: Player.h:279
PlayerCreateInfoItems item
Definition: Player.h:347

References _playerInfo, GENDER_NONE, GetCharStartOutfitEntry(), PlayerInfo::item, LOG_ERROR, and MAX_OUTFIT_ITEMS.

Referenced by LoadPlayerInfo().

◆ RemoveCreatureFromGrid()

void ObjectMgr::RemoveCreatureFromGrid ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)
2314{
2315 uint8 mask = data->spawnMask;
2316 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2317 {
2318 if (mask & 1)
2319 {
2320 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2321 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2322 cell_guids.creatures.erase(guid);
2323 }
2324 }
2325}

References _mapObjectGuidsStore, Acore::ComputeCellCoord(), CellObjectGuids::creatures, CoordPair< LIMIT >::GetId(), MAKE_PAIR32(), CreatureData::mapid, CreatureData::posX, CreatureData::posY, and CreatureData::spawnMask.

Referenced by DeleteCreatureData().

◆ RemoveGameobjectFromGrid()

void ObjectMgr::RemoveGameobjectFromGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2617{
2618 uint8 mask = data->spawnMask;
2619 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2620 {
2621 if (mask & 1)
2622 {
2623 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2624 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2625 cell_guids.gameobjects.erase(guid);
2626 }
2627 }
2628}

References _mapObjectGuidsStore, Acore::ComputeCellCoord(), CellObjectGuids::gameobjects, CoordPair< LIMIT >::GetId(), MAKE_PAIR32(), GameObjectData::mapid, GameObjectData::posX, GameObjectData::posY, and GameObjectData::spawnMask.

Referenced by DeleteGOData().

◆ RemoveVendorItem()

bool ObjectMgr::RemoveVendorItem ( uint32  entry,
uint32  item,
bool  persist = true 
)
9379{
9380 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
9381 if (iter == _cacheVendorItemStore.end())
9382 return false;
9383
9384 if (!iter->second.RemoveItem(item))
9385 return false;
9386
9387 if (persist)
9388 {
9390
9391 stmt->SetData(0, entry);
9392 stmt->SetData(1, item);
9393
9394 WorldDatabase.Execute(stmt);
9395 }
9396
9397 return true;
9398}
@ WORLD_DEL_NPC_VENDOR
Definition: WorldDatabase.h:44

References _cacheVendorItemStore, PreparedStatementBase::SetData(), WORLD_DEL_NPC_VENDOR, and WorldDatabase.

◆ ReturnOrDeleteOldMails()

void ObjectMgr::ReturnOrDeleteOldMails ( bool  serverUp)
6032{
6033 uint32 oldMSTime = getMSTime();
6034
6035 time_t curTime = GameTime::GetGameTime().count();
6036
6038 stmt->SetData(0, uint32(curTime));
6039 PreparedQueryResult result = CharacterDatabase.Query(stmt);
6040 if (!result)
6041 return;
6042
6043 std::map<uint32 /*messageId*/, MailItemInfoVec> itemsCache;
6044 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS);
6045 stmt->SetData(0, uint32(curTime));
6046 if (PreparedQueryResult items = CharacterDatabase.Query(stmt))
6047 {
6048 MailItemInfo item;
6049 do
6050 {
6051 Field* fields = items->Fetch();
6052 item.item_guid = fields[0].Get<uint32>();
6053 item.item_template = fields[1].Get<uint32>();
6054 uint32 mailId = fields[2].Get<uint32>();
6055 itemsCache[mailId].push_back(item);
6056 } while (items->NextRow());
6057 }
6058
6059 uint32 deletedCount = 0;
6060 uint32 returnedCount = 0;
6061 do
6062 {
6063 Field* fields = result->Fetch();
6064 Mail* m = new Mail;
6065 m->messageID = fields[0].Get<uint32>();
6066 m->messageType = fields[1].Get<uint8>();
6067 m->sender = fields[2].Get<uint32>();
6068 m->receiver = fields[3].Get<uint32>();
6069 bool has_items = fields[4].Get<bool>();
6070 m->expire_time = time_t(fields[5].Get<uint32>());
6071 m->deliver_time = time_t(0);
6072 m->stationery = fields[6].Get<uint8>();
6073 m->checked = fields[7].Get<uint8>();
6074 m->mailTemplateId = fields[8].Get<int16>();
6075
6076 Player* player = nullptr;
6077 if (serverUp)
6079
6080 if (player) // don't modify mails of a logged in player
6081 {
6082 delete m;
6083 continue;
6084 }
6085
6086 // Delete or return mail
6087 if (has_items)
6088 {
6089 // read items from cache
6090 m->items.swap(itemsCache[m->messageID]);
6091
6092 // If it is mail from non-player, or if it's already return mail, it shouldn't be returned, but deleted
6093 if (!m->IsSentByPlayer() || m->IsSentByGM() || (m->IsCODPayment() || m->IsReturnedMail()))
6094 {
6095 for (auto const& mailedItem : m->items)
6096 {
6097 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
6098 stmt->SetData(0, mailedItem.item_guid);
6099 CharacterDatabase.Execute(stmt);
6100 }
6101
6102 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
6103 stmt->SetData(0, m->messageID);
6104 CharacterDatabase.Execute(stmt);
6105 }
6106 else
6107 {
6108 // Mail will be returned
6109 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_RETURNED);
6110 stmt->SetData(0, m->receiver);
6111 stmt->SetData(1, m->sender);
6112 stmt->SetData(2, uint32(curTime + 30 * DAY));
6113 stmt->SetData(3, uint32(curTime));
6115 stmt->SetData(5, m->messageID);
6116 CharacterDatabase.Execute(stmt);
6117 for (auto const& mailedItem : m->items)
6118 {
6119 // Update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete
6120 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_ITEM_RECEIVER);
6121 stmt->SetData(0, m->sender);
6122 stmt->SetData(1, mailedItem.item_guid);
6123 CharacterDatabase.Execute(stmt);
6124
6125 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
6126 stmt->SetData(0, m->sender);
6127 stmt->SetData(1, mailedItem.item_guid);
6128 CharacterDatabase.Execute(stmt);
6129 }
6130
6131 // xinef: update global data
6132 sCharacterCache->IncreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->sender));
6133 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6134
6135 delete m;
6136 ++returnedCount;
6137 continue;
6138 }
6139 }
6140
6141 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6142
6143 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
6144 stmt->SetData(0, m->messageID);
6145 CharacterDatabase.Execute(stmt);
6146 delete m;
6147 ++deletedCount;
6148 } while (result->NextRow());
6149
6150 LOG_INFO("server.loading", ">> Processed {} expired mails: {} deleted and {} returned in {} ms", deletedCount + returnedCount, deletedCount, returnedCount, GetMSTimeDiffToNow(oldMSTime));
6151 LOG_INFO("server.loading", " ");
6152}
#define sCharacterCache
Definition: CharacterCache.h:83
std::vector< MailItemInfo > MailItemInfoVec
Definition: Mail.h:165
@ MAIL_CHECK_MASK_RETURNED
Definition: Mail.h:49
@ CHAR_UPD_ITEM_OWNER
Definition: CharacterDatabase.h:118
@ CHAR_DEL_ITEM_INSTANCE
Definition: CharacterDatabase.h:127
@ CHAR_UPD_MAIL_RETURNED
Definition: CharacterDatabase.h:116
@ CHAR_SEL_EXPIRED_MAIL
Definition: CharacterDatabase.h:114
@ CHAR_SEL_EXPIRED_MAIL_ITEMS
Definition: CharacterDatabase.h:115
@ CHAR_DEL_MAIL_BY_ID
Definition: CharacterDatabase.h:110
@ CHAR_DEL_MAIL_ITEM_BY_ID
Definition: CharacterDatabase.h:380
@ CHAR_UPD_MAIL_ITEM_RECEIVER
Definition: CharacterDatabase.h:117
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:254
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: Player.h:1064
Definition: Mail.h:161
ObjectGuid::LowType item_guid
Definition: Mail.h:162
uint32 item_template
Definition: Mail.h:163
Definition: Mail.h:168
bool IsSentByGM() const
Definition: Mail.h:209
bool IsCODPayment() const
Definition: Mail.h:210
ObjectGuid::LowType receiver
Definition: Mail.h:174
uint8 messageType
Definition: Mail.h:170
bool IsSentByPlayer() const
Definition: Mail.h:208
uint32 messageID
Definition: Mail.h:169
time_t expire_time
Definition: Mail.h:179
uint32 sender
Definition: Mail.h:173
uint8 stationery
Definition: Mail.h:171
std::vector< MailItemInfo > items
Definition: Mail.h:177
time_t deliver_time
Definition: Mail.h:180
bool IsReturnedMail() const
Definition: Mail.h:211
uint32 checked
Definition: Mail.h:183
uint16 mailTemplateId
Definition: Mail.h:172

References CHAR_DEL_ITEM_INSTANCE, CHAR_DEL_MAIL_BY_ID, CHAR_DEL_MAIL_ITEM_BY_ID, CHAR_SEL_EXPIRED_MAIL, CHAR_SEL_EXPIRED_MAIL_ITEMS, CHAR_UPD_ITEM_OWNER, CHAR_UPD_MAIL_ITEM_RECEIVER, CHAR_UPD_MAIL_RETURNED, CharacterDatabase, Mail::checked, DAY, Mail::deliver_time, Mail::expire_time, ObjectAccessor::FindPlayerByLowGUID(), Field::Get(), GameTime::GetGameTime(), getMSTime(), GetMSTimeDiffToNow(), Mail::IsCODPayment(), Mail::IsReturnedMail(), Mail::IsSentByGM(), Mail::IsSentByPlayer(), MailItemInfo::item_guid, MailItemInfo::item_template, Mail::items, LOG_INFO, MAIL_CHECK_MASK_RETURNED, Mail::mailTemplateId, Mail::messageID, Mail::messageType, Mail::receiver, sCharacterCache, Mail::sender, PreparedStatementBase::SetData(), and Mail::stationery.

◆ SendServerMail()

void ObjectMgr::SendServerMail ( Player player,
uint32  id,
uint32  reqLevel,
uint32  reqPlayTime,
uint32  rewardMoneyA,
uint32  rewardMoneyH,
uint32  rewardItemA,
uint32  rewardItemCountA,
uint32  rewardItemH,
uint32  rewardItemCountH,
std::string  subject,
std::string  body,
uint8  active 
) const
10203{
10204 if (active)
10205 {
10206 if (player->GetLevel() < reqLevel)
10207 return;
10208
10209 if (player->GetTotalPlayedTime() < reqPlayTime)
10210 return;
10211
10212 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
10213
10215 MailDraft draft(subject, body);
10216
10217 draft.AddMoney(player->GetTeamId() == TEAM_ALLIANCE ? rewardMoneyA : rewardMoneyH);
10218 if (Item* mailItem = Item::CreateItem(player->GetTeamId() == TEAM_ALLIANCE ? rewardItemA : rewardItemH, player->GetTeamId() == TEAM_ALLIANCE ? rewardItemCountA : rewardItemCountH))
10219 {
10220 mailItem->SaveToDB(trans);
10221 draft.AddItem(mailItem);
10222 }
10223
10224 draft.SendMailTo(trans, MailReceiver(player), sender);
10225 CharacterDatabase.CommitTransaction(trans);
10226
10228 stmt->SetData(0, player->GetGUID().GetCounter());
10229 stmt->SetData(1, id);
10230 CharacterDatabase.Execute(stmt);
10231
10232 LOG_DEBUG("entities.player", "ObjectMgr::SendServerMail() Sent mail id {} to {}", id, player->GetGUID().ToString());
10233 }
10234}
@ MAIL_STATIONERY_GM
Definition: Mail.h:60
@ MAIL_NORMAL
Definition: Mail.h:38
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
@ CHAR_REP_MAIL_SERVER_CHARACTER
Definition: CharacterDatabase.h:85
Definition: Item.h:220
static Item * CreateItem(uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
Definition: Item.cpp:1088
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
LowType GetCounter() const
Definition: ObjectGuid.h:145
std::string ToString() const
Definition: ObjectGuid.cpp:47
uint32 GetTotalPlayedTime()
Definition: Player.h:1186
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088
uint8 GetLevel() const
Definition: Unit.h:855
Definition: Mail.h:84
Definition: Mail.h:106
Definition: Mail.h:120

References MailDraft::AddItem(), MailDraft::AddMoney(), CHAR_REP_MAIL_SERVER_CHARACTER, CharacterDatabase, Item::CreateItem(), ObjectGuid::GetCounter(), Object::GetGUID(), Unit::GetLevel(), Player::GetTeamId(), Player::GetTotalPlayedTime(), LOG_DEBUG, MAIL_NORMAL, MAIL_STATIONERY_GM, MailDraft::SendMailTo(), PreparedStatementBase::SetData(), TEAM_ALLIANCE, and ObjectGuid::ToString().

◆ SetCreatureLinkedRespawn()

bool ObjectMgr::SetCreatureLinkedRespawn ( ObjectGuid::LowType  guid,
ObjectGuid::LowType  linkedGuid 
)
1972{
1973 if (!guidLow)
1974 return false;
1975
1976 CreatureData const* master = GetCreatureData(guidLow);
1977 ObjectGuid guid = ObjectGuid::Create<HighGuid::Unit>(master->id1, guidLow);
1978
1979 if (!linkedGuidLow) // we're removing the linking
1980 {
1981 _linkedRespawnStore.erase(guid);
1983 stmt->SetData(0, guidLow);
1984 WorldDatabase.Execute(stmt);
1985 return true;
1986 }
1987
1988 CreatureData const* slave = GetCreatureData(linkedGuidLow);
1989 if (!slave)
1990 {
1991 LOG_ERROR("sql.sql", "Creature '{}' linking to non-existent creature '{}'.", guidLow, linkedGuidLow);
1992 return false;
1993 }
1994
1995 MapEntry const* map = sMapStore.LookupEntry(master->mapid);
1996 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1997 {
1998 LOG_ERROR("sql.sql", "Creature '{}' linking to '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1999 return false;
2000 }
2001
2002 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2003 {
2004 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2005 return false;
2006 }
2007
2008 ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, linkedGuidLow);
2009
2010 _linkedRespawnStore[guid] = linkedGuid;
2012 stmt->SetData(0, guidLow);
2013 stmt->SetData(1, linkedGuidLow);
2014 WorldDatabase.Execute(stmt);
2015 return true;
2016}
@ WORLD_REP_CREATURE_LINKED_RESPAWN
Definition: WorldDatabase.h:33
@ WORLD_DEL_CRELINKED_RESPAWN
Definition: WorldDatabase.h:32

References _linkedRespawnStore, GetCreatureData(), CreatureData::id1, MapEntry::Instanceable(), LOG_ERROR, CreatureData::mapid, PreparedStatementBase::SetData(), sMapStore, CreatureData::spawnMask, WORLD_DEL_CRELINKED_RESPAWN, WORLD_REP_CREATURE_LINKED_RESPAWN, and WorldDatabase.

◆ SetDBCLocaleIndex()

void ObjectMgr::SetDBCLocaleIndex ( LocaleConstant  locale)
inline
1312{ DBCLocaleIndex = locale; }

References DBCLocaleIndex.

◆ SetHighestGuids()

void ObjectMgr::SetHighestGuids ( )
6914{
6915 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
6916 if (result)
6917 GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].Get<uint32>() + 1);
6918
6919 result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
6920 if (result)
6921 GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].Get<uint32>() + 1);
6922
6923 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
6924 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6925 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6926 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6927 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6928
6929 result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
6930 if (result)
6931 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
6932
6933 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
6934 if (result)
6935 _auctionId = (*result)[0].Get<uint32>() + 1;
6936
6937 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
6938 if (result)
6939 _mailId = (*result)[0].Get<uint32>() + 1;
6940
6941 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
6942 if (result)
6943 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
6944
6945 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
6946 if (result)
6947 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
6948
6949 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
6950 if (result)
6951 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
6952
6953 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
6954 if (result)
6955 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
6956
6957 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
6958 if (result)
6959 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
6960
6961 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
6962 if (result)
6963 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
6964}
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define sGuildMgr
Definition: GuildMgr.h:51

References _auctionId, _creatureSpawnId, _equipmentSetGuid, _gameObjectSpawnId, _mailId, CharacterDatabase, sArenaTeamMgr, sGuildMgr, and WorldDatabase.

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
5628{
5629 uint32 oldMSTime = getMSTime();
5630
5631 if (_spellScriptsStore.empty())
5632 {
5633 LOG_INFO("server.loading", ">> Validated 0 scripts.");
5634 LOG_INFO("server.loading", " ");
5635 return;
5636 }
5637
5638 uint32 count = 0;
5639
5640 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
5641 {
5642 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
5643 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
5644 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
5645 itr = _spellScriptsStore.upper_bound(itr->first);
5646
5647 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
5648 {
5649 SpellScript* spellScript = sitr->first->GetSpellScript();
5650 AuraScript* auraScript = sitr->first->GetAuraScript();
5651 bool valid = true;
5652 if (!spellScript && !auraScript)
5653 {
5654 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
5655 valid = false;
5656 }
5657 if (spellScript)
5658 {
5659 spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5660 spellScript->_Register();
5661 if (!spellScript->_Validate(spellInfo))
5662 valid = false;
5663 delete spellScript;
5664 }
5665 if (auraScript)
5666 {
5667 auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5668 auraScript->_Register();
5669 if (!auraScript->_Validate(spellInfo))
5670 valid = false;
5671 delete auraScript;
5672 }
5673 if (!valid)
5674 {
5675 _spellScriptsStore.erase(sitr->second);
5676 }
5677 }
5678 ++count;
5679 }
5680
5681 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5682 LOG_INFO("server.loading", " ");
5683}
std::string const & GetScriptName(uint32 id) const
Definition: ObjectMgr.cpp:9536
virtual void _Register()
Definition: SpellScript.cpp:45
virtual void _Init(std::string const *scriptname, uint32 spellId)
Definition: SpellScript.cpp:59
Definition: SpellScript.h:182
bool _Validate(SpellInfo const *entry) override
Definition: SpellScript.cpp:316
Definition: SpellScript.h:517
bool _Validate(SpellInfo const *entry) override
Definition: SpellScript.cpp:662

References _SpellScript::_Init(), _SpellScript::_Register(), _spellScriptsStore, SpellScript::_Validate(), AuraScript::_Validate(), getMSTime(), GetMSTimeDiffToNow(), GetScriptName(), SpellInfo::Id, LOG_ERROR, LOG_INFO, sScriptMgr, and sSpellMgr.

Friends And Related Function Documentation

◆ PlayerDumpReader

friend class PlayerDumpReader
friend

Member Data Documentation

◆ _accessRequirementStore

DungeonProgressionRequirementsContainer ObjectMgr::_accessRequirementStore
private

◆ _acoreStringStore

AcoreStringContainer ObjectMgr::_acoreStringStore
private

Referenced by GetAcoreString(), and LoadAcoreStrings().

◆ _areaTriggerScriptStore

AreaTriggerScriptContainer ObjectMgr::_areaTriggerScriptStore
private

◆ _areaTriggerStore

AreaTriggerContainer ObjectMgr::_areaTriggerStore
private

Referenced by GetAreaTrigger(), and LoadAreaTriggers().

◆ _areaTriggerTeleportStore

◆ _auctionId

uint32 ObjectMgr::_auctionId
private

◆ _baseXPTable

BaseXPContainer ObjectMgr::_baseXPTable
private

Referenced by GetBaseXP(), and LoadExplorationBaseXP().

◆ _broadcastTextStore

BroadcastTextContainer ObjectMgr::_broadcastTextStore
private

◆ _cacheTrainerSpellStore

CacheTrainerSpellContainer ObjectMgr::_cacheTrainerSpellStore
private

◆ _cacheVendorItemStore

◆ _creatureAddonStore

CreatureAddonContainer ObjectMgr::_creatureAddonStore
private

◆ _creatureBaseStatsStore

CreatureBaseStatsContainer ObjectMgr::_creatureBaseStatsStore
private

◆ _creatureCustomIDsStore

CreatureCustomIDsContainer ObjectMgr::_creatureCustomIDsStore
private

◆ _creatureDataStore

◆ _creatureLocaleStore

CreatureLocaleContainer ObjectMgr::_creatureLocaleStore
private

◆ _creatureModelStore

CreatureModelContainer ObjectMgr::_creatureModelStore
private

◆ _creatureMovementOverrides

std::unordered_map<ObjectGuid::LowType, CreatureMovementData> ObjectMgr::_creatureMovementOverrides
private

◆ _creatureQuestInvolvedRelations

◆ _creatureQuestItemStore

CreatureQuestItemMap ObjectMgr::_creatureQuestItemStore
private

◆ _creatureQuestRelations

QuestRelations ObjectMgr::_creatureQuestRelations
private

◆ _creatureSpawnId

ObjectGuid::LowType ObjectMgr::_creatureSpawnId
private

◆ _creatureTemplateAddonStore

CreatureAddonContainer ObjectMgr::_creatureTemplateAddonStore
private

◆ _creatureTemplateStore

◆ _creatureTemplateStoreFast

std::vector<CreatureTemplate*> ObjectMgr::_creatureTemplateStoreFast
private

◆ _difficultyEntries

std::set<uint32> ObjectMgr::_difficultyEntries[MAX_DIFFICULTY - 1]
private

◆ _dungeonEncounterStore

DungeonEncounterContainer ObjectMgr::_dungeonEncounterStore
private

◆ _emptyCellObjectGuids

CellObjectGuids ObjectMgr::_emptyCellObjectGuids
private

Referenced by GetCellObjectGuids().

◆ _emptyCellObjectGuidsMap

CellObjectGuidsMap ObjectMgr::_emptyCellObjectGuidsMap
private

Referenced by GetMapObjectGuids().

◆ _equipmentInfoStore

EquipmentInfoContainer ObjectMgr::_equipmentInfoStore
private

◆ _equipmentSetGuid

uint64 ObjectMgr::_equipmentSetGuid
private

◆ _fishingBaseForAreaStore

◆ _gameObjectAddonStore

GameObjectAddonContainer ObjectMgr::_gameObjectAddonStore
private

◆ _gameObjectDataStore

GameObjectDataContainer ObjectMgr::_gameObjectDataStore
private

◆ _gameObjectLocaleStore

GameObjectLocaleContainer ObjectMgr::_gameObjectLocaleStore
private

◆ _gameObjectQuestItemStore

GameObjectQuestItemMap ObjectMgr::_gameObjectQuestItemStore
private

◆ _gameObjectSpawnId

ObjectGuid::LowType ObjectMgr::_gameObjectSpawnId
private

◆ _gameObjectTemplateAddonStore

GameObjectTemplateAddonContainer ObjectMgr::_gameObjectTemplateAddonStore
private

◆ _gameObjectTemplateStore

GameObjectTemplateContainer ObjectMgr::_gameObjectTemplateStore
private

◆ _gameTeleStore

GameTeleContainer ObjectMgr::_gameTeleStore
private

◆ _goQuestInvolvedRelations

QuestRelations ObjectMgr::_goQuestInvolvedRelations
private

◆ _goQuestRelations

QuestRelations ObjectMgr::_goQuestRelations
private

◆ _gossipMenuItemsLocaleStore

GossipMenuItemsLocaleContainer ObjectMgr::_gossipMenuItemsLocaleStore
private

◆ _gossipMenuItemsStore

◆ _gossipMenusStore

GossipMenusContainer ObjectMgr::_gossipMenusStore
private

◆ _gossipTextStore

GossipTextContainer ObjectMgr::_gossipTextStore
private

Referenced by GetGossipText(), and LoadGossipText().

◆ _guidGenerators

std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase> > ObjectMgr::_guidGenerators
private

◆ _hasDifficultyEntries

std::set<uint32> ObjectMgr::_hasDifficultyEntries[MAX_DIFFICULTY - 1]
private

Referenced by CheckCreatureTemplate().

◆ _hiPetNumber

uint32 ObjectMgr::_hiPetNumber
private

Referenced by GeneratePetNumber(), and LoadPetNumber().

◆ _hiPetNumberMutex

std::mutex ObjectMgr::_hiPetNumberMutex
private

Referenced by GeneratePetNumber().

◆ _instanceTemplateStore

InstanceTemplateContainer ObjectMgr::_instanceTemplateStore
private

◆ _itemLocaleStore

ItemLocaleContainer ObjectMgr::_itemLocaleStore
private

Referenced by GetItemLocale(), and LoadItemLocales().

◆ _itemSetNameLocaleStore

ItemSetNameLocaleContainer ObjectMgr::_itemSetNameLocaleStore
private

◆ _itemSetNameStore

ItemSetNameContainer ObjectMgr::_itemSetNameStore
private

◆ _itemTemplateStore

ItemTemplateContainer ObjectMgr::_itemTemplateStore
private

◆ _itemTemplateStoreFast

std::vector<ItemTemplate*> ObjectMgr::_itemTemplateStoreFast
private

◆ _linkedRespawnStore

LinkedRespawnContainer ObjectMgr::_linkedRespawnStore
private

◆ _mailId

uint32 ObjectMgr::_mailId
private

Referenced by GenerateMailID(), and SetHighestGuids().

◆ _mailIdMutex

std::mutex ObjectMgr::_mailIdMutex
private

Referenced by GenerateMailID().

◆ _mailLevelRewardStore

MailLevelRewardContainer ObjectMgr::_mailLevelRewardStore
private

◆ _mapObjectGuidsStore

◆ _moduleStringStore

ModuleStringContainer ObjectMgr::_moduleStringStore
private

◆ _npcTextLocaleStore

NpcTextLocaleContainer ObjectMgr::_npcTextLocaleStore
private

◆ _pageTextLocaleStore

PageTextLocaleContainer ObjectMgr::_pageTextLocaleStore
private

◆ _pageTextStore

PageTextContainer ObjectMgr::_pageTextStore
private

Referenced by GetPageText(), and LoadPageTexts().

◆ _petHalfLocaleName0

HalfNameContainerLocale ObjectMgr::_petHalfLocaleName0
private

◆ _petHalfLocaleName1

HalfNameContainerLocale ObjectMgr::_petHalfLocaleName1
private

◆ _petHalfName0

HalfNameContainer ObjectMgr::_petHalfName0
private

Referenced by GeneratePetName(), and LoadPetNames().

◆ _petHalfName1

HalfNameContainer ObjectMgr::_petHalfName1
private

Referenced by GeneratePetName(), and LoadPetNames().

◆ _petInfoStore

PetLevelInfoContainer ObjectMgr::_petInfoStore
private

◆ _playerClassInfo

◆ _playerInfo

◆ _playerXPperLevel

PlayerXPperLevel ObjectMgr::_playerXPperLevel
private

Referenced by GetXPForLevel(), and LoadPlayerInfo().

◆ _pointOfInterestLocaleStore

PointOfInterestLocaleContainer ObjectMgr::_pointOfInterestLocaleStore
private

◆ _pointsOfInterestStore

PointOfInterestContainer ObjectMgr::_pointsOfInterestStore
private

◆ _profanityNamesStore

◆ _questAreaTriggerStore

QuestAreaTriggerContainer ObjectMgr::_questAreaTriggerStore
private

◆ _questGreetingStore

QuestGreetingContainer ObjectMgr::_questGreetingStore
private

◆ _questLocaleStore

QuestLocaleContainer ObjectMgr::_questLocaleStore
private

Referenced by GetQuestLocale(), and LoadQuestLocales().

◆ _questMoneyRewards

QuestMoneyRewardStore ObjectMgr::_questMoneyRewards
private

◆ _questOfferRewardLocaleStore

QuestOfferRewardLocaleContainer ObjectMgr::_questOfferRewardLocaleStore
private

◆ _questPOIStore

QuestPOIContainer ObjectMgr::_questPOIStore
private

Referenced by GetQuestPOIVector(), and LoadQuestPOI().

◆ _questRequestItemsLocaleStore

QuestRequestItemsLocaleContainer ObjectMgr::_questRequestItemsLocaleStore
private

◆ _questTemplates

QuestMap ObjectMgr::_questTemplates
private

◆ _questTemplatesFast

std::vector<Quest*> ObjectMgr::_questTemplatesFast
private

Referenced by GetQuestTemplate(), and LoadQuests().

◆ _repOnKillStore

RepOnKillContainer ObjectMgr::_repOnKillStore
private

◆ _repRewardRateStore

RepRewardRateContainer ObjectMgr::_repRewardRateStore
private

◆ _repSpilloverTemplateStore

RepSpilloverTemplateContainer ObjectMgr::_repSpilloverTemplateStore
private

◆ _reservedNamesStore

◆ _scriptNamesStore

ScriptNameContainer ObjectMgr::_scriptNamesStore
private

◆ _serverMailStore

ServerMailContainer ObjectMgr::_serverMailStore
private

◆ _spellClickInfoStore

◆ _spellScriptsStore

SpellScriptsContainer ObjectMgr::_spellScriptsStore
private

◆ _tavernAreaTriggerStore

TavernAreaTriggerContainer ObjectMgr::_tavernAreaTriggerStore
private

◆ _tempSummonDataStore

TempSummonDataContainer ObjectMgr::_tempSummonDataStore
private

Stores temp summon data grouped by summoner's entry, summoner's type and group id.

Referenced by GetSummonGroup(), and LoadTempSummons().

◆ _transportMaps

std::set<uint32> ObjectMgr::_transportMaps
private

◆ _vehicleAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleAccessoryStore
private

◆ _vehicleTemplateAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleTemplateAccessoryStore
private

◆ DBCLocaleIndex

LocaleConstant ObjectMgr::DBCLocaleIndex
private

◆ FactionChangeAchievements

CharacterConversionMap ObjectMgr::FactionChangeAchievements

◆ FactionChangeItems

CharacterConversionMap ObjectMgr::FactionChangeItems

Referenced by LoadFactionChangeItems().

◆ FactionChangeQuests

CharacterConversionMap ObjectMgr::FactionChangeQuests

Referenced by LoadFactionChangeQuests().

◆ FactionChangeReputation

CharacterConversionMap ObjectMgr::FactionChangeReputation

◆ FactionChangeSpells

CharacterConversionMap ObjectMgr::FactionChangeSpells

Referenced by LoadFactionChangeSpells().

◆ FactionChangeTitles

CharacterConversionMap ObjectMgr::FactionChangeTitles

Referenced by LoadFactionChangeTitles().

◆ GameobjectInstanceSavedStateList

std::vector<GameobjectInstanceSavedState> ObjectMgr::GameobjectInstanceSavedStateList
private

◆ mExclusiveQuestGroups

ExclusiveQuestGroups ObjectMgr::mExclusiveQuestGroups

Referenced by LoadQuests().