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, AreaTrigger > AreaTriggerContainer
 
typedef std::unordered_map< uint32, AreaTriggerTeleport > AreaTriggerTeleportContainer
 
typedef std::unordered_map< uint32, uint32 > AreaTriggerScriptContainer
 
typedef std::unordered_map< uint32, std::unordered_map< uint8, DungeonProgressionRequirements * > > DungeonProgressionRequirementsContainer
 
typedef std::unordered_map< uint32, RepRewardRate > RepRewardRateContainer
 
typedef std::unordered_map< uint32, ReputationOnKillEntry > RepOnKillContainer
 
typedef std::unordered_map< uint32, RepSpilloverTemplate > RepSpilloverTemplateContainer
 
typedef std::unordered_map< uint32, PointOfInterest > PointOfInterestContainer
 
typedef std::vector< std::string > ScriptNameContainer
 
typedef std::map< uint32, uint32 > CharacterConversionMap
 
typedef std::unordered_map< ObjectGuid::LowType, std::vector< float > > CreatureSparringContainer
 
typedef std::multimap< int32, uint32 > ExclusiveQuestGroups
 
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
 
AreaTriggerTeleportContainer const & GetAllAreaTriggerTeleports () 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 ()
 
QuestRelations * GetGOQuestRelationMap ()
 
QuestRelations * GetGOQuestInvolvedRelationMap ()
 
QuestRelationBounds GetGOQuestRelationBounds (uint32 go_entry)
 
QuestRelationBounds GetGOQuestInvolvedRelationBounds (uint32 go_entry)
 
QuestRelations * GetCreatureQuestRelationMap ()
 
QuestRelations * GetCreatureQuestInvolvedRelationMap ()
 
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
 
CreatureBaseStats const * GetCreatureBaseStats (uint8 level, uint8 unitClass)
 
void SetHighestGuids ()
 
template<HighGuid type>
ObjectGuidGeneratorBase & GetGenerator ()
 
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
 
CreatureData & NewOrExistCreatureData (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
 
GameObjectData & NewGOData (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)
 
void LoadChatFilter ()
 
bool IsChatFiltered (std::string_view text) const
 
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::Trainer * GetTrainer (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 ()
 
ScriptNameContainer & GetScriptNames ()
 
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 ObjectMgr * instance ()
 
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 (std::vector< std::string > const &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, GossipText > GossipTextContainer
 
typedef std::unordered_map< uint32, uint32 > QuestAreaTriggerContainer
 
typedef std::unordered_map< uint32, uint32 > TavernAreaTriggerContainer
 
typedef std::set< std::wstring > ReservedNamesContainer
 
typedef std::set< std::wstring > ProfanityNamesContainer
 
typedef std::map< uint32, PetLevelInfo * > PetLevelInfoContainer
 
typedef std::vector< uint32 > PlayerXPperLevel
 
typedef std::map< uint32, uint32 > BaseXPContainer
 
typedef std::map< uint32, int32 > FishingBaseSkillContainer
 
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, ItemSetNameEntry > ItemSetNameContainer
 

Private Member Functions

 ObjectMgr ()
 
 ~ObjectMgr ()
 
template<HighGuid high>
ObjectGuidGeneratorBase & GetGuidSequenceGenerator ()
 
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
 
std::unique_ptr< Acore::AhoCorasick< wchar_t > > _chatFilterAutomaton
 
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< GameobjectInstanceSavedState > GameobjectInstanceSavedStateList
 

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 
1707 {
1709 CREATURE_TO_GO, // Creature is dependant on GO
1710 GO_TO_GO,
1711 GO_TO_CREATURE, // GO is dependant on creature
1712 };
@ CREATURE_TO_GO
Definition ObjectMgr.h:1709
@ CREATURE_TO_CREATURE
Definition ObjectMgr.h:1708
@ GO_TO_GO
Definition ObjectMgr.h:1710
@ GO_TO_CREATURE
Definition ObjectMgr.h:1711

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:126
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:1673
ObjectGuid::LowType _gameObjectSpawnId
Definition ObjectMgr.h:1540
uint32 _mailId
Definition ObjectMgr.h:1534
ObjectGuid::LowType _creatureSpawnId
Definition ObjectMgr.h:1539
LocaleConstant DBCLocaleIndex
Definition ObjectMgr.h:1610
PlayerClassInfo * _playerClassInfo[MAX_CLASSES]
Definition ObjectMgr.h:1630
uint64 _equipmentSetGuid
Definition ObjectMgr.h:1533
uint32 _auctionId
Definition ObjectMgr.h:1532
uint32 _hiPetNumber
Definition ObjectMgr.h:1536

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:1634
PetLevelInfoContainer _petInfoStore
Definition ObjectMgr.h:1628
QuestMap _questTemplates
Definition ObjectMgr.h:1555
DungeonProgressionRequirementsContainer _accessRequirementStore
Definition ObjectMgr.h:1569
DungeonEncounterContainer _dungeonEncounterStore
Definition ObjectMgr.h:1570
CacheVendorItemContainer _cacheVendorItemStore
Definition ObjectMgr.h:1698
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 
)
2784{
2785 uint8 mask = data->spawnMask;
2786 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2787 {
2788 if (mask & 1)
2789 {
2790 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2791 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2792 cell_guids.creatures.insert(guid);
2793 }
2794 }
2795}
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition ObjectDefines.h:88
MapObjectGuids _mapObjectGuidsStore
Definition ObjectMgr.h:1655
GridCoord ComputeGridCoord(float x, float y)
Definition GridDefines.h:185
Definition ObjectMgr.h:481
CellGuidSet creatures
Definition ObjectMgr.h:482
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 
)
2865{
2866 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2867 if (!cInfo)
2868 return 0;
2869
2870 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2871 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2872 Map* map = sMapMgr->CreateBaseMap(mapId);
2873 if (!map)
2874 return 0;
2875
2877 CreatureData& data = NewOrExistCreatureData(spawnId);
2878 data.spawnId = spawnId;
2879 data.spawnMask = spawnId;
2880 data.id = entry;
2881 data.id2 = 0;
2882 data.id3 = 0;
2883 data.mapid = mapId;
2884 data.displayid = 0;
2885 data.equipmentId = 0;
2886 data.posX = x;
2887 data.posY = y;
2888 data.posZ = z;
2889 data.orientation = o;
2890 data.spawntimesecs = spawntimedelay;
2891 data.wander_distance = 0;
2892 data.currentwaypoint = 0;
2893 data.curhealth = stats->GenerateHealth(cInfo);
2894 data.curmana = stats->GenerateMana(cInfo);
2895 data.movementType = cInfo->MovementType;
2896 data.spawnMask = 1;
2898 data.dbData = false;
2899 data.npcflag = cInfo->npcflag;
2900 data.unit_flags = cInfo->unit_flags;
2901 data.dynamicflags = cInfo->dynamicflags;
2902
2903 AddCreatureToGrid(spawnId, &data);
2904
2905 // Spawn if necessary (loaded grids only)
2906 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2907 {
2908 Creature* creature = new Creature();
2909 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
2910 {
2911 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2912 delete creature;
2913 return 0;
2914 }
2915 }
2916
2917 return spawnId;
2918}
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:64
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:1694
Definition Map.h:168
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:206
bool Instanceable() const
Definition Map.h:298
uint32 LowType
Definition ObjectGuid.h:125
CreatureBaseStats const * GetCreatureBaseStats(uint8 level, uint8 unitClass)
Definition ObjectMgr.cpp:10695
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2783
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition ObjectMgr.cpp:7683
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition ObjectMgr.h:1245
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition ObjectMgr.cpp:11060
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 id
Definition CreatureData.h:372
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
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::id, 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 
)
3236{
3237 uint8 mask = data->spawnMask;
3238 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
3239 {
3240 if (mask & 1)
3241 {
3242 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
3243 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
3244 cell_guids.gameobjects.insert(guid);
3245 }
3246 }
3247}
CellGuidSet gameobjects
Definition ObjectMgr.h:483

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)
9865{
9866 // find max id
9867 uint32 new_id = 0;
9868 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9869 if (itr->first > new_id)
9870 new_id = itr->first;
9871
9872 // use next
9873 ++new_id;
9874
9875 if (!Utf8toWStr(tele.name, tele.wnameLow))
9876 return false;
9877
9878 wstrToLower(tele.wnameLow);
9879
9880 _gameTeleStore[new_id] = tele;
9881
9883
9884 stmt->SetData(0, new_id);
9885 stmt->SetData(1, tele.position_x);
9886 stmt->SetData(2, tele.position_y);
9887 stmt->SetData(3, tele.position_z);
9888 stmt->SetData(4, tele.orientation);
9889 stmt->SetData(5, uint16(tele.mapId));
9890 stmt->SetData(6, tele.name);
9891
9892 WorldDatabase.Execute(stmt);
9893
9894 return true;
9895}
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:42
GameTeleContainer _gameTeleStore
Definition ObjectMgr.h:1598
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 
)
2812{
2813 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2814 if (!goinfo)
2815 return 0;
2816
2817 Map* map = sMapMgr->CreateBaseMap(mapId);
2818 if (!map)
2819 return 0;
2820
2822
2823 GameObjectData& data = NewGOData(spawnId);
2824 data.spawnId = spawnId;
2825 data.id = entry;
2826 data.mapid = mapId;
2827 data.posX = x;
2828 data.posY = y;
2829 data.posZ = z;
2830 data.orientation = o;
2831 data.rotation.x = rotation0;
2832 data.rotation.y = rotation1;
2833 data.rotation.z = rotation2;
2834 data.rotation.w = rotation3;
2835 data.spawntimesecs = spawntimedelay;
2836 data.animprogress = 100;
2837 data.spawnMask = 1;
2838 data.go_state = GO_STATE_READY;
2840 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2841 data.dbData = false;
2842 data.spawnGroupId = 0;
2843
2844 AddGameobjectToGrid(spawnId, &data);
2845
2846 // Spawn if necessary (loaded grids only)
2847 // We use spawn coords to spawn
2848 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2849 {
2851 if (!go->LoadGameObjectFromDB(spawnId, map))
2852 {
2853 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2854 delete go;
2855 return 0;
2856 }
2857 }
2858
2859 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2860
2861 return spawnId;
2862}
@ 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:125
virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition GameObject.cpp:1201
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:3235
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition ObjectMgr.cpp:11036
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition ObjectMgr.cpp:7693
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition ObjectMgr.h:1360
bool IsGameObjectStaticTransport(uint32 entry)
Definition ObjectMgr.cpp:11045
Definition Transport.h:120
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)
9148{
9149 if (!IsProfanityName(name))
9150 {
9151 std::wstring wstr;
9152 if (!Utf8toWStr(name, wstr))
9153 {
9154 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
9155 return;
9156 }
9157 wstrToLower(wstr);
9158
9159 _profanityNamesStore.insert(wstr);
9160
9162 stmt->SetData(0, name);
9163 CharacterDatabase.Execute(stmt);
9164 }
9165}
@ CHAR_INS_PROFANITY_PLAYER_NAME
Definition CharacterDatabase.h:530
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
ProfanityNamesContainer _profanityNamesStore
Definition ObjectMgr.h:1593
bool IsProfanityName(std::string_view name) const
Definition ObjectMgr.cpp:9132

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

◆ AddReservedPlayerName()

void ObjectMgr::AddReservedPlayerName ( std::string const &  name)
9045{
9046 if (!IsReservedName(name))
9047 {
9048 std::wstring wstr;
9049 if (!Utf8toWStr(name, wstr))
9050 {
9051 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
9052 return;
9053 }
9054 wstrToLower(wstr);
9055
9056 _reservedNamesStore.insert(wstr);
9057
9059 stmt->SetData(0, name);
9060 CharacterDatabase.Execute(stmt);
9061 }
9062}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition CharacterDatabase.h:529
bool IsReservedName(std::string_view name) const
Definition ObjectMgr.cpp:9029
ReservedNamesContainer _reservedNamesStore
Definition ObjectMgr.h:1589

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 
)
10373{
10374 VendorItemData& vList = _cacheVendorItemStore[entry];
10375 vList.AddItem(item, maxcount, incrtime, extendedCost);
10376
10377 if (persist)
10378 {
10380
10381 stmt->SetData(0, entry);
10382 stmt->SetData(1, item);
10383 stmt->SetData(2, maxcount);
10384 stmt->SetData(3, incrtime);
10385 stmt->SetData(4, extendedCost);
10386
10387 WorldDatabase.Execute(stmt);
10388 }
10389}
@ WORLD_INS_NPC_VENDOR
Definition WorldDatabase.h:44
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
5006{
5007 // base data (last known level)
5008 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
5009
5010 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
5011 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
5012 {
5013 switch (_class)
5014 {
5015 case CLASS_WARRIOR:
5016 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
5017 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
5018 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
5019 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5020 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5021 break;
5022 case CLASS_PALADIN:
5023 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
5024 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
5025 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
5026 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
5027 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
5028 break;
5029 case CLASS_HUNTER:
5030 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
5031 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
5032 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
5033 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
5034 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
5035 break;
5036 case CLASS_ROGUE:
5037 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
5038 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
5039 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
5040 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
5041 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
5042 break;
5043 case CLASS_PRIEST:
5044 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5045 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
5046 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
5047 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
5048 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
5049 break;
5050 case CLASS_SHAMAN:
5051 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
5052 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
5053 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
5054 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
5055 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
5056 break;
5057 case CLASS_MAGE:
5058 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5059 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
5060 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5061 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
5062 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
5063 break;
5064 case CLASS_WARLOCK:
5065 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5066 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
5067 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
5068 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
5069 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
5070 break;
5071 case CLASS_DRUID:
5072 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
5073 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
5074 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
5075 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
5076 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
5077 }
5078 }
5079}
@ 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:337

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 
)
9684{
9685 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
9686 if (!fArea)
9687 {
9688 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
9689 return;
9690 }
9691
9692 _fishingBaseForAreaStore[entry] = skill;
9693
9694 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
9695 LOG_INFO("server.loading", " ");
9696}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define LOG_INFO(filterType__,...)
Definition Log.h:153
FishingBaseSkillContainer _fishingBaseForAreaStore
Definition ObjectMgr.h:1643
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:847
@ UNIT_NPC_FLAG_GOSSIP
Definition UnitDefines.h:322
#define BASE_ATTACK_TIME
Definition Unit.h:42
static constexpr uint32 MAX_CREATURE_SPELLS
Definition Unit.h:46
Models
Definition boss_black_knight.cpp:79
spells
Definition boss_krystallus.cpp:26
static float _GetDamageMod(int32 Rank)
Definition Creature.cpp:1594
std::set< uint32 > _difficultyEntries[MAX_DIFFICULTY - 1]
Definition ObjectMgr.h:1703
CreatureCustomIDsContainer _creatureCustomIDsStore
Definition ObjectMgr.h:1660
std::set< uint32 > _hasDifficultyEntries[MAX_DIFFICULTY - 1]
Definition ObjectMgr.h:1704
void CheckCreatureMovement(char const *table, uint64 id, CreatureMovementData &creatureMovement)
Definition ObjectMgr.cpp:1235
Definition CreatureData.h:170
Definition DBCStructure.h:837
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:975
Definition DBCStructure.h:2063

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
9699{
9700 // get main part of the name
9701 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
9702 // prepare flags
9703 bool x = true;
9704 bool y = true;
9705
9706 // check declined names
9707 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
9708 {
9709 std::wstring wname;
9710 if (!Utf8toWStr(names.name[i], wname))
9711 return false;
9712
9713 if (mainpart != GetMainPartOfName(wname, i + 1))
9714 x = false;
9715
9716 if (w_ownname != wname)
9717 y = false;
9718 }
9719 return (x || y);
9720}
#define MAX_DECLINED_NAME_CASES
Definition Unit.h:549
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
9387{
9388 std::wstring wname;
9389 if (!Utf8toWStr(name, wname))
9390 return PET_NAME_INVALID;
9391
9392 if (wname.size() > MAX_PET_NAME)
9393 return PET_NAME_TOO_LONG;
9394
9395 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
9396 if (wname.size() < minName)
9397 return PET_NAME_TOO_SHORT;
9398
9399 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
9400 if (!isValidString(wname, strictMask, false))
9402
9403 // Check Reserved Name
9404 if (sObjectMgr->IsReservedName(name))
9405 return PET_NAME_RESERVED;
9406
9407 // Check Profanity Name
9408 if (sObjectMgr->IsProfanityName(name))
9409 return PET_NAME_PROFANE;
9410
9411 return PET_NAME_SUCCESS;
9412}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition ObjectMgr.cpp:9271
#define sObjectMgr
Definition ObjectMgr.h:1731
#define MAX_PET_NAME
Definition ObjectMgr.h:689
@ 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(), and pet_commandscript::HandlePetRenameCommand().

◆ CheckPlayerName()

uint8 ObjectMgr::CheckPlayerName ( std::string_view  name,
bool  create = false 
)
static
9308{
9309 std::wstring wname;
9310
9311 // Check for invalid characters
9312 if (!Utf8toWStr(name, wname))
9314
9315 // Check for too long name
9316 if (wname.size() > MAX_PLAYER_NAME)
9317 return CHAR_NAME_TOO_LONG;
9318
9319 // Check for too short name
9320 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
9321 if (wname.size() < minName)
9322 return CHAR_NAME_TOO_SHORT;
9323
9324 // Check for mixed languages
9325 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
9326 if (!isValidString(wname, strictMask, false, create))
9328
9329 // Check for three consecutive letters
9330 wstrToLower(wname);
9331 for (std::size_t i = 2; i < wname.size(); ++i)
9332 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
9334
9335 // Check Reserved Name
9336 if (sObjectMgr->IsReservedName(name))
9337 return CHAR_NAME_RESERVED;
9338
9339 // Check Profanity Name
9340 if (sObjectMgr->IsProfanityName(name))
9341 return CHAR_NAME_PROFANE;
9342
9343 return CHAR_NAME_SUCCESS;
9344}
#define MAX_PLAYER_NAME
Definition ObjectMgr.h:687
@ 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)
8661{
8662 // remove mapid*cellid -> guid_set map
8663 CreatureData const* data = GetCreatureData(guid);
8664 if (data)
8665 RemoveCreatureFromGrid(guid, data);
8666
8667 _creatureDataStore.erase(guid);
8668}
CreatureDataContainer _creatureDataStore
Definition ObjectMgr.h:1658
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2797
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1236

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

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
9898{
9899 // explicit name case
9900 std::wstring wname;
9901 if (!Utf8toWStr(name, wname))
9902 return false;
9903
9904 // converting string that we try to find to lower case
9905 wstrToLower(wname);
9906
9907 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9908 {
9909 if (itr->second.wnameLow == wname)
9910 {
9912
9913 stmt->SetData(0, itr->second.name);
9914
9915 WorldDatabase.Execute(stmt);
9916
9917 _gameTeleStore.erase(itr);
9918 return true;
9919 }
9920 }
9921
9922 return false;
9923}
@ WORLD_DEL_GAME_TELE
Definition WorldDatabase.h:43

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

◆ DeleteGOData()

void ObjectMgr::DeleteGOData ( ObjectGuid::LowType  guid)
8671{
8672 // remove mapid*cellid -> guid_set map
8673 GameObjectData const* data = GetGameObjectData(guid);
8674 if (data)
8675 RemoveGameobjectFromGrid(guid, data);
8676
8677 _gameObjectDataStore.erase(guid);
8678}
GameObjectData const * GetGameObjectData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1271
GameObjectDataContainer _gameObjectDataStore
Definition ObjectMgr.h:1672
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:3249

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

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
7653{
7654 if (_auctionId >= 0xFFFFFFFE)
7655 {
7656 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
7658 }
7659 return _auctionId++;
7660}
static void StopNow(uint8 exitcode)
Definition World.h:195
@ ERROR_EXIT_CODE
Definition World.h:54

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

◆ GenerateCreatureSpawnId()

uint32 ObjectMgr::GenerateCreatureSpawnId ( )
7684{
7685 if (_creatureSpawnId >= uint32(0xFFFFFF))
7686 {
7687 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7689 }
7690 return _creatureSpawnId++;
7691}

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

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
7663{
7664 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
7665 {
7666 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
7668 }
7669 return _equipmentSetGuid++;
7670}
std::uint64_t uint64
Definition Define.h:106

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

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7694{
7695 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7696 {
7697 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7699 }
7700 return _gameObjectSpawnId++;
7701}

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

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
7673{
7674 if (_mailId >= 0xFFFFFFFE)
7675 {
7676 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
7678 }
7679 std::lock_guard<std::mutex> guard(_mailIdMutex);
7680 return _mailId++;
7681}
std::mutex _mailIdMutex
Definition ObjectMgr.h:1535

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

◆ GeneratePetName()

std::string ObjectMgr::GeneratePetName ( uint32  entry)
8160{
8161 std::vector<std::string>& list0 = _petHalfName0[entry];
8162 std::vector<std::string>& list1 = _petHalfName1[entry];
8163
8164 if (list0.empty() || list1.empty())
8165 {
8166 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
8167 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
8168 if (!petname)
8169 return cinfo->Name;
8170
8171 return std::string(petname);
8172 }
8173
8174 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
8175}
char const * GetPetName(uint32 petfamily, uint32 dbclang)
Definition DBCStores.cpp:677
HalfNameContainer _petHalfName1
Definition ObjectMgr.h:1647
HalfNameContainer _petHalfName0
Definition ObjectMgr.h:1646
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 
)
8147{
8148 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
8149 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
8150
8151 if (list0.empty() || list1.empty())
8152 {
8153 return GeneratePetName(entry);
8154 }
8155
8156 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
8157}
HalfNameContainerLocale _petHalfLocaleName0
Definition ObjectMgr.h:1649
HalfNameContainerLocale _petHalfLocaleName1
Definition ObjectMgr.h:1650
std::string GeneratePetName(uint32 entry)
Definition ObjectMgr.cpp:8159

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

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
8178{
8179 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
8180 return ++_hiPetNumber;
8181}
std::mutex _hiPetNumberMutex
Definition ObjectMgr.h:1537

References _hiPetNumber, and _hiPetNumberMutex.

◆ GetAccessRequirement()

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

References _accessRequirementStore.

◆ GetAcoreString() [1/2]

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

References _acoreStringStore.

Referenced by GetAcoreString(), and GetAcoreStringForDBCLocale().

◆ GetAcoreString() [2/2]

std::string ObjectMgr::GetAcoreString ( uint32  entry,
LocaleConstant  locale 
) const
9630{
9631 AcoreString const* as = GetAcoreString(entry);
9632 if (as && !as->Content.empty())
9633 {
9634 if (as->Content.size() > std::size_t(locale) && !as->Content[locale].empty())
9635 return as->Content[locale];
9636
9637 return as->Content[DEFAULT_LOCALE];
9638 }
9639
9640 std::string msg = Acore::StringFormat("No entry for acore_string ({}) in DB.", entry);
9641 LOG_ERROR("sql.sql", msg);
9642 return msg;
9643}
#define DEFAULT_LOCALE
Definition Common.h:140
AcoreString const * GetAcoreString(uint32 entry) const
Definition ObjectMgr.h:1389
std::string StringFormat(FormatStringView fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:44
Definition ObjectMgr.h:504
std::vector< std::string > Content
Definition ObjectMgr.h:505

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

◆ GetAcoreStringForDBCLocale()

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

References DBCLocaleIndex, and GetAcoreString().

◆ GetAllAreaTriggerScriptData()

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

References _areaTriggerScriptStore.

◆ GetAllAreaTriggerTeleports()

AreaTriggerTeleportContainer const & ObjectMgr::GetAllAreaTriggerTeleports ( ) const
inline
AreaTriggerTeleportContainer _areaTriggerTeleportStore
Definition ObjectMgr.h:1567

References _areaTriggerTeleportStore.

◆ GetAllCreatureData()

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

References _creatureDataStore.

◆ GetAllGOData()

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

References _gameObjectDataStore.

◆ GetAreaTrigger()

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

References _areaTriggerStore.

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

◆ GetAreaTriggerScriptId()

uint32 ObjectMgr::GetAreaTriggerScriptId ( uint32  trigger_id)
9723{
9724 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
9725 if (i != _areaTriggerScriptStore.end())
9726 return i->second;
9727 return 0;
9728}

References _areaTriggerScriptStore.

◆ GetAreaTriggerTeleport()

AreaTriggerTeleport const * ObjectMgr::GetAreaTriggerTeleport ( uint32  trigger) const
inline
878 {
879 AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.find(trigger);
880 if (itr != _areaTriggerTeleportStore.end())
881 return &itr->second;
882 return nullptr;
883 }

References _areaTriggerTeleportStore.

◆ GetBaseReputationOf()

int32 ObjectMgr::GetBaseReputationOf ( FactionEntry const *  factionEntry,
uint8  race,
uint8  playerClass 
)
9737{
9738 if (!factionEntry)
9739 return 0;
9740
9741 uint32 raceMask = (1 << (race - 1));
9742 uint32 classMask = (1 << (playerClass - 1));
9743
9744 for (int i = 0; i < 4; i++)
9745 {
9746 if ((!factionEntry->BaseRepClassMask[i] ||
9747 factionEntry->BaseRepClassMask[i] & classMask) &&
9748 (!factionEntry->BaseRepRaceMask[i] ||
9749 factionEntry->BaseRepRaceMask[i] & raceMask))
9750 return factionEntry->BaseRepValue[i];
9751 }
9752
9753 return 0;
9754}

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

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
8088{
8089 return _baseXPTable[level] ? _baseXPTable[level] : 0;
8090}
BaseXPContainer _baseXPTable
Definition ObjectMgr.h:1640

References _baseXPTable.

◆ GetBreadcrumbsForQuest()

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

References _breadcrumbsForQuest.

◆ GetBroadcastText()

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

References _broadcastTextStore.

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

◆ GetClassTrainers()

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

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:1663

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
10696{
10697 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
10698
10699 if (it != _creatureBaseStatsStore.end())
10700 return &(it->second);
10701
10702 struct DefaultCreatureBaseStats : public CreatureBaseStats
10703 {
10704 DefaultCreatureBaseStats()
10705 {
10706 BaseArmor = 1;
10707 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
10708 {
10709 BaseHealth[j] = 1;
10710 BaseDamage[j] = 0.0f;
10711 }
10712 BaseMana = 0;
10713 AttackPower = 0;
10714 RangedAttackPower = 0;
10715 Strength = 0;
10716 Agility = 0;
10717 Stamina = 0;
10718 Intellect = 0;
10719 Spirit = 0;
10720 }
10721 };
10722 static const DefaultCreatureBaseStats defStats;
10723 return &defStats;
10724}
uint16 MAKE_PAIR16(uint8 l, uint8 h)
Definition ObjectDefines.h:83
CreatureBaseStatsContainer _creatureBaseStatsStore
Definition ObjectMgr.h:1624

References _creatureBaseStatsStore, MAKE_PAIR16(), and MAX_EXPANSIONS.

Referenced by AddCreData().

◆ GetCreatureData()

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

References _creatureDataStore.

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

◆ GetCreatureLocale()

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

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:1662

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:1665
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
1015 {
1016 return _creatureQuestInvolvedRelations.equal_range(creature_entry);
1017 }
QuestRelations _creatureQuestInvolvedRelations
Definition ObjectMgr.h:1585

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestInvolvedRelationMap ( )
inline
1005 {
1007 }

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestItemList()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestItemMap()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestRelationBounds ( uint32  creature_entry)
inline
1010 {
1011 return _creatureQuestRelations.equal_range(creature_entry);
1012 }
QuestRelations _creatureQuestRelations
Definition ObjectMgr.h:1584

References _creatureQuestRelations.

◆ GetCreatureQuestRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestRelationMap ( )
inline
1000 {
1002 }

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:1664

References _creatureTemplateAddonStore.

◆ GetCreatureTemplates()

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

References _creatureTemplateStore.

Referenced by LoadCreatureClassLevelStats(), and LoadNPCSpellClickSpells().

◆ GetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ GetDefaultSpawnGroup()

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

References _spawnGroupDataStore.

◆ GetDungeonEncounterList()

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

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:1669

References _equipmentInfoStore, and urand().

Referenced by LoadCreatureDataFromDB(), and LoadCreatures().

◆ GetFishingBaseSkillLevel()

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

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:1666

References _gameObjectAddonStore.

◆ GetGameObjectData()

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

References _gameObjectDataStore.

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

◆ GetGameObjectLocale()

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

References _gameObjectLocaleStore.

◆ GetGameObjectQuestItemList()

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

References _gameObjectQuestItemStore.

◆ GetGameObjectQuestItemMap()

GameObjectQuestItemMap const * ObjectMgr::GetGameObjectQuestItemMap ( ) const
inline

◆ GetGameObjectSummonGroup()

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

References _goSummonDataStore.

◆ GetGameObjectTemplate()

GameObjectTemplate const * ObjectMgr::GetGameObjectTemplate ( uint32  entry)
11037{
11038 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
11039 if (itr != _gameObjectTemplateStore.end())
11040 return &(itr->second);
11041
11042 return nullptr;
11043}
GameObjectTemplateContainer _gameObjectTemplateStore
Definition ObjectMgr.h:1676

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
11052{
11053 auto itr = _gameObjectTemplateAddonStore.find(entry);
11054 if (itr != _gameObjectTemplateAddonStore.end())
11055 return &itr->second;
11056
11057 return nullptr;
11058}
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
Definition ObjectMgr.h:1677

References _gameObjectTemplateAddonStore.

◆ GetGameObjectTemplates()

GameObjectTemplateContainer const * ObjectMgr::GetGameObjectTemplates ( ) const
inline

◆ GetGameTele() [1/2]

GameTele const * ObjectMgr::GetGameTele ( std::string_view  name,
bool  exactSearch = false 
) const
9842{
9843 // explicit name case
9844 std::wstring wname;
9845 if (!Utf8toWStr(name, wname))
9846 return nullptr;
9847
9848 // converting string that we try to find to lower case
9849 wstrToLower(wname);
9850
9851 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
9852 GameTele const* alt = nullptr;
9853 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9854 {
9855 if (itr->second.wnameLow == wname)
9856 return &itr->second;
9857 else if (!exactSearch && !alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
9858 alt = &itr->second;
9859 }
9860
9861 return alt;
9862}
Definition ObjectMgr.h:135

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

◆ GetGameTele() [2/2]

GameTele const * ObjectMgr::GetGameTele ( uint32  id) const
inline
1435 {
1436 GameTeleContainer::const_iterator itr = _gameTeleStore.find(id);
1437 if (itr == _gameTeleStore.end()) return nullptr;
1438 return &itr->second;
1439 }

References _gameTeleStore.

◆ GetGameTeleMap()

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

References _gameTeleStore.

◆ GetGenerator()

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

◆ GetGoBackTrigger()

AreaTriggerTeleport const * ObjectMgr::GetGoBackTrigger ( uint32  Map) const
7538{
7539 bool useParentDbValue = false;
7540 uint32 parentId = 0;
7541 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
7542 if (!mapEntry || mapEntry->entrance_map < 0)
7543 return nullptr;
7544
7545 if (mapEntry->IsDungeon())
7546 {
7547 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
7548
7549 if (!iTemplate)
7550 return nullptr;
7551
7552 parentId = iTemplate->Parent;
7553 useParentDbValue = true;
7554 }
7555
7556 uint32 entrance_map = uint32(mapEntry->entrance_map);
7557 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
7558 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
7559 {
7560 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
7561 if (atEntry && atEntry->map == Map)
7562 return &itr->second;
7563 }
7564 return nullptr;
7565}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
AreaTrigger const * GetAreaTrigger(uint32 trigger) const
Definition ObjectMgr.h:868
Definition ObjectMgr.h:423
uint32 map
Definition ObjectMgr.h:425
Definition Map.h:126
uint32 Parent
Definition Map.h:127
Definition DBCStructure.h:1361
int32 entrance_map
Definition DBCStructure.h:1376
bool IsDungeon() const
Definition DBCStructure.h:1387

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

◆ GetGOQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestInvolvedRelationBounds ( uint32  go_entry)
inline
995 {
996 return _goQuestInvolvedRelations.equal_range(go_entry);
997 }
QuestRelations _goQuestInvolvedRelations
Definition ObjectMgr.h:1583

References _goQuestInvolvedRelations.

◆ GetGOQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetGOQuestInvolvedRelationMap ( )
inline
985 {
987 }

References _goQuestInvolvedRelations.

◆ GetGOQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestRelationBounds ( uint32  go_entry)
inline
990 {
991 return _goQuestRelations.equal_range(go_entry);
992 }
QuestRelations _goQuestRelations
Definition ObjectMgr.h:1582

References _goQuestRelations.

◆ GetGOQuestRelationMap()

QuestRelations * ObjectMgr::GetGOQuestRelationMap ( )
inline
980 {
981 return &_goQuestRelations;
982 }

References _goQuestRelations.

◆ GetGossipMenuItemsLocale()

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

References _gossipMenuItemsLocaleStore.

◆ GetGossipMenuItemsMapBounds()

GossipMenuItemsMapBounds ObjectMgr::GetGossipMenuItemsMapBounds ( uint32  uiMenuId) const
inline
1482 {
1483 return _gossipMenuItemsStore.equal_range(uiMenuId);
1484 }
GossipMenuItemsContainer _gossipMenuItemsStore
Definition ObjectMgr.h:1577

References _gossipMenuItemsStore.

◆ GetGossipMenuItemsMapBoundsNonConst()

GossipMenuItemsMapBoundsNonConst ObjectMgr::GetGossipMenuItemsMapBoundsNonConst ( uint32  uiMenuId)
inline
1486 {
1487 return _gossipMenuItemsStore.equal_range(uiMenuId);
1488 }

References _gossipMenuItemsStore.

◆ GetGossipMenusMapBounds()

GossipMenusMapBounds ObjectMgr::GetGossipMenusMapBounds ( uint32  uiMenuId) const
inline
1472 {
1473 return _gossipMenusStore.equal_range(uiMenuId);
1474 }
GossipMenusContainer _gossipMenusStore
Definition ObjectMgr.h:1576

References _gossipMenusStore.

◆ GetGossipMenusMapBoundsNonConst()

GossipMenusMapBoundsNonConst ObjectMgr::GetGossipMenusMapBoundsNonConst ( uint32  uiMenuId)
inline
1477 {
1478 return _gossipMenusStore.equal_range(uiMenuId);
1479 }

References _gossipMenusStore.

◆ GetGossipText()

GossipText const * ObjectMgr::GetGossipText ( uint32  Text_ID) const
6703{
6704 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
6705 if (itr != _gossipTextStore.end())
6706 return &itr->second;
6707 return nullptr;
6708}
GossipTextContainer _gossipTextStore
Definition ObjectMgr.h:1564

References _gossipTextStore.

Referenced by LoadGossipMenu().

◆ GetGridObjectGuids()

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

References _emptyCellObjectGuids, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & ObjectMgr::GetGuidSequenceGenerator ( )
inlineprivate
1545 {
1546 auto itr = _guidGenerators.find(high);
1547 if (itr == _guidGenerators.end())
1548 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
1549
1550 return *itr->second;
1551 }
Definition ObjectGuid.h:302
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition ObjectMgr.h:1553

References _guidGenerators.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
6609{
6610 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
6611 if (itr != _instanceTemplateStore.end())
6612 return &(itr->second);
6613
6614 return nullptr;
6615}
InstanceTemplateContainer _instanceTemplateStore
Definition ObjectMgr.h:1613

References _instanceTemplateStore.

◆ GetItemLocale()

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

References _itemLocaleStore.

◆ GetItemSetNameEntry()

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

References _itemSetNameStore.

◆ GetItemSetNameLocale()

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

References _itemSetNameLocaleStore.

◆ GetItemTemplate()

ItemTemplate const * ObjectMgr::GetItemTemplate ( uint32  entry)
3935{
3936 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3937}
std::vector< ItemTemplate * > _itemTemplateStoreFast
Definition ObjectMgr.h:1685

References _itemTemplateStoreFast.

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

◆ GetItemTemplateStore()

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

References _itemTemplateStore.

◆ GetItemTemplateStoreFast()

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

References _itemTemplateStoreFast.

◆ GetLegacySpawnGroup()

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

References _spawnGroupDataStore.

◆ GetLinkedRespawnGuid()

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

References _linkedRespawnStore, and ObjectGuid::Empty.

◆ GetLocaleString() [1/2]

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

◆ GetLocaleString() [2/2]

◆ GetMailLevelReward()

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

References _mailLevelRewardStore.

◆ GetMapEntranceTrigger()

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

Searches for the areatrigger which teleports players to the given map

7571{
7572 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
7573 {
7574 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
7575 {
7576 // xinef: no need to check, already done at loading
7577 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
7578 //if (atEntry)
7579 return &itr->second;
7580 }
7581 }
7582 return nullptr;
7583}

References _areaTriggerTeleportStore.

◆ GetMapObjectGuids()

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

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 // getGender() tracks the active display model; real gender lives in PLAYER_BYTES_3
1900
1901 auto itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), customizationID, gender));
1902 if (itr != _playerShapeshiftModel.end())
1903 return itr->second; // Explicit combination
1904
1905 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), customizationID, GENDER_NONE));
1906 if (itr != _playerShapeshiftModel.end())
1907 return itr->second; // Combination applied to both genders
1908
1909 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), 255, gender));
1910 if (itr != _playerShapeshiftModel.end())
1911 return itr->second; // Default gender-dependent model
1912
1913 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), 255, GENDER_NONE));
1914 if (itr != _playerShapeshiftModel.end())
1915 return itr->second; // Last resort
1916
1917 LOG_DEBUG("entities.player", "ShapeshiftForm {} with RaceID ({}) have no shapeshift model data defined, using fallback data.", form, player->getRace());
1918 return 0;
1919}
@ PLAYER_BYTES_3_OFFSET_GENDER
Definition Player.h:513
@ GENDER_NONE
Definition SharedDefines.h:63
@ TEAM_ALLIANCE
Definition SharedDefines.h:748
@ PLAYER_BYTES_3
Definition UpdateFields.h:183
@ PLAYER_BYTES
Definition UpdateFields.h:181
PlayerShapeshiftModelMap _playerShapeshiftModel
Definition ObjectMgr.h:1718
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:321
TeamId GetTeamId(bool original=false) const
Definition Player.h:2140
uint8 getRace(bool original=false) const
Definition Unit.cpp:16698

