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

#include "ObjectMgr.h"

Classes

struct  GameobjectInstanceSavedState
 

Public Types

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

Public Member Functions

GameObjectTemplateContainer const * GetGameObjectTemplates () const
 
void AddGameobjectInfo (GameObjectTemplate *goinfo)
 
CreatureTemplateContainer const * GetCreatureTemplates () const
 
ItemTemplateContainer const * GetItemTemplateStore () const
 
std::vector< ItemTemplate * > const * GetItemTemplateStoreFast () const
 
ItemSetNameEntry const * GetItemSetNameEntry (uint32 itemId)
 
PlayerClassInfo const * GetPlayerClassInfo (uint32 class_) const
 
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
 
AreaTrigger const * GetAreaTrigger (uint32 trigger) const
 
AreaTriggerTeleport const * GetAreaTriggerTeleport (uint32 trigger) const
 
DungeonProgressionRequirements const * GetAccessRequirement (uint32 mapid, Difficulty difficulty) const
 
RepRewardRate const * GetRepRewardRate (uint32 factionId) const
 
ReputationOnKillEntry const * GetReputationOnKilEntry (uint32 id) const
 
RepSpilloverTemplate const * GetRepSpilloverTemplate (uint32 factionId) const
 
PointOfInterest const * GetPointOfInterest (uint32 id) const
 
QuestPOIVector const * GetQuestPOIVector (uint32 questId)
 
DungeonEncounterList const * GetDungeonEncounterList (uint32 mapId, Difficulty difficulty)
 
void LoadQuestStartersAndEnders ()
 
QuestRelationsGetGOQuestRelationMap ()
 
QuestRelationsGetGOQuestInvolvedRelationMap ()
 
QuestRelationBounds GetGOQuestRelationBounds (uint32 go_entry)
 
QuestRelationBounds GetGOQuestInvolvedRelationBounds (uint32 go_entry)
 
QuestRelationsGetCreatureQuestRelationMap ()
 
QuestRelationsGetCreatureQuestInvolvedRelationMap ()
 
QuestRelationBounds GetCreatureQuestRelationBounds (uint32 creature_entry)
 
QuestRelationBounds GetCreatureQuestInvolvedRelationBounds (uint32 creature_entry)
 
int32 GetFishingBaseSkillLevel (uint32 entry) const
 
template<HighGuid type>
ObjectGuidGeneratorBaseGetGenerator ()
 
MailLevelReward const * GetMailLevelReward (uint32 level, uint32 raceMask)
 
CellObjectGuids const & GetCellObjectGuids (uint16 mapid, uint8 spawnMode, uint32 cell_id)
 
CellObjectGuidsMap const & GetMapObjectGuids (uint16 mapid, uint8 spawnMode)
 
std::vector< TempSummonData > const * GetSummonGroup (uint32 summonerId, SummonerType summonerType, uint8 group) const
 
ServerMailContainer const & GetAllServerMailStore () const
 
BroadcastText const * GetBroadcastText (uint32 id) const
 
CreatureDataContainer const & GetAllCreatureData () const
 
CreatureData const * GetCreatureData (ObjectGuid::LowType spawnId) const
 
CreatureDataNewOrExistCreatureData (ObjectGuid::LowType spawnId)
 
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
 
QuestGreetingLocale const * GetQuestGreetingLocale (TypeID type, uint32 id) const
 
QuestOfferRewardLocale const * GetQuestOfferRewardLocale (uint32 entry) const
 
QuestRequestItemsLocale const * GetQuestRequestItemsLocale (uint32 entry) const
 
NpcTextLocale const * GetNpcTextLocale (uint32 entry) const
 
GameObjectDataNewGOData (ObjectGuid::LowType guid)
 
AcoreString const * GetAcoreString (uint32 entry) const
 
char const * GetAcoreStringForDBCLocale (uint32 entry) const
 
LocaleConstant GetDBCLocaleIndex () const
 
void SetDBCLocaleIndex (LocaleConstant locale)
 
GameTele const * GetGameTele (uint32 id) const
 
GameTeleContainer const & GetGameTeleMap () const
 
TrainerSpellData const * GetNpcTrainerSpells (uint32 entry) const
 
VendorItemData const * GetNpcVendorItemList (uint32 entry) const
 
ScriptNameContainerGetScriptNames ()
 
SpellClickInfoMapBounds GetSpellClickInfoMapBounds (uint32 creature_id) const
 
GossipMenusMapBounds GetGossipMenusMapBounds (uint32 uiMenuId) const
 
GossipMenusMapBoundsNonConst GetGossipMenusMapBoundsNonConst (uint32 uiMenuId)
 
GossipMenuItemsMapBounds GetGossipMenuItemsMapBounds (uint32 uiMenuId) const
 
GossipMenuItemsMapBoundsNonConst GetGossipMenuItemsMapBoundsNonConst (uint32 uiMenuId)
 
bool IsTransportMap (uint32 mapId) const
 

Static Public Member Functions

static std::string_view GetLocaleString (std::vector< std::string > const &data, 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

template<HighGuid high>
ObjectGuidGeneratorBaseGetGuidSequenceGenerator ()
 

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
 
ReservedNamesContainer _profanityNamesStore
 
GameTeleContainer _gameTeleStore
 
ScriptNameContainer _scriptNamesStore
 
SpellClickInfoContainer _spellClickInfoStore
 
SpellScriptsContainer _spellScriptsStore
 
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
 
VehicleAccessoryContainer _vehicleAccessoryStore
 
LocaleConstant DBCLocaleIndex
 
PageTextContainer _pageTextStore
 
InstanceTemplateContainer _instanceTemplateStore
 
MailLevelRewardContainer _mailLevelRewardStore
 
CreatureBaseStatsContainer _creatureBaseStatsStore
 
PetLevelInfoContainer _petInfoStore
 
PlayerClassInfo_playerClassInfo [MAX_CLASSES]
 
PlayerInfo_playerInfo [MAX_RACES][MAX_CLASSES]
 
PlayerXPperLevel _playerXPperLevel
 
BaseXPContainer _baseXPTable
 
FishingBaseSkillContainer _fishingBaseForAreaStore
 
HalfNameContainer _petHalfName0
 
HalfNameContainer _petHalfName1
 
HalfNameContainerLocale _petHalfLocaleName0
 
HalfNameContainerLocale _petHalfLocaleName1
 
ItemSetNameContainer _itemSetNameStore
 
MapObjectGuids _mapObjectGuidsStore
 
CellObjectGuidsMap _emptyCellObjectGuidsMap
 
CellObjectGuids _emptyCellObjectGuids
 
CreatureDataContainer _creatureDataStore
 
CreatureTemplateContainer _creatureTemplateStore
 
CreatureCustomIDsContainer _creatureCustomIDsStore
 
std::vector< CreatureTemplate * > _creatureTemplateStoreFast
 
CreatureModelContainer _creatureModelStore
 
CreatureAddonContainer _creatureAddonStore
 
CreatureAddonContainer _creatureTemplateAddonStore
 
std::unordered_map< ObjectGuid::LowType, CreatureMovementData_creatureMovementOverrides
 
GameObjectAddonContainer _gameObjectAddonStore
 
GameObjectQuestItemMap _gameObjectQuestItemStore
 
CreatureQuestItemMap _creatureQuestItemStore
 
EquipmentInfoContainer _equipmentInfoStore
 
LinkedRespawnContainer _linkedRespawnStore
 
CreatureLocaleContainer _creatureLocaleStore
 
GameObjectDataContainer _gameObjectDataStore
 
GameObjectLocaleContainer _gameObjectLocaleStore
 
GameObjectTemplateContainer _gameObjectTemplateStore
 
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
 
TempSummonDataContainer _tempSummonDataStore
 Stores temp summon data grouped by summoner's entry, summoner's type and group id.
 
BroadcastTextContainer _broadcastTextStore
 
ItemTemplateContainer _itemTemplateStore
 
std::vector< ItemTemplate * > _itemTemplateStoreFast
 
ItemLocaleContainer _itemLocaleStore
 
ItemSetNameLocaleContainer _itemSetNameLocaleStore
 
QuestLocaleContainer _questLocaleStore
 
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
 
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
 
NpcTextLocaleContainer _npcTextLocaleStore
 
PageTextLocaleContainer _pageTextLocaleStore
 
AcoreStringContainer _acoreStringStore
 
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore
 
PointOfInterestLocaleContainer _pointOfInterestLocaleStore
 
QuestGreetingLocaleContainer _questGreetingLocaleStore
 
CacheVendorItemContainer _cacheVendorItemStore
 
CacheTrainerSpellContainer _cacheTrainerSpellStore
 
ServerMailContainer _serverMailStore
 
std::set< uint32_difficultyEntries [MAX_DIFFICULTY - 1]
 
std::set< uint32_hasDifficultyEntries [MAX_DIFFICULTY - 1]
 
std::set< uint32_transportMaps
 
QuestMoneyRewardStore _questMoneyRewards
 
std::vector< GameobjectInstanceSavedStateGameobjectInstanceSavedStateList
 

Friends

class PlayerDumpReader
 

ProfanityNames

Checks NamesProfanity.dbc for reserved names

Parameters
nameName to check for match in NamesProfanity.dbc
Returns
true/false
 ObjectMgr ()
 
 ~ObjectMgr ()
 
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
 
static ObjectMgrinstance ()
 
static uint32 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)
 
GameObjectTemplate const * GetGameObjectTemplate (uint32 entry)
 
bool IsGameObjectStaticTransport (uint32 entry)
 
int LoadReferenceVendor (int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
 
void LoadGameObjectTemplate ()
 
void LoadGameObjectTemplateAddons ()
 
CreatureTemplate const * GetCreatureTemplate (uint32 entry)
 
CreatureModelInfo const * GetCreatureModelInfo (uint32 modelId) const
 
CreatureModelInfo const * GetCreatureModelRandomGender (uint32 *displayID)
 
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)
 
InstanceTemplate const * GetInstanceTemplate (uint32 mapId)
 
PetLevelInfo const * GetPetLevelInfo (uint32 creature_id, uint8 level) 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)
 
GossipText const * GetGossipText (uint32 Text_ID) const
 
AreaTriggerTeleport const * GetGoBackTrigger (uint32 Map) const
 
AreaTriggerTeleport const * GetMapEntranceTrigger (uint32 Map) const
 
uint32 GetAreaTriggerScriptId (uint32 trigger_id)
 
SpellScriptsBounds GetSpellScriptsBounds (uint32 spell_id)
 
int32 GetBaseReputationOf (FactionEntry const *factionEntry, uint8 race, uint8 playerClass)
 
VehicleAccessoryList const * GetVehicleAccessoryList (Vehicle *veh) const
 
void LoadQuests ()
 
void LoadQuestMoneyRewards ()
 
void LoadGameobjectQuestStarters ()
 
void LoadGameobjectQuestEnders ()
 
void LoadCreatureQuestStarters ()
 
void LoadCreatureQuestEnders ()
 
void LoadEventScripts ()
 
void LoadSpellScripts ()
 
void LoadWaypointScripts ()
 
void LoadSpellScriptNames ()
 
void ValidateSpellScripts ()
 
void InitializeSpellInfoPrecomputedData ()
 
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 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 LoadLinkedRespawn ()
 
bool SetCreatureLinkedRespawn (ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid)
 
void LoadCreatureAddons ()
 
void LoadGameObjectAddons ()
 
void LoadCreatureModelInfo ()
 
void LoadEquipmentTemplates ()
 
void LoadCreatureMovementOverrides ()
 
void LoadGameObjectLocales ()
 
void LoadGameobjects ()
 
void LoadItemTemplates ()
 
void LoadItemLocales ()
 
void LoadItemSetNames ()
 
void LoadItemSetNameLocales ()
 
void LoadQuestLocales ()
 
void LoadNpcTextLocales ()
 
void LoadQuestOfferRewardLocale ()
 
void LoadQuestRequestItemsLocale ()
 
void LoadPageTextLocales ()
 
void LoadGossipMenuItemsLocales ()
 
void LoadPointOfInterestLocales ()
 
void LoadQuestGreetingsLocales ()
 
void LoadInstanceTemplate ()
 
void LoadInstanceEncounters ()
 
void LoadMailLevelRewards ()
 
void LoadMailServerTemplates ()
 
void LoadVehicleTemplateAccessories ()
 
void LoadVehicleAccessories ()
 
void LoadGossipText ()
 
void LoadAreaTriggers ()
 
void LoadAreaTriggerTeleports ()
 
void LoadAccessRequirements ()
 
void LoadQuestAreaTriggers ()
 
void LoadQuestGreetings ()
 
void LoadAreaTriggerScripts ()
 
void LoadTavernAreaTriggers ()
 
void LoadGameObjectForQuests ()
 
void LoadPageTexts ()
 
PageText const * GetPageText (uint32 pageEntry)
 
void LoadPlayerInfo ()
 
void LoadPetLevelInfo ()
 
void LoadExplorationBaseXP ()
 
void LoadPetNames ()
 
void LoadPetNamesLocales ()
 
void LoadPetNumber ()
 
void LoadFishingBaseSkillLevel ()
 
void ChangeFishingBaseSkillLevel (uint32 entry, int32 skill)
 
void LoadReputationRewardRate ()
 
void LoadReputationOnKill ()
 
void LoadReputationSpilloverTemplate ()
 
void LoadPointsOfInterest ()
 
void LoadQuestPOI ()
 
void LoadNPCSpellClickSpells ()
 
void LoadGameTele ()
 
void LoadGossipMenu ()
 
void LoadGossipMenuItems ()
 
void LoadVendors ()
 
void LoadTrainerSpell ()
 
void AddSpellToTrainer (uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
 
std::string GeneratePetName (uint32 entry)
 
std::string GeneratePetNameLocale (uint32 entry, LocaleConstant locale)
 
uint32 GetBaseXP (uint8 level)
 
uint32 GetXPForLevel (uint8 level) const
 
void ReturnOrDeleteOldMails (bool serverUp)
 
CreatureBaseStats const * GetCreatureBaseStats (uint8 level, uint8 unitClass)
 
void SetHighestGuids ()
 
uint32 GenerateAuctionID ()
 
uint64 GenerateEquipmentSetGuid ()
 
uint32 GenerateMailID ()
 
uint32 GeneratePetNumber ()
 
ObjectGuid::LowType GenerateCreatureSpawnId ()
 
ObjectGuid::LowType GenerateGameObjectSpawnId ()
 
void DeleteCreatureData (ObjectGuid::LowType spawnId)
 
QuestGreeting const * GetQuestGreeting (TypeID type, uint32 id) const
 
void DeleteGOData (ObjectGuid::LowType guid)
 
char const * GetAcoreString (uint32 entry, LocaleConstant locale) const
 
void AddCreatureToGrid (ObjectGuid::LowType guid, CreatureData const *data)
 
void RemoveCreatureFromGrid (ObjectGuid::LowType guid, CreatureData const *data)
 
void AddGameobjectToGrid (ObjectGuid::LowType guid, GameObjectData const *data)
 
void RemoveGameobjectFromGrid (ObjectGuid::LowType guid, GameObjectData const *data)
 
uint32 AddGOData (uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0, float rotation0=0, float rotation1=0, float rotation2=0, float rotation3=0)
 
uint32 AddCreData (uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0)
 
void LoadReservedPlayersNames ()
 
bool IsReservedName (std::string_view name) const
 
void AddReservedPlayerName (std::string const &name)
 
void LoadProfanityPlayersNames ()
 
bool IsProfanityName (std::string_view name) const
 
void AddProfanityPlayerName (std::string const &name)
 
GameTele const * GetGameTele (std::string_view name) const
 
bool AddGameTele (GameTele &data)
 
bool DeleteGameTele (std::string_view name)
 
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 ()
 
std::string const & GetScriptName (uint32 id) const
 
uint32 GetScriptId (std::string const &name)
 
void LoadFactionChangeAchievements ()
 
void LoadFactionChangeItems ()
 
void LoadFactionChangeQuests ()
 
void LoadFactionChangeReputations ()
 
void LoadFactionChangeSpells ()
 
void LoadFactionChangeTitles ()
 
uint32 GetQuestMoneyReward (uint8 level, uint32 questMoneyDifficulty) const
 
void SendServerMail (Player *player, uint32 id, uint32 reqLevel, uint32 reqPlayTime, uint32 rewardMoneyA, uint32 rewardMoneyH, uint32 rewardItemA, uint32 rewardItemCountA, uint32 rewardItemH, uint32 rewardItemCountH, std::string subject, std::string body, uint8 active) const
 
void LoadInstanceSavedGameobjectStateData ()
 
bool FindInstanceSavedGameobjectState (uint32 id, uint32 guid)
 
uint8 GetInstanceSavedGameobjectState (uint32 id, uint32 guid)
 
void SetInstanceSavedGameobjectState (uint32 id, uint32 guid, uint8 state)
 
void NewInstanceSavedGameobjectState (uint32 id, uint32 guid, uint8 state)
 

Detailed Description

Member Typedef Documentation

◆ AreaTriggerContainer

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

◆ AreaTriggerScriptContainer

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

◆ AreaTriggerTeleportContainer

◆ BaseXPContainer

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

◆ CharacterConversionMap

◆ DungeonProgressionRequirementsContainer

◆ ExclusiveQuestGroups

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

◆ ExclusiveQuestGroupsBounds

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

◆ FishingBaseSkillContainer

◆ GossipTextContainer

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

◆ HalfNameContainer

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

◆ HalfNameContainerLocale

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

◆ ItemMap

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

◆ ItemSetNameContainer

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

◆ PetLevelInfoContainer

◆ PlayerXPperLevel

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

◆ PointOfInterestContainer

◆ ProfanityNamesContainer

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

◆ QuestAreaTriggerContainer

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

◆ QuestMap

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

◆ RepOnKillContainer

◆ RepRewardRateContainer

◆ RepSpilloverTemplateContainer

◆ ReservedNamesContainer

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

◆ ScriptNameContainer

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

◆ TavernAreaTriggerContainer

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

Member Enumeration Documentation

◆ CreatureLinkedRespawnType

Enumerator
CREATURE_TO_CREATURE 
CREATURE_TO_GO 
GO_TO_GO 
GO_TO_CREATURE 
1620 {
1622 CREATURE_TO_GO, // Creature is dependant on GO
1623 GO_TO_GO,
1624 GO_TO_CREATURE, // GO is dependant on creature
1625 };
@ CREATURE_TO_GO
Definition: ObjectMgr.h:1622
@ CREATURE_TO_CREATURE
Definition: ObjectMgr.h:1621
@ GO_TO_GO
Definition: ObjectMgr.h:1623
@ GO_TO_CREATURE
Definition: ObjectMgr.h:1624

Constructor & Destructor Documentation

◆ ObjectMgr()

ObjectMgr::ObjectMgr ( )
private
353 :
354 _auctionId(1),
356 _mailId(1),
357 _hiPetNumber(1),
361{
362 for (uint8 i = 0; i < MAX_CLASSES; ++i)
363 {
364 _playerClassInfo[i] = nullptr;
365 for (uint8 j = 0; j < MAX_RACES; ++j)
366 _playerInfo[j][i] = nullptr;
367 }
368}
@ LOCALE_enUS
Definition: Common.h:68
std::uint8_t uint8
Definition: Define.h:110
#define MAX_RACES
Definition: SharedDefines.h:95
#define MAX_CLASSES
Definition: SharedDefines.h:155
PlayerInfo * _playerInfo[MAX_RACES][MAX_CLASSES]
Definition: ObjectMgr.h:1551
ObjectGuid::LowType _gameObjectSpawnId
Definition: ObjectMgr.h:1463
uint32 _mailId
Definition: ObjectMgr.h:1457
ObjectGuid::LowType _creatureSpawnId
Definition: ObjectMgr.h:1462
LocaleConstant DBCLocaleIndex
Definition: ObjectMgr.h:1529
PlayerClassInfo * _playerClassInfo[MAX_CLASSES]
Definition: ObjectMgr.h:1547
uint64 _equipmentSetGuid
Definition: ObjectMgr.h:1456
uint32 _auctionId
Definition: ObjectMgr.h:1455
uint32 _hiPetNumber
Definition: ObjectMgr.h:1459

References _playerClassInfo, _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ ~ObjectMgr()

ObjectMgr::~ObjectMgr ( )
private
371{
372 for (QuestMap::iterator i = _questTemplates.begin(); i != _questTemplates.end(); ++i)
373 delete i->second;
374
375 for (PetLevelInfoContainer::iterator i = _petInfoStore.begin(); i != _petInfoStore.end(); ++i)
376 delete[] i->second;
377
378 // free only if loaded
379 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
380 {
381 if (_playerClassInfo[class_])
382 delete[] _playerClassInfo[class_]->levelInfo;
383 delete _playerClassInfo[class_];
384 }
385
386 for (int race = 0; race < MAX_RACES; ++race)
387 {
388 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
389 {
390 if (_playerInfo[race][class_])
391 delete[] _playerInfo[race][class_]->levelInfo;
392 delete _playerInfo[race][class_];
393 }
394 }
395
396 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
397 itr->second.Clear();
398
400
401 for (DungeonEncounterContainer::iterator itr = _dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr)
402 for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr)
403 delete *encounterItr;
404
405 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
406 {
407 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
408 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
409 {
410 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
411 {
412 delete* questItr;
413 }
414
415 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
416 {
417 delete* achievementItr;
418 }
419
420 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
421 {
422 delete* itemsItr;
423 }
424
425 delete difficultiesItr->second;
426 }
427 }
428}
PlayerClassLevelInfo * levelInfo
Definition: Player.h:300
PlayerLevelInfo * levelInfo
Definition: Player.h:354
CacheTrainerSpellContainer _cacheTrainerSpellStore
Definition: ObjectMgr.h:1612
PetLevelInfoContainer _petInfoStore
Definition: ObjectMgr.h:1545
QuestMap _questTemplates
Definition: ObjectMgr.h:1478
DungeonProgressionRequirementsContainer _accessRequirementStore
Definition: ObjectMgr.h:1492
DungeonEncounterContainer _dungeonEncounterStore
Definition: ObjectMgr.h:1493
CacheVendorItemContainer _cacheVendorItemStore
Definition: ObjectMgr.h:1611

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 
)
2348{
2349 uint8 mask = data->spawnMask;
2350 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2351 {
2352 if (mask & 1)
2353 {
2354 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2355 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2356 cell_guids.creatures.insert(guid);
2357 }
2358 }
2359}
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition: ObjectDefines.h:87
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:191
Definition: ObjectMgr.h:479
CellGuidSet creatures
Definition: ObjectMgr.h:480
MapObjectGuids _mapObjectGuidsStore
Definition: ObjectMgr.h:1572
uint32 GetId() const
Definition: GridDefines.h:148

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

Referenced by AddCreData(), and LoadCreatures().

◆ AddCreData()

uint32 ObjectMgr::AddCreData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0 
)
2427{
2428 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2429 if (!cInfo)
2430 return 0;
2431
2432 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2433 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2434 Map* map = sMapMgr->CreateBaseMap(mapId);
2435 if (!map)
2436 return 0;
2437
2439 CreatureData& data = NewOrExistCreatureData(spawnId);
2440 data.spawnMask = spawnId;
2441 data.id1 = entry;
2442 data.id2 = 0;
2443 data.id3 = 0;
2444 data.mapid = mapId;
2445 data.displayid = 0;
2446 data.equipmentId = 0;
2447 data.posX = x;
2448 data.posY = y;
2449 data.posZ = z;
2450 data.orientation = o;
2451 data.spawntimesecs = spawntimedelay;
2452 data.wander_distance = 0;
2453 data.currentwaypoint = 0;
2454 data.curhealth = stats->GenerateHealth(cInfo);
2455 data.curmana = stats->GenerateMana(cInfo);
2456 data.movementType = cInfo->MovementType;
2457 data.spawnMask = 1;
2459 data.dbData = false;
2460 data.npcflag = cInfo->npcflag;
2461 data.unit_flags = cInfo->unit_flags;
2462 data.dynamicflags = cInfo->dynamicflags;
2463
2464 AddCreatureToGrid(spawnId, &data);
2465
2466 // Spawn if necessary (loaded grids only)
2467 if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
2468 {
2469 Creature* creature = new Creature();
2470 if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true))
2471 {
2472 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2473 delete creature;
2474 return 0;
2475 }
2476 }
2477
2478 return spawnId;
2479}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ PHASEMASK_NORMAL
Definition: Object.h:56
#define sMapMgr
Definition: MapMgr.h:221
Definition: Creature.h:46
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool gridLoad=false, bool allowDuplicate=false)
Definition: Creature.cpp:1630
Definition: CreatureData.h:176
uint32 unit_flags
Definition: CreatureData.h:207
uint8 minlevel
Definition: CreatureData.h:188
uint8 maxlevel
Definition: CreatureData.h:189
uint32 MovementType
Definition: CreatureData.h:227
uint32 npcflag
Definition: CreatureData.h:192
uint32 unit_class
Definition: CreatureData.h:206
uint32 dynamicflags
Definition: CreatureData.h:209
Definition: CreatureData.h:292
uint32 GenerateMana(CreatureTemplate const *info) const
Definition: CreatureData.h:307
uint32 GenerateHealth(CreatureTemplate const *info) const
Definition: CreatureData.h:302
Definition: CreatureData.h:359
float wander_distance
Definition: CreatureData.h:373
uint32 phaseMask
Definition: CreatureData.h:365
uint32 spawntimesecs
Definition: CreatureData.h:372
uint32 dynamicflags
Definition: CreatureData.h:381
uint32 npcflag
Definition: CreatureData.h:379
bool dbData
Definition: CreatureData.h:383
uint32 displayid
Definition: CreatureData.h:366
uint8 movementType
Definition: CreatureData.h:377
uint8 spawnMask
Definition: CreatureData.h:378
uint32 unit_flags
Definition: CreatureData.h:380
uint32 id2
Definition: CreatureData.h:362
uint32 curhealth
Definition: CreatureData.h:375
float orientation
Definition: CreatureData.h:371
uint32 curmana
Definition: CreatureData.h:376
uint32 id3
Definition: CreatureData.h:363
float posY
Definition: CreatureData.h:369
float posX
Definition: CreatureData.h:368
int8 equipmentId
Definition: CreatureData.h:367
uint32 currentwaypoint
Definition: CreatureData.h:374
uint16 mapid
Definition: CreatureData.h:364
float posZ
Definition: CreatureData.h:370
uint32 id1
Definition: CreatureData.h:361
uint32 LowType
Definition: ObjectGuid.h:124
CreatureBaseStats const * GetCreatureBaseStats(uint8 level, uint8 unitClass)
Definition: ObjectMgr.cpp:9619
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition: ObjectMgr.cpp:2347
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition: ObjectMgr.cpp:7041
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition: ObjectMgr.h:1206
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition: ObjectMgr.cpp:9967
Definition: Map.h:313
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:363
bool Instanceable() const
Definition: Map.h:447

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

◆ AddGameobjectInfo()

void ObjectMgr::AddGameobjectInfo ( GameObjectTemplate goinfo)

◆ AddGameobjectToGrid()

void ObjectMgr::AddGameobjectToGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2654{
2655 uint8 mask = data->spawnMask;
2656 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2657 {
2658 if (mask & 1)
2659 {
2660 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2661 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2662 cell_guids.gameobjects.insert(guid);
2663 }
2664 }
2665}
CellGuidSet gameobjects
Definition: ObjectMgr.h:481

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

Referenced by AddGOData(), and LoadGameobjects().

◆ AddGameTele()

bool ObjectMgr::AddGameTele ( GameTele data)
8851{
8852 // find max id
8853 uint32 new_id = 0;
8854 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8855 if (itr->first > new_id)
8856 new_id = itr->first;
8857
8858 // use next
8859 ++new_id;
8860
8861 if (!Utf8toWStr(tele.name, tele.wnameLow))
8862 return false;
8863
8864 wstrToLower(tele.wnameLow);
8865
8866 _gameTeleStore[new_id] = tele;
8867
8869
8870 stmt->SetData(0, new_id);
8871 stmt->SetData(1, tele.position_x);
8872 stmt->SetData(2, tele.position_y);
8873 stmt->SetData(3, tele.position_z);
8874 stmt->SetData(4, tele.orientation);
8875 stmt->SetData(5, uint16(tele.mapId));
8876 stmt->SetData(6, tele.name);
8877
8878 WorldDatabase.Execute(stmt);
8879
8880 return true;
8881}
std::uint16_t uint16
Definition: Define.h:109
void wstrToLower(std::wstring &str)
Definition: Util.cpp:382
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
@ WORLD_INS_GAME_TELE
Definition: WorldDatabase.h:41
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
GameTeleContainer _gameTeleStore
Definition: ObjectMgr.h:1518

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

◆ AddGOData()

uint32 ObjectMgr::AddGOData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0,
float  rotation0 = 0,
float  rotation1 = 0,
float  rotation2 = 0,
float  rotation3 = 0 
)
2376{
2377 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2378 if (!goinfo)
2379 return 0;
2380
2381 Map* map = sMapMgr->CreateBaseMap(mapId);
2382 if (!map)
2383 return 0;
2384
2386
2387 GameObjectData& data = NewGOData(spawnId);
2388 data.id = entry;
2389 data.mapid = mapId;
2390 data.posX = x;
2391 data.posY = y;
2392 data.posZ = z;
2393 data.orientation = o;
2394 data.rotation.x = rotation0;
2395 data.rotation.y = rotation1;
2396 data.rotation.z = rotation2;
2397 data.rotation.w = rotation3;
2398 data.spawntimesecs = spawntimedelay;
2399 data.animprogress = 100;
2400 data.spawnMask = 1;
2401 data.go_state = GO_STATE_READY;
2403 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2404 data.dbData = false;
2405
2406 AddGameobjectToGrid(spawnId, &data);
2407
2408 // Spawn if necessary (loaded grids only)
2409 // We use spawn coords to spawn
2410 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2411 {
2412 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(data.id) ? new StaticTransport() : new GameObject();
2413 if (!go->LoadGameObjectFromDB(spawnId, map))
2414 {
2415 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2416 delete go;
2417 return 0;
2418 }
2419 }
2420
2421 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2422
2423 return spawnId;
2424}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
@ GO_STATE_READY
Definition: GameObjectData.h:691
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition: SharedDefines.h:1589
Definition: GameObject.h:122
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition: GameObject.cpp:1120
Definition: GameObjectData.h:32
uint32 type
Definition: GameObjectData.h:34
Definition: GameObjectData.h:697
bool dbData
Definition: GameObjectData.h:713
float orientation
Definition: GameObjectData.h:705
float posZ
Definition: GameObjectData.h:704
uint8 artKit
Definition: GameObjectData.h:712
int32 spawntimesecs
Definition: GameObjectData.h:707
uint8 spawnMask
Definition: GameObjectData.h:711
G3D::Quat rotation
Definition: GameObjectData.h:706
uint32 animprogress
Definition: GameObjectData.h:709
uint16 mapid
Definition: GameObjectData.h:700
float posX
Definition: GameObjectData.h:702
uint32 phaseMask
Definition: GameObjectData.h:701
float posY
Definition: GameObjectData.h:703
uint32 id
Definition: GameObjectData.h:699
GOState go_state
Definition: GameObjectData.h:710
Definition: Transport.h:112
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition: ObjectMgr.cpp:2653
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition: ObjectMgr.cpp:9943
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition: ObjectMgr.cpp:7051
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition: ObjectMgr.h:1311
bool IsGridLoaded(float x, float y) const
Definition: Map.h:369

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

◆ AddLocaleString()

void ObjectMgr::AddLocaleString ( std::string &&  s,
LocaleConstant  locale,
std::vector< std::string > &  data 
)
static

◆ AddProfanityPlayerName()

void ObjectMgr::AddProfanityPlayerName ( std::string const &  name)
8270{
8271 if (!IsProfanityName(name))
8272 {
8273 std::wstring wstr;
8274 if (!Utf8toWStr(name, wstr))
8275 {
8276 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
8277 return;
8278 }
8279 wstrToLower(wstr);
8280
8281 _profanityNamesStore.insert(wstr);
8282
8284 stmt->SetData(0, name);
8285 CharacterDatabase.Execute(stmt);
8286 }
8287}
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_INS_PROFANITY_PLAYER_NAME
Definition: CharacterDatabase.h:513
bool IsProfanityName(std::string_view name) const
Definition: ObjectMgr.cpp:8254
ReservedNamesContainer _profanityNamesStore
Definition: ObjectMgr.h:1516

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

◆ AddReservedPlayerName()

void ObjectMgr::AddReservedPlayerName ( std::string const &  name)
8195{
8196 if (!IsReservedName(name))
8197 {
8198 std::wstring wstr;
8199 if (!Utf8toWStr(name, wstr))
8200 {
8201 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
8202 return;
8203 }
8204 wstrToLower(wstr);
8205
8206 _reservedNamesStore.insert(wstr);
8207
8209 stmt->SetData(0, name);
8210 CharacterDatabase.Execute(stmt);
8211 }
8212}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition: CharacterDatabase.h:512
bool IsReservedName(std::string_view name) const
Definition: ObjectMgr.cpp:8179
ReservedNamesContainer _reservedNamesStore
Definition: ObjectMgr.h:1512

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 
)
8972{
8973 if (entry >= ACORE_TRAINER_START_REF)
8974 return;
8975
8976 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
8977 if (!cInfo)
8978 {
8979 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a non-existing creature template (Entry: {}), ignoring", entry);
8980 return;
8981 }
8982
8983 if (!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
8984 {
8985 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a creature template (Entry: {}) without trainer flag, ignoring", entry);
8986 return;
8987 }
8988
8989 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spell);
8990 if (!spellinfo)
8991 {
8992 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}), ignoring", entry, spell);
8993 return;
8994 }
8995
8996 if (!SpellMgr::ComputeIsSpellValid(spellinfo))
8997 {
8998 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a broken spell (Spell: {}), ignoring", entry, spell);
8999 return;
9000 }
9001
9002 if (GetTalentSpellCost(spell))
9003 {
9004 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}) which is a talent, ignoring", entry, spell);
9005 return;
9006 }
9007
9008 if (reqSpell && !sSpellMgr->GetSpellInfo(reqSpell))
9009 {
9010 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing reqSpell (Spell: {}), ignoring", entry, reqSpell);
9011 return;
9012 }
9013
9015
9016 TrainerSpell& trainerSpell = data.spellList[spell];
9017 trainerSpell.spell = spell;
9018 trainerSpell.spellCost = spellCost;
9019 trainerSpell.reqSkill = reqSkill;
9020 trainerSpell.reqSkillValue = reqSkillValue;
9021 trainerSpell.reqLevel = reqLevel;
9022 trainerSpell.reqSpell = reqSpell;
9023
9024 if (!trainerSpell.reqLevel)
9025 trainerSpell.reqLevel = spellinfo->SpellLevel;
9026
9027 // calculate learned spell for profession case when stored cast-spell
9028 trainerSpell.learnedSpell[0] = spell;
9029 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
9030 {
9031 if (spellinfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
9032 continue;
9033 if (trainerSpell.learnedSpell[0] == spell)
9034 trainerSpell.learnedSpell[0] = 0;
9035 // player must be able to cast spell on himself
9036 if (spellinfo->Effects[i].TargetA.GetTarget() != 0 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ALLY
9037 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_CASTER)
9038 {
9039 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);
9040 continue;
9041 }
9042
9043 trainerSpell.learnedSpell[i] = spellinfo->Effects[i].TriggerSpell;
9044
9045 if (trainerSpell.learnedSpell[i])
9046 {
9047 SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.learnedSpell[i]);
9048 if (learnedSpellInfo && learnedSpellInfo->IsProfession())
9049 data.trainerType = 2;
9050 }
9051 }
9052
9053 return;
9054}
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:682
@ UNIT_NPC_FLAG_TRAINER
Definition: Unit.h:520
#define ACORE_TRAINER_START_REF
Definition: ObjectMgr.h:494
#define sSpellMgr
Definition: SpellMgr.h:825
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1635
@ 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
Definition: CreatureData.h:496
uint32 reqSkillValue
Definition: CreatureData.h:506
uint32 learnedSpell[3]
Definition: CreatureData.h:508
uint32 reqSpell
Definition: CreatureData.h:509
uint32 spellCost
Definition: CreatureData.h:504
uint32 reqSkill
Definition: CreatureData.h:505
uint32 reqLevel
Definition: CreatureData.h:507
uint32 spell
Definition: CreatureData.h:503
Definition: CreatureData.h:518
TrainerSpellMap spellList
Definition: CreatureData.h:522
uint32 trainerType
Definition: CreatureData.h:523
Definition: SpellInfo.h:314
uint32 SpellLevel
Definition: SpellInfo.h:358
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:391
bool IsProfession() const
Definition: SpellInfo.cpp:940
static bool ComputeIsSpellValid(SpellInfo const *spellInfo, bool msg=true)
Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book,...
Definition: SpellMgr.cpp:371

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

