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)
 
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
355 :
356 _auctionId(1),
358 _mailId(1),
359 _hiPetNumber(1),
363{
364 for (uint8 i = 0; i < MAX_CLASSES; ++i)
365 {
366 _playerClassInfo[i] = nullptr;
367 for (uint8 j = 0; j < MAX_RACES; ++j)
368 _playerInfo[j][i] = nullptr;
369 }
370}
@ LOCALE_enUS
Definition: Common.h:75
std::uint8_t uint8
Definition: Define.h:110
#define MAX_RACES
Definition: SharedDefines.h:94
#define MAX_CLASSES
Definition: SharedDefines.h:127
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
373{
374 for (QuestMap::iterator i = _questTemplates.begin(); i != _questTemplates.end(); ++i)
375 delete i->second;
376
377 for (PetLevelInfoContainer::iterator i = _petInfoStore.begin(); i != _petInfoStore.end(); ++i)
378 delete[] i->second;
379
380 // free only if loaded
381 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
382 {
383 if (_playerClassInfo[class_])
384 delete[] _playerClassInfo[class_]->levelInfo;
385 delete _playerClassInfo[class_];
386 }
387
388 for (int race = 0; race < MAX_RACES; ++race)
389 {
390 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
391 {
392 if (_playerInfo[race][class_])
393 delete[] _playerInfo[race][class_]->levelInfo;
394 delete _playerInfo[race][class_];
395 }
396 }
397
398 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
399 itr->second.Clear();
400
402
403 for (DungeonEncounterContainer::iterator itr = _dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr)
404 for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr)
405 delete *encounterItr;
406
407 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
408 {
409 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
410 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
411 {
412 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
413 {
414 delete* questItr;
415 }
416
417 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
418 {
419 delete* achievementItr;
420 }
421
422 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
423 {
424 delete* itemsItr;
425 }
426
427 delete difficultiesItr->second;
428 }
429 }
430}
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 
)
2339{
2340 uint8 mask = data->spawnMask;
2341 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2342 {
2343 if (mask & 1)
2344 {
2345 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2346 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2347 cell_guids.creatures.insert(guid);
2348 }
2349 }
2350}
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 
)
2418{
2419 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2420 if (!cInfo)
2421 return 0;
2422
2423 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2424 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2425 Map* map = sMapMgr->CreateBaseMap(mapId);
2426 if (!map)
2427 return 0;
2428
2430 CreatureData& data = NewOrExistCreatureData(spawnId);
2431 data.spawnMask = spawnId;
2432 data.id1 = entry;
2433 data.id2 = 0;
2434 data.id3 = 0;
2435 data.mapid = mapId;
2436 data.displayid = 0;
2437 data.equipmentId = 0;
2438 data.posX = x;
2439 data.posY = y;
2440 data.posZ = z;
2441 data.orientation = o;
2442 data.spawntimesecs = spawntimedelay;
2443 data.wander_distance = 0;
2444 data.currentwaypoint = 0;
2445 data.curhealth = stats->GenerateHealth(cInfo);
2446 data.curmana = stats->GenerateMana(cInfo);
2447 data.movementType = cInfo->MovementType;
2448 data.spawnMask = 1;
2450 data.dbData = false;
2451 data.npcflag = cInfo->npcflag;
2452 data.unit_flags = cInfo->unit_flags;
2453 data.dynamicflags = cInfo->dynamicflags;
2454
2455 AddCreatureToGrid(spawnId, &data);
2456
2457 // Spawn if necessary (loaded grids only)
2458 if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
2459 {
2460 Creature* creature = new Creature();
2461 if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true))
2462 {
2463 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2464 delete creature;
2465 return 0;
2466 }
2467 }
2468
2469 return spawnId;
2470}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
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:1661
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:9640
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition: ObjectMgr.cpp:2338
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition: ObjectMgr.cpp:7068
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition: ObjectMgr.h:1206
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition: ObjectMgr.cpp:9988
Definition: Map.h:312
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:362
bool Instanceable() const
Definition: Map.h:446

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 
)
2645{
2646 uint8 mask = data->spawnMask;
2647 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2648 {
2649 if (mask & 1)
2650 {
2651 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2652 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2653 cell_guids.gameobjects.insert(guid);
2654 }
2655 }
2656}
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)
8872{
8873 // find max id
8874 uint32 new_id = 0;
8875 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8876 if (itr->first > new_id)
8877 new_id = itr->first;
8878
8879 // use next
8880 ++new_id;
8881
8882 if (!Utf8toWStr(tele.name, tele.wnameLow))
8883 return false;
8884
8885 wstrToLower(tele.wnameLow);
8886
8887 _gameTeleStore[new_id] = tele;
8888
8890
8891 stmt->SetData(0, new_id);
8892 stmt->SetData(1, tele.position_x);
8893 stmt->SetData(2, tele.position_y);
8894 stmt->SetData(3, tele.position_z);
8895 stmt->SetData(4, tele.orientation);
8896 stmt->SetData(5, uint16(tele.mapId));
8897 stmt->SetData(6, tele.name);
8898
8899 WorldDatabase.Execute(stmt);
8900
8901 return true;
8902}
std::uint16_t uint16
Definition: Define.h:109
void wstrToLower(std::wstring &str)
Definition: Util.cpp:383
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:282
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 
)
2367{
2368 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2369 if (!goinfo)
2370 return 0;
2371
2372 Map* map = sMapMgr->CreateBaseMap(mapId);
2373 if (!map)
2374 return 0;
2375
2377
2378 GameObjectData& data = NewGOData(spawnId);
2379 data.id = entry;
2380 data.mapid = mapId;
2381 data.posX = x;
2382 data.posY = y;
2383 data.posZ = z;
2384 data.orientation = o;
2385 data.rotation.x = rotation0;
2386 data.rotation.y = rotation1;
2387 data.rotation.z = rotation2;
2388 data.rotation.w = rotation3;
2389 data.spawntimesecs = spawntimedelay;
2390 data.animprogress = 100;
2391 data.spawnMask = 1;
2392 data.go_state = GO_STATE_READY;
2394 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2395 data.dbData = false;
2396
2397 AddGameobjectToGrid(spawnId, &data);
2398
2399 // Spawn if necessary (loaded grids only)
2400 // We use spawn coords to spawn
2401 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2402 {
2403 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(data.id) ? new StaticTransport() : new GameObject();
2404 if (!go->LoadGameObjectFromDB(spawnId, map))
2405 {
2406 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2407 delete go;
2408 return 0;
2409 }
2410 }
2411
2412 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2413
2414 return spawnId;
2415}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
@ GO_STATE_READY
Definition: GameObjectData.h:691
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition: SharedDefines.h:1561
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:2644
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition: ObjectMgr.cpp:9964
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition: ObjectMgr.cpp:7078
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition: ObjectMgr.h:1311
bool IsGridLoaded(float x, float y) const
Definition: Map.h:368

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)
8291{
8292 if (!IsProfanityName(name))
8293 {
8294 std::wstring wstr;
8295 if (!Utf8toWStr(name, wstr))
8296 {
8297 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
8298 return;
8299 }
8300 wstrToLower(wstr);
8301
8302 _profanityNamesStore.insert(wstr);
8303
8305 stmt->SetData(0, name);
8306 CharacterDatabase.Execute(stmt);
8307 }
8308}
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:8275
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)
8216{
8217 if (!IsReservedName(name))
8218 {
8219 std::wstring wstr;
8220 if (!Utf8toWStr(name, wstr))
8221 {
8222 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
8223 return;
8224 }
8225 wstrToLower(wstr);
8226
8227 _reservedNamesStore.insert(wstr);
8228
8230 stmt->SetData(0, name);
8231 CharacterDatabase.Execute(stmt);
8232 }
8233}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition: CharacterDatabase.h:512
bool IsReservedName(std::string_view name) const
Definition: ObjectMgr.cpp:8200
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 
)
8993{
8994 if (entry >= ACORE_TRAINER_START_REF)
8995 return;
8996
8997 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
8998 if (!cInfo)
8999 {
9000 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a non-existing creature template (Entry: {}), ignoring", entry);
9001 return;
9002 }
9003
9004 if (!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
9005 {
9006 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry for a creature template (Entry: {}) without trainer flag, ignoring", entry);
9007 return;
9008 }
9009
9010 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spell);
9011 if (!spellinfo)
9012 {
9013 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}), ignoring", entry, spell);
9014 return;
9015 }
9016
9017 if (!SpellMgr::ComputeIsSpellValid(spellinfo))
9018 {
9019 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a broken spell (Spell: {}), ignoring", entry, spell);
9020 return;
9021 }
9022
9023 if (GetTalentSpellCost(spell))
9024 {
9025 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing spell (Spell: {}) which is a talent, ignoring", entry, spell);
9026 return;
9027 }
9028
9029 if (reqSpell && !sSpellMgr->GetSpellInfo(reqSpell))
9030 {
9031 LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: {}) for a non-existing reqSpell (Spell: {}), ignoring", entry, reqSpell);
9032 return;
9033 }
9034
9036
9037 TrainerSpell& trainerSpell = data.spellList[spell];
9038 trainerSpell.spell = spell;
9039 trainerSpell.spellCost = spellCost;
9040 trainerSpell.reqSkill = reqSkill;
9041 trainerSpell.reqSkillValue = reqSkillValue;
9042 trainerSpell.reqLevel = reqLevel;
9043 trainerSpell.reqSpell = reqSpell;
9044
9045 if (!trainerSpell.reqLevel)
9046 trainerSpell.reqLevel = spellinfo->SpellLevel;
9047
9048 // calculate learned spell for profession case when stored cast-spell
9049 trainerSpell.learnedSpell[0] = spell;
9050 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
9051 {
9052 if (spellinfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
9053 continue;
9054 if (trainerSpell.learnedSpell[0] == spell)
9055 trainerSpell.learnedSpell[0] = 0;
9056 // player must be able to cast spell on himself
9057 if (spellinfo->Effects[i].TargetA.GetTarget() != 0 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ALLY
9058 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_CASTER)
9059 {
9060 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);
9061 continue;
9062 }
9063
9064 trainerSpell.learnedSpell[i] = spellinfo->Effects[i].TriggerSpell;
9065
9066 if (trainerSpell.learnedSpell[i])
9067 {
9068 SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.learnedSpell[i]);
9069 if (learnedSpellInfo && learnedSpellInfo->IsProfession())
9070 data.trainerType = 2;
9071 }
9072 }
9073
9074 return;
9075}
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:786
@ TARGET_UNIT_TARGET_ALLY
Definition: SharedDefines.h:1397
@ TARGET_UNIT_TARGET_ANY
Definition: SharedDefines.h:1401
@ TARGET_UNIT_CASTER
Definition: SharedDefines.h:1382
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:937
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 
)
9318{
9319 VendorItemData& vList = _cacheVendorItemStore[entry];
9320 vList.AddItem(item, maxcount, incrtime, extendedCost);
9321
9322 if (persist)
9323 {
9325
9326 stmt->SetData(0, entry);
9327 stmt->SetData(1, item);
9328 stmt->SetData(2, maxcount);
9329 stmt->SetData(3, incrtime);
9330 stmt->SetData(4, extendedCost);
9331
9332 WorldDatabase.Execute(stmt);
9333 }
9334}
@ 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
4372{
4373 // base data (last known level)
4374 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
4375
4376 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
4377 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
4378 {
4379 switch (_class)
4380 {
4381 case CLASS_WARRIOR:
4382 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4383 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4384 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4385 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4386 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4387 break;
4388 case CLASS_PALADIN:
4389 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
4390 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4391 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
4392 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
4393 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
4394 break;
4395 case CLASS_HUNTER:
4396 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
4397 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4398 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4399 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
4400 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4401 break;
4402 case CLASS_ROGUE:
4403 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
4404 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4405 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
4406 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
4407 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4408 break;
4409 case CLASS_PRIEST:
4410 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4411 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4412 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4413 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
4414 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
4415 break;
4416 case CLASS_SHAMAN:
4417 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4418 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4419 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
4420 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
4421 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
4422 break;
4423 case CLASS_MAGE:
4424 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4425 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4426 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4427 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
4428 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4429 break;
4430 case CLASS_WARLOCK:
4431 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4432 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4433 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4434 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4435 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4436 break;
4437 case CLASS_DRUID:
4438 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4439 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
4440 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4441 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
4442 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
4443 }
4444 }
4445}
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:236
@ CLASS_HUNTER
Definition: SharedDefines.h:115
@ CLASS_DRUID
Definition: SharedDefines.h:123
@ CLASS_SHAMAN
Definition: SharedDefines.h:119
@ CLASS_PRIEST
Definition: SharedDefines.h:117
@ CLASS_WARRIOR
Definition: SharedDefines.h:113
@ CLASS_WARLOCK
Definition: SharedDefines.h:121
@ CLASS_MAGE
Definition: SharedDefines.h:120
@ CLASS_PALADIN
Definition: SharedDefines.h:114
@ CLASS_ROGUE
Definition: SharedDefines.h:116
@ STAT_SPIRIT
Definition: SharedDefines.h:234
@ STAT_INTELLECT
Definition: SharedDefines.h:233
@ STAT_AGILITY
Definition: SharedDefines.h:231
@ STAT_STRENGTH
Definition: SharedDefines.h:230
@ STAT_STAMINA
Definition: SharedDefines.h:232
#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 
)
8691{
8692 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8693 if (!fArea)
8694 {
8695 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8696 return;
8697 }
8698
8699 _fishingBaseForAreaStore[entry] = skill;
8700
8701 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
8702 LOG_INFO("server.loading", " ");
8703}
#define LOG_INFO(filterType__,...)
Definition: Log.h:167
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 
)
1316{
1317 if (creatureMovement.Ground >= CreatureGroundMovementType::Max)
1318 {
1319 LOG_ERROR("sql.sql", "`{}`.`Ground` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Ground), id);
1320 creatureMovement.Ground = CreatureGroundMovementType::Run;
1321 }
1322
1323 if (creatureMovement.Flight >= CreatureFlightMovementType::Max)
1324 {
1325 LOG_ERROR("sql.sql", "`{}`.`Flight` wrong value ({}) for Id {}, setting to None.", table, uint32(creatureMovement.Flight), id);
1326 creatureMovement.Flight = CreatureFlightMovementType::None;
1327 }
1328
1329 if (creatureMovement.Chase >= CreatureChaseMovementType::Max)
1330 {
1331 LOG_ERROR("sql.sql", "`{}`.`Chase` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Chase), id);
1332 creatureMovement.Chase = CreatureChaseMovementType::Run;
1333 }
1334
1335 if (creatureMovement.Random >= CreatureRandomMovementType::Max)
1336 {
1337 LOG_ERROR("sql.sql", "`{}`.`Random` wrong value ({}) for Id {}, setting to Walk.", table, uint32(creatureMovement.Random), id);
1338 creatureMovement.Random = CreatureRandomMovementType::Walk;
1339 }
1340}
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

958{
959 if (!cInfo)
960 return;
961
962 bool ok = true; // bool to allow continue outside this loop
963 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
964 {
965 if (!cInfo->DifficultyEntry[diff])
966 continue;
967 ok = false; // will be set to true at the end of this loop again
968
969 CreatureTemplate const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
970 if (!difficultyInfo)
971 {
972 LOG_ERROR("sql.sql", "Creature (Entry: {}) has `difficulty_entry_{}`={} but creature entry {} does not exist.",
973 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]);
974 continue;
975 }
976
977 bool ok2 = true;
978 for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2)
979 {
980 ok2 = false;
981 if (_difficultyEntries[diff2].find(cInfo->Entry) != _difficultyEntries[diff2].end())
982 {
983 LOG_ERROR("sql.sql", "Creature (Entry: {}) is listed as `difficulty_entry_{}` of another creature, but itself lists {} in `difficulty_entry_{}`.",
984 cInfo->Entry, diff2 + 1, cInfo->DifficultyEntry[diff], diff + 1);
985 continue;
986 }
987
988 if (_difficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != _difficultyEntries[diff2].end())
989 {
990 LOG_ERROR("sql.sql", "Creature (Entry: {}) already listed as `difficulty_entry_{}` for another entry.", cInfo->DifficultyEntry[diff], diff2 + 1);
991 continue;
992 }
993
994 if (_hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != _hasDifficultyEntries[diff2].end())
995 {
996 LOG_ERROR("sql.sql", "Creature (Entry: {}) has `difficulty_entry_{}`={} but creature entry {} has itself a value in `difficulty_entry_{}`.",
997 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1);
998 continue;
999 }
1000 ok2 = true;
1001 }
1002 if (!ok2)
1003 continue;
1004
1005 if (cInfo->expansion > difficultyInfo->expansion)
1006 {
1007 LOG_ERROR("sql.sql", "Creature (Entry: {}, expansion {}) has different `expansion` in difficulty {} mode (Entry: {}, expansion {}).",
1008 cInfo->Entry, cInfo->expansion, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->expansion);
1009 }
1010
1011 if (cInfo->faction != difficultyInfo->faction)
1012 {
1013 LOG_ERROR("sql.sql", "Creature (Entry: {}, faction {}) has different `faction` in difficulty {} mode (Entry: {}, faction {}).",
1014 cInfo->Entry, cInfo->faction, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->faction);
1015 }
1016
1017 if (cInfo->unit_class != difficultyInfo->unit_class)
1018 {
1019 LOG_ERROR("sql.sql", "Creature (Entry: {}, class {}) has different `unit_class` in difficulty {} mode (Entry: {}, class {}).",
1020 cInfo->Entry, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class);
1021 continue;
1022 }
1023
1024 if (cInfo->npcflag != difficultyInfo->npcflag)
1025 {
1026 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `npcflag` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1027 continue;
1028 }
1029
1030 if (cInfo->family != difficultyInfo->family)
1031 {
1032 LOG_ERROR("sql.sql", "Creature (Entry: {}, family {}) has different `family` in difficulty {} mode (Entry: {}, family {}).",
1033 cInfo->Entry, cInfo->family, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->family);
1034 }
1035
1036 if (cInfo->trainer_class != difficultyInfo->trainer_class)
1037 {
1038 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_class` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1039 continue;
1040 }
1041
1042 if (cInfo->trainer_race != difficultyInfo->trainer_race)
1043 {
1044 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_race` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1045 continue;
1046 }
1047
1048 if (cInfo->trainer_type != difficultyInfo->trainer_type)
1049 {
1050 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_type` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1051 continue;
1052 }
1053
1054 if (cInfo->trainer_spell != difficultyInfo->trainer_spell)
1055 {
1056 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `trainer_spell` in difficulty {} mode (Entry: {}).", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1057 continue;
1058 }
1059
1060 if (cInfo->type != difficultyInfo->type)
1061 {
1062 LOG_ERROR("sql.sql", "Creature (Entry: {}, type {}) has different `type` in difficulty {} mode (Entry: {}, type {}).",
1063 cInfo->Entry, cInfo->type, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->type);
1064 }
1065
1066 if (!cInfo->VehicleId && difficultyInfo->VehicleId)
1067 {
1068 LOG_ERROR("sql.sql", "Creature (Entry: {}, VehicleId {}) has different `VehicleId` in difficulty {} mode (Entry: {}, VehicleId {}).",
1069 cInfo->Entry, cInfo->VehicleId, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->VehicleId);
1070 }
1071
1072 // Xinef: check dmg school
1073 if (cInfo->dmgschool != difficultyInfo->dmgschool)
1074 {
1075 LOG_ERROR("sql.sql", "Creature (Entry: {}) has different `dmgschool` in difficulty {} mode (Entry: {})", cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1076 }
1077
1078 if (!difficultyInfo->AIName.empty())
1079 {
1080 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists difficulty {} mode entry {} with `AIName` filled in. `AIName` of difficulty 0 mode creature is always used instead.",
1081 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1082 continue;
1083 }
1084
1085 if (difficultyInfo->ScriptID)
1086 {
1087 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists difficulty {} mode entry {} with `ScriptName` filled in. `ScriptName` of difficulty 0 mode creature is always used instead.",
1088 cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
1089 continue;
1090 }
1091
1092 _hasDifficultyEntries[diff].insert(cInfo->Entry);
1093 _difficultyEntries[diff].insert(cInfo->DifficultyEntry[diff]);
1094 ok = true;
1095 }
1096
1097 if (!cInfo->AIName.empty() && !sCreatureAIRegistry->HasItem(cInfo->AIName))
1098 {
1099 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-registered `AIName` '{}' set, removing", cInfo->Entry, cInfo->AIName);
1100 const_cast<CreatureTemplate*>(cInfo)->AIName.clear();
1101 }
1102
1103 FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction);
1104 if (!factionTemplate)
1105 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing faction template ({}).", cInfo->Entry, cInfo->faction);
1106
1107 // used later for scale
1108 CreatureDisplayInfoEntry const* displayScaleEntry = nullptr;
1109
1110 if (cInfo->Modelid1)
1111 {
1112 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid1);
1113 if (!displayEntry)
1114 {
1115 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid1 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid1);
1116 const_cast<CreatureTemplate*>(cInfo)->Modelid1 = 0;
1117 }
1118 else if (!displayScaleEntry)
1119 displayScaleEntry = displayEntry;
1120
1121 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid1);
1122 if (!modelInfo)
1123 LOG_ERROR("sql.sql", "No model data exist for `Modelid1` = {} listed by creature (Entry: {}).", cInfo->Modelid1, cInfo->Entry);
1124 }
1125
1126 if (cInfo->Modelid2)
1127 {
1128 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid2);
1129 if (!displayEntry)
1130 {
1131 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid2 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid2);
1132 const_cast<CreatureTemplate*>(cInfo)->Modelid2 = 0;
1133 }
1134 else if (!displayScaleEntry)
1135 displayScaleEntry = displayEntry;
1136
1137 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid2);
1138 if (!modelInfo)
1139 LOG_ERROR("sql.sql", "No model data exist for `Modelid2` = {} listed by creature (Entry: {}).", cInfo->Modelid2, cInfo->Entry);
1140 }
1141
1142 if (cInfo->Modelid3)
1143 {
1144 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid3);
1145 if (!displayEntry)
1146 {
1147 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid3 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid3);
1148 const_cast<CreatureTemplate*>(cInfo)->Modelid3 = 0;
1149 }
1150 else if (!displayScaleEntry)
1151 displayScaleEntry = displayEntry;
1152
1153 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid3);
1154 if (!modelInfo)
1155 LOG_ERROR("sql.sql", "No model data exist for `Modelid3` = {} listed by creature (Entry: {}).", cInfo->Modelid3, cInfo->Entry);
1156 }
1157
1158 if (cInfo->Modelid4)
1159 {
1160 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid4);
1161 if (!displayEntry)
1162 {
1163 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing Modelid4 id ({}), this can crash the client.", cInfo->Entry, cInfo->Modelid4);
1164 const_cast<CreatureTemplate*>(cInfo)->Modelid4 = 0;
1165 }
1166 else if (!displayScaleEntry)
1167 displayScaleEntry = displayEntry;
1168
1169 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid4);
1170 if (!modelInfo)
1171 LOG_ERROR("sql.sql", "No model data exist for `Modelid4` = {} listed by creature (Entry: {}).", cInfo->Modelid4, cInfo->Entry);
1172 }
1173
1174 if (!displayScaleEntry)
1175 LOG_ERROR("sql.sql", "Creature (Entry: {}) does not have any existing display id in Modelid1/Modelid2/Modelid3/Modelid4.", cInfo->Entry);
1176
1177 for (int k = 0; k < MAX_KILL_CREDIT; ++k)
1178 {
1179 if (cInfo->KillCredit[k])
1180 {
1181 if (!GetCreatureTemplate(cInfo->KillCredit[k]))
1182 {
1183 LOG_ERROR("sql.sql", "Creature (Entry: {}) lists non-existing creature entry {} in `KillCredit{}`.", cInfo->Entry, cInfo->KillCredit[k], k + 1);
1184 const_cast<CreatureTemplate*>(cInfo)->KillCredit[k] = 0;
1185 }
1186 }
1187 }
1188
1189 if (!cInfo->unit_class || ((1 << (cInfo->unit_class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
1190 {
1191 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid unit_class ({}) in creature_template. Set to 1 (UNIT_CLASS_WARRIOR).", cInfo->Entry, cInfo->unit_class);
1192 const_cast<CreatureTemplate*>(cInfo)->unit_class = UNIT_CLASS_WARRIOR;
1193 }
1194
1195 if (cInfo->dmgschool >= MAX_SPELL_SCHOOL)
1196 {
1197 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid spell school value ({}) in `dmgschool`.", cInfo->Entry, cInfo->dmgschool);
1198 const_cast<CreatureTemplate*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL;
1199 }
1200
1201 if (cInfo->BaseAttackTime == 0)
1202 const_cast<CreatureTemplate*>(cInfo)->BaseAttackTime = BASE_ATTACK_TIME;
1203
1204 if (cInfo->RangeAttackTime == 0)
1205 const_cast<CreatureTemplate*>(cInfo)->RangeAttackTime = BASE_ATTACK_TIME;
1206
1207 if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE)
1208 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong trainer type {}.", cInfo->Entry, cInfo->trainer_type);
1209
1210 if (cInfo->speed_walk == 0.0f)
1211 {
1212 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in speed_walk, set to 1.", cInfo->Entry, cInfo->speed_walk);
1213 const_cast<CreatureTemplate*>(cInfo)->speed_walk = 1.0f;
1214 }
1215
1216 if (cInfo->speed_run == 0.0f)
1217 {
1218 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in speed_run, set to 1.14286.", cInfo->Entry, cInfo->speed_run);
1219 const_cast<CreatureTemplate*>(cInfo)->speed_run = 1.14286f;
1220 }
1221
1222 if (cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type))
1223 {
1224 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid creature type ({}) in `type`.", cInfo->Entry, cInfo->type);
1225 const_cast<CreatureTemplate*>(cInfo)->type = CREATURE_TYPE_HUMANOID;
1226 }
1227
1228 // must exist or used hidden but used in data horse case
1229 if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM)
1230 {
1231 LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid creature family ({}) in `family`.", cInfo->Entry, cInfo->family);
1232 const_cast<CreatureTemplate*>(cInfo)->family = 0;
1233 }
1234
1235 CheckCreatureMovement("creature_template_movement", cInfo->Entry, const_cast<CreatureTemplate*>(cInfo)->Movement);
1236
1237 if (cInfo->HoverHeight < 0.0f)
1238 {
1239 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong value ({}) in `HoverHeight`", cInfo->Entry, cInfo->HoverHeight);
1240 const_cast<CreatureTemplate*>(cInfo)->HoverHeight = 1.0f;
1241 }
1242
1243 if (cInfo->VehicleId)
1244 {
1245 VehicleEntry const* vehId = sVehicleStore.LookupEntry(cInfo->VehicleId);
1246 if (!vehId)
1247 {
1248 LOG_ERROR("sql.sql", "Creature (Entry: {}) has a non-existing VehicleId ({}). This *WILL* cause the client to freeze!", cInfo->Entry, cInfo->VehicleId);
1249 const_cast<CreatureTemplate*>(cInfo)->VehicleId = 0;
1250 }
1251 }
1252
1253 if (cInfo->PetSpellDataId)
1254 {
1255 CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
1256 if (!spellDataId)
1257 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing PetSpellDataId ({}).", cInfo->Entry, cInfo->PetSpellDataId);
1258 }
1259
1260 for (uint8 j = 0; j < MAX_CREATURE_SPELLS; ++j)
1261 {
1262 if (cInfo->spells[j] && !sSpellMgr->GetSpellInfo(cInfo->spells[j]))
1263 {
1264 LOG_ERROR("sql.sql", "Creature (Entry: {}) has non-existing Spell{} ({}), set to 0.", cInfo->Entry, j + 1, cInfo->spells[j]);
1265 const_cast<CreatureTemplate*>(cInfo)->spells[j] = 0;
1266 }
1267 }
1268
1269 if (cInfo->MovementType >= MAX_DB_MOTION_TYPE)
1270 {
1271 LOG_ERROR("sql.sql", "Creature (Entry: {}) has wrong movement generator type ({}), ignored and set to IDLE.", cInfo->Entry, cInfo->MovementType);
1272 const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
1273 }
1274
1276 if (cInfo->scale <= 0.0f)
1277 {
1278 if (displayScaleEntry)
1279 const_cast<CreatureTemplate*>(cInfo)->scale = displayScaleEntry->scale;
1280 else
1281 const_cast<CreatureTemplate*>(cInfo)->scale = 1.0f;
1282 }
1283
1284 if (cInfo->expansion > (MAX_EXPANSIONS - 1))
1285 {
1286 LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: {}) with expansion {}. Ignored and set to 0.", cInfo->Entry, cInfo->expansion);
1287 const_cast<CreatureTemplate*>(cInfo)->expansion = 0;
1288 }
1289
1290 if (uint32 badFlags = (cInfo->flags_extra & ~CREATURE_FLAG_EXTRA_DB_ALLOWED))
1291 {
1292 LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: {}) with disallowed `flags_extra` {}, removing incorrect flag.", cInfo->Entry, badFlags);
1293 const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
1294 }
1295
1296 const_cast<CreatureTemplate*>(cInfo)->DamageModifier *= Creature::_GetDamageMod(cInfo->rank);
1297
1298 // Hack for modules
1299 for (auto& itr : _creatureCustomIDsStore)
1300 {
1301 if (cInfo->Entry == itr)
1302 return;
1303 }
1304
1305 if ((cInfo->GossipMenuId && !(cInfo->npcflag & UNIT_NPC_FLAG_GOSSIP)) && !(cInfo->flags_extra & CREATURE_FLAG_EXTRA_MODULE))
1306 {
1307 LOG_ERROR("sql.sql", "Creature (Entry: {}) has assigned gossip menu {}, but npcflag does not include UNIT_NPC_FLAG_GOSSIP (1).", cInfo->Entry, cInfo->GossipMenuId);
1308 }
1309 else if ((!cInfo->GossipMenuId && (cInfo->npcflag & UNIT_NPC_FLAG_GOSSIP)) && !(cInfo->flags_extra & CREATURE_FLAG_EXTRA_MODULE))
1310 {
1311 LOG_INFO("sql.sql", "Creature (Entry: {}) has npcflag UNIT_NPC_FLAG_GOSSIP (1), but gossip menu is unassigned.", cInfo->Entry);
1312 }
1313}
#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:25
#define MAX_DIFFICULTY
Definition: DBCEnums.h:288
@ SPELL_SCHOOL_NORMAL
Definition: SharedDefines.h:255
constexpr auto MAX_SPELL_SCHOOL
Definition: SharedDefines.h:264
@ CREATURE_FAMILY_HORSE_CUSTOM
Definition: SharedDefines.h:2631
@ UNIT_CLASS_WARRIOR
Definition: SharedDefines.h:138
@ CREATURE_TYPE_HUMANOID
Definition: SharedDefines.h:2606
#define CLASSMASK_ALL_CREATURES
Definition: SharedDefines.h:144
@ MAX_EXPANSIONS
Definition: SharedDefines.h:55
#define MAX_TRAINER_TYPE
Definition: SharedDefines.h:2595
static float _GetDamageMod(int32 Rank)
Definition: Creature.cpp:1561
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:1315
CreatureModelInfo const * GetCreatureModelInfo(uint32 modelId) const
Definition: ObjectMgr.cpp:1708
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
8706{
8707 // get main part of the name
8708 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
8709 // prepare flags
8710 bool x = true;
8711 bool y = true;
8712
8713 // check declined names
8714 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
8715 {
8716 std::wstring wname;
8717 if (!Utf8toWStr(names.name[i], wname))
8718 return false;
8719
8720 if (mainpart != GetMainPartOfName(wname, i + 1))
8721 x = false;
8722
8723 if (w_ownname != wname)
8724 y = false;
8725 }
8726 return (x || y);
8727}
std::wstring GetMainPartOfName(std::wstring const &wname, uint32 declension)
Definition: Util.cpp:387
#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
8494{
8495 std::wstring wname;
8496 if (!Utf8toWStr(name, wname))
8497 return PET_NAME_INVALID;
8498
8499 if (wname.size() > MAX_PET_NAME)
8500 return PET_NAME_TOO_LONG;
8501
8502 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
8503 if (wname.size() < minName)
8504 return PET_NAME_TOO_SHORT;
8505
8506 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
8507 if (!isValidString(wname, strictMask, false))
8509
8510 // Check for Reserved Name from DBC
8511 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8512 {
8513 if (ReservedNames(wname))
8514 {
8515 return PET_NAME_RESERVED;
8516 }
8517 }
8518
8519 // Check for Profanity
8520 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8521 {
8522 if (ProfanityNames(wname))
8523 {
8524 return PET_NAME_PROFANE;
8525 }
8526 }
8527
8528 return PET_NAME_SUCCESS;
8529}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition: ObjectMgr.cpp:8347
bool ReservedNames(std::wstring &name)
Definition: ObjectMgr.cpp:215
bool ProfanityNames(std::wstring &name)
Definition: ObjectMgr.cpp:243
#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:3632
@ PET_NAME_RESERVED
Definition: SharedDefines.h:3638
@ PET_NAME_SUCCESS
Definition: SharedDefines.h:3630
@ PET_NAME_MIXED_LANGUAGES
Definition: SharedDefines.h:3636
@ PET_NAME_TOO_SHORT
Definition: SharedDefines.h:3634
@ PET_NAME_TOO_LONG
Definition: SharedDefines.h:3635
@ PET_NAME_PROFANE
Definition: SharedDefines.h:3637

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
8384{
8385 std::wstring wname;
8386
8387 // Check for invalid characters
8388 if (!Utf8toWStr(name, wname))
8390
8391 // Check for too long name
8392 if (wname.size() > MAX_PLAYER_NAME)
8393 return CHAR_NAME_TOO_LONG;
8394
8395 // Check for too short name
8396 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
8397 if (wname.size() < minName)
8398 return CHAR_NAME_TOO_SHORT;
8399
8400 // Check for mixed languages
8401 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
8402 if (!isValidString(wname, strictMask, false, create))
8404
8405 // Check for three consecutive letters
8406 wstrToLower(wname);
8407 for (size_t i = 2; i < wname.size(); ++i)
8408 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
8410
8411 // Check Reserved Name from Database
8412 if (sObjectMgr->IsReservedName(name))
8413 {
8414 return CHAR_NAME_RESERVED;
8415 }
8416
8417 if (sObjectMgr->IsProfanityName(name))
8418 {
8419 return CHAR_NAME_PROFANE;
8420 }
8421
8422 // Check for Reserved Name from DBC
8423 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8424 {
8425 if (ReservedNames(wname))
8426 {
8427 return CHAR_NAME_RESERVED;
8428 }
8429 }
8430
8431 // Check for Profanity
8432 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8433 {
8434 if (ProfanityNames(wname))
8435 {
8436 return CHAR_NAME_PROFANE;
8437 }
8438 }
8439
8440 return CHAR_NAME_SUCCESS;
8441}
#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:3394
@ CHAR_NAME_THREE_CONSECUTIVE
Definition: SharedDefines.h:3402
@ CHAR_NAME_INVALID_CHARACTER
Definition: SharedDefines.h:3396
@ CHAR_NAME_TOO_LONG
Definition: SharedDefines.h:3395
@ CHAR_NAME_RESERVED
Definition: SharedDefines.h:3399
@ CHAR_NAME_MIXED_LANGUAGES
Definition: SharedDefines.h:3397
@ CHAR_NAME_PROFANE
Definition: SharedDefines.h:3398
@ CHAR_NAME_SUCCESS
Definition: SharedDefines.h:3391

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
1727{
1728 npcflag = cinfo->npcflag;
1729 unit_flags = cinfo->unit_flags;
1730 dynamicflags = cinfo->dynamicflags;
1731
1732 if (data)
1733 {
1734 if (data->npcflag)
1735 npcflag = data->npcflag;
1736
1737 if (data->unit_flags)
1738 unit_flags = data->unit_flags;
1739
1740 if (data->dynamicflags)
1741 dynamicflags = data->dynamicflags;
1742 }
1743}

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
1718{
1719 // Load creature model (display id)
1720 if (data && data->displayid)
1721 return data->displayid;
1722
1723 return cinfo->GetRandomValidModelId();
1724}

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)
8040{
8041 // remove mapid*cellid -> guid_set map
8042 CreatureData const* data = GetCreatureData(guid);
8043 if (data)
8044 RemoveCreatureFromGrid(guid, data);
8045
8046 _creatureDataStore.erase(guid);
8047}
CreatureDataContainer _creatureDataStore
Definition: ObjectMgr.h:1575
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition: ObjectMgr.cpp:2352
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition: ObjectMgr.h:1200

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

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
8905{
8906 // explicit name case
8907 std::wstring wname;
8908 if (!Utf8toWStr(name, wname))
8909 return false;
8910
8911 // converting string that we try to find to lower case
8912 wstrToLower(wname);
8913
8914 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8915 {
8916 if (itr->second.wnameLow == wname)
8917 {
8919
8920 stmt->SetData(0, itr->second.name);
8921
8922 WorldDatabase.Execute(stmt);
8923
8924 _gameTeleStore.erase(itr);
8925 return true;
8926 }
8927 }
8928
8929 return false;
8930}
@ 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)
8050{
8051 // remove mapid*cellid -> guid_set map
8052 GameObjectData const* data = GetGameObjectData(guid);
8053 if (data)
8054 RemoveGameobjectFromGrid(guid, data);
8055
8056 _gameObjectDataStore.erase(guid);
8057}
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:2658

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

◆ FindInstanceSavedGameobjectState()

bool ObjectMgr::FindInstanceSavedGameobjectState ( uint32  id,
uint32  guid 
)
10200{
10201 for (auto it = GameobjectInstanceSavedStateList.begin(); it != GameobjectInstanceSavedStateList.end(); it++)
10202 {
10203 if (it->m_guid == guid && it->m_instance == id)
10204 {
10205 return true;
10206 }
10207 }
10208 return false;
10209}
std::vector< GameobjectInstanceSavedState > GameobjectInstanceSavedStateList
Definition: ObjectMgr.h:1637

References GameobjectInstanceSavedStateList.

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
7038{
7039 if (_auctionId >= 0xFFFFFFFE)
7040 {
7041 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
7043 }
7044 return _auctionId++;
7045}
@ 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 ( )
7069{
7070 if (_creatureSpawnId >= uint32(0xFFFFFF))
7071 {
7072 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7074 }
7075 return _creatureSpawnId++;
7076}

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

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
7048{
7049 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
7050 {
7051 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
7053 }
7054 return _equipmentSetGuid++;
7055}
std::uint64_t uint64
Definition: Define.h:107

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

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7079{
7080 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7081 {
7082 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7084 }
7085 return _gameObjectSpawnId++;
7086}

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

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
7058{
7059 if (_mailId >= 0xFFFFFFFE)
7060 {
7061 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
7063 }
7064 std::lock_guard<std::mutex> guard(_mailIdMutex);
7065 return _mailId++;
7066}
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)
7545{
7546 std::vector<std::string>& list0 = _petHalfName0[entry];
7547 std::vector<std::string>& list1 = _petHalfName1[entry];
7548
7549 if (list0.empty() || list1.empty())
7550 {
7551 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
7552 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
7553 if (!petname)
7554 return cinfo->Name;
7555
7556 return std::string(petname);
7557 }
7558
7559 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7560}
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 
)
7532{
7533 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
7534 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
7535
7536 if (list0.empty() || list1.empty())
7537 {
7538 return GeneratePetName(entry);
7539 }
7540
7541 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7542}
HalfNameContainerLocale _petHalfLocaleName0
Definition: ObjectMgr.h:1566
HalfNameContainerLocale _petHalfLocaleName1
Definition: ObjectMgr.h:1567
std::string GeneratePetName(uint32 entry)
Definition: ObjectMgr.cpp:7544

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

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
7563{
7564 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
7565 return ++_hiPetNumber;
7566}
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
8638{
8639 if (AcoreString const* ts = GetAcoreString(entry))
8640 {
8641 if (ts->Content.size() > size_t(locale) && !ts->Content[locale].empty())
8642 return ts->Content[locale].c_str();
8643
8644 return ts->Content[DEFAULT_LOCALE].c_str();
8645 }
8646
8647 LOG_ERROR("sql.sql", "Acore string entry {} not found in DB.", entry);
8648
8649 return "<error>";
8650}
#define DEFAULT_LOCALE
Definition: Common.h:88
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)
8730{
8731 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
8732 if (i != _areaTriggerScriptStore.end())
8733 return i->second;
8734 return 0;
8735}
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 
)
8744{
8745 if (!factionEntry)
8746 return 0;
8747
8748 uint32 raceMask = (1 << (race - 1));
8749 uint32 classMask = (1 << (playerClass - 1));
8750
8751 for (int i = 0; i < 4; i++)
8752 {
8753 if ((!factionEntry->BaseRepClassMask[i] ||
8754 factionEntry->BaseRepClassMask[i] & classMask) &&
8755 (!factionEntry->BaseRepRaceMask[i] ||
8756 factionEntry->BaseRepRaceMask[i] & raceMask))
8757 return factionEntry->BaseRepValue[i];
8758 }
8759
8760 return 0;
8761}

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

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
7473{
7474 return _baseXPTable[level] ? _baseXPTable[level] : 0;
7475}
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)
1505{
1506 CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid);
1507 if (itr != _creatureAddonStore.end())
1508 return &(itr->second);
1509
1510 return nullptr;
1511}
CreatureAddonContainer _creatureAddonStore
Definition: ObjectMgr.h:1580

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
9641{
9642 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
9643
9644 if (it != _creatureBaseStatsStore.end())
9645 return &(it->second);
9646
9647 struct DefaultCreatureBaseStats : public CreatureBaseStats
9648 {
9649 DefaultCreatureBaseStats()
9650 {
9651 BaseArmor = 1;
9652 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
9653 {
9654 BaseHealth[j] = 1;
9655 BaseDamage[j] = 0.0f;
9656 }
9657 BaseMana = 0;
9658 AttackPower = 0;
9659 RangedAttackPower = 0;
9660 }
9661 };
9662 static const DefaultCreatureBaseStats defStats;
9663 return &defStats;
9664}
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
1709{
1710 CreatureModelContainer::const_iterator itr = _creatureModelStore.find(modelId);
1711 if (itr != _creatureModelStore.end())
1712 return &(itr->second);
1713
1714 return nullptr;
1715}
CreatureModelContainer _creatureModelStore
Definition: ObjectMgr.h:1579

References _creatureModelStore.

Referenced by CheckCreatureTemplate(), and GetCreatureModelRandomGender().

◆ GetCreatureModelRandomGender()

CreatureModelInfo const * ObjectMgr::GetCreatureModelRandomGender ( uint32 displayID)
1746{
1747 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(*displayID);
1748 if (!modelInfo)
1749 return nullptr;
1750
1751 // If a model for another gender exists, 50% chance to use it
1752 if (modelInfo->modelid_other_gender != 0 && urand(0, 1) == 0)
1753 {
1754 CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender);
1755 if (!minfo_tmp)
1756 LOG_ERROR("sql.sql", "Model (Entry: {}) has modelid_other_gender {} not found in table `creature_model_info`. ", *displayID, modelInfo->modelid_other_gender);
1757 else
1758 {
1759 // Model ID changed
1760 *displayID = modelInfo->modelid_other_gender;
1761 return minfo_tmp;
1762 }
1763 }
1764
1765 return modelInfo;
1766}
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
1523{
1525}
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)
1514{
1515 CreatureAddonContainer::const_iterator itr = _creatureTemplateAddonStore.find(entry);
1516 if (itr != _creatureTemplateAddonStore.end())
1517 return &(itr->second);
1518
1519 return nullptr;
1520}
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 
)
1528{
1529 EquipmentInfoContainer::const_iterator itr = _equipmentInfoStore.find(entry);
1530 if (itr == _equipmentInfoStore.end())
1531 return nullptr;
1532
1533 if (itr->second.empty())
1534 return nullptr;
1535
1536 if (id == -1) // select a random element
1537 {
1538 EquipmentInfoContainerInternal::const_iterator ritr = itr->second.begin();
1539 std::advance(ritr, urand(0u, itr->second.size() - 1));
1540 id = std::distance(itr->second.begin(), ritr) + 1;
1541 return &ritr->second;
1542 }
1543 else
1544 {
1545 EquipmentInfoContainerInternal::const_iterator itr2 = itr->second.find(id);
1546 if (itr2 != itr->second.end())
1547 return &itr2->second;
1548 }
1549
1550 return nullptr;
1551}
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)
1496{
1497 GameObjectAddonContainer::const_iterator itr = _gameObjectAddonStore.find(lowguid);
1498 if (itr != _gameObjectAddonStore.end())
1499 return &(itr->second);
1500
1501 return nullptr;
1502}
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)
9965{
9966 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
9967 if (itr != _gameObjectTemplateStore.end())
9968 return &(itr->second);
9969
9970 return nullptr;
9971}
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
9980{
9981 auto itr = _gameObjectTemplateAddonStore.find(entry);
9982 if (itr != _gameObjectTemplateAddonStore.end())
9983 return &itr->second;
9984
9985 return nullptr;
9986}
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
8849{
8850 // explicit name case
8851 std::wstring wname;
8852 if (!Utf8toWStr(name, wname))
8853 return nullptr;
8854
8855 // converting string that we try to find to lower case
8856 wstrToLower(wname);
8857
8858 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
8859 const GameTele* alt = nullptr;
8860 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
8861 {
8862 if (itr->second.wnameLow == wname)
8863 return &itr->second;
8864 else if (!alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
8865 alt = &itr->second;
8866 }
8867
8868 return alt;
8869}
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
6937{
6938 bool useParentDbValue = false;
6939 uint32 parentId = 0;
6940 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
6941 if (!mapEntry || mapEntry->entrance_map < 0)
6942 return nullptr;
6943
6944 if (mapEntry->IsDungeon())
6945 {
6946 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
6947
6948 if (!iTemplate)
6949 return nullptr;
6950
6951 parentId = iTemplate->Parent;
6952 useParentDbValue = true;
6953 }
6954
6955 uint32 entrance_map = uint32(mapEntry->entrance_map);
6956 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6957 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
6958 {
6959 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
6960 if (atEntry && atEntry->map == Map)
6961 return &itr->second;
6962 }
6963 return nullptr;
6964}
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:273
uint32 Parent
Definition: Map.h:274
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
5991{
5992 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
5993 if (itr != _gossipTextStore.end())
5994 return &itr->second;
5995 return nullptr;
5996}
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 
)
10188{
10189 for (auto it = GameobjectInstanceSavedStateList.begin(); it != GameobjectInstanceSavedStateList.end(); it++)
10190 {
10191 if (it->m_guid == guid && it->m_instance == id)
10192 {
10193 return it->m_state;
10194 }
10195 }
10196 return 3; // Any state higher than 2 to get the default state
10197}

References GameobjectInstanceSavedStateList.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
5897{
5898 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
5899 if (itr != _instanceTemplateStore.end())
5900 return &(itr->second);
5901
5902 return nullptr;
5903}
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)
3316{
3317 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3318}
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

6970{
6971 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
6972 {
6973 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
6974 {
6975 // xinef: no need to check, already done at loading
6976 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
6977 //if (atEntry)
6978 return &itr->second;
6979 }
6980 }
6981 return nullptr;
6982}

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 
)
6556{
6557 bool found = false;
6558 float dist = 10000;
6559 uint32 id = 0;
6560
6561 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
6562 {
6563 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
6564
6565 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
6566 continue;
6567
6568 uint8 field = (uint8)((i - 1) / 32);
6569 uint32 submask = 1 << ((i - 1) % 32);
6570
6571 // skip not taxi network nodes
6572 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
6573 {
6574 continue;
6575 }
6576
6577 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
6578 if (found)
6579 {
6580 if (dist2 < dist)
6581 {
6582 dist = dist2;
6583 id = i;
6584 }
6585 }
6586 else
6587 {
6588 found = true;
6589 dist = dist2;
6590 id = i;
6591 }
6592 }
6593
6594 return id;
6595}
TaxiMask sTaxiNodesMask
Definition: DBCStores.cpp:175
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
static constexpr size_t TaxiMaskSize
Definition: DBCStructure.h:2246
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732
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)
5817{
5818 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
5819 if (itr != _pageTextStore.end())
5820 return &(itr->second);
5821
5822 return nullptr;
5823}
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
3626{
3627 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3628 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
3629
3630 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
3631 if (itr == _petInfoStore.end())
3632 return nullptr;
3633
3634 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
3635}

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
4344{
4345 if (level < 1 || class_ >= MAX_CLASSES)
4346 return;
4347
4348 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4349
4350 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4351 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4352
4353 *info = pInfo->levelInfo[level - 1];
4354}
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
10011{
10012 if (race >= MAX_RACES)
10013 return nullptr;
10014 if (class_ >= MAX_CLASSES)
10015 return nullptr;
10016 PlayerInfo const* info = _playerInfo[race][class_];
10017 if (!info)
10018 return nullptr;
10019 return info;
10020}
Definition: Player.h:336

References _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ GetPlayerLevelInfo()

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

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
6291{
6292 uint32 typeIndex;
6293 if (type == TYPEID_UNIT)
6294 typeIndex = 0;
6295 else if (type == TYPEID_GAMEOBJECT)
6296 typeIndex = 1;
6297 else
6298 return nullptr;
6299
6301}
@ 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
10147{
10148 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
10149 {
10150 auto const& itr = _questMoneyRewards.find(level);
10151 if (itr != _questMoneyRewards.end())
10152 {
10153 return itr->second.at(questMoneyDifficulty);
10154 }
10155 }
10156
10157 return 0;
10158}
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)
9501{
9502 // use binary search to find the script name in the sorted vector
9503 // assume "" is the first element
9504 if (name.empty())
9505 return 0;
9506
9507 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
9508 if (itr == _scriptNamesStore.end() || (*itr != name))
9509 return 0;
9510
9511 return uint32(itr - _scriptNamesStore.begin());
9512}
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
9495{
9496 static std::string const empty = "";
9497 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
9498}

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)
8738{
8739 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
8740}
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 
)
6622{
6623 uint32 mount_id = 0;
6624
6625 // select mount creature id
6626 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
6627 if (node)
6628 {
6629 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
6630
6631 // Fix for Alliance not being able to use Acherus taxi
6632 // only one mount type for both sides
6633 if (mount_entry == 0 && allowed_alt_team)
6634 {
6635 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
6636 mount_entry = node->MountCreatureID[teamId];
6637 }
6638
6639 CreatureTemplate const* mount_info = GetCreatureTemplate(mount_entry);
6640 if (mount_info)
6641 {
6642 mount_id = mount_info->GetRandomValidModelId();
6643 if (!mount_id)
6644 {
6645 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
6646 return 0;
6647 }
6648 }
6649 }
6650
6651 // minfo is not actually used but the mount_id was updated
6653
6654 return mount_id;
6655}
uint32 GetRandomValidModelId() const
Definition: Creature.cpp:120
CreatureModelInfo const * GetCreatureModelRandomGender(uint32 *displayID)
Definition: ObjectMgr.cpp:1745

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 
)
6598{
6599 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
6600 if (src_i == sTaxiPathSetBySource.end())
6601 {
6602 path = 0;
6603 cost = 0;
6604 return;
6605 }
6606
6607 TaxiPathSetForSource& pathSet = src_i->second;
6608
6609 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
6610 if (dest_i == pathSet.end())
6611 {
6612 path = 0;
6613 cost = 0;
6614 return;
6615 }
6616
6617 cost = dest_i->second->price;
6618 path = dest_i->second->ID;
6619}
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
9994{
9995 if (Creature* cre = veh->GetBase()->ToCreature())
9996 {
9997 // Give preference to GUID-based accessories
9998 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
9999 if (itr != _vehicleAccessoryStore.end())
10000 return &itr->second;
10001 }
10002
10003 // Otherwise return entry-based
10004 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
10005 if (itr != _vehicleTemplateAccessoryStore.end())
10006 return &itr->second;
10007 return nullptr;
10008}
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
7478{
7479 if (level < _playerXPperLevel.size())
7480 return _playerXPperLevel[level];
7481 return 0;
7482}
PlayerXPperLevel _playerXPperLevel
Definition: ObjectMgr.h:1554

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
5764{
5765 uint32 limit = sSpellStore.GetNumRows();
5766 for(uint32 i = 0; i <= limit; ++i)
5767 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
5768 {
5769 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
5770 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
5771 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
5772 }
5773}
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
9974{
9975 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
9976 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
9977}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition: SharedDefines.h:1543

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

◆ IsProfanityName()

bool ObjectMgr::IsProfanityName ( std::string_view  name) const
8276{
8277 // pussywizard
8278 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8279 return true;
8280
8281 std::wstring wstr;
8282 if (!Utf8toWStr (name, wstr))
8283 return false;
8284
8285 wstrToLower(wstr);
8286
8287 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
8288}

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

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
8201{
8202 // pussywizard
8203 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8204 return true;
8205
8206 std::wstring wstr;
8207 if (!Utf8toWStr (name, wstr))
8208 return false;
8209
8210 wstrToLower(wstr);
8211
8212 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
8213}

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
8480{
8481 std::wstring wname;
8482 if (!Utf8toWStr(name, wname))
8483 return false;
8484
8485 if (wname.size() > MAX_CHANNEL_NAME)
8486 return false;
8487
8488 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
8489
8490 return isValidString(wname, strictMask, true);
8491}
#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
8444{
8445 std::wstring wname;
8446 if (!Utf8toWStr(name, wname))
8447 return false;
8448
8449 if (wname.size() > MAX_CHARTER_NAME)
8450 return false;
8451
8452 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
8453 if (wname.size() < minName)
8454 return false;
8455
8456 // Check for Reserved Name from DBC
8457 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8458 {
8459 if (ReservedNames(wname))
8460 {
8461 return false;
8462 }
8463 }
8464
8465 // Check for Profanity
8466 if (sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8467 {
8468 if (ProfanityNames(wname))
8469 {
8470 return false;
8471 }
8472 }
8473
8474 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
8475
8476 return isValidString(wname, strictMask, true);
8477}
#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
9359{
9360 /*
9361 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry);
9362 if (!cInfo)
9363 {
9364 if (player)
9365 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9366 else
9367 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
9368 return false;
9369 }
9370
9371 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
9372 {
9373 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
9374 {
9375 if (player)
9376 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9377 else
9378 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
9379
9380 if (skip_vendors)
9381 skip_vendors->insert(vendor_entry);
9382 }
9383 return false;
9384 }
9385 */
9386
9387 if (!sObjectMgr->GetItemTemplate(item_id))
9388 {
9389 if (player)
9391 else
9392 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
9393 return false;
9394 }
9395
9396 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
9397 {
9398 if (player)
9400 else
9401 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
9402 return false;
9403 }
9404
9405 if (maxcount > 0 && incrtime == 0)
9406 {
9407 if (player)
9408 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount);
9409 else
9410 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);
9411 return false;
9412 }
9413 else if (maxcount == 0 && incrtime > 0)
9414 {
9415 if (player)
9416 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
9417 else
9418 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);
9419 return false;
9420 }
9421
9422 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
9423 if (!vItems)
9424 return true; // later checks for non-empty lists
9425
9426 if (vItems->FindItemCostPair(item_id, ExtendedCost))
9427 {
9428 if (player)
9429 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
9430 else
9431 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
9432 return false;
9433 }
9434
9435 return true;
9436}
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:112
WorldSession * GetSession() const
Definition: Player.h:1958
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 ( )
6769{
6770 uint32 oldMSTime = getMSTime();
6771
6772 if (!_accessRequirementStore.empty())
6773 {
6774 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
6775 {
6776 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
6777 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
6778 {
6779 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
6780 {
6781 delete* questItr;
6782 }
6783
6784 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
6785 {
6786 delete* achievementItr;
6787 }
6788
6789 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
6790 {
6791 delete* itemsItr;
6792 }
6793
6794 delete difficultiesItr->second;
6795 }
6796 }
6797
6798 _accessRequirementStore.clear(); // need for reload case
6799 }
6800 // 0 1 2 3 4 5
6801 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
6802 if (!access_template_result)
6803 {
6804 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
6805 LOG_INFO("server.loading", " ");
6806 return;
6807 }
6808
6809 uint32 count = 0;
6810 uint32 countProgressionRequirements = 0;
6811
6812 do
6813 {
6814 Field* fields = access_template_result->Fetch();
6815
6816 //Get the common variables for the access requirements
6817 uint8 dungeon_access_id = fields[0].Get<uint8>();
6818 uint32 mapid = fields[1].Get<uint32>();
6819 uint8 difficulty = fields[2].Get<uint8>();
6820
6821 //Set up the access requirements
6823 ar->levelMin = fields[3].Get<uint8>();
6824 ar->levelMax = fields[4].Get<uint8>();
6825 ar->reqItemLevel = fields[5].Get<uint16>();
6826
6827 // 0 1 2 3 4 6
6828 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);
6829 if (progression_requirements_results)
6830 {
6831 do
6832 {
6833 Field* progression_requirement_row = progression_requirements_results->Fetch();
6834
6835 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
6836 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
6837 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
6838 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
6839 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
6840 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
6841
6842 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
6843 progression_requirement->id = requirement_id;
6844 progression_requirement->note = requirement_note;
6845 progression_requirement->faction = (TeamId)requirement_faction;
6846 progression_requirement->priority = requirement_priority;
6847 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
6848
6849 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
6850
6851 switch (requirement_type)
6852 {
6853 case 0:
6854 {
6855 //Achievement
6856 if (!sAchievementStore.LookupEntry(progression_requirement->id))
6857 {
6858 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);
6859 break;
6860 }
6861
6862 currentRequirementsList = &ar->achievements;
6863 break;
6864 }
6865 case 1:
6866 {
6867 //Quest
6868 if (!GetQuestTemplate(progression_requirement->id))
6869 {
6870 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);
6871 break;
6872 }
6873
6874 currentRequirementsList = &ar->quests;
6875 break;
6876 }
6877 case 2:
6878 {
6879 //Item
6880 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
6881 if (!pProto)
6882 {
6883 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);
6884 break;
6885 }
6886
6887 currentRequirementsList = &ar->items;
6888 break;
6889 }
6890 default:
6891 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);
6892 break;
6893 }
6894
6895 //Check if array is valid and delete the progression requirement
6896 if (!currentRequirementsList)
6897 {
6898 delete progression_requirement;
6899 continue;
6900 }
6901
6902 //Insert into the array
6903 if (currentRequirementsList->size() > requirement_priority)
6904 {
6905 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
6906 }
6907 else
6908 {
6909 currentRequirementsList->push_back(progression_requirement);
6910 }
6911
6912 } while (progression_requirements_results->NextRow());
6913 }
6914
6915 //Sort all arrays for priority
6916 auto sortFunction = [](const ProgressionRequirement* const a, const ProgressionRequirement* const b) {return a->priority > b->priority; };
6917 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
6918 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
6919 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
6920
6921 countProgressionRequirements += ar->achievements.size();
6922 countProgressionRequirements += ar->quests.size();
6923 countProgressionRequirements += ar->items.size();
6924 count++;
6925
6926 _accessRequirementStore[mapid][difficulty] = ar;
6927 } while (access_template_result->NextRow());
6928
6929 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
6930 LOG_INFO("server.loading", " ");
6931}
#define LOG_WARN(filterType__,...)
Definition: Log.h:163
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:731
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:3315
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 ( )
8605{
8606 uint32 oldMSTime = getMSTime();
8607
8608 _acoreStringStore.clear(); // for reload case
8609 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");
8610 if (!result)
8611 {
8612 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty.");
8613 LOG_INFO("server.loading", " ");
8614 return false;
8615 }
8616
8617 do
8618 {
8619 Field* fields = result->Fetch();
8620
8621 uint32 entry = fields[0].Get<uint32>();
8622
8623 AcoreString& data = _acoreStringStore[entry];
8624
8625 data.Content.resize(DEFAULT_LOCALE + 1);
8626
8627 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
8628 AddLocaleString(fields[i + 1].Get<std::string>(), LocaleConstant(i), data.Content);
8629 } while (result->NextRow());
8630
8631 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8632 LOG_INFO("server.loading", " ");
8633
8634 return true;
8635}
LocaleConstant
Definition: Common.h:74
@ TOTAL_LOCALES
Definition: Common.h:85
static void AddLocaleString(std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
Definition: ObjectMgr.cpp:438

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

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
6658{
6659 uint32 oldMSTime = getMSTime();
6660
6661 _areaTriggerStore.clear();
6662
6663 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
6664
6665 if (!result)
6666 {
6667 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
6668 LOG_INFO("server.loading", " ");
6669 return;
6670 }
6671
6672 uint32 count = 0;
6673
6674 do
6675 {
6676 Field* fields = result->Fetch();
6677
6678 ++count;
6679
6680 AreaTrigger at;
6681
6682 at.entry = fields[0].Get<uint32>();
6683 at.map = fields[1].Get<uint32>();
6684 at.x = fields[2].Get<float>();
6685 at.y = fields[3].Get<float>();
6686 at.z = fields[4].Get<float>();
6687 at.radius = fields[5].Get<float>();
6688 at.length = fields[6].Get<float>();
6689 at.width = fields[7].Get<float>();
6690 at.height = fields[8].Get<float>();
6691 at.orientation = fields[9].Get<float>();
6692
6693 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
6694 if (!mapEntry)
6695 {
6696 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
6697 continue;
6698 }
6699
6700 _areaTriggerStore[at.entry] = at;
6701 } while (result->NextRow());
6702
6703 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6704 LOG_INFO("server.loading", " ");
6705}
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 ( )
6518{
6519 uint32 oldMSTime = getMSTime();
6520
6521 _areaTriggerScriptStore.clear(); // need for reload case
6522 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
6523
6524 if (!result)
6525 {
6526 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
6527 LOG_INFO("server.loading", " ");
6528 return;
6529 }
6530
6531 uint32 count = 0;
6532
6533 do
6534 {
6535 ++count;
6536
6537 Field* fields = result->Fetch();
6538
6539 uint32 Trigger_ID = fields[0].Get<uint32>();
6540 std::string scriptName = fields[1].Get<std::string>();
6541
6542 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6543 if (!atEntry)
6544 {
6545 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6546 continue;
6547 }
6548 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
6549 } while (result->NextRow());
6550
6551 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6552 LOG_INFO("server.loading", " ");
6553}
uint32 GetScriptId(std::string const &name)
Definition: ObjectMgr.cpp:9500

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

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
6708{
6709 uint32 oldMSTime = getMSTime();
6710
6711 _areaTriggerTeleportStore.clear(); // need for reload case
6712
6713 // 0 1 2 3 4 5
6714 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
6715
6716 if (!result)
6717 {
6718 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
6719 LOG_INFO("server.loading", " ");
6720 return;
6721 }
6722
6723 uint32 count = 0;
6724
6725 do
6726 {
6727 Field* fields = result->Fetch();
6728
6729 ++count;
6730
6731 uint32 Trigger_ID = fields[0].Get<uint32>();
6732
6734
6735 at.target_mapId = fields[1].Get<uint16>();
6736 at.target_X = fields[2].Get<float>();
6737 at.target_Y = fields[3].Get<float>();
6738 at.target_Z = fields[4].Get<float>();
6739 at.target_Orientation = fields[5].Get<float>();
6740
6741 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6742 if (!atEntry)
6743 {
6744 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6745 continue;
6746 }
6747
6748 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
6749 if (!mapEntry)
6750 {
6751 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
6752 continue;
6753 }
6754
6755 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
6756 {
6757 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
6758 continue;
6759 }
6760
6761 _areaTriggerTeleportStore[Trigger_ID] = at;
6762 } while (result->NextRow());
6763
6764 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6765 LOG_INFO("server.loading", " ");
6766}
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 ( )
9600{
9601 uint32 oldMSTime = getMSTime();
9602
9603 // 0 1 2 3
9604 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
9605
9606 if (!result)
9607 {
9608 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
9609 LOG_INFO("server.loading", " ");
9610 return;
9611 }
9612
9613 uint32 locales_count = 0;
9614 do
9615 {
9616 Field* fields = result->Fetch();
9617
9618 uint32 id = fields[0].Get<uint32>();
9619
9620 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
9621 if (bct == _broadcastTextStore.end())
9622 {
9623 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
9624 continue;
9625 }
9626
9627 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
9628 if (locale == LOCALE_enUS)
9629 continue;
9630
9631 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
9632 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
9633 locales_count++;
9634 } while (result->NextRow());
9635
9636 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
9637 LOG_INFO("server.loading", " ");
9638}
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 ( )
9515{
9516 uint32 oldMSTime = getMSTime();
9517
9518 _broadcastTextStore.clear(); // for reload case
9519
9520 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9521 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
9522 if (!result)
9523 {
9524 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
9525 LOG_INFO("server.loading", " ");
9526 return;
9527 }
9528
9529 _broadcastTextStore.rehash(result->GetRowCount());
9530
9531 do
9532 {
9533 Field* fields = result->Fetch();
9534
9535 BroadcastText bct;
9536
9537 bct.Id = fields[0].Get<uint32>();
9538 bct.LanguageID = fields[1].Get<uint32>();
9539 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
9540 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
9541 bct.EmoteId1 = fields[4].Get<uint32>();
9542 bct.EmoteId2 = fields[5].Get<uint32>();
9543 bct.EmoteId3 = fields[6].Get<uint32>();
9544 bct.EmoteDelay1 = fields[7].Get<uint32>();
9545 bct.EmoteDelay2 = fields[8].Get<uint32>();
9546 bct.EmoteDelay3 = fields[9].Get<uint32>();
9547 bct.SoundEntriesId = fields[10].Get<uint32>();
9548 bct.EmotesID = fields[11].Get<uint32>();
9549 bct.Flags = fields[12].Get<uint32>();
9550
9551 if (bct.SoundEntriesId)
9552 {
9553 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
9554 {
9555 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
9556 bct.SoundEntriesId = 0;
9557 }
9558 }
9559
9561 {
9562 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
9564 }
9565
9566 if (bct.EmoteId1)
9567 {
9568 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
9569 {
9570 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
9571 bct.EmoteId1 = 0;
9572 }
9573 }
9574
9575 if (bct.EmoteId2)
9576 {
9577 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
9578 {
9579 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
9580 bct.EmoteId2 = 0;
9581 }
9582 }
9583
9584 if (bct.EmoteId3)
9585 {
9586 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
9587 {
9588 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
9589 bct.EmoteId3 = 0;
9590 }
9591 }
9592
9593 _broadcastTextStore[bct.Id] = bct;
9594 } while (result->NextRow());
9595
9596 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
9597}
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition: ObjectMgr.cpp:309
@ LANG_UNIVERSAL
Definition: SharedDefines.h:707
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 ( )
1343{
1344 uint32 oldMSTime = getMSTime();
1345
1346 // 0 1 2 3 4 5 6 7
1347 QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_addon");
1348
1349 if (!result)
1350 {
1351 LOG_WARN("server.loading", ">> Loaded 0 creature addon definitions. DB table `creature_addon` is empty.");
1352 LOG_INFO("server.loading", " ");
1353 return;
1354 }
1355
1356 uint32 count = 0;
1357 do
1358 {
1359 Field* fields = result->Fetch();
1360
1361 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1362
1363 CreatureData const* creData = GetCreatureData(guid);
1364 if (!creData)
1365 {
1366 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_addon`", guid);
1367 continue;
1368 }
1369
1370 CreatureAddon& creatureAddon = _creatureAddonStore[guid];
1371
1372 creatureAddon.path_id = fields[1].Get<uint32>();
1373 if (creData->movementType == WAYPOINT_MOTION_TYPE && !creatureAddon.path_id)
1374 {
1375 const_cast<CreatureData*>(creData)->movementType = IDLE_MOTION_TYPE;
1376 LOG_ERROR("sql.sql", "Creature (GUID {}) has movement type set to WAYPOINT_MOTION_TYPE but no path assigned", guid);
1377 }
1378
1379 creatureAddon.mount = fields[2].Get<uint32>();
1380 creatureAddon.bytes1 = fields[3].Get<uint32>();
1381 creatureAddon.bytes2 = fields[4].Get<uint32>();
1382 creatureAddon.emote = fields[5].Get<uint32>();
1383 creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].Get<uint8>());
1384
1385 for (std::string_view aura : Acore::Tokenize(fields[7].Get<std::string_view>(), ' ', false))
1386 {
1387 SpellInfo const* spellInfo = nullptr;
1388
1389 if (Optional<uint32> spellId = Acore::StringTo<uint32>(aura))
1390 {
1391 spellInfo = sSpellMgr->GetSpellInfo(*spellId);
1392 }
1393
1394 if (!spellInfo)
1395 {
1396 LOG_ERROR("sql.sql", "Creature (GUID: {}) has wrong spell '{}' defined in `auras` field in `creature_addon`.", guid, aura);
1397 continue;
1398 }
1399
1400 if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
1401 {
1402 LOG_ERROR("sql.sql", "Creature (GUID: {}) has duplicate aura (spell {}) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
1403 continue;
1404 }
1405
1406 if (spellInfo->GetDuration() > 0)
1407 {
1408 LOG_DEBUG/*ERROR*/("sql.sql", "Creature (Entry: {}) has temporary aura (spell {}) in `auras` field in `creature_template_addon`.", guid, spellInfo->Id);
1409 // continue;
1410 }
1411
1412 creatureAddon.auras.push_back(spellInfo->Id);
1413 }
1414
1415 if (creatureAddon.mount)
1416 {
1417 if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
1418 {
1419 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid displayInfoId ({}) for mount defined in `creature_addon`", guid, creatureAddon.mount);
1420 creatureAddon.mount = 0;
1421 }
1422 }
1423
1424 if (!sEmotesStore.LookupEntry(creatureAddon.emote))
1425 {
1426 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid emote ({}) defined in `creature_addon`.", guid, creatureAddon.emote);
1427 creatureAddon.emote = 0;
1428 }
1429
1430 if (creatureAddon.visibilityDistanceType >= VisibilityDistanceType::Max)
1431 {
1432 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid visibilityDistanceType ({}) defined in `creature_addon`.", guid, AsUnderlyingType(creatureAddon.visibilityDistanceType));
1433 creatureAddon.visibilityDistanceType = VisibilityDistanceType::Normal;
1434 }
1435
1436 ++count;
1437 } while (result->NextRow());
1438
1439 LOG_INFO("server.loading", ">> Loaded {} Creature Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1440 LOG_INFO("server.loading", " ");
1441}
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:2322

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 ( )
9667{
9668 uint32 oldMSTime = getMSTime();
9669
9670 QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2 FROM creature_classlevelstats");
9671
9672 if (!result)
9673 {
9674 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
9675 LOG_INFO("server.loading", " ");
9676 return;
9677 }
9678
9679 uint32 count = 0;
9680 do
9681 {
9682 Field* fields = result->Fetch();
9683
9684 uint8 Level = fields[0].Get<uint8>();
9685 uint8 Class = fields[1].Get<uint8>();
9686
9687 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
9688 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
9689
9690 CreatureBaseStats stats;
9691
9692 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
9693 {
9694 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
9695
9696 if (stats.BaseHealth[i] == 0)
9697 {
9698 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
9699 stats.BaseHealth[i] = 1;
9700 }
9701
9702 // xinef: if no data is available, get them from lower expansions
9703 if (stats.BaseHealth[i] <= 1)
9704 {
9705 for (uint8 j = i; j > 0;)
9706 {
9707 --j;
9708 if (stats.BaseHealth[j] > 1)
9709 {
9710 stats.BaseHealth[i] = stats.BaseHealth[j];
9711 break;
9712 }
9713 }
9714 }
9715
9716 stats.BaseDamage[i] = fields[9 + i].Get<float>();
9717 if (stats.BaseDamage[i] < 0.0f)
9718 {
9719 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
9720 stats.BaseDamage[i] = 0.0f;
9721 }
9722 }
9723
9724 stats.BaseMana = fields[5].Get<uint32>();
9725 stats.BaseArmor = fields[6].Get<uint32>();
9726
9727 stats.AttackPower = fields[7].Get<uint32>();
9728 stats.RangedAttackPower = fields[8].Get<uint32>();
9729
9730 _creatureBaseStatsStore[MAKE_PAIR16(Level, Class)] = stats;
9731
9732 ++count;
9733 } while (result->NextRow());
9734
9735 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
9736 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
9737 {
9738 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
9739 {
9740 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
9741 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
9742 }
9743 }
9744
9745 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9746 LOG_INFO("server.loading", " ");
9747}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: CreatureData.h:281
uint32 BaseMana
Definition: CreatureData.h:294
uint32 BaseArmor
Definition: CreatureData.h:295
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

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.