References _playerShapeshiftModel, GENDER_NONE, Object::GetByteValue(), Unit::getRace(), Player::GetTeamId(), LOG_DEBUG, PLAYER_BYTES, PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER, 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:1716

References _playerTotemModel, and LOG_ERROR.

◆ GetModuleString() [1/2]

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

References _moduleStringStore.

Referenced by GetModuleString().

◆ GetModuleString() [2/2]

std::string const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id,
LocaleConstant  locale 
) const
9564{
9565 ModuleString const* ms = GetModuleString(module, id);
9566 if (ms && !ms->Content.empty())
9567 {
9568 if (ms->Content.size() > size_t(locale) && !ms->Content[locale].empty())
9569 return &ms->Content[locale];
9570
9571 return &ms->Content[DEFAULT_LOCALE];
9572 }
9573
9574 LOG_ERROR("sql.sql", "Module string module {} id {} not found in DB.", module, id);
9575
9576 return (std::string*)"error";
9577}
ModuleString const * GetModuleString(std::string module, uint32 id) const
Definition ObjectMgr.h:1378
Definition ObjectMgr.h:499
std::vector< std::string > Content
Definition ObjectMgr.h:500

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 
)
7155{
7156 bool found = false;
7157 float dist = 10000;
7158 uint32 id = 0;
7159
7160 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
7161 {
7162 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
7163
7164 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
7165 continue;
7166
7167 uint8 field = (uint8)((i - 1) / 32);
7168 uint32 submask = 1 << ((i - 1) % 32);
7169
7170 // skip not taxi network nodes
7171 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
7172 {
7173 continue;
7174 }
7175
7176 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
7177 if (found)
7178 {
7179 if (dist2 < dist)
7180 {
7181 dist = dist2;
7182 id = i;
7183 }
7184 }
7185 else
7186 {
7187 found = true;
7188 dist = dist2;
7189 id = i;
7190 }
7191 }
7192
7193 return id;
7194}
TaxiMask sTaxiNodesMask
Definition DBCStores.cpp:180
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
static constexpr std::size_t TaxiMaskSize
Definition DBCStructure.h:2284
Definition DBCStructure.h:1989
float z
Definition DBCStructure.h:1994
uint32 map_id
Definition DBCStructure.h:1991
float x
Definition DBCStructure.h:1992
float y
Definition DBCStructure.h:1993
uint32 MountCreatureID[2]
Definition DBCStructure.h:1997

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 
)
7150{
7151 return GetNearestTaxiNode(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetMapId(), teamId);
7152}
uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 teamId)
Definition ObjectMgr.cpp:7154

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

◆ GetNpcTextLocale()

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

References _npcTextLocaleStore.

◆ GetNpcVendorItemList()

VendorItemData const * ObjectMgr::GetNpcVendorItemList ( uint32  entry) const
inline
1449 {
1450 CacheVendorItemContainer::const_iterator iter = _cacheVendorItemStore.find(entry);
1451 if (iter == _cacheVendorItemStore.end())
1452 return nullptr;
1453
1454 return &iter->second;
1455 }

References _cacheVendorItemStore.

Referenced by IsVendorItemValid().

◆ GetPageText()

PageText const * ObjectMgr::GetPageText ( uint32  pageEntry)
6525{
6526 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
6527 if (itr != _pageTextStore.end())
6528 return &(itr->second);
6529
6530 return nullptr;
6531}
PageTextContainer _pageTextStore
Definition ObjectMgr.h:1612

References _pageTextStore.

Referenced by LoadGameObjectTemplate(), and LoadItemTemplates().

◆ GetPageTextLocale()

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

References _pageTextLocaleStore.

◆ GetPetLevelInfo()

PetLevelInfo const * ObjectMgr::GetPetLevelInfo ( uint32  creature_id,
uint8  level 
) const
4301{
4302 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4303 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4304
4305 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
4306 if (itr == _petInfoStore.end())
4307 return nullptr;
4308
4309 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
4310}

References _petInfoStore, CONFIG_MAX_PLAYER_LEVEL, and sWorld.

◆ GetPlayerClassInfo()

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

References _playerClassInfo, and MAX_CLASSES.

◆ GetPlayerClassLevelInfo()

void ObjectMgr::GetPlayerClassLevelInfo ( uint32  class_,
uint8  level,
PlayerClassLevelInfo *  info 
) const
4978{
4979 if (level < 1 || class_ >= MAX_CLASSES)
4980 return;
4981
4982 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4983
4984 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4985 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4986
4987 *info = pInfo->levelInfo[level - 1];
4988}
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
11083{
11084 if (race >= sRaceMgr->GetMaxRaces())
11085 return nullptr;
11086 if (class_ >= MAX_CLASSES)
11087 return nullptr;
11088 PlayerInfo const* info = _playerInfo[race][class_];
11089 if (!info)
11090 return nullptr;
11091 return info;
11092}
Definition Player.h:322

References _playerInfo, MAX_CLASSES, and sRaceMgr.

◆ GetPlayerLevelInfo()

void ObjectMgr::GetPlayerLevelInfo ( uint32  race,
uint32  class_,
uint8  level,
PlayerLevelInfo *  info 
) const
4991{
4992 if (level < 1 || race >= sRaceMgr->GetMaxRaces() || class_ >= MAX_CLASSES)
4993 return;
4994
4995 PlayerInfo const* pInfo = _playerInfo[race][class_];
4996 if (!pInfo)
4997 return;
4998
4999 if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
5000 *info = pInfo->levelInfo[level - 1];
5001 else
5002 BuildPlayerLevelInfo(race, class_, level, info);
5003}
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
Definition ObjectMgr.cpp:5005
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
936 {
937 PointOfInterestContainer::const_iterator itr = _pointsOfInterestStore.find(id);
938 if (itr != _pointsOfInterestStore.end())
939 return &itr->second;
940 return nullptr;
941 }
PointOfInterestContainer _pointsOfInterestStore
Definition ObjectMgr.h:1578

References _pointsOfInterestStore.

Referenced by LoadGossipMenuItems().

◆ GetPointOfInterestLocale()

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

References _pointOfInterestLocaleStore.

◆ GetQuestForAreaTrigger()

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

References _questAreaTriggerStore.

◆ GetQuestGreeting()

QuestGreeting const * ObjectMgr::GetQuestGreeting ( TypeID  type,
uint32  id 
) const
6880{
6881 uint8 typeIndex;
6882 if (type == TYPEID_UNIT)
6883 typeIndex = 0;
6884 else if (type == TYPEID_GAMEOBJECT)
6885 typeIndex = 1;
6886 else
6887 return nullptr;
6888
6889 std::pair<uint32, uint8> pairKey = std::make_pair(id, typeIndex);
6890 QuestGreetingContainer::const_iterator itr = _questGreetingStore.find(pairKey);
6891 if (itr == _questGreetingStore.end())
6892 return nullptr;
6893
6894 return &itr->second;
6895}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:40
@ TYPEID_UNIT
Definition ObjectGuid.h:38
QuestGreetingContainer _questGreetingStore
Definition ObjectMgr.h:1565

References _questGreetingStore, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

◆ GetQuestLocale()

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

References _questLocaleStore.

◆ GetQuestMoneyReward()

uint32 ObjectMgr::GetQuestMoneyReward ( uint8  level,
uint32  questMoneyDifficulty 
) const
11219{
11220 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
11221 {
11222 auto const& itr = _questMoneyRewards.find(level);
11223 if (itr != _questMoneyRewards.end())
11224 {
11225 return itr->second.at(questMoneyDifficulty);
11226 }
11227 }
11228
11229 return 0;
11230}
static constexpr uint32 MAX_QUEST_MONEY_REWARDS
Definition ObjectMgr.h:723
QuestMoneyRewardStore _questMoneyRewards
Definition ObjectMgr.h:1720

References _questMoneyRewards, and MAX_QUEST_MONEY_REWARDS.

◆ GetQuestOfferRewardLocale()

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

References _questOfferRewardLocaleStore.

◆ GetQuestPOIVector()

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

References _questPOIStore.

◆ GetQuestRequestItemsLocale()

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

References _questRequestItemsLocaleStore.

◆ GetQuestTemplate()

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

References _questTemplatesFast.

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

◆ GetQuestTemplates()

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

References _questTemplates.

◆ GetRepRewardRate()

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

References _repRewardRateStore.

◆ GetRepSpilloverTemplate()

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

References _repSpilloverTemplateStore.

◆ GetReputationOnKilEntry()

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

References _repOnKillStore.

◆ GetScriptId()

uint32 ObjectMgr::GetScriptId ( std::string const &  name)
10556{
10557 // use binary search to find the script name in the sorted vector
10558 // assume "" is the first element
10559 if (name.empty())
10560 return 0;
10561
10562 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
10563 if (itr == _scriptNamesStore.end() || (*itr != name))
10564 return 0;
10565
10566 return uint32(itr - _scriptNamesStore.begin());
10567}
ScriptNameContainer _scriptNamesStore
Definition ObjectMgr.h:1600

References _scriptNamesStore.

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

◆ GetScriptName()

std::string const & ObjectMgr::GetScriptName ( uint32  id) const
10550{
10551 static std::string const empty = "";
10552 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
10553}

References _scriptNamesStore.

Referenced by ValidateSpellScripts().

◆ GetScriptNames()

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

References _scriptNamesStore.

◆ GetSparringData()

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

References _creatureSparringStore.

◆ GetSpawnData()

SpawnData const * ObjectMgr::GetSpawnData ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId 
) const
8681{
8682 switch (type)
8683 {
8685 return GetCreatureData(spawnId);
8687 return GetGameObjectData(spawnId);
8688 default:
8689 return nullptr;
8690 }
8691}
@ 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
1287 {
1288 return _spawnGroupMapStore.equal_range(groupId);
1289 }
SpawnGroupLinkContainer _spawnGroupMapStore
Definition ObjectMgr.h:1674

References _spawnGroupMapStore.

◆ GetSpawnGroupData()

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

References _spawnGroupDataStore.

◆ GetSpellClickInfoMapBounds()

SpellClickInfoMapBounds ObjectMgr::GetSpellClickInfoMapBounds ( uint32  creature_id) const
inline
1467 {
1468 return _spellClickInfoStore.equal_range(creature_id);
1469 }
SpellClickInfoContainer _spellClickInfoStore
Definition ObjectMgr.h:1602

References _spellClickInfoStore.

◆ GetSpellScriptsBounds()

SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds ( uint32  spell_id)
9731{
9732 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
9733}
std::pair< SpellScriptsContainer::iterator, SpellScriptsContainer::iterator > SpellScriptsBounds
Definition ObjectMgr.h:391
SpellScriptsContainer _spellScriptsStore
Definition ObjectMgr.h:1604

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

References _tempSummonDataStore.

◆ GetTaxiMountDisplayId()

uint32 ObjectMgr::GetTaxiMountDisplayId ( uint32  id,
TeamId  teamId,
bool  allowed_alt_team = false 
)
7221{
7222 CreatureModel mountModel;
7223 CreatureTemplate const* mount_info = nullptr;
7224
7225 // select mount creature id
7226 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
7227 if (node)
7228 {
7229 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
7230
7231 // Fix for Alliance not being able to use Acherus taxi
7232 // only one mount type for both sides
7233 if (mount_entry == 0 && allowed_alt_team)
7234 {
7235 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
7236 mount_entry = node->MountCreatureID[teamId];
7237 }
7238
7239 mount_info = GetCreatureTemplate(mount_entry);
7240 if (mount_info)
7241 {
7242 CreatureModel const* model = mount_info->GetRandomValidModel();
7243 if (!model)
7244 {
7245 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
7246 return 0;
7247 }
7248 mountModel = *model;
7249 }
7250 }
7251
7252 // minfo is not actually used but the mount_id was updated
7253 GetCreatureModelRandomGender(&mountModel, mount_info);
7254
7255 return mountModel.CreatureDisplayID;
7256}
CreatureModelInfo const * GetCreatureModelRandomGender(CreatureModel *model, CreatureTemplate const *creatureTemplate) const
Definition ObjectMgr.cpp:1678
CreatureModel const * GetRandomValidModel() const
Definition Creature.cpp:125

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 
)
7197{
7198 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
7199 if (src_i == sTaxiPathSetBySource.end())
7200 {
7201 path = 0;
7202 cost = 0;
7203 return;
7204 }
7205
7206 TaxiPathSetForSource& pathSet = src_i->second;
7207
7208 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
7209 if (dest_i == pathSet.end())
7210 {
7211 path = 0;
7212 cost = 0;
7213 return;
7214 }
7215
7216 cost = dest_i->second->price;
7217 path = dest_i->second->ID;
7218}
TaxiPathSetBySource sTaxiPathSetBySource
Definition DBCStores.cpp:187
std::map< uint32, TaxiPathEntry const * > TaxiPathSetForSource
Definition DBCStructure.h:2278

References TaxiNodesEntry::ID, and sTaxiPathSetBySource.

◆ GetTrainer()

Trainer::Trainer * ObjectMgr::GetTrainer ( uint32  creatureId)
10143{
10144 auto itr = _creatureDefaultTrainers.find(creatureId);
10145 if (itr != _creatureDefaultTrainers.end())
10146 return Acore::Containers::MapGetValuePtr(_trainers, itr->second);
10147
10148 return nullptr;
10149}
std::unordered_map< uint32, uint32 > _creatureDefaultTrainers
Definition ObjectMgr.h:1701
std::unordered_map< uint32, Trainer::Trainer > _trainers
Definition ObjectMgr.h:1699

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

◆ GetVehicleAccessoryList()

VehicleAccessoryList const * ObjectMgr::GetVehicleAccessoryList ( Vehicle *  veh) const
11066{
11067 if (Creature* cre = veh->GetBase()->ToCreature())
11068 {
11069 // Give preference to GUID-based accessories
11070 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
11071 if (itr != _vehicleAccessoryStore.end())
11072 return &itr->second;
11073 }
11074
11075 // Otherwise return entry-based
11076 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
11077 if (itr != _vehicleTemplateAccessoryStore.end())
11078 return &itr->second;
11079 return nullptr;
11080}
VehicleAccessoryContainer _vehicleAccessoryStore
Definition ObjectMgr.h:1607
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
Definition ObjectMgr.h:1606
Creature * ToCreature()
Definition Object.h:212
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
1521 {
1522 VehicleSeatAddonContainer::const_iterator itr = _vehicleSeatAddonStore.find(seatId);
1523 if (itr == _vehicleSeatAddonStore.end())
1524 return nullptr;
1525
1526 return &itr->second;
1527 }
VehicleSeatAddonContainer _vehicleSeatAddonStore
Definition ObjectMgr.h:1608

References _vehicleSeatAddonStore.

◆ GetXPForLevel()

uint32 ObjectMgr::GetXPForLevel ( uint8  level) const
8093{
8094 if (level < _playerXPperLevel.size())
8095 return _playerXPperLevel[level];
8096 return 0;
8097}
PlayerXPperLevel _playerXPperLevel
Definition ObjectMgr.h:1637

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
6472{
6473 uint32 limit = sSpellStore.GetNumRows();
6474 for(uint32 i = 0; i <= limit; ++i)
6475 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
6476 {
6477 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
6478 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
6479 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
6480 }
6481}
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:419

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsChatFiltered()

bool ObjectMgr::IsChatFiltered ( std::string_view  text) const
9221{
9222 if (!_chatFilterAutomaton || text.empty())
9223 return false;
9224
9225 std::wstring wtext;
9226 if (!Utf8toWStr(text, wtext))
9227 return false;
9228
9229 wstrToLower(wtext);
9230
9231 return _chatFilterAutomaton->ContainsAny(wtext);
9232}
std::unique_ptr< Acore::AhoCorasick< wchar_t > > _chatFilterAutomaton
Definition ObjectMgr.h:1596

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

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
11046{
11047 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
11048 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
11049}
@ 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
9133{
9134 // pussywizard
9135 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
9136 return true;
9137
9138 std::wstring wstr;
9139 if (!Utf8toWStr (name, wstr))
9140 return false;
9141
9142 wstrToLower(wstr);
9143
9144 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
9145}

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

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
9030{
9031 // pussywizard
9032 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
9033 return true;
9034
9035 std::wstring wstr;
9036 if (!Utf8toWStr (name, wstr))
9037 return false;
9038
9039 wstrToLower(wstr);
9040
9041 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
9042}

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

Referenced by AddReservedPlayerName().

◆ IsTavernAreaTrigger()

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

References _tavernAreaTriggerStore.

◆ IsTransportMap()

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

References _transportMaps.

◆ IsValidChannelName()