Referenced by LoadTrainerSpell().

◆ AddVendorItem()

void ObjectMgr::AddVendorItem ( uint32  entry,
uint32  item,
int32  maxcount,
uint32  incrtime,
uint32  extendedCost,
bool  persist = true 
)
9297{
9298 VendorItemData& vList = _cacheVendorItemStore[entry];
9299 vList.AddItem(item, maxcount, incrtime, extendedCost);
9300
9301 if (persist)
9302 {
9304
9305 stmt->SetData(0, entry);
9306 stmt->SetData(1, item);
9307 stmt->SetData(2, maxcount);
9308 stmt->SetData(3, incrtime);
9309 stmt->SetData(4, extendedCost);
9310
9311 WorldDatabase.Execute(stmt);
9312 }
9313}
@ WORLD_INS_NPC_VENDOR
Definition: WorldDatabase.h:43
Definition: CreatureData.h:458
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition: CreatureData.h:470

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
4326{
4327 // base data (last known level)
4328 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
4329
4330 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
4331 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
4332 {
4333 switch (_class)
4334 {
4335 case CLASS_WARRIOR:
4336 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4337 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4338 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4339 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4340 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4341 break;
4342 case CLASS_PALADIN:
4343 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
4344 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4345 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
4346 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
4347 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
4348 break;
4349 case CLASS_HUNTER:
4350 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
4351 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4352 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4353 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
4354 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4355 break;
4356 case CLASS_ROGUE:
4357 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
4358 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4359 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
4360 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
4361 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4362 break;
4363 case CLASS_PRIEST:
4364 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4365 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4366 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4367 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
4368 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
4369 break;
4370 case CLASS_SHAMAN:
4371 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4372 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4373 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
4374 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
4375 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
4376 break;
4377 case CLASS_MAGE:
4378 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4379 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4380 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4381 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
4382 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4383 break;
4384 case CLASS_WARLOCK:
4385 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4386 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4387 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4388 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4389 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4390 break;
4391 case CLASS_DRUID:
4392 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4393 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
4394 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4395 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
4396 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
4397 }
4398 }
4399}
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:236
@ 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:447

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 
)
8670{
8671 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8672 if (!fArea)
8673 {
8674 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8675 return;
8676 }
8677
8678 _fishingBaseForAreaStore[entry] = skill;
8679
8680 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
8681 LOG_INFO("server.loading", " ");
8682}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
FishingBaseSkillContainer _fishingBaseForAreaStore
Definition: ObjectMgr.h:1560
Definition: DBCStructure.h:519

References _fishingBaseForAreaStore, LOG_ERROR, LOG_INFO, and sAreaTableStore.

◆ CheckCreatureMovement()

void ObjectMgr::CheckCreatureMovement ( char const *  table,
uint64  id,
CreatureMovementData creatureMovement 
)
1325{
1326 if (creatureMovement.Ground >= CreatureGroundMovementType::Max)
1327 {
1328 LOG_ERROR("sql.sql", "`{}`.`Ground` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Ground), id);
1329 creatureMovement.Ground = CreatureGroundMovementType::Run;
1330 }
1331
1332 if (creatureMovement.Flight >= CreatureFlightMovementType::Max)
1333 {
1334 LOG_ERROR("sql.sql", "`{}`.`Flight` wrong value ({}) for Id {}, setting to None.", table, uint32(creatureMovement.Flight), id);
1335 creatureMovement.Flight = CreatureFlightMovementType::None;
1336 }
1337
1338 if (creatureMovement.Chase >= CreatureChaseMovementType::Max)
1339 {
1340 LOG_ERROR("sql.sql", "`{}`.`Chase` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Chase), id);
1341 creatureMovement.Chase = CreatureChaseMovementType::Run;
1342 }
1343
1344 if (creatureMovement.Random >= CreatureRandomMovementType::Max)
1345 {
1346 LOG_ERROR("sql.sql", "`{}`.`Random` wrong value ({}) for Id {}, setting to Walk.", table, uint32(creatureMovement.Random), id);
1347 creatureMovement.Random = CreatureRandomMovementType::Walk;
1348 }
1349}
CreatureRandomMovementType Random
Definition: CreatureData.h:133
CreatureFlightMovementType Flight
Definition: CreatureData.h:129
CreatureChaseMovementType Chase
Definition: CreatureData.h:132
CreatureGroundMovementType Ground
Definition: CreatureData.h:128

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

Referenced by CheckCreatureTemplate(), and LoadCreatureMovementOverrides().

◆ CheckCreatureTemplate()

void ObjectMgr::CheckCreatureTemplate ( CreatureTemplate const *  cInfo)

if not set custom creature scale then load scale from CreatureDisplayInfo.dbc

967{
968 if (!cInfo)
969 return;
970
971 bool ok = true; // bool to allow continue outside this loop
972 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
973 {
974 if (!cInfo->DifficultyEntry[diff])
975 continue;
976 ok = false; // will be set to true at the end of this loop again
977
978 CreatureTemplate const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
979 if (!difficultyInfo)
980 {
981 LOG_ERROR("sql.sql", "Creature (Entry: {}) has `difficulty_entry_{}`={} but creature entry {} does not exist.",
982 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]);
983 continue;
984 }
985
986 bool ok2 = true;
987 for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2)
988 {
989 ok2 = false;
990 if (_difficultyEntries[diff2].find(cInfo->Entry) != _difficultyEntries[diff2].end())
991 {
992 LOG_ERROR("sql.sql", "Creature (Entry: {}) is listed as `difficulty_entry_{}` of another creature, but itself lists {} in `difficulty_entry_{}`.",
993 cInfo->Entry, diff2 + 1, cInfo->DifficultyEntry[diff], diff + 1);
994 continue;
995 }
996
997 if (_difficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != _difficultyEntries[diff2].end())
998 {
999 LOG_ERROR("sql.sql", "Creature (Entry: {}) already listed as `difficulty_entry_{}` for another entry.", cInfo->DifficultyEntry[diff], diff2 + 1);
1000 continue;
1001 }
1002
1003 if (_hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != _hasDifficultyEntries[diff2].end())
1004 {
1005 LOG_ERROR("sql.sql", "Creature (Entry: {}) has `difficulty_entry_{}`={} but creature entry {} has itself a value in `difficulty_entry_{}`.",
1006 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1);
1007 continue;
1008 }
1009 ok2 = true;
1010 }
1011 if (!ok2)
1012 continue;
1013
1014 if (cInfo->expansion > difficultyInfo->expansion)
1015 {
1016 LOG_ERROR("sql.sql", "Creature (Entry: {}, expansion {}) has different `expansion` in difficulty {} mode (Entry: {}, expansion {}).",
1017 cInfo->Entry, cInfo->expansion, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->expansion);
1018 }
1019
1020 if (cInfo->faction != difficultyInfo->faction)
1021 {
1022 LOG_ERROR("sql.sql", "Creature (Entry: {}, faction {}) has different `faction` in difficulty {} mode (Entry: {}, faction {}).",
1023 cInfo->Entry, cInfo->faction, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->faction);
1024 }
1025
1026 if (cInfo->unit_class != difficultyInfo->unit_class)
1027 {
1028 LOG_ERROR("sql.sql", "Creature (Entry: {}, class {}) has different `unit_class` in difficulty {} mode (Entry: {}, class {}).",
1029 cInfo->Entry, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class);
1030 continue;
1031 }
1032
1033 if (cInfo->npcflag != difficultyInfo->npcflag)
1034 {
1035 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `npcflag` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1036 continue;
1037 }
1038
1039 if (cInfo->family != difficultyInfo->family)
1040 {
1041 LOG_ERROR("sql.sql", "Creature (Entry: {}, family {}) has different `family` in difficulty {} mode (Entry: {}, family {}).",
1042 cInfo->Entry, cInfo->family, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->family);
1043 }
1044
1045 if (cInfo->trainer_class != difficultyInfo->trainer_class)
1046 {
1047 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_class` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1048 continue;
1049 }
1050
1051 if (cInfo->trainer_race != difficultyInfo->trainer_race)
1052 {
1053 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_race` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1054 continue;
1055 }
1056
1057 if (cInfo->trainer_type != difficultyInfo->trainer_type)
1058 {
1059 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_type` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1060 continue;
1061 }
1062
1063 if (cInfo->trainer_spell != difficultyInfo->trainer_spell)
1064 {
1065 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_spell` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1066 continue;
1067 }
1068
1069 if (cInfo->type != difficultyInfo->type)
1070 {
1071 LOG_ERROR("sql.sql", "Creature (Entry: {}, type {}) has different `type` in difficulty {} mode (Entry: {}, type {}).",
1072 cInfo->Entry, cInfo->type, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->type);
1073 }
1074
1075 if (!cInfo->VehicleId && difficultyInfo->VehicleId)
1076 {
1077 LOG_ERROR("sql.sql", "Creature (Entry: {}, VehicleId {}) has different `VehicleId` in difficulty {} mode (Entry: {}, VehicleId {}).",
1078 cInfo->Entry, cInfo->VehicleId, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->VehicleId);
1079 }
1080
1081 // Xinef: check dmg school
1082 if (cInfo->dmgschool != difficultyInfo->dmgschool)
1083 {
1084 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `dmgschool` in difficulty {} mode (Entry: {})", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1085 }
1086
1087 if (!difficultyInfo->AIName.empty())
1088 {
1089 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists difficulty {} mode entry {} with `AIName` filled in. `AIName` of difficulty 0 mode creature is always used instead.",
1090 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1091 continue;
1092 }
1093
1094 if (difficultyInfo->ScriptID)
1095 {
1096 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists difficulty {} mode entry {} with `ScriptName` filled in. `ScriptName` of difficulty 0 mode creature is always used instead.",
1097 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1098 continue;
1099 }
1100
1101 _hasDifficultyEntries[diff].insert(cInfo->Entry);
1102 _difficultyEntries[diff].insert(cInfo->DifficultyEntry[diff]);
1103 ok = true;
1104 }
1105
1106 if (!cInfo->AIName.empty() && !sCreatureAIRegistry->HasItem(cInfo->AIName))
1107 {
1108 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-registered `AIName` '{}' set, removing", cInfo->Entry, cInfo->AIName);
1109 const_cast<CreatureTemplate*>(cInfo)->AIName.clear();
1110 }
1111
1112 FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction);
1113 if (!factionTemplate)
1114 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing faction template ({}).", cInfo->Entry, cInfo->faction);
1115
1116 // used later for scale
1117 CreatureDisplayInfoEntry const* displayScaleEntry = nullptr;
1118
1119 if (cInfo->Modelid1)
1120 {
1121 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid1);
1122 if (!displayEntry)
1123 {
1124 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid1 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid1);
1125 const_cast<CreatureTemplate*>(cInfo)->Modelid1 = 0;
1126 }
1127 else if (!displayScaleEntry)
1128 displayScaleEntry = displayEntry;
1129
1130 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid1);
1131 if (!modelInfo)
1132 LOG_ERROR("sql.sql", "No model data exist for `Modelid1` = {} listed by creature (Entry: {}).", cInfo->Modelid1, cInfo->Entry);
1133 }
1134
1135 if (cInfo->Modelid2)
1136 {
1137 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid2);
1138 if (!displayEntry)
1139 {
1140 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid2 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid2);
1141 const_cast<CreatureTemplate*>(cInfo)->Modelid2 = 0;
1142 }
1143 else if (!displayScaleEntry)
1144 displayScaleEntry = displayEntry;
1145
1146 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid2);
1147 if (!modelInfo)
1148 LOG_ERROR("sql.sql", "No model data exist for `Modelid2` = {} listed by creature (Entry: {}).", cInfo->Modelid2, cInfo->Entry);
1149 }
1150
1151 if (cInfo->Modelid3)
1152 {
1153 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid3);
1154 if (!displayEntry)
1155 {
1156 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid3 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid3);
1157 const_cast<CreatureTemplate*>(cInfo)->Modelid3 = 0;
1158 }
1159 else if (!displayScaleEntry)
1160 displayScaleEntry = displayEntry;
1161
1162 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid3);
1163 if (!modelInfo)
1164 LOG_ERROR("sql.sql", "No model data exist for `Modelid3` = {} listed by creature (Entry: {}).", cInfo->Modelid3, cInfo->Entry);
1165 }
1166
1167 if (cInfo->Modelid4)
1168 {
1169 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid4);
1170 if (!displayEntry)
1171 {
1172 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid4 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid4);
1173 const_cast<CreatureTemplate*>(cInfo)->Modelid4 = 0;
1174 }
1175 else if (!displayScaleEntry)
1176 displayScaleEntry = displayEntry;
1177
1178 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid4);
1179 if (!modelInfo)
1180 LOG_ERROR("sql.sql", "No model data exist for `Modelid4` = {} listed by creature (Entry: {}).", cInfo->Modelid4, cInfo->Entry);
1181 }
1182
1183 if (!displayScaleEntry)
1184 LOG_ERROR("sql.sql", "Creature (Entry: {}) does not have any existing display id in Modelid1/Modelid2/Modelid3/Modelid4.", cInfo->Entry);
1185
1186 for (int k = 0; k < MAX_KILL_CREDIT; ++k)
1187 {
1188 if (cInfo->KillCredit[k])
1189 {
1190 if (!GetCreatureTemplate(cInfo->KillCredit[k]))
1191 {
1192 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing creature entry {} in `KillCredit{}`.", cInfo->Entry, cInfo->KillCredit[k], k + 1);
1193 const_cast<CreatureTemplate*>(cInfo)->KillCredit[k] = 0;
1194 }
1195 }
1196 }
1197
1198 if (!cInfo->unit_class || ((1 << (cInfo->unit_class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
1199 {
1200 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid unit_class ({}) in creature_template. Set to 1 (UNIT_CLASS_WARRIOR).", cInfo->Entry, cInfo->unit_class);
1201 const_cast<CreatureTemplate*>(cInfo)->unit_class = UNIT_CLASS_WARRIOR;
1202 }
1203
1204 if (cInfo->dmgschool >= MAX_SPELL_SCHOOL)
1205 {
1206 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid spell school value ({}) in `dmgschool`.", cInfo->Entry, cInfo->dmgschool);
1207 const_cast<CreatureTemplate*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL;
1208 }
1209
1210 if (cInfo->BaseAttackTime == 0)
1211 const_cast<CreatureTemplate*>(cInfo)->BaseAttackTime = BASE_ATTACK_TIME;
1212
1213 if (cInfo->RangeAttackTime == 0)
1214 const_cast<CreatureTemplate*>(cInfo)->RangeAttackTime = BASE_ATTACK_TIME;
1215
1216 if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE)
1217 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong trainer type {}.", cInfo->Entry, cInfo->trainer_type);
1218
1219 if (cInfo->speed_walk == 0.0f)
1220 {
1221 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in speed_walk, set to 1.", cInfo->Entry, cInfo->speed_walk);
1222 const_cast<CreatureTemplate*>(cInfo)->speed_walk = 1.0f;
1223 }
1224
1225 if (cInfo->speed_run == 0.0f)
1226 {
1227 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in speed_run, set to 1.14286.", cInfo->Entry, cInfo->speed_run);
1228 const_cast<CreatureTemplate*>(cInfo)->speed_run = 1.14286f;
1229 }
1230
1231 if (cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type))
1232 {
1233 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid creature type ({}) in `type`.", cInfo->Entry, cInfo->type);
1234 const_cast<CreatureTemplate*>(cInfo)->type = CREATURE_TYPE_HUMANOID;
1235 }
1236
1237 // must exist or used hidden but used in data horse case
1238 if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM)
1239 {
1240 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid creature family ({}) in `family`.", cInfo->Entry, cInfo->family);
1241 const_cast<CreatureTemplate*>(cInfo)->family = 0;
1242 }
1243
1244 CheckCreatureMovement("creature_template_movement", cInfo->Entry, const_cast<CreatureTemplate*>(cInfo)->Movement);
1245
1246 if (cInfo->HoverHeight < 0.0f)
1247 {
1248 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in `HoverHeight`", cInfo->Entry, cInfo->HoverHeight);
1249 const_cast<CreatureTemplate*>(cInfo)->HoverHeight = 1.0f;
1250 }
1251
1252 if (cInfo->VehicleId)
1253 {
1254 VehicleEntry const* vehId = sVehicleStore.LookupEntry(cInfo->VehicleId);
1255 if (!vehId)
1256 {
1257 LOG_ERROR("sql.sql", "Creature (Entry: {}) has a non-existing VehicleId ({}). This *WILL* cause the client to freeze!", cInfo->Entry, cInfo->VehicleId);
1258 const_cast<CreatureTemplate*>(cInfo)->VehicleId = 0;
1259 }
1260 }
1261
1262 if (cInfo->PetSpellDataId)
1263 {
1264 CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
1265 if (!spellDataId)
1266 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing PetSpellDataId ({}).", cInfo->Entry, cInfo->PetSpellDataId);
1267 }
1268
1269 for (uint8 j = 0; j < MAX_CREATURE_SPELLS; ++j)
1270 {
1271 if (cInfo->spells[j] && !sSpellMgr->GetSpellInfo(cInfo->spells[j]))
1272 {
1273 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing Spell{} ({}), set to 0.", cInfo->Entry, j + 1, cInfo->spells[j]);
1274 const_cast<CreatureTemplate*>(cInfo)->spells[j] = 0;
1275 }
1276 }
1277
1278 if (cInfo->MovementType >= MAX_DB_MOTION_TYPE)
1279 {
1280 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong movement generator type ({}), ignored and set to IDLE.", cInfo->Entry, cInfo->MovementType);
1281 const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
1282 }
1283
1285 if (cInfo->scale <= 0.0f)
1286 {
1287 if (displayScaleEntry)
1288 const_cast<CreatureTemplate*>(cInfo)->scale = displayScaleEntry->scale;
1289 else
1290 const_cast<CreatureTemplate*>(cInfo)->scale = 1.0f;
1291 }
1292
1293 if (cInfo->expansion > (MAX_EXPANSIONS - 1))
1294 {
1295 LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: {}) with expansion {}. Ignored and set to 0.", cInfo->Entry, cInfo->expansion);
1296 const_cast<CreatureTemplate*>(cInfo)->expansion = 0;
1297 }
1298
1299 if (uint32 badFlags = (cInfo->flags_extra & ~CREATURE_FLAG_EXTRA_DB_ALLOWED))
1300 {
1301 LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: {}) with disallowed `flags_extra` {}, removing incorrect flag.", cInfo->Entry, badFlags);
1302 const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
1303 }
1304
1305 const_cast<CreatureTemplate*>(cInfo)->DamageModifier *= Creature::_GetDamageMod(cInfo->rank);
1306
1307 // Hack for modules
1308 for (auto& itr : _creatureCustomIDsStore)
1309 {
1310 if (cInfo->Entry == itr)
1311 return;
1312 }
1313
1314 if ((cInfo->GossipMenuId && !(cInfo->npcflag & UNIT_NPC_FLAG_GOSSIP)) && !(cInfo->flags_extra & CREATURE_FLAG_EXTRA_MODULE))
1315 {
1316 LOG_ERROR("sql.sql", "Creature (Entry: {}) has assigned gossip menu {}, but npcflag does not include UNIT_NPC_FLAG_GOSSIP (1).", cInfo->Entry, cInfo->GossipMenuId);
1317 }
1318 else if ((!cInfo->GossipMenuId && (cInfo->npcflag & UNIT_NPC_FLAG_GOSSIP)) && !(cInfo->flags_extra & CREATURE_FLAG_EXTRA_MODULE))
1319 {
1320 LOG_INFO("sql.sql", "Creature (Entry: {}) has npcflag UNIT_NPC_FLAG_GOSSIP (1), but gossip menu is unassigned.", cInfo->Entry);
1321 }
1322}
#define sCreatureAIRegistry
Definition: CreatureAIFactory.h:48
DBCStorage< VehicleEntry > sVehicleStore(VehicleEntryfmt)
DBCStorage< CreatureSpellDataEntry > sCreatureSpellDataStore(CreatureSpellDatafmt)
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
DBCStorage< CreatureTypeEntry > sCreatureTypeStore(CreatureTypefmt)
@ CREATURE_FLAG_EXTRA_DB_ALLOWED
Definition: CreatureData.h:85
@ CREATURE_FLAG_EXTRA_MODULE
Definition: CreatureData.h:73
#define MAX_KILL_CREDIT
Definition: CreatureData.h:34
#define BASE_ATTACK_TIME
Definition: Unit.h:40
@ UNIT_NPC_FLAG_GOSSIP
Definition: Unit.h:516
static constexpr uint32 MAX_CREATURE_SPELLS
Definition: Unit.h:153
@ MAX_DB_MOTION_TYPE
Definition: MotionMaster.h:40
@ IDLE_MOTION_TYPE
Definition: MotionMaster.h:37
spells
Definition: boss_krystallus.cpp:26
#define MAX_DIFFICULTY
Definition: DBCEnums.h:291
@ 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
static float _GetDamageMod(int32 Rank)
Definition: Creature.cpp:1530
float scale
Definition: CreatureData.h:198
uint32 trainer_spell
Definition: CreatureData.h:212
uint32 trainer_class
Definition: CreatureData.h:213
uint32 type
Definition: CreatureData.h:215
uint32 trainer_race
Definition: CreatureData.h:214
uint32 ScriptID
Definition: CreatureData.h:240
uint32 VehicleId
Definition: CreatureData.h:223
CreatureMovementData Movement
Definition: CreatureData.h:228
uint32 faction
Definition: CreatureData.h:191
uint32 dmgschool
Definition: CreatureData.h:200
uint32 expansion
Definition: CreatureData.h:190
uint32 trainer_type
Definition: CreatureData.h:211
std::string AIName
Definition: CreatureData.h:226
uint32 family
Definition: CreatureData.h:210
Definition: CreatureData.h:388
std::set< uint32 > _difficultyEntries[MAX_DIFFICULTY - 1]
Definition: ObjectMgr.h:1616
CreatureCustomIDsContainer _creatureCustomIDsStore
Definition: ObjectMgr.h:1577
std::set< uint32 > _hasDifficultyEntries[MAX_DIFFICULTY - 1]
Definition: ObjectMgr.h:1617
void CheckCreatureMovement(char const *table, uint64 id, CreatureMovementData &creatureMovement)
Definition: ObjectMgr.cpp:1324
CreatureModelInfo const * GetCreatureModelInfo(uint32 modelId) const
Definition: ObjectMgr.cpp:1717
Definition: DBCStructure.h:721
float scale
Definition: DBCStructure.h:726
Definition: DBCStructure.h:801
Definition: DBCStructure.h:930
Definition: DBCStructure.h:2028

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, GetCreatureModelInfo(), 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::Modelid1, CreatureTemplate::Modelid2, CreatureTemplate::Modelid3, CreatureTemplate::Modelid4, CreatureTemplate::Movement, CreatureTemplate::MovementType, CreatureTemplate::npcflag, CreatureTemplate::PetSpellDataId, CreatureTemplate::RangeAttackTime, CreatureTemplate::rank, CreatureTemplate::scale, CreatureDisplayInfoEntry::scale, sCreatureAIRegistry, sCreatureDisplayInfoStore, 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
8685{
8686 // get main part of the name
8687 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
8688 // prepare flags
8689 bool x = true;
8690 bool y = true;
8691
8692 // check declined names
8693 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
8694 {
8695 std::wstring wname;
8696 if (!Utf8toWStr(names.name[i], wname))
8697 return false;
8698
8699 if (mainpart != GetMainPartOfName(wname, i + 1))
8700 x = false;
8701
8702 if (w_ownname != wname)
8703 y = false;
8704 }
8705 return (x || y);
8706}
std::wstring GetMainPartOfName(std::wstring const &wname, uint32 declension)
Definition: Util.cpp:386
#define MAX_DECLINED_NAME_CASES
Definition: Unit.h:981

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
8473{
8474 std::wstring wname;
8475 if (!Utf8toWStr(name, wname))
8476 return PET_NAME_INVALID;
8477
8478 if (wname.size() > MAX_PET_NAME)
8479 return PET_NAME_TOO_LONG;
8480
8481 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
8482 if (wname.size() < minName)
8483 return PET_NAME_TOO_SHORT;
8484
8485 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
8486 if (!isValidString(wname, strictMask, false))
8488
8489 // Check for Reserved Name from DBC
8490 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8491 {
8492 if (ReservedNames(wname))
8493 {
8494 return PET_NAME_RESERVED;
8495 }
8496 }
8497
8498 // Check for Profanity
8499 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8500 {
8501 if (ProfanityNames(wname))
8502 {
8503 return PET_NAME_PROFANE;
8504 }
8505 }
8506
8507 return PET_NAME_SUCCESS;
8508}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition: ObjectMgr.cpp:8326
bool ReservedNames(std::wstring &name)
Definition: ObjectMgr.cpp:213
bool ProfanityNames(std::wstring &name)
Definition: ObjectMgr.cpp:241
#define MAX_PET_NAME
Definition: ObjectMgr.h:690
@ CONFIG_STRICT_PET_NAMES
Definition: IWorld.h:223
@ CONFIG_MIN_PET_NAME
Definition: IWorld.h:226
@ CONFIG_STRICT_NAMES_PROFANITY
Definition: IWorld.h:185
@ CONFIG_STRICT_NAMES_RESERVED
Definition: IWorld.h:184
@ 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_NAMES_PROFANITY, CONFIG_STRICT_NAMES_RESERVED, 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, ProfanityNames(), ReservedNames(), sWorld, and Utf8toWStr().

Referenced by WorldSession::HandlePetRename().

◆ CheckPlayerName()

uint8 ObjectMgr::CheckPlayerName ( std::string_view  name,
bool  create = false 
)
static
8363{
8364 std::wstring wname;
8365
8366 // Check for invalid characters
8367 if (!Utf8toWStr(name, wname))
8369
8370 // Check for too long name
8371 if (wname.size() > MAX_PLAYER_NAME)
8372 return CHAR_NAME_TOO_LONG;
8373
8374 // Check for too short name
8375 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
8376 if (wname.size() < minName)
8377 return CHAR_NAME_TOO_SHORT;
8378
8379 // Check for mixed languages
8380 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
8381 if (!isValidString(wname, strictMask, false, create))
8383
8384 // Check for three consecutive letters
8385 wstrToLower(wname);
8386 for (size_t i = 2; i < wname.size(); ++i)
8387 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
8389
8390 // Check Reserved Name from Database
8391 if (sObjectMgr->IsReservedName(name))
8392 {
8393 return CHAR_NAME_RESERVED;
8394 }
8395
8396 if (sObjectMgr->IsProfanityName(name))
8397 {
8398 return CHAR_NAME_PROFANE;
8399 }
8400
8401 // Check for Reserved Name from DBC
8402 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8403 {
8404 if (ReservedNames(wname))
8405 {
8406 return CHAR_NAME_RESERVED;
8407 }
8408 }
8409
8410 // Check for Profanity
8411 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8412 {
8413 if (ProfanityNames(wname))
8414 {
8415 return CHAR_NAME_PROFANE;
8416 }
8417 }
8418
8419 return CHAR_NAME_SUCCESS;
8420}
#define MAX_PLAYER_NAME
Definition: ObjectMgr.h:688
@ CONFIG_STRICT_PLAYER_NAMES
Definition: IWorld.h:220
@ CONFIG_MIN_PLAYER_NAME
Definition: IWorld.h:224
@ 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_NAMES_PROFANITY, CONFIG_STRICT_NAMES_RESERVED, CONFIG_STRICT_PLAYER_NAMES, isValidString(), MAX_PLAYER_NAME, ProfanityNames(), ReservedNames(), 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
1736{
1737 npcflag = cinfo->npcflag;
1738 unit_flags = cinfo->unit_flags;
1739 dynamicflags = cinfo->dynamicflags;
1740
1741 if (data)
1742 {
1743 if (data->npcflag)
1744 npcflag = data->npcflag;
1745
1746 if (data->unit_flags)
1747 unit_flags = data->unit_flags;
1748
1749 if (data->dynamicflags)
1750 dynamicflags = data->dynamicflags;
1751 }
1752}

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

Referenced by Creature::UpdateEntry().

◆ ChooseDisplayId()

uint32 ObjectMgr::ChooseDisplayId ( CreatureTemplate const *  cinfo,
CreatureData const *  data = nullptr 
)
static
1727{
1728 // Load creature model (display id)
1729 if (data && data->displayid)
1730 return data->displayid;
1731
1732 return cinfo->GetRandomValidModelId();
1733}

References CreatureData::displayid, and CreatureTemplate::GetRandomValidModelId().

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

◆ DeleteCreatureData()

void ObjectMgr::DeleteCreatureData ( ObjectGuid::LowType  spawnId)
8019{
8020 // remove mapid*cellid -> guid_set map
8021 CreatureData const* data = GetCreatureData(guid);
8022 if (data)
8023 RemoveCreatureFromGrid(guid, data);
8024
8025 _creatureDataStore.erase(guid);
8026}
CreatureDataContainer _creatureDataStore
Definition: ObjectMgr.h:1575
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition: ObjectMgr.cpp:2361
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition: ObjectMgr.h:1200

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

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
8884{
8885 // explicit name case
8886 std::wstring wname;
8887 if (!Utf8toWStr(name, wname))
8888 return false;
8889
8890 // converting string that we try to find to lower case
8891 wstrToLower(wname);
8892
8893 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8894 {
8895 if (itr->second.wnameLow == wname)
8896 {
8898
8899 stmt->SetData(0, itr->second.name);
8900
8901 WorldDatabase.Execute(stmt);
8902
8903 _gameTeleStore.erase(itr);
8904 return true;
8905 }
8906 }
8907
8908 return false;
8909}
@ 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)
8029{
8030 // remove mapid*cellid -> guid_set map
8031 GameObjectData const* data = GetGameObjectData(guid);
8032 if (data)
8033 RemoveGameobjectFromGrid(guid, data);
8034
8035 _gameObjectDataStore.erase(guid);
8036}
GameObjectData const * GetGameObjectData(ObjectGuid::LowType spawnId) const
Definition: ObjectMgr.h:1217
GameObjectDataContainer _gameObjectDataStore
Definition: ObjectMgr.h:1589
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition: ObjectMgr.cpp:2667

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

◆ FindInstanceSavedGameobjectState()

bool ObjectMgr::FindInstanceSavedGameobjectState ( uint32  id,
uint32  guid 
)
10179{
10180 for (auto it = GameobjectInstanceSavedStateList.begin(); it != GameobjectInstanceSavedStateList.end(); it++)
10181 {
10182 if (it->m_guid == guid && it->m_instance == id)
10183 {
10184 return true;
10185 }
10186 }
10187 return false;
10188}
std::vector< GameobjectInstanceSavedState > GameobjectInstanceSavedStateList
Definition: ObjectMgr.h:1637

References GameobjectInstanceSavedStateList.

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
7011{
7012 if (_auctionId >= 0xFFFFFFFE)
7013 {
7014 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
7016 }
7017 return _auctionId++;
7018}
@ ERROR_EXIT_CODE
Definition: World.h:55
static void StopNow(uint8 exitcode)
Definition: World.h:259

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

◆ GenerateCreatureSpawnId()

uint32 ObjectMgr::GenerateCreatureSpawnId ( )
7042{
7043 if (_creatureSpawnId >= uint32(0xFFFFFF))
7044 {
7045 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7047 }
7048 return _creatureSpawnId++;
7049}

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

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
7021{
7022 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
7023 {
7024 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
7026 }
7027 return _equipmentSetGuid++;
7028}
std::uint64_t uint64
Definition: Define.h:107

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

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7052{
7053 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7054 {
7055 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7057 }
7058 return _gameObjectSpawnId++;
7059}

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

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
7031{
7032 if (_mailId >= 0xFFFFFFFE)
7033 {
7034 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
7036 }
7037 std::lock_guard<std::mutex> guard(_mailIdMutex);
7038 return _mailId++;
7039}
std::mutex _mailIdMutex
Definition: ObjectMgr.h:1458

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

◆ GeneratePetName()

std::string ObjectMgr::GeneratePetName ( uint32  entry)
7518{
7519 std::vector<std::string>& list0 = _petHalfName0[entry];
7520 std::vector<std::string>& list1 = _petHalfName1[entry];
7521
7522 if (list0.empty() || list1.empty())
7523 {
7524 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
7525 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
7526 if (!petname)
7527 return cinfo->Name;
7528
7529 return std::string(petname);
7530 }
7531
7532 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7533}
char const * GetPetName(uint32 petfamily, uint32 dbclang)
Definition: DBCStores.cpp:661
std::string Name
Definition: CreatureData.h:184
HalfNameContainer _petHalfName1
Definition: ObjectMgr.h:1564
HalfNameContainer _petHalfName0
Definition: ObjectMgr.h:1563

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

Referenced by GeneratePetNameLocale().

◆ GeneratePetNameLocale()

std::string ObjectMgr::GeneratePetNameLocale ( uint32  entry,
LocaleConstant  locale 
)
7505{
7506 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
7507 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
7508
7509 if (list0.empty() || list1.empty())
7510 {
7511 return GeneratePetName(entry);
7512 }
7513
7514 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7515}
HalfNameContainerLocale _petHalfLocaleName0
Definition: ObjectMgr.h:1566
HalfNameContainerLocale _petHalfLocaleName1
Definition: ObjectMgr.h:1567
std::string GeneratePetName(uint32 entry)
Definition: ObjectMgr.cpp:7517

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

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
7536{
7537 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
7538 return ++_hiPetNumber;
7539}
std::mutex _hiPetNumberMutex
Definition: ObjectMgr.h:1460

References _hiPetNumber, and _hiPetNumberMutex.

◆ GetAccessRequirement()

DungeonProgressionRequirements const * ObjectMgr::GetAccessRequirement ( uint32  mapid,
Difficulty  difficulty 
) const
inline
877 {
878 DungeonProgressionRequirementsContainer::const_iterator itr = _accessRequirementStore.find(mapid);
879 if (itr != _accessRequirementStore.end())
880 {
881 std::unordered_map<uint8, DungeonProgressionRequirements*> difficultiesProgressionRequirements = itr->second;
882 auto difficultiesItr = difficultiesProgressionRequirements.find(difficulty);
883 if (difficultiesItr != difficultiesProgressionRequirements.end())
884 {
885 return difficultiesItr->second;
886 }
887 }
888 return nullptr;
889 }

References _accessRequirementStore.

◆ GetAcoreString() [1/2]

