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::unordered_map< ObjectGuid::LowType, std::vector< float > > CreatureSparringContainer
 
typedef std::multimap< int32, uint32ExclusiveQuestGroups
 
typedef std::pair< ExclusiveQuestGroups::const_iterator, ExclusiveQuestGroups::const_iterator > ExclusiveQuestGroupsBounds
 
typedef std::unordered_map< uint32, std::vector< uint32 > > BreadcrumbQuestMap
 

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
 
uint32 GetModelForTotem (SummonSlot totemSlot, Races race) const
 
uint32 GetModelForShapeshift (ShapeshiftForm form, Player *player) 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)
 
uint32 GetNearestTaxiNode (WorldLocation const &loc, 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
 
AreaTriggerScriptContainer const & GetAllAreaTriggerScriptData () 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.
 
void LoadCreatureTemplateModels ()
 
void LoadCreatureTemplateAddons ()
 
void LoadCreatureTemplateResistances ()
 
void LoadCreatureTemplateSpells ()
 
void LoadCreatureCustomIDs ()
 Load config option Creatures.CustomIDs into Store.
 
void CheckCreatureTemplate (CreatureTemplate const *cInfo)
 
void CheckCreatureMovement (char const *table, uint64 id, CreatureMovementData &creatureMovement)
 
void LoadGameObjectQuestItems ()
 
void LoadCreatureQuestItems ()
 
void LoadTempSummons ()
 
void LoadGameObjectSummons ()
 
void LoadSpawnGroupTemplates ()
 
void LoadSpawnGroups ()
 
void LoadCreatures ()
 
void LoadCreatureSparring ()
 
void LoadLinkedRespawn ()
 
bool SetCreatureLinkedRespawn (ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid)
 
void LoadCreatureAddons ()
 
void LoadGameObjectAddons ()
 
void LoadCreatureModelInfo ()
 
void LoadPlayerTotemModels ()
 
void LoadPlayerShapeshiftModels ()
 
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 LoadVehicleTemplateAccessories ()
 
void LoadVehicleAccessories ()
 
void LoadVehicleSeatAddon ()
 
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 LoadTrainers ()
 
void LoadCreatureDefaultTrainers ()
 
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 ()
 
std::vector< uint32 > const * GetBreadcrumbsForQuest (uint32 questId) const
 
MailLevelReward const * GetMailLevelReward (uint32 level, uint32 raceMask)
 
CellObjectGuids const & GetGridObjectGuids (uint16 mapid, uint8 spawnMode, uint32 gridId)
 
CellObjectGuidsMap const & GetMapObjectGuids (uint16 mapid, uint8 spawnMode)
 
std::vector< TempSummonData > const * GetSummonGroup (uint32 summonerId, SummonerType summonerType, uint8 group) const
 
std::vector< GameObjectSummonData > const * GetGameObjectSummonGroup (uint32 summonerId, SummonerType summonerType, uint8 group) const
 
BroadcastText const * GetBroadcastText (uint32 id) const
 
CreatureDataContainer const & GetAllCreatureData () const
 
CreatureData const * GetCreatureData (ObjectGuid::LowType spawnId) const
 
CreatureSparringContainer const & GetSparringData () const
 
CreatureDataNewOrExistCreatureData (ObjectGuid::LowType spawnId)
 
CreatureData const * LoadCreatureDataFromDB (ObjectGuid::LowType spawnId)
 Loads a single creature spawn entry from the database into the data store cache.
 
void DeleteCreatureData (ObjectGuid::LowType spawnId)
 
ObjectGuid GetLinkedRespawnGuid (ObjectGuid guid) const
 
GameObjectDataContainer const & GetAllGOData () const
 
GameObjectData const * GetGameObjectData (ObjectGuid::LowType spawnId) const
 
SpawnData const * GetSpawnData (SpawnObjectType type, ObjectGuid::LowType spawnId) const
 
SpawnGroupTemplateData const * GetSpawnGroupData (uint32 groupId) const
 
SpawnGroupTemplateData const * GetDefaultSpawnGroup () const
 
SpawnGroupTemplateData const * GetLegacySpawnGroup () const
 
std::pair< SpawnGroupLinkContainer::const_iterator, SpawnGroupLinkContainer::const_iterator > GetSpawnDataForGroup (uint32 groupId) const
 
void OnDeleteSpawnData (SpawnData const *data)
 
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)
 
GameObjectData const * LoadGameObjectDataFromDB (ObjectGuid::LowType spawnId)
 Loads a single gameobject spawn entry from the database into the data store cache.
 
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
 
std::string GetAcoreString (uint32 entry, LocaleConstant locale) const
 
std::string 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)
 
ObjectGuid::LowType 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)
 
ObjectGuid::LowType 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, bool exactSearch=false) const
 
GameTeleContainer const & GetGameTeleMap () const
 
bool AddGameTele (GameTele &data)
 
bool DeleteGameTele (std::string_view name)
 
Trainer::TrainerGetTrainer (uint32 creatureId)
 
std::vector< Trainer::Trainer const * > const & GetClassTrainers (uint8 classId) const
 
VendorItemData const * GetNpcVendorItemList (uint32 entry) const
 
void AddVendorItem (uint32 entry, uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedCost, bool persist=true)
 
bool RemoveVendorItem (uint32 entry, uint32 item, bool persist=true)
 
bool IsVendorItemValid (uint32 vendor_entry, uint32 item, uint32 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
 
VehicleSeatAddon const * GetVehicleSeatAddon (uint32 seatId) const
 
uint32 GetQuestMoneyReward (uint8 level, uint32 questMoneyDifficulty) 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
 
BreadcrumbQuestMap _breadcrumbsForQuest
 
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
 
VehicleSeatAddonContainer _vehicleSeatAddonStore
 
LocaleConstant DBCLocaleIndex
 
PageTextContainer _pageTextStore
 
InstanceTemplateContainer _instanceTemplateStore
 
CreatureSparringContainer _creatureSparringStore
 
MailLevelRewardContainer _mailLevelRewardStore
 
CreatureBaseStatsContainer _creatureBaseStatsStore
 
PetLevelInfoContainer _petInfoStore
 
PlayerClassInfo_playerClassInfo [MAX_CLASSES]
 
std::vector< std::vector< PlayerInfo * > > _playerInfo
 
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
 
SpawnGroupDataContainer _spawnGroupDataStore
 
SpawnGroupLinkContainer _spawnGroupMapStore
 
GameObjectLocaleContainer _gameObjectLocaleStore
 
GameObjectTemplateContainer _gameObjectTemplateStore
 
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
 
TempSummonDataContainer _tempSummonDataStore
 Stores temp summon data grouped by summoner's entry, summoner's type and group id.
 
GameObjectSummonDataContainer _goSummonDataStore
 Stores gameobject summon data grouped by summoner's entry, summoner's type and group id.
 
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
 
std::unordered_map< uint32, Trainer::Trainer_trainers
 
std::unordered_map< uint8, std::vector< Trainer::Trainer const * > > _classTrainers
 
std::unordered_map< uint32, uint32_creatureDefaultTrainers
 
std::set< uint32_difficultyEntries [MAX_DIFFICULTY - 1]
 
std::set< uint32_hasDifficultyEntries [MAX_DIFFICULTY - 1]
 
std::set< uint32_transportMaps
 
PlayerTotemModelMap _playerTotemModel
 
PlayerShapeshiftModelMap _playerShapeshiftModel
 
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

◆ BreadcrumbQuestMap

typedef std::unordered_map<uint32, std::vector<uint32> > ObjectMgr::BreadcrumbQuestMap

◆ CharacterConversionMap

◆ CreatureSparringContainer

typedef std::unordered_map<ObjectGuid::LowType, std::vector<float> > ObjectMgr::CreatureSparringContainer

◆ 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 
1699 {
1701 CREATURE_TO_GO, // Creature is dependant on GO
1702 GO_TO_GO,
1703 GO_TO_CREATURE, // GO is dependant on creature
1704 };
@ CREATURE_TO_GO
Definition ObjectMgr.h:1701
@ CREATURE_TO_CREATURE
Definition ObjectMgr.h:1700
@ GO_TO_GO
Definition ObjectMgr.h:1702
@ GO_TO_CREATURE
Definition ObjectMgr.h:1703

Constructor & Destructor Documentation

◆ ObjectMgr()

ObjectMgr::ObjectMgr ( )
private
300 :
301 _auctionId(1),
303 _mailId(1),
304 _hiPetNumber(1),
308{
309 for (uint8 i = 0; i < MAX_CLASSES; ++i)
310 {
311 _playerClassInfo[i] = nullptr;
312 }
313
314 // Initialize default spawn groups
317}
@ LOCALE_enUS
Definition Common.h:118
std::uint8_t uint8
Definition Define.h:109
#define MAX_CLASSES
Definition SharedDefines.h:140
SpawnGroupFlags
Definition SpawnData.h:42
@ SPAWNGROUP_FLAG_COMPATIBILITY_MODE
Definition SpawnData.h:45
@ SPAWNGROUP_FLAG_SYSTEM
Definition SpawnData.h:44
constexpr uint32 SPAWNGROUP_MAP_UNSET
Definition SpawnData.h:55
SpawnGroupDataContainer _spawnGroupDataStore
Definition ObjectMgr.h:1665
ObjectGuid::LowType _gameObjectSpawnId
Definition ObjectMgr.h:1535
uint32 _mailId
Definition ObjectMgr.h:1529
ObjectGuid::LowType _creatureSpawnId
Definition ObjectMgr.h:1534
LocaleConstant DBCLocaleIndex
Definition ObjectMgr.h:1602
PlayerClassInfo * _playerClassInfo[MAX_CLASSES]
Definition ObjectMgr.h:1622
uint64 _equipmentSetGuid
Definition ObjectMgr.h:1528
uint32 _auctionId
Definition ObjectMgr.h:1527
uint32 _hiPetNumber
Definition ObjectMgr.h:1531

References _playerClassInfo, _spawnGroupDataStore, MAX_CLASSES, SPAWNGROUP_FLAG_COMPATIBILITY_MODE, SPAWNGROUP_FLAG_SYSTEM, and SPAWNGROUP_MAP_UNSET.

◆ ~ObjectMgr()

ObjectMgr::~ObjectMgr ( )
private
320{
321 for (QuestMap::iterator i = _questTemplates.begin(); i != _questTemplates.end(); ++i)
322 delete i->second;
323
324 for (PetLevelInfoContainer::iterator i = _petInfoStore.begin(); i != _petInfoStore.end(); ++i)
325 delete[] i->second;
326
327 // free only if loaded
328 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
329 {
330 if (_playerClassInfo[class_])
331 delete[] _playerClassInfo[class_]->levelInfo;
332 delete _playerClassInfo[class_];
333 }
334
335 for (int race = 0; race < sRaceMgr->GetMaxRaces(); ++race)
336 {
337 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
338 {
339 if (_playerInfo[race][class_])
340 delete[] _playerInfo[race][class_]->levelInfo;
341 delete _playerInfo[race][class_];
342 }
343 }
344
345 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
346 itr->second.Clear();
347
348 for (DungeonEncounterContainer::iterator itr = _dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr)
349 for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr)
350 delete *encounterItr;
351
352 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
353 {
354 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
355 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
356 {
357 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
358 {
359 delete* questItr;
360 }
361
362 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
363 {
364 delete* achievementItr;
365 }
366
367 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
368 {
369 delete* itemsItr;
370 }
371
372 delete difficultiesItr->second;
373 }
374 }
375}
#define sRaceMgr
Definition RaceMgr.h:52
std::vector< std::vector< PlayerInfo * > > _playerInfo
Definition ObjectMgr.h:1626
PetLevelInfoContainer _petInfoStore
Definition ObjectMgr.h:1620
QuestMap _questTemplates
Definition ObjectMgr.h:1550
DungeonProgressionRequirementsContainer _accessRequirementStore
Definition ObjectMgr.h:1564
DungeonEncounterContainer _dungeonEncounterStore
Definition ObjectMgr.h:1565
CacheVendorItemContainer _cacheVendorItemStore
Definition ObjectMgr.h:1690
PlayerClassLevelInfo * levelInfo
Definition Player.h:286

References _accessRequirementStore, _cacheVendorItemStore, _dungeonEncounterStore, _petInfoStore, _playerClassInfo, _playerInfo, _questTemplates, PlayerClassInfo::levelInfo, MAX_CLASSES, and sRaceMgr.

Member Function Documentation

◆ AddCreatureToGrid()

void ObjectMgr::AddCreatureToGrid ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)
2718{
2719 uint8 mask = data->spawnMask;
2720 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2721 {
2722 if (mask & 1)
2723 {
2724 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2725 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2726 cell_guids.creatures.insert(guid);
2727 }
2728 }
2729}
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition ObjectDefines.h:88
MapObjectGuids _mapObjectGuidsStore
Definition ObjectMgr.h:1647
GridCoord ComputeGridCoord(float x, float y)
Definition GridDefines.h:185
Definition ObjectMgr.h:479
CellGuidSet creatures
Definition ObjectMgr.h:480
Definition GridDefines.h:88
uint32 GetId() const
Definition GridDefines.h:150

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

Referenced by AddCreData(), and LoadCreatures().

◆ AddCreData()

ObjectGuid::LowType ObjectMgr::AddCreData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0 
)
2799{
2800 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2801 if (!cInfo)
2802 return 0;
2803
2804 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2805 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2806 Map* map = sMapMgr->CreateBaseMap(mapId);
2807 if (!map)
2808 return 0;
2809
2811 CreatureData& data = NewOrExistCreatureData(spawnId);
2812 data.spawnId = spawnId;
2813 data.spawnMask = spawnId;
2814 data.id1 = entry;
2815 data.id2 = 0;
2816 data.id3 = 0;
2817 data.mapid = mapId;
2818 data.displayid = 0;
2819 data.equipmentId = 0;
2820 data.posX = x;
2821 data.posY = y;
2822 data.posZ = z;
2823 data.orientation = o;
2824 data.spawntimesecs = spawntimedelay;
2825 data.wander_distance = 0;
2826 data.currentwaypoint = 0;
2827 data.curhealth = stats->GenerateHealth(cInfo);
2828 data.curmana = stats->GenerateMana(cInfo);
2829 data.movementType = cInfo->MovementType;
2830 data.spawnMask = 1;
2832 data.dbData = false;
2833 data.npcflag = cInfo->npcflag;
2834 data.unit_flags = cInfo->unit_flags;
2835 data.dynamicflags = cInfo->dynamicflags;
2836
2837 AddCreatureToGrid(spawnId, &data);
2838
2839 // Spawn if necessary (loaded grids only)
2840 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2841 {
2842 Creature* creature = new Creature();
2843 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
2844 {
2845 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2846 delete creature;
2847 return 0;
2848 }
2849 }
2850
2851 return spawnId;
2852}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define sMapMgr
Definition MapMgr.h:220
@ PHASEMASK_NORMAL
Definition Object.h:63
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
Definition Creature.h:47
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition Creature.cpp:1674
Definition Map.h:166
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:203
bool Instanceable() const
Definition Map.h:296
uint32 LowType
Definition ObjectGuid.h:122
CreatureBaseStats const * GetCreatureBaseStats(uint8 level, uint8 unitClass)
Definition ObjectMgr.cpp:10639
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2717
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition ObjectMgr.cpp:7711
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition ObjectMgr.h:1244
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition ObjectMgr.cpp:11004
Definition CreatureData.h:298
uint32 GenerateMana(CreatureTemplate const *info) const
Definition CreatureData.h:318
uint32 GenerateHealth(CreatureTemplate const *info) const
Definition CreatureData.h:313
Definition CreatureData.h:370
float wander_distance
Definition CreatureData.h:378
uint32 spawntimesecs
Definition CreatureData.h:377
uint32 dynamicflags
Definition CreatureData.h:385
uint32 npcflag
Definition CreatureData.h:383
uint32 displayid
Definition CreatureData.h:375
uint8 movementType
Definition CreatureData.h:382
uint32 unit_flags
Definition CreatureData.h:384
uint32 id2
Definition CreatureData.h:373
uint32 curhealth
Definition CreatureData.h:380
uint32 curmana
Definition CreatureData.h:381
uint32 id3
Definition CreatureData.h:374
int8 equipmentId
Definition CreatureData.h:376
uint32 currentwaypoint
Definition CreatureData.h:379
uint32 id1
Definition CreatureData.h:372
Definition CreatureData.h:187
uint32 unit_flags
Definition CreatureData.h:214
uint8 minlevel
Definition CreatureData.h:196
uint8 maxlevel
Definition CreatureData.h:197
uint32 MovementType
Definition CreatureData.h:230
uint32 npcflag
Definition CreatureData.h:200
uint32 unit_class
Definition CreatureData.h:213
uint32 dynamicflags
Definition CreatureData.h:216
float posX
Definition SpawnData.h:71
float posY
Definition SpawnData.h:72
uint32 phaseMask
Definition SpawnData.h:70
uint8 spawnMask
Definition SpawnData.h:75
bool dbData
Definition SpawnData.h:77
ObjectGuid::LowType spawnId
Definition SpawnData.h:68
float orientation
Definition SpawnData.h:74
uint16 mapid
Definition SpawnData.h:69
float posZ
Definition SpawnData.h:73

References AddCreatureToGrid(), CreatureData::curhealth, CreatureData::curmana, CreatureData::currentwaypoint, SpawnData::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::IsGridLoaded(), Creature::LoadCreatureFromDB(), LOG_ERROR, SpawnData::mapid, CreatureTemplate::maxlevel, CreatureTemplate::minlevel, CreatureTemplate::MovementType, CreatureData::movementType, NewOrExistCreatureData(), CreatureTemplate::npcflag, CreatureData::npcflag, SpawnData::orientation, SpawnData::phaseMask, PHASEMASK_NORMAL, SpawnData::posX, SpawnData::posY, SpawnData::posZ, sMapMgr, SpawnData::spawnId, SpawnData::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 
)
3170{
3171 uint8 mask = data->spawnMask;
3172 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
3173 {
3174 if (mask & 1)
3175 {
3176 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
3177 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
3178 cell_guids.gameobjects.insert(guid);
3179 }
3180 }
3181}
CellGuidSet gameobjects
Definition ObjectMgr.h:481

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

Referenced by AddGOData(), and LoadGameobjects().

◆ AddGameTele()

bool ObjectMgr::AddGameTele ( GameTele data)
9809{
9810 // find max id
9811 uint32 new_id = 0;
9812 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9813 if (itr->first > new_id)
9814 new_id = itr->first;
9815
9816 // use next
9817 ++new_id;
9818
9819 if (!Utf8toWStr(tele.name, tele.wnameLow))
9820 return false;
9821
9822 wstrToLower(tele.wnameLow);
9823
9824 _gameTeleStore[new_id] = tele;
9825
9827
9828 stmt->SetData(0, new_id);
9829 stmt->SetData(1, tele.position_x);
9830 stmt->SetData(2, tele.position_y);
9831 stmt->SetData(3, tele.position_z);
9832 stmt->SetData(4, tele.orientation);
9833 stmt->SetData(5, uint16(tele.mapId));
9834 stmt->SetData(6, tele.name);
9835
9836 WorldDatabase.Execute(stmt);
9837
9838 return true;
9839}
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint16_t uint16
Definition Define.h:108
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
@ WORLD_INS_GAME_TELE
Definition WorldDatabase.h:41
GameTeleContainer _gameTeleStore
Definition ObjectMgr.h:1590
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

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()

ObjectGuid::LowType 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 
)
2746{
2747 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2748 if (!goinfo)
2749 return 0;
2750
2751 Map* map = sMapMgr->CreateBaseMap(mapId);
2752 if (!map)
2753 return 0;
2754
2756
2757 GameObjectData& data = NewGOData(spawnId);
2758 data.spawnId = spawnId;
2759 data.id = entry;
2760 data.mapid = mapId;
2761 data.posX = x;
2762 data.posY = y;
2763 data.posZ = z;
2764 data.orientation = o;
2765 data.rotation.x = rotation0;
2766 data.rotation.y = rotation1;
2767 data.rotation.z = rotation2;
2768 data.rotation.w = rotation3;
2769 data.spawntimesecs = spawntimedelay;
2770 data.animprogress = 100;
2771 data.spawnMask = 1;
2772 data.go_state = GO_STATE_READY;
2774 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2775 data.dbData = false;
2776 data.spawnGroupId = 0;
2777
2778 AddGameobjectToGrid(spawnId, &data);
2779
2780 // Spawn if necessary (loaded grids only)
2781 // We use spawn coords to spawn
2782 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2783 {
2785 if (!go->LoadGameObjectFromDB(spawnId, map))
2786 {
2787 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2788 delete go;
2789 return 0;
2790 }
2791 }
2792
2793 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2794
2795 return spawnId;
2796}
@ GO_STATE_READY
Definition GameObjectData.h:709
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition SharedDefines.h:1593
Definition GameObject.h:120
virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition GameObject.cpp:1099
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:3169
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition ObjectMgr.cpp:10980
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition ObjectMgr.cpp:7721
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition ObjectMgr.h:1359
bool IsGameObjectStaticTransport(uint32 entry)
Definition ObjectMgr.cpp:10989
Definition Transport.h:115
Definition GameObjectData.h:715
uint8 artKit
Definition GameObjectData.h:722
int32 spawntimesecs
Definition GameObjectData.h:719
G3D::Quat rotation
Definition GameObjectData.h:718
uint32 animprogress
Definition GameObjectData.h:720
uint32 id
Definition GameObjectData.h:717
GOState go_state
Definition GameObjectData.h:721
Definition GameObjectData.h:32
uint32 type
Definition GameObjectData.h:34
uint32 spawnGroupId
Definition SpawnData.h:78

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

◆ AddLocaleString()

◆ AddProfanityPlayerName()

void ObjectMgr::AddProfanityPlayerName ( std::string const &  name)
9176{
9177 if (!IsProfanityName(name))
9178 {
9179 std::wstring wstr;
9180 if (!Utf8toWStr(name, wstr))
9181 {
9182 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
9183 return;
9184 }
9185 wstrToLower(wstr);
9186
9187 _profanityNamesStore.insert(wstr);
9188
9190 stmt->SetData(0, name);
9191 CharacterDatabase.Execute(stmt);
9192 }
9193}
@ CHAR_INS_PROFANITY_PLAYER_NAME
Definition CharacterDatabase.h:523
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
ProfanityNamesContainer _profanityNamesStore
Definition ObjectMgr.h:1588
bool IsProfanityName(std::string_view name) const
Definition ObjectMgr.cpp:9160

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

◆ AddReservedPlayerName()

void ObjectMgr::AddReservedPlayerName ( std::string const &  name)
9073{
9074 if (!IsReservedName(name))
9075 {
9076 std::wstring wstr;
9077 if (!Utf8toWStr(name, wstr))
9078 {
9079 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
9080 return;
9081 }
9082 wstrToLower(wstr);
9083
9084 _reservedNamesStore.insert(wstr);
9085
9087 stmt->SetData(0, name);
9088 CharacterDatabase.Execute(stmt);
9089 }
9090}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition CharacterDatabase.h:522
bool IsReservedName(std::string_view name) const
Definition ObjectMgr.cpp:9057
ReservedNamesContainer _reservedNamesStore
Definition ObjectMgr.h:1584

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

◆ AddVendorItem()

void ObjectMgr::AddVendorItem ( uint32  entry,
uint32  item,
uint32  maxcount,
uint32  incrtime,
uint32  extendedCost,
bool  persist = true 
)
10317{
10318 VendorItemData& vList = _cacheVendorItemStore[entry];
10319 vList.AddItem(item, maxcount, incrtime, extendedCost);
10320
10321 if (persist)
10322 {
10324
10325 stmt->SetData(0, entry);
10326 stmt->SetData(1, item);
10327 stmt->SetData(2, maxcount);
10328 stmt->SetData(3, incrtime);
10329 stmt->SetData(4, extendedCost);
10330
10331 WorldDatabase.Execute(stmt);
10332 }
10333}
@ WORLD_INS_NPC_VENDOR
Definition WorldDatabase.h:43
Definition CreatureData.h:460
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition CreatureData.h:472

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
4938{
4939 // base data (last known level)
4940 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
4941
4942 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
4943 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
4944 {
4945 switch (_class)
4946 {
4947 case CLASS_WARRIOR:
4948 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4949 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4950 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4951 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4952 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4953 break;
4954 case CLASS_PALADIN:
4955 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
4956 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4957 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
4958 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
4959 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
4960 break;
4961 case CLASS_HUNTER:
4962 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
4963 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4964 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4965 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
4966 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4967 break;
4968 case CLASS_ROGUE:
4969 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
4970 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4971 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
4972 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
4973 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4974 break;
4975 case CLASS_PRIEST:
4976 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4977 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4978 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4979 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
4980 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
4981 break;
4982 case CLASS_SHAMAN:
4983 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4984 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4985 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
4986 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
4987 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
4988 break;
4989 case CLASS_MAGE:
4990 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4991 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4992 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4993 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
4994 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4995 break;
4996 case CLASS_WARLOCK:
4997 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4998 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4999 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5000 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
5001 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
5002 break;
5003 case CLASS_DRUID:
5004 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
5005 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
5006 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
5007 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
5008 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
5009 }
5010 }
5011}
@ CLASS_HUNTER
Definition SharedDefines.h:128
@ CLASS_DRUID
Definition SharedDefines.h:136
@ CLASS_SHAMAN
Definition SharedDefines.h:132
@ CLASS_PRIEST
Definition SharedDefines.h:130
@ CLASS_WARRIOR
Definition SharedDefines.h:126
@ CLASS_WARLOCK
Definition SharedDefines.h:134
@ CLASS_MAGE
Definition SharedDefines.h:133
@ CLASS_PALADIN
Definition SharedDefines.h:127
@ CLASS_ROGUE
Definition SharedDefines.h:129
@ STAT_SPIRIT
Definition SharedDefines.h:250
@ STAT_INTELLECT
Definition SharedDefines.h:249
@ STAT_AGILITY
Definition SharedDefines.h:247
@ STAT_STRENGTH
Definition SharedDefines.h:246
@ STAT_STAMINA
Definition SharedDefines.h:248
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:194
#define sWorld
Definition World.h:316

References _playerInfo, CLASS_DRUID, CLASS_HUNTER, CLASS_MAGE, CLASS_PALADIN, CLASS_PRIEST, CLASS_ROGUE, CLASS_SHAMAN, CLASS_WARLOCK, CLASS_WARRIOR, CONFIG_MAX_PLAYER_LEVEL, 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 
)
9628{
9629 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
9630 if (!fArea)
9631 {
9632 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
9633 return;
9634 }
9635
9636 _fishingBaseForAreaStore[entry] = skill;
9637
9638 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
9639 LOG_INFO("server.loading", " ");
9640}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define LOG_INFO(filterType__,...)
Definition Log.h:153
FishingBaseSkillContainer _fishingBaseForAreaStore
Definition ObjectMgr.h:1635
Definition DBCStructure.h:519

References _fishingBaseForAreaStore, LOG_ERROR, LOG_INFO, and sAreaTableStore.

◆ CheckCreatureMovement()

void ObjectMgr::CheckCreatureMovement ( char const *  table,
uint64  id,
CreatureMovementData creatureMovement 
)
1236{
1237 if (creatureMovement.Ground >= CreatureGroundMovementType::Max)
1238 {
1239 LOG_ERROR("sql.sql", "`{}`.`Ground` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Ground), id);
1240 creatureMovement.Ground = CreatureGroundMovementType::Run;
1241 }
1242
1243 if (creatureMovement.Flight >= CreatureFlightMovementType::Max)
1244 {
1245 LOG_ERROR("sql.sql", "`{}`.`Flight` wrong value ({}) for Id {}, setting to None.", table, uint32(creatureMovement.Flight), id);
1246 creatureMovement.Flight = CreatureFlightMovementType::None;
1247 }
1248
1249 if (creatureMovement.Chase >= CreatureChaseMovementType::Max)
1250 {
1251 LOG_ERROR("sql.sql", "`{}`.`Chase` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Chase), id);
1252 creatureMovement.Chase = CreatureChaseMovementType::Run;
1253 }
1254
1255 if (creatureMovement.Random >= CreatureRandomMovementType::Max)
1256 {
1257 LOG_ERROR("sql.sql", "`{}`.`Random` wrong value ({}) for Id {}, setting to Walk.", table, uint32(creatureMovement.Random), id);
1258 creatureMovement.Random = CreatureRandomMovementType::Walk;
1259 }
1260}
CreatureRandomMovementType Random
Definition CreatureData.h:128
CreatureFlightMovementType Flight
Definition CreatureData.h:124
CreatureChaseMovementType Chase
Definition CreatureData.h:127
CreatureGroundMovementType Ground
Definition CreatureData.h:123

References CreatureMovementData::Chase, CreatureMovementData::Flight, CreatureMovementData::Ground, LOG_ERROR, Max, None, CreatureMovementData::Random, Run, and Walk.

Referenced by CheckCreatureTemplate(), and LoadCreatureMovementOverrides().

◆ CheckCreatureTemplate()

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

References _creatureCustomIDsStore, _difficultyEntries, Creature::_GetDamageMod(), _hasDifficultyEntries, CreatureTemplate::AIName, BASE_ATTACK_TIME, CreatureTemplate::BaseAttackTime, CheckCreatureMovement(), CLASS_WARRIOR, CLASSMASK_ALL_CREATURES, CREATURE_FAMILY_NOT_SPECIFIED, 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_DEBUG, LOG_ERROR, LOG_INFO, MAX_CREATURE_SPELLS, MAX_DB_MOTION_TYPE, MAX_DIFFICULTY, MAX_EXPANSIONS, MAX_KILL_CREDIT, MAX_SPELL_SCHOOL, CreatureTemplate::Models, CreatureTemplate::Movement, CreatureTemplate::MovementType, CreatureTemplate::npcflag, CreatureTemplate::PetSpellDataId, CreatureModel::Probability, 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::type, CreatureTemplate::unit_class, UNIT_NPC_FLAG_GOSSIP, and CreatureTemplate::VehicleId.

Referenced by LoadCreatureTemplates().

◆ CheckDeclinedNames()

bool ObjectMgr::CheckDeclinedNames ( std::wstring  w_ownname,
DeclinedName const &  names 
)
static
9643{
9644 // get main part of the name
9645 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
9646 // prepare flags
9647 bool x = true;
9648 bool y = true;
9649
9650 // check declined names
9651 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
9652 {
9653 std::wstring wname;
9654 if (!Utf8toWStr(names.name[i], wname))
9655 return false;
9656
9657 if (mainpart != GetMainPartOfName(wname, i + 1))
9658 x = false;
9659
9660 if (w_ownname != wname)
9661 y = false;
9662 }
9663 return (x || y);
9664}
#define MAX_DECLINED_NAME_CASES
Definition Unit.h:546
std::wstring GetMainPartOfName(std::wstring const &wname, uint32_t declension)
Definition Util.cpp:386

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
9348{
9349 std::wstring wname;
9350 if (!Utf8toWStr(name, wname))
9351 return PET_NAME_INVALID;
9352
9353 if (wname.size() > MAX_PET_NAME)
9354 return PET_NAME_TOO_LONG;
9355
9356 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
9357 if (wname.size() < minName)
9358 return PET_NAME_TOO_SHORT;
9359
9360 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
9361 if (!isValidString(wname, strictMask, false))
9363
9364 // Check Reserved Name
9365 if (sObjectMgr->IsReservedName(name))
9366 return PET_NAME_RESERVED;
9367
9368 // Check Profanity Name
9369 if (sObjectMgr->IsProfanityName(name))
9370 return PET_NAME_PROFANE;
9371
9372 return PET_NAME_SUCCESS;
9373}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition ObjectMgr.cpp:9232
#define sObjectMgr
Definition ObjectMgr.h:1723
#define MAX_PET_NAME
Definition ObjectMgr.h:687
@ PET_NAME_INVALID
Definition SharedDefines.h:3916
@ PET_NAME_RESERVED
Definition SharedDefines.h:3922
@ PET_NAME_SUCCESS
Definition SharedDefines.h:3914
@ PET_NAME_MIXED_LANGUAGES
Definition SharedDefines.h:3920
@ PET_NAME_TOO_SHORT
Definition SharedDefines.h:3918
@ PET_NAME_TOO_LONG
Definition SharedDefines.h:3919
@ PET_NAME_PROFANE
Definition SharedDefines.h:3921
@ CONFIG_STRICT_PET_NAMES
Definition WorldConfig.h:181
@ CONFIG_MIN_PET_NAME
Definition WorldConfig.h:184

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
9269{
9270 std::wstring wname;
9271
9272 // Check for invalid characters
9273 if (!Utf8toWStr(name, wname))
9275
9276 // Check for too long name
9277 if (wname.size() > MAX_PLAYER_NAME)
9278 return CHAR_NAME_TOO_LONG;
9279
9280 // Check for too short name
9281 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
9282 if (wname.size() < minName)
9283 return CHAR_NAME_TOO_SHORT;
9284
9285 // Check for mixed languages
9286 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
9287 if (!isValidString(wname, strictMask, false, create))
9289
9290 // Check for three consecutive letters
9291 wstrToLower(wname);
9292 for (std::size_t i = 2; i < wname.size(); ++i)
9293 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
9295
9296 // Check Reserved Name
9297 if (sObjectMgr->IsReservedName(name))
9298 return CHAR_NAME_RESERVED;
9299
9300 // Check Profanity Name
9301 if (sObjectMgr->IsProfanityName(name))
9302 return CHAR_NAME_PROFANE;
9303
9304 return CHAR_NAME_SUCCESS;
9305}
#define MAX_PLAYER_NAME
Definition ObjectMgr.h:685
@ CHAR_NAME_TOO_SHORT
Definition SharedDefines.h:3671
@ CHAR_NAME_THREE_CONSECUTIVE
Definition SharedDefines.h:3679
@ CHAR_NAME_INVALID_CHARACTER
Definition SharedDefines.h:3673
@ CHAR_NAME_TOO_LONG
Definition SharedDefines.h:3672
@ CHAR_NAME_RESERVED
Definition SharedDefines.h:3676
@ CHAR_NAME_MIXED_LANGUAGES
Definition SharedDefines.h:3674
@ CHAR_NAME_PROFANE
Definition SharedDefines.h:3675
@ CHAR_NAME_SUCCESS
Definition SharedDefines.h:3668
@ CONFIG_STRICT_PLAYER_NAMES
Definition WorldConfig.h:178
@ CONFIG_MIN_PLAYER_NAME
Definition WorldConfig.h:182

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
1660{
1661 npcflag = cinfo->npcflag;
1662 unit_flags = cinfo->unit_flags;
1663 dynamicflags = cinfo->dynamicflags;
1664
1665 if (data)
1666 {
1667 if (data->npcflag)
1668 npcflag = data->npcflag;
1669
1670 if (data->unit_flags)
1671 unit_flags = data->unit_flags;
1672
1673 if (data->dynamicflags)
1674 dynamicflags = data->dynamicflags;
1675 }
1676}

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
1645{
1646 // Load creature model (display id)
1647 if (data && data->displayid)
1648 if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid))
1649 return model;
1650
1651 if (!cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER))
1652 if (CreatureModel const* model = cinfo->GetRandomValidModel())
1653 return model;
1654
1655 // Triggers by default receive the invisible model
1656 return cinfo->GetFirstInvisibleModel();
1657}
@ CREATURE_FLAG_EXTRA_TRIGGER
Definition CreatureData.h:53

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

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)
8689{
8690 // remove mapid*cellid -> guid_set map
8691 CreatureData const* data = GetCreatureData(guid);
8692 if (data)
8693 RemoveCreatureFromGrid(guid, data);
8694
8695 _creatureDataStore.erase(guid);
8696}
CreatureDataContainer _creatureDataStore
Definition ObjectMgr.h:1650
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2731
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1235

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

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
9842{
9843 // explicit name case
9844 std::wstring wname;
9845 if (!Utf8toWStr(name, wname))
9846 return false;
9847
9848 // converting string that we try to find to lower case
9849 wstrToLower(wname);
9850
9851 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9852 {
9853 if (itr->second.wnameLow == wname)
9854 {
9856
9857 stmt->SetData(0, itr->second.name);
9858
9859 WorldDatabase.Execute(stmt);
9860
9861 _gameTeleStore.erase(itr);
9862 return true;
9863 }
9864 }
9865
9866 return false;
9867}
@ 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)
8699{
8700 // remove mapid*cellid -> guid_set map
8701 GameObjectData const* data = GetGameObjectData(guid);
8702 if (data)
8703 RemoveGameobjectFromGrid(guid, data);
8704
8705 _gameObjectDataStore.erase(guid);
8706}
GameObjectData const * GetGameObjectData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1270
GameObjectDataContainer _gameObjectDataStore
Definition ObjectMgr.h:1664
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:3183

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

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
7681{
7682 if (_auctionId >= 0xFFFFFFFE)
7683 {
7684 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
7686 }
7687 return _auctionId++;
7688}
static void StopNow(uint8 exitcode)
Definition World.h:188
@ ERROR_EXIT_CODE
Definition World.h:54

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

◆ GenerateCreatureSpawnId()

uint32 ObjectMgr::GenerateCreatureSpawnId ( )
7712{
7713 if (_creatureSpawnId >= uint32(0xFFFFFF))
7714 {
7715 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7717 }
7718 return _creatureSpawnId++;
7719}

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

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
7691{
7692 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
7693 {
7694 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
7696 }
7697 return _equipmentSetGuid++;
7698}
std::uint64_t uint64
Definition Define.h:106

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

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7722{
7723 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7724 {
7725 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7727 }
7728 return _gameObjectSpawnId++;
7729}

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

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
7701{
7702 if (_mailId >= 0xFFFFFFFE)
7703 {
7704 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
7706 }
7707 std::lock_guard<std::mutex> guard(_mailIdMutex);
7708 return _mailId++;
7709}
std::mutex _mailIdMutex
Definition ObjectMgr.h:1530

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

◆ GeneratePetName()

std::string ObjectMgr::GeneratePetName ( uint32  entry)
8188{
8189 std::vector<std::string>& list0 = _petHalfName0[entry];
8190 std::vector<std::string>& list1 = _petHalfName1[entry];
8191
8192 if (list0.empty() || list1.empty())
8193 {
8194 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
8195 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
8196 if (!petname)
8197 return cinfo->Name;
8198
8199 return std::string(petname);
8200 }
8201
8202 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
8203}
char const * GetPetName(uint32 petfamily, uint32 dbclang)
Definition DBCStores.cpp:665
HalfNameContainer _petHalfName1
Definition ObjectMgr.h:1639
HalfNameContainer _petHalfName0
Definition ObjectMgr.h:1638
std::string Name
Definition CreatureData.h:192

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

Referenced by GeneratePetNameLocale().

◆ GeneratePetNameLocale()

std::string ObjectMgr::GeneratePetNameLocale ( uint32  entry,
LocaleConstant  locale 
)
8175{
8176 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
8177 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
8178
8179 if (list0.empty() || list1.empty())
8180 {
8181 return GeneratePetName(entry);
8182 }
8183
8184 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
8185}
HalfNameContainerLocale _petHalfLocaleName0
Definition ObjectMgr.h:1641
HalfNameContainerLocale _petHalfLocaleName1
Definition ObjectMgr.h:1642
std::string GeneratePetName(uint32 entry)
Definition ObjectMgr.cpp:8187

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

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
8206{
8207 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
8208 return ++_hiPetNumber;
8209}
std::mutex _hiPetNumberMutex
Definition ObjectMgr.h:1532

References _hiPetNumber, and _hiPetNumberMutex.

◆ GetAccessRequirement()

DungeonProgressionRequirements const * ObjectMgr::GetAccessRequirement ( uint32  mapid,
Difficulty  difficulty 
) const
inline
883 {
884 DungeonProgressionRequirementsContainer::const_iterator itr = _accessRequirementStore.find(mapid);
885 if (itr != _accessRequirementStore.end())
886 {
887 std::unordered_map<uint8, DungeonProgressionRequirements*> difficultiesProgressionRequirements = itr->second;
888 auto difficultiesItr = difficultiesProgressionRequirements.find(difficulty);
889 if (difficultiesItr != difficultiesProgressionRequirements.end())
890 {
891 return difficultiesItr->second;
892 }
893 }
894 return nullptr;
895 }

References _accessRequirementStore.

◆ GetAcoreString() [1/2]

AcoreString const * ObjectMgr::GetAcoreString ( uint32  entry) const
inline
1389 {
1390 AcoreStringContainer::const_iterator itr = _acoreStringStore.find(entry);
1391 if (itr == _acoreStringStore.end())
1392 return nullptr;
1393
1394 return &itr->second;
1395 }
AcoreStringContainer _acoreStringStore
Definition ObjectMgr.h:1686

References _acoreStringStore.

Referenced by GetAcoreString(), and GetAcoreStringForDBCLocale().

◆ GetAcoreString() [2/2]

std::string ObjectMgr::GetAcoreString ( uint32  entry,
LocaleConstant  locale 
) const
9574{
9575 AcoreString const* as = GetAcoreString(entry);
9576 if (as && !as->Content.empty())
9577 {
9578 if (as->Content.size() > std::size_t(locale) && !as->Content[locale].empty())
9579 return as->Content[locale];
9580
9581 return as->Content[DEFAULT_LOCALE];
9582 }
9583
9584 std::string msg = Acore::StringFormat("No entry for acore_string ({}) in DB.", entry);
9585 LOG_ERROR("sql.sql", msg);
9586 return msg;
9587}
#define DEFAULT_LOCALE
Definition Common.h:131
AcoreString const * GetAcoreString(uint32 entry) const
Definition ObjectMgr.h:1388
std::string StringFormat(FormatStringView fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:44
Definition ObjectMgr.h:502
std::vector< std::string > Content
Definition ObjectMgr.h:503

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

◆ GetAcoreStringForDBCLocale()

std::string ObjectMgr::GetAcoreStringForDBCLocale ( uint32  entry) const
inline
1397{ return GetAcoreString(entry, DBCLocaleIndex); }

References DBCLocaleIndex, and GetAcoreString().

◆ GetAllAreaTriggerScriptData()

AreaTriggerScriptContainer const & ObjectMgr::GetAllAreaTriggerScriptData ( ) const
inline
900{ return _areaTriggerScriptStore; }
AreaTriggerScriptContainer _areaTriggerScriptStore
Definition ObjectMgr.h:1563

References _areaTriggerScriptStore.

◆ GetAllCreatureData()

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

References _creatureDataStore.

◆ GetAllGOData()

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

References _gameObjectDataStore.

◆ GetAreaTrigger()

AreaTrigger const * ObjectMgr::GetAreaTrigger ( uint32  trigger) const
inline
867 {
868 AreaTriggerContainer::const_iterator itr = _areaTriggerStore.find(trigger);
869 if (itr != _areaTriggerStore.end())
870 return &itr->second;
871 return nullptr;
872 }
AreaTriggerContainer _areaTriggerStore
Definition ObjectMgr.h:1561

References _areaTriggerStore.

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

◆ GetAreaTriggerScriptId()

uint32 ObjectMgr::GetAreaTriggerScriptId ( uint32  trigger_id)
9667{
9668 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
9669 if (i != _areaTriggerScriptStore.end())
9670 return i->second;
9671 return 0;
9672}

References _areaTriggerScriptStore.

◆ GetAreaTriggerTeleport()

AreaTriggerTeleport const * ObjectMgr::GetAreaTriggerTeleport ( uint32  trigger) const
inline
875 {
876 AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.find(trigger);
877 if (itr != _areaTriggerTeleportStore.end())
878 return &itr->second;
879 return nullptr;
880 }
AreaTriggerTeleportContainer _areaTriggerTeleportStore
Definition ObjectMgr.h:1562

References _areaTriggerTeleportStore.

◆ GetBaseReputationOf()

int32 ObjectMgr::GetBaseReputationOf ( FactionEntry const *  factionEntry,
uint8  race,
uint8  playerClass 
)
9681{
9682 if (!factionEntry)
9683 return 0;
9684
9685 uint32 raceMask = (1 << (race - 1));
9686 uint32 classMask = (1 << (playerClass - 1));
9687
9688 for (int i = 0; i < 4; i++)
9689 {
9690 if ((!factionEntry->BaseRepClassMask[i] ||
9691 factionEntry->BaseRepClassMask[i] & classMask) &&
9692 (!factionEntry->BaseRepRaceMask[i] ||
9693 factionEntry->BaseRepRaceMask[i] & raceMask))
9694 return factionEntry->BaseRepValue[i];
9695 }
9696
9697 return 0;
9698}

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

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
8116{
8117 return _baseXPTable[level] ? _baseXPTable[level] : 0;
8118}
BaseXPContainer _baseXPTable
Definition ObjectMgr.h:1632

References _baseXPTable.

◆ GetBreadcrumbsForQuest()

std::vector< uint32 > const * ObjectMgr::GetBreadcrumbsForQuest ( uint32  questId) const
inline
1159 {
1160 auto itr = _breadcrumbsForQuest.find(questId);
1161 if (itr != _breadcrumbsForQuest.end())
1162 return &itr->second;
1163
1164 return nullptr;
1165 }
BreadcrumbQuestMap _breadcrumbsForQuest
Definition ObjectMgr.h:1156

References _breadcrumbsForQuest.

◆ GetBroadcastText()

BroadcastText const * ObjectMgr::GetBroadcastText ( uint32  id) const
inline
1228 {
1229 BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id);
1230 if (itr != _broadcastTextStore.end())
1231 return &itr->second;
1232 return nullptr;
1233 }
BroadcastTextContainer _broadcastTextStore
Definition ObjectMgr.h:1675

References _broadcastTextStore.

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

◆ GetClassTrainers()

std::vector< Trainer::Trainer const * > const & ObjectMgr::GetClassTrainers ( uint8  classId) const
inline
1441{ return _classTrainers.at(classId); }
std::unordered_map< uint8, std::vector< Trainer::Trainer const * > > _classTrainers
Definition ObjectMgr.h:1692

References _classTrainers.

◆ GetCreatureAddon()

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

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
10640{
10641 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
10642
10643 if (it != _creatureBaseStatsStore.end())
10644 return &(it->second);
10645
10646 struct DefaultCreatureBaseStats : public CreatureBaseStats
10647 {
10648 DefaultCreatureBaseStats()
10649 {
10650 BaseArmor = 1;
10651 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
10652 {
10653 BaseHealth[j] = 1;
10654 BaseDamage[j] = 0.0f;
10655 }
10656 BaseMana = 0;
10657 AttackPower = 0;
10658 RangedAttackPower = 0;
10659 Strength = 0;
10660 Agility = 0;
10661 Stamina = 0;
10662 Intellect = 0;
10663 Spirit = 0;
10664 }
10665 };
10666 static const DefaultCreatureBaseStats defStats;
10667 return &defStats;
10668}
uint16 MAKE_PAIR16(uint8 l, uint8 h)
Definition ObjectDefines.h:83
CreatureBaseStatsContainer _creatureBaseStatsStore
Definition ObjectMgr.h:1616

References _creatureBaseStatsStore, MAKE_PAIR16(), and MAX_EXPANSIONS.

Referenced by AddCreData().

◆ GetCreatureData()

CreatureData const * ObjectMgr::GetCreatureData ( ObjectGuid::LowType  spawnId) const
inline
1236 {
1237 CreatureDataContainer::const_iterator itr = _creatureDataStore.find(spawnId);
1238 if (itr == _creatureDataStore.end()) return nullptr;
1239 return &itr->second;
1240 }

References _creatureDataStore.

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

◆ GetCreatureLocale()

CreatureLocale const * ObjectMgr::GetCreatureLocale ( uint32  entry) const
inline
1292 {
1293 CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry);
1294 if (itr == _creatureLocaleStore.end()) return nullptr;
1295 return &itr->second;
1296 }
CreatureLocaleContainer _creatureLocaleStore
Definition ObjectMgr.h:1663

References _creatureLocaleStore.

◆ GetCreatureModelInfo()

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

References _creatureModelStore.

Referenced by GetCreatureModelRandomGender(), and LoadCreatureTemplateModels().

◆ GetCreatureModelRandomGender()

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

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
1450{
1452}
std::unordered_map< ObjectGuid::LowType, CreatureMovementData > _creatureMovementOverrides
Definition ObjectMgr.h:1657
auto MapGetValuePtr(M &map, typename M::key_type const &key) -> decltype(AddressOrSelf(map.find(key) ->second))
Definition Containers.h:216

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

◆ GetCreatureQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestInvolvedRelationBounds ( uint32  creature_entry)
inline
1012 {
1013 return _creatureQuestInvolvedRelations.equal_range(creature_entry);
1014 }
QuestRelations _creatureQuestInvolvedRelations
Definition ObjectMgr.h:1580

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestInvolvedRelationMap ( )
inline
1002 {
1004 }

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestItemList()

CreatureQuestItemList const * ObjectMgr::GetCreatureQuestItemList ( uint32  id) const
inline
830 {
831 CreatureQuestItemMap::const_iterator itr = _creatureQuestItemStore.find(id);
832 if (itr != _creatureQuestItemStore.end())
833 return &itr->second;
834 return nullptr;
835 }
CreatureQuestItemMap _creatureQuestItemStore
Definition ObjectMgr.h:1660

References _creatureQuestItemStore.

◆ GetCreatureQuestItemMap()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestRelationBounds ( uint32  creature_entry)
inline
1007 {
1008 return _creatureQuestRelations.equal_range(creature_entry);
1009 }
QuestRelations _creatureQuestRelations
Definition ObjectMgr.h:1579

References _creatureQuestRelations.

◆ GetCreatureQuestRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestRelationMap ( )
inline
997 {
999 }

References _creatureQuestRelations.

◆ GetCreatureTemplate()

◆ GetCreatureTemplateAddon()

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

References _creatureTemplateAddonStore.

◆ GetCreatureTemplates()

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

References _creatureTemplateStore.

Referenced by LoadCreatureClassLevelStats(), and LoadNPCSpellClickSpells().

◆ GetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ GetDefaultSpawnGroup()

SpawnGroupTemplateData const * ObjectMgr::GetDefaultSpawnGroup ( ) const
inline
1283{ return &_spawnGroupDataStore.at(0); }

References _spawnGroupDataStore.

◆ GetDungeonEncounterList()

DungeonEncounterList const * ObjectMgr::GetDungeonEncounterList ( uint32  mapId,
Difficulty  difficulty 
)
inline
951 {
952 std::unordered_map<uint32, DungeonEncounterList>::const_iterator itr = _dungeonEncounterStore.find(MAKE_PAIR32(mapId, difficulty));
953 if (itr != _dungeonEncounterStore.end())
954 return &itr->second;
955 return nullptr;
956 }

References _dungeonEncounterStore, and MAKE_PAIR32().

◆ GetEquipmentInfo()

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

References _equipmentInfoStore, and urand().

Referenced by LoadCreatureDataFromDB(), and LoadCreatures().

◆ GetFishingBaseSkillLevel()

int32 ObjectMgr::GetFishingBaseSkillLevel ( uint32  entry) const
inline
1125 {
1126 FishingBaseSkillContainer::const_iterator itr = _fishingBaseForAreaStore.find(entry);
1127 return itr != _fishingBaseForAreaStore.end() ? itr->second : 0;
1128 }

References _fishingBaseForAreaStore.

◆ GetGameObjectAddon()

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

References _gameObjectAddonStore.

◆ GetGameObjectData()

GameObjectData const * ObjectMgr::GetGameObjectData ( ObjectGuid::LowType  spawnId) const
inline
1271 {
1272 GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(spawnId);
1273 if (itr == _gameObjectDataStore.end()) return nullptr;
1274 return &itr->second;
1275 }

References _gameObjectDataStore.

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

◆ GetGameObjectLocale()

GameObjectLocale const * ObjectMgr::GetGameObjectLocale ( uint32  entry) const
inline
1298 {
1299 GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
1300 if (itr == _gameObjectLocaleStore.end()) return nullptr;
1301 return &itr->second;
1302 }
GameObjectLocaleContainer _gameObjectLocaleStore
Definition ObjectMgr.h:1667

References _gameObjectLocaleStore.

◆ GetGameObjectQuestItemList()

GameObjectQuestItemList const * ObjectMgr::GetGameObjectQuestItemList ( uint32  id) const
inline
821 {
822 GameObjectQuestItemMap::const_iterator itr = _gameObjectQuestItemStore.find(id);
823 if (itr != _gameObjectQuestItemStore.end())
824 return &itr->second;
825 return nullptr;
826 }
GameObjectQuestItemMap _gameObjectQuestItemStore
Definition ObjectMgr.h:1659

References _gameObjectQuestItemStore.

◆ GetGameObjectQuestItemMap()

GameObjectQuestItemMap const * ObjectMgr::GetGameObjectQuestItemMap ( ) const
inline

◆ GetGameObjectSummonGroup()

std::vector< GameObjectSummonData > const * ObjectMgr::GetGameObjectSummonGroup ( uint32  summonerId,
SummonerType  summonerType,
uint8  group 
) const
inline
1219 {
1220 GameObjectSummonDataContainer::const_iterator itr = _goSummonDataStore.find(TempSummonGroupKey(summonerId, summonerType, group));
1221 if (itr != _goSummonDataStore.end())
1222 return &itr->second;
1223
1224 return nullptr;
1225 }
GameObjectSummonDataContainer _goSummonDataStore
Stores gameobject summon data grouped by summoner's entry, summoner's type and group id.
Definition ObjectMgr.h:1673
Key for storing temp summon data in TempSummonDataContainer.
Definition ObjectMgr.h:65

References _goSummonDataStore.

◆ GetGameObjectTemplate()

GameObjectTemplate const * ObjectMgr::GetGameObjectTemplate ( uint32  entry)
10981{
10982 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
10983 if (itr != _gameObjectTemplateStore.end())
10984 return &(itr->second);
10985
10986 return nullptr;
10987}
GameObjectTemplateContainer _gameObjectTemplateStore
Definition ObjectMgr.h:1668

References _gameObjectTemplateStore.

Referenced by AddGOData(), IsGameObjectStaticTransport(), LoadGameObjectDataFromDB(), LoadGameobjectQuestEnders(), LoadGameObjectQuestItems(), LoadGameobjectQuestStarters(), LoadGameobjects(), LoadGameObjectSummons(), LoadGameObjectTemplateAddons(), LoadQuestGreetings(), LoadQuestGreetingsLocales(), LoadQuests(), LoadScripts(), and LoadTempSummons().

◆ GetGameObjectTemplateAddon()

GameObjectTemplateAddon const * ObjectMgr::GetGameObjectTemplateAddon ( uint32  entry) const
10996{
10997 auto itr = _gameObjectTemplateAddonStore.find(entry);
10998 if (itr != _gameObjectTemplateAddonStore.end())
10999 return &itr->second;
11000
11001 return nullptr;
11002}
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
Definition ObjectMgr.h:1669

References _gameObjectTemplateAddonStore.

◆ GetGameObjectTemplates()

GameObjectTemplateContainer const * ObjectMgr::GetGameObjectTemplates ( ) const
inline

◆ GetGameTele() [1/2]

GameTele const * ObjectMgr::GetGameTele ( std::string_view  name,
bool  exactSearch = false 
) const
9786{
9787 // explicit name case
9788 std::wstring wname;
9789 if (!Utf8toWStr(name, wname))
9790 return nullptr;
9791
9792 // converting string that we try to find to lower case
9793 wstrToLower(wname);
9794
9795 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
9796 const GameTele* alt = nullptr;
9797 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9798 {
9799 if (itr->second.wnameLow == wname)
9800 return &itr->second;
9801 else if (!exactSearch && !alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
9802 alt = &itr->second;
9803 }
9804
9805 return alt;
9806}
Definition ObjectMgr.h:133

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

◆ GetGameTele() [2/2]

GameTele const * ObjectMgr::GetGameTele ( uint32  id) const
inline
1430 {
1431 GameTeleContainer::const_iterator itr = _gameTeleStore.find(id);
1432 if (itr == _gameTeleStore.end()) return nullptr;
1433 return &itr->second;
1434 }

References _gameTeleStore.

◆ GetGameTeleMap()

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

References _gameTeleStore.

◆ GetGenerator()

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

◆ GetGoBackTrigger()

AreaTriggerTeleport const * ObjectMgr::GetGoBackTrigger ( uint32  Map) const
7580{
7581 bool useParentDbValue = false;
7582 uint32 parentId = 0;
7583 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
7584 if (!mapEntry || mapEntry->entrance_map < 0)
7585 return nullptr;
7586
7587 if (mapEntry->IsDungeon())
7588 {
7589 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
7590
7591 if (!iTemplate)
7592 return nullptr;
7593
7594 parentId = iTemplate->Parent;
7595 useParentDbValue = true;
7596 }
7597
7598 uint32 entrance_map = uint32(mapEntry->entrance_map);
7599 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
7600 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
7601 {
7602 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
7603 if (atEntry && atEntry->map == Map)
7604 return &itr->second;
7605 }
7606 return nullptr;
7607}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
AreaTrigger const * GetAreaTrigger(uint32 trigger) const
Definition ObjectMgr.h:866
Definition ObjectMgr.h:421
uint32 map
Definition ObjectMgr.h:423
Definition Map.h:124
uint32 Parent
Definition Map.h:125
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
992 {
993 return _goQuestInvolvedRelations.equal_range(go_entry);
994 }
QuestRelations _goQuestInvolvedRelations
Definition ObjectMgr.h:1578

References _goQuestInvolvedRelations.

◆ GetGOQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetGOQuestInvolvedRelationMap ( )
inline
982 {
984 }

References _goQuestInvolvedRelations.

◆ GetGOQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestRelationBounds ( uint32  go_entry)
inline
987 {
988 return _goQuestRelations.equal_range(go_entry);
989 }
QuestRelations _goQuestRelations
Definition ObjectMgr.h:1577

References _goQuestRelations.

◆ GetGOQuestRelationMap()

QuestRelations * ObjectMgr::GetGOQuestRelationMap ( )
inline
977 {
978 return &_goQuestRelations;
979 }

References _goQuestRelations.

◆ GetGossipMenuItemsLocale()

GossipMenuItemsLocale const * ObjectMgr::GetGossipMenuItemsLocale ( uint32  entry) const
inline
1328 {
1329 GossipMenuItemsLocaleContainer::const_iterator itr = _gossipMenuItemsLocaleStore.find(entry);
1330 if (itr == _gossipMenuItemsLocaleStore.end()) return nullptr;
1331 return &itr->second;
1332 }
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore
Definition ObjectMgr.h:1687

References _gossipMenuItemsLocaleStore.

◆ GetGossipMenuItemsMapBounds()

GossipMenuItemsMapBounds ObjectMgr::GetGossipMenuItemsMapBounds ( uint32  uiMenuId) const
inline
1477 {
1478 return _gossipMenuItemsStore.equal_range(uiMenuId);
1479 }
GossipMenuItemsContainer _gossipMenuItemsStore
Definition ObjectMgr.h:1572

References _gossipMenuItemsStore.

◆ GetGossipMenuItemsMapBoundsNonConst()

GossipMenuItemsMapBoundsNonConst ObjectMgr::GetGossipMenuItemsMapBoundsNonConst ( uint32  uiMenuId)
inline
1481 {
1482 return _gossipMenuItemsStore.equal_range(uiMenuId);
1483 }

References _gossipMenuItemsStore.

◆ GetGossipMenusMapBounds()

GossipMenusMapBounds ObjectMgr::GetGossipMenusMapBounds ( uint32  uiMenuId) const
inline
1467 {
1468 return _gossipMenusStore.equal_range(uiMenuId);
1469 }
GossipMenusContainer _gossipMenusStore
Definition ObjectMgr.h:1571

References _gossipMenusStore.

◆ GetGossipMenusMapBoundsNonConst()

GossipMenusMapBoundsNonConst ObjectMgr::GetGossipMenusMapBoundsNonConst ( uint32  uiMenuId)
inline
1472 {
1473 return _gossipMenusStore.equal_range(uiMenuId);
1474 }

References _gossipMenusStore.

◆ GetGossipText()

GossipText const * ObjectMgr::GetGossipText ( uint32  Text_ID) const
6622{
6623 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
6624 if (itr != _gossipTextStore.end())
6625 return &itr->second;
6626 return nullptr;
6627}
GossipTextContainer _gossipTextStore
Definition ObjectMgr.h:1559

References _gossipTextStore.

Referenced by LoadGossipMenu().

◆ GetGridObjectGuids()

CellObjectGuids const & ObjectMgr::GetGridObjectGuids ( uint16  mapid,
uint8  spawnMode,
uint32  gridId 
)
inline
1181 {
1182 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1183 if (itr1 != _mapObjectGuidsStore.end())
1184 {
1185 CellObjectGuidsMap::const_iterator itr2 = itr1->second.find(gridId);
1186 if (itr2 != itr1->second.end())
1187 return itr2->second;
1188 }
1189 return _emptyCellObjectGuids;
1190 }
CellObjectGuids _emptyCellObjectGuids
Definition ObjectMgr.h:1649

References _emptyCellObjectGuids, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & ObjectMgr::GetGuidSequenceGenerator ( )
inlineprivate
1540 {
1541 auto itr = _guidGenerators.find(high);
1542 if (itr == _guidGenerators.end())
1543 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
1544
1545 return *itr->second;
1546 }
Definition ObjectGuid.h:297
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition ObjectMgr.h:1548

References _guidGenerators.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
6528{
6529 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
6530 if (itr != _instanceTemplateStore.end())
6531 return &(itr->second);
6532
6533 return nullptr;
6534}
InstanceTemplateContainer _instanceTemplateStore
Definition ObjectMgr.h:1605

References _instanceTemplateStore.

◆ GetItemLocale()

ItemLocale const * ObjectMgr::GetItemLocale ( uint32  entry) const
inline
1304 {
1305 ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
1306 if (itr == _itemLocaleStore.end()) return nullptr;
1307 return &itr->second;
1308 }
ItemLocaleContainer _itemLocaleStore
Definition ObjectMgr.h:1678

References _itemLocaleStore.

◆ GetItemSetNameEntry()

ItemSetNameEntry const * ObjectMgr::GetItemSetNameEntry ( uint32  itemId)
inline
792 {
793 ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
794 if (itr != _itemSetNameStore.end())
795 return &itr->second;
796 return nullptr;
797 }
ItemSetNameContainer _itemSetNameStore
Definition ObjectMgr.h:1645

References _itemSetNameStore.

◆ GetItemSetNameLocale()

ItemSetNameLocale const * ObjectMgr::GetItemSetNameLocale ( uint32  entry) const
inline
1310 {
1311 ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
1312 if (itr == _itemSetNameLocaleStore.end())return nullptr;
1313 return &itr->second;
1314 }
ItemSetNameLocaleContainer _itemSetNameLocaleStore
Definition ObjectMgr.h:1679

References _itemSetNameLocaleStore.

◆ GetItemTemplate()

ItemTemplate const * ObjectMgr::GetItemTemplate ( uint32  entry)
3867{
3868 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3869}
std::vector< ItemTemplate * > _itemTemplateStoreFast
Definition ObjectMgr.h:1677

References _itemTemplateStoreFast.

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

◆ GetItemTemplateStore()

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

References _itemTemplateStore.

◆ GetItemTemplateStoreFast()

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

References _itemTemplateStoreFast.

◆ GetLegacySpawnGroup()

SpawnGroupTemplateData const * ObjectMgr::GetLegacySpawnGroup ( ) const
inline
1284{ return &_spawnGroupDataStore.at(1); }

References _spawnGroupDataStore.

◆ GetLinkedRespawnGuid()

ObjectGuid ObjectMgr::GetLinkedRespawnGuid ( ObjectGuid  guid) const
inline
1262 {
1263 LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid);
1264 if (itr == _linkedRespawnStore.end())
1265 return ObjectGuid::Empty;
1266 return itr->second;
1267 }
static ObjectGuid const Empty
Definition ObjectGuid.h:120
LinkedRespawnContainer _linkedRespawnStore
Definition ObjectMgr.h:1662

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
1494 {
1495 if (data.size() > std::size_t(loc_idx) && !data[loc_idx].empty())
1496 value = data[loc_idx];
1497 }

◆ GetLocaleString() [2/2]

◆ GetMailLevelReward()

MailLevelReward const * ObjectMgr::GetMailLevelReward ( uint32  level,
uint32  raceMask 
)
inline
1168 {
1169 MailLevelRewardContainer::const_iterator map_itr = _mailLevelRewardStore.find(level);
1170 if (map_itr == _mailLevelRewardStore.end())
1171 return nullptr;
1172
1173 for (const auto & set_itr : map_itr->second)
1174 if (set_itr.raceMask & raceMask)
1175 return &set_itr;
1176
1177 return nullptr;
1178 }
MailLevelRewardContainer _mailLevelRewardStore
Definition ObjectMgr.h:1614

References _mailLevelRewardStore.

◆ GetMapEntranceTrigger()

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

Searches for the areatrigger which teleports players to the given map

7613{
7614 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
7615 {
7616 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
7617 {
7618 // xinef: no need to check, already done at loading
7619 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
7620 //if (atEntry)
7621 return &itr->second;
7622 }
7623 }
7624 return nullptr;
7625}

References _areaTriggerTeleportStore.

◆ GetMapObjectGuids()

CellObjectGuidsMap const & ObjectMgr::GetMapObjectGuids ( uint16  mapid,
uint8  spawnMode 
)
inline
1193 {
1194 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1195 if (itr1 != _mapObjectGuidsStore.end())
1196 return itr1->second;
1198 }
CellObjectGuidsMap _emptyCellObjectGuidsMap
Definition ObjectMgr.h:1648

References _emptyCellObjectGuidsMap, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetModelForShapeshift()

uint32 ObjectMgr::GetModelForShapeshift ( ShapeshiftForm  form,
Player player 
) const
1890{
1891 uint8 customizationID;
1892
1893 if (player->GetTeamId() == TEAM_ALLIANCE)
1894 customizationID = player->GetByteValue(PLAYER_BYTES, 3); // Use Hair Color
1895 else
1896 customizationID = player->GetByteValue(PLAYER_BYTES, 0); // Use Skin Color
1897
1898 auto itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), customizationID, player->getGender()));
1899 if (itr != _playerShapeshiftModel.end())
1900 return itr->second; // Explicit combination
1901
1902 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), customizationID, GENDER_NONE));
1903 if (itr != _playerShapeshiftModel.end())
1904 return itr->second; // Combination applied to both genders
1905
1906 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), 255, player->getGender()));
1907 if (itr != _playerShapeshiftModel.end())
1908 return itr->second; // Default gender-dependent model
1909
1910 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), 255, GENDER_NONE));
1911 if (itr != _playerShapeshiftModel.end())
1912 return itr->second; // Last resort
1913
1914 LOG_DEBUG("entities.player", "ShapeshiftForm {} with RaceID ({}) have no shapeshift model data defined, using fallback data.", form, player->getRace());
1915 return 0;
1916}
@ GENDER_NONE
Definition SharedDefines.h:63
@ TEAM_ALLIANCE
Definition SharedDefines.h:748
@ PLAYER_BYTES
Definition UpdateFields.h:181
PlayerShapeshiftModelMap _playerShapeshiftModel
Definition ObjectMgr.h:1710
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:312
TeamId GetTeamId(bool original=false) const
Definition Player.h:2127
uint8 getGender() const
Definition Unit.h:848
uint8 getRace(bool original=false) const
Definition Unit.cpp:17046

References _playerShapeshiftModel, GENDER_NONE, Object::GetByteValue(), Unit::getGender(), Unit::getRace(), Player::GetTeamId(), LOG_DEBUG, PLAYER_BYTES, and TEAM_ALLIANCE.

◆ GetModelForTotem()

uint32 ObjectMgr::GetModelForTotem ( SummonSlot  totemSlot,
Races  race 
) const
1835{
1836 auto itr = _playerTotemModel.find(std::make_pair(totemSlot, race));
1837 if (itr != _playerTotemModel.end())
1838 return itr->second;
1839
1840 LOG_ERROR("misc", "TotemSlot {} with RaceID ({}) have no totem model data defined, set to default model.", totemSlot, race);
1841 return 0;
1842}
PlayerTotemModelMap _playerTotemModel
Definition ObjectMgr.h:1708

References _playerTotemModel, and LOG_ERROR.

◆ GetModuleString() [1/2]

ModuleString const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id 
) const
inline
1378 {
1379 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
1380 ModuleStringContainer::const_iterator itr = _moduleStringStore.find(pairKey);
1381 if (itr == _moduleStringStore.end())
1382 return nullptr;
1383
1384 return &itr->second;
1385 }
ModuleStringContainer _moduleStringStore
Definition ObjectMgr.h:1685

References _moduleStringStore.

Referenced by GetModuleString().

◆ GetModuleString() [2/2]

std::string const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id,
LocaleConstant  locale 
) const
9525{
9526 ModuleString const* ms = GetModuleString(module, id);
9527 if (ms && !ms->Content.empty())
9528 {
9529 if (ms->Content.size() > size_t(locale) && !ms->Content[locale].empty())
9530 return &ms->Content[locale];
9531
9532 return &ms->Content[DEFAULT_LOCALE];
9533 }
9534
9535 LOG_ERROR("sql.sql", "Module string module {} id {} not found in DB.", module, id);
9536
9537 return (std::string*)"error";
9538}
ModuleString const * GetModuleString(std::string module, uint32 id) const
Definition ObjectMgr.h:1377
Definition ObjectMgr.h:497
std::vector< std::string > Content
Definition ObjectMgr.h:498

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

◆ GetNearestTaxiNode() [1/2]

uint32 ObjectMgr::GetNearestTaxiNode ( float  x,
float  y,
float  z,
uint32  mapid,
uint32  teamId 
)
7197{
7198 bool found = false;
7199 float dist = 10000;
7200 uint32 id = 0;
7201
7202 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
7203 {
7204 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
7205
7206 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
7207 continue;
7208
7209 uint8 field = (uint8)((i - 1) / 32);
7210 uint32 submask = 1 << ((i - 1) % 32);
7211
7212 // skip not taxi network nodes
7213 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
7214 {
7215 continue;
7216 }
7217
7218 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
7219 if (found)
7220 {
7221 if (dist2 < dist)
7222 {
7223 dist = dist2;
7224 id = i;
7225 }
7226 }
7227 else
7228 {
7229 found = true;
7230 dist = dist2;
7231 id = i;
7232 }
7233 }
7234
7235 return id;
7236}
TaxiMask sTaxiNodesMask
Definition DBCStores.cpp:176
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
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.

Referenced by GetNearestTaxiNode().

◆ GetNearestTaxiNode() [2/2]

uint32 ObjectMgr::GetNearestTaxiNode ( WorldLocation const &  loc,
uint32  teamId 
)
7192{
7193 return GetNearestTaxiNode(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetMapId(), teamId);
7194}
uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 teamId)
Definition ObjectMgr.cpp:7196

References WorldLocation::GetMapId(), GetNearestTaxiNode(), Position::GetPositionX(), Position::GetPositionY(), and Position::GetPositionZ().

◆ GetNpcTextLocale()

NpcTextLocale const * ObjectMgr::GetNpcTextLocale ( uint32  entry) const
inline
1352 {
1353 NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
1354 if (itr == _npcTextLocaleStore.end()) return nullptr;
1355 return &itr->second;
1356 }
NpcTextLocaleContainer _npcTextLocaleStore
Definition ObjectMgr.h:1683

References _npcTextLocaleStore.

◆ GetNpcVendorItemList()

VendorItemData const * ObjectMgr::GetNpcVendorItemList ( uint32  entry) const
inline
1444 {
1445 CacheVendorItemContainer::const_iterator iter = _cacheVendorItemStore.find(entry);
1446 if (iter == _cacheVendorItemStore.end())
1447 return nullptr;
1448
1449 return &iter->second;
1450 }

References _cacheVendorItemStore.

Referenced by IsVendorItemValid().

◆ GetPageText()

PageText const * ObjectMgr::GetPageText ( uint32  pageEntry)
6444{
6445 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
6446 if (itr != _pageTextStore.end())
6447 return &(itr->second);
6448
6449 return nullptr;
6450}
PageTextContainer _pageTextStore
Definition ObjectMgr.h:1604

References _pageTextStore.

Referenced by LoadGameObjectTemplate(), and LoadItemTemplates().

◆ GetPageTextLocale()

PageTextLocale const * ObjectMgr::GetPageTextLocale ( uint32  entry) const
inline
1316 {
1317 PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
1318 if (itr == _pageTextLocaleStore.end()) return nullptr;
1319 return &itr->second;
1320 }
PageTextLocaleContainer _pageTextLocaleStore
Definition ObjectMgr.h:1684

References _pageTextLocaleStore.

◆ GetPetLevelInfo()

PetLevelInfo const * ObjectMgr::GetPetLevelInfo ( uint32  creature_id,
uint8  level 
) const
4233{
4234 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4235 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4236
4237 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
4238 if (itr == _petInfoStore.end())
4239 return nullptr;
4240
4241 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
4242}

References _petInfoStore, CONFIG_MAX_PLAYER_LEVEL, and sWorld.

◆ GetPlayerClassInfo()

PlayerClassInfo const * ObjectMgr::GetPlayerClassInfo ( uint32  class_) const
inline
804 {
805 if (class_ >= MAX_CLASSES)
806 return nullptr;
807 return _playerClassInfo[class_];
808 }

References _playerClassInfo, and MAX_CLASSES.

◆ GetPlayerClassLevelInfo()

void ObjectMgr::GetPlayerClassLevelInfo ( uint32  class_,
uint8  level,
PlayerClassLevelInfo info 
) const
4910{
4911 if (level < 1 || class_ >= MAX_CLASSES)
4912 return;
4913
4914 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4915
4916 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4917 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4918
4919 *info = pInfo->levelInfo[level - 1];
4920}
Definition Player.h:283

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

◆ GetPlayerInfo()

PlayerInfo const * ObjectMgr::GetPlayerInfo ( uint32  race,
uint32  class_ 
) const
11027{
11028 if (race >= sRaceMgr->GetMaxRaces())
11029 return nullptr;
11030 if (class_ >= MAX_CLASSES)
11031 return nullptr;
11032 PlayerInfo const* info = _playerInfo[race][class_];
11033 if (!info)
11034 return nullptr;
11035 return info;
11036}
Definition Player.h:322

References _playerInfo, MAX_CLASSES, and sRaceMgr.

◆ GetPlayerLevelInfo()

void ObjectMgr::GetPlayerLevelInfo ( uint32  race,
uint32  class_,
uint8  level,
PlayerLevelInfo info 
) const
4923{
4924 if (level < 1 || race >= sRaceMgr->GetMaxRaces() || class_ >= MAX_CLASSES)
4925 return;
4926
4927 PlayerInfo const* pInfo = _playerInfo[race][class_];
4928 if (!pInfo)
4929 return;
4930
4931 if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4932 *info = pInfo->levelInfo[level - 1];
4933 else
4934 BuildPlayerLevelInfo(race, class_, level, info);
4935}
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
Definition ObjectMgr.cpp:4937
PlayerLevelInfo * levelInfo
Definition Player.h:340

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

◆ GetPointOfInterest()

PointOfInterest const * ObjectMgr::GetPointOfInterest ( uint32  id) const
inline
933 {
934 PointOfInterestContainer::const_iterator itr = _pointsOfInterestStore.find(id);
935 if (itr != _pointsOfInterestStore.end())
936 return &itr->second;
937 return nullptr;
938 }
PointOfInterestContainer _pointsOfInterestStore
Definition ObjectMgr.h:1573

References _pointsOfInterestStore.

Referenced by LoadGossipMenuItems().

◆ GetPointOfInterestLocale()

PointOfInterestLocale const * ObjectMgr::GetPointOfInterestLocale ( uint32  poi_id) const
inline
1334 {
1335 PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id);
1336 if (itr == _pointOfInterestLocaleStore.end()) return nullptr;
1337 return &itr->second;
1338 }
PointOfInterestLocaleContainer _pointOfInterestLocaleStore
Definition ObjectMgr.h:1688

References _pointOfInterestLocaleStore.

◆ GetQuestForAreaTrigger()

uint32 ObjectMgr::GetQuestForAreaTrigger ( uint32  Trigger_ID) const
inline
846 {
847 QuestAreaTriggerContainer::const_iterator itr = _questAreaTriggerStore.find(Trigger_ID);
848 if (itr != _questAreaTriggerStore.end())
849 return itr->second;
850 return 0;
851 }
QuestAreaTriggerContainer _questAreaTriggerStore
Definition ObjectMgr.h:1557

References _questAreaTriggerStore.

◆ GetQuestGreeting()

QuestGreeting const * ObjectMgr::GetQuestGreeting ( TypeID  type,
uint32  id 
) const
6922{
6923 uint8 typeIndex;
6924 if (type == TYPEID_UNIT)
6925 typeIndex = 0;
6926 else if (type == TYPEID_GAMEOBJECT)
6927 typeIndex = 1;
6928 else
6929 return nullptr;
6930
6931 std::pair<uint32, uint8> pairKey = std::make_pair(id, typeIndex);
6932 QuestGreetingContainer::const_iterator itr = _questGreetingStore.find(pairKey);
6933 if (itr == _questGreetingStore.end())
6934 return nullptr;
6935
6936 return &itr->second;
6937}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
QuestGreetingContainer _questGreetingStore
Definition ObjectMgr.h:1560

References _questGreetingStore, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

◆ GetQuestLocale()

QuestLocale const * ObjectMgr::GetQuestLocale ( uint32  entry) const
inline
1322 {
1323 QuestLocaleContainer::const_iterator itr = _questLocaleStore.find(entry);
1324 if (itr == _questLocaleStore.end()) return nullptr;
1325 return &itr->second;
1326 }
QuestLocaleContainer _questLocaleStore
Definition ObjectMgr.h:1680

References _questLocaleStore.

◆ GetQuestMoneyReward()

uint32 ObjectMgr::GetQuestMoneyReward ( uint8  level,
uint32  questMoneyDifficulty 
) const
11163{
11164 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
11165 {
11166 auto const& itr = _questMoneyRewards.find(level);
11167 if (itr != _questMoneyRewards.end())
11168 {
11169 return itr->second.at(questMoneyDifficulty);
11170 }
11171 }
11172
11173 return 0;
11174}
static constexpr uint32 MAX_QUEST_MONEY_REWARDS
Definition ObjectMgr.h:721
QuestMoneyRewardStore _questMoneyRewards
Definition ObjectMgr.h:1712

References _questMoneyRewards, and MAX_QUEST_MONEY_REWARDS.

◆ GetQuestOfferRewardLocale()

QuestOfferRewardLocale const * ObjectMgr::GetQuestOfferRewardLocale ( uint32  entry) const
inline
1340 {
1341 auto itr = _questOfferRewardLocaleStore.find(entry);
1342 if (itr == _questOfferRewardLocaleStore.end()) return nullptr;
1343 return &itr->second;
1344 }
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
Definition ObjectMgr.h:1681

References _questOfferRewardLocaleStore.

◆ GetQuestPOIVector()

QuestPOIVector const * ObjectMgr::GetQuestPOIVector ( uint32  questId)
inline
941 {
942 QuestPOIContainer::const_iterator itr = _questPOIStore.find(questId);
943 if (itr != _questPOIStore.end())
944 return &itr->second;
945 return nullptr;
946 }
QuestPOIContainer _questPOIStore
Definition ObjectMgr.h:1575

References _questPOIStore.

◆ GetQuestRequestItemsLocale()

QuestRequestItemsLocale const * ObjectMgr::GetQuestRequestItemsLocale ( uint32  entry) const
inline
1346 {
1347 auto itr = _questRequestItemsLocaleStore.find(entry);
1348 if (itr == _questRequestItemsLocaleStore.end()) return nullptr;
1349 return &itr->second;
1350 }
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
Definition ObjectMgr.h:1682

References _questRequestItemsLocaleStore.

◆ GetQuestTemplate()

Quest const * ObjectMgr::GetQuestTemplate ( uint32  quest_id) const
inline
839 {
840 return quest_id < _questTemplatesFast.size() ? _questTemplatesFast[quest_id] : nullptr;
841 }
std::vector< Quest * > _questTemplatesFast
Definition ObjectMgr.h:1551

References _questTemplatesFast.

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

◆ GetQuestTemplates()

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

References _questTemplates.

◆ GetRepRewardRate()

RepRewardRate const * ObjectMgr::GetRepRewardRate ( uint32  factionId) const
inline
905 {
906 RepRewardRateContainer::const_iterator itr = _repRewardRateStore.find(factionId);
907 if (itr != _repRewardRateStore.end())
908 return &itr->second;
909
910 return nullptr;
911 }
RepRewardRateContainer _repRewardRateStore
Definition ObjectMgr.h:1567

References _repRewardRateStore.

◆ GetRepSpilloverTemplate()

RepSpilloverTemplate const * ObjectMgr::GetRepSpilloverTemplate ( uint32  factionId) const
inline
924 {
925 RepSpilloverTemplateContainer::const_iterator itr = _repSpilloverTemplateStore.find(factionId);
926 if (itr != _repSpilloverTemplateStore.end())
927 return &itr->second;
928
929 return nullptr;
930 }
RepSpilloverTemplateContainer _repSpilloverTemplateStore
Definition ObjectMgr.h:1569

References _repSpilloverTemplateStore.

◆ GetReputationOnKilEntry()

ReputationOnKillEntry const * ObjectMgr::GetReputationOnKilEntry ( uint32  id) const
inline
914 {
915 RepOnKillContainer::const_iterator itr = _repOnKillStore.find(id);
916 if (itr != _repOnKillStore.end())
917 return &itr->second;
918 return nullptr;
919 }
RepOnKillContainer _repOnKillStore
Definition ObjectMgr.h:1568

References _repOnKillStore.

◆ GetScriptId()

uint32 ObjectMgr::GetScriptId ( std::string const &  name)
10500{
10501 // use binary search to find the script name in the sorted vector
10502 // assume "" is the first element
10503 if (name.empty())
10504 return 0;
10505
10506 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
10507 if (itr == _scriptNamesStore.end() || (*itr != name))
10508 return 0;
10509
10510 return uint32(itr - _scriptNamesStore.begin());
10511}
ScriptNameContainer _scriptNamesStore
Definition ObjectMgr.h:1592

References _scriptNamesStore.

Referenced by LoadAreaTriggerScripts(), LoadCreatureDataFromDB(), LoadCreatures(), LoadCreatureTemplate(), LoadGameObjectDataFromDB(), LoadGameobjects(), LoadGameObjectTemplate(), LoadInstanceTemplate(), LoadItemTemplates(), and LoadSpellScriptNames().

◆ GetScriptName()

std::string const & ObjectMgr::GetScriptName ( uint32  id) const
10494{
10495 static std::string const empty = "";
10496 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
10497}

References _scriptNamesStore.

Referenced by ValidateSpellScripts().

◆ GetScriptNames()

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

References _scriptNamesStore.

◆ GetSparringData()

CreatureSparringContainer const & ObjectMgr::GetSparringData ( ) const
inline
1242{ return _creatureSparringStore; }
CreatureSparringContainer _creatureSparringStore
Definition ObjectMgr.h:1607

References _creatureSparringStore.

◆ GetSpawnData()

SpawnData const * ObjectMgr::GetSpawnData ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId 
) const
8709{
8710 switch (type)
8711 {
8713 return GetCreatureData(spawnId);
8715 return GetGameObjectData(spawnId);
8716 default:
8717 return nullptr;
8718 }
8719}
@ SPAWN_TYPE_GAMEOBJECT
Definition SpawnData.h:28
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:27

References GetCreatureData(), GetGameObjectData(), SPAWN_TYPE_CREATURE, and SPAWN_TYPE_GAMEOBJECT.

Referenced by LoadSpawnGroups().

◆ GetSpawnDataForGroup()

std::pair< SpawnGroupLinkContainer::const_iterator, SpawnGroupLinkContainer::const_iterator > ObjectMgr::GetSpawnDataForGroup ( uint32  groupId) const
inline
1286 {
1287 return _spawnGroupMapStore.equal_range(groupId);
1288 }
SpawnGroupLinkContainer _spawnGroupMapStore
Definition ObjectMgr.h:1666

References _spawnGroupMapStore.

◆ GetSpawnGroupData()

SpawnGroupTemplateData const * ObjectMgr::GetSpawnGroupData ( uint32  groupId) const
inline
1279 {
1280 auto itr = _spawnGroupDataStore.find(groupId);
1281 return itr != _spawnGroupDataStore.end() ? &itr->second : nullptr;
1282 }

References _spawnGroupDataStore.

◆ GetSpellClickInfoMapBounds()

SpellClickInfoMapBounds ObjectMgr::GetSpellClickInfoMapBounds ( uint32  creature_id) const
inline
1462 {
1463 return _spellClickInfoStore.equal_range(creature_id);
1464 }
SpellClickInfoContainer _spellClickInfoStore
Definition ObjectMgr.h:1594

References _spellClickInfoStore.

◆ GetSpellScriptsBounds()

SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds ( uint32  spell_id)
9675{
9676 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
9677}
std::pair< SpellScriptsContainer::iterator, SpellScriptsContainer::iterator > SpellScriptsBounds
Definition ObjectMgr.h:389
SpellScriptsContainer _spellScriptsStore
Definition ObjectMgr.h:1596

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
1210 {
1211 TempSummonDataContainer::const_iterator itr = _tempSummonDataStore.find(TempSummonGroupKey(summonerId, summonerType, group));
1212 if (itr != _tempSummonDataStore.end())
1213 return &itr->second;
1214
1215 return nullptr;
1216 }
TempSummonDataContainer _tempSummonDataStore
Stores temp summon data grouped by summoner's entry, summoner's type and group id.
Definition ObjectMgr.h:1671

References _tempSummonDataStore.

◆ GetTaxiMountDisplayId()

uint32 ObjectMgr::GetTaxiMountDisplayId ( uint32  id,
TeamId  teamId,
bool  allowed_alt_team = false 
)
7263{
7264 CreatureModel mountModel;
7265 CreatureTemplate const* mount_info = nullptr;
7266
7267 // select mount creature id
7268 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
7269 if (node)
7270 {
7271 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
7272
7273 // Fix for Alliance not being able to use Acherus taxi
7274 // only one mount type for both sides
7275 if (mount_entry == 0 && allowed_alt_team)
7276 {
7277 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
7278 mount_entry = node->MountCreatureID[teamId];
7279 }
7280
7281 mount_info = GetCreatureTemplate(mount_entry);
7282 if (mount_info)
7283 {
7284 CreatureModel const* model = mount_info->GetRandomValidModel();
7285 if (!model)
7286 {
7287 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
7288 return 0;
7289 }
7290 mountModel = *model;
7291 }
7292 }
7293
7294 // minfo is not actually used but the mount_id was updated
7295 GetCreatureModelRandomGender(&mountModel, mount_info);
7296
7297 return mountModel.CreatureDisplayID;
7298}
CreatureModelInfo const * GetCreatureModelRandomGender(CreatureModel *model, CreatureTemplate const *creatureTemplate) const
Definition ObjectMgr.cpp:1678
CreatureModel const * GetRandomValidModel() const
Definition Creature.cpp:120

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 
)
7239{
7240 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
7241 if (src_i == sTaxiPathSetBySource.end())
7242 {
7243 path = 0;
7244 cost = 0;
7245 return;
7246 }
7247
7248 TaxiPathSetForSource& pathSet = src_i->second;
7249
7250 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
7251 if (dest_i == pathSet.end())
7252 {
7253 path = 0;
7254 cost = 0;
7255 return;
7256 }
7257
7258 cost = dest_i->second->price;
7259 path = dest_i->second->ID;
7260}
TaxiPathSetBySource sTaxiPathSetBySource
Definition DBCStores.cpp:183
std::map< uint32, TaxiPathEntry const * > TaxiPathSetForSource
Definition DBCStructure.h:2242

References TaxiNodesEntry::ID, and sTaxiPathSetBySource.

◆ GetTrainer()

Trainer::Trainer * ObjectMgr::GetTrainer ( uint32  creatureId)
10087{
10088 auto itr = _creatureDefaultTrainers.find(creatureId);
10089 if (itr != _creatureDefaultTrainers.end())
10090 return Acore::Containers::MapGetValuePtr(_trainers, itr->second);
10091
10092 return nullptr;
10093}
std::unordered_map< uint32, uint32 > _creatureDefaultTrainers
Definition ObjectMgr.h:1693
std::unordered_map< uint32, Trainer::Trainer > _trainers
Definition ObjectMgr.h:1691

References _creatureDefaultTrainers, _trainers, and Acore::Containers::MapGetValuePtr().

◆ GetVehicleAccessoryList()

VehicleAccessoryList const * ObjectMgr::GetVehicleAccessoryList ( Vehicle veh) const
11010{
11011 if (Creature* cre = veh->GetBase()->ToCreature())
11012 {
11013 // Give preference to GUID-based accessories
11014 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
11015 if (itr != _vehicleAccessoryStore.end())
11016 return &itr->second;
11017 }
11018
11019 // Otherwise return entry-based
11020 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
11021 if (itr != _vehicleTemplateAccessoryStore.end())
11022 return &itr->second;
11023 return nullptr;
11024}
VehicleAccessoryContainer _vehicleAccessoryStore
Definition ObjectMgr.h:1599
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
Definition ObjectMgr.h:1598
Creature * ToCreature()
Definition Object.h:206
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
uint32 GetCreatureEntry() const
Definition Vehicle.h:39

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

◆ GetVehicleSeatAddon()

VehicleSeatAddon const * ObjectMgr::GetVehicleSeatAddon ( uint32  seatId) const
inline
1516 {
1517 VehicleSeatAddonContainer::const_iterator itr = _vehicleSeatAddonStore.find(seatId);
1518 if (itr == _vehicleSeatAddonStore.end())
1519 return nullptr;
1520
1521 return &itr->second;
1522 }
VehicleSeatAddonContainer _vehicleSeatAddonStore
Definition ObjectMgr.h:1600

References _vehicleSeatAddonStore.

◆ GetXPForLevel()

uint32 ObjectMgr::GetXPForLevel ( uint8  level) const
8121{
8122 if (level < _playerXPperLevel.size())
8123 return _playerXPperLevel[level];
8124 return 0;
8125}
PlayerXPperLevel _playerXPperLevel
Definition ObjectMgr.h:1629

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
6391{
6392 uint32 limit = sSpellStore.GetNumRows();
6393 for(uint32 i = 0; i <= limit; ++i)
6394 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
6395 {
6396 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
6397 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
6398 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
6399 }
6400}
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
Definition SpellInfo.h:340
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:417

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

◆ instance()

ObjectMgr * ObjectMgr::instance ( )
static
378{
379 static ObjectMgr instance;
380 return &instance;
381}
Definition ObjectMgr.h:728
static ObjectMgr * instance()
Definition ObjectMgr.cpp:377

References instance().

Referenced by instance().

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
10990{
10991 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
10992 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
10993}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1575

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

Referenced by AddGOData().

◆ IsProfanityName()

bool ObjectMgr::IsProfanityName ( std::string_view  name) const
9161{
9162 // pussywizard
9163 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
9164 return true;
9165
9166 std::wstring wstr;
9167 if (!Utf8toWStr (name, wstr))
9168 return false;
9169
9170 wstrToLower(wstr);
9171
9172 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
9173}

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

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
9058{
9059 // pussywizard
9060 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
9061 return true;
9062
9063 std::wstring wstr;
9064 if (!Utf8toWStr (name, wstr))
9065 return false;
9066
9067 wstrToLower(wstr);
9068
9069 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
9070}

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

Referenced by AddReservedPlayerName().

◆ IsTavernAreaTrigger()

bool ObjectMgr::IsTavernAreaTrigger ( uint32  triggerID,
uint32  faction 
) const
inline
854 {
855 auto itr = _tavernAreaTriggerStore.find(triggerID);
856 if (itr != _tavernAreaTriggerStore.end())
857 {
858 return (itr->second & faction) != 0;
859 }
860
861 return false;
862 }
TavernAreaTriggerContainer _tavernAreaTriggerStore
Definition ObjectMgr.h:1558

References _tavernAreaTriggerStore.

◆ IsTransportMap()

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

References _transportMaps.

◆ IsValidChannelName()

bool ObjectMgr::IsValidChannelName ( std::string const &  name)
static
9334{
9335 std::wstring wname;
9336 if (!Utf8toWStr(name, wname))
9337 return false;
9338
9339 if (wname.size() > MAX_CHANNEL_NAME)
9340 return false;
9341
9342 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
9343
9344 return isValidString(wname, strictMask, true);
9345}
#define MAX_CHANNEL_NAME
Definition ObjectMgr.h:689
@ CONFIG_STRICT_CHANNEL_NAMES
Definition WorldConfig.h:180

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

◆ IsValidCharterName()

bool ObjectMgr::IsValidCharterName ( std::string_view  name)
static
9308{
9309 std::wstring wname;
9310 if (!Utf8toWStr(name, wname))
9311 return false;
9312
9313 if (wname.size() > MAX_CHARTER_NAME)
9314 return false;
9315
9316 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
9317 if (wname.size() < minName)
9318 return false;
9319
9320 // Check Reserved Name
9321 if (sObjectMgr->IsReservedName(name))
9322 return false;
9323
9324 // Check Profanity Name
9325 if (sObjectMgr->IsProfanityName(name))
9326 return false;
9327
9328 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
9329
9330 return isValidString(wname, strictMask, true);
9331}
#define MAX_CHARTER_NAME
Definition ObjectMgr.h:688
@ CONFIG_MIN_CHARTER_NAME
Definition WorldConfig.h:183
@ CONFIG_STRICT_CHARTER_NAMES
Definition WorldConfig.h:179

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,
uint32  maxcount,
uint32  ptime,
uint32  ExtendedCost,
Player player = nullptr,
std::set< uint32 > *  skip_vendors = nullptr,
uint32  ORnpcflag = 0 
) const
10358{
10359 /*
10360 CreatureTemplate const* cInfo = GetCreatureTemplate(vendor_entry);
10361 if (!cInfo)
10362 {
10363 if (player)
10364 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
10365 else
10366 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
10367 return false;
10368 }
10369
10370 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
10371 {
10372 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
10373 {
10374 if (player)
10375 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
10376 else
10377 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
10378
10379 if (skip_vendors)
10380 skip_vendors->insert(vendor_entry);
10381 }
10382 return false;
10383 }
10384 */
10385
10386 if (!sObjectMgr->GetItemTemplate(item_id))
10387 {
10388 if (player)
10390 else
10391 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
10392 return false;
10393 }
10394
10395 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
10396 {
10397 if (player)
10399 else
10400 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
10401 return false;
10402 }
10403
10404 if (maxcount > 0 && incrtime == 0)
10405 {
10406 if (player)
10407 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 ({}) but IncrTime == 0", maxcount);
10408 else
10409 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);
10410 return false;
10411 }
10412 else if (maxcount == 0 && incrtime > 0)
10413 {
10414 if (player)
10415 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
10416 else
10417 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);
10418 return false;
10419 }
10420
10421 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
10422 if (!vItems)
10423 return true; // later checks for non-empty lists
10424
10425 if (vItems->FindItemCostPair(item_id, ExtendedCost))
10426 {
10427 if (player)
10428 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
10429 else
10430 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
10431 return false;
10432 }
10433
10434 return true;
10435}
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
@ LANG_ITEM_ALREADY_IN_LIST
Definition Language.h:253
@ LANG_ITEM_NOT_FOUND
Definition Language.h:250
@ LANG_EXTENDED_COST_NOT_EXIST
Definition Language.h:378
Definition Chat.h:37
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
VendorItemData const * GetNpcVendorItemList(uint32 entry) const
Definition ObjectMgr.h:1443
WorldSession * GetSession() const
Definition Player.h:2019
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost) const
Definition Creature.cpp:104

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 ( )
7412{
7413 uint32 oldMSTime = getMSTime();
7414
7415 if (!_accessRequirementStore.empty())
7416 {
7417 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
7418 {
7419 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
7420 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
7421 {
7422 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
7423 {
7424 delete* questItr;
7425 }
7426
7427 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
7428 {
7429 delete* achievementItr;
7430 }
7431
7432 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
7433 {
7434 delete* itemsItr;
7435 }
7436
7437 delete difficultiesItr->second;
7438 }
7439 }
7440
7441 _accessRequirementStore.clear(); // need for reload case
7442 }
7443 // 0 1 2 3 4 5
7444 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
7445 if (!access_template_result)
7446 {
7447 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
7448 LOG_INFO("server.loading", " ");
7449 return;
7450 }
7451
7452 uint32 count = 0;
7453 uint32 countProgressionRequirements = 0;
7454
7455 do
7456 {
7457 Field* fields = access_template_result->Fetch();
7458
7459 //Get the common variables for the access requirements
7460 uint8 dungeon_access_id = fields[0].Get<uint8>();
7461 uint32 mapid = fields[1].Get<uint32>();
7462 uint8 difficulty = fields[2].Get<uint8>();
7463
7464 //Set up the access requirements
7466 ar->levelMin = fields[3].Get<uint8>();
7467 ar->levelMax = fields[4].Get<uint8>();
7468 ar->reqItemLevel = fields[5].Get<uint16>();
7469
7470 // 0 1 2 3 4 6
7471 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);
7472 if (progression_requirements_results)
7473 {
7474 do
7475 {
7476 Field* progression_requirement_row = progression_requirements_results->Fetch();
7477
7478 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
7479 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
7480 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
7481 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
7482 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
7483 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
7484
7485 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
7486 progression_requirement->id = requirement_id;
7487 progression_requirement->note = requirement_note;
7488 progression_requirement->faction = (TeamId)requirement_faction;
7489 progression_requirement->priority = requirement_priority;
7490 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
7491
7492 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
7493
7494 switch (requirement_type)
7495 {
7496 case 0:
7497 {
7498 //Achievement
7499 if (!sAchievementStore.LookupEntry(progression_requirement->id))
7500 {
7501 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);
7502 break;
7503 }
7504
7505 currentRequirementsList = &ar->achievements;
7506 break;
7507 }
7508 case 1:
7509 {
7510 //Quest
7511 if (!GetQuestTemplate(progression_requirement->id))
7512 {
7513 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);
7514 break;
7515 }
7516
7517 currentRequirementsList = &ar->quests;
7518 break;
7519 }
7520 case 2:
7521 {
7522 //Item
7523 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
7524 if (!pProto)
7525 {
7526 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);
7527 break;
7528 }
7529
7530 currentRequirementsList = &ar->items;
7531 break;
7532 }
7533 default:
7534 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);
7535 break;
7536 }
7537
7538 //Check if array is valid and delete the progression requirement
7539 if (!currentRequirementsList)
7540 {
7541 delete progression_requirement;
7542 continue;
7543 }
7544
7545 //Insert into the array
7546 if (currentRequirementsList->size() > requirement_priority)
7547 {
7548 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
7549 }
7550 else
7551 {
7552 currentRequirementsList->push_back(progression_requirement);
7553 }
7554
7555 } while (progression_requirements_results->NextRow());
7556 }
7557
7558 //Sort all arrays for priority
7559 auto sortFunction = [](const ProgressionRequirement* const a, const ProgressionRequirement* const b) {return a->priority > b->priority; };
7560 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
7561 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
7562 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
7563
7564 countProgressionRequirements += ar->achievements.size();
7565 countProgressionRequirements += ar->quests.size();
7566 countProgressionRequirements += ar->items.size();
7567 count++;
7568
7569 _accessRequirementStore[mapid][difficulty] = ar;
7570 } while (access_template_result->NextRow());
7571
7572 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
7573 LOG_INFO("server.loading", " ");
7574}
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
#define LOG_WARN(filterType__,...)
Definition Log.h:149
TeamId
Definition SharedDefines.h:747
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
Class used to access individual fields of database query result.
Definition Field.h:98
bool IsNull() const
Definition Field.h:106
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
ItemTemplate const * GetItemTemplate(uint32 entry)
Definition ObjectMgr.cpp:3866
Quest const * GetQuestTemplate(uint32 quest_id) const
Definition ObjectMgr.h:838
Definition Player.h:935
Definition ItemTemplate.h:619
Definition Player.h:926
uint32 priority
Definition Player.h:930

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 ( )
9541{
9542 uint32 oldMSTime = getMSTime();
9543
9544 _acoreStringStore.clear(); // for reload case
9545 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");
9546 if (!result)
9547 {
9548 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty.");
9549 LOG_INFO("server.loading", " ");
9550 return false;
9551 }
9552
9553 do
9554 {
9555 Field* fields = result->Fetch();
9556
9557 uint32 entry = fields[0].Get<uint32>();
9558
9559 AcoreString& data = _acoreStringStore[entry];
9560
9561 data.Content.resize(DEFAULT_LOCALE + 1);
9562
9563 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
9564 AddLocaleString(fields[i + 1].Get<std::string>(), LocaleConstant(i), data.Content);
9565 } while (result->NextRow());
9566
9567 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
9568 LOG_INFO("server.loading", " ");
9569
9570 return true;
9571}
LocaleConstant
Definition Common.h:117
@ TOTAL_LOCALES
Definition Common.h:128
static void AddLocaleString(std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
Definition ObjectMgr.cpp:383

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

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
7301{
7302 uint32 oldMSTime = getMSTime();
7303
7304 _areaTriggerStore.clear();
7305
7306 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
7307
7308 if (!result)
7309 {
7310 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
7311 LOG_INFO("server.loading", " ");
7312 return;
7313 }
7314
7315 uint32 count = 0;
7316
7317 do
7318 {
7319 Field* fields = result->Fetch();
7320
7321 ++count;
7322
7323 AreaTrigger at;
7324
7325 at.entry = fields[0].Get<uint32>();
7326 at.map = fields[1].Get<uint32>();
7327 at.x = fields[2].Get<float>();
7328 at.y = fields[3].Get<float>();
7329 at.z = fields[4].Get<float>();
7330 at.radius = fields[5].Get<float>();
7331 at.length = fields[6].Get<float>();
7332 at.width = fields[7].Get<float>();
7333 at.height = fields[8].Get<float>();
7334 at.orientation = fields[9].Get<float>();
7335
7336 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
7337 if (!mapEntry)
7338 {
7339 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
7340 continue;
7341 }
7342
7343 _areaTriggerStore[at.entry] = at;
7344 } while (result->NextRow());
7345
7346 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7347 LOG_INFO("server.loading", " ");
7348}
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 ( )
7154{
7155 uint32 oldMSTime = getMSTime();
7156
7157 _areaTriggerScriptStore.clear(); // need for reload case
7158 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
7159
7160 if (!result)
7161 {
7162 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
7163 LOG_INFO("server.loading", " ");
7164 return;
7165 }
7166
7167 uint32 count = 0;
7168
7169 do
7170 {
7171 ++count;
7172
7173 Field* fields = result->Fetch();
7174
7175 uint32 Trigger_ID = fields[0].Get<uint32>();
7176 std::string scriptName = fields[1].Get<std::string>();
7177
7178 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
7179 if (!atEntry)
7180 {
7181 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
7182 continue;
7183 }
7184 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
7185 } while (result->NextRow());
7186
7187 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7188 LOG_INFO("server.loading", " ");
7189}
uint32 GetScriptId(std::string const &name)
Definition ObjectMgr.cpp:10499

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

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
7351{
7352 uint32 oldMSTime = getMSTime();
7353
7354 _areaTriggerTeleportStore.clear(); // need for reload case
7355
7356 // 0 1 2 3 4 5
7357 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
7358
7359 if (!result)
7360 {
7361 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
7362 LOG_INFO("server.loading", " ");
7363 return;
7364 }
7365
7366 uint32 count = 0;
7367
7368 do
7369 {
7370 Field* fields = result->Fetch();
7371
7372 ++count;
7373
7374 uint32 Trigger_ID = fields[0].Get<uint32>();
7375
7377
7378 at.target_mapId = fields[1].Get<uint16>();
7379 at.target_X = fields[2].Get<float>();
7380 at.target_Y = fields[3].Get<float>();
7381 at.target_Z = fields[4].Get<float>();
7382 at.target_Orientation = fields[5].Get<float>();
7383
7384 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
7385 if (!atEntry)
7386 {
7387 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
7388 continue;
7389 }
7390
7391 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
7392 if (!mapEntry)
7393 {
7394 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
7395 continue;
7396 }
7397
7398 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
7399 {
7400 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
7401 continue;
7402 }
7403
7404 _areaTriggerTeleportStore[Trigger_ID] = at;
7405 } while (result->NextRow());
7406
7407 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7408 LOG_INFO("server.loading", " ");
7409}
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 ( )
10599{
10600 uint32 oldMSTime = getMSTime();
10601
10602 // 0 1 2 3
10603 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
10604
10605 if (!result)
10606 {
10607 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
10608 LOG_INFO("server.loading", " ");
10609 return;
10610 }
10611
10612 uint32 locales_count = 0;
10613 do
10614 {
10615 Field* fields = result->Fetch();
10616
10617 uint32 id = fields[0].Get<uint32>();
10618
10619 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
10620 if (bct == _broadcastTextStore.end())
10621 {
10622 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
10623 continue;
10624 }
10625
10626 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
10627 if (locale == LOCALE_enUS)
10628 continue;
10629
10630 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
10631 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
10632 locales_count++;
10633 } while (result->NextRow());
10634
10635 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
10636 LOG_INFO("server.loading", " ");
10637}
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:42

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

◆ LoadBroadcastTexts()

void ObjectMgr::LoadBroadcastTexts ( )
10514{
10515 uint32 oldMSTime = getMSTime();
10516
10517 _broadcastTextStore.clear(); // for reload case
10518
10519 // 0 1 2 3 4 5 6 7 8 9 10 11 12
10520 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
10521 if (!result)
10522 {
10523 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
10524 LOG_INFO("server.loading", " ");
10525 return;
10526 }
10527
10528 _broadcastTextStore.rehash(result->GetRowCount());
10529
10530 do
10531 {
10532 Field* fields = result->Fetch();
10533
10534 BroadcastText bct;
10535
10536 bct.Id = fields[0].Get<uint32>();
10537 bct.LanguageID = fields[1].Get<uint32>();
10538 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
10539 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
10540 bct.EmoteId1 = fields[4].Get<uint32>();
10541 bct.EmoteId2 = fields[5].Get<uint32>();
10542 bct.EmoteId3 = fields[6].Get<uint32>();
10543 bct.EmoteDelay1 = fields[7].Get<uint32>();
10544 bct.EmoteDelay2 = fields[8].Get<uint32>();
10545 bct.EmoteDelay3 = fields[9].Get<uint32>();
10546 bct.SoundEntriesId = fields[10].Get<uint32>();
10547 bct.EmotesID = fields[11].Get<uint32>();
10548 bct.Flags = fields[12].Get<uint32>();
10549
10550 if (bct.SoundEntriesId)
10551 {
10552 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
10553 {
10554 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
10555 bct.SoundEntriesId = 0;
10556 }
10557 }
10558
10560 {
10561 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
10563 }
10564
10565 if (bct.EmoteId1)
10566 {
10567 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
10568 {
10569 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
10570 bct.EmoteId1 = 0;
10571 }
10572 }
10573
10574 if (bct.EmoteId2)
10575 {
10576 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
10577 {
10578 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
10579 bct.EmoteId2 = 0;
10580 }
10581 }
10582
10583 if (bct.EmoteId3)
10584 {
10585 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
10586 {
10587 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
10588 bct.EmoteId3 = 0;
10589 }
10590 }
10591
10592 _broadcastTextStore[bct.Id] = bct;
10593 } while (result->NextRow());
10594
10595 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
10596}
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition ObjectMgr.cpp:254
@ LANG_UNIVERSAL
Definition SharedDefines.h:723
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 ( )
1263{
1264 uint32 oldMSTime = getMSTime();
1265
1266 // 0 1 2 3 4 5 6 7
1267 QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_addon");
1268
1269 if (!result)
1270 {
1271 LOG_WARN("server.loading", ">> Loaded 0 creature addon definitions. DB table `creature_addon` is empty.");
1272 LOG_INFO("server.loading", " ");
1273 return;
1274 }
1275
1276 uint32 count = 0;
1277 do
1278 {
1279 Field* fields = result->Fetch();
1280
1281 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1282
1283 CreatureData const* creData = GetCreatureData(guid);
1284 if (!creData)
1285 {
1286 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_addon`", guid);
1287 continue;
1288 }
1289
1290 CreatureAddon& creatureAddon = _creatureAddonStore[guid];
1291
1292 creatureAddon.path_id = fields[1].Get<uint32>();
1293 if (creData->movementType == WAYPOINT_MOTION_TYPE && !creatureAddon.path_id)
1294 {
1295 const_cast<CreatureData*>(creData)->movementType = IDLE_MOTION_TYPE;
1296 LOG_ERROR("sql.sql", "Creature (GUID {}) has movement type set to WAYPOINT_MOTION_TYPE but no path assigned", guid);
1297 }
1298
1299 creatureAddon.mount = fields[2].Get<uint32>();
1300 creatureAddon.bytes1 = fields[3].Get<uint32>();
1301 creatureAddon.bytes2 = fields[4].Get<uint32>();
1302 creatureAddon.emote = fields[5].Get<uint32>();
1303 creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].Get<uint8>());
1304
1305 for (std::string_view aura : Acore::Tokenize(fields[7].Get<std::string_view>(), ' ', false))
1306 {
1307 SpellInfo const* spellInfo = nullptr;
1308
1309 if (Optional<uint32> spellId = Acore::StringTo<uint32>(aura))
1310 {
1311 spellInfo = sSpellMgr->GetSpellInfo(*spellId);
1312 }
1313
1314 if (!spellInfo)
1315 {
1316 LOG_ERROR("sql.sql", "Creature (GUID: {}) has wrong spell '{}' defined in `auras` field in `creature_addon`.", guid, aura);
1317 continue;
1318 }
1319
1320 if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
1321 {
1322 LOG_ERROR("sql.sql", "Creature (GUID: {}) has duplicate aura (spell {}) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
1323 continue;
1324 }
1325
1326 if (spellInfo->GetDuration() > 0)
1327 {
1328 LOG_DEBUG/*ERROR*/("sql.sql", "Creature (Entry: {}) has temporary aura (spell {}) in `auras` field in `creature_template_addon`.", guid, spellInfo->Id);
1329 // continue;
1330 }
1331
1332 creatureAddon.auras.push_back(spellInfo->Id);
1333 }
1334
1335 if (creatureAddon.mount)
1336 {
1337 if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
1338 {
1339 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid displayInfoId ({}) for mount defined in `creature_addon`", guid, creatureAddon.mount);
1340 creatureAddon.mount = 0;
1341 }
1342 }
1343
1344 if (!sEmotesStore.LookupEntry(creatureAddon.emote))
1345 {
1346 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid emote ({}) defined in `creature_addon`.", guid, creatureAddon.emote);
1347 creatureAddon.emote = 0;
1348 }
1349
1351 {
1352 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid visibilityDistanceType ({}) defined in `creature_addon`.", guid, AsUnderlyingType(creatureAddon.visibilityDistanceType));
1354 }
1355
1356 ++count;
1357 } while (result->NextRow());
1358
1359 LOG_INFO("server.loading", ">> Loaded {} Creature Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1360 LOG_INFO("server.loading", " ");
1361}
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ WAYPOINT_MOTION_TYPE
Definition MotionMaster.h:41
VisibilityDistanceType
Definition ObjectDefines.h:62
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:610
uint32 Id
Definition SpellInfo.h:344
int32 GetDuration() const
Definition SpellInfo.cpp:2738
Definition AsioHacksFwd.h:47
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Tokenize.cpp:20
STL namespace.
Definition CreatureData.h:431
std::vector< uint32 > auras
Definition CreatureData.h:437
uint32 mount
Definition CreatureData.h:433
uint32 emote
Definition CreatureData.h:436
uint32 path_id
Definition CreatureData.h:432
VisibilityDistanceType visibilityDistanceType
Definition CreatureData.h:438
uint32 bytes1
Definition CreatureData.h:434
uint32 bytes2
Definition CreatureData.h:435

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, Max, CreatureAddon::mount, Normal, CreatureAddon::path_id, sCreatureDisplayInfoStore, sEmotesStore, sSpellMgr, Acore::Tokenize(), CreatureAddon::visibilityDistanceType, WAYPOINT_MOTION_TYPE, and WorldDatabase.

◆ LoadCreatureClassLevelStats()

void ObjectMgr::LoadCreatureClassLevelStats ( )
10671{
10672 uint32 oldMSTime = getMSTime();
10673
10674 QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2, Strength, Agility, Stamina, Intellect, Spirit FROM creature_classlevelstats");
10675
10676 if (!result)
10677 {
10678 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
10679 LOG_INFO("server.loading", " ");
10680 return;
10681 }
10682
10683 uint32 count = 0;
10684 do
10685 {
10686 Field* fields = result->Fetch();
10687
10688 uint8 Level = fields[0].Get<uint8>();
10689 uint8 Class = fields[1].Get<uint8>();
10690
10691 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
10692 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
10693
10694 CreatureBaseStats stats;
10695
10696 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
10697 {
10698 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
10699
10700 if (stats.BaseHealth[i] == 0)
10701 {
10702 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
10703 stats.BaseHealth[i] = 1;
10704 }
10705
10706 // xinef: if no data is available, get them from lower expansions
10707 if (stats.BaseHealth[i] <= 1)
10708 {
10709 for (uint8 j = i; j > 0;)
10710 {
10711 --j;
10712 if (stats.BaseHealth[j] > 1)
10713 {
10714 stats.BaseHealth[i] = stats.BaseHealth[j];
10715 break;
10716 }
10717 }
10718 }
10719
10720 stats.BaseDamage[i] = fields[9 + i].Get<float>();
10721 if (stats.BaseDamage[i] < 0.0f)
10722 {
10723 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
10724 stats.BaseDamage[i] = 0.0f;
10725 }
10726 }
10727
10728 stats.BaseMana = fields[5].Get<uint32>();
10729 stats.BaseArmor = fields[6].Get<uint32>();
10730
10731 stats.AttackPower = fields[7].Get<uint32>();
10732 stats.RangedAttackPower = fields[8].Get<uint32>();
10733
10734 stats.Strength = fields[12].Get<uint32>();
10735 stats.Agility = fields[13].Get<uint32>();
10736 stats.Stamina = fields[14].Get<uint32>();
10737 stats.Intellect = fields[15].Get<uint32>();
10738 stats.Spirit = fields[16].Get<uint32>();
10739
10740 if (!stats.Strength || !stats.Agility || !stats.Stamina || !stats.Intellect || !stats.Spirit)
10741 {
10742 // Once these attributes are implemented, this should probably be uncommented.
10743 // LOG_WARN("server.loading", "Creature base attributes for class {}, level {} are missing!", Class, Level);
10744 }
10745
10747
10748 ++count;
10749 } while (result->NextRow());
10750
10752 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
10753 {
10754 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
10755 {
10756 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
10757 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
10758 }
10759 }
10760
10761 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10762 LOG_INFO("server.loading", " ");
10763}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:287
@ Class
Requires the player to be a specific class.
@ Level
Requires the player to be at least a specific level.
CreatureTemplateContainer const * GetCreatureTemplates() const
Definition ObjectMgr.h:772
uint32 BaseMana
Definition CreatureData.h:300
uint32 Agility
Definition CreatureData.h:306
float BaseDamage[MAX_EXPANSIONS]
Definition CreatureData.h:304
uint32 RangedAttackPower
Definition CreatureData.h:303
uint32 AttackPower
Definition CreatureData.h:302
uint32 BaseHealth[MAX_EXPANSIONS]
Definition CreatureData.h:299
uint32 Strength
Definition CreatureData.h:305
float BaseArmor
Definition CreatureData.h:301
uint32 Spirit
Definition CreatureData.h:309
uint32 Stamina
Definition CreatureData.h:307
uint32 Intellect
Definition CreatureData.h:308

References _creatureBaseStatsStore, CreatureBaseStats::Agility, CreatureBaseStats::AttackPower, CreatureBaseStats::BaseArmor, CreatureBaseStats::BaseDamage, CreatureBaseStats::BaseHealth, CreatureBaseStats::BaseMana, Class, CLASSMASK_ALL_CREATURES, Field::Get(), GetCreatureTemplates(), getMSTime(), GetMSTimeDiffToNow(), CreatureBaseStats::Intellect, Level, LOG_ERROR, LOG_INFO, LOG_WARN, MAKE_PAIR16(), MAX_EXPANSIONS, CreatureBaseStats::RangedAttackPower, CreatureBaseStats::Spirit, CreatureBaseStats::Stamina, CreatureBaseStats::Strength, and WorldDatabase.

◆ LoadCreatureCustomIDs()

void ObjectMgr::LoadCreatureCustomIDs ( )

Load config option Creatures.CustomIDs into Store.

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

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

◆ LoadCreatureDataFromDB()

CreatureData const * ObjectMgr::LoadCreatureDataFromDB ( ObjectGuid::LowType  spawnId)

Loads a single creature spawn entry from the database into the data store cache.

This is needed as a prerequisite for Creature::LoadCreatureFromDB(), which reads from the in-memory cache (via GetCreatureData()) rather than querying the DB itself. For spawns not loaded during server startup, this method populates the cache so that Creature::LoadCreatureFromDB() can then create the live entity.

Returns the cached data if already loaded, or nullptr if the spawn doesn't exist or fails validation.

Parameters
spawnIdThe creature spawn GUID to load.
Returns
Pointer to the cached CreatureData, or nullptr on failure.
2526{
2527 CreatureData const* data = GetCreatureData(spawnId);
2528 if (data)
2529 return data;
2530
2531 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, "
2532 "position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2533 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, "
2534 "creature.npcflag, creature.unit_flags, creature.dynamicflags, creature.ScriptName "
2535 "FROM creature WHERE creature.guid = {}", spawnId);
2536
2537 if (!result)
2538 return nullptr;
2539
2540 Field* fields = result->Fetch();
2541 uint32 id1 = fields[1].Get<uint32>();
2542 uint32 id2 = fields[2].Get<uint32>();
2543 uint32 id3 = fields[3].Get<uint32>();
2544
2545 CreatureTemplate const* cInfo = GetCreatureTemplate(id1);
2546 if (!cInfo)
2547 {
2548 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in id1 field, skipped.", spawnId, id1);
2549 return nullptr;
2550 }
2551
2552 if (id2 && !GetCreatureTemplate(id2))
2553 {
2554 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in id2 field, skipped.", spawnId, id2);
2555 return nullptr;
2556 }
2557
2558 if (id3 && !GetCreatureTemplate(id3))
2559 {
2560 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in id3 field, skipped.", spawnId, id3);
2561 return nullptr;
2562 }
2563
2564 if (!id2 && id3)
2565 {
2566 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3);
2567 return nullptr;
2568 }
2569
2571 creatureData.id1 = id1;
2572 creatureData.id2 = id2;
2573 creatureData.id3 = id3;
2574 creatureData.mapid = fields[4].Get<uint16>();
2575 creatureData.equipmentId = fields[5].Get<int8>();
2576 creatureData.posX = fields[6].Get<float>();
2577 creatureData.posY = fields[7].Get<float>();
2578 creatureData.posZ = fields[8].Get<float>();
2579 creatureData.orientation = fields[9].Get<float>();
2580 creatureData.spawntimesecs = fields[10].Get<uint32>();
2581 creatureData.wander_distance = fields[11].Get<float>();
2582 creatureData.currentwaypoint = fields[12].Get<uint32>();
2583 creatureData.curhealth = fields[13].Get<uint32>();
2584 creatureData.curmana = fields[14].Get<uint32>();
2585 creatureData.movementType = fields[15].Get<uint8>();
2586 creatureData.spawnMask = fields[16].Get<uint8>();
2587 creatureData.phaseMask = fields[17].Get<uint32>();
2588 creatureData.npcflag = fields[18].Get<uint32>();
2589 creatureData.unit_flags = fields[19].Get<uint32>();
2590 creatureData.dynamicflags = fields[20].Get<uint32>();
2591 creatureData.ScriptId = GetScriptId(fields[21].Get<std::string>());
2592 creatureData.spawnGroupId = 0;
2593
2594 if (!creatureData.ScriptId)
2595 creatureData.ScriptId = cInfo->ScriptID;
2596
2597 MapEntry const* mapEntry = sMapStore.LookupEntry(creatureData.mapid);
2598 if (!mapEntry)
2599 {
2600 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) that spawned at non-existing map (Id: {}), skipped.", spawnId, creatureData.mapid);
2601 _creatureDataStore.erase(spawnId);
2602 return nullptr;
2603 }
2604
2605 if (mapEntry->IsRaid() && creatureData.spawntimesecs >= 7 * DAY && creatureData.spawntimesecs < 14 * DAY)
2606 creatureData.spawntimesecs = 14 * DAY;
2607
2608 bool ok = true;
2609 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2610 {
2611 if (_difficultyEntries[diff].find(id1) != _difficultyEntries[diff].end() ||
2612 _difficultyEntries[diff].find(id2) != _difficultyEntries[diff].end() ||
2613 _difficultyEntries[diff].find(id3) != _difficultyEntries[diff].end())
2614 {
2615 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) that is listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.",
2616 spawnId, diff + 1, id1, id2, id3);
2617 ok = false;
2618 }
2619 }
2620
2621 if (!ok)
2622 {
2623 _creatureDataStore.erase(spawnId);
2624 return nullptr;
2625 }
2626
2627 if (creatureData.equipmentId != 0)
2628 {
2629 if (!GetEquipmentInfo(id1, creatureData.equipmentId) ||
2630 (id2 && !GetEquipmentInfo(id2, creatureData.equipmentId)) ||
2631 (id3 && !GetEquipmentInfo(id3, creatureData.equipmentId)))
2632 {
2633 LOG_ERROR("sql.sql", "Table `creature` has creature (Entries: {}, {}, {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.",
2634 id1, id2, id3, creatureData.equipmentId);
2635 creatureData.equipmentId = 0;
2636 }
2637 }
2638
2639 if (creatureData.movementType >= MAX_DB_MOTION_TYPE)
2640 {
2641 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with wrong movement generator type ({}), set to IDLE.",
2642 spawnId, id1, id2, id3, creatureData.movementType);
2643 creatureData.movementType = IDLE_MOTION_TYPE;
2644 }
2645
2646 if (creatureData.wander_distance < 0.0f)
2647 {
2648 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.",
2649 spawnId, id1, id2, id3);
2650 creatureData.wander_distance = 0.0f;
2651 }
2652 else if (creatureData.movementType == RANDOM_MOTION_TYPE)
2653 {
2654 if (creatureData.wander_distance == 0.0f)
2655 {
2656 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).",
2657 spawnId, id1, id2, id3);
2658 creatureData.movementType = IDLE_MOTION_TYPE;
2659 }
2660 }
2661 else if (creatureData.movementType == IDLE_MOTION_TYPE)
2662 {
2663 if (creatureData.wander_distance != 0.0f)
2664 {
2665 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.",
2666 spawnId, id1, id2, id3);
2667 creatureData.wander_distance = 0.0f;
2668 }
2669 }
2670
2671 if (creatureData.phaseMask == 0)
2672 {
2673 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `phaseMask`=0 (not visible for anyone), set to 1.",
2674 spawnId, id1, id2, id3);
2675 creatureData.phaseMask = 1;
2676 }
2677
2678 return &creatureData;
2679}
constexpr auto DAY
Definition Common.h:49
std::int8_t int8
Definition Define.h:105
@ RANDOM_MOTION_TYPE
Definition MotionMaster.h:40
EquipmentInfo const * GetEquipmentInfo(uint32 entry, int8 &id)
Definition ObjectMgr.cpp:1454
ObjectData const creatureData[]
Definition instance_blackwing_lair.cpp:45
bool IsRaid() const
Definition DBCStructure.h:1354

References _creatureDataStore, _difficultyEntries, creatureData, DAY, Field::Get(), GetCreatureData(), GetCreatureTemplate(), GetEquipmentInfo(), GetScriptId(), IDLE_MOTION_TYPE, MapEntry::IsRaid(), LOG_ERROR, MAX_DB_MOTION_TYPE, MAX_DIFFICULTY, RANDOM_MOTION_TYPE, sMapStore, and WorldDatabase.

◆ LoadCreatureDefaultTrainers()

void ObjectMgr::LoadCreatureDefaultTrainers ( )
10059{
10060 uint32 oldMSTime = getMSTime();
10061
10063
10064 if (QueryResult result = WorldDatabase.Query("SELECT CreatureId, TrainerId FROM creature_default_trainer"))
10065 {
10066 do
10067 {
10068 Field* fields = result->Fetch();
10069 uint32 creatureId = fields[0].Get<uint32>();
10070 uint32 trainerId = fields[1].Get<uint32>();
10071
10072 if (!GetCreatureTemplate(creatureId))
10073 {
10074 LOG_ERROR("sql.sql", "Table `creature_default_trainer` references non-existing creature template (CreatureId: %u), ignoring", creatureId);
10075 continue;
10076 }
10077
10078 _creatureDefaultTrainers[creatureId] = trainerId;
10079
10080 } while (result->NextRow());
10081 }
10082
10083 LOG_INFO("server.loading", ">> Loaded {} default trainers in {} ms", _creatureDefaultTrainers.size(), GetMSTimeDiffToNow(oldMSTime));
10084}

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

◆ LoadCreatureLocales()

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

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

◆ LoadCreatureModelInfo()

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

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

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 ( )
8976{
8977 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8978
8979 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8980 {
8981 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8982 if (!cInfo)
8983 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8984 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8985 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);
8986 }
8987}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition UnitDefines.h:323
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition ObjectMgr.cpp:8888

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
11084{
11085 uint32 oldMSTime = getMSTime();
11086
11087 // 0 1 2
11088 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
11089
11090 if (!result)
11091 {
11092 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
11093 return;
11094 }
11095
11096 uint32 count = 0;
11097 do
11098 {
11099 Field* fields = result->Fetch();
11100
11101 uint32 entry = fields[0].Get<uint32>();
11102 uint32 item = fields[1].Get<uint32>();
11103 uint32 idx = fields[2].Get<uint32>();
11104
11105 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
11106 if (!creatureInfo)
11107 {
11108 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
11109 continue;
11110 };
11111
11112 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
11113 if (!dbcData)
11114 {
11115 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
11116 continue;
11117 };
11118
11119 _creatureQuestItemStore[entry].push_back(item);
11120
11121 ++count;
11122 } while (result->NextRow());
11123
11124 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11125 LOG_INFO("server.loading", " ");
11126}
DBCStorage< ItemEntry > sItemStore(Itemfmt)
Definition DBCStructure.h:1143

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

◆ LoadCreatureQuestStarters()

void ObjectMgr::LoadCreatureQuestStarters ( )
8962{
8963 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8964
8965 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8966 {
8967 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8968 if (!cInfo)
8969 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8970 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8971 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);
8972 }
8973}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

void ObjectMgr::LoadCreatures ( )
2318{
2319 uint32 oldMSTime = getMSTime();
2320
2321 // 0 1 2 3 4 5 6 7 8 9 10 11
2322 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2323 // 12 13 14 15 16 17 18 19 20 21 22
2324 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
2325 // 23
2326 "creature.ScriptName "
2327 "FROM creature "
2328 "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
2329 "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
2330
2331 if (!result)
2332 {
2333 LOG_WARN("server.loading", ">> Loaded 0 creatures. DB table `creature` is empty.");
2334 LOG_INFO("server.loading", " ");
2335 return;
2336 }
2337
2339 LOG_INFO("server.loading", "Calculating zone and area fields. This may take a moment...");
2340
2341 // Build single time for check spawnmask
2342 std::map<uint32, uint32> spawnMasks;
2343 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2344 if (sMapStore.LookupEntry(i))
2345 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2347 spawnMasks[i] |= (1 << k);
2348
2349 _creatureDataStore.rehash(result->GetRowCount());
2350 uint32 count = 0;
2351 do
2352 {
2353 Field* fields = result->Fetch();
2354
2355 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2356 uint32 id1 = fields[1].Get<uint32>();
2357 uint32 id2 = fields[2].Get<uint32>();
2358 uint32 id3 = fields[3].Get<uint32>();
2359
2360 CreatureTemplate const* cInfo = GetCreatureTemplate(id1);
2361 if (!cInfo)
2362 {
2363 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id1 field, skipped.", spawnId, id1);
2364 continue;
2365 }
2366 CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2);
2367 if (!cInfo2 && id2)
2368 {
2369 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id2 field, skipped.", spawnId, id2);
2370 continue;
2371 }
2372 CreatureTemplate const* cInfo3 = GetCreatureTemplate(id3);
2373 if (!cInfo3 && id3)
2374 {
2375 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id3 field, skipped.", spawnId, id3);
2376 continue;
2377 }
2378 if (!id2 && id3)
2379 {
2380 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3);
2381 continue;
2382 }
2383 CreatureData& data = _creatureDataStore[spawnId];
2384 data.spawnId = spawnId;
2385 data.id1 = id1;
2386 data.id2 = id2;
2387 data.id3 = id3;
2388 data.mapid = fields[4].Get<uint16>();
2389 data.equipmentId = fields[5].Get<int8>();
2390 data.posX = fields[6].Get<float>();
2391 data.posY = fields[7].Get<float>();
2392 data.posZ = fields[8].Get<float>();
2393 data.orientation = fields[9].Get<float>();
2394 data.spawntimesecs = fields[10].Get<uint32>();
2395 data.wander_distance = fields[11].Get<float>();
2396 data.currentwaypoint = fields[12].Get<uint32>();
2397 data.curhealth = fields[13].Get<uint32>();
2398 data.curmana = fields[14].Get<uint32>();
2399 data.movementType = fields[15].Get<uint8>();
2400 data.spawnMask = fields[16].Get<uint8>();
2401 data.phaseMask = fields[17].Get<uint32>();
2402 int16 gameEvent = fields[18].Get<int16>();
2403 uint32 PoolId = fields[19].Get<uint32>();
2404 data.npcflag = fields[20].Get<uint32>();
2405 data.unit_flags = fields[21].Get<uint32>();
2406 data.dynamicflags = fields[22].Get<uint32>();
2407 data.ScriptId = GetScriptId(fields[23].Get<std::string>());
2408 data.spawnGroupId = 0;
2409
2410 if (!data.ScriptId)
2411 data.ScriptId = cInfo->ScriptID;
2412
2413 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2414 if (!mapEntry)
2415 {
2416 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that spawned at not existed map (Id: {}), skipped.", spawnId, data.mapid);
2417 continue;
2418 }
2419
2420 // pussywizard: 7 days means no reaspawn, so set it to 14 days, because manual id reset may be late
2421 if (mapEntry->IsRaid() && data.spawntimesecs >= 7 * DAY && data.spawntimesecs < 14 * DAY)
2422 data.spawntimesecs = 14 * DAY;
2423
2424 // Skip spawnMask check for transport maps
2425 if (!_transportMaps.count(data.mapid))
2426 {
2427 if (data.spawnMask & ~spawnMasks[data.mapid])
2428 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that have wrong spawn mask {} including not supported difficulty modes for map (Id: {}).",
2429 spawnId, data.spawnMask, data.mapid);
2430 }
2431 else
2432 data.spawnGroupId = 1; // force compatibility group for transport spawns
2433
2434 bool ok = true;
2435 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2436 {
2437 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()))
2438 {
2439 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.",
2440 spawnId, diff + 1, data.id1, data.id2, data.id3);
2441 ok = false;
2442 }
2443 }
2444 if (!ok)
2445 continue;
2446
2447 // -1 random, 0 no equipment,
2448 if (data.equipmentId != 0)
2449 {
2450 if ((!GetEquipmentInfo(data.id1, data.equipmentId)) || (data.id2 && !GetEquipmentInfo(data.id2, data.equipmentId)) || (data.id3 && !GetEquipmentInfo(data.id3, data.equipmentId)))
2451 {
2452 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.",
2453 data.id1, data.id2, data.id3, data.equipmentId);
2454 data.equipmentId = 0;
2455 }
2456 }
2458 {
2459 if (!mapEntry->IsDungeon())
2460 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.",
2461 spawnId, data.id1, data.id2, data.id3);
2462 }
2463 if (data.movementType >= MAX_DB_MOTION_TYPE)
2464 {
2465 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);
2467 }
2468 if (data.wander_distance < 0.0f)
2469 {
2470 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", spawnId, data.id1, data.id2, data.id3);
2471 data.wander_distance = 0.0f;
2472 }
2473 else if (data.movementType == RANDOM_MOTION_TYPE)
2474 {
2475 if (data.wander_distance == 0.0f)
2476 {
2477 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).",
2478 spawnId, data.id1, data.id2, data.id3);
2480 }
2481 }
2482 else if (data.movementType == IDLE_MOTION_TYPE)
2483 {
2484 if (data.wander_distance != 0.0f)
2485 {
2486 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);
2487 data.wander_distance = 0.0f;
2488 }
2489 }
2490
2491 if (data.phaseMask == 0)
2492 {
2493 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);
2494 data.phaseMask = 1;
2495 }
2496
2498 {
2499 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2500 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2501
2503
2504 stmt->SetData(0, zoneId);
2505 stmt->SetData(1, areaId);
2506 stmt->SetData(2, spawnId);
2507
2508 WorldDatabase.Execute(stmt);
2509 }
2510
2511 // Add to grid if not managed by the game event or pool system
2512 if (gameEvent == 0 && PoolId == 0)
2513 AddCreatureToGrid(spawnId, &data);
2514
2515 ++count;
2516 } while (result->NextRow());
2517
2518 LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2519 LOG_INFO("server.loading", " ");
2520}
@ CREATURE_FLAG_EXTRA_INSTANCE_BIND
Definition CreatureData.h:46
Difficulty
Definition DBCEnums.h:266
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition DBCStores.cpp:761
std::int16_t int16
Definition Define.h:104
@ CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA
Definition WorldConfig.h:116
@ WORLD_UPD_CREATURE_ZONE_AREA_DATA
Definition WorldDatabase.h:114
bool HasFlagsExtra(uint32 flag) const
Definition CreatureData.h:278
uint32 ScriptId
Definition SpawnData.h:76

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, Field::Get(), GetCreatureTemplate(), GetEquipmentInfo(), GetMapDifficultyData(), getMSTime(), GetMSTimeDiffToNow(), GetScriptId(), CreatureTemplate::HasFlagsExtra(), CreatureData::id1, CreatureData::id2, CreatureData::id3, IDLE_MOTION_TYPE, MapEntry::IsDungeon(), MapEntry::IsRaid(), LOG_ERROR, LOG_INFO, LOG_WARN, SpawnData::mapid, MAX_DB_MOTION_TYPE, MAX_DIFFICULTY, CreatureData::movementType, CreatureData::npcflag, SpawnData::orientation, SpawnData::phaseMask, SpawnData::posX, SpawnData::posY, SpawnData::posZ, RANDOM_MOTION_TYPE, SpawnData::ScriptId, PreparedStatementBase::SetData(), sMapMgr, sMapStore, SpawnData::spawnGroupId, SpawnData::spawnId, SpawnData::spawnMask, CreatureData::spawntimesecs, sWorld, CreatureData::unit_flags, CreatureData::wander_distance, WORLD_UPD_CREATURE_ZONE_AREA_DATA, and WorldDatabase.

◆ LoadCreatureSparring()

void ObjectMgr::LoadCreatureSparring ( )
2682{
2683 uint32 oldMSTime = getMSTime();
2684
2685 QueryResult result = WorldDatabase.Query("SELECT GUID, SparringPCT FROM creature_sparring");
2686
2687 if (!result)
2688 {
2689 LOG_WARN("server.loading", ">> Loaded 0 sparring data. DB table `creature_sparring` is empty.");
2690 LOG_INFO("server.loading", " ");
2691 return;
2692 }
2693
2694 uint32 count = 0;
2695 do
2696 {
2697 Field* fields = result->Fetch();
2698
2699 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2700 float sparringHealthPct = fields[1].Get<float>();
2701
2702 if (!GetCreatureData(spawnId))
2703 {
2704 LOG_ERROR("sql.sql", "Entry {} has a record in `creature_sparring` but doesn't exist in `creatures` table");
2705 continue;
2706 }
2707
2708 _creatureSparringStore[spawnId].push_back(sparringHealthPct);
2709
2710 ++count;
2711 } while (result->NextRow());
2712
2713 LOG_INFO("server.loading", ">> Loaded {} sparring data in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2714 LOG_INFO("server.loading", " ");
2715}

References _creatureSparringStore, Field::Get(), GetCreatureData(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, 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.
586{
587 uint32 entry = fields[0].Get<uint32>();
588
589 CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry];
590
591 // enlarge the fast cache as necessary
592 if (_creatureTemplateStoreFast.size() < entry + 1)
593 {
594 _creatureTemplateStoreFast.resize(entry + 1, nullptr);
595 }
596
597 // load a pointer to this creatureTemplate into the fast cache
598 _creatureTemplateStoreFast[entry] = &creatureTemplate;
599
600 // build the creatureTemplate
601 creatureTemplate.Entry = entry;
602
603 for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
604 {
605 creatureTemplate.DifficultyEntry[i] = fields[1 + i].Get<uint32>();
606 }
607
608 for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
609 {
610 creatureTemplate.KillCredit[i] = fields[4 + i].Get<uint32>();
611 }
612 creatureTemplate.Name = fields[6].Get<std::string>();
613 creatureTemplate.SubName = fields[7].Get<std::string>();
614 creatureTemplate.IconName = fields[8].Get<std::string>();
615 creatureTemplate.GossipMenuId = fields[9].Get<uint32>();
616 creatureTemplate.minlevel = fields[10].Get<uint8>();
617 creatureTemplate.maxlevel = fields[11].Get<uint8>();
618 creatureTemplate.expansion = uint32(fields[12].Get<int16>());
619 creatureTemplate.faction = uint32(fields[13].Get<uint16>());
620 creatureTemplate.npcflag = fields[14].Get<uint32>();
621 creatureTemplate.speed_walk = fields[15].Get<float>();
622 creatureTemplate.speed_run = fields[16].Get<float>();
623 creatureTemplate.speed_swim = fields[17].Get<float>();
624 creatureTemplate.speed_flight = fields[18].Get<float>();
625 creatureTemplate.detection_range = fields[19].Get<float>();
626 creatureTemplate.rank = uint32(fields[20].Get<uint8>());
627 creatureTemplate.dmgschool = uint32(fields[21].Get<int8>());
628 creatureTemplate.DamageModifier = fields[22].Get<float>();
629 creatureTemplate.BaseAttackTime = fields[23].Get<uint32>();
630 creatureTemplate.RangeAttackTime = fields[24].Get<uint32>();
631 creatureTemplate.BaseVariance = fields[25].Get<float>();
632 creatureTemplate.RangeVariance = fields[26].Get<float>();
633 creatureTemplate.unit_class = uint32(fields[27].Get<uint8>());
634 creatureTemplate.unit_flags = fields[28].Get<uint32>();
635 creatureTemplate.unit_flags2 = fields[29].Get<uint32>();
636 creatureTemplate.dynamicflags = fields[30].Get<uint32>();
637 creatureTemplate.family = uint32(fields[31].Get<uint8>());
638 creatureTemplate.type = uint32(fields[32].Get<uint8>());
639 creatureTemplate.type_flags = fields[33].Get<uint32>();
640 creatureTemplate.lootid = fields[34].Get<uint32>();
641 creatureTemplate.pickpocketLootId = fields[35].Get<uint32>();
642 creatureTemplate.SkinLootId = fields[36].Get<uint32>();
643
644 for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
645 {
646 creatureTemplate.resistance[i] = 0;
647 }
648
649 for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i)
650 {
651 creatureTemplate.spells[i] = 0;
652 }
653
654 creatureTemplate.PetSpellDataId = fields[37].Get<uint32>();
655 creatureTemplate.VehicleId = fields[38].Get<uint32>();
656 creatureTemplate.mingold = fields[39].Get<uint32>();
657 creatureTemplate.maxgold = fields[40].Get<uint32>();
658 creatureTemplate.AIName = fields[41].Get<std::string>();
659 creatureTemplate.MovementType = uint32(fields[42].Get<uint8>());
660 if (!fields[43].IsNull())
661 {
662 creatureTemplate.Movement.Ground = static_cast<CreatureGroundMovementType>(fields[43].Get<uint8>());
663 }
664
665 creatureTemplate.Movement.Swim = fields[44].Get<bool>();
666 if (!fields[45].IsNull())
667 {
668 creatureTemplate.Movement.Flight = static_cast<CreatureFlightMovementType>(fields[45].Get<uint8>());
669 }
670
671 creatureTemplate.Movement.Rooted = fields[46].Get<bool>();
672 if (!fields[47].IsNull())
673 {
674 creatureTemplate.Movement.Chase = static_cast<CreatureChaseMovementType>(fields[47].Get<uint8>());
675 }
676 if (!fields[48].IsNull())
677 {
678 creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[48].Get<uint8>());
679 }
680 if (!fields[49].IsNull())
681 {
682 creatureTemplate.Movement.InteractionPauseTimer = fields[49].Get<uint32>();
683 }
684
685 creatureTemplate.HoverHeight = fields[50].Get<float>();
686 creatureTemplate.ModHealth = fields[51].Get<float>();
687 creatureTemplate.ModMana = fields[52].Get<float>();
688 creatureTemplate.ModArmor = fields[53].Get<float>();
689 creatureTemplate.ModExperience = fields[54].Get<float>();
690 creatureTemplate.RacialLeader = fields[55].Get<bool>();
691 creatureTemplate.movementId = fields[56].Get<uint32>();
692 creatureTemplate.RegenHealth = fields[57].Get<bool>();
693 creatureTemplate.CreatureImmunitiesId = fields[58].Get<int32>();
694 creatureTemplate.flags_extra = fields[59].Get<uint32>();
695 creatureTemplate.ScriptID = GetScriptId(fields[60].Get<std::string>());
696
697 // Warn about deprecated immunity flags that should be moved to `creature_immunities` table
698 if (creatureTemplate.flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT)
699 LOG_WARN("server.loading", "Creature (Entry: {}) has deprecated flags_extra bit NO_TAUNT (0x100) set. This will be migrated to the `creature_immunities` table in a future update.", entry);
700 if (creatureTemplate.flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE)
701 LOG_WARN("server.loading", "Creature (Entry: {}) has deprecated flags_extra bit AVOID_AOE (0x400000) set. This will be migrated to the `creature_immunities` table in a future update.", entry);
702 if (creatureTemplate.flags_extra & CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK)
703 LOG_WARN("server.loading", "Creature (Entry: {}) has deprecated flags_extra bit IMMUNITY_KNOCKBACK (0x40000000) set. This will be migrated to the `creature_immunities` table in a future update.", entry);
704
705 // useful if the creature template load is being triggered from outside this class
706 if (triggerHook)
707 {
708 sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
709 }
710}
@ CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK
Definition CreatureData.h:76
@ CREATURE_FLAG_EXTRA_NO_TAUNT
Definition CreatureData.h:54
@ CREATURE_FLAG_EXTRA_AVOID_AOE
Definition CreatureData.h:68
std::int32_t int32
Definition Define.h:103
#define sScriptMgr
Definition ScriptMgr.h:735
@ SPELL_SCHOOL_HOLY
Definition SharedDefines.h:272
uint32 Entry
Definition CreatureData.h:188

References _creatureTemplateStore, _creatureTemplateStoreFast, CREATURE_FLAG_EXTRA_AVOID_AOE, CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK, CREATURE_FLAG_EXTRA_NO_TAUNT, CreatureTemplate::Entry, Field::Get(), GetScriptId(), LOG_WARN, MAX_CREATURE_SPELLS, MAX_DIFFICULTY, MAX_KILL_CREDIT, MAX_SPELL_SCHOOL, SPELL_SCHOOL_HOLY, and sScriptMgr.

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateAddons()

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

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

◆ LoadCreatureTemplateModels()

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

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateResistances()

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

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

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

◆ LoadCreatureTemplateSpells()

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

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

References _equipmentInfoStore, Field::Get(), GetCreatureTemplate(), 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, and WorldDatabase.

◆ LoadEventScripts()

void ObjectMgr::LoadEventScripts ( )
6202{
6204
6205 std::set<uint32> evt_scripts;
6206 // Load all possible script entries from gameobjects
6208 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
6209 if (uint32 eventId = itr->second.GetEventScriptId())
6210 evt_scripts.insert(eventId);
6211
6212 // Load all possible script entries from spells
6213 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
6214 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
6215 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
6216 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
6217 if (spell->Effects[j].MiscValue)
6218 evt_scripts.insert(spell->Effects[j].MiscValue);
6219
6220 for (std::size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
6221 {
6222 for (std::size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
6223 {
6224 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
6225
6226 if (node->arrivalEventID)
6227 evt_scripts.insert(node->arrivalEventID);
6228
6229 if (node->departureEventID)
6230 evt_scripts.insert(node->departureEventID);
6231 }
6232 }
6233
6234 // Then check if all scripts are in above list of possible script entries
6235 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
6236 {
6237 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
6238 if (itr2 == evt_scripts.end())
6239 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 {}",
6240 itr->first, SPELL_EFFECT_SEND_EVENT);
6241 }
6242}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition DBCStores.cpp:187
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1637
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition GameObject.h:42
ScriptMapMap sEventScripts
Definition ObjectMgr.cpp:61
@ SCRIPTS_EVENT
Definition ObjectMgr.h:150
@ SPELL_EFFECT_SEND_EVENT
Definition SharedDefines.h:827
GameObjectTemplateContainer const * GetGameObjectTemplates() const
Definition ObjectMgr.h:764
void LoadScripts(ScriptsType type)
Definition ObjectMgr.cpp:5859
Definition DBCStructure.h:1973
uint32 arrivalEventID
Definition DBCStructure.h:1983
uint32 departureEventID
Definition DBCStructure.h:1984

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

◆ LoadExplorationBaseXP()

void ObjectMgr::LoadExplorationBaseXP ( )
8088{
8089 uint32 oldMSTime = getMSTime();
8090
8091 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
8092
8093 if (!result)
8094 {
8095 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
8096 LOG_INFO("server.loading", " ");
8097 return;
8098 }
8099
8100 uint32 count = 0;
8101
8102 do
8103 {
8104 Field* fields = result->Fetch();
8105 uint8 level = fields[0].Get<uint8>();
8106 uint32 basexp = fields[1].Get<int32>();
8107 _baseXPTable[level] = basexp;
8108 ++count;
8109 } while (result->NextRow());
8110
8111 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8112 LOG_INFO("server.loading", " ");
8113}

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

◆ LoadFactionChangeAchievements()

void ObjectMgr::LoadFactionChangeAchievements ( )
10766{
10767 uint32 oldMSTime = getMSTime();
10768
10769 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_achievement");
10770
10771 if (!result)
10772 {
10773 LOG_WARN("server.loading", ">> Loaded 0 faction change achievement pairs. DB table `player_factionchange_achievement` is empty.");
10774 LOG_INFO("server.loading", " ");
10775 return;
10776 }
10777
10778 uint32 count = 0;
10779
10780 do
10781 {
10782 Field* fields = result->Fetch();
10783
10784 uint32 alliance = fields[0].Get<uint32>();
10785 uint32 horde = fields[1].Get<uint32>();
10786
10787 if (!sAchievementStore.LookupEntry(alliance))
10788 LOG_ERROR("sql.sql", "Achievement {} (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance);
10789 else if (!sAchievementStore.LookupEntry(horde))
10790 LOG_ERROR("sql.sql", "Achievement {} (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde);
10791 else
10792 FactionChangeAchievements[alliance] = horde;
10793
10794 ++count;
10795 } while (result->NextRow());
10796
10797 LOG_INFO("server.loading", ">> Loaded {} faction change achievement pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10798 LOG_INFO("server.loading", " ");
10799}
CharacterConversionMap FactionChangeAchievements
Definition ObjectMgr.h:1499

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

◆ LoadFactionChangeItems()

void ObjectMgr::LoadFactionChangeItems ( )
10802{
10803 uint32 oldMSTime = getMSTime();
10804
10805 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
10806
10807 if (!result)
10808 {
10809 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
10810 LOG_INFO("server.loading", " ");
10811 return;
10812 }
10813
10814 uint32 count = 0;
10815
10816 do
10817 {
10818 Field* fields = result->Fetch();
10819
10820 uint32 alliance = fields[0].Get<uint32>();
10821 uint32 horde = fields[1].Get<uint32>();
10822
10823 if (!GetItemTemplate(alliance))
10824 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
10825 else if (!GetItemTemplate(horde))
10826 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
10827 else
10828 FactionChangeItems[alliance] = horde;
10829
10830 ++count;
10831 } while (result->NextRow());
10832
10833 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10834 LOG_INFO("server.loading", " ");
10835}
CharacterConversionMap FactionChangeItems
Definition ObjectMgr.h:1500

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

◆ LoadFactionChangeQuests()

void ObjectMgr::LoadFactionChangeQuests ( )
10838{
10839 uint32 oldMSTime = getMSTime();
10840
10841 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
10842
10843 if (!result)
10844 {
10845 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
10846 LOG_INFO("server.loading", " ");
10847 return;
10848 }
10849
10850 uint32 count = 0;
10851
10852 do
10853 {
10854 Field* fields = result->Fetch();
10855
10856 uint32 alliance = fields[0].Get<uint32>();
10857 uint32 horde = fields[1].Get<uint32>();
10858
10859 if (!GetQuestTemplate(alliance))
10860 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
10861 else if (!GetQuestTemplate(horde))
10862 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
10863 else
10864 FactionChangeQuests[alliance] = horde;
10865
10866 ++count;
10867 } while (result->NextRow());
10868
10869 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10870 LOG_INFO("server.loading", " ");
10871}
CharacterConversionMap FactionChangeQuests
Definition ObjectMgr.h:1501

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

◆ LoadFactionChangeReputations()

void ObjectMgr::LoadFactionChangeReputations ( )
10874{
10875 uint32 oldMSTime = getMSTime();
10876
10877 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
10878
10879 if (!result)
10880 {
10881 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
10882 LOG_INFO("server.loading", " ");
10883 return;
10884 }
10885
10886 uint32 count = 0;
10887
10888 do
10889 {
10890 Field* fields = result->Fetch();
10891
10892 uint32 alliance = fields[0].Get<uint32>();
10893 uint32 horde = fields[1].Get<uint32>();
10894
10895 if (!sFactionStore.LookupEntry(alliance))
10896 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
10897 else if (!sFactionStore.LookupEntry(horde))
10898 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
10899 else
10900 FactionChangeReputation[alliance] = horde;
10901
10902 ++count;
10903 } while (result->NextRow());
10904
10905 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10906 LOG_INFO("server.loading", " ");
10907}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
CharacterConversionMap FactionChangeReputation
Definition ObjectMgr.h:1502

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

◆ LoadFactionChangeSpells()

void ObjectMgr::LoadFactionChangeSpells ( )
10910{
10911 uint32 oldMSTime = getMSTime();
10912
10913 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
10914
10915 if (!result)
10916 {
10917 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
10918 LOG_INFO("server.loading", " ");
10919 return;
10920 }
10921
10922 uint32 count = 0;
10923
10924 do
10925 {
10926 Field* fields = result->Fetch();
10927
10928 uint32 alliance = fields[0].Get<uint32>();
10929 uint32 horde = fields[1].Get<uint32>();
10930
10931 if (!sSpellMgr->GetSpellInfo(alliance))
10932 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
10933 else if (!sSpellMgr->GetSpellInfo(horde))
10934 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
10935 else
10936 FactionChangeSpells[alliance] = horde;
10937
10938 ++count;
10939 } while (result->NextRow());
10940
10941 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10942 LOG_INFO("server.loading", " ");
10943}
CharacterConversionMap FactionChangeSpells
Definition ObjectMgr.h:1503

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

◆ LoadFactionChangeTitles()

void ObjectMgr::LoadFactionChangeTitles ( )
10946{
10947 uint32 oldMSTime = getMSTime();
10948
10949 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
10950
10951 if (!result)
10952 {
10953 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
10954 return;
10955 }
10956
10957 uint32 count = 0;
10958
10959 do
10960 {
10961 Field* fields = result->Fetch();
10962
10963 uint32 alliance = fields[0].Get<uint32>();
10964 uint32 horde = fields[1].Get<uint32>();
10965
10966 if (!sCharTitlesStore.LookupEntry(alliance))
10967 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
10968 else if (!sCharTitlesStore.LookupEntry(horde))
10969 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
10970 else
10971 FactionChangeTitles[alliance] = horde;
10972
10973 ++count;
10974 } while (result->NextRow());
10975
10976 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10977 LOG_INFO("server.loading", " ");
10978}
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
CharacterConversionMap FactionChangeTitles
Definition ObjectMgr.h:1504

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

◆ LoadFishingBaseSkillLevel()

void ObjectMgr::LoadFishingBaseSkillLevel ( )
9590{
9591 uint32 oldMSTime = getMSTime();
9592
9593 _fishingBaseForAreaStore.clear(); // for reload case
9594
9595 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
9596
9597 if (!result)
9598 {
9599 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
9600 LOG_INFO("server.loading", " ");
9601 return;
9602 }
9603
9604 uint32 count = 0;
9605
9606 do
9607 {
9608 Field* fields = result->Fetch();
9609 uint32 entry = fields[0].Get<uint32>();
9610 int32 skill = fields[1].Get<int16>();
9611
9612 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
9613 if (!fArea)
9614 {
9615 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
9616 continue;
9617 }
9618
9619 _fishingBaseForAreaStore[entry] = skill;
9620 ++count;
9621 } while (result->NextRow());
9622
9623 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9624 LOG_INFO("server.loading", " ");
9625}

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

◆ LoadGameObjectAddons()

void ObjectMgr::LoadGameObjectAddons ( )
1364{
1365 uint32 oldMSTime = getMSTime();
1366
1367 // 0 1 2 3 4 5 6
1368 QueryResult result = WorldDatabase.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue FROM gameobject_addon");
1369
1370 if (!result)
1371 {
1372 LOG_WARN("server.loading", ">> Loaded 0 gameobject addon definitions. DB table `gameobject_addon` is empty.");
1373 LOG_INFO("server.loading", " ");
1374 return;
1375 }
1376
1377 uint32 count = 0;
1378 do
1379 {
1380 Field* fields = result->Fetch();
1381
1382 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1383
1385 if (!goData)
1386 {
1387 LOG_ERROR("sql.sql", "GameObject (GUID: {}) does not exist but has a record in `gameobject_addon`", guid);
1388 continue;
1389 }
1390
1391 GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
1392 gameObjectAddon.ParentRotation = QuaternionData(fields[1].Get<float>(), fields[2].Get<float>(), fields[3].Get<float>(), fields[4].Get<float>());
1393 gameObjectAddon.invisibilityType = InvisibilityType(fields[5].Get<uint8>());
1394 gameObjectAddon.InvisibilityValue = fields[6].Get<uint32>();
1395
1396 if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
1397 {
1398 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid InvisibilityType in `gameobject_addon`", guid);
1399 gameObjectAddon.invisibilityType = INVISIBILITY_GENERAL;
1400 gameObjectAddon.InvisibilityValue = 0;
1401 }
1402
1403 if (gameObjectAddon.invisibilityType && !gameObjectAddon.InvisibilityValue)
1404 {
1405 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid);
1406 gameObjectAddon.InvisibilityValue = 1;
1407 }
1408
1409 if (!gameObjectAddon.ParentRotation.IsUnit())
1410 {
1411 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid parent rotation in `gameobject_addon`, set to default", guid);
1412 gameObjectAddon.ParentRotation = QuaternionData();
1413 }
1414
1415 ++count;
1416 } while (result->NextRow());
1417
1418 LOG_INFO("server.loading", ">> Loaded {} Gameobject Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1419 LOG_INFO("server.loading", " ");
1420}
InvisibilityType
Definition SharedDefines.h:1242
@ TOTAL_INVISIBILITY_TYPES
Definition SharedDefines.h:1256
@ INVISIBILITY_GENERAL
Definition SharedDefines.h:1243
ObjectData const goData[]
Definition instance_violet_hold.cpp:48
Definition GameObjectData.h:699
QuaternionData ParentRotation
Definition GameObjectData.h:700
uint32 InvisibilityValue
Definition GameObjectData.h:702
InvisibilityType invisibilityType
Definition GameObjectData.h:701
Definition GameObjectData.h:683
bool IsUnit() const
Definition GameObject.cpp:41

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

◆ LoadGameObjectDataFromDB()

GameObjectData const * ObjectMgr::LoadGameObjectDataFromDB ( ObjectGuid::LowType  spawnId)

Loads a single gameobject spawn entry from the database into the data store cache.

This is needed as a prerequisite for GameObject::LoadGameObjectFromDB(), which reads from the in-memory cache (via GetGameObjectData()) rather than querying the DB itself. For spawns not loaded during server startup, this method populates the cache so that GameObject::LoadGameObjectFromDB() can then create the live entity.

Returns the cached data if already loaded, or nullptr if the spawn doesn't exist or fails validation.

Parameters
spawnIdThe gameobject spawn GUID to load.
Returns
Pointer to the cached GameObjectData, or nullptr on failure.
3044{
3045 GameObjectData const* data = GetGameObjectData(spawnId);
3046 if (data)
3047 return data;
3048
3049 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
3050 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, "
3051 "ScriptName "
3052 "FROM gameobject WHERE gameobject.guid = {}", spawnId);
3053
3054 if (!result)
3055 return nullptr;
3056
3057 Field* fields = result->Fetch();
3058 uint32 entry = fields[1].Get<uint32>();
3059
3060 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
3061 if (!gInfo)
3062 {
3063 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non-existing gameobject entry {}, skipped.", spawnId, entry);
3064 return nullptr;
3065 }
3066
3067 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
3068 {
3069 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry {} GoType: {}) with an invalid displayId ({}), not loaded.",
3070 spawnId, entry, gInfo->type, gInfo->displayId);
3071 return nullptr;
3072 }
3073
3075 goData.id = entry;
3076 goData.mapid = fields[2].Get<uint16>();
3077 goData.posX = fields[3].Get<float>();
3078 goData.posY = fields[4].Get<float>();
3079 goData.posZ = fields[5].Get<float>();
3080 goData.orientation = fields[6].Get<float>();
3081 goData.rotation.x = fields[7].Get<float>();
3082 goData.rotation.y = fields[8].Get<float>();
3083 goData.rotation.z = fields[9].Get<float>();
3084 goData.rotation.w = fields[10].Get<float>();
3085 goData.spawntimesecs = fields[11].Get<int32>();
3086 goData.animprogress = fields[12].Get<uint8>();
3087 goData.artKit = 0;
3088 goData.ScriptId = GetScriptId(fields[16].Get<std::string>());
3089
3090 if (!goData.ScriptId)
3091 goData.ScriptId = gInfo->ScriptId;
3092
3093 MapEntry const* mapEntry = sMapStore.LookupEntry(goData.mapid);
3094 if (!mapEntry)
3095 {
3096 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existing map (Id: {}), skipped.", spawnId, entry, goData.mapid);
3097 _gameObjectDataStore.erase(spawnId);
3098 return nullptr;
3099 }
3100
3101 if (goData.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
3102 {
3103 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `spawntimesecs` (0) value, but the gameobject is marked as despawnable at action.", spawnId, entry);
3104 }
3105
3106 uint32 go_state = fields[13].Get<uint8>();
3107 if (go_state >= MAX_GO_STATE)
3108 {
3109 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skipped.", spawnId, entry, go_state);
3110 _gameObjectDataStore.erase(spawnId);
3111 return nullptr;
3112 }
3113 goData.go_state = GOState(go_state);
3114
3115 goData.spawnMask = fields[14].Get<uint8>();
3116 goData.phaseMask = fields[15].Get<uint32>();
3117
3118 if (goData.rotation.x < -1.0f || goData.rotation.x > 1.0f)
3119 {
3120 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skipped.", spawnId, entry, goData.rotation.x);
3121 _gameObjectDataStore.erase(spawnId);
3122 return nullptr;
3123 }
3124
3125 if (goData.rotation.y < -1.0f || goData.rotation.y > 1.0f)
3126 {
3127 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skipped.", spawnId, entry, goData.rotation.y);
3128 _gameObjectDataStore.erase(spawnId);
3129 return nullptr;
3130 }
3131
3132 if (goData.rotation.z < -1.0f || goData.rotation.z > 1.0f)
3133 {
3134 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skipped.", spawnId, entry, goData.rotation.z);
3135 _gameObjectDataStore.erase(spawnId);
3136 return nullptr;
3137 }
3138
3139 if (goData.rotation.w < -1.0f || goData.rotation.w > 1.0f)
3140 {
3141 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skipped.", spawnId, entry, goData.rotation.w);
3142 _gameObjectDataStore.erase(spawnId);
3143 return nullptr;
3144 }
3145
3146 if (fabs(goData.rotation.x * goData.rotation.x + goData.rotation.y * goData.rotation.y +
3147 goData.rotation.z * goData.rotation.z + goData.rotation.w * goData.rotation.w - 1.0f) >= 1e-5f)
3148 {
3149 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotation quaternion (non-unit), defaulting to orientation on Z axis only", spawnId, entry);
3150 goData.rotation = G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(goData.orientation, 0.0f, 0.0f));
3151 }
3152
3153 if (!MapMgr::IsValidMapCoord(goData.mapid, goData.posX, goData.posY, goData.posZ, goData.orientation))
3154 {
3155 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skipped.", spawnId, entry);
3156 _gameObjectDataStore.erase(spawnId);
3157 return nullptr;
3158 }
3159
3160 if (goData.phaseMask == 0)
3161 {
3162 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, entry);
3163 goData.phaseMask = 1;
3164 }
3165
3166 return &goData;
3167}
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
#define MAX_GO_STATE
Definition GameObjectData.h:28
GOState
Definition GameObjectData.h:707
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition MapMgr.h:90

References _gameObjectDataStore, Field::Get(), GetGameObjectData(), GetGameObjectTemplate(), GetScriptId(), goData, MapMgr::IsValidMapCoord(), LOG_ERROR, MAX_GO_STATE, sGameObjectDisplayInfoStore, sMapStore, and WorldDatabase.

◆ LoadGameObjectForQuests()

void ObjectMgr::LoadGameObjectForQuests ( )
9376{
9377 uint32 oldMSTime = getMSTime();
9378
9379 if (GetGameObjectTemplates()->empty())
9380 {
9381 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
9382 LOG_INFO("server.loading", " ");
9383 return;
9384 }
9385
9386 uint32 count = 0;
9387
9388 // collect GO entries for GO that must activated
9390 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
9391 {
9392 itr->second.IsForQuests = false;
9393 switch (itr->second.type)
9394 {
9396 itr->second.IsForQuests = true;
9397 ++count;
9398 break;
9400 {
9401 // scan GO chest with loot including quest items
9402 uint32 loot_id = (itr->second.GetLootId());
9403
9404 // find quest loot for GO
9405 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
9406 {
9407 itr->second.IsForQuests = true;
9408 ++count;
9409 }
9410 break;
9411 }
9413 {
9414 if (itr->second._generic.questID > 0) //quests objects
9415 {
9416 itr->second.IsForQuests = true;
9417 ++count;
9418 }
9419 break;
9420 }
9422 {
9423 if (itr->second.spellFocus.questID > 0) //quests objects
9424 {
9425 itr->second.IsForQuests = true;
9426 ++count;
9427 }
9428 break;
9429 }
9431 {
9432 if (itr->second.goober.questId > 0) //quests objects
9433 {
9434 itr->second.IsForQuests = true;
9435 ++count;
9436 }
9437 break;
9438 }
9439 default:
9440 break;
9441 }
9442 }
9443
9444 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9445 LOG_INFO("server.loading", " ");
9446}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition SharedDefines.h:1572
@ GAMEOBJECT_TYPE_GENERIC
Definition SharedDefines.h:1569
@ GAMEOBJECT_TYPE_CHEST
Definition SharedDefines.h:1567
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition SharedDefines.h:1566
@ GAMEOBJECT_TYPE_GOOBER
Definition SharedDefines.h:1574
bool HaveQuestLootFor(uint32 loot_id) const
Definition LootMgr.cpp:218

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

◆ LoadGameObjectLocales()

void ObjectMgr::LoadGameObjectLocales ( )
7732{
7733 uint32 oldMSTime = getMSTime();
7734
7735 _gameObjectLocaleStore.clear(); // need for reload case
7736
7737 // 0 1 2 3
7738 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7739 if (!result)
7740 return;
7741
7742 do
7743 {
7744 Field* fields = result->Fetch();
7745
7746 uint32 ID = fields[0].Get<uint32>();
7747
7748 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7749 if (locale == LOCALE_enUS)
7750 continue;
7751
7753 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7754 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7755 } while (result->NextRow());
7756
7757 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7758}
Definition GameObjectData.h:677
std::vector< std::string > Name
Definition GameObjectData.h:678
std::vector< std::string > CastBarCaption
Definition GameObjectData.h:679

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

◆ LoadGameobjectQuestEnders()

void ObjectMgr::LoadGameobjectQuestEnders ( )
8948{
8949 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8950
8951 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8952 {
8953 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8954 if (!goInfo)
8955 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8956 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8957 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8958 }
8959}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
11039{
11040 uint32 oldMSTime = getMSTime();
11041
11042 // 0 1 2
11043 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
11044
11045 if (!result)
11046 {
11047 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
11048 return;
11049 }
11050
11051 uint32 count = 0;
11052 do
11053 {
11054 Field* fields = result->Fetch();
11055
11056 uint32 entry = fields[0].Get<uint32>();
11057 uint32 item = fields[1].Get<uint32>();
11058 uint32 idx = fields[2].Get<uint32>();
11059
11060 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
11061 if (!goInfo)
11062 {
11063 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
11064 continue;
11065 };
11066
11067 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
11068 if (!dbcData)
11069 {
11070 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
11071 continue;
11072 };
11073
11074 _gameObjectQuestItemStore[entry].push_back(item);
11075
11076 ++count;
11077 } while (result->NextRow());
11078
11079 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11080 LOG_INFO("server.loading", " ");
11081}

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

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8934{
8935 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8936
8937 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8938 {
8939 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8940 if (!goInfo)
8941 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8942 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8943 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8944 }
8945}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

void ObjectMgr::LoadGameobjects ( )
2855{
2856 uint32 oldMSTime = getMSTime();
2857
2858 // 0 1 2 3 4 5 6
2859 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
2860 // 7 8 9 10 11 12 13 14 15 16 17
2861 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, "
2862 // 18
2863 "ScriptName "
2864 "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
2865 "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
2866
2867 if (!result)
2868 {
2869 LOG_WARN("server.loading", ">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
2870 LOG_INFO("server.loading", " ");
2871 return;
2872 }
2873
2875 LOG_INFO("server.loading", "Calculating zone and area fields. This may take a moment...");
2876
2877 // build single time for check spawnmask
2878 std::map<uint32, uint32> spawnMasks;
2879 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2880 if (sMapStore.LookupEntry(i))
2881 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2883 spawnMasks[i] |= (1 << k);
2884
2885 _gameObjectDataStore.rehash(result->GetRowCount());
2886 do
2887 {
2888 Field* fields = result->Fetch();
2889
2890 ObjectGuid::LowType guid = fields[0].Get<uint32>();
2891 uint32 entry = fields[1].Get<uint32>();
2892
2893 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
2894 if (!gInfo)
2895 {
2896 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non existing gameobject entry {}, skipped.", guid, entry);
2897 continue;
2898 }
2899
2900 if (!gInfo->displayId)
2901 {
2902 switch (gInfo->type)
2903 {
2906 break;
2907 default:
2908 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) doesn't have a displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2909 break;
2910 }
2911 }
2912
2913 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
2914 {
2915 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) has an invalid displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2916 continue;
2917 }
2918
2920
2921 data.spawnId = guid;
2922 data.id = entry;
2923 data.mapid = fields[2].Get<uint16>();
2924 data.posX = fields[3].Get<float>();
2925 data.posY = fields[4].Get<float>();
2926 data.posZ = fields[5].Get<float>();
2927 data.orientation = fields[6].Get<float>();
2928 data.rotation.x = fields[7].Get<float>();
2929 data.rotation.y = fields[8].Get<float>();
2930 data.rotation.z = fields[9].Get<float>();
2931 data.rotation.w = fields[10].Get<float>();
2932 data.spawntimesecs = fields[11].Get<int32>();
2933 data.ScriptId = GetScriptId(fields[18].Get<std::string>());
2934 data.spawnGroupId = 0;
2935 if (!data.ScriptId)
2936 data.ScriptId = gInfo->ScriptId;
2937
2938 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2939 if (!mapEntry)
2940 {
2941 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existed map (Id: {}), skip", guid, data.id, data.mapid);
2942 continue;
2943 }
2944
2945 if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
2946 {
2947 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);
2948 }
2949
2950 data.animprogress = fields[12].Get<uint8>();
2951 data.artKit = 0;
2952
2953 uint32 go_state = fields[13].Get<uint8>();
2954 if (go_state >= MAX_GO_STATE)
2955 {
2956 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skip", guid, data.id, go_state);
2957 continue;
2958 }
2959 data.go_state = GOState(go_state);
2960
2961 data.spawnMask = fields[14].Get<uint8>();
2962
2963 if (!_transportMaps.count(data.mapid))
2964 {
2965 if (data.spawnMask & ~spawnMasks[data.mapid])
2966 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);
2967 }
2968 else
2969 data.spawnGroupId = 1; // force compatibility group for transport spawns
2970
2971 data.phaseMask = fields[15].Get<uint32>();
2972 int16 gameEvent = fields[16].Get<int16>();
2973 uint32 PoolId = fields[17].Get<uint32>();
2974
2975 if (data.rotation.x < -1.0f || data.rotation.x > 1.0f)
2976 {
2977 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skip", guid, data.id, data.rotation.x);
2978 continue;
2979 }
2980
2981 if (data.rotation.y < -1.0f || data.rotation.y > 1.0f)
2982 {
2983 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skip", guid, data.id, data.rotation.y);
2984 continue;
2985 }
2986
2987 if (data.rotation.z < -1.0f || data.rotation.z > 1.0f)
2988 {
2989 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skip", guid, data.id, data.rotation.z);
2990 continue;
2991 }
2992
2993 if (data.rotation.w < -1.0f || data.rotation.w > 1.0f)
2994 {
2995 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skip", guid, data.id, data.rotation.w);
2996 continue;
2997 }
2998
2999 if (fabs(data.rotation.x * data.rotation.x + data.rotation.y * data.rotation.y +
3000 data.rotation.z * data.rotation.z + data.rotation.w * data.rotation.w - 1.0f) >= 1e-5f)
3001 {
3002 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotation quaternion (non-unit), defaulting to orientation on Z axis only", guid, data.id);
3003 data.rotation = G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(data.orientation, 0.0f, 0.0f));
3004 }
3005
3006 if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
3007 {
3008 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
3009 continue;
3010 }
3011
3012 if (data.phaseMask == 0)
3013 {
3014 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
3015 data.phaseMask = 1;
3016 }
3017
3019 {
3020 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
3021 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
3022
3024
3025 stmt->SetData(0, zoneId);
3026 stmt->SetData(1, areaId);
3027 stmt->SetData(2, guid);
3028
3029 WorldDatabase.Execute(stmt);
3030 }
3031
3032 if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
3033 AddGameobjectToGrid(guid, &data);
3034 } while (result->NextRow());
3035
3036 LOG_INFO("server.loading", ">> Loaded {} Gameobjects in {} ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
3037 LOG_INFO("server.loading", " ");
3038}
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1570
@ CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldConfig.h:117
@ WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldDatabase.h:115

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, SpawnData::mapid, MAX_DIFFICULTY, MAX_GO_STATE, SpawnData::orientation, SpawnData::phaseMask, SpawnData::posX, SpawnData::posY, SpawnData::posZ, GameObjectData::rotation, SpawnData::ScriptId, PreparedStatementBase::SetData(), sGameObjectDisplayInfoStore, sMapMgr, sMapStore, SpawnData::spawnGroupId, SpawnData::spawnId, SpawnData::spawnMask, GameObjectData::spawntimesecs, sWorld, WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA, and WorldDatabase.

◆ LoadGameObjectSummons()

void ObjectMgr::LoadGameObjectSummons ( )
2237{
2238 uint32 oldMSTime = getMSTime();
2239
2240 _goSummonDataStore.clear();
2241
2242 // 0 1 2 3 4 5 6 7 8 9 10 11 12
2243 QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, respawnTime FROM gameobject_summon_groups");
2244
2245 if (!result)
2246 {
2247 LOG_WARN("server.loading", ">> Loaded 0 gameobject summons. DB table `gameobject_summon_groups` is empty.");
2248 return;
2249 }
2250
2251 uint32 count = 0;
2252 do
2253 {
2254 Field* fields = result->Fetch();
2255
2256 uint32 summonerId = fields[0].Get<uint32>();
2257 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2258 uint8 group = fields[2].Get<uint8>();
2259
2260 switch (summonerType)
2261 {
2263 if (!GetCreatureTemplate(summonerId))
2264 {
2265 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2266 continue;
2267 }
2268 break;
2270 if (!GetGameObjectTemplate(summonerId))
2271 {
2272 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2273 continue;
2274 }
2275 break;
2276 case SUMMONER_TYPE_MAP:
2277 if (!sMapStore.LookupEntry(summonerId))
2278 {
2279 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2280 continue;
2281 }
2282 break;
2283 default:
2284 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2285 continue;
2286 }
2287
2289 data.entry = fields[3].Get<uint32>();
2290
2291 if (!GetGameObjectTemplate(data.entry))
2292 {
2293 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has gameobject in group [Summoner ID: {}, Summoner Type: {}, Group ID: {}] with non existing gameobject entry {}, skipped.", summonerId, summonerType, group, data.entry);
2294 continue;
2295 }
2296
2297 float posX = fields[4].Get<float>();
2298 float posY = fields[5].Get<float>();
2299 float posZ = fields[6].Get<float>();
2300 float orientation = fields[7].Get<float>();
2301
2302 data.pos.Relocate(posX, posY, posZ, orientation);
2303
2304 data.rot = G3D::Quat(fields[8].Get<float>(), fields[9].Get<float>(), fields[10].Get<float>(), fields[11].Get<float>());
2305 data.respawnTime = fields[12].Get<uint32>();
2306
2307 TempSummonGroupKey key(summonerId, summonerType, group);
2308 _goSummonDataStore[key].push_back(data);
2309
2310 ++count;
2311 } while (result->NextRow());
2312
2313 LOG_INFO("server.loading", ">> Loaded {} Gameobject Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2314 LOG_INFO("server.loading", " ");
2315}
SummonerType
Definition TemporarySummon.h:25
@ SUMMONER_TYPE_MAP
Definition TemporarySummon.h:28
@ SUMMONER_TYPE_CREATURE
Definition TemporarySummon.h:26
@ SUMMONER_TYPE_GAMEOBJECT
Definition TemporarySummon.h:27
Stores data for temp gameobject summons.
Definition TemporarySummon.h:42
G3D::Quat rot
Definition TemporarySummon.h:45
uint32 respawnTime
Duration in seconds; passed to SummonGameObject's respawnTime parameter.
Definition TemporarySummon.h:46
uint32 entry
Definition TemporarySummon.h:43
Position pos
Definition TemporarySummon.h:44
void Relocate(float x, float y)
Definition Position.h:77

References _goSummonDataStore, GameObjectSummonData::entry, Field::Get(), GetCreatureTemplate(), GetGameObjectTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, GameObjectSummonData::pos, Position::Relocate(), GameObjectSummonData::respawnTime, GameObjectSummonData::rot, sMapStore, SUMMONER_TYPE_CREATURE, SUMMONER_TYPE_GAMEOBJECT, SUMMONER_TYPE_MAP, and WorldDatabase.

◆ LoadGameObjectTemplate()

void ObjectMgr::LoadGameObjectTemplate ( )
7820{
7821 uint32 oldMSTime = getMSTime();
7822
7823 // 0 1 2 3 4 5 6 7
7824 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7825 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7826 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7827 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7828 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7829 "FROM gameobject_template");
7830
7831 if (!result)
7832 {
7833 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7834 LOG_INFO("server.loading", " ");
7835 return;
7836 }
7837
7838 _gameObjectTemplateStore.rehash(result->GetRowCount());
7839 uint32 count = 0;
7840 do
7841 {
7842 Field* fields = result->Fetch();
7843
7844 uint32 entry = fields[0].Get<uint32>();
7845
7847
7848 got.entry = entry;
7849 got.type = uint32(fields[1].Get<uint8>());
7850 got.displayId = fields[2].Get<uint32>();
7851 got.name = fields[3].Get<std::string>();
7852 got.IconName = fields[4].Get<std::string>();
7853 got.castBarCaption = fields[5].Get<std::string>();
7854 got.unk1 = fields[6].Get<std::string>();
7855 got.size = fields[7].Get<float>();
7856
7857 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7858 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7859
7860 got.AIName = fields[32].Get<std::string>();
7861 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7862 got.IsForQuests = false;
7863
7864 // Checks
7865 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7866 {
7867 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7868 }
7869
7870 switch (got.type)
7871 {
7872 case GAMEOBJECT_TYPE_DOOR: //0
7873 {
7874 if (got.door.lockId)
7875 CheckGOLockId(&got, got.door.lockId, 1);
7876 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7877 break;
7878 }
7879 case GAMEOBJECT_TYPE_BUTTON: //1
7880 {
7881 if (got.button.lockId)
7882 CheckGOLockId(&got, got.button.lockId, 1);
7883 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7884 break;
7885 }
7887 {
7888 if (got.questgiver.lockId)
7889 CheckGOLockId(&got, got.questgiver.lockId, 0);
7890 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7891 break;
7892 }
7893 case GAMEOBJECT_TYPE_CHEST: //3
7894 {
7895 if (got.chest.lockId)
7896 CheckGOLockId(&got, got.chest.lockId, 0);
7897
7898 CheckGOConsumable(&got, got.chest.consumable, 3);
7899
7900 if (got.chest.linkedTrapId) // linked trap
7901 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7902 break;
7903 }
7904 case GAMEOBJECT_TYPE_TRAP: //6
7905 {
7906 if (got.trap.lockId)
7907 CheckGOLockId(&got, got.trap.lockId, 0);
7908 break;
7909 }
7910 case GAMEOBJECT_TYPE_CHAIR: //7
7911 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7912 break;
7914 {
7915 if (got.spellFocus.focusId)
7916 {
7917 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7918 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7919 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7920 }
7921
7922 if (got.spellFocus.linkedTrapId) // linked trap
7923 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7924 break;
7925 }
7926 case GAMEOBJECT_TYPE_GOOBER: //10
7927 {
7928 if (got.goober.lockId)
7929 CheckGOLockId(&got, got.goober.lockId, 0);
7930
7931 CheckGOConsumable(&got, got.goober.consumable, 3);
7932
7933 if (got.goober.pageId) // pageId
7934 {
7935 if (!GetPageText(got.goober.pageId))
7936 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7937 entry, got.type, got.goober.pageId, got.goober.pageId);
7938 }
7939 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7940 if (got.goober.linkedTrapId) // linked trap
7941 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7942 break;
7943 }
7945 {
7946 if (got.areadamage.lockId)
7947 CheckGOLockId(&got, got.areadamage.lockId, 0);
7948 break;
7949 }
7950 case GAMEOBJECT_TYPE_CAMERA: //13
7951 {
7952 if (got.camera.lockId)
7953 CheckGOLockId(&got, got.camera.lockId, 0);
7954 break;
7955 }
7957 {
7958 if (got.moTransport.taxiPathId)
7959 {
7960 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7961 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7962 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7963 }
7964 if (uint32 transportMap = got.moTransport.mapID)
7965 _transportMaps.insert(transportMap);
7966 break;
7967 }
7969 break;
7971 {
7972 // always must have spell
7973 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7974 break;
7975 }
7976 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7977 {
7978 if (got.flagstand.lockId)
7979 CheckGOLockId(&got, got.flagstand.lockId, 0);
7980 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7981 break;
7982 }
7984 {
7985 if (got.fishinghole.lockId)
7986 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7987 break;
7988 }
7989 case GAMEOBJECT_TYPE_FLAGDROP: //26
7990 {
7991 if (got.flagdrop.lockId)
7992 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7993 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7994 break;
7995 }
7997 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7998 break;
7999 }
8000
8001 ++count;
8002 } while (result->NextRow());
8003
8004 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8005 LOG_INFO("server.loading", " ");
8006}
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
#define sGameObjectAIRegistry
Definition GameObjectAIFactory.h:49
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7800
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7779
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition ObjectMgr.cpp:7788
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7809
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7769
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7760
@ GAMEOBJECT_TYPE_CAMERA
Definition SharedDefines.h:1577
@ GAMEOBJECT_TYPE_BUTTON
Definition SharedDefines.h:1565
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition SharedDefines.h:1579
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition SharedDefines.h:1582
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition SharedDefines.h:1589
@ GAMEOBJECT_TYPE_FLAGDROP
Definition SharedDefines.h:1590
@ GAMEOBJECT_TYPE_SPELLCASTER
Definition SharedDefines.h:1586
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition SharedDefines.h:1588
@ GAMEOBJECT_TYPE_CHAIR
Definition SharedDefines.h:1571
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition SharedDefines.h:1576
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition SharedDefines.h:1596
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1564
#define MAX_GAMEOBJECT_DATA
Definition SharedDefines.h:1603
PageText const * GetPageText(uint32 pageEntry)
Definition ObjectMgr.cpp:6443
uint32 entry
Definition GameObjectData.h:33

References _gameObjectTemplateStore, _transportMaps, CheckAndFixGOChairHeightId(), CheckGOConsumable(), CheckGOLinkedTrapId(), CheckGOLockId(), CheckGONoDamageImmuneId(), CheckGOSpellId(), GameObjectTemplate::entry, 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 ( )
8009{
8010 uint32 oldMSTime = getMSTime();
8011
8012 // 0 1 2 3 4 5 6 7 8
8013 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
8014
8015 if (!result)
8016 {
8017 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
8018 LOG_INFO("server.loading", " ");
8019 return;
8020 }
8021
8022 uint32 count = 0;
8023 do
8024 {
8025 Field* fields = result->Fetch();
8026
8027 uint32 entry = fields[0].Get<uint32>();
8028
8029 GameObjectTemplate const* got = GetGameObjectTemplate(entry);
8030 if (!got)
8031 {
8032 LOG_ERROR("sql.sql",
8033 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
8034 entry);
8035 continue;
8036 }
8037
8039 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
8040 gameObjectAddon.flags = fields[2].Get<uint32>();
8041 gameObjectAddon.mingold = fields[3].Get<uint32>();
8042 gameObjectAddon.maxgold = fields[4].Get<uint32>();
8043
8044 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
8045 {
8046 uint32 artKitID = fields[5 + i].Get<uint32>();
8047 if (!artKitID)
8048 continue;
8049
8050 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
8051 {
8052 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
8053 continue;
8054 }
8055
8056 gameObjectAddon.artKits[i] = artKitID;
8057 }
8058
8059 // checks
8060 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
8061 LOG_ERROR("sql.sql",
8062 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
8063 entry, gameObjectAddon.faction);
8064
8065 if (gameObjectAddon.maxgold > 0)
8066 {
8067 switch (got->type)
8068 {
8071 break;
8072 default:
8073 LOG_ERROR("sql.sql",
8074 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
8075 entry, got->type);
8076 break;
8077 }
8078 }
8079
8080 ++count;
8081 } while (result->NextRow());
8082
8083 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8084 LOG_INFO("server.loading", " ");
8085}
DBCStorage< GameObjectArtKitEntry > sGameObjectArtKitStore(GameObjectArtKitfmt)
Definition GameObjectData.h:667
uint32 mingold
Definition GameObjectData.h:671
uint32 flags
Definition GameObjectData.h:670
uint32 faction
Definition GameObjectData.h:669
std::array< uint32, 4 > artKits
Definition GameObjectData.h:673
uint32 maxgold
Definition GameObjectData.h:672

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

◆ LoadGameTele()

void ObjectMgr::LoadGameTele ( )
9730{
9731 uint32 oldMSTime = getMSTime();
9732
9733 _gameTeleStore.clear(); // for reload case
9734
9735 // 0 1 2 3 4 5 6
9736 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
9737
9738 if (!result)
9739 {
9740 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
9741 LOG_INFO("server.loading", " ");
9742 return;
9743 }
9744
9745 uint32 count = 0;
9746
9747 do
9748 {
9749 Field* fields = result->Fetch();
9750
9751 uint32 id = fields[0].Get<uint32>();
9752
9753 GameTele gt;
9754
9755 gt.position_x = fields[1].Get<float>();
9756 gt.position_y = fields[2].Get<float>();
9757 gt.position_z = fields[3].Get<float>();
9758 gt.orientation = fields[4].Get<float>();
9759 gt.mapId = fields[5].Get<uint16>();
9760 gt.name = fields[6].Get<std::string>();
9761
9762 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
9763 {
9764 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
9765 continue;
9766 }
9767
9768 if (!Utf8toWStr(gt.name, gt.wnameLow))
9769 {
9770 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
9771 continue;
9772 }
9773
9774 wstrToLower(gt.wnameLow);
9775
9776 _gameTeleStore[id] = gt;
9777
9778 ++count;
9779 } while (result->NextRow());
9780
9781 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9782 LOG_INFO("server.loading", " ");
9783}
float position_x
Definition ObjectMgr.h:134

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 ( )
10186{
10187 uint32 oldMSTime = getMSTime();
10188
10189 _gossipMenusStore.clear();
10190
10191 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
10192
10193 if (!result)
10194 {
10195 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
10196 LOG_INFO("server.loading", " ");
10197 return;
10198 }
10199
10200 do
10201 {
10202 Field* fields = result->Fetch();
10203
10204 GossipMenus gMenu;
10205
10206 gMenu.MenuID = fields[0].Get<uint32>();
10207 gMenu.TextID = fields[1].Get<uint32>();
10208
10209 if (!GetGossipText(gMenu.TextID))
10210 {
10211 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
10212 continue;
10213 }
10214
10215 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
10216 } while (result->NextRow());
10217
10218 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
10219 LOG_INFO("server.loading", " ");
10220}
GossipText const * GetGossipText(uint32 Text_ID) const
Definition ObjectMgr.cpp:6621
Definition ObjectMgr.h:628
uint32 TextID
Definition ObjectMgr.h:630
uint32 MenuID
Definition ObjectMgr.h:629

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

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
10223{
10224 uint32 oldMSTime = getMSTime();
10225
10226 _gossipMenuItemsStore.clear();
10227
10228 QueryResult result = WorldDatabase.Query(
10229 // 0 1 2 3 4 5 6 7 8 9 10 11 12
10230 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
10231 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
10232
10233 if (!result)
10234 {
10235 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
10236 LOG_INFO("server.loading", " ");
10237 return;
10238 }
10239
10240 do
10241 {
10242 Field* fields = result->Fetch();
10243
10244 GossipMenuItems gMenuItem;
10245
10246 gMenuItem.MenuID = fields[0].Get<uint32>();
10247 gMenuItem.OptionID = fields[1].Get<uint16>();
10248 gMenuItem.OptionIcon = fields[2].Get<uint32>();
10249 gMenuItem.OptionText = fields[3].Get<std::string>();
10250 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
10251 gMenuItem.OptionType = fields[5].Get<uint8>();
10252 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
10253 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
10254 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
10255 gMenuItem.BoxCoded = fields[9].Get<bool>();
10256 gMenuItem.BoxMoney = fields[10].Get<uint32>();
10257 gMenuItem.BoxText = fields[11].Get<std::string>();
10258 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
10259
10260 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
10261 {
10262 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);
10263 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
10264 }
10265
10267 {
10268 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
10269 gMenuItem.OptionBroadcastTextID = 0;
10270 }
10271
10272 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
10273 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);
10274
10275 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
10276 {
10277 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
10278 gMenuItem.ActionPoiID = 0;
10279 }
10280
10281 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
10282 {
10283 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
10284 gMenuItem.BoxBroadcastTextID = 0;
10285 }
10286
10287 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
10288 } while (result->NextRow());
10289
10290 // Warn if any trainer creature templates reference a GossipMenuId that has no gossip_menu_option entries
10291 // This will cause the gossip menu to fallback to MenuID 0 at runtime which will display: "I wish to unlearn my talents."
10292 std::set<uint32> checkedMenuIds;
10293 for (auto const& [entry, tmpl] : _creatureTemplateStore)
10294 {
10295 uint32 menuId = tmpl.GossipMenuId;
10296 if (!menuId)
10297 continue;
10298
10299 if (!(tmpl.npcflag & UNIT_NPC_FLAG_TRAINER))
10300 continue;
10301
10302 if (checkedMenuIds.contains(menuId))
10303 continue;
10304
10305 checkedMenuIds.insert(menuId);
10306
10307 auto [first, second] = _gossipMenuItemsStore.equal_range(menuId);
10308 if (first == second)
10309 LOG_WARN("server.loading", "Trainer creature template references GossipMenuId {} has no `gossip_menu_option` entries. This will fallback to MenuID 0.", menuId);
10310 }
10311
10312 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
10313 LOG_INFO("server.loading", " ");
10314}
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:61
@ GOSSIP_ICON_MAX
Definition GossipDef.h:82
@ GOSSIP_OPTION_MAX
Definition GossipDef.h:56
@ UNIT_NPC_FLAG_TRAINER
Definition UnitDefines.h:326
PointOfInterest const * GetPointOfInterest(uint32 id) const
Definition ObjectMgr.h:932
BroadcastText const * GetBroadcastText(uint32 id) const
Definition ObjectMgr.h:1227
Definition ObjectMgr.h:610
uint8 OptionIcon
Definition ObjectMgr.h:613
uint32 BoxBroadcastTextID
Definition ObjectMgr.h:624
std::string OptionText
Definition ObjectMgr.h:614
uint32 ActionMenuID
Definition ObjectMgr.h:618
bool BoxCoded
Definition ObjectMgr.h:620
uint32 MenuID
Definition ObjectMgr.h:611
uint32 OptionNpcFlag
Definition ObjectMgr.h:617
uint32 ActionPoiID
Definition ObjectMgr.h:619
uint32 BoxMoney
Definition ObjectMgr.h:621
std::string BoxText
Definition ObjectMgr.h:622
uint32 OptionID
Definition ObjectMgr.h:612
uint32 OptionType
Definition ObjectMgr.h:616
uint32 OptionBroadcastTextID
Definition ObjectMgr.h:615

References _creatureTemplateStore, _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, UNIT_NPC_FLAG_TRAINER, and WorldDatabase.

◆ LoadGossipMenuItemsLocales()

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

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

◆ LoadGossipText()

void ObjectMgr::LoadGossipText ( )
6630{
6631 uint32 oldMSTime = getMSTime();
6632
6633 QueryResult result = WorldDatabase.Query("SELECT ID, "
6634 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
6635 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
6636 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
6637 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
6638 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
6639 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
6640 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
6641 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
6642 "FROM npc_text");
6643
6644 if (!result)
6645 {
6646 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
6647 LOG_INFO("server.loading", " ");
6648 return;
6649 }
6650
6651 _gossipTextStore.rehash(result->GetRowCount());
6652
6653 uint32 count = 0;
6654 uint8 cic;
6655
6656 do
6657 {
6658 cic = 0;
6659
6660 Field* fields = result->Fetch();
6661
6662 uint32 id = fields[cic++].Get<uint32>();
6663 if (!id)
6664 {
6665 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
6666 continue;
6667 }
6668
6669 GossipText& gText = _gossipTextStore[id];
6670
6671 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6672 {
6673 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
6674 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
6675 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
6676 gText.Options[i].Language = fields[cic++].Get<uint8>();
6677 gText.Options[i].Probability = fields[cic++].Get<float>();
6678
6679 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
6680 {
6681 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
6682 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
6683 }
6684 }
6685
6686 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
6687 {
6688 if (gText.Options[i].BroadcastTextID)
6689 {
6691 {
6692 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
6693 gText.Options[i].BroadcastTextID = 0;
6694 }
6695 }
6696 }
6697
6698 count++;
6699 } while (result->NextRow());
6700
6701 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6702 LOG_INFO("server.loading", " ");
6703}
#define MAX_GOSSIP_TEXT_OPTIONS
Definition NPCHandler.h:42
#define MAX_GOSSIP_TEXT_EMOTES
Definition NPCHandler.h:30
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
uint32 _Emote
Definition NPCHandler.h:26
uint32 _Delay
Definition NPCHandler.h:27

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 ( )
6537{
6538 uint32 oldMSTime = getMSTime();
6539
6540 // 0 1 2 3
6541 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
6542 if (!result)
6543 {
6544 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
6545 LOG_INFO("server.loading", " ");
6546 return;
6547 }
6548
6549 uint32 count = 0;
6550 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
6551 do
6552 {
6553 Field* fields = result->Fetch();
6554 uint32 entry = fields[0].Get<uint32>();
6555 uint8 creditType = fields[1].Get<uint8>();
6556 uint32 creditEntry = fields[2].Get<uint32>();
6557 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
6558 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
6559 if (!dungeonEncounter)
6560 {
6561 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
6562 continue;
6563 }
6564
6565 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
6566 {
6567 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
6568 continue;
6569 }
6570
6571 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
6572 if (lastEncounterDungeon)
6573 {
6574 if (itr != dungeonLastBosses.end())
6575 {
6576 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]);
6577 continue;
6578 }
6579
6580 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
6581 }
6582
6583 switch (creditType)
6584 {
6586 {
6587 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
6588 if (!creatureInfo)
6589 {
6590 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
6591 continue;
6592 }
6593 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
6594 break;
6595 }
6597 {
6598 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
6599 if (!spellInfo)
6600 {
6601 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
6602 continue;
6603 }
6604 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
6605 break;
6606 }
6607 default:
6608 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
6609 continue;
6610 }
6611
6612 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
6613 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
6614 ++count;
6615 } while (result->NextRow());
6616
6617 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6618 LOG_INFO("server.loading", " ");
6619}
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition CreatureData.h:74
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
#define sLFGMgr
Definition LFGMgr.h:658
EncounterCreditType
Definition Map.h:160
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition Map.h:161
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition Map.h:162
std::list< DungeonEncounter const * > DungeonEncounterList
Definition ObjectMgr.h:714
@ SPELL_ATTR0_CU_ENCOUNTER_REWARD
Definition SpellInfo.h:208
Definition DBCStructure.h:866
Definition ObjectMgr.h:704

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 ( )
6486{
6487 uint32 oldMSTime = getMSTime();
6488
6489 // 0 1 2 4
6490 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
6491
6492 if (!result)
6493 {
6494 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `instance_template` is empty!");
6495 LOG_INFO("server.loading", " ");
6496 return;
6497 }
6498
6499 uint32 count = 0;
6500 do
6501 {
6502 Field* fields = result->Fetch();
6503
6504 uint16 mapID = fields[0].Get<uint16>();
6505
6506 if (!MapMgr::IsValidMAP(mapID, true))
6507 {
6508 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
6509 continue;
6510 }
6511
6512 InstanceTemplate instanceTemplate;
6513
6514 instanceTemplate.AllowMount = fields[3].Get<bool>();
6515 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
6516 instanceTemplate.ScriptId = GetScriptId(fields[2].Get<std::string>());
6517
6518 _instanceTemplateStore[mapID] = instanceTemplate;
6519
6520 ++count;
6521 } while (result->NextRow());
6522
6523 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6524 LOG_INFO("server.loading", " ");
6525}
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition MapMgr.cpp:311
bool AllowMount
Definition Map.h:127
uint32 ScriptId
Definition Map.h:126

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

◆ LoadItemLocales()

void ObjectMgr::LoadItemLocales ( )
3198{
3199 uint32 oldMSTime = getMSTime();
3200
3201 _itemLocaleStore.clear(); // need for reload case
3202
3203 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
3204 if (!result)
3205 return;
3206
3207 do
3208 {
3209 Field* fields = result->Fetch();
3210
3211 uint32 ID = fields[0].Get<uint32>();
3212
3213 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3214 if (locale == LOCALE_enUS)
3215 continue;
3216
3217 ItemLocale& data = _itemLocaleStore[ID];
3218 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3219 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
3220 } while (result->NextRow());
3221
3222 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
3223}
Definition ItemTemplate.h:834
std::vector< std::string > Description
Definition ItemTemplate.h:836
std::vector< std::string > Name
Definition ItemTemplate.h:835

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

◆ LoadItemSetNameLocales()

void ObjectMgr::LoadItemSetNameLocales ( )
3872{
3873 uint32 oldMSTime = getMSTime();
3874
3875 _itemSetNameLocaleStore.clear(); // need for reload case
3876
3877 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3878
3879 if (!result)
3880 return;
3881
3882 do
3883 {
3884 Field* fields = result->Fetch();
3885
3886 uint32 ID = fields[0].Get<uint32>();
3887
3888 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3889 if (locale == LOCALE_enUS)
3890 continue;
3891
3893 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3894 } while (result->NextRow());
3895
3896 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3897}
Definition ItemTemplate.h:846
std::vector< std::string > Name
Definition ItemTemplate.h:847

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

◆ LoadItemSetNames()

void ObjectMgr::LoadItemSetNames ( )
3900{
3901 uint32 oldMSTime = getMSTime();
3902
3903 _itemSetNameStore.clear(); // needed for reload case
3904
3905 std::set<uint32> itemSetItems;
3906
3907 // fill item set member ids
3908 for (uint32 entryId = 0; entryId < sItemSetStore.GetNumRows(); ++entryId)
3909 {
3910 ItemSetEntry const* setEntry = sItemSetStore.LookupEntry(entryId);
3911 if (!setEntry)
3912 continue;
3913
3914 for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
3915 if (setEntry->itemId[i])
3916 itemSetItems.insert(setEntry->itemId[i]);
3917 }
3918
3919 // 0 1 2
3920 QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
3921
3922 if (!result)
3923 {
3924 LOG_WARN("server.loading", ">> Loaded 0 item set names. DB table `item_set_names` is empty.");
3925 LOG_INFO("server.loading", " ");
3926 return;
3927 }
3928
3929 _itemSetNameStore.rehash(result->GetRowCount());
3930 uint32 count = 0;
3931
3932 do
3933 {
3934 Field* fields = result->Fetch();
3935
3936 uint32 entry = fields[0].Get<uint32>();
3937 if (itemSetItems.find(entry) == itemSetItems.end())
3938 {
3939 LOG_ERROR("sql.sql", "Item set name (Entry: {}) not found in ItemSet.dbc, data useless.", entry);
3940 continue;
3941 }
3942
3943 ItemSetNameEntry& data = _itemSetNameStore[entry];
3944 data.name = fields[1].Get<std::string>();
3945
3946 uint32 invType = fields[2].Get<uint8>();
3947 if (invType >= MAX_INVTYPE)
3948 {
3949 LOG_ERROR("sql.sql", "Item set name (Entry: {}) has wrong InventoryType value ({})", entry, invType);
3950 invType = INVTYPE_NON_EQUIP;
3951 }
3952
3953 data.InventoryType = invType;
3954 itemSetItems.erase(entry);
3955 ++count;
3956 } while (result->NextRow());
3957
3958 if (!itemSetItems.empty())
3959 {
3960 ItemTemplate const* pProto;
3961 for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr)
3962 {
3963 uint32 entry = *itr;
3964 // add data from item_template if available
3965 pProto = GetItemTemplate(entry);
3966 if (pProto)
3967 {
3968 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, adding data from `item_template`.", entry);
3969 ItemSetNameEntry& data = _itemSetNameStore[entry];
3970 data.name = pProto->Name1;
3971 data.InventoryType = pProto->InventoryType;
3972 ++count;
3973 }
3974 else
3975 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, set will not display properly.", entry);
3976 }
3977 }
3978
3979 LOG_INFO("server.loading", ">> Loaded {} Item Set Names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3980 LOG_INFO("server.loading", " ");
3981}
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
#define MAX_ITEM_SET_ITEMS
Definition DBCStructure.h:1228
@ INVTYPE_NON_EQUIP
Definition ItemTemplate.h:256
#define MAX_INVTYPE
Definition ItemTemplate.h:287
Definition DBCStructure.h:1232
uint32 itemId[MAX_ITEM_SET_ITEMS]
Definition DBCStructure.h:1236
Definition ItemTemplate.h:840
uint32 InventoryType
Definition ItemTemplate.h:842
std::string name
Definition ItemTemplate.h:841
std::string Name1
Definition ItemTemplate.h:624
uint32 InventoryType
Definition ItemTemplate.h:632

References _itemSetNameStore, Field::Get(), GetItemTemplate(), 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, and WorldDatabase.

◆ LoadItemTemplates()

void ObjectMgr::LoadItemTemplates ( )
3250{
3251 uint32 oldMSTime = getMSTime();
3252
3253 // 0 1 2 3 4 5 6 7 8 9 10 11 12
3254 QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, "
3255 // 13 14 15 16 17 18 19 20
3256 "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, "
3257 // 21 22 23 24 25 26 27
3258 "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, stat_type1, "
3259 // 28 29 30 31 32 33 34 35 36 37
3260 "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, "
3261 // 38 39 40 41 42 43 44 45 46
3262 "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, "
3263 // 47 48 49 50 51 52 53 54 55 56 57
3264 "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, "
3265 // 58 59 60 61 62 63 64 65 66 67
3266 "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, "
3267 // 68 69 70 71 72 73 74
3268 "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, "
3269 // 75 76 77 78 79 80 81
3270 "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, "
3271 // 82 83 84 85 86 87 88
3272 "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, "
3273 // 89 90 91 92 93 94 95
3274 "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, "
3275 // 96 97 98 99 100 101 102 103 104
3276 "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, "
3277 // 105 106 107 108 109 110 111 112 113 114 115 116
3278 "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, "
3279 // 117 118 119 120 121 122 123 124
3280 "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
3281 // 125 126 127 128 129 130 131 132
3282 "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
3283 // 133 134 135 136
3284 "FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
3285
3286 if (!result)
3287 {
3288 LOG_WARN("server.loading", ">> Loaded 0 item templates. DB table `item_template` is empty.");
3289 LOG_INFO("server.loading", " ");
3290 return;
3291 }
3292
3293 _itemTemplateStore.reserve(result->GetRowCount());
3294 uint32 count = 0;
3295 // original inspiration https://github.com/TrinityCore/TrinityCore/commit/0c44bd33ee7b42c924859139a9f4b04cf2b91261
3296 bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
3297
3298 do
3299 {
3300 Field* fields = result->Fetch();
3301
3302 uint32 entry = fields[0].Get<uint32>();
3303
3304 ItemTemplate& itemTemplate = _itemTemplateStore[entry];
3305
3306 itemTemplate.ItemId = entry;
3307 itemTemplate.Class = uint32(fields[1].Get<uint8>());
3308 itemTemplate.SubClass = uint32(fields[2].Get<uint8>());
3309 itemTemplate.SoundOverrideSubclass = int32(fields[3].Get<int8>());
3310 itemTemplate.Name1 = fields[4].Get<std::string>();
3311 itemTemplate.DisplayInfoID = fields[5].Get<uint32>();
3312 itemTemplate.Quality = uint32(fields[6].Get<uint8>());
3313 itemTemplate.Flags = ItemFlags(fields[7].Get<uint32>());
3314 itemTemplate.Flags2 = ItemFlags2(fields[8].Get<uint32>());
3315 itemTemplate.BuyCount = uint32(fields[9].Get<uint8>());
3316 itemTemplate.BuyPrice = int32(fields[10].Get<int64>());
3317 itemTemplate.SellPrice = uint32(fields[11].Get<uint32>());
3318 itemTemplate.InventoryType = uint32(fields[12].Get<uint8>());
3319 itemTemplate.AllowableClass = fields[13].Get<int32>();
3320 itemTemplate.AllowableRace = fields[14].Get<int32>();
3321 itemTemplate.ItemLevel = uint32(fields[15].Get<uint16>());
3322 itemTemplate.RequiredLevel = uint32(fields[16].Get<uint8>());
3323 itemTemplate.RequiredSkill = uint32(fields[17].Get<uint16>());
3324 itemTemplate.RequiredSkillRank = uint32(fields[18].Get<uint16>());
3325 itemTemplate.RequiredSpell = fields[19].Get<uint32>();
3326 itemTemplate.RequiredHonorRank = fields[20].Get<uint32>();
3327 itemTemplate.RequiredCityRank = fields[21].Get<uint32>();
3328 itemTemplate.RequiredReputationFaction = uint32(fields[22].Get<uint16>());
3329 itemTemplate.RequiredReputationRank = uint32(fields[23].Get<uint16>());
3330 itemTemplate.MaxCount = fields[24].Get<int32>();
3331 itemTemplate.Stackable = fields[25].Get<int32>();
3332 itemTemplate.ContainerSlots = uint32(fields[26].Get<uint8>());
3333
3334 uint8 statsCount = 0;
3335 while (statsCount < MAX_ITEM_PROTO_STATS)
3336 {
3337 uint32 statType = uint32(fields[27 + statsCount * 2].Get<uint8>());
3338 int32 statValue = fields[28 + statsCount * 2].Get<int32>();
3339 if (statType == 0)
3340 break;
3341
3342 itemTemplate.ItemStat[statsCount].ItemStatType = statType;
3343 itemTemplate.ItemStat[statsCount].ItemStatValue = statValue;
3344 statsCount++;
3345 }
3346 itemTemplate.StatsCount = statsCount;
3347
3348 itemTemplate.ScalingStatDistribution = uint32(fields[47].Get<uint16>());
3349 itemTemplate.ScalingStatValue = fields[48].Get<int32>();
3350
3351 for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
3352 {
3353 itemTemplate.Damage[i].DamageMin = fields[49 + i * 3].Get<float>();
3354 itemTemplate.Damage[i].DamageMax = fields[50 + i * 3].Get<float>();
3355 itemTemplate.Damage[i].DamageType = uint32(fields[51 + i * 3].Get<uint8>());
3356 }
3357
3358 itemTemplate.Armor = fields[55].Get<uint32>();
3359 itemTemplate.HolyRes = fields[56].Get<int32>();
3360 itemTemplate.FireRes = fields[57].Get<int32>();
3361 itemTemplate.NatureRes = fields[58].Get<int32>();
3362 itemTemplate.FrostRes = fields[59].Get<int32>();
3363 itemTemplate.ShadowRes = fields[60].Get<int32>();
3364 itemTemplate.ArcaneRes = fields[61].Get<int32>();
3365 itemTemplate.Delay = uint32(fields[62].Get<uint16>());
3366 itemTemplate.AmmoType = uint32(fields[63].Get<uint8>());
3367 itemTemplate.RangedModRange = fields[64].Get<float>();
3368
3369 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3370 {
3371 itemTemplate.Spells[i].SpellId = fields[65 + i * 7 ].Get<int32>();
3372 itemTemplate.Spells[i].SpellTrigger = uint32(fields[66 + i * 7].Get<uint8>());
3373 itemTemplate.Spells[i].SpellCharges = int32(fields[67 + i * 7].Get<int16>());
3374 itemTemplate.Spells[i].SpellPPMRate = fields[68 + i * 7].Get<float>();
3375 itemTemplate.Spells[i].SpellCooldown = fields[69 + i * 7].Get<int32>();
3376 itemTemplate.Spells[i].SpellCategory = uint32(fields[70 + i * 7].Get<uint16>());
3377 itemTemplate.Spells[i].SpellCategoryCooldown = fields[71 + i * 7].Get<int32>();
3378 }
3379
3380 itemTemplate.Bonding = uint32(fields[100].Get<uint8>());
3381 itemTemplate.Description = fields[101].Get<std::string>();
3382 itemTemplate.PageText = fields[102].Get<uint32>();
3383 itemTemplate.LanguageID = uint32(fields[103].Get<uint8>());
3384 itemTemplate.PageMaterial = uint32(fields[104].Get<uint8>());
3385 itemTemplate.StartQuest = fields[105].Get<uint32>();
3386 itemTemplate.LockID = fields[106].Get<uint32>();
3387 itemTemplate.Material = int32(fields[107].Get<int8>());
3388 itemTemplate.Sheath = uint32(fields[108].Get<uint8>());
3389 itemTemplate.RandomProperty = fields[109].Get<int32>();
3390 itemTemplate.RandomSuffix = fields[110].Get<int32>();
3391 itemTemplate.Block = fields[111].Get<uint32>();
3392 itemTemplate.ItemSet = fields[112].Get<uint32>();
3393 itemTemplate.MaxDurability = uint32(fields[113].Get<uint16>());
3394 itemTemplate.Area = fields[114].Get<uint32>();
3395 itemTemplate.Map = uint32(fields[115].Get<uint16>());
3396 itemTemplate.BagFamily = fields[116].Get<uint32>();
3397 itemTemplate.TotemCategory = fields[117].Get<uint32>();
3398
3399 for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
3400 {
3401 itemTemplate.Socket[i].Color = uint32(fields[118 + i * 2].Get<uint8>());
3402 itemTemplate.Socket[i].Content = fields[119 + i * 2].Get<uint32>();
3403 }
3404
3405 itemTemplate.socketBonus = fields[124].Get<uint32>();
3406 itemTemplate.GemProperties = fields[125].Get<uint32>();
3407 itemTemplate.RequiredDisenchantSkill = uint32(fields[126].Get<int16>());
3408 itemTemplate.ArmorDamageModifier = fields[127].Get<float>();
3409 itemTemplate.Duration = fields[128].Get<uint32>();
3410 itemTemplate.ItemLimitCategory = uint32(fields[129].Get<int16>());
3411 itemTemplate.HolidayId = fields[130].Get<uint32>();
3412 itemTemplate.ScriptId = GetScriptId(fields[131].Get<std::string>());
3413 itemTemplate.DisenchantID = fields[132].Get<uint32>();
3414 itemTemplate.FoodType = uint32(fields[133].Get<uint8>());
3415 itemTemplate.MinMoneyLoot = fields[134].Get<uint32>();
3416 itemTemplate.MaxMoneyLoot = fields[135].Get<uint32>();
3417 itemTemplate.FlagsCu = ItemFlagsCustom(fields[136].Get<uint32>());
3418
3419 // Checks
3420 ItemEntry const* dbcitem = sItemStore.LookupEntry(entry);
3421
3422 if (!dbcitem)
3423 {
3424 LOG_DEBUG("sql.sql", "Item (Entry: {}) does not exist in item.dbc! (not correct id?).", entry);
3425 continue;
3426 }
3427
3428 if (enforceDBCAttributes)
3429 {
3430 if (itemTemplate.Class != dbcitem->ClassID)
3431 {
3432 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Class value ({}), must be ({}).", entry, itemTemplate.Class, dbcitem->ClassID);
3433 itemTemplate.Class = dbcitem->ClassID;
3434 }
3435 if (itemTemplate.SubClass != dbcitem->SubclassID)
3436 {
3437 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Subclass value ({}) for class {}, must be ({}).", entry, itemTemplate.SubClass, itemTemplate.Class, dbcitem->SubclassID);
3438 itemTemplate.SubClass = dbcitem->SubclassID;
3439 }
3440 if (itemTemplate.SoundOverrideSubclass != dbcitem->SoundOverrideSubclassID)
3441 {
3442 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct SoundOverrideSubclass ({}), must be {}.", entry, itemTemplate.SoundOverrideSubclass, dbcitem->SoundOverrideSubclassID);
3443 itemTemplate.SoundOverrideSubclass = dbcitem->SoundOverrideSubclassID;
3444 }
3445 if (itemTemplate.Material != dbcitem->Material)
3446 {
3447 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct material ({}), must be {}.", entry, itemTemplate.Material, dbcitem->Material);
3448 itemTemplate.Material = dbcitem->Material;
3449 }
3450 if (itemTemplate.InventoryType != dbcitem->InventoryType)
3451 {
3452 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong InventoryType value ({}), must be {}.", entry, itemTemplate.InventoryType, dbcitem->InventoryType);
3453 itemTemplate.InventoryType = dbcitem->InventoryType;
3454 }
3455 if (itemTemplate.DisplayInfoID != dbcitem->DisplayInfoID)
3456 {
3457 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct display id ({}), must be {}.", entry, itemTemplate.DisplayInfoID, dbcitem->DisplayInfoID);
3458 itemTemplate.DisplayInfoID = dbcitem->DisplayInfoID;
3459 }
3460 if (itemTemplate.Sheath != dbcitem->SheatheType)
3461 {
3462 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Sheath ({}), must be {}.", entry, itemTemplate.Sheath, dbcitem->SheatheType);
3463 itemTemplate.Sheath = dbcitem->SheatheType;
3464 }
3465 }
3466
3467 if (itemTemplate.Quality >= MAX_ITEM_QUALITY)
3468 {
3469 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Quality value ({})", entry, itemTemplate.Quality);
3470 itemTemplate.Quality = ITEM_QUALITY_NORMAL;
3471 }
3472
3473 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_HORDE))
3474 {
3475 if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
3476 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
3477 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.",
3478 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_HORDE);
3479
3480 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
3481 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.",
3483 }
3484 else if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
3485 {
3486 if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
3487 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
3488 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.",
3489 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_ALLIANCE);
3490 }
3491
3492 if (itemTemplate.BuyCount <= 0)
3493 {
3494 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong BuyCount value ({}), set to default(1).", entry, itemTemplate.BuyCount);
3495 itemTemplate.BuyCount = 1;
3496 }
3497
3498 if (itemTemplate.RequiredSkill >= MAX_SKILL_TYPE)
3499 {
3500 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RequiredSkill value ({})", entry, itemTemplate.RequiredSkill);
3501 itemTemplate.RequiredSkill = 0;
3502 }
3503
3504 {
3505 // can be used in equip slot, as page read use in inventory, or spell casting at use
3506 bool req = itemTemplate.InventoryType != INVTYPE_NON_EQUIP || itemTemplate.PageText;
3507 if (!req)
3508 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3509 {
3510 if (itemTemplate.Spells[j].SpellId)
3511 {
3512 req = true;
3513 break;
3514 }
3515 }
3516
3517 if (req)
3518 {
3519 if (!(itemTemplate.AllowableClass & CLASSMASK_ALL_PLAYABLE))
3520 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable classes ({}) in `AllowableClass` and can't be equipped or used.", entry, itemTemplate.AllowableClass);
3521
3522 if (!(itemTemplate.AllowableRace & sRaceMgr->GetPlayableRaceMask()))
3523 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable races ({}) in `AllowableRace` and can't be equipped or used.", entry, itemTemplate.AllowableRace);
3524 }
3525 }
3526
3527 if (itemTemplate.RequiredSpell && !sSpellMgr->GetSpellInfo(itemTemplate.RequiredSpell))
3528 {
3529 LOG_ERROR("sql.sql", "Item (Entry: {}) has a wrong (non-existing) spell in RequiredSpell ({})", entry, itemTemplate.RequiredSpell);
3530 itemTemplate.RequiredSpell = 0;
3531 }
3532
3533 if (itemTemplate.RequiredReputationRank >= MAX_REPUTATION_RANK)
3534 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong reputation rank in RequiredReputationRank ({}), item can't be used.", entry, itemTemplate.RequiredReputationRank);
3535
3536 if (itemTemplate.RequiredReputationFaction)
3537 {
3538 if (!sFactionStore.LookupEntry(itemTemplate.RequiredReputationFaction))
3539 {
3540 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) faction in RequiredReputationFaction ({})", entry, itemTemplate.RequiredReputationFaction);
3541 itemTemplate.RequiredReputationFaction = 0;
3542 }
3543
3544 if (itemTemplate.RequiredReputationRank == MIN_REPUTATION_RANK)
3545 LOG_ERROR("sql.sql", "Item (Entry: {}) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", entry);
3546 }
3547
3548 if (itemTemplate.MaxCount < -1)
3549 {
3550 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in maxcount ({}), replace by value (-1) no storing limits.", entry, itemTemplate.MaxCount);
3551 itemTemplate.MaxCount = -1;
3552 }
3553
3554 if (itemTemplate.Stackable == 0)
3555 {
3556 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong value in stackable ({}), replace by default 1.", entry, itemTemplate.Stackable);
3557 itemTemplate.Stackable = 1;
3558 }
3559 else if (itemTemplate.Stackable < -1)
3560 {
3561 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in stackable ({}), replace by value (-1) no stacking limits.", entry, itemTemplate.Stackable);
3562 itemTemplate.Stackable = -1;
3563 }
3564
3565 if (itemTemplate.ContainerSlots > MAX_BAG_SIZE)
3566 {
3567 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in ContainerSlots ({}), replace by hardcoded limit ({}).", entry, itemTemplate.ContainerSlots, MAX_BAG_SIZE);
3568 itemTemplate.ContainerSlots = MAX_BAG_SIZE;
3569 }
3570
3571 for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
3572 {
3573 // for ItemStatValue != 0
3574 if (itemTemplate.ItemStat[j].ItemStatValue && itemTemplate.ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
3575 {
3576 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (non-existing?) stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3577 itemTemplate.ItemStat[j].ItemStatType = 0;
3578 }
3579
3580 switch (itemTemplate.ItemStat[j].ItemStatType)
3581 {
3584 // Skip warning for specific items: 13113 (Feathermoon Headdress - Blizzard oversight), 34967 (test item)
3585 if (entry != 13113 && entry != 34967)
3586 LOG_WARN("sql.sql", "Item (Entry: {}) has deprecated stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3587
3588 break;
3589 default:
3590 break;
3591 }
3592 }
3593
3594 for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
3595 {
3596 if (itemTemplate.Damage[j].DamageType >= MAX_SPELL_SCHOOL)
3597 {
3598 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong dmg_type{} ({})", entry, j + 1, itemTemplate.Damage[j].DamageType);
3599 itemTemplate.Damage[j].DamageType = 0;
3600 }
3601 }
3602
3603 // special format
3604 if ((itemTemplate.Spells[0].SpellId == 483) || (itemTemplate.Spells[0].SpellId == 55884))
3605 {
3606 // spell_1
3607 if (itemTemplate.Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3608 {
3609 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);
3610 itemTemplate.Spells[0].SpellId = 0;
3611 itemTemplate.Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3612 itemTemplate.Spells[1].SpellId = 0;
3613 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3614 }
3615
3616 // spell_2 have learning spell
3617 if (itemTemplate.Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3618 {
3619 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);
3620 itemTemplate.Spells[0].SpellId = 0;
3621 itemTemplate.Spells[1].SpellId = 0;
3622 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3623 }
3624 else if (!itemTemplate.Spells[1].SpellId)
3625 {
3626 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have an expected spell in spellid_{} in special learning format.", entry, 1 + 1);
3627 itemTemplate.Spells[0].SpellId = 0;
3628 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3629 }
3630 else if (itemTemplate.Spells[1].SpellId != -1)
3631 {
3632 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
3633 if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
3634 {
3635 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3636 itemTemplate.Spells[0].SpellId = 0;
3637 itemTemplate.Spells[1].SpellId = 0;
3638 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3639 }
3640 // allowed only in special format
3641 else if ((itemTemplate.Spells[1].SpellId == 483) || (itemTemplate.Spells[1].SpellId == 55884))
3642 {
3643 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3644 itemTemplate.Spells[0].SpellId = 0;
3645 itemTemplate.Spells[1].SpellId = 0;
3646 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3647 }
3648 }
3649
3650 // spell_3*, spell_4*, spell_5* is empty
3651 for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
3652 {
3653 if (itemTemplate.Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3654 {
3655 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3656 itemTemplate.Spells[j].SpellId = 0;
3657 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3658 }
3659 else if (itemTemplate.Spells[j].SpellId != 0)
3660 {
3661 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong spell in spellid_{} ({}) for learning special format", entry, j + 1, itemTemplate.Spells[j].SpellId);
3662 itemTemplate.Spells[j].SpellId = 0;
3663 }
3664 }
3665 }
3666 // normal spell list
3667 else
3668 {
3669 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3670 {
3671 if (itemTemplate.Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || itemTemplate.Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3672 {
3673 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3674 itemTemplate.Spells[j].SpellId = 0;
3675 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3676 }
3677
3678 if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
3679 {
3680 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
3681 if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
3682 {
3683 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3684 itemTemplate.Spells[j].SpellId = 0;
3685 }
3686 // allowed only in special format
3687 else if ((itemTemplate.Spells[j].SpellId == 483) || (itemTemplate.Spells[j].SpellId == 55884))
3688 {
3689 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3690 itemTemplate.Spells[j].SpellId = 0;
3691 }
3692 }
3693 }
3694 }
3695
3696 if (itemTemplate.Bonding >= MAX_BIND_TYPE)
3697 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Bonding value ({})", entry, itemTemplate.Bonding);
3698
3699 if (itemTemplate.PageText && !GetPageText(itemTemplate.PageText))
3700 LOG_ERROR("sql.sql", "Item (Entry: {}) has non existing first page (Id:{})", entry, itemTemplate.PageText);
3701
3702 if (itemTemplate.LockID && !sLockStore.LookupEntry(itemTemplate.LockID))
3703 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LockID ({})", entry, itemTemplate.LockID);
3704
3705 if (itemTemplate.RandomProperty)
3706 {
3707 // To be implemented later
3708 if (itemTemplate.RandomProperty == -1)
3709 itemTemplate.RandomProperty = 0;
3710
3711 else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomProperty)))
3712 {
3713 LOG_ERROR("sql.sql", "Item (Entry: {}) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty ({})", entry, itemTemplate.RandomProperty);
3714 itemTemplate.RandomProperty = 0;
3715 }
3716 }
3717
3718 if (itemTemplate.RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomSuffix)))
3719 {
3720 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RandomSuffix ({})", entry, itemTemplate.RandomSuffix);
3721 itemTemplate.RandomSuffix = 0;
3722 }
3723
3724 if (itemTemplate.ItemSet && !sItemSetStore.LookupEntry(itemTemplate.ItemSet))
3725 {
3726 LOG_ERROR("sql.sql", "Item (Entry: {}) have wrong ItemSet ({})", entry, itemTemplate.ItemSet);
3727 itemTemplate.ItemSet = 0;
3728 }
3729
3730 if (itemTemplate.Area && !sAreaTableStore.LookupEntry(itemTemplate.Area))
3731 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Area ({})", entry, itemTemplate.Area);
3732
3733 if (itemTemplate.Map && !sMapStore.LookupEntry(itemTemplate.Map))
3734 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Map ({})", entry, itemTemplate.Map);
3735
3736 if (itemTemplate.BagFamily)
3737 {
3738 // check bits
3739 for (uint32 j = 0; j < sizeof(itemTemplate.BagFamily) * 8; ++j)
3740 {
3741 uint32 mask = 1 << j;
3742 if ((itemTemplate.BagFamily & mask) == 0)
3743 continue;
3744
3745 ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j + 1);
3746 if (!bf)
3747 {
3748 LOG_ERROR("sql.sql", "Item (Entry: {}) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", entry);
3749 itemTemplate.BagFamily &= ~mask;
3750 continue;
3751 }
3752
3754 {
3755 CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemTemplate.ItemId);
3756 if (!ctEntry)
3757 {
3758 LOG_ERROR("sql.sql", "Item (Entry: {}) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit", entry);
3759 itemTemplate.BagFamily &= ~mask;
3760 }
3761 }
3762 }
3763 }
3764
3765 if (itemTemplate.TotemCategory && !sTotemCategoryStore.LookupEntry(itemTemplate.TotemCategory))
3766 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong TotemCategory ({})", entry, itemTemplate.TotemCategory);
3767
3768 for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
3769 {
3770 if (itemTemplate.Socket[j].Color && (itemTemplate.Socket[j].Color & SOCKET_COLOR_ALL) != itemTemplate.Socket[j].Color)
3771 {
3772 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong socketColor_{} ({})", entry, j + 1, itemTemplate.Socket[j].Color);
3773 itemTemplate.Socket[j].Color = 0;
3774 }
3775 }
3776
3777 if (itemTemplate.GemProperties && !sGemPropertiesStore.LookupEntry(itemTemplate.GemProperties))
3778 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong GemProperties ({})", entry, itemTemplate.GemProperties);
3779
3780 if (itemTemplate.FoodType >= MAX_PET_DIET)
3781 {
3782 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong FoodType value ({})", entry, itemTemplate.FoodType);
3783 itemTemplate.FoodType = 0;
3784 }
3785
3786 if (itemTemplate.ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(itemTemplate.ItemLimitCategory))
3787 {
3788 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LimitCategory value ({})", entry, itemTemplate.ItemLimitCategory);
3789 itemTemplate.ItemLimitCategory = 0;
3790 }
3791
3792 if (itemTemplate.HolidayId && !sHolidaysStore.LookupEntry(itemTemplate.HolidayId))
3793 {
3794 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong HolidayId value ({})", entry, itemTemplate.HolidayId);
3795 itemTemplate.HolidayId = 0;
3796 }
3797
3798 if (itemTemplate.HasFlagCu(ITEM_FLAGS_CU_DURATION_REAL_TIME) && !itemTemplate.Duration)
3799 {
3800 LOG_ERROR("sql.sql", "Item (Entry {}) has flag ITEM_FLAGS_CU_DURATION_REAL_TIME but it does not have duration limit", entry);
3801 itemTemplate.FlagsCu = static_cast<ItemFlagsCustom>(static_cast<uint32>(itemTemplate.FlagsCu) & ~ITEM_FLAGS_CU_DURATION_REAL_TIME);
3802 }
3803
3804 // Set after checks to ensure valid item quality
3805 itemTemplate.BuyPrice *= sWorld->getRate(qualityToBuyValueConfig[itemTemplate.Quality]);
3806 itemTemplate.SellPrice *= sWorld->getRate(qualityToSellValueConfig[itemTemplate.Quality]);
3807
3808 // Fill categories map
3809 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3810 if (itemTemplate.Spells[i].SpellId && itemTemplate.Spells[i].SpellCategory && itemTemplate.Spells[i].SpellCategoryCooldown)
3811 {
3812 SpellCategoryStore::iterator ct = sSpellsByCategoryStore.find(itemTemplate.Spells[i].SpellCategory);
3813 if (ct != sSpellsByCategoryStore.end())
3814 {
3815 ct->second.emplace(true, itemTemplate.Spells[i].SpellId);
3816 }
3817 else
3818 sSpellsByCategoryStore[itemTemplate.Spells[i].SpellCategory].emplace(true, itemTemplate.Spells[i].SpellId);
3819 }
3820
3821 ++count;
3822 } while (result->NextRow());
3823
3824 // pussywizard:
3825 {
3826 uint32 max = 0;
3827 for (ItemTemplateContainer::const_iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3828 if (itr->first > max)
3829 max = itr->first;
3830 if (max)
3831 {
3832 _itemTemplateStoreFast.clear();
3833 _itemTemplateStoreFast.resize(max + 1, nullptr);
3834 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3835 _itemTemplateStoreFast[itr->first] = &(itr->second);
3836 }
3837 }
3838
3839 // Check if item templates for DBC referenced character start outfit are present
3840 std::set<uint32> notFoundOutfit;
3841 for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i)
3842 {
3843 CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i);
3844 if (!entry)
3845 continue;
3846
3847 for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
3848 {
3849 if (entry->ItemId[j] <= 0)
3850 continue;
3851
3852 uint32 item_id = entry->ItemId[j];
3853
3854 if (!GetItemTemplate(item_id))
3855 notFoundOutfit.insert(item_id);
3856 }
3857 }
3858
3859 for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr)
3860 LOG_ERROR("sql.sql", "Item (Entry: {}) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr);
3861
3862 LOG_INFO("server.loading", ">> Loaded {} Item Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3863 LOG_INFO("server.loading", " ");
3864}
#define MAX_BAG_SIZE
Definition Bag.h:22
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)
#define MAX_OUTFIT_ITEMS
Definition DBCStructure.h:617
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_SPELL
Definition DisableMgr.h:28
uint32 GetItemEnchantMod(int32 entry)
Definition ItemEnchantmentMgr.cpp:84
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
@ ITEM_MOD_SPELL_DAMAGE_DONE
Definition ItemTemplate.h:64
#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
ServerConfigs const qualityToSellValueConfig[MAX_ITEM_QUALITY]
Definition ObjectMgr.cpp:3237
ServerConfigs const qualityToBuyValueConfig[MAX_ITEM_QUALITY]
Definition ObjectMgr.cpp:3225
#define MAX_REPUTATION_RANK
Definition SharedDefines.h:233
#define MIN_REPUTATION_RANK
Definition SharedDefines.h:232
#define MAX_PET_DIET
Definition SharedDefines.h:3464
@ ITEM_QUALITY_NORMAL
Definition SharedDefines.h:318
#define MAX_ITEM_QUALITY
Definition SharedDefines.h:327
#define MAX_SKILL_TYPE
Definition SharedDefines.h:3251
@ ALLIANCE
Definition SharedDefines.h:756
@ HORDE
Definition SharedDefines.h:755
#define CLASSMASK_ALL_PLAYABLE
Definition SharedDefines.h:142
@ CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES
Definition WorldConfig.h:100
Definition DBCStructure.h:620
int32 ItemId[MAX_OUTFIT_ITEMS]
Definition DBCStructure.h:626
Definition DBCStructure.h:835
Definition DBCStructure.h:907
Definition DBCStructure.h:1155
int32 SoundOverrideSubclassID
Definition DBCStructure.h:1147
uint32 SheatheType
Definition DBCStructure.h:1151
uint32 DisplayInfoID
Definition DBCStructure.h:1149
uint32 ClassID
Definition DBCStructure.h:1145
int32 Material
Definition DBCStructure.h:1148
uint32 SubclassID
Definition DBCStructure.h:1146
uint32 ItemId
Definition ItemTemplate.h:620

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(), GetScriptId(), HORDE, ItemEntry::InventoryType, INVTYPE_NON_EQUIP, ITEM_FLAG2_FACTION_ALLIANCE, ITEM_FLAG2_FACTION_HORDE, ITEM_FLAGS_CU_DURATION_REAL_TIME, ITEM_MOD_SPELL_DAMAGE_DONE, ITEM_MOD_SPELL_HEALING_DONE, ITEM_QUALITY_NORMAL, ITEM_SPELLTRIGGER_LEARN_SPELL_ID, ITEM_SPELLTRIGGER_ON_USE, ItemTemplate::ItemId, 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, qualityToBuyValueConfig, qualityToSellValueConfig, sAreaTableStore, sCharStartOutfitStore, sCurrencyTypesStore, sDisableMgr, sFactionStore, sGemPropertiesStore, ItemEntry::SheatheType, sHolidaysStore, sItemBagFamilyStore, sItemLimitCategoryStore, sItemRandomPropertiesStore, sItemRandomSuffixStore, sItemSetStore, sItemStore, sLockStore, sMapStore, SOCKET_COLOR_ALL, ItemEntry::SoundOverrideSubclassID, sRaceMgr, sSpellMgr, sSpellsByCategoryStore, sTotemCategoryStore, ItemEntry::SubclassID, sWorld, and WorldDatabase.

◆ LoadLinkedRespawn()

void ObjectMgr::LoadLinkedRespawn ( )
1919{
1920 uint32 oldMSTime = getMSTime();
1921
1922 _linkedRespawnStore.clear();
1923 // 0 1 2
1924 QueryResult result = WorldDatabase.Query("SELECT guid, linkedGuid, linkType FROM linked_respawn ORDER BY guid ASC");
1925
1926 if (!result)
1927 {
1928 LOG_WARN("server.loading", ">> Loaded 0 linked respawns. DB table `linked_respawn` is empty.");
1929 LOG_INFO("server.loading", " ");
1930 return;
1931 }
1932
1933 do
1934 {
1935 Field* fields = result->Fetch();
1936
1937 ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
1938 ObjectGuid::LowType linkedGuidLow = fields[1].Get<uint32>();
1939 uint8 linkType = fields[2].Get<uint8>();
1940
1941 ObjectGuid guid, linkedGuid;
1942 bool error = false;
1943 switch (linkType)
1944 {
1946 {
1947 const CreatureData* slave = GetCreatureData(guidLow);
1948 if (!slave)
1949 {
1950 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1951 error = true;
1952 break;
1953 }
1954
1955 const CreatureData* master = GetCreatureData(linkedGuidLow);
1956 if (!master)
1957 {
1958 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1959 error = true;
1960 break;
1961 }
1962
1963 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1964 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1965 {
1966 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1967 error = true;
1968 break;
1969 }
1970
1971 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1972 {
1973 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1974 error = true;
1975 break;
1976 }
1977
1978 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1979 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1980 break;
1981 }
1982 case CREATURE_TO_GO:
1983 {
1984 const CreatureData* slave = GetCreatureData(guidLow);
1985 if (!slave)
1986 {
1987 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1988 error = true;
1989 break;
1990 }
1991
1992 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1993 if (!master)
1994 {
1995 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1996 error = true;
1997 break;
1998 }
1999
2000 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2001 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2002 {
2003 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2004 error = true;
2005 break;
2006 }
2007
2008 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2009 {
2010 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2011 error = true;
2012 break;
2013 }
2014
2015 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
2016 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
2017 break;
2018 }
2019 case GO_TO_GO:
2020 {
2021 const GameObjectData* slave = GetGameObjectData(guidLow);
2022 if (!slave)
2023 {
2024 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
2025 error = true;
2026 break;
2027 }
2028
2029 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
2030 if (!master)
2031 {
2032 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
2033 error = true;
2034 break;
2035 }
2036
2037 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2038 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2039 {
2040 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2041 error = true;
2042 break;
2043 }
2044
2045 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2046 {
2047 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2048 error = true;
2049 break;
2050 }
2051
2052 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2053 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
2054 break;
2055 }
2056 case GO_TO_CREATURE:
2057 {
2058 const GameObjectData* slave = GetGameObjectData(guidLow);
2059 if (!slave)
2060 {
2061 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
2062 error = true;
2063 break;
2064 }
2065
2066 const CreatureData* master = GetCreatureData(linkedGuidLow);
2067 if (!master)
2068 {
2069 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
2070 error = true;
2071 break;
2072 }
2073
2074 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2075 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2076 {
2077 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2078 error = true;
2079 break;
2080 }
2081
2082 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2083 {
2084 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2085 error = true;
2086 break;
2087 }
2088
2089 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2090 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
2091 break;
2092 }
2093 }
2094
2095 if (!error)
2096 _linkedRespawnStore[guid] = linkedGuid;
2097 } while (result->NextRow());
2098
2099 LOG_INFO("server.loading", ">> Loaded {} Linked Respawns In {} ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime));
2100 LOG_INFO("server.loading", " ");
2101}
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, SpawnData::mapid, sMapStore, SpawnData::spawnMask, and WorldDatabase.

◆ LoadMailLevelRewards()

void ObjectMgr::LoadMailLevelRewards ( )
9870{
9871 uint32 oldMSTime = getMSTime();
9872
9873 _mailLevelRewardStore.clear(); // for reload case
9874
9875 // 0 1 2 3
9876 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
9877
9878 if (!result)
9879 {
9880 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
9881 LOG_INFO("server.loading", " ");
9882 return;
9883 }
9884
9885 uint32 count = 0;
9886
9887 do
9888 {
9889 Field* fields = result->Fetch();
9890
9891 uint8 level = fields[0].Get<uint8>();
9892 uint32 raceMask = fields[1].Get<uint32>();
9893 uint32 mailTemplateId = fields[2].Get<uint32>();
9894 uint32 senderEntry = fields[3].Get<uint32>();
9895
9896 if (level > MAX_LEVEL)
9897 {
9898 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
9899 continue;
9900 }
9901
9902 if (!(raceMask & sRaceMgr->GetPlayableRaceMask()))
9903 {
9904 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
9905 continue;
9906 }
9907
9908 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
9909 {
9910 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
9911 continue;
9912 }
9913
9914 if (!GetCreatureTemplate(senderEntry))
9915 {
9916 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);
9917 continue;
9918 }
9919
9920 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
9921
9922 ++count;
9923 } while (result->NextRow());
9924
9925 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9926 LOG_INFO("server.loading", " ");
9927}
#define MAX_LEVEL
Definition DBCEnums.h:39
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
Definition ObjectMgr.h:547

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

◆ LoadModuleStrings()

bool ObjectMgr::LoadModuleStrings ( )
9449{
9450 uint32 oldMSTime = getMSTime();
9451
9452 _moduleStringStore.clear(); // for reload case
9453 QueryResult result = WorldDatabase.Query("SELECT module, id, string FROM module_string");
9454 if (!result)
9455 {
9456 LOG_WARN("server.loading", ">> Loaded 0 module strings. DB table `module_string` is empty.");
9457 LOG_INFO("server.loading", " ");
9458 return false;
9459 }
9460
9461 do
9462 {
9463 Field* fields = result->Fetch();
9464
9465 std::string module = fields[0].Get<std::string>();
9466 uint32 id = fields[1].Get<uint32>();
9467
9468 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
9469 ModuleString& data = _moduleStringStore[pairKey];
9470
9471 AddLocaleString(fields[2].Get<std::string>(), LOCALE_enUS, data.Content);
9472 } while (result->NextRow());
9473
9474 LOG_INFO("server.loading", ">> Loaded {} Module Strings in {} ms", _moduleStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
9475 LOG_INFO("server.loading", " ");
9476
9477 return true;
9478}

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

◆ LoadModuleStringsLocale()

bool ObjectMgr::LoadModuleStringsLocale ( )
9481{
9482 uint32 oldMSTime = getMSTime();
9483
9484 QueryResult result = WorldDatabase.Query("SELECT module, id, locale, string FROM module_string_locale");
9485 if (!result)
9486 {
9487 LOG_WARN("server.loading", ">> Loaded 0 module strings locale. DB table `module_string_locale` is empty.");
9488 LOG_INFO("server.loading", " ");
9489 return false;
9490 }
9491
9492 uint32 localeCount = 0;
9493 do
9494 {
9495 Field* fields = result->Fetch();
9496
9497 std::string module = fields[0].Get<std::string>();
9498 uint32 id = fields[1].Get<uint32>();
9499
9500 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
9501 ModuleString& data = _moduleStringStore[pairKey];
9502
9503 ModuleStringContainer::iterator ms = _moduleStringStore.find(pairKey);
9504 if (ms == _moduleStringStore.end())
9505 {
9506 LOG_ERROR("sql.sql", "ModuleString (Module: {} Id: {}) found in table `module_string_locale` but does not exist in `module_string`. Skipped!", module, id);
9507 continue;
9508 }
9509
9510 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
9511 if (locale == LOCALE_enUS)
9512 continue;
9513
9514 AddLocaleString(fields[3].Get<std::string>(), locale, data.Content);
9515 localeCount++;
9516 } while (result->NextRow());
9517
9518 LOG_INFO("server.loading", ">> Loaded {} Module Strings Locales in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
9519 LOG_INFO("server.loading", " ");
9520
9521 return true;
9522}

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

◆ LoadNPCSpellClickSpells()

void ObjectMgr::LoadNPCSpellClickSpells ( )
8622{
8623 uint32 oldMSTime = getMSTime();
8624
8625 _spellClickInfoStore.clear();
8626 // 0 1 2 3
8627 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
8628
8629 if (!result)
8630 {
8631 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
8632 LOG_INFO("server.loading", " ");
8633 return;
8634 }
8635
8636 uint32 count = 0;
8637
8638 do
8639 {
8640 Field* fields = result->Fetch();
8641
8642 uint32 npc_entry = fields[0].Get<uint32>();
8643 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
8644 if (!cInfo)
8645 {
8646 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
8647 continue;
8648 }
8649
8650 uint32 spellid = fields[1].Get<uint32>();
8651 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
8652 if (!spellinfo)
8653 {
8654 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
8655 continue;
8656 }
8657
8658 uint8 userType = fields[3].Get<uint16>();
8659 if (userType >= SPELL_CLICK_USER_MAX)
8660 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
8661
8662 uint8 castFlags = fields[2].Get<uint8>();
8663 SpellClickInfo info;
8664 info.spellId = spellid;
8665 info.castFlags = castFlags;
8666 info.userType = SpellClickUserTypes(userType);
8667 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
8668
8669 ++count;
8670 } while (result->NextRow());
8671
8672 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
8673 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
8675 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
8676 {
8677 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
8678 {
8679 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);
8680 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
8681 }
8682 }
8683
8684 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8685 LOG_INFO("server.loading", " ");
8686}
SpellClickUserTypes
Definition SharedDefines.h:668
@ SPELL_CLICK_USER_MAX
Definition SharedDefines.h:673
@ UNIT_NPC_FLAG_SPELLCLICK
Definition UnitDefines.h:346
Definition ObjectMgr.h:399
uint32 spellId
Definition ObjectMgr.h:400

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

◆ LoadNpcTextLocales()

void ObjectMgr::LoadNpcTextLocales ( )
6706{
6707 uint32 oldMSTime = getMSTime();
6708
6709 _npcTextLocaleStore.clear(); // need for reload case
6710
6711 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6712 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6713 "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 "
6714 "FROM npc_text_locale");
6715
6716 if (!result)
6717 return;
6718
6719 do
6720 {
6721 Field* fields = result->Fetch();
6722
6723 uint32 ID = fields[0].Get<uint32>();
6724
6725 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6726 if (locale == LOCALE_enUS)
6727 continue;
6728
6730 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6731 {
6732 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6733 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6734 }
6735 } while (result->NextRow());
6736
6737 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6738}
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 ( )
6453{
6454 uint32 oldMSTime = getMSTime();
6455
6456 _pageTextLocaleStore.clear(); // need for reload case
6457
6458 // 0 1 2
6459 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
6460
6461 if (!result)
6462 {
6463 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text_locale` is empty!");
6464 LOG_INFO("server.loading", " ");
6465 return;
6466 }
6467
6468 do
6469 {
6470 Field* fields = result->Fetch();
6471
6472 uint32 ID = fields[0].Get<uint32>();
6473
6474 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6475 if (locale == LOCALE_enUS)
6476 continue;
6477
6479 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
6480 } while (result->NextRow());
6481
6482 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6483}
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, LOG_WARN, PageTextLocale::Text, and WorldDatabase.

◆ LoadPageTexts()

void ObjectMgr::LoadPageTexts ( )
6403{
6404 uint32 oldMSTime = getMSTime();
6405
6406 // 0 1 2
6407 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
6408
6409 if (!result)
6410 {
6411 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
6412 LOG_INFO("server.loading", " ");
6413 return;
6414 }
6415
6416 uint32 count = 0;
6417 do
6418 {
6419 Field* fields = result->Fetch();
6420
6421 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
6422
6423 pageText.Text = fields[1].Get<std::string>();
6424 pageText.NextPage = fields[2].Get<uint32>();
6425
6426 ++count;
6427 } while (result->NextRow());
6428
6429 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
6430 {
6431 if (itr->second.NextPage)
6432 {
6433 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
6434 if (itr2 == _pageTextStore.end())
6435 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
6436 }
6437 }
6438
6439 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6440 LOG_INFO("server.loading", " ");
6441}
Definition ObjectMgr.h:58
std::string Text
Definition ObjectMgr.h:59
uint32 NextPage
Definition ObjectMgr.h:60

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

◆ LoadPetLevelInfo()

void ObjectMgr::LoadPetLevelInfo ( )
4140{
4141 uint32 oldMSTime = getMSTime();
4142
4143 // 0 1 2 3 4 5 6 7 8 9 10 11
4144 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
4145
4146 if (!result)
4147 {
4148 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
4149 LOG_INFO("server.loading", " ");
4150 return;
4151 }
4152
4153 uint32 count = 0;
4154
4155 do
4156 {
4157 Field* fields = result->Fetch();
4158
4159 uint32 creature_id = fields[0].Get<uint32>();
4160 if (!GetCreatureTemplate(creature_id))
4161 {
4162 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
4163 continue;
4164 }
4165
4166 uint32 current_level = fields[1].Get<uint8>();
4167 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4168 {
4169 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4170 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4171 else
4172 {
4173 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
4174 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4175 }
4176 continue;
4177 }
4178 else if (current_level < 1)
4179 {
4180 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
4181 continue;
4182 }
4183
4184 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
4185
4186 if (!pInfoMapEntry)
4187 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4188
4189 // data for level 1 stored in [0] array element, ...
4190 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
4191
4192 pLevelInfo->health = fields[2].Get<uint32>();
4193 pLevelInfo->mana = fields[3].Get<uint32>();
4194 pLevelInfo->armor = fields[9].Get<uint32>();
4195 pLevelInfo->min_dmg = fields[10].Get<uint32>();
4196 pLevelInfo->max_dmg = fields[11].Get<uint32>();
4197 for (uint8 i = 0; i < MAX_STATS; i++)
4198 {
4199 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
4200 }
4201
4202 ++count;
4203 } while (result->NextRow());
4204
4205 // Fill gaps and check integrity
4206 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
4207 {
4208 PetLevelInfo* pInfo = itr->second;
4209
4210 // fatal error if no level 1 data
4211 if (!pInfo || pInfo[0].health == 0)
4212 {
4213 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
4214 exit(1);
4215 }
4216
4217 // fill level gaps
4218 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4219 {
4220 if (pInfo[level].health == 0)
4221 {
4222 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
4223 pInfo[level] = pInfo[level - 1];
4224 }
4225 }
4226 }
4227
4228 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4229 LOG_INFO("server.loading", " ");
4230}
#define STRONG_MAX_LEVEL
Definition DBCEnums.h:43
#define MAX_STATS
Definition SharedDefines.h:253
Definition ObjectMgr.h:532
uint32 max_dmg
Definition ObjectMgr.h:543
uint32 mana
Definition ObjectMgr.h:540
uint32 min_dmg
Definition ObjectMgr.h:542
uint32 health
Definition ObjectMgr.h:539
std::array< uint32, MAX_STATS > stats
Definition ObjectMgr.h:538
uint32 armor
Definition ObjectMgr.h:541

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

◆ LoadPetNames()

void ObjectMgr::LoadPetNames ( )
8128{
8129 uint32 oldMSTime = getMSTime();
8130 // 0 1 2
8131 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
8132
8133 if (!result)
8134 {
8135 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
8136 LOG_INFO("server.loading", " ");
8137 return;
8138 }
8139
8140 uint32 count = 0;
8141
8142 do
8143 {
8144 Field* fields = result->Fetch();
8145 std::string word = fields[0].Get<std::string>();
8146 uint32 entry = fields[1].Get<uint32>();
8147 bool half = fields[2].Get<bool>();
8148 if (half)
8149 _petHalfName1[entry].push_back(word);
8150 else
8151 _petHalfName0[entry].push_back(word);
8152 ++count;
8153 } while (result->NextRow());
8154
8155 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8156 LOG_INFO("server.loading", " ");
8157}

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

◆ LoadPetNamesLocales()

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

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

◆ LoadPetNumber()

void ObjectMgr::LoadPetNumber ( )
8160{
8161 uint32 oldMSTime = getMSTime();
8162
8163 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
8164 if (result)
8165 {
8166 Field* fields = result->Fetch();
8167 _hiPetNumber = fields[0].Get<uint32>() + 1;
8168 }
8169
8170 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
8171 LOG_INFO("server.loading", " ");
8172}

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

◆ LoadPlayerInfo()

void ObjectMgr::LoadPlayerInfo ( )
4279{
4280 // Load playercreate
4281 {
4282 if (_playerInfo.empty() || _playerInfo.size() != sRaceMgr->GetMaxRaces())
4283 {
4284 _playerInfo.clear();
4285 _playerInfo.resize(sRaceMgr->GetMaxRaces());
4286 for (auto& classVec : _playerInfo)
4287 classVec.resize(MAX_CLASSES, nullptr);
4288 }
4289
4290 uint32 oldMSTime = getMSTime();
4291 // 0 1 2 3 4 5 6
4292 QueryResult result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
4293
4294 if (!result)
4295 {
4296 LOG_INFO("server.loading", " ");
4297 LOG_WARN("server.loading", ">> Loaded 0 player create definitions. DB table `playercreateinfo` is empty.");
4298 exit(1);
4299 }
4300 else
4301 {
4302 uint32 count = 0;
4303
4304 do
4305 {
4306 Field* fields = result->Fetch();
4307
4308 uint32 current_race = fields[0].Get<uint8>();
4309 uint32 current_class = fields[1].Get<uint8>();
4310 uint32 mapId = fields[2].Get<uint16>();
4311 uint32 areaId = fields[3].Get<uint32>(); // zone
4312 float positionX = fields[4].Get<float>();
4313 float positionY = fields[5].Get<float>();
4314 float positionZ = fields[6].Get<float>();
4315 float orientation = fields[7].Get<float>();
4316
4317 if (current_race >= sRaceMgr->GetMaxRaces())
4318 {
4319 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
4320 continue;
4321 }
4322
4323 ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
4324 if (!rEntry)
4325 {
4326 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
4327 continue;
4328 }
4329
4330 if (current_class >= MAX_CLASSES)
4331 {
4332 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
4333 continue;
4334 }
4335
4336 if (!sChrClassesStore.LookupEntry(current_class))
4337 {
4338 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
4339 continue;
4340 }
4341
4342 // accept DB data only for valid position (and non instanceable)
4343 if (!MapMgr::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation))
4344 {
4345 LOG_ERROR("sql.sql", "Wrong home position for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
4346 continue;
4347 }
4348
4349 if (sMapStore.LookupEntry(mapId)->Instanceable())
4350 {
4351 LOG_ERROR("sql.sql", "Home position in instanceable map for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
4352 continue;
4353 }
4354
4355 PlayerInfo* info = new PlayerInfo();
4356 info->mapId = mapId;
4357 info->areaId = areaId;
4358 info->positionX = positionX;
4359 info->positionY = positionY;
4360 info->positionZ = positionZ;
4361 info->orientation = orientation;
4362 info->displayId_m = rEntry->model_m;
4363 info->displayId_f = rEntry->model_f;
4364 _playerInfo[current_race][current_class] = info;
4365
4366 ++count;
4367 } while (result->NextRow());
4368
4369 LOG_INFO("server.loading", ">> Loaded {} Player Create Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4370 LOG_INFO("server.loading", " ");
4371 }
4372 }
4373
4374 // Load playercreate items
4375 LOG_INFO("server.loading", "Loading Player Create Items Data...");
4376 {
4377 uint32 oldMSTime = getMSTime();
4378 // 0 1 2 3
4379 QueryResult result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
4380
4381 if (!result)
4382 {
4383 LOG_WARN("server.loading", ">> Loaded 0 Custom Player Create Items. DB Table `playercreateinfo_item` Is Empty.");
4384 LOG_INFO("server.loading", " ");
4385 }
4386 else
4387 {
4388 uint32 count = 0;
4389
4390 do
4391 {
4392 Field* fields = result->Fetch();
4393
4394 uint32 current_race = fields[0].Get<uint8>();
4395 if (current_race >= sRaceMgr->GetMaxRaces())
4396 {
4397 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_item` table, ignoring.", current_race);
4398 continue;
4399 }
4400
4401 uint32 current_class = fields[1].Get<uint8>();
4402 if (current_class >= MAX_CLASSES)
4403 {
4404 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_item` table, ignoring.", current_class);
4405 continue;
4406 }
4407
4408 uint32 item_id = fields[2].Get<uint32>();
4409
4410 if (!GetItemTemplate(item_id))
4411 {
4412 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);
4413 continue;
4414 }
4415
4416 int32 amount = fields[3].Get<int32>();
4417
4418 if (!amount)
4419 {
4420 LOG_ERROR("sql.sql", "Item id {} (class {} race {}) have amount == 0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class);
4421 continue;
4422 }
4423
4424 if (!current_race || !current_class)
4425 {
4426 uint32 min_race = current_race ? current_race : 1;
4427 uint32 max_race = current_race ? current_race + 1 : sRaceMgr->GetMaxRaces();
4428 uint32 min_class = current_class ? current_class : 1;
4429 uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
4430 for (uint32 r = min_race; r < max_race; ++r)
4431 for (uint32 c = min_class; c < max_class; ++c)
4432 PlayerCreateInfoAddItemHelper(r, c, item_id, amount);
4433 }
4434 else
4435 PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount);
4436
4437 ++count;
4438 } while (result->NextRow());
4439
4440 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4441 LOG_INFO("server.loading", " ");
4442 }
4443 }
4444
4445 // Load playercreate skills
4446 LOG_INFO("server.loading", "Loading Player Create Skill Data...");
4447 {
4448 uint32 oldMSTime = getMSTime();
4449
4450 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, skill, `rank` FROM playercreateinfo_skills");
4451
4452 if (!result)
4453 {
4454 LOG_WARN("server.loading", ">> Loaded 0 Player Create Skills. DB Table `playercreateinfo_skills` Is Empty.");
4455 }
4456 else
4457 {
4458 uint32 count = 0;
4459
4460 do
4461 {
4462 Field* fields = result->Fetch();
4463 uint32 raceMask = fields[0].Get<uint32>();
4464 uint32 classMask = fields[1].Get<uint32>();
4466 skill.SkillId = fields[2].Get<uint16>();
4467 skill.Rank = fields[3].Get<uint16>();
4468
4469 if (skill.Rank >= MAX_SKILL_STEP)
4470 {
4471 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);
4472 continue;
4473 }
4474
4475 if (raceMask != 0 && !(raceMask & sRaceMgr->GetPlayableRaceMask()))
4476 {
4477 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_skills` table, ignoring.", raceMask);
4478 continue;
4479 }
4480
4481 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4482 {
4483 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_skills` table, ignoring.", classMask);
4484 continue;
4485 }
4486
4487 if (!sSkillLineStore.LookupEntry(skill.SkillId))
4488 {
4489 LOG_ERROR("sql.sql", "Wrong skill id {} in `playercreateinfo_skills` table, ignoring.", skill.SkillId);
4490 continue;
4491 }
4492
4493 for (uint32 raceIndex = RACE_HUMAN; raceIndex < sRaceMgr->GetMaxRaces(); ++raceIndex)
4494 {
4495 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4496 {
4497 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4498 {
4499 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4500 {
4501 if (!GetSkillRaceClassInfo(skill.SkillId, raceIndex, classIndex))
4502 continue;
4503
4504 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4505 {
4506 info->skills.push_back(skill);
4507 ++count;
4508 }
4509 }
4510 }
4511 }
4512 }
4513 } while (result->NextRow());
4514
4515 LOG_INFO("server.loading", ">> Loaded {} Player Create Skills in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4516 LOG_INFO("server.loading", " ");
4517 }
4518 }
4519
4520 // Load playercreate spells
4521 LOG_INFO("server.loading", "Loading Player Create Spell Data...");
4522 {
4523 uint32 oldMSTime = getMSTime();
4524
4525 QueryResult result = WorldDatabase.Query("SELECT racemask, classmask, Spell FROM playercreateinfo_spell_custom");
4526
4527 if (!result)
4528 {
4529 LOG_WARN("server.loading", ">> Loaded 0 player create spells. DB table `playercreateinfo_spell_custom` is empty.");
4530 }
4531 else
4532 {
4533 uint32 count = 0;
4534
4535 do
4536 {
4537 Field* fields = result->Fetch();
4538 uint32 raceMask = fields[0].Get<uint32>();
4539 uint32 classMask = fields[1].Get<uint32>();
4540 uint32 spellId = fields[2].Get<uint32>();
4541
4542 if (raceMask != 0 && !(raceMask & sRaceMgr->GetPlayableRaceMask()))
4543 {
4544 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_spell_custom` table, ignoring.", raceMask);
4545 continue;
4546 }
4547
4548 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4549 {
4550 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_spell_custom` table, ignoring.", classMask);
4551 continue;
4552 }
4553
4554 for (uint32 raceIndex = RACE_HUMAN; raceIndex < sRaceMgr->GetMaxRaces(); ++raceIndex)
4555 {
4556 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4557 {
4558 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4559 {
4560 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4561 {
4562 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4563 {
4564 info->customSpells.push_back(spellId);
4565 ++count;
4566 }
4567 }
4568 }
4569 }
4570 }
4571 } while (result->NextRow());
4572
4573 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4574 LOG_INFO("server.loading", " ");
4575 }
4576 }
4577
4578 // Load playercreate cast spell
4579 LOG_INFO("server.loading", "Loading Player Create Cast Spell Data...");
4580 {
4581 uint32 oldMSTime = getMSTime();
4582
4583 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
4584
4585 if (!result)
4586 {
4587 LOG_WARN("server.loading", ">> Loaded 0 Player Create Cast Spells. DB Table `playercreateinfo_cast_spell` Is Empty.");
4588 }
4589 else
4590 {
4591 uint32 count = 0;
4592
4593 do
4594 {
4595 Field* fields = result->Fetch();
4596 uint32 raceMask = fields[0].Get<uint32>();
4597 uint32 classMask = fields[1].Get<uint32>();
4598 uint32 spellId = fields[2].Get<uint32>();
4599
4600 if (raceMask != 0 && !(raceMask & sRaceMgr->GetPlayableRaceMask()))
4601 {
4602 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
4603 continue;
4604 }
4605
4606 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4607 {
4608 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
4609 continue;
4610 }
4611
4612 for (uint32 raceIndex = RACE_HUMAN; raceIndex < sRaceMgr->GetMaxRaces(); ++raceIndex)
4613 {
4614 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4615 {
4616 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4617 {
4618 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4619 {
4620 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4621 {
4622 info->castSpells.push_back(spellId);
4623 ++count;
4624 }
4625 }
4626 }
4627 }
4628 }
4629 } while (result->NextRow());
4630
4631 LOG_INFO("server.loading", ">> Loaded {} Player Create Cast Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4632 LOG_INFO("server.loading", " ");
4633 }
4634 }
4635
4636 // Load playercreate actions
4637 LOG_INFO("server.loading", "Loading Player Create Action Data...");
4638 {
4639 uint32 oldMSTime = getMSTime();
4640
4641 // 0 1 2 3 4
4642 QueryResult result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
4643
4644 if (!result)
4645 {
4646 LOG_WARN("server.loading", ">> Loaded 0 Player Create Actions. DB Table `playercreateinfo_action` Is Empty.");
4647 LOG_INFO("server.loading", " ");
4648 }
4649 else
4650 {
4651 uint32 count = 0;
4652
4653 do
4654 {
4655 Field* fields = result->Fetch();
4656
4657 uint32 current_race = fields[0].Get<uint8>();
4658 if (current_race >= sRaceMgr->GetMaxRaces())
4659 {
4660 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_action` table, ignoring.", current_race);
4661 continue;
4662 }
4663
4664 uint32 current_class = fields[1].Get<uint8>();
4665 if (current_class >= MAX_CLASSES)
4666 {
4667 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_action` table, ignoring.", current_class);
4668 continue;
4669 }
4670
4671 if (PlayerInfo* info = _playerInfo[current_race][current_class])
4672 info->action.push_back(PlayerCreateInfoAction(fields[2].Get<uint16>(), fields[3].Get<uint32>(), fields[4].Get<uint16>()));
4673
4674 ++count;
4675 } while (result->NextRow());
4676
4677 LOG_INFO("server.loading", ">> Loaded {} Player Create Actions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4678 LOG_INFO("server.loading", " ");
4679 }
4680 }
4681
4682 // Loading levels data (class/race dependent)
4683 LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
4684 {
4685 struct RaceStats
4686 {
4687 int16 StatModifier[MAX_STATS];
4688 };
4689
4690 std::vector<RaceStats> raceStatModifiers;
4691
4692 raceStatModifiers.resize(sRaceMgr->GetMaxRaces());
4693
4694 uint32 oldMSTime = getMSTime();
4695
4696 // 0 1 2 3 4 5
4697 QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
4698
4699 if (!raceStatsResult)
4700 {
4701 LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
4702 LOG_INFO("server.loading", " ");
4703 exit(1);
4704 }
4705
4706 do
4707 {
4708 Field* fields = raceStatsResult->Fetch();
4709
4710 uint32 current_race = fields[0].Get<uint8>();
4711 if (current_race >= sRaceMgr->GetMaxRaces())
4712 {
4713 LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
4714 continue;
4715 }
4716
4717 for (uint32 i = 0; i < MAX_STATS; ++i)
4718 raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
4719
4720 } while (raceStatsResult->NextRow());
4721
4722 // 0 1 2 3 4 5 6 7 8
4723 QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit, BaseHP, BaseMana FROM player_class_stats");
4724
4725 if (!result)
4726 {
4727 LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
4728 exit(1);
4729 }
4730
4731 uint32 count = 0;
4732
4733 do
4734 {
4735 Field* fields = result->Fetch();
4736
4737 uint32 current_class = fields[0].Get<uint8>();
4738 if (current_class >= MAX_CLASSES)
4739 {
4740 LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
4741 continue;
4742 }
4743
4744 uint32 current_level = fields[1].Get<uint8>();
4745 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4746 {
4747 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4748 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4749 else
4750 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
4751
4752 continue;
4753 }
4754
4755 for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
4756 {
4757 if (PlayerInfo* info = _playerInfo[race][current_class])
4758 {
4759 if (!info->levelInfo)
4760 info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4761
4762 PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4763 for (int i = 0; i < MAX_STATS; ++i)
4764 levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
4765 }
4766 }
4767
4768 PlayerClassInfo* info = _playerClassInfo[current_class];
4769 if (!info)
4770 {
4771 info = new PlayerClassInfo();
4773 _playerClassInfo[current_class] = info;
4774 }
4775
4776 PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4777
4778 levelInfo.basehealth = fields[7].Get<uint32>();
4779 levelInfo.basemana = fields[8].Get<uint32>();
4780
4781 ++count;
4782 } while (result->NextRow());
4783
4784 // Fill gaps and check integrity
4785 for (int race = RACE_HUMAN; race < sRaceMgr->GetMaxRaces(); ++race)
4786 {
4787 // skip non existed races
4788 if (!sChrRacesStore.LookupEntry(race))
4789 continue;
4790
4791 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4792 {
4793 // skip non existed classes
4794 if (!sChrClassesStore.LookupEntry(class_))
4795 continue;
4796
4797 PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
4798 PlayerInfo* info = _playerInfo[race][class_];
4799 if (!info)
4800 continue;
4801
4802 // skip expansion races if not playing with expansion
4803 if (sWorld->getIntConfig(CONFIG_EXPANSION) < EXPANSION_THE_BURNING_CRUSADE && (race == RACE_BLOODELF || race == RACE_DRAENEI))
4804 continue;
4805
4806 // skip expansion classes if not playing with expansion
4808 continue;
4809
4810 // fatal error if no initial stats data
4811 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))
4812 {
4813 LOG_ERROR("sql.sql", "Race {} class {} initial level does not have stats data!", race, class_);
4814 exit(1);
4815 }
4816
4817 // fatal error if no initial health/mana data
4818 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))
4819 {
4820 LOG_ERROR("sql.sql", "Class {} initial level does not have health/mana data!", class_);
4821 exit(1);
4822 }
4823
4824 // fill level gaps for stats
4825 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4826 {
4827 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))
4828 {
4829 LOG_ERROR("sql.sql", "Race {} class {} level {} does not have stats data. Using stats data of level {}.", race, class_, level + 1, level);
4830 info->levelInfo[level] = info->levelInfo[level - 1];
4831 }
4832 }
4833
4834 // fill level gaps for health/mana
4835 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4836 {
4837 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))
4838 {
4839 LOG_ERROR("sql.sql", "Class {} level {} does not have health/mana data. Using stats data of level {}.", class_, level + 1, level);
4840 pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1];
4841 }
4842 }
4843 }
4844 }
4845
4846 LOG_INFO("server.loading", ">> Loaded {} Level Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4847 LOG_INFO("server.loading", " ");
4848 }
4849
4850 // Loading xp per level data
4851 LOG_INFO("server.loading", "Loading Player Create XP Data...");
4852 {
4853 uint32 oldMSTime = getMSTime();
4854
4855 _playerXPperLevel.resize(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
4856 for (uint8 level = 0; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4857 _playerXPperLevel[level] = 0;
4858
4859 // 0 1
4860 QueryResult result = WorldDatabase.Query("SELECT Level, Experience FROM player_xp_for_level");
4861
4862 if (!result)
4863 {
4864 LOG_WARN("server.loading", ">> Loaded 0 xp for level definitions. DB table `player_xp_for_level` is empty.");
4865 LOG_INFO("server.loading", " ");
4866 exit(1);
4867 }
4868
4869 uint32 count = 0;
4870
4871 do
4872 {
4873 Field* fields = result->Fetch();
4874
4875 uint32 current_level = fields[0].Get<uint8>();
4876 uint32 current_xp = fields[1].Get<uint32>();
4877
4878 if (current_level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4879 {
4880 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4881 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4882 else
4883 {
4884 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_xp_for_levels` table, ignoring.", current_level);
4885 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4886 }
4887 continue;
4888 }
4889 //PlayerXPperLevel
4890 _playerXPperLevel[current_level] = current_xp;
4891 ++count;
4892 } while (result->NextRow());
4893
4894 // fill level gaps
4895 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4896 {
4897 if (_playerXPperLevel[level] == 0)
4898 {
4899 LOG_ERROR("sql.sql", "Level {} does not have XP for level data. Using data of level [{}] + 100.", level + 1, level);
4900 _playerXPperLevel[level] = _playerXPperLevel[level - 1] + 100;
4901 }
4902 }
4903
4904 LOG_INFO("server.loading", ">> Loaded {} XP For Level Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4905 LOG_INFO("server.loading", " ");
4906 }
4907}
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)
#define MAX_SKILL_STEP
Definition DBCStructure.h:1580
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:131
@ 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
@ CONFIG_START_HEROIC_PLAYER_LEVEL
Definition WorldConfig.h:197
@ CONFIG_START_PLAYER_LEVEL
Definition WorldConfig.h:196
@ CONFIG_EXPANSION
Definition WorldConfig.h:233
void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count)
Definition ObjectMgr.cpp:4244
Definition DBCStructure.h:679
uint32 model_f
Definition DBCStructure.h:685
uint32 model_m
Definition DBCStructure.h:684
Definition Player.h:276
uint32 basehealth
Definition Player.h:278
uint32 basemana
Definition Player.h:279
Definition Player.h:302
Definition Player.h:314
uint16 SkillId
Definition Player.h:315
float orientation
Definition Player.h:331
uint16 displayId_m
Definition Player.h:332
float positionX
Definition Player.h:328
uint32 areaId
Definition Player.h:327
float positionY
Definition Player.h:329
float positionZ
Definition Player.h:330
uint32 mapId
Definition Player.h:326
uint16 displayId_f
Definition Player.h:333
Definition Player.h:290
std::array< uint32, MAX_STATS > stats
Definition Player.h:296

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_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, sChrClassesStore, sChrRacesStore, PlayerCreateInfoSkill::SkillId, sMapStore, sRaceMgr, sSkillLineStore, PlayerLevelInfo::stats, STRONG_MAX_LEVEL, sWorld, and WorldDatabase.

◆ LoadPlayerShapeshiftModels()

void ObjectMgr::LoadPlayerShapeshiftModels ( )
1845{
1846 uint32 oldMSTime = getMSTime();
1847
1848 QueryResult result = WorldDatabase.Query("SELECT ShapeshiftID, RaceID, CustomizationID, GenderID, ModelID from player_shapeshift_model");
1849
1850 if (!result)
1851 {
1852 LOG_INFO("server.loading", ">> Loaded 0 player shapeshift model records. DB table `player_shapeshift_model` is empty.");
1853 return;
1854 }
1855
1856 uint32 count = 0;
1857 do
1858 {
1859 Field* fields = result->Fetch();
1860
1861 ShapeshiftForm shapeshiftForm = ShapeshiftForm(fields[0].Get<uint8>());
1862 uint8 race = fields[1].Get<uint8>();
1863 uint8 customizationID = fields[2].Get<uint8>();
1864 uint8 genderID = Gender(fields[3].Get<uint8>());
1865 uint32 modelId = fields[4].Get<uint32>();
1866
1867 ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race);
1868 if (!raceEntry)
1869 {
1870 LOG_ERROR("sql.sql", "Race {} defined in `player_shapeshift_model` does not exists, skipped.", uint32(race));
1871 continue;
1872 }
1873
1874 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(modelId);
1875 if (!displayEntry)
1876 {
1877 LOG_ERROR("sql.sql", "ShapeshiftForm: {}, Race: {} defined in `player_shapeshift_model` has non-existing model ({}), skipped.", shapeshiftForm, race, modelId);
1878 continue;
1879 }
1880
1881 _playerShapeshiftModel[std::make_tuple(shapeshiftForm, race, customizationID, genderID)] = modelId;
1882 ++count;
1883 } while (result->NextRow());
1884
1885 LOG_INFO("server.loading", ">> Loaded {} player totem model records in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1886 LOG_INFO("server.loading", " ");
1887}
Gender
Definition SharedDefines.h:60
ShapeshiftForm
Definition UnitDefines.h:71

References _playerShapeshiftModel, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, sChrRacesStore, sCreatureDisplayInfoStore, and WorldDatabase.

◆ LoadPlayerTotemModels()

void ObjectMgr::LoadPlayerTotemModels ( )
1786{
1787 uint32 oldMSTime = getMSTime();
1788
1789 QueryResult result = WorldDatabase.Query("SELECT TotemID, RaceID, ModelID from player_totem_model");
1790
1791 if (!result)
1792 {
1793 LOG_INFO("server.loading", ">> Loaded 0 player totem model records. DB table `player_totem_model` is empty.");
1794 return;
1795 }
1796
1797 uint32 count = 0;
1798 do
1799 {
1800 Field* fields = result->Fetch();
1801
1802 SummonSlot totemSlot = SummonSlot(fields[0].Get<uint8>());
1803 uint8 race = fields[1].Get<uint8>();
1804 uint32 displayId = fields[2].Get<uint32>();
1805
1806 if (totemSlot < SUMMON_SLOT_TOTEM_FIRE || totemSlot >= MAX_TOTEM_SLOT)
1807 {
1808 LOG_ERROR("sql.sql", "Wrong TotemSlot {} in `player_totem_model` table, skipped.", totemSlot);
1809 continue;
1810 }
1811
1812 ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race);
1813 if (!raceEntry)
1814 {
1815 LOG_ERROR("sql.sql", "Race {} defined in `player_totem_model` does not exists, skipped.", uint32(race));
1816 continue;
1817 }
1818
1819 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(displayId);
1820 if (!displayEntry)
1821 {
1822 LOG_ERROR("sql.sql", "TotemSlot: {} defined in `player_totem_model` has non-existing model ({}), skipped.", totemSlot, displayId);
1823 continue;
1824 }
1825
1826 _playerTotemModel[std::make_pair(totemSlot, Races(race))] = displayId;
1827 ++count;
1828 } while (result->NextRow());
1829
1830 LOG_INFO("server.loading", ">> Loaded {} player totem model records in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1831 LOG_INFO("server.loading", " ");
1832}
#define MAX_TOTEM_SLOT
Definition SharedDefines.h:3555
SummonSlot
Definition SharedDefines.h:3543
Races
Definition SharedDefines.h:69

References _playerTotemModel, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, MAX_TOTEM_SLOT, sChrRacesStore, sCreatureDisplayInfoStore, and WorldDatabase.

◆ LoadPointOfInterestLocales()

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

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

◆ LoadPointsOfInterest()

void ObjectMgr::LoadPointsOfInterest ( )
8491{
8492 uint32 oldMSTime = getMSTime();
8493
8494 _pointsOfInterestStore.clear(); // need for reload case
8495
8496 uint32 count = 0;
8497
8498 // 0 1 2 3 4 5 6
8499 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
8500
8501 if (!result)
8502 {
8503 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
8504 LOG_INFO("server.loading", " ");
8505 return;
8506 }
8507
8508 do
8509 {
8510 Field* fields = result->Fetch();
8511
8512 uint32 point_id = fields[0].Get<uint32>();
8513
8514 PointOfInterest POI;
8515 POI.ID = point_id;
8516 POI.PositionX = fields[1].Get<float>();
8517 POI.PositionY = fields[2].Get<float>();
8518 POI.Icon = fields[3].Get<uint32>();
8519 POI.Flags = fields[4].Get<uint32>();
8520 POI.Importance = fields[5].Get<uint32>();
8521 POI.Name = fields[6].Get<std::string>();
8522
8523 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
8524 {
8525 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
8526 continue;
8527 }
8528
8529 _pointsOfInterestStore[point_id] = POI;
8530
8531 ++count;
8532 } while (result->NextRow());
8533
8534 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8535 LOG_INFO("server.loading", " ");
8536}
bool IsValidMapCoord(float c)
Definition GridDefines.h:210
Definition ObjectMgr.h:592
uint32 ID
Definition ObjectMgr.h:593

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

◆ LoadProfanityNamesFromDB()

void ObjectMgr::LoadProfanityNamesFromDB ( )
9093{
9094 uint32 oldMSTime = getMSTime();
9095
9096 _profanityNamesStore.clear(); // need for reload case
9097
9098 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
9099
9100 if (!result)
9101 {
9102 LOG_WARN("server.loading", ">> Loaded 0 profanity names. DB table `profanity_name` is empty!");
9103 return;
9104 }
9105
9106 uint32 count = 0;
9107
9108 Field* fields;
9109 do
9110 {
9111 fields = result->Fetch();
9112 std::string name = fields[0].Get<std::string>();
9113
9114 std::wstring wstr;
9115 if (!Utf8toWStr (name, wstr))
9116 {
9117 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
9118 continue;
9119 }
9120
9121 wstrToLower(wstr);
9122
9123 _profanityNamesStore.insert(wstr);
9124 ++count;
9125 } while (result->NextRow());
9126
9127 LOG_INFO("server.loading", ">> Loaded {} profanity names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9128}

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

◆ LoadProfanityNamesFromDBC()

void ObjectMgr::LoadProfanityNamesFromDBC ( )
9131{
9132 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
9133 {
9134 LOG_WARN("server.loading", ">> Loaded 0 profanity names from DBC. Config option disabled.");
9135 return;
9136 }
9137
9138 uint32 oldMSTime = getMSTime();
9139
9140 uint32 count = 0;
9141
9142 for (NamesProfanityEntry const* profanityStore : sNamesProfanityStore)
9143 {
9144 std::wstring wstr;
9145
9146 Utf8toWStr(profanityStore->Pattern, wstr);
9147
9148 // DBC does not have clean entries, remove the junk.
9149 boost::algorithm::replace_all(wstr, "\\<", "");
9150 boost::algorithm::replace_all(wstr, "\\>", "");
9151
9152 _profanityNamesStore.insert(wstr);
9153 count++;
9154 }
9155
9156 LOG_INFO("server.loading", ">> Loaded {} profanity names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9157 LOG_INFO("server.loading", " ");
9158}
DBCStorage< NamesProfanityEntry > sNamesProfanityStore(NamesProfanityfmt)
@ CONFIG_STRICT_NAMES_PROFANITY
Definition WorldConfig.h:146
Definition DBCStructure.h:1405

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

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6864{
6865 uint32 oldMSTime = getMSTime();
6866
6867 _questAreaTriggerStore.clear(); // need for reload case
6868
6869 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6870
6871 if (!result)
6872 {
6873 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6874 LOG_INFO("server.loading", " ");
6875 return;
6876 }
6877
6878 uint32 count = 0;
6879
6880 do
6881 {
6882 ++count;
6883
6884 Field* fields = result->Fetch();
6885
6886 uint32 trigger_ID = fields[0].Get<uint32>();
6887 uint32 quest_ID = fields[1].Get<uint32>();
6888
6889 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6890 if (!atEntry)
6891 {
6892 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6893 continue;
6894 }
6895
6896 Quest const* quest = GetQuestTemplate(quest_ID);
6897
6898 if (!quest)
6899 {
6900 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6901 continue;
6902 }
6903
6905 {
6906 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);
6907
6908 // this will prevent quest completing without objective
6909 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6910
6911 // continue; - quest modified to required objective and trigger can be allowed.
6912 }
6913
6914 _questAreaTriggerStore[trigger_ID] = quest_ID;
6915 } while (result->NextRow());
6916
6917 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6918 LOG_INFO("server.loading", " ");
6919}
@ 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 ( )
6940{
6941 uint32 oldMSTime = getMSTime();
6942
6943 _questGreetingStore.clear(); // For reload case
6944
6945 // 0 1 2 3 4
6946 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6947 if (!result)
6948 {
6949 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6950 return;
6951 }
6952
6953 do
6954 {
6955 Field* fields = result->Fetch();
6956
6957 uint32 id = fields[0].Get<uint32>();
6958 uint8 type = fields[1].Get<uint8>();
6959 switch (type)
6960 {
6961 case 0: // Creature
6962 if (!GetCreatureTemplate(id))
6963 {
6964 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6965 continue;
6966 }
6967 break;
6968 case 1: // GameObject
6969 if (!GetGameObjectTemplate(id))
6970 {
6971 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6972 continue;
6973 }
6974 break;
6975 default:
6976 LOG_ERROR("sql.sql", "Table `quest_greeting` has unknown type {} for id {}, skipped.", type, id);
6977 continue;
6978 }
6979
6980 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6981 QuestGreeting& data = _questGreetingStore[pairKey];
6982
6983 data.EmoteType = fields[2].Get<uint16>();
6984 data.EmoteDelay = fields[3].Get<uint32>();
6985 AddLocaleString(fields[4].Get<std::string>(), LOCALE_enUS, data.Greeting);
6986 }
6987 while (result->NextRow());
6988
6989 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", _questGreetingStore.size(), GetMSTimeDiffToNow(oldMSTime));
6990 LOG_INFO("server.loading", " ");
6991}
Definition ObjectMgr.h:603
uint32 EmoteDelay
Definition ObjectMgr.h:605
std::vector< std::string > Greeting
Definition ObjectMgr.h:606
uint16 EmoteType
Definition ObjectMgr.h:604

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

◆ LoadQuestGreetingsLocales()

void ObjectMgr::LoadQuestGreetingsLocales ( )
6994{
6995 uint32 oldMSTime = getMSTime();
6996
6997 // 0 1 2 3
6998 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6999 if (!result)
7000 {
7001 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
7002 return;
7003 }
7004
7005 uint32 localeCount = 0;
7006 do
7007 {
7008 Field* fields = result->Fetch();
7009
7010 uint32 id = fields[0].Get<uint32>();
7011 uint8 type = fields[1].Get<uint8>();
7012 switch (type)
7013 {
7014 case 0: // Creature
7015 if (!GetCreatureTemplate(id))
7016 {
7017 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
7018 continue;
7019 }
7020 break;
7021 case 1: // GameObject
7022 if (!GetGameObjectTemplate(id))
7023 {
7024 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
7025 continue;
7026 }
7027 break;
7028 default:
7029 continue;
7030 }
7031
7032 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
7033 QuestGreeting& data = _questGreetingStore[pairKey];
7034
7035 QuestGreetingContainer::iterator qgc = _questGreetingStore.find(pairKey);
7036 if (qgc == _questGreetingStore.end())
7037 {
7038 LOG_ERROR("sql.sql", "QuestGreeting (Id: {} Type: {}) found in table `quest_greeting_locale` but does not exist in `quest_greeting`. Skipped!", id, type);
7039 continue;
7040 }
7041
7042 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
7043 if (locale == LOCALE_enUS)
7044 continue;
7045
7046 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
7047 localeCount++;
7048 } while (result->NextRow());
7049
7050 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
7051 LOG_INFO("server.loading", " ");
7052}

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

◆ LoadQuestLocales()

void ObjectMgr::LoadQuestLocales ( )
5824{
5825 uint32 oldMSTime = getMSTime();
5826
5827 _questLocaleStore.clear(); // need for reload case
5828
5829 // 0 1 2 3 4 5 6 7 8 9 10
5830 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5831
5832 if (!result)
5833 return;
5834
5835 do
5836 {
5837 Field* fields = result->Fetch();
5838
5839 uint32 ID = fields[0].Get<uint32>();
5840
5841 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5842 if (locale == LOCALE_enUS)
5843 continue;
5844
5845 QuestLocale& data = _questLocaleStore[ID];
5846 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5847 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5848 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5849 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5850 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5851
5852 for (uint8 i = 0; i < 4; ++i)
5853 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5854 } while (result->NextRow());
5855
5856 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5857}
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 ( )
11129{
11130 uint32 oldMSTime = getMSTime();
11131
11132 _questMoneyRewards.clear();
11133
11134 // 0 1 2 3 4 5 6 7 8 9 10
11135 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
11136 if (!result)
11137 {
11138 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
11139 return;
11140 }
11141
11142 uint32 count = 0;
11143 do
11144 {
11145 Field* fields = result->Fetch();
11146 uint32 Level = fields[0].Get<uint32>();
11147
11148 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
11149 questMoneyReward.fill(0);
11150
11151 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
11152 {
11153 questMoneyReward[i] = fields[1 + i].Get<uint32>();
11154 ++count;
11155 }
11156 } while (result->NextRow());
11157
11158 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11159 LOG_INFO("server.loading", " ");
11160}
std::array< uint32, MAX_QUEST_MONEY_REWARDS > QuestMoneyRewardArray
Definition ObjectMgr.h:722

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

◆ LoadQuestOfferRewardLocale()

void ObjectMgr::LoadQuestOfferRewardLocale ( )
7055{
7056 uint32 oldMSTime = getMSTime();
7057
7058 _questOfferRewardLocaleStore.clear(); // need for reload case
7059
7060 // 0 1 2
7061 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
7062 if (!result)
7063 return;
7064
7065 do
7066 {
7067 Field* fields = result->Fetch();
7068
7069 uint32 id = fields[0].Get<uint32>();
7070 std::string localeName = fields[1].Get<std::string>();
7071
7072 LocaleConstant locale = GetLocaleByName(localeName);
7073 if (locale == LOCALE_enUS)
7074 continue;
7075
7077 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
7078 } while (result->NextRow());
7079
7080 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7081}
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 ( )
8539{
8540 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
8541 {
8542 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
8543 LOG_INFO("server.loading", " ");
8544 return;
8545 }
8546
8547 uint32 oldMSTime = getMSTime();
8548
8549 _questPOIStore.clear(); // need for reload case
8550
8551 uint32 count = 0;
8552
8553 // 0 1 2 3 4 5 6 7
8554 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
8555
8556 if (!result)
8557 {
8558 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
8559 LOG_INFO("server.loading", " ");
8560 return;
8561 }
8562
8563 // 0 1 2 3
8564 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
8565
8566 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
8567
8568 if (points)
8569 {
8570 // The first result should have the highest questId
8571 Field* fields = points->Fetch();
8572 uint32 questIdMax = fields[0].Get<uint32>();
8573 POIs.resize(questIdMax + 1);
8574
8575 do
8576 {
8577 fields = points->Fetch();
8578
8579 uint32 questId = fields[0].Get<uint32>();
8580 uint32 id = fields[1].Get<uint32>();
8581 int32 x = fields[2].Get<int32>();
8582 int32 y = fields[3].Get<int32>();
8583
8584 if (POIs[questId].size() <= id + 1)
8585 POIs[questId].resize(id + 10);
8586
8587 QuestPOIPoint point(x, y);
8588 POIs[questId][id].push_back(point);
8589 } while (points->NextRow());
8590 }
8591
8592 do
8593 {
8594 Field* fields = result->Fetch();
8595
8596 uint32 questId = fields[0].Get<uint32>();
8597 uint32 id = fields[1].Get<uint32>();
8598 int32 objIndex = fields[2].Get<int32>();
8599 uint32 mapId = fields[3].Get<uint32>();
8600 uint32 WorldMapAreaId = fields[4].Get<uint32>();
8601 uint32 FloorId = fields[5].Get<uint32>();
8602 uint32 unk3 = fields[6].Get<uint32>();
8603 uint32 unk4 = fields[7].Get<uint32>();
8604
8605 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
8606 if (questId < POIs.size() && id < POIs[questId].size())
8607 {
8608 POI.points = POIs[questId][id];
8609 _questPOIStore[questId].push_back(POI);
8610 }
8611 else
8612 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
8613
8614 ++count;
8615 } while (result->NextRow());
8616
8617 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8618 LOG_INFO("server.loading", " ");
8619}
@ CONFIG_QUEST_POI_ENABLED
Definition WorldConfig.h:139
Definition ObjectMgr.h:642
Definition ObjectMgr.h:651

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
8889{
8890 uint32 oldMSTime = getMSTime();
8891
8892 map.clear(); // need for reload case
8893
8894 uint32 count = 0;
8895
8896 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8897
8898 if (!result)
8899 {
8900 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8901 LOG_INFO("server.loading", " ");
8902 return;
8903 }
8904
8905 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8906 if (starter)
8907 poolRelationMap->clear();
8908
8909 do
8910 {
8911 uint32 id = result->Fetch()[0].Get<uint32>();
8912 uint32 quest = result->Fetch()[1].Get<uint32>();
8913 uint32 poolId = result->Fetch()[2].Get<uint32>();
8914
8915 if (_questTemplates.find(quest) == _questTemplates.end())
8916 {
8917 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8918 continue;
8919 }
8920
8921 if (!poolId || !starter)
8922 map.insert(QuestRelations::value_type(id, quest));
8923 else if (starter)
8924 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8925
8926 ++count;
8927 } while (result->NextRow());
8928
8929 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8930 LOG_INFO("server.loading", " ");
8931}
#define sPoolMgr
Definition PoolMgr.h:177
std::multimap< uint32, uint32 > PooledQuestRelation
Definition PoolMgr.h:101

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

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

◆ LoadQuestRequestItemsLocale()

void ObjectMgr::LoadQuestRequestItemsLocale ( )
7084{
7085 uint32 oldMSTime = getMSTime();
7086
7087 _questRequestItemsLocaleStore.clear(); // need for reload case
7088
7089 // 0 1 2
7090 QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale");
7091 if (!result)
7092 return;
7093
7094 do
7095 {
7096 Field* fields = result->Fetch();
7097
7098 uint32 id = fields[0].Get<uint32>();
7099 std::string localeName = fields[1].Get<std::string>();
7100
7101 LocaleConstant locale = GetLocaleByName(localeName);
7102 if (locale == LOCALE_enUS)
7103 continue;
7104
7106 AddLocaleString(fields[2].Get<std::string>(), locale, data.CompletionText);
7107 } while (result->NextRow());
7108
7109 LOG_INFO("server.loading", ">> Loaded {} Quest Request Items Locale Strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7110}
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 ( )
5014{
5015 uint32 oldMSTime = getMSTime();
5016
5017 // For reload case
5018 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
5019 delete itr->second;
5020 _questTemplates.clear();
5021
5022 mExclusiveQuestGroups.clear();
5023
5024 QueryResult result = WorldDatabase.Query("SELECT "
5025 //0 1 2 3 4 5 6 7 8
5026 "ID, QuestType, QuestLevel, MinLevel, QuestSortID, QuestInfoID, SuggestedGroupNum, TimeAllowed, AllowableRaces,"
5027 // 9 10 11 12
5028 "RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2, "
5029 // 13 14 15 16 17 18 19 20
5030 "RewardNextQuest, RewardXPDifficulty, RewardMoney, RewardMoneyDifficulty, RewardDisplaySpell, RewardSpell, RewardHonor, RewardKillHonor, "
5031 // 21 22 23 24 25 26
5032 "StartItem, Flags, RewardTitle, RequiredPlayerKills, RewardTalents, RewardArenaPoints, "
5033 // 27 28 29 30 31 32 33 34
5034 "RewardItem1, RewardAmount1, RewardItem2, RewardAmount2, RewardItem3, RewardAmount3, RewardItem4, RewardAmount4, "
5035 // 35 36 37 38 39 40 41 42 43 44 45 46
5036 "RewardChoiceItemID1, RewardChoiceItemQuantity1, RewardChoiceItemID2, RewardChoiceItemQuantity2, RewardChoiceItemID3, RewardChoiceItemQuantity3, RewardChoiceItemID4, RewardChoiceItemQuantity4, RewardChoiceItemID5, RewardChoiceItemQuantity5, RewardChoiceItemID6, RewardChoiceItemQuantity6, "
5037 // 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
5038 "RewardFactionID1, RewardFactionValue1, RewardFactionOverride1, RewardFactionID2, RewardFactionValue2, RewardFactionOverride2, RewardFactionID3, RewardFactionValue3, RewardFactionOverride3, RewardFactionID4, RewardFactionValue4, RewardFactionOverride4, RewardFactionID5, RewardFactionValue5, RewardFactionOverride5,"
5039 // 61 63 64 65
5040 "POIContinent, POIx, POIy, POIPriority, "
5041 // 66 67 68 69 70
5042 "LogTitle, LogDescription, QuestDescription, AreaDescription, QuestCompletionLog, "
5043 // 71 72 73 74 75 76 77 78
5044 "RequiredNpcOrGo1, RequiredNpcOrGo2, RequiredNpcOrGo3, RequiredNpcOrGo4, RequiredNpcOrGoCount1, RequiredNpcOrGoCount2, RequiredNpcOrGoCount3, RequiredNpcOrGoCount4, "
5045 // 79 80 81 82 83 84 85 86
5046 "ItemDrop1, ItemDrop2, ItemDrop3, ItemDrop4, ItemDropQuantity1, ItemDropQuantity2, ItemDropQuantity3, ItemDropQuantity4, "
5047 // 87 88 89 90 91 92 93 94 95 96 97 98
5048 "RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
5049 // 99 100 101 102 103
5050 "Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4"
5051 " FROM quest_template");
5052 if (!result)
5053 {
5054 LOG_WARN("server.loading", ">> Loaded 0 quests definitions. DB table `quest_template` is empty.");
5055 LOG_INFO("server.loading", " ");
5056 return;
5057 }
5058
5059 // create multimap previous quest for each existed quest
5060 // some quests can have many previous maps set by NextQuestId in previous quest
5061 // for example set of race quests can lead to single not race specific quest
5062 do
5063 {
5064 Field* fields = result->Fetch();
5065
5066 Quest* newQuest = new Quest(fields);
5067 _questTemplates[newQuest->GetQuestId()] = newQuest;
5068 } while (result->NextRow());
5069
5070 // pussywizard:
5071 {
5072 uint32 max = 0;
5073 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
5074 if (itr->first > max)
5075 max = itr->first;
5076 if (max)
5077 {
5078 _questTemplatesFast.clear();
5079 _questTemplatesFast.resize(max + 1, nullptr);
5080 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
5081 _questTemplatesFast[itr->first] = itr->second;
5082 }
5083 }
5084
5085 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
5086 itr->second->InitializeQueryData();
5087
5088 std::map<uint32, uint32> usedMailTemplates;
5089
5090 // Load `quest_details`
5091 // 0 1 2 3 4 5 6 7 8
5092 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4 FROM quest_details");
5093
5094 if (!result)
5095 {
5096 LOG_WARN("server.loading", ">> Loaded 0 quest details. DB table `quest_details` is empty.");
5097 }
5098 else
5099 {
5100 do
5101 {
5102 Field* fields = result->Fetch();
5103 uint32 questId = fields[0].Get<uint32>();
5104
5105 auto itr = _questTemplates.find(questId);
5106 if (itr != _questTemplates.end())
5107 itr->second->LoadQuestDetails(fields);
5108 else
5109 LOG_ERROR("sql.sql", "Table `quest_details` has data for quest {} but such quest does not exist", questId);
5110 } while (result->NextRow());
5111 }
5112
5113 // Load `quest_request_items`
5114 // 0 1 2 3
5115 result = WorldDatabase.Query("SELECT ID, EmoteOnComplete, EmoteOnIncomplete, CompletionText FROM quest_request_items");
5116
5117 if (!result)
5118 {
5119 LOG_WARN("server.loading", ">> Loaded 0 quest request items. DB table `quest_request_items` is empty.");
5120 }
5121 else
5122 {
5123 do
5124 {
5125 Field* fields = result->Fetch();
5126 uint32 questId = fields[0].Get<uint32>();
5127
5128 auto itr = _questTemplates.find(questId);
5129 if (itr != _questTemplates.end())
5130 itr->second->LoadQuestRequestItems(fields);
5131 else
5132 LOG_ERROR("sql.sql", "Table `quest_request_items` has data for quest {} but such quest does not exist", questId);
5133 } while (result->NextRow());
5134 }
5135
5136 // Load `quest_offer_reward`
5137 // 0 1 2 3 4 5 6 7 8 9
5138 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4, RewardText FROM quest_offer_reward");
5139
5140 if (!result)
5141 {
5142 LOG_WARN("server.loading", ">> Loaded 0 quest reward emotes. DB table `quest_offer_reward` is empty.");
5143 }
5144 else
5145 {
5146 do
5147 {
5148 Field* fields = result->Fetch();
5149 uint32 questId = fields[0].Get<uint32>();
5150
5151 auto itr = _questTemplates.find(questId);
5152 if (itr != _questTemplates.end())
5153 itr->second->LoadQuestOfferReward(fields);
5154 else
5155 LOG_ERROR("sql.sql", "Table `quest_offer_reward` has data for quest {} but such quest does not exist", questId);
5156 } while (result->NextRow());
5157 }
5158
5159 // Load `quest_template_addon`
5160 // 0 1 2 3 4 5 6 7 8
5161 result = WorldDatabase.Query("SELECT ID, MaxLevel, AllowableClasses, SourceSpellID, PrevQuestID, NextQuestID, ExclusiveGroup, BreadcrumbForQuestId, RewardMailTemplateID, "
5162 //9 10 11 12 13 14 15 16 17 18
5163 "RewardMailDelay, RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, RewardMailSenderEntry, SpecialFlags FROM quest_template_addon LEFT JOIN quest_mail_sender ON Id=QuestId");
5164
5165 if (!result)
5166 {
5167 LOG_WARN("server.loading", ">> Loaded 0 quest template addons. DB table `quest_template_addon` is empty.");
5168 }
5169 else
5170 {
5171 do
5172 {
5173 Field* fields = result->Fetch();
5174 uint32 questId = fields[0].Get<uint32>();
5175
5176 auto itr = _questTemplates.find(questId);
5177 if (itr != _questTemplates.end())
5178 itr->second->LoadQuestTemplateAddon(fields);
5179 else
5180 LOG_ERROR("sql.sql", "Table `quest_template_addon` has data for quest {} but such quest does not exist", questId);
5181 } while (result->NextRow());
5182 }
5183
5184 // Post processing
5185 for (QuestMap::iterator iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter)
5186 {
5187 // skip post-loading checks for disabled quests
5188 if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr))
5189 continue;
5190
5191 Quest* qinfo = iter->second;
5192
5193 // additional quest integrity checks (GO, creature_template and item_template must be loaded already)
5194
5195 if (qinfo->GetQuestMethod() >= 3)
5196 LOG_ERROR("sql.sql", "Quest {} has `Method` = {}, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod());
5197
5199 {
5200 LOG_ERROR("sql.sql", "Quest {} has `SpecialFlags` = {} > max allowed value. Correct `SpecialFlags` to value <= {}",
5203 }
5204
5205 if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY)
5206 {
5207 LOG_ERROR("sql.sql", "Weekly Quest {} is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId());
5208 qinfo->Flags &= ~QUEST_FLAGS_DAILY;
5209 }
5210
5211 if (qinfo->Flags & QUEST_FLAGS_DAILY)
5212 {
5214 {
5215 LOG_ERROR("sql.sql", "Daily Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
5217 }
5218 }
5219
5220 if (qinfo->Flags & QUEST_FLAGS_WEEKLY)
5221 {
5223 {
5224 LOG_ERROR("sql.sql", "Weekly Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
5226 }
5227 }
5228
5230 {
5232 {
5233 LOG_ERROR("sql.sql", "Monthly quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
5235 }
5236 }
5237
5238 if (qinfo->Flags & QUEST_FLAGS_TRACKING)
5239 {
5240 // at auto-reward can be rewarded only RewardChoiceItemId[0]
5241 for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j )
5242 {
5243 if (uint32 id = qinfo->RewardChoiceItemId[j])
5244 {
5245 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item from `RewardChoiceItemId{}` can't be rewarded with quest flag QUEST_FLAGS_TRACKING.",
5246 qinfo->GetQuestId(), j + 1, id, j + 1);
5247 // no changes, quest ignore this data
5248 }
5249 }
5250 }
5251
5252 // client quest log visual (area case)
5253 if (qinfo->ZoneOrSort > 0)
5254 {
5255 if (!sAreaTableStore.LookupEntry(qinfo->ZoneOrSort))
5256 {
5257 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (zone case) but zone with this id does not exist.",
5258 qinfo->GetQuestId(), qinfo->ZoneOrSort);
5259 // no changes, quest not dependent from this value but can have problems at client
5260 }
5261 }
5262 // client quest log visual (sort case)
5263 if (qinfo->ZoneOrSort < 0)
5264 {
5265 QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort));
5266 if (!qSort)
5267 {
5268 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (sort case) but quest sort with this id does not exist.",
5269 qinfo->GetQuestId(), qinfo->ZoneOrSort);
5270 // 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)
5271 }
5272 //check for proper RequiredSkillId value (skill case)
5273 if (uint32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
5274 {
5275 if (qinfo->RequiredSkillId != skill_id)
5276 {
5277 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} but `RequiredSkillId` does not have a corresponding value ({}).",
5278 qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id);
5279 //override, and force proper value here?
5280 }
5281 }
5282 }
5283
5284 // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class
5285 if (qinfo->RequiredClasses)
5286 {
5288 {
5289 LOG_ERROR("sql.sql", "Quest {} does not contain any playable classes in `RequiredClasses` ({}), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses);
5290 qinfo->RequiredClasses = 0;
5291 }
5292 }
5293 // AllowableRaces, can be 0/PlayableRaceMask to allow any race
5294 if (qinfo->AllowableRaces)
5295 {
5296 if (!(qinfo->AllowableRaces & sRaceMgr->GetPlayableRaceMask()))
5297 {
5298 LOG_ERROR("sql.sql", "Quest {} does not contain any playable races in `AllowableRaces` ({}), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->AllowableRaces);
5299 qinfo->AllowableRaces = 0;
5300 }
5301 }
5302 // RequiredSkillId, can be 0
5303 if (qinfo->RequiredSkillId)
5304 {
5305 if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId))
5306 {
5307 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillId` = {} but this skill does not exist",
5308 qinfo->GetQuestId(), qinfo->RequiredSkillId);
5309 }
5310 }
5311
5312 if (qinfo->RequiredSkillPoints)
5313 {
5314 if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue())
5315 {
5316 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillPoints` = {} but max possible skill is {}, quest can't be done.",
5317 qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue());
5318 // no changes, quest can't be done for this requirement
5319 }
5320 }
5321 // else Skill quests can have 0 skill level, this is ok
5322
5323 if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2))
5324 {
5325 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId2` = {} but faction template {} does not exist, quest can't be done.",
5326 qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2);
5327 // no changes, quest can't be done for this requirement
5328 }
5329
5330 if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1))
5331 {
5332 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId1` = {} but faction template {} does not exist, quest can't be done.",
5333 qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1);
5334 // no changes, quest can't be done for this requirement
5335 }
5336
5337 if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction))
5338 {
5339 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepFaction` = {} but faction template {} does not exist, quest can't be done.",
5340 qinfo->GetQuestId(), qinfo->RequiredMinRepFaction, qinfo->RequiredMinRepFaction);
5341 // no changes, quest can't be done for this requirement
5342 }
5343
5344 if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction))
5345 {
5346 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepFaction` = {} but faction template {} does not exist, quest can't be done.",
5347 qinfo->GetQuestId(), qinfo->RequiredMaxRepFaction, qinfo->RequiredMaxRepFaction);
5348 // no changes, quest can't be done for this requirement
5349 }
5350
5352 {
5353 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but max reputation is {}, quest can't be done.",
5355 // no changes, quest can't be done for this requirement
5356 }
5357
5358 if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue)
5359 {
5360 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} and `RequiredMinRepValue` = {}, quest can't be done.",
5361 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue, qinfo->RequiredMinRepValue);
5362 // no changes, quest can't be done for this requirement
5363 }
5364
5365 if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0)
5366 {
5367 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue1` = {} but `RequiredFactionId1` is 0, value has no effect",
5368 qinfo->GetQuestId(), qinfo->RequiredFactionValue1);
5369 // warning
5370 }
5371
5372 if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0)
5373 {
5374 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue2` = {} but `RequiredFactionId2` is 0, value has no effect",
5375 qinfo->GetQuestId(), qinfo->RequiredFactionValue2);
5376 // warning
5377 }
5378
5379 if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue != 0)
5380 {
5381 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but `RequiredMinRepFaction` is 0, value has no effect",
5382 qinfo->GetQuestId(), qinfo->RequiredMinRepValue);
5383 // warning
5384 }
5385
5386 if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue != 0)
5387 {
5388 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} but `RequiredMaxRepFaction` is 0, value has no effect",
5389 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue);
5390 // warning
5391 }
5392
5393 if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId))
5394 {
5395 LOG_ERROR("sql.sql", "Quest {} has `RewardTitleId` = {} but CharTitle Id {} does not exist, quest can't be rewarded with title.",
5396 qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId());
5397 qinfo->RewardTitleId = 0;
5398 // quest can't reward this title
5399 }
5400
5401 if (qinfo->StartItem)
5402 {
5403 if (!GetItemTemplate(qinfo->StartItem))
5404 {
5405 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but item with entry {} does not exist, quest can't be done.",
5406 qinfo->GetQuestId(), qinfo->StartItem, qinfo->StartItem);
5407 qinfo->StartItem = 0; // quest can't be done for this requirement
5408 }
5409 else if (qinfo->StartItemCount == 0)
5410 {
5411 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but `StartItemCount` = 0, set to 1 but need fix in DB.",
5412 qinfo->GetQuestId(), qinfo->StartItem);
5413 qinfo->StartItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB
5414 }
5415 }
5416 else if (qinfo->StartItemCount > 0)
5417 {
5418 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = 0 but `StartItemCount` = {}, useless value.",
5419 qinfo->GetQuestId(), qinfo->StartItemCount);
5420 qinfo->StartItemCount = 0; // no quest work changes in fact
5421 }
5422
5423 if (qinfo->SourceSpellid)
5424 {
5425 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid);
5426 if (!spellInfo)
5427 {
5428 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} doesn't exist, quest can't be done.",
5429 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
5430 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
5431 }
5432 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5433 {
5434 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} is broken, quest can't be done.",
5435 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
5436 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
5437 }
5438 }
5439
5440 for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
5441 {
5442 uint32 id = qinfo->RequiredItemId[j];
5443 if (id)
5444 {
5445 if (qinfo->RequiredItemCount[j] == 0)
5446 {
5447 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but `RequiredItemCount{}` = 0, quest can't be done.",
5448 qinfo->GetQuestId(), j + 1, id, j + 1);
5449 // no changes, quest can't be done for this requirement
5450 }
5451
5453
5454 if (!GetItemTemplate(id))
5455 {
5456 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but item with entry {} does not exist, quest can't be done.",
5457 qinfo->GetQuestId(), j + 1, id, id);
5458 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
5459 }
5460 }
5461 else if (qinfo->RequiredItemCount[j] > 0)
5462 {
5463 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = 0 but `RequiredItemCount{}` = {}, quest can't be done.",
5464 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredItemCount[j]);
5465 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
5466 }
5467 }
5468
5469 for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
5470 {
5471 uint32 id = qinfo->ItemDrop[j];
5472 if (id)
5473 {
5474 if (!GetItemTemplate(id))
5475 {
5476 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = {} but item with entry {} does not exist, quest can't be done.",
5477 qinfo->GetQuestId(), j + 1, id, id);
5478 // no changes, quest can't be done for this requirement
5479 }
5480 }
5481 else
5482 {
5483 if (qinfo->ItemDropQuantity[j] > 0)
5484 {
5485 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = 0 but `ItemDropQuantity{}` = {}.",
5486 qinfo->GetQuestId(), j + 1, j + 1, qinfo->ItemDropQuantity[j]);
5487 // no changes, quest ignore this data
5488 }
5489 }
5490 }
5491
5492 for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
5493 {
5494 int32 id = qinfo->RequiredNpcOrGo[j];
5495 if (id < 0 && !GetGameObjectTemplate(-id))
5496 {
5497 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but gameobject {} does not exist, quest can't be done.",
5498 qinfo->GetQuestId(), j + 1, id, uint32(-id));
5499 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
5500 }
5501
5502 if (id > 0 && !GetCreatureTemplate(id))
5503 {
5504 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but creature with entry {} does not exist, quest can't be done.",
5505 qinfo->GetQuestId(), j + 1, id, uint32(id));
5506 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
5507 }
5508
5509 if (id)
5510 {
5511 // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast
5512
5514
5515 if (!qinfo->RequiredNpcOrGoCount[j])
5516 {
5517 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but `RequiredNpcOrGoCount{}` = 0, quest can't be done.",
5518 qinfo->GetQuestId(), j + 1, id, j + 1);
5519 // no changes, quest can be incorrectly done, but we already report this
5520 }
5521 }
5522 else if (qinfo->RequiredNpcOrGoCount[j] > 0)
5523 {
5524 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = 0 but `RequiredNpcOrGoCount{}` = {}.",
5525 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredNpcOrGoCount[j]);
5526 // no changes, quest ignore this data
5527 }
5528 }
5529
5530 for (uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j)
5531 {
5532 uint32 id = qinfo->RewardChoiceItemId[j];
5533 if (id)
5534 {
5535 if (!GetItemTemplate(id))
5536 {
5537 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
5538 qinfo->GetQuestId(), j + 1, id, id);
5539 qinfo->RewardChoiceItemId[j] = 0; // no changes, quest will not reward this
5540 }
5541
5542 if (!qinfo->RewardChoiceItemCount[j])
5543 {
5544 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but `RewardChoiceItemCount{}` = 0, quest can't be done.",
5545 qinfo->GetQuestId(), j + 1, id, j + 1);
5546 // no changes, quest can't be done
5547 }
5548 }
5549 else if (qinfo->RewardChoiceItemCount[j] > 0)
5550 {
5551 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = 0 but `RewardChoiceItemCount{}` = {}.",
5552 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardChoiceItemCount[j]);
5553 // no changes, quest ignore this data
5554 }
5555 }
5556
5557 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
5558 {
5559 if (!qinfo->RewardItemId[0] && qinfo->RewardItemId[j])
5560 {
5561 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId1` but has `RewardItem{}`. Reward item will not be loaded.",
5562 qinfo->GetQuestId(), j + 1);
5563 }
5564 if (!qinfo->RewardItemId[1] && j > 1 && qinfo->RewardItemId[j])
5565 {
5566 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId2` but has `RewardItem{}`. Reward item will not be loaded.",
5567 qinfo->GetQuestId(), j + 1);
5568 }
5569 if (!qinfo->RewardItemId[2] && j > 2 && qinfo->RewardItemId[j])
5570 {
5571 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId3` but has `RewardItem{}`. Reward item will not be loaded.",
5572 qinfo->GetQuestId(), j + 1);
5573 }
5574 }
5575
5576 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
5577 {
5578 uint32 id = qinfo->RewardItemId[j];
5579 if (id)
5580 {
5581 if (!GetItemTemplate(id))
5582 {
5583 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
5584 qinfo->GetQuestId(), j + 1, id, id);
5585 qinfo->RewardItemId[j] = 0; // no changes, quest will not reward this item
5586 }
5587
5588 if (!qinfo->RewardItemIdCount[j])
5589 {
5590 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but `RewardItemIdCount{}` = 0, quest will not reward this item.",
5591 qinfo->GetQuestId(), j + 1, id, j + 1);
5592 // no changes
5593 }
5594 }
5595 else if (qinfo->RewardItemIdCount[j] > 0)
5596 {
5597 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = 0 but `RewardItemIdCount{}` = {}.",
5598 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardItemIdCount[j]);
5599 // no changes, quest ignore this data
5600 }
5601 }
5602
5603 for (uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j)
5604 {
5605 if (qinfo->RewardFactionId[j])
5606 {
5607 if (std::abs(qinfo->RewardFactionValueId[j]) > 9)
5608 {
5609 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]);
5610 }
5611 if (!sFactionStore.LookupEntry(qinfo->RewardFactionId[j]))
5612 {
5613 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]);
5614 qinfo->RewardFactionId[j] = 0; // quest will not reward this
5615 }
5616 }
5617
5618 else if (qinfo->RewardFactionValueIdOverride[j] != 0)
5619 {
5620 LOG_ERROR("sql.sql", "Quest {} has `RewardFactionId{}` = 0 but `RewardFactionValueIdOverride{}` = {}.",
5621 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardFactionValueIdOverride[j]);
5622 // no changes, quest ignore this data
5623 }
5624 }
5625
5626 if (qinfo->RewardDisplaySpell)
5627 {
5628 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell);
5629
5630 if (!spellInfo)
5631 {
5632 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} does not exist, spell removed as display reward.",
5633 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5634 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5635 }
5636
5637 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5638 {
5639 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is broken, quest will not have a spell reward.",
5640 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5641 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5642 }
5643
5644 else if (GetTalentSpellCost(qinfo->RewardDisplaySpell))
5645 {
5646 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5647 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5648 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5649 }
5650 }
5651
5652 if (qinfo->RewardSpell > 0)
5653 {
5654 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell);
5655
5656 if (!spellInfo)
5657 {
5658 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} does not exist, quest will not have a spell reward.",
5659 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5660 qinfo->RewardSpell = 0; // no spell will be casted on player
5661 }
5662
5663 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5664 {
5665 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} is broken, quest will not have a spell reward.",
5666 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5667 qinfo->RewardSpell = 0; // no spell will be casted on player
5668 }
5669
5670 else if (GetTalentSpellCost(qinfo->RewardSpell))
5671 {
5672 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5673 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5674 qinfo->RewardSpell = 0; // no spell will be casted on player
5675 }
5676 }
5677
5678 if (qinfo->RewardMailTemplateId)
5679 {
5680 if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId))
5681 {
5682 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} does not exist, quest will not have a mail reward.",
5683 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId);
5684 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5685 qinfo->RewardMailDelay = 0; // no mail will send to player
5686 qinfo->RewardMailSenderEntry = 0;
5687 }
5688 else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end())
5689 {
5690 std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId);
5691 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} already used for quest {}, quest will not have a mail reward.",
5692 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second);
5693 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5694 qinfo->RewardMailDelay = 0; // no mail will send to player
5695 qinfo->RewardMailSenderEntry = 0;
5696 }
5697 else
5698 usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId();
5699 }
5700
5701 if (qinfo->RewardNextQuest)
5702 {
5703 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->RewardNextQuest);
5704 if (qNextItr == _questTemplates.end())
5705 {
5706 LOG_ERROR("sql.sql", "Quest {} has `RewardNextQuest` = {} but quest {} does not exist, quest chain will not work.",
5707 qinfo->GetQuestId(), qinfo->RewardNextQuest, qinfo->RewardNextQuest);
5708 qinfo->RewardNextQuest = 0;
5709 }
5710 else
5711 qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId());
5712 }
5713
5714 // fill additional data stores
5715 if (qinfo->PrevQuestId)
5716 {
5717 if (_questTemplates.find(std::abs(qinfo->GetPrevQuestId())) == _questTemplates.end())
5718 {
5719 LOG_ERROR("sql.sql", "Quest {} has PrevQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId());
5720 }
5721 else
5722 {
5723 qinfo->prevQuests.push_back(qinfo->PrevQuestId);
5724 }
5725 }
5726
5727 if (qinfo->NextQuestId)
5728 {
5729 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->GetNextQuestId());
5730 if (qNextItr == _questTemplates.end())
5731 {
5732 LOG_ERROR("sql.sql", "Quest {} has NextQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId());
5733 }
5734 else
5735 qNextItr->second->prevQuests.push_back(static_cast<int32>(qinfo->GetQuestId()));
5736 }
5737
5738 if (qinfo->ExclusiveGroup)
5739 mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
5740
5741 if (uint32 breadcrumbForQuestId = qinfo->GetBreadcrumbForQuestId())
5742 {
5743 if (_questTemplates.find(breadcrumbForQuestId) == _questTemplates.end())
5744 LOG_ERROR("sql.sql", "Quest {} has BreadcrumbForQuestId {}, but no such quest exists", qinfo->GetQuestId(), breadcrumbForQuestId);
5745 else
5746 _breadcrumbsForQuest[breadcrumbForQuestId].push_back(qinfo->GetQuestId());
5747
5748 if (qinfo->GetNextQuestId())
5749 LOG_ERROR("sql.sql", "Quest {} is a breadcrumb quest but also has NextQuestID {} set", qinfo->GetQuestId(), qinfo->GetNextQuestId());
5750 if (qinfo->GetExclusiveGroup())
5751 LOG_ERROR("sql.sql", "Quest {} is a breadcrumb quest but also has ExclusiveGroup {} set", qinfo->GetQuestId(), qinfo->GetExclusiveGroup());
5752 }
5753
5754 if (qinfo->TimeAllowed)
5756 if (qinfo->RequiredPlayerKills)
5758 }
5759
5760 for (auto const& [questId, quest] : _questTemplates)
5761 {
5762 if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, questId, nullptr))
5763 continue;
5764
5765 uint32 breadcrumbForQuestId = quest->GetBreadcrumbForQuestId();
5766 if (!breadcrumbForQuestId)
5767 continue;
5768
5769 std::set<uint32> visitedQuests;
5770 visitedQuests.insert(questId);
5771
5772 while (breadcrumbForQuestId)
5773 {
5774 if (!visitedQuests.insert(breadcrumbForQuestId).second)
5775 {
5776 LOG_ERROR("sql.sql", "Breadcrumb quests {} and {} form a loop", questId, breadcrumbForQuestId);
5777 break;
5778 }
5779
5780 Quest const* targetQuest = GetQuestTemplate(breadcrumbForQuestId);
5781 if (!targetQuest)
5782 break;
5783
5784 breadcrumbForQuestId = targetQuest->GetBreadcrumbForQuestId();
5785 }
5786 }
5787
5788 // check QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
5789 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5790 {
5791 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
5792 if (!spellInfo)
5793 continue;
5794
5795 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5796 {
5797 if (spellInfo->Effects[j].Effect != SPELL_EFFECT_QUEST_COMPLETE)
5798 continue;
5799
5800 uint32 quest_id = spellInfo->Effects[j].MiscValue;
5801
5802 Quest const* quest = GetQuestTemplate(quest_id);
5803
5804 // some quest referenced in spells not exist (outdated spells)
5805 if (!quest)
5806 continue;
5807
5809 {
5810 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);
5811
5812 // this will prevent quest completing without objective
5813 // xinef: remove this, leave error but do not break the quest
5814 // const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5815 }
5816 }
5817 }
5818
5819 LOG_INFO("server.loading", ">> Loaded {} Quests Definitions in {} ms", (unsigned long)_questTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
5820 LOG_INFO("server.loading", " ");
5821}
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
DBCStorage< QuestSortEntry > sQuestSortStore(QuestSortEntryfmt)
@ DISABLE_TYPE_QUEST
Definition DisableMgr.h:29
#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
@ SPELL_EFFECT_QUEST_COMPLETE
Definition SharedDefines.h:782
uint32 SkillByQuestSort(int32 QuestSort)
Definition SharedDefines.h:3273
ExclusiveQuestGroups mExclusiveQuestGroups
Definition ObjectMgr.h:1153
uint32 ItemDropQuantity[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition QuestDef.h:304
uint32 RewardMailDelay
Definition QuestDef.h:396
uint32 RewardMailSenderEntry
Definition QuestDef.h:404
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:305
uint32 RequiredMaxRepFaction
Definition QuestDef.h:401
uint32 SourceSpellid
Definition QuestDef.h:390
uint32 RequiredMinRepFaction
Definition QuestDef.h:399
int32 RequiredFactionValue2
Definition QuestDef.h:356
int32 RequiredFactionValue1
Definition QuestDef.h:354
int32 ZoneOrSort
Definition QuestDef.h:348
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:306
uint32 StartItemCount
Definition QuestDef.h:403
void SetSpecialFlag(uint32 flag)
Definition QuestDef.h:225
uint32 GetCharTitleId() const
Definition QuestDef.h:254
uint32 RewardTitleId
Definition QuestDef.h:360
uint32 RewardItemIdCount[QUEST_REWARDS_COUNT]
Definition QuestDef.h:310
uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT]
Definition QuestDef.h:307
uint32 NextQuestId
Definition QuestDef.h:392
uint32 RewardMailTemplateId
Definition QuestDef.h:395
uint32 ItemDrop[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition QuestDef.h:303
int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT]
Definition QuestDef.h:313
uint32 RequiredSkillPoints
Definition QuestDef.h:398
int32 RewardSpell
Definition QuestDef.h:379
uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]
Definition QuestDef.h:308
uint32 AllowableRaces
Definition QuestDef.h:352
uint32 RewardNextQuest
Definition QuestDef.h:364
uint32 RequiredPlayerKills
Definition QuestDef.h:361
int32 GetPrevQuestId() const
Definition QuestDef.h:249
uint32 StartItem
Definition QuestDef.h:366
uint32 GetQuestId() const
Definition QuestDef.h:228
int32 RequiredMaxRepValue
Definition QuestDef.h:402
uint32 RequiredClasses
Definition QuestDef.h:389
uint32 Flags
Definition QuestDef.h:359
uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]
Definition QuestDef.h:302
uint32 GetBreadcrumbForQuestId() const
Definition QuestDef.h:252
int32 GetExclusiveGroup() const
Definition QuestDef.h:251
uint32 TimeAllowed
Definition QuestDef.h:358
uint32 RequiredFactionId1
Definition QuestDef.h:353
uint32 RequiredFactionId2
Definition QuestDef.h:355
PrevQuests prevQuests
Definition QuestDef.h:325
uint32 RewardDisplaySpell
Definition QuestDef.h:378
uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]
Definition QuestDef.h:301
int32 PrevQuestId
Definition QuestDef.h:391
uint32 GetNextQuestId() const
Definition QuestDef.h:250
uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT]
Definition QuestDef.h:311
int32 ExclusiveGroup
Definition QuestDef.h:393
uint32 RequiredSkillId
Definition QuestDef.h:397
int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT]
Definition QuestDef.h:312
uint32 RewardItemId[QUEST_REWARDS_COUNT]
Definition QuestDef.h:309
uint32 GetQuestMethod() const
Definition QuestDef.h:229
int32 RequiredMinRepValue
Definition QuestDef.h:400
uint32 SpecialFlags
Definition QuestDef.h:405
static const int32 Reputation_Cap
Definition ReputationMgr.h:67
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417
Definition DBCStructure.h:1445

References _breadcrumbsForQuest, _questTemplates, _questTemplatesFast, Quest::AllowableRaces, CLASSMASK_ALL_PLAYABLE, SpellMgr::ComputeIsSpellValid(), DISABLE_TYPE_QUEST, SpellInfo::Effects, Quest::ExclusiveGroup, Quest::Flags, Field::Get(), Quest::GetBreadcrumbForQuestId(), Quest::GetCharTitleId(), GetCreatureTemplate(), Quest::GetExclusiveGroup(), GetGameObjectTemplate(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), Quest::GetNextQuestId(), Quest::GetPrevQuestId(), Quest::GetQuestId(), Quest::GetQuestMethod(), GetQuestTemplate(), GetTalentSpellCost(), Quest::HasSpecialFlag(), SpellInfo::Id, 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, 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, sDisableMgr, Quest::SetSpecialFlag(), sFactionStore, SkillByQuestSort(), sMailTemplateStore, Quest::SourceSpellid, Quest::SpecialFlags, SPELL_EFFECT_QUEST_COMPLETE, sQuestSortStore, sRaceMgr, sSkillLineStore, sSpellMgr, Quest::StartItem, Quest::StartItemCount, sWorld, Quest::TimeAllowed, WorldDatabase, and Quest::ZoneOrSort.

◆ LoadQuestStartersAndEnders()

void ObjectMgr::LoadQuestStartersAndEnders ( )
inline
961 {
962 LOG_INFO("server.loading", "Loading GO Start Quest Data...");
964 LOG_INFO("server.loading", "Loading GO End Quest Data...");
966 LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
968 LOG_INFO("server.loading", "Loading Creature End Quest Data...");
970 }
void LoadCreatureQuestEnders()
Definition ObjectMgr.cpp:8975
void LoadGameobjectQuestEnders()
Definition ObjectMgr.cpp:8947
void LoadGameobjectQuestStarters()
Definition ObjectMgr.cpp:8933
void LoadCreatureQuestStarters()
Definition ObjectMgr.cpp:8961

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

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
10096{
10097 // find all items from the reference vendor
10099 stmt->SetData(0, uint32(item));
10100 PreparedQueryResult result = WorldDatabase.Query(stmt);
10101
10102 if (!result)
10103 return 0;
10104
10105 uint32 count = 0;
10106 do
10107 {
10108 Field* fields = result->Fetch();
10109
10110 int32 item_id = fields[0].Get<int32>();
10111
10112 // if item is a negative, its a reference
10113 if (item_id < 0)
10114 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
10115 else
10116 {
10117 uint32 maxcount = fields[1].Get<uint32>();
10118 uint32 incrtime = fields[2].Get<uint32>();
10119 uint32 ExtendedCost = fields[3].Get<uint32>();
10120
10121 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
10122 continue;
10123
10124 VendorItemData& vList = _cacheVendorItemStore[vendor];
10125
10126 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
10127 ++count;
10128 }
10129 } while (result->NextRow());
10130
10131 return count;
10132}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
@ WORLD_SEL_NPC_VENDOR_REF
Definition WorldDatabase.h:45
bool IsVendorItemValid(uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player *player=nullptr, std::set< uint32 > *skip_vendors=nullptr, uint32 ORnpcflag=0) const
Definition ObjectMgr.cpp:10357
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition ObjectMgr.cpp:10095

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 ( )
8300{
8301 uint32 oldMSTime = getMSTime();
8302
8303 // For reload case
8304 _repOnKillStore.clear();
8305
8306 uint32 count = 0;
8307
8308 // 0 1 2
8309 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
8310 // 3 4 5 6 7 8 9
8311 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
8312 "FROM creature_onkill_reputation");
8313
8314 if (!result)
8315 {
8316 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
8317 LOG_INFO("server.loading", " ");
8318 return;
8319 }
8320
8321 do
8322 {
8323 Field* fields = result->Fetch();
8324
8325 uint32 creature_id = fields[0].Get<uint32>();
8326
8327 ReputationOnKillEntry repOnKill;
8328 repOnKill.RepFaction1 = fields[1].Get<int16>();
8329 repOnKill.RepFaction2 = fields[2].Get<int16>();
8330 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
8331 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
8332 repOnKill.RepValue1 = fields[5].Get<float>();
8333 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
8334 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
8335 repOnKill.RepValue2 = fields[8].Get<float>();
8336 repOnKill.TeamDependent = fields[9].Get<uint8>();
8337
8338 if (!GetCreatureTemplate(creature_id))
8339 {
8340 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
8341 continue;
8342 }
8343
8344 if (repOnKill.RepFaction1)
8345 {
8346 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
8347 if (!factionEntry1)
8348 {
8349 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
8350 continue;
8351 }
8352 }
8353
8354 if (repOnKill.RepFaction2)
8355 {
8356 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
8357 if (!factionEntry2)
8358 {
8359 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
8360 continue;
8361 }
8362 }
8363
8364 _repOnKillStore[creature_id] = repOnKill;
8365
8366 ++count;
8367 } while (result->NextRow());
8368
8369 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8370 LOG_INFO("server.loading", " ");
8371}
Definition ObjectMgr.h:572
uint32 RepFaction1
Definition ObjectMgr.h:573

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

◆ LoadReputationRewardRate()

void ObjectMgr::LoadReputationRewardRate ( )
8212{
8213 uint32 oldMSTime = getMSTime();
8214
8215 _repRewardRateStore.clear(); // for reload case
8216
8217 uint32 count = 0; // 0 1 2 3 4 5 6 7
8218 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");
8219 if (!result)
8220 {
8221 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
8222 return;
8223 }
8224
8225 do
8226 {
8227 Field* fields = result->Fetch();
8228
8229 uint32 factionId = fields[0].Get<uint32>();
8230
8231 RepRewardRate repRate;
8232
8233 repRate.questRate = fields[1].Get<float>();
8234 repRate.questDailyRate = fields[2].Get<float>();
8235 repRate.questWeeklyRate = fields[3].Get<float>();
8236 repRate.questMonthlyRate = fields[4].Get<float>();
8237 repRate.questRepeatableRate = fields[5].Get<float>();
8238 repRate.creatureRate = fields[6].Get<float>();
8239 repRate.spellRate = fields[7].Get<float>();
8240
8241 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
8242 if (!factionEntry)
8243 {
8244 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
8245 continue;
8246 }
8247
8248 if (repRate.questRate < 0.0f)
8249 {
8250 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
8251 continue;
8252 }
8253
8254 if (repRate.questDailyRate < 0.0f)
8255 {
8256 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
8257 continue;
8258 }
8259
8260 if (repRate.questWeeklyRate < 0.0f)
8261 {
8262 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
8263 continue;
8264 }
8265
8266 if (repRate.questMonthlyRate < 0.0f)
8267 {
8268 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
8269 continue;
8270 }
8271
8272 if (repRate.questRepeatableRate < 0.0f)
8273 {
8274 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
8275 continue;
8276 }
8277
8278 if (repRate.creatureRate < 0.0f)
8279 {
8280 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
8281 continue;
8282 }
8283
8284 if (repRate.spellRate < 0.0f)
8285 {
8286 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
8287 continue;
8288 }
8289
8290 _repRewardRateStore[factionId] = repRate;
8291
8292 ++count;
8293 } while (result->NextRow());
8294
8295 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8296 LOG_INFO("server.loading", " ");
8297}
Definition ObjectMgr.h:561
float questRate
Definition ObjectMgr.h:562

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

◆ LoadReputationSpilloverTemplate()

void ObjectMgr::LoadReputationSpilloverTemplate ( )
8374{
8375 uint32 oldMSTime = getMSTime();
8376
8377 _repSpilloverTemplateStore.clear(); // for reload case
8378
8379 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
8380 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");
8381
8382 if (!result)
8383 {
8384 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
8385 LOG_INFO("server.loading", " ");
8386 return;
8387 }
8388
8389 do
8390 {
8391 Field* fields = result->Fetch();
8392
8393 uint32 factionId = fields[0].Get<uint16>();
8394
8395 RepSpilloverTemplate repTemplate;
8396
8397 repTemplate.faction[0] = fields[1].Get<uint16>();
8398 repTemplate.faction_rate[0] = fields[2].Get<float>();
8399 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
8400 repTemplate.faction[1] = fields[4].Get<uint16>();
8401 repTemplate.faction_rate[1] = fields[5].Get<float>();
8402 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
8403 repTemplate.faction[2] = fields[7].Get<uint16>();
8404 repTemplate.faction_rate[2] = fields[8].Get<float>();
8405 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
8406 repTemplate.faction[3] = fields[10].Get<uint16>();
8407 repTemplate.faction_rate[3] = fields[11].Get<float>();
8408 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
8409 repTemplate.faction[4] = fields[13].Get<uint16>();
8410 repTemplate.faction_rate[4] = fields[14].Get<float>();
8411 repTemplate.faction_rank[4] = fields[15].Get<uint8>();
8412 repTemplate.faction[5] = fields[16].Get<uint16>();
8413 repTemplate.faction_rate[5] = fields[17].Get<float>();
8414 repTemplate.faction_rank[5] = fields[18].Get<uint8>();
8415
8416 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
8417
8418 if (!factionEntry)
8419 {
8420 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
8421 continue;
8422 }
8423
8424 if (factionEntry->team == 0)
8425 {
8426 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
8427 continue;
8428 }
8429
8430 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
8431 {
8432 if (repTemplate.faction[i])
8433 {
8434 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
8435
8436 if (!factionSpillover)
8437 {
8438 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);
8439 continue;
8440 }
8441
8442 if (factionSpillover->reputationListID < 0)
8443 {
8444 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);
8445 continue;
8446 }
8447
8448 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
8449 {
8450 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
8451 continue;
8452 }
8453 }
8454 }
8455
8456 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
8457 if (repTemplate.faction[0] && !factionEntry0)
8458 {
8459 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
8460 continue;
8461 }
8462 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
8463 if (repTemplate.faction[1] && !factionEntry1)
8464 {
8465 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
8466 continue;
8467 }
8468 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
8469 if (repTemplate.faction[2] && !factionEntry2)
8470 {
8471 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
8472 continue;
8473 }
8474 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
8475 if (repTemplate.faction[3] && !factionEntry3)
8476 {
8477 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
8478 continue;
8479 }
8480
8481 _repSpilloverTemplateStore[factionId] = repTemplate;
8482
8483 ++count;
8484 } while (result->NextRow());
8485
8486 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8487 LOG_INFO("server.loading", " ");
8488}
#define MAX_SPILLOVER_FACTIONS
Definition SharedDefines.h:235
int32 reputationListID
Definition DBCStructure.h:909
Definition ObjectMgr.h:585
uint32 faction[MAX_SPILLOVER_FACTIONS]
Definition ObjectMgr.h:586

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 ( )
8990{
8991 uint32 oldMSTime = getMSTime();
8992
8993 _reservedNamesStore.clear(); // need for reload case
8994
8995 QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
8996
8997 if (!result)
8998 {
8999 LOG_WARN("server.loading", ">> Loaded 0 reserved names. DB table `reserved_name` is empty!");
9000 return;
9001 }
9002
9003 uint32 count = 0;
9004
9005 Field* fields;
9006 do
9007 {
9008 fields = result->Fetch();
9009 std::string name = fields[0].Get<std::string>();
9010
9011 std::wstring wstr;
9012 if (!Utf8toWStr (name, wstr))
9013 {
9014 LOG_ERROR("sql.sql", "Table `reserved_name` have invalid name: {}", name);
9015 continue;
9016 }
9017
9018 wstrToLower(wstr);
9019
9020 _reservedNamesStore.insert(wstr);
9021 ++count;
9022 } while (result->NextRow());
9023
9024 LOG_INFO("server.loading", ">> Loaded {} reserved names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9025}

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

◆ LoadReservedPlayerNamesDBC()

void ObjectMgr::LoadReservedPlayerNamesDBC ( )
9028{
9029 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
9030 {
9031 LOG_WARN("server.loading", ">> Loaded 0 reserved names from DBC. Config option disabled.");
9032 return;
9033 }
9034
9035 uint32 oldMSTime = getMSTime();
9036
9037 uint32 count = 0;
9038
9039 for (NamesReservedEntry const* reservedStore : sNamesReservedStore)
9040 {
9041 std::wstring wstr;
9042
9043 Utf8toWStr(reservedStore->Pattern, wstr);
9044
9045 // DBC does not have clean entries, remove the junk.
9046 boost::algorithm::replace_all(wstr, "\\<", "");
9047 boost::algorithm::replace_all(wstr, "\\>", "");
9048
9049 _reservedNamesStore.insert(wstr);
9050 count++;
9051 }
9052
9053 LOG_INFO("server.loading", ">> Loaded {} reserved names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9054 LOG_INFO("server.loading", " ");
9055}
DBCStorage< NamesReservedEntry > sNamesReservedStore(NamesReservedfmt)
@ CONFIG_STRICT_NAMES_RESERVED
Definition WorldConfig.h:145
Definition DBCStructure.h:1398

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

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
10438{
10439 uint32 oldMSTime = getMSTime();
10440
10441 // We insert an empty placeholder here so we can use the
10442 // script id 0 as dummy for "no script found".
10443 _scriptNamesStore.emplace_back("");
10444
10445 QueryResult result = WorldDatabase.Query(
10446 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
10447 "UNION "
10448 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
10449 "UNION "
10450 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
10451 "UNION "
10452 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
10453 "UNION "
10454 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
10455 "UNION "
10456 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
10457 "UNION "
10458 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
10459 "UNION "
10460 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
10461 "UNION "
10462 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
10463 "UNION "
10464 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
10465 "UNION "
10466 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
10467 "UNION "
10468 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
10469 "UNION "
10470 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
10471 "UNION "
10472 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
10473
10474 if (!result)
10475 {
10476 LOG_INFO("server.loading", " ");
10477 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
10478 return;
10479 }
10480
10481 _scriptNamesStore.reserve(result->GetRowCount() + 1);
10482
10483 do
10484 {
10485 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
10486 } while (result->NextRow());
10487
10488 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
10489 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
10490 LOG_INFO("server.loading", " ");
10491}

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

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5860{
5861 uint32 oldMSTime = getMSTime();
5862
5863 ScriptMapMap* scripts = GetScriptsMapByType(type);
5864 if (!scripts)
5865 return;
5866
5867 std::string tableName = GetScriptsTableNameByType(type);
5868 if (tableName.empty())
5869 return;
5870
5871 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5872 return;
5873
5874 LOG_INFO("server.loading", "Loading {}...", tableName);
5875
5876 scripts->clear(); // need for reload support
5877
5878 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5879 // 0 1 2 3 4 5 6 7 8 9
5880 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5881
5882 if (!result)
5883 {
5884 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5885 LOG_INFO("server.loading", " ");
5886 return;
5887 }
5888
5889 uint32 count = 0;
5890
5891 do
5892 {
5893 Field* fields = result->Fetch();
5894 ScriptInfo tmp;
5895 tmp.type = type;
5896 tmp.id = fields[0].Get<uint32>();
5897 if (isSpellScriptTable)
5898 tmp.id |= fields[10].Get<uint8>() << 24;
5899 tmp.delay = fields[1].Get<uint32>();
5900 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5901 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5902 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5903 tmp.Raw.nData[2] = fields[5].Get<int32>();
5904 tmp.Raw.fData[0] = fields[6].Get<float>();
5905 tmp.Raw.fData[1] = fields[7].Get<float>();
5906 tmp.Raw.fData[2] = fields[8].Get<float>();
5907 tmp.Raw.fData[3] = fields[9].Get<float>();
5908
5909 // generic command args check
5910 switch (tmp.command)
5911 {
5913 {
5915 {
5916 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5917 tableName, tmp.Talk.ChatType, tmp.id);
5918 continue;
5919 }
5921 {
5922 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
5923 tableName, tmp.Talk.TextID, tmp.id);
5924 continue;
5925 }
5926 break;
5927 }
5928
5930 {
5931 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
5932 {
5933 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
5934 tableName, tmp.Emote.EmoteID, tmp.id);
5935 continue;
5936 }
5937 break;
5938 }
5939
5941 {
5942 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
5943 {
5944 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5945 tableName, tmp.TeleportTo.MapID, tmp.id);
5946 continue;
5947 }
5948
5950 {
5951 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5952 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
5953 continue;
5954 }
5955 break;
5956 }
5957
5959 {
5960 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
5961 if (!quest)
5962 {
5963 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5964 tableName, tmp.QuestExplored.QuestID, tmp.id);
5965 continue;
5966 }
5967
5969 {
5970 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.",
5971 tableName, tmp.QuestExplored.QuestID, tmp.id);
5972
5973 // this will prevent quest completing without objective
5974 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5975
5976 // continue; - quest objective requirement set and command can be allowed
5977 }
5978
5980 {
5981 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 {}",
5982 tableName, tmp.QuestExplored.Distance, tmp.id);
5983 continue;
5984 }
5985
5987 {
5988 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",
5990 continue;
5991 }
5992
5994 {
5995 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",
5996 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
5997 continue;
5998 }
5999
6000 break;
6001 }
6002
6004 {
6006 {
6007 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
6008 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
6009 continue;
6010 }
6011 break;
6012 }
6013
6015 {
6017 if (!data)
6018 {
6019 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
6020 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
6021 continue;
6022 }
6023
6024 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
6025 if (!info)
6026 {
6027 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
6028 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
6029 continue;
6030 }
6031
6032 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
6034 info->type == GAMEOBJECT_TYPE_DOOR ||
6035 info->type == GAMEOBJECT_TYPE_BUTTON ||
6036 info->type == GAMEOBJECT_TYPE_TRAP)
6037 {
6038 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
6039 tableName, info->entry, tmp.id);
6040 continue;
6041 }
6042 break;
6043 }
6044
6046 {
6048 {
6049 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
6051 continue;
6052 }
6053
6055 if (!GetCreatureTemplate(entry))
6056 {
6057 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
6058 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
6059 continue;
6060 }
6061 break;
6062 }
6063
6066 {
6068 if (!data)
6069 {
6070 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
6071 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
6072 continue;
6073 }
6074
6075 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
6076 if (!info)
6077 {
6078 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
6079 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
6080 continue;
6081 }
6082
6083 if (info->type != GAMEOBJECT_TYPE_DOOR)
6084 {
6085 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
6086 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
6087 continue;
6088 }
6089
6090 break;
6091 }
6092
6094 {
6095 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
6096 {
6097 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
6098 tableName, tmp.RemoveAura.SpellID, tmp.id);
6099 continue;
6100 }
6101 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
6102 {
6103 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
6104 tableName, tmp.RemoveAura.Flags, tmp.id);
6105 continue;
6106 }
6107 break;
6108 }
6109
6111 {
6112 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
6113 {
6114 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6115 tableName, tmp.CastSpell.SpellID, tmp.id);
6116 continue;
6117 }
6118 if (tmp.CastSpell.Flags > 4) // targeting type
6119 {
6120 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6121 tableName, tmp.CastSpell.Flags, tmp.id);
6122 continue;
6123 }
6124 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
6125 {
6126 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6127 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
6128 continue;
6129 }
6130 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
6131 {
6132 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6133 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
6134 continue;
6135 }
6136 break;
6137 }
6138
6140 {
6142 {
6143 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
6144 tableName, tmp.CreateItem.ItemEntry, tmp.id);
6145 continue;
6146 }
6147 if (!tmp.CreateItem.Amount)
6148 {
6149 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
6150 tableName, tmp.CreateItem.Amount, tmp.id);
6151 continue;
6152 }
6153 break;
6154 }
6155 default:
6156 break;
6157 }
6158
6159 if (scripts->find(tmp.id) == scripts->end())
6160 {
6161 ScriptMap emptyMap;
6162 (*scripts)[tmp.id] = emptyMap;
6163 }
6164 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
6165
6166 ++count;
6167 } while (result->NextRow());
6168
6169 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6170 LOG_INFO("server.loading", " ");
6171}
@ CHAT_TYPE_WHISPER
Definition CreatureData.h:416
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
#define INTERACTION_DISTANCE
Definition ObjectDefines.h:24
std::multimap< uint32, ScriptInfo > ScriptMap
Definition ObjectMgr.h:386
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition ObjectMgr.cpp:84
ScriptCommands
Definition ObjectMgr.h:92
@ SCRIPT_COMMAND_EMOTE
Definition ObjectMgr.h:94
@ SCRIPT_COMMAND_CREATE_ITEM
Definition ObjectMgr.h:110
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition ObjectMgr.h:105
@ SCRIPT_COMMAND_CAST_SPELL
Definition ObjectMgr.h:108
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition ObjectMgr.h:102
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition ObjectMgr.h:100
@ SCRIPT_COMMAND_TALK
Definition ObjectMgr.h:93
@ SCRIPT_COMMAND_OPEN_DOOR
Definition ObjectMgr.h:104
@ SCRIPT_COMMAND_TELEPORT_TO
Definition ObjectMgr.h:99
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition ObjectMgr.h:103
@ SCRIPT_COMMAND_KILL_CREDIT
Definition ObjectMgr.h:101
@ SCRIPT_COMMAND_REMOVE_AURA
Definition ObjectMgr.h:107
std::string GetScriptCommandName(ScriptCommands command)
Definition ObjectMgr.cpp:104
std::map< uint32, ScriptMap > ScriptMapMap
Definition ObjectMgr.h:387
std::string GetScriptsTableNameByType(ScriptsType type)
Definition ObjectMgr.cpp:64
@ SCRIPTS_SPELL
Definition ObjectMgr.h:149
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1581
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3427
Definition ObjectMgr.h:191
float Orientation
Definition ObjectMgr.h:251
uint32 Flags
Definition ObjectMgr.h:208
struct ScriptInfo::@270::@273 Talk
ScriptsType type
Definition ObjectMgr.h:192
uint32 QuestID
Definition ObjectMgr.h:256
struct ScriptInfo::@270::@280 KillCredit
struct ScriptInfo::@270::@287 CreateItem
int32 TextID
Definition ObjectMgr.h:209
struct ScriptInfo::@270::@278 TeleportTo
float DestX
Definition ObjectMgr.h:230
uint32 ItemEntry
Definition ObjectMgr.h:317
struct ScriptInfo::@270::@285 CastSpell
uint32 ChatType
Definition ObjectMgr.h:207
uint32 id
Definition ObjectMgr.h:193
struct ScriptInfo::@270::@272 Raw
uint32 delay
Definition ObjectMgr.h:194
float fData[4]
Definition ObjectMgr.h:202
float PosY
Definition ObjectMgr.h:279
ScriptCommands command
Definition ObjectMgr.h:195
float DestY
Definition ObjectMgr.h:231
uint32 MapID
Definition ObjectMgr.h:244
uint32 nData[3]
Definition ObjectMgr.h:201
float PosZ
Definition ObjectMgr.h:280
struct ScriptInfo::@270::@284 RemoveAura
struct ScriptInfo::@270::@282 TempSummonCreature
float PosX
Definition ObjectMgr.h:278
uint32 Distance
Definition ObjectMgr.h:257
uint32 SpellID
Definition ObjectMgr.h:295
float DestZ
Definition ObjectMgr.h:232
struct ScriptInfo::@270::@279 QuestExplored
struct ScriptInfo::@270::@283 ToggleDoor
struct ScriptInfo::@270::@281 RespawnGameobject
uint32 GOGuid
Definition ObjectMgr.h:268
uint32 CreatureEntry
Definition ObjectMgr.h:262
uint32 Amount
Definition ObjectMgr.h:318
struct ScriptInfo::@270::@274 Emote
uint32 EmoteID
Definition ObjectMgr.h:214

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().

◆ LoadSpawnGroups()

void ObjectMgr::LoadSpawnGroups ( )
8780{
8781 uint32 oldMSTime = getMSTime();
8782
8783 // Reset prior state for hot-reload support
8784 // Preserve the forced legacy group for spawns on transport maps (set in LoadCreatures/LoadGameobjects).
8785 _spawnGroupMapStore.clear();
8786 for (auto& [id, data] : _creatureDataStore)
8787 data.spawnGroupId = _transportMaps.count(data.mapid) ? 1 : 0;
8788 for (auto& [id, data] : _gameObjectDataStore)
8789 data.spawnGroupId = _transportMaps.count(data.mapid) ? 1 : 0;
8790
8791 // 0 1 2
8792 QueryResult result = WorldDatabase.Query("SELECT groupId, spawnType, spawnId FROM spawn_group");
8793
8794 if (!result)
8795 {
8796 LOG_INFO("server.loading", ">> Loaded 0 spawn group members. DB table `spawn_group` is empty.");
8797 LOG_INFO("server.loading", " ");
8798 return;
8799 }
8800
8801 uint32 numMembers = 0;
8802 do
8803 {
8804 Field* fields = result->Fetch();
8805 uint32 groupId = fields[0].Get<uint32>();
8806 uint32 type = fields[1].Get<uint8>();
8807 if (type >= SPAWN_TYPE_MAX)
8808 {
8809 LOG_ERROR("sql.sql", "Spawn data with invalid type {} listed for spawn group {}. Skipped.", type, groupId);
8810 continue;
8811 }
8812 SpawnObjectType spawnType = SpawnObjectType(type);
8813 ObjectGuid::LowType spawnId = fields[2].Get<uint32>();
8814
8815 SpawnData const* data = GetSpawnData(spawnType, spawnId);
8816 if (!data)
8817 {
8818 LOG_ERROR("sql.sql", "Spawn data with ID ({},{}) not found, but is listed as a member of spawn group {}!",
8819 uint32(spawnType), spawnId, groupId);
8820 continue;
8821 }
8822 if (data->spawnGroupId)
8823 {
8824 LOG_ERROR("sql.sql", "Spawn with ID ({},{}) is listed as a member of spawn group {}, but is already a member of spawn group {}. Skipping.",
8825 uint32(spawnType), spawnId, groupId, data->spawnGroupId);
8826 continue;
8827 }
8828
8829 auto it = _spawnGroupDataStore.find(groupId);
8830 if (it == _spawnGroupDataStore.end())
8831 {
8832 LOG_ERROR("sql.sql", "Spawn group {} assigned to spawn ID ({},{}), but group is not found!", groupId, uint32(spawnType), spawnId);
8833 continue;
8834 }
8835
8836 SpawnGroupTemplateData& groupTemplate = it->second;
8837 if (groupTemplate.mapId == SPAWNGROUP_MAP_UNSET)
8838 groupTemplate.mapId = data->mapid;
8839 else if (groupTemplate.mapId != data->mapid && !(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
8840 {
8841 LOG_ERROR("sql.sql", "Spawn group {} has map ID {}, but spawn ({},{}) has map id {} - spawn NOT added to group!",
8842 groupId, groupTemplate.mapId, uint32(spawnType), spawnId, data->mapid);
8843 continue;
8844 }
8845
8846 // Warn if spawn is also in a pool (non-system groups and pools are mutually exclusive)
8847 if (!(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
8848 {
8849 uint32 poolId = 0;
8850 if (spawnType == SPAWN_TYPE_CREATURE)
8851 poolId = sPoolMgr->IsPartOfAPool<Creature>(spawnId);
8852 else if (spawnType == SPAWN_TYPE_GAMEOBJECT)
8853 poolId = sPoolMgr->IsPartOfAPool<GameObject>(spawnId);
8854
8855 if (poolId)
8856 LOG_WARN("sql.sql", "Spawn ({},{}) is a member of spawn group {} and also part of pool {}. This may cause issues!",
8857 uint32(spawnType), spawnId, groupId, poolId);
8858 }
8859
8860 const_cast<SpawnData*>(data)->spawnGroupId = groupId;
8861 if (!(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
8862 _spawnGroupMapStore.emplace(groupId, data);
8863 ++numMembers;
8864 } while (result->NextRow());
8865
8866 LOG_INFO("server.loading", ">> Loaded {} spawn group members in {} ms", numMembers, GetMSTimeDiffToNow(oldMSTime));
8867 LOG_INFO("server.loading", " ");
8868}
SpawnObjectType
Definition SpawnData.h:26
@ SPAWN_TYPE_MAX
Definition SpawnData.h:30
SpawnData const * GetSpawnData(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition ObjectMgr.cpp:8708
Definition SpawnData.h:66
Definition SpawnData.h:58
SpawnGroupFlags flags
Definition SpawnData.h:62
uint32 mapId
Definition SpawnData.h:61

References _creatureDataStore, _gameObjectDataStore, _spawnGroupDataStore, _spawnGroupMapStore, _transportMaps, SpawnGroupTemplateData::flags, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), GetSpawnData(), LOG_ERROR, LOG_INFO, LOG_WARN, SpawnGroupTemplateData::mapId, SPAWN_TYPE_CREATURE, SPAWN_TYPE_GAMEOBJECT, SPAWN_TYPE_MAX, SPAWNGROUP_FLAG_SYSTEM, SPAWNGROUP_MAP_UNSET, sPoolMgr, and WorldDatabase.

◆ LoadSpawnGroupTemplates()

void ObjectMgr::LoadSpawnGroupTemplates ( )
8722{
8723 uint32 oldMSTime = getMSTime();
8724
8725 _spawnGroupDataStore.clear();
8726
8727 // 0 1 2
8728 QueryResult result = WorldDatabase.Query("SELECT groupId, groupName, groupFlags FROM spawn_group_template");
8729
8730 if (result)
8731 {
8732 do
8733 {
8734 Field* fields = result->Fetch();
8735 uint32 groupId = fields[0].Get<uint32>();
8737 group.groupId = groupId;
8738 group.name = fields[1].Get<std::string>();
8739 group.mapId = SPAWNGROUP_MAP_UNSET;
8740 uint32 flags = fields[2].Get<uint32>();
8741 if (flags & ~uint32(SPAWNGROUP_FLAG_ALL))
8742 {
8743 flags &= uint32(SPAWNGROUP_FLAG_ALL);
8744 LOG_ERROR("sql.sql", "Invalid spawn group flag {} on group ID {} ({}), reduced to valid flags {}.",
8745 fields[2].Get<uint32>(), groupId, group.name, flags);
8746 }
8747 if ((flags & SPAWNGROUP_FLAG_SYSTEM) && (flags & SPAWNGROUP_FLAG_MANUAL_SPAWN))
8748 {
8749 flags &= ~SPAWNGROUP_FLAG_MANUAL_SPAWN;
8750 LOG_ERROR("sql.sql", "System spawn group {} ({}) has invalid manual spawn flag. Ignored.", groupId, group.name);
8751 }
8752 group.flags = SpawnGroupFlags(flags);
8753 } while (result->NextRow());
8754 }
8755
8756 if (_spawnGroupDataStore.find(0) == _spawnGroupDataStore.end())
8757 {
8758 LOG_ERROR("sql.sql", "Default spawn group (index 0) is missing from DB! Manually inserted.");
8760 data.groupId = 0;
8761 data.name = "Default Group";
8764 }
8765 if (_spawnGroupDataStore.find(1) == _spawnGroupDataStore.end())
8766 {
8767 LOG_ERROR("sql.sql", "Default legacy spawn group (index 1) is missing from DB! Manually inserted.");
8769 data.groupId = 1;
8770 data.name = "Legacy Group";
8773 }
8774
8775 LOG_INFO("server.loading", ">> Loaded {} spawn group templates in {} ms", _spawnGroupDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
8776 LOG_INFO("server.loading", " ");
8777}
@ SPAWNGROUP_FLAG_ALL
Definition SpawnData.h:50
@ SPAWNGROUP_FLAG_MANUAL_SPAWN
Definition SpawnData.h:46
std::string name
Definition SpawnData.h:60
uint32 groupId
Definition SpawnData.h:59

References _spawnGroupDataStore, SpawnGroupTemplateData::flags, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), SpawnGroupTemplateData::groupId, LOG_ERROR, LOG_INFO, SpawnGroupTemplateData::mapId, SpawnGroupTemplateData::name, SPAWNGROUP_FLAG_ALL, SPAWNGROUP_FLAG_COMPATIBILITY_MODE, SPAWNGROUP_FLAG_MANUAL_SPAWN, SPAWNGROUP_FLAG_SYSTEM, SPAWNGROUP_MAP_UNSET, and WorldDatabase.

◆ LoadSpellScriptNames()

void ObjectMgr::LoadSpellScriptNames ( )
6273{
6274 uint32 oldMSTime = getMSTime();
6275
6276 _spellScriptsStore.clear(); // need for reload case
6277
6278 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
6279
6280 if (!result)
6281 {
6282 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
6283 LOG_INFO("server.loading", " ");
6284 return;
6285 }
6286
6287 uint32 count = 0;
6288
6289 do
6290 {
6291 Field* fields = result->Fetch();
6292
6293 int32 spellId = fields[0].Get<int32>();
6294 std::string scriptName = fields[1].Get<std::string>();
6295
6296 bool allRanks = false;
6297 if (spellId <= 0)
6298 {
6299 allRanks = true;
6300 spellId = -spellId;
6301 }
6302
6303 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
6304 if (!spellInfo)
6305 {
6306 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
6307 continue;
6308 }
6309
6310 if (allRanks)
6311 {
6312 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
6313 {
6314 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
6315 continue;
6316 }
6317 while (spellInfo)
6318 {
6319 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
6320 spellInfo = spellInfo->GetNextRankSpell();
6321 }
6322 }
6323 else
6324 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
6325 ++count;
6326 } while (result->NextRow());
6327
6328 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6329 LOG_INFO("server.loading", " ");
6330}
SpellInfo const * GetNextRankSpell() const
Definition SpellInfo.cpp:2915

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

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
6174{
6176
6177 // check ids
6178 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
6179 {
6180 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
6181 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
6182
6183 if (!spellInfo)
6184 {
6185 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
6186 continue;
6187 }
6188
6189 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
6190 if (uint32(i) >= MAX_SPELL_EFFECTS)
6191 {
6192 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
6193 }
6194
6195 //check for correct spellEffect
6196 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
6197 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
6198 }
6199}
ScriptMapMap sSpellScripts
Definition ObjectMgr.cpp:60
SpellEffIndex
Definition SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:769
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:843

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 ( )
7113{
7114 uint32 oldMSTime = getMSTime();
7115
7116 _tavernAreaTriggerStore.clear(); // need for reload case
7117
7118 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
7119
7120 if (!result)
7121 {
7122 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
7123 LOG_INFO("server.loading", " ");
7124 return;
7125 }
7126
7127 uint32 count = 0;
7128
7129 do
7130 {
7131 ++count;
7132
7133 Field* fields = result->Fetch();
7134
7135 uint32 Trigger_ID = fields[0].Get<uint32>();
7136
7137 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
7138 if (!atEntry)
7139 {
7140 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
7141 continue;
7142 }
7143
7144 uint32 faction = fields[1].Get<uint32>();
7145
7146 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
7147 } while (result->NextRow());
7148
7149 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7150 LOG_INFO("server.loading", " ");
7151}

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

◆ LoadTempSummons()

void ObjectMgr::LoadTempSummons ( )
2151{
2152 uint32 oldMSTime = getMSTime();
2153
2154 // 0 1 2 3 4 5 6 7 8 9
2155 QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, summonType, summonTime FROM creature_summon_groups");
2156
2157 if (!result)
2158 {
2159 LOG_WARN("server.loading", ">> Loaded 0 temp summons. DB table `creature_summon_groups` is empty.");
2160 return;
2161 }
2162
2163 uint32 count = 0;
2164 do
2165 {
2166 Field* fields = result->Fetch();
2167
2168 uint32 summonerId = fields[0].Get<uint32>();
2169 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2170 uint8 group = fields[2].Get<uint8>();
2171
2172 switch (summonerType)
2173 {
2175 if (!GetCreatureTemplate(summonerId))
2176 {
2177 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2178 continue;
2179 }
2180 break;
2182 if (!GetGameObjectTemplate(summonerId))
2183 {
2184 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2185 continue;
2186 }
2187 break;
2188 case SUMMONER_TYPE_MAP:
2189 if (!sMapStore.LookupEntry(summonerId))
2190 {
2191 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2192 continue;
2193 }
2194 break;
2195 default:
2196 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2197 continue;
2198 }
2199
2200 TempSummonData data;
2201 data.entry = fields[3].Get<uint32>();
2202
2203 if (!GetCreatureTemplate(data.entry))
2204 {
2205 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);
2206 continue;
2207 }
2208
2209 float posX = fields[4].Get<float>();
2210 float posY = fields[5].Get<float>();
2211 float posZ = fields[6].Get<float>();
2212 float orientation = fields[7].Get<float>();
2213
2214 data.pos.Relocate(posX, posY, posZ, orientation);
2215
2216 data.type = TempSummonType(fields[8].Get<uint8>());
2217
2219 {
2220 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);
2221 continue;
2222 }
2223
2224 data.time = fields[9].Get<uint32>();
2225
2226 TempSummonGroupKey key(summonerId, summonerType, group);
2227 _tempSummonDataStore[key].push_back(data);
2228
2229 ++count;
2230 } while (result->NextRow());
2231
2232 LOG_INFO("server.loading", ">> Loaded {} Temporary Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2233 LOG_INFO("server.loading", " ");
2234}
TempSummonType
Definition Object.h:48
@ TEMPSUMMON_MANUAL_DESPAWN
Definition Object.h:56
Stores data for temp summons.
Definition TemporarySummon.h:33
TempSummonType type
Summon type, see TempSummonType for available types.
Definition TemporarySummon.h:36
uint32 time
Despawn time, usable only with certain temp summon types.
Definition TemporarySummon.h:37
uint32 entry
Entry of summoned creature.
Definition TemporarySummon.h:34
Position pos
Position, where should be creature spawned.
Definition TemporarySummon.h:35

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.

◆ LoadTrainers()

void ObjectMgr::LoadTrainers ( )
9930{
9931 uint32 oldMSTime = getMSTime();
9932
9933 // For reload case
9934 _trainers.clear();
9935 _classTrainers.clear();
9936
9937 std::unordered_map<int32, std::vector<Trainer::Spell>> spellsByTrainer;
9938 if (QueryResult trainerSpellsResult = WorldDatabase.Query("SELECT TrainerId, SpellId, MoneyCost, ReqSkillLine, ReqSkillRank, ReqAbility1, ReqAbility2, ReqAbility3, ReqLevel FROM trainer_spell"))
9939 {
9940 do
9941 {
9942 Field* fields = trainerSpellsResult->Fetch();
9943
9944 Trainer::Spell spell;
9945 uint32 trainerId = fields[0].Get<uint32>();
9946 spell.SpellId = fields[1].Get<uint32>();
9947 spell.MoneyCost = fields[2].Get<uint32>();
9948 spell.ReqSkillLine = fields[3].Get<uint32>();
9949 spell.ReqSkillRank = fields[4].Get<uint32>();
9950 spell.ReqAbility[0] = fields[5].Get<uint32>();
9951 spell.ReqAbility[1] = fields[6].Get<uint32>();
9952 spell.ReqAbility[2] = fields[7].Get<uint32>();
9953 spell.ReqLevel = fields[8].Get<uint8>();
9954
9955 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.SpellId);
9956 if (!spellInfo)
9957 {
9958 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: {}) for TrainerId {}, ignoring", spell.SpellId, trainerId);
9959 continue;
9960 }
9961
9962 if (GetTalentSpellCost(spell.SpellId))
9963 {
9964 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: {}) which is a talent, for TrainerId {}, ignoring", spell.SpellId, trainerId);
9965 continue;
9966 }
9967
9968 if (spell.ReqSkillLine && !sSkillLineStore.LookupEntry(spell.ReqSkillLine))
9969 {
9970 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing skill (ReqSkillLine: {}) for TrainerId {} and SpellId {}, ignoring",
9971 spell.ReqSkillLine, spell.SpellId, trainerId);
9972 continue;
9973 }
9974
9975 bool allReqValid = true;
9976 for (std::size_t i = 0; i < spell.ReqAbility.size(); ++i)
9977 {
9978 uint32 requiredSpell = spell.ReqAbility[i];
9979 if (requiredSpell && !sSpellMgr->GetSpellInfo(requiredSpell))
9980 {
9981 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (ReqAbility {} : {}) for TrainerId {} and SpellId {}, ignoring",
9982 i + 1, requiredSpell, trainerId, spell.SpellId);
9983 allReqValid = false;
9984 }
9985 }
9986
9987 if (!allReqValid)
9988 continue;
9989
9990 spellsByTrainer[trainerId].push_back(spell);
9991 } while (trainerSpellsResult->NextRow());
9992 }
9993
9994 if (QueryResult trainersResult = WorldDatabase.Query("SELECT Id, Type, Requirement, Greeting FROM trainer"))
9995 {
9996 do
9997 {
9998 Field* fields = trainersResult->Fetch();
9999
10000 uint32 trainerId = fields[0].Get<uint32>();
10001 Trainer::Type trainerType = Trainer::Type(fields[1].Get<uint8>());
10002 uint32 requirement = fields[2].Get<uint32>();
10003 std::string greeting = fields[3].Get<std::string>();
10004 std::vector<Trainer::Spell> spells;
10005 auto spellsItr = spellsByTrainer.find(trainerId);
10006 if (spellsItr != spellsByTrainer.end())
10007 {
10008 spells = std::move(spellsItr->second);
10009 spellsByTrainer.erase(spellsItr);
10010 }
10011
10012 auto [it, isNew] = _trainers.emplace(std::piecewise_construct, std::forward_as_tuple(trainerId), std::forward_as_tuple(trainerId, trainerType, requirement, std::move(greeting), std::move(spells)));
10013 ASSERT(isNew);
10014 if (trainerType == Trainer::Type::Class)
10015 {
10016 if (!requirement || requirement >= MAX_CLASSES)
10017 LOG_ERROR("sql.sql", "Table `trainer` has invalid class requirement for trainer {}, ignoring");
10018 else
10019 {
10020 uint8 classId = static_cast<uint8>(requirement);
10021 _classTrainers[classId].push_back(&it->second);
10022 }
10023 }
10024 } while (trainersResult->NextRow());
10025 }
10026
10027 for (auto const& unusedSpells : spellsByTrainer)
10028 {
10029 for (Trainer::Spell const& unusedSpell : unusedSpells.second)
10030 {
10031 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing trainer (TrainerId: {}) for SpellId {}, ignoring", unusedSpells.first, unusedSpell.SpellId);
10032 }
10033 }
10034
10035 if (QueryResult trainerLocalesResult = WorldDatabase.Query("SELECT Id, locale, Greeting_lang FROM trainer_locale"))
10036 {
10037 do
10038 {
10039 Field* fields = trainerLocalesResult->Fetch();
10040 uint32 trainerId = fields[0].Get<uint32>();
10041 std::string localeName = fields[1].Get<std::string>();
10042
10043 LocaleConstant locale = GetLocaleByName(localeName);
10044 if (locale == LOCALE_enUS)
10045 continue;
10046
10048 trainer->AddGreetingLocale(locale, fields[2].Get<std::string>());
10049 else
10050 LOG_ERROR("sql.sql", "Table `trainer_locale` references non-existing trainer (TrainerId: {}) for locale %s, ignoring",
10051 trainerId, localeName.c_str());
10052 } while (trainerLocalesResult->NextRow());
10053 }
10054
10055 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", _trainers.size(), GetMSTimeDiffToNow(oldMSTime));
10056}
#define ASSERT
Definition Errors.h:68
Definition Trainer.h:66
Type
Definition Trainer.h:32
Definition Trainer.h:54
uint32 ReqSkillLine
Definition Trainer.h:57
std::array< uint32, 3 > ReqAbility
Definition Trainer.h:59
uint8 ReqLevel
Definition Trainer.h:60
uint32 ReqSkillRank
Definition Trainer.h:58
uint32 SpellId
Definition Trainer.h:55
uint32 MoneyCost
Definition Trainer.h:56

References _classTrainers, _trainers, ASSERT, Trainer::Class, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), GetTalentSpellCost(), LOCALE_enUS, LOG_ERROR, LOG_INFO, Acore::Containers::MapGetValuePtr(), MAX_CLASSES, Trainer::Spell::MoneyCost, Trainer::Spell::ReqAbility, Trainer::Spell::ReqLevel, Trainer::Spell::ReqSkillLine, Trainer::Spell::ReqSkillRank, Trainer::Spell::SpellId, sSkillLineStore, sSpellMgr, and WorldDatabase.

◆ LoadVehicleAccessories()

void ObjectMgr::LoadVehicleAccessories ( )
4040{
4041 uint32 oldMSTime = getMSTime();
4042
4043 _vehicleAccessoryStore.clear(); // needed for reload case
4044
4045 uint32 count = 0;
4046
4047 // 0 1 2 3 4 5
4048 QueryResult result = WorldDatabase.Query("SELECT `guid`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_accessory`");
4049
4050 if (!result)
4051 {
4052 LOG_WARN("server.loading", ">> Loaded 0 Vehicle Accessories in {} ms", GetMSTimeDiffToNow(oldMSTime));
4053 LOG_INFO("server.loading", " ");
4054 return;
4055 }
4056
4057 do
4058 {
4059 Field* fields = result->Fetch();
4060
4061 uint32 uiGUID = fields[0].Get<uint32>();
4062 uint32 uiAccessory = fields[1].Get<uint32>();
4063 int8 uiSeat = int8(fields[2].Get<int16>());
4064 bool bMinion = fields[3].Get<bool>();
4065 uint8 uiSummonType = fields[4].Get<uint8>();
4066 uint32 uiSummonTimer = fields[5].Get<uint32>();
4067
4068 if (!GetCreatureTemplate(uiAccessory))
4069 {
4070 LOG_ERROR("sql.sql", "Table `vehicle_accessory`: Accessory {} does not exist.", uiAccessory);
4071 continue;
4072 }
4073
4074 _vehicleAccessoryStore[uiGUID].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
4075
4076 ++count;
4077 } while (result->NextRow());
4078
4079 LOG_INFO("server.loading", ">> Loaded {} Vehicle Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4080 LOG_INFO("server.loading", " ");
4081}
Definition VehicleDefines.h:115

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

◆ LoadVehicleSeatAddon()

void ObjectMgr::LoadVehicleSeatAddon ( )
4084{
4085 uint32 oldMSTime = getMSTime();
4086
4087 _vehicleSeatAddonStore.clear(); // needed for reload case
4088
4089 uint32 count = 0;
4090
4091 // 0 1 2 3 4 5 6
4092 QueryResult result = WorldDatabase.Query("SELECT `SeatEntry`, `SeatOrientation`, `ExitParamX`, `ExitParamY`, `ExitParamZ`, `ExitParamO`, `ExitParamValue` FROM `vehicle_seat_addon`");
4093
4094 if (!result)
4095 {
4096 LOG_ERROR("server.loading", ">> Loaded 0 vehicle seat addons. DB table `vehicle_seat_addon` is empty.");
4097 return;
4098 }
4099
4100 do
4101 {
4102 Field* fields = result->Fetch();
4103
4104 uint32 seatID = fields[0].Get<uint32>();
4105 float orientation = fields[1].Get<float>();
4106 float exitX = fields[2].Get<float>();
4107 float exitY = fields[3].Get<float>();
4108 float exitZ = fields[4].Get<float>();
4109 float exitO = fields[5].Get<float>();
4110 uint8 exitParam = fields[6].Get<uint8>();
4111
4112 if (!sVehicleSeatStore.LookupEntry(seatID))
4113 {
4114 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} does not exist in VehicleSeat.dbc. Skipping entry.", seatID);
4115 continue;
4116 }
4117
4118 // Sanitizing values
4119 if (orientation > float(M_PI * 2))
4120 {
4121 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid angle offset value ({}). Set Value to 0.", seatID, orientation);
4122 orientation = 0.0f;
4123 }
4124
4126 {
4127 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid exit parameter value ({}). Setting to 0 (none).", seatID, exitParam);
4128 continue;
4129 }
4130
4131 _vehicleSeatAddonStore[seatID] = VehicleSeatAddon(orientation, exitX, exitY, exitZ, exitO, exitParam);
4132
4133 ++count;
4134 } while (result->NextRow());
4135
4136 LOG_INFO("server.loading", ">> Loaded {} Vehicle Seat Addon entries in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4137}
DBCStorage< VehicleSeatEntry > sVehicleSeatStore(VehicleSeatEntryfmt)
Definition VehicleDefines.h:86

References _vehicleSeatAddonStore, AsUnderlyingType(), Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, sVehicleSeatStore, VehicleExitParamMax, and WorldDatabase.

◆ LoadVehicleTemplateAccessories()

void ObjectMgr::LoadVehicleTemplateAccessories ( )
3984{
3985 uint32 oldMSTime = getMSTime();
3986
3987 _vehicleTemplateAccessoryStore.clear(); // needed for reload case
3988
3989 uint32 count = 0;
3990
3991 // 0 1 2 3 4 5
3992 QueryResult result = WorldDatabase.Query("SELECT `entry`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_template_accessory`");
3993
3994 if (!result)
3995 {
3996 LOG_WARN("server.loading", ">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
3997 LOG_INFO("server.loading", " ");
3998 return;
3999 }
4000
4001 do
4002 {
4003 Field* fields = result->Fetch();
4004
4005 uint32 uiEntry = fields[0].Get<uint32>();
4006 uint32 uiAccessory = fields[1].Get<uint32>();
4007 int8 uiSeat = int8(fields[2].Get<int8>());
4008 bool bMinion = fields[3].Get<bool>();
4009 uint8 uiSummonType = fields[4].Get<uint8>();
4010 uint32 uiSummonTimer = fields[5].Get<uint32>();
4011
4012 if (!GetCreatureTemplate(uiEntry))
4013 {
4014 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} does not exist.", uiEntry);
4015 continue;
4016 }
4017
4018 if (!GetCreatureTemplate(uiAccessory))
4019 {
4020 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: Accessory {} does not exist.", uiAccessory);
4021 continue;
4022 }
4023
4024 if (_spellClickInfoStore.find(uiEntry) == _spellClickInfoStore.end())
4025 {
4026 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} has no data in npc_spellclick_spells", uiEntry);
4027 continue;
4028 }
4029
4030 _vehicleTemplateAccessoryStore[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
4031
4032 ++count;
4033 } while (result->NextRow());
4034
4035 LOG_INFO("server.loading", ">> Loaded {} Vehicle Template Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4036 LOG_INFO("server.loading", " ");
4037}

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

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
10135{
10136 uint32 oldMSTime = getMSTime();
10137
10138 // For reload case
10139 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
10140 itr->second.Clear();
10141 _cacheVendorItemStore.clear();
10142
10143 std::set<uint32> skip_vendors;
10144
10145 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
10146 if (!result)
10147 {
10148 LOG_INFO("server.loading", " ");
10149 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
10150 return;
10151 }
10152
10153 uint32 count = 0;
10154
10155 do
10156 {
10157 Field* fields = result->Fetch();
10158
10159 uint32 entry = fields[0].Get<uint32>();
10160 int32 item_id = fields[1].Get<int32>();
10161
10162 // if item is a negative, its a reference
10163 if (item_id < 0)
10164 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
10165 else
10166 {
10167 uint32 maxcount = fields[2].Get<uint32>();
10168 uint32 incrtime = fields[3].Get<uint32>();
10169 uint32 ExtendedCost = fields[4].Get<uint32>();
10170
10171 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
10172 continue;
10173
10174 VendorItemData& vList = _cacheVendorItemStore[entry];
10175
10176 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
10177 ++count;
10178 }
10179 } while (result->NextRow());
10180
10181 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10182 LOG_INFO("server.loading", " ");
10183}

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

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
6246{
6248
6249 std::set<uint32> actionSet;
6250
6251 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
6252 actionSet.insert(itr->first);
6253
6255 PreparedQueryResult result = WorldDatabase.Query(stmt);
6256
6257 if (result)
6258 {
6259 do
6260 {
6261 Field* fields = result->Fetch();
6262 uint32 action = fields[0].Get<uint32>();
6263
6264 actionSet.erase(action);
6265 } while (result->NextRow());
6266 }
6267
6268 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
6269 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
6270}
ScriptMapMap sWaypointScripts
Definition ObjectMgr.cpp:62
@ SCRIPTS_WAYPOINT
Definition ObjectMgr.h:151
@ 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
1359{ return _gameObjectDataStore[guid]; }

References _gameObjectDataStore.

Referenced by AddGOData().

◆ NewOrExistCreatureData()

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

References _creatureDataStore.

Referenced by AddCreData().

◆ OnDeleteSpawnData()

void ObjectMgr::OnDeleteSpawnData ( SpawnData const *  data)
8871{
8872 auto templateIt = _spawnGroupDataStore.find(data->spawnGroupId);
8873 ASSERT(templateIt != _spawnGroupDataStore.end(), "Spawn data is being deleted and has invalid spawn group index {}!", data->spawnGroupId);
8874 if (templateIt->second.flags & SPAWNGROUP_FLAG_SYSTEM)
8875 return;
8876
8877 auto pair = _spawnGroupMapStore.equal_range(data->spawnGroupId);
8878 for (auto it = pair.first; it != pair.second; ++it)
8879 {
8880 if (it->second != data)
8881 continue;
8882 _spawnGroupMapStore.erase(it);
8883 return;
8884 }
8885 ASSERT(false, "Spawn data being removed is member of spawn group {}, but not found in lookup table!", data->spawnGroupId);
8886}

References _spawnGroupDataStore, _spawnGroupMapStore, ASSERT, SPAWNGROUP_FLAG_SYSTEM, and SpawnData::spawnGroupId.

◆ PlayerCreateInfoAddItemHelper()

void ObjectMgr::PlayerCreateInfoAddItemHelper ( uint32  race_,
uint32  class_,
uint32  itemId,
int32  count 
)
private
4245{
4246 if (!_playerInfo[race_][class_])
4247 return;
4248
4249 if (count > 0)
4250 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
4251 else
4252 {
4253 if (count < -1)
4254 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
4255
4256 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
4257 {
4258 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
4259 {
4260 bool found = false;
4261 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
4262 {
4263 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
4264 {
4265 found = true;
4266 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
4267 break;
4268 }
4269 }
4270
4271 if (!found)
4272 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
4273 }
4274 }
4275 }
4276}
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition DBCStores.cpp:842
Definition Player.h:266

References _playerInfo, GENDER_NONE, GetCharStartOutfitEntry(), LOG_ERROR, and MAX_OUTFIT_ITEMS.

Referenced by LoadPlayerInfo().

◆ RemoveCreatureFromGrid()

void ObjectMgr::RemoveCreatureFromGrid ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)
2732{
2733 uint8 mask = data->spawnMask;
2734 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2735 {
2736 if (mask & 1)
2737 {
2738 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2739 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2740 cell_guids.creatures.erase(guid);
2741 }
2742 }
2743}

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

Referenced by DeleteCreatureData().

◆ RemoveGameobjectFromGrid()

void ObjectMgr::RemoveGameobjectFromGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
3184{
3185 uint8 mask = data->spawnMask;
3186 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
3187 {
3188 if (mask & 1)
3189 {
3190 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
3191 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
3192 cell_guids.gameobjects.erase(guid);
3193 }
3194 }
3195}

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

Referenced by DeleteGOData().

◆ RemoveVendorItem()

bool ObjectMgr::RemoveVendorItem ( uint32  entry,
uint32  item,
bool  persist = true 
)
10336{
10337 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
10338 if (iter == _cacheVendorItemStore.end())
10339 return false;
10340
10341 if (!iter->second.RemoveItem(item))
10342 return false;
10343
10344 if (persist)
10345 {
10347
10348 stmt->SetData(0, entry);
10349 stmt->SetData(1, item);
10350
10351 WorldDatabase.Execute(stmt);
10352 }
10353
10354 return true;
10355}
@ WORLD_DEL_NPC_VENDOR
Definition WorldDatabase.h:44

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

◆ ReturnOrDeleteOldMails()

void ObjectMgr::ReturnOrDeleteOldMails ( bool  serverUp)
6741{
6742 uint32 oldMSTime = getMSTime();
6743
6744 time_t curTime = GameTime::GetGameTime().count();
6745
6747 stmt->SetData(0, uint32(curTime));
6748 PreparedQueryResult result = CharacterDatabase.Query(stmt);
6749 if (!result)
6750 return;
6751
6752 std::map<uint32 /*messageId*/, MailItemInfoVec> itemsCache;
6753 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS);
6754 stmt->SetData(0, uint32(curTime));
6755 if (PreparedQueryResult items = CharacterDatabase.Query(stmt))
6756 {
6757 MailItemInfo item;
6758 do
6759 {
6760 Field* fields = items->Fetch();
6761 item.item_guid = fields[0].Get<uint32>();
6762 item.item_template = fields[1].Get<uint32>();
6763 uint32 mailId = fields[2].Get<uint32>();
6764 itemsCache[mailId].push_back(item);
6765 } while (items->NextRow());
6766 }
6767
6768 uint32 deletedCount = 0;
6769 uint32 returnedCount = 0;
6770 do
6771 {
6772 Field* fields = result->Fetch();
6773 Mail* m = new Mail;
6774 m->messageID = fields[0].Get<uint32>();
6775 m->messageType = fields[1].Get<uint8>();
6776 m->sender = fields[2].Get<uint32>();
6777 m->receiver = fields[3].Get<uint32>();
6778 bool has_items = fields[4].Get<bool>();
6779 m->expire_time = time_t(fields[5].Get<uint32>());
6780 m->deliver_time = time_t(0);
6781 m->stationery = fields[6].Get<uint8>();
6782 m->checked = fields[7].Get<uint8>();
6783 m->mailTemplateId = fields[8].Get<int16>();
6784
6785 Player* player = nullptr;
6786 if (serverUp)
6788
6789 if (player) // don't modify mails of a logged in player
6790 {
6791 delete m;
6792 continue;
6793 }
6794
6795 // Delete or return mail
6796 if (has_items)
6797 {
6798 // read items from cache
6799 m->items.swap(itemsCache[m->messageID]);
6800
6801 // If it is mail from non-player, or if it's already return mail, it shouldn't be returned, but deleted
6802 if (!m->IsSentByPlayer() || m->IsSentByGM() || (m->IsCODPayment() || m->IsReturnedMail()))
6803 {
6804 for (auto const& mailedItem : m->items)
6805 {
6806 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
6807 stmt->SetData(0, mailedItem.item_guid);
6808 CharacterDatabase.Execute(stmt);
6809 }
6810
6811 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
6812 stmt->SetData(0, m->messageID);
6813 CharacterDatabase.Execute(stmt);
6814 }
6815 else
6816 {
6817 // Mail will be returned
6818 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_RETURNED);
6819 stmt->SetData(0, m->receiver);
6820 stmt->SetData(1, m->sender);
6821 stmt->SetData(2, uint32(curTime + 30 * DAY));
6822 stmt->SetData(3, uint32(curTime));
6824 stmt->SetData(5, m->messageID);
6825 CharacterDatabase.Execute(stmt);
6826 for (auto const& mailedItem : m->items)
6827 {
6828 // Update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete
6829 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_ITEM_RECEIVER);
6830 stmt->SetData(0, m->sender);
6831 stmt->SetData(1, mailedItem.item_guid);
6832 CharacterDatabase.Execute(stmt);
6833
6834 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
6835 stmt->SetData(0, m->sender);
6836 stmt->SetData(1, mailedItem.item_guid);
6837 CharacterDatabase.Execute(stmt);
6838 }
6839
6840 // xinef: update global data
6841 sCharacterCache->IncreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->sender));
6842 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6843
6844 delete m;
6845 ++returnedCount;
6846 continue;
6847 }
6848 }
6849
6850 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6851
6852 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
6853 stmt->SetData(0, m->messageID);
6854 CharacterDatabase.Execute(stmt);
6855 delete m;
6856 ++deletedCount;
6857 } while (result->NextRow());
6858
6859 LOG_INFO("server.loading", ">> Processed {} expired mails: {} deleted and {} returned in {} ms", deletedCount + returnedCount, deletedCount, returnedCount, GetMSTimeDiffToNow(oldMSTime));
6860 LOG_INFO("server.loading", " ");
6861}
#define sCharacterCache
Definition CharacterCache.h:83
@ 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:383
@ CHAR_UPD_MAIL_ITEM_RECEIVER
Definition CharacterDatabase.h:117
std::vector< MailItemInfo > MailItemInfoVec
Definition Mail.h:164
@ MAIL_CHECK_MASK_RETURNED
Definition Mail.h:48
Definition Player.h:1084
Seconds GetGameTime()
Definition GameTime.cpp:38
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition ObjectAccessor.cpp:251
Definition Mail.h:160
ObjectGuid::LowType item_guid
Definition Mail.h:161
uint32 item_template
Definition Mail.h:162
Definition Mail.h:167
bool IsSentByGM() const
Definition Mail.h:208
bool IsCODPayment() const
Definition Mail.h:209
ObjectGuid::LowType receiver
Definition Mail.h:173
uint8 messageType
Definition Mail.h:169
bool IsSentByPlayer() const
Definition Mail.h:207
uint32 messageID
Definition Mail.h:168
time_t expire_time
Definition Mail.h:178
uint32 sender
Definition Mail.h:172
uint8 stationery
Definition Mail.h:170
std::vector< MailItemInfo > items
Definition Mail.h:176
time_t deliver_time
Definition Mail.h:179
bool IsReturnedMail() const
Definition Mail.h:210
uint32 checked
Definition Mail.h:182
uint16 mailTemplateId
Definition Mail.h:171

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, Player, Mail::receiver, sCharacterCache, Mail::sender, PreparedStatementBase::SetData(), and Mail::stationery.

◆ SetCreatureLinkedRespawn()

bool ObjectMgr::SetCreatureLinkedRespawn ( ObjectGuid::LowType  guid,
ObjectGuid::LowType  linkedGuid 
)
2104{
2105 if (!guidLow)
2106 return false;
2107
2108 CreatureData const* master = GetCreatureData(guidLow);
2109 ObjectGuid guid = ObjectGuid::Create<HighGuid::Unit>(master->id1, guidLow);
2110
2111 if (!linkedGuidLow) // we're removing the linking
2112 {
2113 _linkedRespawnStore.erase(guid);
2115 stmt->SetData(0, guidLow);
2116 WorldDatabase.Execute(stmt);
2117 return true;
2118 }
2119
2120 CreatureData const* slave = GetCreatureData(linkedGuidLow);
2121 if (!slave)
2122 {
2123 LOG_ERROR("sql.sql", "Creature '{}' linking to non-existent creature '{}'.", guidLow, linkedGuidLow);
2124 return false;
2125 }
2126
2127 MapEntry const* map = sMapStore.LookupEntry(master->mapid);
2128 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2129 {
2130 LOG_ERROR("sql.sql", "Creature '{}' linking to '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2131 return false;
2132 }
2133
2134 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2135 {
2136 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2137 return false;
2138 }
2139
2140 ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, linkedGuidLow);
2141
2142 _linkedRespawnStore[guid] = linkedGuid;
2144 stmt->SetData(0, guidLow);
2145 stmt->SetData(1, linkedGuidLow);
2146 WorldDatabase.Execute(stmt);
2147 return true;
2148}
@ 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, SpawnData::mapid, PreparedStatementBase::SetData(), sMapStore, SpawnData::spawnMask, WORLD_DEL_CRELINKED_RESPAWN, WORLD_REP_CREATURE_LINKED_RESPAWN, and WorldDatabase.

◆ SetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ SetHighestGuids()

void ObjectMgr::SetHighestGuids ( )
7628{
7629 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
7630 if (result)
7631 GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].Get<uint32>() + 1);
7632
7633 result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
7634 if (result)
7635 GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].Get<uint32>() + 1);
7636
7637 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
7638 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7639 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7640 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7641 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7642
7643 result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
7644 if (result)
7645 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
7646
7647 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
7648 if (result)
7649 _auctionId = (*result)[0].Get<uint32>() + 1;
7650
7651 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
7652 if (result)
7653 _mailId = (*result)[0].Get<uint32>() + 1;
7654
7655 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
7656 if (result)
7657 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
7658
7659 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
7660 if (result)
7661 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
7662
7663 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
7664 if (result)
7665 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
7666
7667 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
7668 if (result)
7669 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
7670
7671 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
7672 if (result)
7673 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
7674
7675 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
7676 if (result)
7677 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
7678}
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sGuildMgr
Definition GuildMgr.h:51

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

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
6333{
6334 uint32 oldMSTime = getMSTime();
6335
6336 if (_spellScriptsStore.empty())
6337 {
6338 LOG_INFO("server.loading", ">> Validated 0 scripts.");
6339 LOG_INFO("server.loading", " ");
6340 return;
6341 }
6342
6343 uint32 count = 0;
6344
6345 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
6346 {
6347 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
6348 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
6349 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
6350 itr = _spellScriptsStore.upper_bound(itr->first);
6351
6352 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
6353 {
6354 SpellScript* spellScript = sitr->first->GetSpellScript();
6355 AuraScript* auraScript = sitr->first->GetAuraScript();
6356 bool valid = true;
6357 if (!spellScript && !auraScript)
6358 {
6359 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
6360 valid = false;
6361 }
6362 if (spellScript)
6363 {
6364 spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
6365 spellScript->_Register();
6366 if (!spellScript->_Validate(spellInfo))
6367 valid = false;
6368 delete spellScript;
6369 }
6370 if (auraScript)
6371 {
6372 auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
6373 auraScript->_Register();
6374 if (!auraScript->_Validate(spellInfo))
6375 valid = false;
6376 delete auraScript;
6377 }
6378 if (!valid)
6379 {
6380 _spellScriptsStore.erase(sitr->second);
6381 }
6382 }
6383 ++count;
6384 }
6385
6386 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6387 LOG_INFO("server.loading", " ");
6388}
Definition SpellScript.h:518
bool _Validate(SpellInfo const *entry) override
Definition SpellScript.cpp:662
std::string const & GetScriptName(uint32 id) const
Definition ObjectMgr.cpp:10493
Definition SpellScript.h:182
bool _Validate(SpellInfo const *entry) override
Definition SpellScript.cpp:316
virtual void _Register()
Definition SpellScript.cpp:45
virtual void _Init(std::string const *scriptname, uint32 spellId)
Definition SpellScript.cpp:59

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 Symbol 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().

◆ _breadcrumbsForQuest

BreadcrumbQuestMap ObjectMgr::_breadcrumbsForQuest

◆ _broadcastTextStore

BroadcastTextContainer ObjectMgr::_broadcastTextStore
private

◆ _cacheVendorItemStore

◆ _classTrainers

std::unordered_map<uint8, std::vector<Trainer::Trainer const*> > ObjectMgr::_classTrainers
private

Referenced by GetClassTrainers(), and LoadTrainers().

◆ _creatureAddonStore

CreatureAddonContainer ObjectMgr::_creatureAddonStore
private

◆ _creatureBaseStatsStore

CreatureBaseStatsContainer ObjectMgr::_creatureBaseStatsStore
private

◆ _creatureCustomIDsStore

CreatureCustomIDsContainer ObjectMgr::_creatureCustomIDsStore
private

◆ _creatureDataStore

◆ _creatureDefaultTrainers

std::unordered_map<uint32, uint32> ObjectMgr::_creatureDefaultTrainers
private

◆ _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

◆ _creatureSparringStore

CreatureSparringContainer ObjectMgr::_creatureSparringStore
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 GetGridObjectGuids().

◆ _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

◆ _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

◆ _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().

◆ _goSummonDataStore

GameObjectSummonDataContainer ObjectMgr::_goSummonDataStore
private

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

Referenced by GetGameObjectSummonGroup(), and LoadGameObjectSummons().

◆ _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

std::vector<std::vector<PlayerInfo*> > ObjectMgr::_playerInfo
private

◆ _playerShapeshiftModel

PlayerShapeshiftModelMap ObjectMgr::_playerShapeshiftModel
private

◆ _playerTotemModel

PlayerTotemModelMap ObjectMgr::_playerTotemModel
private

◆ _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

◆ _spawnGroupDataStore

◆ _spawnGroupMapStore

SpawnGroupLinkContainer ObjectMgr::_spawnGroupMapStore
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().

◆ _trainers

std::unordered_map<uint32, Trainer::Trainer> ObjectMgr::_trainers
private

Referenced by GetTrainer(), and LoadTrainers().

◆ _transportMaps

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

◆ _vehicleAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleAccessoryStore
private

◆ _vehicleSeatAddonStore

VehicleSeatAddonContainer ObjectMgr::_vehicleSeatAddonStore
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().


The documentation for this class was generated from the following files: