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

#include "ObjectMgr.h"

Classes

struct  GameobjectInstanceSavedState
 

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

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

Private Types

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

Private Member Functions

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

Private Attributes

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

Friends

class PlayerDumpReader
 

Detailed Description

Member Typedef Documentation

◆ AreaTriggerContainer

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

◆ AreaTriggerScriptContainer

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

◆ AreaTriggerTeleportContainer

◆ BaseXPContainer

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

◆ CharacterConversionMap

◆ 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 
1616 {
1618 CREATURE_TO_GO, // Creature is dependant on GO
1619 GO_TO_GO,
1620 GO_TO_CREATURE, // GO is dependant on creature
1621 };
@ CREATURE_TO_GO
Definition ObjectMgr.h:1618
@ CREATURE_TO_CREATURE
Definition ObjectMgr.h:1617
@ GO_TO_GO
Definition ObjectMgr.h:1619
@ GO_TO_CREATURE
Definition ObjectMgr.h:1620

Constructor & Destructor Documentation

◆ ObjectMgr()

ObjectMgr::ObjectMgr ( )
private
299 :
300 _auctionId(1),
302 _mailId(1),
303 _hiPetNumber(1),
307{
308 for (uint8 i = 0; i < MAX_CLASSES; ++i)
309 {
310 _playerClassInfo[i] = nullptr;
311 for (uint8 j = 0; j < MAX_RACES; ++j)
312 _playerInfo[j][i] = nullptr;
313 }
314}
@ LOCALE_enUS
Definition Common.h:66
std::uint8_t uint8
Definition Define.h:109
#define MAX_RACES
Definition SharedDefines.h:95
#define MAX_CLASSES
Definition SharedDefines.h:155
PlayerInfo * _playerInfo[MAX_RACES][MAX_CLASSES]
Definition ObjectMgr.h:1549
ObjectGuid::LowType _gameObjectSpawnId
Definition ObjectMgr.h:1458
uint32 _mailId
Definition ObjectMgr.h:1452
ObjectGuid::LowType _creatureSpawnId
Definition ObjectMgr.h:1457
LocaleConstant DBCLocaleIndex
Definition ObjectMgr.h:1525
PlayerClassInfo * _playerClassInfo[MAX_CLASSES]
Definition ObjectMgr.h:1545
uint64 _equipmentSetGuid
Definition ObjectMgr.h:1451
uint32 _auctionId
Definition ObjectMgr.h:1450
uint32 _hiPetNumber
Definition ObjectMgr.h:1454

References _playerClassInfo, _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ ~ObjectMgr()

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

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

Member Function Documentation

◆ AddCreatureToGrid()

void ObjectMgr::AddCreatureToGrid ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)
2338{
2339 uint8 mask = data->spawnMask;
2340 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2341 {
2342 if (mask & 1)
2343 {
2344 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2345 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2346 cell_guids.creatures.insert(guid);
2347 }
2348 }
2349}
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition ObjectDefines.h:87
MapObjectGuids _mapObjectGuidsStore
Definition ObjectMgr.h:1570
GridCoord ComputeGridCoord(float x, float y)
Definition GridDefines.h:181
Definition ObjectMgr.h:478
CellGuidSet creatures
Definition ObjectMgr.h:479
Definition GridDefines.h:84
uint32 GetId() const
Definition GridDefines.h:146

References _mapObjectGuidsStore, Acore::ComputeGridCoord(), CellObjectGuids::creatures, CoordPair< LIMIT >::GetId(), MAKE_PAIR32(), CreatureData::mapid, CreatureData::posX, CreatureData::posY, and CreatureData::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 
)
2417{
2418 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2419 if (!cInfo)
2420 return 0;
2421
2422 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2423 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2424 Map* map = sMapMgr->CreateBaseMap(mapId);
2425 if (!map)
2426 return 0;
2427
2429 CreatureData& data = NewOrExistCreatureData(spawnId);
2430 data.spawnMask = spawnId;
2431 data.id1 = entry;
2432 data.id2 = 0;
2433 data.id3 = 0;
2434 data.mapid = mapId;
2435 data.displayid = 0;
2436 data.equipmentId = 0;
2437 data.posX = x;
2438 data.posY = y;
2439 data.posZ = z;
2440 data.orientation = o;
2441 data.spawntimesecs = spawntimedelay;
2442 data.wander_distance = 0;
2443 data.currentwaypoint = 0;
2444 data.curhealth = stats->GenerateHealth(cInfo);
2445 data.curmana = stats->GenerateMana(cInfo);
2446 data.movementType = cInfo->MovementType;
2447 data.spawnMask = 1;
2449 data.dbData = false;
2450 data.npcflag = cInfo->npcflag;
2451 data.unit_flags = cInfo->unit_flags;
2452 data.dynamicflags = cInfo->dynamicflags;
2453
2454 AddCreatureToGrid(spawnId, &data);
2455
2456 // Spawn if necessary (loaded grids only)
2457 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2458 {
2459 Creature* creature = new Creature();
2460 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
2461 {
2462 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2463 delete creature;
2464 return 0;
2465 }
2466 }
2467
2468 return spawnId;
2469}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
#define sMapMgr
Definition MapMgr.h:220
@ PHASEMASK_NORMAL
Definition Object.h:60
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
Definition Creature.h:43
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition Creature.cpp:1698
Definition Map.h:156
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:291
bool Instanceable() const
Definition Map.h:294
uint32 LowType
Definition ObjectGuid.h:122
CreatureBaseStats const * GetCreatureBaseStats(uint8 level, uint8 unitClass)
Definition ObjectMgr.cpp:9781
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2337
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition ObjectMgr.cpp:7095
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition ObjectMgr.h:1206
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition ObjectMgr.cpp:10129
Definition CreatureData.h:303
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:384
uint32 phaseMask
Definition CreatureData.h:376
uint32 spawntimesecs
Definition CreatureData.h:383
uint32 dynamicflags
Definition CreatureData.h:392
uint32 npcflag
Definition CreatureData.h:390
bool dbData
Definition CreatureData.h:394
uint32 displayid
Definition CreatureData.h:377
uint8 movementType
Definition CreatureData.h:388
uint8 spawnMask
Definition CreatureData.h:389
uint32 unit_flags
Definition CreatureData.h:391
uint32 id2
Definition CreatureData.h:373
uint32 curhealth
Definition CreatureData.h:386
float orientation
Definition CreatureData.h:382
uint32 curmana
Definition CreatureData.h:387
uint32 id3
Definition CreatureData.h:374
float posY
Definition CreatureData.h:380
float posX
Definition CreatureData.h:379
int8 equipmentId
Definition CreatureData.h:378
uint32 currentwaypoint
Definition CreatureData.h:385
uint16 mapid
Definition CreatureData.h:375
float posZ
Definition CreatureData.h:381
uint32 id1
Definition CreatureData.h:372
Definition CreatureData.h:186
uint32 unit_flags
Definition CreatureData.h:214
uint8 minlevel
Definition CreatureData.h:195
uint8 maxlevel
Definition CreatureData.h:196
uint32 MovementType
Definition CreatureData.h:234
uint32 npcflag
Definition CreatureData.h:199
uint32 unit_class
Definition CreatureData.h:213
uint32 dynamicflags
Definition CreatureData.h:216

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

◆ AddGameobjectInfo()

void ObjectMgr::AddGameobjectInfo ( GameObjectTemplate goinfo)

◆ AddGameobjectToGrid()

void ObjectMgr::AddGameobjectToGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2641{
2642 uint8 mask = data->spawnMask;
2643 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2644 {
2645 if (mask & 1)
2646 {
2647 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2648 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2649 cell_guids.gameobjects.insert(guid);
2650 }
2651 }
2652}
CellGuidSet gameobjects
Definition ObjectMgr.h:480

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

Referenced by AddGOData(), and LoadGameobjects().

◆ AddGameTele()

bool ObjectMgr::AddGameTele ( GameTele data)
9013{
9014 // find max id
9015 uint32 new_id = 0;
9016 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9017 if (itr->first > new_id)
9018 new_id = itr->first;
9019
9020 // use next
9021 ++new_id;
9022
9023 if (!Utf8toWStr(tele.name, tele.wnameLow))
9024 return false;
9025
9026 wstrToLower(tele.wnameLow);
9027
9028 _gameTeleStore[new_id] = tele;
9029
9031
9032 stmt->SetData(0, new_id);
9033 stmt->SetData(1, tele.position_x);
9034 stmt->SetData(2, tele.position_y);
9035 stmt->SetData(3, tele.position_z);
9036 stmt->SetData(4, tele.orientation);
9037 stmt->SetData(5, uint16(tele.mapId));
9038 stmt->SetData(6, tele.name);
9039
9040 WorldDatabase.Execute(stmt);
9041
9042 return true;
9043}
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint16_t uint16
Definition Define.h:108
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition Util.cpp:281
void wstrToLower(std::wstring &str)
Definition Util.cpp:382
@ WORLD_INS_GAME_TELE
Definition WorldDatabase.h:41
GameTeleContainer _gameTeleStore
Definition ObjectMgr.h:1513
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 
)
2366{
2367 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2368 if (!goinfo)
2369 return 0;
2370
2371 Map* map = sMapMgr->CreateBaseMap(mapId);
2372 if (!map)
2373 return 0;
2374
2376
2377 GameObjectData& data = NewGOData(spawnId);
2378 data.id = entry;
2379 data.mapid = mapId;
2380 data.posX = x;
2381 data.posY = y;
2382 data.posZ = z;
2383 data.orientation = o;
2384 data.rotation.x = rotation0;
2385 data.rotation.y = rotation1;
2386 data.rotation.z = rotation2;
2387 data.rotation.w = rotation3;
2388 data.spawntimesecs = spawntimedelay;
2389 data.animprogress = 100;
2390 data.spawnMask = 1;
2391 data.go_state = GO_STATE_READY;
2393 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2394 data.dbData = false;
2395
2396 AddGameobjectToGrid(spawnId, &data);
2397
2398 // Spawn if necessary (loaded grids only)
2399 // We use spawn coords to spawn
2400 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2401 {
2402 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(data.id) ? new StaticTransport() : new GameObject();
2403 if (!go->LoadGameObjectFromDB(spawnId, map))
2404 {
2405 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2406 delete go;
2407 return 0;
2408 }
2409 }
2410
2411 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2412
2413 return spawnId;
2414}
@ GO_STATE_READY
Definition GameObjectData.h:690
#define LOG_DEBUG(filterType__,...)
Definition Log.h:169
#define sObjectMgr
Definition ObjectMgr.h:1636
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition SharedDefines.h:1589
Definition GameObject.h:120
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition GameObject.cpp:1108
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:2640
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition ObjectMgr.cpp:10105
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition ObjectMgr.cpp:7105
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition ObjectMgr.h:1291
Definition Transport.h:113
Definition GameObjectData.h:696
bool dbData
Definition GameObjectData.h:712
float orientation
Definition GameObjectData.h:704
float posZ
Definition GameObjectData.h:703
uint8 artKit
Definition GameObjectData.h:711
int32 spawntimesecs
Definition GameObjectData.h:706
uint8 spawnMask
Definition GameObjectData.h:710
G3D::Quat rotation
Definition GameObjectData.h:705
uint32 animprogress
Definition GameObjectData.h:708
uint16 mapid
Definition GameObjectData.h:699
float posX
Definition GameObjectData.h:701
uint32 phaseMask
Definition GameObjectData.h:700
float posY
Definition GameObjectData.h:702
uint32 id
Definition GameObjectData.h:698
GOState go_state
Definition GameObjectData.h:709
Definition GameObjectData.h:31
uint32 type
Definition GameObjectData.h:33

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

◆ AddLocaleString()

◆ AddProfanityPlayerName()

void ObjectMgr::AddProfanityPlayerName ( std::string const &  name)
8380{
8381 if (!IsProfanityName(name))
8382 {
8383 std::wstring wstr;
8384 if (!Utf8toWStr(name, wstr))
8385 {
8386 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
8387 return;
8388 }
8389 wstrToLower(wstr);
8390
8391 _profanityNamesStore.insert(wstr);
8392
8394 stmt->SetData(0, name);
8395 CharacterDatabase.Execute(stmt);
8396 }
8397}
@ CHAR_INS_PROFANITY_PLAYER_NAME
Definition CharacterDatabase.h:520
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
ProfanityNamesContainer _profanityNamesStore
Definition ObjectMgr.h:1511
bool IsProfanityName(std::string_view name) const
Definition ObjectMgr.cpp:8364

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

◆ AddReservedPlayerName()

void ObjectMgr::AddReservedPlayerName ( std::string const &  name)
8277{
8278 if (!IsReservedName(name))
8279 {
8280 std::wstring wstr;
8281 if (!Utf8toWStr(name, wstr))
8282 {
8283 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
8284 return;
8285 }
8286 wstrToLower(wstr);
8287
8288 _reservedNamesStore.insert(wstr);
8289
8291 stmt->SetData(0, name);
8292 CharacterDatabase.Execute(stmt);
8293 }
8294}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition CharacterDatabase.h:519
bool IsReservedName(std::string_view name) const
Definition ObjectMgr.cpp:8261
ReservedNamesContainer _reservedNamesStore
Definition ObjectMgr.h:1507

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

◆ AddSpellToTrainer()

void ObjectMgr::AddSpellToTrainer ( uint32  entry,
uint32  spell,
uint32  spellCost,
uint32  reqSkill,
uint32  reqSkillValue,
uint32  reqLevel,
uint32  reqSpell 
)
9134{
9135 if (entry >= ACORE_TRAINER_START_REF)
9136 return;
9137
9138 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
9139 if (!cInfo)
9140 {
9141 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a non-existing creature template (Entry: {}), ignoring", entry);
9142 return;
9143 }
9144
9145 if (!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
9146 {
9147 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a creature template (Entry: {}) without trainer flag, ignoring", entry);
9148 return;
9149 }
9150
9151 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spell);
9152 if (!spellinfo)
9153 {
9154 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}), ignoring", entry, spell);
9155 return;
9156 }
9157
9158 if (!SpellMgr::ComputeIsSpellValid(spellinfo))
9159 {
9160 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a broken spell (Spell: {}), ignoring", entry, spell);
9161 return;
9162 }
9163
9164 if (GetTalentSpellCost(spell))
9165 {
9166 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}) which is a talent, ignoring", entry, spell);
9167 return;
9168 }
9169
9170 if (reqSpell && !sSpellMgr->GetSpellInfo(reqSpell))
9171 {
9172 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing reqSpell (Spell: {}), ignoring", entry, reqSpell);
9173 return;
9174 }
9175
9177
9178 TrainerSpell& trainerSpell = data.spellList[spell];
9179 trainerSpell.spell = spell;
9180 trainerSpell.spellCost = spellCost;
9181 trainerSpell.reqSkill = reqSkill;
9182 trainerSpell.reqSkillValue = reqSkillValue;
9183 trainerSpell.reqLevel = reqLevel;
9184 trainerSpell.reqSpell = reqSpell;
9185
9186 if (!trainerSpell.reqLevel)
9187 trainerSpell.reqLevel = spellinfo->SpellLevel;
9188
9189 // calculate learned spell for profession case when stored cast-spell
9190 trainerSpell.learnedSpell[0] = spell;
9191 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
9192 {
9193 if (spellinfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
9194 continue;
9195 if (trainerSpell.learnedSpell[0] == spell)
9196 trainerSpell.learnedSpell[0] = 0;
9197 // player must be able to cast spell on himself
9198 if (spellinfo->Effects[i].TargetA.GetTarget() != 0 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ALLY
9199 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_CASTER)
9200 {
9201 LOG_ERROR("sql.sql", "Table `npc_trainer` has spell {} for trainer entry {} with learn effect which has incorrect target type, ignoring learn effect!", spell, entry);
9202 continue;
9203 }
9204
9205 trainerSpell.learnedSpell[i] = spellinfo->Effects[i].TriggerSpell;
9206
9207 if (trainerSpell.learnedSpell[i])
9208 {
9209 SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.learnedSpell[i]);
9210 if (learnedSpellInfo && learnedSpellInfo->IsProfession())
9211 data.trainerType = 2;
9212 }
9213 }
9214
9215 return;
9216}
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1636
#define ACORE_TRAINER_START_REF
Definition ObjectMgr.h:493
@ SPELL_EFFECT_LEARN_SPELL
Definition SharedDefines.h:814
@ TARGET_UNIT_TARGET_ALLY
Definition SharedDefines.h:1425
@ TARGET_UNIT_TARGET_ANY
Definition SharedDefines.h:1429
@ TARGET_UNIT_CASTER
Definition SharedDefines.h:1410
#define sSpellMgr
Definition SpellMgr.h:825
@ UNIT_NPC_FLAG_TRAINER
Definition UnitDefines.h:319
Definition SpellInfo.h:316
uint32 SpellLevel
Definition SpellInfo.h:360
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:393
bool IsProfession() const
Definition SpellInfo.cpp:953
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:370
Definition CreatureData.h:529
TrainerSpellMap spellList
Definition CreatureData.h:533
uint32 trainerType
Definition CreatureData.h:534
Definition CreatureData.h:507
uint32 reqSkillValue
Definition CreatureData.h:517
uint32 learnedSpell[3]
Definition CreatureData.h:519
uint32 reqSpell
Definition CreatureData.h:520
uint32 spellCost
Definition CreatureData.h:515
uint32 reqSkill
Definition CreatureData.h:516
uint32 reqLevel
Definition CreatureData.h:518
uint32 spell
Definition CreatureData.h:514

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

Referenced by LoadTrainerSpell().

◆ AddVendorItem()

void ObjectMgr::AddVendorItem ( uint32  entry,
uint32  item,
int32  maxcount,
uint32  incrtime,
uint32  extendedCost,
bool  persist = true 
)
9459{
9460 VendorItemData& vList = _cacheVendorItemStore[entry];
9461 vList.AddItem(item, maxcount, incrtime, extendedCost);
9462
9463 if (persist)
9464 {
9466
9467 stmt->SetData(0, entry);
9468 stmt->SetData(1, item);
9469 stmt->SetData(2, maxcount);
9470 stmt->SetData(3, incrtime);
9471 stmt->SetData(4, extendedCost);
9472
9473 WorldDatabase.Execute(stmt);
9474 }
9475}
@ WORLD_INS_NPC_VENDOR
Definition WorldDatabase.h:43
Definition CreatureData.h:469
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition CreatureData.h:481

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
4369{
4370 // base data (last known level)
4371 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
4372
4373 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
4374 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
4375 {
4376 switch (_class)
4377 {
4378 case CLASS_WARRIOR:
4379 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4380 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4381 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4382 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4383 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4384 break;
4385 case CLASS_PALADIN:
4386 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
4387 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4388 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
4389 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
4390 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
4391 break;
4392 case CLASS_HUNTER:
4393 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
4394 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4395 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4396 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
4397 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4398 break;
4399 case CLASS_ROGUE:
4400 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
4401 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4402 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
4403 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
4404 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4405 break;
4406 case CLASS_PRIEST:
4407 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4408 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4409 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4410 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
4411 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
4412 break;
4413 case CLASS_SHAMAN:
4414 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4415 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4416 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
4417 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
4418 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
4419 break;
4420 case CLASS_MAGE:
4421 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4422 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4423 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4424 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
4425 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4426 break;
4427 case CLASS_WARLOCK:
4428 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4429 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4430 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4431 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4432 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4433 break;
4434 case CLASS_DRUID:
4435 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4436 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
4437 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4438 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
4439 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
4440 }
4441 }
4442}
@ CONFIG_MAX_PLAYER_LEVEL
Definition IWorld.h:235
@ CLASS_HUNTER
Definition SharedDefines.h:143
@ CLASS_DRUID
Definition SharedDefines.h:151
@ CLASS_SHAMAN
Definition SharedDefines.h:147
@ CLASS_PRIEST
Definition SharedDefines.h:145
@ CLASS_WARRIOR
Definition SharedDefines.h:141
@ CLASS_WARLOCK
Definition SharedDefines.h:149
@ CLASS_MAGE
Definition SharedDefines.h:148
@ CLASS_PALADIN
Definition SharedDefines.h:142
@ CLASS_ROGUE
Definition SharedDefines.h:144
@ STAT_SPIRIT
Definition SharedDefines.h:262
@ STAT_INTELLECT
Definition SharedDefines.h:261
@ STAT_AGILITY
Definition SharedDefines.h:259
@ STAT_STRENGTH
Definition SharedDefines.h:258
@ STAT_STAMINA
Definition SharedDefines.h:260
#define sWorld
Definition World.h:363
std::array< uint32, MAX_STATS > stats
Definition Player.h:314

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

Referenced by GetPlayerLevelInfo().

◆ ChangeFishingBaseSkillLevel()

void ObjectMgr::ChangeFishingBaseSkillLevel ( uint32  entry,
int32  skill 
)
8832{
8833 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8834 if (!fArea)
8835 {
8836 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8837 return;
8838 }
8839
8840 _fishingBaseForAreaStore[entry] = skill;
8841
8842 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
8843 LOG_INFO("server.loading", " ");
8844}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define LOG_INFO(filterType__,...)
Definition Log.h:165
FishingBaseSkillContainer _fishingBaseForAreaStore
Definition ObjectMgr.h:1558
Definition DBCStructure.h:518

References _fishingBaseForAreaStore, LOG_ERROR, LOG_INFO, and sAreaTableStore.

◆ CheckCreatureMovement()

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

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

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

Referenced by LoadCreatureTemplates().

◆ CheckDeclinedNames()

bool ObjectMgr::CheckDeclinedNames ( std::wstring  w_ownname,
DeclinedName const &  names 
)
static
8847{
8848 // get main part of the name
8849 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
8850 // prepare flags
8851 bool x = true;
8852 bool y = true;
8853
8854 // check declined names
8855 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
8856 {
8857 std::wstring wname;
8858 if (!Utf8toWStr(names.name[i], wname))
8859 return false;
8860
8861 if (mainpart != GetMainPartOfName(wname, i + 1))
8862 x = false;
8863
8864 if (w_ownname != wname)
8865 y = false;
8866 }
8867 return (x || y);
8868}
#define MAX_DECLINED_NAME_CASES
Definition Unit.h:528
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
8552{
8553 std::wstring wname;
8554 if (!Utf8toWStr(name, wname))
8555 return PET_NAME_INVALID;
8556
8557 if (wname.size() > MAX_PET_NAME)
8558 return PET_NAME_TOO_LONG;
8559
8560 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
8561 if (wname.size() < minName)
8562 return PET_NAME_TOO_SHORT;
8563
8564 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
8565 if (!isValidString(wname, strictMask, false))
8567
8568 // Check Reserved Name
8569 if (sObjectMgr->IsReservedName(name))
8570 return PET_NAME_RESERVED;
8571
8572 // Check Profanity Name
8573 if (sObjectMgr->IsProfanityName(name))
8574 return PET_NAME_PROFANE;
8575
8576 return PET_NAME_SUCCESS;
8577}
@ CONFIG_STRICT_PET_NAMES
Definition IWorld.h:222
@ CONFIG_MIN_PET_NAME
Definition IWorld.h:225
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition ObjectMgr.cpp:8436
#define MAX_PET_NAME
Definition ObjectMgr.h:684
@ PET_NAME_INVALID
Definition SharedDefines.h:3660
@ PET_NAME_RESERVED
Definition SharedDefines.h:3666
@ PET_NAME_SUCCESS
Definition SharedDefines.h:3658
@ PET_NAME_MIXED_LANGUAGES
Definition SharedDefines.h:3664
@ PET_NAME_TOO_SHORT
Definition SharedDefines.h:3662
@ PET_NAME_TOO_LONG
Definition SharedDefines.h:3663
@ PET_NAME_PROFANE
Definition SharedDefines.h:3665

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

Referenced by WorldSession::HandlePetRename().

◆ CheckPlayerName()

uint8 ObjectMgr::CheckPlayerName ( std::string_view  name,
bool  create = false 
)
static
8473{
8474 std::wstring wname;
8475
8476 // Check for invalid characters
8477 if (!Utf8toWStr(name, wname))
8479
8480 // Check for too long name
8481 if (wname.size() > MAX_PLAYER_NAME)
8482 return CHAR_NAME_TOO_LONG;
8483
8484 // Check for too short name
8485 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
8486 if (wname.size() < minName)
8487 return CHAR_NAME_TOO_SHORT;
8488
8489 // Check for mixed languages
8490 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
8491 if (!isValidString(wname, strictMask, false, create))
8493
8494 // Check for three consecutive letters
8495 wstrToLower(wname);
8496 for (std::size_t i = 2; i < wname.size(); ++i)
8497 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
8499
8500 // Check Reserved Name
8501 if (sObjectMgr->IsReservedName(name))
8502 return CHAR_NAME_RESERVED;
8503
8504 // Check Profanity Name
8505 if (sObjectMgr->IsProfanityName(name))
8506 return CHAR_NAME_PROFANE;
8507
8508 return CHAR_NAME_SUCCESS;
8509}
@ CONFIG_STRICT_PLAYER_NAMES
Definition IWorld.h:219
@ CONFIG_MIN_PLAYER_NAME
Definition IWorld.h:223
#define MAX_PLAYER_NAME
Definition ObjectMgr.h:682
@ CHAR_NAME_TOO_SHORT
Definition SharedDefines.h:3422
@ CHAR_NAME_THREE_CONSECUTIVE
Definition SharedDefines.h:3430
@ CHAR_NAME_INVALID_CHARACTER
Definition SharedDefines.h:3424
@ CHAR_NAME_TOO_LONG
Definition SharedDefines.h:3423
@ CHAR_NAME_RESERVED
Definition SharedDefines.h:3427
@ CHAR_NAME_MIXED_LANGUAGES
Definition SharedDefines.h:3425
@ CHAR_NAME_PROFANE
Definition SharedDefines.h:3426
@ CHAR_NAME_SUCCESS
Definition SharedDefines.h:3419

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

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

◆ ChooseCreatureFlags()

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

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

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)
8073{
8074 // remove mapid*cellid -> guid_set map
8075 CreatureData const* data = GetCreatureData(guid);
8076 if (data)
8077 RemoveCreatureFromGrid(guid, data);
8078
8079 _creatureDataStore.erase(guid);
8080}
CreatureDataContainer _creatureDataStore
Definition ObjectMgr.h:1573
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2351
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1197

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

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
9046{
9047 // explicit name case
9048 std::wstring wname;
9049 if (!Utf8toWStr(name, wname))
9050 return false;
9051
9052 // converting string that we try to find to lower case
9053 wstrToLower(wname);
9054
9055 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9056 {
9057 if (itr->second.wnameLow == wname)
9058 {
9060
9061 stmt->SetData(0, itr->second.name);
9062
9063 WorldDatabase.Execute(stmt);
9064
9065 _gameTeleStore.erase(itr);
9066 return true;
9067 }
9068 }
9069
9070 return false;
9071}
@ WORLD_DEL_GAME_TELE
Definition WorldDatabase.h:42

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

◆ DeleteGOData()

void ObjectMgr::DeleteGOData ( ObjectGuid::LowType  guid)
8083{
8084 // remove mapid*cellid -> guid_set map
8085 GameObjectData const* data = GetGameObjectData(guid);
8086 if (data)
8087 RemoveGameobjectFromGrid(guid, data);
8088
8089 _gameObjectDataStore.erase(guid);
8090}
GameObjectData const * GetGameObjectData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1217
GameObjectDataContainer _gameObjectDataStore
Definition ObjectMgr.h:1587
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:2654

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

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
7065{
7066 if (_auctionId >= 0xFFFFFFFE)
7067 {
7068 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
7070 }
7071 return _auctionId++;
7072}
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 ( )
7096{
7097 if (_creatureSpawnId >= uint32(0xFFFFFF))
7098 {
7099 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7101 }
7102 return _creatureSpawnId++;
7103}

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

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
7075{
7076 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
7077 {
7078 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
7080 }
7081 return _equipmentSetGuid++;
7082}
std::uint64_t uint64
Definition Define.h:106

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

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7106{
7107 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7108 {
7109 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7111 }
7112 return _gameObjectSpawnId++;
7113}

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

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
7085{
7086 if (_mailId >= 0xFFFFFFFE)
7087 {
7088 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
7090 }
7091 std::lock_guard<std::mutex> guard(_mailIdMutex);
7092 return _mailId++;
7093}
std::mutex _mailIdMutex
Definition ObjectMgr.h:1453

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

◆ GeneratePetName()

std::string ObjectMgr::GeneratePetName ( uint32  entry)
7572{
7573 std::vector<std::string>& list0 = _petHalfName0[entry];
7574 std::vector<std::string>& list1 = _petHalfName1[entry];
7575
7576 if (list0.empty() || list1.empty())
7577 {
7578 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
7579 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
7580 if (!petname)
7581 return cinfo->Name;
7582
7583 return std::string(petname);
7584 }
7585
7586 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7587}
char const * GetPetName(uint32 petfamily, uint32 dbclang)
Definition DBCStores.cpp:665
HalfNameContainer _petHalfName1
Definition ObjectMgr.h:1562
HalfNameContainer _petHalfName0
Definition ObjectMgr.h:1561
std::string Name
Definition CreatureData.h:191

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

Referenced by GeneratePetNameLocale().

◆ GeneratePetNameLocale()

std::string ObjectMgr::GeneratePetNameLocale ( uint32  entry,
LocaleConstant  locale 
)
7559{
7560 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
7561 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
7562
7563 if (list0.empty() || list1.empty())
7564 {
7565 return GeneratePetName(entry);
7566 }
7567
7568 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7569}
HalfNameContainerLocale _petHalfLocaleName0
Definition ObjectMgr.h:1564
HalfNameContainerLocale _petHalfLocaleName1
Definition ObjectMgr.h:1565
std::string GeneratePetName(uint32 entry)
Definition ObjectMgr.cpp:7571

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

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
7590{
7591 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
7592 return ++_hiPetNumber;
7593}
std::mutex _hiPetNumberMutex
Definition ObjectMgr.h:1455

References _hiPetNumber, and _hiPetNumberMutex.

◆ GetAccessRequirement()

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

References _accessRequirementStore.

◆ GetAcoreString() [1/2]

AcoreString const * ObjectMgr::GetAcoreString ( uint32  entry) const
inline
1306 {
1307 AcoreStringContainer::const_iterator itr = _acoreStringStore.find(entry);
1308 if (itr == _acoreStringStore.end())
1309 return nullptr;
1310
1311 return &itr->second;
1312 }
AcoreStringContainer _acoreStringStore
Definition ObjectMgr.h:1605

References _acoreStringStore.

Referenced by GetAcoreString(), and GetAcoreStringForDBCLocale().

◆ GetAcoreString() [2/2]

std::string ObjectMgr::GetAcoreString ( uint32  entry,
LocaleConstant  locale 
) const
8778{
8779 AcoreString const* as = GetAcoreString(entry);
8780 if (as && !as->Content.empty())
8781 {
8782 if (as->Content.size() > std::size_t(locale) && !as->Content[locale].empty())
8783 return as->Content[locale];
8784
8785 return as->Content[DEFAULT_LOCALE];
8786 }
8787
8788 std::string msg = Acore::StringFormat("No entry for acore_string ({}) in DB.", entry);
8789 LOG_ERROR("sql.sql", msg);
8790 return msg;
8791}
#define DEFAULT_LOCALE
Definition Common.h:79
AcoreString const * GetAcoreString(uint32 entry) const
Definition ObjectMgr.h:1305
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:34
Definition ObjectMgr.h:501
std::vector< std::string > Content
Definition ObjectMgr.h:502

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

◆ GetAcoreStringForDBCLocale()

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

References DBCLocaleIndex, and GetAcoreString().

◆ GetAllAreaTriggerScriptData()

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

References _areaTriggerScriptStore.

◆ GetAllCreatureData()

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

References _creatureDataStore.

◆ GetAllGOData()

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

References _gameObjectDataStore.

◆ GetAreaTrigger()

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

References _areaTriggerStore.

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

◆ GetAreaTriggerScriptId()

uint32 ObjectMgr::GetAreaTriggerScriptId ( uint32  trigger_id)
8871{
8872 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
8873 if (i != _areaTriggerScriptStore.end())
8874 return i->second;
8875 return 0;
8876}

References _areaTriggerScriptStore.

◆ GetAreaTriggerTeleport()

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

References _areaTriggerTeleportStore.

◆ GetBaseReputationOf()

int32 ObjectMgr::GetBaseReputationOf ( FactionEntry const *  factionEntry,
uint8  race,
uint8  playerClass 
)
8885{
8886 if (!factionEntry)
8887 return 0;
8888
8889 uint32 raceMask = (1 << (race - 1));
8890 uint32 classMask = (1 << (playerClass - 1));
8891
8892 for (int i = 0; i < 4; i++)
8893 {
8894 if ((!factionEntry->BaseRepClassMask[i] ||
8895 factionEntry->BaseRepClassMask[i] & classMask) &&
8896 (!factionEntry->BaseRepRaceMask[i] ||
8897 factionEntry->BaseRepRaceMask[i] & raceMask))
8898 return factionEntry->BaseRepValue[i];
8899 }
8900
8901 return 0;
8902}

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

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
7500{
7501 return _baseXPTable[level] ? _baseXPTable[level] : 0;
7502}
BaseXPContainer _baseXPTable
Definition ObjectMgr.h:1555

References _baseXPTable.

◆ GetBroadcastText()

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

References _broadcastTextStore.

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

◆ GetCreatureAddon()

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

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
9782{
9783 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
9784
9785 if (it != _creatureBaseStatsStore.end())
9786 return &(it->second);
9787
9788 struct DefaultCreatureBaseStats : public CreatureBaseStats
9789 {
9790 DefaultCreatureBaseStats()
9791 {
9792 BaseArmor = 1;
9793 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
9794 {
9795 BaseHealth[j] = 1;
9796 BaseDamage[j] = 0.0f;
9797 }
9798 BaseMana = 0;
9799 AttackPower = 0;
9800 RangedAttackPower = 0;
9801 }
9802 };
9803 static const DefaultCreatureBaseStats defStats;
9804 return &defStats;
9805}
uint16 MAKE_PAIR16(uint8 l, uint8 h)
Definition ObjectDefines.h:82
CreatureBaseStatsContainer _creatureBaseStatsStore
Definition ObjectMgr.h:1539

References _creatureBaseStatsStore, MAKE_PAIR16(), and MAX_EXPANSIONS.

Referenced by AddCreData().

◆ GetCreatureData()

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

References _creatureDataStore.

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

◆ GetCreatureLocale()

CreatureLocale const * ObjectMgr::GetCreatureLocale ( uint32  entry) const
inline
1224 {
1225 CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry);
1226 if (itr == _creatureLocaleStore.end()) return nullptr;
1227 return &itr->second;
1228 }
CreatureLocaleContainer _creatureLocaleStore
Definition ObjectMgr.h:1586

References _creatureLocaleStore.

◆ GetCreatureModelInfo()

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

References _creatureModelStore.

Referenced by GetCreatureModelRandomGender(), and LoadCreatureTemplateModels().

◆ GetCreatureModelRandomGender()

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

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
1453{
1455}
std::unordered_map< ObjectGuid::LowType, CreatureMovementData > _creatureMovementOverrides
Definition ObjectMgr.h:1580
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
1000 {
1001 return _creatureQuestInvolvedRelations.equal_range(creature_entry);
1002 }
QuestRelations _creatureQuestInvolvedRelations
Definition ObjectMgr.h:1503

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestInvolvedRelationMap ( )
inline

◆ GetCreatureQuestItemList()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestItemMap()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestRelationBounds ( uint32  creature_entry)
inline
995 {
996 return _creatureQuestRelations.equal_range(creature_entry);
997 }
QuestRelations _creatureQuestRelations
Definition ObjectMgr.h:1502

References _creatureQuestRelations.

◆ GetCreatureQuestRelationMap()

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

References _creatureQuestRelations.

◆ GetCreatureTemplate()

◆ GetCreatureTemplateAddon()

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

References _creatureTemplateAddonStore.

◆ GetCreatureTemplates()

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

References _creatureTemplateStore.

◆ GetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ GetDungeonEncounterList()

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

References _dungeonEncounterStore, and MAKE_PAIR32().

◆ GetEquipmentInfo()

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

References _equipmentInfoStore, and urand().

Referenced by LoadCreatures().

◆ GetFishingBaseSkillLevel()

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

References _fishingBaseForAreaStore.

◆ GetGameObjectAddon()

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

References _gameObjectAddonStore.

◆ GetGameObjectData()

GameObjectData const * ObjectMgr::GetGameObjectData ( ObjectGuid::LowType  spawnId) const
inline
1218 {
1219 GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(spawnId);
1220 if (itr == _gameObjectDataStore.end()) return nullptr;
1221 return &itr->second;
1222 }

References _gameObjectDataStore.

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

◆ GetGameObjectLocale()

GameObjectLocale const * ObjectMgr::GetGameObjectLocale ( uint32  entry) const
inline
1230 {
1231 GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
1232 if (itr == _gameObjectLocaleStore.end()) return nullptr;
1233 return &itr->second;
1234 }
GameObjectLocaleContainer _gameObjectLocaleStore
Definition ObjectMgr.h:1588

References _gameObjectLocaleStore.

◆ GetGameObjectQuestItemList()

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

References _gameObjectQuestItemStore.

◆ GetGameObjectQuestItemMap()

GameObjectQuestItemMap const * ObjectMgr::GetGameObjectQuestItemMap ( ) const
inline

◆ GetGameObjectTemplate()

GameObjectTemplate const * ObjectMgr::GetGameObjectTemplate ( uint32  entry)
10106{
10107 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
10108 if (itr != _gameObjectTemplateStore.end())
10109 return &(itr->second);
10110
10111 return nullptr;
10112}
GameObjectTemplateContainer _gameObjectTemplateStore
Definition ObjectMgr.h:1589

References _gameObjectTemplateStore.

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

◆ GetGameObjectTemplateAddon()

GameObjectTemplateAddon const * ObjectMgr::GetGameObjectTemplateAddon ( uint32  entry) const
10121{
10122 auto itr = _gameObjectTemplateAddonStore.find(entry);
10123 if (itr != _gameObjectTemplateAddonStore.end())
10124 return &itr->second;
10125
10126 return nullptr;
10127}
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
Definition ObjectMgr.h:1590

References _gameObjectTemplateAddonStore.

◆ GetGameObjectTemplates()

GameObjectTemplateContainer const * ObjectMgr::GetGameObjectTemplates ( ) const
inline

◆ GetGameTele() [1/2]

GameTele const * ObjectMgr::GetGameTele ( std::string_view  name,
bool  exactSearch = false 
) const
8990{
8991 // explicit name case
8992 std::wstring wname;
8993 if (!Utf8toWStr(name, wname))
8994 return nullptr;
8995
8996 // converting string that we try to find to lower case
8997 wstrToLower(wname);
8998
8999 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
9000 const GameTele* alt = nullptr;
9001 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9002 {
9003 if (itr->second.wnameLow == wname)
9004 return &itr->second;
9005 else if (!exactSearch && !alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
9006 alt = &itr->second;
9007 }
9008
9009 return alt;
9010}
Definition ObjectMgr.h:132

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

◆ GetGameTele() [2/2]

GameTele const * ObjectMgr::GetGameTele ( uint32  id) const
inline
1347 {
1348 GameTeleContainer::const_iterator itr = _gameTeleStore.find(id);
1349 if (itr == _gameTeleStore.end()) return nullptr;
1350 return &itr->second;
1351 }

References _gameTeleStore.

◆ GetGameTeleMap()

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

References _gameTeleStore.

◆ GetGenerator()

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

◆ GetGoBackTrigger()

AreaTriggerTeleport const * ObjectMgr::GetGoBackTrigger ( uint32  Map) const
6964{
6965 bool useParentDbValue = false;
6966 uint32 parentId = 0;
6967 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
6968 if (!mapEntry || mapEntry->entrance_map < 0)
6969 return nullptr;
6970
6971 if (mapEntry->IsDungeon())
6972 {
6973 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
6974
6975 if (!iTemplate)
6976 return nullptr;
6977
6978 parentId = iTemplate->Parent;
6979 useParentDbValue = true;
6980 }
6981
6982 uint32 entrance_map = uint32(mapEntry->entrance_map);
6983 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6984 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
6985 {
6986 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
6987 if (atEntry && atEntry->map == Map)
6988 return &itr->second;
6989 }
6990 return nullptr;
6991}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
AreaTrigger const * GetAreaTrigger(uint32 trigger) const
Definition ObjectMgr.h:854
Definition ObjectMgr.h:420
uint32 map
Definition ObjectMgr.h:422
Definition Map.h:117
uint32 Parent
Definition Map.h:118
Definition DBCStructure.h:1324
int32 entrance_map
Definition DBCStructure.h:1339
bool IsDungeon() const
Definition DBCStructure.h:1350

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

◆ GetGOQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestInvolvedRelationBounds ( uint32  go_entry)
inline
980 {
981 return _goQuestInvolvedRelations.equal_range(go_entry);
982 }
QuestRelations _goQuestInvolvedRelations
Definition ObjectMgr.h:1501

References _goQuestInvolvedRelations.

◆ GetGOQuestInvolvedRelationMap()

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

References _goQuestInvolvedRelations.

◆ GetGOQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestRelationBounds ( uint32  go_entry)
inline
975 {
976 return _goQuestRelations.equal_range(go_entry);
977 }
QuestRelations _goQuestRelations
Definition ObjectMgr.h:1500

References _goQuestRelations.

◆ GetGOQuestRelationMap()

QuestRelations * ObjectMgr::GetGOQuestRelationMap ( )
inline
965 {
966 return &_goQuestRelations;
967 }

References _goQuestRelations.

◆ GetGossipMenuItemsLocale()

GossipMenuItemsLocale const * ObjectMgr::GetGossipMenuItemsLocale ( uint32  entry) const
inline
1260 {
1261 GossipMenuItemsLocaleContainer::const_iterator itr = _gossipMenuItemsLocaleStore.find(entry);
1262 if (itr == _gossipMenuItemsLocaleStore.end()) return nullptr;
1263 return &itr->second;
1264 }
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore
Definition ObjectMgr.h:1606

References _gossipMenuItemsLocaleStore.

◆ GetGossipMenuItemsMapBounds()

GossipMenuItemsMapBounds ObjectMgr::GetGossipMenuItemsMapBounds ( uint32  uiMenuId) const
inline
1400 {
1401 return _gossipMenuItemsStore.equal_range(uiMenuId);
1402 }
GossipMenuItemsContainer _gossipMenuItemsStore
Definition ObjectMgr.h:1495

References _gossipMenuItemsStore.

◆ GetGossipMenuItemsMapBoundsNonConst()

GossipMenuItemsMapBoundsNonConst ObjectMgr::GetGossipMenuItemsMapBoundsNonConst ( uint32  uiMenuId)
inline
1404 {
1405 return _gossipMenuItemsStore.equal_range(uiMenuId);
1406 }

References _gossipMenuItemsStore.

◆ GetGossipMenusMapBounds()

GossipMenusMapBounds ObjectMgr::GetGossipMenusMapBounds ( uint32  uiMenuId) const
inline
1390 {
1391 return _gossipMenusStore.equal_range(uiMenuId);
1392 }
GossipMenusContainer _gossipMenusStore
Definition ObjectMgr.h:1494

References _gossipMenusStore.

◆ GetGossipMenusMapBoundsNonConst()

GossipMenusMapBoundsNonConst ObjectMgr::GetGossipMenusMapBoundsNonConst ( uint32  uiMenuId)
inline
1395 {
1396 return _gossipMenusStore.equal_range(uiMenuId);
1397 }

References _gossipMenusStore.

◆ GetGossipText()

GossipText const * ObjectMgr::GetGossipText ( uint32  Text_ID) const
6011{
6012 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
6013 if (itr != _gossipTextStore.end())
6014 return &itr->second;
6015 return nullptr;
6016}
GossipTextContainer _gossipTextStore
Definition ObjectMgr.h:1482

References _gossipTextStore.

Referenced by LoadGossipMenu().

◆ GetGridObjectGuids()

CellObjectGuids const & ObjectMgr::GetGridObjectGuids ( uint16  mapid,
uint8  spawnMode,
uint32  gridId 
)
inline
1152 {
1153 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1154 if (itr1 != _mapObjectGuidsStore.end())
1155 {
1156 CellObjectGuidsMap::const_iterator itr2 = itr1->second.find(gridId);
1157 if (itr2 != itr1->second.end())
1158 return itr2->second;
1159 }
1160 return _emptyCellObjectGuids;
1161 }
CellObjectGuids _emptyCellObjectGuids
Definition ObjectMgr.h:1572

References _emptyCellObjectGuids, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & ObjectMgr::GetGuidSequenceGenerator ( )
inlineprivate
1463 {
1464 auto itr = _guidGenerators.find(high);
1465 if (itr == _guidGenerators.end())
1466 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
1467
1468 return *itr->second;
1469 }
Definition ObjectGuid.h:297
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition ObjectMgr.h:1471

References _guidGenerators.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
5917{
5918 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
5919 if (itr != _instanceTemplateStore.end())
5920 return &(itr->second);
5921
5922 return nullptr;
5923}
InstanceTemplateContainer _instanceTemplateStore
Definition ObjectMgr.h:1528

References _instanceTemplateStore.

◆ GetItemLocale()

ItemLocale const * ObjectMgr::GetItemLocale ( uint32  entry) const
inline
1236 {
1237 ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
1238 if (itr == _itemLocaleStore.end()) return nullptr;
1239 return &itr->second;
1240 }
ItemLocaleContainer _itemLocaleStore
Definition ObjectMgr.h:1597

References _itemLocaleStore.

◆ GetItemSetNameEntry()

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

References _itemSetNameStore.

◆ GetItemSetNameLocale()

ItemSetNameLocale const * ObjectMgr::GetItemSetNameLocale ( uint32  entry) const
inline
1242 {
1243 ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
1244 if (itr == _itemSetNameLocaleStore.end())return nullptr;
1245 return &itr->second;
1246 }
ItemSetNameLocaleContainer _itemSetNameLocaleStore
Definition ObjectMgr.h:1598

References _itemSetNameLocaleStore.

◆ GetItemTemplate()

ItemTemplate const * ObjectMgr::GetItemTemplate ( uint32  entry)
3308{
3309 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3310}
std::vector< ItemTemplate * > _itemTemplateStoreFast
Definition ObjectMgr.h:1596

References _itemTemplateStoreFast.

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

◆ GetItemTemplateStore()

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

References _itemTemplateStore.

◆ GetItemTemplateStoreFast()

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

References _itemTemplateStoreFast.

◆ GetLinkedRespawnGuid()

ObjectGuid ObjectMgr::GetLinkedRespawnGuid ( ObjectGuid  guid) const
inline
1209 {
1210 LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid);
1211 if (itr == _linkedRespawnStore.end())
1212 return ObjectGuid::Empty;
1213 return itr->second;
1214 }
static ObjectGuid const Empty
Definition ObjectGuid.h:120
LinkedRespawnContainer _linkedRespawnStore
Definition ObjectMgr.h:1585

References _linkedRespawnStore, and ObjectGuid::Empty.

◆ GetLocaleString() [1/2]

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

◆ GetLocaleString() [2/2]

◆ GetMailLevelReward()

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

References _mailLevelRewardStore.

◆ GetMapEntranceTrigger()

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

Searches for the areatrigger which teleports players to the given map

6997{
6998 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6999 {
7000 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
7001 {
7002 // xinef: no need to check, already done at loading
7003 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
7004 //if (atEntry)
7005 return &itr->second;
7006 }
7007 }
7008 return nullptr;
7009}

References _areaTriggerTeleportStore.

◆ GetMapObjectGuids()

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

References _emptyCellObjectGuidsMap, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetModuleString() [1/2]

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

References _moduleStringStore.

Referenced by GetModuleString().

◆ GetModuleString() [2/2]

std::string const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id,
LocaleConstant  locale 
) const
8729{
8730 ModuleString const* ms = GetModuleString(module, id);
8731 if (ms && !ms->Content.empty())
8732 {
8733 if (ms->Content.size() > size_t(locale) && !ms->Content[locale].empty())
8734 return &ms->Content[locale];
8735
8736 return &ms->Content[DEFAULT_LOCALE];
8737 }
8738
8739 LOG_ERROR("sql.sql", "Module string module {} id {} not found in DB.", module, id);
8740
8741 return (std::string*)"error";
8742}
ModuleString const * GetModuleString(std::string module, uint32 id) const
Definition ObjectMgr.h:1294
Definition ObjectMgr.h:496
std::vector< std::string > Content
Definition ObjectMgr.h:497

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

◆ GetNearestTaxiNode()

uint32 ObjectMgr::GetNearestTaxiNode ( float  x,
float  y,
float  z,
uint32  mapid,
uint32  teamId 
)
6581{
6582 bool found = false;
6583 float dist = 10000;
6584 uint32 id = 0;
6585
6586 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
6587 {
6588 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
6589
6590 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
6591 continue;
6592
6593 uint8 field = (uint8)((i - 1) / 32);
6594 uint32 submask = 1 << ((i - 1) % 32);
6595
6596 // skip not taxi network nodes
6597 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
6598 {
6599 continue;
6600 }
6601
6602 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
6603 if (found)
6604 {
6605 if (dist2 < dist)
6606 {
6607 dist = dist2;
6608 id = i;
6609 }
6610 }
6611 else
6612 {
6613 found = true;
6614 dist = dist2;
6615 id = i;
6616 }
6617 }
6618
6619 return id;
6620}
TaxiMask sTaxiNodesMask
Definition DBCStores.cpp:176
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
static constexpr std::size_t TaxiMaskSize
Definition DBCStructure.h:2247
@ TEAM_ALLIANCE
Definition SharedDefines.h:760
Definition DBCStructure.h:1952
float z
Definition DBCStructure.h:1957
uint32 map_id
Definition DBCStructure.h:1954
float x
Definition DBCStructure.h:1955
float y
Definition DBCStructure.h:1956
uint32 MountCreatureID[2]
Definition DBCStructure.h:1960

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

◆ GetNpcTextLocale()

NpcTextLocale const * ObjectMgr::GetNpcTextLocale ( uint32  entry) const
inline
1284 {
1285 NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
1286 if (itr == _npcTextLocaleStore.end()) return nullptr;
1287 return &itr->second;
1288 }
NpcTextLocaleContainer _npcTextLocaleStore
Definition ObjectMgr.h:1602

References _npcTextLocaleStore.

◆ GetNpcTrainerSpells()

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

References _cacheTrainerSpellStore.

◆ GetNpcVendorItemList()

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

References _cacheVendorItemStore.

Referenced by IsVendorItemValid().

◆ GetPageText()

PageText const * ObjectMgr::GetPageText ( uint32  pageEntry)
5833{
5834 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
5835 if (itr != _pageTextStore.end())
5836 return &(itr->second);
5837
5838 return nullptr;
5839}
PageTextContainer _pageTextStore
Definition ObjectMgr.h:1527

References _pageTextStore.

Referenced by LoadGameObjectTemplate(), and LoadItemTemplates().

◆ GetPageTextLocale()

PageTextLocale const * ObjectMgr::GetPageTextLocale ( uint32  entry) const
inline
1248 {
1249 PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
1250 if (itr == _pageTextLocaleStore.end()) return nullptr;
1251 return &itr->second;
1252 }
PageTextLocaleContainer _pageTextLocaleStore
Definition ObjectMgr.h:1603

References _pageTextLocaleStore.

◆ GetPetLevelInfo()

PetLevelInfo const * ObjectMgr::GetPetLevelInfo ( uint32  creature_id,
uint8  level 
) const
3674{
3675 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3676 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
3677
3678 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
3679 if (itr == _petInfoStore.end())
3680 return nullptr;
3681
3682 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
3683}

References _petInfoStore, CONFIG_MAX_PLAYER_LEVEL, and sWorld.

◆ GetPlayerClassInfo()

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

References _playerClassInfo, and MAX_CLASSES.

◆ GetPlayerClassLevelInfo()

void ObjectMgr::GetPlayerClassLevelInfo ( uint32  class_,
uint8  level,
PlayerClassLevelInfo info 
) const
4341{
4342 if (level < 1 || class_ >= MAX_CLASSES)
4343 return;
4344
4345 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4346
4347 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4348 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4349
4350 *info = pInfo->levelInfo[level - 1];
4351}
Definition Player.h:301

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

◆ GetPlayerInfo()

PlayerInfo const * ObjectMgr::GetPlayerInfo ( uint32  race,
uint32  class_ 
) const
10152{
10153 if (race >= MAX_RACES)
10154 return nullptr;
10155 if (class_ >= MAX_CLASSES)
10156 return nullptr;
10157 PlayerInfo const* info = _playerInfo[race][class_];
10158 if (!info)
10159 return nullptr;
10160 return info;
10161}
Definition Player.h:340

References _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ GetPlayerLevelInfo()

void ObjectMgr::GetPlayerLevelInfo ( uint32  race,
uint32  class_,
uint8  level,
PlayerLevelInfo info 
) const
4354{
4355 if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
4356 return;
4357
4358 PlayerInfo const* pInfo = _playerInfo[race][class_];
4359 if (!pInfo)
4360 return;
4361
4362 if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4363 *info = pInfo->levelInfo[level - 1];
4364 else
4365 BuildPlayerLevelInfo(race, class_, level, info);
4366}
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
Definition ObjectMgr.cpp:4368

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

◆ GetPointOfInterest()

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

References _pointsOfInterestStore.

Referenced by LoadGossipMenuItems().

◆ GetPointOfInterestLocale()

PointOfInterestLocale const * ObjectMgr::GetPointOfInterestLocale ( uint32  poi_id) const
inline
1266 {
1267 PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id);
1268 if (itr == _pointOfInterestLocaleStore.end()) return nullptr;
1269 return &itr->second;
1270 }
PointOfInterestLocaleContainer _pointOfInterestLocaleStore
Definition ObjectMgr.h:1607

References _pointOfInterestLocaleStore.

◆ GetQuestForAreaTrigger()

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

References _questAreaTriggerStore.

◆ GetQuestGreeting()

QuestGreeting const * ObjectMgr::GetQuestGreeting ( TypeID  type,
uint32  id 
) const
6311{
6312 uint8 typeIndex;
6313 if (type == TYPEID_UNIT)
6314 typeIndex = 0;
6315 else if (type == TYPEID_GAMEOBJECT)
6316 typeIndex = 1;
6317 else
6318 return nullptr;
6319
6320 std::pair<uint32, uint8> pairKey = std::make_pair(id, typeIndex);
6321 QuestGreetingContainer::const_iterator itr = _questGreetingStore.find(pairKey);
6322 if (itr == _questGreetingStore.end())
6323 return nullptr;
6324
6325 return &itr->second;
6326}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
QuestGreetingContainer _questGreetingStore
Definition ObjectMgr.h:1483

References _questGreetingStore, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

◆ GetQuestLocale()

QuestLocale const * ObjectMgr::GetQuestLocale ( uint32  entry) const
inline
1254 {
1255 QuestLocaleContainer::const_iterator itr = _questLocaleStore.find(entry);
1256 if (itr == _questLocaleStore.end()) return nullptr;
1257 return &itr->second;
1258 }
QuestLocaleContainer _questLocaleStore
Definition ObjectMgr.h:1599

References _questLocaleStore.

◆ GetQuestMoneyReward()

uint32 ObjectMgr::GetQuestMoneyReward ( uint8  level,
uint32  questMoneyDifficulty 
) const
10288{
10289 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
10290 {
10291 auto const& itr = _questMoneyRewards.find(level);
10292 if (itr != _questMoneyRewards.end())
10293 {
10294 return itr->second.at(questMoneyDifficulty);
10295 }
10296 }
10297
10298 return 0;
10299}
static constexpr uint32 MAX_QUEST_MONEY_REWARDS
Definition ObjectMgr.h:714
QuestMoneyRewardStore _questMoneyRewards
Definition ObjectMgr.h:1625

References _questMoneyRewards, and MAX_QUEST_MONEY_REWARDS.

◆ GetQuestOfferRewardLocale()

QuestOfferRewardLocale const * ObjectMgr::GetQuestOfferRewardLocale ( uint32  entry) const
inline
1272 {
1273 auto itr = _questOfferRewardLocaleStore.find(entry);
1274 if (itr == _questOfferRewardLocaleStore.end()) return nullptr;
1275 return &itr->second;
1276 }
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
Definition ObjectMgr.h:1600

References _questOfferRewardLocaleStore.

◆ GetQuestPOIVector()

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

References _questPOIStore.

◆ GetQuestRequestItemsLocale()

QuestRequestItemsLocale const * ObjectMgr::GetQuestRequestItemsLocale ( uint32  entry) const
inline
1278 {
1279 auto itr = _questRequestItemsLocaleStore.find(entry);
1280 if (itr == _questRequestItemsLocaleStore.end()) return nullptr;
1281 return &itr->second;
1282 }
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
Definition ObjectMgr.h:1601

References _questRequestItemsLocaleStore.

◆ GetQuestTemplate()

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

References _questTemplatesFast.

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

◆ GetQuestTemplates()

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

References _questTemplates.

◆ GetRepRewardRate()

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

References _repRewardRateStore.

◆ GetRepSpilloverTemplate()

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

References _repSpilloverTemplateStore.

◆ GetReputationOnKilEntry()

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

References _repOnKillStore.

◆ GetScriptId()

uint32 ObjectMgr::GetScriptId ( std::string const &  name)
9642{
9643 // use binary search to find the script name in the sorted vector
9644 // assume "" is the first element
9645 if (name.empty())
9646 return 0;
9647
9648 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
9649 if (itr == _scriptNamesStore.end() || (*itr != name))
9650 return 0;
9651
9652 return uint32(itr - _scriptNamesStore.begin());
9653}
ScriptNameContainer _scriptNamesStore
Definition ObjectMgr.h:1515

References _scriptNamesStore.

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

◆ GetScriptName()

std::string const & ObjectMgr::GetScriptName ( uint32  id) const
9636{
9637 static std::string const empty = "";
9638 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
9639}

References _scriptNamesStore.

Referenced by ValidateSpellScripts().

◆ GetScriptNames()

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

References _scriptNamesStore.

◆ GetSparringData()

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

References _creatureSparringStore.

◆ GetSpellClickInfoMapBounds()

SpellClickInfoMapBounds ObjectMgr::GetSpellClickInfoMapBounds ( uint32  creature_id) const
inline
1385 {
1386 return _spellClickInfoStore.equal_range(creature_id);
1387 }
SpellClickInfoContainer _spellClickInfoStore
Definition ObjectMgr.h:1517

References _spellClickInfoStore.

◆ GetSpellScriptsBounds()

SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds ( uint32  spell_id)
8879{
8880 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
8881}
std::pair< SpellScriptsContainer::iterator, SpellScriptsContainer::iterator > SpellScriptsBounds
Definition ObjectMgr.h:388
SpellScriptsContainer _spellScriptsStore
Definition ObjectMgr.h:1519

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
1181 {
1182 TempSummonDataContainer::const_iterator itr = _tempSummonDataStore.find(TempSummonGroupKey(summonerId, summonerType, group));
1183 if (itr != _tempSummonDataStore.end())
1184 return &itr->second;
1185
1186 return nullptr;
1187 }
TempSummonDataContainer _tempSummonDataStore
Stores temp summon data grouped by summoner's entry, summoner's type and group id.
Definition ObjectMgr.h:1592
Key for storing temp summon data in TempSummonDataContainer.
Definition ObjectMgr.h:64

References _tempSummonDataStore.

◆ GetTaxiMountDisplayId()

uint32 ObjectMgr::GetTaxiMountDisplayId ( uint32  id,
TeamId  teamId,
bool  allowed_alt_team = false 
)
6647{
6648 CreatureModel mountModel;
6649 CreatureTemplate const* mount_info = nullptr;
6650
6651 // select mount creature id
6652 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
6653 if (node)
6654 {
6655 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
6656
6657 // Fix for Alliance not being able to use Acherus taxi
6658 // only one mount type for both sides
6659 if (mount_entry == 0 && allowed_alt_team)
6660 {
6661 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
6662 mount_entry = node->MountCreatureID[teamId];
6663 }
6664
6665 mount_info = GetCreatureTemplate(mount_entry);
6666 if (mount_info)
6667 {
6668 CreatureModel const* model = mount_info->GetRandomValidModel();
6669 if (!model)
6670 {
6671 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
6672 return 0;
6673 }
6674 mountModel = *model;
6675 }
6676 }
6677
6678 // minfo is not actually used but the mount_id was updated
6679 GetCreatureModelRandomGender(&mountModel, mount_info);
6680
6681 return mountModel.CreatureDisplayID;
6682}
CreatureModelInfo const * GetCreatureModelRandomGender(CreatureModel *model, CreatureTemplate const *creatureTemplate) const
Definition ObjectMgr.cpp:1681
CreatureModel const * GetRandomValidModel() const
Definition Creature.cpp:127

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 
)
6623{
6624 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
6625 if (src_i == sTaxiPathSetBySource.end())
6626 {
6627 path = 0;
6628 cost = 0;
6629 return;
6630 }
6631
6632 TaxiPathSetForSource& pathSet = src_i->second;
6633
6634 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
6635 if (dest_i == pathSet.end())
6636 {
6637 path = 0;
6638 cost = 0;
6639 return;
6640 }
6641
6642 cost = dest_i->second->price;
6643 path = dest_i->second->ID;
6644}
TaxiPathSetBySource sTaxiPathSetBySource
Definition DBCStores.cpp:183
std::map< uint32, TaxiPathEntry const * > TaxiPathSetForSource
Definition DBCStructure.h:2241

References TaxiNodesEntry::ID, and sTaxiPathSetBySource.

◆ GetVehicleAccessoryList()

VehicleAccessoryList const * ObjectMgr::GetVehicleAccessoryList ( Vehicle veh) const
10135{
10136 if (Creature* cre = veh->GetBase()->ToCreature())
10137 {
10138 // Give preference to GUID-based accessories
10139 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
10140 if (itr != _vehicleAccessoryStore.end())
10141 return &itr->second;
10142 }
10143
10144 // Otherwise return entry-based
10145 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
10146 if (itr != _vehicleTemplateAccessoryStore.end())
10147 return &itr->second;
10148 return nullptr;
10149}
VehicleAccessoryContainer _vehicleAccessoryStore
Definition ObjectMgr.h:1522
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
Definition ObjectMgr.h:1521
Creature * ToCreature()
Definition Object.h:205
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
1439 {
1440 VehicleSeatAddonContainer::const_iterator itr = _vehicleSeatAddonStore.find(seatId);
1441 if (itr == _vehicleSeatAddonStore.end())
1442 return nullptr;
1443
1444 return &itr->second;
1445 }
VehicleSeatAddonContainer _vehicleSeatAddonStore
Definition ObjectMgr.h:1523

References _vehicleSeatAddonStore.

◆ GetXPForLevel()

uint32 ObjectMgr::GetXPForLevel ( uint8  level) const
7505{
7506 if (level < _playerXPperLevel.size())
7507 return _playerXPperLevel[level];
7508 return 0;
7509}
PlayerXPperLevel _playerXPperLevel
Definition ObjectMgr.h:1552

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
5780{
5781 uint32 limit = sSpellStore.GetNumRows();
5782 for(uint32 i = 0; i <= limit; ++i)
5783 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
5784 {
5785 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
5786 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
5787 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
5788 }
5789}
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
10115{
10116 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
10117 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
10118}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1571

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

◆ IsProfanityName()

bool ObjectMgr::IsProfanityName ( std::string_view  name) const
8365{
8366 // pussywizard
8367 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8368 return true;
8369
8370 std::wstring wstr;
8371 if (!Utf8toWStr (name, wstr))
8372 return false;
8373
8374 wstrToLower(wstr);
8375
8376 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
8377}

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

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
8262{
8263 // pussywizard
8264 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8265 return true;
8266
8267 std::wstring wstr;
8268 if (!Utf8toWStr (name, wstr))
8269 return false;
8270
8271 wstrToLower(wstr);
8272
8273 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
8274}

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

Referenced by AddReservedPlayerName().

◆ IsTavernAreaTrigger()

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

References _tavernAreaTriggerStore.

◆ IsTransportMap()

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

References _transportMaps.

◆ IsValidChannelName()

bool ObjectMgr::IsValidChannelName ( std::string const &  name)
static
8538{
8539 std::wstring wname;
8540 if (!Utf8toWStr(name, wname))
8541 return false;
8542
8543 if (wname.size() > MAX_CHANNEL_NAME)
8544 return false;
8545
8546 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
8547
8548 return isValidString(wname, strictMask, true);
8549}
@ CONFIG_STRICT_CHANNEL_NAMES
Definition IWorld.h:221
#define MAX_CHANNEL_NAME
Definition ObjectMgr.h:686

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

◆ IsValidCharterName()

bool ObjectMgr::IsValidCharterName ( std::string_view  name)
static
8512{
8513 std::wstring wname;
8514 if (!Utf8toWStr(name, wname))
8515 return false;
8516
8517 if (wname.size() > MAX_CHARTER_NAME)
8518 return false;
8519
8520 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
8521 if (wname.size() < minName)
8522 return false;
8523
8524 // Check Reserved Name
8525 if (sObjectMgr->IsReservedName(name))
8526 return false;
8527
8528 // Check Profanity Name
8529 if (sObjectMgr->IsProfanityName(name))
8530 return false;
8531
8532 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
8533
8534 return isValidString(wname, strictMask, true);
8535}
@ CONFIG_MIN_CHARTER_NAME
Definition IWorld.h:224
@ CONFIG_STRICT_CHARTER_NAMES
Definition IWorld.h:220
#define MAX_CHARTER_NAME
Definition ObjectMgr.h:685

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

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

◆ IsVendorItemValid()

bool ObjectMgr::IsVendorItemValid ( uint32  vendor_entry,
uint32  item,
int32  maxcount,
uint32  ptime,
uint32  ExtendedCost,
Player player = nullptr,
std::set< uint32 > *  skip_vendors = nullptr,
uint32  ORnpcflag = 0 
) const
9500{
9501 /*
9502 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry);
9503 if (!cInfo)
9504 {
9505 if (player)
9506 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9507 else
9508 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
9509 return false;
9510 }
9511
9512 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
9513 {
9514 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
9515 {
9516 if (player)
9517 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9518 else
9519 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
9520
9521 if (skip_vendors)
9522 skip_vendors->insert(vendor_entry);
9523 }
9524 return false;
9525 }
9526 */
9527
9528 if (!sObjectMgr->GetItemTemplate(item_id))
9529 {
9530 if (player)
9532 else
9533 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
9534 return false;
9535 }
9536
9537 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
9538 {
9539 if (player)
9541 else
9542 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
9543 return false;
9544 }
9545
9546 if (maxcount > 0 && incrtime == 0)
9547 {
9548 if (player)
9549 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 ({}) but IncrTime == 0", maxcount);
9550 else
9551 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);
9552 return false;
9553 }
9554 else if (maxcount == 0 && incrtime > 0)
9555 {
9556 if (player)
9557 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
9558 else
9559 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);
9560 return false;
9561 }
9562
9563 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
9564 if (!vItems)
9565 return true; // later checks for non-empty lists
9566
9567 if (vItems->FindItemCostPair(item_id, ExtendedCost))
9568 {
9569 if (player)
9570 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
9571 else
9572 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
9573 return false;
9574 }
9575
9576 return true;
9577}
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
@ LANG_ITEM_ALREADY_IN_LIST
Definition Language.h:249
@ LANG_ITEM_NOT_FOUND
Definition Language.h:246
@ LANG_EXTENDED_COST_NOT_EXIST
Definition Language.h:373
Definition Chat.h:37
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
VendorItemData const * GetNpcVendorItemList(uint32 entry) const
Definition ObjectMgr.h:1366
WorldSession * GetSession() const
Definition Player.h:2005
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost) const
Definition Creature.cpp:111

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 ( )
6796{
6797 uint32 oldMSTime = getMSTime();
6798
6799 if (!_accessRequirementStore.empty())
6800 {
6801 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
6802 {
6803 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
6804 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
6805 {
6806 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
6807 {
6808 delete* questItr;
6809 }
6810
6811 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
6812 {
6813 delete* achievementItr;
6814 }
6815
6816 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
6817 {
6818 delete* itemsItr;
6819 }
6820
6821 delete difficultiesItr->second;
6822 }
6823 }
6824
6825 _accessRequirementStore.clear(); // need for reload case
6826 }
6827 // 0 1 2 3 4 5
6828 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
6829 if (!access_template_result)
6830 {
6831 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
6832 LOG_INFO("server.loading", " ");
6833 return;
6834 }
6835
6836 uint32 count = 0;
6837 uint32 countProgressionRequirements = 0;
6838
6839 do
6840 {
6841 Field* fields = access_template_result->Fetch();
6842
6843 //Get the common variables for the access requirements
6844 uint8 dungeon_access_id = fields[0].Get<uint8>();
6845 uint32 mapid = fields[1].Get<uint32>();
6846 uint8 difficulty = fields[2].Get<uint8>();
6847
6848 //Set up the access requirements
6850 ar->levelMin = fields[3].Get<uint8>();
6851 ar->levelMax = fields[4].Get<uint8>();
6852 ar->reqItemLevel = fields[5].Get<uint16>();
6853
6854 // 0 1 2 3 4 6
6855 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);
6856 if (progression_requirements_results)
6857 {
6858 do
6859 {
6860 Field* progression_requirement_row = progression_requirements_results->Fetch();
6861
6862 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
6863 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
6864 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
6865 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
6866 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
6867 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
6868
6869 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
6870 progression_requirement->id = requirement_id;
6871 progression_requirement->note = requirement_note;
6872 progression_requirement->faction = (TeamId)requirement_faction;
6873 progression_requirement->priority = requirement_priority;
6874 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
6875
6876 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
6877
6878 switch (requirement_type)
6879 {
6880 case 0:
6881 {
6882 //Achievement
6883 if (!sAchievementStore.LookupEntry(progression_requirement->id))
6884 {
6885 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);
6886 break;
6887 }
6888
6889 currentRequirementsList = &ar->achievements;
6890 break;
6891 }
6892 case 1:
6893 {
6894 //Quest
6895 if (!GetQuestTemplate(progression_requirement->id))
6896 {
6897 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);
6898 break;
6899 }
6900
6901 currentRequirementsList = &ar->quests;
6902 break;
6903 }
6904 case 2:
6905 {
6906 //Item
6907 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
6908 if (!pProto)
6909 {
6910 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);
6911 break;
6912 }
6913
6914 currentRequirementsList = &ar->items;
6915 break;
6916 }
6917 default:
6918 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);
6919 break;
6920 }
6921
6922 //Check if array is valid and delete the progression requirement
6923 if (!currentRequirementsList)
6924 {
6925 delete progression_requirement;
6926 continue;
6927 }
6928
6929 //Insert into the array
6930 if (currentRequirementsList->size() > requirement_priority)
6931 {
6932 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
6933 }
6934 else
6935 {
6936 currentRequirementsList->push_back(progression_requirement);
6937 }
6938
6939 } while (progression_requirements_results->NextRow());
6940 }
6941
6942 //Sort all arrays for priority
6943 auto sortFunction = [](const ProgressionRequirement* const a, const ProgressionRequirement* const b) {return a->priority > b->priority; };
6944 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
6945 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
6946 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
6947
6948 countProgressionRequirements += ar->achievements.size();
6949 countProgressionRequirements += ar->quests.size();
6950 countProgressionRequirements += ar->items.size();
6951 count++;
6952
6953 _accessRequirementStore[mapid][difficulty] = ar;
6954 } while (access_template_result->NextRow());
6955
6956 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
6957 LOG_INFO("server.loading", " ");
6958}
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
#define LOG_WARN(filterType__,...)
Definition Log.h:161
TeamId
Definition SharedDefines.h:759
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
Class used to access individual fields of database query result.
Definition Field.h:98
bool IsNull() const
Definition Field.h:106
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
ItemTemplate const * GetItemTemplate(uint32 entry)
Definition ObjectMgr.cpp:3307
Quest const * GetQuestTemplate(uint32 quest_id) const
Definition ObjectMgr.h:826
Definition Player.h:947
Definition ItemTemplate.h:619
Definition Player.h:938
uint32 priority
Definition Player.h:942

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 ( )
8745{
8746 uint32 oldMSTime = getMSTime();
8747
8748 _acoreStringStore.clear(); // for reload case
8749 QueryResult result = WorldDatabase.Query("SELECT entry, content_default, locale_koKR, locale_frFR, locale_deDE, locale_zhCN, locale_zhTW, locale_esES, locale_esMX, locale_ruRU FROM acore_string");
8750 if (!result)
8751 {
8752 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty.");
8753 LOG_INFO("server.loading", " ");
8754 return false;
8755 }
8756
8757 do
8758 {
8759 Field* fields = result->Fetch();
8760
8761 uint32 entry = fields[0].Get<uint32>();
8762
8763 AcoreString& data = _acoreStringStore[entry];
8764
8765 data.Content.resize(DEFAULT_LOCALE + 1);
8766
8767 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
8768 AddLocaleString(fields[i + 1].Get<std::string>(), LocaleConstant(i), data.Content);
8769 } while (result->NextRow());
8770
8771 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8772 LOG_INFO("server.loading", " ");
8773
8774 return true;
8775}
LocaleConstant
Definition Common.h:65
@ TOTAL_LOCALES
Definition Common.h:76
static void AddLocaleString(std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
Definition ObjectMgr.cpp:382

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

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
6685{
6686 uint32 oldMSTime = getMSTime();
6687
6688 _areaTriggerStore.clear();
6689
6690 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
6691
6692 if (!result)
6693 {
6694 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
6695 LOG_INFO("server.loading", " ");
6696 return;
6697 }
6698
6699 uint32 count = 0;
6700
6701 do
6702 {
6703 Field* fields = result->Fetch();
6704
6705 ++count;
6706
6707 AreaTrigger at;
6708
6709 at.entry = fields[0].Get<uint32>();
6710 at.map = fields[1].Get<uint32>();
6711 at.x = fields[2].Get<float>();
6712 at.y = fields[3].Get<float>();
6713 at.z = fields[4].Get<float>();
6714 at.radius = fields[5].Get<float>();
6715 at.length = fields[6].Get<float>();
6716 at.width = fields[7].Get<float>();
6717 at.height = fields[8].Get<float>();
6718 at.orientation = fields[9].Get<float>();
6719
6720 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
6721 if (!mapEntry)
6722 {
6723 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
6724 continue;
6725 }
6726
6727 _areaTriggerStore[at.entry] = at;
6728 } while (result->NextRow());
6729
6730 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6731 LOG_INFO("server.loading", " ");
6732}
float height
Definition ObjectMgr.h:429
float x
Definition ObjectMgr.h:423
float y
Definition ObjectMgr.h:424
float orientation
Definition ObjectMgr.h:430
float length
Definition ObjectMgr.h:427
uint32 entry
Definition ObjectMgr.h:421
float radius
Definition ObjectMgr.h:426
float z
Definition ObjectMgr.h:425
float width
Definition ObjectMgr.h:428

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 ( )
6543{
6544 uint32 oldMSTime = getMSTime();
6545
6546 _areaTriggerScriptStore.clear(); // need for reload case
6547 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
6548
6549 if (!result)
6550 {
6551 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
6552 LOG_INFO("server.loading", " ");
6553 return;
6554 }
6555
6556 uint32 count = 0;
6557
6558 do
6559 {
6560 ++count;
6561
6562 Field* fields = result->Fetch();
6563
6564 uint32 Trigger_ID = fields[0].Get<uint32>();
6565 std::string scriptName = fields[1].Get<std::string>();
6566
6567 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6568 if (!atEntry)
6569 {
6570 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6571 continue;
6572 }
6573 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
6574 } while (result->NextRow());
6575
6576 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6577 LOG_INFO("server.loading", " ");
6578}
uint32 GetScriptId(std::string const &name)
Definition ObjectMgr.cpp:9641

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

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
6735{
6736 uint32 oldMSTime = getMSTime();
6737
6738 _areaTriggerTeleportStore.clear(); // need for reload case
6739
6740 // 0 1 2 3 4 5
6741 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
6742
6743 if (!result)
6744 {
6745 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
6746 LOG_INFO("server.loading", " ");
6747 return;
6748 }
6749
6750 uint32 count = 0;
6751
6752 do
6753 {
6754 Field* fields = result->Fetch();
6755
6756 ++count;
6757
6758 uint32 Trigger_ID = fields[0].Get<uint32>();
6759
6761
6762 at.target_mapId = fields[1].Get<uint16>();
6763 at.target_X = fields[2].Get<float>();
6764 at.target_Y = fields[3].Get<float>();
6765 at.target_Z = fields[4].Get<float>();
6766 at.target_Orientation = fields[5].Get<float>();
6767
6768 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6769 if (!atEntry)
6770 {
6771 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6772 continue;
6773 }
6774
6775 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
6776 if (!mapEntry)
6777 {
6778 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
6779 continue;
6780 }
6781
6782 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
6783 {
6784 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
6785 continue;
6786 }
6787
6788 _areaTriggerTeleportStore[Trigger_ID] = at;
6789 } while (result->NextRow());
6790
6791 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6792 LOG_INFO("server.loading", " ");
6793}
Definition ObjectMgr.h:411
uint32 target_mapId
Definition ObjectMgr.h:412

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

◆ LoadBroadcastTextLocales()

void ObjectMgr::LoadBroadcastTextLocales ( )
9741{
9742 uint32 oldMSTime = getMSTime();
9743
9744 // 0 1 2 3
9745 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
9746
9747 if (!result)
9748 {
9749 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
9750 LOG_INFO("server.loading", " ");
9751 return;
9752 }
9753
9754 uint32 locales_count = 0;
9755 do
9756 {
9757 Field* fields = result->Fetch();
9758
9759 uint32 id = fields[0].Get<uint32>();
9760
9761 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
9762 if (bct == _broadcastTextStore.end())
9763 {
9764 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
9765 continue;
9766 }
9767
9768 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
9769 if (locale == LOCALE_enUS)
9770 continue;
9771
9772 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
9773 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
9774 locales_count++;
9775 } while (result->NextRow());
9776
9777 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
9778 LOG_INFO("server.loading", " ");
9779}
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:42

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

◆ LoadBroadcastTexts()

void ObjectMgr::LoadBroadcastTexts ( )
9656{
9657 uint32 oldMSTime = getMSTime();
9658
9659 _broadcastTextStore.clear(); // for reload case
9660
9661 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9662 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
9663 if (!result)
9664 {
9665 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
9666 LOG_INFO("server.loading", " ");
9667 return;
9668 }
9669
9670 _broadcastTextStore.rehash(result->GetRowCount());
9671
9672 do
9673 {
9674 Field* fields = result->Fetch();
9675
9676 BroadcastText bct;
9677
9678 bct.Id = fields[0].Get<uint32>();
9679 bct.LanguageID = fields[1].Get<uint32>();
9680 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
9681 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
9682 bct.EmoteId1 = fields[4].Get<uint32>();
9683 bct.EmoteId2 = fields[5].Get<uint32>();
9684 bct.EmoteId3 = fields[6].Get<uint32>();
9685 bct.EmoteDelay1 = fields[7].Get<uint32>();
9686 bct.EmoteDelay2 = fields[8].Get<uint32>();
9687 bct.EmoteDelay3 = fields[9].Get<uint32>();
9688 bct.SoundEntriesId = fields[10].Get<uint32>();
9689 bct.EmotesID = fields[11].Get<uint32>();
9690 bct.Flags = fields[12].Get<uint32>();
9691
9692 if (bct.SoundEntriesId)
9693 {
9694 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
9695 {
9696 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
9697 bct.SoundEntriesId = 0;
9698 }
9699 }
9700
9702 {
9703 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
9705 }
9706
9707 if (bct.EmoteId1)
9708 {
9709 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
9710 {
9711 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
9712 bct.EmoteId1 = 0;
9713 }
9714 }
9715
9716 if (bct.EmoteId2)
9717 {
9718 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
9719 {
9720 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
9721 bct.EmoteId2 = 0;
9722 }
9723 }
9724
9725 if (bct.EmoteId3)
9726 {
9727 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
9728 {
9729 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
9730 bct.EmoteId3 = 0;
9731 }
9732 }
9733
9734 _broadcastTextStore[bct.Id] = bct;
9735 } while (result->NextRow());
9736
9737 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
9738}
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition ObjectMgr.cpp:253
@ LANG_UNIVERSAL
Definition SharedDefines.h:735
Definition ObjectMgr.h:434
uint32 EmoteDelay2
Definition ObjectMgr.h:449
uint32 Id
Definition ObjectMgr.h:441
std::vector< std::string > FemaleText
Definition ObjectMgr.h:444
uint32 EmotesID
Definition ObjectMgr.h:452
uint32 LanguageID
Definition ObjectMgr.h:442
uint32 EmoteId2
Definition ObjectMgr.h:446
uint32 EmoteDelay1
Definition ObjectMgr.h:448
uint32 SoundEntriesId
Definition ObjectMgr.h:451
std::vector< std::string > MaleText
Definition ObjectMgr.h:443
uint32 EmoteId3
Definition ObjectMgr.h:447
uint32 EmoteId1
Definition ObjectMgr.h:445
uint32 EmoteDelay3
Definition ObjectMgr.h:450
uint32 Flags
Definition ObjectMgr.h:453

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

◆ LoadCreatureAddons()

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

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 ( )
9808{
9809 uint32 oldMSTime = getMSTime();
9810
9811 QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2 FROM creature_classlevelstats");
9812
9813 if (!result)
9814 {
9815 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
9816 LOG_INFO("server.loading", " ");
9817 return;
9818 }
9819
9820 uint32 count = 0;
9821 do
9822 {
9823 Field* fields = result->Fetch();
9824
9825 uint8 Level = fields[0].Get<uint8>();
9826 uint8 Class = fields[1].Get<uint8>();
9827
9828 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
9829 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
9830
9831 CreatureBaseStats stats;
9832
9833 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
9834 {
9835 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
9836
9837 if (stats.BaseHealth[i] == 0)
9838 {
9839 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
9840 stats.BaseHealth[i] = 1;
9841 }
9842
9843 // xinef: if no data is available, get them from lower expansions
9844 if (stats.BaseHealth[i] <= 1)
9845 {
9846 for (uint8 j = i; j > 0;)
9847 {
9848 --j;
9849 if (stats.BaseHealth[j] > 1)
9850 {
9851 stats.BaseHealth[i] = stats.BaseHealth[j];
9852 break;
9853 }
9854 }
9855 }
9856
9857 stats.BaseDamage[i] = fields[9 + i].Get<float>();
9858 if (stats.BaseDamage[i] < 0.0f)
9859 {
9860 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
9861 stats.BaseDamage[i] = 0.0f;
9862 }
9863 }
9864
9865 stats.BaseMana = fields[5].Get<uint32>();
9866 stats.BaseArmor = fields[6].Get<uint32>();
9867
9868 stats.AttackPower = fields[7].Get<uint32>();
9869 stats.RangedAttackPower = fields[8].Get<uint32>();
9870
9872
9873 ++count;
9874 } while (result->NextRow());
9875
9876 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
9877 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
9878 {
9879 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
9880 {
9881 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
9882 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
9883 }
9884 }
9885
9886 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9887 LOG_INFO("server.loading", " ");
9888}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:292
@ Class
Requires the player to be a specific class.
@ Level
Requires the player to be at least a specific level.
uint32 BaseMana
Definition CreatureData.h:305
float BaseDamage[MAX_EXPANSIONS]
Definition CreatureData.h:309
uint32 RangedAttackPower
Definition CreatureData.h:308
uint32 AttackPower
Definition CreatureData.h:307
uint32 BaseHealth[MAX_EXPANSIONS]
Definition CreatureData.h:304
float BaseArmor
Definition CreatureData.h:306

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

◆ LoadCreatureCustomIDs()

void ObjectMgr::LoadCreatureCustomIDs ( )

Load config option Creatures.CustomIDs into Store.

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

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

◆ LoadCreatureLocales()

void ObjectMgr::LoadCreatureLocales ( )
394{
395 uint32 oldMSTime = getMSTime();
396
397 _creatureLocaleStore.clear(); // need for reload case
398
399 // 0 1 2 3
400 QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale");
401 if (!result)
402 return;
403
404 do
405 {
406 Field* fields = result->Fetch();
407
408 uint32 ID = fields[0].Get<uint32>();
409
410 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
411 if (locale == LOCALE_enUS)
412 continue;
413
415 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
416 AddLocaleString(fields[3].Get<std::string>(), locale, data.Title);
417 } while (result->NextRow());
418
419 LOG_INFO("server.loading", ">> Loaded {} Creature Locale Strings in {} ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
420}
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 ( )
1714{
1715 uint32 oldMSTime = getMSTime();
1716
1717 // 0 1 2 3 4
1718 QueryResult result = WorldDatabase.Query("SELECT DisplayID, BoundingRadius, CombatReach, Gender, DisplayID_Other_Gender FROM creature_model_info");
1719
1720 if (!result)
1721 {
1722 LOG_WARN("server.loading", ">> Loaded 0 creature model definitions. DB table `creature_model_info` is empty.");
1723 LOG_INFO("server.loading", " ");
1724 return;
1725 }
1726
1727 _creatureModelStore.rehash(result->GetRowCount());
1728 uint32 count = 0;
1729
1730 // List of ModelDataIDs that use Invisible models
1731 uint32 triggerCreatureModelDataID[14] = { 1731, 1752, 2206, 2296, 2372, 2382, 2481, 2512, 2513, 2611, 2636, 2790, 3230, 3274 };
1732
1733 do
1734 {
1735 Field* fields = result->Fetch();
1736
1737 uint32 displayId = fields[0].Get<uint32>();
1738 CreatureDisplayInfoEntry const* creatureDisplay = sCreatureDisplayInfoStore.LookupEntry(displayId);
1739 uint32 modelId = fields[0].Get<uint32>();
1740
1741 CreatureModelInfo& modelInfo = _creatureModelStore[modelId];
1742
1743 modelInfo.bounding_radius = fields[1].Get<float>();
1744 modelInfo.combat_reach = fields[2].Get<float>();
1745 modelInfo.gender = fields[3].Get<uint8>();
1746 modelInfo.modelid_other_gender = fields[4].Get<uint32>();
1747 modelInfo.is_trigger = false;
1748
1749 // Checks
1750
1751 if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
1752 LOG_ERROR("sql.sql", "Table `creature_model_info` has model for not existed display id ({}).", modelId);
1753
1754 if (modelInfo.gender > GENDER_NONE)
1755 {
1756 LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender ({}) for display id ({}).", uint32(modelInfo.gender), modelId);
1757 modelInfo.gender = GENDER_MALE;
1758 }
1759
1760 if (modelInfo.modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.modelid_other_gender))
1761 {
1762 LOG_ERROR("sql.sql", "Table `creature_model_info` has not existed alt.gender model ({}) for existed display id ({}).", modelInfo.modelid_other_gender, modelId);
1763 modelInfo.modelid_other_gender = 0;
1764 }
1765
1766 if (modelInfo.combat_reach < 0.1f)
1767 modelInfo.combat_reach = DEFAULT_COMBAT_REACH;
1768
1769 if (CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(creatureDisplay->ModelId))
1770 {
1771 for (uint32 i = 0; i < 14; i++)
1772 {
1773 if (modelData->Id == triggerCreatureModelDataID[i])
1774 {
1775 modelInfo.is_trigger = true;
1776 break;
1777 }
1778 }
1779 }
1780
1781 ++count;
1782 } while (result->NextRow());
1783
1784 LOG_INFO("server.loading", ">> Loaded {} Creature Model Based Info in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1785 LOG_INFO("server.loading", " ");
1786}
DBCStorage< CreatureModelDataEntry > sCreatureModelDataStore(CreatureModelDatafmt)
#define DEFAULT_COMBAT_REACH
Definition ObjectDefines.h:46
@ GENDER_MALE
Definition SharedDefines.h:61
@ GENDER_NONE
Definition SharedDefines.h:63
Definition DBCStructure.h:720
Definition DBCStructure.h:774
float bounding_radius
Definition CreatureData.h:399

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

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 ( )
8180{
8181 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8182
8183 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8184 {
8185 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8186 if (!cInfo)
8187 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8188 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8189 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);
8190 }
8191}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition UnitDefines.h:316
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition ObjectMgr.cpp:8092

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
10209{
10210 uint32 oldMSTime = getMSTime();
10211
10212 // 0 1 2
10213 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
10214
10215 if (!result)
10216 {
10217 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
10218 return;
10219 }
10220
10221 uint32 count = 0;
10222 do
10223 {
10224 Field* fields = result->Fetch();
10225
10226 uint32 entry = fields[0].Get<uint32>();
10227 uint32 item = fields[1].Get<uint32>();
10228 uint32 idx = fields[2].Get<uint32>();
10229
10230 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
10231 if (!creatureInfo)
10232 {
10233 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
10234 continue;
10235 };
10236
10237 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10238 if (!dbcData)
10239 {
10240 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
10241 continue;
10242 };
10243
10244 _creatureQuestItemStore[entry].push_back(item);
10245
10246 ++count;
10247 } while (result->NextRow());
10248
10249 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10250 LOG_INFO("server.loading", " ");
10251}
DBCStorage< ItemEntry > sItemStore(Itemfmt)
Definition DBCStructure.h:1139

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

◆ LoadCreatureQuestStarters()

void ObjectMgr::LoadCreatureQuestStarters ( )
8166{
8167 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8168
8169 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8170 {
8171 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8172 if (!cInfo)
8173 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8174 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8175 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);
8176 }
8177}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

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

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

◆ LoadCreatureSparring()

void ObjectMgr::LoadCreatureSparring ( )
2302{
2303 uint32 oldMSTime = getMSTime();
2304
2305 QueryResult result = WorldDatabase.Query("SELECT GUID, SparringPCT FROM creature_sparring");
2306
2307 if (!result)
2308 {
2309 LOG_WARN("server.loading", ">> Loaded 0 sparring data. DB table `creature_sparring` is empty.");
2310 LOG_INFO("server.loading", " ");
2311 return;
2312 }
2313
2314 uint32 count = 0;
2315 do
2316 {
2317 Field* fields = result->Fetch();
2318
2319 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2320 float sparringHealthPct = fields[1].Get<float>();
2321
2322 if (!sObjectMgr->GetCreatureData(spawnId))
2323 {
2324 LOG_ERROR("sql.sql", "Entry {} has a record in `creature_sparring` but doesn't exist in `creatures` table");
2325 continue;
2326 }
2327
2328 _creatureSparringStore[spawnId].push_back(sparringHealthPct);
2329
2330 ++count;
2331 } while (result->NextRow());
2332
2333 LOG_INFO("server.loading", ">> Loaded {} sparring data in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2334 LOG_INFO("server.loading", " ");
2335}

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

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateAddons()

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

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

◆ LoadCreatureTemplateModels()

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

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateResistances()

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

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

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

◆ LoadCreatureTemplateSpells()

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

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

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

◆ LoadEventScripts()

void ObjectMgr::LoadEventScripts ( )
5591{
5593
5594 std::set<uint32> evt_scripts;
5595 // Load all possible script entries from gameobjects
5596 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
5597 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
5598 if (uint32 eventId = itr->second.GetEventScriptId())
5599 evt_scripts.insert(eventId);
5600
5601 // Load all possible script entries from spells
5602 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5603 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
5604 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5605 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
5606 if (spell->Effects[j].MiscValue)
5607 evt_scripts.insert(spell->Effects[j].MiscValue);
5608
5609 for (std::size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
5610 {
5611 for (std::size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
5612 {
5613 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
5614
5615 if (node->arrivalEventID)
5616 evt_scripts.insert(node->arrivalEventID);
5617
5618 if (node->departureEventID)
5619 evt_scripts.insert(node->departureEventID);
5620 }
5621 }
5622
5623 // Then check if all scripts are in above list of possible script entries
5624 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
5625 {
5626 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
5627 if (itr2 == evt_scripts.end())
5628 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 {}",
5629 itr->first, SPELL_EFFECT_SEND_EVENT);
5630 }
5631}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition DBCStores.cpp:187
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition GameObject.h:42
ScriptMapMap sEventScripts
Definition ObjectMgr.cpp:60
@ SCRIPTS_EVENT
Definition ObjectMgr.h:149
@ SPELL_EFFECT_SEND_EVENT
Definition SharedDefines.h:839
void LoadScripts(ScriptsType type)
Definition ObjectMgr.cpp:5248
Definition DBCStructure.h:1972
uint32 arrivalEventID
Definition DBCStructure.h:1982
uint32 departureEventID
Definition DBCStructure.h:1983

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

◆ LoadExplorationBaseXP()

void ObjectMgr::LoadExplorationBaseXP ( )
7472{
7473 uint32 oldMSTime = getMSTime();
7474
7475 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
7476
7477 if (!result)
7478 {
7479 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
7480 LOG_INFO("server.loading", " ");
7481 return;
7482 }
7483
7484 uint32 count = 0;
7485
7486 do
7487 {
7488 Field* fields = result->Fetch();
7489 uint8 level = fields[0].Get<uint8>();
7490 uint32 basexp = fields[1].Get<int32>();
7491 _baseXPTable[level] = basexp;
7492 ++count;
7493 } while (result->NextRow());
7494
7495 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7496 LOG_INFO("server.loading", " ");
7497}
std::int32_t int32
Definition Define.h:103

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

◆ LoadFactionChangeAchievements()

void ObjectMgr::LoadFactionChangeAchievements ( )
9891{
9892 uint32 oldMSTime = getMSTime();
9893
9894 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_achievement");
9895
9896 if (!result)
9897 {
9898 LOG_WARN("server.loading", ">> Loaded 0 faction change achievement pairs. DB table `player_factionchange_achievement` is empty.");
9899 LOG_INFO("server.loading", " ");
9900 return;
9901 }
9902
9903 uint32 count = 0;
9904
9905 do
9906 {
9907 Field* fields = result->Fetch();
9908
9909 uint32 alliance = fields[0].Get<uint32>();
9910 uint32 horde = fields[1].Get<uint32>();
9911
9912 if (!sAchievementStore.LookupEntry(alliance))
9913 LOG_ERROR("sql.sql", "Achievement {} (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance);
9914 else if (!sAchievementStore.LookupEntry(horde))
9915 LOG_ERROR("sql.sql", "Achievement {} (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde);
9916 else
9917 FactionChangeAchievements[alliance] = horde;
9918
9919 ++count;
9920 } while (result->NextRow());
9921
9922 LOG_INFO("server.loading", ">> Loaded {} faction change achievement pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9923 LOG_INFO("server.loading", " ");
9924}
CharacterConversionMap FactionChangeAchievements
Definition ObjectMgr.h:1422

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

◆ LoadFactionChangeItems()

void ObjectMgr::LoadFactionChangeItems ( )
9927{
9928 uint32 oldMSTime = getMSTime();
9929
9930 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
9931
9932 if (!result)
9933 {
9934 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
9935 LOG_INFO("server.loading", " ");
9936 return;
9937 }
9938
9939 uint32 count = 0;
9940
9941 do
9942 {
9943 Field* fields = result->Fetch();
9944
9945 uint32 alliance = fields[0].Get<uint32>();
9946 uint32 horde = fields[1].Get<uint32>();
9947
9948 if (!GetItemTemplate(alliance))
9949 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
9950 else if (!GetItemTemplate(horde))
9951 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
9952 else
9953 FactionChangeItems[alliance] = horde;
9954
9955 ++count;
9956 } while (result->NextRow());
9957
9958 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9959 LOG_INFO("server.loading", " ");
9960}
CharacterConversionMap FactionChangeItems
Definition ObjectMgr.h:1423

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

◆ LoadFactionChangeQuests()

void ObjectMgr::LoadFactionChangeQuests ( )
9963{
9964 uint32 oldMSTime = getMSTime();
9965
9966 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
9967
9968 if (!result)
9969 {
9970 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
9971 LOG_INFO("server.loading", " ");
9972 return;
9973 }
9974
9975 uint32 count = 0;
9976
9977 do
9978 {
9979 Field* fields = result->Fetch();
9980
9981 uint32 alliance = fields[0].Get<uint32>();
9982 uint32 horde = fields[1].Get<uint32>();
9983
9984 if (!sObjectMgr->GetQuestTemplate(alliance))
9985 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
9986 else if (!sObjectMgr->GetQuestTemplate(horde))
9987 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
9988 else
9989 FactionChangeQuests[alliance] = horde;
9990
9991 ++count;
9992 } while (result->NextRow());
9993
9994 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9995 LOG_INFO("server.loading", " ");
9996}
CharacterConversionMap FactionChangeQuests
Definition ObjectMgr.h:1424

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

◆ LoadFactionChangeReputations()

void ObjectMgr::LoadFactionChangeReputations ( )
9999{
10000 uint32 oldMSTime = getMSTime();
10001
10002 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
10003
10004 if (!result)
10005 {
10006 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
10007 LOG_INFO("server.loading", " ");
10008 return;
10009 }
10010
10011 uint32 count = 0;
10012
10013 do
10014 {
10015 Field* fields = result->Fetch();
10016
10017 uint32 alliance = fields[0].Get<uint32>();
10018 uint32 horde = fields[1].Get<uint32>();
10019
10020 if (!sFactionStore.LookupEntry(alliance))
10021 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
10022 else if (!sFactionStore.LookupEntry(horde))
10023 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
10024 else
10025 FactionChangeReputation[alliance] = horde;
10026
10027 ++count;
10028 } while (result->NextRow());
10029
10030 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10031 LOG_INFO("server.loading", " ");
10032}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
CharacterConversionMap FactionChangeReputation
Definition ObjectMgr.h:1425

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

◆ LoadFactionChangeSpells()

void ObjectMgr::LoadFactionChangeSpells ( )
10035{
10036 uint32 oldMSTime = getMSTime();
10037
10038 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
10039
10040 if (!result)
10041 {
10042 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
10043 LOG_INFO("server.loading", " ");
10044 return;
10045 }
10046
10047 uint32 count = 0;
10048
10049 do
10050 {
10051 Field* fields = result->Fetch();
10052
10053 uint32 alliance = fields[0].Get<uint32>();
10054 uint32 horde = fields[1].Get<uint32>();
10055
10056 if (!sSpellMgr->GetSpellInfo(alliance))
10057 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
10058 else if (!sSpellMgr->GetSpellInfo(horde))
10059 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
10060 else
10061 FactionChangeSpells[alliance] = horde;
10062
10063 ++count;
10064 } while (result->NextRow());
10065
10066 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10067 LOG_INFO("server.loading", " ");
10068}
CharacterConversionMap FactionChangeSpells
Definition ObjectMgr.h:1426

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

◆ LoadFactionChangeTitles()

void ObjectMgr::LoadFactionChangeTitles ( )
10071{
10072 uint32 oldMSTime = getMSTime();
10073
10074 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
10075
10076 if (!result)
10077 {
10078 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
10079 return;
10080 }
10081
10082 uint32 count = 0;
10083
10084 do
10085 {
10086 Field* fields = result->Fetch();
10087
10088 uint32 alliance = fields[0].Get<uint32>();
10089 uint32 horde = fields[1].Get<uint32>();
10090
10091 if (!sCharTitlesStore.LookupEntry(alliance))
10092 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
10093 else if (!sCharTitlesStore.LookupEntry(horde))
10094 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
10095 else
10096 FactionChangeTitles[alliance] = horde;
10097
10098 ++count;
10099 } while (result->NextRow());
10100
10101 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10102 LOG_INFO("server.loading", " ");
10103}
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
CharacterConversionMap FactionChangeTitles
Definition ObjectMgr.h:1427

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

◆ LoadFishingBaseSkillLevel()

void ObjectMgr::LoadFishingBaseSkillLevel ( )
8794{
8795 uint32 oldMSTime = getMSTime();
8796
8797 _fishingBaseForAreaStore.clear(); // for reload case
8798
8799 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
8800
8801 if (!result)
8802 {
8803 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
8804 LOG_INFO("server.loading", " ");
8805 return;
8806 }
8807
8808 uint32 count = 0;
8809
8810 do
8811 {
8812 Field* fields = result->Fetch();
8813 uint32 entry = fields[0].Get<uint32>();
8814 int32 skill = fields[1].Get<int16>();
8815
8816 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8817 if (!fArea)
8818 {
8819 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8820 continue;
8821 }
8822
8823 _fishingBaseForAreaStore[entry] = skill;
8824 ++count;
8825 } while (result->NextRow());
8826
8827 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8828 LOG_INFO("server.loading", " ");
8829}

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

◆ LoadGameObjectAddons()

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

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

◆ LoadGameObjectForQuests()

void ObjectMgr::LoadGameObjectForQuests ( )
8580{
8581 uint32 oldMSTime = getMSTime();
8582
8583 if (sObjectMgr->GetGameObjectTemplates()->empty())
8584 {
8585 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
8586 LOG_INFO("server.loading", " ");
8587 return;
8588 }
8589
8590 uint32 count = 0;
8591
8592 // collect GO entries for GO that must activated
8593 GameObjectTemplateContainer* gotc = const_cast<GameObjectTemplateContainer*>(sObjectMgr->GetGameObjectTemplates());
8594 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
8595 {
8596 itr->second.IsForQuests = false;
8597 switch (itr->second.type)
8598 {
8600 itr->second.IsForQuests = true;
8601 ++count;
8602 break;
8604 {
8605 // scan GO chest with loot including quest items
8606 uint32 loot_id = (itr->second.GetLootId());
8607
8608 // find quest loot for GO
8609 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
8610 {
8611 itr->second.IsForQuests = true;
8612 ++count;
8613 }
8614 break;
8615 }
8617 {
8618 if (itr->second._generic.questID > 0) //quests objects
8619 {
8620 itr->second.IsForQuests = true;
8621 ++count;
8622 }
8623 break;
8624 }
8626 {
8627 if (itr->second.spellFocus.questID > 0) //quests objects
8628 {
8629 itr->second.IsForQuests = true;
8630 ++count;
8631 }
8632 break;
8633 }
8635 {
8636 if (itr->second.goober.questId > 0) //quests objects
8637 {
8638 itr->second.IsForQuests = true;
8639 ++count;
8640 }
8641 break;
8642 }
8643 default:
8644 break;
8645 }
8646 }
8647
8648 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8649 LOG_INFO("server.loading", " ");
8650}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition SharedDefines.h:1568
@ GAMEOBJECT_TYPE_GENERIC
Definition SharedDefines.h:1565
@ GAMEOBJECT_TYPE_CHEST
Definition SharedDefines.h:1563
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition SharedDefines.h:1562
@ GAMEOBJECT_TYPE_GOOBER
Definition SharedDefines.h:1570
bool HaveQuestLootFor(uint32 loot_id) const
Definition LootMgr.cpp:218

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

◆ LoadGameObjectLocales()

void ObjectMgr::LoadGameObjectLocales ( )
7116{
7117 uint32 oldMSTime = getMSTime();
7118
7119 _gameObjectLocaleStore.clear(); // need for reload case
7120
7121 // 0 1 2 3
7122 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7123 if (!result)
7124 return;
7125
7126 do
7127 {
7128 Field* fields = result->Fetch();
7129
7130 uint32 ID = fields[0].Get<uint32>();
7131
7132 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7133 if (locale == LOCALE_enUS)
7134 continue;
7135
7137 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7138 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7139 } while (result->NextRow());
7140
7141 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7142}
Definition GameObjectData.h:674
std::vector< std::string > Name
Definition GameObjectData.h:675
std::vector< std::string > CastBarCaption
Definition GameObjectData.h:676

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

◆ LoadGameobjectQuestEnders()

void ObjectMgr::LoadGameobjectQuestEnders ( )
8152{
8153 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8154
8155 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8156 {
8157 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8158 if (!goInfo)
8159 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8160 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8161 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8162 }
8163}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
10164{
10165 uint32 oldMSTime = getMSTime();
10166
10167 // 0 1 2
10168 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
10169
10170 if (!result)
10171 {
10172 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
10173 return;
10174 }
10175
10176 uint32 count = 0;
10177 do
10178 {
10179 Field* fields = result->Fetch();
10180
10181 uint32 entry = fields[0].Get<uint32>();
10182 uint32 item = fields[1].Get<uint32>();
10183 uint32 idx = fields[2].Get<uint32>();
10184
10185 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
10186 if (!goInfo)
10187 {
10188 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
10189 continue;
10190 };
10191
10192 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10193 if (!dbcData)
10194 {
10195 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
10196 continue;
10197 };
10198
10199 _gameObjectQuestItemStore[entry].push_back(item);
10200
10201 ++count;
10202 } while (result->NextRow());
10203
10204 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10205 LOG_INFO("server.loading", " ");
10206}

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

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8138{
8139 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8140
8141 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8142 {
8143 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8144 if (!goInfo)
8145 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8146 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8147 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8148 }
8149}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

void ObjectMgr::LoadGameobjects ( )
2472{
2473 uint32 oldMSTime = getMSTime();
2474
2475 // 0 1 2 3 4 5 6
2476 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
2477 // 7 8 9 10 11 12 13 14 15 16 17
2478 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, "
2479 // 18
2480 "ScriptName "
2481 "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
2482 "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
2483
2484 if (!result)
2485 {
2486 LOG_WARN("server.loading", ">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
2487 LOG_INFO("server.loading", " ");
2488 return;
2489 }
2490
2491 // build single time for check spawnmask
2492 std::map<uint32, uint32> spawnMasks;
2493 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2494 if (sMapStore.LookupEntry(i))
2495 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2497 spawnMasks[i] |= (1 << k);
2498
2499 _gameObjectDataStore.rehash(result->GetRowCount());
2500 do
2501 {
2502 Field* fields = result->Fetch();
2503
2504 ObjectGuid::LowType guid = fields[0].Get<uint32>();
2505 uint32 entry = fields[1].Get<uint32>();
2506
2507 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
2508 if (!gInfo)
2509 {
2510 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non existing gameobject entry {}, skipped.", guid, entry);
2511 continue;
2512 }
2513
2514 if (!gInfo->displayId)
2515 {
2516 switch (gInfo->type)
2517 {
2520 break;
2521 default:
2522 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) doesn't have a displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2523 break;
2524 }
2525 }
2526
2527 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
2528 {
2529 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) has an invalid displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2530 continue;
2531 }
2532
2534
2535 data.id = entry;
2536 data.mapid = fields[2].Get<uint16>();
2537 data.posX = fields[3].Get<float>();
2538 data.posY = fields[4].Get<float>();
2539 data.posZ = fields[5].Get<float>();
2540 data.orientation = fields[6].Get<float>();
2541 data.rotation.x = fields[7].Get<float>();
2542 data.rotation.y = fields[8].Get<float>();
2543 data.rotation.z = fields[9].Get<float>();
2544 data.rotation.w = fields[10].Get<float>();
2545 data.spawntimesecs = fields[11].Get<int32>();
2546 data.ScriptId = GetScriptId(fields[18].Get<std::string>());
2547 if (!data.ScriptId)
2548 data.ScriptId = gInfo->ScriptId;
2549
2550 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2551 if (!mapEntry)
2552 {
2553 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existed map (Id: {}), skip", guid, data.id, data.mapid);
2554 continue;
2555 }
2556
2557 if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
2558 {
2559 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);
2560 }
2561
2562 data.animprogress = fields[12].Get<uint8>();
2563 data.artKit = 0;
2564
2565 uint32 go_state = fields[13].Get<uint8>();
2566 if (go_state >= MAX_GO_STATE)
2567 {
2568 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skip", guid, data.id, go_state);
2569 continue;
2570 }
2571 data.go_state = GOState(go_state);
2572
2573 data.spawnMask = fields[14].Get<uint8>();
2574
2575 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2576 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);
2577
2578 data.phaseMask = fields[15].Get<uint32>();
2579 int16 gameEvent = fields[16].Get<int8>();
2580 uint32 PoolId = fields[17].Get<uint32>();
2581
2582 if (data.rotation.x < -1.0f || data.rotation.x > 1.0f)
2583 {
2584 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skip", guid, data.id, data.rotation.x);
2585 continue;
2586 }
2587
2588 if (data.rotation.y < -1.0f || data.rotation.y > 1.0f)
2589 {
2590 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skip", guid, data.id, data.rotation.y);
2591 continue;
2592 }
2593
2594 if (data.rotation.z < -1.0f || data.rotation.z > 1.0f)
2595 {
2596 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skip", guid, data.id, data.rotation.z);
2597 continue;
2598 }
2599
2600 if (data.rotation.w < -1.0f || data.rotation.w > 1.0f)
2601 {
2602 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skip", guid, data.id, data.rotation.w);
2603 continue;
2604 }
2605
2606 if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
2607 {
2608 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
2609 continue;
2610 }
2611
2612 if (data.phaseMask == 0)
2613 {
2614 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
2615 data.phaseMask = 1;
2616 }
2617
2619 {
2620 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2621 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2622
2624
2625 stmt->SetData(0, zoneId);
2626 stmt->SetData(1, areaId);
2627 stmt->SetData(2, guid);
2628
2629 WorldDatabase.Execute(stmt);
2630 }
2631
2632 if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
2633 AddGameobjectToGrid(guid, &data);
2634 } while (result->NextRow());
2635
2636 LOG_INFO("server.loading", ">> Loaded {} Gameobjects in {} ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
2637 LOG_INFO("server.loading", " ");
2638}
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
#define MAX_GO_STATE
Definition GameObjectData.h:27
GOState
Definition GameObjectData.h:688
@ CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA
Definition IWorld.h:151
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1566
@ WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldDatabase.h:116
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition MapMgr.h:90
uint32 ScriptId
Definition GameObjectData.h:707

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

◆ LoadGameObjectTemplate()

void ObjectMgr::LoadGameObjectTemplate ( )
7204{
7205 uint32 oldMSTime = getMSTime();
7206
7207 // 0 1 2 3 4 5 6 7
7208 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7209 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7210 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7211 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7212 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7213 "FROM gameobject_template");
7214
7215 if (!result)
7216 {
7217 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7218 LOG_INFO("server.loading", " ");
7219 return;
7220 }
7221
7222 _gameObjectTemplateStore.rehash(result->GetRowCount());
7223 uint32 count = 0;
7224 do
7225 {
7226 Field* fields = result->Fetch();
7227
7228 uint32 entry = fields[0].Get<uint32>();
7229
7231
7232 got.entry = entry;
7233 got.type = uint32(fields[1].Get<uint8>());
7234 got.displayId = fields[2].Get<uint32>();
7235 got.name = fields[3].Get<std::string>();
7236 got.IconName = fields[4].Get<std::string>();
7237 got.castBarCaption = fields[5].Get<std::string>();
7238 got.unk1 = fields[6].Get<std::string>();
7239 got.size = fields[7].Get<float>();
7240
7241 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7242 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7243
7244 got.AIName = fields[32].Get<std::string>();
7245 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7246 got.IsForQuests = false;
7247
7248 // Checks
7249 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7250 {
7251 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7252 }
7253
7254 switch (got.type)
7255 {
7256 case GAMEOBJECT_TYPE_DOOR: //0
7257 {
7258 if (got.door.lockId)
7259 CheckGOLockId(&got, got.door.lockId, 1);
7260 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7261 break;
7262 }
7263 case GAMEOBJECT_TYPE_BUTTON: //1
7264 {
7265 if (got.button.lockId)
7266 CheckGOLockId(&got, got.button.lockId, 1);
7267 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7268 break;
7269 }
7271 {
7272 if (got.questgiver.lockId)
7273 CheckGOLockId(&got, got.questgiver.lockId, 0);
7274 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7275 break;
7276 }
7277 case GAMEOBJECT_TYPE_CHEST: //3
7278 {
7279 if (got.chest.lockId)
7280 CheckGOLockId(&got, got.chest.lockId, 0);
7281
7282 CheckGOConsumable(&got, got.chest.consumable, 3);
7283
7284 if (got.chest.linkedTrapId) // linked trap
7285 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7286 break;
7287 }
7288 case GAMEOBJECT_TYPE_TRAP: //6
7289 {
7290 if (got.trap.lockId)
7291 CheckGOLockId(&got, got.trap.lockId, 0);
7292 break;
7293 }
7294 case GAMEOBJECT_TYPE_CHAIR: //7
7295 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7296 break;
7298 {
7299 if (got.spellFocus.focusId)
7300 {
7301 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7302 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7303 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7304 }
7305
7306 if (got.spellFocus.linkedTrapId) // linked trap
7307 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7308 break;
7309 }
7310 case GAMEOBJECT_TYPE_GOOBER: //10
7311 {
7312 if (got.goober.lockId)
7313 CheckGOLockId(&got, got.goober.lockId, 0);
7314
7315 CheckGOConsumable(&got, got.goober.consumable, 3);
7316
7317 if (got.goober.pageId) // pageId
7318 {
7319 if (!GetPageText(got.goober.pageId))
7320 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7321 entry, got.type, got.goober.pageId, got.goober.pageId);
7322 }
7323 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7324 if (got.goober.linkedTrapId) // linked trap
7325 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7326 break;
7327 }
7329 {
7330 if (got.areadamage.lockId)
7331 CheckGOLockId(&got, got.areadamage.lockId, 0);
7332 break;
7333 }
7334 case GAMEOBJECT_TYPE_CAMERA: //13
7335 {
7336 if (got.camera.lockId)
7337 CheckGOLockId(&got, got.camera.lockId, 0);
7338 break;
7339 }
7341 {
7342 if (got.moTransport.taxiPathId)
7343 {
7344 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7345 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7346 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7347 }
7348 if (uint32 transportMap = got.moTransport.mapID)
7349 _transportMaps.insert(transportMap);
7350 break;
7351 }
7353 break;
7355 {
7356 // always must have spell
7357 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7358 break;
7359 }
7360 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7361 {
7362 if (got.flagstand.lockId)
7363 CheckGOLockId(&got, got.flagstand.lockId, 0);
7364 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7365 break;
7366 }
7368 {
7369 if (got.fishinghole.lockId)
7370 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7371 break;
7372 }
7373 case GAMEOBJECT_TYPE_FLAGDROP: //26
7374 {
7375 if (got.flagdrop.lockId)
7376 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7377 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7378 break;
7379 }
7381 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7382 break;
7383 }
7384
7385 ++count;
7386 } while (result->NextRow());
7387
7388 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7389 LOG_INFO("server.loading", " ");
7390}
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
#define sGameObjectAIRegistry
Definition GameObjectAIFactory.h:49
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7184
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7163
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition ObjectMgr.cpp:7172
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7193
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7153
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7144
@ GAMEOBJECT_TYPE_CAMERA
Definition SharedDefines.h:1573
@ GAMEOBJECT_TYPE_BUTTON
Definition SharedDefines.h:1561
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition SharedDefines.h:1575
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition SharedDefines.h:1578
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition SharedDefines.h:1585
@ GAMEOBJECT_TYPE_FLAGDROP
Definition SharedDefines.h:1586
@ GAMEOBJECT_TYPE_SPELLCASTER
Definition SharedDefines.h:1582
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition SharedDefines.h:1584
@ GAMEOBJECT_TYPE_CHAIR
Definition SharedDefines.h:1567
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition SharedDefines.h:1572
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition SharedDefines.h:1592
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1560
#define MAX_GAMEOBJECT_DATA
Definition SharedDefines.h:1599
PageText const * GetPageText(uint32 pageEntry)
Definition ObjectMgr.cpp:5832
uint32 entry
Definition GameObjectData.h:32

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 ( )
7393{
7394 uint32 oldMSTime = getMSTime();
7395
7396 // 0 1 2 3 4 5 6 7 8
7397 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
7398
7399 if (!result)
7400 {
7401 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
7402 LOG_INFO("server.loading", " ");
7403 return;
7404 }
7405
7406 uint32 count = 0;
7407 do
7408 {
7409 Field* fields = result->Fetch();
7410
7411 uint32 entry = fields[0].Get<uint32>();
7412
7413 GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(entry);
7414 if (!got)
7415 {
7416 LOG_ERROR("sql.sql",
7417 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
7418 entry);
7419 continue;
7420 }
7421
7423 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
7424 gameObjectAddon.flags = fields[2].Get<uint32>();
7425 gameObjectAddon.mingold = fields[3].Get<uint32>();
7426 gameObjectAddon.maxgold = fields[4].Get<uint32>();
7427
7428 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
7429 {
7430 uint32 artKitID = fields[5 + i].Get<uint32>();
7431 if (!artKitID)
7432 continue;
7433
7434 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
7435 {
7436 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
7437 continue;
7438 }
7439
7440 gameObjectAddon.artKits[i] = artKitID;
7441 }
7442
7443 // checks
7444 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
7445 LOG_ERROR("sql.sql",
7446 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
7447 entry, gameObjectAddon.faction);
7448
7449 if (gameObjectAddon.maxgold > 0)
7450 {
7451 switch (got->type)
7452 {
7455 break;
7456 default:
7457 LOG_ERROR("sql.sql",
7458 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
7459 entry, got->type);
7460 break;
7461 }
7462 }
7463
7464 ++count;
7465 } while (result->NextRow());
7466
7467 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7468 LOG_INFO("server.loading", " ");
7469}
DBCStorage< GameObjectArtKitEntry > sGameObjectArtKitStore(GameObjectArtKitfmt)
Definition GameObjectData.h:664
uint32 mingold
Definition GameObjectData.h:668
uint32 flags
Definition GameObjectData.h:667
uint32 faction
Definition GameObjectData.h:666
std::array< uint32, 4 > artKits
Definition GameObjectData.h:670
uint32 maxgold
Definition GameObjectData.h:669

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

◆ LoadGameTele()

void ObjectMgr::LoadGameTele ( )
8934{
8935 uint32 oldMSTime = getMSTime();
8936
8937 _gameTeleStore.clear(); // for reload case
8938
8939 // 0 1 2 3 4 5 6
8940 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
8941
8942 if (!result)
8943 {
8944 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
8945 LOG_INFO("server.loading", " ");
8946 return;
8947 }
8948
8949 uint32 count = 0;
8950
8951 do
8952 {
8953 Field* fields = result->Fetch();
8954
8955 uint32 id = fields[0].Get<uint32>();
8956
8957 GameTele gt;
8958
8959 gt.position_x = fields[1].Get<float>();
8960 gt.position_y = fields[2].Get<float>();
8961 gt.position_z = fields[3].Get<float>();
8962 gt.orientation = fields[4].Get<float>();
8963 gt.mapId = fields[5].Get<uint16>();
8964 gt.name = fields[6].Get<std::string>();
8965
8966 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
8967 {
8968 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
8969 continue;
8970 }
8971
8972 if (!Utf8toWStr(gt.name, gt.wnameLow))
8973 {
8974 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
8975 continue;
8976 }
8977
8978 wstrToLower(gt.wnameLow);
8979
8980 _gameTeleStore[id] = gt;
8981
8982 ++count;
8983 } while (result->NextRow());
8984
8985 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8986 LOG_INFO("server.loading", " ");
8987}
float position_x
Definition ObjectMgr.h:133

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 ( )
9350{
9351 uint32 oldMSTime = getMSTime();
9352
9353 _gossipMenusStore.clear();
9354
9355 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
9356
9357 if (!result)
9358 {
9359 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
9360 LOG_INFO("server.loading", " ");
9361 return;
9362 }
9363
9364 do
9365 {
9366 Field* fields = result->Fetch();
9367
9368 GossipMenus gMenu;
9369
9370 gMenu.MenuID = fields[0].Get<uint32>();
9371 gMenu.TextID = fields[1].Get<uint32>();
9372
9373 if (!GetGossipText(gMenu.TextID))
9374 {
9375 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
9376 continue;
9377 }
9378
9379 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
9380 } while (result->NextRow());
9381
9382 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
9383 LOG_INFO("server.loading", " ");
9384}
GossipText const * GetGossipText(uint32 Text_ID) const
Definition ObjectMgr.cpp:6010
Definition ObjectMgr.h:624
uint32 TextID
Definition ObjectMgr.h:626
uint32 MenuID
Definition ObjectMgr.h:625

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

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
9387{
9388 uint32 oldMSTime = getMSTime();
9389
9390 _gossipMenuItemsStore.clear();
9391
9392 QueryResult result = WorldDatabase.Query(
9393 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9394 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
9395 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
9396
9397 if (!result)
9398 {
9399 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
9400 LOG_INFO("server.loading", " ");
9401 return;
9402 }
9403
9404 do
9405 {
9406 Field* fields = result->Fetch();
9407
9408 GossipMenuItems gMenuItem;
9409
9410 gMenuItem.MenuID = fields[0].Get<uint32>();
9411 gMenuItem.OptionID = fields[1].Get<uint16>();
9412 gMenuItem.OptionIcon = fields[2].Get<uint32>();
9413 gMenuItem.OptionText = fields[3].Get<std::string>();
9414 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
9415 gMenuItem.OptionType = fields[5].Get<uint8>();
9416 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
9417 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
9418 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
9419 gMenuItem.BoxCoded = fields[9].Get<bool>();
9420 gMenuItem.BoxMoney = fields[10].Get<uint32>();
9421 gMenuItem.BoxText = fields[11].Get<std::string>();
9422 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
9423
9424 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
9425 {
9426 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);
9427 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
9428 }
9429
9431 {
9432 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
9433 gMenuItem.OptionBroadcastTextID = 0;
9434 }
9435
9436 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
9437 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);
9438
9439 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
9440 {
9441 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
9442 gMenuItem.ActionPoiID = 0;
9443 }
9444
9445 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
9446 {
9447 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
9448 gMenuItem.BoxBroadcastTextID = 0;
9449 }
9450
9451 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
9452 } while (result->NextRow());
9453
9454 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
9455 LOG_INFO("server.loading", " ");
9456}
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:61
@ GOSSIP_ICON_MAX
Definition GossipDef.h:82
@ GOSSIP_OPTION_MAX
Definition GossipDef.h:56
PointOfInterest const * GetPointOfInterest(uint32 id) const
Definition ObjectMgr.h:920
BroadcastText const * GetBroadcastText(uint32 id) const
Definition ObjectMgr.h:1189
Definition ObjectMgr.h:606
uint8 OptionIcon
Definition ObjectMgr.h:609
uint32 BoxBroadcastTextID
Definition ObjectMgr.h:620
std::string OptionText
Definition ObjectMgr.h:610
uint32 ActionMenuID
Definition ObjectMgr.h:614
bool BoxCoded
Definition ObjectMgr.h:616
uint32 MenuID
Definition ObjectMgr.h:607
uint32 OptionNpcFlag
Definition ObjectMgr.h:613
uint32 ActionPoiID
Definition ObjectMgr.h:615
uint32 BoxMoney
Definition ObjectMgr.h:617
std::string BoxText
Definition ObjectMgr.h:618
uint32 OptionID
Definition ObjectMgr.h:608
uint32 OptionType
Definition ObjectMgr.h:612
uint32 OptionBroadcastTextID
Definition ObjectMgr.h:611

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