AcoreString const * ObjectMgr::GetAcoreString ( uint32  entry) const
inline
1315 {
1316 AcoreStringContainer::const_iterator itr = _acoreStringStore.find(entry);
1317 if (itr == _acoreStringStore.end())
1318 return nullptr;
1319
1320 return &itr->second;
1321 }
AcoreStringContainer _acoreStringStore
Definition: ObjectMgr.h:1606

References _acoreStringStore.

Referenced by GetAcoreString(), and GetAcoreStringForDBCLocale().

◆ GetAcoreString() [2/2]

char const * ObjectMgr::GetAcoreString ( uint32  entry,
LocaleConstant  locale 
) const
8617{
8618 if (AcoreString const* ts = GetAcoreString(entry))
8619 {
8620 if (ts->Content.size() > size_t(locale) && !ts->Content[locale].empty())
8621 return ts->Content[locale].c_str();
8622
8623 return ts->Content[DEFAULT_LOCALE].c_str();
8624 }
8625
8626 LOG_ERROR("sql.sql", "Acore string entry {} not found in DB.", entry);
8627
8628 return "<error>";
8629}
#define DEFAULT_LOCALE
Definition: Common.h:81
Definition: ObjectMgr.h:497
AcoreString const * GetAcoreString(uint32 entry) const
Definition: ObjectMgr.h:1314

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

◆ GetAcoreStringForDBCLocale()

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

References DBCLocaleIndex, and GetAcoreString().

◆ GetAllCreatureData()

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

References _creatureDataStore.

◆ GetAllGOData()

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

References _gameObjectDataStore.

◆ GetAllServerMailStore()

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

References _serverMailStore.

◆ GetAreaTrigger()

AreaTrigger const * ObjectMgr::GetAreaTrigger ( uint32  trigger) const
inline
861 {
862 AreaTriggerContainer::const_iterator itr = _areaTriggerStore.find(trigger);
863 if (itr != _areaTriggerStore.end())
864 return &itr->second;
865 return nullptr;
866 }
AreaTriggerContainer _areaTriggerStore
Definition: ObjectMgr.h:1489

References _areaTriggerStore.

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

◆ GetAreaTriggerScriptId()

uint32 ObjectMgr::GetAreaTriggerScriptId ( uint32  trigger_id)
8709{
8710 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
8711 if (i != _areaTriggerScriptStore.end())
8712 return i->second;
8713 return 0;
8714}
AreaTriggerScriptContainer _areaTriggerScriptStore
Definition: ObjectMgr.h:1491

References _areaTriggerScriptStore.

◆ GetAreaTriggerTeleport()

AreaTriggerTeleport const * ObjectMgr::GetAreaTriggerTeleport ( uint32  trigger) const
inline
869 {
870 AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.find(trigger);
871 if (itr != _areaTriggerTeleportStore.end())
872 return &itr->second;
873 return nullptr;
874 }
AreaTriggerTeleportContainer _areaTriggerTeleportStore
Definition: ObjectMgr.h:1490

References _areaTriggerTeleportStore.

◆ GetBaseReputationOf()

int32 ObjectMgr::GetBaseReputationOf ( FactionEntry const *  factionEntry,
uint8  race,
uint8  playerClass 
)
8723{
8724 if (!factionEntry)
8725 return 0;
8726
8727 uint32 raceMask = (1 << (race - 1));
8728 uint32 classMask = (1 << (playerClass - 1));
8729
8730 for (int i = 0; i < 4; i++)
8731 {
8732 if ((!factionEntry->BaseRepClassMask[i] ||
8733 factionEntry->BaseRepClassMask[i] & classMask) &&
8734 (!factionEntry->BaseRepRaceMask[i] ||
8735 factionEntry->BaseRepRaceMask[i] & raceMask))
8736 return factionEntry->BaseRepValue[i];
8737 }
8738
8739 return 0;
8740}

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

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
7446{
7447 return _baseXPTable[level] ? _baseXPTable[level] : 0;
7448}
BaseXPContainer _baseXPTable
Definition: ObjectMgr.h:1557

References _baseXPTable.

◆ GetBroadcastText()

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

References _broadcastTextStore.

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

◆ GetCellObjectGuids()

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

References _emptyCellObjectGuids, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetCreatureAddon()

CreatureAddon const * ObjectMgr::GetCreatureAddon ( ObjectGuid::LowType  lowguid)
1514{
1515 CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid);
1516 if (itr != _creatureAddonStore.end())
1517 return &(itr->second);
1518
1519 return nullptr;
1520}
CreatureAddonContainer _creatureAddonStore
Definition: ObjectMgr.h:1580

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
9620{
9621 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
9622
9623 if (it != _creatureBaseStatsStore.end())
9624 return &(it->second);
9625
9626 struct DefaultCreatureBaseStats : public CreatureBaseStats
9627 {
9628 DefaultCreatureBaseStats()
9629 {
9630 BaseArmor = 1;
9631 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
9632 {
9633 BaseHealth[j] = 1;
9634 BaseDamage[j] = 0.0f;
9635 }
9636 BaseMana = 0;
9637 AttackPower = 0;
9638 RangedAttackPower = 0;
9639 }
9640 };
9641 static const DefaultCreatureBaseStats defStats;
9642 return &defStats;
9643}
uint16 MAKE_PAIR16(uint8 l, uint8 h)
Definition: ObjectDefines.h:82
CreatureBaseStatsContainer _creatureBaseStatsStore
Definition: ObjectMgr.h:1541

References _creatureBaseStatsStore, MAKE_PAIR16(), and MAX_EXPANSIONS.

Referenced by AddCreData().

◆ GetCreatureData()

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

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

References _creatureLocaleStore.

◆ GetCreatureModelInfo()

CreatureModelInfo const * ObjectMgr::GetCreatureModelInfo ( uint32  modelId) const
1718{
1719 CreatureModelContainer::const_iterator itr = _creatureModelStore.find(modelId);
1720 if (itr != _creatureModelStore.end())
1721 return &(itr->second);
1722
1723 return nullptr;
1724}
CreatureModelContainer _creatureModelStore
Definition: ObjectMgr.h:1579

References _creatureModelStore.

Referenced by CheckCreatureTemplate(), and GetCreatureModelRandomGender().

◆ GetCreatureModelRandomGender()

CreatureModelInfo const * ObjectMgr::GetCreatureModelRandomGender ( uint32 displayID)
1755{
1756 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(*displayID);
1757 if (!modelInfo)
1758 return nullptr;
1759
1760 // If a model for another gender exists, 50% chance to use it
1761 if (modelInfo->modelid_other_gender != 0 && urand(0, 1) == 0)
1762 {
1763 CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender);
1764 if (!minfo_tmp)
1765 LOG_ERROR("sql.sql", "Model (Entry: {}) has modelid_other_gender {} not found in table `creature_model_info`. ", *displayID, modelInfo->modelid_other_gender);
1766 else
1767 {
1768 // Model ID changed
1769 *displayID = modelInfo->modelid_other_gender;
1770 return minfo_tmp;
1771 }
1772 }
1773
1774 return modelInfo;
1775}
uint32 modelid_other_gender
Definition: CreatureData.h:392

References GetCreatureModelInfo(), LOG_ERROR, CreatureModelInfo::modelid_other_gender, and urand().

Referenced by GetTaxiMountDisplayId().

◆ GetCreatureMovementOverride()

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

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

◆ GetCreatureQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestInvolvedRelationBounds ( uint32  creature_entry)
inline
1005 {
1006 return _creatureQuestInvolvedRelations.equal_range(creature_entry);
1007 }
QuestRelations _creatureQuestInvolvedRelations
Definition: ObjectMgr.h:1508

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestInvolvedRelationMap ( )
inline

◆ GetCreatureQuestItemList()

CreatureQuestItemList const * ObjectMgr::GetCreatureQuestItemList ( uint32  id) const
inline
824 {
825 CreatureQuestItemMap::const_iterator itr = _creatureQuestItemStore.find(id);
826 if (itr != _creatureQuestItemStore.end())
827 return &itr->second;
828 return nullptr;
829 }
CreatureQuestItemMap _creatureQuestItemStore
Definition: ObjectMgr.h:1585

References _creatureQuestItemStore.

◆ GetCreatureQuestItemMap()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestRelationBounds ( uint32  creature_entry)
inline
1000 {
1001 return _creatureQuestRelations.equal_range(creature_entry);
1002 }
QuestRelations _creatureQuestRelations
Definition: ObjectMgr.h:1507

References _creatureQuestRelations.

◆ GetCreatureQuestRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestRelationMap ( )
inline
990 {
992 }

References _creatureQuestRelations.

◆ GetCreatureTemplate()

◆ GetCreatureTemplateAddon()

CreatureAddon const * ObjectMgr::GetCreatureTemplateAddon ( uint32  entry)
1523{
1524 CreatureAddonContainer::const_iterator itr = _creatureTemplateAddonStore.find(entry);
1525 if (itr != _creatureTemplateAddonStore.end())
1526 return &(itr->second);
1527
1528 return nullptr;
1529}
CreatureAddonContainer _creatureTemplateAddonStore
Definition: ObjectMgr.h:1581

References _creatureTemplateAddonStore.

◆ GetCreatureTemplates()

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

References _creatureTemplateStore.

◆ GetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ GetDungeonEncounterList()

DungeonEncounterList const * ObjectMgr::GetDungeonEncounterList ( uint32  mapId,
Difficulty  difficulty 
)
inline
944 {
945 std::unordered_map<uint32, DungeonEncounterList>::const_iterator itr = _dungeonEncounterStore.find(MAKE_PAIR32(mapId, difficulty));
946 if (itr != _dungeonEncounterStore.end())
947 return &itr->second;
948 return nullptr;
949 }

References _dungeonEncounterStore, and MAKE_PAIR32().

◆ GetEquipmentInfo()

EquipmentInfo const * ObjectMgr::GetEquipmentInfo ( uint32  entry,
int8 id 
)
1537{
1538 EquipmentInfoContainer::const_iterator itr = _equipmentInfoStore.find(entry);
1539 if (itr == _equipmentInfoStore.end())
1540 return nullptr;
1541
1542 if (itr->second.empty())
1543 return nullptr;
1544
1545 if (id == -1) // select a random element
1546 {
1547 EquipmentInfoContainerInternal::const_iterator ritr = itr->second.begin();
1548 std::advance(ritr, urand(0u, itr->second.size() - 1));
1549 id = std::distance(itr->second.begin(), ritr) + 1;
1550 return &ritr->second;
1551 }
1552 else
1553 {
1554 EquipmentInfoContainerInternal::const_iterator itr2 = itr->second.find(id);
1555 if (itr2 != itr->second.end())
1556 return &itr2->second;
1557 }
1558
1559 return nullptr;
1560}
EquipmentInfoContainer _equipmentInfoStore
Definition: ObjectMgr.h:1586

References _equipmentInfoStore, and urand().

Referenced by LoadCreatures().

◆ GetFishingBaseSkillLevel()

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

References _fishingBaseForAreaStore.

◆ GetGameObjectAddon()

GameObjectAddon const * ObjectMgr::GetGameObjectAddon ( ObjectGuid::LowType  lowguid)
1505{
1506 GameObjectAddonContainer::const_iterator itr = _gameObjectAddonStore.find(lowguid);
1507 if (itr != _gameObjectAddonStore.end())
1508 return &(itr->second);
1509
1510 return nullptr;
1511}
GameObjectAddonContainer _gameObjectAddonStore
Definition: ObjectMgr.h:1583

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

References _gameObjectLocaleStore.

◆ GetGameObjectQuestItemList()

GameObjectQuestItemList const * ObjectMgr::GetGameObjectQuestItemList ( uint32  id) const
inline
815 {
816 GameObjectQuestItemMap::const_iterator itr = _gameObjectQuestItemStore.find(id);
817 if (itr != _gameObjectQuestItemStore.end())
818 return &itr->second;
819 return nullptr;
820 }
GameObjectQuestItemMap _gameObjectQuestItemStore
Definition: ObjectMgr.h:1584

References _gameObjectQuestItemStore.

◆ GetGameObjectQuestItemMap()

GameObjectQuestItemMap const * ObjectMgr::GetGameObjectQuestItemMap ( ) const
inline

◆ GetGameObjectTemplate()

GameObjectTemplate const * ObjectMgr::GetGameObjectTemplate ( uint32  entry)
9944{
9945 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
9946 if (itr != _gameObjectTemplateStore.end())
9947 return &(itr->second);
9948
9949 return nullptr;
9950}
GameObjectTemplateContainer _gameObjectTemplateStore
Definition: ObjectMgr.h:1591

References _gameObjectTemplateStore.

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

◆ GetGameObjectTemplateAddon()

GameObjectTemplateAddon const * ObjectMgr::GetGameObjectTemplateAddon ( uint32  entry) const
9959{
9960 auto itr = _gameObjectTemplateAddonStore.find(entry);
9961 if (itr != _gameObjectTemplateAddonStore.end())
9962 return &itr->second;
9963
9964 return nullptr;
9965}
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
Definition: ObjectMgr.h:1592

References _gameObjectTemplateAddonStore.

◆ GetGameObjectTemplates()

GameObjectTemplateContainer const * ObjectMgr::GetGameObjectTemplates ( ) const
inline

◆ GetGameTele() [1/2]