bool ObjectMgr::IsValidChannelName ( std::string const &  name)
static
9373{
9374 std::wstring wname;
9375 if (!Utf8toWStr(name, wname))
9376 return false;
9377
9378 if (wname.size() > MAX_CHANNEL_NAME)
9379 return false;
9380
9381 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
9382
9383 return isValidString(wname, strictMask, true);
9384}
#define MAX_CHANNEL_NAME
Definition ObjectMgr.h:691
@ 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
9347{
9348 std::wstring wname;
9349 if (!Utf8toWStr(name, wname))
9350 return false;
9351
9352 if (wname.size() > MAX_CHARTER_NAME)
9353 return false;
9354
9355 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
9356 if (wname.size() < minName)
9357 return false;
9358
9359 // Check Reserved Name
9360 if (sObjectMgr->IsReservedName(name))
9361 return false;
9362
9363 // Check Profanity Name
9364 if (sObjectMgr->IsProfanityName(name))
9365 return false;
9366
9367 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
9368
9369 return isValidString(wname, strictMask, true);
9370}
#define MAX_CHARTER_NAME
Definition ObjectMgr.h:690
@ 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
10414{
10415 /*
10416 CreatureTemplate const* cInfo = GetCreatureTemplate(vendor_entry);
10417 if (!cInfo)
10418 {
10419 if (player)
10420 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
10421 else
10422 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
10423 return false;
10424 }
10425
10426 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
10427 {
10428 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
10429 {
10430 if (player)
10431 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
10432 else
10433 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
10434
10435 if (skip_vendors)
10436 skip_vendors->insert(vendor_entry);
10437 }
10438 return false;
10439 }
10440 */
10441
10442 if (!sObjectMgr->GetItemTemplate(item_id))
10443 {
10444 if (player)
10446 else
10447 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
10448 return false;
10449 }
10450
10451 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
10452 {
10453 if (player)
10455 else
10456 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
10457 return false;
10458 }
10459
10460 if (maxcount > 0 && incrtime == 0)
10461 {
10462 if (player)
10463 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 ({}) but IncrTime == 0", maxcount);
10464 else
10465 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);
10466 return false;
10467 }
10468 else if (maxcount == 0 && incrtime > 0)
10469 {
10470 if (player)
10471 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
10472 else
10473 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);
10474 return false;
10475 }
10476
10477 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
10478 if (!vItems)
10479 return true; // later checks for non-empty lists
10480
10481 if (vItems->FindItemCostPair(item_id, ExtendedCost))
10482 {
10483 if (player)
10484 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
10485 else
10486 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
10487 return false;
10488 }
10489
10490 return true;
10491}
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
@ LANG_ITEM_ALREADY_IN_LIST
Definition Language.h:256
@ LANG_ITEM_NOT_FOUND
Definition Language.h:253
@ LANG_EXTENDED_COST_NOT_EXIST
Definition Language.h:381
Definition Chat.h:37
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
VendorItemData const * GetNpcVendorItemList(uint32 entry) const
Definition ObjectMgr.h:1448
WorldSession * GetSession() const
Definition Player.h:2032
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost) const
Definition Creature.cpp:109

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 ( )
7370{
7371 uint32 oldMSTime = getMSTime();
7372
7373 if (!_accessRequirementStore.empty())
7374 {
7375 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
7376 {
7377 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
7378 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
7379 {
7380 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
7381 {
7382 delete* questItr;
7383 }
7384
7385 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
7386 {
7387 delete* achievementItr;
7388 }
7389
7390 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
7391 {
7392 delete* itemsItr;
7393 }
7394
7395 delete difficultiesItr->second;
7396 }
7397 }
7398
7399 _accessRequirementStore.clear(); // need for reload case
7400 }
7401 // 0 1 2 3 4 5
7402 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
7403 if (!access_template_result)
7404 {
7405 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
7406 LOG_INFO("server.loading", " ");
7407 return;
7408 }
7409
7410 uint32 count = 0;
7411 uint32 countProgressionRequirements = 0;
7412
7413 do
7414 {
7415 Field* fields = access_template_result->Fetch();
7416
7417 //Get the common variables for the access requirements
7418 uint8 dungeon_access_id = fields[0].Get<uint8>();
7419 uint32 mapid = fields[1].Get<uint32>();
7420 uint8 difficulty = fields[2].Get<uint8>();
7421
7422 //Set up the access requirements
7424 ar->levelMin = fields[3].Get<uint8>();
7425 ar->levelMax = fields[4].Get<uint8>();
7426 ar->reqItemLevel = fields[5].Get<uint16>();
7427
7428 // 0 1 2 3 4 6
7429 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);
7430 if (progression_requirements_results)
7431 {
7432 do
7433 {
7434 Field* progression_requirement_row = progression_requirements_results->Fetch();
7435
7436 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
7437 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
7438 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
7439 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
7440 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
7441 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
7442
7443 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
7444 progression_requirement->id = requirement_id;
7445 progression_requirement->note = requirement_note;
7446 progression_requirement->faction = (TeamId)requirement_faction;
7447 progression_requirement->priority = requirement_priority;
7448 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
7449
7450 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
7451
7452 switch (requirement_type)
7453 {
7454 case 0:
7455 {
7456 //Achievement
7457 if (!sAchievementStore.LookupEntry(progression_requirement->id))
7458 {
7459 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);
7460 break;
7461 }
7462
7463 currentRequirementsList = &ar->achievements;
7464 break;
7465 }
7466 case 1:
7467 {
7468 //Quest
7469 if (!GetQuestTemplate(progression_requirement->id))
7470 {
7471 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);
7472 break;
7473 }
7474
7475 currentRequirementsList = &ar->quests;
7476 break;
7477 }
7478 case 2:
7479 {
7480 //Item
7481 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
7482 if (!pProto)
7483 {
7484 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);
7485 break;
7486 }
7487
7488 currentRequirementsList = &ar->items;
7489 break;
7490 }
7491 default:
7492 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);
7493 break;
7494 }
7495
7496 //Check if array is valid and delete the progression requirement
7497 if (!currentRequirementsList)
7498 {
7499 delete progression_requirement;
7500 continue;
7501 }
7502
7503 //Insert into the array
7504 if (currentRequirementsList->size() > requirement_priority)
7505 {
7506 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
7507 }
7508 else
7509 {
7510 currentRequirementsList->push_back(progression_requirement);
7511 }
7512
7513 } while (progression_requirements_results->NextRow());
7514 }
7515
7516 //Sort all arrays for priority
7517 auto sortFunction = [](ProgressionRequirement const* const a, ProgressionRequirement const* const b) {return a->priority > b->priority; };
7518 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
7519 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
7520 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
7521
7522 countProgressionRequirements += ar->achievements.size();
7523 countProgressionRequirements += ar->quests.size();
7524 countProgressionRequirements += ar->items.size();
7525 count++;
7526
7527 _accessRequirementStore[mapid][difficulty] = ar;
7528 } while (access_template_result->NextRow());
7529
7530 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
7531 LOG_INFO("server.loading", " ");
7532}
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:99
bool IsNull() const
Definition Field.h:107
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:113
ItemTemplate const * GetItemTemplate(uint32 entry)
Definition ObjectMgr.cpp:3934
Quest const * GetQuestTemplate(uint32 quest_id) const
Definition ObjectMgr.h:840
Definition Player.h:936
Definition ItemTemplate.h:619
Definition Player.h:927
uint32 priority
Definition Player.h:931

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 ( )
9580{
9581 uint32 oldMSTime = getMSTime();
9582
9583 _acoreStringStore.clear(); // for reload case
9584
9585 // content_default holds enUS. A locale registered by a module needs its own locale_<code> column.
9586 std::string sql = "SELECT entry, content_default";
9587 std::vector<LocaleConstant> columnLocales; // locale of fields[2 + k]
9588 for (uint8 i = LOCALE_koKR; i < TOTAL_LOCALES; ++i)
9589 {
9591 continue;
9592
9593 sql += ", locale_";
9594 sql += localeNames[i];
9595 columnLocales.push_back(LocaleConstant(i));
9596 }
9597 sql += " FROM acore_string";
9598
9599 QueryResult result = WorldDatabase.Query(sql);
9600 if (!result)
9601 {
9602 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_string` is empty "
9603 "or a locale column is missing; queried: {}", sql);
9604 LOG_INFO("server.loading", " ");
9605 return false;
9606 }
9607
9608 do
9609 {
9610 Field* fields = result->Fetch();
9611
9612 uint32 entry = fields[0].Get<uint32>();
9613
9614 AcoreString& data = _acoreStringStore[entry];
9615
9616 data.Content.resize(DEFAULT_LOCALE + 1);
9617
9618 AddLocaleString(fields[1].Get<std::string>(), DEFAULT_LOCALE, data.Content);
9619 for (std::size_t k = 0; k < columnLocales.size(); ++k)
9620 AddLocaleString(fields[2 + k].Get<std::string>(), columnLocales[k], data.Content);
9621 } while (result->NextRow());
9622
9623 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
9624 LOG_INFO("server.loading", " ");
9625
9626 return true;
9627}
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:125
@ TOTAL_LOCALES
Definition Common.h:137
@ LOCALE_koKR
Definition Common.h:127
bool IsLocaleRegistered(LocaleConstant locale)
Definition Common.h:147
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(), IsLocaleRegistered(), LOCALE_koKR, localeNames, LOG_INFO, LOG_WARN, TOTAL_LOCALES, and WorldDatabase.

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
7259{
7260 uint32 oldMSTime = getMSTime();
7261
7262 _areaTriggerStore.clear();
7263
7264 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
7265
7266 if (!result)
7267 {
7268 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
7269 LOG_INFO("server.loading", " ");
7270 return;
7271 }
7272
7273 uint32 count = 0;
7274
7275 do
7276 {
7277 Field* fields = result->Fetch();
7278
7279 ++count;
7280
7281 AreaTrigger at;
7282
7283 at.entry = fields[0].Get<uint32>();
7284 at.map = fields[1].Get<uint32>();
7285 at.x = fields[2].Get<float>();
7286 at.y = fields[3].Get<float>();
7287 at.z = fields[4].Get<float>();
7288 at.radius = fields[5].Get<float>();
7289 at.length = fields[6].Get<float>();
7290 at.width = fields[7].Get<float>();
7291 at.height = fields[8].Get<float>();
7292 at.orientation = fields[9].Get<float>();
7293
7294 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
7295 if (!mapEntry)
7296 {
7297 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
7298 continue;
7299 }
7300
7301 _areaTriggerStore[at.entry] = at;
7302 } while (result->NextRow());
7303
7304 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7305 LOG_INFO("server.loading", " ");
7306}
float height
Definition ObjectMgr.h:432
float x
Definition ObjectMgr.h:426
float y
Definition ObjectMgr.h:427
float orientation
Definition ObjectMgr.h:433
float length
Definition ObjectMgr.h:430
uint32 entry
Definition ObjectMgr.h:424
float radius
Definition ObjectMgr.h:429
float z
Definition ObjectMgr.h:428
float width
Definition ObjectMgr.h:431

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 ( )
7112{
7113 uint32 oldMSTime = getMSTime();
7114
7115 _areaTriggerScriptStore.clear(); // need for reload case
7116 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
7117
7118 if (!result)
7119 {
7120 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
7121 LOG_INFO("server.loading", " ");
7122 return;
7123 }
7124
7125 uint32 count = 0;
7126
7127 do
7128 {
7129 ++count;
7130
7131 Field* fields = result->Fetch();
7132
7133 uint32 Trigger_ID = fields[0].Get<uint32>();
7134 std::string scriptName = fields[1].Get<std::string>();
7135
7136 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
7137 if (!atEntry)
7138 {
7139 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
7140 continue;
7141 }
7142 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
7143 } while (result->NextRow());
7144
7145 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7146 LOG_INFO("server.loading", " ");
7147}
uint32 GetScriptId(std::string const &name)
Definition ObjectMgr.cpp:10555

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

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
7309{
7310 uint32 oldMSTime = getMSTime();
7311
7312 _areaTriggerTeleportStore.clear(); // need for reload case
7313
7314 // 0 1 2 3 4 5
7315 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
7316
7317 if (!result)
7318 {
7319 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
7320 LOG_INFO("server.loading", " ");
7321 return;
7322 }
7323
7324 uint32 count = 0;
7325
7326 do
7327 {
7328 Field* fields = result->Fetch();
7329
7330 ++count;
7331
7332 uint32 Trigger_ID = fields[0].Get<uint32>();
7333
7335
7336 at.target_mapId = fields[1].Get<uint16>();
7337 at.target_X = fields[2].Get<float>();
7338 at.target_Y = fields[3].Get<float>();
7339 at.target_Z = fields[4].Get<float>();
7340 at.target_Orientation = fields[5].Get<float>();
7341
7342 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
7343 if (!atEntry)
7344 {
7345 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
7346 continue;
7347 }
7348
7349 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
7350 if (!mapEntry)
7351 {
7352 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
7353 continue;
7354 }
7355
7356 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
7357 {
7358 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
7359 continue;
7360 }
7361
7362 _areaTriggerTeleportStore[Trigger_ID] = at;
7363 } while (result->NextRow());
7364
7365 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7366 LOG_INFO("server.loading", " ");
7367}
Definition ObjectMgr.h:414
uint32 target_mapId
Definition ObjectMgr.h:415

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

◆ LoadBroadcastTextLocales()

void ObjectMgr::LoadBroadcastTextLocales ( )
10655{
10656 uint32 oldMSTime = getMSTime();
10657
10658 // 0 1 2 3
10659 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
10660
10661 if (!result)
10662 {
10663 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
10664 LOG_INFO("server.loading", " ");
10665 return;
10666 }
10667
10668 uint32 locales_count = 0;
10669 do
10670 {
10671 Field* fields = result->Fetch();
10672
10673 uint32 id = fields[0].Get<uint32>();
10674
10675 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
10676 if (bct == _broadcastTextStore.end())
10677 {
10678 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
10679 continue;
10680 }
10681
10682 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
10683 if (locale == LOCALE_enUS)
10684 continue;
10685
10686 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
10687 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
10688 locales_count++;
10689 } while (result->NextRow());
10690
10691 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
10692 LOG_INFO("server.loading", " ");
10693}
LocaleConstant GetLocaleByName(std::string const &name)
Definition Common.cpp:78

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

◆ LoadBroadcastTexts()

void ObjectMgr::LoadBroadcastTexts ( )
10570{
10571 uint32 oldMSTime = getMSTime();
10572
10573 _broadcastTextStore.clear(); // for reload case
10574
10575 // 0 1 2 3 4 5 6 7 8 9 10 11 12
10576 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
10577 if (!result)
10578 {
10579 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
10580 LOG_INFO("server.loading", " ");
10581 return;
10582 }
10583
10584 _broadcastTextStore.rehash(result->GetRowCount());
10585
10586 do
10587 {
10588 Field* fields = result->Fetch();
10589
10590 BroadcastText bct;
10591
10592 bct.Id = fields[0].Get<uint32>();
10593 bct.LanguageID = fields[1].Get<uint32>();
10594 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
10595 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
10596 bct.EmoteId1 = fields[4].Get<uint32>();
10597 bct.EmoteId2 = fields[5].Get<uint32>();
10598 bct.EmoteId3 = fields[6].Get<uint32>();
10599 bct.EmoteDelay1 = fields[7].Get<uint32>();
10600 bct.EmoteDelay2 = fields[8].Get<uint32>();
10601 bct.EmoteDelay3 = fields[9].Get<uint32>();
10602 bct.SoundEntriesId = fields[10].Get<uint32>();
10603 bct.EmotesID = fields[11].Get<uint32>();
10604 bct.Flags = fields[12].Get<uint32>();
10605
10606 if (bct.SoundEntriesId)
10607 {
10608 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
10609 {
10610 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
10611 bct.SoundEntriesId = 0;
10612 }
10613 }
10614
10616 {
10617 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
10619 }
10620
10621 if (bct.EmoteId1)
10622 {
10623 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
10624 {
10625 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
10626 bct.EmoteId1 = 0;
10627 }
10628 }
10629
10630 if (bct.EmoteId2)
10631 {
10632 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
10633 {
10634 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
10635 bct.EmoteId2 = 0;
10636 }
10637 }
10638
10639 if (bct.EmoteId3)
10640 {
10641 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
10642 {
10643 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
10644 bct.EmoteId3 = 0;
10645 }
10646 }
10647
10648 _broadcastTextStore[bct.Id] = bct;
10649 } while (result->NextRow());
10650
10651 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
10652}
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:437
uint32 EmoteDelay2
Definition ObjectMgr.h:452
uint32 Id
Definition ObjectMgr.h:444
std::vector< std::string > FemaleText
Definition ObjectMgr.h:447
uint32 EmotesID
Definition ObjectMgr.h:455
uint32 LanguageID
Definition ObjectMgr.h:445
uint32 EmoteId2
Definition ObjectMgr.h:449
uint32 EmoteDelay1
Definition ObjectMgr.h:451
uint32 SoundEntriesId
Definition ObjectMgr.h:454
std::vector< std::string > MaleText
Definition ObjectMgr.h:446
uint32 EmoteId3
Definition ObjectMgr.h:450
uint32 EmoteId1
Definition ObjectMgr.h:448
uint32 EmoteDelay3
Definition ObjectMgr.h:453
uint32 Flags
Definition ObjectMgr.h:456

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.

◆ LoadChatFilter()

void ObjectMgr::LoadChatFilter ( )
9168{
9169 uint32 oldMSTime = getMSTime();
9170
9171 _chatFilterAutomaton.reset(); // need for reload case
9172
9174 PreparedQueryResult result = CharacterDatabase.Query(stmt);
9175
9176 if (!result)
9177 {
9178 LOG_WARN("server.loading", ">> Loaded 0 chat filter words. DB table `chat_filter` is empty!");
9179 LOG_INFO("server.loading", " ");
9180 return;
9181 }
9182
9183 auto automaton = std::make_unique<Acore::AhoCorasick<wchar_t>>();
9184 uint32 count = 0;
9185
9186 do
9187 {
9188 Field* fields = result->Fetch();
9189 std::string word = fields[1].Get<std::string>();
9190
9191 if (word.empty())
9192 continue;
9193
9194 std::wstring wstr;
9195 if (!Utf8toWStr(word, wstr))
9196 {
9197 LOG_ERROR("sql.sql", "Table `chat_filter` has invalid word: {}", word);
9198 continue;
9199 }
9200
9201 wstrToLower(wstr);
9202
9203 if (wstr.empty())
9204 continue;
9205
9206 automaton->Insert(wstr);
9207 ++count;
9208 } while (result->NextRow());
9209
9210 if (count > 0)
9211 {
9212 automaton->Build();
9213 _chatFilterAutomaton = std::move(automaton);
9214 }
9215
9216 LOG_INFO("server.loading", ">> Loaded {} chat filter words in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9217 LOG_INFO("server.loading", " ");
9218}
@ CHAR_SEL_CHAT_FILTER
Definition CharacterDatabase.h:532
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45

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

◆ 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:2764
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 ( )
10727{
10728 uint32 oldMSTime = getMSTime();
10729
10730 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");
10731
10732 if (!result)
10733 {
10734 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
10735 LOG_INFO("server.loading", " ");
10736 return;
10737 }
10738
10739 uint32 count = 0;
10740 do
10741 {
10742 Field* fields = result->Fetch();
10743
10744 uint8 Level = fields[0].Get<uint8>();
10745 uint8 Class = fields[1].Get<uint8>();
10746
10747 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
10748 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
10749
10750 CreatureBaseStats stats;
10751
10752 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
10753 {
10754 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
10755
10756 if (stats.BaseHealth[i] == 0)
10757 {
10758 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
10759 stats.BaseHealth[i] = 1;
10760 }
10761
10762 // xinef: if no data is available, get them from lower expansions
10763 if (stats.BaseHealth[i] <= 1)
10764 {
10765 for (uint8 j = i; j > 0;)
10766 {
10767 --j;
10768 if (stats.BaseHealth[j] > 1)
10769 {
10770 stats.BaseHealth[i] = stats.BaseHealth[j];
10771 break;
10772 }
10773 }
10774 }
10775
10776 stats.BaseDamage[i] = fields[9 + i].Get<float>();
10777 if (stats.BaseDamage[i] < 0.0f)
10778 {
10779 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
10780 stats.BaseDamage[i] = 0.0f;
10781 }
10782 }
10783
10784 stats.BaseMana = fields[5].Get<uint32>();
10785 stats.BaseArmor = fields[6].Get<uint32>();
10786
10787 stats.AttackPower = fields[7].Get<uint32>();
10788 stats.RangedAttackPower = fields[8].Get<uint32>();
10789
10790 stats.Strength = fields[12].Get<uint32>();
10791 stats.Agility = fields[13].Get<uint32>();
10792 stats.Stamina = fields[14].Get<uint32>();
10793 stats.Intellect = fields[15].Get<uint32>();
10794 stats.Spirit = fields[16].Get<uint32>();
10795
10796 if (!stats.Strength || !stats.Agility || !stats.Stamina || !stats.Intellect || !stats.Spirit)
10797 {
10798 // Once these attributes are implemented, this should probably be uncommented.
10799 // LOG_WARN("server.loading", "Creature base attributes for class {}, level {} are missing!", Class, Level);
10800 }
10801
10803
10804 ++count;
10805 } while (result->NextRow());
10806
10808 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
10809 {
10810 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
10811 {
10812 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
10813 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
10814 }
10815 }
10816
10817 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10818 LOG_INFO("server.loading", " ");
10819}
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:774
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.
2575{
2576 CreatureData const* data = GetCreatureData(spawnId);
2577 if (data)
2578 return data;
2579
2580 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, equipment_id, "
2581 "position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2582 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, "
2583 "creature.npcflag, creature.unit_flags, creature.dynamicflags, creature.ScriptName "
2584 "FROM creature WHERE creature.guid = {}", spawnId);
2585
2586 if (!result)
2587 return nullptr;
2588
2589 Field* fields = result->Fetch();
2590 uint32 creatureId = fields[1].Get<uint32>();
2591
2592 CreatureTemplate const* cInfo = GetCreatureTemplate(creatureId);
2593 if (!cInfo)
2594 {
2595 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in `id` field, skipped.", spawnId, creatureId);
2596 return nullptr;
2597 }
2598
2600 creatureData.id = creatureId;
2601 creatureData.mapid = fields[2].Get<uint16>();
2602 creatureData.equipmentId = fields[3].Get<int8>();
2603 creatureData.posX = fields[4].Get<float>();
2604 creatureData.posY = fields[5].Get<float>();
2605 creatureData.posZ = fields[6].Get<float>();
2606 creatureData.orientation = fields[7].Get<float>();
2607 creatureData.spawntimesecs = fields[8].Get<uint32>();
2608 creatureData.wander_distance = fields[9].Get<float>();
2609 creatureData.currentwaypoint = fields[10].Get<uint32>();
2610 creatureData.curhealth = fields[11].Get<uint32>();
2611 creatureData.curmana = fields[12].Get<uint32>();
2612 creatureData.movementType = fields[13].Get<uint8>();
2613 creatureData.spawnMask = fields[14].Get<uint8>();
2614 creatureData.phaseMask = fields[15].Get<uint32>();
2615 creatureData.npcflag = fields[16].Get<uint32>();
2616 creatureData.unit_flags = fields[17].Get<uint32>();
2617 creatureData.dynamicflags = fields[18].Get<uint32>();
2618 creatureData.ScriptId = GetScriptId(fields[19].Get<std::string>());
2619 creatureData.spawnGroupId = 0;
2620
2621 if (!creatureData.ScriptId)
2622 creatureData.ScriptId = cInfo->ScriptID;
2623
2624 // Load alternate entries from creature_multispawn
2625 QueryResult variantResult = WorldDatabase.Query("SELECT entry FROM creature_multispawn WHERE spawnId = {} ORDER BY entry", spawnId);
2626 if (variantResult)
2627 {
2628 do
2629 {
2630 uint32 variantEntry = variantResult->Fetch()[0].Get<uint32>();
2631 if (!GetCreatureTemplate(variantEntry))
2632 {
2633 LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with non-existing entry {}, skipped.", spawnId, variantEntry);
2634 continue;
2635 }
2636
2637 // Check difficulty entries for variant
2638 bool diffOk = true;
2639 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && diffOk; ++diff)
2640 {
2641 if (_difficultyEntries[diff].find(variantEntry) != _difficultyEntries[diff].end())
2642 {
2643 LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} listed as difficulty template in `creature_template`, skipped.",
2644 spawnId, variantEntry);
2645 diffOk = false;
2646 }
2647 }
2648 if (!diffOk)
2649 continue;
2650
2651 // Validate equipment for variant entry
2652 if (creatureData.equipmentId != 0 && !GetEquipmentInfo(variantEntry, creatureData.equipmentId))
2653 {
2654 LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} where equipment_id {} not found in `creature_equip_template`.",
2655 spawnId, variantEntry, creatureData.equipmentId);
2656 }
2657
2658 if (!creatureData.id2)
2659 creatureData.id2 = variantEntry;
2660 else if (!creatureData.id3)
2661 creatureData.id3 = variantEntry;
2662 else
2663 LOG_ERROR("sql.sql", "Table `creature_multispawn` has more than 2 variant entries for creature (SpawnId: {}), extra entry {} skipped.", spawnId, variantEntry);
2664 } while (variantResult->NextRow());
2665 }
2666
2667 MapEntry const* mapEntry = sMapStore.LookupEntry(creatureData.mapid);
2668 if (!mapEntry)
2669 {
2670 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) that spawned at non-existing map (Id: {}), skipped.", spawnId, creatureData.mapid);
2671 _creatureDataStore.erase(spawnId);
2672 return nullptr;
2673 }
2674
2675 if (mapEntry->IsRaid() && creatureData.spawntimesecs >= 7 * DAY && creatureData.spawntimesecs < 14 * DAY)
2676 creatureData.spawntimesecs = 14 * DAY;
2677
2678 bool ok = true;
2679 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2680 {
2681 if (_difficultyEntries[diff].find(creatureId) != _difficultyEntries[diff].end())
2682 {
2683 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) that is listed as difficulty {} template (Entry: {}) in `creature_template`, skipped.",
2684 spawnId, diff + 1, creatureId);
2685 ok = false;
2686 }
2687 }
2688
2689 if (!ok)
2690 {
2691 _creatureDataStore.erase(spawnId);
2692 return nullptr;
2693 }
2694
2695 if (creatureData.equipmentId != 0)
2696 {
2697 if (!GetEquipmentInfo(creatureId, creatureData.equipmentId))
2698 {
2699 LOG_ERROR("sql.sql", "Table `creature` has creature (Entry: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.",
2700 creatureId, creatureData.equipmentId);
2701 creatureData.equipmentId = 0;
2702 }
2703 }
2704
2705 if (creatureData.movementType >= MAX_DB_MOTION_TYPE)
2706 {
2707 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with wrong movement generator type ({}), set to IDLE.",
2708 spawnId, creatureId, creatureData.movementType);
2709 creatureData.movementType = IDLE_MOTION_TYPE;
2710 }
2711
2712 if (creatureData.wander_distance < 0.0f)
2713 {
2714 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `wander_distance`< 0, set to 0.",
2715 spawnId, creatureId);
2716 creatureData.wander_distance = 0.0f;
2717 }
2718 else if (creatureData.movementType == RANDOM_MOTION_TYPE)
2719 {
2720 if (creatureData.wander_distance == 0.0f)
2721 {
2722 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).",
2723 spawnId, creatureId);
2724 creatureData.movementType = IDLE_MOTION_TYPE;
2725 }
2726 }
2727 else if (creatureData.movementType == IDLE_MOTION_TYPE)
2728 {
2729 if (creatureData.wander_distance != 0.0f)
2730 {
2731 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.",
2732 spawnId, creatureId);
2733 creatureData.wander_distance = 0.0f;
2734 }
2735 }
2736
2737 if (creatureData.phaseMask == 0)
2738 {
2739 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.",
2740 spawnId, creatureId);
2741 creatureData.phaseMask = 1;
2742 }
2743
2744 return &creatureData;
2745}
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:1390

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 ( )
10115{
10116 uint32 oldMSTime = getMSTime();
10117
10119
10120 if (QueryResult result = WorldDatabase.Query("SELECT CreatureId, TrainerId FROM creature_default_trainer"))
10121 {
10122 do
10123 {
10124 Field* fields = result->Fetch();
10125 uint32 creatureId = fields[0].Get<uint32>();
10126 uint32 trainerId = fields[1].Get<uint32>();
10127
10128 if (!GetCreatureTemplate(creatureId))
10129 {
10130 LOG_ERROR("sql.sql", "Table `creature_default_trainer` references non-existing creature template (CreatureId: %u), ignoring", creatureId);
10131 continue;
10132 }
10133
10134 _creatureDefaultTrainers[creatureId] = trainerId;
10135
10136 } while (result->NextRow());
10137 }
10138
10139 LOG_INFO("server.loading", ">> Loaded {} default trainers in {} ms", _creatureDefaultTrainers.size(), GetMSTimeDiffToNow(oldMSTime));
10140}

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:748
Definition DBCStructure.h:802
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.id");
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 ( )
8948{
8949 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8950
8951 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8952 {
8953 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8954 if (!cInfo)
8955 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8956 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8957 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);
8958 }
8959}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition UnitDefines.h:323
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition ObjectMgr.cpp:8860

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
11140{
11141 uint32 oldMSTime = getMSTime();
11142
11143 // 0 1 2
11144 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
11145
11146 if (!result)
11147 {
11148 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
11149 return;
11150 }
11151
11152 uint32 count = 0;
11153 do
11154 {
11155 Field* fields = result->Fetch();
11156
11157 uint32 entry = fields[0].Get<uint32>();
11158 uint32 item = fields[1].Get<uint32>();
11159 uint32 idx = fields[2].Get<uint32>();
11160
11161 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
11162 if (!creatureInfo)
11163 {
11164 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
11165 continue;
11166 };
11167
11168 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
11169 if (!dbcData)
11170 {
11171 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
11172 continue;
11173 };
11174
11175 _creatureQuestItemStore[entry].push_back(item);
11176
11177 ++count;
11178 } while (result->NextRow());
11179
11180 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11181 LOG_INFO("server.loading", " ");
11182}
DBCStorage< ItemEntry > sItemStore(Itemfmt)
Definition DBCStructure.h:1179

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

◆ LoadCreatureQuestStarters()

void ObjectMgr::LoadCreatureQuestStarters ( )
8934{
8935 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8936
8937 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8938 {
8939 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8940 if (!cInfo)
8941 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8942 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8943 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);
8944 }
8945}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

void ObjectMgr::LoadCreatures ( )
2321{
2322 uint32 oldMSTime = getMSTime();
2323
2324 // 0 1 2 3 4 5 6 7 8 9
2325 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2326 // 10 11 12 13 14 15 16 17 18 19 20
2327 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
2328 // 21
2329 "creature.ScriptName "
2330 "FROM creature "
2331 "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
2332 "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
2333
2334 if (!result)
2335 {
2336 LOG_WARN("server.loading", ">> Loaded 0 creatures. DB table `creature` is empty.");
2337 LOG_INFO("server.loading", " ");
2338 return;
2339 }
2340
2342 LOG_INFO("server.loading", "Calculating zone and area fields. This may take a moment...");
2343
2344 // Build single time for check spawnmask
2345 std::map<uint32, uint32> spawnMasks;
2346 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2347 if (sMapStore.LookupEntry(i))
2348 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2350 spawnMasks[i] |= (1 << k);
2351
2352 _creatureDataStore.rehash(result->GetRowCount());
2353 uint32 count = 0;
2354 do
2355 {
2356 Field* fields = result->Fetch();
2357
2358 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2359 uint32 creatureId = fields[1].Get<uint32>();
2360
2361 CreatureTemplate const* cInfo = GetCreatureTemplate(creatureId);
2362 if (!cInfo)
2363 {
2364 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in `id` field, skipped.", spawnId, creatureId);
2365 continue;
2366 }
2367 CreatureData& data = _creatureDataStore[spawnId];
2368 data.spawnId = spawnId;
2369 data.id = creatureId;
2370 data.mapid = fields[2].Get<uint16>();
2371 data.equipmentId = fields[3].Get<int8>();
2372 data.posX = fields[4].Get<float>();
2373 data.posY = fields[5].Get<float>();
2374 data.posZ = fields[6].Get<float>();
2375 data.orientation = fields[7].Get<float>();
2376 data.spawntimesecs = fields[8].Get<uint32>();
2377 data.wander_distance = fields[9].Get<float>();
2378 data.currentwaypoint = fields[10].Get<uint32>();
2379 data.curhealth = fields[11].Get<uint32>();
2380 data.curmana = fields[12].Get<uint32>();
2381 data.movementType = fields[13].Get<uint8>();
2382 data.spawnMask = fields[14].Get<uint8>();
2383 data.phaseMask = fields[15].Get<uint32>();
2384 int16 gameEvent = fields[16].Get<int16>();
2385 data.poolId = fields[17].Get<uint32>();
2386 data.npcflag = fields[18].Get<uint32>();
2387 data.unit_flags = fields[19].Get<uint32>();
2388 data.dynamicflags = fields[20].Get<uint32>();
2389 data.ScriptId = GetScriptId(fields[21].Get<std::string>());
2390 data.spawnGroupId = 0;
2391
2392 if (!data.ScriptId)
2393 data.ScriptId = cInfo->ScriptID;
2394
2395 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2396 if (!mapEntry)
2397 {
2398 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that spawned at not existed map (Id: {}), skipped.", spawnId, data.mapid);
2399 continue;
2400 }
2401
2402 // pussywizard: 7 days means no reaspawn, so set it to 14 days, because manual id reset may be late
2403 if (mapEntry->IsRaid() && data.spawntimesecs >= 7 * DAY && data.spawntimesecs < 14 * DAY)
2404 data.spawntimesecs = 14 * DAY;
2405
2406 // Skip spawnMask check for transport maps
2407 if (!_transportMaps.count(data.mapid))
2408 {
2409 if (data.spawnMask & ~spawnMasks[data.mapid])
2410 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that have wrong spawn mask {} including not supported difficulty modes for map (Id: {}).",
2411 spawnId, data.spawnMask, data.mapid);
2412 }
2413 else
2414 data.spawnGroupId = 1; // force compatibility group for transport spawns
2415
2416 bool ok = true;
2417 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2418 {
2419 if (_difficultyEntries[diff].find(data.id) != _difficultyEntries[diff].end())
2420 {
2421 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entry: {}) in `creature_template`, skipped.",
2422 spawnId, diff + 1, data.id);
2423 ok = false;
2424 }
2425 }
2426 if (!ok)
2427 continue;
2428
2429 // -1 random, 0 no equipment,
2430 if (data.equipmentId != 0)
2431 {
2432 if (!GetEquipmentInfo(data.id, data.equipmentId))
2433 {
2434 LOG_ERROR("sql.sql", "Table `creature` have creature (Entry: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.",
2435 data.id, data.equipmentId);
2436 data.equipmentId = 0;
2437 }
2438 }
2439 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND))
2440 {
2441 if (!mapEntry->IsDungeon())
2442 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",
2443 spawnId, data.id);
2444 }
2445 if (data.movementType >= MAX_DB_MOTION_TYPE)
2446 {
2447 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with wrong movement generator type ({}), ignored and set to IDLE.", spawnId, data.id, data.movementType);
2449 }
2450 if (data.wander_distance < 0.0f)
2451 {
2452 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `wander_distance`< 0, set to 0.", spawnId, data.id);
2453 data.wander_distance = 0.0f;
2454 }
2455 else if (data.movementType == RANDOM_MOTION_TYPE)
2456 {
2457 if (data.wander_distance == 0.0f)
2458 {
2459 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).",
2460 spawnId, data.id);
2462 }
2463 }
2464 else if (data.movementType == IDLE_MOTION_TYPE)
2465 {
2466 if (data.wander_distance != 0.0f)
2467 {
2468 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", spawnId, data.id);
2469 data.wander_distance = 0.0f;
2470 }
2471 }
2472
2473 if (data.phaseMask == 0)
2474 {
2475 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, data.id);
2476 data.phaseMask = 1;
2477 }
2478
2480 {
2481 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2482 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2483
2485
2486 stmt->SetData(0, zoneId);
2487 stmt->SetData(1, areaId);
2488 stmt->SetData(2, spawnId);
2489
2490 WorldDatabase.Execute(stmt);
2491 }
2492
2493 // Add to grid if not managed by the game event. Pooled spawns are in
2494 // the grid data too; the grid loader filters them by pool state.
2495 if (gameEvent == 0)
2496 AddCreatureToGrid(spawnId, &data);
2497
2498 ++count;
2499 } while (result->NextRow());
2500
2501 // Load alternate entries from creature_multispawn
2502 QueryResult variantResult = WorldDatabase.Query("SELECT spawnId, entry FROM creature_multispawn ORDER BY spawnId");
2503 if (variantResult)
2504 {
2505 uint32 variantCount = 0;
2506 do
2507 {
2508 Field* fields = variantResult->Fetch();
2509 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2510 uint32 entry = fields[1].Get<uint32>();
2511
2512 auto creatureDataIt = _creatureDataStore.find(spawnId);
2513 if (creatureDataIt == _creatureDataStore.end())
2514 {
2515 LOG_ERROR("sql.sql", "Table `creature_multispawn` has entry for non-existing creature spawn (SpawnId: {}), skipped.", spawnId);
2516 continue;
2517 }
2518
2519 CreatureData* data = &creatureDataIt->second;
2520
2521 CreatureTemplate const* variantInfo = GetCreatureTemplate(entry);
2522 if (!variantInfo)
2523 {
2524 LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with non-existing creature entry {}, skipped.", spawnId, entry);
2525 continue;
2526 }
2527
2528 // Check difficulty entries for variant
2529 bool diffOk = true;
2530 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && diffOk; ++diff)
2531 {
2532 if (_difficultyEntries[diff].find(entry) != _difficultyEntries[diff].end())
2533 {
2534 LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} listed as difficulty template in `creature_template`, skipped.",
2535 spawnId, entry);
2536 diffOk = false;
2537 }
2538 }
2539 if (!diffOk)
2540 continue;
2541
2542 // Validate equipment for variant entry
2543 if (data->equipmentId != 0 && !GetEquipmentInfo(entry, data->equipmentId))
2544 {
2545 LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} where equipment_id {} not found in `creature_equip_template`.",
2546 spawnId, entry, data->equipmentId);
2547 }
2548
2549 // Populate id2/id3 fields
2550 if (!data->id2)
2551 {
2552 data->id2 = entry;
2553 ++variantCount;
2554 }
2555 else if (!data->id3)
2556 {
2557 data->id3 = entry;
2558 ++variantCount;
2559 }
2560 else
2561 LOG_ERROR("sql.sql", "Table `creature_multispawn` has more than 2 variant entries for creature (SpawnId: {}), extra entry {} skipped.", spawnId, entry);
2562 } while (variantResult->NextRow());
2563
2564 LOG_INFO("server.loading", ">> Loaded {} creature spawn variants", variantCount);
2565 }
2566
2567 LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2568 LOG_INFO("server.loading", " ");
2569}
@ CREATURE_FLAG_EXTRA_INSTANCE_BIND
Definition CreatureData.h:46
Difficulty
Definition DBCEnums.h:266
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition DBCStores.cpp:773
std::int16_t int16
Definition Define.h:104
@ CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA
Definition WorldConfig.h:115
@ WORLD_UPD_CREATURE_ZONE_AREA_DATA
Definition WorldDatabase.h:116
uint32 ScriptId
Definition SpawnData.h:76
uint32 poolId
Definition SpawnData.h:79

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(), CreatureData::id, 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::poolId, 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 ( )
2748{
2749 uint32 oldMSTime = getMSTime();
2750
2751 QueryResult result = WorldDatabase.Query("SELECT GUID, SparringPCT FROM creature_sparring");
2752
2753 if (!result)
2754 {
2755 LOG_WARN("server.loading", ">> Loaded 0 sparring data. DB table `creature_sparring` is empty.");
2756 LOG_INFO("server.loading", " ");
2757 return;
2758 }
2759
2760 uint32 count = 0;
2761 do
2762 {
2763 Field* fields = result->Fetch();
2764
2765 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2766 float sparringHealthPct = fields[1].Get<float>();
2767
2768 if (!GetCreatureData(spawnId))
2769 {
2770 LOG_ERROR("sql.sql", "Entry {} has a record in `creature_sparring` but doesn't exist in `creatures` table");
2771 continue;
2772 }
2773
2774 _creatureSparringStore[spawnId].push_back(sparringHealthPct);
2775
2776 ++count;
2777 } while (result->NextRow());
2778
2779 LOG_INFO("server.loading", ">> Loaded {} sparring data in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2780 LOG_INFO("server.loading", " ");
2781}

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:767
@ 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:1186

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 ( )
6283{
6285
6286 std::set<uint32> evt_scripts;
6287 // Load all possible script entries from gameobjects
6289 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
6290 if (uint32 eventId = itr->second.GetEventScriptId())
6291 evt_scripts.insert(eventId);
6292
6293 // Load all possible script entries from spells
6294 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
6295 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
6296 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
6297 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
6298 if (spell->Effects[j].MiscValue)
6299 evt_scripts.insert(spell->Effects[j].MiscValue);
6300
6301 for (std::size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
6302 {
6303 for (std::size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
6304 {
6305 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
6306
6307 if (node->arrivalEventID)
6308 evt_scripts.insert(node->arrivalEventID);
6309
6310 if (node->departureEventID)
6311 evt_scripts.insert(node->departureEventID);
6312 }
6313 }
6314
6315 // Then check if all scripts are in above list of possible script entries
6316 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
6317 {
6318 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
6319 if (itr2 == evt_scripts.end())
6320 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 {}",
6321 itr->first, SPELL_EFFECT_SEND_EVENT);
6322 }
6323}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition DBCStores.cpp:191
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1673
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition GameObject.h:42
ScriptMapMap sEventScripts
Definition ObjectMgr.cpp:61
@ SCRIPTS_EVENT
Definition ObjectMgr.h:152
@ SPELL_EFFECT_SEND_EVENT
Definition SharedDefines.h:827
GameObjectTemplateContainer const * GetGameObjectTemplates() const
Definition ObjectMgr.h:766
void LoadScripts(ScriptsType type)
Definition ObjectMgr.cpp:5940
Definition DBCStructure.h:2009
uint32 arrivalEventID
Definition DBCStructure.h:2019
uint32 departureEventID
Definition DBCStructure.h:2020

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 ( )
8060{
8061 uint32 oldMSTime = getMSTime();
8062
8063 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
8064
8065 if (!result)
8066 {
8067 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
8068 LOG_INFO("server.loading", " ");
8069 return;
8070 }
8071
8072 uint32 count = 0;
8073
8074 do
8075 {
8076 Field* fields = result->Fetch();
8077 uint8 level = fields[0].Get<uint8>();
8078 uint32 basexp = fields[1].Get<int32>();
8079 _baseXPTable[level] = basexp;
8080 ++count;
8081 } while (result->NextRow());
8082
8083 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8084 LOG_INFO("server.loading", " ");
8085}

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

◆ LoadFactionChangeAchievements()

void ObjectMgr::LoadFactionChangeAchievements ( )
10822{
10823 uint32 oldMSTime = getMSTime();
10824
10825 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_achievement");
10826
10827 if (!result)
10828 {
10829 LOG_WARN("server.loading", ">> Loaded 0 faction change achievement pairs. DB table `player_factionchange_achievement` is empty.");
10830 LOG_INFO("server.loading", " ");
10831 return;
10832 }
10833
10834 uint32 count = 0;
10835
10836 do
10837 {
10838 Field* fields = result->Fetch();
10839
10840 uint32 alliance = fields[0].Get<uint32>();
10841 uint32 horde = fields[1].Get<uint32>();
10842
10843 if (!sAchievementStore.LookupEntry(alliance))
10844 LOG_ERROR("sql.sql", "Achievement {} (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance);
10845 else if (!sAchievementStore.LookupEntry(horde))
10846 LOG_ERROR("sql.sql", "Achievement {} (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde);
10847 else
10848 FactionChangeAchievements[alliance] = horde;
10849
10850 ++count;
10851 } while (result->NextRow());
10852
10853 LOG_INFO("server.loading", ">> Loaded {} faction change achievement pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10854 LOG_INFO("server.loading", " ");
10855}
CharacterConversionMap FactionChangeAchievements
Definition ObjectMgr.h:1504

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

◆ LoadFactionChangeItems()

void ObjectMgr::LoadFactionChangeItems ( )
10858{
10859 uint32 oldMSTime = getMSTime();
10860
10861 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
10862
10863 if (!result)
10864 {
10865 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
10866 LOG_INFO("server.loading", " ");
10867 return;
10868 }
10869
10870 uint32 count = 0;
10871
10872 do
10873 {
10874 Field* fields = result->Fetch();
10875
10876 uint32 alliance = fields[0].Get<uint32>();
10877 uint32 horde = fields[1].Get<uint32>();
10878
10879 if (!GetItemTemplate(alliance))
10880 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
10881 else if (!GetItemTemplate(horde))
10882 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
10883 else
10884 FactionChangeItems[alliance] = horde;
10885
10886 ++count;
10887 } while (result->NextRow());
10888
10889 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10890 LOG_INFO("server.loading", " ");
10891}
CharacterConversionMap FactionChangeItems
Definition ObjectMgr.h:1505

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

◆ LoadFactionChangeQuests()

void ObjectMgr::LoadFactionChangeQuests ( )
10894{
10895 uint32 oldMSTime = getMSTime();
10896
10897 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
10898
10899 if (!result)
10900 {
10901 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
10902 LOG_INFO("server.loading", " ");
10903 return;
10904 }
10905
10906 uint32 count = 0;
10907
10908 do
10909 {
10910 Field* fields = result->Fetch();
10911
10912 uint32 alliance = fields[0].Get<uint32>();
10913 uint32 horde = fields[1].Get<uint32>();
10914
10915 if (!GetQuestTemplate(alliance))
10916 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
10917 else if (!GetQuestTemplate(horde))
10918 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
10919 else
10920 FactionChangeQuests[alliance] = horde;
10921
10922 ++count;
10923 } while (result->NextRow());
10924
10925 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10926 LOG_INFO("server.loading", " ");
10927}
CharacterConversionMap FactionChangeQuests
Definition ObjectMgr.h:1506

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

◆ LoadFactionChangeReputations()

void ObjectMgr::LoadFactionChangeReputations ( )
10930{
10931 uint32 oldMSTime = getMSTime();
10932
10933 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
10934
10935 if (!result)
10936 {
10937 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
10938 LOG_INFO("server.loading", " ");
10939 return;
10940 }
10941
10942 uint32 count = 0;
10943
10944 do
10945 {
10946 Field* fields = result->Fetch();
10947
10948 uint32 alliance = fields[0].Get<uint32>();
10949 uint32 horde = fields[1].Get<uint32>();
10950
10951 if (!sFactionStore.LookupEntry(alliance))
10952 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
10953 else if (!sFactionStore.LookupEntry(horde))
10954 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
10955 else
10956 FactionChangeReputation[alliance] = horde;
10957
10958 ++count;
10959 } while (result->NextRow());
10960
10961 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10962 LOG_INFO("server.loading", " ");
10963}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
CharacterConversionMap FactionChangeReputation
Definition ObjectMgr.h:1507

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

◆ LoadFactionChangeSpells()

void ObjectMgr::LoadFactionChangeSpells ( )
10966{
10967 uint32 oldMSTime = getMSTime();
10968
10969 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
10970
10971 if (!result)
10972 {
10973 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
10974 LOG_INFO("server.loading", " ");
10975 return;
10976 }
10977
10978 uint32 count = 0;
10979
10980 do
10981 {
10982 Field* fields = result->Fetch();
10983
10984 uint32 alliance = fields[0].Get<uint32>();
10985 uint32 horde = fields[1].Get<uint32>();
10986
10987 if (!sSpellMgr->GetSpellInfo(alliance))
10988 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
10989 else if (!sSpellMgr->GetSpellInfo(horde))
10990 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
10991 else
10992 FactionChangeSpells[alliance] = horde;
10993
10994 ++count;
10995 } while (result->NextRow());
10996
10997 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10998 LOG_INFO("server.loading", " ");
10999}
CharacterConversionMap FactionChangeSpells
Definition ObjectMgr.h:1508

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

◆ LoadFactionChangeTitles()

void ObjectMgr::LoadFactionChangeTitles ( )
11002{
11003 uint32 oldMSTime = getMSTime();
11004
11005 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
11006
11007 if (!result)
11008 {
11009 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
11010 return;
11011 }
11012
11013 uint32 count = 0;
11014
11015 do
11016 {
11017 Field* fields = result->Fetch();
11018
11019 uint32 alliance = fields[0].Get<uint32>();
11020 uint32 horde = fields[1].Get<uint32>();
11021
11022 if (!sCharTitlesStore.LookupEntry(alliance))
11023 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
11024 else if (!sCharTitlesStore.LookupEntry(horde))
11025 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
11026 else
11027 FactionChangeTitles[alliance] = horde;
11028
11029 ++count;
11030 } while (result->NextRow());
11031
11032 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11033 LOG_INFO("server.loading", " ");
11034}
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
CharacterConversionMap FactionChangeTitles
Definition ObjectMgr.h:1509

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

◆ LoadFishingBaseSkillLevel()

void ObjectMgr::LoadFishingBaseSkillLevel ( )
9646{
9647 uint32 oldMSTime = getMSTime();
9648
9649 _fishingBaseForAreaStore.clear(); // for reload case
9650
9651 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
9652
9653 if (!result)
9654 {
9655 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
9656 LOG_INFO("server.loading", " ");
9657 return;
9658 }
9659
9660 uint32 count = 0;
9661
9662 do
9663 {
9664 Field* fields = result->Fetch();
9665 uint32 entry = fields[0].Get<uint32>();
9666 int32 skill = fields[1].Get<int16>();
9667
9668 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
9669 if (!fArea)
9670 {
9671 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
9672 continue;
9673 }
9674
9675 _fishingBaseForAreaStore[entry] = skill;
9676 ++count;
9677 } while (result->NextRow());
9678
9679 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9680 LOG_INFO("server.loading", " ");
9681}

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:82

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.
3110{
3111 GameObjectData const* data = GetGameObjectData(spawnId);
3112 if (data)
3113 return data;
3114
3115 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
3116 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, "
3117 "ScriptName "
3118 "FROM gameobject WHERE gameobject.guid = {}", spawnId);
3119
3120 if (!result)
3121 return nullptr;
3122
3123 Field* fields = result->Fetch();
3124 uint32 entry = fields[1].Get<uint32>();
3125
3126 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
3127 if (!gInfo)
3128 {
3129 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non-existing gameobject entry {}, skipped.", spawnId, entry);
3130 return nullptr;
3131 }
3132
3133 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
3134 {
3135 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry {} GoType: {}) with an invalid displayId ({}), not loaded.",
3136 spawnId, entry, gInfo->type, gInfo->displayId);
3137 return nullptr;
3138 }
3139
3141 goData.id = entry;
3142 goData.mapid = fields[2].Get<uint16>();
3143 goData.posX = fields[3].Get<float>();
3144 goData.posY = fields[4].Get<float>();
3145 goData.posZ = fields[5].Get<float>();
3146 goData.orientation = fields[6].Get<float>();
3147 goData.rotation.x = fields[7].Get<float>();
3148 goData.rotation.y = fields[8].Get<float>();
3149 goData.rotation.z = fields[9].Get<float>();
3150 goData.rotation.w = fields[10].Get<float>();
3151 goData.spawntimesecs = fields[11].Get<int32>();
3152 goData.animprogress = fields[12].Get<uint8>();
3153 goData.artKit = 0;
3154 goData.ScriptId = GetScriptId(fields[16].Get<std::string>());
3155
3156 if (!goData.ScriptId)
3157 goData.ScriptId = gInfo->ScriptId;
3158
3159 MapEntry const* mapEntry = sMapStore.LookupEntry(goData.mapid);
3160 if (!mapEntry)
3161 {
3162 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existing map (Id: {}), skipped.", spawnId, entry, goData.mapid);
3163 _gameObjectDataStore.erase(spawnId);
3164 return nullptr;
3165 }
3166
3167 if (goData.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
3168 {
3169 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);
3170 }
3171
3172 uint32 go_state = fields[13].Get<uint8>();
3173 if (go_state >= MAX_GO_STATE)
3174 {
3175 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skipped.", spawnId, entry, go_state);
3176 _gameObjectDataStore.erase(spawnId);
3177 return nullptr;
3178 }
3179 goData.go_state = GOState(go_state);
3180
3181 goData.spawnMask = fields[14].Get<uint8>();
3182 goData.phaseMask = fields[15].Get<uint32>();
3183
3184 if (goData.rotation.x < -1.0f || goData.rotation.x > 1.0f)
3185 {
3186 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skipped.", spawnId, entry, goData.rotation.x);
3187 _gameObjectDataStore.erase(spawnId);
3188 return nullptr;
3189 }
3190
3191 if (goData.rotation.y < -1.0f || goData.rotation.y > 1.0f)
3192 {
3193 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skipped.", spawnId, entry, goData.rotation.y);
3194 _gameObjectDataStore.erase(spawnId);
3195 return nullptr;
3196 }
3197
3198 if (goData.rotation.z < -1.0f || goData.rotation.z > 1.0f)
3199 {
3200 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skipped.", spawnId, entry, goData.rotation.z);
3201 _gameObjectDataStore.erase(spawnId);
3202 return nullptr;
3203 }
3204
3205 if (goData.rotation.w < -1.0f || goData.rotation.w > 1.0f)
3206 {
3207 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skipped.", spawnId, entry, goData.rotation.w);
3208 _gameObjectDataStore.erase(spawnId);
3209 return nullptr;
3210 }
3211
3212 if (fabs(goData.rotation.x * goData.rotation.x + goData.rotation.y * goData.rotation.y +
3213 goData.rotation.z * goData.rotation.z + goData.rotation.w * goData.rotation.w - 1.0f) >= 1e-5f)
3214 {
3215 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);
3216 goData.rotation = G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(goData.orientation, 0.0f, 0.0f));
3217 }
3218
3219 if (!MapMgr::IsValidMapCoord(goData.mapid, goData.posX, goData.posY, goData.posZ, goData.orientation))
3220 {
3221 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skipped.", spawnId, entry);
3222 _gameObjectDataStore.erase(spawnId);
3223 return nullptr;
3224 }
3225
3226 if (goData.phaseMask == 0)
3227 {
3228 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, entry);
3229 goData.phaseMask = 1;
3230 }
3231
3232 return &goData;
3233}
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 ( )
9415{
9416 uint32 oldMSTime = getMSTime();
9417
9418 if (GetGameObjectTemplates()->empty())
9419 {
9420 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
9421 LOG_INFO("server.loading", " ");
9422 return;
9423 }
9424
9425 uint32 count = 0;
9426
9427 // collect GO entries for GO that must activated
9429 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
9430 {
9431 itr->second.IsForQuests = false;
9432 switch (itr->second.type)
9433 {
9435 itr->second.IsForQuests = true;
9436 ++count;
9437 break;
9439 {
9440 // scan GO chest with loot including quest items
9441 uint32 loot_id = (itr->second.GetLootId());
9442
9443 // find quest loot for GO
9444 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
9445 {
9446 itr->second.IsForQuests = true;
9447 ++count;
9448 }
9449 break;
9450 }
9452 {
9453 if (itr->second._generic.questID > 0) //quests objects
9454 {
9455 itr->second.IsForQuests = true;
9456 ++count;
9457 }
9458 break;
9459 }
9461 {
9462 if (itr->second.spellFocus.questID > 0) //quests objects
9463 {
9464 itr->second.IsForQuests = true;
9465 ++count;
9466 }
9467 break;
9468 }
9470 {
9471 if (itr->second.goober.questId > 0) //quests objects
9472 {
9473 itr->second.IsForQuests = true;
9474 ++count;
9475 }
9476 break;
9477 }
9478 default:
9479 break;
9480 }
9481 }
9482
9483 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9484 LOG_INFO("server.loading", " ");
9485}
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 ( )
7704{
7705 uint32 oldMSTime = getMSTime();
7706
7707 _gameObjectLocaleStore.clear(); // need for reload case
7708
7709 // 0 1 2 3
7710 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7711 if (!result)
7712 return;
7713
7714 do
7715 {
7716 Field* fields = result->Fetch();
7717
7718 uint32 ID = fields[0].Get<uint32>();
7719
7720 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7721 if (locale == LOCALE_enUS)
7722 continue;
7723
7725 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7726 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7727 } while (result->NextRow());
7728
7729 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7730}
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 ( )
8920{
8921 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8922
8923 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8924 {
8925 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8926 if (!goInfo)
8927 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8928 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8929 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8930 }
8931}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
11095{
11096 uint32 oldMSTime = getMSTime();
11097
11098 // 0 1 2
11099 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
11100
11101 if (!result)
11102 {
11103 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
11104 return;
11105 }
11106
11107 uint32 count = 0;
11108 do
11109 {
11110 Field* fields = result->Fetch();
11111
11112 uint32 entry = fields[0].Get<uint32>();
11113 uint32 item = fields[1].Get<uint32>();
11114 uint32 idx = fields[2].Get<uint32>();
11115
11116 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
11117 if (!goInfo)
11118 {
11119 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
11120 continue;
11121 };
11122
11123 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
11124 if (!dbcData)
11125 {
11126 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
11127 continue;
11128 };
11129
11130 _gameObjectQuestItemStore[entry].push_back(item);
11131
11132 ++count;
11133 } while (result->NextRow());
11134
11135 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11136 LOG_INFO("server.loading", " ");
11137}

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

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8906{
8907 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8908
8909 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8910 {
8911 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8912 if (!goInfo)
8913 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8914 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8915 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8916 }
8917}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

void ObjectMgr::LoadGameobjects ( )
2921{
2922 uint32 oldMSTime = getMSTime();
2923
2924 // 0 1 2 3 4 5 6
2925 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
2926 // 7 8 9 10 11 12 13 14 15 16 17
2927 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, "
2928 // 18
2929 "ScriptName "
2930 "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
2931 "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
2932
2933 if (!result)
2934 {
2935 LOG_WARN("server.loading", ">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
2936 LOG_INFO("server.loading", " ");
2937 return;
2938 }
2939
2941 LOG_INFO("server.loading", "Calculating zone and area fields. This may take a moment...");
2942
2943 // build single time for check spawnmask
2944 std::map<uint32, uint32> spawnMasks;
2945 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2946 if (sMapStore.LookupEntry(i))
2947 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2949 spawnMasks[i] |= (1 << k);
2950
2951 _gameObjectDataStore.rehash(result->GetRowCount());
2952 do
2953 {
2954 Field* fields = result->Fetch();
2955
2956 ObjectGuid::LowType guid = fields[0].Get<uint32>();
2957 uint32 entry = fields[1].Get<uint32>();
2958
2959 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
2960 if (!gInfo)
2961 {
2962 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non existing gameobject entry {}, skipped.", guid, entry);
2963 continue;
2964 }
2965
2966 if (!gInfo->displayId)
2967 {
2968 switch (gInfo->type)
2969 {
2972 break;
2973 default:
2974 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) doesn't have a displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2975 break;
2976 }
2977 }
2978
2979 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
2980 {
2981 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) has an invalid displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2982 continue;
2983 }
2984
2986
2987 data.spawnId = guid;
2988 data.id = entry;
2989 data.mapid = fields[2].Get<uint16>();
2990 data.posX = fields[3].Get<float>();
2991 data.posY = fields[4].Get<float>();
2992 data.posZ = fields[5].Get<float>();
2993 data.orientation = fields[6].Get<float>();
2994 data.rotation.x = fields[7].Get<float>();
2995 data.rotation.y = fields[8].Get<float>();
2996 data.rotation.z = fields[9].Get<float>();
2997 data.rotation.w = fields[10].Get<float>();
2998 data.spawntimesecs = fields[11].Get<int32>();
2999 data.ScriptId = GetScriptId(fields[18].Get<std::string>());
3000 data.spawnGroupId = 0;
3001 if (!data.ScriptId)
3002 data.ScriptId = gInfo->ScriptId;
3003
3004 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
3005 if (!mapEntry)
3006 {
3007 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existed map (Id: {}), skip", guid, data.id, data.mapid);
3008 continue;
3009 }
3010
3011 if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
3012 {
3013 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);
3014 }
3015
3016 data.animprogress = fields[12].Get<uint8>();
3017 data.artKit = 0;
3018
3019 uint32 go_state = fields[13].Get<uint8>();
3020 if (go_state >= MAX_GO_STATE)
3021 {
3022 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skip", guid, data.id, go_state);
3023 continue;
3024 }
3025 data.go_state = GOState(go_state);
3026
3027 data.spawnMask = fields[14].Get<uint8>();
3028
3029 if (!_transportMaps.count(data.mapid))
3030 {
3031 if (data.spawnMask & ~spawnMasks[data.mapid])
3032 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);
3033 }
3034 else
3035 data.spawnGroupId = 1; // force compatibility group for transport spawns
3036
3037 data.phaseMask = fields[15].Get<uint32>();
3038 int16 gameEvent = fields[16].Get<int16>();
3039 data.poolId = fields[17].Get<uint32>();
3040
3041 if (data.rotation.x < -1.0f || data.rotation.x > 1.0f)
3042 {
3043 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skip", guid, data.id, data.rotation.x);
3044 continue;
3045 }
3046
3047 if (data.rotation.y < -1.0f || data.rotation.y > 1.0f)
3048 {
3049 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skip", guid, data.id, data.rotation.y);
3050 continue;
3051 }
3052
3053 if (data.rotation.z < -1.0f || data.rotation.z > 1.0f)
3054 {
3055 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skip", guid, data.id, data.rotation.z);
3056 continue;
3057 }
3058
3059 if (data.rotation.w < -1.0f || data.rotation.w > 1.0f)
3060 {
3061 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skip", guid, data.id, data.rotation.w);
3062 continue;
3063 }
3064
3065 if (fabs(data.rotation.x * data.rotation.x + data.rotation.y * data.rotation.y +
3066 data.rotation.z * data.rotation.z + data.rotation.w * data.rotation.w - 1.0f) >= 1e-5f)
3067 {
3068 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);
3069 data.rotation = G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(data.orientation, 0.0f, 0.0f));
3070 }
3071
3072 if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
3073 {
3074 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
3075 continue;
3076 }
3077
3078 if (data.phaseMask == 0)
3079 {
3080 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
3081 data.phaseMask = 1;
3082 }
3083
3085 {
3086 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
3087 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
3088
3090
3091 stmt->SetData(0, zoneId);
3092 stmt->SetData(1, areaId);
3093 stmt->SetData(2, guid);
3094
3095 WorldDatabase.Execute(stmt);
3096 }
3097
3098 if (gameEvent == 0) // if not this is to be managed by GameEvent System
3099 AddGameobjectToGrid(guid, &data);
3100 } while (result->NextRow());
3101
3102 LOG_INFO("server.loading", ">> Loaded {} Gameobjects in {} ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
3103 LOG_INFO("server.loading", " ");
3104}
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1570
@ CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldConfig.h:116
@ WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldDatabase.h:117

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::poolId, 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 ( )
2240{
2241 uint32 oldMSTime = getMSTime();
2242
2243 _goSummonDataStore.clear();
2244
2245 // 0 1 2 3 4 5 6 7 8 9 10 11 12
2246 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");
2247
2248 if (!result)
2249 {
2250 LOG_WARN("server.loading", ">> Loaded 0 gameobject summons. DB table `gameobject_summon_groups` is empty.");
2251 return;
2252 }
2253
2254 uint32 count = 0;
2255 do
2256 {
2257 Field* fields = result->Fetch();
2258
2259 uint32 summonerId = fields[0].Get<uint32>();
2260 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2261 uint8 group = fields[2].Get<uint8>();
2262
2263 switch (summonerType)
2264 {
2266 if (!GetCreatureTemplate(summonerId))
2267 {
2268 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2269 continue;
2270 }
2271 break;
2273 if (!GetGameObjectTemplate(summonerId))
2274 {
2275 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2276 continue;
2277 }
2278 break;
2279 case SUMMONER_TYPE_MAP:
2280 if (!sMapStore.LookupEntry(summonerId))
2281 {
2282 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2283 continue;
2284 }
2285 break;
2286 default:
2287 LOG_ERROR("sql.sql", "Table `gameobject_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2288 continue;
2289 }
2290
2292 data.entry = fields[3].Get<uint32>();
2293
2294 if (!GetGameObjectTemplate(data.entry))
2295 {
2296 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);
2297 continue;
2298 }
2299
2300 float posX = fields[4].Get<float>();
2301 float posY = fields[5].Get<float>();
2302 float posZ = fields[6].Get<float>();
2303 float orientation = fields[7].Get<float>();
2304
2305 data.pos.Relocate(posX, posY, posZ, orientation);
2306
2307 data.rot = G3D::Quat(fields[8].Get<float>(), fields[9].Get<float>(), fields[10].Get<float>(), fields[11].Get<float>());
2308 data.respawnTime = fields[12].Get<uint32>();
2309
2310 TempSummonGroupKey key(summonerId, summonerType, group);
2311 _goSummonDataStore[key].push_back(data);
2312
2313 ++count;
2314 } while (result->NextRow());
2315
2316 LOG_INFO("server.loading", ">> Loaded {} Gameobject Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2317 LOG_INFO("server.loading", " ");
2318}
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 ( )
7792{
7793 uint32 oldMSTime = getMSTime();
7794
7795 // 0 1 2 3 4 5 6 7
7796 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7797 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7798 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7799 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7800 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7801 "FROM gameobject_template");
7802
7803 if (!result)
7804 {
7805 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7806 LOG_INFO("server.loading", " ");
7807 return;
7808 }
7809
7810 _gameObjectTemplateStore.rehash(result->GetRowCount());
7811 uint32 count = 0;
7812 do
7813 {
7814 Field* fields = result->Fetch();
7815
7816 uint32 entry = fields[0].Get<uint32>();
7817
7819
7820 got.entry = entry;
7821 got.type = uint32(fields[1].Get<uint8>());
7822 got.displayId = fields[2].Get<uint32>();
7823 got.name = fields[3].Get<std::string>();
7824 got.IconName = fields[4].Get<std::string>();
7825 got.castBarCaption = fields[5].Get<std::string>();
7826 got.unk1 = fields[6].Get<std::string>();
7827 got.size = fields[7].Get<float>();
7828
7829 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7830 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7831
7832 got.AIName = fields[32].Get<std::string>();
7833 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7834 got.IsForQuests = false;
7835
7836 // Checks
7837 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7838 {
7839 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7840 }
7841
7842 switch (got.type)
7843 {
7844 case GAMEOBJECT_TYPE_DOOR: //0
7845 {
7846 if (got.door.lockId)
7847 CheckGOLockId(&got, got.door.lockId, 1);
7848 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7849 break;
7850 }
7851 case GAMEOBJECT_TYPE_BUTTON: //1
7852 {
7853 if (got.button.lockId)
7854 CheckGOLockId(&got, got.button.lockId, 1);
7855 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7856 break;
7857 }
7859 {
7860 if (got.questgiver.lockId)
7861 CheckGOLockId(&got, got.questgiver.lockId, 0);
7862 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7863 break;
7864 }
7865 case GAMEOBJECT_TYPE_CHEST: //3
7866 {
7867 if (got.chest.lockId)
7868 CheckGOLockId(&got, got.chest.lockId, 0);
7869
7870 CheckGOConsumable(&got, got.chest.consumable, 3);
7871
7872 if (got.chest.linkedTrapId) // linked trap
7873 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7874 break;
7875 }
7876 case GAMEOBJECT_TYPE_TRAP: //6
7877 {
7878 if (got.trap.lockId)
7879 CheckGOLockId(&got, got.trap.lockId, 0);
7880 break;
7881 }
7882 case GAMEOBJECT_TYPE_CHAIR: //7
7883 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7884 break;
7886 {
7887 if (got.spellFocus.focusId)
7888 {
7889 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7890 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7891 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7892 }
7893
7894 if (got.spellFocus.linkedTrapId) // linked trap
7895 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7896 break;
7897 }
7898 case GAMEOBJECT_TYPE_GOOBER: //10
7899 {
7900 if (got.goober.lockId)
7901 CheckGOLockId(&got, got.goober.lockId, 0);
7902
7903 CheckGOConsumable(&got, got.goober.consumable, 3);
7904
7905 if (got.goober.pageId) // pageId
7906 {
7907 if (!GetPageText(got.goober.pageId))
7908 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7909 entry, got.type, got.goober.pageId, got.goober.pageId);
7910 }
7911 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7912 if (got.goober.linkedTrapId) // linked trap
7913 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7914 break;
7915 }
7917 {
7918 if (got.areadamage.lockId)
7919 CheckGOLockId(&got, got.areadamage.lockId, 0);
7920 break;
7921 }
7922 case GAMEOBJECT_TYPE_CAMERA: //13
7923 {
7924 if (got.camera.lockId)
7925 CheckGOLockId(&got, got.camera.lockId, 0);
7926 break;
7927 }
7929 {
7930 if (got.moTransport.taxiPathId)
7931 {
7932 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7933 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7934 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7935 }
7936 if (uint32 transportMap = got.moTransport.mapID)
7937 _transportMaps.insert(transportMap);
7938 break;
7939 }
7941 break;
7943 {
7944 // always must have spell
7945 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7946 break;
7947 }
7948 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7949 {
7950 if (got.flagstand.lockId)
7951 CheckGOLockId(&got, got.flagstand.lockId, 0);
7952 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7953 break;
7954 }
7956 {
7957 if (got.fishinghole.lockId)
7958 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7959 break;
7960 }
7961 case GAMEOBJECT_TYPE_FLAGDROP: //26
7962 {
7963 if (got.flagdrop.lockId)
7964 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7965 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7966 break;
7967 }
7969 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7970 break;
7971 }
7972
7973 ++count;
7974 } while (result->NextRow());
7975
7976 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7977 LOG_INFO("server.loading", " ");
7978}
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
#define sGameObjectAIRegistry
Definition GameObjectAIFactory.h:49
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7772
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7751
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition ObjectMgr.cpp:7760
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7781
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7741
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7732
@ 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:6524
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 ( )
7981{
7982 uint32 oldMSTime = getMSTime();
7983
7984 // 0 1 2 3 4 5 6 7 8
7985 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
7986
7987 if (!result)
7988 {
7989 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
7990 LOG_INFO("server.loading", " ");
7991 return;
7992 }
7993
7994 uint32 count = 0;
7995 do
7996 {
7997 Field* fields = result->Fetch();
7998
7999 uint32 entry = fields[0].Get<uint32>();
8000
8001 GameObjectTemplate const* got = GetGameObjectTemplate(entry);
8002 if (!got)
8003 {
8004 LOG_ERROR("sql.sql",
8005 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
8006 entry);
8007 continue;
8008 }
8009
8011 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
8012 gameObjectAddon.flags = fields[2].Get<uint32>();
8013 gameObjectAddon.mingold = fields[3].Get<uint32>();
8014 gameObjectAddon.maxgold = fields[4].Get<uint32>();
8015
8016 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
8017 {
8018 uint32 artKitID = fields[5 + i].Get<uint32>();
8019 if (!artKitID)
8020 continue;
8021
8022 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
8023 {
8024 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
8025 continue;
8026 }
8027
8028 gameObjectAddon.artKits[i] = artKitID;
8029 }
8030
8031 // checks
8032 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
8033 LOG_ERROR("sql.sql",
8034 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
8035 entry, gameObjectAddon.faction);
8036
8037 if (gameObjectAddon.maxgold > 0)
8038 {
8039 switch (got->type)
8040 {
8043 break;
8044 default:
8045 LOG_ERROR("sql.sql",
8046 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
8047 entry, got->type);
8048 break;
8049 }
8050 }
8051
8052 ++count;
8053 } while (result->NextRow());
8054
8055 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8056 LOG_INFO("server.loading", " ");
8057}
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 ( )
9786{
9787 uint32 oldMSTime = getMSTime();
9788
9789 _gameTeleStore.clear(); // for reload case
9790
9791 // 0 1 2 3 4 5 6
9792 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
9793
9794 if (!result)
9795 {
9796 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
9797 LOG_INFO("server.loading", " ");
9798 return;
9799 }
9800
9801 uint32 count = 0;
9802
9803 do
9804 {
9805 Field* fields = result->Fetch();
9806
9807 uint32 id = fields[0].Get<uint32>();
9808
9809 GameTele gt;
9810
9811 gt.position_x = fields[1].Get<float>();
9812 gt.position_y = fields[2].Get<float>();
9813 gt.position_z = fields[3].Get<float>();
9814 gt.orientation = fields[4].Get<float>();
9815 gt.mapId = fields[5].Get<uint16>();
9816 gt.name = fields[6].Get<std::string>();
9817
9818 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
9819 {
9820 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
9821 continue;
9822 }
9823
9824 if (!Utf8toWStr(gt.name, gt.wnameLow))
9825 {
9826 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
9827 continue;
9828 }
9829
9830 wstrToLower(gt.wnameLow);
9831
9832 _gameTeleStore[id] = gt;
9833
9834 ++count;
9835 } while (result->NextRow());
9836
9837 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9838 LOG_INFO("server.loading", " ");
9839}
float position_x
Definition ObjectMgr.h:136

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