◆ LoadGossipMenuItemsLocales()

void ObjectMgr::LoadGossipMenuItemsLocales ( )
423{
424 uint32 oldMSTime = getMSTime();
425
426 _gossipMenuItemsLocaleStore.clear(); // need for reload case
427
428 // 0 1 2 3 4
429 QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale");
430
431 if (!result)
432 return;
433
434 do
435 {
436 Field* fields = result->Fetch();
437
438 uint32 MenuID = fields[0].Get<uint32>();
439 uint16 OptionID = fields[1].Get<uint16>();
440
441 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
442 if (locale == LOCALE_enUS)
443 continue;
444
446 AddLocaleString(fields[3].Get<std::string>(), locale, data.OptionText);
447 AddLocaleString(fields[4].Get<std::string>(), locale, data.BoxText);
448 } while (result->NextRow());
449
450 LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale Strings in {} ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
451}
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 ( )
6019{
6020 uint32 oldMSTime = getMSTime();
6021
6022 QueryResult result = WorldDatabase.Query("SELECT ID, "
6023 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
6024 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
6025 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
6026 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
6027 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
6028 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
6029 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
6030 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
6031 "FROM npc_text");
6032
6033 if (!result)
6034 {
6035 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
6036 LOG_INFO("server.loading", " ");
6037 return;
6038 }
6039
6040 _gossipTextStore.rehash(result->GetRowCount());
6041
6042 uint32 count = 0;
6043 uint8 cic;
6044
6045 do
6046 {
6047 cic = 0;
6048
6049 Field* fields = result->Fetch();
6050
6051 uint32 id = fields[cic++].Get<uint32>();
6052 if (!id)
6053 {
6054 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
6055 continue;
6056 }
6057
6058 GossipText& gText = _gossipTextStore[id];
6059
6060 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6061 {
6062 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
6063 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
6064 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
6065 gText.Options[i].Language = fields[cic++].Get<uint8>();
6066 gText.Options[i].Probability = fields[cic++].Get<float>();
6067
6068 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
6069 {
6070 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
6071 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
6072 }
6073 }
6074
6075 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
6076 {
6077 if (gText.Options[i].BroadcastTextID)
6078 {
6080 {
6081 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
6082 gText.Options[i].BroadcastTextID = 0;
6083 }
6084 }
6085 }
6086
6087 count++;
6088 } while (result->NextRow());
6089
6090 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6091 LOG_INFO("server.loading", " ");
6092}
#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 ( )
5926{
5927 uint32 oldMSTime = getMSTime();
5928
5929 // 0 1 2 3
5930 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
5931 if (!result)
5932 {
5933 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
5934 LOG_INFO("server.loading", " ");
5935 return;
5936 }
5937
5938 uint32 count = 0;
5939 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
5940 do
5941 {
5942 Field* fields = result->Fetch();
5943 uint32 entry = fields[0].Get<uint32>();
5944 uint8 creditType = fields[1].Get<uint8>();
5945 uint32 creditEntry = fields[2].Get<uint32>();
5946 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
5947 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
5948 if (!dungeonEncounter)
5949 {
5950 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
5951 continue;
5952 }
5953
5954 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
5955 {
5956 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
5957 continue;
5958 }
5959
5960 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
5961 if (lastEncounterDungeon)
5962 {
5963 if (itr != dungeonLastBosses.end())
5964 {
5965 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]);
5966 continue;
5967 }
5968
5969 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
5970 }
5971
5972 switch (creditType)
5973 {
5975 {
5976 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
5977 if (!creatureInfo)
5978 {
5979 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5980 continue;
5981 }
5982 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
5983 break;
5984 }
5986 {
5987 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
5988 if (!spellInfo)
5989 {
5990 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5991 continue;
5992 }
5993 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
5994 break;
5995 }
5996 default:
5997 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
5998 continue;
5999 }
6000
6001 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
6002 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
6003 ++count;
6004 } while (result->NextRow());
6005
6006 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6007 LOG_INFO("server.loading", " ");
6008}
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition CreatureData.h:73
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
#define sLFGMgr
Definition LFGMgr.h:641
EncounterCreditType
Definition Map.h:150
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition Map.h:151
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition Map.h:152
std::list< DungeonEncounter const * > DungeonEncounterList
Definition ObjectMgr.h:711
@ SPELL_ATTR0_CU_ENCOUNTER_REWARD
Definition SpellInfo.h:207
Definition DBCStructure.h:865
Definition ObjectMgr.h:701

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 ( )
5875{
5876 uint32 oldMSTime = getMSTime();
5877
5878 // 0 1 2 4
5879 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
5880
5881 if (!result)
5882 {
5883 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `instance_template` is empty!");
5884 LOG_INFO("server.loading", " ");
5885 return;
5886 }
5887
5888 uint32 count = 0;
5889 do
5890 {
5891 Field* fields = result->Fetch();
5892
5893 uint16 mapID = fields[0].Get<uint16>();
5894
5895 if (!MapMgr::IsValidMAP(mapID, true))
5896 {
5897 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
5898 continue;
5899 }
5900
5901 InstanceTemplate instanceTemplate;
5902
5903 instanceTemplate.AllowMount = fields[3].Get<bool>();
5904 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
5905 instanceTemplate.ScriptId = sObjectMgr->GetScriptId(fields[2].Get<std::string>());
5906
5907 _instanceTemplateStore[mapID] = instanceTemplate;
5908
5909 ++count;
5910 } while (result->NextRow());
5911
5912 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5913 LOG_INFO("server.loading", " ");
5914}
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition MapMgr.cpp:311
bool AllowMount
Definition Map.h:120
uint32 ScriptId
Definition Map.h:119

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

◆ LoadItemLocales()

void ObjectMgr::LoadItemLocales ( )
2669{
2670 uint32 oldMSTime = getMSTime();
2671
2672 _itemLocaleStore.clear(); // need for reload case
2673
2674 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
2675 if (!result)
2676 return;
2677
2678 do
2679 {
2680 Field* fields = result->Fetch();
2681
2682 uint32 ID = fields[0].Get<uint32>();
2683
2684 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
2685 if (locale == LOCALE_enUS)
2686 continue;
2687
2688 ItemLocale& data = _itemLocaleStore[ID];
2689 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
2690 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
2691 } while (result->NextRow());
2692
2693 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
2694}
Definition ItemTemplate.h:838
std::vector< std::string > Description
Definition ItemTemplate.h:840
std::vector< std::string > Name
Definition ItemTemplate.h:839

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

◆ LoadItemSetNameLocales()

void ObjectMgr::LoadItemSetNameLocales ( )
3313{
3314 uint32 oldMSTime = getMSTime();
3315
3316 _itemSetNameLocaleStore.clear(); // need for reload case
3317
3318 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3319
3320 if (!result)
3321 return;
3322
3323 do
3324 {
3325 Field* fields = result->Fetch();
3326
3327 uint32 ID = fields[0].Get<uint32>();
3328
3329 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3330 if (locale == LOCALE_enUS)
3331 continue;
3332
3334 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3335 } while (result->NextRow());
3336
3337 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3338}
Definition ItemTemplate.h:850
std::vector< std::string > Name
Definition ItemTemplate.h:851

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

◆ LoadItemSetNames()

void ObjectMgr::LoadItemSetNames ( )
3341{
3342 uint32 oldMSTime = getMSTime();
3343
3344 _itemSetNameStore.clear(); // needed for reload case
3345
3346 std::set<uint32> itemSetItems;
3347
3348 // fill item set member ids
3349 for (uint32 entryId = 0; entryId < sItemSetStore.GetNumRows(); ++entryId)
3350 {
3351 ItemSetEntry const* setEntry = sItemSetStore.LookupEntry(entryId);
3352 if (!setEntry)
3353 continue;
3354
3355 for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
3356 if (setEntry->itemId[i])
3357 itemSetItems.insert(setEntry->itemId[i]);
3358 }
3359
3360 // 0 1 2
3361 QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
3362
3363 if (!result)
3364 {
3365 LOG_WARN("server.loading", ">> Loaded 0 item set names. DB table `item_set_names` is empty.");
3366 LOG_INFO("server.loading", " ");
3367 return;
3368 }
3369
3370 _itemSetNameStore.rehash(result->GetRowCount());
3371 uint32 count = 0;
3372
3373 do
3374 {
3375 Field* fields = result->Fetch();
3376
3377 uint32 entry = fields[0].Get<uint32>();
3378 if (itemSetItems.find(entry) == itemSetItems.end())
3379 {
3380 LOG_ERROR("sql.sql", "Item set name (Entry: {}) not found in ItemSet.dbc, data useless.", entry);
3381 continue;
3382 }
3383
3384 ItemSetNameEntry& data = _itemSetNameStore[entry];
3385 data.name = fields[1].Get<std::string>();
3386
3387 uint32 invType = fields[2].Get<uint8>();
3388 if (invType >= MAX_INVTYPE)
3389 {
3390 LOG_ERROR("sql.sql", "Item set name (Entry: {}) has wrong InventoryType value ({})", entry, invType);
3391 invType = INVTYPE_NON_EQUIP;
3392 }
3393
3394 data.InventoryType = invType;
3395 itemSetItems.erase(entry);
3396 ++count;
3397 } while (result->NextRow());
3398
3399 if (!itemSetItems.empty())
3400 {
3401 ItemTemplate const* pProto;
3402 for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr)
3403 {
3404 uint32 entry = *itr;
3405 // add data from item_template if available
3406 pProto = sObjectMgr->GetItemTemplate(entry);
3407 if (pProto)
3408 {
3409 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, adding data from `item_template`.", entry);
3410 ItemSetNameEntry& data = _itemSetNameStore[entry];
3411 data.name = pProto->Name1;
3412 data.InventoryType = pProto->InventoryType;
3413 ++count;
3414 }
3415 else
3416 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, set will not display properly.", entry);
3417 }
3418 }
3419
3420 LOG_INFO("server.loading", ">> Loaded {} Item Set Names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3421 LOG_INFO("server.loading", " ");
3422}
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
#define MAX_ITEM_SET_ITEMS
Definition DBCStructure.h:1227
@ INVTYPE_NON_EQUIP
Definition ItemTemplate.h:256
#define MAX_INVTYPE
Definition ItemTemplate.h:287
Definition DBCStructure.h:1231
uint32 itemId[MAX_ITEM_SET_ITEMS]
Definition DBCStructure.h:1235
Definition ItemTemplate.h:844
uint32 InventoryType
Definition ItemTemplate.h:846
std::string name
Definition ItemTemplate.h:845
std::string Name1
Definition ItemTemplate.h:624
uint32 InventoryType
Definition ItemTemplate.h:632

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

◆ LoadItemTemplates()

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

◆ LoadLinkedRespawn()

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

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

◆ LoadMailLevelRewards()

void ObjectMgr::LoadMailLevelRewards ( )
9074{
9075 uint32 oldMSTime = getMSTime();
9076
9077 _mailLevelRewardStore.clear(); // for reload case
9078
9079 // 0 1 2 3
9080 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
9081
9082 if (!result)
9083 {
9084 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
9085 LOG_INFO("server.loading", " ");
9086 return;
9087 }
9088
9089 uint32 count = 0;
9090
9091 do
9092 {
9093 Field* fields = result->Fetch();
9094
9095 uint8 level = fields[0].Get<uint8>();
9096 uint32 raceMask = fields[1].Get<uint32>();
9097 uint32 mailTemplateId = fields[2].Get<uint32>();
9098 uint32 senderEntry = fields[3].Get<uint32>();
9099
9100 if (level > MAX_LEVEL)
9101 {
9102 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
9103 continue;
9104 }
9105
9106 if (!(raceMask & RACEMASK_ALL_PLAYABLE))
9107 {
9108 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
9109 continue;
9110 }
9111
9112 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
9113 {
9114 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
9115 continue;
9116 }
9117
9118 if (!GetCreatureTemplate(senderEntry))
9119 {
9120 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);
9121 continue;
9122 }
9123
9124 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
9125
9126 ++count;
9127 } while (result->NextRow());
9128
9129 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9130 LOG_INFO("server.loading", " ");
9131}
#define MAX_LEVEL
Definition DBCEnums.h:39
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
Definition ObjectMgr.h:543

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

◆ LoadModuleStrings()