GameTele const * ObjectMgr::GetGameTele ( std::string_view  name) const
8828{
8829 // explicit name case
8830 std::wstring wname;
8831 if (!Utf8toWStr(name, wname))
8832 return nullptr;
8833
8834 // converting string that we try to find to lower case
8835 wstrToLower(wname);
8836
8837 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
8838 const GameTele* alt = nullptr;
8839 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8840 {
8841 if (itr->second.wnameLow == wname)
8842 return &itr->second;
8843 else if (!alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
8844 alt = &itr->second;
8845 }
8846
8847 return alt;
8848}
Definition: ObjectMgr.h:135

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

◆ GetGameTele() [2/2]

GameTele const * ObjectMgr::GetGameTele ( uint32  id) const
inline
1354 {
1355 GameTeleContainer::const_iterator itr = _gameTeleStore.find(id);
1356 if (itr == _gameTeleStore.end()) return nullptr;
1357 return &itr->second;
1358 }

References _gameTeleStore.

◆ GetGameTeleMap()

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

References _gameTeleStore.

◆ GetGenerator()

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

◆ GetGoBackTrigger()

AreaTriggerTeleport const * ObjectMgr::GetGoBackTrigger ( uint32  Map) const
6910{
6911 bool useParentDbValue = false;
6912 uint32 parentId = 0;
6913 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
6914 if (!mapEntry || mapEntry->entrance_map < 0)
6915 return nullptr;
6916
6917 if (mapEntry->IsDungeon())
6918 {
6919 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
6920
6921 if (!iTemplate)
6922 return nullptr;
6923
6924 parentId = iTemplate->Parent;
6925 useParentDbValue = true;
6926 }
6927
6928 uint32 entrance_map = uint32(mapEntry->entrance_map);
6929 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6930 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
6931 {
6932 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
6933 if (atEntry && atEntry->map == Map)
6934 return &itr->second;
6935 }
6936 return nullptr;
6937}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
Definition: ObjectMgr.h:421
uint32 map
Definition: ObjectMgr.h:423
AreaTrigger const * GetAreaTrigger(uint32 trigger) const
Definition: ObjectMgr.h:860
Definition: Map.h:274
uint32 Parent
Definition: Map.h:275
Definition: DBCStructure.h:1323
int32 entrance_map
Definition: DBCStructure.h:1338
bool IsDungeon() const
Definition: DBCStructure.h:1349

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

◆ GetGOQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestInvolvedRelationBounds ( uint32  go_entry)
inline
985 {
986 return _goQuestInvolvedRelations.equal_range(go_entry);
987 }
QuestRelations _goQuestInvolvedRelations
Definition: ObjectMgr.h:1506

References _goQuestInvolvedRelations.

◆ GetGOQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetGOQuestInvolvedRelationMap ( )
inline
975 {
977 }

References _goQuestInvolvedRelations.

◆ GetGOQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestRelationBounds ( uint32  go_entry)
inline
980 {
981 return _goQuestRelations.equal_range(go_entry);
982 }
QuestRelations _goQuestRelations
Definition: ObjectMgr.h:1505

References _goQuestRelations.

◆ GetGOQuestRelationMap()

QuestRelations * ObjectMgr::GetGOQuestRelationMap ( )
inline
970 {
971 return &_goQuestRelations;
972 }

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

References _gossipMenuItemsLocaleStore.

◆ GetGossipMenuItemsMapBounds()

GossipMenuItemsMapBounds ObjectMgr::GetGossipMenuItemsMapBounds ( uint32  uiMenuId) const
inline
1407 {
1408 return _gossipMenuItemsStore.equal_range(uiMenuId);
1409 }
GossipMenuItemsContainer _gossipMenuItemsStore
Definition: ObjectMgr.h:1500

References _gossipMenuItemsStore.

◆ GetGossipMenuItemsMapBoundsNonConst()

GossipMenuItemsMapBoundsNonConst ObjectMgr::GetGossipMenuItemsMapBoundsNonConst ( uint32  uiMenuId)
inline
1411 {
1412 return _gossipMenuItemsStore.equal_range(uiMenuId);
1413 }

References _gossipMenuItemsStore.

◆ GetGossipMenusMapBounds()

GossipMenusMapBounds ObjectMgr::GetGossipMenusMapBounds ( uint32  uiMenuId) const
inline
1397 {
1398 return _gossipMenusStore.equal_range(uiMenuId);
1399 }
GossipMenusContainer _gossipMenusStore
Definition: ObjectMgr.h:1499

References _gossipMenusStore.

◆ GetGossipMenusMapBoundsNonConst()

GossipMenusMapBoundsNonConst ObjectMgr::GetGossipMenusMapBoundsNonConst ( uint32  uiMenuId)
inline
1402 {
1403 return _gossipMenusStore.equal_range(uiMenuId);
1404 }

References _gossipMenusStore.

◆ GetGossipText()

GossipText const * ObjectMgr::GetGossipText ( uint32  Text_ID) const
5964{
5965 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
5966 if (itr != _gossipTextStore.end())
5967 return &itr->second;
5968 return nullptr;
5969}
GossipTextContainer _gossipTextStore
Definition: ObjectMgr.h:1487

References _gossipTextStore.

Referenced by LoadGossipMenu().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & ObjectMgr::GetGuidSequenceGenerator ( )
inlineprivate
1468 {
1469 auto itr = _guidGenerators.find(high);
1470 if (itr == _guidGenerators.end())
1471 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
1472
1473 return *itr->second;
1474 }
Definition: ObjectGuid.h:299
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition: ObjectMgr.h:1476

References _guidGenerators.

◆ GetInstanceSavedGameobjectState()

uint8 ObjectMgr::GetInstanceSavedGameobjectState ( uint32  id,
uint32  guid 
)
10167{
10168 for (auto it = GameobjectInstanceSavedStateList.begin(); it != GameobjectInstanceSavedStateList.end(); it++)
10169 {
10170 if (it->m_guid == guid && it->m_instance == id)
10171 {
10172 return it->m_state;
10173 }
10174 }
10175 return 3; // Any state higher than 2 to get the default state
10176}

References GameobjectInstanceSavedStateList.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
5870{
5871 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
5872 if (itr != _instanceTemplateStore.end())
5873 return &(itr->second);
5874
5875 return nullptr;
5876}
InstanceTemplateContainer _instanceTemplateStore
Definition: ObjectMgr.h:1532

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

References _itemLocaleStore.

◆ GetItemSetNameEntry()

ItemSetNameEntry const * ObjectMgr::GetItemSetNameEntry ( uint32  itemId)
inline
787 {
788 ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
789 if (itr != _itemSetNameStore.end())
790 return &itr->second;
791 return nullptr;
792 }
ItemSetNameContainer _itemSetNameStore
Definition: ObjectMgr.h:1570

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

References _itemSetNameLocaleStore.

◆ GetItemTemplate()

ItemTemplate const * ObjectMgr::GetItemTemplate ( uint32  entry)
3321{
3322 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3323}
std::vector< ItemTemplate * > _itemTemplateStoreFast
Definition: ObjectMgr.h:1598

References _itemTemplateStoreFast.

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

◆ GetItemTemplateStore()

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

References _itemTemplateStore.

◆ GetItemTemplateStoreFast()

std::vector< ItemTemplate * > const * ObjectMgr::GetItemTemplateStoreFast ( ) const
inline
784{ 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:122
LinkedRespawnContainer _linkedRespawnStore
Definition: ObjectMgr.h:1587

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
1424 {
1425 if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
1426 value = data[loc_idx];
1427 }

◆ GetLocaleString() [2/2]

◆ GetMailLevelReward()

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

References _mailLevelRewardStore.

◆ GetMapEntranceTrigger()

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

Searches for the areatrigger which teleports players to the given map

6943{
6944 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6945 {
6946 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
6947 {
6948 // xinef: no need to check, already done at loading
6949 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
6950 //if (atEntry)
6951 return &itr->second;
6952 }
6953 }
6954 return nullptr;
6955}

References _areaTriggerTeleportStore.

◆ GetMapObjectGuids()

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

References _emptyCellObjectGuidsMap, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetNearestTaxiNode()

uint32 ObjectMgr::GetNearestTaxiNode ( float  x,
float  y,
float  z,
uint32  mapid,
uint32  teamId 
)
6529{
6530 bool found = false;
6531 float dist = 10000;
6532 uint32 id = 0;
6533
6534 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
6535 {
6536 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
6537
6538 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
6539 continue;
6540
6541 uint8 field = (uint8)((i - 1) / 32);
6542 uint32 submask = 1 << ((i - 1) % 32);
6543
6544 // skip not taxi network nodes
6545 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
6546 {
6547 continue;
6548 }
6549
6550 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
6551 if (found)
6552 {
6553 if (dist2 < dist)
6554 {
6555 dist = dist2;
6556 id = i;
6557 }
6558 }
6559 else
6560 {
6561 found = true;
6562 dist = dist2;
6563 id = i;
6564 }
6565 }
6566
6567 return id;
6568}
TaxiMask sTaxiNodesMask
Definition: DBCStores.cpp:175
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
static constexpr size_t TaxiMaskSize
Definition: DBCStructure.h:2246
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
Definition: DBCStructure.h:1954
float z
Definition: DBCStructure.h:1959
uint32 map_id
Definition: DBCStructure.h:1956
float x
Definition: DBCStructure.h:1957
float y
Definition: DBCStructure.h:1958
uint32 MountCreatureID[2]
Definition: DBCStructure.h:1962

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
1304 {
1305 NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
1306 if (itr == _npcTextLocaleStore.end()) return nullptr;
1307 return &itr->second;
1308 }
NpcTextLocaleContainer _npcTextLocaleStore
Definition: ObjectMgr.h:1604

References _npcTextLocaleStore.

◆ GetNpcTrainerSpells()

TrainerSpellData const * ObjectMgr::GetNpcTrainerSpells ( uint32  entry) const
inline
1365 {
1366 CacheTrainerSpellContainer::const_iterator iter = _cacheTrainerSpellStore.find(entry);
1367 if (iter == _cacheTrainerSpellStore.end())
1368 return nullptr;
1369
1370 return &iter->second;
1371 }

References _cacheTrainerSpellStore.

◆ GetNpcVendorItemList()

VendorItemData const * ObjectMgr::GetNpcVendorItemList ( uint32  entry) const
inline
1374 {
1375 CacheVendorItemContainer::const_iterator iter = _cacheVendorItemStore.find(entry);
1376 if (iter == _cacheVendorItemStore.end())
1377 return nullptr;
1378
1379 return &iter->second;
1380 }

References _cacheVendorItemStore.

Referenced by IsVendorItemValid().

◆ GetPageText()

PageText const * ObjectMgr::GetPageText ( uint32  pageEntry)
5790{
5791 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
5792 if (itr != _pageTextStore.end())
5793 return &(itr->second);
5794
5795 return nullptr;
5796}
PageTextContainer _pageTextStore
Definition: ObjectMgr.h:1531

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

References _pageTextLocaleStore.

◆ GetPetLevelInfo()

PetLevelInfo const * ObjectMgr::GetPetLevelInfo ( uint32  creature_id,
uint8  level 
) const
3631{
3632 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3633 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
3634
3635 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
3636 if (itr == _petInfoStore.end())
3637 return nullptr;
3638
3639 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
3640}

References _petInfoStore, CONFIG_MAX_PLAYER_LEVEL, and sWorld.

◆ GetPlayerClassInfo()

PlayerClassInfo const * ObjectMgr::GetPlayerClassInfo ( uint32  class_) const
inline
799 {
800 if (class_ >= MAX_CLASSES)
801 return nullptr;
802 return _playerClassInfo[class_];
803 }

References _playerClassInfo, and MAX_CLASSES.

◆ GetPlayerClassLevelInfo()

void ObjectMgr::GetPlayerClassLevelInfo ( uint32  class_,
uint8  level,
PlayerClassLevelInfo info 
) const
4298{
4299 if (level < 1 || class_ >= MAX_CLASSES)
4300 return;
4301
4302 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4303
4304 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4305 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4306
4307 *info = pInfo->levelInfo[level - 1];
4308}
Definition: Player.h:297

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

◆ GetPlayerInfo()

PlayerInfo const * ObjectMgr::GetPlayerInfo ( uint32  race,
uint32  class_ 
) const
9990{
9991 if (race >= MAX_RACES)
9992 return nullptr;
9993 if (class_ >= MAX_CLASSES)
9994 return nullptr;
9995 PlayerInfo const* info = _playerInfo[race][class_];
9996 if (!info)
9997 return nullptr;
9998 return info;
9999}
Definition: Player.h:336

References _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ GetPlayerLevelInfo()

void ObjectMgr::GetPlayerLevelInfo ( uint32  race,
uint32  class_,
uint8  level,
PlayerLevelInfo info 
) const
4311{
4312 if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
4313 return;
4314
4315 PlayerInfo const* pInfo = _playerInfo[race][class_];
4316 if (!pInfo)
4317 return;
4318
4319 if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4320 *info = pInfo->levelInfo[level - 1];
4321 else
4322 BuildPlayerLevelInfo(race, class_, level, info);
4323}
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
Definition: ObjectMgr.cpp:4325

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

◆ GetPointOfInterest()

PointOfInterest const * ObjectMgr::GetPointOfInterest ( uint32  id) const
inline
926 {
927 PointOfInterestContainer::const_iterator itr = _pointsOfInterestStore.find(id);
928 if (itr != _pointsOfInterestStore.end())
929 return &itr->second;
930 return nullptr;
931 }
PointOfInterestContainer _pointsOfInterestStore
Definition: ObjectMgr.h:1501

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

References _pointOfInterestLocaleStore.

◆ GetQuestForAreaTrigger()

uint32 ObjectMgr::GetQuestForAreaTrigger ( uint32  Trigger_ID) const
inline
840 {
841 QuestAreaTriggerContainer::const_iterator itr = _questAreaTriggerStore.find(Trigger_ID);
842 if (itr != _questAreaTriggerStore.end())
843 return itr->second;
844 return 0;
845 }
QuestAreaTriggerContainer _questAreaTriggerStore
Definition: ObjectMgr.h:1485

References _questAreaTriggerStore.

◆ GetQuestGreeting()

QuestGreeting const * ObjectMgr::GetQuestGreeting ( TypeID  type,
uint32  id 
) const
6264{
6265 uint32 typeIndex;
6266 if (type == TYPEID_UNIT)
6267 typeIndex = 0;
6268 else if (type == TYPEID_GAMEOBJECT)
6269 typeIndex = 1;
6270 else
6271 return nullptr;
6272
6274}
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:39
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
QuestGreetingContainer _questGreetingStore
Definition: ObjectMgr.h:1488

References _questGreetingStore, Acore::Containers::MapGetValuePtr(), TYPEID_GAMEOBJECT, and TYPEID_UNIT.

◆ GetQuestGreetingLocale()

QuestGreetingLocale const * ObjectMgr::GetQuestGreetingLocale ( TypeID  type,
uint32  id 
) const
inline
1272 {
1273 uint32 typeIndex;
1274 if (type == TYPEID_UNIT)
1275 {
1276 typeIndex = 0;
1277 }
1278 else if (type == TYPEID_GAMEOBJECT)
1279 {
1280 typeIndex = 1;
1281 }
1282 else
1283 {
1284 return nullptr;
1285 }
1286
1287 QuestGreetingLocaleContainer::const_iterator itr = _questGreetingLocaleStore.find(MAKE_PAIR32(typeIndex, id));
1288 if (itr == _questGreetingLocaleStore.end()) return nullptr;
1289 return &itr->second;
1290 }
QuestGreetingLocaleContainer _questGreetingLocaleStore
Definition: ObjectMgr.h:1609

References _questGreetingLocaleStore, MAKE_PAIR32(), 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:1601

References _questLocaleStore.

◆ GetQuestMoneyReward()

uint32 ObjectMgr::GetQuestMoneyReward ( uint8  level,
uint32  questMoneyDifficulty 
) const
10126{
10127 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
10128 {
10129 auto const& itr = _questMoneyRewards.find(level);
10130 if (itr != _questMoneyRewards.end())
10131 {
10132 return itr->second.at(questMoneyDifficulty);
10133 }
10134 }
10135
10136 return 0;
10137}
static constexpr uint32 MAX_QUEST_MONEY_REWARDS
Definition: ObjectMgr.h:722
QuestMoneyRewardStore _questMoneyRewards
Definition: ObjectMgr.h:1629

References _questMoneyRewards, and MAX_QUEST_MONEY_REWARDS.

◆ GetQuestOfferRewardLocale()

QuestOfferRewardLocale const * ObjectMgr::GetQuestOfferRewardLocale ( uint32  entry) const
inline
1292 {
1293 auto itr = _questOfferRewardLocaleStore.find(entry);
1294 if (itr == _questOfferRewardLocaleStore.end()) return nullptr;
1295 return &itr->second;
1296 }
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
Definition: ObjectMgr.h:1602

References _questOfferRewardLocaleStore.

◆ GetQuestPOIVector()

QuestPOIVector const * ObjectMgr::GetQuestPOIVector ( uint32  questId)
inline
934 {
935 QuestPOIContainer::const_iterator itr = _questPOIStore.find(questId);
936 if (itr != _questPOIStore.end())
937 return &itr->second;
938 return nullptr;
939 }
QuestPOIContainer _questPOIStore
Definition: ObjectMgr.h:1503

References _questPOIStore.

◆ GetQuestRequestItemsLocale()

QuestRequestItemsLocale const * ObjectMgr::GetQuestRequestItemsLocale ( uint32  entry) const
inline
1298 {
1299 auto itr = _questRequestItemsLocaleStore.find(entry);
1300 if (itr == _questRequestItemsLocaleStore.end()) return nullptr;
1301 return &itr->second;
1302 }
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
Definition: ObjectMgr.h:1603

References _questRequestItemsLocaleStore.

◆ GetQuestTemplate()

Quest const * ObjectMgr::GetQuestTemplate ( uint32  quest_id) const
inline
833 {
834 return quest_id < _questTemplatesFast.size() ? _questTemplatesFast[quest_id] : nullptr;
835 }
std::vector< Quest * > _questTemplatesFast
Definition: ObjectMgr.h:1479

References _questTemplatesFast.

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

◆ GetQuestTemplates()

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

References _questTemplates.

◆ GetRepRewardRate()

RepRewardRate const * ObjectMgr::GetRepRewardRate ( uint32  factionId) const
inline
898 {
899 RepRewardRateContainer::const_iterator itr = _repRewardRateStore.find(factionId);
900 if (itr != _repRewardRateStore.end())
901 return &itr->second;
902
903 return nullptr;
904 }
RepRewardRateContainer _repRewardRateStore
Definition: ObjectMgr.h:1495

References _repRewardRateStore.

◆ GetRepSpilloverTemplate()

RepSpilloverTemplate const * ObjectMgr::GetRepSpilloverTemplate ( uint32  factionId) const
inline
917 {
918 RepSpilloverTemplateContainer::const_iterator itr = _repSpilloverTemplateStore.find(factionId);
919 if (itr != _repSpilloverTemplateStore.end())
920 return &itr->second;
921
922 return nullptr;
923 }
RepSpilloverTemplateContainer _repSpilloverTemplateStore
Definition: ObjectMgr.h:1497

References _repSpilloverTemplateStore.

◆ GetReputationOnKilEntry()

ReputationOnKillEntry const * ObjectMgr::GetReputationOnKilEntry ( uint32  id) const
inline
907 {
908 RepOnKillContainer::const_iterator itr = _repOnKillStore.find(id);
909 if (itr != _repOnKillStore.end())
910 return &itr->second;
911 return nullptr;
912 }
RepOnKillContainer _repOnKillStore
Definition: ObjectMgr.h:1496

References _repOnKillStore.

◆ GetScriptId()

uint32 ObjectMgr::GetScriptId ( std::string const &  name)
9480{
9481 // use binary search to find the script name in the sorted vector
9482 // assume "" is the first element
9483 if (name.empty())
9484 return 0;
9485
9486 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
9487 if (itr == _scriptNamesStore.end() || (*itr != name))
9488 return 0;
9489
9490 return uint32(itr - _scriptNamesStore.begin());
9491}
ScriptNameContainer _scriptNamesStore
Definition: ObjectMgr.h:1520

References _scriptNamesStore.

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

◆ GetScriptName()

std::string const & ObjectMgr::GetScriptName ( uint32  id) const
9474{
9475 static std::string const empty = "";
9476 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
9477}

References _scriptNamesStore.

Referenced by ValidateSpellScripts().

◆ GetScriptNames()

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

References _scriptNamesStore.

◆ GetSpellClickInfoMapBounds()

SpellClickInfoMapBounds ObjectMgr::GetSpellClickInfoMapBounds ( uint32  creature_id) const
inline
1392 {
1393 return _spellClickInfoStore.equal_range(creature_id);
1394 }
SpellClickInfoContainer _spellClickInfoStore
Definition: ObjectMgr.h:1522

References _spellClickInfoStore.

◆ GetSpellScriptsBounds()

SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds ( uint32  spell_id)
8717{
8718 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
8719}
std::pair< SpellScriptsContainer::iterator, SpellScriptsContainer::iterator > SpellScriptsBounds
Definition: ObjectMgr.h:389
SpellScriptsContainer _spellScriptsStore
Definition: ObjectMgr.h:1524

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

References _tempSummonDataStore.

◆ GetTaxiMountDisplayId()

uint32 ObjectMgr::GetTaxiMountDisplayId ( uint32  id,
TeamId  teamId,
bool  allowed_alt_team = false 
)
6595{
6596 uint32 mount_id = 0;
6597
6598 // select mount creature id
6599 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
6600 if (node)
6601 {
6602 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
6603
6604 // Fix for Alliance not being able to use Acherus taxi
6605 // only one mount type for both sides
6606 if (mount_entry == 0 && allowed_alt_team)
6607 {
6608 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
6609 mount_entry = node->MountCreatureID[teamId];
6610 }
6611
6612 CreatureTemplate const* mount_info = GetCreatureTemplate(mount_entry);
6613 if (mount_info)
6614 {
6615 mount_id = mount_info->GetRandomValidModelId();
6616 if (!mount_id)
6617 {
6618 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
6619 return 0;
6620 }
6621 }
6622 }
6623
6624 // minfo is not actually used but the mount_id was updated
6626
6627 return mount_id;
6628}
uint32 GetRandomValidModelId() const
Definition: Creature.cpp:119
CreatureModelInfo const * GetCreatureModelRandomGender(uint32 *displayID)
Definition: ObjectMgr.cpp:1754

References GetCreatureModelRandomGender(), GetCreatureTemplate(), CreatureTemplate::GetRandomValidModelId(), LOG_ERROR, TaxiNodesEntry::MountCreatureID, sTaxiNodesStore, and TEAM_ALLIANCE.

◆ GetTaxiPath()

void ObjectMgr::GetTaxiPath ( uint32  source,
uint32  destination,
uint32 path,
uint32 cost 
)
6571{
6572 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
6573 if (src_i == sTaxiPathSetBySource.end())
6574 {
6575 path = 0;
6576 cost = 0;
6577 return;
6578 }
6579
6580 TaxiPathSetForSource& pathSet = src_i->second;
6581
6582 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
6583 if (dest_i == pathSet.end())
6584 {
6585 path = 0;
6586 cost = 0;
6587 return;
6588 }
6589
6590 cost = dest_i->second->price;
6591 path = dest_i->second->ID;
6592}
TaxiPathSetBySource sTaxiPathSetBySource
Definition: DBCStores.cpp:182
std::map< uint32, TaxiPathEntry const * > TaxiPathSetForSource
Definition: DBCStructure.h:2240

References sTaxiPathSetBySource.

◆ GetVehicleAccessoryList()

VehicleAccessoryList const * ObjectMgr::GetVehicleAccessoryList ( Vehicle veh) const
9973{
9974 if (Creature* cre = veh->GetBase()->ToCreature())
9975 {
9976 // Give preference to GUID-based accessories
9977 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
9978 if (itr != _vehicleAccessoryStore.end())
9979 return &itr->second;
9980 }
9981
9982 // Otherwise return entry-based
9983 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
9984 if (itr != _vehicleTemplateAccessoryStore.end())
9985 return &itr->second;
9986 return nullptr;
9987}
Creature * ToCreature()
Definition: Object.h:197
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:39
uint32 GetCreatureEntry() const
Definition: Vehicle.h:41
VehicleAccessoryContainer _vehicleAccessoryStore
Definition: ObjectMgr.h:1527
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
Definition: ObjectMgr.h:1526

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

◆ GetXPForLevel()

uint32 ObjectMgr::GetXPForLevel ( uint8  level) const
7451{
7452 if (level < _playerXPperLevel.size())
7453 return _playerXPperLevel[level];
7454 return 0;
7455}
PlayerXPperLevel _playerXPperLevel
Definition: ObjectMgr.h:1554

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
5737{
5738 uint32 limit = sSpellStore.GetNumRows();
5739 for(uint32 i = 0; i <= limit; ++i)
5740 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
5741 {
5742 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
5743 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
5744 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
5745 }
5746}
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)

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

◆ instance()

ObjectMgr * ObjectMgr::instance ( )
static
431{
432 static ObjectMgr instance;
433 return &instance;
434}
Definition: ObjectMgr.h:729
static ObjectMgr * instance()
Definition: ObjectMgr.cpp:430

References instance().

Referenced by instance().

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
9953{
9954 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
9955 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
9956}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition: SharedDefines.h:1571

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

◆ IsProfanityName()

bool ObjectMgr::IsProfanityName ( std::string_view  name) const
8255{
8256 // pussywizard
8257 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8258 return true;
8259
8260 std::wstring wstr;
8261 if (!Utf8toWStr (name, wstr))
8262 return false;
8263
8264 wstrToLower(wstr);
8265
8266 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
8267}

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

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
8180{
8181 // pussywizard
8182 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8183 return true;
8184
8185 std::wstring wstr;
8186 if (!Utf8toWStr (name, wstr))
8187 return false;
8188
8189 wstrToLower(wstr);
8190
8191 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
8192}

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

Referenced by AddReservedPlayerName().

◆ IsTavernAreaTrigger()

bool ObjectMgr::IsTavernAreaTrigger ( uint32  triggerID,
uint32  faction 
) const
inline
848 {
849 auto itr = _tavernAreaTriggerStore.find(triggerID);
850 if (itr != _tavernAreaTriggerStore.end())
851 {
852 return (itr->second & faction) != 0;
853 }
854
855 return false;
856 }
TavernAreaTriggerContainer _tavernAreaTriggerStore
Definition: ObjectMgr.h:1486

References _tavernAreaTriggerStore.

◆ IsTransportMap()

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

References _transportMaps.

◆ IsValidChannelName()

bool ObjectMgr::IsValidChannelName ( std::string const &  name)
static
8459{
8460 std::wstring wname;
8461 if (!Utf8toWStr(name, wname))
8462 return false;
8463
8464 if (wname.size() > MAX_CHANNEL_NAME)
8465 return false;
8466
8467 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
8468
8469 return isValidString(wname, strictMask, true);
8470}
#define MAX_CHANNEL_NAME
Definition: ObjectMgr.h:692
@ CONFIG_STRICT_CHANNEL_NAMES
Definition: IWorld.h:222

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

◆ IsValidCharterName()

bool ObjectMgr::IsValidCharterName ( std::string_view  name)
static
8423{
8424 std::wstring wname;
8425 if (!Utf8toWStr(name, wname))
8426 return false;
8427
8428 if (wname.size() > MAX_CHARTER_NAME)
8429 return false;
8430
8431 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
8432 if (wname.size() < minName)
8433 return false;
8434
8435 // Check for Reserved Name from DBC
8436 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8437 {
8438 if (ReservedNames(wname))
8439 {
8440 return false;
8441 }
8442 }
8443
8444 // Check for Profanity
8445 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8446 {
8447 if (ProfanityNames(wname))
8448 {
8449 return false;
8450 }
8451 }
8452
8453 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
8454
8455 return isValidString(wname, strictMask, true);
8456}
#define MAX_CHARTER_NAME
Definition: ObjectMgr.h:691
@ CONFIG_MIN_CHARTER_NAME
Definition: IWorld.h:225
@ CONFIG_STRICT_CHARTER_NAMES
Definition: IWorld.h:221

References CONFIG_MIN_CHARTER_NAME, CONFIG_STRICT_CHARTER_NAMES, CONFIG_STRICT_NAMES_PROFANITY, CONFIG_STRICT_NAMES_RESERVED, isValidString(), MAX_CHARTER_NAME, ProfanityNames(), ReservedNames(), 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
9338{
9339 /*
9340 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry);
9341 if (!cInfo)
9342 {
9343 if (player)
9344 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9345 else
9346 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
9347 return false;
9348 }
9349
9350 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
9351 {
9352 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
9353 {
9354 if (player)
9355 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9356 else
9357 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
9358
9359 if (skip_vendors)
9360 skip_vendors->insert(vendor_entry);
9361 }
9362 return false;
9363 }
9364 */
9365
9366 if (!sObjectMgr->GetItemTemplate(item_id))
9367 {
9368 if (player)
9370 else
9371 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
9372 return false;
9373 }
9374
9375 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
9376 {
9377 if (player)
9379 else
9380 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
9381 return false;
9382 }
9383
9384 if (maxcount > 0 && incrtime == 0)
9385 {
9386 if (player)
9387 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount);
9388 else
9389 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);
9390 return false;
9391 }
9392 else if (maxcount == 0 && incrtime > 0)
9393 {
9394 if (player)
9395 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
9396 else
9397 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);
9398 return false;
9399 }
9400
9401 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
9402 if (!vItems)
9403 return true; // later checks for non-empty lists
9404
9405 if (vItems->FindItemCostPair(item_id, ExtendedCost))
9406 {
9407 if (player)
9408 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
9409 else
9410 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
9411 return false;
9412 }
9413
9414 return true;
9415}
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
@ LANG_ITEM_ALREADY_IN_LIST
Definition: Language.h:248
@ LANG_ITEM_NOT_FOUND
Definition: Language.h:245
@ LANG_EXTENDED_COST_NOT_EXIST
Definition: Language.h:372
Definition: Chat.h:38
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost) const
Definition: Creature.cpp:111
WorldSession * GetSession() const
Definition: Player.h:1961
VendorItemData const * GetNpcVendorItemList(uint32 entry) const
Definition: ObjectMgr.h:1373

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 ( )
6742{
6743 uint32 oldMSTime = getMSTime();
6744
6745 if (!_accessRequirementStore.empty())
6746 {
6747 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
6748 {
6749 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
6750 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
6751 {
6752 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
6753 {
6754 delete* questItr;
6755 }
6756
6757 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
6758 {
6759 delete* achievementItr;
6760 }
6761
6762 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
6763 {
6764 delete* itemsItr;
6765 }
6766
6767 delete difficultiesItr->second;
6768 }
6769 }
6770
6771 _accessRequirementStore.clear(); // need for reload case
6772 }
6773 // 0 1 2 3 4 5
6774 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
6775 if (!access_template_result)
6776 {
6777 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
6778 LOG_INFO("server.loading", " ");
6779 return;
6780 }
6781
6782 uint32 count = 0;
6783 uint32 countProgressionRequirements = 0;
6784
6785 do
6786 {
6787 Field* fields = access_template_result->Fetch();
6788
6789 //Get the common variables for the access requirements
6790 uint8 dungeon_access_id = fields[0].Get<uint8>();
6791 uint32 mapid = fields[1].Get<uint32>();
6792 uint8 difficulty = fields[2].Get<uint8>();
6793
6794 //Set up the access requirements
6796 ar->levelMin = fields[3].Get<uint8>();
6797 ar->levelMax = fields[4].Get<uint8>();
6798 ar->reqItemLevel = fields[5].Get<uint16>();
6799
6800 // 0 1 2 3 4 6
6801 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);
6802 if (progression_requirements_results)
6803 {
6804 do
6805 {
6806 Field* progression_requirement_row = progression_requirements_results->Fetch();
6807
6808 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
6809 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
6810 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
6811 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
6812 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
6813 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
6814
6815 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
6816 progression_requirement->id = requirement_id;
6817 progression_requirement->note = requirement_note;
6818 progression_requirement->faction = (TeamId)requirement_faction;
6819 progression_requirement->priority = requirement_priority;
6820 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
6821
6822 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
6823
6824 switch (requirement_type)
6825 {
6826 case 0:
6827 {
6828 //Achievement
6829 if (!sAchievementStore.LookupEntry(progression_requirement->id))
6830 {
6831 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);
6832 break;
6833 }
6834
6835 currentRequirementsList = &ar->achievements;
6836 break;
6837 }
6838 case 1:
6839 {
6840 //Quest
6841 if (!GetQuestTemplate(progression_requirement->id))
6842 {
6843 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);
6844 break;
6845 }
6846
6847 currentRequirementsList = &ar->quests;
6848 break;
6849 }
6850 case 2:
6851 {
6852 //Item
6853 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
6854 if (!pProto)
6855 {
6856 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);
6857 break;
6858 }
6859
6860 currentRequirementsList = &ar->items;
6861 break;
6862 }
6863 default:
6864 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);
6865 break;
6866 }
6867
6868 //Check if array is valid and delete the progression requirement
6869 if (!currentRequirementsList)
6870 {
6871 delete progression_requirement;
6872 continue;
6873 }
6874
6875 //Insert into the array
6876 if (currentRequirementsList->size() > requirement_priority)
6877 {
6878 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
6879 }
6880 else
6881 {
6882 currentRequirementsList->push_back(progression_requirement);
6883 }
6884
6885 } while (progression_requirements_results->NextRow());
6886 }
6887
6888 //Sort all arrays for priority
6889 auto sortFunction = [](const ProgressionRequirement* const a, const ProgressionRequirement* const b) {return a->priority > b->priority; };
6890 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
6891 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
6892 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
6893
6894 countProgressionRequirements += ar->achievements.size();
6895 countProgressionRequirements += ar->quests.size();
6896 countProgressionRequirements += ar->items.size();
6897 count++;
6898
6899 _accessRequirementStore[mapid][difficulty] = ar;
6900 } while (access_template_result->NextRow());
6901
6902 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
6903 LOG_INFO("server.loading", " ");
6904}
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
TeamId
Definition: SharedDefines.h:759
Class used to access individual fields of database query result.
Definition: Field.h:99
bool IsNull() const
Definition: Field.h:107
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: ItemTemplate.h:628
Definition: Player.h:925
uint32 priority
Definition: Player.h:929
Definition: Player.h:934
ItemTemplate const * GetItemTemplate(uint32 entry)
Definition: ObjectMgr.cpp:3320
Quest const * GetQuestTemplate(uint32 quest_id) const
Definition: ObjectMgr.h:832

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 ( )
8584{
8585 uint32 oldMSTime = getMSTime();
8586
8587 _acoreStringStore.clear(); // for reload case
8588 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");
8589 if (!result)
8590 {
8591 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty.");
8592 LOG_INFO("server.loading", " ");
8593 return false;
8594 }
8595
8596 do
8597 {
8598 Field* fields = result->Fetch();
8599
8600 uint32 entry = fields[0].Get<uint32>();
8601
8602 AcoreString& data = _acoreStringStore[entry];
8603
8604 data.Content.resize(DEFAULT_LOCALE + 1);
8605
8606 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
8607 AddLocaleString(fields[i + 1].Get<std::string>(), LocaleConstant(i), data.Content);
8608 } while (result->NextRow());
8609
8610 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8611 LOG_INFO("server.loading", " ");
8612
8613 return true;
8614}
LocaleConstant
Definition: Common.h:67
@ TOTAL_LOCALES
Definition: Common.h:78
static void AddLocaleString(std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
Definition: ObjectMgr.cpp:436

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

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
6631{
6632 uint32 oldMSTime = getMSTime();
6633
6634 _areaTriggerStore.clear();
6635
6636 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
6637
6638 if (!result)
6639 {
6640 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
6641 LOG_INFO("server.loading", " ");
6642 return;
6643 }
6644
6645 uint32 count = 0;
6646
6647 do
6648 {
6649 Field* fields = result->Fetch();
6650
6651 ++count;
6652
6653 AreaTrigger at;
6654
6655 at.entry = fields[0].Get<uint32>();
6656 at.map = fields[1].Get<uint32>();
6657 at.x = fields[2].Get<float>();
6658 at.y = fields[3].Get<float>();
6659 at.z = fields[4].Get<float>();
6660 at.radius = fields[5].Get<float>();
6661 at.length = fields[6].Get<float>();
6662 at.width = fields[7].Get<float>();
6663 at.height = fields[8].Get<float>();
6664 at.orientation = fields[9].Get<float>();
6665
6666 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
6667 if (!mapEntry)
6668 {
6669 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
6670 continue;
6671 }
6672
6673 _areaTriggerStore[at.entry] = at;
6674 } while (result->NextRow());
6675
6676 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6677 LOG_INFO("server.loading", " ");
6678}
float height
Definition: ObjectMgr.h:430
float x
Definition: ObjectMgr.h:424
float y
Definition: ObjectMgr.h:425
float orientation
Definition: ObjectMgr.h:431
float length
Definition: ObjectMgr.h:428
uint32 entry
Definition: ObjectMgr.h:422
float radius
Definition: ObjectMgr.h:427
float z
Definition: ObjectMgr.h:426
float width
Definition: ObjectMgr.h:429

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

◆ LoadAreaTriggerScripts()

void ObjectMgr::LoadAreaTriggerScripts ( )
6491{
6492 uint32 oldMSTime = getMSTime();
6493
6494 _areaTriggerScriptStore.clear(); // need for reload case
6495 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
6496
6497 if (!result)
6498 {
6499 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
6500 LOG_INFO("server.loading", " ");
6501 return;
6502 }
6503
6504 uint32 count = 0;
6505
6506 do
6507 {
6508 ++count;
6509
6510 Field* fields = result->Fetch();
6511
6512 uint32 Trigger_ID = fields[0].Get<uint32>();
6513 std::string scriptName = fields[1].Get<std::string>();
6514
6515 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6516 if (!atEntry)
6517 {
6518 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6519 continue;
6520 }
6521 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
6522 } while (result->NextRow());
6523
6524 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6525 LOG_INFO("server.loading", " ");
6526}
uint32 GetScriptId(std::string const &name)
Definition: ObjectMgr.cpp:9479

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

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
6681{
6682 uint32 oldMSTime = getMSTime();
6683
6684 _areaTriggerTeleportStore.clear(); // need for reload case
6685
6686 // 0 1 2 3 4 5
6687 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
6688
6689 if (!result)
6690 {
6691 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
6692 LOG_INFO("server.loading", " ");
6693 return;
6694 }
6695
6696 uint32 count = 0;
6697
6698 do
6699 {
6700 Field* fields = result->Fetch();
6701
6702 ++count;
6703
6704 uint32 Trigger_ID = fields[0].Get<uint32>();
6705
6707
6708 at.target_mapId = fields[1].Get<uint16>();
6709 at.target_X = fields[2].Get<float>();
6710 at.target_Y = fields[3].Get<float>();
6711 at.target_Z = fields[4].Get<float>();
6712 at.target_Orientation = fields[5].Get<float>();
6713
6714 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6715 if (!atEntry)
6716 {
6717 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6718 continue;
6719 }
6720
6721 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
6722 if (!mapEntry)
6723 {
6724 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
6725 continue;
6726 }
6727
6728 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
6729 {
6730 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
6731 continue;
6732 }
6733
6734 _areaTriggerTeleportStore[Trigger_ID] = at;
6735 } while (result->NextRow());
6736
6737 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6738 LOG_INFO("server.loading", " ");
6739}
Definition: ObjectMgr.h:412
uint32 target_mapId
Definition: ObjectMgr.h:413

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

◆ LoadBroadcastTextLocales()

void ObjectMgr::LoadBroadcastTextLocales ( )
9579{
9580 uint32 oldMSTime = getMSTime();
9581
9582 // 0 1 2 3
9583 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
9584
9585 if (!result)
9586 {
9587 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
9588 LOG_INFO("server.loading", " ");
9589 return;
9590 }
9591
9592 uint32 locales_count = 0;
9593 do
9594 {
9595 Field* fields = result->Fetch();
9596
9597 uint32 id = fields[0].Get<uint32>();
9598
9599 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
9600 if (bct == _broadcastTextStore.end())
9601 {
9602 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
9603 continue;
9604 }
9605
9606 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
9607 if (locale == LOCALE_enUS)
9608 continue;
9609
9610 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
9611 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
9612 locales_count++;
9613 } while (result->NextRow());
9614
9615 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
9616 LOG_INFO("server.loading", " ");
9617}
LocaleConstant GetLocaleByName(const std::string &name)
Definition: Common.cpp:33

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

◆ LoadBroadcastTexts()

void ObjectMgr::LoadBroadcastTexts ( )
9494{
9495 uint32 oldMSTime = getMSTime();
9496
9497 _broadcastTextStore.clear(); // for reload case
9498
9499 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9500 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
9501 if (!result)
9502 {
9503 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
9504 LOG_INFO("server.loading", " ");
9505 return;
9506 }
9507
9508 _broadcastTextStore.rehash(result->GetRowCount());
9509
9510 do
9511 {
9512 Field* fields = result->Fetch();
9513
9514 BroadcastText bct;
9515
9516 bct.Id = fields[0].Get<uint32>();
9517 bct.LanguageID = fields[1].Get<uint32>();
9518 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
9519 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
9520 bct.EmoteId1 = fields[4].Get<uint32>();
9521 bct.EmoteId2 = fields[5].Get<uint32>();
9522 bct.EmoteId3 = fields[6].Get<uint32>();
9523 bct.EmoteDelay1 = fields[7].Get<uint32>();
9524 bct.EmoteDelay2 = fields[8].Get<uint32>();
9525 bct.EmoteDelay3 = fields[9].Get<uint32>();
9526 bct.SoundEntriesId = fields[10].Get<uint32>();
9527 bct.EmotesID = fields[11].Get<uint32>();
9528 bct.Flags = fields[12].Get<uint32>();
9529
9530 if (bct.SoundEntriesId)
9531 {
9532 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
9533 {
9534 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
9535 bct.SoundEntriesId = 0;
9536 }
9537 }
9538
9540 {
9541 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
9543 }
9544
9545 if (bct.EmoteId1)
9546 {
9547 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
9548 {
9549 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
9550 bct.EmoteId1 = 0;
9551 }
9552 }
9553
9554 if (bct.EmoteId2)
9555 {
9556 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
9557 {
9558 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
9559 bct.EmoteId2 = 0;
9560 }
9561 }
9562
9563 if (bct.EmoteId3)
9564 {
9565 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
9566 {
9567 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
9568 bct.EmoteId3 = 0;
9569 }
9570 }
9571
9572 _broadcastTextStore[bct.Id] = bct;
9573 } while (result->NextRow());
9574
9575 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
9576}
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition: ObjectMgr.cpp:307
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
Definition: ObjectMgr.h:435
uint32 EmoteDelay2
Definition: ObjectMgr.h:450
uint32 Id
Definition: ObjectMgr.h:442
std::vector< std::string > FemaleText
Definition: ObjectMgr.h:445
uint32 EmotesID
Definition: ObjectMgr.h:453
uint32 LanguageID
Definition: ObjectMgr.h:443
uint32 EmoteId2
Definition: ObjectMgr.h:447
uint32 EmoteDelay1
Definition: ObjectMgr.h:449
uint32 SoundEntriesId
Definition: ObjectMgr.h:452
std::vector< std::string > MaleText
Definition: ObjectMgr.h:444
uint32 EmoteId3
Definition: ObjectMgr.h:448
uint32 EmoteId1
Definition: ObjectMgr.h:446
uint32 EmoteDelay3
Definition: ObjectMgr.h:451
uint32 Flags
Definition: ObjectMgr.h:454

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

◆ LoadCreatureAddons()

void ObjectMgr::LoadCreatureAddons ( )
1352{
1353 uint32 oldMSTime = getMSTime();
1354
1355 // 0 1 2 3 4 5 6 7
1356 QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_addon");
1357
1358 if (!result)
1359 {
1360 LOG_WARN("server.loading", ">> Loaded 0 creature addon definitions. DB table `creature_addon` is empty.");
1361 LOG_INFO("server.loading", " ");
1362 return;
1363 }
1364
1365 uint32 count = 0;
1366 do
1367 {
1368 Field* fields = result->Fetch();
1369
1370 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1371
1372 CreatureData const* creData = GetCreatureData(guid);
1373 if (!creData)
1374 {
1375 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_addon`", guid);
1376 continue;
1377 }
1378
1379 CreatureAddon& creatureAddon = _creatureAddonStore[guid];
1380
1381 creatureAddon.path_id = fields[1].Get<uint32>();
1382 if (creData->movementType == WAYPOINT_MOTION_TYPE && !creatureAddon.path_id)
1383 {
1384 const_cast<CreatureData*>(creData)->movementType = IDLE_MOTION_TYPE;
1385 LOG_ERROR("sql.sql", "Creature (GUID {}) has movement type set to WAYPOINT_MOTION_TYPE but no path assigned", guid);
1386 }
1387
1388 creatureAddon.mount = fields[2].Get<uint32>();
1389 creatureAddon.bytes1 = fields[3].Get<uint32>();
1390 creatureAddon.bytes2 = fields[4].Get<uint32>();
1391 creatureAddon.emote = fields[5].Get<uint32>();
1392 creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].Get<uint8>());
1393
1394 for (std::string_view aura : Acore::Tokenize(fields[7].Get<std::string_view>(), ' ', false))
1395 {
1396 SpellInfo const* spellInfo = nullptr;
1397
1398 if (Optional<uint32> spellId = Acore::StringTo<uint32>(aura))
1399 {
1400 spellInfo = sSpellMgr->GetSpellInfo(*spellId);
1401 }
1402
1403 if (!spellInfo)
1404 {
1405 LOG_ERROR("sql.sql", "Creature (GUID: {}) has wrong spell '{}' defined in `auras` field in `creature_addon`.", guid, aura);
1406 continue;
1407 }
1408
1409 if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
1410 {
1411 LOG_ERROR("sql.sql", "Creature (GUID: {}) has duplicate aura (spell {}) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
1412 continue;
1413 }
1414
1415 if (spellInfo->GetDuration() > 0)
1416 {
1417 LOG_DEBUG/*ERROR*/("sql.sql", "Creature (Entry: {}) has temporary aura (spell {}) in `auras` field in `creature_template_addon`.", guid, spellInfo->Id);
1418 // continue;
1419 }
1420
1421 creatureAddon.auras.push_back(spellInfo->Id);
1422 }
1423
1424 if (creatureAddon.mount)
1425 {
1426 if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
1427 {
1428 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid displayInfoId ({}) for mount defined in `creature_addon`", guid, creatureAddon.mount);
1429 creatureAddon.mount = 0;
1430 }
1431 }
1432
1433 if (!sEmotesStore.LookupEntry(creatureAddon.emote))
1434 {
1435 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid emote ({}) defined in `creature_addon`.", guid, creatureAddon.emote);
1436 creatureAddon.emote = 0;
1437 }
1438
1439 if (creatureAddon.visibilityDistanceType >= VisibilityDistanceType::Max)
1440 {
1441 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid visibilityDistanceType ({}) defined in `creature_addon`.", guid, AsUnderlyingType(creatureAddon.visibilityDistanceType));
1442 creatureAddon.visibilityDistanceType = VisibilityDistanceType::Normal;
1443 }
1444
1445 ++count;
1446 } while (result->NextRow());
1447
1448 LOG_INFO("server.loading", ">> Loaded {} Creature Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1449 LOG_INFO("server.loading", " ");
1450}
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
VisibilityDistanceType
Definition: ObjectDefines.h:61
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Tokenize.cpp:20
Definition: CreatureData.h:429
std::vector< uint32 > auras
Definition: CreatureData.h:435
uint32 mount
Definition: CreatureData.h:431
uint32 emote
Definition: CreatureData.h:434
uint32 path_id
Definition: CreatureData.h:430
VisibilityDistanceType visibilityDistanceType
Definition: CreatureData.h:436
uint32 bytes1
Definition: CreatureData.h:432
uint32 bytes2
Definition: CreatureData.h:433
uint32 Id
Definition: SpellInfo.h:318
int32 GetDuration() const
Definition: SpellInfo.cpp:2324

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

◆ LoadCreatureClassLevelStats()

void ObjectMgr::LoadCreatureClassLevelStats ( )
9646{
9647 uint32 oldMSTime = getMSTime();
9648
9649 QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2 FROM creature_classlevelstats");
9650
9651 if (!result)
9652 {
9653 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
9654 LOG_INFO("server.loading", " ");
9655 return;
9656 }
9657
9658 uint32 count = 0;
9659 do
9660 {
9661 Field* fields = result->Fetch();
9662
9663 uint8 Level = fields[0].Get<uint8>();
9664 uint8 Class = fields[1].Get<uint8>();
9665
9666 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
9667 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
9668
9669 CreatureBaseStats stats;
9670
9671 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
9672 {
9673 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
9674
9675 if (stats.BaseHealth[i] == 0)
9676 {
9677 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
9678 stats.BaseHealth[i] = 1;
9679 }
9680
9681 // xinef: if no data is available, get them from lower expansions
9682 if (stats.BaseHealth[i] <= 1)
9683 {
9684 for (uint8 j = i; j > 0;)
9685 {
9686 --j;
9687 if (stats.BaseHealth[j] > 1)
9688 {
9689 stats.BaseHealth[i] = stats.BaseHealth[j];
9690 break;
9691 }
9692 }
9693 }
9694
9695 stats.BaseDamage[i] = fields[9 + i].Get<float>();
9696 if (stats.BaseDamage[i] < 0.0f)
9697 {
9698 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
9699 stats.BaseDamage[i] = 0.0f;
9700 }
9701 }
9702
9703 stats.BaseMana = fields[5].Get<uint32>();
9704 stats.BaseArmor = fields[6].Get<uint32>();
9705
9706 stats.AttackPower = fields[7].Get<uint32>();
9707 stats.RangedAttackPower = fields[8].Get<uint32>();
9708
9709 _creatureBaseStatsStore[MAKE_PAIR16(Level, Class)] = stats;
9710
9711 ++count;
9712 } while (result->NextRow());
9713
9714 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
9715 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
9716 {
9717 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
9718 {
9719 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
9720 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
9721 }
9722 }
9723
9724 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9725 LOG_INFO("server.loading", " ");
9726}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: CreatureData.h:281
uint32 BaseMana
Definition: CreatureData.h:294
float BaseDamage[MAX_EXPANSIONS]
Definition: CreatureData.h:298
uint32 RangedAttackPower
Definition: CreatureData.h:297
uint32 AttackPower
Definition: CreatureData.h:296
uint32 BaseHealth[MAX_EXPANSIONS]
Definition: CreatureData.h:293
float BaseArmor
Definition: CreatureData.h:295

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

◆ LoadCreatureCustomIDs()

void ObjectMgr::LoadCreatureCustomIDs ( )

Load config option Creatures.CustomIDs into Store.

955{
956 // Hack for modules
957 std::string stringCreatureIds = sConfigMgr->GetOption<std::string>("Creatures.CustomIDs", "");
958 std::vector<std::string_view> CustomCreatures = Acore::Tokenize(stringCreatureIds, ',', false);
959
960 for (auto& itr : CustomCreatures)
961 {
962 _creatureCustomIDsStore.push_back(Acore::StringTo<uint32>(itr).value());
963 }
964}
#define sConfigMgr
Definition: Config.h:95

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

◆ LoadCreatureLocales()

void ObjectMgr::LoadCreatureLocales ( )
448{
449 uint32 oldMSTime = getMSTime();
450
451 _creatureLocaleStore.clear(); // need for reload case
452
453 // 0 1 2 3
454 QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale");
455 if (!result)
456 return;
457
458 do
459 {
460 Field* fields = result->Fetch();
461
462 uint32 ID = fields[0].Get<uint32>();
463
464 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
465 if (locale == LOCALE_enUS)
466 continue;
467
469 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
470 AddLocaleString(fields[3].Get<std::string>(), locale, data.Title);
471 } while (result->NextRow());
472
473 LOG_INFO("server.loading", ">> Loaded {} Creature Locale Strings in {} ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
474}
Definition: CreatureData.h:332
std::vector< std::string > Title
Definition: CreatureData.h:334
std::vector< std::string > Name
Definition: CreatureData.h:333

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

◆ LoadCreatureModelInfo()

void ObjectMgr::LoadCreatureModelInfo ( )
1778{
1779 uint32 oldMSTime = getMSTime();
1780
1781 // 0 1 2 3 4
1782 QueryResult result = WorldDatabase.Query("SELECT DisplayID, BoundingRadius, CombatReach, Gender, DisplayID_Other_Gender FROM creature_model_info");
1783
1784 if (!result)
1785 {
1786 LOG_WARN("server.loading", ">> Loaded 0 creature model definitions. DB table `creature_model_info` is empty.");
1787 LOG_INFO("server.loading", " ");
1788 return;
1789 }
1790
1791 _creatureModelStore.rehash(result->GetRowCount());
1792 uint32 count = 0;
1793
1794 do
1795 {
1796 Field* fields = result->Fetch();
1797
1798 uint32 modelId = fields[0].Get<uint32>();
1799
1800 CreatureModelInfo& modelInfo = _creatureModelStore[modelId];
1801
1802 modelInfo.bounding_radius = fields[1].Get<float>();
1803 modelInfo.combat_reach = fields[2].Get<float>();
1804 modelInfo.gender = fields[3].Get<uint8>();
1805 modelInfo.modelid_other_gender = fields[4].Get<uint32>();
1806
1807 // Checks
1808
1809 if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
1810 LOG_ERROR("sql.sql", "Table `creature_model_info` has model for not existed display id ({}).", modelId);
1811
1812 if (modelInfo.gender > GENDER_NONE)
1813 {
1814 LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender ({}) for display id ({}).", uint32(modelInfo.gender), modelId);
1815 modelInfo.gender = GENDER_MALE;
1816 }
1817
1818 if (modelInfo.modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.modelid_other_gender))
1819 {
1820 LOG_ERROR("sql.sql", "Table `creature_model_info` has not existed alt.gender model ({}) for existed display id ({}).", modelInfo.modelid_other_gender, modelId);
1821 modelInfo.modelid_other_gender = 0;
1822 }
1823
1824 if (modelInfo.combat_reach < 0.1f)
1825 modelInfo.combat_reach = DEFAULT_COMBAT_REACH;
1826
1827 ++count;
1828 } while (result->NextRow());
1829
1830 LOG_INFO("server.loading", ">> Loaded {} Creature Model Based Info in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1831 LOG_INFO("server.loading", " ");
1832}
#define DEFAULT_COMBAT_REACH
Definition: ObjectDefines.h:46
@ GENDER_MALE
Definition: SharedDefines.h:61
@ GENDER_NONE
Definition: SharedDefines.h:63

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

◆ LoadCreatureMovementOverrides()

void ObjectMgr::LoadCreatureMovementOverrides ( )
1641{
1642 uint32 oldMSTime = getMSTime();
1643
1645
1646 // Load the data from creature_movement_override and if NULL fallback to creature_template_movement
1647 QueryResult result = WorldDatabase.Query("SELECT cmo.SpawnId,"
1648 "COALESCE(cmo.Ground, ctm.Ground),"
1649 "COALESCE(cmo.Swim, ctm.Swim),"
1650 "COALESCE(cmo.Flight, ctm.Flight),"
1651 "COALESCE(cmo.Rooted, ctm.Rooted),"
1652 "COALESCE(cmo.Chase, ctm.Chase),"
1653 "COALESCE(cmo.Random, ctm.Random),"
1654 "COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) "
1655 "FROM creature_movement_override AS cmo "
1656 "LEFT JOIN creature AS c ON c.guid = cmo.SpawnId "
1657 "LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id1");
1658 if (!result)
1659 {
1660 LOG_WARN("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
1661 return;
1662 }
1663
1664 do
1665 {
1666 Field* fields = result->Fetch();
1667 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
1668 if (!GetCreatureData(spawnId))
1669 {
1670 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_movement_override`", spawnId);
1671 continue;
1672 }
1673
1675 if (!fields[1].IsNull())
1676 {
1677 movement.Ground = static_cast<CreatureGroundMovementType>(fields[1].Get<uint8>());
1678 }
1679
1680 if (!fields[2].IsNull())
1681 {
1682 movement.Swim = fields[2].Get<bool>();
1683 }
1684
1685 if (!fields[3].IsNull())
1686 {
1687 movement.Flight = static_cast<CreatureFlightMovementType>(fields[3].Get<uint8>());
1688 }
1689
1690 if (!fields[4].IsNull())
1691 {
1692 movement.Rooted = fields[4].Get<bool>();
1693 }
1694
1695 if (!fields[5].IsNull())
1696 {
1697 movement.Chase = static_cast<CreatureChaseMovementType>(fields[5].Get<uint8>());
1698 }
1699
1700 if (!fields[6].IsNull())
1701 {
1702 movement.Random = static_cast<CreatureRandomMovementType>(fields[6].Get<uint8>());
1703 }
1704
1705 if (!fields[7].IsNull())
1706 {
1707 movement.InteractionPauseTimer = fields[7].Get<uint32>();
1708 }
1709
1710 CheckCreatureMovement("creature_movement_override", spawnId, movement);
1711 } while (result->NextRow());
1712
1713 LOG_INFO("server.loading", ">> Loaded {} Movement Overrides in {} ms", _creatureMovementOverrides.size(), GetMSTimeDiffToNow(oldMSTime));
1714 LOG_INFO("server.loading", " ");
1715}
CreatureFlightMovementType
Definition: CreatureData.h:98
CreatureChaseMovementType
Definition: CreatureData.h:107
CreatureGroundMovementType
Definition: CreatureData.h:89
CreatureRandomMovementType
Definition: CreatureData.h:116
Definition: CreatureData.h:125
bool Swim
Definition: CreatureData.h:130
bool Rooted
Definition: CreatureData.h:131
uint32 InteractionPauseTimer
Definition: CreatureData.h:134

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 ( )
8126{
8127 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8128
8129 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8130 {
8131 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8132 if (!cInfo)
8133 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8134 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8135 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);
8136 }
8137}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition: Unit.h:517
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition: ObjectMgr.cpp:8038

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
10047{
10048 uint32 oldMSTime = getMSTime();
10049
10050 // 0 1 2
10051 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
10052
10053 if (!result)
10054 {
10055 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
10056 return;
10057 }
10058
10059 uint32 count = 0;
10060 do
10061 {
10062 Field* fields = result->Fetch();
10063
10064 uint32 entry = fields[0].Get<uint32>();
10065 uint32 item = fields[1].Get<uint32>();
10066 uint32 idx = fields[2].Get<uint32>();
10067
10068 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
10069 if (!creatureInfo)
10070 {
10071 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
10072 continue;
10073 };
10074
10075 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10076 if (!dbcData)
10077 {
10078 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
10079 continue;
10080 };
10081
10082 _creatureQuestItemStore[entry].push_back(item);
10083
10084 ++count;
10085 } while (result->NextRow());
10086
10087 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10088 LOG_INFO("server.loading", " ");
10089}
DBCStorage< ItemEntry > sItemStore(Itemfmt)
Definition: DBCStructure.h:1131

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