◆ LoadGossipMenu()

void ObjectMgr::LoadGossipMenu ( )
10242{
10243 uint32 oldMSTime = getMSTime();
10244
10245 _gossipMenusStore.clear();
10246
10247 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
10248
10249 if (!result)
10250 {
10251 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
10252 LOG_INFO("server.loading", " ");
10253 return;
10254 }
10255
10256 do
10257 {
10258 Field* fields = result->Fetch();
10259
10260 GossipMenus gMenu;
10261
10262 gMenu.MenuID = fields[0].Get<uint32>();
10263 gMenu.TextID = fields[1].Get<uint32>();
10264
10265 if (!GetGossipText(gMenu.TextID))
10266 {
10267 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
10268 continue;
10269 }
10270
10271 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
10272 } while (result->NextRow());
10273
10274 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
10275 LOG_INFO("server.loading", " ");
10276}
GossipText const * GetGossipText(uint32 Text_ID) const
Definition ObjectMgr.cpp:6702
Definition ObjectMgr.h:630
uint32 TextID
Definition ObjectMgr.h:632
uint32 MenuID
Definition ObjectMgr.h:631

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

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
10279{
10280 uint32 oldMSTime = getMSTime();
10281
10282 _gossipMenuItemsStore.clear();
10283
10284 QueryResult result = WorldDatabase.Query(
10285 // 0 1 2 3 4 5 6 7 8 9 10 11 12
10286 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
10287 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
10288
10289 if (!result)
10290 {
10291 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
10292 LOG_INFO("server.loading", " ");
10293 return;
10294 }
10295
10296 do
10297 {
10298 Field* fields = result->Fetch();
10299
10300 GossipMenuItems gMenuItem;
10301
10302 gMenuItem.MenuID = fields[0].Get<uint32>();
10303 gMenuItem.OptionID = fields[1].Get<uint16>();
10304 gMenuItem.OptionIcon = fields[2].Get<uint32>();
10305 gMenuItem.OptionText = fields[3].Get<std::string>();
10306 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
10307 gMenuItem.OptionType = fields[5].Get<uint8>();
10308 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
10309 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
10310 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
10311 gMenuItem.BoxCoded = fields[9].Get<bool>();
10312 gMenuItem.BoxMoney = fields[10].Get<uint32>();
10313 gMenuItem.BoxText = fields[11].Get<std::string>();
10314 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
10315
10316 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
10317 {
10318 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);
10319 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
10320 }
10321
10323 {
10324 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
10325 gMenuItem.OptionBroadcastTextID = 0;
10326 }
10327
10328 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
10329 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);
10330
10331 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
10332 {
10333 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
10334 gMenuItem.ActionPoiID = 0;
10335 }
10336
10337 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
10338 {
10339 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
10340 gMenuItem.BoxBroadcastTextID = 0;
10341 }
10342
10343 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
10344 } while (result->NextRow());
10345
10346 // Warn if any trainer creature templates reference a GossipMenuId that has no gossip_menu_option entries
10347 // This will cause the gossip menu to fallback to MenuID 0 at runtime which will display: "I wish to unlearn my talents."
10348 std::set<uint32> checkedMenuIds;
10349 for (auto const& [entry, tmpl] : _creatureTemplateStore)
10350 {
10351 uint32 menuId = tmpl.GossipMenuId;
10352 if (!menuId)
10353 continue;
10354
10355 if (!(tmpl.npcflag & UNIT_NPC_FLAG_TRAINER))
10356 continue;
10357
10358 if (checkedMenuIds.contains(menuId))
10359 continue;
10360
10361 checkedMenuIds.insert(menuId);
10362
10363 auto [first, second] = _gossipMenuItemsStore.equal_range(menuId);
10364 if (first == second)
10365 LOG_WARN("server.loading", "Trainer creature template references GossipMenuId {} has no `gossip_menu_option` entries. This will fallback to MenuID 0.", menuId);
10366 }
10367
10368 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
10369 LOG_INFO("server.loading", " ");
10370}
@ 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:935
BroadcastText const * GetBroadcastText(uint32 id) const
Definition ObjectMgr.h:1228
Definition ObjectMgr.h:612
uint8 OptionIcon
Definition ObjectMgr.h:615
uint32 BoxBroadcastTextID
Definition ObjectMgr.h:626
std::string OptionText
Definition ObjectMgr.h:616
uint32 ActionMenuID
Definition ObjectMgr.h:620
bool BoxCoded
Definition ObjectMgr.h:622
uint32 MenuID
Definition ObjectMgr.h:613
uint32 OptionNpcFlag
Definition ObjectMgr.h:619
uint32 ActionPoiID
Definition ObjectMgr.h:621
uint32 BoxMoney
Definition ObjectMgr.h:623
std::string BoxText
Definition ObjectMgr.h:624
uint32 OptionID
Definition ObjectMgr.h:614
uint32 OptionType
Definition ObjectMgr.h:618
uint32 OptionBroadcastTextID
Definition ObjectMgr.h:617

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 ( )
6711{
6712 uint32 oldMSTime = getMSTime();
6713
6714 QueryResult result = WorldDatabase.Query("SELECT ID, "
6715 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
6716 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
6717 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
6718 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
6719 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
6720 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
6721 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
6722 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
6723 "FROM npc_text");
6724
6725 if (!result)
6726 {
6727 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
6728 LOG_INFO("server.loading", " ");
6729 return;
6730 }
6731
6732 _gossipTextStore.rehash(result->GetRowCount());
6733
6734 uint32 count = 0;
6735 uint8 cic;
6736
6737 do
6738 {
6739 cic = 0;
6740
6741 Field* fields = result->Fetch();
6742
6743 uint32 id = fields[cic++].Get<uint32>();
6744 if (!id)
6745 {
6746 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
6747 continue;
6748 }
6749
6750 GossipText& gText = _gossipTextStore[id];
6751
6752 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6753 {
6754 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
6755 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
6756 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
6757 gText.Options[i].Language = fields[cic++].Get<uint8>();
6758 gText.Options[i].Probability = fields[cic++].Get<float>();
6759
6760 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
6761 {
6762 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
6763 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
6764 }
6765 }
6766
6767 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
6768 {
6769 if (gText.Options[i].BroadcastTextID)
6770 {
6772 {
6773 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
6774 gText.Options[i].BroadcastTextID = 0;
6775 }
6776 }
6777 }
6778
6779 count++;
6780 } while (result->NextRow());
6781
6782 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6783 LOG_INFO("server.loading", " ");
6784}
#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 ( )
6618{
6619 uint32 oldMSTime = getMSTime();
6620
6621 // 0 1 2 3
6622 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
6623 if (!result)
6624 {
6625 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
6626 LOG_INFO("server.loading", " ");
6627 return;
6628 }
6629
6630 uint32 count = 0;
6631 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
6632 do
6633 {
6634 Field* fields = result->Fetch();
6635 uint32 entry = fields[0].Get<uint32>();
6636 uint8 creditType = fields[1].Get<uint8>();
6637 uint32 creditEntry = fields[2].Get<uint32>();
6638 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
6639 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
6640 if (!dungeonEncounter)
6641 {
6642 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
6643 continue;
6644 }
6645
6646 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
6647 {
6648 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
6649 continue;
6650 }
6651
6652 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
6653 if (lastEncounterDungeon)
6654 {
6655 if (itr != dungeonLastBosses.end())
6656 {
6657 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]);
6658 continue;
6659 }
6660
6661 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
6662 }
6663
6664 switch (creditType)
6665 {
6667 {
6668 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
6669 if (!creatureInfo)
6670 {
6671 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
6672 continue;
6673 }
6674 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
6675 break;
6676 }
6678 {
6679 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
6680 if (!spellInfo)
6681 {
6682 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
6683 continue;
6684 }
6685 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
6686 break;
6687 }
6688 default:
6689 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
6690 continue;
6691 }
6692
6693 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
6694 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
6695 ++count;
6696 } while (result->NextRow());
6697
6698 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6699 LOG_INFO("server.loading", " ");
6700}
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition CreatureData.h:74
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
#define sLFGMgr
Definition LFGMgr.h:665
EncounterCreditType
Definition Map.h:162
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition Map.h:163
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition Map.h:164
std::list< DungeonEncounter const * > DungeonEncounterList
Definition ObjectMgr.h:716
@ SPELL_ATTR0_CU_ENCOUNTER_REWARD
Definition SpellInfo.h:208
Definition DBCStructure.h:893
Definition ObjectMgr.h:706

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 ( )
6567{
6568 uint32 oldMSTime = getMSTime();
6569
6570 // 0 1 2 4
6571 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
6572
6573 if (!result)
6574 {
6575 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `instance_template` is empty!");
6576 LOG_INFO("server.loading", " ");
6577 return;
6578 }
6579
6580 uint32 count = 0;
6581 do
6582 {
6583 Field* fields = result->Fetch();
6584
6585 uint16 mapID = fields[0].Get<uint16>();
6586
6587 if (!MapMgr::IsValidMAP(mapID, true))
6588 {
6589 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
6590 continue;
6591 }
6592
6593 InstanceTemplate instanceTemplate;
6594
6595 instanceTemplate.AllowMount = fields[3].Get<bool>();
6596 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
6597 instanceTemplate.ScriptId = GetScriptId(fields[2].Get<std::string>());
6598
6599 _instanceTemplateStore[mapID] = instanceTemplate;
6600
6601 ++count;
6602 } while (result->NextRow());
6603
6604 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6605 LOG_INFO("server.loading", " ");
6606}
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition MapMgr.cpp:312
bool AllowMount
Definition Map.h:129
uint32 ScriptId
Definition Map.h:128

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 ( )
3264{
3265 uint32 oldMSTime = getMSTime();
3266
3267 _itemLocaleStore.clear(); // need for reload case
3268
3269 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
3270 if (!result)
3271 return;
3272
3273 do
3274 {
3275 Field* fields = result->Fetch();
3276
3277 uint32 ID = fields[0].Get<uint32>();
3278
3279 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3280 if (locale == LOCALE_enUS)
3281 continue;
3282
3283 ItemLocale& data = _itemLocaleStore[ID];
3284 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3285 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
3286 } while (result->NextRow());
3287
3288 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
3289}
Definition ItemTemplate.h:836
std::vector< std::string > Description
Definition ItemTemplate.h:838
std::vector< std::string > Name
Definition ItemTemplate.h:837

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