946{
947 // Hack for modules
948 std::string stringCreatureIds = sConfigMgr->GetOption<std::string>("Creatures.CustomIDs", "");
949 std::vector<std::string_view> CustomCreatures = Acore::Tokenize(stringCreatureIds, ',', false);
950
951 for (auto& itr : CustomCreatures)
952 {
953 _creatureCustomIDsStore.push_back(Acore::StringTo<uint32>(itr).value());
954 }
955}
#define sConfigMgr
Definition: Config.h:95

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

◆ LoadCreatureLocales()

void ObjectMgr::LoadCreatureLocales ( )
450{
451 uint32 oldMSTime = getMSTime();
452
453 _creatureLocaleStore.clear(); // need for reload case
454
455 // 0 1 2 3
456 QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale");
457 if (!result)
458 return;
459
460 do
461 {
462 Field* fields = result->Fetch();
463
464 uint32 ID = fields[0].Get<uint32>();
465
466 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
467 if (locale == LOCALE_enUS)
468 continue;
469
471 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
472 AddLocaleString(fields[3].Get<std::string>(), locale, data.Title);
473 } while (result->NextRow());
474
475 LOG_INFO("server.loading", ">> Loaded {} Creature Locale Strings in {} ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
476}
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 ( )
1769{
1770 uint32 oldMSTime = getMSTime();
1771
1772 // 0 1 2 3 4
1773 QueryResult result = WorldDatabase.Query("SELECT DisplayID, BoundingRadius, CombatReach, Gender, DisplayID_Other_Gender FROM creature_model_info");
1774
1775 if (!result)
1776 {
1777 LOG_WARN("server.loading", ">> Loaded 0 creature model definitions. DB table `creature_model_info` is empty.");
1778 LOG_INFO("server.loading", " ");
1779 return;
1780 }
1781
1782 _creatureModelStore.rehash(result->GetRowCount());
1783 uint32 count = 0;
1784
1785 do
1786 {
1787 Field* fields = result->Fetch();
1788
1789 uint32 modelId = fields[0].Get<uint32>();
1790
1791 CreatureModelInfo& modelInfo = _creatureModelStore[modelId];
1792
1793 modelInfo.bounding_radius = fields[1].Get<float>();
1794 modelInfo.combat_reach = fields[2].Get<float>();
1795 modelInfo.gender = fields[3].Get<uint8>();
1796 modelInfo.modelid_other_gender = fields[4].Get<uint32>();
1797
1798 // Checks
1799
1800 if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
1801 LOG_ERROR("sql.sql", "Table `creature_model_info` has model for not existed display id ({}).", modelId);
1802
1803 if (modelInfo.gender > GENDER_NONE)
1804 {
1805 LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender ({}) for display id ({}).", uint32(modelInfo.gender), modelId);
1806 modelInfo.gender = GENDER_MALE;
1807 }
1808
1809 if (modelInfo.modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.modelid_other_gender))
1810 {
1811 LOG_ERROR("sql.sql", "Table `creature_model_info` has not existed alt.gender model ({}) for existed display id ({}).", modelInfo.modelid_other_gender, modelId);
1812 modelInfo.modelid_other_gender = 0;
1813 }
1814
1815 if (modelInfo.combat_reach < 0.1f)
1816 modelInfo.combat_reach = DEFAULT_COMBAT_REACH;
1817
1818 ++count;
1819 } while (result->NextRow());
1820
1821 LOG_INFO("server.loading", ">> Loaded {} Creature Model Based Info in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1822 LOG_INFO("server.loading", " ");
1823}
#define DEFAULT_COMBAT_REACH
Definition: ObjectDefines.h:46
@ GENDER_MALE
Definition: SharedDefines.h:60
@ GENDER_NONE
Definition: SharedDefines.h:62

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 ( )
1632{
1633 uint32 oldMSTime = getMSTime();
1634
1636
1637 // Load the data from creature_movement_override and if NULL fallback to creature_template_movement
1638 QueryResult result = WorldDatabase.Query("SELECT cmo.SpawnId,"
1639 "COALESCE(cmo.Ground, ctm.Ground),"
1640 "COALESCE(cmo.Swim, ctm.Swim),"
1641 "COALESCE(cmo.Flight, ctm.Flight),"
1642 "COALESCE(cmo.Rooted, ctm.Rooted),"
1643 "COALESCE(cmo.Chase, ctm.Chase),"
1644 "COALESCE(cmo.Random, ctm.Random),"
1645 "COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) "
1646 "FROM creature_movement_override AS cmo "
1647 "LEFT JOIN creature AS c ON c.guid = cmo.SpawnId "
1648 "LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id1");
1649 if (!result)
1650 {
1651 LOG_WARN("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
1652 return;
1653 }
1654
1655 do
1656 {
1657 Field* fields = result->Fetch();
1658 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
1659 if (!GetCreatureData(spawnId))
1660 {
1661 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_movement_override`", spawnId);
1662 continue;
1663 }
1664
1666 if (!fields[1].IsNull())
1667 {
1668 movement.Ground = static_cast<CreatureGroundMovementType>(fields[1].Get<uint8>());
1669 }
1670
1671 if (!fields[2].IsNull())
1672 {
1673 movement.Swim = fields[2].Get<bool>();
1674 }
1675
1676 if (!fields[3].IsNull())
1677 {
1678 movement.Flight = static_cast<CreatureFlightMovementType>(fields[3].Get<uint8>());
1679 }
1680
1681 if (!fields[4].IsNull())
1682 {
1683 movement.Rooted = fields[4].Get<bool>();
1684 }
1685
1686 if (!fields[5].IsNull())
1687 {
1688 movement.Chase = static_cast<CreatureChaseMovementType>(fields[5].Get<uint8>());
1689 }
1690
1691 if (!fields[6].IsNull())
1692 {
1693 movement.Random = static_cast<CreatureRandomMovementType>(fields[6].Get<uint8>());
1694 }
1695
1696 if (!fields[7].IsNull())
1697 {
1698 movement.InteractionPauseTimer = fields[7].Get<uint32>();
1699 }
1700
1701 CheckCreatureMovement("creature_movement_override", spawnId, movement);
1702 } while (result->NextRow());
1703
1704 LOG_INFO("server.loading", ">> Loaded {} Movement Overrides in {} ms", _creatureMovementOverrides.size(), GetMSTimeDiffToNow(oldMSTime));
1705 LOG_INFO("server.loading", " ");
1706}
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 ( )
8147{
8148 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8149
8150 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8151 {
8152 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8153 if (!cInfo)
8154 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8155 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8156 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);
8157 }
8158}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition: Unit.h:517
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition: ObjectMgr.cpp:8059

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
10068{
10069 uint32 oldMSTime = getMSTime();
10070
10071 // 0 1 2
10072 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
10073
10074 if (!result)
10075 {
10076 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
10077 return;
10078 }
10079
10080 uint32 count = 0;
10081 do
10082 {
10083 Field* fields = result->Fetch();
10084
10085 uint32 entry = fields[0].Get<uint32>();
10086 uint32 item = fields[1].Get<uint32>();
10087 uint32 idx = fields[2].Get<uint32>();
10088
10089 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
10090 if (!creatureInfo)
10091 {
10092 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
10093 continue;
10094 };
10095
10096 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10097 if (!dbcData)
10098 {
10099 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
10100 continue;
10101 };
10102
10103 _creatureQuestItemStore[entry].push_back(item);
10104
10105 ++count;
10106 } while (result->NextRow());
10107
10108 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10109 LOG_INFO("server.loading", " ");
10110}
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 ( )
8133{
8134 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8135
8136 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8137 {
8138 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8139 if (!cInfo)
8140 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8141 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8142 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);
8143 }
8144}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

void ObjectMgr::LoadCreatures ( )
2144{
2145 uint32 oldMSTime = getMSTime();
2146
2147 // 0 1 2 3 4 5 6 7 8 9 10 11
2148 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2149 // 12 13 14 15 16 17 18 19 20 21 22
2150 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
2151 // 23
2152 "creature.ScriptName "
2153 "FROM creature "
2154 "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
2155 "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
2156
2157 if (!result)
2158 {
2159 LOG_WARN("server.loading", ">> Loaded 0 creatures. DB table `creature` is empty.");
2160 LOG_INFO("server.loading", " ");
2161 return;
2162 }
2163
2164 // Build single time for check spawnmask
2165 std::map<uint32, uint32> spawnMasks;
2166 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2167 if (sMapStore.LookupEntry(i))
2168 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2170 spawnMasks[i] |= (1 << k);
2171
2172 _creatureDataStore.rehash(result->GetRowCount());
2173 uint32 count = 0;
2174 do
2175 {
2176 Field* fields = result->Fetch();
2177
2178 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2179 uint32 id1 = fields[1].Get<uint32>();
2180 uint32 id2 = fields[2].Get<uint32>();
2181 uint32 id3 = fields[3].Get<uint32>();
2182
2183 CreatureTemplate const* cInfo = GetCreatureTemplate(id1);
2184 if (!cInfo)
2185 {
2186 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id1 field, skipped.", spawnId, id1);
2187 continue;
2188 }
2189 CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2);
2190 if (!cInfo2 && id2)
2191 {
2192 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id2 field, skipped.", spawnId, id2);
2193 continue;
2194 }
2195 CreatureTemplate const* cInfo3 = GetCreatureTemplate(id3);
2196 if (!cInfo3 && id3)
2197 {
2198 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id3 field, skipped.", spawnId, id3);
2199 continue;
2200 }
2201 if (!id2 && id3)
2202 {
2203 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3);
2204 continue;
2205 }
2206 CreatureData& data = _creatureDataStore[spawnId];
2207 data.id1 = id1;
2208 data.id2 = id2;
2209 data.id3 = id3;
2210 data.mapid = fields[4].Get<uint16>();
2211 data.equipmentId = fields[5].Get<int8>();
2212 data.posX = fields[6].Get<float>();
2213 data.posY = fields[7].Get<float>();
2214 data.posZ = fields[8].Get<float>();
2215 data.orientation = fields[9].Get<float>();
2216 data.spawntimesecs = fields[10].Get<uint32>();
2217 data.wander_distance = fields[11].Get<float>();
2218 data.currentwaypoint = fields[12].Get<uint32>();
2219 data.curhealth = fields[13].Get<uint32>();
2220 data.curmana = fields[14].Get<uint32>();
2221 data.movementType = fields[15].Get<uint8>();
2222 data.spawnMask = fields[16].Get<uint8>();
2223 data.phaseMask = fields[17].Get<uint32>();
2224 int16 gameEvent = fields[18].Get<int8>();
2225 uint32 PoolId = fields[19].Get<uint32>();
2226 data.npcflag = fields[20].Get<uint32>();
2227 data.unit_flags = fields[21].Get<uint32>();
2228 data.dynamicflags = fields[22].Get<uint32>();
2229 data.ScriptId = GetScriptId(fields[23].Get<std::string>());
2230
2231 if (!data.ScriptId)
2232 data.ScriptId = cInfo->ScriptID;
2233
2234 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2235 if (!mapEntry)
2236 {
2237 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that spawned at not existed map (Id: {}), skipped.", spawnId, data.mapid);
2238 continue;
2239 }
2240
2241 // pussywizard: 7 days means no reaspawn, so set it to 14 days, because manual id reset may be late
2242 if (mapEntry->IsRaid() && data.spawntimesecs >= 7 * DAY && data.spawntimesecs < 14 * DAY)
2243 data.spawntimesecs = 14 * DAY;
2244
2245 // Skip spawnMask check for transport maps
2246 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2247 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that have wrong spawn mask {} including not supported difficulty modes for map (Id: {}).",
2248 spawnId, data.spawnMask, data.mapid);
2249
2250 bool ok = true;
2251 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2252 {
2253 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()))
2254 {
2255 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.",
2256 spawnId, diff + 1, data.id1, data.id2, data.id3);
2257 ok = false;
2258 }
2259 }
2260 if (!ok)
2261 continue;
2262
2263 // -1 random, 0 no equipment,
2264 if (data.equipmentId != 0)
2265 {
2266 if ((!GetEquipmentInfo(data.id1, data.equipmentId)) || (data.id2 && !GetEquipmentInfo(data.id2, data.equipmentId)) || (data.id3 && !GetEquipmentInfo(data.id3, data.equipmentId)))
2267 {
2268 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.",
2269 data.id1, data.id2, data.id3, data.equipmentId);
2270 data.equipmentId = 0;
2271 }
2272 }
2273 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))
2274 {
2275 if (!mapEntry->IsDungeon())
2276 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.",
2277 spawnId, data.id1, data.id2, data.id3);
2278 }
2279 if (data.movementType >= MAX_DB_MOTION_TYPE)
2280 {
2281 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);
2283 }
2284 if (data.wander_distance < 0.0f)
2285 {
2286 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", spawnId, data.id1, data.id2, data.id3);
2287 data.wander_distance = 0.0f;
2288 }
2289 else if (data.movementType == RANDOM_MOTION_TYPE)
2290 {
2291 if (data.wander_distance == 0.0f)
2292 {
2293 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).",
2294 spawnId, data.id1, data.id2, data.id3);
2296 }
2297 }
2298 else if (data.movementType == IDLE_MOTION_TYPE)
2299 {
2300 if (data.wander_distance != 0.0f)
2301 {
2302 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);
2303 data.wander_distance = 0.0f;
2304 }
2305 }
2306
2307 if (data.phaseMask == 0)
2308 {
2309 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);
2310 data.phaseMask = 1;
2311 }
2312
2314 {
2315 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2316 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2317
2319
2320 stmt->SetData(0, zoneId);
2321 stmt->SetData(1, areaId);
2322 stmt->SetData(2, spawnId);
2323
2324 WorldDatabase.Execute(stmt);
2325 }
2326
2327 // Add to grid if not managed by the game event or pool system
2328 if (gameEvent == 0 && PoolId == 0)
2329 AddCreatureToGrid(spawnId, &data);
2330
2331 ++count;
2332 } while (result->NextRow());
2333
2334 LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2335 LOG_INFO("server.loading", " ");
2336}
constexpr auto DAY
Definition: Common.h:58
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:271
uint32 flags_extra
Definition: CreatureData.h:239
uint32 ScriptId
Definition: CreatureData.h:382
EquipmentInfo const * GetEquipmentInfo(uint32 entry, int8 &id)
Definition: ObjectMgr.cpp:1527
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)
644{
645 uint32 entry = fields[0].Get<uint32>();
646
647 CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry];
648
649 creatureTemplate.Entry = entry;
650
651 for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
652 {
653 creatureTemplate.DifficultyEntry[i] = fields[1 + i].Get<uint32>();
654 }
655
656 for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
657 {
658 creatureTemplate.KillCredit[i] = fields[4 + i].Get<uint32>();
659 }
660
661 creatureTemplate.Modelid1 = fields[6].Get<uint32>();
662 creatureTemplate.Modelid2 = fields[7].Get<uint32>();
663 creatureTemplate.Modelid3 = fields[8].Get<uint32>();
664 creatureTemplate.Modelid4 = fields[9].Get<uint32>();
665 creatureTemplate.Name = fields[10].Get<std::string>();
666 creatureTemplate.SubName = fields[11].Get<std::string>();
667 creatureTemplate.IconName = fields[12].Get<std::string>();
668 creatureTemplate.GossipMenuId = fields[13].Get<uint32>();
669 creatureTemplate.minlevel = fields[14].Get<uint8>();
670 creatureTemplate.maxlevel = fields[15].Get<uint8>();
671 creatureTemplate.expansion = uint32(fields[16].Get<int16>());
672 creatureTemplate.faction = uint32(fields[17].Get<uint16>());
673 creatureTemplate.npcflag = fields[18].Get<uint32>();
674 creatureTemplate.speed_walk = fields[19].Get<float>();
675 creatureTemplate.speed_run = fields[20].Get<float>();
676 creatureTemplate.speed_swim = fields[21].Get<float>();
677 creatureTemplate.speed_flight = fields[22].Get<float>();
678 creatureTemplate.detection_range = fields[23].Get<float>();
679 creatureTemplate.scale = fields[24].Get<float>();
680 creatureTemplate.rank = uint32(fields[25].Get<uint8>());
681 creatureTemplate.dmgschool = uint32(fields[26].Get<int8>());
682 creatureTemplate.DamageModifier = fields[27].Get<float>();
683 creatureTemplate.BaseAttackTime = fields[28].Get<uint32>();
684 creatureTemplate.RangeAttackTime = fields[29].Get<uint32>();
685 creatureTemplate.BaseVariance = fields[30].Get<float>();
686 creatureTemplate.RangeVariance = fields[31].Get<float>();
687 creatureTemplate.unit_class = uint32(fields[32].Get<uint8>());
688 creatureTemplate.unit_flags = fields[33].Get<uint32>();
689 creatureTemplate.unit_flags2 = fields[34].Get<uint32>();
690 creatureTemplate.dynamicflags = fields[35].Get<uint32>();
691 creatureTemplate.family = uint32(fields[36].Get<uint8>());
692 creatureTemplate.trainer_type = uint32(fields[37].Get<uint8>());
693 creatureTemplate.trainer_spell = fields[38].Get<uint32>();
694 creatureTemplate.trainer_class = uint32(fields[39].Get<uint8>());
695 creatureTemplate.trainer_race = uint32(fields[40].Get<uint8>());
696 creatureTemplate.type = uint32(fields[41].Get<uint8>());
697 creatureTemplate.type_flags = fields[42].Get<uint32>();
698 creatureTemplate.lootid = fields[43].Get<uint32>();
699 creatureTemplate.pickpocketLootId = fields[44].Get<uint32>();
700 creatureTemplate.SkinLootId = fields[45].Get<uint32>();
701
702 for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
703 {
704 creatureTemplate.resistance[i] = 0;
705 }
706
707 for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i)
708 {
709 creatureTemplate.spells[i] = 0;
710 }
711
712 creatureTemplate.PetSpellDataId = fields[46].Get<uint32>();
713 creatureTemplate.VehicleId = fields[47].Get<uint32>();
714 creatureTemplate.mingold = fields[48].Get<uint32>();
715 creatureTemplate.maxgold = fields[49].Get<uint32>();
716 creatureTemplate.AIName = fields[50].Get<std::string>();
717 creatureTemplate.MovementType = uint32(fields[51].Get<uint8>());
718 if (!fields[52].IsNull())
719 {
720 creatureTemplate.Movement.Ground = static_cast<CreatureGroundMovementType>(fields[52].Get<uint8>());
721 }
722
723 creatureTemplate.Movement.Swim = fields[53].Get<bool>();
724 if (!fields[54].IsNull())
725 {
726 creatureTemplate.Movement.Flight = static_cast<CreatureFlightMovementType>(fields[54].Get<uint8>());
727 }
728
729 creatureTemplate.Movement.Rooted = fields[55].Get<bool>();
730 if (!fields[56].IsNull())
731 {
732 creatureTemplate.Movement.Chase = static_cast<CreatureChaseMovementType>(fields[56].Get<uint8>());
733 }
734 if (!fields[57].IsNull())
735 {
736 creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[57].Get<uint8>());
737 }
738 if (!fields[58].IsNull())
739 {
740 creatureTemplate.Movement.InteractionPauseTimer = fields[58].Get<uint32>();
741 }
742
743 creatureTemplate.HoverHeight = fields[59].Get<float>();
744 creatureTemplate.ModHealth = fields[60].Get<float>();
745 creatureTemplate.ModMana = fields[61].Get<float>();
746 creatureTemplate.ModArmor = fields[62].Get<float>();
747 creatureTemplate.ModExperience = fields[63].Get<float>();
748 creatureTemplate.RacialLeader = fields[64].Get<bool>();
749 creatureTemplate.movementId = fields[65].Get<uint32>();
750 creatureTemplate.RegenHealth = fields[66].Get<bool>();
751 creatureTemplate.MechanicImmuneMask = fields[67].Get<uint32>();
752 creatureTemplate.SpellSchoolImmuneMask = fields[68].Get<uint8>();
753 creatureTemplate.flags_extra = fields[69].Get<uint32>();
754 creatureTemplate.ScriptID = GetScriptId(fields[70].Get<std::string>());
755}
@ SPELL_SCHOOL_HOLY
Definition: SharedDefines.h:256

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateAddons()

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

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 ( )
758{
759 uint32 oldMSTime = getMSTime();
760
761 // 0 1 2
762 QueryResult result = WorldDatabase.Query("SELECT CreatureID, School, Resistance FROM creature_template_resistance");
763
764 if (!result)
765 {
766 LOG_WARN("server.loading", ">> Loaded 0 creature template resistance definitions. DB table `creature_template_resistance` is empty.");
767 LOG_INFO("server.loading", " ");
768 return;
769 }
770
771 uint32 count = 0;
772
773 do
774 {
775 Field* fields = result->Fetch();
776
777 uint32 creatureID = fields[0].Get<uint32>();
778 uint8 school = fields[1].Get<uint8>();
779
780 if (school == SPELL_SCHOOL_NORMAL || school >= MAX_SPELL_SCHOOL)
781 {
782 LOG_ERROR("sql.sql", "creature_template_resistance has resistance definitions for creature {} but this school {} doesn't exist", creatureID, school);
783 continue;
784 }
785
786 CreatureTemplateContainer::iterator itr = _creatureTemplateStore.find(creatureID);
787 if (itr == _creatureTemplateStore.end())
788 {
789 LOG_ERROR("sql.sql", "creature_template_resistance has resistance definitions for creature {} but this creature doesn't exist", creatureID);
790 continue;
791 }
792
793 CreatureTemplate& creatureTemplate = itr->second;
794 creatureTemplate.resistance[school] = fields[2].Get<int16>();
795
796 ++count;
797 } while (result->NextRow());
798
799 LOG_INFO("server.loading", ">> Loaded {} Creature Template Resistances in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
800 LOG_INFO("server.loading", " ");
801}
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 ( )
579{
580 uint32 oldMSTime = getMSTime();
581
582// 0 1 2 3 4 5 6 7 8
583 QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, "
584// 9 10 11 12 13 14 15 16 17 18 19 20 21 22
585 "modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, speed_swim, speed_flight, "
586// 23 24 25 26 27 28 29 30 31 32 33 34
587 "detection_range, scale, `rank`, dmgschool, DamageModifier, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, "
588// 35 36 37 38 39 40 41
589 "dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, type, "
590// 42 43 44 45 46 47 48 49 50 51
591 "type_flags, lootid, pickpocketloot, skinloot, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, "
592// 52 53 54 55 56 57 58 59 60 61 62 63
593 "ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, ExperienceModifier, "
594// 64 65 66 67 68 69 70
595 "RacialLeader, movementId, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName "
596 "FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId;");
597
598 if (!result)
599 {
600 LOG_WARN("server.loading", ">> Loaded 0 creature template definitions. DB table `creature_template` is empty.");
601 return;
602 }
603
604 _creatureTemplateStore.rehash(result->GetRowCount());
605
606 uint32 count = 0;
607 do
608 {
609 Field* fields = result->Fetch();
610 LoadCreatureTemplate(fields);
611 ++count;
612 } while (result->NextRow());
613
614 // pussywizard:
615 {
616 uint32 max = 0;
617 for (CreatureTemplateContainer::const_iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
618 if (itr->first > max)
619 max = itr->first;
620 if (max)
621 {
623 _creatureTemplateStoreFast.resize(max + 1, nullptr);
624 for (CreatureTemplateContainer::iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
625 _creatureTemplateStoreFast[itr->first] = &(itr->second);
626 }
627 }
628
631
632 // Checking needs to be done after loading because of the difficulty self referencing
633 for (CreatureTemplateContainer::iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
634 {
635 CheckCreatureTemplate(&itr->second);
636 itr->second.InitializeQueryData();
637 }
638
639 LOG_INFO("server.loading", ">> Loaded {} Creature Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
640 LOG_INFO("server.loading", " ");
641}
void LoadCreatureTemplateResistances()
Definition: ObjectMgr.cpp:757
void LoadCreatureTemplate(Field *fields)
Definition: ObjectMgr.cpp:643
void LoadCreatureTemplateSpells()
Definition: ObjectMgr.cpp:803
void CheckCreatureTemplate(CreatureTemplate const *cInfo)
Definition: ObjectMgr.cpp:957

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

◆ LoadCreatureTemplateSpells()

void ObjectMgr::LoadCreatureTemplateSpells ( )
804{
805 uint32 oldMSTime = getMSTime();
806
807 // 0 1 2
808 QueryResult result = WorldDatabase.Query("SELECT CreatureID, `Index`, Spell FROM creature_template_spell");
809
810 if (!result)
811 {
812 LOG_WARN("server.loading", ">> Loaded 0 creature template spell definitions. DB table `creature_template_spell` is empty.");
813 LOG_INFO("server.loading", " ");
814 return;
815 }
816
817 uint32 count = 0;
818
819 do
820 {
821 Field* fields = result->Fetch();
822
823 uint32 creatureID = fields[0].Get<uint32>();
824 uint8 index = fields[1].Get<uint8>();
825
826 if (index >= MAX_CREATURE_SPELLS)
827 {
828 LOG_ERROR("sql.sql", "creature_template_spell has spell definitions for creature {} with a incorrect index {}", creatureID, index);
829 continue;
830 }
831
832 CreatureTemplateContainer::iterator itr = _creatureTemplateStore.find(creatureID);
833 if (itr == _creatureTemplateStore.end())
834 {
835 LOG_ERROR("sql.sql", "creature_template_spell has spell definitions for creature {} but this creature doesn't exist", creatureID);
836 continue;
837 }
838
839 CreatureTemplate& creatureTemplate = itr->second;
840 creatureTemplate.spells[index] = fields[2].Get<uint32>();
841
842 ++count;
843 } while (result->NextRow());
844
845 LOG_INFO("server.loading", ">> Loaded {} Creature Template Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
846 LOG_INFO("server.loading", " ");
847}
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 ( )
1554{
1555 uint32 oldMSTime = getMSTime();
1556
1557 // 0 1 2 3 4
1558 QueryResult result = WorldDatabase.Query("SELECT CreatureID, ID, ItemID1, ItemID2, ItemID3 FROM creature_equip_template");
1559
1560 if (!result)
1561 {
1562 LOG_WARN("server.loading", ">> Loaded 0 creature equipment templates. DB table `creature_equip_template` is empty!");
1563 LOG_INFO("server.loading", " ");
1564 return;
1565 }
1566
1567 uint32 count = 0;
1568 do
1569 {
1570 Field* fields = result->Fetch();
1571
1572 uint32 entry = fields[0].Get<uint32>();
1573
1574 if (!sObjectMgr->GetCreatureTemplate(entry))
1575 {
1576 LOG_ERROR("sql.sql", "Creature template (CreatureID: {}) does not exist but has a record in `creature_equip_template`", entry);
1577 continue;
1578 }
1579
1580 uint8 id = fields[1].Get<uint8>();
1581 if (!id)
1582 {
1583 LOG_ERROR("sql.sql", "Creature equipment template with id 0 found for creature {}, skipped.", entry);
1584 continue;
1585 }
1586
1587 EquipmentInfo& equipmentInfo = _equipmentInfoStore[entry][id];
1588
1589 equipmentInfo.ItemEntry[0] = fields[2].Get<uint32>();
1590 equipmentInfo.ItemEntry[1] = fields[3].Get<uint32>();
1591 equipmentInfo.ItemEntry[2] = fields[4].Get<uint32>();
1592
1593 for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1594 {
1595 if (!equipmentInfo.ItemEntry[i])
1596 continue;
1597
1598 ItemEntry const* dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]);
1599
1600 if (!dbcItem)
1601 {
1602 LOG_ERROR("sql.sql", "Unknown item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {}, forced to 0.",
1603 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1604 equipmentInfo.ItemEntry[i] = 0;
1605 continue;
1606 }
1607
1608 if (dbcItem->InventoryType != INVTYPE_WEAPON &&
1609 dbcItem->InventoryType != INVTYPE_SHIELD &&
1610 dbcItem->InventoryType != INVTYPE_RANGED &&
1611 dbcItem->InventoryType != INVTYPE_2HWEAPON &&
1614 dbcItem->InventoryType != INVTYPE_HOLDABLE &&
1615 dbcItem->InventoryType != INVTYPE_THROWN &&
1617 {
1618 LOG_ERROR("sql.sql", "Item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {} is not equipable in a hand, forced to 0.",
1619 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1620 equipmentInfo.ItemEntry[i] = 0;
1621 }
1622 }
1623
1624 ++count;
1625 } while (result->NextRow());
1626
1627 LOG_INFO("server.loading", ">> Loaded {} Equipment Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1628 LOG_INFO("server.loading", " ");
1629}
#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 ( )
5575{
5577
5578 std::set<uint32> evt_scripts;
5579 // Load all possible script entries from gameobjects
5580 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
5581 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
5582 if (uint32 eventId = itr->second.GetEventScriptId())
5583 evt_scripts.insert(eventId);
5584
5585 // Load all possible script entries from spells
5586 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5587 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
5588 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5589 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
5590 if (spell->Effects[j].MiscValue)
5591 evt_scripts.insert(spell->Effects[j].MiscValue);
5592
5593 for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
5594 {
5595 for (size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
5596 {
5597 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
5598
5599 if (node->arrivalEventID)
5600 evt_scripts.insert(node->arrivalEventID);
5601
5602 if (node->departureEventID)
5603 evt_scripts.insert(node->departureEventID);
5604 }
5605 }
5606
5607 // Then check if all scripts are in above list of possible script entries
5608 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
5609 {
5610 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
5611 if (itr2 == evt_scripts.end())
5612 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 {}",
5613 itr->first, SPELL_EFFECT_SEND_EVENT);
5614 }
5615}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DBCStores.cpp:186
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition: GameObject.h:44
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:60
@ SCRIPTS_EVENT
Definition: ObjectMgr.h:152
@ SPELL_EFFECT_SEND_EVENT
Definition: SharedDefines.h:811
void LoadScripts(ScriptsType type)
Definition: ObjectMgr.cpp:5232
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 ( )
7445{
7446 uint32 oldMSTime = getMSTime();
7447
7448 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
7449
7450 if (!result)
7451 {
7452 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
7453 LOG_INFO("server.loading", " ");
7454 return;
7455 }
7456
7457 uint32 count = 0;
7458
7459 do
7460 {
7461 Field* fields = result->Fetch();
7462 uint8 level = fields[0].Get<uint8>();
7463 uint32 basexp = fields[1].Get<int32>();
7464 _baseXPTable[level] = basexp;
7465 ++count;
7466 } while (result->NextRow());
7467
7468 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7469 LOG_INFO("server.loading", " ");
7470}
std::int32_t int32
Definition: Define.h:104

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

◆ LoadFactionChangeAchievements()

void ObjectMgr::LoadFactionChangeAchievements ( )
9750{
9751 uint32 oldMSTime = getMSTime();
9752
9753 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_achievement");
9754
9755 if (!result)
9756 {
9757 LOG_WARN("server.loading", ">> Loaded 0 faction change achievement pairs. DB table `player_factionchange_achievement` is empty.");
9758 LOG_INFO("server.loading", " ");
9759 return;
9760 }
9761
9762 uint32 count = 0;
9763
9764 do
9765 {
9766 Field* fields = result->Fetch();
9767
9768 uint32 alliance = fields[0].Get<uint32>();
9769 uint32 horde = fields[1].Get<uint32>();
9770
9771 if (!sAchievementStore.LookupEntry(alliance))
9772 LOG_ERROR("sql.sql", "Achievement {} (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance);
9773 else if (!sAchievementStore.LookupEntry(horde))
9774 LOG_ERROR("sql.sql", "Achievement {} (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde);
9775 else
9776 FactionChangeAchievements[alliance] = horde;
9777
9778 ++count;
9779 } while (result->NextRow());
9780
9781 LOG_INFO("server.loading", ">> Loaded {} faction change achievement pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9782 LOG_INFO("server.loading", " ");
9783}
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 ( )
9786{
9787 uint32 oldMSTime = getMSTime();
9788
9789 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
9790
9791 if (!result)
9792 {
9793 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
9794 LOG_INFO("server.loading", " ");
9795 return;
9796 }
9797
9798 uint32 count = 0;
9799
9800 do
9801 {
9802 Field* fields = result->Fetch();
9803
9804 uint32 alliance = fields[0].Get<uint32>();
9805 uint32 horde = fields[1].Get<uint32>();
9806
9807 if (!GetItemTemplate(alliance))
9808 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
9809 else if (!GetItemTemplate(horde))
9810 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
9811 else
9812 FactionChangeItems[alliance] = horde;
9813
9814 ++count;
9815 } while (result->NextRow());
9816
9817 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9818 LOG_INFO("server.loading", " ");
9819}
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 ( )
9822{
9823 uint32 oldMSTime = getMSTime();
9824
9825 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
9826
9827 if (!result)
9828 {
9829 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
9830 LOG_INFO("server.loading", " ");
9831 return;
9832 }
9833
9834 uint32 count = 0;
9835
9836 do
9837 {
9838 Field* fields = result->Fetch();
9839
9840 uint32 alliance = fields[0].Get<uint32>();
9841 uint32 horde = fields[1].Get<uint32>();
9842
9843 if (!sObjectMgr->GetQuestTemplate(alliance))
9844 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
9845 else if (!sObjectMgr->GetQuestTemplate(horde))
9846 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
9847 else
9848 FactionChangeQuests[alliance] = horde;
9849
9850 ++count;
9851 } while (result->NextRow());
9852
9853 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9854 LOG_INFO("server.loading", " ");
9855}
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 ( )
9858{
9859 uint32 oldMSTime = getMSTime();
9860
9861 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
9862
9863 if (!result)
9864 {
9865 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
9866 LOG_INFO("server.loading", " ");
9867 return;
9868 }
9869
9870 uint32 count = 0;
9871
9872 do
9873 {
9874 Field* fields = result->Fetch();
9875
9876 uint32 alliance = fields[0].Get<uint32>();
9877 uint32 horde = fields[1].Get<uint32>();
9878
9879 if (!sFactionStore.LookupEntry(alliance))
9880 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
9881 else if (!sFactionStore.LookupEntry(horde))
9882 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
9883 else
9884 FactionChangeReputation[alliance] = horde;
9885
9886 ++count;
9887 } while (result->NextRow());
9888
9889 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9890 LOG_INFO("server.loading", " ");
9891}
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 ( )
9894{
9895 uint32 oldMSTime = getMSTime();
9896
9897 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
9898
9899 if (!result)
9900 {
9901 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
9902 LOG_INFO("server.loading", " ");
9903 return;
9904 }
9905
9906 uint32 count = 0;
9907
9908 do
9909 {
9910 Field* fields = result->Fetch();
9911
9912 uint32 alliance = fields[0].Get<uint32>();
9913 uint32 horde = fields[1].Get<uint32>();
9914
9915 if (!sSpellMgr->GetSpellInfo(alliance))
9916 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
9917 else if (!sSpellMgr->GetSpellInfo(horde))
9918 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
9919 else
9920 FactionChangeSpells[alliance] = horde;
9921
9922 ++count;
9923 } while (result->NextRow());
9924
9925 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9926 LOG_INFO("server.loading", " ");
9927}
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 ( )
9930{
9931 uint32 oldMSTime = getMSTime();
9932
9933 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
9934
9935 if (!result)
9936 {
9937 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
9938 return;
9939 }
9940
9941 uint32 count = 0;
9942
9943 do
9944 {
9945 Field* fields = result->Fetch();
9946
9947 uint32 alliance = fields[0].Get<uint32>();
9948 uint32 horde = fields[1].Get<uint32>();
9949
9950 if (!sCharTitlesStore.LookupEntry(alliance))
9951 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
9952 else if (!sCharTitlesStore.LookupEntry(horde))
9953 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
9954 else
9955 FactionChangeTitles[alliance] = horde;
9956
9957 ++count;
9958 } while (result->NextRow());
9959
9960 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9961 LOG_INFO("server.loading", " ");
9962}
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 ( )
8653{
8654 uint32 oldMSTime = getMSTime();
8655
8656 _fishingBaseForAreaStore.clear(); // for reload case
8657
8658 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
8659
8660 if (!result)
8661 {
8662 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
8663 LOG_INFO("server.loading", " ");
8664 return;
8665 }
8666
8667 uint32 count = 0;
8668
8669 do
8670 {
8671 Field* fields = result->Fetch();
8672 uint32 entry = fields[0].Get<uint32>();
8673 int32 skill = fields[1].Get<int16>();
8674
8675 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8676 if (!fArea)
8677 {
8678 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8679 continue;
8680 }
8681
8682 _fishingBaseForAreaStore[entry] = skill;
8683 ++count;
8684 } while (result->NextRow());
8685
8686 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8687 LOG_INFO("server.loading", " ");
8688}

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

◆ LoadGameObjectAddons()

void ObjectMgr::LoadGameObjectAddons ( )
1444{
1445 uint32 oldMSTime = getMSTime();
1446
1447 // 0 1 2
1448 QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon");
1449
1450 if (!result)
1451 {
1452 LOG_WARN("server.loading", ">> Loaded 0 gameobject addon definitions. DB table `gameobject_addon` is empty.");
1453 LOG_INFO("server.loading", " ");
1454 return;
1455 }
1456
1457 uint32 count = 0;
1458 do
1459 {
1460 Field* fields = result->Fetch();
1461
1462 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1463
1464 const GameObjectData* goData = GetGameObjectData(guid);
1465 if (!goData)
1466 {
1467 LOG_ERROR("sql.sql", "GameObject (GUID: {}) does not exist but has a record in `gameobject_addon`", guid);
1468 continue;
1469 }
1470
1471 GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
1472 gameObjectAddon.invisibilityType = InvisibilityType(fields[1].Get<uint8>());
1473 gameObjectAddon.InvisibilityValue = fields[2].Get<uint32>();
1474
1475 if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
1476 {
1477 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid InvisibilityType in `gameobject_addon`", guid);
1478 gameObjectAddon.invisibilityType = INVISIBILITY_GENERAL;
1479 gameObjectAddon.InvisibilityValue = 0;
1480 }
1481
1482 if (gameObjectAddon.invisibilityType && !gameObjectAddon.InvisibilityValue)
1483 {
1484 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid);
1485 gameObjectAddon.InvisibilityValue = 1;
1486 }
1487
1488 ++count;
1489 } while (result->NextRow());
1490
1491 LOG_INFO("server.loading", ">> Loaded {} Gameobject Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1492 LOG_INFO("server.loading", " ");
1493}
InvisibilityType
Definition: SharedDefines.h:1226
@ TOTAL_INVISIBILITY_TYPES
Definition: SharedDefines.h:1240
@ INVISIBILITY_GENERAL
Definition: SharedDefines.h:1227
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 ( )
8532{
8533 uint32 oldMSTime = getMSTime();
8534
8535 if (sObjectMgr->GetGameObjectTemplates()->empty())
8536 {
8537 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
8538 LOG_INFO("server.loading", " ");
8539 return;
8540 }
8541
8542 uint32 count = 0;
8543
8544 // collect GO entries for GO that must activated
8545 GameObjectTemplateContainer* gotc = const_cast<GameObjectTemplateContainer*>(sObjectMgr->GetGameObjectTemplates());
8546 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
8547 {
8548 itr->second.IsForQuests = false;
8549 switch (itr->second.type)
8550 {
8552 itr->second.IsForQuests = true;
8553 ++count;
8554 break;
8556 {
8557 // scan GO chest with loot including quest items
8558 uint32 loot_id = (itr->second.GetLootId());
8559
8560 // find quest loot for GO
8561 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
8562 {
8563 itr->second.IsForQuests = true;
8564 ++count;
8565 }
8566 break;
8567 }
8569 {
8570 if (itr->second._generic.questID > 0) //quests objects
8571 {
8572 itr->second.IsForQuests = true;
8573 ++count;
8574 }
8575 break;
8576 }
8578 {
8579 if (itr->second.spellFocus.questID > 0) //quests objects
8580 {
8581 itr->second.IsForQuests = true;
8582 ++count;
8583 }
8584 break;
8585 }
8587 {
8588 if (itr->second.goober.questId > 0) //quests objects
8589 {
8590 itr->second.IsForQuests = true;
8591 ++count;
8592 }
8593 break;
8594 }
8595 default:
8596 break;
8597 }
8598 }
8599
8600 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8601 LOG_INFO("server.loading", " ");
8602}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition: SharedDefines.h:1540
@ GAMEOBJECT_TYPE_GENERIC
Definition: SharedDefines.h:1537
@ GAMEOBJECT_TYPE_CHEST
Definition: SharedDefines.h:1535
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition: SharedDefines.h:1534
@ GAMEOBJECT_TYPE_GOOBER
Definition: SharedDefines.h:1542
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 ( )
7089{
7090 uint32 oldMSTime = getMSTime();
7091
7092 _gameObjectLocaleStore.clear(); // need for reload case
7093
7094 // 0 1 2 3
7095 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7096 if (!result)
7097 return;
7098
7099 do
7100 {
7101 Field* fields = result->Fetch();
7102
7103 uint32 ID = fields[0].Get<uint32>();
7104
7105 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7106 if (locale == LOCALE_enUS)
7107 continue;
7108
7110 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7111 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7112 } while (result->NextRow());
7113
7114 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7115}
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 ( )
8119{
8120 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8121
8122 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8123 {
8124 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8125 if (!goInfo)
8126 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8127 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8128 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8129 }
8130}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
10023{
10024 uint32 oldMSTime = getMSTime();
10025
10026 // 0 1 2
10027 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
10028
10029 if (!result)
10030 {
10031 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
10032 return;
10033 }
10034
10035 uint32 count = 0;
10036 do
10037 {
10038 Field* fields = result->Fetch();
10039
10040 uint32 entry = fields[0].Get<uint32>();
10041 uint32 item = fields[1].Get<uint32>();
10042 uint32 idx = fields[2].Get<uint32>();
10043
10044 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
10045 if (!goInfo)
10046 {
10047 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
10048 continue;
10049 };
10050
10051 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10052 if (!dbcData)
10053 {
10054 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
10055 continue;
10056 };
10057
10058 _gameObjectQuestItemStore[entry].push_back(item);
10059
10060 ++count;
10061 } while (result->NextRow());
10062
10063 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10064 LOG_INFO("server.loading", " ");
10065}

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

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8105{
8106 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8107
8108 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8109 {
8110 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8111 if (!goInfo)
8112 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8113 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8114 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8115 }
8116}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

void ObjectMgr::LoadGameobjects ( )
2473{
2474 uint32 oldMSTime = getMSTime();
2475
2476 uint32 count = 0;
2477
2478 // 0 1 2 3 4 5 6
2479 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
2480 // 7 8 9 10 11 12 13 14 15 16 17
2481 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, "
2482 // 18
2483 "ScriptName "
2484 "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
2485 "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
2486
2487 if (!result)
2488 {
2489 LOG_WARN("server.loading", ">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
2490 LOG_INFO("server.loading", " ");
2491 return;
2492 }
2493
2494 // build single time for check spawnmask
2495 std::map<uint32, uint32> spawnMasks;
2496 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2497 if (sMapStore.LookupEntry(i))
2498 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2500 spawnMasks[i] |= (1 << k);
2501
2502 _gameObjectDataStore.rehash(result->GetRowCount());
2503 do
2504 {
2505 Field* fields = result->Fetch();
2506
2507 ObjectGuid::LowType guid = fields[0].Get<uint32>();
2508 uint32 entry = fields[1].Get<uint32>();
2509
2510 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
2511 if (!gInfo)
2512 {
2513 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non existing gameobject entry {}, skipped.", guid, entry);
2514 continue;
2515 }
2516
2517 if (!gInfo->displayId)
2518 {
2519 switch (gInfo->type)
2520 {
2523 break;
2524 default:
2525 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) doesn't have a displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2526 break;
2527 }
2528 }
2529
2530 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
2531 {
2532 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) has an invalid displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2533 continue;
2534 }
2535
2537
2538 data.id = entry;
2539 data.mapid = fields[2].Get<uint16>();
2540 data.posX = fields[3].Get<float>();
2541 data.posY = fields[4].Get<float>();
2542 data.posZ = fields[5].Get<float>();
2543 data.orientation = fields[6].Get<float>();
2544 data.rotation.x = fields[7].Get<float>();
2545 data.rotation.y = fields[8].Get<float>();
2546 data.rotation.z = fields[9].Get<float>();
2547 data.rotation.w = fields[10].Get<float>();
2548 data.spawntimesecs = fields[11].Get<int32>();
2549 data.ScriptId = GetScriptId(fields[18].Get<std::string>());
2550 if (!data.ScriptId)
2551 data.ScriptId = gInfo->ScriptId;
2552
2553 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2554 if (!mapEntry)
2555 {
2556 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existed map (Id: {}), skip", guid, data.id, data.mapid);
2557 continue;
2558 }
2559
2560 if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
2561 {
2562 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);
2563 }
2564
2565 data.animprogress = fields[12].Get<uint8>();
2566 data.artKit = 0;
2567
2568 uint32 go_state = fields[13].Get<uint8>();
2569 if (go_state >= MAX_GO_STATE)
2570 {
2571 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skip", guid, data.id, go_state);
2572 continue;
2573 }
2574 data.go_state = GOState(go_state);
2575
2576 data.spawnMask = fields[14].Get<uint8>();
2577
2578 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2579 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);
2580
2581 data.phaseMask = fields[15].Get<uint32>();
2582 int16 gameEvent = fields[16].Get<int8>();
2583 uint32 PoolId = fields[17].Get<uint32>();
2584
2585 if (data.rotation.x < -1.0f || data.rotation.x > 1.0f)
2586 {
2587 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skip", guid, data.id, data.rotation.x);
2588 continue;
2589 }
2590
2591 if (data.rotation.y < -1.0f || data.rotation.y > 1.0f)
2592 {
2593 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skip", guid, data.id, data.rotation.y);
2594 continue;
2595 }
2596
2597 if (data.rotation.z < -1.0f || data.rotation.z > 1.0f)
2598 {
2599 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skip", guid, data.id, data.rotation.z);
2600 continue;
2601 }
2602
2603 if (data.rotation.w < -1.0f || data.rotation.w > 1.0f)
2604 {
2605 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skip", guid, data.id, data.rotation.w);
2606 continue;
2607 }
2608
2609 if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
2610 {
2611 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
2612 continue;
2613 }
2614
2615 if (data.phaseMask == 0)
2616 {
2617 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
2618 data.phaseMask = 1;
2619 }
2620
2622 {
2623 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2624 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2625
2627
2628 stmt->SetData(0, zoneId);
2629 stmt->SetData(1, areaId);
2630 stmt->SetData(2, guid);
2631
2632 WorldDatabase.Execute(stmt);
2633 }
2634
2635 if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
2636 AddGameobjectToGrid(guid, &data);
2637 ++count;
2638 } while (result->NextRow());
2639
2640 LOG_INFO("server.loading", ">> Loaded {} Gameobjects in {} ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
2641 LOG_INFO("server.loading", " ");
2642}
@ 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:1538
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 ( )
7177{
7178 uint32 oldMSTime = getMSTime();
7179
7180 // 0 1 2 3 4 5 6 7
7181 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7182 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7183 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7184 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7185 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7186 "FROM gameobject_template");
7187
7188 if (!result)
7189 {
7190 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7191 LOG_INFO("server.loading", " ");
7192 return;
7193 }
7194
7195 _gameObjectTemplateStore.rehash(result->GetRowCount());
7196 uint32 count = 0;
7197 do
7198 {
7199 Field* fields = result->Fetch();
7200
7201 uint32 entry = fields[0].Get<uint32>();
7202
7204
7205 got.entry = entry;
7206 got.type = uint32(fields[1].Get<uint8>());
7207 got.displayId = fields[2].Get<uint32>();
7208 got.name = fields[3].Get<std::string>();
7209 got.IconName = fields[4].Get<std::string>();
7210 got.castBarCaption = fields[5].Get<std::string>();
7211 got.unk1 = fields[6].Get<std::string>();
7212 got.size = fields[7].Get<float>();
7213
7214 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7215 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7216
7217 got.AIName = fields[32].Get<std::string>();
7218 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7219 got.IsForQuests = false;
7220
7221 // Checks
7222 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7223 {
7224 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7225 }
7226
7227 switch (got.type)
7228 {
7229 case GAMEOBJECT_TYPE_DOOR: //0
7230 {
7231 if (got.door.lockId)
7232 CheckGOLockId(&got, got.door.lockId, 1);
7233 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7234 break;
7235 }
7236 case GAMEOBJECT_TYPE_BUTTON: //1
7237 {
7238 if (got.button.lockId)
7239 CheckGOLockId(&got, got.button.lockId, 1);
7240 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7241 break;
7242 }
7244 {
7245 if (got.questgiver.lockId)
7246 CheckGOLockId(&got, got.questgiver.lockId, 0);
7247 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7248 break;
7249 }
7250 case GAMEOBJECT_TYPE_CHEST: //3
7251 {
7252 if (got.chest.lockId)
7253 CheckGOLockId(&got, got.chest.lockId, 0);
7254
7255 CheckGOConsumable(&got, got.chest.consumable, 3);
7256
7257 if (got.chest.linkedTrapId) // linked trap
7258 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7259 break;
7260 }
7261 case GAMEOBJECT_TYPE_TRAP: //6
7262 {
7263 if (got.trap.lockId)
7264 CheckGOLockId(&got, got.trap.lockId, 0);
7265 break;
7266 }
7267 case GAMEOBJECT_TYPE_CHAIR: //7
7268 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7269 break;
7271 {
7272 if (got.spellFocus.focusId)
7273 {
7274 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7275 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7276 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7277 }
7278
7279 if (got.spellFocus.linkedTrapId) // linked trap
7280 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7281 break;
7282 }
7283 case GAMEOBJECT_TYPE_GOOBER: //10
7284 {
7285 if (got.goober.lockId)
7286 CheckGOLockId(&got, got.goober.lockId, 0);
7287
7288 CheckGOConsumable(&got, got.goober.consumable, 3);
7289
7290 if (got.goober.pageId) // pageId
7291 {
7292 if (!GetPageText(got.goober.pageId))
7293 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7294 entry, got.type, got.goober.pageId, got.goober.pageId);
7295 }
7296 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7297 if (got.goober.linkedTrapId) // linked trap
7298 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7299 break;
7300 }
7302 {
7303 if (got.areadamage.lockId)
7304 CheckGOLockId(&got, got.areadamage.lockId, 0);
7305 break;
7306 }
7307 case GAMEOBJECT_TYPE_CAMERA: //13
7308 {
7309 if (got.camera.lockId)
7310 CheckGOLockId(&got, got.camera.lockId, 0);
7311 break;
7312 }
7314 {
7315 if (got.moTransport.taxiPathId)
7316 {
7317 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7318 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7319 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7320 }
7321 if (uint32 transportMap = got.moTransport.mapID)
7322 _transportMaps.insert(transportMap);
7323 break;
7324 }
7326 break;
7328 {
7329 // always must have spell
7330 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7331 break;
7332 }
7333 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7334 {
7335 if (got.flagstand.lockId)
7336 CheckGOLockId(&got, got.flagstand.lockId, 0);
7337 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7338 break;
7339 }
7341 {
7342 if (got.fishinghole.lockId)
7343 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7344 break;
7345 }
7346 case GAMEOBJECT_TYPE_FLAGDROP: //26
7347 {
7348 if (got.flagdrop.lockId)
7349 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7350 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7351 break;
7352 }
7354 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7355 break;
7356 }
7357
7358 ++count;
7359 } while (result->NextRow());
7360
7361 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7362 LOG_INFO("server.loading", " ");
7363}
#define sGameObjectAIRegistry
Definition: GameObjectAIFactory.h:49
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7157
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7136
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition: ObjectMgr.cpp:7145
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7166
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7126
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition: ObjectMgr.cpp:7117
@ GAMEOBJECT_TYPE_CAMERA
Definition: SharedDefines.h:1545
@ GAMEOBJECT_TYPE_BUTTON
Definition: SharedDefines.h:1533
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition: SharedDefines.h:1547
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition: SharedDefines.h:1550
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition: SharedDefines.h:1557
@ GAMEOBJECT_TYPE_FLAGDROP
Definition: SharedDefines.h:1558
@ GAMEOBJECT_TYPE_SPELLCASTER
Definition: SharedDefines.h:1554
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition: SharedDefines.h:1556
@ GAMEOBJECT_TYPE_CHAIR
Definition: SharedDefines.h:1539
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition: SharedDefines.h:1544
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition: SharedDefines.h:1564
@ GAMEOBJECT_TYPE_DOOR
Definition: SharedDefines.h:1532
#define MAX_GAMEOBJECT_DATA
Definition: SharedDefines.h:1571
PageText const * GetPageText(uint32 pageEntry)
Definition: ObjectMgr.cpp:5816

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 ( )
7366{
7367 uint32 oldMSTime = getMSTime();
7368
7369 // 0 1 2 3 4 5 6 7 8
7370 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
7371
7372 if (!result)
7373 {
7374 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
7375 LOG_INFO("server.loading", " ");
7376 return;
7377 }
7378
7379 uint32 count = 0;
7380 do
7381 {
7382 Field* fields = result->Fetch();
7383
7384 uint32 entry = fields[0].Get<uint32>();
7385
7386 GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(entry);
7387 if (!got)
7388 {
7389 LOG_ERROR("sql.sql",
7390 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
7391 entry);
7392 continue;
7393 }
7394
7396 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
7397 gameObjectAddon.flags = fields[2].Get<uint32>();
7398 gameObjectAddon.mingold = fields[3].Get<uint32>();
7399 gameObjectAddon.maxgold = fields[4].Get<uint32>();
7400
7401 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
7402 {
7403 uint32 artKitID = fields[5 + i].Get<uint32>();
7404 if (!artKitID)
7405 continue;
7406
7407 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
7408 {
7409 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
7410 continue;
7411 }
7412
7413 gameObjectAddon.artKits[i] = artKitID;
7414 }
7415
7416 // checks
7417 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
7418 LOG_ERROR("sql.sql",
7419 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
7420 entry, gameObjectAddon.faction);
7421
7422 if (gameObjectAddon.maxgold > 0)
7423 {
7424 switch (got->type)
7425 {
7428 break;
7429 default:
7430 LOG_ERROR("sql.sql",
7431 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
7432 entry, got->type);
7433 break;
7434 }
7435 }
7436
7437 ++count;
7438 } while (result->NextRow());
7439
7440 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7441 LOG_INFO("server.loading", " ");
7442}
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 ( )
8793{
8794 uint32 oldMSTime = getMSTime();
8795
8796 _gameTeleStore.clear(); // for reload case
8797
8798 // 0 1 2 3 4 5 6
8799 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
8800
8801 if (!result)
8802 {
8803 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
8804 LOG_INFO("server.loading", " ");
8805 return;
8806 }
8807
8808 uint32 count = 0;
8809
8810 do
8811 {
8812 Field* fields = result->Fetch();
8813
8814 uint32 id = fields[0].Get<uint32>();
8815
8816 GameTele gt;
8817
8818 gt.position_x = fields[1].Get<float>();
8819 gt.position_y = fields[2].Get<float>();
8820 gt.position_z = fields[3].Get<float>();
8821 gt.orientation = fields[4].Get<float>();
8822 gt.mapId = fields[5].Get<uint16>();
8823 gt.name = fields[6].Get<std::string>();
8824
8825 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
8826 {
8827 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
8828 continue;
8829 }
8830
8831 if (!Utf8toWStr(gt.name, gt.wnameLow))
8832 {
8833 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
8834 continue;
8835 }
8836
8837 wstrToLower(gt.wnameLow);
8838
8839 _gameTeleStore[id] = gt;
8840
8841 ++count;
8842 } while (result->NextRow());
8843
8844 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8845 LOG_INFO("server.loading", " ");
8846}
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 ( )
9209{
9210 uint32 oldMSTime = getMSTime();
9211
9212 _gossipMenusStore.clear();
9213
9214 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
9215
9216 if (!result)
9217 {
9218 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
9219 LOG_INFO("server.loading", " ");
9220 return;
9221 }
9222
9223 do
9224 {
9225 Field* fields = result->Fetch();
9226
9227 GossipMenus gMenu;
9228
9229 gMenu.MenuID = fields[0].Get<uint32>();
9230 gMenu.TextID = fields[1].Get<uint32>();
9231
9232 if (!GetGossipText(gMenu.TextID))
9233 {
9234 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
9235 continue;
9236 }
9237
9238 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
9239 } while (result->NextRow());
9240
9241 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
9242 LOG_INFO("server.loading", " ");
9243}
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:5990

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

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
9246{
9247 uint32 oldMSTime = getMSTime();
9248
9249 _gossipMenuItemsStore.clear();
9250
9251 QueryResult result = WorldDatabase.Query(
9252 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9253 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
9254 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
9255
9256 if (!result)
9257 {
9258 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
9259 LOG_INFO("server.loading", " ");
9260 return;
9261 }
9262
9263 do
9264 {
9265 Field* fields = result->Fetch();
9266
9267 GossipMenuItems gMenuItem;
9268
9269 gMenuItem.MenuID = fields[0].Get<uint32>();
9270 gMenuItem.OptionID = fields[1].Get<uint16>();
9271 gMenuItem.OptionIcon = fields[2].Get<uint32>();
9272 gMenuItem.OptionText = fields[3].Get<std::string>();
9273 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
9274 gMenuItem.OptionType = fields[5].Get<uint8>();
9275 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
9276 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
9277 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
9278 gMenuItem.BoxCoded = fields[9].Get<bool>();
9279 gMenuItem.BoxMoney = fields[10].Get<uint32>();
9280 gMenuItem.BoxText = fields[11].Get<std::string>();
9281 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
9282
9283 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
9284 {
9285 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);
9286 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
9287 }
9288
9290 {
9291 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
9292 gMenuItem.OptionBroadcastTextID = 0;
9293 }
9294
9295 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
9296 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);
9297
9298 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
9299 {
9300 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
9301 gMenuItem.ActionPoiID = 0;
9302 }
9303
9304 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
9305 {
9306 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
9307 gMenuItem.BoxBroadcastTextID = 0;
9308 }
9309
9310 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
9311 } while (result->NextRow());
9312
9313 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
9314 LOG_INFO("server.loading", " ");
9315}
@ 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 ( )
479{
480 uint32 oldMSTime = getMSTime();
481
482 _gossipMenuItemsLocaleStore.clear(); // need for reload case
483
484 // 0 1 2 3 4
485 QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale");
486
487 if (!result)
488 return;
489
490 do
491 {
492 Field* fields = result->Fetch();
493
494 uint32 MenuID = fields[0].Get<uint32>();
495 uint16 OptionID = fields[1].Get<uint16>();
496
497 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
498 if (locale == LOCALE_enUS)
499 continue;
500
502 AddLocaleString(fields[3].Get<std::string>(), locale, data.OptionText);
503 AddLocaleString(fields[4].Get<std::string>(), locale, data.BoxText);
504 } while (result->NextRow());
505
506 LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale Strings in {} ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
507}
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 ( )
5999{
6000 uint32 oldMSTime = getMSTime();
6001
6002 QueryResult result = WorldDatabase.Query("SELECT ID, "
6003 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
6004 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
6005 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
6006 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
6007 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
6008 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
6009 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
6010 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
6011 "FROM npc_text");
6012
6013 if (!result)
6014 {
6015 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
6016 LOG_INFO("server.loading", " ");
6017 return;
6018 }
6019
6020 _gossipTextStore.rehash(result->GetRowCount());
6021
6022 uint32 count = 0;
6023 uint8 cic;
6024
6025 do
6026 {
6027 cic = 0;
6028
6029 Field* fields = result->Fetch();
6030
6031 uint32 id = fields[cic++].Get<uint32>();
6032 if (!id)
6033 {
6034 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
6035 continue;
6036 }
6037
6038 GossipText& gText = _gossipTextStore[id];
6039
6040 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6041 {
6042 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
6043 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
6044 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
6045 gText.Options[i].Language = fields[cic++].Get<uint8>();
6046 gText.Options[i].Probability = fields[cic++].Get<float>();
6047
6048 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
6049 {
6050 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
6051 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
6052 }
6053 }
6054
6055 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
6056 {
6057 if (gText.Options[i].BroadcastTextID)
6058 {
6060 {
6061 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
6062 gText.Options[i].BroadcastTextID = 0;
6063 }
6064 }
6065 }
6066
6067 count++;
6068 } while (result->NextRow());
6069
6070 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6071 LOG_INFO("server.loading", " ");
6072}
#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 ( )
5906{
5907 uint32 oldMSTime = getMSTime();
5908
5909 // 0 1 2 3
5910 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
5911 if (!result)
5912 {
5913 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
5914 LOG_INFO("server.loading", " ");
5915 return;
5916 }
5917
5918 uint32 count = 0;
5919 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
5920 do
5921 {
5922 Field* fields = result->Fetch();
5923 uint32 entry = fields[0].Get<uint32>();
5924 uint8 creditType = fields[1].Get<uint8>();
5925 uint32 creditEntry = fields[2].Get<uint32>();
5926 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
5927 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
5928 if (!dungeonEncounter)
5929 {
5930 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
5931 continue;
5932 }
5933
5934 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
5935 {
5936 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
5937 continue;
5938 }
5939
5940 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
5941 if (lastEncounterDungeon)
5942 {
5943 if (itr != dungeonLastBosses.end())
5944 {
5945 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]);
5946 continue;
5947 }
5948
5949 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
5950 }
5951
5952 switch (creditType)
5953 {
5955 {
5956 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
5957 if (!creatureInfo)
5958 {
5959 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5960 continue;
5961 }
5962 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
5963 break;
5964 }
5966 {
5967 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
5968 if (!spellInfo)
5969 {
5970 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
5971 continue;
5972 }
5973 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
5974 break;
5975 }
5976 default:
5977 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
5978 continue;
5979 }
5980
5981 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
5982 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
5983 ++count;
5984 } while (result->NextRow());
5985
5986 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5987 LOG_INFO("server.loading", " ");
5988}
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
#define sLFGMgr
Definition: LFGMgr.h:638
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition: CreatureData.h:77
std::list< DungeonEncounter const * > DungeonEncounterList
Definition: ObjectMgr.h:719
EncounterCreditType
Definition: Map.h:306
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition: Map.h:307
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition: Map.h:308
@ 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 ( )
10161{
10162 uint32 oldMSTime = getMSTime();
10163
10165 PreparedQueryResult result = CharacterDatabase.Query(stmt);
10166
10167 if (!result)
10168 {
10169 // There's no gameobject with this GUID saved on the DB
10170 LOG_INFO("sql.sql", ">> Loaded 0 Instance saved gameobject state data. DB table `instance_saved_go_state_data` is empty.");
10171 return;
10172 }
10173
10174 Field* fields;
10175 uint32 count = 0;
10176 do
10177 {
10178 fields = result->Fetch();
10179 GameobjectInstanceSavedStateList.push_back({ fields[0].Get<uint32>(), fields[1].Get<uint32>(), fields[2].Get<unsigned short>() });
10180 count++;
10181 } while (result->NextRow());
10182
10183 LOG_INFO("server.loading", ">> Loaded {} instance saved gameobject state data in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10184 LOG_INFO("server.loading", " ");
10185}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:50
@ 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 ( )
5855{
5856 uint32 oldMSTime = getMSTime();
5857
5858 // 0 1 2 4
5859 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
5860
5861 if (!result)
5862 {
5863 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `page_text` is empty!");
5864 LOG_INFO("server.loading", " ");
5865 return;
5866 }
5867
5868 uint32 count = 0;
5869 do
5870 {
5871 Field* fields = result->Fetch();
5872
5873 uint16 mapID = fields[0].Get<uint16>();
5874
5875 if (!MapMgr::IsValidMAP(mapID, true))
5876 {
5877 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
5878 continue;
5879 }
5880
5881 InstanceTemplate instanceTemplate;
5882
5883 instanceTemplate.AllowMount = fields[3].Get<bool>();
5884 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
5885 instanceTemplate.ScriptId = sObjectMgr->GetScriptId(fields[2].Get<std::string>());
5886
5887 _instanceTemplateStore[mapID] = instanceTemplate;
5888
5889 ++count;
5890 } while (result->NextRow());
5891
5892 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5893 LOG_INFO("server.loading", " ");
5894}
bool AllowMount
Definition: Map.h:276
uint32 ScriptId
Definition: Map.h:275
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition: MapMgr.cpp:310

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 ( )
2673{
2674 uint32 oldMSTime = getMSTime();
2675
2676 _itemLocaleStore.clear(); // need for reload case
2677
2678 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
2679 if (!result)
2680 return;
2681
2682 do
2683 {
2684 Field* fields = result->Fetch();
2685
2686 uint32 ID = fields[0].Get<uint32>();
2687
2688 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
2689 if (locale == LOCALE_enUS)
2690 continue;
2691
2692 ItemLocale& data = _itemLocaleStore[ID];
2693 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
2694 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
2695 } while (result->NextRow());
2696
2697 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
2698}
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 ( )
3321{
3322 uint32 oldMSTime = getMSTime();
3323
3324 _itemSetNameLocaleStore.clear(); // need for reload case
3325
3326 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3327
3328 if (!result)
3329 return;
3330
3331 do
3332 {
3333 Field* fields = result->Fetch();
3334
3335 uint32 ID = fields[0].Get<uint32>();
3336
3337 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3338 if (locale == LOCALE_enUS)
3339 continue;
3340
3342 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3343 } while (result->NextRow());
3344
3345 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3346}
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 ( )
3349{
3350 uint32 oldMSTime = getMSTime();
3351
3352 _itemSetNameStore.clear(); // needed for reload case
3353
3354 std::set<uint32> itemSetItems;
3355
3356 // fill item set member ids
3357 for (uint32 entryId = 0; entryId < sItemSetStore.GetNumRows(); ++entryId)
3358 {
3359 ItemSetEntry const* setEntry = sItemSetStore.LookupEntry(entryId);
3360 if (!setEntry)
3361 continue;
3362
3363 for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
3364 if (setEntry->itemId[i])
3365 itemSetItems.insert(setEntry->itemId[i]);
3366 }
3367
3368 // 0 1 2
3369 QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
3370
3371 if (!result)
3372 {
3373 LOG_WARN("server.loading", ">> Loaded 0 item set names. DB table `item_set_names` is empty.");
3374 LOG_INFO("server.loading", " ");
3375 return;
3376 }
3377
3378 _itemSetNameStore.rehash(result->GetRowCount());
3379 uint32 count = 0;
3380
3381 do
3382 {
3383 Field* fields = result->Fetch();
3384
3385 uint32 entry = fields[0].Get<uint32>();
3386 if (itemSetItems.find(entry) == itemSetItems.end())
3387 {
3388 LOG_ERROR("sql.sql", "Item set name (Entry: {}) not found in ItemSet.dbc, data useless.", entry);
3389 continue;
3390 }
3391
3392 ItemSetNameEntry& data = _itemSetNameStore[entry];
3393 data.name = fields[1].Get<std::string>();
3394
3395 uint32 invType = fields[2].Get<uint8>();
3396 if (invType >= MAX_INVTYPE)
3397 {
3398 LOG_ERROR("sql.sql", "Item set name (Entry: {}) has wrong InventoryType value ({})", entry, invType);
3399 invType = INVTYPE_NON_EQUIP;
3400 }
3401
3402 data.InventoryType = invType;
3403 itemSetItems.erase(entry);
3404 ++count;
3405 } while (result->NextRow());
3406
3407 if (!itemSetItems.empty())
3408 {
3409 ItemTemplate const* pProto;
3410 for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr)
3411 {
3412 uint32 entry = *itr;
3413 // add data from item_template if available
3414 pProto = sObjectMgr->GetItemTemplate(entry);
3415 if (pProto)
3416 {
3417 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, adding data from `item_template`.", entry);
3418 ItemSetNameEntry& data = _itemSetNameStore[entry];
3419 data.name = pProto->Name1;
3420 data.InventoryType = pProto->InventoryType;
3421 ++count;
3422 }
3423 else
3424 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, set will not display properly.", entry);
3425 }
3426 }
3427
3428 LOG_INFO("server.loading", ">> Loaded {} Item Set Names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3429 LOG_INFO("server.loading", " ");
3430}
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 ( )
2701{
2702 uint32 oldMSTime = getMSTime();
2703
2704 // 0 1 2 3 4 5 6 7 8 9 10 11 12
2705 QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, "
2706 // 13 14 15 16 17 18 19 20
2707 "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, "
2708 // 21 22 23 24 25 26 27 28
2709 "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, StatsCount, stat_type1, "
2710 // 29 30 31 32 33 34 35 36 37 38
2711 "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, "
2712 // 39 40 41 42 43 44 45 46 47
2713 "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, "
2714 // 48 49 50 51 52 53 54 55 56 57 58
2715 "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, "
2716 // 59 60 61 62 63 64 65 66 67 68
2717 "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, "
2718 // 69 70 71 72 73 74 75
2719 "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, "
2720 // 76 77 78 79 80 81 82
2721 "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, "
2722 // 83 84 85 86 87 88 89
2723 "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, "
2724 // 90 91 92 93 94 95 96
2725 "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, "
2726 // 97 98 99 100 101 102 103 104 105
2727 "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, "
2728 // 106 107 108 109 110 111 112 113 114 115 116 117
2729 "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, "
2730 // 118 119 120 121 122 123 124 125
2731 "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
2732 // 126 127 128 129 130 131 132 133
2733 "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
2734 // 134 135 136
2735 "FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
2736
2737 if (!result)
2738 {
2739 LOG_WARN("server.loading", ">> Loaded 0 item templates. DB table `item_template` is empty.");
2740 LOG_INFO("server.loading", " ");
2741 return;
2742 }
2743
2744 _itemTemplateStore.reserve(result->GetRowCount());
2745 uint32 count = 0;
2746 // original inspiration https://github.com/TrinityCore/TrinityCore/commit/0c44bd33ee7b42c924859139a9f4b04cf2b91261
2747 bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
2748
2749 do
2750 {
2751 Field* fields = result->Fetch();
2752
2753 uint32 entry = fields[0].Get<uint32>();
2754
2755 ItemTemplate& itemTemplate = _itemTemplateStore[entry];
2756
2757 itemTemplate.ItemId = entry;
2758 itemTemplate.Class = uint32(fields[1].Get<uint8>());
2759 itemTemplate.SubClass = uint32(fields[2].Get<uint8>());
2760 itemTemplate.SoundOverrideSubclass = int32(fields[3].Get<int8>());
2761 itemTemplate.Name1 = fields[4].Get<std::string>();
2762 itemTemplate.DisplayInfoID = fields[5].Get<uint32>();
2763 itemTemplate.Quality = uint32(fields[6].Get<uint8>());
2764 itemTemplate.Flags = fields[7].Get<uint32>();
2765 itemTemplate.Flags2 = fields[8].Get<uint32>();
2766 itemTemplate.BuyCount = uint32(fields[9].Get<uint8>());
2767 itemTemplate.BuyPrice = int32(fields[10].Get<int64>() * sWorld->getRate((Rates)(RATE_BUYVALUE_ITEM_POOR + itemTemplate.Quality)));
2768 itemTemplate.SellPrice = uint32(fields[11].Get<uint32>() * sWorld->getRate((Rates)(RATE_SELLVALUE_ITEM_POOR + itemTemplate.Quality)));
2769 itemTemplate.InventoryType = uint32(fields[12].Get<uint8>());
2770 itemTemplate.AllowableClass = fields[13].Get<int32>();
2771 itemTemplate.AllowableRace = fields[14].Get<int32>();
2772 itemTemplate.ItemLevel = uint32(fields[15].Get<uint16>());
2773 itemTemplate.RequiredLevel = uint32(fields[16].Get<uint8>());
2774 itemTemplate.RequiredSkill = uint32(fields[17].Get<uint16>());
2775 itemTemplate.RequiredSkillRank = uint32(fields[18].Get<uint16>());
2776 itemTemplate.RequiredSpell = fields[19].Get<uint32>();
2777 itemTemplate.RequiredHonorRank = fields[20].Get<uint32>();
2778 itemTemplate.RequiredCityRank = fields[21].Get<uint32>();
2779 itemTemplate.RequiredReputationFaction = uint32(fields[22].Get<uint16>());
2780 itemTemplate.RequiredReputationRank = uint32(fields[23].Get<uint16>());
2781 itemTemplate.MaxCount = fields[24].Get<int32>();
2782 itemTemplate.Stackable = fields[25].Get<int32>();
2783 itemTemplate.ContainerSlots = uint32(fields[26].Get<uint8>());
2784 itemTemplate.StatsCount = uint32(fields[27].Get<uint8>());
2785
2786 for (uint8 i = 0; i < itemTemplate.StatsCount; ++i)
2787 {
2788 itemTemplate.ItemStat[i].ItemStatType = uint32(fields[28 + i * 2].Get<uint8>());
2789 itemTemplate.ItemStat[i].ItemStatValue = fields[29 + i * 2].Get<int32>();
2790 }
2791
2792 itemTemplate.ScalingStatDistribution = uint32(fields[48].Get<uint16>());
2793 itemTemplate.ScalingStatValue = fields[49].Get<int32>();
2794
2795 for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
2796 {
2797 itemTemplate.Damage[i].DamageMin = fields[50 + i * 3].Get<float>();
2798 itemTemplate.Damage[i].DamageMax = fields[51 + i * 3].Get<float>();
2799 itemTemplate.Damage[i].DamageType = uint32(fields[52 + i * 3].Get<uint8>());
2800 }
2801
2802 itemTemplate.Armor = fields[56].Get<uint32>();
2803 itemTemplate.HolyRes = fields[57].Get<int32>();
2804 itemTemplate.FireRes = fields[58].Get<int32>();
2805 itemTemplate.NatureRes = fields[59].Get<int32>();
2806 itemTemplate.FrostRes = fields[60].Get<int32>();
2807 itemTemplate.ShadowRes = fields[61].Get<int32>();
2808 itemTemplate.ArcaneRes = fields[62].Get<int32>();
2809 itemTemplate.Delay = uint32(fields[63].Get<uint16>());
2810 itemTemplate.AmmoType = uint32(fields[64].Get<uint8>());
2811 itemTemplate.RangedModRange = fields[65].Get<float>();
2812
2813 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
2814 {
2815 itemTemplate.Spells[i].SpellId = fields[66 + i * 7 ].Get<int32>();
2816 itemTemplate.Spells[i].SpellTrigger = uint32(fields[67 + i * 7].Get<uint8>());
2817 itemTemplate.Spells[i].SpellCharges = int32(fields[68 + i * 7].Get<int16>());
2818 itemTemplate.Spells[i].SpellPPMRate = fields[69 + i * 7].Get<float>();
2819 itemTemplate.Spells[i].SpellCooldown = fields[70 + i * 7].Get<int32>();
2820 itemTemplate.Spells[i].SpellCategory = uint32(fields[71 + i * 7].Get<uint16>());
2821 itemTemplate.Spells[i].SpellCategoryCooldown = fields[72 + i * 7].Get<int32>();
2822 }
2823
2824 itemTemplate.Bonding = uint32(fields[101].Get<uint8>());
2825 itemTemplate.Description = fields[102].Get<std::string>();
2826 itemTemplate.PageText = fields[103].Get<uint32>();
2827 itemTemplate.LanguageID = uint32(fields[104].Get<uint8>());
2828 itemTemplate.PageMaterial = uint32(fields[105].Get<uint8>());
2829 itemTemplate.StartQuest = fields[106].Get<uint32>();
2830 itemTemplate.LockID = fields[107].Get<uint32>();
2831 itemTemplate.Material = int32(fields[108].Get<int8>());
2832 itemTemplate.Sheath = uint32(fields[109].Get<uint8>());
2833 itemTemplate.RandomProperty = fields[110].Get<int32>();
2834 itemTemplate.RandomSuffix = fields[111].Get<int32>();
2835 itemTemplate.Block = fields[112].Get<uint32>();
2836 itemTemplate.ItemSet = fields[113].Get<uint32>();
2837 itemTemplate.MaxDurability = uint32(fields[114].Get<uint16>());
2838 itemTemplate.Area = fields[115].Get<uint32>();
2839 itemTemplate.Map = uint32(fields[116].Get<uint16>());
2840 itemTemplate.BagFamily = fields[117].Get<uint32>();
2841 itemTemplate.TotemCategory = fields[118].Get<uint32>();
2842
2843 for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
2844 {
2845 itemTemplate.Socket[i].Color = uint32(fields[119 + i * 2].Get<uint8>());
2846 itemTemplate.Socket[i].Content = fields[120 + i * 2].Get<uint32>();
2847 }
2848
2849 itemTemplate.socketBonus = fields[125].Get<uint32>();
2850 itemTemplate.GemProperties = fields[126].Get<uint32>();
2851 itemTemplate.RequiredDisenchantSkill = uint32(fields[127].Get<int16>());
2852 itemTemplate.ArmorDamageModifier = fields[128].Get<float>();
2853 itemTemplate.Duration = fields[129].Get<uint32>();
2854 itemTemplate.ItemLimitCategory = uint32(fields[130].Get<int16>());
2855 itemTemplate.HolidayId = fields[131].Get<uint32>();
2856 itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].Get<std::string>());
2857 itemTemplate.DisenchantID = fields[133].Get<uint32>();
2858 itemTemplate.FoodType = uint32(fields[134].Get<uint8>());
2859 itemTemplate.MinMoneyLoot = fields[135].Get<uint32>();
2860 itemTemplate.MaxMoneyLoot = fields[136].Get<uint32>();
2861 itemTemplate.FlagsCu = fields[137].Get<uint32>();
2862
2863 // Checks
2864 ItemEntry const* dbcitem = sItemStore.LookupEntry(entry);
2865
2866 if (dbcitem)
2867 {
2868 if (itemTemplate.Class != dbcitem->ClassID)
2869 {
2870 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Class value ({}), must be ({}).", entry, itemTemplate.Class, dbcitem->ClassID);
2871 if (enforceDBCAttributes)
2872 itemTemplate.Class = dbcitem->ClassID;
2873 }
2874 if (itemTemplate.SubClass != dbcitem->SubclassID)
2875 {
2876 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Subclass value ({}) for class {}, must be ({}).", entry, itemTemplate.SubClass, itemTemplate.Class, dbcitem->SubclassID);
2877 if (enforceDBCAttributes)
2878 itemTemplate.SubClass = dbcitem->SubclassID;
2879 }
2880 if (itemTemplate.SoundOverrideSubclass != dbcitem->SoundOverrideSubclassID)
2881 {
2882 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct SoundOverrideSubclass ({}), must be {}.", entry, itemTemplate.SoundOverrideSubclass);
2883 if (enforceDBCAttributes)
2884 itemTemplate.SoundOverrideSubclass = dbcitem->SoundOverrideSubclassID;
2885 }
2886 if (itemTemplate.Material != dbcitem->Material)
2887 {
2888 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct material ({}), must be {}.", entry, itemTemplate.Material, dbcitem->Material);
2889 if (enforceDBCAttributes)
2890 itemTemplate.Material = dbcitem->Material;
2891 }
2892 if (itemTemplate.InventoryType != dbcitem->InventoryType)
2893 {
2894 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong InventoryType value ({}), must be {}.", entry, itemTemplate.InventoryType, dbcitem->InventoryType);
2895 if (enforceDBCAttributes)
2896 itemTemplate.InventoryType = dbcitem->InventoryType;
2897 }
2898 if (itemTemplate.DisplayInfoID != dbcitem->DisplayInfoID)
2899 {
2900 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct display id ({}), must be {}.", entry, itemTemplate.DisplayInfoID, dbcitem->DisplayInfoID);
2901 if (enforceDBCAttributes)
2902 itemTemplate.DisplayInfoID = dbcitem->DisplayInfoID;
2903 }
2904 if (itemTemplate.Sheath != dbcitem->SheatheType)
2905 {
2906 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Sheath ({}), must be {}.", entry, itemTemplate.Sheath, dbcitem->SheatheType);
2907 if (enforceDBCAttributes)
2908 itemTemplate.Sheath = dbcitem->SheatheType;
2909 }
2910 }
2911 else
2912 LOG_ERROR("sql.sql", "Item (Entry: {}) does not exist in item.dbc! (not correct id?).", entry);
2913
2914 if (itemTemplate.Quality >= MAX_ITEM_QUALITY)
2915 {
2916 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Quality value ({})", entry, itemTemplate.Quality);
2917 itemTemplate.Quality = ITEM_QUALITY_NORMAL;
2918 }
2919
2920 if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY)
2921 {
2922 if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
2923 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
2924 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.",
2925 entry, itemTemplate.AllowableRace, ITEM_FLAGS_EXTRA_HORDE_ONLY);
2926
2927 if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY)
2928 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.",
2930 }
2931 else if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY)
2932 {
2933 if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
2934 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
2935 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.",
2936 entry, itemTemplate.AllowableRace, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY);
2937 }
2938
2939 if (itemTemplate.BuyCount <= 0)
2940 {
2941 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong BuyCount value ({}), set to default(1).", entry, itemTemplate.BuyCount);
2942 itemTemplate.BuyCount = 1;
2943 }
2944
2945 if (itemTemplate.RequiredSkill >= MAX_SKILL_TYPE)
2946 {
2947 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RequiredSkill value ({})", entry, itemTemplate.RequiredSkill);
2948 itemTemplate.RequiredSkill = 0;
2949 }
2950
2951 {
2952 // can be used in equip slot, as page read use in inventory, or spell casting at use
2953 bool req = itemTemplate.InventoryType != INVTYPE_NON_EQUIP || itemTemplate.PageText;
2954 if (!req)
2955 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
2956 {
2957 if (itemTemplate.Spells[j].SpellId)
2958 {
2959 req = true;
2960 break;
2961 }
2962 }
2963
2964 if (req)
2965 {
2966 if (!(itemTemplate.AllowableClass & CLASSMASK_ALL_PLAYABLE))
2967 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable classes ({}) in `AllowableClass` and can't be equipped or used.", entry, itemTemplate.AllowableClass);
2968
2969 if (!(itemTemplate.AllowableRace & RACEMASK_ALL_PLAYABLE))
2970 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable races ({}) in `AllowableRace` and can't be equipped or used.", entry, itemTemplate.AllowableRace);
2971 }
2972 }
2973
2974 if (itemTemplate.RequiredSpell && !sSpellMgr->GetSpellInfo(itemTemplate.RequiredSpell))
2975 {
2976 LOG_ERROR("sql.sql", "Item (Entry: {}) has a wrong (non-existing) spell in RequiredSpell ({})", entry, itemTemplate.RequiredSpell);
2977 itemTemplate.RequiredSpell = 0;
2978 }
2979
2980 if (itemTemplate.RequiredReputationRank >= MAX_REPUTATION_RANK)
2981 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong reputation rank in RequiredReputationRank ({}), item can't be used.", entry, itemTemplate.RequiredReputationRank);
2982
2983 if (itemTemplate.RequiredReputationFaction)
2984 {
2985 if (!sFactionStore.LookupEntry(itemTemplate.RequiredReputationFaction))
2986 {
2987 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) faction in RequiredReputationFaction ({})", entry, itemTemplate.RequiredReputationFaction);
2988 itemTemplate.RequiredReputationFaction = 0;
2989 }
2990
2991 if (itemTemplate.RequiredReputationRank == MIN_REPUTATION_RANK)
2992 LOG_ERROR("sql.sql", "Item (Entry: {}) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", entry);
2993 }
2994
2995 if (itemTemplate.MaxCount < -1)
2996 {
2997 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in maxcount ({}), replace by value (-1) no storing limits.", entry, itemTemplate.MaxCount);
2998 itemTemplate.MaxCount = -1;
2999 }
3000
3001 if (itemTemplate.Stackable == 0)
3002 {
3003 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong value in stackable ({}), replace by default 1.", entry, itemTemplate.Stackable);
3004 itemTemplate.Stackable = 1;
3005 }
3006 else if (itemTemplate.Stackable < -1)
3007 {
3008 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in stackable ({}), replace by value (-1) no stacking limits.", entry, itemTemplate.Stackable);
3009 itemTemplate.Stackable = -1;
3010 }
3011
3012 if (itemTemplate.ContainerSlots > MAX_BAG_SIZE)
3013 {
3014 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in ContainerSlots ({}), replace by hardcoded limit ({}).", entry, itemTemplate.ContainerSlots, MAX_BAG_SIZE);
3015 itemTemplate.ContainerSlots = MAX_BAG_SIZE;
3016 }
3017
3018 if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS)
3019 {
3020 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in statscount ({}), replace by hardcoded limit ({}).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS);
3021 itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS;
3022 }
3023
3024 for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
3025 {
3026 // for ItemStatValue != 0
3027 if (itemTemplate.ItemStat[j].ItemStatValue && itemTemplate.ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
3028 {
3029 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (non-existing?) stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3030 itemTemplate.ItemStat[j].ItemStatType = 0;
3031 }
3032
3033 switch (itemTemplate.ItemStat[j].ItemStatType)
3034 {
3037 LOG_ERROR("sql.sql", "Item (Entry: {}) has deprecated stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3038 break;
3039 default:
3040 break;
3041 }
3042 }
3043
3044 for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
3045 {
3046 if (itemTemplate.Damage[j].DamageType >= MAX_SPELL_SCHOOL)
3047 {
3048 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong dmg_type{} ({})", entry, j + 1, itemTemplate.Damage[j].DamageType);
3049 itemTemplate.Damage[j].DamageType = 0;
3050 }
3051 }
3052
3053 // special format
3054 if ((itemTemplate.Spells[0].SpellId == 483) || (itemTemplate.Spells[0].SpellId == 55884))
3055 {
3056 // spell_1
3057 if (itemTemplate.Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3058 {
3059 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);
3060 itemTemplate.Spells[0].SpellId = 0;
3061 itemTemplate.Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3062 itemTemplate.Spells[1].SpellId = 0;
3063 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3064 }
3065
3066 // spell_2 have learning spell
3067 if (itemTemplate.Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3068 {
3069 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);
3070 itemTemplate.Spells[0].SpellId = 0;
3071 itemTemplate.Spells[1].SpellId = 0;
3072 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3073 }
3074 else if (!itemTemplate.Spells[1].SpellId)
3075 {
3076 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have an expected spell in spellid_{} in special learning format.", entry, 1 + 1);
3077 itemTemplate.Spells[0].SpellId = 0;
3078 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3079 }
3080 else if (itemTemplate.Spells[1].SpellId != -1)
3081 {
3082 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
3083 if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
3084 {
3085 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3086 itemTemplate.Spells[0].SpellId = 0;
3087 itemTemplate.Spells[1].SpellId = 0;
3088 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3089 }
3090 // allowed only in special format
3091 else if ((itemTemplate.Spells[1].SpellId == 483) || (itemTemplate.Spells[1].SpellId == 55884))
3092 {
3093 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3094 itemTemplate.Spells[0].SpellId = 0;
3095 itemTemplate.Spells[1].SpellId = 0;
3096 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3097 }
3098 }
3099
3100 // spell_3*, spell_4*, spell_5* is empty
3101 for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
3102 {
3103 if (itemTemplate.Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3104 {
3105 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3106 itemTemplate.Spells[j].SpellId = 0;
3107 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3108 }
3109 else if (itemTemplate.Spells[j].SpellId != 0)
3110 {
3111 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong spell in spellid_{} ({}) for learning special format", entry, j + 1, itemTemplate.Spells[j].SpellId);
3112 itemTemplate.Spells[j].SpellId = 0;
3113 }
3114 }
3115 }
3116 // normal spell list
3117 else
3118 {
3119 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3120 {
3121 if (itemTemplate.Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || itemTemplate.Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3122 {
3123 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3124 itemTemplate.Spells[j].SpellId = 0;
3125 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3126 }
3127
3128 if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
3129 {
3130 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
3131 if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
3132 {
3133 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3134 itemTemplate.Spells[j].SpellId = 0;
3135 }
3136 // allowed only in special format
3137 else if ((itemTemplate.Spells[j].SpellId == 483) || (itemTemplate.Spells[j].SpellId == 55884))
3138 {
3139 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3140 itemTemplate.Spells[j].SpellId = 0;
3141 }
3142 }
3143 }
3144 }
3145
3146 if (itemTemplate.Bonding >= MAX_BIND_TYPE)
3147 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Bonding value ({})", entry, itemTemplate.Bonding);
3148
3149 if (itemTemplate.PageText && !GetPageText(itemTemplate.PageText))
3150 LOG_ERROR("sql.sql", "Item (Entry: {}) has non existing first page (Id:{})", entry, itemTemplate.PageText);
3151
3152 if (itemTemplate.LockID && !sLockStore.LookupEntry(itemTemplate.LockID))
3153 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LockID ({})", entry, itemTemplate.LockID);
3154
3155 if (itemTemplate.RandomProperty)
3156 {
3157 // To be implemented later
3158 if (itemTemplate.RandomProperty == -1)
3159 itemTemplate.RandomProperty = 0;
3160
3161 else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomProperty)))
3162 {
3163 LOG_ERROR("sql.sql", "Item (Entry: {}) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty ({})", entry, itemTemplate.RandomProperty);
3164 itemTemplate.RandomProperty = 0;
3165 }
3166 }
3167
3168 if (itemTemplate.RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomSuffix)))
3169 {
3170 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RandomSuffix ({})", entry, itemTemplate.RandomSuffix);
3171 itemTemplate.RandomSuffix = 0;
3172 }
3173
3174 if (itemTemplate.ItemSet && !sItemSetStore.LookupEntry(itemTemplate.ItemSet))
3175 {
3176 LOG_ERROR("sql.sql", "Item (Entry: {}) have wrong ItemSet ({})", entry, itemTemplate.ItemSet);
3177 itemTemplate.ItemSet = 0;
3178 }
3179
3180 if (itemTemplate.Area && !sAreaTableStore.LookupEntry(itemTemplate.Area))
3181 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Area ({})", entry, itemTemplate.Area);
3182
3183 if (itemTemplate.Map && !sMapStore.LookupEntry(itemTemplate.Map))
3184 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Map ({})", entry, itemTemplate.Map);
3185
3186 if (itemTemplate.BagFamily)
3187 {
3188 // check bits
3189 for (uint32 j = 0; j < sizeof(itemTemplate.BagFamily) * 8; ++j)
3190 {
3191 uint32 mask = 1 << j;
3192 if ((itemTemplate.BagFamily & mask) == 0)
3193 continue;
3194
3195 ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j + 1);
3196 if (!bf)
3197 {
3198 LOG_ERROR("sql.sql", "Item (Entry: {}) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", entry);
3199 itemTemplate.BagFamily &= ~mask;
3200 continue;
3201 }
3202
3204 {
3205 CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemTemplate.ItemId);
3206 if (!ctEntry)
3207 {
3208 LOG_ERROR("sql.sql", "Item (Entry: {}) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit", entry);
3209 itemTemplate.BagFamily &= ~mask;
3210 }
3211 }
3212 }
3213 }
3214
3215 if (itemTemplate.TotemCategory && !sTotemCategoryStore.LookupEntry(itemTemplate.TotemCategory))
3216 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong TotemCategory ({})", entry, itemTemplate.TotemCategory);
3217
3218 for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
3219 {
3220 if (itemTemplate.Socket[j].Color && (itemTemplate.Socket[j].Color & SOCKET_COLOR_ALL) != itemTemplate.Socket[j].Color)
3221 {
3222 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong socketColor_{} ({})", entry, j + 1, itemTemplate.Socket[j].Color);
3223 itemTemplate.Socket[j].Color = 0;
3224 }
3225 }
3226
3227 if (itemTemplate.GemProperties && !sGemPropertiesStore.LookupEntry(itemTemplate.GemProperties))
3228 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong GemProperties ({})", entry, itemTemplate.GemProperties);
3229
3230 if (itemTemplate.FoodType >= MAX_PET_DIET)
3231 {
3232 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong FoodType value ({})", entry, itemTemplate.FoodType);
3233 itemTemplate.FoodType = 0;
3234 }
3235
3236 if (itemTemplate.ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(itemTemplate.ItemLimitCategory))
3237 {
3238 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LimitCategory value ({})", entry, itemTemplate.ItemLimitCategory);
3239 itemTemplate.ItemLimitCategory = 0;
3240 }
3241
3242 if (itemTemplate.HolidayId && !sHolidaysStore.LookupEntry(itemTemplate.HolidayId))
3243 {
3244 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong HolidayId value ({})", entry, itemTemplate.HolidayId);
3245 itemTemplate.HolidayId = 0;
3246 }
3247
3248 if (itemTemplate.FlagsCu & ITEM_FLAGS_CU_DURATION_REAL_TIME && !itemTemplate.Duration)
3249 {
3250 LOG_ERROR("sql.sql", "Item (Entry {}) has flag ITEM_FLAGS_CU_DURATION_REAL_TIME but it does not have duration limit", entry);
3251 itemTemplate.FlagsCu &= ~ITEM_FLAGS_CU_DURATION_REAL_TIME;
3252 }
3253
3254 // Fill categories map
3255 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3256 if (itemTemplate.Spells[i].SpellId && itemTemplate.Spells[i].SpellCategory && itemTemplate.Spells[i].SpellCategoryCooldown)
3257 {
3258 SpellCategoryStore::iterator ct = sSpellsByCategoryStore.find(itemTemplate.Spells[i].SpellCategory);
3259 if (ct != sSpellsByCategoryStore.end())
3260 {
3261 ct->second.emplace(true, itemTemplate.Spells[i].SpellId);
3262 }
3263 else
3264 sSpellsByCategoryStore[itemTemplate.Spells[i].SpellCategory].emplace(true, itemTemplate.Spells[i].SpellId);
3265 }
3266
3267 ++count;
3268 } while (result->NextRow());
3269
3270 // pussywizard:
3271 {
3272 uint32 max = 0;
3273 for (ItemTemplateContainer::const_iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3274 if (itr->first > max)
3275 max = itr->first;
3276 if (max)
3277 {
3278 _itemTemplateStoreFast.clear();
3279 _itemTemplateStoreFast.resize(max + 1, nullptr);
3280 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3281 _itemTemplateStoreFast[itr->first] = &(itr->second);
3282 }
3283 }
3284
3285 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3286 itr->second.InitializeQueryData();
3287
3288 // Check if item templates for DBC referenced character start outfit are present
3289 std::set<uint32> notFoundOutfit;
3290 for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i)
3291 {
3292 CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i);
3293 if (!entry)
3294 continue;
3295
3296 for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
3297 {
3298 if (entry->ItemId[j] <= 0)
3299 continue;
3300
3301 uint32 item_id = entry->ItemId[j];
3302
3303 if (!GetItemTemplate(item_id))
3304 notFoundOutfit.insert(item_id);
3305 }
3306 }
3307
3308 for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr)
3309 LOG_ERROR("sql.sql", "Item (Entry: {}) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr);
3310
3311 LOG_INFO("server.loading", ">> Loaded {} Item Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3312 LOG_INFO("server.loading", " ");
3313}
@ 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:425
@ RATE_BUYVALUE_ITEM_POOR
Definition: IWorld.h:453
@ RATE_SELLVALUE_ITEM_POOR
Definition: IWorld.h:445
#define MAX_OUTFIT_ITEMS
Definition: DBCStructure.h:617
#define MAX_REPUTATION_RANK
Definition: SharedDefines.h:217
#define MIN_REPUTATION_RANK
Definition: SharedDefines.h:216
#define MAX_PET_DIET
Definition: SharedDefines.h:3203
@ ITEM_QUALITY_NORMAL
Definition: SharedDefines.h:302
#define MAX_ITEM_QUALITY
Definition: SharedDefines.h:311
#define MAX_SKILL_TYPE
Definition: SharedDefines.h:2990
@ ALLIANCE
Definition: SharedDefines.h:740
@ HORDE
Definition: SharedDefines.h:739
#define CLASSMASK_ALL_PLAYABLE
Definition: SharedDefines.h:129
#define RACEMASK_ALL_PLAYABLE
Definition: SharedDefines.h:96
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 ( )
1826{
1827 uint32 oldMSTime = getMSTime();
1828
1829 _linkedRespawnStore.clear();
1830 // 0 1 2
1831 QueryResult result = WorldDatabase.Query("SELECT guid, linkedGuid, linkType FROM linked_respawn ORDER BY guid ASC");
1832
1833 if (!result)
1834 {
1835 LOG_WARN("server.loading", ">> Loaded 0 linked respawns. DB table `linked_respawn` is empty.");
1836 LOG_INFO("server.loading", " ");
1837 return;
1838 }
1839
1840 do
1841 {
1842 Field* fields = result->Fetch();
1843
1844 ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
1845 ObjectGuid::LowType linkedGuidLow = fields[1].Get<uint32>();
1846 uint8 linkType = fields[2].Get<uint8>();
1847
1848 ObjectGuid guid, linkedGuid;
1849 bool error = false;
1850 switch (linkType)
1851 {
1853 {
1854 const CreatureData* slave = GetCreatureData(guidLow);
1855 if (!slave)
1856 {
1857 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1858 error = true;
1859 break;
1860 }
1861
1862 const CreatureData* master = GetCreatureData(linkedGuidLow);
1863 if (!master)
1864 {
1865 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1866 error = true;
1867 break;
1868 }
1869
1870 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1871 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1872 {
1873 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1874 error = true;
1875 break;
1876 }
1877
1878 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1879 {
1880 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1881 error = true;
1882 break;
1883 }
1884
1885 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1886 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1887 break;
1888 }
1889 case CREATURE_TO_GO:
1890 {
1891 const CreatureData* slave = GetCreatureData(guidLow);
1892 if (!slave)
1893 {
1894 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1895 error = true;
1896 break;
1897 }
1898
1899 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1900 if (!master)
1901 {
1902 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1903 error = true;
1904 break;
1905 }
1906
1907 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1908 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1909 {
1910 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1911 error = true;
1912 break;
1913 }
1914
1915 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1916 {
1917 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1918 error = true;
1919 break;
1920 }
1921
1922 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1923 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
1924 break;
1925 }
1926 case GO_TO_GO:
1927 {
1928 const GameObjectData* slave = GetGameObjectData(guidLow);
1929 if (!slave)
1930 {
1931 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
1932 error = true;
1933 break;
1934 }
1935
1936 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1937 if (!master)
1938 {
1939 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1940 error = true;
1941 break;
1942 }
1943
1944 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1945 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1946 {
1947 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1948 error = true;
1949 break;
1950 }
1951
1952 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1953 {
1954 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1955 error = true;
1956 break;
1957 }
1958
1959 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
1960 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
1961 break;
1962 }
1963 case GO_TO_CREATURE:
1964 {
1965 const GameObjectData* slave = GetGameObjectData(guidLow);
1966 if (!slave)
1967 {
1968 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
1969 error = true;
1970 break;
1971 }
1972
1973 const CreatureData* master = GetCreatureData(linkedGuidLow);
1974 if (!master)
1975 {
1976 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1977 error = true;
1978 break;
1979 }
1980
1981 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1982 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1983 {
1984 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1985 error = true;
1986 break;
1987 }
1988
1989 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1990 {
1991 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1992 error = true;
1993 break;
1994 }
1995
1996 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
1997 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1998 break;
1999 }
2000 }
2001
2002 if (!error)
2003 _linkedRespawnStore[guid] = linkedGuid;
2004 } while (result->NextRow());
2005
2006 LOG_INFO("server.loading", ">> Loaded {} Linked Respawns In {} ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime));
2007 LOG_INFO("server.loading", " ");
2008}
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 ( )
8933{
8934 uint32 oldMSTime = getMSTime();
8935
8936 _mailLevelRewardStore.clear(); // for reload case
8937
8938 // 0 1 2 3
8939 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
8940
8941 if (!result)
8942 {
8943 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
8944 LOG_INFO("server.loading", " ");
8945 return;
8946 }
8947
8948 uint32 count = 0;
8949
8950 do
8951 {
8952 Field* fields = result->Fetch();
8953
8954 uint8 level = fields[0].Get<uint8>();
8955 uint32 raceMask = fields[1].Get<uint32>();
8956 uint32 mailTemplateId = fields[2].Get<uint32>();
8957 uint32 senderEntry = fields[3].Get<uint32>();
8958
8959 if (level > MAX_LEVEL)
8960 {
8961 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
8962 continue;
8963 }
8964
8965 if (!(raceMask & RACEMASK_ALL_PLAYABLE))
8966 {
8967 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
8968 continue;
8969 }
8970
8971 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
8972 {
8973 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
8974 continue;
8975 }
8976
8977 if (!GetCreatureTemplate(senderEntry))
8978 {
8979 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);
8980 continue;
8981 }
8982
8983 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
8984
8985 ++count;
8986 } while (result->NextRow());
8987
8988 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8989 LOG_INFO("server.loading", " ");
8990}
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
#define MAX_LEVEL
Definition: DBCEnums.h:45
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 ( )
10261{
10262 uint32 oldMSTime = getMSTime();
10263
10264 _serverMailStore.clear(); // for reload case
10265
10266 // 0 1 2 3 4 5 6 7 8 9 10 11
10267 QueryResult result = CharacterDatabase.Query("SELECT `id`, `reqLevel`, `reqPlayTime`, `moneyA`, `moneyH`, `itemA`, `itemCountA`, `itemH`,`itemCountH`, `subject`, `body`, `active` FROM `mail_server_template`");
10268 if (!result)
10269 {
10270 LOG_INFO("sql.sql", ">> Loaded 0 server mail rewards. DB table `mail_server_template` is empty.");
10271 LOG_INFO("server.loading", " ");
10272 return;
10273 }
10274
10275 _serverMailStore.rehash(result->GetRowCount());
10276
10277 do
10278 {
10279 Field* fields = result->Fetch();
10280
10281 uint32 id = fields[0].Get<uint32>();
10282
10283 ServerMail& servMail = _serverMailStore[id];
10284
10285 servMail.id = id;
10286 servMail.reqLevel = fields[1].Get<uint8>();
10287 servMail.reqPlayTime = fields[2].Get<uint32>();
10288 servMail.moneyA = fields[3].Get<uint32>();
10289 servMail.moneyH = fields[4].Get<uint32>();
10290 servMail.itemA = fields[5].Get<uint32>();
10291 servMail.itemCountA = fields[6].Get<uint32>();
10292 servMail.itemH = fields[7].Get<uint32>();
10293 servMail.itemCountH = fields[8].Get<uint32>();
10294 servMail.subject = fields[9].Get<std::string>();
10295 servMail.body = fields[10].Get<std::string>();
10296 servMail.active = fields[11].Get<uint8>();
10297
10298 if (servMail.reqLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
10299 {
10300 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);
10301 return;
10302 }
10303
10304 if (servMail.moneyA > MAX_MONEY_AMOUNT || servMail.moneyH > MAX_MONEY_AMOUNT)
10305 {
10306 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);
10307 return;
10308 }
10309
10310 ItemTemplate const* itemTemplateA = sObjectMgr->GetItemTemplate(servMail.itemA);
10311 if (!itemTemplateA && servMail.itemA)
10312 {
10313 LOG_ERROR("sql.sql", "Table `mail_server_template` has invalid item in itemA {} for id {}, skipped.", servMail.itemA, servMail.id);
10314 return;
10315 }
10316 ItemTemplate const* itemTemplateH = sObjectMgr->GetItemTemplate(servMail.itemH);
10317 if (!itemTemplateH && servMail.itemH)
10318 {
10319 LOG_ERROR("sql.sql", "Table `mail_server_template` has invalid item in itemH {} for id {}, skipped.", servMail.itemH, servMail.id);
10320 return;
10321 }
10322
10323 if (!servMail.itemA && servMail.itemCountA)
10324 {
10325 LOG_ERROR("sql.sql", "Table `mail_server_template` has itemCountA {} with no ItemA, set to 0", servMail.itemCountA);
10326 servMail.itemCountA = 0;
10327 }
10328 if (!servMail.itemH && servMail.itemCountH)
10329 {
10330 LOG_ERROR("sql.sql", "Table `mail_server_template` has itemCountH {} with no ItemH, set to 0", servMail.itemCountH);
10331 servMail.itemCountH = 0;
10332 }
10333 } while (result->NextRow());
10334
10335 LOG_INFO("server.loading", ">> Loaded {} Mail Server Template in {} ms", _serverMailStore.size(), GetMSTimeDiffToNow(oldMSTime));
10336 LOG_INFO("server.loading", " ");
10337}
#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 ( )
7973{
7974 uint32 oldMSTime = getMSTime();
7975
7976 _spellClickInfoStore.clear();
7977 // 0 1 2 3
7978 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
7979
7980 if (!result)
7981 {
7982 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
7983 LOG_INFO("server.loading", " ");
7984 return;
7985 }
7986
7987 uint32 count = 0;
7988
7989 do
7990 {
7991 Field* fields = result->Fetch();
7992
7993 uint32 npc_entry = fields[0].Get<uint32>();
7994 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
7995 if (!cInfo)
7996 {
7997 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
7998 continue;
7999 }
8000
8001 uint32 spellid = fields[1].Get<uint32>();
8002 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
8003 if (!spellinfo)
8004 {
8005 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
8006 continue;
8007 }
8008
8009 uint8 userType = fields[3].Get<uint16>();
8010 if (userType >= SPELL_CLICK_USER_MAX)
8011 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
8012
8013 uint8 castFlags = fields[2].Get<uint8>();
8014 SpellClickInfo info;
8015 info.spellId = spellid;
8016 info.castFlags = castFlags;
8017 info.userType = SpellClickUserTypes(userType);
8018 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
8019
8020 ++count;
8021 } while (result->NextRow());
8022
8023 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
8024 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
8025 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
8026 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
8027 {
8028 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
8029 {
8030 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);
8031 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
8032 }
8033 }
8034
8035 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8036 LOG_INFO("server.loading", " ");
8037}
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: Unit.h:540
SpellClickUserTypes
Definition: SharedDefines.h:652
@ SPELL_CLICK_USER_MAX
Definition: SharedDefines.h:657
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 ( )
6075{
6076 uint32 oldMSTime = getMSTime();
6077
6078 _npcTextLocaleStore.clear(); // need for reload case
6079
6080 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6081 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6082 "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 "
6083 "FROM npc_text_locale");
6084
6085 if (!result)
6086 return;
6087
6088 do
6089 {
6090 Field* fields = result->Fetch();
6091
6092 uint32 ID = fields[0].Get<uint32>();
6093
6094 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6095 if (locale == LOCALE_enUS)
6096 continue;
6097
6099 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6100 {
6101 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6102 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6103 }
6104 } while (result->NextRow());
6105
6106 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6107}
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 ( )
5826{
5827 uint32 oldMSTime = getMSTime();
5828
5829 _pageTextLocaleStore.clear(); // need for reload case
5830
5831 // 0 1 2
5832 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
5833
5834 if (!result)
5835 return;
5836
5837 do
5838 {
5839 Field* fields = result->Fetch();
5840
5841 uint32 ID = fields[0].Get<uint32>();
5842
5843 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5844 if (locale == LOCALE_enUS)
5845 continue;
5846
5848 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
5849 } while (result->NextRow());
5850
5851 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5852}
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 ( )
5776{
5777 uint32 oldMSTime = getMSTime();
5778
5779 // 0 1 2
5780 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
5781
5782 if (!result)
5783 {
5784 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
5785 LOG_INFO("server.loading", " ");
5786 return;
5787 }
5788
5789 uint32 count = 0;
5790 do
5791 {
5792 Field* fields = result->Fetch();
5793
5794 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
5795
5796 pageText.Text = fields[1].Get<std::string>();
5797 pageText.NextPage = fields[2].Get<uint32>();
5798
5799 ++count;
5800 } while (result->NextRow());
5801
5802 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
5803 {
5804 if (itr->second.NextPage)
5805 {
5806 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
5807 if (itr2 == _pageTextStore.end())
5808 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
5809 }
5810 }
5811
5812 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5813 LOG_INFO("server.loading", " ");
5814}
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 ( )
3533{
3534 uint32 oldMSTime = getMSTime();
3535
3536 // 0 1 2 3 4 5 6 7 8 9 10 11
3537 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
3538
3539 if (!result)
3540 {
3541 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
3542 LOG_INFO("server.loading", " ");
3543 return;
3544 }
3545
3546 uint32 count = 0;
3547
3548 do
3549 {
3550 Field* fields = result->Fetch();
3551
3552 uint32 creature_id = fields[0].Get<uint32>();
3553 if (!sObjectMgr->GetCreatureTemplate(creature_id))
3554 {
3555 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
3556 continue;
3557 }
3558
3559 uint32 current_level = fields[1].Get<uint8>();
3560 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3561 {
3562 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
3563 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
3564 else
3565 {
3566 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
3567 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
3568 }
3569 continue;
3570 }
3571 else if (current_level < 1)
3572 {
3573 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
3574 continue;
3575 }
3576
3577 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
3578
3579 if (!pInfoMapEntry)
3580 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
3581
3582 // data for level 1 stored in [0] array element, ...
3583 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
3584
3585 pLevelInfo->health = fields[2].Get<uint32>();
3586 pLevelInfo->mana = fields[3].Get<uint32>();
3587 pLevelInfo->armor = fields[9].Get<uint32>();
3588 pLevelInfo->min_dmg = fields[10].Get<uint32>();
3589 pLevelInfo->max_dmg = fields[11].Get<uint32>();
3590 for (uint8 i = 0; i < MAX_STATS; i++)
3591 {
3592 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
3593 }
3594
3595 ++count;
3596 } while (result->NextRow());
3597
3598 // Fill gaps and check integrity
3599 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
3600 {
3601 PetLevelInfo* pInfo = itr->second;
3602
3603 // fatal error if no level 1 data
3604 if (!pInfo || pInfo[0].health == 0)
3605 {
3606 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
3607 exit(1);
3608 }
3609
3610 // fill level gaps
3611 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
3612 {
3613 if (pInfo[level].health == 0)
3614 {
3615 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
3616 pInfo[level] = pInfo[level - 1];
3617 }
3618 }
3619 }
3620
3621 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3622 LOG_INFO("server.loading", " ");
3623}
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:49
#define MAX_STATS
Definition: SharedDefines.h:237
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 ( )
7485{
7486 uint32 oldMSTime = getMSTime();
7487 // 0 1 2
7488 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
7489
7490 if (!result)
7491 {
7492 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
7493 LOG_INFO("server.loading", " ");
7494 return;
7495 }
7496
7497 uint32 count = 0;
7498
7499 do
7500 {
7501 Field* fields = result->Fetch();
7502 std::string word = fields[0].Get<std::string>();
7503 uint32 entry = fields[1].Get<uint32>();
7504 bool half = fields[2].Get<bool>();
7505 if (half)
7506 _petHalfName1[entry].push_back(word);
7507 else
7508 _petHalfName0[entry].push_back(word);
7509 ++count;
7510 } while (result->NextRow());
7511
7512 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7513 LOG_INFO("server.loading", " ");
7514}

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

◆ LoadPetNamesLocales()

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

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

◆ LoadPetNumber()

void ObjectMgr::LoadPetNumber ( )
7517{
7518 uint32 oldMSTime = getMSTime();
7519
7520 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
7521 if (result)
7522 {
7523 Field* fields = result->Fetch();
7524 _hiPetNumber = fields[0].Get<uint32>() + 1;
7525 }
7526
7527 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
7528 LOG_INFO("server.loading", " ");
7529}

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

◆ LoadPlayerInfo()

void ObjectMgr::LoadPlayerInfo ( )
3672{
3673 // Load playercreate
3674 {
3675 uint32 oldMSTime = getMSTime();
3676 // 0 1 2 3 4 5 6
3677 QueryResult result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
3678
3679 if (!result)
3680 {
3681 LOG_INFO("server.loading", " ");
3682 LOG_WARN("server.loading", ">> Loaded 0 player create definitions. DB table `playercreateinfo` is empty.");
3683 exit(1);
3684 }
3685 else
3686 {
3687 uint32 count = 0;
3688
3689 do
3690 {
3691 Field* fields = result->Fetch();
3692
3693 uint32 current_race = fields[0].Get<uint8>();
3694 uint32 current_class = fields[1].Get<uint8>();
3695 uint32 mapId = fields[2].Get<uint16>();
3696 uint32 areaId = fields[3].Get<uint32>(); // zone
3697 float positionX = fields[4].Get<float>();
3698 float positionY = fields[5].Get<float>();
3699 float positionZ = fields[6].Get<float>();
3700 float orientation = fields[7].Get<float>();
3701
3702 if (current_race >= MAX_RACES)
3703 {
3704 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3705 continue;
3706 }
3707
3708 ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
3709 if (!rEntry)
3710 {
3711 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3712 continue;
3713 }
3714
3715 if (current_class >= MAX_CLASSES)
3716 {
3717 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3718 continue;
3719 }
3720
3721 if (!sChrClassesStore.LookupEntry(current_class))
3722 {
3723 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3724 continue;
3725 }
3726
3727 // accept DB data only for valid position (and non instanceable)
3728 if (!MapMgr::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation))
3729 {
3730 LOG_ERROR("sql.sql", "Wrong home position for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3731 continue;
3732 }
3733
3734 if (sMapStore.LookupEntry(mapId)->Instanceable())
3735 {
3736 LOG_ERROR("sql.sql", "Home position in instanceable map for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3737 continue;
3738 }
3739
3740 PlayerInfo* info = new PlayerInfo();
3741 info->mapId = mapId;
3742 info->areaId = areaId;
3743 info->positionX = positionX;
3744 info->positionY = positionY;
3745 info->positionZ = positionZ;
3746 info->orientation = orientation;
3747 info->displayId_m = rEntry->model_m;
3748 info->displayId_f = rEntry->model_f;
3749 _playerInfo[current_race][current_class] = info;
3750
3751 ++count;
3752 } while (result->NextRow());
3753
3754 LOG_INFO("server.loading", ">> Loaded {} Player Create Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3755 LOG_INFO("server.loading", " ");
3756 }
3757 }
3758
3759 // Load playercreate items
3760 LOG_INFO("server.loading", "Loading Player Create Items Data...");
3761 {
3762 uint32 oldMSTime = getMSTime();
3763 // 0 1 2 3
3764 QueryResult result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
3765
3766 if (!result)
3767 {
3768 LOG_WARN("server.loading", ">> Loaded 0 Custom Player Create Items. DB Table `playercreateinfo_item` Is Empty.");
3769 LOG_INFO("server.loading", " ");
3770 }
3771 else
3772 {
3773 uint32 count = 0;
3774
3775 do
3776 {
3777 Field* fields = result->Fetch();
3778
3779 uint32 current_race = fields[0].Get<uint8>();
3780 if (current_race >= MAX_RACES)
3781 {
3782 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_item` table, ignoring.", current_race);
3783 continue;
3784 }
3785
3786 uint32 current_class = fields[1].Get<uint8>();
3787 if (current_class >= MAX_CLASSES)
3788 {
3789 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_item` table, ignoring.", current_class);
3790 continue;
3791 }
3792
3793 uint32 item_id = fields[2].Get<uint32>();
3794
3795 if (!GetItemTemplate(item_id))
3796 {
3797 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);
3798 continue;
3799 }
3800
3801 int32 amount = fields[3].Get<int32>();
3802
3803 if (!amount)
3804 {
3805 LOG_ERROR("sql.sql", "Item id {} (class {} race {}) have amount == 0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class);
3806 continue;
3807 }
3808
3809 if (!current_race || !current_class)
3810 {
3811 uint32 min_race = current_race ? current_race : 1;
3812 uint32 max_race = current_race ? current_race + 1 : MAX_RACES;
3813 uint32 min_class = current_class ? current_class : 1;
3814 uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
3815 for (uint32 r = min_race; r < max_race; ++r)
3816 for (uint32 c = min_class; c < max_class; ++c)
3817 PlayerCreateInfoAddItemHelper(r, c, item_id, amount);
3818 }
3819 else
3820 PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount);
3821
3822 ++count;
3823 } while (result->NextRow());
3824
3825 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3826 LOG_INFO("server.loading", " ");
3827 }
3828 }
3829
3830 // Load playercreate skills
3831 LOG_INFO("server.loading", "Loading Player Create Skill Data...");
3832 {
3833 uint32 oldMSTime = getMSTime();
3834
3835 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, skill, `rank` FROM playercreateinfo_skills");
3836
3837 if (!result)
3838 {
3839 LOG_WARN("server.loading", ">> Loaded 0 Player Create Skills. DB Table `playercreateinfo_skills` Is Empty.");
3840 }
3841 else
3842 {
3843 uint32 count = 0;
3844
3845 do
3846 {
3847 Field* fields = result->Fetch();
3848 uint32 raceMask = fields[0].Get<uint32>();
3849 uint32 classMask = fields[1].Get<uint32>();
3851 skill.SkillId = fields[2].Get<uint16>();
3852 skill.Rank = fields[3].Get<uint16>();
3853
3854 if (skill.Rank >= MAX_SKILL_STEP)
3855 {
3856 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);
3857 continue;
3858 }
3859
3860 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3861 {
3862 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_skills` table, ignoring.", raceMask);
3863 continue;
3864 }
3865
3866 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3867 {
3868 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_skills` table, ignoring.", classMask);
3869 continue;
3870 }
3871
3872 if (!sSkillLineStore.LookupEntry(skill.SkillId))
3873 {
3874 LOG_ERROR("sql.sql", "Wrong skill id {} in `playercreateinfo_skills` table, ignoring.", skill.SkillId);
3875 continue;
3876 }
3877
3878 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3879 {
3880 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3881 {
3882 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3883 {
3884 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3885 {
3886 if (!GetSkillRaceClassInfo(skill.SkillId, raceIndex, classIndex))
3887 continue;
3888
3889 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3890 {
3891 info->skills.push_back(skill);
3892 ++count;
3893 }
3894 }
3895 }
3896 }
3897 }
3898 } while (result->NextRow());
3899
3900 LOG_INFO("server.loading", ">> Loaded {} Player Create Skills in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3901 LOG_INFO("server.loading", " ");
3902 }
3903 }
3904
3905 // Load playercreate spells
3906 LOG_INFO("server.loading", "Loading Player Create Spell Data...");
3907 {
3908 uint32 oldMSTime = getMSTime();
3909
3910 QueryResult result = WorldDatabase.Query("SELECT racemask, classmask, Spell FROM playercreateinfo_spell_custom");
3911
3912 if (!result)
3913 {
3914 LOG_WARN("server.loading", ">> Loaded 0 player create spells. DB table `playercreateinfo_spell_custom` is empty.");
3915 }
3916 else
3917 {
3918 uint32 count = 0;
3919
3920 do
3921 {
3922 Field* fields = result->Fetch();
3923 uint32 raceMask = fields[0].Get<uint32>();
3924 uint32 classMask = fields[1].Get<uint32>();
3925 uint32 spellId = fields[2].Get<uint32>();
3926
3927 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3928 {
3929 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_spell_custom` table, ignoring.", raceMask);
3930 continue;
3931 }
3932
3933 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3934 {
3935 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_spell_custom` table, ignoring.", classMask);
3936 continue;
3937 }
3938
3939 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3940 {
3941 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
3942 {
3943 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
3944 {
3945 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
3946 {
3947 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
3948 {
3949 info->customSpells.push_back(spellId);
3950 ++count;
3951 }
3952 }
3953 }
3954 }
3955 }
3956 } while (result->NextRow());
3957
3958 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3959 LOG_INFO("server.loading", " ");
3960 }
3961 }
3962
3963 // Load playercreate cast spell
3964 LOG_INFO("server.loading", "Loading Player Create Cast Spell Data...");
3965 {
3966 uint32 oldMSTime = getMSTime();
3967
3968 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
3969
3970 if (!result)
3971 {
3972 LOG_WARN("server.loading", ">> Loaded 0 Player Create Cast Spells. DB Table `playercreateinfo_cast_spell` Is Empty.");
3973 }
3974 else
3975 {
3976 uint32 count = 0;
3977
3978 do
3979 {
3980 Field* fields = result->Fetch();
3981 uint32 raceMask = fields[0].Get<uint32>();
3982 uint32 classMask = fields[1].Get<uint32>();
3983 uint32 spellId = fields[2].Get<uint32>();
3984
3985 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
3986 {
3987 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
3988 continue;
3989 }
3990
3991 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
3992 {
3993 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
3994 continue;
3995 }
3996
3997 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
3998 {
3999 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4000 {
4001 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4002 {
4003 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4004 {
4005 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4006 {
4007 info->castSpells.push_back(spellId);
4008 ++count;
4009 }
4010 }
4011 }
4012 }
4013 }
4014 } while (result->NextRow());
4015
4016 LOG_INFO("server.loading", ">> Loaded {} Player Create Cast Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4017 LOG_INFO("server.loading", " ");
4018 }
4019 }
4020
4021 // Load playercreate actions
4022 LOG_INFO("server.loading", "Loading Player Create Action Data...");
4023 {
4024 uint32 oldMSTime = getMSTime();
4025
4026 // 0 1 2 3 4
4027 QueryResult result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
4028
4029 if (!result)
4030 {
4031 LOG_WARN("server.loading", ">> Loaded 0 Player Create Actions. DB Table `playercreateinfo_action` Is Empty.");
4032 LOG_INFO("server.loading", " ");
4033 }
4034 else
4035 {
4036 uint32 count = 0;
4037
4038 do
4039 {
4040 Field* fields = result->Fetch();
4041
4042 uint32 current_race = fields[0].Get<uint8>();
4043 if (current_race >= MAX_RACES)
4044 {
4045 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_action` table, ignoring.", current_race);
4046 continue;
4047 }
4048
4049 uint32 current_class = fields[1].Get<uint8>();
4050 if (current_class >= MAX_CLASSES)
4051 {
4052 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_action` table, ignoring.", current_class);
4053 continue;
4054 }
4055
4056 if (PlayerInfo* info = _playerInfo[current_race][current_class])
4057 info->action.push_back(PlayerCreateInfoAction(fields[2].Get<uint16>(), fields[3].Get<uint32>(), fields[4].Get<uint16>()));
4058
4059 ++count;
4060 } while (result->NextRow());
4061
4062 LOG_INFO("server.loading", ">> Loaded {} Player Create Actions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4063 LOG_INFO("server.loading", " ");
4064 }
4065 }
4066
4067 // Loading levels data (class only dependent)
4068 LOG_INFO("server.loading", "Loading Player Create Level HP/Mana Data...");
4069 {
4070 uint32 oldMSTime = getMSTime();
4071
4072 // 0 1 2 3
4073 QueryResult result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats");
4074
4075 if (!result)
4076 {
4077 LOG_FATAL("server.loading", ">> Loaded 0 level health/mana definitions. DB table `player_classlevelstats` is empty.");
4078 exit(1);
4079 }
4080
4081 uint32 count = 0;
4082
4083 do
4084 {
4085 Field* fields = result->Fetch();
4086
4087 uint32 current_class = fields[0].Get<uint8>();
4088 if (current_class >= MAX_CLASSES)
4089 {
4090 LOG_ERROR("sql.sql", "Wrong class {} in `player_classlevelstats` table, ignoring.", current_class);
4091 continue;
4092 }
4093
4094 uint8 current_level = fields[1].Get<uint8>(); // Can't be > than STRONG_MAX_LEVEL (hardcoded level maximum) due to var type
4095 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4096 {
4097 LOG_INFO("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_classlevelstats` table, ignoring.", current_level);
4098 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4099 continue;
4100 }
4101
4102 PlayerClassInfo* info = _playerClassInfo[current_class];
4103 if (!info)
4104 {
4105 info = new PlayerClassInfo();
4107 _playerClassInfo[current_class] = info;
4108 }
4109
4110 PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4111
4112 levelInfo.basehealth = fields[2].Get<uint32>();
4113 levelInfo.basemana = fields[3].Get<uint32>();
4114
4115 ++count;
4116 } while (result->NextRow());
4117
4118 // Fill gaps and check integrity
4119 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4120 {
4121 // skip non existed classes
4122 if (!sChrClassesStore.LookupEntry(class_))
4123 continue;
4124
4125 PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
4126
4127 // fatal error if no initial level data
4128 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))
4129 {
4130 LOG_ERROR("sql.sql", "Class {} initial level does not have health/mana data!", class_);
4131 exit(1);
4132 }
4133
4134 // fill level gaps
4135 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4136 {
4137 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))
4138 {
4139 LOG_ERROR("sql.sql", "Class {} level {} does not have health/mana data. Using stats data of level {}.", class_, level + 1, level);
4140 pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1];
4141 }
4142 }
4143 }
4144
4145 LOG_INFO("server.loading", ">> Loaded {} Level Health/Mana Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4146 LOG_INFO("server.loading", " ");
4147 }
4148
4149 // Loading levels data (class/race dependent)
4150 LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
4151 {
4152 struct RaceStats
4153 {
4154 int16 StatModifier[MAX_STATS];
4155 };
4156
4157 std::array<RaceStats, MAX_RACES> raceStatModifiers;
4158
4159 uint32 oldMSTime = getMSTime();
4160
4161 // 0 1 2 3 4 5
4162 QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
4163
4164 if (!raceStatsResult)
4165 {
4166 LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
4167 LOG_INFO("server.loading", " ");
4168 exit(1);
4169 }
4170
4171 do
4172 {
4173 Field* fields = raceStatsResult->Fetch();
4174
4175 uint32 current_race = fields[0].Get<uint8>();
4176 if (current_race >= MAX_RACES)
4177 {
4178 LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
4179 continue;
4180 }
4181
4182 for (uint32 i = 0; i < MAX_STATS; ++i)
4183 raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
4184
4185 } while (raceStatsResult->NextRow());
4186
4187 // 0 1 2 3 4 5 6
4188 QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit FROM player_class_stats");
4189
4190 if (!result)
4191 {
4192 LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
4193 exit(1);
4194 }
4195
4196 uint32 count = 0;
4197
4198 do
4199 {
4200 Field* fields = result->Fetch();
4201
4202 uint32 current_class = fields[0].Get<uint8>();
4203 if (current_class >= MAX_CLASSES)
4204 {
4205 LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
4206 continue;
4207 }
4208
4209 uint32 current_level = fields[1].Get<uint8>();
4210 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4211 {
4212 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4213 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4214 else
4215 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
4216
4217 continue;
4218 }
4219
4220 for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
4221 {
4222 if (PlayerInfo* info = _playerInfo[race][current_class])
4223 {
4224 if (!info->levelInfo)
4225 info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4226
4227 PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4228 for (int i = 0; i < MAX_STATS; ++i)
4229 levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
4230 }
4231 }
4232
4233 ++count;
4234 } while (result->NextRow());
4235
4236 // Fill gaps and check integrity
4237 for (int race = 0; race < MAX_RACES; ++race)
4238 {
4239 // skip non existed races
4240 if (!sChrRacesStore.LookupEntry(race))
4241 continue;
4242
4243 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4244 {
4245 // skip non existed classes
4246 if (!sChrClassesStore.LookupEntry(class_))
4247 continue;
4248
4249 PlayerInfo* info = _playerInfo[race][class_];
4250 if (!info)
4251 continue;
4252
4253 // skip expansion races if not playing with expansion
4254 if (sWorld->getIntConfig(CONFIG_EXPANSION) < EXPANSION_THE_BURNING_CRUSADE && (race == RACE_BLOODELF || race == RACE_DRAENEI))
4255 continue;
4256
4257 // skip expansion classes if not playing with expansion
4259 continue;
4260
4261 // fatal error if no initial level data
4262 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))
4263 {
4264 LOG_ERROR("sql.sql", "Race {} class {} initial level does not have stats data!", race, class_);
4265 exit(1);
4266 }
4267
4268 // fill level gaps
4269 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4270 {
4271 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))
4272 {
4273 LOG_ERROR("sql.sql", "Race {} class {} level {} does not have stats data. Using stats data of level {}.", race, class_, level + 1, level);
4274 info->levelInfo[level] = info->levelInfo[level - 1];
4275 }
4276 }
4277 }
4278 }
4279
4280 LOG_INFO("server.loading", ">> Loaded {} Level Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4281 LOG_INFO("server.loading", " ");
4282 }
4283
4284 // Loading xp per level data
4285 LOG_INFO("server.loading", "Loading Player Create XP Data...");
4286 {
4287 uint32 oldMSTime = getMSTime();
4288
4289 _playerXPperLevel.resize(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
4290 for (uint8 level = 0; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4291 _playerXPperLevel[level] = 0;
4292
4293 // 0 1
4294 QueryResult result = WorldDatabase.Query("SELECT Level, Experience FROM player_xp_for_level");
4295
4296 if (!result)
4297 {
4298 LOG_WARN("server.loading", ">> Loaded 0 xp for level definitions. DB table `player_xp_for_level` is empty.");
4299 LOG_INFO("server.loading", " ");
4300 exit(1);
4301 }
4302
4303 uint32 count = 0;
4304
4305 do
4306 {
4307 Field* fields = result->Fetch();
4308
4309 uint32 current_level = fields[0].Get<uint8>();
4310 uint32 current_xp = fields[1].Get<uint32>();
4311
4312 if (current_level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4313 {
4314 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4315 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4316 else
4317 {
4318 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_xp_for_levels` table, ignoring.", current_level);
4319 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4320 }
4321 continue;
4322 }
4323 //PlayerXPperLevel
4324 _playerXPperLevel[current_level] = current_xp;
4325 ++count;
4326 } while (result->NextRow());
4327
4328 // fill level gaps
4329 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4330 {
4331 if (_playerXPperLevel[level] == 0)
4332 {
4333 LOG_ERROR("sql.sql", "Level {} does not have XP for level data. Using data of level [{}] + 100.", level + 1, level);
4334 _playerXPperLevel[level] = _playerXPperLevel[level - 1] + 100;
4335 }
4336 }
4337
4338 LOG_INFO("server.loading", ">> Loaded {} XP For Level Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4339 LOG_INFO("server.loading", " ");
4340 }
4341}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:155
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:118
@ RACE_DRAENEI
Definition: SharedDefines.h:80
@ RACE_BLOODELF
Definition: SharedDefines.h:79
@ RACE_HUMAN
Definition: SharedDefines.h:70
@ EXPANSION_THE_BURNING_CRUSADE
Definition: SharedDefines.h:53
@ EXPANSION_WRATH_OF_THE_LICH_KING
Definition: SharedDefines.h:54
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:3637
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_FATAL, 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 ( )
550{
551 uint32 oldMSTime = getMSTime();
552
553 _pointOfInterestLocaleStore.clear(); // need for reload case
554
555 // 0 1 2
556 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale");
557
558 if (!result)
559 return;
560
561 do
562 {
563 Field* fields = result->Fetch();
564
565 uint32 ID = fields[0].Get<uint32>();
566
567 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
568 if (locale == LOCALE_enUS)
569 continue;
570
572 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
573 } while (result->NextRow());
574
575 LOG_INFO("server.loading", ">> Loaded {} Points Of Interest Locale Strings in {} ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
576}
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 ( )
7842{
7843 uint32 oldMSTime = getMSTime();
7844
7845 _pointsOfInterestStore.clear(); // need for reload case
7846
7847 uint32 count = 0;
7848
7849 // 0 1 2 3 4 5 6
7850 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
7851
7852 if (!result)
7853 {
7854 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
7855 LOG_INFO("server.loading", " ");
7856 return;
7857 }
7858
7859 do
7860 {
7861 Field* fields = result->Fetch();
7862
7863 uint32 point_id = fields[0].Get<uint32>();
7864
7865 PointOfInterest POI;
7866 POI.ID = point_id;
7867 POI.PositionX = fields[1].Get<float>();
7868 POI.PositionY = fields[2].Get<float>();
7869 POI.Icon = fields[3].Get<uint32>();
7870 POI.Flags = fields[4].Get<uint32>();
7871 POI.Importance = fields[5].Get<uint32>();
7872 POI.Name = fields[6].Get<std::string>();
7873
7874 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
7875 {
7876 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
7877 continue;
7878 }
7879
7880 _pointsOfInterestStore[point_id] = POI;
7881
7882 ++count;
7883 } while (result->NextRow());
7884
7885 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7886 LOG_INFO("server.loading", " ");
7887}
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 ( )
8236{
8237 uint32 oldMSTime = getMSTime();
8238
8239 _profanityNamesStore.clear(); // need for reload case
8240
8241 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
8242
8243 if (!result)
8244 {
8245 LOG_WARN("server.loading", ">> Loaded 0 profanity player names. DB table `profanity_name` is empty!");
8246 LOG_INFO("server.loading", " ");
8247 return;
8248 }
8249
8250 uint32 count = 0;
8251
8252 Field* fields;
8253 do
8254 {
8255 fields = result->Fetch();
8256 std::string name = fields[0].Get<std::string>();
8257
8258 std::wstring wstr;
8259 if (!Utf8toWStr (name, wstr))
8260 {
8261 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
8262 continue;
8263 }
8264
8265 wstrToLower(wstr);
8266
8267 _profanityNamesStore.insert(wstr);
8268 ++count;
8269 } while (result->NextRow());
8270
8271 LOG_INFO("server.loading", ">> Loaded {} profanity player names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8272 LOG_INFO("server.loading", " ");
8273}

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

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6233{
6234 uint32 oldMSTime = getMSTime();
6235
6236 _questAreaTriggerStore.clear(); // need for reload case
6237
6238 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6239
6240 if (!result)
6241 {
6242 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6243 LOG_INFO("server.loading", " ");
6244 return;
6245 }
6246
6247 uint32 count = 0;
6248
6249 do
6250 {
6251 ++count;
6252
6253 Field* fields = result->Fetch();
6254
6255 uint32 trigger_ID = fields[0].Get<uint32>();
6256 uint32 quest_ID = fields[1].Get<uint32>();
6257
6258 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6259 if (!atEntry)
6260 {
6261 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6262 continue;
6263 }
6264
6265 Quest const* quest = GetQuestTemplate(quest_ID);
6266
6267 if (!quest)
6268 {
6269 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6270 continue;
6271 }
6272
6274 {
6275 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);
6276
6277 // this will prevent quest completing without objective
6278 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6279
6280 // continue; - quest modified to required objective and trigger can be allowed.
6281 }
6282
6283 _questAreaTriggerStore[trigger_ID] = quest_ID;
6284 } while (result->NextRow());
6285
6286 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6287 LOG_INFO("server.loading", " ");
6288}
@ 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 ( )
6304{
6305 uint32 oldMSTime = getMSTime();
6306
6307 for (std::size_t i = 0; i < _questGreetingStore.size(); ++i)
6308 _questGreetingStore[i].clear();
6309
6310 // 0 1 2 3 4
6311 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6312 if (!result)
6313 {
6314 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6315 return;
6316 }
6317
6318 uint32 count = 0;
6319
6320 do
6321 {
6322 Field* fields = result->Fetch();
6323
6324 uint32 id = fields[0].Get<uint32>();
6325 uint8 type = fields[1].Get<uint8>();
6326 switch (type)
6327 {
6328 case 0: // Creature
6329 if (!sObjectMgr->GetCreatureTemplate(id))
6330 {
6331 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6332 continue;
6333 }
6334 break;
6335 case 1: // GameObject
6336 if (!sObjectMgr->GetGameObjectTemplate(id))
6337 {
6338 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6339 continue;
6340 }
6341 break;
6342 default:
6343 continue;
6344 }
6345
6346 uint16 greetEmoteType = fields[2].Get<uint16>();
6347 uint32 greetEmoteDelay = fields[3].Get<uint32>();
6348 std::string greeting = fields[4].Get<std::string>();
6349
6350 _questGreetingStore[type].emplace(std::piecewise_construct, std::forward_as_tuple(id), std::forward_as_tuple(greetEmoteType, greetEmoteDelay, std::move(greeting)));
6351
6352 ++count;
6353 }
6354 while (result->NextRow());
6355
6356 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6357 LOG_INFO("server.loading", " ");
6358}

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

◆ LoadQuestGreetingsLocales()

void ObjectMgr::LoadQuestGreetingsLocales ( )
6361{
6362 uint32 oldMSTime = getMSTime();
6363
6365
6366 // 0 1 2 3
6367 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6368 if (!result)
6369 {
6370 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
6371 return;
6372 }
6373
6374 uint32 count = 0;
6375
6376 do
6377 {
6378 Field* fields = result->Fetch();
6379
6380 uint32 id = fields[0].Get<uint32>();
6381 uint8 type = fields[1].Get<uint8>();
6382 switch (type)
6383 {
6384 case 0: // Creature
6385 if (!sObjectMgr->GetCreatureTemplate(id))
6386 {
6387 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
6388 continue;
6389 }
6390 break;
6391 case 1: // GameObject
6392 if (!sObjectMgr->GetGameObjectTemplate(id))
6393 {
6394 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
6395 continue;
6396 }
6397 break;
6398 default:
6399 continue;
6400 }
6401
6402 std::string localeName = fields[2].Get<std::string>();
6403
6404 LocaleConstant locale = GetLocaleByName(localeName);
6405 if (locale == LOCALE_enUS)
6406 continue;
6407
6409 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
6410
6411 ++count;
6412 } while (result->NextRow());
6413
6414 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", (uint32)_questGreetingLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6415 LOG_INFO("server.loading", " ");
6416}
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 ( )
5197{
5198 uint32 oldMSTime = getMSTime();
5199
5200 _questLocaleStore.clear(); // need for reload case
5201
5202 // 0 1 2 3 4 5 6 7 8 9 10
5203 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5204
5205 if (!result)
5206 return;
5207
5208 do
5209 {
5210 Field* fields = result->Fetch();
5211
5212 uint32 ID = fields[0].Get<uint32>();
5213
5214 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5215 if (locale == LOCALE_enUS)
5216 continue;
5217
5218 QuestLocale& data = _questLocaleStore[ID];
5219 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5220 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5221 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5222 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5223 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5224
5225 for (uint8 i = 0; i < 4; ++i)
5226 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5227 } while (result->NextRow());
5228
5229 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5230}
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 ( )
10113{
10114 uint32 oldMSTime = getMSTime();
10115
10116 _questMoneyRewards.clear();
10117
10118 // 0 1 2 3 4 5 6 7 8 9 10
10119 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
10120 if (!result)
10121 {
10122 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
10123 return;
10124 }
10125
10126 uint32 count = 0;
10127 do
10128 {
10129 Field* fields = result->Fetch();
10130 uint32 Level = fields[0].Get<uint32>();
10131
10132 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
10133 questMoneyReward.fill(0);
10134
10135 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
10136 {
10137 questMoneyReward[i] = fields[1 + i].Get<uint32>();
10138 ++count;
10139 }
10140 } while (result->NextRow());
10141
10142 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10143 LOG_INFO("server.loading", " ");
10144}
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 ( )
6419{
6420 uint32 oldMSTime = getMSTime();
6421
6422 _questOfferRewardLocaleStore.clear(); // need for reload case
6423
6424 // 0 1 2
6425 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
6426 if (!result)
6427 return;
6428
6429 do
6430 {
6431 Field* fields = result->Fetch();
6432
6433 uint32 id = fields[0].Get<uint32>();
6434 std::string localeName = fields[1].Get<std::string>();
6435
6436 LocaleConstant locale = GetLocaleByName(localeName);
6437 if (locale == LOCALE_enUS)
6438 continue;
6439
6441 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
6442 } while (result->NextRow());
6443
6444 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6445}
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 ( )
7890{
7891 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
7892 {
7893 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
7894 LOG_INFO("server.loading", " ");
7895 return;
7896 }
7897
7898 uint32 oldMSTime = getMSTime();
7899
7900 _questPOIStore.clear(); // need for reload case
7901
7902 uint32 count = 0;
7903
7904 // 0 1 2 3 4 5 6 7
7905 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
7906
7907 if (!result)
7908 {
7909 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
7910 LOG_INFO("server.loading", " ");
7911 return;
7912 }
7913
7914 // 0 1 2 3
7915 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
7916
7917 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
7918
7919 if (points)
7920 {
7921 // The first result should have the highest questId
7922 Field* fields = points->Fetch();
7923 uint32 questIdMax = fields[0].Get<uint32>();
7924 POIs.resize(questIdMax + 1);
7925
7926 do
7927 {
7928 fields = points->Fetch();
7929
7930 uint32 questId = fields[0].Get<uint32>();
7931 uint32 id = fields[1].Get<uint32>();
7932 int32 x = fields[2].Get<int32>();
7933 int32 y = fields[3].Get<int32>();
7934
7935 if (POIs[questId].size() <= id + 1)
7936 POIs[questId].resize(id + 10);
7937
7938 QuestPOIPoint point(x, y);
7939 POIs[questId][id].push_back(point);
7940 } while (points->NextRow());
7941 }
7942
7943 do
7944 {
7945 Field* fields = result->Fetch();
7946
7947 uint32 questId = fields[0].Get<uint32>();
7948 uint32 id = fields[1].Get<uint32>();
7949 int32 objIndex = fields[2].Get<int32>();
7950 uint32 mapId = fields[3].Get<uint32>();
7951 uint32 WorldMapAreaId = fields[4].Get<uint32>();
7952 uint32 FloorId = fields[5].Get<uint32>();
7953 uint32 unk3 = fields[6].Get<uint32>();
7954 uint32 unk4 = fields[7].Get<uint32>();
7955
7956 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
7957 if (questId < POIs.size() && id < POIs[questId].size())
7958 {
7959 POI.points = POIs[questId][id];
7960 _questPOIStore[questId].push_back(POI);
7961 }
7962 else
7963 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
7964
7965 ++count;
7966 } while (result->NextRow());
7967
7968 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7969 LOG_INFO("server.loading", " ");
7970}
@ 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
8060{
8061 uint32 oldMSTime = getMSTime();
8062
8063 map.clear(); // need for reload case
8064
8065 uint32 count = 0;
8066
8067 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8068
8069 if (!result)
8070 {
8071 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8072 LOG_INFO("server.loading", " ");
8073 return;
8074 }
8075
8076 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8077 if (starter)
8078 poolRelationMap->clear();
8079
8080 do
8081 {
8082 uint32 id = result->Fetch()[0].Get<uint32>();
8083 uint32 quest = result->Fetch()[1].Get<uint32>();
8084 uint32 poolId = result->Fetch()[2].Get<uint32>();
8085
8086 if (_questTemplates.find(quest) == _questTemplates.end())
8087 {
8088 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8089 continue;
8090 }
8091
8092 if (!poolId || !starter)
8093 map.insert(QuestRelations::value_type(id, quest));
8094 else if (starter)
8095 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8096
8097 ++count;
8098 } while (result->NextRow());
8099
8100 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8101 LOG_INFO("server.loading", " ");
8102}
#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 ( )
6448{
6449 uint32 oldMSTime = getMSTime();
6450
6451 _questRequestItemsLocaleStore.clear(); // need for reload case
6452
6453 // 0 1 2
6454 QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale");
6455 if (!result)
6456 return;
6457
6458 do
6459 {
6460 Field* fields = result->Fetch();
6461
6462 uint32 id = fields[0].Get<uint32>();
6463 std::string localeName = fields[1].Get<std::string>();
6464
6465 LocaleConstant locale = GetLocaleByName(localeName);
6466 if (locale == LOCALE_enUS)
6467 continue;
6468
6470 AddLocaleString(fields[2].Get<std::string>(), locale, data.CompletionText);
6471 } while (result->NextRow());
6472
6473 LOG_INFO("server.loading", ">> Loaded {} Quest Request Items Locale Strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6474}
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 ( )
4448{
4449 uint32 oldMSTime = getMSTime();
4450
4451 // For reload case
4452 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4453 delete itr->second;
4454 _questTemplates.clear();
4455
4456 mExclusiveQuestGroups.clear();
4457
4458 QueryResult result = WorldDatabase.Query("SELECT "
4459 //0 1 2 3 4 5 6 7 8
4460 "ID, QuestType, QuestLevel, MinLevel, QuestSortID, QuestInfoID, SuggestedGroupNum, TimeAllowed, AllowableRaces,"
4461 // 9 10 11 12
4462 "RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2, "
4463 // 13 14 15 16 17 18 19 20 21
4464 "RewardNextQuest, RewardXPDifficulty, RewardMoney, RewardMoneyDifficulty, RewardBonusMoney, RewardDisplaySpell, RewardSpell, RewardHonor, RewardKillHonor, "
4465 // 22 23 24 25 26 27
4466 "StartItem, Flags, RewardTitle, RequiredPlayerKills, RewardTalents, RewardArenaPoints, "
4467 // 28 29 30 31 32 33 34 35
4468 "RewardItem1, RewardAmount1, RewardItem2, RewardAmount2, RewardItem3, RewardAmount3, RewardItem4, RewardAmount4, "
4469 // 36 37 38 39 40 41 42 43 44 45 46 47
4470 "RewardChoiceItemID1, RewardChoiceItemQuantity1, RewardChoiceItemID2, RewardChoiceItemQuantity2, RewardChoiceItemID3, RewardChoiceItemQuantity3, RewardChoiceItemID4, RewardChoiceItemQuantity4, RewardChoiceItemID5, RewardChoiceItemQuantity5, RewardChoiceItemID6, RewardChoiceItemQuantity6, "
4471 // 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
4472 "RewardFactionID1, RewardFactionValue1, RewardFactionOverride1, RewardFactionID2, RewardFactionValue2, RewardFactionOverride2, RewardFactionID3, RewardFactionValue3, RewardFactionOverride3, RewardFactionID4, RewardFactionValue4, RewardFactionOverride4, RewardFactionID5, RewardFactionValue5, RewardFactionOverride5,"
4473 // 62 64 65 66
4474 "POIContinent, POIx, POIy, POIPriority, "
4475 // 67 68 69 70 71
4476 "LogTitle, LogDescription, QuestDescription, AreaDescription, QuestCompletionLog, "
4477 // 72 73 74 75 76 77 78 79
4478 "RequiredNpcOrGo1, RequiredNpcOrGo2, RequiredNpcOrGo3, RequiredNpcOrGo4, RequiredNpcOrGoCount1, RequiredNpcOrGoCount2, RequiredNpcOrGoCount3, RequiredNpcOrGoCount4, "
4479 // 80 81 82 83 84 85 86 87
4480 "ItemDrop1, ItemDrop2, ItemDrop3, ItemDrop4, ItemDropQuantity1, ItemDropQuantity2, ItemDropQuantity3, ItemDropQuantity4, "
4481 // 88 89 90 91 92 93 94 95 96 97 98 99
4482 "RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
4483 // 100 101 102 103 104
4484 "Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4"
4485 " FROM quest_template");
4486 if (!result)
4487 {
4488 LOG_WARN("server.loading", ">> Loaded 0 quests definitions. DB table `quest_template` is empty.");
4489 LOG_INFO("server.loading", " ");
4490 return;
4491 }
4492
4493 // create multimap previous quest for each existed quest
4494 // some quests can have many previous maps set by NextQuestId in previous quest
4495 // for example set of race quests can lead to single not race specific quest
4496 do
4497 {
4498 Field* fields = result->Fetch();
4499
4500 Quest* newQuest = new Quest(fields);
4501 _questTemplates[newQuest->GetQuestId()] = newQuest;
4502 } while (result->NextRow());
4503
4504 // pussywizard:
4505 {
4506 uint32 max = 0;
4507 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4508 if (itr->first > max)
4509 max = itr->first;
4510 if (max)
4511 {
4512 _questTemplatesFast.clear();
4513 _questTemplatesFast.resize(max + 1, nullptr);
4514 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4515 _questTemplatesFast[itr->first] = itr->second;
4516 }
4517 }
4518
4519 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4520 itr->second->InitializeQueryData();
4521
4522 std::map<uint32, uint32> usedMailTemplates;
4523
4524 // Load `quest_details`
4525 // 0 1 2 3 4 5 6 7 8
4526 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4 FROM quest_details");
4527
4528 if (!result)
4529 {
4530 LOG_WARN("server.loading", ">> Loaded 0 quest details. DB table `quest_details` 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->LoadQuestDetails(fields);
4542 else
4543 LOG_ERROR("sql.sql", "Table `quest_details` has data for quest {} but such quest does not exist", questId);
4544 } while (result->NextRow());
4545 }
4546
4547 // Load `quest_request_items`
4548 // 0 1 2 3
4549 result = WorldDatabase.Query("SELECT ID, EmoteOnComplete, EmoteOnIncomplete, CompletionText FROM quest_request_items");
4550
4551 if (!result)
4552 {
4553 LOG_WARN("server.loading", ">> Loaded 0 quest request items. DB table `quest_request_items` is empty.");
4554 }
4555 else
4556 {
4557 do
4558 {
4559 Field* fields = result->Fetch();
4560 uint32 questId = fields[0].Get<uint32>();
4561
4562 auto itr = _questTemplates.find(questId);
4563 if (itr != _questTemplates.end())
4564 itr->second->LoadQuestRequestItems(fields);
4565 else
4566 LOG_ERROR("sql.sql", "Table `quest_request_items` has data for quest {} but such quest does not exist", questId);
4567 } while (result->NextRow());
4568 }
4569
4570 // Load `quest_offer_reward`
4571 // 0 1 2 3 4 5 6 7 8 9
4572 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4, RewardText FROM quest_offer_reward");
4573
4574 if (!result)
4575 {
4576 LOG_WARN("server.loading", ">> Loaded 0 quest reward emotes. DB table `quest_offer_reward` is empty.");
4577 }
4578 else
4579 {
4580 do
4581 {
4582 Field* fields = result->Fetch();
4583 uint32 questId = fields[0].Get<uint32>();
4584
4585 auto itr = _questTemplates.find(questId);
4586 if (itr != _questTemplates.end())
4587 itr->second->LoadQuestOfferReward(fields);
4588 else
4589 LOG_ERROR("sql.sql", "Table `quest_offer_reward` has data for quest {} but such quest does not exist", questId);
4590 } while (result->NextRow());
4591 }
4592
4593 // Load `quest_template_addon`
4594 // 0 1 2 3 4 5 6 7 8
4595 result = WorldDatabase.Query("SELECT ID, MaxLevel, AllowableClasses, SourceSpellID, PrevQuestID, NextQuestID, ExclusiveGroup, RewardMailTemplateID, RewardMailDelay, "
4596 //9 10 11 12 13 14 15 16 17
4597 "RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, RewardMailSenderEntry, SpecialFlags FROM quest_template_addon LEFT JOIN quest_mail_sender ON Id=QuestId");
4598
4599 if (!result)
4600 {
4601 LOG_WARN("server.loading", ">> Loaded 0 quest template addons. DB table `quest_template_addon` is empty.");
4602 }
4603 else
4604 {
4605 do
4606 {
4607 Field* fields = result->Fetch();
4608 uint32 questId = fields[0].Get<uint32>();
4609
4610 auto itr = _questTemplates.find(questId);
4611 if (itr != _questTemplates.end())
4612 itr->second->LoadQuestTemplateAddon(fields);
4613 else
4614 LOG_ERROR("sql.sql", "Table `quest_template_addon` has data for quest {} but such quest does not exist", questId);
4615 } while (result->NextRow());
4616 }
4617
4618 // Post processing
4619 for (QuestMap::iterator iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter)
4620 {
4621 // skip post-loading checks for disabled quests
4622 if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr))
4623 continue;
4624
4625 Quest* qinfo = iter->second;
4626
4627 // additional quest integrity checks (GO, creature_template and item_template must be loaded already)
4628
4629 if (qinfo->GetQuestMethod() >= 3)
4630 LOG_ERROR("sql.sql", "Quest {} has `Method` = {}, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod());
4631
4633 {
4634 LOG_ERROR("sql.sql", "Quest {} has `SpecialFlags` = {} > max allowed value. Correct `SpecialFlags` to value <= {}",
4637 }
4638
4639 if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY)
4640 {
4641 LOG_ERROR("sql.sql", "Weekly Quest {} is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId());
4642 qinfo->Flags &= ~QUEST_FLAGS_DAILY;
4643 }
4644
4645 if (qinfo->Flags & QUEST_FLAGS_DAILY)
4646 {
4648 {
4649 LOG_ERROR("sql.sql", "Daily Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4651 }
4652 }
4653
4654 if (qinfo->Flags & QUEST_FLAGS_WEEKLY)
4655 {
4657 {
4658 LOG_ERROR("sql.sql", "Weekly Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4660 }
4661 }
4662
4664 {
4666 {
4667 LOG_ERROR("sql.sql", "Monthly quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4669 }
4670 }
4671
4672 if (qinfo->Flags & QUEST_FLAGS_TRACKING)
4673 {
4674 // at auto-reward can be rewarded only RewardChoiceItemId[0]
4675 for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j )
4676 {
4677 if (uint32 id = qinfo->RewardChoiceItemId[j])
4678 {
4679 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item from `RewardChoiceItemId{}` can't be rewarded with quest flag QUEST_FLAGS_TRACKING.",
4680 qinfo->GetQuestId(), j + 1, id, j + 1);
4681 // no changes, quest ignore this data
4682 }
4683 }
4684 }
4685
4686 // client quest log visual (area case)
4687 if (qinfo->ZoneOrSort > 0)
4688 {
4689 if (!sAreaTableStore.LookupEntry(qinfo->ZoneOrSort))
4690 {
4691 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (zone case) but zone with this id does not exist.",
4692 qinfo->GetQuestId(), qinfo->ZoneOrSort);
4693 // no changes, quest not dependent from this value but can have problems at client
4694 }
4695 }
4696 // client quest log visual (sort case)
4697 if (qinfo->ZoneOrSort < 0)
4698 {
4699 QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort));
4700 if (!qSort)
4701 {
4702 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (sort case) but quest sort with this id does not exist.",
4703 qinfo->GetQuestId(), qinfo->ZoneOrSort);
4704 // 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)
4705 }
4706 //check for proper RequiredSkillId value (skill case)
4707 if (uint32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
4708 {
4709 if (qinfo->RequiredSkillId != skill_id)
4710 {
4711 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} but `RequiredSkillId` does not have a corresponding value ({}).",
4712 qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id);
4713 //override, and force proper value here?
4714 }
4715 }
4716 }
4717
4718 // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class
4719 if (qinfo->RequiredClasses)
4720 {
4722 {
4723 LOG_ERROR("sql.sql", "Quest {} does not contain any playable classes in `RequiredClasses` ({}), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses);
4724 qinfo->RequiredClasses = 0;
4725 }
4726 }
4727 // AllowableRaces, can be 0/RACEMASK_ALL_PLAYABLE to allow any race
4728 if (qinfo->AllowableRaces)
4729 {
4730 if (!(qinfo->AllowableRaces & RACEMASK_ALL_PLAYABLE))
4731 {
4732 LOG_ERROR("sql.sql", "Quest {} does not contain any playable races in `AllowableRaces` ({}), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->AllowableRaces);
4733 qinfo->AllowableRaces = 0;
4734 }
4735 }
4736 // RequiredSkillId, can be 0
4737 if (qinfo->RequiredSkillId)
4738 {
4739 if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId))
4740 {
4741 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillId` = {} but this skill does not exist",
4742 qinfo->GetQuestId(), qinfo->RequiredSkillId);
4743 }
4744 }
4745
4746 if (qinfo->RequiredSkillPoints)
4747 {
4748 if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue())
4749 {
4750 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillPoints` = {} but max possible skill is {}, quest can't be done.",
4751 qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue());
4752 // no changes, quest can't be done for this requirement
4753 }
4754 }
4755 // else Skill quests can have 0 skill level, this is ok
4756
4757 if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2))
4758 {
4759 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId2` = {} but faction template {} does not exist, quest can't be done.",
4760 qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2);
4761 // no changes, quest can't be done for this requirement
4762 }
4763
4764 if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1))
4765 {
4766 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId1` = {} but faction template {} does not exist, quest can't be done.",
4767 qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1);
4768 // no changes, quest can't be done for this requirement
4769 }
4770
4771 if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction))
4772 {
4773 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepFaction` = {} but faction template {} does not exist, quest can't be done.",
4774 qinfo->GetQuestId(), qinfo->RequiredMinRepFaction, qinfo->RequiredMinRepFaction);
4775 // no changes, quest can't be done for this requirement
4776 }
4777
4778 if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction))
4779 {
4780 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepFaction` = {} but faction template {} does not exist, quest can't be done.",
4781 qinfo->GetQuestId(), qinfo->RequiredMaxRepFaction, qinfo->RequiredMaxRepFaction);
4782 // no changes, quest can't be done for this requirement
4783 }
4784
4786 {
4787 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but max reputation is {}, quest can't be done.",
4789 // no changes, quest can't be done for this requirement
4790 }
4791
4792 if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue)
4793 {
4794 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} and `RequiredMinRepValue` = {}, quest can't be done.",
4795 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue, qinfo->RequiredMinRepValue);
4796 // no changes, quest can't be done for this requirement
4797 }
4798
4799 if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0)
4800 {
4801 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue1` = {} but `RequiredFactionId1` is 0, value has no effect",
4802 qinfo->GetQuestId(), qinfo->RequiredFactionValue1);
4803 // warning
4804 }
4805
4806 if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0)
4807 {
4808 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue2` = {} but `RequiredFactionId2` is 0, value has no effect",
4809 qinfo->GetQuestId(), qinfo->RequiredFactionValue2);
4810 // warning
4811 }
4812
4813 if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue != 0)
4814 {
4815 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but `RequiredMinRepFaction` is 0, value has no effect",
4816 qinfo->GetQuestId(), qinfo->RequiredMinRepValue);
4817 // warning
4818 }
4819
4820 if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue != 0)
4821 {
4822 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} but `RequiredMaxRepFaction` is 0, value has no effect",
4823 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue);
4824 // warning
4825 }
4826
4827 if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId))
4828 {
4829 LOG_ERROR("sql.sql", "Quest {} has `RewardTitleId` = {} but CharTitle Id {} does not exist, quest can't be rewarded with title.",
4830 qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId());
4831 qinfo->RewardTitleId = 0;
4832 // quest can't reward this title
4833 }
4834
4835 if (qinfo->StartItem)
4836 {
4837 if (!sObjectMgr->GetItemTemplate(qinfo->StartItem))
4838 {
4839 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but item with entry {} does not exist, quest can't be done.",
4840 qinfo->GetQuestId(), qinfo->StartItem, qinfo->StartItem);
4841 qinfo->StartItem = 0; // quest can't be done for this requirement
4842 }
4843 else if (qinfo->StartItemCount == 0)
4844 {
4845 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but `StartItemCount` = 0, set to 1 but need fix in DB.",
4846 qinfo->GetQuestId(), qinfo->StartItem);
4847 qinfo->StartItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB
4848 }
4849 }
4850 else if (qinfo->StartItemCount > 0)
4851 {
4852 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = 0 but `StartItemCount` = {}, useless value.",
4853 qinfo->GetQuestId(), qinfo->StartItemCount);
4854 qinfo->StartItemCount = 0; // no quest work changes in fact
4855 }
4856
4857 if (qinfo->SourceSpellid)
4858 {
4859 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid);
4860 if (!spellInfo)
4861 {
4862 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} doesn't exist, quest can't be done.",
4863 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
4864 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
4865 }
4866 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
4867 {
4868 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} is broken, quest can't be done.",
4869 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
4870 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
4871 }
4872 }
4873
4874 for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
4875 {
4876 uint32 id = qinfo->RequiredItemId[j];
4877 if (id)
4878 {
4879 if (qinfo->RequiredItemCount[j] == 0)
4880 {
4881 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but `RequiredItemCount{}` = 0, quest can't be done.",
4882 qinfo->GetQuestId(), j + 1, id, j + 1);
4883 // no changes, quest can't be done for this requirement
4884 }
4885
4887
4888 if (!sObjectMgr->GetItemTemplate(id))
4889 {
4890 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but item with entry {} does not exist, quest can't be done.",
4891 qinfo->GetQuestId(), j + 1, id, id);
4892 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
4893 }
4894 }
4895 else if (qinfo->RequiredItemCount[j] > 0)
4896 {
4897 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = 0 but `RequiredItemCount{}` = {}, quest can't be done.",
4898 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredItemCount[j]);
4899 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
4900 }
4901 }
4902
4903 for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
4904 {
4905 uint32 id = qinfo->ItemDrop[j];
4906 if (id)
4907 {
4908 if (!sObjectMgr->GetItemTemplate(id))
4909 {
4910 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = {} but item with entry {} does not exist, quest can't be done.",
4911 qinfo->GetQuestId(), j + 1, id, id);
4912 // no changes, quest can't be done for this requirement
4913 }
4914 }
4915 else
4916 {
4917 if (qinfo->ItemDropQuantity[j] > 0)
4918 {
4919 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = 0 but `ItemDropQuantity{}` = {}.",
4920 qinfo->GetQuestId(), j + 1, j + 1, qinfo->ItemDropQuantity[j]);
4921 // no changes, quest ignore this data
4922 }
4923 }
4924 }
4925
4926 for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
4927 {
4928 int32 id = qinfo->RequiredNpcOrGo[j];
4929 if (id < 0 && !sObjectMgr->GetGameObjectTemplate(-id))
4930 {
4931 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but gameobject {} does not exist, quest can't be done.",
4932 qinfo->GetQuestId(), j + 1, id, uint32(-id));
4933 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
4934 }
4935
4936 if (id > 0 && !sObjectMgr->GetCreatureTemplate(id))
4937 {
4938 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but creature with entry {} does not exist, quest can't be done.",
4939 qinfo->GetQuestId(), j + 1, id, uint32(id));
4940 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
4941 }
4942
4943 if (id)
4944 {
4945 // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast
4946
4948
4949 if (!qinfo->RequiredNpcOrGoCount[j])
4950 {
4951 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but `RequiredNpcOrGoCount{}` = 0, quest can't be done.",
4952 qinfo->GetQuestId(), j + 1, id, j + 1);
4953 // no changes, quest can be incorrectly done, but we already report this
4954 }
4955 }
4956 else if (qinfo->RequiredNpcOrGoCount[j] > 0)
4957 {
4958 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = 0 but `RequiredNpcOrGoCount{}` = {}.",
4959 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredNpcOrGoCount[j]);
4960 // no changes, quest ignore this data
4961 }
4962 }
4963
4964 for (uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j)
4965 {
4966 uint32 id = qinfo->RewardChoiceItemId[j];
4967 if (id)
4968 {
4969 if (!sObjectMgr->GetItemTemplate(id))
4970 {
4971 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
4972 qinfo->GetQuestId(), j + 1, id, id);
4973 qinfo->RewardChoiceItemId[j] = 0; // no changes, quest will not reward this
4974 }
4975
4976 if (!qinfo->RewardChoiceItemCount[j])
4977 {
4978 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but `RewardChoiceItemCount{}` = 0, quest can't be done.",
4979 qinfo->GetQuestId(), j + 1, id, j + 1);
4980 // no changes, quest can't be done
4981 }
4982 }
4983 else if (qinfo->RewardChoiceItemCount[j] > 0)
4984 {
4985 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = 0 but `RewardChoiceItemCount{}` = {}.",
4986 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardChoiceItemCount[j]);
4987 // no changes, quest ignore this data
4988 }
4989 }
4990
4991 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
4992 {
4993 uint32 id = qinfo->RewardItemId[j];
4994 if (id)
4995 {
4996 if (!sObjectMgr->GetItemTemplate(id))
4997 {
4998 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
4999 qinfo->GetQuestId(), j + 1, id, id);
5000 qinfo->RewardItemId[j] = 0; // no changes, quest will not reward this item
5001 }
5002
5003 if (!qinfo->RewardItemIdCount[j])
5004 {
5005 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but `RewardItemIdCount{}` = 0, quest will not reward this item.",
5006 qinfo->GetQuestId(), j + 1, id, j + 1);
5007 // no changes
5008 }
5009 }
5010 else if (qinfo->RewardItemIdCount[j] > 0)
5011 {
5012 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = 0 but `RewardItemIdCount{}` = {}.",
5013 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardItemIdCount[j]);
5014 // no changes, quest ignore this data
5015 }
5016 }
5017
5018 for (uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j)
5019 {
5020 if (qinfo->RewardFactionId[j])
5021 {
5022 if (std::abs(qinfo->RewardFactionValueId[j]) > 9)
5023 {
5024 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]);
5025 }
5026 if (!sFactionStore.LookupEntry(qinfo->RewardFactionId[j]))
5027 {
5028 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]);
5029 qinfo->RewardFactionId[j] = 0; // quest will not reward this
5030 }
5031 }
5032
5033 else if (qinfo->RewardFactionValueIdOverride[j] != 0)
5034 {
5035 LOG_ERROR("sql.sql", "Quest {} has `RewardFactionId{}` = 0 but `RewardFactionValueIdOverride{}` = {}.",
5036 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardFactionValueIdOverride[j]);
5037 // no changes, quest ignore this data
5038 }
5039 }
5040
5041 if (qinfo->RewardDisplaySpell)
5042 {
5043 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell);
5044
5045 if (!spellInfo)
5046 {
5047 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} does not exist, spell removed as display reward.",
5048 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5049 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5050 }
5051
5052 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5053 {
5054 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is broken, quest will not have a spell reward.",
5055 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5056 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5057 }
5058
5059 else if (GetTalentSpellCost(qinfo->RewardDisplaySpell))
5060 {
5061 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5062 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5063 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5064 }
5065 }
5066
5067 if (qinfo->RewardSpell > 0)
5068 {
5069 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell);
5070
5071 if (!spellInfo)
5072 {
5073 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} does not exist, quest will not have a spell reward.",
5074 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5075 qinfo->RewardSpell = 0; // no spell will be casted on player
5076 }
5077
5078 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5079 {
5080 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} is broken, quest will not have a spell reward.",
5081 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5082 qinfo->RewardSpell = 0; // no spell will be casted on player
5083 }
5084
5085 else if (GetTalentSpellCost(qinfo->RewardSpell))
5086 {
5087 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5088 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5089 qinfo->RewardSpell = 0; // no spell will be casted on player
5090 }
5091 }
5092
5093 if (qinfo->RewardMailTemplateId)
5094 {
5095 if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId))
5096 {
5097 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} does not exist, quest will not have a mail reward.",
5098 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId);
5099 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5100 qinfo->RewardMailDelay = 0; // no mail will send to player
5101 qinfo->RewardMailSenderEntry = 0;
5102 }
5103 else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end())
5104 {
5105 std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId);
5106 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} already used for quest {}, quest will not have a mail reward.",
5107 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second);
5108 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5109 qinfo->RewardMailDelay = 0; // no mail will send to player
5110 qinfo->RewardMailSenderEntry = 0;
5111 }
5112 else
5113 usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId();
5114 }
5115
5116 if (qinfo->RewardNextQuest)
5117 {
5118 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->RewardNextQuest);
5119 if (qNextItr == _questTemplates.end())
5120 {
5121 LOG_ERROR("sql.sql", "Quest {} has `RewardNextQuest` = {} but quest {} does not exist, quest chain will not work.",
5122 qinfo->GetQuestId(), qinfo->RewardNextQuest, qinfo->RewardNextQuest);
5123 qinfo->RewardNextQuest = 0;
5124 }
5125 else
5126 qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId());
5127 }
5128
5129 // fill additional data stores
5130 if (qinfo->PrevQuestId)
5131 {
5132 if (_questTemplates.find(std::abs(qinfo->GetPrevQuestId())) == _questTemplates.end())
5133 {
5134 LOG_ERROR("sql.sql", "Quest {} has PrevQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId());
5135 }
5136 else
5137 {
5138 qinfo->prevQuests.push_back(qinfo->PrevQuestId);
5139 }
5140 }
5141
5142 if (qinfo->NextQuestId)
5143 {
5144 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->GetNextQuestId());
5145 if (qNextItr == _questTemplates.end())
5146 {
5147 LOG_ERROR("sql.sql", "Quest {} has NextQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId());
5148 }
5149 else
5150 qNextItr->second->prevQuests.push_back(static_cast<int32>(qinfo->GetQuestId()));
5151 }
5152
5153 if (qinfo->ExclusiveGroup)
5154 mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
5155 if (qinfo->TimeAllowed)
5157 if (qinfo->RequiredPlayerKills)
5159 }
5160
5161 // check QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
5162 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5163 {
5164 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
5165 if (!spellInfo)
5166 continue;
5167
5168 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5169 {
5170 if (spellInfo->Effects[j].Effect != SPELL_EFFECT_QUEST_COMPLETE)
5171 continue;
5172
5173 uint32 quest_id = spellInfo->Effects[j].MiscValue;
5174
5175 Quest const* quest = GetQuestTemplate(quest_id);
5176
5177 // some quest referenced in spells not exist (outdated spells)
5178 if (!quest)
5179 continue;
5180
5182 {
5183 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);
5184
5185 // this will prevent quest completing without objective
5186 // xinef: remove this, leave error but do not break the quest
5187 // const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5188 }
5189 }
5190 }
5191
5192 LOG_INFO("server.loading", ">> Loaded {} Quests Definitions in {} ms", (unsigned long)_questTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
5193 LOG_INFO("server.loading", " ");
5194}
@ 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:766
uint32 SkillByQuestSort(int32 QuestSort)
Definition: SharedDefines.h:3012
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:8146
void LoadGameobjectQuestEnders()
Definition: ObjectMgr.cpp:8118
void LoadGameobjectQuestStarters()
Definition: ObjectMgr.cpp:8104
void LoadCreatureQuestStarters()
Definition: ObjectMgr.cpp:8132

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

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
9119{
9120 // find all items from the reference vendor
9122 stmt->SetData(0, uint32(item));
9123 PreparedQueryResult result = WorldDatabase.Query(stmt);
9124
9125 if (!result)
9126 return 0;
9127
9128 uint32 count = 0;
9129 do
9130 {
9131 Field* fields = result->Fetch();
9132
9133 int32 item_id = fields[0].Get<int32>();
9134
9135 // if item is a negative, its a reference
9136 if (item_id < 0)
9137 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
9138 else
9139 {
9140 int32 maxcount = fields[1].Get<uint8>();
9141 uint32 incrtime = fields[2].Get<uint32>();
9142 uint32 ExtendedCost = fields[3].Get<uint32>();
9143
9144 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
9145 continue;
9146
9147 VendorItemData& vList = _cacheVendorItemStore[vendor];
9148
9149 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9150 ++count;
9151 }
9152 } while (result->NextRow());
9153
9154 return count;
9155}
@ 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:9358
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition: ObjectMgr.cpp:9118

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 ( )
7657{
7658 uint32 oldMSTime = getMSTime();
7659
7660 // For reload case
7661 _repOnKillStore.clear();
7662
7663 uint32 count = 0;
7664
7665 // 0 1 2
7666 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
7667 // 3 4 5 6 7 8 9
7668 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
7669 "FROM creature_onkill_reputation");
7670
7671 if (!result)
7672 {
7673 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
7674 LOG_INFO("server.loading", " ");
7675 return;
7676 }
7677
7678 do
7679 {
7680 Field* fields = result->Fetch();
7681
7682 uint32 creature_id = fields[0].Get<uint32>();
7683
7684 ReputationOnKillEntry repOnKill;
7685 repOnKill.RepFaction1 = fields[1].Get<int16>();
7686 repOnKill.RepFaction2 = fields[2].Get<int16>();
7687 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
7688 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
7689 repOnKill.RepValue1 = fields[5].Get<float>();
7690 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
7691 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
7692 repOnKill.RepValue2 = fields[8].Get<float>();
7693 repOnKill.TeamDependent = fields[9].Get<uint8>();
7694
7695 if (!GetCreatureTemplate(creature_id))
7696 {
7697 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
7698 continue;
7699 }
7700
7701 if (repOnKill.RepFaction1)
7702 {
7703 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
7704 if (!factionEntry1)
7705 {
7706 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
7707 continue;
7708 }
7709 }
7710
7711 if (repOnKill.RepFaction2)
7712 {
7713 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
7714 if (!factionEntry2)
7715 {
7716 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
7717 continue;
7718 }
7719 }
7720
7721 _repOnKillStore[creature_id] = repOnKill;
7722
7723 ++count;
7724 } while (result->NextRow());
7725
7726 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7727 LOG_INFO("server.loading", " ");
7728}
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 ( )
7569{
7570 uint32 oldMSTime = getMSTime();
7571
7572 _repRewardRateStore.clear(); // for reload case
7573
7574 uint32 count = 0; // 0 1 2 3 4 5 6 7
7575 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");
7576 if (!result)
7577 {
7578 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
7579 return;
7580 }
7581
7582 do
7583 {
7584 Field* fields = result->Fetch();
7585
7586 uint32 factionId = fields[0].Get<uint32>();
7587
7588 RepRewardRate repRate;
7589
7590 repRate.questRate = fields[1].Get<float>();
7591 repRate.questDailyRate = fields[2].Get<float>();
7592 repRate.questWeeklyRate = fields[3].Get<float>();
7593 repRate.questMonthlyRate = fields[4].Get<float>();
7594 repRate.questRepeatableRate = fields[5].Get<float>();
7595 repRate.creatureRate = fields[6].Get<float>();
7596 repRate.spellRate = fields[7].Get<float>();
7597
7598 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7599 if (!factionEntry)
7600 {
7601 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
7602 continue;
7603 }
7604
7605 if (repRate.questRate < 0.0f)
7606 {
7607 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
7608 continue;
7609 }
7610
7611 if (repRate.questDailyRate < 0.0f)
7612 {
7613 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
7614 continue;
7615 }
7616
7617 if (repRate.questWeeklyRate < 0.0f)
7618 {
7619 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
7620 continue;
7621 }
7622
7623 if (repRate.questMonthlyRate < 0.0f)
7624 {
7625 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
7626 continue;
7627 }
7628
7629 if (repRate.questRepeatableRate < 0.0f)
7630 {
7631 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
7632 continue;
7633 }
7634
7635 if (repRate.creatureRate < 0.0f)
7636 {
7637 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
7638 continue;
7639 }
7640
7641 if (repRate.spellRate < 0.0f)
7642 {
7643 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
7644 continue;
7645 }
7646
7647 _repRewardRateStore[factionId] = repRate;
7648
7649 ++count;
7650 } while (result->NextRow());
7651
7652 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7653 LOG_INFO("server.loading", " ");
7654}
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 ( )
7731{
7732 uint32 oldMSTime = getMSTime();
7733
7734 _repSpilloverTemplateStore.clear(); // for reload case
7735
7736 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12
7737 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 FROM reputation_spillover_template");
7738
7739 if (!result)
7740 {
7741 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
7742 LOG_INFO("server.loading", " ");
7743 return;
7744 }
7745
7746 do
7747 {
7748 Field* fields = result->Fetch();
7749
7750 uint32 factionId = fields[0].Get<uint16>();
7751
7752 RepSpilloverTemplate repTemplate;
7753
7754 repTemplate.faction[0] = fields[1].Get<uint16>();
7755 repTemplate.faction_rate[0] = fields[2].Get<float>();
7756 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
7757 repTemplate.faction[1] = fields[4].Get<uint16>();
7758 repTemplate.faction_rate[1] = fields[5].Get<float>();
7759 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
7760 repTemplate.faction[2] = fields[7].Get<uint16>();
7761 repTemplate.faction_rate[2] = fields[8].Get<float>();
7762 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
7763 repTemplate.faction[3] = fields[10].Get<uint16>();
7764 repTemplate.faction_rate[3] = fields[11].Get<float>();
7765 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
7766
7767 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7768
7769 if (!factionEntry)
7770 {
7771 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
7772 continue;
7773 }
7774
7775 if (factionEntry->team == 0)
7776 {
7777 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
7778 continue;
7779 }
7780
7781 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
7782 {
7783 if (repTemplate.faction[i])
7784 {
7785 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
7786
7787 if (!factionSpillover)
7788 {
7789 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);
7790 continue;
7791 }
7792
7793 if (factionSpillover->reputationListID < 0)
7794 {
7795 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);
7796 continue;
7797 }
7798
7799 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
7800 {
7801 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
7802 continue;
7803 }
7804 }
7805 }
7806
7807 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
7808 if (repTemplate.faction[0] && !factionEntry0)
7809 {
7810 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
7811 continue;
7812 }
7813 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
7814 if (repTemplate.faction[1] && !factionEntry1)
7815 {
7816 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
7817 continue;
7818 }
7819 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
7820 if (repTemplate.faction[2] && !factionEntry2)
7821 {
7822 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
7823 continue;
7824 }
7825 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
7826 if (repTemplate.faction[3] && !factionEntry3)
7827 {
7828 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
7829 continue;
7830 }
7831
7832 _repSpilloverTemplateStore[factionId] = repTemplate;
7833
7834 ++count;
7835 } while (result->NextRow());
7836
7837 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7838 LOG_INFO("server.loading", " ");
7839}
#define MAX_SPILLOVER_FACTIONS
Definition: SharedDefines.h:219
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 ( )
8161{
8162 uint32 oldMSTime = getMSTime();
8163
8164 _reservedNamesStore.clear(); // need for reload case
8165
8166 QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
8167
8168 if (!result)
8169 {
8170 LOG_WARN("server.loading", ">> Loaded 0 reserved player names. DB table `reserved_name` is empty!");
8171 LOG_INFO("server.loading", " ");
8172 return;
8173 }
8174
8175 uint32 count = 0;
8176
8177 Field* fields;
8178 do
8179 {
8180 fields = result->Fetch();
8181 std::string name = fields[0].Get<std::string>();
8182
8183 std::wstring wstr;
8184 if (!Utf8toWStr (name, wstr))
8185 {
8186 LOG_ERROR("sql.sql", "Table `reserved_name` have invalid name: {}", name);
8187 continue;
8188 }
8189
8190 wstrToLower(wstr);
8191
8192 _reservedNamesStore.insert(wstr);
8193 ++count;
8194 } while (result->NextRow());
8195
8196 LOG_INFO("server.loading", ">> Loaded {} reserved player names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8197 LOG_INFO("server.loading", " ");
8198}

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

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
9439{
9440 uint32 oldMSTime = getMSTime();
9441
9442 // We insert an empty placeholder here so we can use the
9443 // script id 0 as dummy for "no script found".
9444 _scriptNamesStore.emplace_back("");
9445
9446 QueryResult result = WorldDatabase.Query(
9447 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
9448 "UNION "
9449 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
9450 "UNION "
9451 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
9452 "UNION "
9453 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
9454 "UNION "
9455 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
9456 "UNION "
9457 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
9458 "UNION "
9459 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
9460 "UNION "
9461 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
9462 "UNION "
9463 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
9464 "UNION "
9465 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
9466 "UNION "
9467 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
9468 "UNION "
9469 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
9470 "UNION "
9471 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
9472 "UNION "
9473 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
9474
9475 if (!result)
9476 {
9477 LOG_INFO("server.loading", " ");
9478 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
9479 return;
9480 }
9481
9482 _scriptNamesStore.reserve(result->GetRowCount() + 1);
9483
9484 do
9485 {
9486 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
9487 } while (result->NextRow());
9488
9489 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
9490 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
9491 LOG_INFO("server.loading", " ");
9492}

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

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5233{
5234 uint32 oldMSTime = getMSTime();
5235
5236 ScriptMapMap* scripts = GetScriptsMapByType(type);
5237 if (!scripts)
5238 return;
5239
5240 std::string tableName = GetScriptsTableNameByType(type);
5241 if (tableName.empty())
5242 return;
5243
5244 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5245 return;
5246
5247 LOG_INFO("server.loading", "Loading {}...", tableName);
5248
5249 scripts->clear(); // need for reload support
5250
5251 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5252 // 0 1 2 3 4 5 6 7 8 9
5253 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5254
5255 if (!result)
5256 {
5257 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5258 LOG_INFO("server.loading", " ");
5259 return;
5260 }
5261
5262 uint32 count = 0;
5263
5264 do
5265 {
5266 Field* fields = result->Fetch();
5267 ScriptInfo tmp;
5268 tmp.type = type;
5269 tmp.id = fields[0].Get<uint32>();
5270 if (isSpellScriptTable)
5271 tmp.id |= fields[10].Get<uint8>() << 24;
5272 tmp.delay = fields[1].Get<uint32>();
5273 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5274 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5275 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5276 tmp.Raw.nData[2] = fields[5].Get<int32>();
5277 tmp.Raw.fData[0] = fields[6].Get<float>();
5278 tmp.Raw.fData[1] = fields[7].Get<float>();
5279 tmp.Raw.fData[2] = fields[8].Get<float>();
5280 tmp.Raw.fData[3] = fields[9].Get<float>();
5281
5282 // generic command args check
5283 switch (tmp.command)
5284 {
5286 {
5288 {
5289 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5290 tableName, tmp.Talk.ChatType, tmp.id);
5291 continue;
5292 }
5294 {
5295 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
5296 tableName, tmp.Talk.TextID, tmp.id);
5297 continue;
5298 }
5299 break;
5300 }
5301
5303 {
5304 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
5305 {
5306 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
5307 tableName, tmp.Emote.EmoteID, tmp.id);
5308 continue;
5309 }
5310 break;
5311 }
5312
5314 {
5315 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
5316 {
5317 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5318 tableName, tmp.TeleportTo.MapID, tmp.id);
5319 continue;
5320 }
5321
5323 {
5324 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5325 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
5326 continue;
5327 }
5328 break;
5329 }
5330
5332 {
5333 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
5334 if (!quest)
5335 {
5336 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5337 tableName, tmp.QuestExplored.QuestID, tmp.id);
5338 continue;
5339 }
5340
5342 {
5343 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.",
5344 tableName, tmp.QuestExplored.QuestID, tmp.id);
5345
5346 // this will prevent quest completing without objective
5347 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5348
5349 // continue; - quest objective requirement set and command can be allowed
5350 }
5351
5353 {
5354 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 {}",
5355 tableName, tmp.QuestExplored.Distance, tmp.id);
5356 continue;
5357 }
5358
5360 {
5361 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",
5363 continue;
5364 }
5365
5367 {
5368 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",
5369 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
5370 continue;
5371 }
5372
5373 break;
5374 }
5375
5377 {
5379 {
5380 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
5381 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
5382 continue;
5383 }
5384 break;
5385 }
5386
5388 {
5390 if (!data)
5391 {
5392 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5393 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
5394 continue;
5395 }
5396
5397 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5398 if (!info)
5399 {
5400 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5401 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
5402 continue;
5403 }
5404
5405 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
5407 info->type == GAMEOBJECT_TYPE_DOOR ||
5408 info->type == GAMEOBJECT_TYPE_BUTTON ||
5409 info->type == GAMEOBJECT_TYPE_TRAP)
5410 {
5411 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5412 tableName, info->entry, tmp.id);
5413 continue;
5414 }
5415 break;
5416 }
5417
5419 {
5421 {
5422 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5424 continue;
5425 }
5426
5428 if (!GetCreatureTemplate(entry))
5429 {
5430 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5431 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
5432 continue;
5433 }
5434 break;
5435 }
5436
5439 {
5441 if (!data)
5442 {
5443 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
5444 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
5445 continue;
5446 }
5447
5448 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5449 if (!info)
5450 {
5451 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
5452 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
5453 continue;
5454 }
5455
5456 if (info->type != GAMEOBJECT_TYPE_DOOR)
5457 {
5458 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
5459 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
5460 continue;
5461 }
5462
5463 break;
5464 }
5465
5467 {
5468 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
5469 {
5470 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5471 tableName, tmp.RemoveAura.SpellID, tmp.id);
5472 continue;
5473 }
5474 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
5475 {
5476 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5477 tableName, tmp.RemoveAura.Flags, tmp.id);
5478 continue;
5479 }
5480 break;
5481 }
5482
5484 {
5485 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
5486 {
5487 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5488 tableName, tmp.CastSpell.SpellID, tmp.id);
5489 continue;
5490 }
5491 if (tmp.CastSpell.Flags > 4) // targeting type
5492 {
5493 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5494 tableName, tmp.CastSpell.Flags, tmp.id);
5495 continue;
5496 }
5497 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
5498 {
5499 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5500 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5501 continue;
5502 }
5503 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
5504 {
5505 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5506 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5507 continue;
5508 }
5509 break;
5510 }
5511
5513 {
5515 {
5516 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
5517 tableName, tmp.CreateItem.ItemEntry, tmp.id);
5518 continue;
5519 }
5520 if (!tmp.CreateItem.Amount)
5521 {
5522 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
5523 tableName, tmp.CreateItem.Amount, tmp.id);
5524 continue;
5525 }
5526 break;
5527 }
5528 default:
5529 break;
5530 }
5531
5532 if (scripts->find(tmp.id) == scripts->end())
5533 {
5534 ScriptMap emptyMap;
5535 (*scripts)[tmp.id] = emptyMap;
5536 }
5537 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
5538
5539 ++count;
5540 } while (result->NextRow());
5541
5542 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5543 LOG_INFO("server.loading", " ");
5544}
@ 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:83
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:103
std::map< uint32, ScriptMap > ScriptMapMap
Definition: ObjectMgr.h:387
std::string GetScriptsTableNameByType(ScriptsType type)
Definition: ObjectMgr.cpp:63
@ SCRIPTS_SPELL
Definition: ObjectMgr.h:151
#define sScriptMgr
Definition: ScriptMgr.h:2762
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition: SharedDefines.h:1549
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition: SharedDefines.h:3166
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::@260::@275 CastSpell
uint32 QuestID
Definition: ObjectMgr.h:257
struct ScriptInfo::@260::@268 TeleportTo
struct ScriptInfo::@260::@263 Talk
int32 TextID
Definition: ObjectMgr.h:210
struct ScriptInfo::@260::@264 Emote
float DestX
Definition: ObjectMgr.h:231
uint32 ItemEntry
Definition: ObjectMgr.h:317
uint32 ChatType
Definition: ObjectMgr.h:208
uint32 id
Definition: ObjectMgr.h:194
struct ScriptInfo::@260::@274 RemoveAura
uint32 delay
Definition: ObjectMgr.h:195
float fData[4]
Definition: ObjectMgr.h:203
struct ScriptInfo::@260::@271 RespawnGameobject
struct ScriptInfo::@260::@269 QuestExplored
float PosY
Definition: ObjectMgr.h:280
ScriptCommands command
Definition: ObjectMgr.h:196
struct ScriptInfo::@260::@277 CreateItem
float DestY
Definition: ObjectMgr.h:232
uint32 MapID
Definition: ObjectMgr.h:245
uint32 nData[3]
Definition: ObjectMgr.h:202
float PosZ
Definition: ObjectMgr.h:281
struct ScriptInfo::@260::@273 ToggleDoor
struct ScriptInfo::@260::@272 TempSummonCreature
float PosX
Definition: ObjectMgr.h:279
uint32 Distance
Definition: ObjectMgr.h:258
uint32 SpellID
Definition: ObjectMgr.h:296
struct ScriptInfo::@260::@262 Raw
float DestZ
Definition: ObjectMgr.h:233
uint32 GOGuid
Definition: ObjectMgr.h:269
struct ScriptInfo::@260::@270 KillCredit
uint32 CreatureEntry
Definition: ObjectMgr.h:263
uint32 Amount
Definition: ObjectMgr.h:318
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 ( )
5646{
5647 uint32 oldMSTime = getMSTime();
5648
5649 _spellScriptsStore.clear(); // need for reload case
5650
5651 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
5652
5653 if (!result)
5654 {
5655 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
5656 LOG_INFO("server.loading", " ");
5657 return;
5658 }
5659
5660 uint32 count = 0;
5661
5662 do
5663 {
5664 Field* fields = result->Fetch();
5665
5666 int32 spellId = fields[0].Get<int32>();
5667 std::string scriptName = fields[1].Get<std::string>();
5668
5669 bool allRanks = false;
5670 if (spellId <= 0)
5671 {
5672 allRanks = true;
5673 spellId = -spellId;
5674 }
5675
5676 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5677 if (!spellInfo)
5678 {
5679 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
5680 continue;
5681 }
5682
5683 if (allRanks)
5684 {
5685 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
5686 {
5687 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
5688 continue;
5689 }
5690 while (spellInfo)
5691 {
5692 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5693 spellInfo = spellInfo->GetNextRankSpell();
5694 }
5695 }
5696 else
5697 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5698 ++count;
5699 } while (result->NextRow());
5700
5701 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5702 LOG_INFO("server.loading", " ");
5703}
SpellInfo const * GetNextRankSpell() const
Definition: SpellInfo.cpp:2497

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

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
5547{
5549
5550 // check ids
5551 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
5552 {
5553 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
5554 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5555
5556 if (!spellInfo)
5557 {
5558 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
5559 continue;
5560 }
5561
5562 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
5563 if (uint32(i) >= MAX_SPELL_EFFECTS)
5564 {
5565 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
5566 }
5567
5568 //check for correct spellEffect
5569 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
5570 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
5571 }
5572}
ScriptMapMap sSpellScripts
Definition: ObjectMgr.cpp:59
SpellEffIndex
Definition: SharedDefines.h:29
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:753
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:827

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 ( )
6477{
6478 uint32 oldMSTime = getMSTime();
6479
6480 _tavernAreaTriggerStore.clear(); // need for reload case
6481
6482 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
6483
6484 if (!result)
6485 {
6486 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
6487 LOG_INFO("server.loading", " ");
6488 return;
6489 }
6490
6491 uint32 count = 0;
6492
6493 do
6494 {
6495 ++count;
6496
6497 Field* fields = result->Fetch();
6498
6499 uint32 Trigger_ID = fields[0].Get<uint32>();
6500
6501 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6502 if (!atEntry)
6503 {
6504 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6505 continue;
6506 }
6507
6508 uint32 faction = fields[1].Get<uint32>();
6509
6510 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
6511 } while (result->NextRow());
6512
6513 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6514 LOG_INFO("server.loading", " ");
6515}

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

◆ LoadTempSummons()

void ObjectMgr::LoadTempSummons ( )
2058{
2059 uint32 oldMSTime = getMSTime();
2060
2061 // 0 1 2 3 4 5 6 7 8 9
2062 QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, summonType, summonTime FROM creature_summon_groups");
2063
2064 if (!result)
2065 {
2066 LOG_WARN("server.loading", ">> Loaded 0 temp summons. DB table `creature_summon_groups` is empty.");
2067 return;
2068 }
2069
2070 uint32 count = 0;
2071 do
2072 {
2073 Field* fields = result->Fetch();
2074
2075 uint32 summonerId = fields[0].Get<uint32>();
2076 SummonerType summonerType = SummonerType(fields[1].Get<uint8>());
2077 uint8 group = fields[2].Get<uint8>();
2078
2079 switch (summonerType)
2080 {
2082 if (!GetCreatureTemplate(summonerId))
2083 {
2084 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for creature summoner type, skipped.", summonerId);
2085 continue;
2086 }
2087 break;
2089 if (!GetGameObjectTemplate(summonerId))
2090 {
2091 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for gameobject summoner type, skipped.", summonerId);
2092 continue;
2093 }
2094 break;
2095 case SUMMONER_TYPE_MAP:
2096 if (!sMapStore.LookupEntry(summonerId))
2097 {
2098 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has summoner with non existing entry {} for map summoner type, skipped.", summonerId);
2099 continue;
2100 }
2101 break;
2102 default:
2103 LOG_ERROR("sql.sql", "Table `creature_summon_groups` has unhandled summoner type {} for summoner {}, skipped.", summonerType, summonerId);
2104 continue;
2105 }
2106
2107 TempSummonData data;
2108 data.entry = fields[3].Get<uint32>();
2109
2110 if (!GetCreatureTemplate(data.entry))
2111 {
2112 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);
2113 continue;
2114 }
2115
2116 float posX = fields[4].Get<float>();
2117 float posY = fields[5].Get<float>();
2118 float posZ = fields[6].Get<float>();
2119 float orientation = fields[7].Get<float>();
2120
2121 data.pos.Relocate(posX, posY, posZ, orientation);
2122
2123 data.type = TempSummonType(fields[8].Get<uint8>());
2124
2126 {
2127 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);
2128 continue;
2129 }
2130
2131 data.time = fields[9].Get<uint32>();
2132
2133 TempSummonGroupKey key(summonerId, summonerType, group);
2134 _tempSummonDataStore[key].push_back(data);
2135
2136 ++count;
2137 } while (result->NextRow());
2138
2139 LOG_INFO("server.loading", ">> Loaded {} Temporary Summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2140 LOG_INFO("server.loading", " ");
2141}
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 ( )
9078{
9079 uint32 oldMSTime = getMSTime();
9080
9081 // For reload case
9083
9084 QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.ReqLevel, a.ReqSpell FROM npc_trainer AS a "
9085 "INNER JOIN npc_trainer AS b ON a.ID = -(b.SpellID) "
9086 "UNION SELECT * FROM npc_trainer WHERE SpellID > 0");
9087
9088 if (!result)
9089 {
9090 LOG_WARN("server.loading", ">> Loaded 0 Trainers. DB table `npc_trainer` is empty!");
9091 LOG_INFO("server.loading", " ");
9092 return;
9093 }
9094
9095 uint32 count = 0;
9096
9097 do
9098 {
9099 Field* fields = result->Fetch();
9100
9101 uint32 entry = fields[0].Get<uint32>();
9102 uint32 spell = fields[1].Get<uint32>();
9103 uint32 spellCost = fields[2].Get<uint32>();
9104 uint32 reqSkill = fields[3].Get<uint16>();
9105 uint32 reqSkillValue = fields[4].Get<uint16>();
9106 uint32 reqLevel = fields[5].Get<uint8>();
9107 uint32 reqSpell = fields[6].Get<uint32>();
9108
9109 AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel, reqSpell);
9110
9111 ++count;
9112 } while (result->NextRow());
9113
9114 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9115 LOG_INFO("server.loading", " ");
9116}
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
Definition: ObjectMgr.cpp:8992

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

◆ LoadVehicleAccessories()

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

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

◆ LoadVehicleTemplateAccessories()

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

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

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
9158{
9159 uint32 oldMSTime = getMSTime();
9160
9161 // For reload case
9162 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
9163 itr->second.Clear();
9164 _cacheVendorItemStore.clear();
9165
9166 std::set<uint32> skip_vendors;
9167
9168 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
9169 if (!result)
9170 {
9171 LOG_INFO("server.loading", " ");
9172 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
9173 return;
9174 }
9175
9176 uint32 count = 0;
9177
9178 do
9179 {
9180 Field* fields = result->Fetch();
9181
9182 uint32 entry = fields[0].Get<uint32>();
9183 int32 item_id = fields[1].Get<int32>();
9184
9185 // if item is a negative, its a reference
9186 if (item_id < 0)
9187 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
9188 else
9189 {
9190 uint32 maxcount = fields[2].Get<uint8>();
9191 uint32 incrtime = fields[3].Get<uint32>();
9192 uint32 ExtendedCost = fields[4].Get<uint32>();
9193
9194 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
9195 continue;
9196
9197 VendorItemData& vList = _cacheVendorItemStore[entry];
9198
9199 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9200 ++count;
9201 }
9202 } while (result->NextRow());
9203
9204 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9205 LOG_INFO("server.loading", " ");
9206}

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

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
5619{
5621
5622 std::set<uint32> actionSet;
5623
5624 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
5625 actionSet.insert(itr->first);
5626
5628 PreparedQueryResult result = WorldDatabase.Query(stmt);
5629
5630 if (result)
5631 {
5632 do
5633 {
5634 Field* fields = result->Fetch();
5635 uint32 action = fields[0].Get<uint32>();
5636
5637 actionSet.erase(action);
5638 } while (result->NextRow());
5639 }
5640
5641 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
5642 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
5643}
@ WORLD_SEL_WAYPOINT_DATA_ACTION
Definition: WorldDatabase.h:69
ScriptMapMap sWaypointScripts
Definition: ObjectMgr.cpp:61
@ 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 
)
10222{
10223 GameobjectInstanceSavedStateList.push_back({ id, guid, state });
10224}

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
3638{
3639 if (!_playerInfo[race_][class_])
3640 return;
3641
3642 if (count > 0)
3643 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
3644 else
3645 {
3646 if (count < -1)
3647 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
3648
3649 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
3650 {
3651 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
3652 {
3653 bool found = false;
3654 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
3655 {
3656 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
3657 {
3658 found = true;
3659 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
3660 break;
3661 }
3662 }
3663
3664 if (!found)
3665 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
3666 }
3667 }
3668 }
3669}
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 
)
2353{
2354 uint8 mask = data->spawnMask;
2355 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2356 {
2357 if (mask & 1)
2358 {
2359 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2360 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2361 cell_guids.creatures.erase(guid);
2362 }
2363 }
2364}

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 
)
2659{
2660 uint8 mask = data->spawnMask;
2661 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2662 {
2663 if (mask & 1)
2664 {
2665 CellCoord cellCoord = Acore::ComputeCellCoord(data->posX, data->posY);
2666 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][cellCoord.GetId()];
2667 cell_guids.gameobjects.erase(guid);
2668 }
2669 }
2670}

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 
)
9337{
9338 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
9339 if (iter == _cacheVendorItemStore.end())
9340 return false;
9341
9342 if (!iter->second.RemoveItem(item))
9343 return false;
9344
9345 if (persist)
9346 {
9348
9349 stmt->SetData(0, entry);
9350 stmt->SetData(1, item);
9351
9352 WorldDatabase.Execute(stmt);
9353 }
9354
9355 return true;
9356}
@ WORLD_DEL_NPC_VENDOR
Definition: WorldDatabase.h:44

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

◆ ReturnOrDeleteOldMails()

void ObjectMgr::ReturnOrDeleteOldMails ( bool  serverUp)
6110{
6111 uint32 oldMSTime = getMSTime();
6112
6113 time_t curTime = GameTime::GetGameTime().count();
6114
6116 stmt->SetData(0, uint32(curTime));
6117 PreparedQueryResult result = CharacterDatabase.Query(stmt);
6118 if (!result)
6119 return;
6120
6121 std::map<uint32 /*messageId*/, MailItemInfoVec> itemsCache;
6122 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS);
6123 stmt->SetData(0, uint32(curTime));
6124 if (PreparedQueryResult items = CharacterDatabase.Query(stmt))
6125 {
6126 MailItemInfo item;
6127 do
6128 {
6129 Field* fields = items->Fetch();
6130 item.item_guid = fields[0].Get<uint32>();
6131 item.item_template = fields[1].Get<uint32>();
6132 uint32 mailId = fields[2].Get<uint32>();
6133 itemsCache[mailId].push_back(item);
6134 } while (items->NextRow());
6135 }
6136
6137 uint32 deletedCount = 0;
6138 uint32 returnedCount = 0;
6139 do
6140 {
6141 Field* fields = result->Fetch();
6142 Mail* m = new Mail;
6143 m->messageID = fields[0].Get<uint32>();
6144 m->messageType = fields[1].Get<uint8>();
6145 m->sender = fields[2].Get<uint32>();
6146 m->receiver = fields[3].Get<uint32>();
6147 bool has_items = fields[4].Get<bool>();
6148 m->expire_time = time_t(fields[5].Get<uint32>());
6149 m->deliver_time = time_t(0);
6150 m->stationery = fields[6].Get<uint8>();
6151 m->checked = fields[7].Get<uint8>();
6152 m->mailTemplateId = fields[8].Get<int16>();
6153
6154 Player* player = nullptr;
6155 if (serverUp)
6157
6158 if (player) // don't modify mails of a logged in player
6159 {
6160 delete m;
6161 continue;
6162 }
6163
6164 // Delete or return mail
6165 if (has_items)
6166 {
6167 // read items from cache
6168 m->items.swap(itemsCache[m->messageID]);
6169
6170 // If it is mail from non-player, or if it's already return mail, it shouldn't be returned, but deleted
6171 if (!m->IsSentByPlayer() || m->IsSentByGM() || (m->IsCODPayment() || m->IsReturnedMail()))
6172 {
6173 for (auto const& mailedItem : m->items)
6174 {
6175 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
6176 stmt->SetData(0, mailedItem.item_guid);
6177 CharacterDatabase.Execute(stmt);
6178 }
6179
6180 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
6181 stmt->SetData(0, m->messageID);
6182 CharacterDatabase.Execute(stmt);
6183 }
6184 else
6185 {
6186 // Mail will be returned
6187 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_RETURNED);
6188 stmt->SetData(0, m->receiver);
6189 stmt->SetData(1, m->sender);
6190 stmt->SetData(2, uint32(curTime + 30 * DAY));
6191 stmt->SetData(3, uint32(curTime));
6193 stmt->SetData(5, m->messageID);
6194 CharacterDatabase.Execute(stmt);
6195 for (auto const& mailedItem : m->items)
6196 {
6197 // Update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete
6198 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_ITEM_RECEIVER);
6199 stmt->SetData(0, m->sender);
6200 stmt->SetData(1, mailedItem.item_guid);
6201 CharacterDatabase.Execute(stmt);
6202
6203 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
6204 stmt->SetData(0, m->sender);
6205 stmt->SetData(1, mailedItem.item_guid);
6206 CharacterDatabase.Execute(stmt);
6207 }
6208
6209 // xinef: update global data
6210 sCharacterCache->IncreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->sender));
6211 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6212
6213 delete m;
6214 ++returnedCount;
6215 continue;
6216 }
6217 }
6218
6219 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6220
6221 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
6222 stmt->SetData(0, m->messageID);
6223 CharacterDatabase.Execute(stmt);
6224 delete m;
6225 ++deletedCount;
6226 } while (result->NextRow());
6227
6228 LOG_INFO("server.loading", ">> Processed {} expired mails: {} deleted and {} returned in {} ms", deletedCount + returnedCount, deletedCount, returnedCount, GetMSTimeDiffToNow(oldMSTime));
6229 LOG_INFO("server.loading", " ");
6230}
@ 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
@ MAIL_CHECK_MASK_RETURNED
Definition: Mail.h:49
std::vector< MailItemInfo > MailItemInfoVec
Definition: Mail.h:165
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:256
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
10227{
10228 if (active)
10229 {
10230 if (player->GetLevel() < reqLevel)
10231 return;
10232
10233 if (player->GetTotalPlayedTime() < reqPlayTime)
10234 return;
10235
10236 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
10237
10239 MailDraft draft(subject, body);
10240
10241 draft.AddMoney(player->GetTeamId() == TEAM_ALLIANCE ? rewardMoneyA : rewardMoneyH);
10242 if (Item* mailItem = Item::CreateItem(player->GetTeamId() == TEAM_ALLIANCE ? rewardItemA : rewardItemH, player->GetTeamId() == TEAM_ALLIANCE ? rewardItemCountA : rewardItemCountH))
10243 {
10244 mailItem->SaveToDB(trans);
10245 draft.AddItem(mailItem);
10246 }
10247
10248 draft.SendMailTo(trans, MailReceiver(player), sender);
10249 CharacterDatabase.CommitTransaction(trans);
10250
10252 stmt->SetData(0, player->GetGUID().GetCounter());
10253 stmt->SetData(1, id);
10254 CharacterDatabase.Execute(stmt);
10255
10256 LOG_DEBUG("entities.player", "ObjectMgr::SendServerMail() Sent mail id {} to {}", id, player->GetGUID().ToString());
10257 }
10258}
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:74
@ 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:1089
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:1172
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2069
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 
)
2011{
2012 if (!guidLow)
2013 return false;
2014
2015 CreatureData const* master = GetCreatureData(guidLow);
2016 ObjectGuid guid = ObjectGuid::Create<HighGuid::Unit>(master->id1, guidLow);
2017
2018 if (!linkedGuidLow) // we're removing the linking
2019 {
2020 _linkedRespawnStore.erase(guid);
2022 stmt->SetData(0, guidLow);
2023 WorldDatabase.Execute(stmt);
2024 return true;
2025 }
2026
2027 CreatureData const* slave = GetCreatureData(linkedGuidLow);
2028 if (!slave)
2029 {
2030 LOG_ERROR("sql.sql", "Creature '{}' linking to non-existent creature '{}'.", guidLow, linkedGuidLow);
2031 return false;
2032 }
2033
2034 MapEntry const* map = sMapStore.LookupEntry(master->mapid);
2035 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2036 {
2037 LOG_ERROR("sql.sql", "Creature '{}' linking to '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2038 return false;
2039 }
2040
2041 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2042 {
2043 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2044 return false;
2045 }
2046
2047 ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, linkedGuidLow);
2048
2049 _linkedRespawnStore[guid] = linkedGuid;
2051 stmt->SetData(0, guidLow);
2052 stmt->SetData(1, linkedGuidLow);
2053 WorldDatabase.Execute(stmt);
2054 return true;
2055}
@ 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 ( )
6985{
6986 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
6987 if (result)
6988 GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].Get<uint32>() + 1);
6989
6990 result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
6991 if (result)
6992 GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].Get<uint32>() + 1);
6993
6994 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
6995 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6996 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6997 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6998 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
6999
7000 result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
7001 if (result)
7002 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
7003
7004 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
7005 if (result)
7006 _auctionId = (*result)[0].Get<uint32>() + 1;
7007
7008 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
7009 if (result)
7010 _mailId = (*result)[0].Get<uint32>() + 1;
7011
7012 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
7013 if (result)
7014 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
7015
7016 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
7017 if (result)
7018 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
7019
7020 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
7021 if (result)
7022 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
7023
7024 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
7025 if (result)
7026 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
7027
7028 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
7029 if (result)
7030 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
7031
7032 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
7033 if (result)
7034 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
7035}
#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 
)
10212{
10213 for (auto it = GameobjectInstanceSavedStateList.begin(); it != GameobjectInstanceSavedStateList.end(); it++)
10214 {
10215 if (it->m_guid == guid && it->m_instance == id)
10216 {
10217 it->m_state = state;
10218 }
10219 }
10220}

References GameobjectInstanceSavedStateList.

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
5706{
5707 uint32 oldMSTime = getMSTime();
5708
5709 if (_spellScriptsStore.empty())
5710 {
5711 LOG_INFO("server.loading", ">> Validated 0 scripts.");
5712 LOG_INFO("server.loading", " ");
5713 return;
5714 }
5715
5716 uint32 count = 0;
5717
5718 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
5719 {
5720 SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->first);
5721 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
5722 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
5723 itr = _spellScriptsStore.upper_bound(itr->first);
5724
5725 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
5726 {
5727 SpellScript* spellScript = sitr->first->GetSpellScript();
5728 AuraScript* auraScript = sitr->first->GetAuraScript();
5729 bool valid = true;
5730 if (!spellScript && !auraScript)
5731 {
5732 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
5733 valid = false;
5734 }
5735 if (spellScript)
5736 {
5737 spellScript->_Init(&sitr->first->GetName(), spellEntry->Id);
5738 spellScript->_Register();
5739 if (!spellScript->_Validate(spellEntry))
5740 valid = false;
5741 delete spellScript;
5742 }
5743 if (auraScript)
5744 {
5745 auraScript->_Init(&sitr->first->GetName(), spellEntry->Id);
5746 auraScript->_Register();
5747 if (!auraScript->_Validate(spellEntry))
5748 valid = false;
5749 delete auraScript;
5750 }
5751 if (!valid)
5752 {
5753 _spellScriptsStore.erase(sitr->second);
5754 }
5755 }
5756 ++count;
5757 }
5758
5759 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5760 LOG_INFO("server.loading", " ");
5761}
std::string const & GetScriptName(uint32 id) const
Definition: ObjectMgr.cpp:9494
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().