◆ LoadCreatureQuestStarters()

void ObjectMgr::LoadCreatureQuestStarters ( )
8112{
8113 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8114
8115 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8116 {
8117 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8118 if (!cInfo)
8119 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8120 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8121 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);
8122 }
8123}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

void ObjectMgr::LoadCreatures ( )
2153{
2154 uint32 oldMSTime = getMSTime();
2155
2156 // 0 1 2 3 4 5 6 7 8 9 10 11
2157 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2158 // 12 13 14 15 16 17 18 19 20 21 22
2159 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
2160 // 23
2161 "creature.ScriptName "
2162 "FROM creature "
2163 "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
2164 "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
2165
2166 if (!result)
2167 {
2168 LOG_WARN("server.loading", ">> Loaded 0 creatures. DB table `creature` is empty.");
2169 LOG_INFO("server.loading", " ");
2170 return;
2171 }
2172
2173 // Build single time for check spawnmask
2174 std::map<uint32, uint32> spawnMasks;
2175 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2176 if (sMapStore.LookupEntry(i))
2177 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2179 spawnMasks[i] |= (1 << k);
2180
2181 _creatureDataStore.rehash(result->GetRowCount());
2182 uint32 count = 0;
2183 do
2184 {
2185 Field* fields = result->Fetch();
2186
2187 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2188 uint32 id1 = fields[1].Get<uint32>();
2189 uint32 id2 = fields[2].Get<uint32>();
2190 uint32 id3 = fields[3].Get<uint32>();
2191
2192 CreatureTemplate const* cInfo = GetCreatureTemplate(id1);
2193 if (!cInfo)
2194 {
2195 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id1 field, skipped.", spawnId, id1);
2196 continue;
2197 }
2198 CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2);
2199 if (!cInfo2 && id2)
2200 {
2201 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id2 field, skipped.", spawnId, id2);
2202 continue;
2203 }
2204 CreatureTemplate const* cInfo3 = GetCreatureTemplate(id3);
2205 if (!cInfo3 && id3)
2206 {
2207 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id3 field, skipped.", spawnId, id3);
2208 continue;
2209 }
2210 if (!id2 && id3)
2211 {
2212 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3);
2213 continue;
2214 }
2215 CreatureData& data = _creatureDataStore[spawnId];
2216 data.id1 = id1;
2217 data.id2 = id2;
2218 data.id3 = id3;
2219 data.mapid = fields[4].Get<uint16>();
2220 data.equipmentId = fields[5].Get<int8>();
2221 data.posX = fields[6].Get<float>();
2222 data.posY = fields[7].Get<float>();
2223 data.posZ = fields[8].Get<float>();
2224 data.orientation = fields[9].Get<float>();
2225 data.spawntimesecs = fields[10].Get<uint32>();
2226 data.wander_distance = fields[11].Get<float>();
2227 data.currentwaypoint = fields[12].Get<uint32>();
2228 data.curhealth = fields[13].Get<uint32>();
2229 data.curmana = fields[14].Get<uint32>();
2230 data.movementType = fields[15].Get<uint8>();
2231 data.spawnMask = fields[16].Get<uint8>();
2232 data.phaseMask = fields[17].Get<uint32>();
2233 int16 gameEvent = fields[18].Get<int8>();
2234 uint32 PoolId = fields[19].Get<uint32>();
2235 data.npcflag = fields[20].Get<uint32>();
2236 data.unit_flags = fields[21].Get<uint32>();
2237 data.dynamicflags = fields[22].Get<uint32>();
2238 data.ScriptId = GetScriptId(fields[23].Get<std::string>());
2239
2240 if (!data.ScriptId)
2241 data.ScriptId = cInfo->ScriptID;
2242
2243 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2244 if (!mapEntry)
2245 {
2246 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that spawned at not existed map (Id: {}), skipped.", spawnId, data.mapid);
2247 continue;
2248 }
2249
2250 // pussywizard: 7 days means no reaspawn, so set it to 14 days, because manual id reset may be late
2251 if (mapEntry->IsRaid() && data.spawntimesecs >= 7 * DAY && data.spawntimesecs < 14 * DAY)
2252 data.spawntimesecs = 14 * DAY;
2253
2254 // Skip spawnMask check for transport maps
2255 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2256 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that have wrong spawn mask {} including not supported difficulty modes for map (Id: {}).",
2257 spawnId, data.spawnMask, data.mapid);
2258
2259 bool ok = true;
2260 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2261 {
2262 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()))
2263 {
2264 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.",
2265 spawnId, diff + 1, data.id1, data.id2, data.id3);
2266 ok = false;
2267 }
2268 }
2269 if (!ok)
2270 continue;
2271
2272 // -1 random, 0 no equipment,
2273 if (data.equipmentId != 0)
2274 {
2275 if ((!GetEquipmentInfo(data.id1, data.equipmentId)) || (data.id2 && !GetEquipmentInfo(data.id2, data.equipmentId)) || (data.id3 && !GetEquipmentInfo(data.id3, data.equipmentId)))
2276 {
2277 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.",
2278 data.id1, data.id2, data.id3, data.equipmentId);
2279 data.equipmentId = 0;
2280 }
2281 }
2282 if ((cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id3 && cInfo3->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND))
2283 {
2284 if (!mapEntry->IsDungeon())
2285 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.",
2286 spawnId, data.id1, data.id2, data.id3);
2287 }
2288 if (data.movementType >= MAX_DB_MOTION_TYPE)
2289 {
2290 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);
2292 }
2293 if (data.wander_distance < 0.0f)
2294 {
2295 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", spawnId, data.id1, data.id2, data.id3);
2296 data.wander_distance = 0.0f;
2297 }
2298 else if (data.movementType == RANDOM_MOTION_TYPE)
2299 {
2300 if (data.wander_distance == 0.0f)
2301 {
2302 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).",
2303 spawnId, data.id1, data.id2, data.id3);
2305 }
2306 }
2307 else if (data.movementType == IDLE_MOTION_TYPE)
2308 {
2309 if (data.wander_distance != 0.0f)
2310 {
2311 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);
2312 data.wander_distance = 0.0f;
2313 }
2314 }
2315
2316 if (data.phaseMask == 0)
2317 {
2318 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);
2319 data.phaseMask = 1;
2320 }
2321
2323 {
2324 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2325 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2326
2328
2329 stmt->SetData(0, zoneId);
2330 stmt->SetData(1, areaId);
2331 stmt->SetData(2, spawnId);
2332
2333 WorldDatabase.Execute(stmt);
2334 }
2335
2336 // Add to grid if not managed by the game event or pool system
2337 if (gameEvent == 0 && PoolId == 0)
2338 AddCreatureToGrid(spawnId, &data);
2339
2340 ++count;
2341 } while (result->NextRow());
2342
2343 LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2344 LOG_INFO("server.loading", " ");
2345}
constexpr auto DAY
Definition: Common.h:51
std::int8_t int8
Definition: Define.h:106
std::int16_t int16
Definition: Define.h:105
@ WORLD_UPD_CREATURE_ZONE_AREA_DATA
Definition: WorldDatabase.h:99
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition: DBCStores.cpp:757
@ CREATURE_FLAG_EXTRA_INSTANCE_BIND
Definition: CreatureData.h:49
@ RANDOM_MOTION_TYPE
Definition: MotionMaster.h:38
@ CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA
Definition: IWorld.h:157
Difficulty
Definition: DBCEnums.h:274
uint32 flags_extra
Definition: CreatureData.h:239
uint32 ScriptId
Definition: CreatureData.h:382
EquipmentInfo const * GetEquipmentInfo(uint32 entry, int8 &id)
Definition: ObjectMgr.cpp:1536
bool IsRaid() const
Definition: DBCStructure.h:1352

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

◆ LoadCreatureTemplate()

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

Loads a creature template from a database result.

Parameters
fieldsDatabase result
triggerHookIf true, will trigger the OnAfterDatabaseLoadCreatureTemplates hook. Useful if you are not calling the hook yourself.
636{
637 uint32 entry = fields[0].Get<uint32>();
638
639 CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry];
640
641 // enlarge the fast cache as necessary
642 if (_creatureTemplateStoreFast.size() < entry + 1)
643 {
644 _creatureTemplateStoreFast.resize(entry + 1, nullptr);
645 }
646
647 // load a pointer to this creatureTemplate into the fast cache
648 _creatureTemplateStoreFast[entry] = &creatureTemplate;
649
650 // build the creatureTemplate
651 creatureTemplate.Entry = entry;
652
653 for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
654 {
655 creatureTemplate.DifficultyEntry[i] = fields[1 + i].Get<uint32>();
656 }
657
658 for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
659 {
660 creatureTemplate.KillCredit[i] = fields[4 + i].Get<uint32>();
661 }
662
663 creatureTemplate.Modelid1 = fields[6].Get<uint32>();
664 creatureTemplate.Modelid2 = fields[7].Get<uint32>();
665 creatureTemplate.Modelid3 = fields[8].Get<uint32>();
666 creatureTemplate.Modelid4 = fields[9].Get<uint32>();
667 creatureTemplate.Name = fields[10].Get<std::string>();
668 creatureTemplate.SubName = fields[11].Get<std::string>();
669 creatureTemplate.IconName = fields[12].Get<std::string>();
670 creatureTemplate.GossipMenuId = fields[13].Get<uint32>();
671 creatureTemplate.minlevel = fields[14].Get<uint8>();
672 creatureTemplate.maxlevel = fields[15].Get<uint8>();
673 creatureTemplate.expansion = uint32(fields[16].Get<int16>());
674 creatureTemplate.faction = uint32(fields[17].Get<uint16>());
675 creatureTemplate.npcflag = fields[18].Get<uint32>();
676 creatureTemplate.speed_walk = fields[19].Get<float>();
677 creatureTemplate.speed_run = fields[20].Get<float>();
678 creatureTemplate.speed_swim = fields[21].Get<float>();
679 creatureTemplate.speed_flight = fields[22].Get<float>();
680 creatureTemplate.detection_range = fields[23].Get<float>();
681 creatureTemplate.scale = fields[24].Get<float>();
682 creatureTemplate.rank = uint32(fields[25].Get<uint8>());
683 creatureTemplate.dmgschool = uint32(fields[26].Get<int8>());
684 creatureTemplate.DamageModifier = fields[27].Get<float>();
685 creatureTemplate.BaseAttackTime = fields[28].Get<uint32>();
686 creatureTemplate.RangeAttackTime = fields[29].Get<uint32>();
687 creatureTemplate.BaseVariance = fields[30].Get<float>();
688 creatureTemplate.RangeVariance = fields[31].Get<float>();
689 creatureTemplate.unit_class = uint32(fields[32].Get<uint8>());
690 creatureTemplate.unit_flags = fields[33].Get<uint32>();
691 creatureTemplate.unit_flags2 = fields[34].Get<uint32>();
692 creatureTemplate.dynamicflags = fields[35].Get<uint32>();
693 creatureTemplate.family = uint32(fields[36].Get<uint8>());
694 creatureTemplate.trainer_type = uint32(fields[37].Get<uint8>());
695 creatureTemplate.trainer_spell = fields[38].Get<uint32>();
696 creatureTemplate.trainer_class = uint32(fields[39].Get<uint8>());
697 creatureTemplate.trainer_race = uint32(fields[40].Get<uint8>());
698 creatureTemplate.type = uint32(fields[41].Get<uint8>());
699 creatureTemplate.type_flags = fields[42].Get<uint32>();
700 creatureTemplate.lootid = fields[43].Get<uint32>();
701 creatureTemplate.pickpocketLootId = fields[44].Get<uint32>();
702 creatureTemplate.SkinLootId = fields[45].Get<uint32>();
703
704 for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
705 {
706 creatureTemplate.resistance[i] = 0;
707 }
708
709 for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i)
710 {
711 creatureTemplate.spells[i] = 0;
712 }
713
714 creatureTemplate.PetSpellDataId = fields[46].Get<uint32>();
715 creatureTemplate.VehicleId = fields[47].Get<uint32>();
716 creatureTemplate.mingold = fields[48].Get<uint32>();
717 creatureTemplate.maxgold = fields[49].Get<uint32>();
718 creatureTemplate.AIName = fields[50].Get<std::string>();
719 creatureTemplate.MovementType = uint32(fields[51].Get<uint8>());
720 if (!fields[52].IsNull())
721 {
722 creatureTemplate.Movement.Ground = static_cast<CreatureGroundMovementType>(fields[52].Get<uint8>());
723 }
724
725 creatureTemplate.Movement.Swim = fields[53].Get<bool>();
726 if (!fields[54].IsNull())
727 {
728 creatureTemplate.Movement.Flight = static_cast<CreatureFlightMovementType>(fields[54].Get<uint8>());
729 }
730
731 creatureTemplate.Movement.Rooted = fields[55].Get<bool>();
732 if (!fields[56].IsNull())
733 {
734 creatureTemplate.Movement.Chase = static_cast<CreatureChaseMovementType>(fields[56].Get<uint8>());
735 }
736 if (!fields[57].IsNull())
737 {
738 creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[57].Get<uint8>());
739 }
740 if (!fields[58].IsNull())
741 {
742 creatureTemplate.Movement.InteractionPauseTimer = fields[58].Get<uint32>();
743 }
744
745 creatureTemplate.HoverHeight = fields[59].Get<float>();
746 creatureTemplate.ModHealth = fields[60].Get<float>();
747 creatureTemplate.ModMana = fields[61].Get<float>();
748 creatureTemplate.ModArmor = fields[62].Get<float>();
749 creatureTemplate.ModExperience = fields[63].Get<float>();
750 creatureTemplate.RacialLeader = fields[64].Get<bool>();
751 creatureTemplate.movementId = fields[65].Get<uint32>();
752 creatureTemplate.RegenHealth = fields[66].Get<bool>();
753 creatureTemplate.MechanicImmuneMask = fields[67].Get<uint32>();
754 creatureTemplate.SpellSchoolImmuneMask = fields[68].Get<uint8>();
755 creatureTemplate.flags_extra = fields[69].Get<uint32>();
756 creatureTemplate.ScriptID = GetScriptId(fields[70].Get<std::string>());
757
758 // useful if the creature template load is being triggered from outside this class
759 if (triggerHook)
760 {
761 sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
762 }
763
764}
#define sScriptMgr
Definition: ScriptMgr.h:698
@ SPELL_SCHOOL_HOLY
Definition: SharedDefines.h:284

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateAddons()

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

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