◆ LoadItemSetNameLocales()

void ObjectMgr::LoadItemSetNameLocales ( )
3940{
3941 uint32 oldMSTime = getMSTime();
3942
3943 _itemSetNameLocaleStore.clear(); // need for reload case
3944
3945 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3946
3947 if (!result)
3948 return;
3949
3950 do
3951 {
3952 Field* fields = result->Fetch();
3953
3954 uint32 ID = fields[0].Get<uint32>();
3955
3956 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3957 if (locale == LOCALE_enUS)
3958 continue;
3959
3961 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3962 } while (result->NextRow());
3963
3964 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3965}
Definition ItemTemplate.h:848
std::vector< std::string > Name
Definition ItemTemplate.h:849

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

◆ LoadItemSetNames()

void ObjectMgr::LoadItemSetNames ( )
3968{
3969 uint32 oldMSTime = getMSTime();
3970
3971 _itemSetNameStore.clear(); // needed for reload case
3972
3973 std::set<uint32> itemSetItems;
3974
3975 // fill item set member ids
3976 for (uint32 entryId = 0; entryId < sItemSetStore.GetNumRows(); ++entryId)
3977 {
3978 ItemSetEntry const* setEntry = sItemSetStore.LookupEntry(entryId);
3979 if (!setEntry)
3980 continue;
3981
3982 for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
3983 if (setEntry->itemId[i])
3984 itemSetItems.insert(setEntry->itemId[i]);
3985 }
3986
3987 // 0 1 2
3988 QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
3989
3990 if (!result)
3991 {
3992 LOG_WARN("server.loading", ">> Loaded 0 item set names. DB table `item_set_names` is empty.");
3993 LOG_INFO("server.loading", " ");
3994 return;
3995 }
3996
3997 _itemSetNameStore.rehash(result->GetRowCount());
3998 uint32 count = 0;
3999
4000 do
4001 {
4002 Field* fields = result->Fetch();
4003
4004 uint32 entry = fields[0].Get<uint32>();
4005 if (itemSetItems.find(entry) == itemSetItems.end())
4006 {
4007 LOG_ERROR("sql.sql", "Item set name (Entry: {}) not found in ItemSet.dbc, data useless.", entry);
4008 continue;
4009 }
4010
4011 ItemSetNameEntry& data = _itemSetNameStore[entry];
4012 data.name = fields[1].Get<std::string>();
4013
4014 uint32 invType = fields[2].Get<uint8>();
4015 if (invType >= MAX_INVTYPE)
4016 {
4017 LOG_ERROR("sql.sql", "Item set name (Entry: {}) has wrong InventoryType value ({})", entry, invType);
4018 invType = INVTYPE_NON_EQUIP;
4019 }
4020
4021 data.InventoryType = invType;
4022 itemSetItems.erase(entry);
4023 ++count;
4024 } while (result->NextRow());
4025
4026 if (!itemSetItems.empty())
4027 {
4028 ItemTemplate const* pProto;
4029 for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr)
4030 {
4031 uint32 entry = *itr;
4032 // add data from item_template if available
4033 pProto = GetItemTemplate(entry);
4034 if (pProto)
4035 {
4036 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, adding data from `item_template`.", entry);
4037 ItemSetNameEntry& data = _itemSetNameStore[entry];
4038 data.name = pProto->Name1;
4039 data.InventoryType = pProto->InventoryType;
4040 ++count;
4041 }
4042 else
4043 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, set will not display properly.", entry);
4044 }
4045 }
4046
4047 LOG_INFO("server.loading", ">> Loaded {} Item Set Names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4048 LOG_INFO("server.loading", " ");
4049}
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
#define MAX_ITEM_SET_ITEMS
Definition DBCStructure.h:1264
@ INVTYPE_NON_EQUIP
Definition ItemTemplate.h:256
#define MAX_INVTYPE
Definition ItemTemplate.h:287
Definition DBCStructure.h:1268
uint32 itemId[MAX_ITEM_SET_ITEMS]
Definition DBCStructure.h:1272
Definition ItemTemplate.h:842
uint32 InventoryType
Definition ItemTemplate.h:844
std::string name
Definition ItemTemplate.h:843
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 ( )
3316{
3317 uint32 oldMSTime = getMSTime();
3318
3319 // 0 1 2 3 4 5 6 7 8 9 10 11 12
3320 QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, "
3321 // 13 14 15 16 17 18 19 20
3322 "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, "
3323 // 21 22 23 24 25 26 27
3324 "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, stat_type1, "
3325 // 28 29 30 31 32 33 34 35 36 37
3326 "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, "
3327 // 38 39 40 41 42 43 44 45 46
3328 "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, "
3329 // 47 48 49 50 51 52 53 54 55 56 57
3330 "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, "
3331 // 58 59 60 61 62 63 64 65 66 67
3332 "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, "
3333 // 68 69 70 71 72 73 74
3334 "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, "
3335 // 75 76 77 78 79 80 81
3336 "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, "
3337 // 82 83 84 85 86 87 88
3338 "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, "
3339 // 89 90 91 92 93 94 95
3340 "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, "
3341 // 96 97 98 99 100 101 102 103 104
3342 "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, "
3343 // 105 106 107 108 109 110 111 112 113 114 115 116
3344 "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, "
3345 // 117 118 119 120 121 122 123 124
3346 "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
3347 // 125 126 127 128 129 130 131 132
3348 "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
3349 // 133 134 135 136
3350 "FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
3351
3352 if (!result)
3353 {
3354 LOG_WARN("server.loading", ">> Loaded 0 item templates. DB table `item_template` is empty.");
3355 LOG_INFO("server.loading", " ");
3356 return;
3357 }
3358
3359 _itemTemplateStore.reserve(result->GetRowCount());
3360 uint32 count = 0;
3361 // original inspiration https://github.com/TrinityCore/TrinityCore/commit/0c44bd33ee7b42c924859139a9f4b04cf2b91261
3362 bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
3363
3364 do
3365 {
3366 Field* fields = result->Fetch();
3367
3368 uint32 entry = fields[0].Get<uint32>();
3369
3370 ItemTemplate& itemTemplate = _itemTemplateStore[entry];
3371
3372 itemTemplate.ItemId = entry;
3373 itemTemplate.Class = uint32(fields[1].Get<uint8>());
3374 itemTemplate.SubClass = uint32(fields[2].Get<uint8>());
3375 itemTemplate.SoundOverrideSubclass = int32(fields[3].Get<int8>());
3376 itemTemplate.Name1 = fields[4].Get<std::string>();
3377 itemTemplate.DisplayInfoID = fields[5].Get<uint32>();
3378 itemTemplate.Quality = uint32(fields[6].Get<uint8>());
3379 itemTemplate.Flags = ItemFlags(fields[7].Get<uint32>());
3380 itemTemplate.Flags2 = ItemFlags2(fields[8].Get<uint32>());
3381 itemTemplate.BuyCount = uint32(fields[9].Get<uint8>());
3382 itemTemplate.BuyPrice = int32(fields[10].Get<int64>());
3383 itemTemplate.SellPrice = uint32(fields[11].Get<uint32>());
3384 itemTemplate.InventoryType = uint32(fields[12].Get<uint8>());
3385 itemTemplate.AllowableClass = fields[13].Get<int32>();
3386 itemTemplate.AllowableRace = fields[14].Get<int32>();
3387 itemTemplate.ItemLevel = uint32(fields[15].Get<uint16>());
3388 itemTemplate.RequiredLevel = uint32(fields[16].Get<uint8>());
3389 itemTemplate.RequiredSkill = uint32(fields[17].Get<uint16>());
3390 itemTemplate.RequiredSkillRank = uint32(fields[18].Get<uint16>());
3391 itemTemplate.RequiredSpell = fields[19].Get<uint32>();
3392 itemTemplate.RequiredHonorRank = fields[20].Get<uint32>();
3393 itemTemplate.RequiredCityRank = fields[21].Get<uint32>();
3394 itemTemplate.RequiredReputationFaction = uint32(fields[22].Get<uint16>());
3395 itemTemplate.RequiredReputationRank = uint32(fields[23].Get<uint16>());
3396 itemTemplate.MaxCount = fields[24].Get<int32>();
3397 itemTemplate.Stackable = fields[25].Get<int32>();
3398 itemTemplate.ContainerSlots = uint32(fields[26].Get<uint8>());
3399
3400 uint8 statsCount = 0;
3401 uint8 statsIterator = 0;
3402 while (statsIterator < MAX_ITEM_PROTO_STATS)
3403 {
3404 uint32 statType = uint32(fields[27 + statsIterator * 2].Get<uint8>());
3405 int32 statValue = fields[28 + statsIterator * 2].Get<int32>();
3406 statsIterator++;
3407 if (statValue == 0)
3408 continue;
3409
3410 itemTemplate.ItemStat[statsCount].ItemStatType = statType;
3411 itemTemplate.ItemStat[statsCount].ItemStatValue = statValue;
3412 statsCount++;
3413 }
3414 itemTemplate.StatsCount = statsCount;
3415
3416 itemTemplate.ScalingStatDistribution = uint32(fields[47].Get<uint16>());
3417 itemTemplate.ScalingStatValue = fields[48].Get<int32>();
3418
3419 for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
3420 {
3421 itemTemplate.Damage[i].DamageMin = fields[49 + i * 3].Get<float>();
3422 itemTemplate.Damage[i].DamageMax = fields[50 + i * 3].Get<float>();
3423 itemTemplate.Damage[i].DamageType = uint32(fields[51 + i * 3].Get<uint8>());
3424 }
3425
3426 itemTemplate.Armor = fields[55].Get<uint32>();
3427 itemTemplate.HolyRes = fields[56].Get<int32>();
3428 itemTemplate.FireRes = fields[57].Get<int32>();
3429 itemTemplate.NatureRes = fields[58].Get<int32>();
3430 itemTemplate.FrostRes = fields[59].Get<int32>();
3431 itemTemplate.ShadowRes = fields[60].Get<int32>();
3432 itemTemplate.ArcaneRes = fields[61].Get<int32>();
3433 itemTemplate.Delay = uint32(fields[62].Get<uint16>());
3434 itemTemplate.AmmoType = uint32(fields[63].Get<uint8>());
3435 itemTemplate.RangedModRange = fields[64].Get<float>();
3436
3437 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3438 {
3439 itemTemplate.Spells[i].SpellId = fields[65 + i * 7 ].Get<int32>();
3440 itemTemplate.Spells[i].SpellTrigger = uint32(fields[66 + i * 7].Get<uint8>());
3441 itemTemplate.Spells[i].SpellCharges = int32(fields[67 + i * 7].Get<int16>());
3442 itemTemplate.Spells[i].SpellPPMRate = fields[68 + i * 7].Get<float>();
3443 itemTemplate.Spells[i].SpellCooldown = fields[69 + i * 7].Get<int32>();
3444 itemTemplate.Spells[i].SpellCategory = uint32(fields[70 + i * 7].Get<uint16>());
3445 itemTemplate.Spells[i].SpellCategoryCooldown = fields[71 + i * 7].Get<int32>();
3446 }
3447
3448 itemTemplate.Bonding = uint32(fields[100].Get<uint8>());
3449 itemTemplate.Description = fields[101].Get<std::string>();
3450 itemTemplate.PageText = fields[102].Get<uint32>();
3451 itemTemplate.LanguageID = uint32(fields[103].Get<uint8>());
3452 itemTemplate.PageMaterial = uint32(fields[104].Get<uint8>());
3453 itemTemplate.StartQuest = fields[105].Get<uint32>();
3454 itemTemplate.LockID = fields[106].Get<uint32>();
3455 itemTemplate.Material = int32(fields[107].Get<int8>());
3456 itemTemplate.Sheath = uint32(fields[108].Get<uint8>());
3457 itemTemplate.RandomProperty = fields[109].Get<int32>();
3458 itemTemplate.RandomSuffix = fields[110].Get<int32>();
3459 itemTemplate.Block = fields[111].Get<uint32>();
3460 itemTemplate.ItemSet = fields[112].Get<uint32>();
3461 itemTemplate.MaxDurability = uint32(fields[113].Get<uint16>());
3462 itemTemplate.Area = fields[114].Get<uint32>();
3463 itemTemplate.Map = uint32(fields[115].Get<uint16>());
3464 itemTemplate.BagFamily = fields[116].Get<uint32>();
3465 itemTemplate.TotemCategory = fields[117].Get<uint32>();
3466
3467 for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
3468 {
3469 itemTemplate.Socket[i].Color = uint32(fields[118 + i * 2].Get<uint8>());
3470 itemTemplate.Socket[i].Content = fields[119 + i * 2].Get<uint32>();
3471 }
3472
3473 itemTemplate.socketBonus = fields[124].Get<uint32>();
3474 itemTemplate.GemProperties = fields[125].Get<uint32>();
3475 itemTemplate.RequiredDisenchantSkill = uint32(fields[126].Get<int16>());
3476 itemTemplate.ArmorDamageModifier = fields[127].Get<float>();
3477 itemTemplate.Duration = fields[128].Get<uint32>();
3478 itemTemplate.ItemLimitCategory = uint32(fields[129].Get<int16>());
3479 itemTemplate.HolidayId = fields[130].Get<uint32>();
3480 itemTemplate.ScriptId = GetScriptId(fields[131].Get<std::string>());
3481 itemTemplate.DisenchantID = fields[132].Get<uint32>();
3482 itemTemplate.FoodType = uint32(fields[133].Get<uint8>());
3483 itemTemplate.MinMoneyLoot = fields[134].Get<uint32>();
3484 itemTemplate.MaxMoneyLoot = fields[135].Get<uint32>();
3485 itemTemplate.FlagsCu = ItemFlagsCustom(fields[136].Get<uint32>());
3486
3487 // Checks
3488 ItemEntry const* dbcitem = sItemStore.LookupEntry(entry);
3489
3490 if (!dbcitem)
3491 {
3492 LOG_DEBUG("sql.sql", "Item (Entry: {}) does not exist in item.dbc! (not correct id?).", entry);
3493 continue;
3494 }
3495
3496 if (enforceDBCAttributes)
3497 {
3498 if (itemTemplate.Class != dbcitem->ClassID)
3499 {
3500 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Class value ({}), must be ({}).", entry, itemTemplate.Class, dbcitem->ClassID);
3501 itemTemplate.Class = dbcitem->ClassID;
3502 }
3503 if (itemTemplate.SubClass != dbcitem->SubclassID)
3504 {
3505 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Subclass value ({}) for class {}, must be ({}).", entry, itemTemplate.SubClass, itemTemplate.Class, dbcitem->SubclassID);
3506 itemTemplate.SubClass = dbcitem->SubclassID;
3507 }
3508 if (itemTemplate.SoundOverrideSubclass != dbcitem->SoundOverrideSubclassID)
3509 {
3510 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct SoundOverrideSubclass ({}), must be {}.", entry, itemTemplate.SoundOverrideSubclass, dbcitem->SoundOverrideSubclassID);
3511 itemTemplate.SoundOverrideSubclass = dbcitem->SoundOverrideSubclassID;
3512 }
3513 if (itemTemplate.Material != dbcitem->Material)
3514 {
3515 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct material ({}), must be {}.", entry, itemTemplate.Material, dbcitem->Material);
3516 itemTemplate.Material = dbcitem->Material;
3517 }
3518 if (itemTemplate.InventoryType != dbcitem->InventoryType)
3519 {
3520 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong InventoryType value ({}), must be {}.", entry, itemTemplate.InventoryType, dbcitem->InventoryType);
3521 itemTemplate.InventoryType = dbcitem->InventoryType;
3522 }
3523 if (itemTemplate.DisplayInfoID != dbcitem->DisplayInfoID)
3524 {
3525 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct display id ({}), must be {}.", entry, itemTemplate.DisplayInfoID, dbcitem->DisplayInfoID);
3526 itemTemplate.DisplayInfoID = dbcitem->DisplayInfoID;
3527 }
3528 if (itemTemplate.Sheath != dbcitem->SheatheType)
3529 {
3530 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Sheath ({}), must be {}.", entry, itemTemplate.Sheath, dbcitem->SheatheType);
3531 itemTemplate.Sheath = dbcitem->SheatheType;
3532 }
3533 }
3534
3535 if (itemTemplate.Quality >= MAX_ITEM_QUALITY)
3536 {
3537 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Quality value ({})", entry, itemTemplate.Quality);
3538 itemTemplate.Quality = ITEM_QUALITY_NORMAL;
3539 }
3540
3541 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_HORDE))
3542 {
3543 if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
3544 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
3545 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.",
3546 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_HORDE);
3547
3548 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
3549 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.",
3551 }
3552 else if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
3553 {
3554 if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
3555 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
3556 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.",
3557 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_ALLIANCE);
3558 }
3559
3560 if (itemTemplate.BuyCount <= 0)
3561 {
3562 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong BuyCount value ({}), set to default(1).", entry, itemTemplate.BuyCount);
3563 itemTemplate.BuyCount = 1;
3564 }
3565
3566 if (itemTemplate.RequiredSkill >= MAX_SKILL_TYPE)
3567 {
3568 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RequiredSkill value ({})", entry, itemTemplate.RequiredSkill);
3569 itemTemplate.RequiredSkill = 0;
3570 }
3571
3572 {
3573 // can be used in equip slot, as page read use in inventory, or spell casting at use
3574 bool req = itemTemplate.InventoryType != INVTYPE_NON_EQUIP || itemTemplate.PageText;
3575 if (!req)
3576 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3577 {
3578 if (itemTemplate.Spells[j].SpellId)
3579 {
3580 req = true;
3581 break;
3582 }
3583 }
3584
3585 if (req)
3586 {
3587 if (!(itemTemplate.AllowableClass & CLASSMASK_ALL_PLAYABLE))
3588 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable classes ({}) in `AllowableClass` and can't be equipped or used.", entry, itemTemplate.AllowableClass);
3589
3590 if (!(itemTemplate.AllowableRace & sRaceMgr->GetPlayableRaceMask()))
3591 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable races ({}) in `AllowableRace` and can't be equipped or used.", entry, itemTemplate.AllowableRace);
3592 }
3593 }
3594
3595 if (itemTemplate.RequiredSpell && !sSpellMgr->GetSpellInfo(itemTemplate.RequiredSpell))
3596 {
3597 LOG_ERROR("sql.sql", "Item (Entry: {}) has a wrong (non-existing) spell in RequiredSpell ({})", entry, itemTemplate.RequiredSpell);
3598 itemTemplate.RequiredSpell = 0;
3599 }
3600
3601 if (itemTemplate.RequiredReputationRank >= MAX_REPUTATION_RANK)
3602 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong reputation rank in RequiredReputationRank ({}), item can't be used.", entry, itemTemplate.RequiredReputationRank);
3603
3604 if (itemTemplate.RequiredReputationFaction)
3605 {
3606 if (!sFactionStore.LookupEntry(itemTemplate.RequiredReputationFaction))
3607 {
3608 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) faction in RequiredReputationFaction ({})", entry, itemTemplate.RequiredReputationFaction);
3609 itemTemplate.RequiredReputationFaction = 0;
3610 }
3611
3612 if (itemTemplate.RequiredReputationRank == MIN_REPUTATION_RANK)
3613 LOG_ERROR("sql.sql", "Item (Entry: {}) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", entry);
3614 }
3615
3616 if (itemTemplate.MaxCount < -1)
3617 {
3618 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in maxcount ({}), replace by value (-1) no storing limits.", entry, itemTemplate.MaxCount);
3619 itemTemplate.MaxCount = -1;
3620 }
3621
3622 if (itemTemplate.Stackable == 0)
3623 {
3624 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong value in stackable ({}), replace by default 1.", entry, itemTemplate.Stackable);
3625 itemTemplate.Stackable = 1;
3626 }
3627 else if (itemTemplate.Stackable < -1)
3628 {
3629 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in stackable ({}), replace by value (-1) no stacking limits.", entry, itemTemplate.Stackable);
3630 itemTemplate.Stackable = -1;
3631 }
3632
3633 if (itemTemplate.ContainerSlots > MAX_BAG_SIZE)
3634 {
3635 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in ContainerSlots ({}), replace by hardcoded limit ({}).", entry, itemTemplate.ContainerSlots, MAX_BAG_SIZE);
3636 itemTemplate.ContainerSlots = MAX_BAG_SIZE;
3637 }
3638
3639 for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
3640 {
3641 // for ItemStatValue != 0
3642 if (itemTemplate.ItemStat[j].ItemStatValue && itemTemplate.ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
3643 {
3644 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (non-existing?) stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3645 itemTemplate.ItemStat[j].ItemStatType = 0;
3646 }
3647
3648 switch (itemTemplate.ItemStat[j].ItemStatType)
3649 {
3652 // Skip warning for specific items: 13113 (Feathermoon Headdress - Blizzard oversight), 34967 (test item)
3653 if (entry != 13113 && entry != 34967)
3654 LOG_WARN("sql.sql", "Item (Entry: {}) has deprecated stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3655
3656 break;
3657 default:
3658 break;
3659 }
3660 }
3661
3662 for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
3663 {
3664 if (itemTemplate.Damage[j].DamageType >= MAX_SPELL_SCHOOL)
3665 {
3666 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong dmg_type{} ({})", entry, j + 1, itemTemplate.Damage[j].DamageType);
3667 itemTemplate.Damage[j].DamageType = 0;
3668 }
3669 }
3670
3671 // special format
3672 if ((itemTemplate.Spells[0].SpellId == 483) || (itemTemplate.Spells[0].SpellId == 55884))
3673 {
3674 // spell_1
3675 if (itemTemplate.Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3676 {
3677 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);
3678 itemTemplate.Spells[0].SpellId = 0;
3679 itemTemplate.Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3680 itemTemplate.Spells[1].SpellId = 0;
3681 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3682 }
3683
3684 // spell_2 have learning spell
3685 if (itemTemplate.Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3686 {
3687 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);
3688 itemTemplate.Spells[0].SpellId = 0;
3689 itemTemplate.Spells[1].SpellId = 0;
3690 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3691 }
3692 else if (!itemTemplate.Spells[1].SpellId)
3693 {
3694 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have an expected spell in spellid_{} in special learning format.", entry, 1 + 1);
3695 itemTemplate.Spells[0].SpellId = 0;
3696 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3697 }
3698 else if (itemTemplate.Spells[1].SpellId != -1)
3699 {
3700 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
3701 if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
3702 {
3703 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3704 itemTemplate.Spells[0].SpellId = 0;
3705 itemTemplate.Spells[1].SpellId = 0;
3706 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3707 }
3708 // allowed only in special format
3709 else if ((itemTemplate.Spells[1].SpellId == 483) || (itemTemplate.Spells[1].SpellId == 55884))
3710 {
3711 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3712 itemTemplate.Spells[0].SpellId = 0;
3713 itemTemplate.Spells[1].SpellId = 0;
3714 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3715 }
3716 }
3717
3718 // spell_3*, spell_4*, spell_5* is empty
3719 for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
3720 {
3721 if (itemTemplate.Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3722 {
3723 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3724 itemTemplate.Spells[j].SpellId = 0;
3725 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3726 }
3727 else if (itemTemplate.Spells[j].SpellId != 0)
3728 {
3729 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong spell in spellid_{} ({}) for learning special format", entry, j + 1, itemTemplate.Spells[j].SpellId);
3730 itemTemplate.Spells[j].SpellId = 0;
3731 }
3732 }
3733 }
3734 // normal spell list
3735 else
3736 {
3737 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3738 {
3739 if (itemTemplate.Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || itemTemplate.Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3740 {
3741 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3742 itemTemplate.Spells[j].SpellId = 0;
3743 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3744 }
3745
3746 if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
3747 {
3748 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
3749 if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
3750 {
3751 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3752 itemTemplate.Spells[j].SpellId = 0;
3753 }
3754 // allowed only in special format
3755 else if ((itemTemplate.Spells[j].SpellId == 483) || (itemTemplate.Spells[j].SpellId == 55884))
3756 {
3757 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3758 itemTemplate.Spells[j].SpellId = 0;
3759 }
3760 }
3761 }
3762 }
3763
3764 if (itemTemplate.Bonding >= MAX_BIND_TYPE)
3765 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Bonding value ({})", entry, itemTemplate.Bonding);
3766
3767 if (itemTemplate.PageText && !GetPageText(itemTemplate.PageText))
3768 LOG_ERROR("sql.sql", "Item (Entry: {}) has non existing first page (Id:{})", entry, itemTemplate.PageText);
3769
3770 if (itemTemplate.LockID && !sLockStore.LookupEntry(itemTemplate.LockID))
3771 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LockID ({})", entry, itemTemplate.LockID);
3772
3773 if (itemTemplate.RandomProperty)
3774 {
3775 // To be implemented later
3776 if (itemTemplate.RandomProperty == -1)
3777 itemTemplate.RandomProperty = 0;
3778
3779 else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomProperty)))
3780 {
3781 LOG_ERROR("sql.sql", "Item (Entry: {}) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty ({})", entry, itemTemplate.RandomProperty);
3782 itemTemplate.RandomProperty = 0;
3783 }
3784 }
3785
3786 if (itemTemplate.RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomSuffix)))
3787 {
3788 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RandomSuffix ({})", entry, itemTemplate.RandomSuffix);
3789 itemTemplate.RandomSuffix = 0;
3790 }
3791
3792 if (itemTemplate.ItemSet && !sItemSetStore.LookupEntry(itemTemplate.ItemSet))
3793 {
3794 LOG_ERROR("sql.sql", "Item (Entry: {}) have wrong ItemSet ({})", entry, itemTemplate.ItemSet);
3795 itemTemplate.ItemSet = 0;
3796 }
3797
3798 if (itemTemplate.Area && !sAreaTableStore.LookupEntry(itemTemplate.Area))
3799 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Area ({})", entry, itemTemplate.Area);
3800
3801 if (itemTemplate.Map && !sMapStore.LookupEntry(itemTemplate.Map))
3802 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Map ({})", entry, itemTemplate.Map);
3803
3804 if (itemTemplate.BagFamily)
3805 {
3806 // check bits
3807 for (uint32 j = 0; j < sizeof(itemTemplate.BagFamily) * 8; ++j)
3808 {
3809 uint32 mask = 1 << j;
3810 if ((itemTemplate.BagFamily & mask) == 0)
3811 continue;
3812
3813 ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j + 1);
3814 if (!bf)
3815 {
3816 LOG_ERROR("sql.sql", "Item (Entry: {}) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", entry);
3817 itemTemplate.BagFamily &= ~mask;
3818 continue;
3819 }
3820
3822 {
3823 CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemTemplate.ItemId);
3824 if (!ctEntry)
3825 {
3826 LOG_ERROR("sql.sql", "Item (Entry: {}) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit", entry);
3827 itemTemplate.BagFamily &= ~mask;
3828 }
3829 }
3830 }
3831 }
3832
3833 if (itemTemplate.TotemCategory && !sTotemCategoryStore.LookupEntry(itemTemplate.TotemCategory))
3834 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong TotemCategory ({})", entry, itemTemplate.TotemCategory);
3835
3836 for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
3837 {
3838 if (itemTemplate.Socket[j].Color && (itemTemplate.Socket[j].Color & SOCKET_COLOR_ALL) != itemTemplate.Socket[j].Color)
3839 {
3840 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong socketColor_{} ({})", entry, j + 1, itemTemplate.Socket[j].Color);
3841 itemTemplate.Socket[j].Color = 0;
3842 }
3843 }
3844
3845 if (itemTemplate.GemProperties && !sGemPropertiesStore.LookupEntry(itemTemplate.GemProperties))
3846 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong GemProperties ({})", entry, itemTemplate.GemProperties);
3847
3848 if (itemTemplate.FoodType >= MAX_PET_DIET)
3849 {
3850 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong FoodType value ({})", entry, itemTemplate.FoodType);
3851 itemTemplate.FoodType = 0;
3852 }
3853
3854 if (itemTemplate.ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(itemTemplate.ItemLimitCategory))
3855 {
3856 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LimitCategory value ({})", entry, itemTemplate.ItemLimitCategory);
3857 itemTemplate.ItemLimitCategory = 0;
3858 }
3859
3860 if (itemTemplate.HolidayId && !sHolidaysStore.LookupEntry(itemTemplate.HolidayId))
3861 {
3862 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong HolidayId value ({})", entry, itemTemplate.HolidayId);
3863 itemTemplate.HolidayId = 0;
3864 }
3865
3866 if (itemTemplate.HasFlagCu(ITEM_FLAGS_CU_DURATION_REAL_TIME) && !itemTemplate.Duration)
3867 {
3868 LOG_ERROR("sql.sql", "Item (Entry {}) has flag ITEM_FLAGS_CU_DURATION_REAL_TIME but it does not have duration limit", entry);
3869 itemTemplate.FlagsCu = static_cast<ItemFlagsCustom>(static_cast<uint32>(itemTemplate.FlagsCu) & ~ITEM_FLAGS_CU_DURATION_REAL_TIME);
3870 }
3871
3872 // Set after checks to ensure valid item quality
3873 itemTemplate.BuyPrice *= sWorld->getRate(qualityToBuyValueConfig[itemTemplate.Quality]);
3874 itemTemplate.SellPrice *= sWorld->getRate(qualityToSellValueConfig[itemTemplate.Quality]);
3875
3876 // Fill categories map
3877 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3878 if (itemTemplate.Spells[i].SpellId && itemTemplate.Spells[i].SpellCategory && itemTemplate.Spells[i].SpellCategoryCooldown)
3879 {
3880 SpellCategoryStore::iterator ct = sSpellsByCategoryStore.find(itemTemplate.Spells[i].SpellCategory);
3881 if (ct != sSpellsByCategoryStore.end())
3882 {
3883 ct->second.emplace(true, itemTemplate.Spells[i].SpellId);
3884 }
3885 else
3886 sSpellsByCategoryStore[itemTemplate.Spells[i].SpellCategory].emplace(true, itemTemplate.Spells[i].SpellId);
3887 }
3888
3889 ++count;
3890 } while (result->NextRow());
3891
3892 // pussywizard:
3893 {
3894 uint32 max = 0;
3895 for (ItemTemplateContainer::const_iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3896 if (itr->first > max)
3897 max = itr->first;
3898 if (max)
3899 {
3900 _itemTemplateStoreFast.clear();
3901 _itemTemplateStoreFast.resize(max + 1, nullptr);
3902 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3903 _itemTemplateStoreFast[itr->first] = &(itr->second);
3904 }
3905 }
3906
3907 // Check if item templates for DBC referenced character start outfit are present
3908 std::set<uint32> notFoundOutfit;
3909 for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i)
3910 {
3911 CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i);
3912 if (!entry)
3913 continue;
3914
3915 for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
3916 {
3917 if (entry->ItemId[j] <= 0)
3918 continue;
3919
3920 uint32 item_id = entry->ItemId[j];
3921
3922 if (!GetItemTemplate(item_id))
3923 notFoundOutfit.insert(item_id);
3924 }
3925 }
3926
3927 for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr)
3928 LOG_ERROR("sql.sql", "Item (Entry: {}) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr);
3929
3930 LOG_INFO("server.loading", ">> Loaded {} Item Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3931 LOG_INFO("server.loading", " ");
3932}
#define MAX_BAG_SIZE
Definition Bag.h:22
DBCStorage< ItemLimitCategoryEntry > sItemLimitCategoryStore(ItemLimitCategoryEntryfmt)
SpellCategoryStore sSpellsByCategoryStore
Definition DBCStores.cpp:156
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:3303
ServerConfigs const qualityToBuyValueConfig[MAX_ITEM_QUALITY]
Definition ObjectMgr.cpp:3291
#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:99
Definition DBCStructure.h:620
int32 ItemId[MAX_OUTFIT_ITEMS]
Definition DBCStructure.h:626
Definition DBCStructure.h:862
Definition DBCStructure.h:943
Definition DBCStructure.h:1191
int32 SoundOverrideSubclassID
Definition DBCStructure.h:1183
uint32 SheatheType
Definition DBCStructure.h:1187
uint32 DisplayInfoID
Definition DBCStructure.h:1185
uint32 ClassID
Definition DBCStructure.h:1181
int32 Material
Definition DBCStructure.h:1184
uint32 SubclassID
Definition DBCStructure.h:1182
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 ( )
1922{
1923 uint32 oldMSTime = getMSTime();
1924
1925 _linkedRespawnStore.clear();
1926 // 0 1 2
1927 QueryResult result = WorldDatabase.Query("SELECT guid, linkedGuid, linkType FROM linked_respawn ORDER BY guid ASC");
1928
1929 if (!result)
1930 {
1931 LOG_WARN("server.loading", ">> Loaded 0 linked respawns. DB table `linked_respawn` is empty.");
1932 LOG_INFO("server.loading", " ");
1933 return;
1934 }
1935
1936 do
1937 {
1938 Field* fields = result->Fetch();
1939
1940 ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
1941 ObjectGuid::LowType linkedGuidLow = fields[1].Get<uint32>();
1942 uint8 linkType = fields[2].Get<uint8>();
1943
1944 ObjectGuid guid, linkedGuid;
1945 bool error = false;
1946 switch (linkType)
1947 {
1949 {
1950 CreatureData const* slave = GetCreatureData(guidLow);
1951 if (!slave)
1952 {
1953 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1954 error = true;
1955 break;
1956 }
1957
1958 CreatureData const* master = GetCreatureData(linkedGuidLow);
1959 if (!master)
1960 {
1961 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1962 error = true;
1963 break;
1964 }
1965
1966 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1967 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1968 {
1969 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1970 error = true;
1971 break;
1972 }
1973
1974 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1975 {
1976 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1977 error = true;
1978 break;
1979 }
1980
1981 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id, guidLow);
1982 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id, linkedGuidLow);
1983 break;
1984 }
1985 case CREATURE_TO_GO:
1986 {
1987 CreatureData const* slave = GetCreatureData(guidLow);
1988 if (!slave)
1989 {
1990 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1991 error = true;
1992 break;
1993 }
1994
1995 GameObjectData const* master = GetGameObjectData(linkedGuidLow);
1996 if (!master)
1997 {
1998 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1999 error = true;
2000 break;
2001 }
2002
2003 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2004 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2005 {
2006 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2007 error = true;
2008 break;
2009 }
2010
2011 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2012 {
2013 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2014 error = true;
2015 break;
2016 }
2017
2018 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id, guidLow);
2019 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
2020 break;
2021 }
2022 case GO_TO_GO:
2023 {
2024 GameObjectData const* slave = GetGameObjectData(guidLow);
2025 if (!slave)
2026 {
2027 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
2028 error = true;
2029 break;
2030 }
2031
2032 GameObjectData const* master = GetGameObjectData(linkedGuidLow);
2033 if (!master)
2034 {
2035 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
2036 error = true;
2037 break;
2038 }
2039
2040 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2041 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2042 {
2043 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2044 error = true;
2045 break;
2046 }
2047
2048 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2049 {
2050 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2051 error = true;
2052 break;
2053 }
2054
2055 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2056 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
2057 break;
2058 }
2059 case GO_TO_CREATURE:
2060 {
2061 GameObjectData const* slave = GetGameObjectData(guidLow);
2062 if (!slave)
2063 {
2064 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
2065 error = true;
2066 break;
2067 }
2068
2069 CreatureData const* master = GetCreatureData(linkedGuidLow);
2070 if (!master)
2071 {
2072 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
2073 error = true;
2074 break;
2075 }
2076
2077 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2078 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2079 {
2080 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2081 error = true;
2082 break;
2083 }
2084
2085 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2086 {
2087 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2088 error = true;
2089 break;
2090 }
2091
2092 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2093 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id, linkedGuidLow);
2094 break;
2095 }
2096 }
2097
2098 if (!error)
2099 _linkedRespawnStore[guid] = linkedGuid;
2100 } while (result->NextRow());
2101
2102 LOG_INFO("server.loading", ">> Loaded {} Linked Respawns In {} ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime));
2103 LOG_INFO("server.loading", " ");
2104}
Definition ObjectGuid.h:121
bool Instanceable() const
Definition DBCStructure.h:1389

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