bool ObjectMgr::LoadModuleStrings ( )
8653{
8654 uint32 oldMSTime = getMSTime();
8655
8656 _moduleStringStore.clear(); // for reload case
8657 QueryResult result = WorldDatabase.Query("SELECT module, id, string FROM module_string");
8658 if (!result)
8659 {
8660 LOG_WARN("server.loading", ">> Loaded 0 module strings. DB table `module_string` is empty.");
8661 LOG_INFO("server.loading", " ");
8662 return false;
8663 }
8664
8665 do
8666 {
8667 Field* fields = result->Fetch();
8668
8669 std::string module = fields[0].Get<std::string>();
8670 uint32 id = fields[1].Get<uint32>();
8671
8672 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
8673 ModuleString& data = _moduleStringStore[pairKey];
8674
8675 AddLocaleString(fields[2].Get<std::string>(), LOCALE_enUS, data.Content);
8676 } while (result->NextRow());
8677
8678 LOG_INFO("server.loading", ">> Loaded {} Module Strings in {} ms", _moduleStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8679 LOG_INFO("server.loading", " ");
8680
8681 return true;
8682}

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

◆ LoadModuleStringsLocale()

bool ObjectMgr::LoadModuleStringsLocale ( )
8685{
8686 uint32 oldMSTime = getMSTime();
8687
8688 QueryResult result = WorldDatabase.Query("SELECT module, id, locale, string FROM module_string_locale");
8689 if (!result)
8690 {
8691 LOG_WARN("server.loading", ">> Loaded 0 module strings locale. DB table `module_string_locale` is empty.");
8692 LOG_INFO("server.loading", " ");
8693 return false;
8694 }
8695
8696 uint32 localeCount = 0;
8697 do
8698 {
8699 Field* fields = result->Fetch();
8700
8701 std::string module = fields[0].Get<std::string>();
8702 uint32 id = fields[1].Get<uint32>();
8703
8704 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
8705 ModuleString& data = _moduleStringStore[pairKey];
8706
8707 ModuleStringContainer::iterator ms = _moduleStringStore.find(pairKey);
8708 if (ms == _moduleStringStore.end())
8709 {
8710 LOG_ERROR("sql.sql", "ModuleString (Module: {} Id: {}) found in table `module_string_locale` but does not exist in `module_string`. Skipped!", module, id);
8711 continue;
8712 }
8713
8714 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
8715 if (locale == LOCALE_enUS)
8716 continue;
8717
8718 AddLocaleString(fields[3].Get<std::string>(), locale, data.Content);
8719 localeCount++;
8720 } while (result->NextRow());
8721
8722 LOG_INFO("server.loading", ">> Loaded {} Module Strings Locales in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
8723 LOG_INFO("server.loading", " ");
8724
8725 return true;
8726}

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

◆ LoadNPCSpellClickSpells()

void ObjectMgr::LoadNPCSpellClickSpells ( )
8006{
8007 uint32 oldMSTime = getMSTime();
8008
8009 _spellClickInfoStore.clear();
8010 // 0 1 2 3
8011 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
8012
8013 if (!result)
8014 {
8015 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
8016 LOG_INFO("server.loading", " ");
8017 return;
8018 }
8019
8020 uint32 count = 0;
8021
8022 do
8023 {
8024 Field* fields = result->Fetch();
8025
8026 uint32 npc_entry = fields[0].Get<uint32>();
8027 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
8028 if (!cInfo)
8029 {
8030 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
8031 continue;
8032 }
8033
8034 uint32 spellid = fields[1].Get<uint32>();
8035 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
8036 if (!spellinfo)
8037 {
8038 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
8039 continue;
8040 }
8041
8042 uint8 userType = fields[3].Get<uint16>();
8043 if (userType >= SPELL_CLICK_USER_MAX)
8044 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
8045
8046 uint8 castFlags = fields[2].Get<uint8>();
8047 SpellClickInfo info;
8048 info.spellId = spellid;
8049 info.castFlags = castFlags;
8050 info.userType = SpellClickUserTypes(userType);
8051 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
8052
8053 ++count;
8054 } while (result->NextRow());
8055
8056 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
8057 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
8058 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
8059 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
8060 {
8061 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
8062 {
8063 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);
8064 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
8065 }
8066 }
8067
8068 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8069 LOG_INFO("server.loading", " ");
8070}
SpellClickUserTypes
Definition SharedDefines.h:680
@ SPELL_CLICK_USER_MAX
Definition SharedDefines.h:685
@ UNIT_NPC_FLAG_SPELLCLICK
Definition UnitDefines.h:339
Definition ObjectMgr.h:398
uint32 spellId
Definition ObjectMgr.h:399

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

◆ LoadNpcTextLocales()

void ObjectMgr::LoadNpcTextLocales ( )
6095{
6096 uint32 oldMSTime = getMSTime();
6097
6098 _npcTextLocaleStore.clear(); // need for reload case
6099
6100 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6101 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6102 "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 "
6103 "FROM npc_text_locale");
6104
6105 if (!result)
6106 return;
6107
6108 do
6109 {
6110 Field* fields = result->Fetch();
6111
6112 uint32 ID = fields[0].Get<uint32>();
6113
6114 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6115 if (locale == LOCALE_enUS)
6116 continue;
6117
6119 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6120 {
6121 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6122 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6123 }
6124 } while (result->NextRow());
6125
6126 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6127}
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 ( )
5842{
5843 uint32 oldMSTime = getMSTime();
5844
5845 _pageTextLocaleStore.clear(); // need for reload case
5846
5847 // 0 1 2
5848 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
5849
5850 if (!result)
5851 {
5852 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text_locale` is empty!");
5853 LOG_INFO("server.loading", " ");
5854 return;
5855 }
5856
5857 do
5858 {
5859 Field* fields = result->Fetch();
5860
5861 uint32 ID = fields[0].Get<uint32>();
5862
5863 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5864 if (locale == LOCALE_enUS)
5865 continue;
5866
5868 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
5869 } while (result->NextRow());
5870
5871 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5872}
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 ( )
5792{
5793 uint32 oldMSTime = getMSTime();
5794
5795 // 0 1 2
5796 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
5797
5798 if (!result)
5799 {
5800 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
5801 LOG_INFO("server.loading", " ");
5802 return;
5803 }
5804
5805 uint32 count = 0;
5806 do
5807 {
5808 Field* fields = result->Fetch();
5809
5810 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
5811
5812 pageText.Text = fields[1].Get<std::string>();
5813 pageText.NextPage = fields[2].Get<uint32>();
5814
5815 ++count;
5816 } while (result->NextRow());
5817
5818 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
5819 {
5820 if (itr->second.NextPage)
5821 {
5822 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
5823 if (itr2 == _pageTextStore.end())
5824 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
5825 }
5826 }
5827
5828 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5829 LOG_INFO("server.loading", " ");
5830}
Definition ObjectMgr.h:57
std::string Text
Definition ObjectMgr.h:58
uint32 NextPage
Definition ObjectMgr.h:59

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

◆ LoadPetLevelInfo()

void ObjectMgr::LoadPetLevelInfo ( )
3581{
3582 uint32 oldMSTime = getMSTime();
3583
3584 // 0 1 2 3 4 5 6 7 8 9 10 11
3585 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
3586
3587 if (!result)
3588 {
3589 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
3590 LOG_INFO("server.loading", " ");
3591 return;
3592 }
3593
3594 uint32 count = 0;
3595
3596 do
3597 {
3598 Field* fields = result->Fetch();
3599
3600 uint32 creature_id = fields[0].Get<uint32>();
3601 if (!sObjectMgr->GetCreatureTemplate(creature_id))
3602 {
3603 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
3604 continue;
3605 }
3606
3607 uint32 current_level = fields[1].Get<uint8>();
3608 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3609 {
3610 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
3611 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
3612 else
3613 {
3614 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
3615 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
3616 }
3617 continue;
3618 }
3619 else if (current_level < 1)
3620 {
3621 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
3622 continue;
3623 }
3624
3625 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
3626
3627 if (!pInfoMapEntry)
3628 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
3629
3630 // data for level 1 stored in [0] array element, ...
3631 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
3632
3633 pLevelInfo->health = fields[2].Get<uint32>();
3634 pLevelInfo->mana = fields[3].Get<uint32>();
3635 pLevelInfo->armor = fields[9].Get<uint32>();
3636 pLevelInfo->min_dmg = fields[10].Get<uint32>();
3637 pLevelInfo->max_dmg = fields[11].Get<uint32>();
3638 for (uint8 i = 0; i < MAX_STATS; i++)
3639 {
3640 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
3641 }
3642
3643 ++count;
3644 } while (result->NextRow());
3645
3646 // Fill gaps and check integrity
3647 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
3648 {
3649 PetLevelInfo* pInfo = itr->second;
3650
3651 // fatal error if no level 1 data
3652 if (!pInfo || pInfo[0].health == 0)
3653 {
3654 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
3655 exit(1);
3656 }
3657
3658 // fill level gaps
3659 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
3660 {
3661 if (pInfo[level].health == 0)
3662 {
3663 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
3664 pInfo[level] = pInfo[level - 1];
3665 }
3666 }
3667 }
3668
3669 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3670 LOG_INFO("server.loading", " ");
3671}
#define STRONG_MAX_LEVEL
Definition DBCEnums.h:43
#define MAX_STATS
Definition SharedDefines.h:265
Definition ObjectMgr.h:528
uint32 max_dmg
Definition ObjectMgr.h:539
uint32 mana
Definition ObjectMgr.h:536
uint32 min_dmg
Definition ObjectMgr.h:538
uint32 health
Definition ObjectMgr.h:535
std::array< uint32, MAX_STATS > stats
Definition ObjectMgr.h:534
uint32 armor
Definition ObjectMgr.h:537

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

◆ LoadPetNames()

void ObjectMgr::LoadPetNames ( )
7512{
7513 uint32 oldMSTime = getMSTime();
7514 // 0 1 2
7515 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
7516
7517 if (!result)
7518 {
7519 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
7520 LOG_INFO("server.loading", " ");
7521 return;
7522 }
7523
7524 uint32 count = 0;
7525
7526 do
7527 {
7528 Field* fields = result->Fetch();
7529 std::string word = fields[0].Get<std::string>();
7530 uint32 entry = fields[1].Get<uint32>();
7531 bool half = fields[2].Get<bool>();
7532 if (half)
7533 _petHalfName1[entry].push_back(word);
7534 else
7535 _petHalfName0[entry].push_back(word);
7536 ++count;
7537 } while (result->NextRow());
7538
7539 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7540 LOG_INFO("server.loading", " ");
7541}

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

◆ LoadPetNamesLocales()

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

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

◆ LoadPetNumber()

void ObjectMgr::LoadPetNumber ( )
7544{
7545 uint32 oldMSTime = getMSTime();
7546
7547 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
7548 if (result)
7549 {
7550 Field* fields = result->Fetch();
7551 _hiPetNumber = fields[0].Get<uint32>() + 1;
7552 }
7553
7554 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
7555 LOG_INFO("server.loading", " ");
7556}

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

◆ LoadPlayerInfo()

void ObjectMgr::LoadPlayerInfo ( )
3720{
3721 // Load playercreate
3722 {
3723 uint32 oldMSTime = getMSTime();
3724 // 0 1 2 3 4 5 6
3725 QueryResult result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
3726
3727 if (!result)
3728 {
3729 LOG_INFO("server.loading", " ");
3730 LOG_WARN("server.loading", ">> Loaded 0 player create definitions. DB table `playercreateinfo` is empty.");
3731 exit(1);
3732 }
3733 else
3734 {
3735 uint32 count = 0;
3736
3737 do
3738 {
3739 Field* fields = result->Fetch();
3740
3741 uint32 current_race = fields[0].Get<uint8>();
3742 uint32 current_class = fields[1].Get<uint8>();
3743 uint32 mapId = fields[2].Get<uint16>();
3744 uint32 areaId = fields[3].Get<uint32>(); // zone
3745 float positionX = fields[4].Get<float>();
3746 float positionY = fields[5].Get<float>();
3747 float positionZ = fields[6].Get<float>();
3748 float orientation = fields[7].Get<float>();
3749
3750 if (current_race >= MAX_RACES)
3751 {
3752 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3753 continue;
3754 }
3755
3756 ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
3757 if (!rEntry)
3758 {
3759 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3760 continue;
3761 }
3762
3763 if (current_class >= MAX_CLASSES)
3764 {
3765 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3766 continue;
3767 }
3768
3769 if (!sChrClassesStore.LookupEntry(current_class))
3770 {
3771 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3772 continue;
3773 }
3774
3775 // accept DB data only for valid position (and non instanceable)
3776 if (!MapMgr::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation))
3777 {
3778 LOG_ERROR("sql.sql", "Wrong home position for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3779 continue;
3780 }
3781
3782 if (sMapStore.LookupEntry(mapId)->Instanceable())
3783 {
3784 LOG_ERROR("sql.sql", "Home position in instanceable map for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3785 continue;
3786 }
3787
3788 PlayerInfo* info = new PlayerInfo();
3789 info->mapId = mapId;
3790 info->areaId = areaId;
3791 info->positionX = positionX;
3792 info->positionY = positionY;
3793 info->positionZ = positionZ;
3794 info->orientation = orientation;
3795 info->displayId_m = rEntry->model_m;
3796 info->displayId_f = rEntry->model_f;
3797 _playerInfo[current_race][current_class] = info;
3798
3799 ++count;
3800 } while (result->NextRow());
3801
3802 LOG_INFO("server.loading", ">> Loaded {} Player Create Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3803 LOG_INFO("server.loading", " ");
3804 }
3805 }
3806
3807 // Load playercreate items
3808 LOG_INFO("server.loading", "Loading Player Create Items Data...");
3809 {
3810 uint32 oldMSTime = getMSTime();
3811 // 0 1 2 3
3812 QueryResult result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
3813
3814 if (!result)
3815 {
3816 LOG_WARN("server.loading", ">> Loaded 0 Custom Player Create Items. DB Table `playercreateinfo_item` Is Empty.");
3817 LOG_INFO("server.loading", " ");
3818 }
3819 else
3820 {
3821 uint32 count = 0;
3822
3823 do
3824 {
3825 Field* fields = result->Fetch();
3826
3827 uint32 current_race = fields[0].Get<uint8>();
3828 if (current_race >= MAX_RACES)
3829 {
3830 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_item` table, ignoring.", current_race);
3831 continue;
3832 }
3833
3834 uint32 current_class = fields[1].Get<uint8>();
3835 if (current_class >= MAX_CLASSES)
3836 {
3837 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_item` table, ignoring.", current_class);
3838 continue;
3839 }
3840
3841 uint32 item_id = fields[2].Get<uint32>();
3842
3843 if (!GetItemTemplate(item_id))
3844 {
3845 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);
3846 continue;
3847 }
3848
3849 int32 amount = fields[3].Get<int32>();
3850
3851 if (!amount)
3852 {
3853 LOG_ERROR("sql.sql", "Item id {} (class {} race {}) have amount == 0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class);
3854 continue;
3855 }
3856
3857 if (!current_race || !current_class)
3858 {
3859 uint32 min_race = current_race ? current_race : 1;
3860 uint32 max_race = current_race ? current_race + 1 : MAX_RACES;
3861 uint32 min_class = current_class ? current_class : 1;
3862 uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
3863 for (uint32 r = min_race; r < max_race; ++r)
3864 for (uint32 c = min_class; c < max_class; ++c)
3865 PlayerCreateInfoAddItemHelper(r, c, item_id, amount);
3866 }
3867 else
3868 PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount);
3869
3870 ++count;
3871 } while (result->NextRow());
3872
3873 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3874 LOG_INFO("server.loading", " ");
3875 }
3876 }
3877
3878 // Load playercreate skills
3879 LOG_INFO("server.loading", "Loading Player Create Skill Data...");
3880 {
3881 uint32 oldMSTime = getMSTime();
3882
3883 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, skill, `rank` FROM playercreateinfo_skills");
3884
3885 if (!result)
3886 {
3887 LOG_WARN("server.loading", ">> Loaded 0 Player Create Skills. DB Table `playercreateinfo_skills` Is Empty.");
3888 }
3889 else
3890 {
3891 uint32 count = 0;
3892
3893 do
3894 {
3895 Field* fields = result->Fetch();
3896 uint32 raceMask = fields[0].Get<uint32>();
3897 uint32 classMask = fields[1].Get<uint32>();
3899 skill.SkillId = fields[2].Get<uint16>();
3900 skill.Rank = fields[3].Get<uint16>();
3901
3902 if (skill.Rank >= MAX_SKILL_STEP)
3903 {
3904 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);
3905 continue;
3906 }
3907
3908 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3909 {
3910 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_skills` table, ignoring.", raceMask);
3911 continue;
3912 }
3913
3914 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3915 {
3916 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_skills` table, ignoring.", classMask);
3917 continue;
3918 }
3919
3920 if (!sSkillLineStore.LookupEntry(skill.SkillId))
3921 {
3922 LOG_ERROR("sql.sql", "Wrong skill id {} in `playercreateinfo_skills` table, ignoring.", skill.SkillId);
3923 continue;
3924 }
3925
3926 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3927 {
3928 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3929 {
3930 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3931 {
3932 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3933 {
3934 if (!GetSkillRaceClassInfo(skill.SkillId, raceIndex, classIndex))
3935 continue;
3936
3937 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3938 {
3939 info->skills.push_back(skill);
3940 ++count;
3941 }
3942 }
3943 }
3944 }
3945 }
3946 } while (result->NextRow());
3947
3948 LOG_INFO("server.loading", ">> Loaded {} Player Create Skills in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3949 LOG_INFO("server.loading", " ");
3950 }
3951 }
3952
3953 // Load playercreate spells
3954 LOG_INFO("server.loading", "Loading Player Create Spell Data...");
3955 {
3956 uint32 oldMSTime = getMSTime();
3957
3958 QueryResult result = WorldDatabase.Query("SELECT racemask, classmask, Spell FROM playercreateinfo_spell_custom");
3959
3960 if (!result)
3961 {
3962 LOG_WARN("server.loading", ">> Loaded 0 player create spells. DB table `playercreateinfo_spell_custom` is empty.");
3963 }
3964 else
3965 {
3966 uint32 count = 0;
3967
3968 do
3969 {
3970 Field* fields = result->Fetch();
3971 uint32 raceMask = fields[0].Get<uint32>();
3972 uint32 classMask = fields[1].Get<uint32>();
3973 uint32 spellId = fields[2].Get<uint32>();
3974
3975 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3976 {
3977 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_spell_custom` table, ignoring.", raceMask);
3978 continue;
3979 }
3980
3981 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3982 {
3983 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_spell_custom` table, ignoring.", classMask);
3984 continue;
3985 }
3986
3987 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3988 {
3989 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3990 {
3991 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3992 {
3993 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3994 {
3995 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3996 {
3997 info->customSpells.push_back(spellId);
3998 ++count;
3999 }
4000 }
4001 }
4002 }
4003 }
4004 } while (result->NextRow());
4005
4006 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4007 LOG_INFO("server.loading", " ");
4008 }
4009 }
4010
4011 // Load playercreate cast spell
4012 LOG_INFO("server.loading", "Loading Player Create Cast Spell Data...");
4013 {
4014 uint32 oldMSTime = getMSTime();
4015
4016 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
4017
4018 if (!result)
4019 {
4020 LOG_WARN("server.loading", ">> Loaded 0 Player Create Cast Spells. DB Table `playercreateinfo_cast_spell` Is Empty.");
4021 }
4022 else
4023 {
4024 uint32 count = 0;
4025
4026 do
4027 {
4028 Field* fields = result->Fetch();
4029 uint32 raceMask = fields[0].Get<uint32>();
4030 uint32 classMask = fields[1].Get<uint32>();
4031 uint32 spellId = fields[2].Get<uint32>();
4032
4033 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
4034 {
4035 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
4036 continue;
4037 }
4038
4039 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4040 {
4041 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
4042 continue;
4043 }
4044
4045 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
4046 {
4047 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4048 {
4049 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4050 {
4051 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4052 {
4053 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4054 {
4055 info->castSpells.push_back(spellId);
4056 ++count;
4057 }
4058 }
4059 }
4060 }
4061 }
4062 } while (result->NextRow());
4063
4064 LOG_INFO("server.loading", ">> Loaded {} Player Create Cast Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4065 LOG_INFO("server.loading", " ");
4066 }
4067 }
4068
4069 // Load playercreate actions
4070 LOG_INFO("server.loading", "Loading Player Create Action Data...");
4071 {
4072 uint32 oldMSTime = getMSTime();
4073
4074 // 0 1 2 3 4
4075 QueryResult result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
4076
4077 if (!result)
4078 {
4079 LOG_WARN("server.loading", ">> Loaded 0 Player Create Actions. DB Table `playercreateinfo_action` Is Empty.");
4080 LOG_INFO("server.loading", " ");
4081 }
4082 else
4083 {
4084 uint32 count = 0;
4085
4086 do
4087 {
4088 Field* fields = result->Fetch();
4089
4090 uint32 current_race = fields[0].Get<uint8>();
4091 if (current_race >= MAX_RACES)
4092 {
4093 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_action` table, ignoring.", current_race);
4094 continue;
4095 }
4096
4097 uint32 current_class = fields[1].Get<uint8>();
4098 if (current_class >= MAX_CLASSES)
4099 {
4100 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_action` table, ignoring.", current_class);
4101 continue;
4102 }
4103
4104 if (PlayerInfo* info = _playerInfo[current_race][current_class])
4105 info->action.push_back(PlayerCreateInfoAction(fields[2].Get<uint16>(), fields[3].Get<uint32>(), fields[4].Get<uint16>()));
4106
4107 ++count;
4108 } while (result->NextRow());
4109
4110 LOG_INFO("server.loading", ">> Loaded {} Player Create Actions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4111 LOG_INFO("server.loading", " ");
4112 }
4113 }
4114
4115 // Loading levels data (class/race dependent)
4116 LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
4117 {
4118 struct RaceStats
4119 {
4120 int16 StatModifier[MAX_STATS];
4121 };
4122
4123 std::array<RaceStats, MAX_RACES> raceStatModifiers;
4124
4125 uint32 oldMSTime = getMSTime();
4126
4127 // 0 1 2 3 4 5
4128 QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
4129
4130 if (!raceStatsResult)
4131 {
4132 LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
4133 LOG_INFO("server.loading", " ");
4134 exit(1);
4135 }
4136
4137 do
4138 {
4139 Field* fields = raceStatsResult->Fetch();
4140
4141 uint32 current_race = fields[0].Get<uint8>();
4142 if (current_race >= MAX_RACES)
4143 {
4144 LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
4145 continue;
4146 }
4147
4148 for (uint32 i = 0; i < MAX_STATS; ++i)
4149 raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
4150
4151 } while (raceStatsResult->NextRow());
4152
4153 // 0 1 2 3 4 5 6 7 8
4154 QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit, BaseHP, BaseMana FROM player_class_stats");
4155
4156 if (!result)
4157 {
4158 LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
4159 exit(1);
4160 }
4161
4162 uint32 count = 0;
4163
4164 do
4165 {
4166 Field* fields = result->Fetch();
4167
4168 uint32 current_class = fields[0].Get<uint8>();
4169 if (current_class >= MAX_CLASSES)
4170 {
4171 LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
4172 continue;
4173 }
4174
4175 uint32 current_level = fields[1].Get<uint8>();
4176 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4177 {
4178 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4179 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4180 else
4181 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
4182
4183 continue;
4184 }
4185
4186 for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
4187 {
4188 if (PlayerInfo* info = _playerInfo[race][current_class])
4189 {
4190 if (!info->levelInfo)
4191 info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4192
4193 PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4194 for (int i = 0; i < MAX_STATS; ++i)
4195 levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
4196 }
4197 }
4198
4199 PlayerClassInfo* info = _playerClassInfo[current_class];
4200 if (!info)
4201 {
4202 info = new PlayerClassInfo();
4204 _playerClassInfo[current_class] = info;
4205 }
4206
4207 PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4208
4209 levelInfo.basehealth = fields[7].Get<uint32>();
4210 levelInfo.basemana = fields[8].Get<uint32>();
4211
4212 ++count;
4213 } while (result->NextRow());
4214
4215 // Fill gaps and check integrity
4216 for (int race = 0; race < MAX_RACES; ++race)
4217 {
4218 // skip non existed races
4219 if (!sChrRacesStore.LookupEntry(race))
4220 continue;
4221
4222 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4223 {
4224 // skip non existed classes
4225 if (!sChrClassesStore.LookupEntry(class_))
4226 continue;
4227
4228 PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
4229 PlayerInfo* info = _playerInfo[race][class_];
4230 if (!info)
4231 continue;
4232
4233 // skip expansion races if not playing with expansion
4234 if (sWorld->getIntConfig(CONFIG_EXPANSION) < EXPANSION_THE_BURNING_CRUSADE && (race == RACE_BLOODELF || race == RACE_DRAENEI))
4235 continue;
4236
4237 // skip expansion classes if not playing with expansion
4239 continue;
4240
4241 // fatal error if no initial stats data
4242 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))
4243 {
4244 LOG_ERROR("sql.sql", "Race {} class {} initial level does not have stats data!", race, class_);
4245 exit(1);
4246 }
4247
4248 // fatal error if no initial health/mana data
4249 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))
4250 {
4251 LOG_ERROR("sql.sql", "Class {} initial level does not have health/mana data!", class_);
4252 exit(1);
4253 }
4254
4255 // fill level gaps for stats
4256 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4257 {
4258 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))
4259 {
4260 LOG_ERROR("sql.sql", "Race {} class {} level {} does not have stats data. Using stats data of level {}.", race, class_, level + 1, level);
4261 info->levelInfo[level] = info->levelInfo[level - 1];
4262 }
4263 }
4264
4265 // fill level gaps for health/mana
4266 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4267 {
4268 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))
4269 {
4270 LOG_ERROR("sql.sql", "Class {} level {} does not have health/mana data. Using stats data of level {}.", class_, level + 1, level);
4271 pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1];
4272 }
4273 }
4274 }
4275 }
4276
4277 LOG_INFO("server.loading", ">> Loaded {} Level Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4278 LOG_INFO("server.loading", " ");
4279 }
4280
4281 // Loading xp per level data
4282 LOG_INFO("server.loading", "Loading Player Create XP Data...");
4283 {
4284 uint32 oldMSTime = getMSTime();
4285
4286 _playerXPperLevel.resize(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
4287 for (uint8 level = 0; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4288 _playerXPperLevel[level] = 0;
4289
4290 // 0 1
4291 QueryResult result = WorldDatabase.Query("SELECT Level, Experience FROM player_xp_for_level");
4292
4293 if (!result)
4294 {
4295 LOG_WARN("server.loading", ">> Loaded 0 xp for level definitions. DB table `player_xp_for_level` is empty.");
4296 LOG_INFO("server.loading", " ");
4297 exit(1);
4298 }
4299
4300 uint32 count = 0;
4301
4302 do
4303 {
4304 Field* fields = result->Fetch();
4305
4306 uint32 current_level = fields[0].Get<uint8>();
4307 uint32 current_xp = fields[1].Get<uint32>();
4308
4309 if (current_level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4310 {
4311 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4312 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4313 else
4314 {
4315 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_xp_for_levels` table, ignoring.", current_level);
4316 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4317 }
4318 continue;
4319 }
4320 //PlayerXPperLevel
4321 _playerXPperLevel[current_level] = current_xp;
4322 ++count;
4323 } while (result->NextRow());
4324
4325 // fill level gaps
4326 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4327 {
4328 if (_playerXPperLevel[level] == 0)
4329 {
4330 LOG_ERROR("sql.sql", "Level {} does not have XP for level data. Using data of level [{}] + 100.", level + 1, level);
4331 _playerXPperLevel[level] = _playerXPperLevel[level - 1] + 100;
4332 }
4333 }
4334
4335 LOG_INFO("server.loading", ">> Loaded {} XP For Level Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4336 LOG_INFO("server.loading", " ");
4337 }
4338}
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition DBCStores.cpp:895
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
#define MAX_SKILL_STEP
Definition DBCStructure.h:1579
@ CONFIG_START_HEROIC_PLAYER_LEVEL
Definition IWorld.h:238
@ CONFIG_START_PLAYER_LEVEL
Definition IWorld.h:237
@ CONFIG_EXPANSION
Definition IWorld.h:275
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:146
@ RACE_DRAENEI
Definition SharedDefines.h:81
@ RACE_BLOODELF
Definition SharedDefines.h:80
@ RACE_HUMAN
Definition SharedDefines.h:71
@ EXPANSION_THE_BURNING_CRUSADE
Definition SharedDefines.h:54
@ EXPANSION_WRATH_OF_THE_LICH_KING
Definition SharedDefines.h:55
void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count)
Definition ObjectMgr.cpp:3685
Definition DBCStructure.h:678
uint32 model_f
Definition DBCStructure.h:684
uint32 model_m
Definition DBCStructure.h:683
Definition Player.h:294
uint32 basehealth
Definition Player.h:296
uint32 basemana
Definition Player.h:297
Definition Player.h:320
Definition Player.h:332
uint16 SkillId
Definition Player.h:333
float orientation
Definition Player.h:349
uint16 displayId_m
Definition Player.h:350
float positionX
Definition Player.h:346
uint32 areaId
Definition Player.h:345
float positionY
Definition Player.h:347
float positionZ
Definition Player.h:348
uint32 mapId
Definition Player.h:344
uint16 displayId_f
Definition Player.h:351
Definition Player.h:308

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

◆ LoadPointOfInterestLocales()