◆ LoadCreatureTemplateResistances()

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

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 ( )
577{
578 uint32 oldMSTime = getMSTime();
579
580// 0 1 2 3 4 5 6 7 8
581 QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, "
582// 9 10 11 12 13 14 15 16 17 18 19 20 21 22
583 "modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, speed_swim, speed_flight, "
584// 23 24 25 26 27 28 29 30 31 32 33 34
585 "detection_range, scale, `rank`, dmgschool, DamageModifier, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, "
586// 35 36 37 38 39 40 41
587 "dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, type, "
588// 42 43 44 45 46 47 48 49 50 51
589 "type_flags, lootid, pickpocketloot, skinloot, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, "
590// 52 53 54 55 56 57 58 59 60 61 62 63
591 "ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, ExperienceModifier, "
592// 64 65 66 67 68 69 70
593 "RacialLeader, movementId, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName "
594 "FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId ORDER BY entry DESC;");
595
596 if (!result)
597 {
598 LOG_WARN("server.loading", ">> Loaded 0 creature template definitions. DB table `creature_template` is empty.");
599 return;
600 }
601
602 _creatureTemplateStore.rehash(result->GetRowCount());
604
605 uint32 count = 0;
606 do
607 {
608 Field* fields = result->Fetch();
609 LoadCreatureTemplate(fields);
610 ++count;
611 } while (result->NextRow());
612
613 sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
614
617
618 // Checking needs to be done after loading because of the difficulty self referencing
619 for (CreatureTemplateContainer::iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
620 {
621 CheckCreatureTemplate(&itr->second);
622 itr->second.InitializeQueryData();
623 }
624
625 LOG_INFO("server.loading", ">> Loaded {} Creature Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
626 LOG_INFO("server.loading", " ");
627}
void LoadCreatureTemplateResistances()
Definition: ObjectMgr.cpp:766
void LoadCreatureTemplateSpells()
Definition: ObjectMgr.cpp:812
void CheckCreatureTemplate(CreatureTemplate const *cInfo)
Definition: ObjectMgr.cpp:966
void LoadCreatureTemplate(Field *fields, bool triggerHook=false)
Loads a creature template from a database result.
Definition: ObjectMgr.cpp:635

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

◆ LoadCreatureTemplateSpells()

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

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 ( )
1563{
1564 uint32 oldMSTime = getMSTime();
1565
1566 // 0 1 2 3 4
1567 QueryResult result = WorldDatabase.Query("SELECT CreatureID, ID, ItemID1, ItemID2, ItemID3 FROM creature_equip_template");
1568
1569 if (!result)
1570 {
1571 LOG_WARN("server.loading", ">> Loaded 0 creature equipment templates. DB table `creature_equip_template` is empty!");
1572 LOG_INFO("server.loading", " ");
1573 return;
1574 }
1575
1576 uint32 count = 0;
1577 do
1578 {
1579 Field* fields = result->Fetch();
1580
1581 uint32 entry = fields[0].Get<uint32>();
1582
1583 if (!sObjectMgr->GetCreatureTemplate(entry))
1584 {
1585 LOG_ERROR("sql.sql", "Creature template (CreatureID: {}) does not exist but has a record in `creature_equip_template`", entry);
1586 continue;
1587 }
1588
1589 uint8 id = fields[1].Get<uint8>();
1590 if (!id)
1591 {
1592 LOG_ERROR("sql.sql", "Creature equipment template with id 0 found for creature {}, skipped.", entry);
1593 continue;
1594 }
1595
1596 EquipmentInfo& equipmentInfo = _equipmentInfoStore[entry][id];
1597
1598 equipmentInfo.ItemEntry[0] = fields[2].Get<uint32>();
1599 equipmentInfo.ItemEntry[1] = fields[3].Get<uint32>();
1600 equipmentInfo.ItemEntry[2] = fields[4].Get<uint32>();
1601
1602 for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1603 {
1604 if (!equipmentInfo.ItemEntry[i])
1605 continue;
1606
1607 ItemEntry const* dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]);
1608
1609 if (!dbcItem)
1610 {
1611 LOG_ERROR("sql.sql", "Unknown item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {}, forced to 0.",
1612 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1613 equipmentInfo.ItemEntry[i] = 0;
1614 continue;
1615 }
1616
1617 if (dbcItem->InventoryType != INVTYPE_WEAPON &&
1618 dbcItem->InventoryType != INVTYPE_SHIELD &&
1619 dbcItem->InventoryType != INVTYPE_RANGED &&
1620 dbcItem->InventoryType != INVTYPE_2HWEAPON &&
1623 dbcItem->InventoryType != INVTYPE_HOLDABLE &&
1624 dbcItem->InventoryType != INVTYPE_THROWN &&
1626 {
1627 LOG_ERROR("sql.sql", "Item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {} is not equipable in a hand, forced to 0.",
1628 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1629 equipmentInfo.ItemEntry[i] = 0;
1630 }
1631 }
1632
1633 ++count;
1634 } while (result->NextRow());
1635
1636 LOG_INFO("server.loading", ">> Loaded {} Equipment Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1637 LOG_INFO("server.loading", " ");
1638}
#define MAX_EQUIPMENT_ITEMS
Definition: CreatureData.h:39
@ INVTYPE_HOLDABLE
Definition: ItemTemplate.h:288
@ INVTYPE_RANGED
Definition: ItemTemplate.h:280
@ INVTYPE_THROWN
Definition: ItemTemplate.h:290
@ INVTYPE_RANGEDRIGHT
Definition: ItemTemplate.h:291
@ INVTYPE_WEAPON
Definition: ItemTemplate.h:278
@ INVTYPE_WEAPONMAINHAND
Definition: ItemTemplate.h:286
@ INVTYPE_WEAPONOFFHAND
Definition: ItemTemplate.h:287
@ INVTYPE_2HWEAPON
Definition: ItemTemplate.h:282
@ INVTYPE_SHIELD
Definition: ItemTemplate.h:279
Definition: CreatureData.h:349
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition: CreatureData.h:350
uint32 InventoryType
Definition: DBCStructure.h:1138

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 ( )
5548{
5550
5551 std::set<uint32> evt_scripts;
5552 // Load all possible script entries from gameobjects
5553 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
5554 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
5555 if (uint32 eventId = itr->second.GetEventScriptId())
5556 evt_scripts.insert(eventId);
5557
5558 // Load all possible script entries from spells
5559 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5560 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
5561 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5562 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
5563 if (spell->Effects[j].MiscValue)
5564 evt_scripts.insert(spell->Effects[j].MiscValue);
5565
5566 for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
5567 {
5568 for (size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
5569 {
5570 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
5571
5572 if (node->arrivalEventID)
5573 evt_scripts.insert(node->arrivalEventID);
5574
5575 if (node->departureEventID)
5576 evt_scripts.insert(node->departureEventID);
5577 }
5578 }
5579
5580 // Then check if all scripts are in above list of possible script entries
5581 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
5582 {
5583 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
5584 if (itr2 == evt_scripts.end())
5585 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 {}",
5586 itr->first, SPELL_EFFECT_SEND_EVENT);
5587 }
5588}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DBCStores.cpp:186
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition: GameObject.h:44
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:58
@ SCRIPTS_EVENT
Definition: ObjectMgr.h:152
@ SPELL_EFFECT_SEND_EVENT
Definition: SharedDefines.h:839
void LoadScripts(ScriptsType type)
Definition: ObjectMgr.cpp:5205
Definition: DBCStructure.h:1974
uint32 arrivalEventID
Definition: DBCStructure.h:1984
uint32 departureEventID
Definition: DBCStructure.h:1985

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 ( )
7418{
7419 uint32 oldMSTime = getMSTime();
7420
7421 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
7422
7423 if (!result)
7424 {
7425 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
7426 LOG_INFO("server.loading", " ");
7427 return;
7428 }
7429
7430 uint32 count = 0;
7431
7432 do
7433 {
7434 Field* fields = result->Fetch();
7435 uint8 level = fields[0].Get<uint8>();
7436 uint32 basexp = fields[1].Get<int32>();
7437 _baseXPTable[level] = basexp;
7438 ++count;
7439 } while (result->NextRow());
7440
7441 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7442 LOG_INFO("server.loading", " ");
7443}
std::int32_t int32
Definition: Define.h:104

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

◆ LoadFactionChangeAchievements()

void ObjectMgr::LoadFactionChangeAchievements ( )
9729{
9730 uint32 oldMSTime = getMSTime();
9731
9732 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_achievement");
9733
9734 if (!result)
9735 {
9736 LOG_WARN("server.loading", ">> Loaded 0 faction change achievement pairs. DB table `player_factionchange_achievement` is empty.");
9737 LOG_INFO("server.loading", " ");
9738 return;
9739 }
9740
9741 uint32 count = 0;
9742
9743 do
9744 {
9745 Field* fields = result->Fetch();
9746
9747 uint32 alliance = fields[0].Get<uint32>();
9748 uint32 horde = fields[1].Get<uint32>();
9749
9750 if (!sAchievementStore.LookupEntry(alliance))
9751 LOG_ERROR("sql.sql", "Achievement {} (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance);
9752 else if (!sAchievementStore.LookupEntry(horde))
9753 LOG_ERROR("sql.sql", "Achievement {} (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde);
9754 else
9755 FactionChangeAchievements[alliance] = horde;
9756
9757 ++count;
9758 } while (result->NextRow());
9759
9760 LOG_INFO("server.loading", ">> Loaded {} faction change achievement pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9761 LOG_INFO("server.loading", " ");
9762}
CharacterConversionMap FactionChangeAchievements
Definition: ObjectMgr.h:1429

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

◆ LoadFactionChangeItems()

void ObjectMgr::LoadFactionChangeItems ( )
9765{
9766 uint32 oldMSTime = getMSTime();
9767
9768 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
9769
9770 if (!result)
9771 {
9772 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
9773 LOG_INFO("server.loading", " ");
9774 return;
9775 }
9776
9777 uint32 count = 0;
9778
9779 do
9780 {
9781 Field* fields = result->Fetch();
9782
9783 uint32 alliance = fields[0].Get<uint32>();
9784 uint32 horde = fields[1].Get<uint32>();
9785
9786 if (!GetItemTemplate(alliance))
9787 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
9788 else if (!GetItemTemplate(horde))
9789 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
9790 else
9791 FactionChangeItems[alliance] = horde;
9792
9793 ++count;
9794 } while (result->NextRow());
9795
9796 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9797 LOG_INFO("server.loading", " ");
9798}
CharacterConversionMap FactionChangeItems
Definition: ObjectMgr.h:1430

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

◆ LoadFactionChangeQuests()

void ObjectMgr::LoadFactionChangeQuests ( )
9801{
9802 uint32 oldMSTime = getMSTime();
9803
9804 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
9805
9806 if (!result)
9807 {
9808 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
9809 LOG_INFO("server.loading", " ");
9810 return;
9811 }
9812
9813 uint32 count = 0;
9814
9815 do
9816 {
9817 Field* fields = result->Fetch();
9818
9819 uint32 alliance = fields[0].Get<uint32>();
9820 uint32 horde = fields[1].Get<uint32>();
9821
9822 if (!sObjectMgr->GetQuestTemplate(alliance))
9823 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
9824 else if (!sObjectMgr->GetQuestTemplate(horde))
9825 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
9826 else
9827 FactionChangeQuests[alliance] = horde;
9828
9829 ++count;
9830 } while (result->NextRow());
9831
9832 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9833 LOG_INFO("server.loading", " ");
9834}
CharacterConversionMap FactionChangeQuests
Definition: ObjectMgr.h:1431

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

◆ LoadFactionChangeReputations()

void ObjectMgr::LoadFactionChangeReputations ( )
9837{
9838 uint32 oldMSTime = getMSTime();
9839
9840 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
9841
9842 if (!result)
9843 {
9844 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
9845 LOG_INFO("server.loading", " ");
9846 return;
9847 }
9848
9849 uint32 count = 0;
9850
9851 do
9852 {
9853 Field* fields = result->Fetch();
9854
9855 uint32 alliance = fields[0].Get<uint32>();
9856 uint32 horde = fields[1].Get<uint32>();
9857
9858 if (!sFactionStore.LookupEntry(alliance))
9859 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
9860 else if (!sFactionStore.LookupEntry(horde))
9861 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
9862 else
9863 FactionChangeReputation[alliance] = horde;
9864
9865 ++count;
9866 } while (result->NextRow());
9867
9868 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9869 LOG_INFO("server.loading", " ");
9870}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
CharacterConversionMap FactionChangeReputation
Definition: ObjectMgr.h:1432

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

◆ LoadFactionChangeSpells()

void ObjectMgr::LoadFactionChangeSpells ( )
9873{
9874 uint32 oldMSTime = getMSTime();
9875
9876 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
9877
9878 if (!result)
9879 {
9880 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
9881 LOG_INFO("server.loading", " ");
9882 return;
9883 }
9884
9885 uint32 count = 0;
9886
9887 do
9888 {
9889 Field* fields = result->Fetch();
9890
9891 uint32 alliance = fields[0].Get<uint32>();
9892 uint32 horde = fields[1].Get<uint32>();
9893
9894 if (!sSpellMgr->GetSpellInfo(alliance))
9895 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
9896 else if (!sSpellMgr->GetSpellInfo(horde))
9897 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
9898 else
9899 FactionChangeSpells[alliance] = horde;
9900
9901 ++count;
9902 } while (result->NextRow());
9903
9904 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9905 LOG_INFO("server.loading", " ");
9906}
CharacterConversionMap FactionChangeSpells
Definition: ObjectMgr.h:1433

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

◆ LoadFactionChangeTitles()

void ObjectMgr::LoadFactionChangeTitles ( )
9909{
9910 uint32 oldMSTime = getMSTime();
9911
9912 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
9913
9914 if (!result)
9915 {
9916 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
9917 return;
9918 }
9919
9920 uint32 count = 0;
9921
9922 do
9923 {
9924 Field* fields = result->Fetch();
9925
9926 uint32 alliance = fields[0].Get<uint32>();
9927 uint32 horde = fields[1].Get<uint32>();
9928
9929 if (!sCharTitlesStore.LookupEntry(alliance))
9930 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
9931 else if (!sCharTitlesStore.LookupEntry(horde))
9932 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
9933 else
9934 FactionChangeTitles[alliance] = horde;
9935
9936 ++count;
9937 } while (result->NextRow());
9938
9939 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9940 LOG_INFO("server.loading", " ");
9941}
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
CharacterConversionMap FactionChangeTitles
Definition: ObjectMgr.h:1434

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

◆ LoadFishingBaseSkillLevel()

void ObjectMgr::LoadFishingBaseSkillLevel ( )
8632{
8633 uint32 oldMSTime = getMSTime();
8634
8635 _fishingBaseForAreaStore.clear(); // for reload case
8636
8637 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
8638
8639 if (!result)
8640 {
8641 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
8642 LOG_INFO("server.loading", " ");
8643 return;
8644 }
8645
8646 uint32 count = 0;
8647
8648 do
8649 {
8650 Field* fields = result->Fetch();
8651 uint32 entry = fields[0].Get<uint32>();
8652 int32 skill = fields[1].Get<int16>();
8653
8654 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8655 if (!fArea)
8656 {
8657 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8658 continue;
8659 }
8660
8661 _fishingBaseForAreaStore[entry] = skill;
8662 ++count;
8663 } while (result->NextRow());
8664
8665 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8666 LOG_INFO("server.loading", " ");
8667}

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

◆ LoadGameObjectAddons()

void ObjectMgr::LoadGameObjectAddons ( )
1453{
1454 uint32 oldMSTime = getMSTime();
1455
1456 // 0 1 2
1457 QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon");
1458
1459 if (!result)
1460 {
1461 LOG_WARN("server.loading", ">> Loaded 0 gameobject addon definitions. DB table `gameobject_addon` is empty.");
1462 LOG_INFO("server.loading", " ");
1463 return;
1464 }
1465
1466 uint32 count = 0;
1467 do
1468 {
1469 Field* fields = result->Fetch();
1470
1471 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1472
1473 const GameObjectData* goData = GetGameObjectData(guid);
1474 if (!goData)
1475 {
1476 LOG_ERROR("sql.sql", "GameObject (GUID: {}) does not exist but has a record in `gameobject_addon`", guid);
1477 continue;
1478 }
1479
1480 GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
1481 gameObjectAddon.invisibilityType = InvisibilityType(fields[1].Get<uint8>());
1482 gameObjectAddon.InvisibilityValue = fields[2].Get<uint32>();
1483
1484 if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
1485 {
1486 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid InvisibilityType in `gameobject_addon`", guid);
1487 gameObjectAddon.invisibilityType = INVISIBILITY_GENERAL;
1488 gameObjectAddon.InvisibilityValue = 0;
1489 }
1490
1491 if (gameObjectAddon.invisibilityType && !gameObjectAddon.InvisibilityValue)
1492 {
1493 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid);
1494 gameObjectAddon.InvisibilityValue = 1;
1495 }
1496
1497 ++count;
1498 } while (result->NextRow());
1499
1500 LOG_INFO("server.loading", ">> Loaded {} Gameobject Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1501 LOG_INFO("server.loading", " ");
1502}
InvisibilityType
Definition: SharedDefines.h:1254
@ TOTAL_INVISIBILITY_TYPES
Definition: SharedDefines.h:1268
@ INVISIBILITY_GENERAL
Definition: SharedDefines.h:1255
Definition: GameObjectData.h:682
uint32 InvisibilityValue
Definition: GameObjectData.h:684
InvisibilityType invisibilityType
Definition: GameObjectData.h:683

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

◆ LoadGameObjectForQuests()

void ObjectMgr::LoadGameObjectForQuests ( )
8511{
8512 uint32 oldMSTime = getMSTime();
8513
8514 if (sObjectMgr->GetGameObjectTemplates()->empty())
8515 {
8516 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
8517 LOG_INFO("server.loading", " ");
8518 return;
8519 }
8520
8521 uint32 count = 0;
8522
8523 // collect GO entries for GO that must activated
8524 GameObjectTemplateContainer* gotc = const_cast<GameObjectTemplateContainer*>(sObjectMgr->GetGameObjectTemplates());
8525 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
8526 {
8527 itr->second.IsForQuests = false;
8528 switch (itr->second.type)
8529 {
8531 itr->second.IsForQuests = true;
8532 ++count;
8533 break;
8535 {
8536 // scan GO chest with loot including quest items
8537 uint32 loot_id = (itr->second.GetLootId());
8538
8539 // find quest loot for GO
8540 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
8541 {
8542 itr->second.IsForQuests = true;
8543 ++count;
8544 }
8545 break;
8546 }
8548 {
8549 if (itr->second._generic.questID > 0) //quests objects
8550 {
8551 itr->second.IsForQuests = true;
8552 ++count;
8553 }
8554 break;
8555 }
8557 {
8558 if (itr->second.spellFocus.questID > 0) //quests objects
8559 {
8560 itr->second.IsForQuests = true;
8561 ++count;
8562 }
8563 break;
8564 }
8566 {
8567 if (itr->second.goober.questId > 0) //quests objects
8568 {
8569 itr->second.IsForQuests = true;
8570 ++count;
8571 }
8572 break;
8573 }
8574 default:
8575 break;
8576 }
8577 }
8578
8579 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8580 LOG_INFO("server.loading", " ");
8581}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition: SharedDefines.h:1568
@ GAMEOBJECT_TYPE_GENERIC
Definition: SharedDefines.h:1565
@ GAMEOBJECT_TYPE_CHEST
Definition: SharedDefines.h:1563
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition: SharedDefines.h:1562
@ GAMEOBJECT_TYPE_GOOBER
Definition: SharedDefines.h:1570
bool HaveQuestLootFor(uint32 loot_id) const
Definition: LootMgr.cpp:217

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

◆ LoadGameObjectLocales()

void ObjectMgr::LoadGameObjectLocales ( )
7062{
7063 uint32 oldMSTime = getMSTime();
7064
7065 _gameObjectLocaleStore.clear(); // need for reload case
7066
7067 // 0 1 2 3
7068 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7069 if (!result)
7070 return;
7071
7072 do
7073 {
7074 Field* fields = result->Fetch();
7075
7076 uint32 ID = fields[0].Get<uint32>();
7077
7078 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7079 if (locale == LOCALE_enUS)
7080 continue;
7081
7083 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7084 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7085 } while (result->NextRow());
7086
7087 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7088}
Definition: GameObjectData.h:675
std::vector< std::string > Name
Definition: GameObjectData.h:676
std::vector< std::string > CastBarCaption
Definition: GameObjectData.h:677

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

◆ LoadGameobjectQuestEnders()

void ObjectMgr::LoadGameobjectQuestEnders ( )
8098{
8099 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8100
8101 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8102 {
8103 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8104 if (!goInfo)
8105 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8106 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8107 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8108 }
8109}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
10002{
10003 uint32 oldMSTime = getMSTime();
10004
10005 // 0 1 2
10006 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
10007
10008 if (!result)
10009 {
10010 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
10011 return;
10012 }
10013
10014 uint32 count = 0;
10015 do
10016 {
10017 Field* fields = result->Fetch();
10018
10019 uint32 entry = fields[0].Get<uint32>();
10020 uint32 item = fields[1].Get<uint32>();
10021 uint32 idx = fields[2].Get<uint32>();
10022
10023 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
10024 if (!goInfo)
10025 {
10026 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
10027 continue;
10028 };
10029
10030 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10031 if (!dbcData)
10032 {
10033 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
10034 continue;
10035 };
10036
10037 _gameObjectQuestItemStore[entry].push_back(item);
10038
10039 ++count;
10040 } while (result->NextRow());
10041
10042 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10043 LOG_INFO("server.loading", " ");
10044}

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

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8084{
8085 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8086
8087 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8088 {
8089 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8090 if (!goInfo)
8091 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8092 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8093 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8094 }
8095}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

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

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

◆ LoadGameObjectTemplate()

void ObjectMgr::LoadGameObjectTemplate ( )
7150{
7151 uint32 oldMSTime = getMSTime();
7152
7153 // 0 1 2 3 4 5 6 7
7154 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7155 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7156 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7157 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7158 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7159 "FROM gameobject_template");
7160
7161 if (!result)
7162 {
7163 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7164 LOG_INFO("server.loading", " ");
7165 return;
7166 }
7167
7168 _gameObjectTemplateStore.rehash(result->GetRowCount());
7169 uint32 count = 0;
7170 do
7171 {
7172 Field* fields = result->Fetch();
7173
7174 uint32 entry = fields[0].Get<uint32>();
7175
7177
7178 got.entry = entry;
7179 got.type = uint32(fields[1].Get<uint8>());
7180 got.displayId = fields[2].Get<uint32>();
7181 got.name = fields[3].Get<std::string>();
7182 got.IconName = fields[4].Get<std::string>();
7183 got.castBarCaption = fields[5].Get<std::string>();
7184 got.unk1 = fields[6].Get<std::string>();
7185 got.size = fields[7].Get<float>();
7186
7187 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7188 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7189
7190 got.AIName = fields[32].Get<std::string>();
7191 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7192 got.IsForQuests = false;
7193
7194 // Checks
7195 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7196 {
7197 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7198 }
7199
7200 switch (got.type)
7201 {
7202 case GAMEOBJECT_TYPE_DOOR: //0
7203 {
7204 if (got.door.lockId)
7205 CheckGOLockId(&got, got.door.lockId, 1);
7206 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7207 break;
7208 }
7209 case GAMEOBJECT_TYPE_BUTTON: //1
7210 {
7211 if (got.button.lockId)
7212 CheckGOLockId(&got, got.button.lockId, 1);
7213 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7214 break;
7215 }
7217 {
7218 if (got.questgiver.lockId)
7219 CheckGOLockId(&got, got.questgiver.lockId, 0);
7220 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7221 break;
7222 }
7223 case GAMEOBJECT_TYPE_CHEST: //3
7224 {
7225 if (got.chest.lockId)
7226 CheckGOLockId(&got, got.chest.lockId, 0);
7227
7228 CheckGOConsumable(&got, got.chest.consumable, 3);
7229
7230 if (got.chest.linkedTrapId) // linked trap
7231 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7232 break;
7233 }
7234 case GAMEOBJECT_TYPE_TRAP: //6
7235 {
7236 if (got.trap.lockId)
7237 CheckGOLockId(&got, got.trap.lockId, 0);
7238 break;
7239 }
7240 case GAMEOBJECT_TYPE_CHAIR: //7
7241 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7242 break;
7244 {
7245 if (got.spellFocus.focusId)
7246 {
7247 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7248 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7249 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7250 }
7251
7252 if (got.spellFocus.linkedTrapId) // linked trap
7253 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7254 break;
7255 }
7256 case GAMEOBJECT_TYPE_GOOBER: //10
7257 {
7258 if (got.goober.lockId)
7259 CheckGOLockId(&got, got.goober.lockId, 0);
7260
7261 CheckGOConsumable(&got, got.goober.consumable, 3);
7262
7263 if (got.goober.pageId) // pageId
7264 {
7265 if (!GetPageText(got.goober.pageId))
7266 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7267 entry, got.type, got.goober.pageId, got.goober.pageId);
7268 }
7269 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7270 if (got.goober.linkedTrapId) // linked trap
7271 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7272 break;
7273 }
7275 {
7276 if (got.areadamage.lockId)
7277 CheckGOLockId(&got, got.areadamage.lockId, 0);
7278 break;
7279 }
7280 case GAMEOBJECT_TYPE_CAMERA: //13
7281 {
7282 if (got.camera.lockId)
7283 CheckGOLockId(&got, got.camera.lockId, 0);
7284 break;
7285 }
7287 {
7288 if (got.moTransport.taxiPathId)
7289 {
7290 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7291 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7292 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7293 }
7294 if (uint32 transportMap = got.moTransport.mapID)
7295 _transportMaps.insert(transportMap);
7296 break;
7297 }
7299 break;
7301 {
7302 // always must have spell
7303 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7304 break;
7305 }
7306 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7307 {
7308 if (got.flagstand.lockId)
7309 CheckGOLockId(&got, got.flagstand.lockId, 0);
7310 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7311 break;
7312 }
7314 {
7315 if (got.fishinghole.lockId)
7316 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7317 break;
7318 }
7319 case GAMEOBJECT_TYPE_FLAGDROP: //26
7320 {
7321 if (got.flagdrop.lockId)
7322 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7323 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7324 break;
7325 }
7327 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7328 break;
7329 }
7330
7331 ++count;
7332 } while (result->NextRow());
7333
7334 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7335 LOG_INFO("server.loading", " ");
7336}
#define sGameObjectAIRegistry
Definition: GameObjectAIFactory.h:50
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7130
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7109
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition: ObjectMgr.cpp:7118
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7139
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7099
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7090
@ 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:5789

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

◆ LoadGameObjectTemplateAddons()

void ObjectMgr::LoadGameObjectTemplateAddons ( )
7339{
7340 uint32 oldMSTime = getMSTime();
7341
7342 // 0 1 2 3 4 5 6 7 8
7343 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
7344
7345 if (!result)
7346 {
7347 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
7348 LOG_INFO("server.loading", " ");
7349 return;
7350 }
7351
7352 uint32 count = 0;
7353 do
7354 {
7355 Field* fields = result->Fetch();
7356
7357 uint32 entry = fields[0].Get<uint32>();
7358
7359 GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(entry);
7360 if (!got)
7361 {
7362 LOG_ERROR("sql.sql",
7363 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
7364 entry);
7365 continue;
7366 }
7367
7369 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
7370 gameObjectAddon.flags = fields[2].Get<uint32>();
7371 gameObjectAddon.mingold = fields[3].Get<uint32>();
7372 gameObjectAddon.maxgold = fields[4].Get<uint32>();
7373
7374 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
7375 {
7376 uint32 artKitID = fields[5 + i].Get<uint32>();
7377 if (!artKitID)
7378 continue;
7379
7380 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
7381 {
7382 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
7383 continue;
7384 }
7385
7386 gameObjectAddon.artKits[i] = artKitID;
7387 }
7388
7389 // checks
7390 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
7391 LOG_ERROR("sql.sql",
7392 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
7393 entry, gameObjectAddon.faction);
7394
7395 if (gameObjectAddon.maxgold > 0)
7396 {
7397 switch (got->type)
7398 {
7401 break;
7402 default:
7403 LOG_ERROR("sql.sql",
7404 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
7405 entry, got->type);
7406 break;
7407 }
7408 }
7409
7410 ++count;
7411 } while (result->NextRow());
7412
7413 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7414 LOG_INFO("server.loading", " ");
7415}
DBCStorage< GameObjectArtKitEntry > sGameObjectArtKitStore(GameObjectArtKitfmt)
Definition: GameObjectData.h:665
uint32 mingold
Definition: GameObjectData.h:669
uint32 flags
Definition: GameObjectData.h:668
uint32 faction
Definition: GameObjectData.h:667
std::array< uint32, 4 > artKits
Definition: GameObjectData.h:671
uint32 maxgold
Definition: GameObjectData.h:670

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

◆ LoadGameTele()

void ObjectMgr::LoadGameTele ( )
8772{
8773 uint32 oldMSTime = getMSTime();
8774
8775 _gameTeleStore.clear(); // for reload case
8776
8777 // 0 1 2 3 4 5 6
8778 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
8779
8780 if (!result)
8781 {
8782 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
8783 LOG_INFO("server.loading", " ");
8784 return;
8785 }
8786
8787 uint32 count = 0;
8788
8789 do
8790 {
8791 Field* fields = result->Fetch();
8792
8793 uint32 id = fields[0].Get<uint32>();
8794
8795 GameTele gt;
8796
8797 gt.position_x = fields[1].Get<float>();
8798 gt.position_y = fields[2].Get<float>();
8799 gt.position_z = fields[3].Get<float>();
8800 gt.orientation = fields[4].Get<float>();
8801 gt.mapId = fields[5].Get<uint16>();
8802 gt.name = fields[6].Get<std::string>();
8803
8804 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
8805 {
8806 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
8807 continue;
8808 }
8809
8810 if (!Utf8toWStr(gt.name, gt.wnameLow))
8811 {
8812 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
8813 continue;
8814 }
8815
8816 wstrToLower(gt.wnameLow);
8817
8818 _gameTeleStore[id] = gt;
8819
8820 ++count;
8821 } while (result->NextRow());
8822
8823 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8824 LOG_INFO("server.loading", " ");
8825}
float position_x
Definition: ObjectMgr.h:136

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

◆ LoadGossipMenu()

void ObjectMgr::LoadGossipMenu ( )
9188{
9189 uint32 oldMSTime = getMSTime();
9190
9191 _gossipMenusStore.clear();
9192
9193 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
9194
9195 if (!result)
9196 {
9197 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
9198 LOG_INFO("server.loading", " ");
9199 return;
9200 }
9201
9202 do
9203 {
9204 Field* fields = result->Fetch();
9205
9206 GossipMenus gMenu;
9207
9208 gMenu.MenuID = fields[0].Get<uint32>();
9209 gMenu.TextID = fields[1].Get<uint32>();
9210
9211 if (!GetGossipText(gMenu.TextID))
9212 {
9213 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
9214 continue;
9215 }
9216
9217 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
9218 } while (result->NextRow());
9219
9220 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
9221 LOG_INFO("server.loading", " ");
9222}
Definition: ObjectMgr.h:629
uint32 TextID
Definition: ObjectMgr.h:631
uint32 MenuID
Definition: ObjectMgr.h:630
GossipText const * GetGossipText(uint32 Text_ID) const
Definition: ObjectMgr.cpp:5963

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

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
9225{
9226 uint32 oldMSTime = getMSTime();
9227
9228 _gossipMenuItemsStore.clear();
9229
9230 QueryResult result = WorldDatabase.Query(
9231 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9232 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
9233 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
9234
9235 if (!result)
9236 {
9237 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
9238 LOG_INFO("server.loading", " ");
9239 return;
9240 }
9241
9242 do
9243 {
9244 Field* fields = result->Fetch();
9245
9246 GossipMenuItems gMenuItem;
9247
9248 gMenuItem.MenuID = fields[0].Get<uint32>();
9249 gMenuItem.OptionID = fields[1].Get<uint16>();
9250 gMenuItem.OptionIcon = fields[2].Get<uint32>();
9251 gMenuItem.OptionText = fields[3].Get<std::string>();
9252 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
9253 gMenuItem.OptionType = fields[5].Get<uint8>();
9254 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
9255 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
9256 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
9257 gMenuItem.BoxCoded = fields[9].Get<bool>();
9258 gMenuItem.BoxMoney = fields[10].Get<uint32>();
9259 gMenuItem.BoxText = fields[11].Get<std::string>();
9260 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
9261
9262 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
9263 {
9264 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);
9265 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
9266 }
9267
9269 {
9270 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
9271 gMenuItem.OptionBroadcastTextID = 0;
9272 }
9273
9274 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
9275 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);
9276
9277 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
9278 {
9279 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
9280 gMenuItem.ActionPoiID = 0;
9281 }
9282
9283 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
9284 {
9285 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
9286 gMenuItem.BoxBroadcastTextID = 0;
9287 }
9288
9289 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
9290 } while (result->NextRow());
9291
9292 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
9293 LOG_INFO("server.loading", " ");
9294}
@ GOSSIP_ICON_CHAT
Definition: GossipDef.h:60
@ GOSSIP_ICON_MAX
Definition: GossipDef.h:81
@ GOSSIP_OPTION_MAX
Definition: GossipDef.h:55
Definition: ObjectMgr.h:611
uint8 OptionIcon
Definition: ObjectMgr.h:614
uint32 BoxBroadcastTextID
Definition: ObjectMgr.h:625
std::string OptionText
Definition: ObjectMgr.h:615
uint32 ActionMenuID
Definition: ObjectMgr.h:619
bool BoxCoded
Definition: ObjectMgr.h:621
uint32 MenuID
Definition: ObjectMgr.h:612
uint32 OptionNpcFlag
Definition: ObjectMgr.h:618
uint32 ActionPoiID
Definition: ObjectMgr.h:620
uint32 BoxMoney
Definition: ObjectMgr.h:622
std::string BoxText
Definition: ObjectMgr.h:623
uint32 OptionID
Definition: ObjectMgr.h:613
uint32 OptionType
Definition: ObjectMgr.h:617
uint32 OptionBroadcastTextID
Definition: ObjectMgr.h:616
PointOfInterest const * GetPointOfInterest(uint32 id) const
Definition: ObjectMgr.h:925
BroadcastText const * GetBroadcastText(uint32 id) const
Definition: ObjectMgr.h:1192

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 ( )
477{
478 uint32 oldMSTime = getMSTime();
479
480 _gossipMenuItemsLocaleStore.clear(); // need for reload case
481
482 // 0 1 2 3 4
483 QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale");
484
485 if (!result)
486 return;
487
488 do
489 {
490 Field* fields = result->Fetch();
491
492 uint32 MenuID = fields[0].Get<uint32>();
493 uint16 OptionID = fields[1].Get<uint16>();
494
495 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
496 if (locale == LOCALE_enUS)
497 continue;
498
500 AddLocaleString(fields[3].Get<std::string>(), locale, data.OptionText);
501 AddLocaleString(fields[4].Get<std::string>(), locale, data.BoxText);
502 } while (result->NextRow());
503
504 LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale Strings in {} ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
505}
Definition: CreatureData.h:338
std::vector< std::string > BoxText
Definition: CreatureData.h:340
std::vector< std::string > OptionText
Definition: CreatureData.h:339

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

◆ LoadGossipText()

void ObjectMgr::LoadGossipText ( )
5972{
5973 uint32 oldMSTime = getMSTime();
5974
5975 QueryResult result = WorldDatabase.Query("SELECT ID, "
5976 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
5977 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
5978 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
5979 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
5980 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
5981 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
5982 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
5983 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
5984 "FROM npc_text");
5985
5986 if (!result)
5987 {
5988 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
5989 LOG_INFO("server.loading", " ");
5990 return;
5991 }
5992
5993 _gossipTextStore.rehash(result->GetRowCount());
5994
5995 uint32 count = 0;
5996 uint8 cic;
5997
5998 do
5999 {
6000 cic = 0;
6001
6002 Field* fields = result->Fetch();
6003
6004 uint32 id = fields[cic++].Get<uint32>();
6005 if (!id)
6006 {
6007 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
6008 continue;
6009 }
6010
6011 GossipText& gText = _gossipTextStore[id];
6012
6013 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6014 {
6015 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
6016 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
6017 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
6018 gText.Options[i].Language = fields[cic++].Get<uint8>();
6019 gText.Options[i].Probability = fields[cic++].Get<float>();
6020
6021 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
6022 {
6023 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
6024 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
6025 }
6026 }
6027
6028 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
6029 {
6030 if (gText.Options[i].BroadcastTextID)
6031 {
6033 {
6034 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
6035 gText.Options[i].BroadcastTextID = 0;
6036 }
6037 }
6038 }
6039
6040 count++;
6041 } while (result->NextRow());
6042
6043 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6044 LOG_INFO("server.loading", " ");
6045}
#define MAX_GOSSIP_TEXT_OPTIONS
Definition: NPCHandler.h:42
#define MAX_GOSSIP_TEXT_EMOTES
Definition: NPCHandler.h:30
uint32 _Emote
Definition: NPCHandler.h:26
uint32 _Delay
Definition: NPCHandler.h:27
std::string Text_0
Definition: NPCHandler.h:34
QEmote Emotes[MAX_GOSSIP_TEXT_EMOTES]
Definition: NPCHandler.h:39
uint32 Language
Definition: NPCHandler.h:37
float Probability
Definition: NPCHandler.h:38
uint32 BroadcastTextID
Definition: NPCHandler.h:36
std::string Text_1
Definition: NPCHandler.h:35
Definition: NPCHandler.h:45
GossipTextOption Options[MAX_GOSSIP_TEXT_OPTIONS]
Definition: NPCHandler.h:46

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

◆ LoadInstanceEncounters()

void ObjectMgr::LoadInstanceEncounters ( )
5879{
5880 uint32 oldMSTime = getMSTime();
5881
5882 // 0 1 2 3
5883 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
5884 if (!result)
5885 {
5886 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
5887 LOG_INFO("server.loading", " ");
5888 return;
5889 }
5890
5891 uint32 count = 0;
5892 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
5893 do
5894 {
5895 Field* fields = result->Fetch();
5896 uint32 entry = fields[0].Get<uint32>();
5897 uint8 creditType = fields[1].Get<uint8>();
5898 uint32 creditEntry = fields[2].Get<uint32>();
5899 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
5900 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
5901 if (!dungeonEncounter)
5902 {
5903 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
5904 continue;
5905 }
5906
5907 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
5908 {
5909 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
5910 continue;
5911 }
5912
5913 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
5914 if (lastEncounterDungeon)
5915 {
5916 if (itr != dungeonLastBosses.end())
5917 {
5918 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]);
5919 continue;
5920 }
5921
5922 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
5923 }
5924
5925 switch (creditType)
5926 {
5928 {
5929 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
5930 if (!creatureInfo)
5931 {
5932 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5933 continue;
5934 }
5935 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
5936 break;
5937 }
5939 {
5940 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
5941 if (!spellInfo)
5942 {
5943 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5944 continue;
5945 }
5946 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
5947 break;
5948 }
5949 default:
5950 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
5951 continue;
5952 }
5953
5954 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
5955 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
5956 ++count;
5957 } while (result->NextRow());
5958
5959 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5960 LOG_INFO("server.loading", " ");
5961}
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
#define sLFGMgr
Definition: LFGMgr.h:641
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition: CreatureData.h:77
std::list< DungeonEncounter const * > DungeonEncounterList
Definition: ObjectMgr.h:719
EncounterCreditType
Definition: Map.h:307
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition: Map.h:308
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition: Map.h:309
@ SPELL_ATTR0_CU_ENCOUNTER_REWARD
Definition: SpellInfo.h:206
Definition: ObjectMgr.h:709
Definition: DBCStructure.h:857

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.

◆ LoadInstanceSavedGameobjectStateData()

void ObjectMgr::LoadInstanceSavedGameobjectStateData ( )
10140{
10141 uint32 oldMSTime = getMSTime();
10142
10144 PreparedQueryResult result = CharacterDatabase.Query(stmt);
10145
10146 if (!result)
10147 {
10148 // There's no gameobject with this GUID saved on the DB
10149 LOG_INFO("sql.sql", ">> Loaded 0 Instance saved gameobject state data. DB table `instance_saved_go_state_data` is empty.");
10150 return;
10151 }
10152
10153 Field* fields;
10154 uint32 count = 0;
10155 do
10156 {
10157 fields = result->Fetch();
10158 GameobjectInstanceSavedStateList.push_back({ fields[0].Get<uint32>(), fields[1].Get<uint32>(), fields[2].Get<unsigned short>() });
10159 count++;
10160 } while (result->NextRow());
10161
10162 LOG_INFO("server.loading", ">> Loaded {} instance saved gameobject state data in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10163 LOG_INFO("server.loading", " ");
10164}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ CHAR_SELECT_INSTANCE_SAVED_DATA
Definition: CharacterDatabase.h:519

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

◆ LoadInstanceTemplate()

void ObjectMgr::LoadInstanceTemplate ( )
5828{
5829 uint32 oldMSTime = getMSTime();
5830
5831 // 0 1 2 4
5832 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
5833
5834 if (!result)
5835 {
5836 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `page_text` is empty!");
5837 LOG_INFO("server.loading", " ");
5838 return;
5839 }
5840
5841 uint32 count = 0;
5842 do
5843 {
5844 Field* fields = result->Fetch();
5845
5846 uint16 mapID = fields[0].Get<uint16>();
5847
5848 if (!MapMgr::IsValidMAP(mapID, true))
5849 {
5850 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
5851 continue;
5852 }
5853
5854 InstanceTemplate instanceTemplate;
5855
5856 instanceTemplate.AllowMount = fields[3].Get<bool>();
5857 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
5858 instanceTemplate.ScriptId = sObjectMgr->GetScriptId(fields[2].Get<std::string>());
5859
5860 _instanceTemplateStore[mapID] = instanceTemplate;
5861
5862 ++count;
5863 } while (result->NextRow());
5864
5865 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5866 LOG_INFO("server.loading", " ");
5867}
bool AllowMount
Definition: Map.h:277
uint32 ScriptId
Definition: Map.h:276
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition: MapMgr.cpp:309

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

◆ LoadItemLocales()

void ObjectMgr::LoadItemLocales ( )
2682{
2683 uint32 oldMSTime = getMSTime();
2684
2685 _itemLocaleStore.clear(); // need for reload case
2686
2687 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
2688 if (!result)
2689 return;
2690
2691 do
2692 {
2693 Field* fields = result->Fetch();
2694
2695 uint32 ID = fields[0].Get<uint32>();
2696
2697 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
2698 if (locale == LOCALE_enUS)
2699 continue;
2700
2701 ItemLocale& data = _itemLocaleStore[ID];
2702 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
2703 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
2704 } while (result->NextRow());
2705
2706 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
2707}
Definition: ItemTemplate.h:843
std::vector< std::string > Description
Definition: ItemTemplate.h:845
std::vector< std::string > Name
Definition: ItemTemplate.h:844

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

◆ LoadItemSetNameLocales()

void ObjectMgr::LoadItemSetNameLocales ( )
3326{
3327 uint32 oldMSTime = getMSTime();
3328
3329 _itemSetNameLocaleStore.clear(); // need for reload case
3330
3331 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3332
3333 if (!result)
3334 return;
3335
3336 do
3337 {
3338 Field* fields = result->Fetch();
3339
3340 uint32 ID = fields[0].Get<uint32>();
3341
3342 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3343 if (locale == LOCALE_enUS)
3344 continue;
3345
3347 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3348 } while (result->NextRow());
3349
3350 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3351}
Definition: ItemTemplate.h:855
std::vector< std::string > Name
Definition: ItemTemplate.h:856

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

◆ LoadItemSetNames()

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

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

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

◆ LoadLinkedRespawn()

void ObjectMgr::LoadLinkedRespawn ( )
1835{
1836 uint32 oldMSTime = getMSTime();
1837
1838 _linkedRespawnStore.clear();
1839 // 0 1 2
1840 QueryResult result = WorldDatabase.Query("SELECT guid, linkedGuid, linkType FROM linked_respawn ORDER BY guid ASC");
1841
1842 if (!result)
1843 {
1844 LOG_WARN("server.loading", ">> Loaded 0 linked respawns. DB table `linked_respawn` is empty.");
1845 LOG_INFO("server.loading", " ");
1846 return;
1847 }
1848
1849 do
1850 {
1851 Field* fields = result->Fetch();
1852
1853 ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
1854 ObjectGuid::LowType linkedGuidLow = fields[1].Get<uint32>();
1855 uint8 linkType = fields[2].Get<uint8>();
1856
1857 ObjectGuid guid, linkedGuid;
1858 bool error = false;
1859 switch (linkType)
1860 {
1862 {
1863 const CreatureData* slave = GetCreatureData(guidLow);
1864 if (!slave)
1865 {
1866 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1867 error = true;
1868 break;
1869 }
1870
1871 const CreatureData* master = GetCreatureData(linkedGuidLow);
1872 if (!master)
1873 {
1874 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1875 error = true;
1876 break;
1877 }
1878
1879 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1880 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1881 {
1882 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1883 error = true;
1884 break;
1885 }
1886
1887 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1888 {
1889 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1890 error = true;
1891 break;
1892 }
1893
1894 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1895 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1896 break;
1897 }
1898 case CREATURE_TO_GO:
1899 {
1900 const CreatureData* slave = GetCreatureData(guidLow);
1901 if (!slave)
1902 {
1903 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1904 error = true;
1905 break;
1906 }
1907
1908 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1909 if (!master)
1910 {
1911 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1912 error = true;
1913 break;
1914 }
1915
1916 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1917 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1918 {
1919 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1920 error = true;
1921 break;
1922 }
1923
1924 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1925 {
1926 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1927 error = true;
1928 break;
1929 }
1930
1931 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1932 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
1933 break;
1934 }
1935 case GO_TO_GO:
1936 {
1937 const GameObjectData* slave = GetGameObjectData(guidLow);
1938 if (!slave)
1939 {
1940 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
1941 error = true;
1942 break;
1943 }
1944
1945 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1946 if (!master)
1947 {
1948 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1949 error = true;
1950 break;
1951 }
1952
1953 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1954 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1955 {
1956 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1957 error = true;
1958 break;
1959 }
1960
1961 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1962 {
1963 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1964 error = true;
1965 break;
1966 }
1967
1968 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
1969 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
1970 break;
1971 }
1972 case GO_TO_CREATURE:
1973 {
1974 const GameObjectData* slave = GetGameObjectData(guidLow);
1975 if (!slave)
1976 {
1977 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
1978 error = true;
1979 break;
1980 }
1981
1982 const CreatureData* master = GetCreatureData(linkedGuidLow);
1983 if (!master)
1984 {
1985 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1986 error = true;
1987 break;
1988 }
1989
1990 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1991 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1992 {
1993 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1994 error = true;
1995 break;
1996 }
1997
1998 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1999 {
2000 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2001 error = true;
2002 break;
2003 }
2004
2005 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2006 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
2007 break;
2008 }
2009 }
2010
2011 if (!error)
2012 _linkedRespawnStore[guid] = linkedGuid;
2013 } while (result->NextRow());
2014
2015 LOG_INFO("server.loading", ">> Loaded {} Linked Respawns In {} ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime));
2016 LOG_INFO("server.loading", " ");
2017}
Definition: ObjectGuid.h:120
bool Instanceable() const
Definition: DBCStructure.h:1351

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 ( )
8912{
8913 uint32 oldMSTime = getMSTime();
8914
8915 _mailLevelRewardStore.clear(); // for reload case
8916
8917 // 0 1 2 3
8918 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
8919
8920 if (!result)
8921 {
8922 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
8923 LOG_INFO("server.loading", " ");
8924 return;
8925 }
8926
8927 uint32 count = 0;
8928
8929 do
8930 {
8931 Field* fields = result->Fetch();
8932
8933 uint8 level = fields[0].Get<uint8>();
8934 uint32 raceMask = fields[1].Get<uint32>();
8935 uint32 mailTemplateId = fields[2].Get<uint32>();
8936 uint32 senderEntry = fields[3].Get<uint32>();
8937
8938 if (level > MAX_LEVEL)
8939 {
8940 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
8941 continue;
8942 }
8943
8944 if (!(raceMask & RACEMASK_ALL_PLAYABLE))
8945 {
8946 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
8947 continue;
8948 }
8949
8950 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
8951 {
8952 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
8953 continue;
8954 }
8955
8956 if (!GetCreatureTemplate(senderEntry))
8957 {
8958 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);
8959 continue;
8960 }
8961
8962 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
8963
8964 ++count;
8965 } while (result->NextRow());
8966
8967 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8968 LOG_INFO("server.loading", " ");
8969}
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
#define MAX_LEVEL
Definition: DBCEnums.h:47
Definition: ObjectMgr.h:537

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

◆ LoadMailServerTemplates()

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

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

◆ LoadNPCSpellClickSpells()

void ObjectMgr::LoadNPCSpellClickSpells ( )
7952{
7953 uint32 oldMSTime = getMSTime();
7954
7955 _spellClickInfoStore.clear();
7956 // 0 1 2 3
7957 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
7958
7959 if (!result)
7960 {
7961 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
7962 LOG_INFO("server.loading", " ");
7963 return;
7964 }
7965
7966 uint32 count = 0;
7967
7968 do
7969 {
7970 Field* fields = result->Fetch();
7971
7972 uint32 npc_entry = fields[0].Get<uint32>();
7973 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
7974 if (!cInfo)
7975 {
7976 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
7977 continue;
7978 }
7979
7980 uint32 spellid = fields[1].Get<uint32>();
7981 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
7982 if (!spellinfo)
7983 {
7984 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
7985 continue;
7986 }
7987
7988 uint8 userType = fields[3].Get<uint16>();
7989 if (userType >= SPELL_CLICK_USER_MAX)
7990 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
7991
7992 uint8 castFlags = fields[2].Get<uint8>();
7993 SpellClickInfo info;
7994 info.spellId = spellid;
7995 info.castFlags = castFlags;
7996 info.userType = SpellClickUserTypes(userType);
7997 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
7998
7999 ++count;
8000 } while (result->NextRow());
8001
8002 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
8003 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
8004 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
8005 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
8006 {
8007 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
8008 {
8009 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);
8010 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
8011 }
8012 }
8013
8014 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8015 LOG_INFO("server.loading", " ");
8016}
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: Unit.h:540
SpellClickUserTypes
Definition: SharedDefines.h:680
@ SPELL_CLICK_USER_MAX
Definition: SharedDefines.h:685
Definition: ObjectMgr.h:399
uint32 spellId
Definition: ObjectMgr.h:400

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

◆ LoadNpcTextLocales()

void ObjectMgr::LoadNpcTextLocales ( )
6048{
6049 uint32 oldMSTime = getMSTime();
6050
6051 _npcTextLocaleStore.clear(); // need for reload case
6052
6053 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6054 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6055 "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 "
6056 "FROM npc_text_locale");
6057
6058 if (!result)
6059 return;
6060
6061 do
6062 {
6063 Field* fields = result->Fetch();
6064
6065 uint32 ID = fields[0].Get<uint32>();
6066
6067 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6068 if (locale == LOCALE_enUS)
6069 continue;
6070
6072 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6073 {
6074 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6075 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6076 }
6077 } while (result->NextRow());
6078
6079 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6080}
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 ( )
5799{
5800 uint32 oldMSTime = getMSTime();
5801
5802 _pageTextLocaleStore.clear(); // need for reload case
5803
5804 // 0 1 2
5805 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
5806
5807 if (!result)
5808 return;
5809
5810 do
5811 {
5812 Field* fields = result->Fetch();
5813
5814 uint32 ID = fields[0].Get<uint32>();
5815
5816 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5817 if (locale == LOCALE_enUS)
5818 continue;
5819
5821 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
5822 } while (result->NextRow());
5823
5824 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5825}
Definition: NPCHandler.h:50
std::vector< std::string > Text
Definition: NPCHandler.h:51

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

◆ LoadPageTexts()

void ObjectMgr::LoadPageTexts ( )
5749{
5750 uint32 oldMSTime = getMSTime();
5751
5752 // 0 1 2
5753 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
5754
5755 if (!result)
5756 {
5757 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
5758 LOG_INFO("server.loading", " ");
5759 return;
5760 }
5761
5762 uint32 count = 0;
5763 do
5764 {
5765 Field* fields = result->Fetch();
5766
5767 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
5768
5769 pageText.Text = fields[1].Get<std::string>();
5770 pageText.NextPage = fields[2].Get<uint32>();
5771
5772 ++count;
5773 } while (result->NextRow());
5774
5775 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
5776 {
5777 if (itr->second.NextPage)
5778 {
5779 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
5780 if (itr2 == _pageTextStore.end())
5781 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
5782 }
5783 }
5784
5785 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5786 LOG_INFO("server.loading", " ");
5787}
Definition: ObjectMgr.h:60
uint16 NextPage
Definition: ObjectMgr.h:62
std::string Text
Definition: ObjectMgr.h:61

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

◆ LoadPetLevelInfo()

void ObjectMgr::LoadPetLevelInfo ( )
3538{
3539 uint32 oldMSTime = getMSTime();
3540
3541 // 0 1 2 3 4 5 6 7 8 9 10 11
3542 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
3543
3544 if (!result)
3545 {
3546 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
3547 LOG_INFO("server.loading", " ");
3548 return;
3549 }
3550
3551 uint32 count = 0;
3552
3553 do
3554 {
3555 Field* fields = result->Fetch();
3556
3557 uint32 creature_id = fields[0].Get<uint32>();
3558 if (!sObjectMgr->GetCreatureTemplate(creature_id))
3559 {
3560 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
3561 continue;
3562 }
3563
3564 uint32 current_level = fields[1].Get<uint8>();
3565 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3566 {
3567 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
3568 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
3569 else
3570 {
3571 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
3572 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
3573 }
3574 continue;
3575 }
3576 else if (current_level < 1)
3577 {
3578 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
3579 continue;
3580 }
3581
3582 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
3583
3584 if (!pInfoMapEntry)
3585 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
3586
3587 // data for level 1 stored in [0] array element, ...
3588 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
3589
3590 pLevelInfo->health = fields[2].Get<uint32>();
3591 pLevelInfo->mana = fields[3].Get<uint32>();
3592 pLevelInfo->armor = fields[9].Get<uint32>();
3593 pLevelInfo->min_dmg = fields[10].Get<uint32>();
3594 pLevelInfo->max_dmg = fields[11].Get<uint32>();
3595 for (uint8 i = 0; i < MAX_STATS; i++)
3596 {
3597 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
3598 }
3599
3600 ++count;
3601 } while (result->NextRow());
3602
3603 // Fill gaps and check integrity
3604 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
3605 {
3606 PetLevelInfo* pInfo = itr->second;
3607
3608 // fatal error if no level 1 data
3609 if (!pInfo || pInfo[0].health == 0)
3610 {
3611 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
3612 exit(1);
3613 }
3614
3615 // fill level gaps
3616 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
3617 {
3618 if (pInfo[level].health == 0)
3619 {
3620 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
3621 pInfo[level] = pInfo[level - 1];
3622 }
3623 }
3624 }
3625
3626 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3627 LOG_INFO("server.loading", " ");
3628}
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:51
#define MAX_STATS
Definition: SharedDefines.h:265
Definition: ObjectMgr.h:522
uint32 max_dmg
Definition: ObjectMgr.h:533
uint32 mana
Definition: ObjectMgr.h:530
uint32 min_dmg
Definition: ObjectMgr.h:532
uint32 health
Definition: ObjectMgr.h:529
std::array< uint32, MAX_STATS > stats
Definition: ObjectMgr.h:528
uint32 armor
Definition: ObjectMgr.h:531

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 ( )
7458{
7459 uint32 oldMSTime = getMSTime();
7460 // 0 1 2
7461 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
7462
7463 if (!result)
7464 {
7465 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
7466 LOG_INFO("server.loading", " ");
7467 return;
7468 }
7469
7470 uint32 count = 0;
7471
7472 do
7473 {
7474 Field* fields = result->Fetch();
7475 std::string word = fields[0].Get<std::string>();
7476 uint32 entry = fields[1].Get<uint32>();
7477 bool half = fields[2].Get<bool>();
7478 if (half)
7479 _petHalfName1[entry].push_back(word);
7480 else
7481 _petHalfName0[entry].push_back(word);
7482 ++count;
7483 } while (result->NextRow());
7484
7485 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7486 LOG_INFO("server.loading", " ");
7487}

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