◆ LoadMailLevelRewards()

void ObjectMgr::LoadMailLevelRewards ( )
9926{
9927 uint32 oldMSTime = getMSTime();
9928
9929 _mailLevelRewardStore.clear(); // for reload case
9930
9931 // 0 1 2 3
9932 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
9933
9934 if (!result)
9935 {
9936 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
9937 LOG_INFO("server.loading", " ");
9938 return;
9939 }
9940
9941 uint32 count = 0;
9942
9943 do
9944 {
9945 Field* fields = result->Fetch();
9946
9947 uint8 level = fields[0].Get<uint8>();
9948 uint32 raceMask = fields[1].Get<uint32>();
9949 uint32 mailTemplateId = fields[2].Get<uint32>();
9950 uint32 senderEntry = fields[3].Get<uint32>();
9951
9952 if (level > MAX_LEVEL)
9953 {
9954 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
9955 continue;
9956 }
9957
9958 if (!(raceMask & sRaceMgr->GetPlayableRaceMask()))
9959 {
9960 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
9961 continue;
9962 }
9963
9964 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
9965 {
9966 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
9967 continue;
9968 }
9969
9970 if (!GetCreatureTemplate(senderEntry))
9971 {
9972 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);
9973 continue;
9974 }
9975
9976 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
9977
9978 ++count;
9979 } while (result->NextRow());
9980
9981 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9982 LOG_INFO("server.loading", " ");
9983}
#define MAX_LEVEL
Definition DBCEnums.h:39
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
Definition ObjectMgr.h:549

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

◆ LoadModuleStrings()

bool ObjectMgr::LoadModuleStrings ( )
9488{
9489 uint32 oldMSTime = getMSTime();
9490
9491 _moduleStringStore.clear(); // for reload case
9492 QueryResult result = WorldDatabase.Query("SELECT module, id, string FROM module_string");
9493 if (!result)
9494 {
9495 LOG_WARN("server.loading", ">> Loaded 0 module strings. DB table `module_string` is empty.");
9496 LOG_INFO("server.loading", " ");
9497 return false;
9498 }
9499
9500 do
9501 {
9502 Field* fields = result->Fetch();
9503
9504 std::string module = fields[0].Get<std::string>();
9505 uint32 id = fields[1].Get<uint32>();
9506
9507 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
9508 ModuleString& data = _moduleStringStore[pairKey];
9509
9510 AddLocaleString(fields[2].Get<std::string>(), LOCALE_enUS, data.Content);
9511 } while (result->NextRow());
9512
9513 LOG_INFO("server.loading", ">> Loaded {} Module Strings in {} ms", _moduleStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
9514 LOG_INFO("server.loading", " ");
9515
9516 return true;
9517}

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

◆ LoadModuleStringsLocale()

bool ObjectMgr::LoadModuleStringsLocale ( )
9520{
9521 uint32 oldMSTime = getMSTime();
9522
9523 QueryResult result = WorldDatabase.Query("SELECT module, id, locale, string FROM module_string_locale");
9524 if (!result)
9525 {
9526 LOG_WARN("server.loading", ">> Loaded 0 module strings locale. DB table `module_string_locale` is empty.");
9527 LOG_INFO("server.loading", " ");
9528 return false;
9529 }
9530
9531 uint32 localeCount = 0;
9532 do
9533 {
9534 Field* fields = result->Fetch();
9535
9536 std::string module = fields[0].Get<std::string>();
9537 uint32 id = fields[1].Get<uint32>();
9538
9539 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
9540 ModuleString& data = _moduleStringStore[pairKey];
9541
9542 ModuleStringContainer::iterator ms = _moduleStringStore.find(pairKey);
9543 if (ms == _moduleStringStore.end())
9544 {
9545 LOG_ERROR("sql.sql", "ModuleString (Module: {} Id: {}) found in table `module_string_locale` but does not exist in `module_string`. Skipped!", module, id);
9546 continue;
9547 }
9548
9549 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
9550 if (locale == LOCALE_enUS)
9551 continue;
9552
9553 AddLocaleString(fields[3].Get<std::string>(), locale, data.Content);
9554 localeCount++;
9555 } while (result->NextRow());
9556
9557 LOG_INFO("server.loading", ">> Loaded {} Module Strings Locales in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
9558 LOG_INFO("server.loading", " ");
9559
9560 return true;
9561}

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

◆ LoadNPCSpellClickSpells()

void ObjectMgr::LoadNPCSpellClickSpells ( )
8594{
8595 uint32 oldMSTime = getMSTime();
8596
8597 _spellClickInfoStore.clear();
8598 // 0 1 2 3
8599 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
8600
8601 if (!result)
8602 {
8603 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
8604 LOG_INFO("server.loading", " ");
8605 return;
8606 }
8607
8608 uint32 count = 0;
8609
8610 do
8611 {
8612 Field* fields = result->Fetch();
8613
8614 uint32 npc_entry = fields[0].Get<uint32>();
8615 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
8616 if (!cInfo)
8617 {
8618 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
8619 continue;
8620 }
8621
8622 uint32 spellid = fields[1].Get<uint32>();
8623 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
8624 if (!spellinfo)
8625 {
8626 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
8627 continue;
8628 }
8629
8630 uint8 userType = fields[3].Get<uint16>();
8631 if (userType >= SPELL_CLICK_USER_MAX)
8632 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
8633
8634 uint8 castFlags = fields[2].Get<uint8>();
8635 SpellClickInfo info;
8636 info.spellId = spellid;
8637 info.castFlags = castFlags;
8638 info.userType = SpellClickUserTypes(userType);
8639 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
8640
8641 ++count;
8642 } while (result->NextRow());
8643
8644 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
8645 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
8647 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
8648 {
8649 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
8650 {
8651 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);
8652 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
8653 }
8654 }
8655
8656 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8657 LOG_INFO("server.loading", " ");
8658}
SpellClickUserTypes
Definition SharedDefines.h:668
@ SPELL_CLICK_USER_MAX
Definition SharedDefines.h:673
@ UNIT_NPC_FLAG_SPELLCLICK
Definition UnitDefines.h:346
Definition ObjectMgr.h:401
uint32 spellId
Definition ObjectMgr.h:402

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 ( )
6787{
6788 uint32 oldMSTime = getMSTime();
6789
6790 _npcTextLocaleStore.clear(); // need for reload case
6791
6792 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6793 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6794 "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 "
6795 "FROM npc_text_locale");
6796
6797 if (!result)
6798 return;
6799
6800 do
6801 {
6802 Field* fields = result->Fetch();
6803
6804 uint32 ID = fields[0].Get<uint32>();
6805
6806 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6807 if (locale == LOCALE_enUS)
6808 continue;
6809
6811 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6812 {
6813 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6814 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6815 }
6816 } while (result->NextRow());
6817
6818 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6819}
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 ( )
6534{
6535 uint32 oldMSTime = getMSTime();
6536
6537 _pageTextLocaleStore.clear(); // need for reload case
6538
6539 // 0 1 2
6540 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
6541
6542 if (!result)
6543 {
6544 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text_locale` is empty!");
6545 LOG_INFO("server.loading", " ");
6546 return;
6547 }
6548
6549 do
6550 {
6551 Field* fields = result->Fetch();
6552
6553 uint32 ID = fields[0].Get<uint32>();
6554
6555 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6556 if (locale == LOCALE_enUS)
6557 continue;
6558
6560 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
6561 } while (result->NextRow());
6562
6563 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6564}
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 ( )
6484{
6485 uint32 oldMSTime = getMSTime();
6486
6487 // 0 1 2
6488 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
6489
6490 if (!result)
6491 {
6492 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
6493 LOG_INFO("server.loading", " ");
6494 return;
6495 }
6496
6497 uint32 count = 0;
6498 do
6499 {
6500 Field* fields = result->Fetch();
6501
6502 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
6503
6504 pageText.Text = fields[1].Get<std::string>();
6505 pageText.NextPage = fields[2].Get<uint32>();
6506
6507 ++count;
6508 } while (result->NextRow());
6509
6510 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
6511 {
6512 if (itr->second.NextPage)
6513 {
6514 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
6515 if (itr2 == _pageTextStore.end())
6516 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
6517 }
6518 }
6519
6520 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6521 LOG_INFO("server.loading", " ");
6522}
Definition ObjectMgr.h:60
std::string Text
Definition ObjectMgr.h:61
uint32 NextPage
Definition ObjectMgr.h:62

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

◆ LoadPetLevelInfo()

void ObjectMgr::LoadPetLevelInfo ( )
4208{
4209 uint32 oldMSTime = getMSTime();
4210
4211 // 0 1 2 3 4 5 6 7 8 9 10 11
4212 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
4213
4214 if (!result)
4215 {
4216 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
4217 LOG_INFO("server.loading", " ");
4218 return;
4219 }
4220
4221 uint32 count = 0;
4222
4223 do
4224 {
4225 Field* fields = result->Fetch();
4226
4227 uint32 creature_id = fields[0].Get<uint32>();
4228 if (!GetCreatureTemplate(creature_id))
4229 {
4230 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
4231 continue;
4232 }
4233
4234 uint32 current_level = fields[1].Get<uint8>();
4235 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4236 {
4237 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4238 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4239 else
4240 {
4241 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
4242 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4243 }
4244 continue;
4245 }
4246 else if (current_level < 1)
4247 {
4248 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
4249 continue;
4250 }
4251
4252 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
4253
4254 if (!pInfoMapEntry)
4255 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4256
4257 // data for level 1 stored in [0] array element, ...
4258 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
4259
4260 pLevelInfo->health = fields[2].Get<uint32>();
4261 pLevelInfo->mana = fields[3].Get<uint32>();
4262 pLevelInfo->armor = fields[9].Get<uint32>();
4263 pLevelInfo->min_dmg = fields[10].Get<uint32>();
4264 pLevelInfo->max_dmg = fields[11].Get<uint32>();
4265 for (uint8 i = 0; i < MAX_STATS; i++)
4266 {
4267 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
4268 }
4269
4270 ++count;
4271 } while (result->NextRow());
4272
4273 // Fill gaps and check integrity
4274 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
4275 {
4276 PetLevelInfo* pInfo = itr->second;
4277
4278 // fatal error if no level 1 data
4279 if (!pInfo || pInfo[0].health == 0)
4280 {
4281 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
4282 exit(1);
4283 }
4284
4285 // fill level gaps
4286 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4287 {
4288 if (pInfo[level].health == 0)
4289 {
4290 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
4291 pInfo[level] = pInfo[level - 1];
4292 }
4293 }
4294 }
4295
4296 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4297 LOG_INFO("server.loading", " ");
4298}
#define STRONG_MAX_LEVEL
Definition DBCEnums.h:43
#define MAX_STATS
Definition SharedDefines.h:253
Definition ObjectMgr.h:534
uint32 max_dmg
Definition ObjectMgr.h:545
uint32 mana
Definition ObjectMgr.h:542
uint32 min_dmg
Definition ObjectMgr.h:544
uint32 health
Definition ObjectMgr.h:541
std::array< uint32, MAX_STATS > stats
Definition ObjectMgr.h:540
uint32 armor
Definition ObjectMgr.h:543

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 ( )
8100{
8101 uint32 oldMSTime = getMSTime();
8102 // 0 1 2
8103 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
8104
8105 if (!result)
8106 {
8107 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
8108 LOG_INFO("server.loading", " ");
8109 return;
8110 }
8111
8112 uint32 count = 0;
8113
8114 do
8115 {
8116 Field* fields = result->Fetch();
8117 std::string word = fields[0].Get<std::string>();
8118 uint32 entry = fields[1].Get<uint32>();
8119 bool half = fields[2].Get<bool>();
8120 if (half)
8121 _petHalfName1[entry].push_back(word);
8122 else
8123 _petHalfName0[entry].push_back(word);
8124 ++count;
8125 } while (result->NextRow());
8126
8127 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8128 LOG_INFO("server.loading", " ");
8129}

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 ( )
8132{
8133 uint32 oldMSTime = getMSTime();
8134
8135 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
8136 if (result)
8137 {
8138 Field* fields = result->Fetch();
8139 _hiPetNumber = fields[0].Get<uint32>() + 1;
8140 }
8141
8142 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
8143 LOG_INFO("server.loading", " ");
8144}

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

◆ LoadPlayerInfo()

void ObjectMgr::LoadPlayerInfo ( )
4347{
4348 // Load playercreate
4349 {
4350 if (_playerInfo.empty() || _playerInfo.size() != sRaceMgr->GetMaxRaces())
4351 {
4352 _playerInfo.clear();
4353 _playerInfo.resize(sRaceMgr->GetMaxRaces());
4354 for (auto& classVec : _playerInfo)
4355 classVec.resize(MAX_CLASSES, nullptr);
4356 }
4357
4358 uint32 oldMSTime = getMSTime();
4359 // 0 1 2 3 4 5 6
4360 QueryResult result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
4361
4362 if (!result)
4363 {
4364 LOG_INFO("server.loading", " ");
4365 LOG_WARN("server.loading", ">> Loaded 0 player create definitions. DB table `playercreateinfo` is empty.");
4366 exit(1);
4367 }
4368 else
4369 {
4370 uint32 count = 0;
4371
4372 do
4373 {
4374 Field* fields = result->Fetch();
4375
4376 uint32 current_race = fields[0].Get<uint8>();
4377 uint32 current_class = fields[1].Get<uint8>();
4378 uint32 mapId = fields[2].Get<uint16>();
4379 uint32 areaId = fields[3].Get<uint32>(); // zone
4380 float positionX = fields[4].Get<float>();
4381 float positionY = fields[5].Get<float>();
4382 float positionZ = fields[6].Get<float>();
4383 float orientation = fields[7].Get<float>();
4384
4385 if (current_race >= sRaceMgr->GetMaxRaces())
4386 {
4387 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
4388 continue;
4389 }
4390
4391 ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
4392 if (!rEntry)
4393 {
4394 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
4395 continue;
4396 }
4397
4398 if (current_class >= MAX_CLASSES)
4399 {
4400 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
4401 continue;
4402 }
4403
4404 if (!sChrClassesStore.LookupEntry(current_class))
4405 {
4406 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
4407 continue;
4408 }
4409
4410 // accept DB data only for valid position (and non instanceable)
4411 if (!MapMgr::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation))
4412 {
4413 LOG_ERROR("sql.sql", "Wrong home position for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
4414 continue;
4415 }
4416
4417 if (sMapStore.LookupEntry(mapId)->Instanceable())
4418 {
4419 LOG_ERROR("sql.sql", "Home position in instanceable map for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
4420 continue;
4421 }
4422
4423 PlayerInfo* info = new PlayerInfo();
4424 info->mapId = mapId;
4425 info->areaId = areaId;
4426 info->positionX = positionX;
4427 info->positionY = positionY;
4428 info->positionZ = positionZ;
4429 info->orientation = orientation;
4430 info->displayId_m = rEntry->model_m;
4431 info->displayId_f = rEntry->model_f;
4432 _playerInfo[current_race][current_class] = info;
4433
4434 ++count;
4435 } while (result->NextRow());
4436
4437 LOG_INFO("server.loading", ">> Loaded {} Player Create Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4438 LOG_INFO("server.loading", " ");
4439 }
4440 }
4441
4442 // Load playercreate items
4443 LOG_INFO("server.loading", "Loading Player Create Items Data...");
4444 {
4445 uint32 oldMSTime = getMSTime();
4446 // 0 1 2 3
4447 QueryResult result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
4448
4449 if (!result)
4450 {
4451 LOG_WARN("server.loading", ">> Loaded 0 Custom Player Create Items. DB Table `playercreateinfo_item` Is Empty.");
4452 LOG_INFO("server.loading", " ");
4453 }
4454 else
4455 {
4456 uint32 count = 0;
4457
4458 do
4459 {
4460 Field* fields = result->Fetch();
4461
4462 uint32 current_race = fields[0].Get<uint8>();
4463 if (current_race >= sRaceMgr->GetMaxRaces())
4464 {
4465 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_item` table, ignoring.", current_race);
4466 continue;
4467 }
4468
4469 uint32 current_class = fields[1].Get<uint8>();
4470 if (current_class >= MAX_CLASSES)
4471 {
4472 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_item` table, ignoring.", current_class);
4473 continue;
4474 }
4475
4476 uint32 item_id = fields[2].Get<uint32>();
4477
4478 if (!GetItemTemplate(item_id))
4479 {
4480 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);
4481 continue;
4482 }
4483
4484 int32 amount = fields[3].Get<int32>();
4485
4486 if (!amount)
4487 {
4488 LOG_ERROR("sql.sql", "Item id {} (class {} race {}) have amount == 0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class);
4489 continue;
4490 }
4491
4492 if (!current_race || !current_class)
4493 {
4494 uint32 min_race = current_race ? current_race : 1;
4495 uint32 max_race = current_race ? current_race + 1 : sRaceMgr->GetMaxRaces();
4496 uint32 min_class = current_class ? current_class : 1;
4497 uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
4498 for (uint32 r = min_race; r < max_race; ++r)
4499 for (uint32 c = min_class; c < max_class; ++c)
4500 PlayerCreateInfoAddItemHelper(r, c, item_id, amount);
4501 }
4502 else
4503 PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount);
4504
4505 ++count;
4506 } while (result->NextRow());
4507
4508 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4509 LOG_INFO("server.loading", " ");
4510 }
4511 }
4512
4513 // Load playercreate skills
4514 LOG_INFO("server.loading", "Loading Player Create Skill Data...");
4515 {
4516 uint32 oldMSTime = getMSTime();
4517
4518 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, skill, `rank` FROM playercreateinfo_skills");
4519
4520 if (!result)
4521 {
4522 LOG_WARN("server.loading", ">> Loaded 0 Player Create Skills. DB Table `playercreateinfo_skills` Is Empty.");
4523 }
4524 else
4525 {
4526 uint32 count = 0;
4527
4528 do
4529 {
4530 Field* fields = result->Fetch();
4531 uint32 raceMask = fields[0].Get<uint32>();
4532 uint32 classMask = fields[1].Get<uint32>();
4534 skill.SkillId = fields[2].Get<uint16>();
4535 skill.Rank = fields[3].Get<uint16>();
4536
4537 if (skill.Rank >= MAX_SKILL_STEP)
4538 {
4539 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);
4540 continue;
4541 }
4542
4543 if (raceMask != 0 && !(raceMask & sRaceMgr->GetPlayableRaceMask()))
4544 {
4545 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_skills` table, ignoring.", raceMask);
4546 continue;
4547 }
4548
4549 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4550 {
4551 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_skills` table, ignoring.", classMask);
4552 continue;
4553 }
4554
4555 if (!sSkillLineStore.LookupEntry(skill.SkillId))
4556 {
4557 LOG_ERROR("sql.sql", "Wrong skill id {} in `playercreateinfo_skills` table, ignoring.", skill.SkillId);
4558 continue;
4559 }
4560
4561 for (uint32 raceIndex = RACE_HUMAN; raceIndex < sRaceMgr->GetMaxRaces(); ++raceIndex)
4562 {
4563 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4564 {
4565 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4566 {
4567 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4568 {
4569 if (!GetSkillRaceClassInfo(skill.SkillId, raceIndex, classIndex))
4570 continue;
4571
4572 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4573 {
4574 info->skills.push_back(skill);
4575 ++count;
4576 }
4577 }
4578 }
4579 }
4580 }
4581 } while (result->NextRow());
4582
4583 LOG_INFO("server.loading", ">> Loaded {} Player Create Skills in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4584 LOG_INFO("server.loading", " ");
4585 }
4586 }
4587
4588 // Load playercreate spells
4589 LOG_INFO("server.loading", "Loading Player Create Spell Data...");
4590 {
4591 uint32 oldMSTime = getMSTime();
4592
4593 QueryResult result = WorldDatabase.Query("SELECT racemask, classmask, Spell FROM playercreateinfo_spell_custom");
4594
4595 if (!result)
4596 {
4597 LOG_WARN("server.loading", ">> Loaded 0 player create spells. DB table `playercreateinfo_spell_custom` is empty.");
4598 }
4599 else
4600 {
4601 uint32 count = 0;
4602
4603 do
4604 {
4605 Field* fields = result->Fetch();
4606 uint32 raceMask = fields[0].Get<uint32>();
4607 uint32 classMask = fields[1].Get<uint32>();
4608 uint32 spellId = fields[2].Get<uint32>();
4609
4610 if (raceMask != 0 && !(raceMask & sRaceMgr->GetPlayableRaceMask()))
4611 {
4612 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_spell_custom` table, ignoring.", raceMask);
4613 continue;
4614 }
4615
4616 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4617 {
4618 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_spell_custom` table, ignoring.", classMask);
4619 continue;
4620 }
4621
4622 for (uint32 raceIndex = RACE_HUMAN; raceIndex < sRaceMgr->GetMaxRaces(); ++raceIndex)
4623 {
4624 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4625 {
4626 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4627 {
4628 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4629 {
4630 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4631 {
4632 info->customSpells.push_back(spellId);
4633 ++count;
4634 }
4635 }
4636 }
4637 }
4638 }
4639 } while (result->NextRow());
4640
4641 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4642 LOG_INFO("server.loading", " ");
4643 }
4644 }
4645
4646 // Load playercreate cast spell
4647 LOG_INFO("server.loading", "Loading Player Create Cast Spell Data...");
4648 {
4649 uint32 oldMSTime = getMSTime();
4650
4651 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
4652
4653 if (!result)
4654 {
4655 LOG_WARN("server.loading", ">> Loaded 0 Player Create Cast Spells. DB Table `playercreateinfo_cast_spell` Is Empty.");
4656 }
4657 else
4658 {
4659 uint32 count = 0;
4660
4661 do
4662 {
4663 Field* fields = result->Fetch();
4664 uint32 raceMask = fields[0].Get<uint32>();
4665 uint32 classMask = fields[1].Get<uint32>();
4666 uint32 spellId = fields[2].Get<uint32>();
4667
4668 if (raceMask != 0 && !(raceMask & sRaceMgr->GetPlayableRaceMask()))
4669 {
4670 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
4671 continue;
4672 }
4673
4674 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4675 {
4676 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
4677 continue;
4678 }
4679
4680 for (uint32 raceIndex = RACE_HUMAN; raceIndex < sRaceMgr->GetMaxRaces(); ++raceIndex)
4681 {
4682 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4683 {
4684 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4685 {
4686 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4687 {
4688 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4689 {
4690 info->castSpells.push_back(spellId);
4691 ++count;
4692 }
4693 }
4694 }
4695 }
4696 }
4697 } while (result->NextRow());
4698
4699 LOG_INFO("server.loading", ">> Loaded {} Player Create Cast Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4700 LOG_INFO("server.loading", " ");
4701 }
4702 }
4703
4704 // Load playercreate actions
4705 LOG_INFO("server.loading", "Loading Player Create Action Data...");
4706 {
4707 uint32 oldMSTime = getMSTime();
4708
4709 // 0 1 2 3 4
4710 QueryResult result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
4711
4712 if (!result)
4713 {
4714 LOG_WARN("server.loading", ">> Loaded 0 Player Create Actions. DB Table `playercreateinfo_action` Is Empty.");
4715 LOG_INFO("server.loading", " ");
4716 }
4717 else
4718 {
4719 uint32 count = 0;
4720
4721 do
4722 {
4723 Field* fields = result->Fetch();
4724
4725 uint32 current_race = fields[0].Get<uint8>();
4726 if (current_race >= sRaceMgr->GetMaxRaces())
4727 {
4728 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_action` table, ignoring.", current_race);
4729 continue;
4730 }
4731
4732 uint32 current_class = fields[1].Get<uint8>();
4733 if (current_class >= MAX_CLASSES)
4734 {
4735 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_action` table, ignoring.", current_class);
4736 continue;
4737 }
4738
4739 if (PlayerInfo* info = _playerInfo[current_race][current_class])
4740 info->action.push_back(PlayerCreateInfoAction(fields[2].Get<uint16>(), fields[3].Get<uint32>(), fields[4].Get<uint16>()));
4741
4742 ++count;
4743 } while (result->NextRow());
4744
4745 LOG_INFO("server.loading", ">> Loaded {} Player Create Actions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4746 LOG_INFO("server.loading", " ");
4747 }
4748 }
4749
4750 // Loading levels data (class/race dependent)
4751 LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
4752 {
4753 struct RaceStats
4754 {
4755 int16 StatModifier[MAX_STATS];
4756 };
4757
4758 std::vector<RaceStats> raceStatModifiers;
4759
4760 raceStatModifiers.resize(sRaceMgr->GetMaxRaces());
4761
4762 uint32 oldMSTime = getMSTime();
4763
4764 // 0 1 2 3 4 5
4765 QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
4766
4767 if (!raceStatsResult)
4768 {
4769 LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
4770 LOG_INFO("server.loading", " ");
4771 exit(1);
4772 }
4773
4774 do
4775 {
4776 Field* fields = raceStatsResult->Fetch();
4777
4778 uint32 current_race = fields[0].Get<uint8>();
4779 if (current_race >= sRaceMgr->GetMaxRaces())
4780 {
4781 LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
4782 continue;
4783 }
4784
4785 for (uint32 i = 0; i < MAX_STATS; ++i)
4786 raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
4787
4788 } while (raceStatsResult->NextRow());
4789
4790 // 0 1 2 3 4 5 6 7 8
4791 QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit, BaseHP, BaseMana FROM player_class_stats");
4792
4793 if (!result)
4794 {
4795 LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
4796 exit(1);
4797 }
4798
4799 uint32 count = 0;
4800
4801 do
4802 {
4803 Field* fields = result->Fetch();
4804
4805 uint32 current_class = fields[0].Get<uint8>();
4806 if (current_class >= MAX_CLASSES)
4807 {
4808 LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
4809 continue;
4810 }
4811
4812 uint32 current_level = fields[1].Get<uint8>();
4813 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4814 {
4815 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4816 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4817 else
4818 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
4819
4820 continue;
4821 }
4822
4823 for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
4824 {
4825 if (PlayerInfo* info = _playerInfo[race][current_class])
4826 {
4827 if (!info->levelInfo)
4828 info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4829
4830 PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4831 for (int i = 0; i < MAX_STATS; ++i)
4832 levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
4833 }
4834 }
4835
4836 PlayerClassInfo* info = _playerClassInfo[current_class];
4837 if (!info)
4838 {
4839 info = new PlayerClassInfo();
4841 _playerClassInfo[current_class] = info;
4842 }
4843
4844 PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4845
4846 levelInfo.basehealth = fields[7].Get<uint32>();
4847 levelInfo.basemana = fields[8].Get<uint32>();
4848
4849 ++count;
4850 } while (result->NextRow());
4851
4852 // Fill gaps and check integrity
4853 for (int race = RACE_HUMAN; race < sRaceMgr->GetMaxRaces(); ++race)
4854 {
4855 // skip non existed races
4856 if (!sChrRacesStore.LookupEntry(race))
4857 continue;
4858
4859 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4860 {
4861 // skip non existed classes
4862 if (!sChrClassesStore.LookupEntry(class_))
4863 continue;
4864
4865 PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
4866 PlayerInfo* info = _playerInfo[race][class_];
4867 if (!info)
4868 continue;
4869
4870 // skip expansion races if not playing with expansion
4871 if (sWorld->getIntConfig(CONFIG_EXPANSION) < EXPANSION_THE_BURNING_CRUSADE && (race == RACE_BLOODELF || race == RACE_DRAENEI))
4872 continue;
4873
4874 // skip expansion classes if not playing with expansion
4876 continue;
4877
4878 // fatal error if no initial stats data
4879 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))
4880 {
4881 LOG_ERROR("sql.sql", "Race {} class {} initial level does not have stats data!", race, class_);
4882 exit(1);
4883 }
4884
4885 // fatal error if no initial health/mana data
4886 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))
4887 {
4888 LOG_ERROR("sql.sql", "Class {} initial level does not have health/mana data!", class_);
4889 exit(1);
4890 }
4891
4892 // fill level gaps for stats
4893 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4894 {
4895 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))
4896 {
4897 LOG_ERROR("sql.sql", "Race {} class {} level {} does not have stats data. Using stats data of level {}.", race, class_, level + 1, level);
4898 info->levelInfo[level] = info->levelInfo[level - 1];
4899 }
4900 }
4901
4902 // fill level gaps for health/mana
4903 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4904 {
4905 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))
4906 {
4907 LOG_ERROR("sql.sql", "Class {} level {} does not have health/mana data. Using stats data of level {}.", class_, level + 1, level);
4908 pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1];
4909 }
4910 }
4911 }
4912 }
4913
4914 LOG_INFO("server.loading", ">> Loaded {} Level Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4915 LOG_INFO("server.loading", " ");
4916 }
4917
4918 // Loading xp per level data
4919 LOG_INFO("server.loading", "Loading Player Create XP Data...");
4920 {
4921 uint32 oldMSTime = getMSTime();
4922
4923 _playerXPperLevel.resize(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
4924 for (uint8 level = 0; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4925 _playerXPperLevel[level] = 0;
4926
4927 // 0 1
4928 QueryResult result = WorldDatabase.Query("SELECT Level, Experience FROM player_xp_for_level");
4929
4930 if (!result)
4931 {
4932 LOG_WARN("server.loading", ">> Loaded 0 xp for level definitions. DB table `player_xp_for_level` is empty.");
4933 LOG_INFO("server.loading", " ");
4934 exit(1);
4935 }
4936
4937 uint32 count = 0;
4938
4939 do
4940 {
4941 Field* fields = result->Fetch();
4942
4943 uint32 current_level = fields[0].Get<uint8>();
4944 uint32 current_xp = fields[1].Get<uint32>();
4945
4946 if (current_level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4947 {
4948 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4949 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4950 else
4951 {
4952 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_xp_for_levels` table, ignoring.", current_level);
4953 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4954 }
4955 continue;
4956 }
4957 //PlayerXPperLevel
4958 _playerXPperLevel[current_level] = current_xp;
4959 ++count;
4960 } while (result->NextRow());
4961
4962 // fill level gaps
4963 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4964 {
4965 if (_playerXPperLevel[level] == 0)
4966 {
4967 LOG_ERROR("sql.sql", "Level {} does not have XP for level data. Using data of level [{}] + 100.", level + 1, level);
4968 _playerXPperLevel[level] = _playerXPperLevel[level - 1] + 100;
4969 }
4970 }
4971
4972 LOG_INFO("server.loading", ">> Loaded {} XP For Level Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4973 LOG_INFO("server.loading", " ");
4974 }
4975}
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition DBCStores.cpp:907
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
#define MAX_SKILL_STEP
Definition DBCStructure.h:1616
@ 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:234
void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count)
Definition ObjectMgr.cpp:4312
Definition DBCStructure.h:706
uint32 model_f
Definition DBCStructure.h:712
uint32 model_m
Definition DBCStructure.h:711
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 ( )
8463{
8464 uint32 oldMSTime = getMSTime();
8465
8466 _pointsOfInterestStore.clear(); // need for reload case
8467
8468 uint32 count = 0;
8469
8470 // 0 1 2 3 4 5 6
8471 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
8472
8473 if (!result)
8474 {
8475 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
8476 LOG_INFO("server.loading", " ");
8477 return;
8478 }
8479
8480 do
8481 {
8482 Field* fields = result->Fetch();
8483
8484 uint32 point_id = fields[0].Get<uint32>();
8485
8486 PointOfInterest POI;
8487 POI.ID = point_id;
8488 POI.PositionX = fields[1].Get<float>();
8489 POI.PositionY = fields[2].Get<float>();
8490 POI.Icon = fields[3].Get<uint32>();
8491 POI.Flags = fields[4].Get<uint32>();
8492 POI.Importance = fields[5].Get<uint32>();
8493 POI.Name = fields[6].Get<std::string>();
8494
8495 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
8496 {
8497 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
8498 continue;
8499 }
8500
8501 _pointsOfInterestStore[point_id] = POI;
8502
8503 ++count;
8504 } while (result->NextRow());
8505
8506 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8507 LOG_INFO("server.loading", " ");
8508}
bool IsValidMapCoord(float c)
Definition GridDefines.h:210
Definition ObjectMgr.h:594
uint32 ID
Definition ObjectMgr.h:595

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