void ObjectMgr::LoadPointOfInterestLocales ( )
494{
495 uint32 oldMSTime = getMSTime();
496
497 _pointOfInterestLocaleStore.clear(); // need for reload case
498
499 // 0 1 2
500 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale");
501
502 if (!result)
503 return;
504
505 do
506 {
507 Field* fields = result->Fetch();
508
509 uint32 ID = fields[0].Get<uint32>();
510
511 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
512 if (locale == LOCALE_enUS)
513 continue;
514
516 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
517 } while (result->NextRow());
518
519 LOG_INFO("server.loading", ">> Loaded {} Points Of Interest Locale Strings in {} ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
520}
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 ( )
7875{
7876 uint32 oldMSTime = getMSTime();
7877
7878 _pointsOfInterestStore.clear(); // need for reload case
7879
7880 uint32 count = 0;
7881
7882 // 0 1 2 3 4 5 6
7883 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
7884
7885 if (!result)
7886 {
7887 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
7888 LOG_INFO("server.loading", " ");
7889 return;
7890 }
7891
7892 do
7893 {
7894 Field* fields = result->Fetch();
7895
7896 uint32 point_id = fields[0].Get<uint32>();
7897
7898 PointOfInterest POI;
7899 POI.ID = point_id;
7900 POI.PositionX = fields[1].Get<float>();
7901 POI.PositionY = fields[2].Get<float>();
7902 POI.Icon = fields[3].Get<uint32>();
7903 POI.Flags = fields[4].Get<uint32>();
7904 POI.Importance = fields[5].Get<uint32>();
7905 POI.Name = fields[6].Get<std::string>();
7906
7907 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
7908 {
7909 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
7910 continue;
7911 }
7912
7913 _pointsOfInterestStore[point_id] = POI;
7914
7915 ++count;
7916 } while (result->NextRow());
7917
7918 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7919 LOG_INFO("server.loading", " ");
7920}
bool IsValidMapCoord(float c)
Definition GridDefines.h:206
Definition ObjectMgr.h:588
uint32 ID
Definition ObjectMgr.h:589

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

◆ LoadProfanityNamesFromDB()

void ObjectMgr::LoadProfanityNamesFromDB ( )
8297{
8298 uint32 oldMSTime = getMSTime();
8299
8300 _profanityNamesStore.clear(); // need for reload case
8301
8302 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
8303
8304 if (!result)
8305 {
8306 LOG_WARN("server.loading", ">> Loaded 0 profanity names. DB table `profanity_name` is empty!");
8307 return;
8308 }
8309
8310 uint32 count = 0;
8311
8312 Field* fields;
8313 do
8314 {
8315 fields = result->Fetch();
8316 std::string name = fields[0].Get<std::string>();
8317
8318 std::wstring wstr;
8319 if (!Utf8toWStr (name, wstr))
8320 {
8321 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
8322 continue;
8323 }
8324
8325 wstrToLower(wstr);
8326
8327 _profanityNamesStore.insert(wstr);
8328 ++count;
8329 } while (result->NextRow());
8330
8331 LOG_INFO("server.loading", ">> Loaded {} profanity names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8332}

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

◆ LoadProfanityNamesFromDBC()

void ObjectMgr::LoadProfanityNamesFromDBC ( )
8335{
8336 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8337 {
8338 LOG_WARN("server.loading", ">> Loaded 0 profanity names from DBC. Config option disabled.");
8339 return;
8340 }
8341
8342 uint32 oldMSTime = getMSTime();
8343
8344 uint32 count = 0;
8345
8346 for (NamesProfanityEntry const* profanityStore : sNamesProfanityStore)
8347 {
8348 std::wstring wstr;
8349
8350 Utf8toWStr(profanityStore->Pattern, wstr);
8351
8352 // DBC does not have clean entries, remove the junk.
8353 boost::algorithm::replace_all(wstr, "\\<", "");
8354 boost::algorithm::replace_all(wstr, "\\>", "");
8355
8356 _profanityNamesStore.insert(wstr);
8357 count++;
8358 }
8359
8360 LOG_INFO("server.loading", ">> Loaded {} profanity names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8361 LOG_INFO("server.loading", " ");
8362}
DBCStorage< NamesProfanityEntry > sNamesProfanityStore(NamesProfanityfmt)
@ CONFIG_STRICT_NAMES_PROFANITY
Definition IWorld.h:179
Definition DBCStructure.h:1404

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

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6253{
6254 uint32 oldMSTime = getMSTime();
6255
6256 _questAreaTriggerStore.clear(); // need for reload case
6257
6258 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6259
6260 if (!result)
6261 {
6262 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6263 LOG_INFO("server.loading", " ");
6264 return;
6265 }
6266
6267 uint32 count = 0;
6268
6269 do
6270 {
6271 ++count;
6272
6273 Field* fields = result->Fetch();
6274
6275 uint32 trigger_ID = fields[0].Get<uint32>();
6276 uint32 quest_ID = fields[1].Get<uint32>();
6277
6278 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6279 if (!atEntry)
6280 {
6281 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6282 continue;
6283 }
6284
6285 Quest const* quest = GetQuestTemplate(quest_ID);
6286
6287 if (!quest)
6288 {
6289 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6290 continue;
6291 }
6292
6294 {
6295 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);
6296
6297 // this will prevent quest completing without objective
6298 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6299
6300 // continue; - quest modified to required objective and trigger can be allowed.
6301 }
6302
6303 _questAreaTriggerStore[trigger_ID] = quest_ID;
6304 } while (result->NextRow());
6305
6306 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6307 LOG_INFO("server.loading", " ");
6308}
@ 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 ( )
6329{
6330 uint32 oldMSTime = getMSTime();
6331
6332 _questGreetingStore.clear(); // For reload case
6333
6334 // 0 1 2 3 4
6335 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6336 if (!result)
6337 {
6338 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6339 return;
6340 }
6341
6342 do
6343 {
6344 Field* fields = result->Fetch();
6345
6346 uint32 id = fields[0].Get<uint32>();
6347 uint8 type = fields[1].Get<uint8>();
6348 switch (type)
6349 {
6350 case 0: // Creature
6351 if (!sObjectMgr->GetCreatureTemplate(id))
6352 {
6353 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6354 continue;
6355 }
6356 break;
6357 case 1: // GameObject
6358 if (!sObjectMgr->GetGameObjectTemplate(id))
6359 {
6360 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6361 continue;
6362 }
6363 break;
6364 default:
6365 LOG_ERROR("sql.sql", "Table `quest_greeting` has unknown type {} for id {}, skipped.", type, id);
6366 continue;
6367 }
6368
6369 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6370 QuestGreeting& data = _questGreetingStore[pairKey];
6371
6372 data.EmoteType = fields[2].Get<uint16>();
6373 data.EmoteDelay = fields[3].Get<uint32>();
6374 AddLocaleString(fields[4].Get<std::string>(), LOCALE_enUS, data.Greeting);
6375 }
6376 while (result->NextRow());
6377
6378 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", _questGreetingStore.size(), GetMSTimeDiffToNow(oldMSTime));
6379 LOG_INFO("server.loading", " ");
6380}
Definition ObjectMgr.h:599
uint32 EmoteDelay
Definition ObjectMgr.h:601
std::vector< std::string > Greeting
Definition ObjectMgr.h:602
uint16 EmoteType
Definition ObjectMgr.h:600

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

◆ LoadQuestGreetingsLocales()

void ObjectMgr::LoadQuestGreetingsLocales ( )
6383{
6384 uint32 oldMSTime = getMSTime();
6385
6386 // 0 1 2 3
6387 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6388 if (!result)
6389 {
6390 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
6391 return;
6392 }
6393
6394 uint32 localeCount = 0;
6395 do
6396 {
6397 Field* fields = result->Fetch();
6398
6399 uint32 id = fields[0].Get<uint32>();
6400 uint8 type = fields[1].Get<uint8>();
6401 switch (type)
6402 {
6403 case 0: // Creature
6404 if (!sObjectMgr->GetCreatureTemplate(id))
6405 {
6406 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
6407 continue;
6408 }
6409 break;
6410 case 1: // GameObject
6411 if (!sObjectMgr->GetGameObjectTemplate(id))
6412 {
6413 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
6414 continue;
6415 }
6416 break;
6417 default:
6418 continue;
6419 }
6420
6421 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6422 QuestGreeting& data = _questGreetingStore[pairKey];
6423
6424 QuestGreetingContainer::iterator qgc = _questGreetingStore.find(pairKey);
6425 if (qgc == _questGreetingStore.end())
6426 {
6427 LOG_ERROR("sql.sql", "QuestGreeting (Id: {} Type: {}) found in table `quest_greeting_locale` but does not exist in `quest_greeting`. Skipped!", id, type);
6428 continue;
6429 }
6430
6431 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
6432 if (locale == LOCALE_enUS)
6433 continue;
6434
6435 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
6436 localeCount++;
6437 } while (result->NextRow());
6438
6439 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
6440 LOG_INFO("server.loading", " ");
6441}

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

◆ LoadQuestLocales()

void ObjectMgr::LoadQuestLocales ( )
5213{
5214 uint32 oldMSTime = getMSTime();
5215
5216 _questLocaleStore.clear(); // need for reload case
5217
5218 // 0 1 2 3 4 5 6 7 8 9 10
5219 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5220
5221 if (!result)
5222 return;
5223
5224 do
5225 {
5226 Field* fields = result->Fetch();
5227
5228 uint32 ID = fields[0].Get<uint32>();
5229
5230 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5231 if (locale == LOCALE_enUS)
5232 continue;
5233
5234 QuestLocale& data = _questLocaleStore[ID];
5235 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5236 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5237 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5238 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5239 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5240
5241 for (uint8 i = 0; i < 4; ++i)
5242 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5243 } while (result->NextRow());
5244
5245 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5246}
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 ( )
10254{
10255 uint32 oldMSTime = getMSTime();
10256
10257 _questMoneyRewards.clear();
10258
10259 // 0 1 2 3 4 5 6 7 8 9 10
10260 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
10261 if (!result)
10262 {
10263 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
10264 return;
10265 }
10266
10267 uint32 count = 0;
10268 do
10269 {
10270 Field* fields = result->Fetch();
10271 uint32 Level = fields[0].Get<uint32>();
10272
10273 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
10274 questMoneyReward.fill(0);
10275
10276 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
10277 {
10278 questMoneyReward[i] = fields[1 + i].Get<uint32>();
10279 ++count;
10280 }
10281 } while (result->NextRow());
10282
10283 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10284 LOG_INFO("server.loading", " ");
10285}
std::array< uint32, MAX_QUEST_MONEY_REWARDS > QuestMoneyRewardArray
Definition ObjectMgr.h:715

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

◆ LoadQuestOfferRewardLocale()

void ObjectMgr::LoadQuestOfferRewardLocale ( )
6444{
6445 uint32 oldMSTime = getMSTime();
6446
6447 _questOfferRewardLocaleStore.clear(); // need for reload case
6448
6449 // 0 1 2
6450 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
6451 if (!result)
6452 return;
6453
6454 do
6455 {
6456 Field* fields = result->Fetch();
6457
6458 uint32 id = fields[0].Get<uint32>();
6459 std::string localeName = fields[1].Get<std::string>();
6460
6461 LocaleConstant locale = GetLocaleByName(localeName);
6462 if (locale == LOCALE_enUS)
6463 continue;
6464
6466 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
6467 } while (result->NextRow());
6468
6469 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6470}
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 ( )
7923{
7924 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
7925 {
7926 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
7927 LOG_INFO("server.loading", " ");
7928 return;
7929 }
7930
7931 uint32 oldMSTime = getMSTime();
7932
7933 _questPOIStore.clear(); // need for reload case
7934
7935 uint32 count = 0;
7936
7937 // 0 1 2 3 4 5 6 7
7938 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
7939
7940 if (!result)
7941 {
7942 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
7943 LOG_INFO("server.loading", " ");
7944 return;
7945 }
7946
7947 // 0 1 2 3
7948 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
7949
7950 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
7951
7952 if (points)
7953 {
7954 // The first result should have the highest questId
7955 Field* fields = points->Fetch();
7956 uint32 questIdMax = fields[0].Get<uint32>();
7957 POIs.resize(questIdMax + 1);
7958
7959 do
7960 {
7961 fields = points->Fetch();
7962
7963 uint32 questId = fields[0].Get<uint32>();
7964 uint32 id = fields[1].Get<uint32>();
7965 int32 x = fields[2].Get<int32>();
7966 int32 y = fields[3].Get<int32>();
7967
7968 if (POIs[questId].size() <= id + 1)
7969 POIs[questId].resize(id + 10);
7970
7971 QuestPOIPoint point(x, y);
7972 POIs[questId][id].push_back(point);
7973 } while (points->NextRow());
7974 }
7975
7976 do
7977 {
7978 Field* fields = result->Fetch();
7979
7980 uint32 questId = fields[0].Get<uint32>();
7981 uint32 id = fields[1].Get<uint32>();
7982 int32 objIndex = fields[2].Get<int32>();
7983 uint32 mapId = fields[3].Get<uint32>();
7984 uint32 WorldMapAreaId = fields[4].Get<uint32>();
7985 uint32 FloorId = fields[5].Get<uint32>();
7986 uint32 unk3 = fields[6].Get<uint32>();
7987 uint32 unk4 = fields[7].Get<uint32>();
7988
7989 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
7990 if (questId < POIs.size() && id < POIs[questId].size())
7991 {
7992 POI.points = POIs[questId][id];
7993 _questPOIStore[questId].push_back(POI);
7994 }
7995 else
7996 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
7997
7998 ++count;
7999 } while (result->NextRow());
8000
8001 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8002 LOG_INFO("server.loading", " ");
8003}
@ CONFIG_QUEST_POI_ENABLED
Definition IWorld.h:172
Definition ObjectMgr.h:638
Definition ObjectMgr.h:647

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

◆ LoadQuestRelationsHelper()

void ObjectMgr::LoadQuestRelationsHelper ( QuestRelations map,
std::string const &  table,
bool  starter,
bool  go 
)
private
8093{
8094 uint32 oldMSTime = getMSTime();
8095
8096 map.clear(); // need for reload case
8097
8098 uint32 count = 0;
8099
8100 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8101
8102 if (!result)
8103 {
8104 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8105 LOG_INFO("server.loading", " ");
8106 return;
8107 }
8108
8109 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8110 if (starter)
8111 poolRelationMap->clear();
8112
8113 do
8114 {
8115 uint32 id = result->Fetch()[0].Get<uint32>();
8116 uint32 quest = result->Fetch()[1].Get<uint32>();
8117 uint32 poolId = result->Fetch()[2].Get<uint32>();
8118
8119 if (_questTemplates.find(quest) == _questTemplates.end())
8120 {
8121 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8122 continue;
8123 }
8124
8125 if (!poolId || !starter)
8126 map.insert(QuestRelations::value_type(id, quest));
8127 else if (starter)
8128 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8129
8130 ++count;
8131 } while (result->NextRow());
8132
8133 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8134 LOG_INFO("server.loading", " ");
8135}
#define sPoolMgr
Definition PoolMgr.h:163
std::multimap< uint32, uint32 > PooledQuestRelation
Definition PoolMgr.h:98

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

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

◆ LoadQuestRequestItemsLocale()

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

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

◆ LoadQuestStartersAndEnders()

void ObjectMgr::LoadQuestStartersAndEnders ( )
inline
949 {
950 LOG_INFO("server.loading", "Loading GO Start Quest Data...");
952 LOG_INFO("server.loading", "Loading GO End Quest Data...");
954 LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
956 LOG_INFO("server.loading", "Loading Creature End Quest Data...");
958 }
void LoadCreatureQuestEnders()
Definition ObjectMgr.cpp:8179
void LoadGameobjectQuestEnders()
Definition ObjectMgr.cpp:8151
void LoadGameobjectQuestStarters()
Definition ObjectMgr.cpp:8137
void LoadCreatureQuestStarters()
Definition ObjectMgr.cpp:8165

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

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
9260{
9261 // find all items from the reference vendor
9263 stmt->SetData(0, uint32(item));
9264 PreparedQueryResult result = WorldDatabase.Query(stmt);
9265
9266 if (!result)
9267 return 0;
9268
9269 uint32 count = 0;
9270 do
9271 {
9272 Field* fields = result->Fetch();
9273
9274 int32 item_id = fields[0].Get<int32>();
9275
9276 // if item is a negative, its a reference
9277 if (item_id < 0)
9278 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
9279 else
9280 {
9281 int32 maxcount = fields[1].Get<uint8>();
9282 uint32 incrtime = fields[2].Get<uint32>();
9283 uint32 ExtendedCost = fields[3].Get<uint32>();
9284
9285 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
9286 continue;
9287
9288 VendorItemData& vList = _cacheVendorItemStore[vendor];
9289
9290 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9291 ++count;
9292 }
9293 } while (result->NextRow());
9294
9295 return count;
9296}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
@ WORLD_SEL_NPC_VENDOR_REF
Definition WorldDatabase.h:45
bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player *player=nullptr, std::set< uint32 > *skip_vendors=nullptr, uint32 ORnpcflag=0) const
Definition ObjectMgr.cpp:9499
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition ObjectMgr.cpp:9259

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 ( )
7684{
7685 uint32 oldMSTime = getMSTime();
7686
7687 // For reload case
7688 _repOnKillStore.clear();
7689
7690 uint32 count = 0;
7691
7692 // 0 1 2
7693 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
7694 // 3 4 5 6 7 8 9
7695 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
7696 "FROM creature_onkill_reputation");
7697
7698 if (!result)
7699 {
7700 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
7701 LOG_INFO("server.loading", " ");
7702 return;
7703 }
7704
7705 do
7706 {
7707 Field* fields = result->Fetch();
7708
7709 uint32 creature_id = fields[0].Get<uint32>();
7710
7711 ReputationOnKillEntry repOnKill;
7712 repOnKill.RepFaction1 = fields[1].Get<int16>();
7713 repOnKill.RepFaction2 = fields[2].Get<int16>();
7714 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
7715 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
7716 repOnKill.RepValue1 = fields[5].Get<float>();
7717 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
7718 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
7719 repOnKill.RepValue2 = fields[8].Get<float>();
7720 repOnKill.TeamDependent = fields[9].Get<uint8>();
7721
7722 if (!GetCreatureTemplate(creature_id))
7723 {
7724 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
7725 continue;
7726 }
7727
7728 if (repOnKill.RepFaction1)
7729 {
7730 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
7731 if (!factionEntry1)
7732 {
7733 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
7734 continue;
7735 }
7736 }
7737
7738 if (repOnKill.RepFaction2)
7739 {
7740 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
7741 if (!factionEntry2)
7742 {
7743 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
7744 continue;
7745 }
7746 }
7747
7748 _repOnKillStore[creature_id] = repOnKill;
7749
7750 ++count;
7751 } while (result->NextRow());
7752
7753 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7754 LOG_INFO("server.loading", " ");
7755}
Definition ObjectMgr.h:568
uint32 RepFaction1
Definition ObjectMgr.h:569

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

◆ LoadReputationRewardRate()

void ObjectMgr::LoadReputationRewardRate ( )
7596{
7597 uint32 oldMSTime = getMSTime();
7598
7599 _repRewardRateStore.clear(); // for reload case
7600
7601 uint32 count = 0; // 0 1 2 3 4 5 6 7
7602 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");
7603 if (!result)
7604 {
7605 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
7606 return;
7607 }
7608
7609 do
7610 {
7611 Field* fields = result->Fetch();
7612
7613 uint32 factionId = fields[0].Get<uint32>();
7614
7615 RepRewardRate repRate;
7616
7617 repRate.questRate = fields[1].Get<float>();
7618 repRate.questDailyRate = fields[2].Get<float>();
7619 repRate.questWeeklyRate = fields[3].Get<float>();
7620 repRate.questMonthlyRate = fields[4].Get<float>();
7621 repRate.questRepeatableRate = fields[5].Get<float>();
7622 repRate.creatureRate = fields[6].Get<float>();
7623 repRate.spellRate = fields[7].Get<float>();
7624
7625 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7626 if (!factionEntry)
7627 {
7628 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
7629 continue;
7630 }
7631
7632 if (repRate.questRate < 0.0f)
7633 {
7634 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
7635 continue;
7636 }
7637
7638 if (repRate.questDailyRate < 0.0f)
7639 {
7640 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
7641 continue;
7642 }
7643
7644 if (repRate.questWeeklyRate < 0.0f)
7645 {
7646 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
7647 continue;
7648 }
7649
7650 if (repRate.questMonthlyRate < 0.0f)
7651 {
7652 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
7653 continue;
7654 }
7655
7656 if (repRate.questRepeatableRate < 0.0f)
7657 {
7658 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
7659 continue;
7660 }
7661
7662 if (repRate.creatureRate < 0.0f)
7663 {
7664 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
7665 continue;
7666 }
7667
7668 if (repRate.spellRate < 0.0f)
7669 {
7670 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
7671 continue;
7672 }
7673
7674 _repRewardRateStore[factionId] = repRate;
7675
7676 ++count;
7677 } while (result->NextRow());
7678
7679 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7680 LOG_INFO("server.loading", " ");
7681}
Definition ObjectMgr.h:557
float questRate
Definition ObjectMgr.h:558

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

◆ LoadReputationSpilloverTemplate()

void ObjectMgr::LoadReputationSpilloverTemplate ( )
7758{
7759 uint32 oldMSTime = getMSTime();
7760
7761 _repSpilloverTemplateStore.clear(); // for reload case
7762
7763 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
7764 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");
7765
7766 if (!result)
7767 {
7768 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
7769 LOG_INFO("server.loading", " ");
7770 return;
7771 }
7772
7773 do
7774 {
7775 Field* fields = result->Fetch();
7776
7777 uint32 factionId = fields[0].Get<uint16>();
7778
7779 RepSpilloverTemplate repTemplate;
7780
7781 repTemplate.faction[0] = fields[1].Get<uint16>();
7782 repTemplate.faction_rate[0] = fields[2].Get<float>();
7783 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
7784 repTemplate.faction[1] = fields[4].Get<uint16>();
7785 repTemplate.faction_rate[1] = fields[5].Get<float>();
7786 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
7787 repTemplate.faction[2] = fields[7].Get<uint16>();
7788 repTemplate.faction_rate[2] = fields[8].Get<float>();
7789 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
7790 repTemplate.faction[3] = fields[10].Get<uint16>();
7791 repTemplate.faction_rate[3] = fields[11].Get<float>();
7792 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
7793 repTemplate.faction[4] = fields[13].Get<uint16>();
7794 repTemplate.faction_rate[4] = fields[14].Get<float>();
7795 repTemplate.faction_rank[4] = fields[15].Get<uint8>();
7796 repTemplate.faction[5] = fields[16].Get<uint16>();
7797 repTemplate.faction_rate[5] = fields[17].Get<float>();
7798 repTemplate.faction_rank[5] = fields[18].Get<uint8>();
7799
7800 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7801
7802 if (!factionEntry)
7803 {
7804 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
7805 continue;
7806 }
7807
7808 if (factionEntry->team == 0)
7809 {
7810 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
7811 continue;
7812 }
7813
7814 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
7815 {
7816 if (repTemplate.faction[i])
7817 {
7818 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
7819
7820 if (!factionSpillover)
7821 {
7822 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);
7823 continue;
7824 }
7825
7826 if (factionSpillover->reputationListID < 0)
7827 {
7828 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);
7829 continue;
7830 }
7831
7832 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
7833 {
7834 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
7835 continue;
7836 }
7837 }
7838 }
7839
7840 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
7841 if (repTemplate.faction[0] && !factionEntry0)
7842 {
7843 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
7844 continue;
7845 }
7846 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
7847 if (repTemplate.faction[1] && !factionEntry1)
7848 {
7849 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
7850 continue;
7851 }
7852 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
7853 if (repTemplate.faction[2] && !factionEntry2)
7854 {
7855 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
7856 continue;
7857 }
7858 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
7859 if (repTemplate.faction[3] && !factionEntry3)
7860 {
7861 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
7862 continue;
7863 }
7864
7865 _repSpilloverTemplateStore[factionId] = repTemplate;
7866
7867 ++count;
7868 } while (result->NextRow());
7869
7870 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7871 LOG_INFO("server.loading", " ");
7872}
#define MAX_SPILLOVER_FACTIONS
Definition SharedDefines.h:247
int32 reputationListID
Definition DBCStructure.h:908
Definition ObjectMgr.h:581
uint32 faction[MAX_SPILLOVER_FACTIONS]
Definition ObjectMgr.h:582

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

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

◆ LoadReservedPlayerNamesDBC()

void ObjectMgr::LoadReservedPlayerNamesDBC ( )
8232{
8233 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8234 {
8235 LOG_WARN("server.loading", ">> Loaded 0 reserved names from DBC. Config option disabled.");
8236 return;
8237 }
8238
8239 uint32 oldMSTime = getMSTime();
8240
8241 uint32 count = 0;
8242
8243 for (NamesReservedEntry const* reservedStore : sNamesReservedStore)
8244 {
8245 std::wstring wstr;
8246
8247 Utf8toWStr(reservedStore->Pattern, wstr);
8248
8249 // DBC does not have clean entries, remove the junk.
8250 boost::algorithm::replace_all(wstr, "\\<", "");
8251 boost::algorithm::replace_all(wstr, "\\>", "");
8252
8253 _reservedNamesStore.insert(wstr);
8254 count++;
8255 }
8256
8257 LOG_INFO("server.loading", ">> Loaded {} reserved names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8258 LOG_INFO("server.loading", " ");
8259}
DBCStorage< NamesReservedEntry > sNamesReservedStore(NamesReservedfmt)
@ CONFIG_STRICT_NAMES_RESERVED
Definition IWorld.h:178
Definition DBCStructure.h:1397

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

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
9580{
9581 uint32 oldMSTime = getMSTime();
9582
9583 // We insert an empty placeholder here so we can use the
9584 // script id 0 as dummy for "no script found".
9585 _scriptNamesStore.emplace_back("");
9586
9587 QueryResult result = WorldDatabase.Query(
9588 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
9589 "UNION "
9590 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
9591 "UNION "
9592 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
9593 "UNION "
9594 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
9595 "UNION "
9596 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
9597 "UNION "
9598 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
9599 "UNION "
9600 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
9601 "UNION "
9602 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
9603 "UNION "
9604 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
9605 "UNION "
9606 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
9607 "UNION "
9608 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
9609 "UNION "
9610 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
9611 "UNION "
9612 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
9613 "UNION "
9614 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
9615
9616 if (!result)
9617 {
9618 LOG_INFO("server.loading", " ");
9619 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
9620 return;
9621 }
9622
9623 _scriptNamesStore.reserve(result->GetRowCount() + 1);
9624
9625 do
9626 {
9627 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
9628 } while (result->NextRow());
9629
9630 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
9631 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
9632 LOG_INFO("server.loading", " ");
9633}

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

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5249{
5250 uint32 oldMSTime = getMSTime();
5251
5252 ScriptMapMap* scripts = GetScriptsMapByType(type);
5253 if (!scripts)
5254 return;
5255
5256 std::string tableName = GetScriptsTableNameByType(type);
5257 if (tableName.empty())
5258 return;
5259
5260 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5261 return;
5262
5263 LOG_INFO("server.loading", "Loading {}...", tableName);
5264
5265 scripts->clear(); // need for reload support
5266
5267 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5268 // 0 1 2 3 4 5 6 7 8 9
5269 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5270
5271 if (!result)
5272 {
5273 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5274 LOG_INFO("server.loading", " ");
5275 return;
5276 }
5277
5278 uint32 count = 0;
5279
5280 do
5281 {
5282 Field* fields = result->Fetch();
5283 ScriptInfo tmp;
5284 tmp.type = type;
5285 tmp.id = fields[0].Get<uint32>();
5286 if (isSpellScriptTable)
5287 tmp.id |= fields[10].Get<uint8>() << 24;
5288 tmp.delay = fields[1].Get<uint32>();
5289 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5290 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5291 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5292 tmp.Raw.nData[2] = fields[5].Get<int32>();
5293 tmp.Raw.fData[0] = fields[6].Get<float>();
5294 tmp.Raw.fData[1] = fields[7].Get<float>();
5295 tmp.Raw.fData[2] = fields[8].Get<float>();
5296 tmp.Raw.fData[3] = fields[9].Get<float>();
5297
5298 // generic command args check
5299 switch (tmp.command)
5300 {
5302 {
5304 {
5305 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5306 tableName, tmp.Talk.ChatType, tmp.id);
5307 continue;
5308 }
5310 {
5311 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
5312 tableName, tmp.Talk.TextID, tmp.id);
5313 continue;
5314 }
5315 break;
5316 }
5317
5319 {
5320 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
5321 {
5322 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
5323 tableName, tmp.Emote.EmoteID, tmp.id);
5324 continue;
5325 }
5326 break;
5327 }
5328
5330 {
5331 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
5332 {
5333 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5334 tableName, tmp.TeleportTo.MapID, tmp.id);
5335 continue;
5336 }
5337
5339 {
5340 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5341 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
5342 continue;
5343 }
5344 break;
5345 }
5346
5348 {
5349 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
5350 if (!quest)
5351 {
5352 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5353 tableName, tmp.QuestExplored.QuestID, tmp.id);
5354 continue;
5355 }
5356
5358 {
5359 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.",
5360 tableName, tmp.QuestExplored.QuestID, tmp.id);
5361
5362 // this will prevent quest completing without objective
5363 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5364
5365 // continue; - quest objective requirement set and command can be allowed
5366 }
5367
5369 {
5370 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 {}",
5371 tableName, tmp.QuestExplored.Distance, tmp.id);
5372 continue;
5373 }
5374
5376 {
5377 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",
5379 continue;
5380 }
5381
5383 {
5384 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",
5385 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
5386 continue;
5387 }
5388
5389 break;
5390 }
5391
5393 {
5395 {
5396 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
5397 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
5398 continue;
5399 }
5400 break;
5401 }
5402
5404 {
5406 if (!data)
5407 {
5408 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5409 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
5410 continue;
5411 }
5412
5413 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5414 if (!info)
5415 {
5416 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5417 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
5418 continue;
5419 }
5420
5421 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
5423 info->type == GAMEOBJECT_TYPE_DOOR ||
5424 info->type == GAMEOBJECT_TYPE_BUTTON ||
5425 info->type == GAMEOBJECT_TYPE_TRAP)
5426 {
5427 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5428 tableName, info->entry, tmp.id);
5429 continue;
5430 }
5431 break;
5432 }
5433
5435 {
5437 {
5438 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5440 continue;
5441 }
5442
5444 if (!GetCreatureTemplate(entry))
5445 {
5446 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5447 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
5448 continue;
5449 }
5450 break;
5451 }
5452
5455 {
5457 if (!data)
5458 {
5459 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
5460 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
5461 continue;
5462 }
5463
5464 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5465 if (!info)
5466 {
5467 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
5468 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
5469 continue;
5470 }
5471
5472 if (info->type != GAMEOBJECT_TYPE_DOOR)
5473 {
5474 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
5475 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
5476 continue;
5477 }
5478
5479 break;
5480 }
5481
5483 {
5484 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
5485 {
5486 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5487 tableName, tmp.RemoveAura.SpellID, tmp.id);
5488 continue;
5489 }
5490 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
5491 {
5492 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5493 tableName, tmp.RemoveAura.Flags, tmp.id);
5494 continue;
5495 }
5496 break;
5497 }
5498
5500 {
5501 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
5502 {
5503 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5504 tableName, tmp.CastSpell.SpellID, tmp.id);
5505 continue;
5506 }
5507 if (tmp.CastSpell.Flags > 4) // targeting type
5508 {
5509 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5510 tableName, tmp.CastSpell.Flags, tmp.id);
5511 continue;
5512 }
5513 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
5514 {
5515 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5516 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5517 continue;
5518 }
5519 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
5520 {
5521 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5522 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5523 continue;
5524 }
5525 break;
5526 }
5527
5529 {
5531 {
5532 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
5533 tableName, tmp.CreateItem.ItemEntry, tmp.id);
5534 continue;
5535 }
5536 if (!tmp.CreateItem.Amount)
5537 {
5538 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
5539 tableName, tmp.CreateItem.Amount, tmp.id);
5540 continue;
5541 }
5542 break;
5543 }
5544 default:
5545 break;
5546 }
5547
5548 if (scripts->find(tmp.id) == scripts->end())
5549 {
5550 ScriptMap emptyMap;
5551 (*scripts)[tmp.id] = emptyMap;
5552 }
5553 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
5554
5555 ++count;
5556 } while (result->NextRow());
5557
5558 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5559 LOG_INFO("server.loading", " ");
5560}
@ CHAT_TYPE_WHISPER
Definition CreatureData.h:425
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:40
#define INTERACTION_DISTANCE
Definition ObjectDefines.h:24
std::multimap< uint32, ScriptInfo > ScriptMap
Definition ObjectMgr.h:385
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition ObjectMgr.cpp:83
ScriptCommands
Definition ObjectMgr.h:91
@ SCRIPT_COMMAND_EMOTE
Definition ObjectMgr.h:93
@ SCRIPT_COMMAND_CREATE_ITEM
Definition ObjectMgr.h:109
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition ObjectMgr.h:104
@ SCRIPT_COMMAND_CAST_SPELL
Definition ObjectMgr.h:107
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition ObjectMgr.h:101
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition ObjectMgr.h:99
@ SCRIPT_COMMAND_TALK
Definition ObjectMgr.h:92
@ SCRIPT_COMMAND_OPEN_DOOR
Definition ObjectMgr.h:103
@ SCRIPT_COMMAND_TELEPORT_TO
Definition ObjectMgr.h:98
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition ObjectMgr.h:102
@ SCRIPT_COMMAND_KILL_CREDIT
Definition ObjectMgr.h:100
@ SCRIPT_COMMAND_REMOVE_AURA
Definition ObjectMgr.h:106
std::string GetScriptCommandName(ScriptCommands command)
Definition ObjectMgr.cpp:103
std::map< uint32, ScriptMap > ScriptMapMap
Definition ObjectMgr.h:386
std::string GetScriptsTableNameByType(ScriptsType type)
Definition ObjectMgr.cpp:63
@ SCRIPTS_SPELL
Definition ObjectMgr.h:148
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1577
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3194
Definition ObjectMgr.h:190
float Orientation
Definition ObjectMgr.h:250
struct ScriptInfo::@266::@277 RespawnGameobject
uint32 Flags
Definition ObjectMgr.h:207
ScriptsType type
Definition ObjectMgr.h:191
uint32 QuestID
Definition ObjectMgr.h:255
int32 TextID
Definition ObjectMgr.h:208
struct ScriptInfo::@266::@279 ToggleDoor
struct ScriptInfo::@266::@281 CastSpell
float DestX
Definition ObjectMgr.h:229
uint32 ItemEntry
Definition ObjectMgr.h:316
uint32 ChatType
Definition ObjectMgr.h:206
uint32 id
Definition ObjectMgr.h:192
struct ScriptInfo::@266::@268 Raw
struct ScriptInfo::@266::@269 Talk
uint32 delay
Definition ObjectMgr.h:193
struct ScriptInfo::@266::@270 Emote
float fData[4]
Definition ObjectMgr.h:201
struct ScriptInfo::@266::@280 RemoveAura
struct ScriptInfo::@266::@274 TeleportTo
float PosY
Definition ObjectMgr.h:278
ScriptCommands command
Definition ObjectMgr.h:194
float DestY
Definition ObjectMgr.h:230
struct ScriptInfo::@266::@275 QuestExplored
uint32 MapID
Definition ObjectMgr.h:243
uint32 nData[3]
Definition ObjectMgr.h:200
float PosZ
Definition ObjectMgr.h:279
struct ScriptInfo::@266::@283 CreateItem
float PosX
Definition ObjectMgr.h:277
uint32 Distance
Definition ObjectMgr.h:256
struct ScriptInfo::@266::@276 KillCredit
uint32 SpellID
Definition ObjectMgr.h:294
float DestZ
Definition ObjectMgr.h:231
uint32 GOGuid
Definition ObjectMgr.h:267
uint32 CreatureEntry
Definition ObjectMgr.h:261
uint32 Amount
Definition ObjectMgr.h:317
struct ScriptInfo::@266::@278 TempSummonCreature
uint32 EmoteID
Definition ObjectMgr.h:213

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

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

◆ LoadSpellScriptNames()

void ObjectMgr::LoadSpellScriptNames ( )
5662{
5663 uint32 oldMSTime = getMSTime();
5664
5665 _spellScriptsStore.clear(); // need for reload case
5666
5667 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
5668
5669 if (!result)
5670 {
5671 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
5672 LOG_INFO("server.loading", " ");
5673 return;
5674 }
5675
5676 uint32 count = 0;
5677
5678 do
5679 {
5680 Field* fields = result->Fetch();
5681
5682 int32 spellId = fields[0].Get<int32>();
5683 std::string scriptName = fields[1].Get<std::string>();
5684
5685 bool allRanks = false;
5686 if (spellId <= 0)
5687 {
5688 allRanks = true;
5689 spellId = -spellId;
5690 }
5691
5692 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5693 if (!spellInfo)
5694 {
5695 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
5696 continue;
5697 }
5698
5699 if (allRanks)
5700 {
5701 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
5702 {
5703 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
5704 continue;
5705 }
5706 while (spellInfo)
5707 {
5708 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5709 spellInfo = spellInfo->GetNextRankSpell();
5710 }
5711 }
5712 else
5713 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5714 ++count;
5715 } while (result->NextRow());
5716
5717 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5718 LOG_INFO("server.loading", " ");
5719}
SpellInfo const * GetNextRankSpell() const
Definition SpellInfo.cpp:2513

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

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
5563{
5565
5566 // check ids
5567 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
5568 {
5569 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
5570 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5571
5572 if (!spellInfo)
5573 {
5574 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
5575 continue;
5576 }
5577
5578 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
5579 if (uint32(i) >= MAX_SPELL_EFFECTS)
5580 {
5581 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
5582 }
5583
5584 //check for correct spellEffect
5585 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
5586 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
5587 }
5588}
ScriptMapMap sSpellScripts
Definition ObjectMgr.cpp:59
SpellEffIndex
Definition SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:781
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:855

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

◆ LoadTavernAreaTriggers()