◆ LoadPetNamesLocales()

void ObjectMgr::LoadPetNamesLocales ( )
508{
509 uint32 oldMSTime = getMSTime();
510
511 // 0 1 2 3
512 QueryResult result = WorldDatabase.Query("SELECT Locale, Word, Entry, Half FROM pet_name_generation_locale");
513
514 if (!result)
515 {
516 LOG_WARN("server.loading", ">> Loaded 0 pet name locales parts. DB table `pet_name_generation_locale` is empty!");
517 LOG_INFO("server.loading", " ");
518 return;
519 }
520
521 uint32 count = 0;
522
523 do
524 {
525 Field* fields = result->Fetch();
526 LocaleConstant locale = GetLocaleByName(fields[0].Get<std::string>());
527 std::string word = fields[1].Get<std::string>();
528
529 uint32 entry = fields[2].Get<uint32>();
530 bool half = fields[3].Get<bool>();
531 std::pair<uint32, LocaleConstant> pairkey = std::make_pair(entry, locale);
532 if (half)
533 {
534 _petHalfLocaleName1[pairkey].push_back(word);
535 }
536 else
537 {
538 _petHalfLocaleName0[pairkey].push_back(word);
539 }
540 ++count;
541 } while (result->NextRow());
542
543 LOG_INFO("server.loading", ">> Loaded {} Pet Name Locales Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
544 LOG_INFO("server.loading", " ");
545}

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

◆ LoadPetNumber()

void ObjectMgr::LoadPetNumber ( )
7490{
7491 uint32 oldMSTime = getMSTime();
7492
7493 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
7494 if (result)
7495 {
7496 Field* fields = result->Fetch();
7497 _hiPetNumber = fields[0].Get<uint32>() + 1;
7498 }
7499
7500 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
7501 LOG_INFO("server.loading", " ");
7502}

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

◆ LoadPlayerInfo()

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

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

◆ LoadPointOfInterestLocales()

void ObjectMgr::LoadPointOfInterestLocales ( )
548{
549 uint32 oldMSTime = getMSTime();
550
551 _pointOfInterestLocaleStore.clear(); // need for reload case
552
553 // 0 1 2
554 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale");
555
556 if (!result)
557 return;
558
559 do
560 {
561 Field* fields = result->Fetch();
562
563 uint32 ID = fields[0].Get<uint32>();
564
565 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
566 if (locale == LOCALE_enUS)
567 continue;
568
570 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
571 } while (result->NextRow());
572
573 LOG_INFO("server.loading", ">> Loaded {} Points Of Interest Locale Strings in {} ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
574}
Definition: CreatureData.h:344
std::vector< std::string > Name
Definition: CreatureData.h:345

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

◆ LoadPointsOfInterest()

void ObjectMgr::LoadPointsOfInterest ( )
7821{
7822 uint32 oldMSTime = getMSTime();
7823
7824 _pointsOfInterestStore.clear(); // need for reload case
7825
7826 uint32 count = 0;
7827
7828 // 0 1 2 3 4 5 6
7829 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
7830
7831 if (!result)
7832 {
7833 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
7834 LOG_INFO("server.loading", " ");
7835 return;
7836 }
7837
7838 do
7839 {
7840 Field* fields = result->Fetch();
7841
7842 uint32 point_id = fields[0].Get<uint32>();
7843
7844 PointOfInterest POI;
7845 POI.ID = point_id;
7846 POI.PositionX = fields[1].Get<float>();
7847 POI.PositionY = fields[2].Get<float>();
7848 POI.Icon = fields[3].Get<uint32>();
7849 POI.Flags = fields[4].Get<uint32>();
7850 POI.Importance = fields[5].Get<uint32>();
7851 POI.Name = fields[6].Get<std::string>();
7852
7853 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
7854 {
7855 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
7856 continue;
7857 }
7858
7859 _pointsOfInterestStore[point_id] = POI;
7860
7861 ++count;
7862 } while (result->NextRow());
7863
7864 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7865 LOG_INFO("server.loading", " ");
7866}
bool IsValidMapCoord(float c)
Definition: GridDefines.h:216
Definition: ObjectMgr.h:582
uint32 ID
Definition: ObjectMgr.h:583

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

◆ LoadProfanityPlayersNames()

void ObjectMgr::LoadProfanityPlayersNames ( )
8215{
8216 uint32 oldMSTime = getMSTime();
8217
8218 _profanityNamesStore.clear(); // need for reload case
8219
8220 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
8221
8222 if (!result)
8223 {
8224 LOG_WARN("server.loading", ">> Loaded 0 profanity player names. DB table `profanity_name` is empty!");
8225 LOG_INFO("server.loading", " ");
8226 return;
8227 }
8228
8229 uint32 count = 0;
8230
8231 Field* fields;
8232 do
8233 {
8234 fields = result->Fetch();
8235 std::string name = fields[0].Get<std::string>();
8236
8237 std::wstring wstr;
8238 if (!Utf8toWStr (name, wstr))
8239 {
8240 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
8241 continue;
8242 }
8243
8244 wstrToLower(wstr);
8245
8246 _profanityNamesStore.insert(wstr);
8247 ++count;
8248 } while (result->NextRow());
8249
8250 LOG_INFO("server.loading", ">> Loaded {} profanity player names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8251 LOG_INFO("server.loading", " ");
8252}

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

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6206{
6207 uint32 oldMSTime = getMSTime();
6208
6209 _questAreaTriggerStore.clear(); // need for reload case
6210
6211 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6212
6213 if (!result)
6214 {
6215 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6216 LOG_INFO("server.loading", " ");
6217 return;
6218 }
6219
6220 uint32 count = 0;
6221
6222 do
6223 {
6224 ++count;
6225
6226 Field* fields = result->Fetch();
6227
6228 uint32 trigger_ID = fields[0].Get<uint32>();
6229 uint32 quest_ID = fields[1].Get<uint32>();
6230
6231 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6232 if (!atEntry)
6233 {
6234 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6235 continue;
6236 }
6237
6238 Quest const* quest = GetQuestTemplate(quest_ID);
6239
6240 if (!quest)
6241 {
6242 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6243 continue;
6244 }
6245
6247 {
6248 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);
6249
6250 // this will prevent quest completing without objective
6251 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6252
6253 // continue; - quest modified to required objective and trigger can be allowed.
6254 }
6255
6256 _questAreaTriggerStore[trigger_ID] = quest_ID;
6257 } while (result->NextRow());
6258
6259 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6260 LOG_INFO("server.loading", " ");
6261}
@ QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT
Definition: QuestDef.h:161
Definition: QuestDef.h:207
bool HasSpecialFlag(uint32 flag) const
Definition: QuestDef.h:221

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 ( )
6277{
6278 uint32 oldMSTime = getMSTime();
6279
6280 for (std::size_t i = 0; i < _questGreetingStore.size(); ++i)
6281 _questGreetingStore[i].clear();
6282
6283 // 0 1 2 3 4
6284 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6285 if (!result)
6286 {
6287 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6288 return;
6289 }
6290
6291 uint32 count = 0;
6292
6293 do
6294 {
6295 Field* fields = result->Fetch();
6296
6297 uint32 id = fields[0].Get<uint32>();
6298 uint8 type = fields[1].Get<uint8>();
6299 switch (type)
6300 {
6301 case 0: // Creature
6302 if (!sObjectMgr->GetCreatureTemplate(id))
6303 {
6304 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6305 continue;
6306 }
6307 break;
6308 case 1: // GameObject
6309 if (!sObjectMgr->GetGameObjectTemplate(id))
6310 {
6311 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6312 continue;
6313 }
6314 break;
6315 default:
6316 continue;
6317 }
6318
6319 uint16 greetEmoteType = fields[2].Get<uint16>();
6320 uint32 greetEmoteDelay = fields[3].Get<uint32>();
6321 std::string greeting = fields[4].Get<std::string>();
6322
6323 _questGreetingStore[type].emplace(std::piecewise_construct, std::forward_as_tuple(id), std::forward_as_tuple(greetEmoteType, greetEmoteDelay, std::move(greeting)));
6324
6325 ++count;
6326 }
6327 while (result->NextRow());
6328
6329 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6330 LOG_INFO("server.loading", " ");
6331}

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

◆ LoadQuestGreetingsLocales()

void ObjectMgr::LoadQuestGreetingsLocales ( )
6334{
6335 uint32 oldMSTime = getMSTime();
6336
6338
6339 // 0 1 2 3
6340 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6341 if (!result)
6342 {
6343 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
6344 return;
6345 }
6346
6347 uint32 count = 0;
6348
6349 do
6350 {
6351 Field* fields = result->Fetch();
6352
6353 uint32 id = fields[0].Get<uint32>();
6354 uint8 type = fields[1].Get<uint8>();
6355 switch (type)
6356 {
6357 case 0: // Creature
6358 if (!sObjectMgr->GetCreatureTemplate(id))
6359 {
6360 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
6361 continue;
6362 }
6363 break;
6364 case 1: // GameObject
6365 if (!sObjectMgr->GetGameObjectTemplate(id))
6366 {
6367 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
6368 continue;
6369 }
6370 break;
6371 default:
6372 continue;
6373 }
6374
6375 std::string localeName = fields[2].Get<std::string>();
6376
6377 LocaleConstant locale = GetLocaleByName(localeName);
6378 if (locale == LOCALE_enUS)
6379 continue;
6380
6382 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
6383
6384 ++count;
6385 } while (result->NextRow());
6386
6387 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", (uint32)_questGreetingLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6388 LOG_INFO("server.loading", " ");
6389}
Definition: ObjectMgr.h:604
std::vector< std::string > Greeting
Definition: ObjectMgr.h:605

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

◆ LoadQuestLocales()

void ObjectMgr::LoadQuestLocales ( )
5170{
5171 uint32 oldMSTime = getMSTime();
5172
5173 _questLocaleStore.clear(); // need for reload case
5174
5175 // 0 1 2 3 4 5 6 7 8 9 10
5176 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5177
5178 if (!result)
5179 return;
5180
5181 do
5182 {
5183 Field* fields = result->Fetch();
5184
5185 uint32 ID = fields[0].Get<uint32>();
5186
5187 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5188 if (locale == LOCALE_enUS)
5189 continue;
5190
5191 QuestLocale& data = _questLocaleStore[ID];
5192 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5193 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5194 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5195 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5196 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5197
5198 for (uint8 i = 0; i < 4; ++i)
5199 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5200 } while (result->NextRow());
5201
5202 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5203}
Definition: QuestDef.h:180
std::vector< std::string > AreaDescription
Definition: QuestDef.h:188
std::vector< std::string > CompletedText
Definition: QuestDef.h:189
std::vector< std::string > Title
Definition: QuestDef.h:183
std::vector< std::string > Objectives
Definition: QuestDef.h:185
std::vector< std::vector< std::string > > ObjectiveText
Definition: QuestDef.h:190
std::vector< std::string > Details
Definition: QuestDef.h:184

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 ( )
10092{
10093 uint32 oldMSTime = getMSTime();
10094
10095 _questMoneyRewards.clear();
10096
10097 // 0 1 2 3 4 5 6 7 8 9 10
10098 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
10099 if (!result)
10100 {
10101 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
10102 return;
10103 }
10104
10105 uint32 count = 0;
10106 do
10107 {
10108 Field* fields = result->Fetch();
10109 uint32 Level = fields[0].Get<uint32>();
10110
10111 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
10112 questMoneyReward.fill(0);
10113
10114 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
10115 {
10116 questMoneyReward[i] = fields[1 + i].Get<uint32>();
10117 ++count;
10118 }
10119 } while (result->NextRow());
10120
10121 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10122 LOG_INFO("server.loading", " ");
10123}
std::array< uint32, MAX_QUEST_MONEY_REWARDS > QuestMoneyRewardArray
Definition: ObjectMgr.h:723

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

◆ LoadQuestOfferRewardLocale()

void ObjectMgr::LoadQuestOfferRewardLocale ( )
6392{
6393 uint32 oldMSTime = getMSTime();
6394
6395 _questOfferRewardLocaleStore.clear(); // need for reload case
6396
6397 // 0 1 2
6398 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
6399 if (!result)
6400 return;
6401
6402 do
6403 {
6404 Field* fields = result->Fetch();
6405
6406 uint32 id = fields[0].Get<uint32>();
6407 std::string localeName = fields[1].Get<std::string>();
6408
6409 LocaleConstant locale = GetLocaleByName(localeName);
6410 if (locale == LOCALE_enUS)
6411 continue;
6412
6414 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
6415 } while (result->NextRow());
6416
6417 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6418}
Definition: QuestDef.h:199
std::vector< std::string > RewardText
Definition: QuestDef.h:200

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

◆ LoadQuestPOI()

void ObjectMgr::LoadQuestPOI ( )
7869{
7870 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
7871 {
7872 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
7873 LOG_INFO("server.loading", " ");
7874 return;
7875 }
7876
7877 uint32 oldMSTime = getMSTime();
7878
7879 _questPOIStore.clear(); // need for reload case
7880
7881 uint32 count = 0;
7882
7883 // 0 1 2 3 4 5 6 7
7884 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
7885
7886 if (!result)
7887 {
7888 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
7889 LOG_INFO("server.loading", " ");
7890 return;
7891 }
7892
7893 // 0 1 2 3
7894 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
7895
7896 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
7897
7898 if (points)
7899 {
7900 // The first result should have the highest questId
7901 Field* fields = points->Fetch();
7902 uint32 questIdMax = fields[0].Get<uint32>();
7903 POIs.resize(questIdMax + 1);
7904
7905 do
7906 {
7907 fields = points->Fetch();
7908
7909 uint32 questId = fields[0].Get<uint32>();
7910 uint32 id = fields[1].Get<uint32>();
7911 int32 x = fields[2].Get<int32>();
7912 int32 y = fields[3].Get<int32>();
7913
7914 if (POIs[questId].size() <= id + 1)
7915 POIs[questId].resize(id + 10);
7916
7917 QuestPOIPoint point(x, y);
7918 POIs[questId][id].push_back(point);
7919 } while (points->NextRow());
7920 }
7921
7922 do
7923 {
7924 Field* fields = result->Fetch();
7925
7926 uint32 questId = fields[0].Get<uint32>();
7927 uint32 id = fields[1].Get<uint32>();
7928 int32 objIndex = fields[2].Get<int32>();
7929 uint32 mapId = fields[3].Get<uint32>();
7930 uint32 WorldMapAreaId = fields[4].Get<uint32>();
7931 uint32 FloorId = fields[5].Get<uint32>();
7932 uint32 unk3 = fields[6].Get<uint32>();
7933 uint32 unk4 = fields[7].Get<uint32>();
7934
7935 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
7936 if (questId < POIs.size() && id < POIs[questId].size())
7937 {
7938 POI.points = POIs[questId][id];
7939 _questPOIStore[questId].push_back(POI);
7940 }
7941 else
7942 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
7943
7944 ++count;
7945 } while (result->NextRow());
7946
7947 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7948 LOG_INFO("server.loading", " ");
7949}
@ CONFIG_QUEST_POI_ENABLED
Definition: IWorld.h:179
Definition: ObjectMgr.h:643
Definition: ObjectMgr.h:652

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
8039{
8040 uint32 oldMSTime = getMSTime();
8041
8042 map.clear(); // need for reload case
8043
8044 uint32 count = 0;
8045
8046 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8047
8048 if (!result)
8049 {
8050 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8051 LOG_INFO("server.loading", " ");
8052 return;
8053 }
8054
8055 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8056 if (starter)
8057 poolRelationMap->clear();
8058
8059 do
8060 {
8061 uint32 id = result->Fetch()[0].Get<uint32>();
8062 uint32 quest = result->Fetch()[1].Get<uint32>();
8063 uint32 poolId = result->Fetch()[2].Get<uint32>();
8064
8065 if (_questTemplates.find(quest) == _questTemplates.end())
8066 {
8067 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8068 continue;
8069 }
8070
8071 if (!poolId || !starter)
8072 map.insert(QuestRelations::value_type(id, quest));
8073 else if (starter)
8074 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8075
8076 ++count;
8077 } while (result->NextRow());
8078
8079 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8080 LOG_INFO("server.loading", " ");
8081}
#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 ( )
6421{
6422 uint32 oldMSTime = getMSTime();
6423
6424 _questRequestItemsLocaleStore.clear(); // need for reload case
6425
6426 // 0 1 2
6427 QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale");
6428 if (!result)
6429 return;
6430
6431 do
6432 {
6433 Field* fields = result->Fetch();
6434
6435 uint32 id = fields[0].Get<uint32>();
6436 std::string localeName = fields[1].Get<std::string>();
6437
6438 LocaleConstant locale = GetLocaleByName(localeName);
6439 if (locale == LOCALE_enUS)
6440 continue;
6441
6443 AddLocaleString(fields[2].Get<std::string>(), locale, data.CompletionText);
6444 } while (result->NextRow());
6445
6446 LOG_INFO("server.loading", ">> Loaded {} Quest Request Items Locale Strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6447}
Definition: QuestDef.h:194
std::vector< std::string > CompletionText
Definition: QuestDef.h:195

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

◆ LoadQuests()

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

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

◆ LoadQuestStartersAndEnders()

void ObjectMgr::LoadQuestStartersAndEnders ( )
inline
954 {
955 LOG_INFO("server.loading", "Loading GO Start Quest Data...");
957 LOG_INFO("server.loading", "Loading GO End Quest Data...");
959 LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
961 LOG_INFO("server.loading", "Loading Creature End Quest Data...");
963 }
void LoadCreatureQuestEnders()
Definition: ObjectMgr.cpp:8125
void LoadGameobjectQuestEnders()
Definition: ObjectMgr.cpp:8097
void LoadGameobjectQuestStarters()
Definition: ObjectMgr.cpp:8083
void LoadCreatureQuestStarters()
Definition: ObjectMgr.cpp:8111

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

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
9098{
9099 // find all items from the reference vendor
9101 stmt->SetData(0, uint32(item));
9102 PreparedQueryResult result = WorldDatabase.Query(stmt);
9103
9104 if (!result)
9105 return 0;
9106
9107 uint32 count = 0;
9108 do
9109 {
9110 Field* fields = result->Fetch();
9111
9112 int32 item_id = fields[0].Get<int32>();
9113
9114 // if item is a negative, its a reference
9115 if (item_id < 0)
9116 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
9117 else
9118 {
9119 int32 maxcount = fields[1].Get<uint8>();
9120 uint32 incrtime = fields[2].Get<uint32>();
9121 uint32 ExtendedCost = fields[3].Get<uint32>();
9122
9123 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
9124 continue;
9125
9126 VendorItemData& vList = _cacheVendorItemStore[vendor];
9127
9128 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9129 ++count;
9130 }
9131 } while (result->NextRow());
9132
9133 return count;
9134}
@ 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:9337
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition: ObjectMgr.cpp:9097

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 ( )
7630{
7631 uint32 oldMSTime = getMSTime();
7632
7633 // For reload case
7634 _repOnKillStore.clear();
7635
7636 uint32 count = 0;
7637
7638 // 0 1 2
7639 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
7640 // 3 4 5 6 7 8 9
7641 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
7642 "FROM creature_onkill_reputation");
7643
7644 if (!result)
7645 {
7646 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
7647 LOG_INFO("server.loading", " ");
7648 return;
7649 }
7650
7651 do
7652 {
7653 Field* fields = result->Fetch();
7654
7655 uint32 creature_id = fields[0].Get<uint32>();
7656
7657 ReputationOnKillEntry repOnKill;
7658 repOnKill.RepFaction1 = fields[1].Get<int16>();
7659 repOnKill.RepFaction2 = fields[2].Get<int16>();
7660 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
7661 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
7662 repOnKill.RepValue1 = fields[5].Get<float>();
7663 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
7664 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
7665 repOnKill.RepValue2 = fields[8].Get<float>();
7666 repOnKill.TeamDependent = fields[9].Get<uint8>();
7667
7668 if (!GetCreatureTemplate(creature_id))
7669 {
7670 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
7671 continue;
7672 }
7673
7674 if (repOnKill.RepFaction1)
7675 {
7676 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
7677 if (!factionEntry1)
7678 {
7679 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
7680 continue;
7681 }
7682 }
7683
7684 if (repOnKill.RepFaction2)
7685 {
7686 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
7687 if (!factionEntry2)
7688 {
7689 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
7690 continue;
7691 }
7692 }
7693
7694 _repOnKillStore[creature_id] = repOnKill;
7695
7696 ++count;
7697 } while (result->NextRow());
7698
7699 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7700 LOG_INFO("server.loading", " ");
7701}
Definition: ObjectMgr.h:562
uint32 RepFaction1
Definition: ObjectMgr.h:563

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

◆ LoadReputationRewardRate()

void ObjectMgr::LoadReputationRewardRate ( )
7542{
7543 uint32 oldMSTime = getMSTime();
7544
7545 _repRewardRateStore.clear(); // for reload case
7546
7547 uint32 count = 0; // 0 1 2 3 4 5 6 7
7548 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");
7549 if (!result)
7550 {
7551 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
7552 return;
7553 }
7554
7555 do
7556 {
7557 Field* fields = result->Fetch();
7558
7559 uint32 factionId = fields[0].Get<uint32>();
7560
7561 RepRewardRate repRate;
7562
7563 repRate.questRate = fields[1].Get<float>();
7564 repRate.questDailyRate = fields[2].Get<float>();
7565 repRate.questWeeklyRate = fields[3].Get<float>();
7566 repRate.questMonthlyRate = fields[4].Get<float>();
7567 repRate.questRepeatableRate = fields[5].Get<float>();
7568 repRate.creatureRate = fields[6].Get<float>();
7569 repRate.spellRate = fields[7].Get<float>();
7570
7571 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7572 if (!factionEntry)
7573 {
7574 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
7575 continue;
7576 }
7577
7578 if (repRate.questRate < 0.0f)
7579 {
7580 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
7581 continue;
7582 }
7583
7584 if (repRate.questDailyRate < 0.0f)
7585 {
7586 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
7587 continue;
7588 }
7589
7590 if (repRate.questWeeklyRate < 0.0f)
7591 {
7592 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
7593 continue;
7594 }
7595
7596 if (repRate.questMonthlyRate < 0.0f)
7597 {
7598 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
7599 continue;
7600 }
7601
7602 if (repRate.questRepeatableRate < 0.0f)
7603 {
7604 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
7605 continue;
7606 }
7607
7608 if (repRate.creatureRate < 0.0f)
7609 {
7610 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
7611 continue;
7612 }
7613
7614 if (repRate.spellRate < 0.0f)
7615 {
7616 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
7617 continue;
7618 }
7619
7620 _repRewardRateStore[factionId] = repRate;
7621
7622 ++count;
7623 } while (result->NextRow());
7624
7625 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7626 LOG_INFO("server.loading", " ");
7627}
Definition: ObjectMgr.h:551
float questRate
Definition: ObjectMgr.h:552

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

◆ LoadReputationSpilloverTemplate()

void ObjectMgr::LoadReputationSpilloverTemplate ( )
7704{
7705 uint32 oldMSTime = getMSTime();
7706
7707 _repSpilloverTemplateStore.clear(); // for reload case
7708
7709 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
7710 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");
7711
7712 if (!result)
7713 {
7714 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
7715 LOG_INFO("server.loading", " ");
7716 return;
7717 }
7718
7719 do
7720 {
7721 Field* fields = result->Fetch();
7722
7723 uint32 factionId = fields[0].Get<uint16>();
7724
7725 RepSpilloverTemplate repTemplate;
7726
7727 repTemplate.faction[0] = fields[1].Get<uint16>();
7728 repTemplate.faction_rate[0] = fields[2].Get<float>();
7729 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
7730 repTemplate.faction[1] = fields[4].Get<uint16>();
7731 repTemplate.faction_rate[1] = fields[5].Get<float>();
7732 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
7733 repTemplate.faction[2] = fields[7].Get<uint16>();
7734 repTemplate.faction_rate[2] = fields[8].Get<float>();
7735 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
7736 repTemplate.faction[3] = fields[10].Get<uint16>();
7737 repTemplate.faction_rate[3] = fields[11].Get<float>();
7738 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
7739 repTemplate.faction[4] = fields[13].Get<uint16>();
7740 repTemplate.faction_rate[4] = fields[14].Get<float>();
7741 repTemplate.faction_rank[4] = fields[15].Get<uint8>();
7742 repTemplate.faction[5] = fields[16].Get<uint16>();
7743 repTemplate.faction_rate[5] = fields[17].Get<float>();
7744 repTemplate.faction_rank[5] = fields[18].Get<uint8>();
7745
7746 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7747
7748 if (!factionEntry)
7749 {
7750 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
7751 continue;
7752 }
7753
7754 if (factionEntry->team == 0)
7755 {
7756 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
7757 continue;
7758 }
7759
7760 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
7761 {
7762 if (repTemplate.faction[i])
7763 {
7764 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
7765
7766 if (!factionSpillover)
7767 {
7768 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);
7769 continue;
7770 }
7771
7772 if (factionSpillover->reputationListID < 0)
7773 {
7774 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);
7775 continue;
7776 }
7777
7778 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
7779 {
7780 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
7781 continue;
7782 }
7783 }
7784 }
7785
7786 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
7787 if (repTemplate.faction[0] && !factionEntry0)
7788 {
7789 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
7790 continue;
7791 }
7792 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
7793 if (repTemplate.faction[1] && !factionEntry1)
7794 {
7795 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
7796 continue;
7797 }
7798 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
7799 if (repTemplate.faction[2] && !factionEntry2)
7800 {
7801 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
7802 continue;
7803 }
7804 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
7805 if (repTemplate.faction[3] && !factionEntry3)
7806 {
7807 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
7808 continue;
7809 }
7810
7811 _repSpilloverTemplateStore[factionId] = repTemplate;
7812
7813 ++count;
7814 } while (result->NextRow());
7815
7816 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7817 LOG_INFO("server.loading", " ");
7818}
#define MAX_SPILLOVER_FACTIONS
Definition: SharedDefines.h:247
Definition: ObjectMgr.h:575
uint32 faction[MAX_SPILLOVER_FACTIONS]
Definition: ObjectMgr.h:576
int32 reputationListID
Definition: DBCStructure.h:900

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

◆ LoadReservedPlayersNames()

void ObjectMgr::LoadReservedPlayersNames ( )
8140{
8141 uint32 oldMSTime = getMSTime();
8142
8143 _reservedNamesStore.clear(); // need for reload case
8144
8145 QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
8146
8147 if (!result)
8148 {
8149 LOG_WARN("server.loading", ">> Loaded 0 reserved player names. DB table `reserved_name` is empty!");
8150 LOG_INFO("server.loading", " ");
8151 return;
8152 }
8153
8154 uint32 count = 0;
8155
8156 Field* fields;
8157 do
8158 {
8159 fields = result->Fetch();
8160 std::string name = fields[0].Get<std::string>();
8161
8162 std::wstring wstr;
8163 if (!Utf8toWStr (name, wstr))
8164 {
8165 LOG_ERROR("sql.sql", "Table `reserved_name` have invalid name: {}", name);
8166 continue;
8167 }
8168
8169 wstrToLower(wstr);
8170
8171 _reservedNamesStore.insert(wstr);
8172 ++count;
8173 } while (result->NextRow());
8174
8175 LOG_INFO("server.loading", ">> Loaded {} reserved player names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8176 LOG_INFO("server.loading", " ");
8177}

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

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
9418{
9419 uint32 oldMSTime = getMSTime();
9420
9421 // We insert an empty placeholder here so we can use the
9422 // script id 0 as dummy for "no script found".
9423 _scriptNamesStore.emplace_back("");
9424
9425 QueryResult result = WorldDatabase.Query(
9426 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
9427 "UNION "
9428 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
9429 "UNION "
9430 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
9431 "UNION "
9432 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
9433 "UNION "
9434 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
9435 "UNION "
9436 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
9437 "UNION "
9438 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
9439 "UNION "
9440 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
9441 "UNION "
9442 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
9443 "UNION "
9444 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
9445 "UNION "
9446 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
9447 "UNION "
9448 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
9449 "UNION "
9450 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
9451 "UNION "
9452 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
9453
9454 if (!result)
9455 {
9456 LOG_INFO("server.loading", " ");
9457 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
9458 return;
9459 }
9460
9461 _scriptNamesStore.reserve(result->GetRowCount() + 1);
9462
9463 do
9464 {
9465 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
9466 } while (result->NextRow());
9467
9468 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
9469 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
9470 LOG_INFO("server.loading", " ");
9471}

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

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5206{
5207 uint32 oldMSTime = getMSTime();
5208
5209 ScriptMapMap* scripts = GetScriptsMapByType(type);
5210 if (!scripts)
5211 return;
5212
5213 std::string tableName = GetScriptsTableNameByType(type);
5214 if (tableName.empty())
5215 return;
5216
5217 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5218 return;
5219
5220 LOG_INFO("server.loading", "Loading {}...", tableName);
5221
5222 scripts->clear(); // need for reload support
5223
5224 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5225 // 0 1 2 3 4 5 6 7 8 9
5226 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5227
5228 if (!result)
5229 {
5230 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5231 LOG_INFO("server.loading", " ");
5232 return;
5233 }
5234
5235 uint32 count = 0;
5236
5237 do
5238 {
5239 Field* fields = result->Fetch();
5240 ScriptInfo tmp;
5241 tmp.type = type;
5242 tmp.id = fields[0].Get<uint32>();
5243 if (isSpellScriptTable)
5244 tmp.id |= fields[10].Get<uint8>() << 24;
5245 tmp.delay = fields[1].Get<uint32>();
5246 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5247 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5248 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5249 tmp.Raw.nData[2] = fields[5].Get<int32>();
5250 tmp.Raw.fData[0] = fields[6].Get<float>();
5251 tmp.Raw.fData[1] = fields[7].Get<float>();
5252 tmp.Raw.fData[2] = fields[8].Get<float>();
5253 tmp.Raw.fData[3] = fields[9].Get<float>();
5254
5255 // generic command args check
5256 switch (tmp.command)
5257 {
5259 {
5261 {
5262 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5263 tableName, tmp.Talk.ChatType, tmp.id);
5264 continue;
5265 }
5267 {
5268 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
5269 tableName, tmp.Talk.TextID, tmp.id);
5270 continue;
5271 }
5272 break;
5273 }
5274
5276 {
5277 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
5278 {
5279 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
5280 tableName, tmp.Emote.EmoteID, tmp.id);
5281 continue;
5282 }
5283 break;
5284 }
5285
5287 {
5288 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
5289 {
5290 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5291 tableName, tmp.TeleportTo.MapID, tmp.id);
5292 continue;
5293 }
5294
5296 {
5297 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5298 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
5299 continue;
5300 }
5301 break;
5302 }
5303
5305 {
5306 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
5307 if (!quest)
5308 {
5309 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5310 tableName, tmp.QuestExplored.QuestID, tmp.id);
5311 continue;
5312 }
5313
5315 {
5316 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.",
5317 tableName, tmp.QuestExplored.QuestID, tmp.id);
5318
5319 // this will prevent quest completing without objective
5320 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5321
5322 // continue; - quest objective requirement set and command can be allowed
5323 }
5324
5326 {
5327 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 {}",
5328 tableName, tmp.QuestExplored.Distance, tmp.id);
5329 continue;
5330 }
5331
5333 {
5334 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",
5336 continue;
5337 }
5338
5340 {
5341 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",
5342 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
5343 continue;
5344 }
5345
5346 break;
5347 }
5348
5350 {
5352 {
5353 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
5354 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
5355 continue;
5356 }
5357 break;
5358 }
5359
5361 {
5363 if (!data)
5364 {
5365 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5366 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
5367 continue;
5368 }
5369
5370 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5371 if (!info)
5372 {
5373 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5374 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
5375 continue;
5376 }
5377
5378 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
5380 info->type == GAMEOBJECT_TYPE_DOOR ||
5381 info->type == GAMEOBJECT_TYPE_BUTTON ||
5382 info->type == GAMEOBJECT_TYPE_TRAP)
5383 {
5384 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5385 tableName, info->entry, tmp.id);
5386 continue;
5387 }
5388 break;
5389 }
5390
5392 {
5394 {
5395 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5397 continue;
5398 }
5399
5401 if (!GetCreatureTemplate(entry))
5402 {
5403 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5404 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
5405 continue;
5406 }
5407 break;
5408 }
5409
5412 {
5414 if (!data)
5415 {
5416 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
5417 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
5418 continue;
5419 }
5420
5421 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5422 if (!info)
5423 {
5424 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
5425 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
5426 continue;
5427 }
5428
5429 if (info->type != GAMEOBJECT_TYPE_DOOR)
5430 {
5431 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
5432 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
5433 continue;
5434 }
5435
5436 break;
5437 }
5438
5440 {
5441 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
5442 {
5443 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5444 tableName, tmp.RemoveAura.SpellID, tmp.id);
5445 continue;
5446 }
5447 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
5448 {
5449 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5450 tableName, tmp.RemoveAura.Flags, tmp.id);
5451 continue;
5452 }
5453 break;
5454 }
5455
5457 {
5458 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
5459 {
5460 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5461 tableName, tmp.CastSpell.SpellID, tmp.id);
5462 continue;
5463 }
5464 if (tmp.CastSpell.Flags > 4) // targeting type
5465 {
5466 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5467 tableName, tmp.CastSpell.Flags, tmp.id);
5468 continue;
5469 }
5470 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
5471 {
5472 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5473 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5474 continue;
5475 }
5476 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
5477 {
5478 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5479 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5480 continue;
5481 }
5482 break;
5483 }
5484
5486 {
5488 {
5489 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
5490 tableName, tmp.CreateItem.ItemEntry, tmp.id);
5491 continue;
5492 }
5493 if (!tmp.CreateItem.Amount)
5494 {
5495 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
5496 tableName, tmp.CreateItem.Amount, tmp.id);
5497 continue;
5498 }
5499 break;
5500 }
5501 default:
5502 break;
5503 }
5504
5505 if (scripts->find(tmp.id) == scripts->end())
5506 {
5507 ScriptMap emptyMap;
5508 (*scripts)[tmp.id] = emptyMap;
5509 }
5510 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
5511
5512 ++count;
5513 } while (result->NextRow());
5514
5515 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5516 LOG_INFO("server.loading", " ");
5517}
@ CHAT_TYPE_WHISPER
Definition: CreatureData.h:414
#define DEFAULT_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:40
#define INTERACTION_DISTANCE
Definition: ObjectDefines.h:24
std::multimap< uint32, ScriptInfo > ScriptMap
Definition: ObjectMgr.h:386
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition: ObjectMgr.cpp:81
ScriptCommands
Definition: ObjectMgr.h:94
@ SCRIPT_COMMAND_EMOTE
Definition: ObjectMgr.h:96
@ SCRIPT_COMMAND_CREATE_ITEM
Definition: ObjectMgr.h:112
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition: ObjectMgr.h:107
@ SCRIPT_COMMAND_CAST_SPELL
Definition: ObjectMgr.h:110
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition: ObjectMgr.h:104
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition: ObjectMgr.h:102
@ SCRIPT_COMMAND_TALK
Definition: ObjectMgr.h:95
@ SCRIPT_COMMAND_OPEN_DOOR
Definition: ObjectMgr.h:106
@ SCRIPT_COMMAND_TELEPORT_TO
Definition: ObjectMgr.h:101
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition: ObjectMgr.h:105
@ SCRIPT_COMMAND_KILL_CREDIT
Definition: ObjectMgr.h:103
@ SCRIPT_COMMAND_REMOVE_AURA
Definition: ObjectMgr.h:109
std::string GetScriptCommandName(ScriptCommands command)
Definition: ObjectMgr.cpp:101
std::map< uint32, ScriptMap > ScriptMapMap
Definition: ObjectMgr.h:387
std::string GetScriptsTableNameByType(ScriptsType type)
Definition: ObjectMgr.cpp:61
@ SCRIPTS_SPELL
Definition: ObjectMgr.h:151
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition: SharedDefines.h:1577
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition: SharedDefines.h:3194
uint32 entry
Definition: GameObjectData.h:33
Definition: ObjectMgr.h:192
float Orientation
Definition: ObjectMgr.h:252
uint32 Flags
Definition: ObjectMgr.h:209
ScriptsType type
Definition: ObjectMgr.h:193
struct ScriptInfo::@258::@261 Talk
struct ScriptInfo::@258::@273 CastSpell
uint32 QuestID
Definition: ObjectMgr.h:257
int32 TextID
Definition: ObjectMgr.h:210
float DestX
Definition: ObjectMgr.h:231
struct ScriptInfo::@258::@266 TeleportTo
uint32 ItemEntry
Definition: ObjectMgr.h:317
uint32 ChatType
Definition: ObjectMgr.h:208
struct ScriptInfo::@258::@268 KillCredit
uint32 id
Definition: ObjectMgr.h:194
uint32 delay
Definition: ObjectMgr.h:195
float fData[4]
Definition: ObjectMgr.h:203
struct ScriptInfo::@258::@262 Emote
float PosY
Definition: ObjectMgr.h:280
ScriptCommands command
Definition: ObjectMgr.h:196
float DestY
Definition: ObjectMgr.h:232
uint32 MapID
Definition: ObjectMgr.h:245
struct ScriptInfo::@258::@267 QuestExplored
uint32 nData[3]
Definition: ObjectMgr.h:202
struct ScriptInfo::@258::@271 ToggleDoor
float PosZ
Definition: ObjectMgr.h:281
float PosX
Definition: ObjectMgr.h:279
struct ScriptInfo::@258::@272 RemoveAura
uint32 Distance
Definition: ObjectMgr.h:258
struct ScriptInfo::@258::@275 CreateItem
uint32 SpellID
Definition: ObjectMgr.h:296
struct ScriptInfo::@258::@260 Raw
float DestZ
Definition: ObjectMgr.h:233
uint32 GOGuid
Definition: ObjectMgr.h:269
uint32 CreatureEntry
Definition: ObjectMgr.h:263
uint32 Amount
Definition: ObjectMgr.h:318
struct ScriptInfo::@258::@270 TempSummonCreature
struct ScriptInfo::@258::@269 RespawnGameobject
uint32 EmoteID
Definition: ObjectMgr.h:215

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

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