◆ LoadProfanityNamesFromDB()

void ObjectMgr::LoadProfanityNamesFromDB ( )
9065{
9066 uint32 oldMSTime = getMSTime();
9067
9068 _profanityNamesStore.clear(); // need for reload case
9069
9070 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
9071
9072 if (!result)
9073 {
9074 LOG_WARN("server.loading", ">> Loaded 0 profanity names. DB table `profanity_name` is empty!");
9075 return;
9076 }
9077
9078 uint32 count = 0;
9079
9080 Field* fields;
9081 do
9082 {
9083 fields = result->Fetch();
9084 std::string name = fields[0].Get<std::string>();
9085
9086 std::wstring wstr;
9087 if (!Utf8toWStr (name, wstr))
9088 {
9089 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
9090 continue;
9091 }
9092
9093 wstrToLower(wstr);
9094
9095 _profanityNamesStore.insert(wstr);
9096 ++count;
9097 } while (result->NextRow());
9098
9099 LOG_INFO("server.loading", ">> Loaded {} profanity names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9100}

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

◆ LoadProfanityNamesFromDBC()

void ObjectMgr::LoadProfanityNamesFromDBC ( )
9103{
9104 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
9105 {
9106 LOG_WARN("server.loading", ">> Loaded 0 profanity names from DBC. Config option disabled.");
9107 return;
9108 }
9109
9110 uint32 oldMSTime = getMSTime();
9111
9112 uint32 count = 0;
9113
9114 for (NamesProfanityEntry const* profanityStore : sNamesProfanityStore)
9115 {
9116 std::wstring wstr;
9117
9118 Utf8toWStr(profanityStore->Pattern, wstr);
9119
9120 // DBC does not have clean entries, remove the junk.
9121 boost::algorithm::replace_all(wstr, "\\<", "");
9122 boost::algorithm::replace_all(wstr, "\\>", "");
9123
9124 _profanityNamesStore.insert(wstr);
9125 count++;
9126 }
9127
9128 LOG_INFO("server.loading", ">> Loaded {} profanity names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9129 LOG_INFO("server.loading", " ");
9130}
DBCStorage< NamesProfanityEntry > sNamesProfanityStore(NamesProfanityfmt)
@ CONFIG_STRICT_NAMES_PROFANITY
Definition WorldConfig.h:143
Definition DBCStructure.h:1441

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

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6822{
6823 uint32 oldMSTime = getMSTime();
6824
6825 _questAreaTriggerStore.clear(); // need for reload case
6826
6827 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6828
6829 if (!result)
6830 {
6831 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6832 LOG_INFO("server.loading", " ");
6833 return;
6834 }
6835
6836 uint32 count = 0;
6837
6838 do
6839 {
6840 ++count;
6841
6842 Field* fields = result->Fetch();
6843
6844 uint32 trigger_ID = fields[0].Get<uint32>();
6845 uint32 quest_ID = fields[1].Get<uint32>();
6846
6847 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6848 if (!atEntry)
6849 {
6850 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6851 continue;
6852 }
6853
6854 Quest const* quest = GetQuestTemplate(quest_ID);
6855
6856 if (!quest)
6857 {
6858 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6859 continue;
6860 }
6861
6863 {
6864 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);
6865
6866 // this will prevent quest completing without objective
6867 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6868
6869 // continue; - quest modified to required objective and trigger can be allowed.
6870 }
6871
6872 _questAreaTriggerStore[trigger_ID] = quest_ID;
6873 } while (result->NextRow());
6874
6875 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6876 LOG_INFO("server.loading", " ");
6877}
@ 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 ( )
6898{
6899 uint32 oldMSTime = getMSTime();
6900
6901 _questGreetingStore.clear(); // For reload case
6902
6903 // 0 1 2 3 4
6904 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6905 if (!result)
6906 {
6907 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6908 return;
6909 }
6910
6911 do
6912 {
6913 Field* fields = result->Fetch();
6914
6915 uint32 id = fields[0].Get<uint32>();
6916 uint8 type = fields[1].Get<uint8>();
6917 switch (type)
6918 {
6919 case 0: // Creature
6920 if (!GetCreatureTemplate(id))
6921 {
6922 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6923 continue;
6924 }
6925 break;
6926 case 1: // GameObject
6927 if (!GetGameObjectTemplate(id))
6928 {
6929 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6930 continue;
6931 }
6932 break;
6933 default:
6934 LOG_ERROR("sql.sql", "Table `quest_greeting` has unknown type {} for id {}, skipped.", type, id);
6935 continue;
6936 }
6937
6938 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6939 QuestGreeting& data = _questGreetingStore[pairKey];
6940
6941 data.EmoteType = fields[2].Get<uint16>();
6942 data.EmoteDelay = fields[3].Get<uint32>();
6943 AddLocaleString(fields[4].Get<std::string>(), LOCALE_enUS, data.Greeting);
6944 }
6945 while (result->NextRow());
6946
6947 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", _questGreetingStore.size(), GetMSTimeDiffToNow(oldMSTime));
6948 LOG_INFO("server.loading", " ");
6949}
Definition ObjectMgr.h:605
uint32 EmoteDelay
Definition ObjectMgr.h:607
std::vector< std::string > Greeting
Definition ObjectMgr.h:608
uint16 EmoteType
Definition ObjectMgr.h:606

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 ( )
6952{
6953 uint32 oldMSTime = getMSTime();
6954
6955 // 0 1 2 3
6956 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6957 if (!result)
6958 {
6959 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
6960 return;
6961 }
6962
6963 uint32 localeCount = 0;
6964 do
6965 {
6966 Field* fields = result->Fetch();
6967
6968 uint32 id = fields[0].Get<uint32>();
6969 uint8 type = fields[1].Get<uint8>();
6970 switch (type)
6971 {
6972 case 0: // Creature
6973 if (!GetCreatureTemplate(id))
6974 {
6975 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
6976 continue;
6977 }
6978 break;
6979 case 1: // GameObject
6980 if (!GetGameObjectTemplate(id))
6981 {
6982 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
6983 continue;
6984 }
6985 break;
6986 default:
6987 continue;
6988 }
6989
6990 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6991 QuestGreeting& data = _questGreetingStore[pairKey];
6992
6993 QuestGreetingContainer::iterator qgc = _questGreetingStore.find(pairKey);
6994 if (qgc == _questGreetingStore.end())
6995 {
6996 LOG_ERROR("sql.sql", "QuestGreeting (Id: {} Type: {}) found in table `quest_greeting_locale` but does not exist in `quest_greeting`. Skipped!", id, type);
6997 continue;
6998 }
6999
7000 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
7001 if (locale == LOCALE_enUS)
7002 continue;
7003
7004 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
7005 localeCount++;
7006 } while (result->NextRow());
7007
7008 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
7009 LOG_INFO("server.loading", " ");
7010}

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 ( )
5905{
5906 uint32 oldMSTime = getMSTime();
5907
5908 _questLocaleStore.clear(); // need for reload case
5909
5910 // 0 1 2 3 4 5 6 7 8 9 10
5911 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5912
5913 if (!result)
5914 return;
5915
5916 do
5917 {
5918 Field* fields = result->Fetch();
5919
5920 uint32 ID = fields[0].Get<uint32>();
5921
5922 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5923 if (locale == LOCALE_enUS)
5924 continue;
5925
5926 QuestLocale& data = _questLocaleStore[ID];
5927 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5928 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5929 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5930 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5931 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5932
5933 for (uint8 i = 0; i < 4; ++i)
5934 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5935 } while (result->NextRow());
5936
5937 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5938}
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 ( )
11185{
11186 uint32 oldMSTime = getMSTime();
11187
11188 _questMoneyRewards.clear();
11189
11190 // 0 1 2 3 4 5 6 7 8 9 10
11191 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
11192 if (!result)
11193 {
11194 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
11195 return;
11196 }
11197
11198 uint32 count = 0;
11199 do
11200 {
11201 Field* fields = result->Fetch();
11202 uint32 Level = fields[0].Get<uint32>();
11203
11204 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
11205 questMoneyReward.fill(0);
11206
11207 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
11208 {
11209 questMoneyReward[i] = fields[1 + i].Get<uint32>();
11210 ++count;
11211 }
11212 } while (result->NextRow());
11213
11214 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
11215 LOG_INFO("server.loading", " ");
11216}
std::array< uint32, MAX_QUEST_MONEY_REWARDS > QuestMoneyRewardArray
Definition ObjectMgr.h:724

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

◆ LoadQuestOfferRewardLocale()

void ObjectMgr::LoadQuestOfferRewardLocale ( )
7013{
7014 uint32 oldMSTime = getMSTime();
7015
7016 _questOfferRewardLocaleStore.clear(); // need for reload case
7017
7018 // 0 1 2
7019 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
7020 if (!result)
7021 return;
7022
7023 do
7024 {
7025 Field* fields = result->Fetch();
7026
7027 uint32 id = fields[0].Get<uint32>();
7028 std::string localeName = fields[1].Get<std::string>();
7029
7030 LocaleConstant locale = GetLocaleByName(localeName);
7031 if (locale == LOCALE_enUS)
7032 continue;
7033
7035 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
7036 } while (result->NextRow());
7037
7038 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7039}
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 ( )
8511{
8512 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
8513 {
8514 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
8515 LOG_INFO("server.loading", " ");
8516 return;
8517 }
8518
8519 uint32 oldMSTime = getMSTime();
8520
8521 _questPOIStore.clear(); // need for reload case
8522
8523 uint32 count = 0;
8524
8525 // 0 1 2 3 4 5 6 7
8526 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
8527
8528 if (!result)
8529 {
8530 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
8531 LOG_INFO("server.loading", " ");
8532 return;
8533 }
8534
8535 // 0 1 2 3
8536 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
8537
8538 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
8539
8540 if (points)
8541 {
8542 // The first result should have the highest questId
8543 Field* fields = points->Fetch();
8544 uint32 questIdMax = fields[0].Get<uint32>();
8545 POIs.resize(questIdMax + 1);
8546
8547 do
8548 {
8549 fields = points->Fetch();
8550
8551 uint32 questId = fields[0].Get<uint32>();
8552 uint32 id = fields[1].Get<uint32>();
8553 int32 x = fields[2].Get<int32>();
8554 int32 y = fields[3].Get<int32>();
8555
8556 if (POIs[questId].size() <= id + 1)
8557 POIs[questId].resize(id + 10);
8558
8559 QuestPOIPoint point(x, y);
8560 POIs[questId][id].push_back(point);
8561 } while (points->NextRow());
8562 }
8563
8564 do
8565 {
8566 Field* fields = result->Fetch();
8567
8568 uint32 questId = fields[0].Get<uint32>();
8569 uint32 id = fields[1].Get<uint32>();
8570 int32 objIndex = fields[2].Get<int32>();
8571 uint32 mapId = fields[3].Get<uint32>();
8572 uint32 WorldMapAreaId = fields[4].Get<uint32>();
8573 uint32 FloorId = fields[5].Get<uint32>();
8574 uint32 unk3 = fields[6].Get<uint32>();
8575 uint32 unk4 = fields[7].Get<uint32>();
8576
8577 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
8578 if (questId < POIs.size() && id < POIs[questId].size())
8579 {
8580 POI.points = POIs[questId][id];
8581 _questPOIStore[questId].push_back(POI);
8582 }
8583 else
8584 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
8585
8586 ++count;
8587 } while (result->NextRow());
8588
8589 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8590 LOG_INFO("server.loading", " ");
8591}
@ CONFIG_QUEST_POI_ENABLED
Definition WorldConfig.h:136
Definition ObjectMgr.h:644
Definition ObjectMgr.h:653

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
8861{
8862 uint32 oldMSTime = getMSTime();
8863
8864 map.clear(); // need for reload case
8865
8866 uint32 count = 0;
8867
8868 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8869
8870 if (!result)
8871 {
8872 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8873 LOG_INFO("server.loading", " ");
8874 return;
8875 }
8876
8877 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8878 if (starter)
8879 poolRelationMap->clear();
8880
8881 do
8882 {
8883 uint32 id = result->Fetch()[0].Get<uint32>();
8884 uint32 quest = result->Fetch()[1].Get<uint32>();
8885 uint32 poolId = result->Fetch()[2].Get<uint32>();
8886
8887 if (_questTemplates.find(quest) == _questTemplates.end())
8888 {
8889 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8890 continue;
8891 }
8892
8893 if (!poolId || !starter)
8894 map.insert(QuestRelations::value_type(id, quest));
8895 else if (starter)
8896 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8897
8898 ++count;
8899 } while (result->NextRow());
8900
8901 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8902 LOG_INFO("server.loading", " ");
8903}
#define sPoolMgr
Definition PoolMgr.h:216
std::multimap< uint32, uint32 > PooledQuestRelation
Definition PoolMgr.h:120

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

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

◆ LoadQuestRequestItemsLocale()

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

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
964 {
965 LOG_INFO("server.loading", "Loading GO Start Quest Data...");
967 LOG_INFO("server.loading", "Loading GO End Quest Data...");
969 LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
971 LOG_INFO("server.loading", "Loading Creature End Quest Data...");
973 }
void LoadCreatureQuestEnders()
Definition ObjectMgr.cpp:8947
void LoadGameobjectQuestEnders()
Definition ObjectMgr.cpp:8919
void LoadGameobjectQuestStarters()
Definition ObjectMgr.cpp:8905
void LoadCreatureQuestStarters()
Definition ObjectMgr.cpp:8933

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

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
10152{
10153 // find all items from the reference vendor
10155 stmt->SetData(0, uint32(item));
10156 PreparedQueryResult result = WorldDatabase.Query(stmt);
10157
10158 if (!result)
10159 return 0;
10160
10161 uint32 count = 0;
10162 do
10163 {
10164 Field* fields = result->Fetch();
10165
10166 int32 item_id = fields[0].Get<int32>();
10167
10168 // if item is a negative, its a reference
10169 if (item_id < 0)
10170 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
10171 else
10172 {
10173 uint32 maxcount = fields[1].Get<uint32>();
10174 uint32 incrtime = fields[2].Get<uint32>();
10175 uint32 ExtendedCost = fields[3].Get<uint32>();
10176
10177 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
10178 continue;
10179
10180 VendorItemData& vList = _cacheVendorItemStore[vendor];
10181
10182 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
10183 ++count;
10184 }
10185 } while (result->NextRow());
10186
10187 return count;
10188}
@ WORLD_SEL_NPC_VENDOR_REF
Definition WorldDatabase.h:46
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:10413
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition ObjectMgr.cpp:10151

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 ( )
8272{
8273 uint32 oldMSTime = getMSTime();
8274
8275 // For reload case
8276 _repOnKillStore.clear();
8277
8278 uint32 count = 0;
8279
8280 // 0 1 2
8281 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
8282 // 3 4 5 6 7 8 9
8283 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
8284 "FROM creature_onkill_reputation");
8285
8286 if (!result)
8287 {
8288 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
8289 LOG_INFO("server.loading", " ");
8290 return;
8291 }
8292
8293 do
8294 {
8295 Field* fields = result->Fetch();
8296
8297 uint32 creature_id = fields[0].Get<uint32>();
8298
8299 ReputationOnKillEntry repOnKill;
8300 repOnKill.RepFaction1 = fields[1].Get<int16>();
8301 repOnKill.RepFaction2 = fields[2].Get<int16>();
8302 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
8303 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
8304 repOnKill.RepValue1 = fields[5].Get<float>();
8305 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
8306 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
8307 repOnKill.RepValue2 = fields[8].Get<float>();
8308 repOnKill.TeamDependent = fields[9].Get<uint8>();
8309
8310 if (!GetCreatureTemplate(creature_id))
8311 {
8312 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
8313 continue;
8314 }
8315
8316 if (repOnKill.RepFaction1)
8317 {
8318 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
8319 if (!factionEntry1)
8320 {
8321 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
8322 continue;
8323 }
8324 }
8325
8326 if (repOnKill.RepFaction2)
8327 {
8328 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
8329 if (!factionEntry2)
8330 {
8331 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
8332 continue;
8333 }
8334 }
8335
8336 _repOnKillStore[creature_id] = repOnKill;
8337
8338 ++count;
8339 } while (result->NextRow());
8340
8341 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8342 LOG_INFO("server.loading", " ");
8343}
Definition ObjectMgr.h:574
uint32 RepFaction1
Definition ObjectMgr.h:575

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

◆ LoadReputationRewardRate()

void ObjectMgr::LoadReputationRewardRate ( )
8184{
8185 uint32 oldMSTime = getMSTime();
8186
8187 _repRewardRateStore.clear(); // for reload case
8188
8189 uint32 count = 0; // 0 1 2 3 4 5 6 7
8190 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");
8191 if (!result)
8192 {
8193 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
8194 return;
8195 }
8196
8197 do
8198 {
8199 Field* fields = result->Fetch();
8200
8201 uint32 factionId = fields[0].Get<uint32>();
8202
8203 RepRewardRate repRate;
8204
8205 repRate.questRate = fields[1].Get<float>();
8206 repRate.questDailyRate = fields[2].Get<float>();
8207 repRate.questWeeklyRate = fields[3].Get<float>();
8208 repRate.questMonthlyRate = fields[4].Get<float>();
8209 repRate.questRepeatableRate = fields[5].Get<float>();
8210 repRate.creatureRate = fields[6].Get<float>();
8211 repRate.spellRate = fields[7].Get<float>();
8212
8213 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
8214 if (!factionEntry)
8215 {
8216 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
8217 continue;
8218 }
8219
8220 if (repRate.questRate < 0.0f)
8221 {
8222 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
8223 continue;
8224 }
8225
8226 if (repRate.questDailyRate < 0.0f)
8227 {
8228 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
8229 continue;
8230 }
8231
8232 if (repRate.questWeeklyRate < 0.0f)
8233 {
8234 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
8235 continue;
8236 }
8237
8238 if (repRate.questMonthlyRate < 0.0f)
8239 {
8240 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
8241 continue;
8242 }
8243
8244 if (repRate.questRepeatableRate < 0.0f)
8245 {
8246 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
8247 continue;
8248 }
8249
8250 if (repRate.creatureRate < 0.0f)
8251 {
8252 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
8253 continue;
8254 }
8255
8256 if (repRate.spellRate < 0.0f)
8257 {
8258 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
8259 continue;
8260 }
8261
8262 _repRewardRateStore[factionId] = repRate;
8263
8264 ++count;
8265 } while (result->NextRow());
8266
8267 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8268 LOG_INFO("server.loading", " ");
8269}
Definition ObjectMgr.h:563
float questRate
Definition ObjectMgr.h:564

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

◆ LoadReputationSpilloverTemplate()

void ObjectMgr::LoadReputationSpilloverTemplate ( )
8346{
8347 uint32 oldMSTime = getMSTime();
8348
8349 _repSpilloverTemplateStore.clear(); // for reload case
8350
8351 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
8352 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");
8353
8354 if (!result)
8355 {
8356 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
8357 LOG_INFO("server.loading", " ");
8358 return;
8359 }
8360
8361 do
8362 {
8363 Field* fields = result->Fetch();
8364
8365 uint32 factionId = fields[0].Get<uint16>();
8366
8367 RepSpilloverTemplate repTemplate;
8368
8369 repTemplate.faction[0] = fields[1].Get<uint16>();
8370 repTemplate.faction_rate[0] = fields[2].Get<float>();
8371 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
8372 repTemplate.faction[1] = fields[4].Get<uint16>();
8373 repTemplate.faction_rate[1] = fields[5].Get<float>();
8374 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
8375 repTemplate.faction[2] = fields[7].Get<uint16>();
8376 repTemplate.faction_rate[2] = fields[8].Get<float>();
8377 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
8378 repTemplate.faction[3] = fields[10].Get<uint16>();
8379 repTemplate.faction_rate[3] = fields[11].Get<float>();
8380 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
8381 repTemplate.faction[4] = fields[13].Get<uint16>();
8382 repTemplate.faction_rate[4] = fields[14].Get<float>();
8383 repTemplate.faction_rank[4] = fields[15].Get<uint8>();
8384 repTemplate.faction[5] = fields[16].Get<uint16>();
8385 repTemplate.faction_rate[5] = fields[17].Get<float>();
8386 repTemplate.faction_rank[5] = fields[18].Get<uint8>();
8387
8388 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
8389
8390 if (!factionEntry)
8391 {
8392 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
8393 continue;
8394 }
8395
8396 if (factionEntry->team == 0)
8397 {
8398 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
8399 continue;
8400 }
8401
8402 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
8403 {
8404 if (repTemplate.faction[i])
8405 {
8406 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
8407
8408 if (!factionSpillover)
8409 {
8410 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);
8411 continue;
8412 }
8413
8414 if (factionSpillover->reputationListID < 0)
8415 {
8416 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);
8417 continue;
8418 }
8419
8420 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
8421 {
8422 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
8423 continue;
8424 }
8425 }
8426 }
8427
8428 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
8429 if (repTemplate.faction[0] && !factionEntry0)
8430 {
8431 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
8432 continue;
8433 }
8434 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
8435 if (repTemplate.faction[1] && !factionEntry1)
8436 {
8437 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
8438 continue;
8439 }
8440 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
8441 if (repTemplate.faction[2] && !factionEntry2)
8442 {
8443 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
8444 continue;
8445 }
8446 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
8447 if (repTemplate.faction[3] && !factionEntry3)
8448 {
8449 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
8450 continue;
8451 }
8452
8453 _repSpilloverTemplateStore[factionId] = repTemplate;
8454
8455 ++count;
8456 } while (result->NextRow());
8457
8458 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8459 LOG_INFO("server.loading", " ");
8460}
#define MAX_SPILLOVER_FACTIONS
Definition SharedDefines.h:235
int32 reputationListID
Definition DBCStructure.h:945
Definition ObjectMgr.h:587
uint32 faction[MAX_SPILLOVER_FACTIONS]
Definition ObjectMgr.h:588

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 ( )
8962{
8963 uint32 oldMSTime = getMSTime();
8964
8965 _reservedNamesStore.clear(); // need for reload case
8966
8967 QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
8968
8969 if (!result)
8970 {
8971 LOG_WARN("server.loading", ">> Loaded 0 reserved names. DB table `reserved_name` is empty!");
8972 return;
8973 }
8974
8975 uint32 count = 0;
8976
8977 Field* fields;
8978 do
8979 {
8980 fields = result->Fetch();
8981 std::string name = fields[0].Get<std::string>();
8982
8983 std::wstring wstr;
8984 if (!Utf8toWStr (name, wstr))
8985 {
8986 LOG_ERROR("sql.sql", "Table `reserved_name` have invalid name: {}", name);
8987 continue;
8988 }
8989
8990 wstrToLower(wstr);
8991
8992 _reservedNamesStore.insert(wstr);
8993 ++count;
8994 } while (result->NextRow());
8995
8996 LOG_INFO("server.loading", ">> Loaded {} reserved names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8997}

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

◆ LoadReservedPlayerNamesDBC()

void ObjectMgr::LoadReservedPlayerNamesDBC ( )
9000{
9001 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
9002 {
9003 LOG_WARN("server.loading", ">> Loaded 0 reserved names from DBC. Config option disabled.");
9004 return;
9005 }
9006
9007 uint32 oldMSTime = getMSTime();
9008
9009 uint32 count = 0;
9010
9011 for (NamesReservedEntry const* reservedStore : sNamesReservedStore)
9012 {
9013 std::wstring wstr;
9014
9015 Utf8toWStr(reservedStore->Pattern, wstr);
9016
9017 // DBC does not have clean entries, remove the junk.
9018 boost::algorithm::replace_all(wstr, "\\<", "");
9019 boost::algorithm::replace_all(wstr, "\\>", "");
9020
9021 _reservedNamesStore.insert(wstr);
9022 count++;
9023 }
9024
9025 LOG_INFO("server.loading", ">> Loaded {} reserved names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9026 LOG_INFO("server.loading", " ");
9027}
DBCStorage< NamesReservedEntry > sNamesReservedStore(NamesReservedfmt)
@ CONFIG_STRICT_NAMES_RESERVED
Definition WorldConfig.h:142
Definition DBCStructure.h:1434

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

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
10494{
10495 uint32 oldMSTime = getMSTime();
10496
10497 // We insert an empty placeholder here so we can use the
10498 // script id 0 as dummy for "no script found".
10499 _scriptNamesStore.emplace_back("");
10500
10501 QueryResult result = WorldDatabase.Query(
10502 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
10503 "UNION "
10504 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
10505 "UNION "
10506 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
10507 "UNION "
10508 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
10509 "UNION "
10510 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
10511 "UNION "
10512 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
10513 "UNION "
10514 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
10515 "UNION "
10516 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
10517 "UNION "
10518 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
10519 "UNION "
10520 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
10521 "UNION "
10522 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
10523 "UNION "
10524 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
10525 "UNION "
10526 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
10527 "UNION "
10528 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
10529
10530 if (!result)
10531 {
10532 LOG_INFO("server.loading", " ");
10533 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
10534 return;
10535 }
10536
10537 _scriptNamesStore.reserve(result->GetRowCount() + 1);
10538
10539 do
10540 {
10541 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
10542 } while (result->NextRow());
10543
10544 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
10545 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
10546 LOG_INFO("server.loading", " ");
10547}

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

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5941{
5942 uint32 oldMSTime = getMSTime();
5943
5944 ScriptMapMap* scripts = GetScriptsMapByType(type);
5945 if (!scripts)
5946 return;
5947
5948 std::string tableName = GetScriptsTableNameByType(type);
5949 if (tableName.empty())
5950 return;
5951
5952 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5953 return;
5954
5955 LOG_INFO("server.loading", "Loading {}...", tableName);
5956
5957 scripts->clear(); // need for reload support
5958
5959 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5960 // 0 1 2 3 4 5 6 7 8 9
5961 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5962
5963 if (!result)
5964 {
5965 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5966 LOG_INFO("server.loading", " ");
5967 return;
5968 }
5969
5970 uint32 count = 0;
5971
5972 do
5973 {
5974 Field* fields = result->Fetch();
5975 ScriptInfo tmp;
5976 tmp.type = type;
5977 tmp.id = fields[0].Get<uint32>();
5978 if (isSpellScriptTable)
5979 tmp.id |= fields[10].Get<uint8>() << 24;
5980 tmp.delay = fields[1].Get<uint32>();
5981 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5982 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5983 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5984 tmp.Raw.nData[2] = fields[5].Get<int32>();
5985 tmp.Raw.fData[0] = fields[6].Get<float>();
5986 tmp.Raw.fData[1] = fields[7].Get<float>();
5987 tmp.Raw.fData[2] = fields[8].Get<float>();
5988 tmp.Raw.fData[3] = fields[9].Get<float>();
5989
5990 // generic command args check
5991 switch (tmp.command)
5992 {
5994 {
5996 {
5997 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5998 tableName, tmp.Talk.ChatType, tmp.id);
5999 continue;
6000 }
6002 {
6003 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
6004 tableName, tmp.Talk.TextID, tmp.id);
6005 continue;
6006 }
6007 break;
6008 }
6009
6011 {
6012 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
6013 {
6014 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
6015 tableName, tmp.Emote.EmoteID, tmp.id);
6016 continue;
6017 }
6018 break;
6019 }
6020
6022 {
6023 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
6024 {
6025 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
6026 tableName, tmp.TeleportTo.MapID, tmp.id);
6027 continue;
6028 }
6029
6031 {
6032 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
6033 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
6034 continue;
6035 }
6036 break;
6037 }
6038
6040 {
6041 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
6042 if (!quest)
6043 {
6044 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
6045 tableName, tmp.QuestExplored.QuestID, tmp.id);
6046 continue;
6047 }
6048
6050 {
6051 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.",
6052 tableName, tmp.QuestExplored.QuestID, tmp.id);
6053
6054 // this will prevent quest completing without objective
6055 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6056
6057 // continue; - quest objective requirement set and command can be allowed
6058 }
6059
6061 {
6062 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 {}",
6063 tableName, tmp.QuestExplored.Distance, tmp.id);
6064 continue;
6065 }
6066
6068 {
6069 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",
6071 continue;
6072 }
6073
6075 {
6076 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",
6077 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
6078 continue;
6079 }
6080
6081 break;
6082 }
6083
6085 {
6087 {
6088 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
6089 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
6090 continue;
6091 }
6092 break;
6093 }
6094
6096 {
6098 if (!data)
6099 {
6100 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
6101 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
6102 continue;
6103 }
6104
6105 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
6106 if (!info)
6107 {
6108 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
6109 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
6110 continue;
6111 }
6112
6113 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
6115 info->type == GAMEOBJECT_TYPE_DOOR ||
6116 info->type == GAMEOBJECT_TYPE_BUTTON ||
6117 info->type == GAMEOBJECT_TYPE_TRAP)
6118 {
6119 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
6120 tableName, info->entry, tmp.id);
6121 continue;
6122 }
6123 break;
6124 }
6125
6127 {
6129 {
6130 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
6132 continue;
6133 }
6134
6136 if (!GetCreatureTemplate(entry))
6137 {
6138 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
6139 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
6140 continue;
6141 }
6142 break;
6143 }
6144
6147 {
6149 if (!data)
6150 {
6151 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
6152 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
6153 continue;
6154 }
6155
6156 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
6157 if (!info)
6158 {
6159 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
6160 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
6161 continue;
6162 }
6163
6164 if (info->type != GAMEOBJECT_TYPE_DOOR)
6165 {
6166 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
6167 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
6168 continue;
6169 }
6170
6171 break;
6172 }
6173
6175 {
6176 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
6177 {
6178 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
6179 tableName, tmp.RemoveAura.SpellID, tmp.id);
6180 continue;
6181 }
6182 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
6183 {
6184 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
6185 tableName, tmp.RemoveAura.Flags, tmp.id);
6186 continue;
6187 }
6188 break;
6189 }
6190
6192 {
6193 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
6194 {
6195 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6196 tableName, tmp.CastSpell.SpellID, tmp.id);
6197 continue;
6198 }
6199 if (tmp.CastSpell.Flags > 4) // targeting type
6200 {
6201 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6202 tableName, tmp.CastSpell.Flags, tmp.id);
6203 continue;
6204 }
6205 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
6206 {
6207 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6208 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
6209 continue;
6210 }
6211 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
6212 {
6213 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
6214 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
6215 continue;
6216 }
6217 break;
6218 }
6219
6221 {
6223 {
6224 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
6225 tableName, tmp.CreateItem.ItemEntry, tmp.id);
6226 continue;
6227 }
6228 if (!tmp.CreateItem.Amount)
6229 {
6230 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
6231 tableName, tmp.CreateItem.Amount, tmp.id);
6232 continue;
6233 }
6234 break;
6235 }
6236 default:
6237 break;
6238 }
6239
6240 if (scripts->find(tmp.id) == scripts->end())
6241 {
6242 ScriptMap emptyMap;
6243 (*scripts)[tmp.id] = emptyMap;
6244 }
6245 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
6246
6247 ++count;
6248 } while (result->NextRow());
6249
6250 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6251 LOG_INFO("server.loading", " ");
6252}
@ 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:388
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition ObjectMgr.cpp:84
ScriptCommands
Definition ObjectMgr.h:94
@ SCRIPT_COMMAND_EMOTE
Definition ObjectMgr.h:96
@ SCRIPT_COMMAND_CREATE_ITEM
Definition ObjectMgr.h:112
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition ObjectMgr.h:107
@ SCRIPT_COMMAND_CAST_SPELL
Definition ObjectMgr.h:110
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition ObjectMgr.h:104
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition ObjectMgr.h:102
@ SCRIPT_COMMAND_TALK
Definition ObjectMgr.h:95
@ SCRIPT_COMMAND_OPEN_DOOR
Definition ObjectMgr.h:106
@ SCRIPT_COMMAND_TELEPORT_TO
Definition ObjectMgr.h:101
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition ObjectMgr.h:105
@ SCRIPT_COMMAND_KILL_CREDIT
Definition ObjectMgr.h:103
@ SCRIPT_COMMAND_REMOVE_AURA
Definition ObjectMgr.h:109
std::string GetScriptCommandName(ScriptCommands command)
Definition ObjectMgr.cpp:104
std::map< uint32, ScriptMap > ScriptMapMap
Definition ObjectMgr.h:389
std::string GetScriptsTableNameByType(ScriptsType type)
Definition ObjectMgr.cpp:64
@ SCRIPTS_SPELL
Definition ObjectMgr.h:151
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1581
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3427
Definition ObjectMgr.h:193
float Orientation
Definition ObjectMgr.h:253
struct ScriptInfo::@272::@275 Talk
uint32 Flags
Definition ObjectMgr.h:210
struct ScriptInfo::@272::@289 CreateItem
struct ScriptInfo::@272::@284 TempSummonCreature
ScriptsType type
Definition ObjectMgr.h:194
uint32 QuestID
Definition ObjectMgr.h:258
struct ScriptInfo::@272::@286 RemoveAura
struct ScriptInfo::@272::@282 KillCredit
int32 TextID
Definition ObjectMgr.h:211
float DestX
Definition ObjectMgr.h:232
struct ScriptInfo::@272::@280 TeleportTo
uint32 ItemEntry
Definition ObjectMgr.h:319
uint32 ChatType
Definition ObjectMgr.h:209
uint32 id
Definition ObjectMgr.h:195
uint32 delay
Definition ObjectMgr.h:196
float fData[4]
Definition ObjectMgr.h:204
struct ScriptInfo::@272::@287 CastSpell
float PosY
Definition ObjectMgr.h:281
ScriptCommands command
Definition ObjectMgr.h:197
float DestY
Definition ObjectMgr.h:233
uint32 MapID
Definition ObjectMgr.h:246
uint32 nData[3]
Definition ObjectMgr.h:203
float PosZ
Definition ObjectMgr.h:282
struct ScriptInfo::@272::@276 Emote
struct ScriptInfo::@272::@274 Raw
float PosX
Definition ObjectMgr.h:280
struct ScriptInfo::@272::@285 ToggleDoor
uint32 Distance
Definition ObjectMgr.h:259
struct ScriptInfo::@272::@283 RespawnGameobject
struct ScriptInfo::@272::@281 QuestExplored
uint32 SpellID
Definition ObjectMgr.h:297
float DestZ
Definition ObjectMgr.h:234
uint32 GOGuid
Definition ObjectMgr.h:270
uint32 CreatureEntry
Definition ObjectMgr.h:264
uint32 Amount
Definition ObjectMgr.h:320
uint32 EmoteID
Definition ObjectMgr.h:216

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 ( )
8752{
8753 uint32 oldMSTime = getMSTime();
8754
8755 // Reset prior state for hot-reload support
8756 // Preserve the forced legacy group for spawns on transport maps (set in LoadCreatures/LoadGameobjects).
8757 _spawnGroupMapStore.clear();
8758 for (auto& [id, data] : _creatureDataStore)
8759 data.spawnGroupId = _transportMaps.count(data.mapid) ? 1 : 0;
8760 for (auto& [id, data] : _gameObjectDataStore)
8761 data.spawnGroupId = _transportMaps.count(data.mapid) ? 1 : 0;
8762
8763 // 0 1 2
8764 QueryResult result = WorldDatabase.Query("SELECT groupId, spawnType, spawnId FROM spawn_group");
8765
8766 if (!result)
8767 {
8768 LOG_INFO("server.loading", ">> Loaded 0 spawn group members. DB table `spawn_group` is empty.");
8769 LOG_INFO("server.loading", " ");
8770 return;
8771 }
8772
8773 uint32 numMembers = 0;
8774 do
8775 {
8776 Field* fields = result->Fetch();
8777 uint32 groupId = fields[0].Get<uint32>();
8778 uint32 type = fields[1].Get<uint8>();
8779 if (type >= SPAWN_TYPE_MAX)
8780 {
8781 LOG_ERROR("sql.sql", "Spawn data with invalid type {} listed for spawn group {}. Skipped.", type, groupId);
8782 continue;
8783 }
8784 SpawnObjectType spawnType = SpawnObjectType(type);
8785 ObjectGuid::LowType spawnId = fields[2].Get<uint32>();
8786
8787 SpawnData const* data = GetSpawnData(spawnType, spawnId);
8788 if (!data)
8789 {
8790 LOG_ERROR("sql.sql", "Spawn data with ID ({},{}) not found, but is listed as a member of spawn group {}!",
8791 uint32(spawnType), spawnId, groupId);
8792 continue;
8793 }
8794 if (data->spawnGroupId)
8795 {
8796 LOG_ERROR("sql.sql", "Spawn with ID ({},{}) is listed as a member of spawn group {}, but is already a member of spawn group {}. Skipping.",
8797 uint32(spawnType), spawnId, groupId, data->spawnGroupId);
8798 continue;
8799 }
8800
8801 auto it = _spawnGroupDataStore.find(groupId);
8802 if (it == _spawnGroupDataStore.end())
8803 {
8804 LOG_ERROR("sql.sql", "Spawn group {} assigned to spawn ID ({},{}), but group is not found!", groupId, uint32(spawnType), spawnId);
8805 continue;
8806 }
8807
8808 SpawnGroupTemplateData& groupTemplate = it->second;
8809 if (groupTemplate.mapId == SPAWNGROUP_MAP_UNSET)
8810 groupTemplate.mapId = data->mapid;
8811 else if (groupTemplate.mapId != data->mapid && !(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
8812 {
8813 LOG_ERROR("sql.sql", "Spawn group {} has map ID {}, but spawn ({},{}) has map id {} - spawn NOT added to group!",
8814 groupId, groupTemplate.mapId, uint32(spawnType), spawnId, data->mapid);
8815 continue;
8816 }
8817
8818 // Warn if spawn is also in a pool (non-system groups and pools are mutually exclusive)
8819 if (!(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
8820 {
8821 uint32 poolId = 0;
8822 if (spawnType == SPAWN_TYPE_CREATURE)
8823 poolId = sPoolMgr->IsPartOfAPool<Creature>(spawnId);
8824 else if (spawnType == SPAWN_TYPE_GAMEOBJECT)
8825 poolId = sPoolMgr->IsPartOfAPool<GameObject>(spawnId);
8826
8827 if (poolId)
8828 LOG_WARN("sql.sql", "Spawn ({},{}) is a member of spawn group {} and also part of pool {}. This may cause issues!",
8829 uint32(spawnType), spawnId, groupId, poolId);
8830 }
8831
8832 const_cast<SpawnData*>(data)->spawnGroupId = groupId;
8833 if (!(groupTemplate.flags & SPAWNGROUP_FLAG_SYSTEM))
8834 _spawnGroupMapStore.emplace(groupId, data);
8835 ++numMembers;
8836 } while (result->NextRow());
8837
8838 LOG_INFO("server.loading", ">> Loaded {} spawn group members in {} ms", numMembers, GetMSTimeDiffToNow(oldMSTime));
8839 LOG_INFO("server.loading", " ");
8840}
SpawnObjectType
Definition SpawnData.h:26
@ SPAWN_TYPE_MAX
Definition SpawnData.h:30
SpawnData const * GetSpawnData(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition ObjectMgr.cpp:8680
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 ( )
8694{
8695 uint32 oldMSTime = getMSTime();
8696
8697 _spawnGroupDataStore.clear();
8698
8699 // 0 1 2
8700 QueryResult result = WorldDatabase.Query("SELECT groupId, groupName, groupFlags FROM spawn_group_template");
8701
8702 if (result)
8703 {
8704 do
8705 {
8706 Field* fields = result->Fetch();
8707 uint32 groupId = fields[0].Get<uint32>();
8709 group.groupId = groupId;
8710 group.name = fields[1].Get<std::string>();
8711 group.mapId = SPAWNGROUP_MAP_UNSET;
8712 uint32 flags = fields[2].Get<uint32>();
8713 if (flags & ~uint32(SPAWNGROUP_FLAG_ALL))
8714 {
8715 flags &= uint32(SPAWNGROUP_FLAG_ALL);
8716 LOG_ERROR("sql.sql", "Invalid spawn group flag {} on group ID {} ({}), reduced to valid flags {}.",
8717 fields[2].Get<uint32>(), groupId, group.name, flags);
8718 }
8719 if ((flags & SPAWNGROUP_FLAG_SYSTEM) && (flags & SPAWNGROUP_FLAG_MANUAL_SPAWN))
8720 {
8721 flags &= ~SPAWNGROUP_FLAG_MANUAL_SPAWN;
8722 LOG_ERROR("sql.sql", "System spawn group {} ({}) has invalid manual spawn flag. Ignored.", groupId, group.name);
8723 }
8724 group.flags = SpawnGroupFlags(flags);
8725 } while (result->NextRow());
8726 }
8727
8728 if (_spawnGroupDataStore.find(0) == _spawnGroupDataStore.end())
8729 {
8730 LOG_ERROR("sql.sql", "Default spawn group (index 0) is missing from DB! Manually inserted.");
8732 data.groupId = 0;
8733 data.name = "Default Group";
8736 }
8737 if (_spawnGroupDataStore.find(1) == _spawnGroupDataStore.end())
8738 {
8739 LOG_ERROR("sql.sql", "Default legacy spawn group (index 1) is missing from DB! Manually inserted.");
8741 data.groupId = 1;
8742 data.name = "Legacy Group";
8745 }
8746
8747 LOG_INFO("server.loading", ">> Loaded {} spawn group templates in {} ms", _spawnGroupDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
8748 LOG_INFO("server.loading", " ");
8749}
@ 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 ( )
6354{
6355 uint32 oldMSTime = getMSTime();
6356
6357 _spellScriptsStore.clear(); // need for reload case
6358
6359 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
6360
6361 if (!result)
6362 {
6363 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
6364 LOG_INFO("server.loading", " ");
6365 return;
6366 }
6367
6368 uint32 count = 0;
6369
6370 do
6371 {
6372 Field* fields = result->Fetch();
6373
6374 int32 spellId = fields[0].Get<int32>();
6375 std::string scriptName = fields[1].Get<std::string>();
6376
6377 bool allRanks = false;
6378 if (spellId <= 0)
6379 {
6380 allRanks = true;
6381 spellId = -spellId;
6382 }
6383
6384 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
6385 if (!spellInfo)
6386 {
6387 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
6388 continue;
6389 }
6390
6391 if (allRanks)
6392 {
6393 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
6394 {
6395 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
6396 continue;
6397 }
6398 while (spellInfo)
6399 {
6400 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
6401 spellInfo = spellInfo->GetNextRankSpell();
6402 }
6403 }
6404 else
6405 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
6406 ++count;
6407 } while (result->NextRow());
6408
6409 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6410 LOG_INFO("server.loading", " ");
6411}
SpellInfo const * GetNextRankSpell() const
Definition SpellInfo.cpp:2946

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

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
6255{
6257
6258 // check ids
6259 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
6260 {
6261 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
6262 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
6263
6264 if (!spellInfo)
6265 {
6266 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
6267 continue;
6268 }
6269
6270 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
6271 if (uint32(i) >= MAX_SPELL_EFFECTS)
6272 {
6273 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
6274 }
6275
6276 //check for correct spellEffect
6277 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
6278 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
6279 }
6280}
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 ( )
7071{
7072 uint32 oldMSTime = getMSTime();
7073
7074 _tavernAreaTriggerStore.clear(); // need for reload case
7075
7076 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
7077
7078 if (!result)
7079 {
7080 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
7081 LOG_INFO("server.loading", " ");
7082 return;
7083 }
7084
7085 uint32 count = 0;
7086
7087 do
7088 {
7089 ++count;
7090
7091 Field* fields = result->Fetch();
7092
7093 uint32 Trigger_ID = fields[0].Get<uint32>();
7094
7095 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
7096 if (!atEntry)
7097 {
7098 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
7099 continue;
7100 }
7101
7102 uint32 faction = fields[1].Get<uint32>();
7103
7104 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
7105 } while (result->NextRow());
7106
7107 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7108 LOG_INFO("server.loading", " ");
7109}

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

◆ LoadTempSummons()

void ObjectMgr::LoadTempSummons ( )
2154{
2155 uint32 oldMSTime = getMSTime();
2156
2157 // 0 1 2 3 4 5 6 7 8 9
2158 QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, summonType, summonTime FROM creature_summon_groups");
2159
2160 if (!result)
2161 {
2162 LOG_WARN("server.loading", ">> Loaded 0 temp summons. DB table `creature_summon_groups` is empty.");
2163 return;
2164 }
2165
2166 uint32 count = 0;
2167 do
2168 {
2169 Field* fields = result->Fetch();
2170
2171 uint32 summonerId = fields[0].Get<uint32>();
2172 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2173 uint8 group = fields[2].Get<uint8>();
2174
2175 switch (summonerType)
2176 {
2178 if (!GetCreatureTemplate(summonerId))
2179 {
2180 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2181 continue;
2182 }
2183 break;
2185 if (!GetGameObjectTemplate(summonerId))
2186 {
2187 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2188 continue;
2189 }
2190 break;
2191 case SUMMONER_TYPE_MAP:
2192 if (!sMapStore.LookupEntry(summonerId))
2193 {
2194 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2195 continue;
2196 }
2197 break;
2198 default:
2199 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2200 continue;
2201 }
2202
2203 TempSummonData data;
2204 data.entry = fields[3].Get<uint32>();
2205
2206 if (!GetCreatureTemplate(data.entry))
2207 {
2208 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);
2209 continue;
2210 }
2211
2212 float posX = fields[4].Get<float>();
2213 float posY = fields[5].Get<float>();
2214 float posZ = fields[6].Get<float>();
2215 float orientation = fields[7].Get<float>();
2216
2217 data.pos.Relocate(posX, posY, posZ, orientation);
2218
2219 data.type = TempSummonType(fields[8].Get<uint8>());
2220
2222 {
2223 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);
2224 continue;
2225 }
2226
2227 data.time = fields[9].Get<uint32>();
2228
2229 TempSummonGroupKey key(summonerId, summonerType, group);
2230 _tempSummonDataStore[key].push_back(data);
2231
2232 ++count;
2233 } while (result->NextRow());
2234
2235 LOG_INFO("server.loading", ">> Loaded {} Temporary Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2236 LOG_INFO("server.loading", " ");
2237}
TempSummonType
Definition Object.h:49
@ TEMPSUMMON_MANUAL_DESPAWN
Definition Object.h:57
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 ( )
9986{
9987 uint32 oldMSTime = getMSTime();
9988
9989 // For reload case
9990 _trainers.clear();
9991 _classTrainers.clear();
9992
9993 std::unordered_map<int32, std::vector<Trainer::Spell>> spellsByTrainer;
9994 if (QueryResult trainerSpellsResult = WorldDatabase.Query("SELECT TrainerId, SpellId, MoneyCost, ReqSkillLine, ReqSkillRank, ReqAbility1, ReqAbility2, ReqAbility3, ReqLevel FROM trainer_spell"))
9995 {
9996 do
9997 {
9998 Field* fields = trainerSpellsResult->Fetch();
9999
10000 Trainer::Spell spell;
10001 uint32 trainerId = fields[0].Get<uint32>();
10002 spell.SpellId = fields[1].Get<uint32>();
10003 spell.MoneyCost = fields[2].Get<uint32>();
10004 spell.ReqSkillLine = fields[3].Get<uint32>();
10005 spell.ReqSkillRank = fields[4].Get<uint32>();
10006 spell.ReqAbility[0] = fields[5].Get<uint32>();
10007 spell.ReqAbility[1] = fields[6].Get<uint32>();
10008 spell.ReqAbility[2] = fields[7].Get<uint32>();
10009 spell.ReqLevel = fields[8].Get<uint8>();
10010
10011 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.SpellId);
10012 if (!spellInfo)
10013 {
10014 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: {}) for TrainerId {}, ignoring", spell.SpellId, trainerId);
10015 continue;
10016 }
10017
10018 if (GetTalentSpellCost(spell.SpellId))
10019 {
10020 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: {}) which is a talent, for TrainerId {}, ignoring", spell.SpellId, trainerId);
10021 continue;
10022 }
10023
10024 if (spell.ReqSkillLine && !sSkillLineStore.LookupEntry(spell.ReqSkillLine))
10025 {
10026 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing skill (ReqSkillLine: {}) for TrainerId {} and SpellId {}, ignoring",
10027 spell.ReqSkillLine, spell.SpellId, trainerId);
10028 continue;
10029 }
10030
10031 bool allReqValid = true;
10032 for (std::size_t i = 0; i < spell.ReqAbility.size(); ++i)
10033 {
10034 uint32 requiredSpell = spell.ReqAbility[i];
10035 if (requiredSpell && !sSpellMgr->GetSpellInfo(requiredSpell))
10036 {
10037 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (ReqAbility {} : {}) for TrainerId {} and SpellId {}, ignoring",
10038 i + 1, requiredSpell, trainerId, spell.SpellId);
10039 allReqValid = false;
10040 }
10041 }
10042
10043 if (!allReqValid)
10044 continue;
10045
10046 spellsByTrainer[trainerId].push_back(spell);
10047 } while (trainerSpellsResult->NextRow());
10048 }
10049
10050 if (QueryResult trainersResult = WorldDatabase.Query("SELECT Id, Type, Requirement, Greeting FROM trainer"))
10051 {
10052 do
10053 {
10054 Field* fields = trainersResult->Fetch();
10055
10056 uint32 trainerId = fields[0].Get<uint32>();
10057 Trainer::Type trainerType = Trainer::Type(fields[1].Get<uint8>());
10058 uint32 requirement = fields[2].Get<uint32>();
10059 std::string greeting = fields[3].Get<std::string>();
10060 std::vector<Trainer::Spell> spells;
10061 auto spellsItr = spellsByTrainer.find(trainerId);
10062 if (spellsItr != spellsByTrainer.end())
10063 {
10064 spells = std::move(spellsItr->second);
10065 spellsByTrainer.erase(spellsItr);
10066 }
10067
10068 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)));
10069 ASSERT(isNew);
10070 if (trainerType == Trainer::Type::Class)
10071 {
10072 if (!requirement || requirement >= MAX_CLASSES)
10073 LOG_ERROR("sql.sql", "Table `trainer` has invalid class requirement for trainer {}, ignoring");
10074 else
10075 {
10076 uint8 classId = static_cast<uint8>(requirement);
10077 _classTrainers[classId].push_back(&it->second);
10078 }
10079 }
10080 } while (trainersResult->NextRow());
10081 }
10082
10083 for (auto const& unusedSpells : spellsByTrainer)
10084 {
10085 for (Trainer::Spell const& unusedSpell : unusedSpells.second)
10086 {
10087 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing trainer (TrainerId: {}) for SpellId {}, ignoring", unusedSpells.first, unusedSpell.SpellId);
10088 }
10089 }
10090
10091 if (QueryResult trainerLocalesResult = WorldDatabase.Query("SELECT Id, locale, Greeting_lang FROM trainer_locale"))
10092 {
10093 do
10094 {
10095 Field* fields = trainerLocalesResult->Fetch();
10096 uint32 trainerId = fields[0].Get<uint32>();
10097 std::string localeName = fields[1].Get<std::string>();
10098
10099 LocaleConstant locale = GetLocaleByName(localeName);
10100 if (locale == LOCALE_enUS)
10101 continue;
10102
10104 trainer->AddGreetingLocale(locale, fields[2].Get<std::string>());
10105 else
10106 LOG_ERROR("sql.sql", "Table `trainer_locale` references non-existing trainer (TrainerId: {}) for locale %s, ignoring",
10107 trainerId, localeName.c_str());
10108 } while (trainerLocalesResult->NextRow());
10109 }
10110
10111 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", _trainers.size(), GetMSTimeDiffToNow(oldMSTime));
10112}
#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 ( )
4108{
4109 uint32 oldMSTime = getMSTime();
4110
4111 _vehicleAccessoryStore.clear(); // needed for reload case
4112
4113 uint32 count = 0;
4114
4115 // 0 1 2 3 4 5
4116 QueryResult result = WorldDatabase.Query("SELECT `guid`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_accessory`");
4117
4118 if (!result)
4119 {
4120 LOG_WARN("server.loading", ">> Loaded 0 Vehicle Accessories in {} ms", GetMSTimeDiffToNow(oldMSTime));
4121 LOG_INFO("server.loading", " ");
4122 return;
4123 }
4124
4125 do
4126 {
4127 Field* fields = result->Fetch();
4128
4129 uint32 uiGUID = fields[0].Get<uint32>();
4130 uint32 uiAccessory = fields[1].Get<uint32>();
4131 int8 uiSeat = int8(fields[2].Get<int16>());
4132 bool bMinion = fields[3].Get<bool>();
4133 uint8 uiSummonType = fields[4].Get<uint8>();
4134 uint32 uiSummonTimer = fields[5].Get<uint32>();
4135
4136 if (!GetCreatureTemplate(uiAccessory))
4137 {
4138 LOG_ERROR("sql.sql", "Table `vehicle_accessory`: Accessory {} does not exist.", uiAccessory);
4139 continue;
4140 }
4141
4142 _vehicleAccessoryStore[uiGUID].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
4143
4144 ++count;
4145 } while (result->NextRow());
4146
4147 LOG_INFO("server.loading", ">> Loaded {} Vehicle Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4148 LOG_INFO("server.loading", " ");
4149}
Definition VehicleDefines.h:115

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

◆ LoadVehicleSeatAddon()

void ObjectMgr::LoadVehicleSeatAddon ( )
4152{
4153 uint32 oldMSTime = getMSTime();
4154
4155 _vehicleSeatAddonStore.clear(); // needed for reload case
4156
4157 uint32 count = 0;
4158
4159 // 0 1 2 3 4 5 6
4160 QueryResult result = WorldDatabase.Query("SELECT `SeatEntry`, `SeatOrientation`, `ExitParamX`, `ExitParamY`, `ExitParamZ`, `ExitParamO`, `ExitParamValue` FROM `vehicle_seat_addon`");
4161
4162 if (!result)
4163 {
4164 LOG_ERROR("server.loading", ">> Loaded 0 vehicle seat addons. DB table `vehicle_seat_addon` is empty.");
4165 return;
4166 }
4167
4168 do
4169 {
4170 Field* fields = result->Fetch();
4171
4172 uint32 seatID = fields[0].Get<uint32>();
4173 float orientation = fields[1].Get<float>();
4174 float exitX = fields[2].Get<float>();
4175 float exitY = fields[3].Get<float>();
4176 float exitZ = fields[4].Get<float>();
4177 float exitO = fields[5].Get<float>();
4178 uint8 exitParam = fields[6].Get<uint8>();
4179
4180 if (!sVehicleSeatStore.LookupEntry(seatID))
4181 {
4182 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} does not exist in VehicleSeat.dbc. Skipping entry.", seatID);
4183 continue;
4184 }
4185
4186 // Sanitizing values
4187 if (orientation > float(M_PI * 2))
4188 {
4189 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid angle offset value ({}). Set Value to 0.", seatID, orientation);
4190 orientation = 0.0f;
4191 }
4192
4194 {
4195 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid exit parameter value ({}). Setting to 0 (none).", seatID, exitParam);
4196 continue;
4197 }
4198
4199 _vehicleSeatAddonStore[seatID] = VehicleSeatAddon(orientation, exitX, exitY, exitZ, exitO, exitParam);
4200
4201 ++count;
4202 } while (result->NextRow());
4203
4204 LOG_INFO("server.loading", ">> Loaded {} Vehicle Seat Addon entries in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4205}
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 ( )
4052{
4053 uint32 oldMSTime = getMSTime();
4054
4055 _vehicleTemplateAccessoryStore.clear(); // needed for reload case
4056
4057 uint32 count = 0;
4058
4059 // 0 1 2 3 4 5
4060 QueryResult result = WorldDatabase.Query("SELECT `entry`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_template_accessory`");
4061
4062 if (!result)
4063 {
4064 LOG_WARN("server.loading", ">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
4065 LOG_INFO("server.loading", " ");
4066 return;
4067 }
4068
4069 do
4070 {
4071 Field* fields = result->Fetch();
4072
4073 uint32 uiEntry = fields[0].Get<uint32>();
4074 uint32 uiAccessory = fields[1].Get<uint32>();
4075 int8 uiSeat = int8(fields[2].Get<int8>());
4076 bool bMinion = fields[3].Get<bool>();
4077 uint8 uiSummonType = fields[4].Get<uint8>();
4078 uint32 uiSummonTimer = fields[5].Get<uint32>();
4079
4080 if (!GetCreatureTemplate(uiEntry))
4081 {
4082 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} does not exist.", uiEntry);
4083 continue;
4084 }
4085
4086 if (!GetCreatureTemplate(uiAccessory))
4087 {
4088 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: Accessory {} does not exist.", uiAccessory);
4089 continue;
4090 }
4091
4092 if (_spellClickInfoStore.find(uiEntry) == _spellClickInfoStore.end())
4093 {
4094 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} has no data in npc_spellclick_spells", uiEntry);
4095 continue;
4096 }
4097
4098 _vehicleTemplateAccessoryStore[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
4099
4100 ++count;
4101 } while (result->NextRow());
4102
4103 LOG_INFO("server.loading", ">> Loaded {} Vehicle Template Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4104 LOG_INFO("server.loading", " ");
4105}

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

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
10191{
10192 uint32 oldMSTime = getMSTime();
10193
10194 // For reload case
10195 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
10196 itr->second.Clear();
10197 _cacheVendorItemStore.clear();
10198
10199 std::set<uint32> skip_vendors;
10200
10201 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
10202 if (!result)
10203 {
10204 LOG_INFO("server.loading", " ");
10205 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
10206 return;
10207 }
10208
10209 uint32 count = 0;
10210
10211 do
10212 {
10213 Field* fields = result->Fetch();
10214
10215 uint32 entry = fields[0].Get<uint32>();
10216 int32 item_id = fields[1].Get<int32>();
10217
10218 // if item is a negative, its a reference
10219 if (item_id < 0)
10220 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
10221 else
10222 {
10223 uint32 maxcount = fields[2].Get<uint32>();
10224 uint32 incrtime = fields[3].Get<uint32>();
10225 uint32 ExtendedCost = fields[4].Get<uint32>();
10226
10227 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
10228 continue;
10229
10230 VendorItemData& vList = _cacheVendorItemStore[entry];
10231
10232 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
10233 ++count;
10234 }
10235 } while (result->NextRow());
10236
10237 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10238 LOG_INFO("server.loading", " ");
10239}

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

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
6327{
6329
6330 std::set<uint32> actionSet;
6331
6332 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
6333 actionSet.insert(itr->first);
6334
6336 PreparedQueryResult result = WorldDatabase.Query(stmt);
6337
6338 if (result)
6339 {
6340 do
6341 {
6342 Field* fields = result->Fetch();
6343 uint32 action = fields[0].Get<uint32>();
6344
6345 actionSet.erase(action);
6346 } while (result->NextRow());
6347 }
6348
6349 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
6350 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
6351}
ScriptMapMap sWaypointScripts
Definition ObjectMgr.cpp:62
@ SCRIPTS_WAYPOINT
Definition ObjectMgr.h:153
@ WORLD_SEL_WAYPOINT_DATA_ACTION
Definition WorldDatabase.h:70

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

◆ NewGOData()

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

References _gameObjectDataStore.

Referenced by AddGOData().

◆ NewOrExistCreatureData()

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

References _creatureDataStore.

Referenced by AddCreData().

◆ OnDeleteSpawnData()

void ObjectMgr::OnDeleteSpawnData ( SpawnData const *  data)
8843{
8844 auto templateIt = _spawnGroupDataStore.find(data->spawnGroupId);
8845 ASSERT(templateIt != _spawnGroupDataStore.end(), "Spawn data is being deleted and has invalid spawn group index {}!", data->spawnGroupId);
8846 if (templateIt->second.flags & SPAWNGROUP_FLAG_SYSTEM)
8847 return;
8848
8849 auto pair = _spawnGroupMapStore.equal_range(data->spawnGroupId);
8850 for (auto it = pair.first; it != pair.second; ++it)
8851 {
8852 if (it->second != data)
8853 continue;
8854 _spawnGroupMapStore.erase(it);
8855 return;
8856 }
8857 ASSERT(false, "Spawn data being removed is member of spawn group {}, but not found in lookup table!", data->spawnGroupId);
8858}

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

◆ PlayerCreateInfoAddItemHelper()

void ObjectMgr::PlayerCreateInfoAddItemHelper ( uint32  race_,
uint32  class_,
uint32  itemId,
int32  count 
)
private
4313{
4314 if (!_playerInfo[race_][class_])
4315 return;
4316
4317 if (count > 0)
4318 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
4319 else
4320 {
4321 if (count < -1)
4322 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
4323
4324 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
4325 {
4326 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
4327 {
4328 bool found = false;
4329 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
4330 {
4331 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
4332 {
4333 found = true;
4334 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
4335 break;
4336 }
4337 }
4338
4339 if (!found)
4340 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
4341 }
4342 }
4343 }
4344}
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition DBCStores.cpp:854
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 
)
2798{
2799 uint8 mask = data->spawnMask;
2800 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2801 {
2802 if (mask & 1)
2803 {
2804 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2805 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2806 cell_guids.creatures.erase(guid);
2807 }
2808 }
2809}

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 
)
3250{
3251 uint8 mask = data->spawnMask;
3252 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
3253 {
3254 if (mask & 1)
3255 {
3256 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
3257 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
3258 cell_guids.gameobjects.erase(guid);
3259 }
3260 }
3261}

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 
)
10392{
10393 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
10394 if (iter == _cacheVendorItemStore.end())
10395 return false;
10396
10397 if (!iter->second.RemoveItem(item))
10398 return false;
10399
10400 if (persist)
10401 {
10403
10404 stmt->SetData(0, entry);
10405 stmt->SetData(1, item);
10406
10407 WorldDatabase.Execute(stmt);
10408 }
10409
10410 return true;
10411}
@ WORLD_DEL_NPC_VENDOR
Definition WorldDatabase.h:45

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