void ObjectMgr::LoadTavernAreaTriggers ( )
6502{
6503 uint32 oldMSTime = getMSTime();
6504
6505 _tavernAreaTriggerStore.clear(); // need for reload case
6506
6507 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
6508
6509 if (!result)
6510 {
6511 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
6512 LOG_INFO("server.loading", " ");
6513 return;
6514 }
6515
6516 uint32 count = 0;
6517
6518 do
6519 {
6520 ++count;
6521
6522 Field* fields = result->Fetch();
6523
6524 uint32 Trigger_ID = fields[0].Get<uint32>();
6525
6526 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6527 if (!atEntry)
6528 {
6529 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6530 continue;
6531 }
6532
6533 uint32 faction = fields[1].Get<uint32>();
6534
6535 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
6536 } while (result->NextRow());
6537
6538 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6539 LOG_INFO("server.loading", " ");
6540}

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

◆ LoadTempSummons()

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

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

◆ LoadTrainerSpell()

void ObjectMgr::LoadTrainerSpell ( )
9219{
9220 uint32 oldMSTime = getMSTime();
9221
9222 // For reload case
9224
9225 QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.ReqLevel, a.ReqSpell FROM npc_trainer AS a "
9226 "INNER JOIN npc_trainer AS b ON a.ID = -(b.SpellID) "
9227 "UNION SELECT * FROM npc_trainer WHERE SpellID > 0");
9228
9229 if (!result)
9230 {
9231 LOG_WARN("server.loading", ">> Loaded 0 Trainers. DB table `npc_trainer` is empty!");
9232 LOG_INFO("server.loading", " ");
9233 return;
9234 }
9235
9236 uint32 count = 0;
9237
9238 do
9239 {
9240 Field* fields = result->Fetch();
9241
9242 uint32 entry = fields[0].Get<uint32>();
9243 uint32 spell = fields[1].Get<uint32>();
9244 uint32 spellCost = fields[2].Get<uint32>();
9245 uint32 reqSkill = fields[3].Get<uint16>();
9246 uint32 reqSkillValue = fields[4].Get<uint16>();
9247 uint32 reqLevel = fields[5].Get<uint8>();
9248 uint32 reqSpell = fields[6].Get<uint32>();
9249
9250 AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel, reqSpell);
9251
9252 ++count;
9253 } while (result->NextRow());
9254
9255 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9256 LOG_INFO("server.loading", " ");
9257}
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
Definition ObjectMgr.cpp:9133

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

◆ LoadVehicleAccessories()

void ObjectMgr::LoadVehicleAccessories ( )
3481{
3482 uint32 oldMSTime = getMSTime();
3483
3484 _vehicleAccessoryStore.clear(); // needed for reload case
3485
3486 uint32 count = 0;
3487
3488 // 0 1 2 3 4 5
3489 QueryResult result = WorldDatabase.Query("SELECT `guid`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_accessory`");
3490
3491 if (!result)
3492 {
3493 LOG_WARN("server.loading", ">> Loaded 0 Vehicle Accessories in {} ms", GetMSTimeDiffToNow(oldMSTime));
3494 LOG_INFO("server.loading", " ");
3495 return;
3496 }
3497
3498 do
3499 {
3500 Field* fields = result->Fetch();
3501
3502 uint32 uiGUID = fields[0].Get<uint32>();
3503 uint32 uiAccessory = fields[1].Get<uint32>();
3504 int8 uiSeat = int8(fields[2].Get<int16>());
3505 bool bMinion = fields[3].Get<bool>();
3506 uint8 uiSummonType = fields[4].Get<uint8>();
3507 uint32 uiSummonTimer = fields[5].Get<uint32>();
3508
3509 if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
3510 {
3511 LOG_ERROR("sql.sql", "Table `vehicle_accessory`: Accessory {} does not exist.", uiAccessory);
3512 continue;
3513 }
3514
3515 _vehicleAccessoryStore[uiGUID].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3516
3517 ++count;
3518 } while (result->NextRow());
3519
3520 LOG_INFO("server.loading", ">> Loaded {} Vehicle Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3521 LOG_INFO("server.loading", " ");
3522}
Definition VehicleDefines.h:115

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

◆ LoadVehicleSeatAddon()

void ObjectMgr::LoadVehicleSeatAddon ( )
3525{
3526 uint32 oldMSTime = getMSTime();
3527
3528 _vehicleSeatAddonStore.clear(); // needed for reload case
3529
3530 uint32 count = 0;
3531
3532 // 0 1 2 3 4 5 6
3533 QueryResult result = WorldDatabase.Query("SELECT `SeatEntry`, `SeatOrientation`, `ExitParamX`, `ExitParamY`, `ExitParamZ`, `ExitParamO`, `ExitParamValue` FROM `vehicle_seat_addon`");
3534
3535 if (!result)
3536 {
3537 LOG_ERROR("server.loading", ">> Loaded 0 vehicle seat addons. DB table `vehicle_seat_addon` is empty.");
3538 return;
3539 }
3540
3541 do
3542 {
3543 Field* fields = result->Fetch();
3544
3545 uint32 seatID = fields[0].Get<uint32>();
3546 float orientation = fields[1].Get<float>();
3547 float exitX = fields[2].Get<float>();
3548 float exitY = fields[3].Get<float>();
3549 float exitZ = fields[4].Get<float>();
3550 float exitO = fields[5].Get<float>();
3551 uint8 exitParam = fields[6].Get<uint8>();
3552
3553 if (!sVehicleSeatStore.LookupEntry(seatID))
3554 {
3555 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} does not exist in VehicleSeat.dbc. Skipping entry.", seatID);
3556 continue;
3557 }
3558
3559 // Sanitizing values
3560 if (orientation > float(M_PI * 2))
3561 {
3562 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid angle offset value ({}). Set Value to 0.", seatID, orientation);
3563 orientation = 0.0f;
3564 }
3565
3567 {
3568 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid exit parameter value ({}). Setting to 0 (none).", seatID, exitParam);
3569 continue;
3570 }
3571
3572 _vehicleSeatAddonStore[seatID] = VehicleSeatAddon(orientation, exitX, exitY, exitZ, exitO, exitParam);
3573
3574 ++count;
3575 } while (result->NextRow());
3576
3577 LOG_INFO("server.loading", ">> Loaded {} Vehicle Seat Addon entries in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3578}
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 ( )
3425{
3426 uint32 oldMSTime = getMSTime();
3427
3428 _vehicleTemplateAccessoryStore.clear(); // needed for reload case
3429
3430 uint32 count = 0;
3431
3432 // 0 1 2 3 4 5
3433 QueryResult result = WorldDatabase.Query("SELECT `entry`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_template_accessory`");
3434
3435 if (!result)
3436 {
3437 LOG_WARN("server.loading", ">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
3438 LOG_INFO("server.loading", " ");
3439 return;
3440 }
3441
3442 do
3443 {
3444 Field* fields = result->Fetch();
3445
3446 uint32 uiEntry = fields[0].Get<uint32>();
3447 uint32 uiAccessory = fields[1].Get<uint32>();
3448 int8 uiSeat = int8(fields[2].Get<int8>());
3449 bool bMinion = fields[3].Get<bool>();
3450 uint8 uiSummonType = fields[4].Get<uint8>();
3451 uint32 uiSummonTimer = fields[5].Get<uint32>();
3452
3453 if (!sObjectMgr->GetCreatureTemplate(uiEntry))
3454 {
3455 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} does not exist.", uiEntry);
3456 continue;
3457 }
3458
3459 if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
3460 {
3461 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: Accessory {} does not exist.", uiAccessory);
3462 continue;
3463 }
3464
3465 if (_spellClickInfoStore.find(uiEntry) == _spellClickInfoStore.end())
3466 {
3467 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} has no data in npc_spellclick_spells", uiEntry);
3468 continue;
3469 }
3470
3471 _vehicleTemplateAccessoryStore[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3472
3473 ++count;
3474 } while (result->NextRow());
3475
3476 LOG_INFO("server.loading", ">> Loaded {} Vehicle Template Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3477 LOG_INFO("server.loading", " ");
3478}

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

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
9299{
9300 uint32 oldMSTime = getMSTime();
9301
9302 // For reload case
9303 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
9304 itr->second.Clear();
9305 _cacheVendorItemStore.clear();
9306
9307 std::set<uint32> skip_vendors;
9308
9309 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
9310 if (!result)
9311 {
9312 LOG_INFO("server.loading", " ");
9313 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
9314 return;
9315 }
9316
9317 uint32 count = 0;
9318
9319 do
9320 {
9321 Field* fields = result->Fetch();
9322
9323 uint32 entry = fields[0].Get<uint32>();
9324 int32 item_id = fields[1].Get<int32>();
9325
9326 // if item is a negative, its a reference
9327 if (item_id < 0)
9328 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
9329 else
9330 {
9331 uint32 maxcount = fields[2].Get<uint8>();
9332 uint32 incrtime = fields[3].Get<uint32>();
9333 uint32 ExtendedCost = fields[4].Get<uint32>();
9334
9335 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
9336 continue;
9337
9338 VendorItemData& vList = _cacheVendorItemStore[entry];
9339
9340 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9341 ++count;
9342 }
9343 } while (result->NextRow());
9344
9345 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9346 LOG_INFO("server.loading", " ");
9347}

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

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
5635{
5637
5638 std::set<uint32> actionSet;
5639
5640 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
5641 actionSet.insert(itr->first);
5642
5644 PreparedQueryResult result = WorldDatabase.Query(stmt);
5645
5646 if (result)
5647 {
5648 do
5649 {
5650 Field* fields = result->Fetch();
5651 uint32 action = fields[0].Get<uint32>();
5652
5653 actionSet.erase(action);
5654 } while (result->NextRow());
5655 }
5656
5657 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
5658 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
5659}
ScriptMapMap sWaypointScripts
Definition ObjectMgr.cpp:61
@ SCRIPTS_WAYPOINT
Definition ObjectMgr.h:150
@ WORLD_SEL_WAYPOINT_DATA_ACTION
Definition WorldDatabase.h:69

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

◆ NewGOData()

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

References _gameObjectDataStore.

Referenced by AddGOData().

◆ NewOrExistCreatureData()

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

References _creatureDataStore.

Referenced by AddCreData().

◆ PlayerCreateInfoAddItemHelper()

void ObjectMgr::PlayerCreateInfoAddItemHelper ( uint32  race_,
uint32  class_,
uint32  itemId,
int32  count 
)
private
3686{
3687 if (!_playerInfo[race_][class_])
3688 return;
3689
3690 if (count > 0)
3691 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
3692 else
3693 {
3694 if (count < -1)
3695 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
3696
3697 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
3698 {
3699 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
3700 {
3701 bool found = false;
3702 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
3703 {
3704 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
3705 {
3706 found = true;
3707 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
3708 break;
3709 }
3710 }
3711
3712 if (!found)
3713 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
3714 }
3715 }
3716 }
3717}
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition DBCStores.cpp:842
Definition Player.h:284
PlayerCreateInfoItems item
Definition Player.h:352

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

Referenced by LoadPlayerInfo().

◆ RemoveCreatureFromGrid()

void ObjectMgr::RemoveCreatureFromGrid ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)
2352{
2353 uint8 mask = data->spawnMask;
2354 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2355 {
2356 if (mask & 1)
2357 {
2358 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2359 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2360 cell_guids.creatures.erase(guid);
2361 }
2362 }
2363}

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

Referenced by DeleteCreatureData().

◆ RemoveGameobjectFromGrid()

void ObjectMgr::RemoveGameobjectFromGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2655{
2656 uint8 mask = data->spawnMask;
2657 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2658 {
2659 if (mask & 1)
2660 {
2661 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2662 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2663 cell_guids.gameobjects.erase(guid);
2664 }
2665 }
2666}

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

Referenced by DeleteGOData().

◆ RemoveVendorItem()

bool ObjectMgr::RemoveVendorItem ( uint32  entry,
uint32  item,
bool  persist = true 
)
9478{
9479 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
9480 if (iter == _cacheVendorItemStore.end())
9481 return false;
9482
9483 if (!iter->second.RemoveItem(item))
9484 return false;
9485
9486 if (persist)
9487 {
9489
9490 stmt->SetData(0, entry);
9491 stmt->SetData(1, item);
9492
9493 WorldDatabase.Execute(stmt);
9494 }
9495
9496 return true;
9497}
@ WORLD_DEL_NPC_VENDOR
Definition WorldDatabase.h:44

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

◆ ReturnOrDeleteOldMails()

void ObjectMgr::ReturnOrDeleteOldMails ( bool  serverUp)
6130{
6131 uint32 oldMSTime = getMSTime();
6132
6133 time_t curTime = GameTime::GetGameTime().count();
6134
6136 stmt->SetData(0, uint32(curTime));
6137 PreparedQueryResult result = CharacterDatabase.Query(stmt);
6138 if (!result)
6139 return;
6140
6141 std::map<uint32 /*messageId*/, MailItemInfoVec> itemsCache;
6142 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS);
6143 stmt->SetData(0, uint32(curTime));
6144 if (PreparedQueryResult items = CharacterDatabase.Query(stmt))
6145 {
6146 MailItemInfo item;
6147 do
6148 {
6149 Field* fields = items->Fetch();
6150 item.item_guid = fields[0].Get<uint32>();
6151 item.item_template = fields[1].Get<uint32>();
6152 uint32 mailId = fields[2].Get<uint32>();
6153 itemsCache[mailId].push_back(item);
6154 } while (items->NextRow());
6155 }
6156
6157 uint32 deletedCount = 0;
6158 uint32 returnedCount = 0;
6159 do
6160 {
6161 Field* fields = result->Fetch();
6162 Mail* m = new Mail;
6163 m->messageID = fields[0].Get<uint32>();
6164 m->messageType = fields[1].Get<uint8>();
6165 m->sender = fields[2].Get<uint32>();
6166 m->receiver = fields[3].Get<uint32>();
6167 bool has_items = fields[4].Get<bool>();
6168 m->expire_time = time_t(fields[5].Get<uint32>());
6169 m->deliver_time = time_t(0);
6170 m->stationery = fields[6].Get<uint8>();
6171 m->checked = fields[7].Get<uint8>();
6172 m->mailTemplateId = fields[8].Get<int16>();
6173
6174 Player* player = nullptr;
6175 if (serverUp)
6177
6178 if (player) // don't modify mails of a logged in player
6179 {
6180 delete m;
6181 continue;
6182 }
6183
6184 // Delete or return mail
6185 if (has_items)
6186 {
6187 // read items from cache
6188 m->items.swap(itemsCache[m->messageID]);
6189
6190 // If it is mail from non-player, or if it's already return mail, it shouldn't be returned, but deleted
6191 if (!m->IsSentByPlayer() || m->IsSentByGM() || (m->IsCODPayment() || m->IsReturnedMail()))
6192 {
6193 for (auto const& mailedItem : m->items)
6194 {
6195 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
6196 stmt->SetData(0, mailedItem.item_guid);
6197 CharacterDatabase.Execute(stmt);
6198 }
6199
6200 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
6201 stmt->SetData(0, m->messageID);
6202 CharacterDatabase.Execute(stmt);
6203 }
6204 else
6205 {
6206 // Mail will be returned
6207 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_RETURNED);
6208 stmt->SetData(0, m->receiver);
6209 stmt->SetData(1, m->sender);
6210 stmt->SetData(2, uint32(curTime + 30 * DAY));
6211 stmt->SetData(3, uint32(curTime));
6213 stmt->SetData(5, m->messageID);
6214 CharacterDatabase.Execute(stmt);
6215 for (auto const& mailedItem : m->items)
6216 {
6217 // Update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete
6218 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_ITEM_RECEIVER);
6219 stmt->SetData(0, m->sender);
6220 stmt->SetData(1, mailedItem.item_guid);
6221 CharacterDatabase.Execute(stmt);
6222
6223 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
6224 stmt->SetData(0, m->sender);
6225 stmt->SetData(1, mailedItem.item_guid);
6226 CharacterDatabase.Execute(stmt);
6227 }
6228
6229 // xinef: update global data
6230 sCharacterCache->IncreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->sender));
6231 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6232
6233 delete m;
6234 ++returnedCount;
6235 continue;
6236 }
6237 }
6238
6239 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6240
6241 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
6242 stmt->SetData(0, m->messageID);
6243 CharacterDatabase.Execute(stmt);
6244 delete m;
6245 ++deletedCount;
6246 } while (result->NextRow());
6247
6248 LOG_INFO("server.loading", ">> Processed {} expired mails: {} deleted and {} returned in {} ms", deletedCount + returnedCount, deletedCount, returnedCount, GetMSTimeDiffToNow(oldMSTime));
6249 LOG_INFO("server.loading", " ");
6250}
#define sCharacterCache
Definition CharacterCache.h:83
@ CHAR_UPD_ITEM_OWNER
Definition CharacterDatabase.h:118
@ CHAR_DEL_ITEM_INSTANCE
Definition CharacterDatabase.h:127
@ CHAR_UPD_MAIL_RETURNED
Definition CharacterDatabase.h:116
@ CHAR_SEL_EXPIRED_MAIL
Definition CharacterDatabase.h:114
@ CHAR_SEL_EXPIRED_MAIL_ITEMS
Definition CharacterDatabase.h:115
@ CHAR_DEL_MAIL_BY_ID
Definition CharacterDatabase.h:110
@ CHAR_DEL_MAIL_ITEM_BY_ID
Definition CharacterDatabase.h:382
@ CHAR_UPD_MAIL_ITEM_RECEIVER
Definition CharacterDatabase.h:117
std::vector< MailItemInfo > MailItemInfoVec
Definition Mail.h:164
@ MAIL_CHECK_MASK_RETURNED
Definition Mail.h:48
Definition Player.h:1081
Seconds GetGameTime()
Definition GameTime.cpp:38
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition ObjectAccessor.cpp:251
Definition Mail.h:160
ObjectGuid::LowType item_guid
Definition Mail.h:161
uint32 item_template
Definition Mail.h:162
Definition Mail.h:167
bool IsSentByGM() const
Definition Mail.h:208
bool IsCODPayment() const
Definition Mail.h:209
ObjectGuid::LowType receiver
Definition Mail.h:173
uint8 messageType
Definition Mail.h:169
bool IsSentByPlayer() const
Definition Mail.h:207
uint32 messageID
Definition Mail.h:168
time_t expire_time
Definition Mail.h:178
uint32 sender
Definition Mail.h:172
uint8 stationery
Definition Mail.h:170
std::vector< MailItemInfo > items
Definition Mail.h:176
time_t deliver_time
Definition Mail.h:179
bool IsReturnedMail() const
Definition Mail.h:210
uint32 checked
Definition Mail.h:182
uint16 mailTemplateId
Definition Mail.h:171

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

◆ SetCreatureLinkedRespawn()

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

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

◆ SetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ SetHighestGuids()

void ObjectMgr::SetHighestGuids ( )
7012{
7013 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
7014 if (result)
7015 GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].Get<uint32>() + 1);
7016
7017 result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
7018 if (result)
7019 GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].Get<uint32>() + 1);
7020
7021 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
7022 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7023 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7024 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7025 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7026
7027 result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
7028 if (result)
7029 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
7030
7031 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
7032 if (result)
7033 _auctionId = (*result)[0].Get<uint32>() + 1;
7034
7035 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
7036 if (result)
7037 _mailId = (*result)[0].Get<uint32>() + 1;
7038
7039 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
7040 if (result)
7041 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
7042
7043 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
7044 if (result)
7045 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
7046
7047 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
7048 if (result)
7049 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
7050
7051 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
7052 if (result)
7053 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
7054
7055 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
7056 if (result)
7057 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
7058
7059 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
7060 if (result)
7061 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
7062}
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sGuildMgr
Definition GuildMgr.h:51

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

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
5722{
5723 uint32 oldMSTime = getMSTime();
5724
5725 if (_spellScriptsStore.empty())
5726 {
5727 LOG_INFO("server.loading", ">> Validated 0 scripts.");
5728 LOG_INFO("server.loading", " ");
5729 return;
5730 }
5731
5732 uint32 count = 0;
5733
5734 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
5735 {
5736 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
5737 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
5738 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
5739 itr = _spellScriptsStore.upper_bound(itr->first);
5740
5741 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
5742 {
5743 SpellScript* spellScript = sitr->first->GetSpellScript();
5744 AuraScript* auraScript = sitr->first->GetAuraScript();
5745 bool valid = true;
5746 if (!spellScript && !auraScript)
5747 {
5748 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
5749 valid = false;
5750 }
5751 if (spellScript)
5752 {
5753 spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5754 spellScript->_Register();
5755 if (!spellScript->_Validate(spellInfo))
5756 valid = false;
5757 delete spellScript;
5758 }
5759 if (auraScript)
5760 {
5761 auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5762 auraScript->_Register();
5763 if (!auraScript->_Validate(spellInfo))
5764 valid = false;
5765 delete auraScript;
5766 }
5767 if (!valid)
5768 {
5769 _spellScriptsStore.erase(sitr->second);
5770 }
5771 }
5772 ++count;
5773 }
5774
5775 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5776 LOG_INFO("server.loading", " ");
5777}
Definition SpellScript.h:517
bool _Validate(SpellInfo const *entry) override
Definition SpellScript.cpp:662
std::string const & GetScriptName(uint32 id) const
Definition ObjectMgr.cpp:9635
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().

◆ _broadcastTextStore

BroadcastTextContainer ObjectMgr::_broadcastTextStore
private

◆ _cacheTrainerSpellStore

CacheTrainerSpellContainer ObjectMgr::_cacheTrainerSpellStore
private

◆ _cacheVendorItemStore

◆ _creatureAddonStore

CreatureAddonContainer ObjectMgr::_creatureAddonStore
private

◆ _creatureBaseStatsStore

CreatureBaseStatsContainer ObjectMgr::_creatureBaseStatsStore
private

◆ _creatureCustomIDsStore

CreatureCustomIDsContainer ObjectMgr::_creatureCustomIDsStore
private

◆ _creatureDataStore

◆ _creatureLocaleStore

CreatureLocaleContainer ObjectMgr::_creatureLocaleStore
private

◆ _creatureModelStore

CreatureModelContainer ObjectMgr::_creatureModelStore
private

◆ _creatureMovementOverrides

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

◆ _creatureQuestInvolvedRelations

◆ _creatureQuestItemStore

CreatureQuestItemMap ObjectMgr::_creatureQuestItemStore
private

◆ _creatureQuestRelations

QuestRelations ObjectMgr::_creatureQuestRelations
private

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

GameObjectDataContainer ObjectMgr::_gameObjectDataStore
private

◆ _gameObjectLocaleStore

GameObjectLocaleContainer ObjectMgr::_gameObjectLocaleStore
private

◆ _gameObjectQuestItemStore

GameObjectQuestItemMap ObjectMgr::_gameObjectQuestItemStore
private

◆ _gameObjectSpawnId

ObjectGuid::LowType ObjectMgr::_gameObjectSpawnId
private

◆ _gameObjectTemplateAddonStore

GameObjectTemplateAddonContainer ObjectMgr::_gameObjectTemplateAddonStore
private

◆ _gameObjectTemplateStore

GameObjectTemplateContainer ObjectMgr::_gameObjectTemplateStore
private

◆ _gameTeleStore

◆ _goQuestInvolvedRelations

QuestRelations ObjectMgr::_goQuestInvolvedRelations
private

◆ _goQuestRelations

QuestRelations ObjectMgr::_goQuestRelations
private

◆ _gossipMenuItemsLocaleStore

GossipMenuItemsLocaleContainer ObjectMgr::_gossipMenuItemsLocaleStore
private

◆ _gossipMenuItemsStore

◆ _gossipMenusStore

GossipMenusContainer ObjectMgr::_gossipMenusStore
private

◆ _gossipTextStore

GossipTextContainer ObjectMgr::_gossipTextStore
private

Referenced by GetGossipText(), and LoadGossipText().

◆ _guidGenerators

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

◆ _hasDifficultyEntries

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

Referenced by CheckCreatureTemplate().

◆ _hiPetNumber

uint32 ObjectMgr::_hiPetNumber
private

Referenced by GeneratePetNumber(), and LoadPetNumber().

◆ _hiPetNumberMutex

std::mutex ObjectMgr::_hiPetNumberMutex
private

Referenced by GeneratePetNumber().

◆ _instanceTemplateStore

InstanceTemplateContainer ObjectMgr::_instanceTemplateStore
private

◆ _itemLocaleStore

ItemLocaleContainer ObjectMgr::_itemLocaleStore
private

Referenced by GetItemLocale(), and LoadItemLocales().

◆ _itemSetNameLocaleStore

ItemSetNameLocaleContainer ObjectMgr::_itemSetNameLocaleStore
private

◆ _itemSetNameStore

ItemSetNameContainer ObjectMgr::_itemSetNameStore
private

◆ _itemTemplateStore

ItemTemplateContainer ObjectMgr::_itemTemplateStore
private

◆ _itemTemplateStoreFast

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

◆ _linkedRespawnStore

LinkedRespawnContainer ObjectMgr::_linkedRespawnStore
private

◆ _mailId

uint32 ObjectMgr::_mailId
private

Referenced by GenerateMailID(), and SetHighestGuids().

◆ _mailIdMutex

std::mutex ObjectMgr::_mailIdMutex
private

Referenced by GenerateMailID().

◆ _mailLevelRewardStore

MailLevelRewardContainer ObjectMgr::_mailLevelRewardStore
private

◆ _mapObjectGuidsStore

◆ _moduleStringStore

ModuleStringContainer ObjectMgr::_moduleStringStore
private

◆ _npcTextLocaleStore

NpcTextLocaleContainer ObjectMgr::_npcTextLocaleStore
private

◆ _pageTextLocaleStore

PageTextLocaleContainer ObjectMgr::_pageTextLocaleStore
private

◆ _pageTextStore

PageTextContainer ObjectMgr::_pageTextStore
private

Referenced by GetPageText(), and LoadPageTexts().

◆ _petHalfLocaleName0

HalfNameContainerLocale ObjectMgr::_petHalfLocaleName0
private

◆ _petHalfLocaleName1

HalfNameContainerLocale ObjectMgr::_petHalfLocaleName1
private

◆ _petHalfName0

HalfNameContainer ObjectMgr::_petHalfName0
private

Referenced by GeneratePetName(), and LoadPetNames().

◆ _petHalfName1

HalfNameContainer ObjectMgr::_petHalfName1
private

Referenced by GeneratePetName(), and LoadPetNames().

◆ _petInfoStore

PetLevelInfoContainer ObjectMgr::_petInfoStore
private

◆ _playerClassInfo

◆ _playerInfo

◆ _playerXPperLevel

PlayerXPperLevel ObjectMgr::_playerXPperLevel
private

Referenced by GetXPForLevel(), and LoadPlayerInfo().

◆ _pointOfInterestLocaleStore

PointOfInterestLocaleContainer ObjectMgr::_pointOfInterestLocaleStore
private

◆ _pointsOfInterestStore

PointOfInterestContainer ObjectMgr::_pointsOfInterestStore
private

◆ _profanityNamesStore

◆ _questAreaTriggerStore

QuestAreaTriggerContainer ObjectMgr::_questAreaTriggerStore
private

◆ _questGreetingStore

QuestGreetingContainer ObjectMgr::_questGreetingStore
private

◆ _questLocaleStore

QuestLocaleContainer ObjectMgr::_questLocaleStore
private

Referenced by GetQuestLocale(), and LoadQuestLocales().

◆ _questMoneyRewards

QuestMoneyRewardStore ObjectMgr::_questMoneyRewards
private

◆ _questOfferRewardLocaleStore

QuestOfferRewardLocaleContainer ObjectMgr::_questOfferRewardLocaleStore
private

◆ _questPOIStore

QuestPOIContainer ObjectMgr::_questPOIStore
private

Referenced by GetQuestPOIVector(), and LoadQuestPOI().

◆ _questRequestItemsLocaleStore

QuestRequestItemsLocaleContainer ObjectMgr::_questRequestItemsLocaleStore
private

◆ _questTemplates

QuestMap ObjectMgr::_questTemplates
private

◆ _questTemplatesFast

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

Referenced by GetQuestTemplate(), and LoadQuests().

◆ _repOnKillStore

RepOnKillContainer ObjectMgr::_repOnKillStore
private

◆ _repRewardRateStore

RepRewardRateContainer ObjectMgr::_repRewardRateStore
private

◆ _repSpilloverTemplateStore

RepSpilloverTemplateContainer ObjectMgr::_repSpilloverTemplateStore
private

◆ _reservedNamesStore

◆ _scriptNamesStore

ScriptNameContainer ObjectMgr::_scriptNamesStore
private

◆ _spellClickInfoStore

◆ _spellScriptsStore

SpellScriptsContainer ObjectMgr::_spellScriptsStore
private

◆ _tavernAreaTriggerStore

TavernAreaTriggerContainer ObjectMgr::_tavernAreaTriggerStore
private

◆ _tempSummonDataStore

TempSummonDataContainer ObjectMgr::_tempSummonDataStore
private

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

Referenced by GetSummonGroup(), and LoadTempSummons().

◆ _transportMaps

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

◆ _vehicleAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleAccessoryStore
private

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