◆ LoadSpellScriptNames()

void ObjectMgr::LoadSpellScriptNames ( )
5619{
5620 uint32 oldMSTime = getMSTime();
5621
5622 _spellScriptsStore.clear(); // need for reload case
5623
5624 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
5625
5626 if (!result)
5627 {
5628 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
5629 LOG_INFO("server.loading", " ");
5630 return;
5631 }
5632
5633 uint32 count = 0;
5634
5635 do
5636 {
5637 Field* fields = result->Fetch();
5638
5639 int32 spellId = fields[0].Get<int32>();
5640 std::string scriptName = fields[1].Get<std::string>();
5641
5642 bool allRanks = false;
5643 if (spellId <= 0)
5644 {
5645 allRanks = true;
5646 spellId = -spellId;
5647 }
5648
5649 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5650 if (!spellInfo)
5651 {
5652 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
5653 continue;
5654 }
5655
5656 if (allRanks)
5657 {
5658 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
5659 {
5660 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
5661 continue;
5662 }
5663 while (spellInfo)
5664 {
5665 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5666 spellInfo = spellInfo->GetNextRankSpell();
5667 }
5668 }
5669 else
5670 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5671 ++count;
5672 } while (result->NextRow());
5673
5674 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5675 LOG_INFO("server.loading", " ");
5676}
SpellInfo const * GetNextRankSpell() const
Definition: SpellInfo.cpp:2499

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

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
5520{
5522
5523 // check ids
5524 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
5525 {
5526 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
5527 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5528
5529 if (!spellInfo)
5530 {
5531 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
5532 continue;
5533 }
5534
5535 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
5536 if (uint32(i) >= MAX_SPELL_EFFECTS)
5537 {
5538 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
5539 }
5540
5541 //check for correct spellEffect
5542 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
5543 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
5544 }
5545}
ScriptMapMap sSpellScripts
Definition: ObjectMgr.cpp:57
SpellEffIndex
Definition: SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:781
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:855

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

◆ LoadTavernAreaTriggers()

void ObjectMgr::LoadTavernAreaTriggers ( )
6450{
6451 uint32 oldMSTime = getMSTime();
6452
6453 _tavernAreaTriggerStore.clear(); // need for reload case
6454
6455 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
6456
6457 if (!result)
6458 {
6459 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
6460 LOG_INFO("server.loading", " ");
6461 return;
6462 }
6463
6464 uint32 count = 0;
6465
6466 do
6467 {
6468 ++count;
6469
6470 Field* fields = result->Fetch();
6471
6472 uint32 Trigger_ID = fields[0].Get<uint32>();
6473
6474 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6475 if (!atEntry)
6476 {
6477 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6478 continue;
6479 }
6480
6481 uint32 faction = fields[1].Get<uint32>();
6482
6483 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
6484 } while (result->NextRow());
6485
6486 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6487 LOG_INFO("server.loading", " ");
6488}

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

◆ LoadTempSummons()

void ObjectMgr::LoadTempSummons ( )
2067{
2068 uint32 oldMSTime = getMSTime();
2069
2070 // 0 1 2 3 4 5 6 7 8 9
2071 QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, summonType, summonTime FROM creature_summon_groups");
2072
2073 if (!result)
2074 {
2075 LOG_WARN("server.loading", ">> Loaded 0 temp summons. DB table `creature_summon_groups` is empty.");
2076 return;
2077 }
2078
2079 uint32 count = 0;
2080 do
2081 {
2082 Field* fields = result->Fetch();
2083
2084 uint32 summonerId = fields[0].Get<uint32>();
2085 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2086 uint8 group = fields[2].Get<uint8>();
2087
2088 switch (summonerType)
2089 {
2091 if (!GetCreatureTemplate(summonerId))
2092 {
2093 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2094 continue;
2095 }
2096 break;
2098 if (!GetGameObjectTemplate(summonerId))
2099 {
2100 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2101 continue;
2102 }
2103 break;
2104 case SUMMONER_TYPE_MAP:
2105 if (!sMapStore.LookupEntry(summonerId))
2106 {
2107 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2108 continue;
2109 }
2110 break;
2111 default:
2112 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2113 continue;
2114 }
2115
2116 TempSummonData data;
2117 data.entry = fields[3].Get<uint32>();
2118
2119 if (!GetCreatureTemplate(data.entry))
2120 {
2121 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);
2122 continue;
2123 }
2124
2125 float posX = fields[4].Get<float>();
2126 float posY = fields[5].Get<float>();
2127 float posZ = fields[6].Get<float>();
2128 float orientation = fields[7].Get<float>();
2129
2130 data.pos.Relocate(posX, posY, posZ, orientation);
2131
2132 data.type = TempSummonType(fields[8].Get<uint8>());
2133
2135 {
2136 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);
2137 continue;
2138 }
2139
2140 data.time = fields[9].Get<uint32>();
2141
2142 TempSummonGroupKey key(summonerId, summonerType, group);
2143 _tempSummonDataStore[key].push_back(data);
2144
2145 ++count;
2146 } while (result->NextRow());
2147
2148 LOG_INFO("server.loading", ">> Loaded {} Temporary Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2149 LOG_INFO("server.loading", " ");
2150}
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
TempSummonType
Definition: Object.h:41
@ TEMPSUMMON_MANUAL_DESPAWN
Definition: Object.h:49
Stores data for temp summons.
Definition: TemporarySummon.h:32
TempSummonType type
Summon type, see TempSummonType for available types.
Definition: TemporarySummon.h:35
uint32 time
Despawn time, usable only with certain temp summon types.
Definition: TemporarySummon.h:36
uint32 entry
Entry of summoned creature.
Definition: TemporarySummon.h:33
Position pos
Position, where should be creature spawned.
Definition: TemporarySummon.h:34
void Relocate(float x, float y)
Definition: Position.h:73

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

◆ LoadTrainerSpell()

void ObjectMgr::LoadTrainerSpell ( )
9057{
9058 uint32 oldMSTime = getMSTime();
9059
9060 // For reload case
9062
9063 QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.ReqLevel, a.ReqSpell FROM npc_trainer AS a "
9064 "INNER JOIN npc_trainer AS b ON a.ID = -(b.SpellID) "
9065 "UNION SELECT * FROM npc_trainer WHERE SpellID > 0");
9066
9067 if (!result)
9068 {
9069 LOG_WARN("server.loading", ">> Loaded 0 Trainers. DB table `npc_trainer` is empty!");
9070 LOG_INFO("server.loading", " ");
9071 return;
9072 }
9073
9074 uint32 count = 0;
9075
9076 do
9077 {
9078 Field* fields = result->Fetch();
9079
9080 uint32 entry = fields[0].Get<uint32>();
9081 uint32 spell = fields[1].Get<uint32>();
9082 uint32 spellCost = fields[2].Get<uint32>();
9083 uint32 reqSkill = fields[3].Get<uint16>();
9084 uint32 reqSkillValue = fields[4].Get<uint16>();
9085 uint32 reqLevel = fields[5].Get<uint8>();
9086 uint32 reqSpell = fields[6].Get<uint32>();
9087
9088 AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel, reqSpell);
9089
9090 ++count;
9091 } while (result->NextRow());
9092
9093 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9094 LOG_INFO("server.loading", " ");
9095}
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
Definition: ObjectMgr.cpp:8971

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

◆ LoadVehicleAccessories()

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

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

◆ LoadVehicleTemplateAccessories()

void ObjectMgr::LoadVehicleTemplateAccessories ( )
3438{
3439 uint32 oldMSTime = getMSTime();
3440
3441 _vehicleTemplateAccessoryStore.clear(); // needed for reload case
3442
3443 uint32 count = 0;
3444
3445 // 0 1 2 3 4 5
3446 QueryResult result = WorldDatabase.Query("SELECT `entry`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_template_accessory`");
3447
3448 if (!result)
3449 {
3450 LOG_WARN("server.loading", ">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
3451 LOG_INFO("server.loading", " ");
3452 return;
3453 }
3454
3455 do
3456 {
3457 Field* fields = result->Fetch();
3458
3459 uint32 uiEntry = fields[0].Get<uint32>();
3460 uint32 uiAccessory = fields[1].Get<uint32>();
3461 int8 uiSeat = int8(fields[2].Get<int8>());
3462 bool bMinion = fields[3].Get<bool>();
3463 uint8 uiSummonType = fields[4].Get<uint8>();
3464 uint32 uiSummonTimer = fields[5].Get<uint32>();
3465
3466 if (!sObjectMgr->GetCreatureTemplate(uiEntry))
3467 {
3468 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} does not exist.", uiEntry);
3469 continue;
3470 }
3471
3472 if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
3473 {
3474 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: Accessory {} does not exist.", uiAccessory);
3475 continue;
3476 }
3477
3478 if (_spellClickInfoStore.find(uiEntry) == _spellClickInfoStore.end())
3479 {
3480 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} has no data in npc_spellclick_spells", uiEntry);
3481 continue;
3482 }
3483
3484 _vehicleTemplateAccessoryStore[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3485
3486 ++count;
3487 } while (result->NextRow());
3488
3489 LOG_INFO("server.loading", ">> Loaded {} Vehicle Template Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3490 LOG_INFO("server.loading", " ");
3491}

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

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
9137{
9138 uint32 oldMSTime = getMSTime();
9139
9140 // For reload case
9141 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
9142 itr->second.Clear();
9143 _cacheVendorItemStore.clear();
9144
9145 std::set<uint32> skip_vendors;
9146
9147 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
9148 if (!result)
9149 {
9150 LOG_INFO("server.loading", " ");
9151 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
9152 return;
9153 }
9154
9155 uint32 count = 0;
9156
9157 do
9158 {
9159 Field* fields = result->Fetch();
9160
9161 uint32 entry = fields[0].Get<uint32>();
9162 int32 item_id = fields[1].Get<int32>();
9163
9164 // if item is a negative, its a reference
9165 if (item_id < 0)
9166 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
9167 else
9168 {
9169 uint32 maxcount = fields[2].Get<uint8>();
9170 uint32 incrtime = fields[3].Get<uint32>();
9171 uint32 ExtendedCost = fields[4].Get<uint32>();
9172
9173 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
9174 continue;
9175
9176 VendorItemData& vList = _cacheVendorItemStore[entry];
9177
9178 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9179 ++count;
9180 }
9181 } while (result->NextRow());
9182
9183 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9184 LOG_INFO("server.loading", " ");
9185}

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

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
5592{
5594
5595 std::set<uint32> actionSet;
5596
5597 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
5598 actionSet.insert(itr->first);
5599
5601 PreparedQueryResult result = WorldDatabase.Query(stmt);
5602
5603 if (result)
5604 {
5605 do
5606 {
5607 Field* fields = result->Fetch();
5608 uint32 action = fields[0].Get<uint32>();
5609
5610 actionSet.erase(action);
5611 } while (result->NextRow());
5612 }
5613
5614 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
5615 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
5616}
@ WORLD_SEL_WAYPOINT_DATA_ACTION
Definition: WorldDatabase.h:69
ScriptMapMap sWaypointScripts
Definition: ObjectMgr.cpp:59
@ SCRIPTS_WAYPOINT
Definition: ObjectMgr.h:153

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

◆ NewGOData()

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

References _gameObjectDataStore.

Referenced by AddGOData().

◆ NewInstanceSavedGameobjectState()

void ObjectMgr::NewInstanceSavedGameobjectState ( uint32  id,
uint32  guid,
uint8  state 
)
10201{
10202 GameobjectInstanceSavedStateList.push_back({ id, guid, state });
10203}

References GameobjectInstanceSavedStateList.

◆ 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
3643{
3644 if (!_playerInfo[race_][class_])
3645 return;
3646
3647 if (count > 0)
3648 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
3649 else
3650 {
3651 if (count < -1)
3652 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
3653
3654 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
3655 {
3656 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
3657 {
3658 bool found = false;
3659 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
3660 {
3661 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
3662 {
3663 found = true;
3664 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
3665 break;
3666 }
3667 }
3668
3669 if (!found)
3670 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
3671 }
3672 }
3673 }
3674}
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition: DBCStores.cpp:838
Definition: Player.h:280
PlayerCreateInfoItems item
Definition: Player.h:348

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 
)
2362{
2363 uint8 mask = data->spawnMask;
2364 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2365 {
2366 if (mask & 1)
2367 {
2368 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2369 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2370 cell_guids.creatures.erase(guid);
2371 }
2372 }
2373}

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

Referenced by DeleteCreatureData().

◆ RemoveGameobjectFromGrid()

void ObjectMgr::RemoveGameobjectFromGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2668{
2669 uint8 mask = data->spawnMask;
2670 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2671 {
2672 if (mask & 1)
2673 {
2674 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2675 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2676 cell_guids.gameobjects.erase(guid);
2677 }
2678 }
2679}

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

Referenced by DeleteGOData().

◆ RemoveVendorItem()

bool ObjectMgr::RemoveVendorItem ( uint32  entry,
uint32  item,
bool  persist = true 
)
9316{
9317 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
9318 if (iter == _cacheVendorItemStore.end())
9319 return false;
9320
9321 if (!iter->second.RemoveItem(item))
9322 return false;
9323
9324 if (persist)
9325 {
9327
9328 stmt->SetData(0, entry);
9329 stmt->SetData(1, item);
9330
9331 WorldDatabase.Execute(stmt);
9332 }
9333
9334 return true;
9335}
@ WORLD_DEL_NPC_VENDOR
Definition: WorldDatabase.h:44

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

◆ ReturnOrDeleteOldMails()

void ObjectMgr::ReturnOrDeleteOldMails ( bool  serverUp)
6083{
6084 uint32 oldMSTime = getMSTime();
6085
6086 time_t curTime = GameTime::GetGameTime().count();
6087
6089 stmt->SetData(0, uint32(curTime));
6090 PreparedQueryResult result = CharacterDatabase.Query(stmt);
6091 if (!result)
6092 return;
6093
6094 std::map<uint32 /*messageId*/, MailItemInfoVec> itemsCache;
6095 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS);
6096 stmt->SetData(0, uint32(curTime));
6097 if (PreparedQueryResult items = CharacterDatabase.Query(stmt))
6098 {
6099 MailItemInfo item;
6100 do
6101 {
6102 Field* fields = items->Fetch();
6103 item.item_guid = fields[0].Get<uint32>();
6104 item.item_template = fields[1].Get<uint32>();
6105 uint32 mailId = fields[2].Get<uint32>();
6106 itemsCache[mailId].push_back(item);
6107 } while (items->NextRow());
6108 }
6109
6110 uint32 deletedCount = 0;
6111 uint32 returnedCount = 0;
6112 do
6113 {
6114 Field* fields = result->Fetch();
6115 Mail* m = new Mail;
6116 m->messageID = fields[0].Get<uint32>();
6117 m->messageType = fields[1].Get<uint8>();
6118 m->sender = fields[2].Get<uint32>();
6119 m->receiver = fields[3].Get<uint32>();
6120 bool has_items = fields[4].Get<bool>();
6121 m->expire_time = time_t(fields[5].Get<uint32>());
6122 m->deliver_time = time_t(0);
6123 m->stationery = fields[6].Get<uint8>();
6124 m->checked = fields[7].Get<uint8>();
6125 m->mailTemplateId = fields[8].Get<int16>();
6126
6127 Player* player = nullptr;
6128 if (serverUp)
6130
6131 if (player) // don't modify mails of a logged in player
6132 {
6133 delete m;
6134 continue;
6135 }
6136
6137 // Delete or return mail
6138 if (has_items)
6139 {
6140 // read items from cache
6141 m->items.swap(itemsCache[m->messageID]);
6142
6143 // If it is mail from non-player, or if it's already return mail, it shouldn't be returned, but deleted
6144 if (!m->IsSentByPlayer() || m->IsSentByGM() || (m->IsCODPayment() || m->IsReturnedMail()))
6145 {
6146 for (auto const& mailedItem : m->items)
6147 {
6148 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
6149 stmt->SetData(0, mailedItem.item_guid);
6150 CharacterDatabase.Execute(stmt);
6151 }
6152
6153 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
6154 stmt->SetData(0, m->messageID);
6155 CharacterDatabase.Execute(stmt);
6156 }
6157 else
6158 {
6159 // Mail will be returned
6160 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_RETURNED);
6161 stmt->SetData(0, m->receiver);
6162 stmt->SetData(1, m->sender);
6163 stmt->SetData(2, uint32(curTime + 30 * DAY));
6164 stmt->SetData(3, uint32(curTime));
6166 stmt->SetData(5, m->messageID);
6167 CharacterDatabase.Execute(stmt);
6168 for (auto const& mailedItem : m->items)
6169 {
6170 // Update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete
6171 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_ITEM_RECEIVER);
6172 stmt->SetData(0, m->sender);
6173 stmt->SetData(1, mailedItem.item_guid);
6174 CharacterDatabase.Execute(stmt);
6175
6176 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
6177 stmt->SetData(0, m->sender);
6178 stmt->SetData(1, mailedItem.item_guid);
6179 CharacterDatabase.Execute(stmt);
6180 }
6181
6182 // xinef: update global data
6183 sCharacterCache->IncreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->sender));
6184 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6185
6186 delete m;
6187 ++returnedCount;
6188 continue;
6189 }
6190 }
6191
6192 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6193
6194 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
6195 stmt->SetData(0, m->messageID);
6196 CharacterDatabase.Execute(stmt);
6197 delete m;
6198 ++deletedCount;
6199 } while (result->NextRow());
6200
6201 LOG_INFO("server.loading", ">> Processed {} expired mails: {} deleted and {} returned in {} ms", deletedCount + returnedCount, deletedCount, returnedCount, GetMSTimeDiffToNow(oldMSTime));
6202 LOG_INFO("server.loading", " ");
6203}
@ 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:377
@ CHAR_UPD_MAIL_ITEM_RECEIVER
Definition: CharacterDatabase.h:117
#define sCharacterCache
Definition: CharacterCache.h:83
std::vector< MailItemInfo > MailItemInfoVec
Definition: Mail.h:165
@ MAIL_CHECK_MASK_RETURNED
Definition: Mail.h:49
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:254
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: Player.h:1056
Definition: Mail.h:161
ObjectGuid::LowType item_guid
Definition: Mail.h:162
uint32 item_template
Definition: Mail.h:163
Definition: Mail.h:168
bool IsSentByGM() const
Definition: Mail.h:209
bool IsCODPayment() const
Definition: Mail.h:210
ObjectGuid::LowType receiver
Definition: Mail.h:174
uint8 messageType
Definition: Mail.h:170
bool IsSentByPlayer() const
Definition: Mail.h:208
uint32 messageID
Definition: Mail.h:169
time_t expire_time
Definition: Mail.h:179
uint32 sender
Definition: Mail.h:173
uint8 stationery
Definition: Mail.h:171
std::vector< MailItemInfo > items
Definition: Mail.h:177
time_t deliver_time
Definition: Mail.h:180
bool IsReturnedMail() const
Definition: Mail.h:211
uint32 checked
Definition: Mail.h:183
uint16 mailTemplateId
Definition: Mail.h:172

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

◆ SendServerMail()

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

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

◆ SetCreatureLinkedRespawn()

bool ObjectMgr::SetCreatureLinkedRespawn ( ObjectGuid::LowType  guid,
ObjectGuid::LowType  linkedGuid 
)
2020{
2021 if (!guidLow)
2022 return false;
2023
2024 CreatureData const* master = GetCreatureData(guidLow);
2025 ObjectGuid guid = ObjectGuid::Create<HighGuid::Unit>(master->id1, guidLow);
2026
2027 if (!linkedGuidLow) // we're removing the linking
2028 {
2029 _linkedRespawnStore.erase(guid);
2031 stmt->SetData(0, guidLow);
2032 WorldDatabase.Execute(stmt);
2033 return true;
2034 }
2035
2036 CreatureData const* slave = GetCreatureData(linkedGuidLow);
2037 if (!slave)
2038 {
2039 LOG_ERROR("sql.sql", "Creature '{}' linking to non-existent creature '{}'.", guidLow, linkedGuidLow);
2040 return false;
2041 }
2042
2043 MapEntry const* map = sMapStore.LookupEntry(master->mapid);
2044 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2045 {
2046 LOG_ERROR("sql.sql", "Creature '{}' linking to '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2047 return false;
2048 }
2049
2050 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2051 {
2052 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2053 return false;
2054 }
2055
2056 ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, linkedGuidLow);
2057
2058 _linkedRespawnStore[guid] = linkedGuid;
2060 stmt->SetData(0, guidLow);
2061 stmt->SetData(1, linkedGuidLow);
2062 WorldDatabase.Execute(stmt);
2063 return true;
2064}
@ 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
1325{ DBCLocaleIndex = locale; }

References DBCLocaleIndex.

◆ SetHighestGuids()

void ObjectMgr::SetHighestGuids ( )
6958{
6959 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
6960 if (result)
6961 GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].Get<uint32>() + 1);
6962
6963 result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
6964 if (result)
6965 GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].Get<uint32>() + 1);
6966
6967 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
6968 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6969 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6970 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6971 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6972
6973 result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
6974 if (result)
6975 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
6976
6977 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
6978 if (result)
6979 _auctionId = (*result)[0].Get<uint32>() + 1;
6980
6981 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
6982 if (result)
6983 _mailId = (*result)[0].Get<uint32>() + 1;
6984
6985 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
6986 if (result)
6987 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
6988
6989 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
6990 if (result)
6991 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
6992
6993 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
6994 if (result)
6995 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
6996
6997 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
6998 if (result)
6999 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
7000
7001 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
7002 if (result)
7003 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
7004
7005 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
7006 if (result)
7007 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
7008}
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define sGuildMgr
Definition: GuildMgr.h:51

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

◆ SetInstanceSavedGameobjectState()

void ObjectMgr::SetInstanceSavedGameobjectState ( uint32  id,
uint32  guid,
uint8  state 
)
10191{
10192 for (auto it = GameobjectInstanceSavedStateList.begin(); it != GameobjectInstanceSavedStateList.end(); it++)
10193 {
10194 if (it->m_guid == guid && it->m_instance == id)
10195 {
10196 it->m_state = state;
10197 }
10198 }
10199}

References GameobjectInstanceSavedStateList.

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
5679{
5680 uint32 oldMSTime = getMSTime();
5681
5682 if (_spellScriptsStore.empty())
5683 {
5684 LOG_INFO("server.loading", ">> Validated 0 scripts.");
5685 LOG_INFO("server.loading", " ");
5686 return;
5687 }
5688
5689 uint32 count = 0;
5690
5691 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
5692 {
5693 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
5694 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
5695 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
5696 itr = _spellScriptsStore.upper_bound(itr->first);
5697
5698 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
5699 {
5700 SpellScript* spellScript = sitr->first->GetSpellScript();
5701 AuraScript* auraScript = sitr->first->GetAuraScript();
5702 bool valid = true;
5703 if (!spellScript && !auraScript)
5704 {
5705 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
5706 valid = false;
5707 }
5708 if (spellScript)
5709 {
5710 spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5711 spellScript->_Register();
5712 if (!spellScript->_Validate(spellInfo))
5713 valid = false;
5714 delete spellScript;
5715 }
5716 if (auraScript)
5717 {
5718 auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5719 auraScript->_Register();
5720 if (!auraScript->_Validate(spellInfo))
5721 valid = false;
5722 delete auraScript;
5723 }
5724 if (!valid)
5725 {
5726 _spellScriptsStore.erase(sitr->second);
5727 }
5728 }
5729 ++count;
5730 }
5731
5732 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5733 LOG_INFO("server.loading", " ");
5734}
std::string const & GetScriptName(uint32 id) const
Definition: ObjectMgr.cpp:9473
virtual void _Register()
Definition: SpellScript.cpp:45
virtual void _Init(std::string const *scriptname, uint32 spellId)
Definition: SpellScript.cpp:59
Definition: SpellScript.h:182
bool _Validate(SpellInfo const *entry) override
Definition: SpellScript.cpp:316
Definition: SpellScript.h:517
bool _Validate(SpellInfo const *entry) override
Definition: SpellScript.cpp:662

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

Friends And Related Function Documentation

◆ PlayerDumpReader

friend class PlayerDumpReader
friend

Member Data Documentation

◆ _accessRequirementStore

DungeonProgressionRequirementsContainer ObjectMgr::_accessRequirementStore
private

◆ _acoreStringStore

AcoreStringContainer ObjectMgr::_acoreStringStore
private

Referenced by GetAcoreString(), and LoadAcoreStrings().

◆ _areaTriggerScriptStore

AreaTriggerScriptContainer ObjectMgr::_areaTriggerScriptStore
private

◆ _areaTriggerStore

AreaTriggerContainer ObjectMgr::_areaTriggerStore
private

Referenced by GetAreaTrigger(), and LoadAreaTriggers().

◆ _areaTriggerTeleportStore

◆ _auctionId

uint32 ObjectMgr::_auctionId
private

◆ _baseXPTable

BaseXPContainer ObjectMgr::_baseXPTable
private

Referenced by GetBaseXP(), and LoadExplorationBaseXP().

◆ _broadcastTextStore

BroadcastTextContainer ObjectMgr::_broadcastTextStore
private

◆ _cacheTrainerSpellStore

CacheTrainerSpellContainer ObjectMgr::_cacheTrainerSpellStore
private

◆ _cacheVendorItemStore

◆ _creatureAddonStore

CreatureAddonContainer ObjectMgr::_creatureAddonStore
private

◆ _creatureBaseStatsStore

CreatureBaseStatsContainer ObjectMgr::_creatureBaseStatsStore
private

◆ _creatureCustomIDsStore

CreatureCustomIDsContainer ObjectMgr::_creatureCustomIDsStore
private

◆ _creatureDataStore

◆ _creatureLocaleStore

CreatureLocaleContainer ObjectMgr::_creatureLocaleStore
private

◆ _creatureModelStore

CreatureModelContainer ObjectMgr::_creatureModelStore
private

◆ _creatureMovementOverrides

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

◆ _creatureQuestInvolvedRelations

◆ _creatureQuestItemStore

CreatureQuestItemMap ObjectMgr::_creatureQuestItemStore
private

◆ _creatureQuestRelations

QuestRelations ObjectMgr::_creatureQuestRelations
private

◆ _creatureSpawnId

ObjectGuid::LowType ObjectMgr::_creatureSpawnId
private

◆ _creatureTemplateAddonStore

CreatureAddonContainer ObjectMgr::_creatureTemplateAddonStore
private

◆ _creatureTemplateStore

◆ _creatureTemplateStoreFast

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

◆ _difficultyEntries

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

◆ _dungeonEncounterStore

DungeonEncounterContainer ObjectMgr::_dungeonEncounterStore
private

◆ _emptyCellObjectGuids

CellObjectGuids ObjectMgr::_emptyCellObjectGuids
private

Referenced by GetCellObjectGuids().

◆ _emptyCellObjectGuidsMap

CellObjectGuidsMap ObjectMgr::_emptyCellObjectGuidsMap
private

Referenced by GetMapObjectGuids().

◆ _equipmentInfoStore

EquipmentInfoContainer ObjectMgr::_equipmentInfoStore
private

◆ _equipmentSetGuid

uint64 ObjectMgr::_equipmentSetGuid
private

◆ _fishingBaseForAreaStore

◆ _gameObjectAddonStore

GameObjectAddonContainer ObjectMgr::_gameObjectAddonStore
private

◆ _gameObjectDataStore

GameObjectDataContainer ObjectMgr::_gameObjectDataStore
private

◆ _gameObjectLocaleStore

GameObjectLocaleContainer ObjectMgr::_gameObjectLocaleStore
private

◆ _gameObjectQuestItemStore

GameObjectQuestItemMap ObjectMgr::_gameObjectQuestItemStore
private

◆ _gameObjectSpawnId

ObjectGuid::LowType ObjectMgr::_gameObjectSpawnId
private

◆ _gameObjectTemplateAddonStore

GameObjectTemplateAddonContainer ObjectMgr::_gameObjectTemplateAddonStore
private

◆ _gameObjectTemplateStore

GameObjectTemplateContainer ObjectMgr::_gameObjectTemplateStore
private

◆ _gameTeleStore

GameTeleContainer ObjectMgr::_gameTeleStore
private

◆ _goQuestInvolvedRelations

QuestRelations ObjectMgr::_goQuestInvolvedRelations
private

◆ _goQuestRelations

QuestRelations ObjectMgr::_goQuestRelations
private

◆ _gossipMenuItemsLocaleStore

GossipMenuItemsLocaleContainer ObjectMgr::_gossipMenuItemsLocaleStore
private

◆ _gossipMenuItemsStore

◆ _gossipMenusStore

GossipMenusContainer ObjectMgr::_gossipMenusStore
private

◆ _gossipTextStore

GossipTextContainer ObjectMgr::_gossipTextStore
private

Referenced by GetGossipText(), and LoadGossipText().

◆ _guidGenerators

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

◆ _hasDifficultyEntries

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

Referenced by CheckCreatureTemplate().

◆ _hiPetNumber

uint32 ObjectMgr::_hiPetNumber
private

Referenced by GeneratePetNumber(), and LoadPetNumber().

◆ _hiPetNumberMutex

std::mutex ObjectMgr::_hiPetNumberMutex
private

Referenced by GeneratePetNumber().

◆ _instanceTemplateStore

InstanceTemplateContainer ObjectMgr::_instanceTemplateStore
private

◆ _itemLocaleStore

ItemLocaleContainer ObjectMgr::_itemLocaleStore
private

Referenced by GetItemLocale(), and LoadItemLocales().

◆ _itemSetNameLocaleStore

ItemSetNameLocaleContainer ObjectMgr::_itemSetNameLocaleStore
private

◆ _itemSetNameStore

ItemSetNameContainer ObjectMgr::_itemSetNameStore
private

◆ _itemTemplateStore

ItemTemplateContainer ObjectMgr::_itemTemplateStore
private

◆ _itemTemplateStoreFast

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

◆ _linkedRespawnStore

LinkedRespawnContainer ObjectMgr::_linkedRespawnStore
private

◆ _mailId

uint32 ObjectMgr::_mailId
private

Referenced by GenerateMailID(), and SetHighestGuids().

◆ _mailIdMutex

std::mutex ObjectMgr::_mailIdMutex
private

Referenced by GenerateMailID().

◆ _mailLevelRewardStore

MailLevelRewardContainer ObjectMgr::_mailLevelRewardStore
private

◆ _mapObjectGuidsStore

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

ReservedNamesContainer ObjectMgr::_profanityNamesStore
private

◆ _questAreaTriggerStore

QuestAreaTriggerContainer ObjectMgr::_questAreaTriggerStore
private

◆ _questGreetingLocaleStore

QuestGreetingLocaleContainer ObjectMgr::_questGreetingLocaleStore
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

ReservedNamesContainer ObjectMgr::_reservedNamesStore
private

◆ _scriptNamesStore

ScriptNameContainer ObjectMgr::_scriptNamesStore
private

◆ _serverMailStore

ServerMailContainer ObjectMgr::_serverMailStore
private

◆ _spellClickInfoStore

◆ _spellScriptsStore

SpellScriptsContainer ObjectMgr::_spellScriptsStore
private

◆ _tavernAreaTriggerStore

TavernAreaTriggerContainer ObjectMgr::_tavernAreaTriggerStore
private

◆ _tempSummonDataStore

TempSummonDataContainer ObjectMgr::_tempSummonDataStore
private

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

Referenced by GetSummonGroup(), and LoadTempSummons().

◆ _transportMaps

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

◆ _vehicleAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleAccessoryStore
private

◆ _vehicleTemplateAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleTemplateAccessoryStore
private

◆ DBCLocaleIndex

LocaleConstant ObjectMgr::DBCLocaleIndex
private

◆ FactionChangeAchievements

CharacterConversionMap ObjectMgr::FactionChangeAchievements

◆ FactionChangeItems

CharacterConversionMap ObjectMgr::FactionChangeItems

Referenced by LoadFactionChangeItems().

◆ FactionChangeQuests

CharacterConversionMap ObjectMgr::FactionChangeQuests

Referenced by LoadFactionChangeQuests().

◆ FactionChangeReputation

CharacterConversionMap ObjectMgr::FactionChangeReputation

◆ FactionChangeSpells

CharacterConversionMap ObjectMgr::FactionChangeSpells

Referenced by LoadFactionChangeSpells().

◆ FactionChangeTitles

CharacterConversionMap ObjectMgr::FactionChangeTitles

Referenced by LoadFactionChangeTitles().

◆ GameobjectInstanceSavedStateList

◆ mExclusiveQuestGroups

ExclusiveQuestGroups ObjectMgr::mExclusiveQuestGroups

Referenced by LoadQuests().