◆ SetCreatureLinkedRespawn()

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

References _linkedRespawnStore, GetCreatureData(), CreatureData::id, 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
1400{ DBCLocaleIndex = locale; }

References DBCLocaleIndex.

◆ SetHighestGuids()

void ObjectMgr::SetHighestGuids ( )
7586{
7587 // Refuse to start once the next guid would already trip ObjectGuidGenerator's overflow check. At the cap,
7588 // MAX(guid) + 1 wraps to 0 and the cleanup below deletes every item relation.
7589 auto setNextGuid = [](ObjectGuidGeneratorBase& generator, HighGuid high, char const* table)
7590 {
7591 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM {}", table);
7592 if (!result)
7593 return;
7594
7595 uint32 maxGuid = (*result)[0].Get<uint32>();
7596 if (maxGuid >= ObjectGuid::GetMaxCounter(high) - 2)
7597 {
7598 LOG_FATAL("server.loading", "{} guid space is exhausted (MAX(guid) in `{}` is {}). Renumber the guids before starting the server.",
7599 ObjectGuid::GetTypeName(high), table, maxGuid);
7600 exit(1);
7601 }
7602
7603 generator.Set(maxGuid + 1);
7604 };
7605
7606 setNextGuid(GetGuidSequenceGenerator<HighGuid::Player>(), HighGuid::Player, "characters");
7607 setNextGuid(GetGuidSequenceGenerator<HighGuid::Item>(), HighGuid::Item, "item_instance");
7608
7609 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
7610 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7611 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7612 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7613 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7614
7615 QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
7616 if (result)
7617 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
7618
7619 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
7620 if (result)
7621 _auctionId = (*result)[0].Get<uint32>() + 1;
7622
7623 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
7624 if (result)
7625 _mailId = (*result)[0].Get<uint32>() + 1;
7626
7627 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
7628 if (result)
7629 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
7630
7631 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
7632 if (result)
7633 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
7634
7635 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
7636 if (result)
7637 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
7638
7639 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
7640 if (result)
7641 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
7642
7643 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
7644 if (result)
7645 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
7646
7647 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
7648 if (result)
7649 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
7650}
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sGuildMgr
Definition GuildMgr.h:51
#define LOG_FATAL(filterType__,...)
Definition Log.h:141
HighGuid
Definition ObjectGuid.h:61
Definition ObjectGuid.h:285
virtual void Set(ObjectGuid::LowType val)
Definition ObjectGuid.h:289
ObjectGuid::LowType GetMaxCounter() const
Definition ObjectGuid.h:163
char const * GetTypeName() const
Definition ObjectGuid.h:215

References _auctionId, _creatureSpawnId, _equipmentSetGuid, _gameObjectSpawnId, _mailId, CharacterDatabase, ObjectGuid::GetMaxCounter(), ObjectGuid::GetTypeName(), Item, LOG_FATAL, Player, sArenaTeamMgr, ObjectGuidGeneratorBase::Set(), sGuildMgr, and WorldDatabase.

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
6414{
6415 uint32 oldMSTime = getMSTime();
6416
6417 if (_spellScriptsStore.empty())
6418 {
6419 LOG_INFO("server.loading", ">> Validated 0 scripts.");
6420 LOG_INFO("server.loading", " ");
6421 return;
6422 }
6423
6424 uint32 count = 0;
6425
6426 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
6427 {
6428 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
6429 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
6430 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
6431 itr = _spellScriptsStore.upper_bound(itr->first);
6432
6433 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
6434 {
6435 SpellScript* spellScript = sitr->first->GetSpellScript();
6436 AuraScript* auraScript = sitr->first->GetAuraScript();
6437 bool valid = true;
6438 if (!spellScript && !auraScript)
6439 {
6440 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
6441 valid = false;
6442 }
6443 if (spellScript)
6444 {
6445 spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
6446 spellScript->_Register();
6447 if (!spellScript->_Validate(spellInfo))
6448 valid = false;
6449 delete spellScript;
6450 }
6451 if (auraScript)
6452 {
6453 auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
6454 auraScript->_Register();
6455 if (!auraScript->_Validate(spellInfo))
6456 valid = false;
6457 delete auraScript;
6458 }
6459 if (!valid)
6460 {
6461 _spellScriptsStore.erase(sitr->second);
6462 }
6463 }
6464 ++count;
6465 }
6466
6467 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6468 LOG_INFO("server.loading", " ");
6469}
Definition SpellScript.h:519
bool _Validate(SpellInfo const *entry) override
Definition SpellScript.cpp:667
std::string const & GetScriptName(uint32 id) const
Definition ObjectMgr.cpp:10549
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

◆ _chatFilterAutomaton

std::unique_ptr<Acore::AhoCorasick<wchar_t> > ObjectMgr::_chatFilterAutomaton
private

Referenced by IsChatFiltered(), and LoadChatFilter().

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