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

#include "ObjectMgr.h"

Classes

struct  GameobjectInstanceSavedState
 

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

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

Private Types

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

Private Member Functions

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

Private Attributes

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

Friends

class PlayerDumpReader
 

Detailed Description

Member Typedef Documentation

◆ AreaTriggerContainer

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

◆ AreaTriggerScriptContainer

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

◆ AreaTriggerTeleportContainer

◆ BaseXPContainer

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

◆ CharacterConversionMap

◆ CreatureSparringContainer

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

◆ DungeonProgressionRequirementsContainer

◆ ExclusiveQuestGroups

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

◆ ExclusiveQuestGroupsBounds

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

◆ FishingBaseSkillContainer

◆ GossipTextContainer

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

◆ HalfNameContainer

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

◆ HalfNameContainerLocale

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

◆ ItemMap

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

◆ ItemSetNameContainer

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

◆ PetLevelInfoContainer

◆ PlayerXPperLevel

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

◆ PointOfInterestContainer

◆ ProfanityNamesContainer

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

◆ QuestAreaTriggerContainer

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

◆ QuestMap

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

◆ RepOnKillContainer

◆ RepRewardRateContainer

◆ RepSpilloverTemplateContainer

◆ ReservedNamesContainer

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

◆ ScriptNameContainer

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

◆ TavernAreaTriggerContainer

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

Member Enumeration Documentation

◆ CreatureLinkedRespawnType

Enumerator
CREATURE_TO_CREATURE 
CREATURE_TO_GO 
GO_TO_GO 
GO_TO_CREATURE 
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
299 :
300 _auctionId(1),
302 _mailId(1),
303 _hiPetNumber(1),
307{
308 for (uint8 i = 0; i < MAX_CLASSES; ++i)
309 {
310 _playerClassInfo[i] = nullptr;
311 for (uint8 j = 0; j < MAX_RACES; ++j)
312 _playerInfo[j][i] = nullptr;
313 }
314}
@ LOCALE_enUS
Definition Common.h:118
std::uint8_t uint8
Definition Define.h:109
#define MAX_RACES
Definition SharedDefines.h:95
#define MAX_CLASSES
Definition SharedDefines.h:155
PlayerInfo * _playerInfo[MAX_RACES][MAX_CLASSES]
Definition ObjectMgr.h:1552
ObjectGuid::LowType _gameObjectSpawnId
Definition ObjectMgr.h:1461
uint32 _mailId
Definition ObjectMgr.h:1455
ObjectGuid::LowType _creatureSpawnId
Definition ObjectMgr.h:1460
LocaleConstant DBCLocaleIndex
Definition ObjectMgr.h:1528
PlayerClassInfo * _playerClassInfo[MAX_CLASSES]
Definition ObjectMgr.h:1548
uint64 _equipmentSetGuid
Definition ObjectMgr.h:1454
uint32 _auctionId
Definition ObjectMgr.h:1453
uint32 _hiPetNumber
Definition ObjectMgr.h:1457

References _playerClassInfo, _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ ~ObjectMgr()

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

References _accessRequirementStore, _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 
)
2455{
2456 uint8 mask = data->spawnMask;
2457 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2458 {
2459 if (mask & 1)
2460 {
2461 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2462 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2463 cell_guids.creatures.insert(guid);
2464 }
2465 }
2466}
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition ObjectDefines.h:88
MapObjectGuids _mapObjectGuidsStore
Definition ObjectMgr.h:1573
GridCoord ComputeGridCoord(float x, float y)
Definition GridDefines.h:185
Definition ObjectMgr.h:479
CellGuidSet creatures
Definition ObjectMgr.h:480
Definition GridDefines.h:88
uint32 GetId() const
Definition GridDefines.h:150

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

Referenced by AddCreData(), and LoadCreatures().

◆ AddCreData()

ObjectGuid::LowType ObjectMgr::AddCreData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0 
)
2534{
2535 CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
2536 if (!cInfo)
2537 return 0;
2538
2539 uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
2540 CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
2541 Map* map = sMapMgr->CreateBaseMap(mapId);
2542 if (!map)
2543 return 0;
2544
2546 CreatureData& data = NewOrExistCreatureData(spawnId);
2547 data.spawnMask = spawnId;
2548 data.id1 = entry;
2549 data.id2 = 0;
2550 data.id3 = 0;
2551 data.mapid = mapId;
2552 data.displayid = 0;
2553 data.equipmentId = 0;
2554 data.posX = x;
2555 data.posY = y;
2556 data.posZ = z;
2557 data.orientation = o;
2558 data.spawntimesecs = spawntimedelay;
2559 data.wander_distance = 0;
2560 data.currentwaypoint = 0;
2561 data.curhealth = stats->GenerateHealth(cInfo);
2562 data.curmana = stats->GenerateMana(cInfo);
2563 data.movementType = cInfo->MovementType;
2564 data.spawnMask = 1;
2566 data.dbData = false;
2567 data.npcflag = cInfo->npcflag;
2568 data.unit_flags = cInfo->unit_flags;
2569 data.dynamicflags = cInfo->dynamicflags;
2570
2571 AddCreatureToGrid(spawnId, &data);
2572
2573 // Spawn if necessary (loaded grids only)
2574 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2575 {
2576 Creature* creature = new Creature();
2577 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
2578 {
2579 LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
2580 delete creature;
2581 return 0;
2582 }
2583 }
2584
2585 return spawnId;
2586}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
#define sMapMgr
Definition MapMgr.h:220
@ PHASEMASK_NORMAL
Definition Object.h:62
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
Definition Creature.h:47
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition Creature.cpp:1653
Definition Map.h:163
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:204
bool Instanceable() const
Definition Map.h:294
uint32 LowType
Definition ObjectGuid.h:122
CreatureBaseStats const * GetCreatureBaseStats(uint8 level, uint8 unitClass)
Definition ObjectMgr.cpp:9959
void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2454
ObjectGuid::LowType GenerateCreatureSpawnId()
Definition ObjectMgr.cpp:7245
CreatureData & NewOrExistCreatureData(ObjectGuid::LowType spawnId)
Definition ObjectMgr.h:1216
CreatureTemplate const * GetCreatureTemplate(uint32 entry)
Definition ObjectMgr.cpp:10307
Definition CreatureData.h:299
uint32 GenerateMana(CreatureTemplate const *info) const
Definition CreatureData.h:314
uint32 GenerateHealth(CreatureTemplate const *info) const
Definition CreatureData.h:309
Definition CreatureData.h:366
float wander_distance
Definition CreatureData.h:380
uint32 phaseMask
Definition CreatureData.h:372
uint32 spawntimesecs
Definition CreatureData.h:379
uint32 dynamicflags
Definition CreatureData.h:388
uint32 npcflag
Definition CreatureData.h:386
bool dbData
Definition CreatureData.h:390
uint32 displayid
Definition CreatureData.h:373
uint8 movementType
Definition CreatureData.h:384
uint8 spawnMask
Definition CreatureData.h:385
uint32 unit_flags
Definition CreatureData.h:387
uint32 id2
Definition CreatureData.h:369
uint32 curhealth
Definition CreatureData.h:382
float orientation
Definition CreatureData.h:378
uint32 curmana
Definition CreatureData.h:383
uint32 id3
Definition CreatureData.h:370
float posY
Definition CreatureData.h:376
float posX
Definition CreatureData.h:375
int8 equipmentId
Definition CreatureData.h:374
uint32 currentwaypoint
Definition CreatureData.h:381
uint16 mapid
Definition CreatureData.h:371
float posZ
Definition CreatureData.h:377
uint32 id1
Definition CreatureData.h:368
Definition CreatureData.h:186
uint32 unit_flags
Definition CreatureData.h:214
uint8 minlevel
Definition CreatureData.h:195
uint8 maxlevel
Definition CreatureData.h:196
uint32 MovementType
Definition CreatureData.h:230
uint32 npcflag
Definition CreatureData.h:199
uint32 unit_class
Definition CreatureData.h:213
uint32 dynamicflags
Definition CreatureData.h:216

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

◆ AddGameobjectInfo()

void ObjectMgr::AddGameobjectInfo ( GameObjectTemplate goinfo)

◆ AddGameobjectToGrid()

void ObjectMgr::AddGameobjectToGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2761{
2762 uint8 mask = data->spawnMask;
2763 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2764 {
2765 if (mask & 1)
2766 {
2767 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2768 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2769 cell_guids.gameobjects.insert(guid);
2770 }
2771 }
2772}
CellGuidSet gameobjects
Definition ObjectMgr.h:481

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

Referenced by AddGOData(), and LoadGameobjects().

◆ AddGameTele()

bool ObjectMgr::AddGameTele ( GameTele data)
9163{
9164 // find max id
9165 uint32 new_id = 0;
9166 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9167 if (itr->first > new_id)
9168 new_id = itr->first;
9169
9170 // use next
9171 ++new_id;
9172
9173 if (!Utf8toWStr(tele.name, tele.wnameLow))
9174 return false;
9175
9176 wstrToLower(tele.wnameLow);
9177
9178 _gameTeleStore[new_id] = tele;
9179
9181
9182 stmt->SetData(0, new_id);
9183 stmt->SetData(1, tele.position_x);
9184 stmt->SetData(2, tele.position_y);
9185 stmt->SetData(3, tele.position_z);
9186 stmt->SetData(4, tele.orientation);
9187 stmt->SetData(5, uint16(tele.mapId));
9188 stmt->SetData(6, tele.name);
9189
9190 WorldDatabase.Execute(stmt);
9191
9192 return true;
9193}
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint16_t uint16
Definition Define.h:108
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition Util.cpp:281
void wstrToLower(std::wstring &str)
Definition Util.cpp:382
@ WORLD_INS_GAME_TELE
Definition WorldDatabase.h:41
GameTeleContainer _gameTeleStore
Definition ObjectMgr.h:1516
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

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

◆ AddGOData()

ObjectGuid::LowType ObjectMgr::AddGOData ( uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0,
float  rotation0 = 0,
float  rotation1 = 0,
float  rotation2 = 0,
float  rotation3 = 0 
)
2483{
2484 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
2485 if (!goinfo)
2486 return 0;
2487
2488 Map* map = sMapMgr->CreateBaseMap(mapId);
2489 if (!map)
2490 return 0;
2491
2493
2494 GameObjectData& data = NewGOData(spawnId);
2495 data.id = entry;
2496 data.mapid = mapId;
2497 data.posX = x;
2498 data.posY = y;
2499 data.posZ = z;
2500 data.orientation = o;
2501 data.rotation.x = rotation0;
2502 data.rotation.y = rotation1;
2503 data.rotation.z = rotation2;
2504 data.rotation.w = rotation3;
2505 data.spawntimesecs = spawntimedelay;
2506 data.animprogress = 100;
2507 data.spawnMask = 1;
2508 data.go_state = GO_STATE_READY;
2510 data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
2511 data.dbData = false;
2512
2513 AddGameobjectToGrid(spawnId, &data);
2514
2515 // Spawn if necessary (loaded grids only)
2516 // We use spawn coords to spawn
2517 if (!map->Instanceable() && map->IsGridLoaded(x, y))
2518 {
2520 if (!go->LoadGameObjectFromDB(spawnId, map))
2521 {
2522 LOG_ERROR("sql.sql", "AddGOData: cannot add gameobject entry {} to map", entry);
2523 delete go;
2524 return 0;
2525 }
2526 }
2527
2528 LOG_DEBUG("maps", "AddGOData: spawnId {} entry {} map {} x {} y {} z {} o {}", spawnId, entry, mapId, x, y, z, o);
2529
2530 return spawnId;
2531}
@ GO_STATE_READY
Definition GameObjectData.h:692
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition SharedDefines.h:1600
Definition GameObject.h:120
virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition GameObject.cpp:1104
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:2760
GameObjectTemplate const * GetGameObjectTemplate(uint32 entry)
Definition ObjectMgr.cpp:10283
ObjectGuid::LowType GenerateGameObjectSpawnId()
Definition ObjectMgr.cpp:7255
GameObjectData & NewGOData(ObjectGuid::LowType guid)
Definition ObjectMgr.h:1301
bool IsGameObjectStaticTransport(uint32 entry)
Definition ObjectMgr.cpp:10292
Definition Transport.h:115
Definition GameObjectData.h:698
bool dbData
Definition GameObjectData.h:714
float orientation
Definition GameObjectData.h:706
float posZ
Definition GameObjectData.h:705
uint8 artKit
Definition GameObjectData.h:713
int32 spawntimesecs
Definition GameObjectData.h:708
uint8 spawnMask
Definition GameObjectData.h:712
G3D::Quat rotation
Definition GameObjectData.h:707
uint32 animprogress
Definition GameObjectData.h:710
uint16 mapid
Definition GameObjectData.h:701
float posX
Definition GameObjectData.h:703
uint32 phaseMask
Definition GameObjectData.h:702
float posY
Definition GameObjectData.h:704
uint32 id
Definition GameObjectData.h:700
GOState go_state
Definition GameObjectData.h:711
Definition GameObjectData.h:31
uint32 type
Definition GameObjectData.h:33

References AddGameobjectToGrid(), GameObjectData::animprogress, GameObjectData::artKit, GameObjectData::dbData, GAMEOBJECT_TYPE_CAPTURE_POINT, GenerateGameObjectSpawnId(), GetGameObjectTemplate(), GameObjectData::go_state, GO_STATE_READY, GameObjectData::id, Map::Instanceable(), IsGameObjectStaticTransport(), 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, GameObjectData::spawnMask, GameObjectData::spawntimesecs, and GameObjectTemplate::type.

◆ AddLocaleString()

◆ AddProfanityPlayerName()

void ObjectMgr::AddProfanityPlayerName ( std::string const &  name)
8530{
8531 if (!IsProfanityName(name))
8532 {
8533 std::wstring wstr;
8534 if (!Utf8toWStr(name, wstr))
8535 {
8536 LOG_ERROR("server", "Could not add invalid name to profanity player names: {}", name);
8537 return;
8538 }
8539 wstrToLower(wstr);
8540
8541 _profanityNamesStore.insert(wstr);
8542
8544 stmt->SetData(0, name);
8545 CharacterDatabase.Execute(stmt);
8546 }
8547}
@ CHAR_INS_PROFANITY_PLAYER_NAME
Definition CharacterDatabase.h:520
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
ProfanityNamesContainer _profanityNamesStore
Definition ObjectMgr.h:1514
bool IsProfanityName(std::string_view name) const
Definition ObjectMgr.cpp:8514

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

◆ AddReservedPlayerName()

void ObjectMgr::AddReservedPlayerName ( std::string const &  name)
8427{
8428 if (!IsReservedName(name))
8429 {
8430 std::wstring wstr;
8431 if (!Utf8toWStr(name, wstr))
8432 {
8433 LOG_ERROR("server", "Could not add invalid name to reserved player names: {}", name);
8434 return;
8435 }
8436 wstrToLower(wstr);
8437
8438 _reservedNamesStore.insert(wstr);
8439
8441 stmt->SetData(0, name);
8442 CharacterDatabase.Execute(stmt);
8443 }
8444}
@ CHAR_INS_RESERVED_PLAYER_NAME
Definition CharacterDatabase.h:519
bool IsReservedName(std::string_view name) const
Definition ObjectMgr.cpp:8411
ReservedNamesContainer _reservedNamesStore
Definition ObjectMgr.h:1510

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

◆ AddVendorItem()

void ObjectMgr::AddVendorItem ( uint32  entry,
uint32  item,
int32  maxcount,
uint32  incrtime,
uint32  extendedCost,
bool  persist = true 
)
9637{
9638 VendorItemData& vList = _cacheVendorItemStore[entry];
9639 vList.AddItem(item, maxcount, incrtime, extendedCost);
9640
9641 if (persist)
9642 {
9644
9645 stmt->SetData(0, entry);
9646 stmt->SetData(1, item);
9647 stmt->SetData(2, maxcount);
9648 stmt->SetData(3, incrtime);
9649 stmt->SetData(4, extendedCost);
9650
9651 WorldDatabase.Execute(stmt);
9652 }
9653}
@ WORLD_INS_NPC_VENDOR
Definition WorldDatabase.h:43
Definition CreatureData.h:465
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition CreatureData.h:477

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
4519{
4520 // base data (last known level)
4521 *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1];
4522
4523 // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
4524 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl)
4525 {
4526 switch (_class)
4527 {
4528 case CLASS_WARRIOR:
4529 info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4530 info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0));
4531 info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4532 info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4533 info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4534 break;
4535 case CLASS_PALADIN:
4536 info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0);
4537 info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4538 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0));
4539 info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0);
4540 info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0);
4541 break;
4542 case CLASS_HUNTER:
4543 info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0);
4544 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4545 info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0));
4546 info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0);
4547 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4548 break;
4549 case CLASS_ROGUE:
4550 info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0);
4551 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4552 info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0));
4553 info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0);
4554 info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0));
4555 break;
4556 case CLASS_PRIEST:
4557 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4558 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4559 info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4560 info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0));
4561 info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0);
4562 break;
4563 case CLASS_SHAMAN:
4564 info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4565 info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0);
4566 info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0);
4567 info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0);
4568 info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0);
4569 break;
4570 case CLASS_MAGE:
4571 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4572 info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0);
4573 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4574 info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0));
4575 info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4576 break;
4577 case CLASS_WARLOCK:
4578 info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4579 info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4580 info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0);
4581 info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0));
4582 info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0));
4583 break;
4584 case CLASS_DRUID:
4585 info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0));
4586 info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0));
4587 info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0));
4588 info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0));
4589 info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0));
4590 }
4591 }
4592}
@ CLASS_HUNTER
Definition SharedDefines.h:143
@ CLASS_DRUID
Definition SharedDefines.h:151
@ CLASS_SHAMAN
Definition SharedDefines.h:147
@ CLASS_PRIEST
Definition SharedDefines.h:145
@ CLASS_WARRIOR
Definition SharedDefines.h:141
@ CLASS_WARLOCK
Definition SharedDefines.h:149
@ CLASS_MAGE
Definition SharedDefines.h:148
@ CLASS_PALADIN
Definition SharedDefines.h:142
@ CLASS_ROGUE
Definition SharedDefines.h:144
@ STAT_SPIRIT
Definition SharedDefines.h:273
@ STAT_INTELLECT
Definition SharedDefines.h:272
@ STAT_AGILITY
Definition SharedDefines.h:270
@ STAT_STRENGTH
Definition SharedDefines.h:269
@ STAT_STAMINA
Definition SharedDefines.h:271
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:190
#define sWorld
Definition World.h:316
std::array< uint32, MAX_STATS > stats
Definition Player.h:297

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 
)
8982{
8983 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8984 if (!fArea)
8985 {
8986 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8987 return;
8988 }
8989
8990 _fishingBaseForAreaStore[entry] = skill;
8991
8992 LOG_INFO("server.loading", ">> Fishing base skill level of area {} changed to {}", entry, skill);
8993 LOG_INFO("server.loading", " ");
8994}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define LOG_INFO(filterType__,...)
Definition Log.h:166
FishingBaseSkillContainer _fishingBaseForAreaStore
Definition ObjectMgr.h:1561
Definition DBCStructure.h:519

References _fishingBaseForAreaStore, LOG_ERROR, LOG_INFO, and sAreaTableStore.

◆ CheckCreatureMovement()

void ObjectMgr::CheckCreatureMovement ( char const *  table,
uint64  id,
CreatureMovementData creatureMovement 
)
1227{
1228 if (creatureMovement.Ground >= CreatureGroundMovementType::Max)
1229 {
1230 LOG_ERROR("sql.sql", "`{}`.`Ground` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Ground), id);
1231 creatureMovement.Ground = CreatureGroundMovementType::Run;
1232 }
1233
1234 if (creatureMovement.Flight >= CreatureFlightMovementType::Max)
1235 {
1236 LOG_ERROR("sql.sql", "`{}`.`Flight` wrong value ({}) for Id {}, setting to None.", table, uint32(creatureMovement.Flight), id);
1237 creatureMovement.Flight = CreatureFlightMovementType::None;
1238 }
1239
1240 if (creatureMovement.Chase >= CreatureChaseMovementType::Max)
1241 {
1242 LOG_ERROR("sql.sql", "`{}`.`Chase` wrong value ({}) for Id {}, setting to Run.", table, uint32(creatureMovement.Chase), id);
1243 creatureMovement.Chase = CreatureChaseMovementType::Run;
1244 }
1245
1246 if (creatureMovement.Random >= CreatureRandomMovementType::Max)
1247 {
1248 LOG_ERROR("sql.sql", "`{}`.`Random` wrong value ({}) for Id {}, setting to Walk.", table, uint32(creatureMovement.Random), id);
1249 creatureMovement.Random = CreatureRandomMovementType::Walk;
1250 }
1251}
CreatureRandomMovementType Random
Definition CreatureData.h:127
CreatureFlightMovementType Flight
Definition CreatureData.h:123
CreatureChaseMovementType Chase
Definition CreatureData.h:126
CreatureGroundMovementType Ground
Definition CreatureData.h:122

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

Referenced by CheckCreatureTemplate(), and LoadCreatureMovementOverrides().

◆ CheckCreatureTemplate()

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

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

Referenced by LoadCreatureTemplates().

◆ CheckDeclinedNames()

bool ObjectMgr::CheckDeclinedNames ( std::wstring  w_ownname,
DeclinedName const &  names 
)
static
8997{
8998 // get main part of the name
8999 std::wstring mainpart = GetMainPartOfName(w_ownname, 0);
9000 // prepare flags
9001 bool x = true;
9002 bool y = true;
9003
9004 // check declined names
9005 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
9006 {
9007 std::wstring wname;
9008 if (!Utf8toWStr(names.name[i], wname))
9009 return false;
9010
9011 if (mainpart != GetMainPartOfName(wname, i + 1))
9012 x = false;
9013
9014 if (w_ownname != wname)
9015 y = false;
9016 }
9017 return (x || y);
9018}
#define MAX_DECLINED_NAME_CASES
Definition Unit.h:535
std::wstring GetMainPartOfName(std::wstring const &wname, uint32_t declension)
Definition Util.cpp:386

References GetMainPartOfName(), MAX_DECLINED_NAME_CASES, DeclinedName::name, and Utf8toWStr().

Referenced by WorldSession::HandlePetRename(), and WorldSession::HandleSetPlayerDeclinedNames().

◆ CheckPetName()

PetNameInvalidReason ObjectMgr::CheckPetName ( std::string_view  name)
static
8702{
8703 std::wstring wname;
8704 if (!Utf8toWStr(name, wname))
8705 return PET_NAME_INVALID;
8706
8707 if (wname.size() > MAX_PET_NAME)
8708 return PET_NAME_TOO_LONG;
8709
8710 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PET_NAME);
8711 if (wname.size() < minName)
8712 return PET_NAME_TOO_SHORT;
8713
8714 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PET_NAMES);
8715 if (!isValidString(wname, strictMask, false))
8717
8718 // Check Reserved Name
8719 if (sObjectMgr->IsReservedName(name))
8720 return PET_NAME_RESERVED;
8721
8722 // Check Profanity Name
8723 if (sObjectMgr->IsProfanityName(name))
8724 return PET_NAME_PROFANE;
8725
8726 return PET_NAME_SUCCESS;
8727}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create=false)
Definition ObjectMgr.cpp:8586
#define sObjectMgr
Definition ObjectMgr.h:1644
#define MAX_PET_NAME
Definition ObjectMgr.h:684
@ PET_NAME_INVALID
Definition SharedDefines.h:3916
@ PET_NAME_RESERVED
Definition SharedDefines.h:3922
@ PET_NAME_SUCCESS
Definition SharedDefines.h:3914
@ PET_NAME_MIXED_LANGUAGES
Definition SharedDefines.h:3920
@ PET_NAME_TOO_SHORT
Definition SharedDefines.h:3918
@ PET_NAME_TOO_LONG
Definition SharedDefines.h:3919
@ PET_NAME_PROFANE
Definition SharedDefines.h:3921
@ CONFIG_STRICT_PET_NAMES
Definition WorldConfig.h:177
@ CONFIG_MIN_PET_NAME
Definition WorldConfig.h:180

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

Referenced by WorldSession::HandlePetRename().

◆ CheckPlayerName()

uint8 ObjectMgr::CheckPlayerName ( std::string_view  name,
bool  create = false 
)
static
8623{
8624 std::wstring wname;
8625
8626 // Check for invalid characters
8627 if (!Utf8toWStr(name, wname))
8629
8630 // Check for too long name
8631 if (wname.size() > MAX_PLAYER_NAME)
8632 return CHAR_NAME_TOO_LONG;
8633
8634 // Check for too short name
8635 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_PLAYER_NAME);
8636 if (wname.size() < minName)
8637 return CHAR_NAME_TOO_SHORT;
8638
8639 // Check for mixed languages
8640 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_PLAYER_NAMES);
8641 if (!isValidString(wname, strictMask, false, create))
8643
8644 // Check for three consecutive letters
8645 wstrToLower(wname);
8646 for (std::size_t i = 2; i < wname.size(); ++i)
8647 if (wname[i] == wname[i - 1] && wname[i] == wname[i - 2])
8649
8650 // Check Reserved Name
8651 if (sObjectMgr->IsReservedName(name))
8652 return CHAR_NAME_RESERVED;
8653
8654 // Check Profanity Name
8655 if (sObjectMgr->IsProfanityName(name))
8656 return CHAR_NAME_PROFANE;
8657
8658 return CHAR_NAME_SUCCESS;
8659}
#define MAX_PLAYER_NAME
Definition ObjectMgr.h:682
@ CHAR_NAME_TOO_SHORT
Definition SharedDefines.h:3678
@ CHAR_NAME_THREE_CONSECUTIVE
Definition SharedDefines.h:3686
@ CHAR_NAME_INVALID_CHARACTER
Definition SharedDefines.h:3680
@ CHAR_NAME_TOO_LONG
Definition SharedDefines.h:3679
@ CHAR_NAME_RESERVED
Definition SharedDefines.h:3683
@ CHAR_NAME_MIXED_LANGUAGES
Definition SharedDefines.h:3681
@ CHAR_NAME_PROFANE
Definition SharedDefines.h:3682
@ CHAR_NAME_SUCCESS
Definition SharedDefines.h:3675
@ CONFIG_STRICT_PLAYER_NAMES
Definition WorldConfig.h:174
@ CONFIG_MIN_PLAYER_NAME
Definition WorldConfig.h:178

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

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

◆ ChooseCreatureFlags()

void ObjectMgr::ChooseCreatureFlags ( CreatureTemplate const *  cinfo,
uint32 npcflag,
uint32 unit_flags,
uint32 dynamicflags,
CreatureData const *  data = nullptr 
)
static
1644{
1645 npcflag = cinfo->npcflag;
1646 unit_flags = cinfo->unit_flags;
1647 dynamicflags = cinfo->dynamicflags;
1648
1649 if (data)
1650 {
1651 if (data->npcflag)
1652 npcflag = data->npcflag;
1653
1654 if (data->unit_flags)
1655 unit_flags = data->unit_flags;
1656
1657 if (data->dynamicflags)
1658 dynamicflags = data->dynamicflags;
1659 }
1660}

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

Referenced by Creature::UpdateEntry().

◆ ChooseDisplayId()

CreatureModel const * ObjectMgr::ChooseDisplayId ( CreatureTemplate const *  cinfo,
CreatureData const *  data = nullptr 
)
static
1629{
1630 // Load creature model (display id)
1631 if (data && data->displayid)
1632 if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid))
1633 return model;
1634
1635 if (!cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER))
1636 if (CreatureModel const* model = cinfo->GetRandomValidModel())
1637 return model;
1638
1639 // Triggers by default receive the invisible model
1640 return cinfo->GetFirstInvisibleModel();
1641}
@ CREATURE_FLAG_EXTRA_TRIGGER
Definition CreatureData.h:52

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

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

◆ DeleteCreatureData()

void ObjectMgr::DeleteCreatureData ( ObjectGuid::LowType  spawnId)
8223{
8224 // remove mapid*cellid -> guid_set map
8225 CreatureData const* data = GetCreatureData(guid);
8226 if (data)
8227 RemoveCreatureFromGrid(guid, data);
8228
8229 _creatureDataStore.erase(guid);
8230}
CreatureDataContainer _creatureDataStore
Definition ObjectMgr.h:1576
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const *data)
Definition ObjectMgr.cpp:2468
CreatureData const * GetCreatureData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1207

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

◆ DeleteGameTele()

bool ObjectMgr::DeleteGameTele ( std::string_view  name)
9196{
9197 // explicit name case
9198 std::wstring wname;
9199 if (!Utf8toWStr(name, wname))
9200 return false;
9201
9202 // converting string that we try to find to lower case
9203 wstrToLower(wname);
9204
9205 for (GameTeleContainer::iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9206 {
9207 if (itr->second.wnameLow == wname)
9208 {
9210
9211 stmt->SetData(0, itr->second.name);
9212
9213 WorldDatabase.Execute(stmt);
9214
9215 _gameTeleStore.erase(itr);
9216 return true;
9217 }
9218 }
9219
9220 return false;
9221}
@ 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)
8233{
8234 // remove mapid*cellid -> guid_set map
8235 GameObjectData const* data = GetGameObjectData(guid);
8236 if (data)
8237 RemoveGameobjectFromGrid(guid, data);
8238
8239 _gameObjectDataStore.erase(guid);
8240}
GameObjectData const * GetGameObjectData(ObjectGuid::LowType spawnId) const
Definition ObjectMgr.h:1227
GameObjectDataContainer _gameObjectDataStore
Definition ObjectMgr.h:1590
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const *data)
Definition ObjectMgr.cpp:2774

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

◆ GenerateAuctionID()

uint32 ObjectMgr::GenerateAuctionID ( )
7215{
7216 if (_auctionId >= 0xFFFFFFFE)
7217 {
7218 LOG_ERROR("server.worldserver", "Auctions ids overflow!! Can't continue, shutting down server. ");
7220 }
7221 return _auctionId++;
7222}
static void StopNow(uint8 exitcode)
Definition World.h:188
@ ERROR_EXIT_CODE
Definition World.h:54

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

◆ GenerateCreatureSpawnId()

uint32 ObjectMgr::GenerateCreatureSpawnId ( )
7246{
7247 if (_creatureSpawnId >= uint32(0xFFFFFF))
7248 {
7249 LOG_ERROR("server.worldserver", "Creature spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info.");
7251 }
7252 return _creatureSpawnId++;
7253}

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

Referenced by AddCreData().

◆ GenerateEquipmentSetGuid()

uint64 ObjectMgr::GenerateEquipmentSetGuid ( )
7225{
7226 if (_equipmentSetGuid >= uint64(0xFFFFFFFFFFFFFFFELL))
7227 {
7228 LOG_ERROR("server.worldserver", "EquipmentSet guid overflow!! Can't continue, shutting down server. ");
7230 }
7231 return _equipmentSetGuid++;
7232}
std::uint64_t uint64
Definition Define.h:106

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

◆ GenerateGameObjectSpawnId()

uint32 ObjectMgr::GenerateGameObjectSpawnId ( )
7256{
7257 if (_gameObjectSpawnId >= uint32(0xFFFFFF))
7258 {
7259 LOG_ERROR("server.worldserver", "GameObject spawn id overflow!! Can't continue, shutting down server. Search on forum for TCE00007 for more info. ");
7261 }
7262 return _gameObjectSpawnId++;
7263}

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

Referenced by AddGOData().

◆ GenerateMailID()

uint32 ObjectMgr::GenerateMailID ( )
7235{
7236 if (_mailId >= 0xFFFFFFFE)
7237 {
7238 LOG_ERROR("server.worldserver", "Mail ids overflow!! Can't continue, shutting down server. ");
7240 }
7241 std::lock_guard<std::mutex> guard(_mailIdMutex);
7242 return _mailId++;
7243}
std::mutex _mailIdMutex
Definition ObjectMgr.h:1456

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

◆ GeneratePetName()

std::string ObjectMgr::GeneratePetName ( uint32  entry)
7722{
7723 std::vector<std::string>& list0 = _petHalfName0[entry];
7724 std::vector<std::string>& list1 = _petHalfName1[entry];
7725
7726 if (list0.empty() || list1.empty())
7727 {
7728 CreatureTemplate const* cinfo = GetCreatureTemplate(entry);
7729 char const* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
7730 if (!petname)
7731 return cinfo->Name;
7732
7733 return std::string(petname);
7734 }
7735
7736 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7737}
char const * GetPetName(uint32 petfamily, uint32 dbclang)
Definition DBCStores.cpp:665
HalfNameContainer _petHalfName1
Definition ObjectMgr.h:1565
HalfNameContainer _petHalfName0
Definition ObjectMgr.h:1564
std::string Name
Definition CreatureData.h:191

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

Referenced by GeneratePetNameLocale().

◆ GeneratePetNameLocale()

std::string ObjectMgr::GeneratePetNameLocale ( uint32  entry,
LocaleConstant  locale 
)
7709{
7710 std::vector<std::string>& list0 = _petHalfLocaleName0[std::make_pair(entry, locale)];
7711 std::vector<std::string>& list1 = _petHalfLocaleName1[std::make_pair(entry, locale)];
7712
7713 if (list0.empty() || list1.empty())
7714 {
7715 return GeneratePetName(entry);
7716 }
7717
7718 return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1));
7719}
HalfNameContainerLocale _petHalfLocaleName0
Definition ObjectMgr.h:1567
HalfNameContainerLocale _petHalfLocaleName1
Definition ObjectMgr.h:1568
std::string GeneratePetName(uint32 entry)
Definition ObjectMgr.cpp:7721

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

◆ GeneratePetNumber()

uint32 ObjectMgr::GeneratePetNumber ( )
7740{
7741 std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
7742 return ++_hiPetNumber;
7743}
std::mutex _hiPetNumberMutex
Definition ObjectMgr.h:1458

References _hiPetNumber, and _hiPetNumberMutex.

◆ GetAccessRequirement()

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

References _accessRequirementStore.

◆ GetAcoreString() [1/2]

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

References _acoreStringStore.

Referenced by GetAcoreString(), and GetAcoreStringForDBCLocale().

◆ GetAcoreString() [2/2]

std::string ObjectMgr::GetAcoreString ( uint32  entry,
LocaleConstant  locale 
) const
8928{
8929 AcoreString const* as = GetAcoreString(entry);
8930 if (as && !as->Content.empty())
8931 {
8932 if (as->Content.size() > std::size_t(locale) && !as->Content[locale].empty())
8933 return as->Content[locale];
8934
8935 return as->Content[DEFAULT_LOCALE];
8936 }
8937
8938 std::string msg = Acore::StringFormat("No entry for acore_string ({}) in DB.", entry);
8939 LOG_ERROR("sql.sql", msg);
8940 return msg;
8941}
#define DEFAULT_LOCALE
Definition Common.h:131
AcoreString const * GetAcoreString(uint32 entry) const
Definition ObjectMgr.h:1315
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:34
Definition ObjectMgr.h:502
std::vector< std::string > Content
Definition ObjectMgr.h:503

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

◆ GetAcoreStringForDBCLocale()

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

References DBCLocaleIndex, and GetAcoreString().

◆ GetAllAreaTriggerScriptData()

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

References _areaTriggerScriptStore.

◆ GetAllCreatureData()

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

References _creatureDataStore.

◆ GetAllGOData()

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

References _gameObjectDataStore.

◆ GetAreaTrigger()

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

References _areaTriggerStore.

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

◆ GetAreaTriggerScriptId()

uint32 ObjectMgr::GetAreaTriggerScriptId ( uint32  trigger_id)
9021{
9022 AreaTriggerScriptContainer::const_iterator i = _areaTriggerScriptStore.find(trigger_id);
9023 if (i != _areaTriggerScriptStore.end())
9024 return i->second;
9025 return 0;
9026}

References _areaTriggerScriptStore.

◆ GetAreaTriggerTeleport()

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

References _areaTriggerTeleportStore.

◆ GetBaseReputationOf()

int32 ObjectMgr::GetBaseReputationOf ( FactionEntry const *  factionEntry,
uint8  race,
uint8  playerClass 
)
9035{
9036 if (!factionEntry)
9037 return 0;
9038
9039 uint32 raceMask = (1 << (race - 1));
9040 uint32 classMask = (1 << (playerClass - 1));
9041
9042 for (int i = 0; i < 4; i++)
9043 {
9044 if ((!factionEntry->BaseRepClassMask[i] ||
9045 factionEntry->BaseRepClassMask[i] & classMask) &&
9046 (!factionEntry->BaseRepRaceMask[i] ||
9047 factionEntry->BaseRepRaceMask[i] & raceMask))
9048 return factionEntry->BaseRepValue[i];
9049 }
9050
9051 return 0;
9052}

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

◆ GetBaseXP()

uint32 ObjectMgr::GetBaseXP ( uint8  level)
7650{
7651 return _baseXPTable[level] ? _baseXPTable[level] : 0;
7652}
BaseXPContainer _baseXPTable
Definition ObjectMgr.h:1558

References _baseXPTable.

◆ GetBroadcastText()

BroadcastText const * ObjectMgr::GetBroadcastText ( uint32  id) const
inline
1200 {
1201 BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id);
1202 if (itr != _broadcastTextStore.end())
1203 return &itr->second;
1204 return nullptr;
1205 }
BroadcastTextContainer _broadcastTextStore
Definition ObjectMgr.h:1597

References _broadcastTextStore.

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

◆ GetCreatureAddon()

CreatureAddon const * ObjectMgr::GetCreatureAddon ( ObjectGuid::LowType  lowguid)
1416{
1417 CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid);
1418 if (itr != _creatureAddonStore.end())
1419 return &(itr->second);
1420
1421 return nullptr;
1422}
CreatureAddonContainer _creatureAddonStore
Definition ObjectMgr.h:1581

References _creatureAddonStore.

◆ GetCreatureBaseStats()

CreatureBaseStats const * ObjectMgr::GetCreatureBaseStats ( uint8  level,
uint8  unitClass 
)
9960{
9961 CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));
9962
9963 if (it != _creatureBaseStatsStore.end())
9964 return &(it->second);
9965
9966 struct DefaultCreatureBaseStats : public CreatureBaseStats
9967 {
9968 DefaultCreatureBaseStats()
9969 {
9970 BaseArmor = 1;
9971 for (uint8 j = 0; j < MAX_EXPANSIONS; ++j)
9972 {
9973 BaseHealth[j] = 1;
9974 BaseDamage[j] = 0.0f;
9975 }
9976 BaseMana = 0;
9977 AttackPower = 0;
9978 RangedAttackPower = 0;
9979 }
9980 };
9981 static const DefaultCreatureBaseStats defStats;
9982 return &defStats;
9983}
uint16 MAKE_PAIR16(uint8 l, uint8 h)
Definition ObjectDefines.h:83
CreatureBaseStatsContainer _creatureBaseStatsStore
Definition ObjectMgr.h:1542

References _creatureBaseStatsStore, MAKE_PAIR16(), and MAX_EXPANSIONS.

Referenced by AddCreData().

◆ GetCreatureData()

CreatureData const * ObjectMgr::GetCreatureData ( ObjectGuid::LowType  spawnId) const
inline
1208 {
1209 CreatureDataContainer::const_iterator itr = _creatureDataStore.find(spawnId);
1210 if (itr == _creatureDataStore.end()) return nullptr;
1211 return &itr->second;
1212 }

References _creatureDataStore.

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

◆ GetCreatureLocale()

CreatureLocale const * ObjectMgr::GetCreatureLocale ( uint32  entry) const
inline
1234 {
1235 CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry);
1236 if (itr == _creatureLocaleStore.end()) return nullptr;
1237 return &itr->second;
1238 }
CreatureLocaleContainer _creatureLocaleStore
Definition ObjectMgr.h:1589

References _creatureLocaleStore.

◆ GetCreatureModelInfo()

CreatureModelInfo const * ObjectMgr::GetCreatureModelInfo ( uint32  modelId) const
1620{
1621 CreatureModelContainer::const_iterator itr = _creatureModelStore.find(modelId);
1622 if (itr != _creatureModelStore.end())
1623 return &(itr->second);
1624
1625 return nullptr;
1626}
CreatureModelContainer _creatureModelStore
Definition ObjectMgr.h:1580

References _creatureModelStore.

Referenced by GetCreatureModelRandomGender(), and LoadCreatureTemplateModels().

◆ GetCreatureModelRandomGender()

CreatureModelInfo const * ObjectMgr::GetCreatureModelRandomGender ( CreatureModel model,
CreatureTemplate const *  creatureTemplate 
) const
1663{
1664 CreatureModelInfo const* modelInfo = GetCreatureModelInfo(model->CreatureDisplayID);
1665 if (!modelInfo)
1666 return nullptr;
1667
1668 // If a model for another gender exists, 50% chance to use it
1669 if (modelInfo->modelid_other_gender != 0 && urand(0, 1) == 0)
1670 {
1671 CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender);
1672 if (!minfo_tmp)
1673 LOG_ERROR("sql.sql", "Model (Entry: {}) has modelid_other_gender {} not found in table `creature_model_info`. ", model->CreatureDisplayID, modelInfo->modelid_other_gender);
1674 else
1675 {
1676 // Model ID changed
1677 model->CreatureDisplayID = modelInfo->modelid_other_gender;
1678 if (creatureTemplate)
1679 {
1680 auto itr = std::find_if(creatureTemplate->Models.begin(), creatureTemplate->Models.end(), [&](CreatureModel const& templateModel)
1681 {
1682 return templateModel.CreatureDisplayID == modelInfo->modelid_other_gender;
1683 });
1684 if (itr != creatureTemplate->Models.end())
1685 *model = *itr;
1686 }
1687 return minfo_tmp;
1688 }
1689 }
1690
1691 return modelInfo;
1692}
CreatureModelInfo const * GetCreatureModelInfo(uint32 modelId) const
Definition ObjectMgr.cpp:1619
Definition CreatureData.h:394
uint32 modelid_other_gender
Definition CreatureData.h:398
uint32 CreatureDisplayID
Definition CreatureData.h:179

References CreatureModel::CreatureDisplayID, GetCreatureModelInfo(), LOG_ERROR, CreatureModelInfo::modelid_other_gender, CreatureTemplate::Models, and urand().

Referenced by GetTaxiMountDisplayId().

◆ GetCreatureMovementOverride()

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

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

◆ GetCreatureQuestInvolvedRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestInvolvedRelationBounds ( uint32  creature_entry)
inline
1008 {
1009 return _creatureQuestInvolvedRelations.equal_range(creature_entry);
1010 }
QuestRelations _creatureQuestInvolvedRelations
Definition ObjectMgr.h:1506

References _creatureQuestInvolvedRelations.

◆ GetCreatureQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestInvolvedRelationMap ( )
inline

◆ GetCreatureQuestItemList()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestItemMap()

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

References _creatureQuestItemStore.

◆ GetCreatureQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetCreatureQuestRelationBounds ( uint32  creature_entry)
inline
1003 {
1004 return _creatureQuestRelations.equal_range(creature_entry);
1005 }
QuestRelations _creatureQuestRelations
Definition ObjectMgr.h:1505

References _creatureQuestRelations.

◆ GetCreatureQuestRelationMap()

QuestRelations * ObjectMgr::GetCreatureQuestRelationMap ( )
inline
993 {
995 }

References _creatureQuestRelations.

◆ GetCreatureTemplate()

◆ GetCreatureTemplateAddon()

CreatureAddon const * ObjectMgr::GetCreatureTemplateAddon ( uint32  entry)
1425{
1426 CreatureAddonContainer::const_iterator itr = _creatureTemplateAddonStore.find(entry);
1427 if (itr != _creatureTemplateAddonStore.end())
1428 return &(itr->second);
1429
1430 return nullptr;
1431}
CreatureAddonContainer _creatureTemplateAddonStore
Definition ObjectMgr.h:1582

References _creatureTemplateAddonStore.

◆ GetCreatureTemplates()

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

References _creatureTemplateStore.

Referenced by LoadCreatureClassLevelStats(), and LoadNPCSpellClickSpells().

◆ GetDBCLocaleIndex()

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

References DBCLocaleIndex.

◆ GetDungeonEncounterList()

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

References _dungeonEncounterStore, and MAKE_PAIR32().

◆ GetEquipmentInfo()

EquipmentInfo const * ObjectMgr::GetEquipmentInfo ( uint32  entry,
int8 id 
)
1439{
1440 EquipmentInfoContainer::const_iterator itr = _equipmentInfoStore.find(entry);
1441 if (itr == _equipmentInfoStore.end())
1442 return nullptr;
1443
1444 if (itr->second.empty())
1445 return nullptr;
1446
1447 if (id == -1) // select a random element
1448 {
1449 EquipmentInfoContainerInternal::const_iterator ritr = itr->second.begin();
1450 std::advance(ritr, urand(0u, itr->second.size() - 1));
1451 id = std::distance(itr->second.begin(), ritr) + 1;
1452 return &ritr->second;
1453 }
1454 else
1455 {
1456 EquipmentInfoContainerInternal::const_iterator itr2 = itr->second.find(id);
1457 if (itr2 != itr->second.end())
1458 return &itr2->second;
1459 }
1460
1461 return nullptr;
1462}
EquipmentInfoContainer _equipmentInfoStore
Definition ObjectMgr.h:1587

References _equipmentInfoStore, and urand().

Referenced by LoadCreatures().

◆ GetFishingBaseSkillLevel()

int32 ObjectMgr::GetFishingBaseSkillLevel ( uint32  entry) const
inline
1118 {
1119 FishingBaseSkillContainer::const_iterator itr = _fishingBaseForAreaStore.find(entry);
1120 return itr != _fishingBaseForAreaStore.end() ? itr->second : 0;
1121 }

References _fishingBaseForAreaStore.

◆ GetGameObjectAddon()

GameObjectAddon const * ObjectMgr::GetGameObjectAddon ( ObjectGuid::LowType  lowguid)
1407{
1408 GameObjectAddonContainer::const_iterator itr = _gameObjectAddonStore.find(lowguid);
1409 if (itr != _gameObjectAddonStore.end())
1410 return &(itr->second);
1411
1412 return nullptr;
1413}
GameObjectAddonContainer _gameObjectAddonStore
Definition ObjectMgr.h:1584

References _gameObjectAddonStore.

◆ GetGameObjectData()

GameObjectData const * ObjectMgr::GetGameObjectData ( ObjectGuid::LowType  spawnId) const
inline
1228 {
1229 GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(spawnId);
1230 if (itr == _gameObjectDataStore.end()) return nullptr;
1231 return &itr->second;
1232 }

References _gameObjectDataStore.

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

◆ GetGameObjectLocale()

GameObjectLocale const * ObjectMgr::GetGameObjectLocale ( uint32  entry) const
inline
1240 {
1241 GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
1242 if (itr == _gameObjectLocaleStore.end()) return nullptr;
1243 return &itr->second;
1244 }
GameObjectLocaleContainer _gameObjectLocaleStore
Definition ObjectMgr.h:1591

References _gameObjectLocaleStore.

◆ GetGameObjectQuestItemList()

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

References _gameObjectQuestItemStore.

◆ GetGameObjectQuestItemMap()

GameObjectQuestItemMap const * ObjectMgr::GetGameObjectQuestItemMap ( ) const
inline

◆ GetGameObjectTemplate()

GameObjectTemplate const * ObjectMgr::GetGameObjectTemplate ( uint32  entry)
10284{
10285 GameObjectTemplateContainer::const_iterator itr = _gameObjectTemplateStore.find(entry);
10286 if (itr != _gameObjectTemplateStore.end())
10287 return &(itr->second);
10288
10289 return nullptr;
10290}
GameObjectTemplateContainer _gameObjectTemplateStore
Definition ObjectMgr.h:1592

References _gameObjectTemplateStore.

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

◆ GetGameObjectTemplateAddon()

GameObjectTemplateAddon const * ObjectMgr::GetGameObjectTemplateAddon ( uint32  entry) const
10299{
10300 auto itr = _gameObjectTemplateAddonStore.find(entry);
10301 if (itr != _gameObjectTemplateAddonStore.end())
10302 return &itr->second;
10303
10304 return nullptr;
10305}
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore
Definition ObjectMgr.h:1593

References _gameObjectTemplateAddonStore.

◆ GetGameObjectTemplates()

GameObjectTemplateContainer const * ObjectMgr::GetGameObjectTemplates ( ) const
inline

◆ GetGameTele() [1/2]

GameTele const * ObjectMgr::GetGameTele ( std::string_view  name,
bool  exactSearch = false 
) const
9140{
9141 // explicit name case
9142 std::wstring wname;
9143 if (!Utf8toWStr(name, wname))
9144 return nullptr;
9145
9146 // converting string that we try to find to lower case
9147 wstrToLower(wname);
9148
9149 // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
9150 const GameTele* alt = nullptr;
9151 for (GameTeleContainer::const_iterator itr = _gameTeleStore.begin(); itr != _gameTeleStore.end(); ++itr)
9152 {
9153 if (itr->second.wnameLow == wname)
9154 return &itr->second;
9155 else if (!exactSearch && !alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
9156 alt = &itr->second;
9157 }
9158
9159 return alt;
9160}
Definition ObjectMgr.h:133

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

◆ GetGameTele() [2/2]

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

References _gameTeleStore.

◆ GetGameTeleMap()

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

References _gameTeleStore.

◆ GetGenerator()

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

◆ GetGoBackTrigger()

AreaTriggerTeleport const * ObjectMgr::GetGoBackTrigger ( uint32  Map) const
7114{
7115 bool useParentDbValue = false;
7116 uint32 parentId = 0;
7117 MapEntry const* mapEntry = sMapStore.LookupEntry(Map);
7118 if (!mapEntry || mapEntry->entrance_map < 0)
7119 return nullptr;
7120
7121 if (mapEntry->IsDungeon())
7122 {
7123 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map);
7124
7125 if (!iTemplate)
7126 return nullptr;
7127
7128 parentId = iTemplate->Parent;
7129 useParentDbValue = true;
7130 }
7131
7132 uint32 entrance_map = uint32(mapEntry->entrance_map);
7133 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
7134 if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
7135 {
7136 AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
7137 if (atEntry && atEntry->map == Map)
7138 return &itr->second;
7139 }
7140 return nullptr;
7141}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
AreaTrigger const * GetAreaTrigger(uint32 trigger) const
Definition ObjectMgr.h:862
Definition ObjectMgr.h:421
uint32 map
Definition ObjectMgr.h:423
Definition Map.h:121
uint32 Parent
Definition Map.h:122
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
988 {
989 return _goQuestInvolvedRelations.equal_range(go_entry);
990 }
QuestRelations _goQuestInvolvedRelations
Definition ObjectMgr.h:1504

References _goQuestInvolvedRelations.

◆ GetGOQuestInvolvedRelationMap()

QuestRelations * ObjectMgr::GetGOQuestInvolvedRelationMap ( )
inline
978 {
980 }

References _goQuestInvolvedRelations.

◆ GetGOQuestRelationBounds()

QuestRelationBounds ObjectMgr::GetGOQuestRelationBounds ( uint32  go_entry)
inline
983 {
984 return _goQuestRelations.equal_range(go_entry);
985 }
QuestRelations _goQuestRelations
Definition ObjectMgr.h:1503

References _goQuestRelations.

◆ GetGOQuestRelationMap()

QuestRelations * ObjectMgr::GetGOQuestRelationMap ( )
inline
973 {
974 return &_goQuestRelations;
975 }

References _goQuestRelations.

◆ GetGossipMenuItemsLocale()

GossipMenuItemsLocale const * ObjectMgr::GetGossipMenuItemsLocale ( uint32  entry) const
inline
1270 {
1271 GossipMenuItemsLocaleContainer::const_iterator itr = _gossipMenuItemsLocaleStore.find(entry);
1272 if (itr == _gossipMenuItemsLocaleStore.end()) return nullptr;
1273 return &itr->second;
1274 }
GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore
Definition ObjectMgr.h:1609

References _gossipMenuItemsLocaleStore.

◆ GetGossipMenuItemsMapBounds()

GossipMenuItemsMapBounds ObjectMgr::GetGossipMenuItemsMapBounds ( uint32  uiMenuId) const
inline
1403 {
1404 return _gossipMenuItemsStore.equal_range(uiMenuId);
1405 }
GossipMenuItemsContainer _gossipMenuItemsStore
Definition ObjectMgr.h:1498

References _gossipMenuItemsStore.

◆ GetGossipMenuItemsMapBoundsNonConst()

GossipMenuItemsMapBoundsNonConst ObjectMgr::GetGossipMenuItemsMapBoundsNonConst ( uint32  uiMenuId)
inline
1407 {
1408 return _gossipMenuItemsStore.equal_range(uiMenuId);
1409 }

References _gossipMenuItemsStore.

◆ GetGossipMenusMapBounds()

GossipMenusMapBounds ObjectMgr::GetGossipMenusMapBounds ( uint32  uiMenuId) const
inline
1393 {
1394 return _gossipMenusStore.equal_range(uiMenuId);
1395 }
GossipMenusContainer _gossipMenusStore
Definition ObjectMgr.h:1497

References _gossipMenusStore.

◆ GetGossipMenusMapBoundsNonConst()

GossipMenusMapBoundsNonConst ObjectMgr::GetGossipMenusMapBoundsNonConst ( uint32  uiMenuId)
inline
1398 {
1399 return _gossipMenusStore.equal_range(uiMenuId);
1400 }

References _gossipMenusStore.

◆ GetGossipText()

GossipText const * ObjectMgr::GetGossipText ( uint32  Text_ID) const
6161{
6162 GossipTextContainer::const_iterator itr = _gossipTextStore.find(Text_ID);
6163 if (itr != _gossipTextStore.end())
6164 return &itr->second;
6165 return nullptr;
6166}
GossipTextContainer _gossipTextStore
Definition ObjectMgr.h:1485

References _gossipTextStore.

Referenced by LoadGossipMenu().

◆ GetGridObjectGuids()

CellObjectGuids const & ObjectMgr::GetGridObjectGuids ( uint16  mapid,
uint8  spawnMode,
uint32  gridId 
)
inline
1162 {
1163 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1164 if (itr1 != _mapObjectGuidsStore.end())
1165 {
1166 CellObjectGuidsMap::const_iterator itr2 = itr1->second.find(gridId);
1167 if (itr2 != itr1->second.end())
1168 return itr2->second;
1169 }
1170 return _emptyCellObjectGuids;
1171 }
CellObjectGuids _emptyCellObjectGuids
Definition ObjectMgr.h:1575

References _emptyCellObjectGuids, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetGuidSequenceGenerator()

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

References _guidGenerators.

◆ GetInstanceTemplate()

InstanceTemplate const * ObjectMgr::GetInstanceTemplate ( uint32  mapId)
6067{
6068 InstanceTemplateContainer::const_iterator itr = _instanceTemplateStore.find(uint16(mapID));
6069 if (itr != _instanceTemplateStore.end())
6070 return &(itr->second);
6071
6072 return nullptr;
6073}
InstanceTemplateContainer _instanceTemplateStore
Definition ObjectMgr.h:1531

References _instanceTemplateStore.

◆ GetItemLocale()

ItemLocale const * ObjectMgr::GetItemLocale ( uint32  entry) const
inline
1246 {
1247 ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
1248 if (itr == _itemLocaleStore.end()) return nullptr;
1249 return &itr->second;
1250 }
ItemLocaleContainer _itemLocaleStore
Definition ObjectMgr.h:1600

References _itemLocaleStore.

◆ GetItemSetNameEntry()

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

References _itemSetNameStore.

◆ GetItemSetNameLocale()

ItemSetNameLocale const * ObjectMgr::GetItemSetNameLocale ( uint32  entry) const
inline
1252 {
1253 ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
1254 if (itr == _itemSetNameLocaleStore.end())return nullptr;
1255 return &itr->second;
1256 }
ItemSetNameLocaleContainer _itemSetNameLocaleStore
Definition ObjectMgr.h:1601

References _itemSetNameLocaleStore.

◆ GetItemTemplate()

ItemTemplate const * ObjectMgr::GetItemTemplate ( uint32  entry)
3458{
3459 return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr;
3460}
std::vector< ItemTemplate * > _itemTemplateStoreFast
Definition ObjectMgr.h:1599

References _itemTemplateStoreFast.

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

◆ GetItemTemplateStore()

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

References _itemTemplateStore.

◆ GetItemTemplateStoreFast()

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

References _itemTemplateStoreFast.

◆ GetLinkedRespawnGuid()

ObjectGuid ObjectMgr::GetLinkedRespawnGuid ( ObjectGuid  guid) const
inline
1219 {
1220 LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid);
1221 if (itr == _linkedRespawnStore.end())
1222 return ObjectGuid::Empty;
1223 return itr->second;
1224 }
static ObjectGuid const Empty
Definition ObjectGuid.h:120
LinkedRespawnContainer _linkedRespawnStore
Definition ObjectMgr.h:1588

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
1420 {
1421 if (data.size() > std::size_t(loc_idx) && !data[loc_idx].empty())
1422 value = data[loc_idx];
1423 }

◆ GetLocaleString() [2/2]

◆ GetMailLevelReward()

MailLevelReward const * ObjectMgr::GetMailLevelReward ( uint32  level,
uint32  raceMask 
)
inline
1149 {
1150 MailLevelRewardContainer::const_iterator map_itr = _mailLevelRewardStore.find(level);
1151 if (map_itr == _mailLevelRewardStore.end())
1152 return nullptr;
1153
1154 for (const auto & set_itr : map_itr->second)
1155 if (set_itr.raceMask & raceMask)
1156 return &set_itr;
1157
1158 return nullptr;
1159 }
MailLevelRewardContainer _mailLevelRewardStore
Definition ObjectMgr.h:1540

References _mailLevelRewardStore.

◆ GetMapEntranceTrigger()

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

Searches for the areatrigger which teleports players to the given map

7147{
7148 for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
7149 {
7150 if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
7151 {
7152 // xinef: no need to check, already done at loading
7153 //AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
7154 //if (atEntry)
7155 return &itr->second;
7156 }
7157 }
7158 return nullptr;
7159}

References _areaTriggerTeleportStore.

◆ GetMapObjectGuids()

CellObjectGuidsMap const & ObjectMgr::GetMapObjectGuids ( uint16  mapid,
uint8  spawnMode 
)
inline
1174 {
1175 MapObjectGuids::const_iterator itr1 = _mapObjectGuidsStore.find(MAKE_PAIR32(mapid, spawnMode));
1176 if (itr1 != _mapObjectGuidsStore.end())
1177 return itr1->second;
1179 }
CellObjectGuidsMap _emptyCellObjectGuidsMap
Definition ObjectMgr.h:1574

References _emptyCellObjectGuidsMap, _mapObjectGuidsStore, and MAKE_PAIR32().

◆ GetModelForShapeshift()

uint32 ObjectMgr::GetModelForShapeshift ( ShapeshiftForm  form,
Player player 
) const
1874{
1875 uint8 customizationID;
1876
1877 if (player->GetTeamId() == TEAM_ALLIANCE)
1878 customizationID = player->GetByteValue(PLAYER_BYTES, 3); // Use Hair Color
1879 else
1880 customizationID = player->GetByteValue(PLAYER_BYTES, 0); // Use Skin Color
1881
1882 auto itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), customizationID, player->getGender()));
1883 if (itr != _playerShapeshiftModel.end())
1884 return itr->second; // Explicit combination
1885
1886 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), customizationID, GENDER_NONE));
1887 if (itr != _playerShapeshiftModel.end())
1888 return itr->second; // Combination applied to both genders
1889
1890 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), 255, player->getGender()));
1891 if (itr != _playerShapeshiftModel.end())
1892 return itr->second; // Default gender-dependent model
1893
1894 itr = _playerShapeshiftModel.find(std::make_tuple(form, player->getRace(), 255, GENDER_NONE));
1895 if (itr != _playerShapeshiftModel.end())
1896 return itr->second; // Last resort
1897
1898 LOG_DEBUG("entities.player", "ShapeshiftForm {} with RaceID ({}) have no shapeshift model data defined, using fallback data.", form, player->getRace());
1899 return 0;
1900}
@ GENDER_NONE
Definition SharedDefines.h:63
@ TEAM_ALLIANCE
Definition SharedDefines.h:771
@ PLAYER_BYTES
Definition UpdateFields.h:181
PlayerShapeshiftModelMap _playerShapeshiftModel
Definition ObjectMgr.h:1631
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:312
TeamId GetTeamId(bool original=false) const
Definition Player.h:2097
uint8 getGender() const
Definition Unit.h:838
uint8 getRace(bool original=false) const
Definition Unit.cpp:21102

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

◆ GetModelForTotem()

uint32 ObjectMgr::GetModelForTotem ( SummonSlot  totemSlot,
Races  race 
) const
1819{
1820 auto itr = _playerTotemModel.find(std::make_pair(totemSlot, race));
1821 if (itr != _playerTotemModel.end())
1822 return itr->second;
1823
1824 LOG_ERROR("misc", "TotemSlot {} with RaceID ({}) have no totem model data defined, set to default model.", totemSlot, race);
1825 return 0;
1826}
PlayerTotemModelMap _playerTotemModel
Definition ObjectMgr.h:1629

References _playerTotemModel, and LOG_ERROR.

◆ GetModuleString() [1/2]

ModuleString const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id 
) const
inline
1305 {
1306 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
1307 ModuleStringContainer::const_iterator itr = _moduleStringStore.find(pairKey);
1308 if (itr == _moduleStringStore.end())
1309 return nullptr;
1310
1311 return &itr->second;
1312 }
ModuleStringContainer _moduleStringStore
Definition ObjectMgr.h:1607

References _moduleStringStore.

Referenced by GetModuleString().

◆ GetModuleString() [2/2]

std::string const * ObjectMgr::GetModuleString ( std::string  module,
uint32  id,
LocaleConstant  locale 
) const
8879{
8880 ModuleString const* ms = GetModuleString(module, id);
8881 if (ms && !ms->Content.empty())
8882 {
8883 if (ms->Content.size() > size_t(locale) && !ms->Content[locale].empty())
8884 return &ms->Content[locale];
8885
8886 return &ms->Content[DEFAULT_LOCALE];
8887 }
8888
8889 LOG_ERROR("sql.sql", "Module string module {} id {} not found in DB.", module, id);
8890
8891 return (std::string*)"error";
8892}
ModuleString const * GetModuleString(std::string module, uint32 id) const
Definition ObjectMgr.h:1304
Definition ObjectMgr.h:497
std::vector< std::string > Content
Definition ObjectMgr.h:498

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

◆ GetNearestTaxiNode()

uint32 ObjectMgr::GetNearestTaxiNode ( float  x,
float  y,
float  z,
uint32  mapid,
uint32  teamId 
)
6731{
6732 bool found = false;
6733 float dist = 10000;
6734 uint32 id = 0;
6735
6736 for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
6737 {
6738 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
6739
6740 if (!node || node->map_id != mapid || (!node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981)) // dk flight
6741 continue;
6742
6743 uint8 field = (uint8)((i - 1) / 32);
6744 uint32 submask = 1 << ((i - 1) % 32);
6745
6746 // skip not taxi network nodes
6747 if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
6748 {
6749 continue;
6750 }
6751
6752 float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
6753 if (found)
6754 {
6755 if (dist2 < dist)
6756 {
6757 dist = dist2;
6758 id = i;
6759 }
6760 }
6761 else
6762 {
6763 found = true;
6764 dist = dist2;
6765 id = i;
6766 }
6767 }
6768
6769 return id;
6770}
TaxiMask sTaxiNodesMask
Definition DBCStores.cpp:176
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
static constexpr std::size_t TaxiMaskSize
Definition DBCStructure.h:2246
Definition DBCStructure.h:1951
float z
Definition DBCStructure.h:1956
uint32 map_id
Definition DBCStructure.h:1953
float x
Definition DBCStructure.h:1954
float y
Definition DBCStructure.h:1955
uint32 MountCreatureID[2]
Definition DBCStructure.h:1959

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
1294 {
1295 NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
1296 if (itr == _npcTextLocaleStore.end()) return nullptr;
1297 return &itr->second;
1298 }
NpcTextLocaleContainer _npcTextLocaleStore
Definition ObjectMgr.h:1605

References _npcTextLocaleStore.

◆ GetNpcVendorItemList()

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

References _cacheVendorItemStore.

Referenced by IsVendorItemValid().

◆ GetPageText()

PageText const * ObjectMgr::GetPageText ( uint32  pageEntry)
5983{
5984 PageTextContainer::const_iterator itr = _pageTextStore.find(pageEntry);
5985 if (itr != _pageTextStore.end())
5986 return &(itr->second);
5987
5988 return nullptr;
5989}
PageTextContainer _pageTextStore
Definition ObjectMgr.h:1530

References _pageTextStore.

Referenced by LoadGameObjectTemplate(), and LoadItemTemplates().

◆ GetPageTextLocale()

PageTextLocale const * ObjectMgr::GetPageTextLocale ( uint32  entry) const
inline
1258 {
1259 PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
1260 if (itr == _pageTextLocaleStore.end()) return nullptr;
1261 return &itr->second;
1262 }
PageTextLocaleContainer _pageTextLocaleStore
Definition ObjectMgr.h:1606

References _pageTextLocaleStore.

◆ GetPetLevelInfo()

PetLevelInfo const * ObjectMgr::GetPetLevelInfo ( uint32  creature_id,
uint8  level 
) const
3824{
3825 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3826 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
3827
3828 PetLevelInfoContainer::const_iterator itr = _petInfoStore.find(creature_id);
3829 if (itr == _petInfoStore.end())
3830 return nullptr;
3831
3832 return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ...
3833}

References _petInfoStore, CONFIG_MAX_PLAYER_LEVEL, and sWorld.

◆ GetPlayerClassInfo()

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

References _playerClassInfo, and MAX_CLASSES.

◆ GetPlayerClassLevelInfo()

void ObjectMgr::GetPlayerClassLevelInfo ( uint32  class_,
uint8  level,
PlayerClassLevelInfo info 
) const
4491{
4492 if (level < 1 || class_ >= MAX_CLASSES)
4493 return;
4494
4495 PlayerClassInfo const* pInfo = _playerClassInfo[class_];
4496
4497 if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4498 level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
4499
4500 *info = pInfo->levelInfo[level - 1];
4501}
Definition Player.h:284

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

◆ GetPlayerInfo()

PlayerInfo const * ObjectMgr::GetPlayerInfo ( uint32  race,
uint32  class_ 
) const
10330{
10331 if (race >= MAX_RACES)
10332 return nullptr;
10333 if (class_ >= MAX_CLASSES)
10334 return nullptr;
10335 PlayerInfo const* info = _playerInfo[race][class_];
10336 if (!info)
10337 return nullptr;
10338 return info;
10339}
Definition Player.h:323

References _playerInfo, MAX_CLASSES, and MAX_RACES.

◆ GetPlayerLevelInfo()

void ObjectMgr::GetPlayerLevelInfo ( uint32  race,
uint32  class_,
uint8  level,
PlayerLevelInfo info 
) const
4504{
4505 if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
4506 return;
4507
4508 PlayerInfo const* pInfo = _playerInfo[race][class_];
4509 if (!pInfo)
4510 return;
4511
4512 if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4513 *info = pInfo->levelInfo[level - 1];
4514 else
4515 BuildPlayerLevelInfo(race, class_, level, info);
4516}
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo *plinfo) const
Definition ObjectMgr.cpp:4518

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

◆ GetPointOfInterest()

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

References _pointsOfInterestStore.

Referenced by LoadGossipMenuItems().

◆ GetPointOfInterestLocale()

PointOfInterestLocale const * ObjectMgr::GetPointOfInterestLocale ( uint32  poi_id) const
inline
1276 {
1277 PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id);
1278 if (itr == _pointOfInterestLocaleStore.end()) return nullptr;
1279 return &itr->second;
1280 }
PointOfInterestLocaleContainer _pointOfInterestLocaleStore
Definition ObjectMgr.h:1610

References _pointOfInterestLocaleStore.

◆ GetQuestForAreaTrigger()

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

References _questAreaTriggerStore.

◆ GetQuestGreeting()

QuestGreeting const * ObjectMgr::GetQuestGreeting ( TypeID  type,
uint32  id 
) const
6461{
6462 uint8 typeIndex;
6463 if (type == TYPEID_UNIT)
6464 typeIndex = 0;
6465 else if (type == TYPEID_GAMEOBJECT)
6466 typeIndex = 1;
6467 else
6468 return nullptr;
6469
6470 std::pair<uint32, uint8> pairKey = std::make_pair(id, typeIndex);
6471 QuestGreetingContainer::const_iterator itr = _questGreetingStore.find(pairKey);
6472 if (itr == _questGreetingStore.end())
6473 return nullptr;
6474
6475 return &itr->second;
6476}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
QuestGreetingContainer _questGreetingStore
Definition ObjectMgr.h:1486

References _questGreetingStore, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

◆ GetQuestLocale()

QuestLocale const * ObjectMgr::GetQuestLocale ( uint32  entry) const
inline
1264 {
1265 QuestLocaleContainer::const_iterator itr = _questLocaleStore.find(entry);
1266 if (itr == _questLocaleStore.end()) return nullptr;
1267 return &itr->second;
1268 }
QuestLocaleContainer _questLocaleStore
Definition ObjectMgr.h:1602

References _questLocaleStore.

◆ GetQuestMoneyReward()

uint32 ObjectMgr::GetQuestMoneyReward ( uint8  level,
uint32  questMoneyDifficulty 
) const
10466{
10467 if (questMoneyDifficulty < MAX_QUEST_MONEY_REWARDS)
10468 {
10469 auto const& itr = _questMoneyRewards.find(level);
10470 if (itr != _questMoneyRewards.end())
10471 {
10472 return itr->second.at(questMoneyDifficulty);
10473 }
10474 }
10475
10476 return 0;
10477}
static constexpr uint32 MAX_QUEST_MONEY_REWARDS
Definition ObjectMgr.h:718
QuestMoneyRewardStore _questMoneyRewards
Definition ObjectMgr.h:1633

References _questMoneyRewards, and MAX_QUEST_MONEY_REWARDS.

◆ GetQuestOfferRewardLocale()

QuestOfferRewardLocale const * ObjectMgr::GetQuestOfferRewardLocale ( uint32  entry) const
inline
1282 {
1283 auto itr = _questOfferRewardLocaleStore.find(entry);
1284 if (itr == _questOfferRewardLocaleStore.end()) return nullptr;
1285 return &itr->second;
1286 }
QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore
Definition ObjectMgr.h:1603

References _questOfferRewardLocaleStore.

◆ GetQuestPOIVector()

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

References _questPOIStore.

◆ GetQuestRequestItemsLocale()

QuestRequestItemsLocale const * ObjectMgr::GetQuestRequestItemsLocale ( uint32  entry) const
inline
1288 {
1289 auto itr = _questRequestItemsLocaleStore.find(entry);
1290 if (itr == _questRequestItemsLocaleStore.end()) return nullptr;
1291 return &itr->second;
1292 }
QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore
Definition ObjectMgr.h:1604

References _questRequestItemsLocaleStore.

◆ GetQuestTemplate()

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

References _questTemplatesFast.

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

◆ GetQuestTemplates()

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

References _questTemplates.

◆ GetRepRewardRate()

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

References _repRewardRateStore.

◆ GetRepSpilloverTemplate()

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

References _repSpilloverTemplateStore.

◆ GetReputationOnKilEntry()

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

References _repOnKillStore.

◆ GetScriptId()

uint32 ObjectMgr::GetScriptId ( std::string const &  name)
9820{
9821 // use binary search to find the script name in the sorted vector
9822 // assume "" is the first element
9823 if (name.empty())
9824 return 0;
9825
9826 ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
9827 if (itr == _scriptNamesStore.end() || (*itr != name))
9828 return 0;
9829
9830 return uint32(itr - _scriptNamesStore.begin());
9831}
ScriptNameContainer _scriptNamesStore
Definition ObjectMgr.h:1518

References _scriptNamesStore.

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

◆ GetScriptName()

std::string const & ObjectMgr::GetScriptName ( uint32  id) const
9814{
9815 static std::string const empty = "";
9816 return (id < _scriptNamesStore.size()) ? _scriptNamesStore[id] : empty;
9817}

References _scriptNamesStore.

Referenced by ValidateSpellScripts().

◆ GetScriptNames()

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

References _scriptNamesStore.

◆ GetSparringData()

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

References _creatureSparringStore.

◆ GetSpellClickInfoMapBounds()

SpellClickInfoMapBounds ObjectMgr::GetSpellClickInfoMapBounds ( uint32  creature_id) const
inline
1388 {
1389 return _spellClickInfoStore.equal_range(creature_id);
1390 }
SpellClickInfoContainer _spellClickInfoStore
Definition ObjectMgr.h:1520

References _spellClickInfoStore.

◆ GetSpellScriptsBounds()

SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds ( uint32  spell_id)
9029{
9030 return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id));
9031}
std::pair< SpellScriptsContainer::iterator, SpellScriptsContainer::iterator > SpellScriptsBounds
Definition ObjectMgr.h:389
SpellScriptsContainer _spellScriptsStore
Definition ObjectMgr.h:1522

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
1191 {
1192 TempSummonDataContainer::const_iterator itr = _tempSummonDataStore.find(TempSummonGroupKey(summonerId, summonerType, group));
1193 if (itr != _tempSummonDataStore.end())
1194 return &itr->second;
1195
1196 return nullptr;
1197 }
TempSummonDataContainer _tempSummonDataStore
Stores temp summon data grouped by summoner's entry, summoner's type and group id.
Definition ObjectMgr.h:1595
Key for storing temp summon data in TempSummonDataContainer.
Definition ObjectMgr.h:65

References _tempSummonDataStore.

◆ GetTaxiMountDisplayId()

uint32 ObjectMgr::GetTaxiMountDisplayId ( uint32  id,
TeamId  teamId,
bool  allowed_alt_team = false 
)
6797{
6798 CreatureModel mountModel;
6799 CreatureTemplate const* mount_info = nullptr;
6800
6801 // select mount creature id
6802 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
6803 if (node)
6804 {
6805 uint32 mount_entry = node->MountCreatureID[teamId == TEAM_ALLIANCE ? 1 : 0];
6806
6807 // Fix for Alliance not being able to use Acherus taxi
6808 // only one mount type for both sides
6809 if (mount_entry == 0 && allowed_alt_team)
6810 {
6811 // Simply reverse the selection. At least one team in theory should have a valid mount ID to choose.
6812 mount_entry = node->MountCreatureID[teamId];
6813 }
6814
6815 mount_info = GetCreatureTemplate(mount_entry);
6816 if (mount_info)
6817 {
6818 CreatureModel const* model = mount_info->GetRandomValidModel();
6819 if (!model)
6820 {
6821 LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry {}! Can't load it!", mount_entry);
6822 return 0;
6823 }
6824 mountModel = *model;
6825 }
6826 }
6827
6828 // minfo is not actually used but the mount_id was updated
6829 GetCreatureModelRandomGender(&mountModel, mount_info);
6830
6831 return mountModel.CreatureDisplayID;
6832}
CreatureModelInfo const * GetCreatureModelRandomGender(CreatureModel *model, CreatureTemplate const *creatureTemplate) const
Definition ObjectMgr.cpp:1662
CreatureModel const * GetRandomValidModel() const
Definition Creature.cpp:119

References CreatureModel::CreatureDisplayID, GetCreatureModelRandomGender(), GetCreatureTemplate(), CreatureTemplate::GetRandomValidModel(), LOG_ERROR, TaxiNodesEntry::MountCreatureID, sTaxiNodesStore, and TEAM_ALLIANCE.

◆ GetTaxiPath()

void ObjectMgr::GetTaxiPath ( uint32  source,
uint32  destination,
uint32 path,
uint32 cost 
)
6773{
6774 TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
6775 if (src_i == sTaxiPathSetBySource.end())
6776 {
6777 path = 0;
6778 cost = 0;
6779 return;
6780 }
6781
6782 TaxiPathSetForSource& pathSet = src_i->second;
6783
6784 TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
6785 if (dest_i == pathSet.end())
6786 {
6787 path = 0;
6788 cost = 0;
6789 return;
6790 }
6791
6792 cost = dest_i->second->price;
6793 path = dest_i->second->ID;
6794}
TaxiPathSetBySource sTaxiPathSetBySource
Definition DBCStores.cpp:183
std::map< uint32, TaxiPathEntry const * > TaxiPathSetForSource
Definition DBCStructure.h:2240

References TaxiNodesEntry::ID, and sTaxiPathSetBySource.

◆ GetTrainer()

Trainer::Trainer * ObjectMgr::GetTrainer ( uint32  creatureId)
9429{
9430 auto itr = _creatureDefaultTrainers.find(creatureId);
9431 if (itr != _creatureDefaultTrainers.end())
9432 return Acore::Containers::MapGetValuePtr(_trainers, itr->second);
9433
9434 return nullptr;
9435}
std::unordered_map< uint32, uint32 > _creatureDefaultTrainers
Definition ObjectMgr.h:1614
std::unordered_map< uint32, Trainer::Trainer > _trainers
Definition ObjectMgr.h:1613

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

◆ GetVehicleAccessoryList()

VehicleAccessoryList const * ObjectMgr::GetVehicleAccessoryList ( Vehicle veh) const
10313{
10314 if (Creature* cre = veh->GetBase()->ToCreature())
10315 {
10316 // Give preference to GUID-based accessories
10317 VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
10318 if (itr != _vehicleAccessoryStore.end())
10319 return &itr->second;
10320 }
10321
10322 // Otherwise return entry-based
10323 VehicleAccessoryContainer::const_iterator itr = _vehicleTemplateAccessoryStore.find(veh->GetCreatureEntry());
10324 if (itr != _vehicleTemplateAccessoryStore.end())
10325 return &itr->second;
10326 return nullptr;
10327}
VehicleAccessoryContainer _vehicleAccessoryStore
Definition ObjectMgr.h:1525
VehicleAccessoryContainer _vehicleTemplateAccessoryStore
Definition ObjectMgr.h:1524
Creature * ToCreature()
Definition Object.h:205
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
uint32 GetCreatureEntry() const
Definition Vehicle.h:39

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

◆ GetVehicleSeatAddon()

VehicleSeatAddon const * ObjectMgr::GetVehicleSeatAddon ( uint32  seatId) const
inline
1442 {
1443 VehicleSeatAddonContainer::const_iterator itr = _vehicleSeatAddonStore.find(seatId);
1444 if (itr == _vehicleSeatAddonStore.end())
1445 return nullptr;
1446
1447 return &itr->second;
1448 }
VehicleSeatAddonContainer _vehicleSeatAddonStore
Definition ObjectMgr.h:1526

References _vehicleSeatAddonStore.

◆ GetXPForLevel()

uint32 ObjectMgr::GetXPForLevel ( uint8  level) const
7655{
7656 if (level < _playerXPperLevel.size())
7657 return _playerXPperLevel[level];
7658 return 0;
7659}
PlayerXPperLevel _playerXPperLevel
Definition ObjectMgr.h:1555

References _playerXPperLevel.

◆ InitializeSpellInfoPrecomputedData()

void ObjectMgr::InitializeSpellInfoPrecomputedData ( )
5930{
5931 uint32 limit = sSpellStore.GetNumRows();
5932 for(uint32 i = 0; i <= limit; ++i)
5933 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i))
5934 {
5935 const_cast<SpellInfo*>(spellInfo)->SetStackableWithRanks(spellInfo->ComputeIsStackableWithRanks());
5936 const_cast<SpellInfo*>(spellInfo)->SetCritCapable(spellInfo->ComputeIsCritCapable());
5937 const_cast<SpellInfo*>(spellInfo)->SetSpellValid(SpellMgr::ComputeIsSpellValid(spellInfo, false));
5938 }
5939}
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
Definition SpellInfo.h:316
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:367

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

◆ instance()

ObjectMgr * ObjectMgr::instance ( )
static
375{
376 static ObjectMgr instance;
377 return &instance;
378}
Definition ObjectMgr.h:725
static ObjectMgr * instance()
Definition ObjectMgr.cpp:374

References instance().

Referenced by instance().

◆ IsGameObjectStaticTransport()

bool ObjectMgr::IsGameObjectStaticTransport ( uint32  entry)
10293{
10294 GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
10295 return goinfo && goinfo->type == GAMEOBJECT_TYPE_TRANSPORT;
10296}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1582

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

Referenced by AddGOData().

◆ IsProfanityName()

bool ObjectMgr::IsProfanityName ( std::string_view  name) const
8515{
8516 // pussywizard
8517 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8518 return true;
8519
8520 std::wstring wstr;
8521 if (!Utf8toWStr (name, wstr))
8522 return false;
8523
8524 wstrToLower(wstr);
8525
8526 return _profanityNamesStore.find(wstr) != _profanityNamesStore.end();
8527}

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

Referenced by AddProfanityPlayerName().

◆ IsReservedName()

bool ObjectMgr::IsReservedName ( std::string_view  name) const
8412{
8413 // pussywizard
8414 if (name.size() >= 2 && (name[name.size() - 2] == 'G' || name[name.size() - 2] == 'g') && (name[name.size() - 1] == 'M' || name[name.size() - 1] == 'm'))
8415 return true;
8416
8417 std::wstring wstr;
8418 if (!Utf8toWStr (name, wstr))
8419 return false;
8420
8421 wstrToLower(wstr);
8422
8423 return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
8424}

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

Referenced by AddReservedPlayerName().

◆ IsTavernAreaTrigger()

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

References _tavernAreaTriggerStore.

◆ IsTransportMap()

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

References _transportMaps.

◆ IsValidChannelName()

bool ObjectMgr::IsValidChannelName ( std::string const &  name)
static
8688{
8689 std::wstring wname;
8690 if (!Utf8toWStr(name, wname))
8691 return false;
8692
8693 if (wname.size() > MAX_CHANNEL_NAME)
8694 return false;
8695
8696 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHANNEL_NAMES);
8697
8698 return isValidString(wname, strictMask, true);
8699}
#define MAX_CHANNEL_NAME
Definition ObjectMgr.h:686
@ CONFIG_STRICT_CHANNEL_NAMES
Definition WorldConfig.h:176

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

◆ IsValidCharterName()

bool ObjectMgr::IsValidCharterName ( std::string_view  name)
static
8662{
8663 std::wstring wname;
8664 if (!Utf8toWStr(name, wname))
8665 return false;
8666
8667 if (wname.size() > MAX_CHARTER_NAME)
8668 return false;
8669
8670 uint32 minName = sWorld->getIntConfig(CONFIG_MIN_CHARTER_NAME);
8671 if (wname.size() < minName)
8672 return false;
8673
8674 // Check Reserved Name
8675 if (sObjectMgr->IsReservedName(name))
8676 return false;
8677
8678 // Check Profanity Name
8679 if (sObjectMgr->IsProfanityName(name))
8680 return false;
8681
8682 uint32 strictMask = sWorld->getIntConfig(CONFIG_STRICT_CHARTER_NAMES);
8683
8684 return isValidString(wname, strictMask, true);
8685}
#define MAX_CHARTER_NAME
Definition ObjectMgr.h:685
@ CONFIG_MIN_CHARTER_NAME
Definition WorldConfig.h:179
@ CONFIG_STRICT_CHARTER_NAMES
Definition WorldConfig.h:175

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

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

◆ IsVendorItemValid()

bool ObjectMgr::IsVendorItemValid ( uint32  vendor_entry,
uint32  item,
int32  maxcount,
uint32  ptime,
uint32  ExtendedCost,
Player player = nullptr,
std::set< uint32 > *  skip_vendors = nullptr,
uint32  ORnpcflag = 0 
) const
9678{
9679 /*
9680 CreatureTemplate const* cInfo = GetCreatureTemplate(vendor_entry);
9681 if (!cInfo)
9682 {
9683 if (player)
9684 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9685 else
9686 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: {}), ignore", vendor_entry);
9687 return false;
9688 }
9689
9690 if (!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
9691 {
9692 if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
9693 {
9694 if (player)
9695 ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
9696 else
9697 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: {}) without vendor flag, ignore", vendor_entry);
9698
9699 if (skip_vendors)
9700 skip_vendors->insert(vendor_entry);
9701 }
9702 return false;
9703 }
9704 */
9705
9706 if (!sObjectMgr->GetItemTemplate(item_id))
9707 {
9708 if (player)
9710 else
9711 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` for Vendor (Entry: {}) have in item list non-existed item ({}), ignore", vendor_entry, item_id);
9712 return false;
9713 }
9714
9715 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
9716 {
9717 if (player)
9719 else
9720 LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: {}) with wrong ExtendedCost ({}) for vendor ({}), ignore", item_id, ExtendedCost, vendor_entry);
9721 return false;
9722 }
9723
9724 if (maxcount > 0 && incrtime == 0)
9725 {
9726 if (player)
9727 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 ({}) but IncrTime == 0", maxcount);
9728 else
9729 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);
9730 return false;
9731 }
9732 else if (maxcount == 0 && incrtime > 0)
9733 {
9734 if (player)
9735 ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
9736 else
9737 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);
9738 return false;
9739 }
9740
9741 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
9742 if (!vItems)
9743 return true; // later checks for non-empty lists
9744
9745 if (vItems->FindItemCostPair(item_id, ExtendedCost))
9746 {
9747 if (player)
9748 ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
9749 else
9750 LOG_ERROR("sql.sql", "Table `npc_vendor` has duplicate items {} (with extended cost {}) for vendor (Entry: {}), ignoring", item_id, ExtendedCost, vendor_entry);
9751 return false;
9752 }
9753
9754 return true;
9755}
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
@ LANG_ITEM_ALREADY_IN_LIST
Definition Language.h:253
@ LANG_ITEM_NOT_FOUND
Definition Language.h:250
@ LANG_EXTENDED_COST_NOT_EXIST
Definition Language.h:378
Definition Chat.h:37
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
VendorItemData const * GetNpcVendorItemList(uint32 entry) const
Definition ObjectMgr.h:1369
WorldSession * GetSession() const
Definition Player.h:1989
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost) const
Definition Creature.cpp:103

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 ( )
6946{
6947 uint32 oldMSTime = getMSTime();
6948
6949 if (!_accessRequirementStore.empty())
6950 {
6951 for (DungeonProgressionRequirementsContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
6952 {
6953 std::unordered_map<uint8, DungeonProgressionRequirements*> difficulties = itr->second;
6954 for (auto difficultiesItr = difficulties.begin(); difficultiesItr != difficulties.end(); ++difficultiesItr)
6955 {
6956 for (auto questItr = difficultiesItr->second->quests.begin(); questItr != difficultiesItr->second->quests.end(); ++questItr)
6957 {
6958 delete* questItr;
6959 }
6960
6961 for (auto achievementItr = difficultiesItr->second->achievements.begin(); achievementItr != difficultiesItr->second->achievements.end(); ++achievementItr)
6962 {
6963 delete* achievementItr;
6964 }
6965
6966 for (auto itemsItr = difficultiesItr->second->items.begin(); itemsItr != difficultiesItr->second->items.end(); ++itemsItr)
6967 {
6968 delete* itemsItr;
6969 }
6970
6971 delete difficultiesItr->second;
6972 }
6973 }
6974
6975 _accessRequirementStore.clear(); // need for reload case
6976 }
6977 // 0 1 2 3 4 5
6978 QueryResult access_template_result = WorldDatabase.Query("SELECT id, map_id, difficulty, min_level, max_level, min_avg_item_level FROM dungeon_access_template");
6979 if (!access_template_result)
6980 {
6981 LOG_WARN("server.loading", ">> Loaded 0 access requirement definitions. DB table `dungeon_access_template` is empty.");
6982 LOG_INFO("server.loading", " ");
6983 return;
6984 }
6985
6986 uint32 count = 0;
6987 uint32 countProgressionRequirements = 0;
6988
6989 do
6990 {
6991 Field* fields = access_template_result->Fetch();
6992
6993 //Get the common variables for the access requirements
6994 uint8 dungeon_access_id = fields[0].Get<uint8>();
6995 uint32 mapid = fields[1].Get<uint32>();
6996 uint8 difficulty = fields[2].Get<uint8>();
6997
6998 //Set up the access requirements
7000 ar->levelMin = fields[3].Get<uint8>();
7001 ar->levelMax = fields[4].Get<uint8>();
7002 ar->reqItemLevel = fields[5].Get<uint16>();
7003
7004 // 0 1 2 3 4 6
7005 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);
7006 if (progression_requirements_results)
7007 {
7008 do
7009 {
7010 Field* progression_requirement_row = progression_requirements_results->Fetch();
7011
7012 const uint8 requirement_type = progression_requirement_row[0].Get<uint8>();
7013 const uint32 requirement_id = progression_requirement_row[1].Get<uint32>();
7014 const std::string requirement_note = progression_requirement_row[2].Get<std::string>();
7015 const uint8 requirement_faction = progression_requirement_row[3].Get<uint8>();
7016 const uint8 requirement_priority = progression_requirement_row[4].IsNull() ? UINT8_MAX : progression_requirement_row[4].Get<uint8>();
7017 const bool requirement_checkLeaderOnly = progression_requirement_row[5].Get<bool>();
7018
7019 ProgressionRequirement* progression_requirement = new ProgressionRequirement();
7020 progression_requirement->id = requirement_id;
7021 progression_requirement->note = requirement_note;
7022 progression_requirement->faction = (TeamId)requirement_faction;
7023 progression_requirement->priority = requirement_priority;
7024 progression_requirement->checkLeaderOnly = requirement_checkLeaderOnly;
7025
7026 std::vector<ProgressionRequirement*>* currentRequirementsList = nullptr;
7027
7028 switch (requirement_type)
7029 {
7030 case 0:
7031 {
7032 //Achievement
7033 if (!sAchievementStore.LookupEntry(progression_requirement->id))
7034 {
7035 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);
7036 break;
7037 }
7038
7039 currentRequirementsList = &ar->achievements;
7040 break;
7041 }
7042 case 1:
7043 {
7044 //Quest
7045 if (!GetQuestTemplate(progression_requirement->id))
7046 {
7047 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);
7048 break;
7049 }
7050
7051 currentRequirementsList = &ar->quests;
7052 break;
7053 }
7054 case 2:
7055 {
7056 //Item
7057 ItemTemplate const* pProto = GetItemTemplate(progression_requirement->id);
7058 if (!pProto)
7059 {
7060 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);
7061 break;
7062 }
7063
7064 currentRequirementsList = &ar->items;
7065 break;
7066 }
7067 default:
7068 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);
7069 break;
7070 }
7071
7072 //Check if array is valid and delete the progression requirement
7073 if (!currentRequirementsList)
7074 {
7075 delete progression_requirement;
7076 continue;
7077 }
7078
7079 //Insert into the array
7080 if (currentRequirementsList->size() > requirement_priority)
7081 {
7082 currentRequirementsList->insert(currentRequirementsList->begin() + requirement_priority, progression_requirement);
7083 }
7084 else
7085 {
7086 currentRequirementsList->push_back(progression_requirement);
7087 }
7088
7089 } while (progression_requirements_results->NextRow());
7090 }
7091
7092 //Sort all arrays for priority
7093 auto sortFunction = [](const ProgressionRequirement* const a, const ProgressionRequirement* const b) {return a->priority > b->priority; };
7094 std::sort(ar->achievements.begin(), ar->achievements.end(), sortFunction);
7095 std::sort(ar->quests.begin(), ar->quests.end(), sortFunction);
7096 std::sort(ar->items.begin(), ar->items.end(), sortFunction);
7097
7098 countProgressionRequirements += ar->achievements.size();
7099 countProgressionRequirements += ar->quests.size();
7100 countProgressionRequirements += ar->items.size();
7101 count++;
7102
7103 _accessRequirementStore[mapid][difficulty] = ar;
7104 } while (access_template_result->NextRow());
7105
7106 LOG_INFO("server.loading", ">> Loaded {} Rows From dungeon_access_template And {} Rows From dungeon_access_requirements in {} ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
7107 LOG_INFO("server.loading", " ");
7108}
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
#define LOG_WARN(filterType__,...)
Definition Log.h:162
TeamId
Definition SharedDefines.h:770
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
Class used to access individual fields of database query result.
Definition Field.h:98
bool IsNull() const
Definition Field.h:106
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
ItemTemplate const * GetItemTemplate(uint32 entry)
Definition ObjectMgr.cpp:3457
Quest const * GetQuestTemplate(uint32 quest_id) const
Definition ObjectMgr.h:834
Definition Player.h:929
Definition ItemTemplate.h:619
Definition Player.h:920
uint32 priority
Definition Player.h:924

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 ( )
8895{
8896 uint32 oldMSTime = getMSTime();
8897
8898 _acoreStringStore.clear(); // for reload case
8899 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");
8900 if (!result)
8901 {
8902 LOG_WARN("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty.");
8903 LOG_INFO("server.loading", " ");
8904 return false;
8905 }
8906
8907 do
8908 {
8909 Field* fields = result->Fetch();
8910
8911 uint32 entry = fields[0].Get<uint32>();
8912
8913 AcoreString& data = _acoreStringStore[entry];
8914
8915 data.Content.resize(DEFAULT_LOCALE + 1);
8916
8917 for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
8918 AddLocaleString(fields[i + 1].Get<std::string>(), LocaleConstant(i), data.Content);
8919 } while (result->NextRow());
8920
8921 LOG_INFO("server.loading", ">> Loaded {} Acore Strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8922 LOG_INFO("server.loading", " ");
8923
8924 return true;
8925}
LocaleConstant
Definition Common.h:117
@ TOTAL_LOCALES
Definition Common.h:128
static void AddLocaleString(std::string &&s, LocaleConstant locale, std::vector< std::string > &data)
Definition ObjectMgr.cpp:380

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

◆ LoadAreaTriggers()

void ObjectMgr::LoadAreaTriggers ( )
6835{
6836 uint32 oldMSTime = getMSTime();
6837
6838 _areaTriggerStore.clear();
6839
6840 QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
6841
6842 if (!result)
6843 {
6844 LOG_WARN("server.loading", ">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
6845 LOG_INFO("server.loading", " ");
6846 return;
6847 }
6848
6849 uint32 count = 0;
6850
6851 do
6852 {
6853 Field* fields = result->Fetch();
6854
6855 ++count;
6856
6857 AreaTrigger at;
6858
6859 at.entry = fields[0].Get<uint32>();
6860 at.map = fields[1].Get<uint32>();
6861 at.x = fields[2].Get<float>();
6862 at.y = fields[3].Get<float>();
6863 at.z = fields[4].Get<float>();
6864 at.radius = fields[5].Get<float>();
6865 at.length = fields[6].Get<float>();
6866 at.width = fields[7].Get<float>();
6867 at.height = fields[8].Get<float>();
6868 at.orientation = fields[9].Get<float>();
6869
6870 MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
6871 if (!mapEntry)
6872 {
6873 LOG_ERROR("sql.sql", "Area trigger (ID:{}) map (ID: {}) does not exist in `Map.dbc`.", at.entry, at.map);
6874 continue;
6875 }
6876
6877 _areaTriggerStore[at.entry] = at;
6878 } while (result->NextRow());
6879
6880 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6881 LOG_INFO("server.loading", " ");
6882}
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 ( )
6693{
6694 uint32 oldMSTime = getMSTime();
6695
6696 _areaTriggerScriptStore.clear(); // need for reload case
6697 QueryResult result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
6698
6699 if (!result)
6700 {
6701 LOG_WARN("server.loading", ">> Loaded 0 Areatrigger Scripts. DB Table `areatrigger_scripts` Is Empty.");
6702 LOG_INFO("server.loading", " ");
6703 return;
6704 }
6705
6706 uint32 count = 0;
6707
6708 do
6709 {
6710 ++count;
6711
6712 Field* fields = result->Fetch();
6713
6714 uint32 Trigger_ID = fields[0].Get<uint32>();
6715 std::string scriptName = fields[1].Get<std::string>();
6716
6717 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6718 if (!atEntry)
6719 {
6720 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6721 continue;
6722 }
6723 _areaTriggerScriptStore[Trigger_ID] = GetScriptId(scriptName);
6724 } while (result->NextRow());
6725
6726 LOG_INFO("server.loading", ">> Loaded {} Areatrigger Scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6727 LOG_INFO("server.loading", " ");
6728}
uint32 GetScriptId(std::string const &name)
Definition ObjectMgr.cpp:9819

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

◆ LoadAreaTriggerTeleports()

void ObjectMgr::LoadAreaTriggerTeleports ( )
6885{
6886 uint32 oldMSTime = getMSTime();
6887
6888 _areaTriggerTeleportStore.clear(); // need for reload case
6889
6890 // 0 1 2 3 4 5
6891 QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
6892
6893 if (!result)
6894 {
6895 LOG_WARN("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty.");
6896 LOG_INFO("server.loading", " ");
6897 return;
6898 }
6899
6900 uint32 count = 0;
6901
6902 do
6903 {
6904 Field* fields = result->Fetch();
6905
6906 ++count;
6907
6908 uint32 Trigger_ID = fields[0].Get<uint32>();
6909
6911
6912 at.target_mapId = fields[1].Get<uint16>();
6913 at.target_X = fields[2].Get<float>();
6914 at.target_Y = fields[3].Get<float>();
6915 at.target_Z = fields[4].Get<float>();
6916 at.target_Orientation = fields[5].Get<float>();
6917
6918 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6919 if (!atEntry)
6920 {
6921 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6922 continue;
6923 }
6924
6925 MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
6926 if (!mapEntry)
6927 {
6928 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target map (ID: {}) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId);
6929 continue;
6930 }
6931
6932 if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0)
6933 {
6934 LOG_ERROR("sql.sql", "Area trigger (ID:{}) target coordinates not provided.", Trigger_ID);
6935 continue;
6936 }
6937
6938 _areaTriggerTeleportStore[Trigger_ID] = at;
6939 } while (result->NextRow());
6940
6941 LOG_INFO("server.loading", ">> Loaded {} Area Trigger Teleport Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6942 LOG_INFO("server.loading", " ");
6943}
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 ( )
9919{
9920 uint32 oldMSTime = getMSTime();
9921
9922 // 0 1 2 3
9923 QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
9924
9925 if (!result)
9926 {
9927 LOG_WARN("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
9928 LOG_INFO("server.loading", " ");
9929 return;
9930 }
9931
9932 uint32 locales_count = 0;
9933 do
9934 {
9935 Field* fields = result->Fetch();
9936
9937 uint32 id = fields[0].Get<uint32>();
9938
9939 BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
9940 if (bct == _broadcastTextStore.end())
9941 {
9942 LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id);
9943 continue;
9944 }
9945
9946 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
9947 if (locale == LOCALE_enUS)
9948 continue;
9949
9950 AddLocaleString(fields[2].Get<std::string>(), locale, bct->second.MaleText);
9951 AddLocaleString(fields[3].Get<std::string>(), locale, bct->second.FemaleText);
9952 locales_count++;
9953 } while (result->NextRow());
9954
9955 LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", locales_count, GetMSTimeDiffToNow(oldMSTime));
9956 LOG_INFO("server.loading", " ");
9957}
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:42

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

◆ LoadBroadcastTexts()

void ObjectMgr::LoadBroadcastTexts ( )
9834{
9835 uint32 oldMSTime = getMSTime();
9836
9837 _broadcastTextStore.clear(); // for reload case
9838
9839 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9840 QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
9841 if (!result)
9842 {
9843 LOG_WARN("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
9844 LOG_INFO("server.loading", " ");
9845 return;
9846 }
9847
9848 _broadcastTextStore.rehash(result->GetRowCount());
9849
9850 do
9851 {
9852 Field* fields = result->Fetch();
9853
9854 BroadcastText bct;
9855
9856 bct.Id = fields[0].Get<uint32>();
9857 bct.LanguageID = fields[1].Get<uint32>();
9858 bct.MaleText[DEFAULT_LOCALE] = fields[2].Get<std::string>();
9859 bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get<std::string>();
9860 bct.EmoteId1 = fields[4].Get<uint32>();
9861 bct.EmoteId2 = fields[5].Get<uint32>();
9862 bct.EmoteId3 = fields[6].Get<uint32>();
9863 bct.EmoteDelay1 = fields[7].Get<uint32>();
9864 bct.EmoteDelay2 = fields[8].Get<uint32>();
9865 bct.EmoteDelay3 = fields[9].Get<uint32>();
9866 bct.SoundEntriesId = fields[10].Get<uint32>();
9867 bct.EmotesID = fields[11].Get<uint32>();
9868 bct.Flags = fields[12].Get<uint32>();
9869
9870 if (bct.SoundEntriesId)
9871 {
9872 if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId))
9873 {
9874 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId);
9875 bct.SoundEntriesId = 0;
9876 }
9877 }
9878
9880 {
9881 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID);
9883 }
9884
9885 if (bct.EmoteId1)
9886 {
9887 if (!sEmotesStore.LookupEntry(bct.EmoteId1))
9888 {
9889 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1);
9890 bct.EmoteId1 = 0;
9891 }
9892 }
9893
9894 if (bct.EmoteId2)
9895 {
9896 if (!sEmotesStore.LookupEntry(bct.EmoteId2))
9897 {
9898 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2);
9899 bct.EmoteId2 = 0;
9900 }
9901 }
9902
9903 if (bct.EmoteId3)
9904 {
9905 if (!sEmotesStore.LookupEntry(bct.EmoteId3))
9906 {
9907 LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3);
9908 bct.EmoteId3 = 0;
9909 }
9910 }
9911
9912 _broadcastTextStore[bct.Id] = bct;
9913 } while (result->NextRow());
9914
9915 LOG_INFO("server.loading", ">> Loaded {} Broadcast Texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime));
9916}
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition ObjectMgr.cpp:253
@ LANG_UNIVERSAL
Definition SharedDefines.h:746
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 ( )
1254{
1255 uint32 oldMSTime = getMSTime();
1256
1257 // 0 1 2 3 4 5 6 7
1258 QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_addon");
1259
1260 if (!result)
1261 {
1262 LOG_WARN("server.loading", ">> Loaded 0 creature addon definitions. DB table `creature_addon` is empty.");
1263 LOG_INFO("server.loading", " ");
1264 return;
1265 }
1266
1267 uint32 count = 0;
1268 do
1269 {
1270 Field* fields = result->Fetch();
1271
1272 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1273
1274 CreatureData const* creData = GetCreatureData(guid);
1275 if (!creData)
1276 {
1277 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_addon`", guid);
1278 continue;
1279 }
1280
1281 CreatureAddon& creatureAddon = _creatureAddonStore[guid];
1282
1283 creatureAddon.path_id = fields[1].Get<uint32>();
1284 if (creData->movementType == WAYPOINT_MOTION_TYPE && !creatureAddon.path_id)
1285 {
1286 const_cast<CreatureData*>(creData)->movementType = IDLE_MOTION_TYPE;
1287 LOG_ERROR("sql.sql", "Creature (GUID {}) has movement type set to WAYPOINT_MOTION_TYPE but no path assigned", guid);
1288 }
1289
1290 creatureAddon.mount = fields[2].Get<uint32>();
1291 creatureAddon.bytes1 = fields[3].Get<uint32>();
1292 creatureAddon.bytes2 = fields[4].Get<uint32>();
1293 creatureAddon.emote = fields[5].Get<uint32>();
1294 creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].Get<uint8>());
1295
1296 for (std::string_view aura : Acore::Tokenize(fields[7].Get<std::string_view>(), ' ', false))
1297 {
1298 SpellInfo const* spellInfo = nullptr;
1299
1300 if (Optional<uint32> spellId = Acore::StringTo<uint32>(aura))
1301 {
1302 spellInfo = sSpellMgr->GetSpellInfo(*spellId);
1303 }
1304
1305 if (!spellInfo)
1306 {
1307 LOG_ERROR("sql.sql", "Creature (GUID: {}) has wrong spell '{}' defined in `auras` field in `creature_addon`.", guid, aura);
1308 continue;
1309 }
1310
1311 if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellInfo->Id) != creatureAddon.auras.end())
1312 {
1313 LOG_ERROR("sql.sql", "Creature (GUID: {}) has duplicate aura (spell {}) in `auras` field in `creature_addon`.", guid, spellInfo->Id);
1314 continue;
1315 }
1316
1317 if (spellInfo->GetDuration() > 0)
1318 {
1319 LOG_DEBUG/*ERROR*/("sql.sql", "Creature (Entry: {}) has temporary aura (spell {}) in `auras` field in `creature_template_addon`.", guid, spellInfo->Id);
1320 // continue;
1321 }
1322
1323 creatureAddon.auras.push_back(spellInfo->Id);
1324 }
1325
1326 if (creatureAddon.mount)
1327 {
1328 if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
1329 {
1330 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid displayInfoId ({}) for mount defined in `creature_addon`", guid, creatureAddon.mount);
1331 creatureAddon.mount = 0;
1332 }
1333 }
1334
1335 if (!sEmotesStore.LookupEntry(creatureAddon.emote))
1336 {
1337 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid emote ({}) defined in `creature_addon`.", guid, creatureAddon.emote);
1338 creatureAddon.emote = 0;
1339 }
1340
1342 {
1343 LOG_ERROR("sql.sql", "Creature (GUID: {}) has invalid visibilityDistanceType ({}) defined in `creature_addon`.", guid, AsUnderlyingType(creatureAddon.visibilityDistanceType));
1345 }
1346
1347 ++count;
1348 } while (result->NextRow());
1349
1350 LOG_INFO("server.loading", ">> Loaded {} Creature Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1351 LOG_INFO("server.loading", " ");
1352}
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ WAYPOINT_MOTION_TYPE
Definition MotionMaster.h:41
VisibilityDistanceType
Definition ObjectDefines.h:62
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition Util.h:610
uint32 Id
Definition SpellInfo.h:320
int32 GetDuration() const
Definition SpellInfo.cpp:2232
Definition AsioHacksFwd.h:47
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Tokenize.cpp:20
STL namespace.
Definition CreatureData.h:436
std::vector< uint32 > auras
Definition CreatureData.h:442
uint32 mount
Definition CreatureData.h:438
uint32 emote
Definition CreatureData.h:441
uint32 path_id
Definition CreatureData.h:437
VisibilityDistanceType visibilityDistanceType
Definition CreatureData.h:443
uint32 bytes1
Definition CreatureData.h:439
uint32 bytes2
Definition CreatureData.h:440

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

◆ LoadCreatureClassLevelStats()

void ObjectMgr::LoadCreatureClassLevelStats ( )
9986{
9987 uint32 oldMSTime = getMSTime();
9988
9989 QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2 FROM creature_classlevelstats");
9990
9991 if (!result)
9992 {
9993 LOG_WARN("server.loading", ">> Loaded 0 creature base stats. DB table `creature_classlevelstats` is empty.");
9994 LOG_INFO("server.loading", " ");
9995 return;
9996 }
9997
9998 uint32 count = 0;
9999 do
10000 {
10001 Field* fields = result->Fetch();
10002
10003 uint8 Level = fields[0].Get<uint8>();
10004 uint8 Class = fields[1].Get<uint8>();
10005
10006 if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
10007 LOG_ERROR("sql.sql", "Creature base stats for level {} has invalid class {}", Level, Class);
10008
10009 CreatureBaseStats stats;
10010
10011 for (uint8 i = 0; i < MAX_EXPANSIONS; ++i)
10012 {
10013 stats.BaseHealth[i] = fields[2 + i].Get<uint32>();
10014
10015 if (stats.BaseHealth[i] == 0)
10016 {
10017 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid zero base HP[{}] - set to 1", Class, Level, i);
10018 stats.BaseHealth[i] = 1;
10019 }
10020
10021 // xinef: if no data is available, get them from lower expansions
10022 if (stats.BaseHealth[i] <= 1)
10023 {
10024 for (uint8 j = i; j > 0;)
10025 {
10026 --j;
10027 if (stats.BaseHealth[j] > 1)
10028 {
10029 stats.BaseHealth[i] = stats.BaseHealth[j];
10030 break;
10031 }
10032 }
10033 }
10034
10035 stats.BaseDamage[i] = fields[9 + i].Get<float>();
10036 if (stats.BaseDamage[i] < 0.0f)
10037 {
10038 LOG_ERROR("sql.sql", "Creature base stats for class {}, level {} has invalid negative base damage[{}] - set to 0.0", Class, Level, i);
10039 stats.BaseDamage[i] = 0.0f;
10040 }
10041 }
10042
10043 stats.BaseMana = fields[5].Get<uint32>();
10044 stats.BaseArmor = fields[6].Get<uint32>();
10045
10046 stats.AttackPower = fields[7].Get<uint32>();
10047 stats.RangedAttackPower = fields[8].Get<uint32>();
10048
10050
10051 ++count;
10052 } while (result->NextRow());
10053
10055 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
10056 {
10057 for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
10058 {
10059 if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end())
10060 LOG_ERROR("sql.sql", "Missing base stats for creature class {} level {}", itr->second.unit_class, lvl);
10061 }
10062 }
10063
10064 LOG_INFO("server.loading", ">> Loaded {} Creature Base Stats in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10065 LOG_INFO("server.loading", " ");
10066}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:288
@ Class
Requires the player to be a specific class.
@ Level
Requires the player to be at least a specific level.
CreatureTemplateContainer const * GetCreatureTemplates() const
Definition ObjectMgr.h:769
uint32 BaseMana
Definition CreatureData.h:301
float BaseDamage[MAX_EXPANSIONS]
Definition CreatureData.h:305
uint32 RangedAttackPower
Definition CreatureData.h:304
uint32 AttackPower
Definition CreatureData.h:303
uint32 BaseHealth[MAX_EXPANSIONS]
Definition CreatureData.h:300
float BaseArmor
Definition CreatureData.h:302

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

◆ LoadCreatureCustomIDs()

void ObjectMgr::LoadCreatureCustomIDs ( )

Load config option Creatures.CustomIDs into Store.

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

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

◆ LoadCreatureDefaultTrainers()

void ObjectMgr::LoadCreatureDefaultTrainers ( )
9401{
9402 uint32 oldMSTime = getMSTime();
9403
9405
9406 if (QueryResult result = WorldDatabase.Query("SELECT CreatureId, TrainerId FROM creature_default_trainer"))
9407 {
9408 do
9409 {
9410 Field* fields = result->Fetch();
9411 uint32 creatureId = fields[0].Get<uint32>();
9412 uint32 trainerId = fields[1].Get<uint32>();
9413
9414 if (!GetCreatureTemplate(creatureId))
9415 {
9416 LOG_ERROR("sql.sql", "Table `creature_default_trainer` references non-existing creature template (CreatureId: %u), ignoring", creatureId);
9417 continue;
9418 }
9419
9420 _creatureDefaultTrainers[creatureId] = trainerId;
9421
9422 } while (result->NextRow());
9423 }
9424
9425 LOG_INFO("server.loading", ">> Loaded {} default trainers in {} ms", _creatureDefaultTrainers.size(), GetMSTimeDiffToNow(oldMSTime));
9426}

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

◆ LoadCreatureLocales()

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

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

◆ LoadCreatureModelInfo()

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

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

◆ LoadCreatureMovementOverrides()

void ObjectMgr::LoadCreatureMovementOverrides ( )
1543{
1544 uint32 oldMSTime = getMSTime();
1545
1547
1548 // Load the data from creature_movement_override and if NULL fallback to creature_template_movement
1549 QueryResult result = WorldDatabase.Query("SELECT cmo.SpawnId,"
1550 "COALESCE(cmo.Ground, ctm.Ground),"
1551 "COALESCE(cmo.Swim, ctm.Swim),"
1552 "COALESCE(cmo.Flight, ctm.Flight),"
1553 "COALESCE(cmo.Rooted, ctm.Rooted),"
1554 "COALESCE(cmo.Chase, ctm.Chase),"
1555 "COALESCE(cmo.Random, ctm.Random),"
1556 "COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) "
1557 "FROM creature_movement_override AS cmo "
1558 "LEFT JOIN creature AS c ON c.guid = cmo.SpawnId "
1559 "LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id1");
1560 if (!result)
1561 {
1562 LOG_WARN("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
1563 return;
1564 }
1565
1566 do
1567 {
1568 Field* fields = result->Fetch();
1569 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
1570 if (!GetCreatureData(spawnId))
1571 {
1572 LOG_ERROR("sql.sql", "Creature (GUID: {}) does not exist but has a record in `creature_movement_override`", spawnId);
1573 continue;
1574 }
1575
1577 if (!fields[1].IsNull())
1578 {
1579 movement.Ground = static_cast<CreatureGroundMovementType>(fields[1].Get<uint8>());
1580 }
1581
1582 if (!fields[2].IsNull())
1583 {
1584 movement.Swim = fields[2].Get<bool>();
1585 }
1586
1587 if (!fields[3].IsNull())
1588 {
1589 movement.Flight = static_cast<CreatureFlightMovementType>(fields[3].Get<uint8>());
1590 }
1591
1592 if (!fields[4].IsNull())
1593 {
1594 movement.Rooted = fields[4].Get<bool>();
1595 }
1596
1597 if (!fields[5].IsNull())
1598 {
1599 movement.Chase = static_cast<CreatureChaseMovementType>(fields[5].Get<uint8>());
1600 }
1601
1602 if (!fields[6].IsNull())
1603 {
1604 movement.Random = static_cast<CreatureRandomMovementType>(fields[6].Get<uint8>());
1605 }
1606
1607 if (!fields[7].IsNull())
1608 {
1609 movement.InteractionPauseTimer = fields[7].Get<uint32>();
1610 }
1611
1612 CheckCreatureMovement("creature_movement_override", spawnId, movement);
1613 } while (result->NextRow());
1614
1615 LOG_INFO("server.loading", ">> Loaded {} Movement Overrides in {} ms", _creatureMovementOverrides.size(), GetMSTimeDiffToNow(oldMSTime));
1616 LOG_INFO("server.loading", " ");
1617}
CreatureFlightMovementType
Definition CreatureData.h:92
CreatureChaseMovementType
Definition CreatureData.h:101
CreatureGroundMovementType
Definition CreatureData.h:83
CreatureRandomMovementType
Definition CreatureData.h:110
Definition CreatureData.h:119
bool Swim
Definition CreatureData.h:124
bool Rooted
Definition CreatureData.h:125
uint32 InteractionPauseTimer
Definition CreatureData.h:128

References _creatureMovementOverrides, CreatureMovementData::Chase, CheckCreatureMovement(), CreatureMovementData::Flight, Field::Get(), GetCreatureData(), getMSTime(), GetMSTimeDiffToNow(), CreatureMovementData::Ground, CreatureMovementData::InteractionPauseTimer, LOG_ERROR, LOG_INFO, LOG_WARN, CreatureMovementData::Random, CreatureMovementData::Rooted, CreatureMovementData::Swim, and WorldDatabase.

◆ LoadCreatureQuestEnders()

void ObjectMgr::LoadCreatureQuestEnders ( )
8330{
8331 LoadQuestRelationsHelper(_creatureQuestInvolvedRelations, "creature_questender", false, false);
8332
8333 for (QuestRelations::iterator itr = _creatureQuestInvolvedRelations.begin(); itr != _creatureQuestInvolvedRelations.end(); ++itr)
8334 {
8335 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8336 if (!cInfo)
8337 LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8338 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8339 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);
8340 }
8341}
@ UNIT_NPC_FLAG_QUESTGIVER
Definition UnitDefines.h:320
void LoadQuestRelationsHelper(QuestRelations &map, std::string const &table, bool starter, bool go)
Definition ObjectMgr.cpp:8242

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatureQuestItems()

void ObjectMgr::LoadCreatureQuestItems ( )
10387{
10388 uint32 oldMSTime = getMSTime();
10389
10390 // 0 1 2
10391 QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC");
10392
10393 if (!result)
10394 {
10395 LOG_WARN("server.loading", ">> Loaded 0 creature quest items. DB table `creature_questitem` is empty.");
10396 return;
10397 }
10398
10399 uint32 count = 0;
10400 do
10401 {
10402 Field* fields = result->Fetch();
10403
10404 uint32 entry = fields[0].Get<uint32>();
10405 uint32 item = fields[1].Get<uint32>();
10406 uint32 idx = fields[2].Get<uint32>();
10407
10408 CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry);
10409 if (!creatureInfo)
10410 {
10411 LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, idx: {}), skipped", entry, idx);
10412 continue;
10413 };
10414
10415 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10416 if (!dbcData)
10417 {
10418 LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, idx: {}), skipped", item, entry, idx);
10419 continue;
10420 };
10421
10422 _creatureQuestItemStore[entry].push_back(item);
10423
10424 ++count;
10425 } while (result->NextRow());
10426
10427 LOG_INFO("server.loading", ">> Loaded {} Creature Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10428 LOG_INFO("server.loading", " ");
10429}
DBCStorage< ItemEntry > sItemStore(Itemfmt)
Definition DBCStructure.h:1141

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

◆ LoadCreatureQuestStarters()

void ObjectMgr::LoadCreatureQuestStarters ( )
8316{
8317 LoadQuestRelationsHelper(_creatureQuestRelations, "creature_queststarter", true, false);
8318
8319 for (QuestRelations::iterator itr = _creatureQuestRelations.begin(); itr != _creatureQuestRelations.end(); ++itr)
8320 {
8321 CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
8322 if (!cInfo)
8323 LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry ({}) and existed quest {}", itr->first, itr->second);
8324 else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
8325 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);
8326 }
8327}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadCreatures()

void ObjectMgr::LoadCreatures ( )
2221{
2222 uint32 oldMSTime = getMSTime();
2223
2224 // 0 1 2 3 4 5 6 7 8 9 10 11
2225 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
2226 // 12 13 14 15 16 17 18 19 20 21 22
2227 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, "
2228 // 23
2229 "creature.ScriptName "
2230 "FROM creature "
2231 "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
2232 "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
2233
2234 if (!result)
2235 {
2236 LOG_WARN("server.loading", ">> Loaded 0 creatures. DB table `creature` is empty.");
2237 LOG_INFO("server.loading", " ");
2238 return;
2239 }
2240
2242 LOG_INFO("server.loading", "Calculating zone and area fields. This may take a moment...");
2243
2244 // Build single time for check spawnmask
2245 std::map<uint32, uint32> spawnMasks;
2246 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2247 if (sMapStore.LookupEntry(i))
2248 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2250 spawnMasks[i] |= (1 << k);
2251
2252 _creatureDataStore.rehash(result->GetRowCount());
2253 uint32 count = 0;
2254 do
2255 {
2256 Field* fields = result->Fetch();
2257
2258 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2259 uint32 id1 = fields[1].Get<uint32>();
2260 uint32 id2 = fields[2].Get<uint32>();
2261 uint32 id3 = fields[3].Get<uint32>();
2262
2263 CreatureTemplate const* cInfo = GetCreatureTemplate(id1);
2264 if (!cInfo)
2265 {
2266 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id1 field, skipped.", spawnId, id1);
2267 continue;
2268 }
2269 CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2);
2270 if (!cInfo2 && id2)
2271 {
2272 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id2 field, skipped.", spawnId, id2);
2273 continue;
2274 }
2275 CreatureTemplate const* cInfo3 = GetCreatureTemplate(id3);
2276 if (!cInfo3 && id3)
2277 {
2278 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id3 field, skipped.", spawnId, id3);
2279 continue;
2280 }
2281 if (!id2 && id3)
2282 {
2283 LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3);
2284 continue;
2285 }
2286 CreatureData& data = _creatureDataStore[spawnId];
2287 data.id1 = id1;
2288 data.id2 = id2;
2289 data.id3 = id3;
2290 data.mapid = fields[4].Get<uint16>();
2291 data.equipmentId = fields[5].Get<int8>();
2292 data.posX = fields[6].Get<float>();
2293 data.posY = fields[7].Get<float>();
2294 data.posZ = fields[8].Get<float>();
2295 data.orientation = fields[9].Get<float>();
2296 data.spawntimesecs = fields[10].Get<uint32>();
2297 data.wander_distance = fields[11].Get<float>();
2298 data.currentwaypoint = fields[12].Get<uint32>();
2299 data.curhealth = fields[13].Get<uint32>();
2300 data.curmana = fields[14].Get<uint32>();
2301 data.movementType = fields[15].Get<uint8>();
2302 data.spawnMask = fields[16].Get<uint8>();
2303 data.phaseMask = fields[17].Get<uint32>();
2304 int16 gameEvent = fields[18].Get<int16>();
2305 uint32 PoolId = fields[19].Get<uint32>();
2306 data.npcflag = fields[20].Get<uint32>();
2307 data.unit_flags = fields[21].Get<uint32>();
2308 data.dynamicflags = fields[22].Get<uint32>();
2309 data.ScriptId = GetScriptId(fields[23].Get<std::string>());
2310
2311 if (!data.ScriptId)
2312 data.ScriptId = cInfo->ScriptID;
2313
2314 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2315 if (!mapEntry)
2316 {
2317 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that spawned at not existed map (Id: {}), skipped.", spawnId, data.mapid);
2318 continue;
2319 }
2320
2321 // pussywizard: 7 days means no reaspawn, so set it to 14 days, because manual id reset may be late
2322 if (mapEntry->IsRaid() && data.spawntimesecs >= 7 * DAY && data.spawntimesecs < 14 * DAY)
2323 data.spawntimesecs = 14 * DAY;
2324
2325 // Skip spawnMask check for transport maps
2326 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2327 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that have wrong spawn mask {} including not supported difficulty modes for map (Id: {}).",
2328 spawnId, data.spawnMask, data.mapid);
2329
2330 bool ok = true;
2331 for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
2332 {
2333 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()))
2334 {
2335 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.",
2336 spawnId, diff + 1, data.id1, data.id2, data.id3);
2337 ok = false;
2338 }
2339 }
2340 if (!ok)
2341 continue;
2342
2343 // -1 random, 0 no equipment,
2344 if (data.equipmentId != 0)
2345 {
2346 if ((!GetEquipmentInfo(data.id1, data.equipmentId)) || (data.id2 && !GetEquipmentInfo(data.id2, data.equipmentId)) || (data.id3 && !GetEquipmentInfo(data.id3, data.equipmentId)))
2347 {
2348 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.",
2349 data.id1, data.id2, data.id3, data.equipmentId);
2350 data.equipmentId = 0;
2351 }
2352 }
2354 {
2355 if (!mapEntry->IsDungeon())
2356 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.",
2357 spawnId, data.id1, data.id2, data.id3);
2358 }
2359 if (data.movementType >= MAX_DB_MOTION_TYPE)
2360 {
2361 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);
2363 }
2364 if (data.wander_distance < 0.0f)
2365 {
2366 LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", spawnId, data.id1, data.id2, data.id3);
2367 data.wander_distance = 0.0f;
2368 }
2369 else if (data.movementType == RANDOM_MOTION_TYPE)
2370 {
2371 if (data.wander_distance == 0.0f)
2372 {
2373 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).",
2374 spawnId, data.id1, data.id2, data.id3);
2376 }
2377 }
2378 else if (data.movementType == IDLE_MOTION_TYPE)
2379 {
2380 if (data.wander_distance != 0.0f)
2381 {
2382 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);
2383 data.wander_distance = 0.0f;
2384 }
2385 }
2386
2387 if (data.phaseMask == 0)
2388 {
2389 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);
2390 data.phaseMask = 1;
2391 }
2392
2394 {
2395 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2396 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2397
2399
2400 stmt->SetData(0, zoneId);
2401 stmt->SetData(1, areaId);
2402 stmt->SetData(2, spawnId);
2403
2404 WorldDatabase.Execute(stmt);
2405 }
2406
2407 // Add to grid if not managed by the game event or pool system
2408 if (gameEvent == 0 && PoolId == 0)
2409 AddCreatureToGrid(spawnId, &data);
2410
2411 ++count;
2412 } while (result->NextRow());
2413
2414 LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2415 LOG_INFO("server.loading", " ");
2416}
constexpr auto DAY
Definition Common.h:49
@ CREATURE_FLAG_EXTRA_INSTANCE_BIND
Definition CreatureData.h:45
Difficulty
Definition DBCEnums.h:266
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition DBCStores.cpp:761
std::int8_t int8
Definition Define.h:105
std::int16_t int16
Definition Define.h:104
@ RANDOM_MOTION_TYPE
Definition MotionMaster.h:40
@ CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA
Definition WorldConfig.h:113
@ WORLD_UPD_CREATURE_ZONE_AREA_DATA
Definition WorldDatabase.h:114
EquipmentInfo const * GetEquipmentInfo(uint32 entry, int8 &id)
Definition ObjectMgr.cpp:1438
uint32 ScriptId
Definition CreatureData.h:389
bool HasFlagsExtra(uint32 flag) const
Definition CreatureData.h:279
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, Field::Get(), GetCreatureTemplate(), GetEquipmentInfo(), GetMapDifficultyData(), getMSTime(), GetMSTimeDiffToNow(), GetScriptId(), CreatureTemplate::HasFlagsExtra(), CreatureData::id1, CreatureData::id2, CreatureData::id3, IDLE_MOTION_TYPE, MapEntry::IsDungeon(), MapEntry::IsRaid(), LOG_ERROR, LOG_INFO, LOG_WARN, CreatureData::mapid, MAX_DB_MOTION_TYPE, MAX_DIFFICULTY, CreatureData::movementType, CreatureData::npcflag, CreatureData::orientation, CreatureData::phaseMask, CreatureData::posX, CreatureData::posY, CreatureData::posZ, RANDOM_MOTION_TYPE, CreatureData::ScriptId, PreparedStatementBase::SetData(), sMapMgr, sMapStore, CreatureData::spawnMask, CreatureData::spawntimesecs, sWorld, CreatureData::unit_flags, CreatureData::wander_distance, WORLD_UPD_CREATURE_ZONE_AREA_DATA, and WorldDatabase.

◆ LoadCreatureSparring()

void ObjectMgr::LoadCreatureSparring ( )
2419{
2420 uint32 oldMSTime = getMSTime();
2421
2422 QueryResult result = WorldDatabase.Query("SELECT GUID, SparringPCT FROM creature_sparring");
2423
2424 if (!result)
2425 {
2426 LOG_WARN("server.loading", ">> Loaded 0 sparring data. DB table `creature_sparring` is empty.");
2427 LOG_INFO("server.loading", " ");
2428 return;
2429 }
2430
2431 uint32 count = 0;
2432 do
2433 {
2434 Field* fields = result->Fetch();
2435
2436 ObjectGuid::LowType spawnId = fields[0].Get<uint32>();
2437 float sparringHealthPct = fields[1].Get<float>();
2438
2439 if (!GetCreatureData(spawnId))
2440 {
2441 LOG_ERROR("sql.sql", "Entry {} has a record in `creature_sparring` but doesn't exist in `creatures` table");
2442 continue;
2443 }
2444
2445 _creatureSparringStore[spawnId].push_back(sparringHealthPct);
2446
2447 ++count;
2448 } while (result->NextRow());
2449
2450 LOG_INFO("server.loading", ">> Loaded {} sparring data in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2451 LOG_INFO("server.loading", " ");
2452}

References _creatureSparringStore, Field::Get(), GetCreatureData(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, and WorldDatabase.

◆ LoadCreatureTemplate()

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

Loads a creature template from a database result.

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

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateAddons()

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

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

◆ LoadCreatureTemplateModels()

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

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

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplateResistances()

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

References _creatureTemplateStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_SPELL_SCHOOL, CreatureTemplate::resistance, SPELL_SCHOOL_NORMAL, and WorldDatabase.

Referenced by LoadCreatureTemplates().

◆ LoadCreatureTemplates()

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

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

◆ LoadCreatureTemplateSpells()

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

References _creatureTemplateStore, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_CREATURE_SPELLS, CreatureTemplate::spells, and WorldDatabase.

Referenced by LoadCreatureTemplates().

◆ LoadEquipmentTemplates()

void ObjectMgr::LoadEquipmentTemplates ( )
1465{
1466 uint32 oldMSTime = getMSTime();
1467
1468 // 0 1 2 3 4
1469 QueryResult result = WorldDatabase.Query("SELECT CreatureID, ID, ItemID1, ItemID2, ItemID3 FROM creature_equip_template");
1470
1471 if (!result)
1472 {
1473 LOG_WARN("server.loading", ">> Loaded 0 creature equipment templates. DB table `creature_equip_template` is empty!");
1474 LOG_INFO("server.loading", " ");
1475 return;
1476 }
1477
1478 uint32 count = 0;
1479 do
1480 {
1481 Field* fields = result->Fetch();
1482
1483 uint32 entry = fields[0].Get<uint32>();
1484
1485 if (!GetCreatureTemplate(entry))
1486 {
1487 LOG_ERROR("sql.sql", "Creature template (CreatureID: {}) does not exist but has a record in `creature_equip_template`", entry);
1488 continue;
1489 }
1490
1491 uint8 id = fields[1].Get<uint8>();
1492 if (!id)
1493 {
1494 LOG_ERROR("sql.sql", "Creature equipment template with id 0 found for creature {}, skipped.", entry);
1495 continue;
1496 }
1497
1498 EquipmentInfo& equipmentInfo = _equipmentInfoStore[entry][id];
1499
1500 equipmentInfo.ItemEntry[0] = fields[2].Get<uint32>();
1501 equipmentInfo.ItemEntry[1] = fields[3].Get<uint32>();
1502 equipmentInfo.ItemEntry[2] = fields[4].Get<uint32>();
1503
1504 for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1505 {
1506 if (!equipmentInfo.ItemEntry[i])
1507 continue;
1508
1509 ItemEntry const* dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]);
1510
1511 if (!dbcItem)
1512 {
1513 LOG_ERROR("sql.sql", "Unknown item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {}, forced to 0.",
1514 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1515 equipmentInfo.ItemEntry[i] = 0;
1516 continue;
1517 }
1518
1519 if (dbcItem->InventoryType != INVTYPE_WEAPON &&
1520 dbcItem->InventoryType != INVTYPE_SHIELD &&
1521 dbcItem->InventoryType != INVTYPE_RANGED &&
1522 dbcItem->InventoryType != INVTYPE_2HWEAPON &&
1525 dbcItem->InventoryType != INVTYPE_HOLDABLE &&
1526 dbcItem->InventoryType != INVTYPE_THROWN &&
1528 {
1529 LOG_ERROR("sql.sql", "Item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {} is not equipable in a hand, forced to 0.",
1530 equipmentInfo.ItemEntry[i], i + 1, entry, id);
1531 equipmentInfo.ItemEntry[i] = 0;
1532 }
1533 }
1534
1535 ++count;
1536 } while (result->NextRow());
1537
1538 LOG_INFO("server.loading", ">> Loaded {} Equipment Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1539 LOG_INFO("server.loading", " ");
1540}
#define MAX_EQUIPMENT_ITEMS
Definition CreatureData.h:35
@ INVTYPE_HOLDABLE
Definition ItemTemplate.h:279
@ INVTYPE_RANGED
Definition ItemTemplate.h:271
@ INVTYPE_THROWN
Definition ItemTemplate.h:281
@ INVTYPE_RANGEDRIGHT
Definition ItemTemplate.h:282
@ INVTYPE_WEAPON
Definition ItemTemplate.h:269
@ INVTYPE_WEAPONMAINHAND
Definition ItemTemplate.h:277
@ INVTYPE_WEAPONOFFHAND
Definition ItemTemplate.h:278
@ INVTYPE_2HWEAPON
Definition ItemTemplate.h:273
@ INVTYPE_SHIELD
Definition ItemTemplate.h:270
Definition CreatureData.h:356
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition CreatureData.h:357
uint32 InventoryType
Definition DBCStructure.h:1148

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

◆ LoadEventScripts()

void ObjectMgr::LoadEventScripts ( )
5741{
5743
5744 std::set<uint32> evt_scripts;
5745 // Load all possible script entries from gameobjects
5747 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
5748 if (uint32 eventId = itr->second.GetEventScriptId())
5749 evt_scripts.insert(eventId);
5750
5751 // Load all possible script entries from spells
5752 for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5753 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
5754 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5755 if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
5756 if (spell->Effects[j].MiscValue)
5757 evt_scripts.insert(spell->Effects[j].MiscValue);
5758
5759 for (std::size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
5760 {
5761 for (std::size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
5762 {
5763 TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
5764
5765 if (node->arrivalEventID)
5766 evt_scripts.insert(node->arrivalEventID);
5767
5768 if (node->departureEventID)
5769 evt_scripts.insert(node->departureEventID);
5770 }
5771 }
5772
5773 // Then check if all scripts are in above list of possible script entries
5774 for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
5775 {
5776 std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
5777 if (itr2 == evt_scripts.end())
5778 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 {}",
5779 itr->first, SPELL_EFFECT_SEND_EVENT);
5780 }
5781}
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition DBCStores.cpp:187
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1635
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition GameObject.h:42
ScriptMapMap sEventScripts
Definition ObjectMgr.cpp:60
@ SCRIPTS_EVENT
Definition ObjectMgr.h:150
@ SPELL_EFFECT_SEND_EVENT
Definition SharedDefines.h:850
GameObjectTemplateContainer const * GetGameObjectTemplates() const
Definition ObjectMgr.h:761
void LoadScripts(ScriptsType type)
Definition ObjectMgr.cpp:5398
Definition DBCStructure.h:1971
uint32 arrivalEventID
Definition DBCStructure.h:1981
uint32 departureEventID
Definition DBCStructure.h:1982

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

◆ LoadExplorationBaseXP()

void ObjectMgr::LoadExplorationBaseXP ( )
7622{
7623 uint32 oldMSTime = getMSTime();
7624
7625 QueryResult result = WorldDatabase.Query("SELECT level, basexp FROM exploration_basexp");
7626
7627 if (!result)
7628 {
7629 LOG_WARN("server.loading", ">> Loaded 0 BaseXP definitions. DB table `exploration_basexp` is empty.");
7630 LOG_INFO("server.loading", " ");
7631 return;
7632 }
7633
7634 uint32 count = 0;
7635
7636 do
7637 {
7638 Field* fields = result->Fetch();
7639 uint8 level = fields[0].Get<uint8>();
7640 uint32 basexp = fields[1].Get<int32>();
7641 _baseXPTable[level] = basexp;
7642 ++count;
7643 } while (result->NextRow());
7644
7645 LOG_INFO("server.loading", ">> Loaded {} BaseXP Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7646 LOG_INFO("server.loading", " ");
7647}
std::int32_t int32
Definition Define.h:103

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

◆ LoadFactionChangeAchievements()

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

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

◆ LoadFactionChangeItems()

void ObjectMgr::LoadFactionChangeItems ( )
10105{
10106 uint32 oldMSTime = getMSTime();
10107
10108 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
10109
10110 if (!result)
10111 {
10112 LOG_WARN("server.loading", ">> Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
10113 LOG_INFO("server.loading", " ");
10114 return;
10115 }
10116
10117 uint32 count = 0;
10118
10119 do
10120 {
10121 Field* fields = result->Fetch();
10122
10123 uint32 alliance = fields[0].Get<uint32>();
10124 uint32 horde = fields[1].Get<uint32>();
10125
10126 if (!GetItemTemplate(alliance))
10127 LOG_ERROR("sql.sql", "Item {} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
10128 else if (!GetItemTemplate(horde))
10129 LOG_ERROR("sql.sql", "Item {} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
10130 else
10131 FactionChangeItems[alliance] = horde;
10132
10133 ++count;
10134 } while (result->NextRow());
10135
10136 LOG_INFO("server.loading", ">> Loaded {} faction change item pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10137 LOG_INFO("server.loading", " ");
10138}
CharacterConversionMap FactionChangeItems
Definition ObjectMgr.h:1426

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

◆ LoadFactionChangeQuests()

void ObjectMgr::LoadFactionChangeQuests ( )
10141{
10142 uint32 oldMSTime = getMSTime();
10143
10144 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests");
10145
10146 if (!result)
10147 {
10148 LOG_WARN("server.loading", ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty.");
10149 LOG_INFO("server.loading", " ");
10150 return;
10151 }
10152
10153 uint32 count = 0;
10154
10155 do
10156 {
10157 Field* fields = result->Fetch();
10158
10159 uint32 alliance = fields[0].Get<uint32>();
10160 uint32 horde = fields[1].Get<uint32>();
10161
10162 if (!GetQuestTemplate(alliance))
10163 LOG_ERROR("sql.sql", "Quest {} (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance);
10164 else if (!GetQuestTemplate(horde))
10165 LOG_ERROR("sql.sql", "Quest {} (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde);
10166 else
10167 FactionChangeQuests[alliance] = horde;
10168
10169 ++count;
10170 } while (result->NextRow());
10171
10172 LOG_INFO("server.loading", ">> Loaded {} faction change quest pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10173 LOG_INFO("server.loading", " ");
10174}
CharacterConversionMap FactionChangeQuests
Definition ObjectMgr.h:1427

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

◆ LoadFactionChangeReputations()

void ObjectMgr::LoadFactionChangeReputations ( )
10177{
10178 uint32 oldMSTime = getMSTime();
10179
10180 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_reputations");
10181
10182 if (!result)
10183 {
10184 LOG_WARN("server.loading", ">> Loaded 0 faction change reputation pairs. DB table `player_factionchange_reputations` is empty.");
10185 LOG_INFO("server.loading", " ");
10186 return;
10187 }
10188
10189 uint32 count = 0;
10190
10191 do
10192 {
10193 Field* fields = result->Fetch();
10194
10195 uint32 alliance = fields[0].Get<uint32>();
10196 uint32 horde = fields[1].Get<uint32>();
10197
10198 if (!sFactionStore.LookupEntry(alliance))
10199 LOG_ERROR("sql.sql", "Reputation {} (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance);
10200 else if (!sFactionStore.LookupEntry(horde))
10201 LOG_ERROR("sql.sql", "Reputation {} (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde);
10202 else
10203 FactionChangeReputation[alliance] = horde;
10204
10205 ++count;
10206 } while (result->NextRow());
10207
10208 LOG_INFO("server.loading", ">> Loaded {} faction change reputation pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10209 LOG_INFO("server.loading", " ");
10210}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
CharacterConversionMap FactionChangeReputation
Definition ObjectMgr.h:1428

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

◆ LoadFactionChangeSpells()

void ObjectMgr::LoadFactionChangeSpells ( )
10213{
10214 uint32 oldMSTime = getMSTime();
10215
10216 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells");
10217
10218 if (!result)
10219 {
10220 LOG_WARN("server.loading", ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty.");
10221 LOG_INFO("server.loading", " ");
10222 return;
10223 }
10224
10225 uint32 count = 0;
10226
10227 do
10228 {
10229 Field* fields = result->Fetch();
10230
10231 uint32 alliance = fields[0].Get<uint32>();
10232 uint32 horde = fields[1].Get<uint32>();
10233
10234 if (!sSpellMgr->GetSpellInfo(alliance))
10235 LOG_ERROR("sql.sql", "Spell {} (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
10236 else if (!sSpellMgr->GetSpellInfo(horde))
10237 LOG_ERROR("sql.sql", "Spell {} (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
10238 else
10239 FactionChangeSpells[alliance] = horde;
10240
10241 ++count;
10242 } while (result->NextRow());
10243
10244 LOG_INFO("server.loading", ">> Loaded {} faction change spell pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10245 LOG_INFO("server.loading", " ");
10246}
CharacterConversionMap FactionChangeSpells
Definition ObjectMgr.h:1429

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

◆ LoadFactionChangeTitles()

void ObjectMgr::LoadFactionChangeTitles ( )
10249{
10250 uint32 oldMSTime = getMSTime();
10251
10252 QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_titles");
10253
10254 if (!result)
10255 {
10256 LOG_WARN("server.loading", ">> Loaded 0 faction change title pairs. DB table `player_factionchange_title` is empty.");
10257 return;
10258 }
10259
10260 uint32 count = 0;
10261
10262 do
10263 {
10264 Field* fields = result->Fetch();
10265
10266 uint32 alliance = fields[0].Get<uint32>();
10267 uint32 horde = fields[1].Get<uint32>();
10268
10269 if (!sCharTitlesStore.LookupEntry(alliance))
10270 LOG_ERROR("sql.sql", "Title {} (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance);
10271 else if (!sCharTitlesStore.LookupEntry(horde))
10272 LOG_ERROR("sql.sql", "Title {} (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde);
10273 else
10274 FactionChangeTitles[alliance] = horde;
10275
10276 ++count;
10277 } while (result->NextRow());
10278
10279 LOG_INFO("server.loading", ">> Loaded {} faction change title pairs in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10280 LOG_INFO("server.loading", " ");
10281}
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
CharacterConversionMap FactionChangeTitles
Definition ObjectMgr.h:1430

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

◆ LoadFishingBaseSkillLevel()

void ObjectMgr::LoadFishingBaseSkillLevel ( )
8944{
8945 uint32 oldMSTime = getMSTime();
8946
8947 _fishingBaseForAreaStore.clear(); // for reload case
8948
8949 QueryResult result = WorldDatabase.Query("SELECT entry, skill FROM skill_fishing_base_level");
8950
8951 if (!result)
8952 {
8953 LOG_WARN("server.loading", ">> Loaded 0 areas for fishing base skill level. DB table `skill_fishing_base_level` is empty.");
8954 LOG_INFO("server.loading", " ");
8955 return;
8956 }
8957
8958 uint32 count = 0;
8959
8960 do
8961 {
8962 Field* fields = result->Fetch();
8963 uint32 entry = fields[0].Get<uint32>();
8964 int32 skill = fields[1].Get<int16>();
8965
8966 AreaTableEntry const* fArea = sAreaTableStore.LookupEntry(entry);
8967 if (!fArea)
8968 {
8969 LOG_ERROR("sql.sql", "AreaId {} defined in `skill_fishing_base_level` does not exist", entry);
8970 continue;
8971 }
8972
8973 _fishingBaseForAreaStore[entry] = skill;
8974 ++count;
8975 } while (result->NextRow());
8976
8977 LOG_INFO("server.loading", ">> Loaded {} areas for fishing base skill level in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8978 LOG_INFO("server.loading", " ");
8979}

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

◆ LoadGameObjectAddons()

void ObjectMgr::LoadGameObjectAddons ( )
1355{
1356 uint32 oldMSTime = getMSTime();
1357
1358 // 0 1 2
1359 QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon");
1360
1361 if (!result)
1362 {
1363 LOG_WARN("server.loading", ">> Loaded 0 gameobject addon definitions. DB table `gameobject_addon` is empty.");
1364 LOG_INFO("server.loading", " ");
1365 return;
1366 }
1367
1368 uint32 count = 0;
1369 do
1370 {
1371 Field* fields = result->Fetch();
1372
1373 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1374
1375 const GameObjectData* goData = GetGameObjectData(guid);
1376 if (!goData)
1377 {
1378 LOG_ERROR("sql.sql", "GameObject (GUID: {}) does not exist but has a record in `gameobject_addon`", guid);
1379 continue;
1380 }
1381
1382 GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
1383 gameObjectAddon.invisibilityType = InvisibilityType(fields[1].Get<uint8>());
1384 gameObjectAddon.InvisibilityValue = fields[2].Get<uint32>();
1385
1386 if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
1387 {
1388 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid InvisibilityType in `gameobject_addon`", guid);
1389 gameObjectAddon.invisibilityType = INVISIBILITY_GENERAL;
1390 gameObjectAddon.InvisibilityValue = 0;
1391 }
1392
1393 if (gameObjectAddon.invisibilityType && !gameObjectAddon.InvisibilityValue)
1394 {
1395 LOG_ERROR("sql.sql", "GameObject (GUID: {}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid);
1396 gameObjectAddon.InvisibilityValue = 1;
1397 }
1398
1399 ++count;
1400 } while (result->NextRow());
1401
1402 LOG_INFO("server.loading", ">> Loaded {} Gameobject Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1403 LOG_INFO("server.loading", " ");
1404}
InvisibilityType
Definition SharedDefines.h:1265
@ TOTAL_INVISIBILITY_TYPES
Definition SharedDefines.h:1279
@ INVISIBILITY_GENERAL
Definition SharedDefines.h:1266
Definition GameObjectData.h:683
uint32 InvisibilityValue
Definition GameObjectData.h:685
InvisibilityType invisibilityType
Definition GameObjectData.h:684

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 ( )
8730{
8731 uint32 oldMSTime = getMSTime();
8732
8733 if (GetGameObjectTemplates()->empty())
8734 {
8735 LOG_WARN("server.loading", ">> Loaded 0 GameObjects for quests");
8736 LOG_INFO("server.loading", " ");
8737 return;
8738 }
8739
8740 uint32 count = 0;
8741
8742 // collect GO entries for GO that must activated
8744 for (GameObjectTemplateContainer::iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
8745 {
8746 itr->second.IsForQuests = false;
8747 switch (itr->second.type)
8748 {
8750 itr->second.IsForQuests = true;
8751 ++count;
8752 break;
8754 {
8755 // scan GO chest with loot including quest items
8756 uint32 loot_id = (itr->second.GetLootId());
8757
8758 // find quest loot for GO
8759 if (itr->second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
8760 {
8761 itr->second.IsForQuests = true;
8762 ++count;
8763 }
8764 break;
8765 }
8767 {
8768 if (itr->second._generic.questID > 0) //quests objects
8769 {
8770 itr->second.IsForQuests = true;
8771 ++count;
8772 }
8773 break;
8774 }
8776 {
8777 if (itr->second.spellFocus.questID > 0) //quests objects
8778 {
8779 itr->second.IsForQuests = true;
8780 ++count;
8781 }
8782 break;
8783 }
8785 {
8786 if (itr->second.goober.questId > 0) //quests objects
8787 {
8788 itr->second.IsForQuests = true;
8789 ++count;
8790 }
8791 break;
8792 }
8793 default:
8794 break;
8795 }
8796 }
8797
8798 LOG_INFO("server.loading", ">> Loaded {} GameObjects for quests in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8799 LOG_INFO("server.loading", " ");
8800}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition SharedDefines.h:1579
@ GAMEOBJECT_TYPE_GENERIC
Definition SharedDefines.h:1576
@ GAMEOBJECT_TYPE_CHEST
Definition SharedDefines.h:1574
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition SharedDefines.h:1573
@ GAMEOBJECT_TYPE_GOOBER
Definition SharedDefines.h:1581
bool HaveQuestLootFor(uint32 loot_id) const
Definition LootMgr.cpp:218

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

◆ LoadGameObjectLocales()

void ObjectMgr::LoadGameObjectLocales ( )
7266{
7267 uint32 oldMSTime = getMSTime();
7268
7269 _gameObjectLocaleStore.clear(); // need for reload case
7270
7271 // 0 1 2 3
7272 QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
7273 if (!result)
7274 return;
7275
7276 do
7277 {
7278 Field* fields = result->Fetch();
7279
7280 uint32 ID = fields[0].Get<uint32>();
7281
7282 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
7283 if (locale == LOCALE_enUS)
7284 continue;
7285
7287 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
7288 AddLocaleString(fields[3].Get<std::string>(), locale, data.CastBarCaption);
7289 } while (result->NextRow());
7290
7291 LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale Strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
7292}
Definition GameObjectData.h:676
std::vector< std::string > Name
Definition GameObjectData.h:677
std::vector< std::string > CastBarCaption
Definition GameObjectData.h:678

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

◆ LoadGameobjectQuestEnders()

void ObjectMgr::LoadGameobjectQuestEnders ( )
8302{
8303 LoadQuestRelationsHelper(_goQuestInvolvedRelations, "gameobject_questender", false, true);
8304
8305 for (QuestRelations::iterator itr = _goQuestInvolvedRelations.begin(); itr != _goQuestInvolvedRelations.end(); ++itr)
8306 {
8307 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8308 if (!goInfo)
8309 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8310 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8311 LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8312 }
8313}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameObjectQuestItems()

void ObjectMgr::LoadGameObjectQuestItems ( )
10342{
10343 uint32 oldMSTime = getMSTime();
10344
10345 // 0 1 2
10346 QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC");
10347
10348 if (!result)
10349 {
10350 LOG_WARN("server.loading", ">> Loaded 0 gameobject quest items. DB table `gameobject_questitem` is empty.");
10351 return;
10352 }
10353
10354 uint32 count = 0;
10355 do
10356 {
10357 Field* fields = result->Fetch();
10358
10359 uint32 entry = fields[0].Get<uint32>();
10360 uint32 item = fields[1].Get<uint32>();
10361 uint32 idx = fields[2].Get<uint32>();
10362
10363 GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry);
10364 if (!goInfo)
10365 {
10366 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: {}, idx: {}), skipped", entry, idx);
10367 continue;
10368 };
10369
10370 ItemEntry const* dbcData = sItemStore.LookupEntry(item);
10371 if (!dbcData)
10372 {
10373 LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: {}) in gameobject (entry: {}, idx: {}), skipped", item, entry, idx);
10374 continue;
10375 };
10376
10377 _gameObjectQuestItemStore[entry].push_back(item);
10378
10379 ++count;
10380 } while (result->NextRow());
10381
10382 LOG_INFO("server.loading", ">> Loaded {} Gameobject Quest Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10383 LOG_INFO("server.loading", " ");
10384}

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

◆ LoadGameobjectQuestStarters()

void ObjectMgr::LoadGameobjectQuestStarters ( )
8288{
8289 LoadQuestRelationsHelper(_goQuestRelations, "gameobject_queststarter", true, true);
8290
8291 for (QuestRelations::iterator itr = _goQuestRelations.begin(); itr != _goQuestRelations.end(); ++itr)
8292 {
8293 GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
8294 if (!goInfo)
8295 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry ({}) and existed quest {}", itr->first, itr->second);
8296 else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
8297 LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry ({}) for quest {}, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
8298 }
8299}

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

Referenced by LoadQuestStartersAndEnders().

◆ LoadGameobjects()

void ObjectMgr::LoadGameobjects ( )
2589{
2590 uint32 oldMSTime = getMSTime();
2591
2592 // 0 1 2 3 4 5 6
2593 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, "
2594 // 7 8 9 10 11 12 13 14 15 16 17
2595 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, "
2596 // 18
2597 "ScriptName "
2598 "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
2599 "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
2600
2601 if (!result)
2602 {
2603 LOG_WARN("server.loading", ">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
2604 LOG_INFO("server.loading", " ");
2605 return;
2606 }
2607
2609 LOG_INFO("server.loading", "Calculating zone and area fields. This may take a moment...");
2610
2611 // build single time for check spawnmask
2612 std::map<uint32, uint32> spawnMasks;
2613 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
2614 if (sMapStore.LookupEntry(i))
2615 for (int k = 0; k < MAX_DIFFICULTY; ++k)
2617 spawnMasks[i] |= (1 << k);
2618
2619 _gameObjectDataStore.rehash(result->GetRowCount());
2620 do
2621 {
2622 Field* fields = result->Fetch();
2623
2624 ObjectGuid::LowType guid = fields[0].Get<uint32>();
2625 uint32 entry = fields[1].Get<uint32>();
2626
2627 GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry);
2628 if (!gInfo)
2629 {
2630 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {}) with non existing gameobject entry {}, skipped.", guid, entry);
2631 continue;
2632 }
2633
2634 if (!gInfo->displayId)
2635 {
2636 switch (gInfo->type)
2637 {
2640 break;
2641 default:
2642 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) doesn't have a displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2643 break;
2644 }
2645 }
2646
2647 if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
2648 {
2649 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry {} GoType: {}) has an invalid displayId ({}), not loaded.", guid, entry, gInfo->type, gInfo->displayId);
2650 continue;
2651 }
2652
2654
2655 data.id = entry;
2656 data.mapid = fields[2].Get<uint16>();
2657 data.posX = fields[3].Get<float>();
2658 data.posY = fields[4].Get<float>();
2659 data.posZ = fields[5].Get<float>();
2660 data.orientation = fields[6].Get<float>();
2661 data.rotation.x = fields[7].Get<float>();
2662 data.rotation.y = fields[8].Get<float>();
2663 data.rotation.z = fields[9].Get<float>();
2664 data.rotation.w = fields[10].Get<float>();
2665 data.spawntimesecs = fields[11].Get<int32>();
2666 data.ScriptId = GetScriptId(fields[18].Get<std::string>());
2667 if (!data.ScriptId)
2668 data.ScriptId = gInfo->ScriptId;
2669
2670 MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
2671 if (!mapEntry)
2672 {
2673 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) spawned on a non-existed map (Id: {}), skip", guid, data.id, data.mapid);
2674 continue;
2675 }
2676
2677 if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
2678 {
2679 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);
2680 }
2681
2682 data.animprogress = fields[12].Get<uint8>();
2683 data.artKit = 0;
2684
2685 uint32 go_state = fields[13].Get<uint8>();
2686 if (go_state >= MAX_GO_STATE)
2687 {
2688 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid `state` ({}) value, skip", guid, data.id, go_state);
2689 continue;
2690 }
2691 data.go_state = GOState(go_state);
2692
2693 data.spawnMask = fields[14].Get<uint8>();
2694
2695 if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
2696 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);
2697
2698 data.phaseMask = fields[15].Get<uint32>();
2699 int16 gameEvent = fields[16].Get<int16>();
2700 uint32 PoolId = fields[17].Get<uint32>();
2701
2702 if (data.rotation.x < -1.0f || data.rotation.x > 1.0f)
2703 {
2704 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationX ({}) value, skip", guid, data.id, data.rotation.x);
2705 continue;
2706 }
2707
2708 if (data.rotation.y < -1.0f || data.rotation.y > 1.0f)
2709 {
2710 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationY ({}) value, skip", guid, data.id, data.rotation.y);
2711 continue;
2712 }
2713
2714 if (data.rotation.z < -1.0f || data.rotation.z > 1.0f)
2715 {
2716 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationZ ({}) value, skip", guid, data.id, data.rotation.z);
2717 continue;
2718 }
2719
2720 if (data.rotation.w < -1.0f || data.rotation.w > 1.0f)
2721 {
2722 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotationW ({}) value, skip", guid, data.id, data.rotation.w);
2723 continue;
2724 }
2725
2726 if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
2727 {
2728 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
2729 continue;
2730 }
2731
2732 if (data.phaseMask == 0)
2733 {
2734 LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
2735 data.phaseMask = 1;
2736 }
2737
2739 {
2740 uint32 zoneId = sMapMgr->GetZoneId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2741 uint32 areaId = sMapMgr->GetAreaId(data.phaseMask, data.mapid, data.posX, data.posY, data.posZ);
2742
2744
2745 stmt->SetData(0, zoneId);
2746 stmt->SetData(1, areaId);
2747 stmt->SetData(2, guid);
2748
2749 WorldDatabase.Execute(stmt);
2750 }
2751
2752 if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
2753 AddGameobjectToGrid(guid, &data);
2754 } while (result->NextRow());
2755
2756 LOG_INFO("server.loading", ">> Loaded {} Gameobjects in {} ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime));
2757 LOG_INFO("server.loading", " ");
2758}
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
#define MAX_GO_STATE
Definition GameObjectData.h:27
GOState
Definition GameObjectData.h:690
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1577
@ CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldConfig.h:114
@ WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA
Definition WorldDatabase.h:115
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition MapMgr.h:90
uint32 ScriptId
Definition GameObjectData.h:709

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 ( )
7354{
7355 uint32 oldMSTime = getMSTime();
7356
7357 // 0 1 2 3 4 5 6 7
7358 QueryResult result = WorldDatabase.Query("SELECT entry, type, displayId, name, IconName, castBarCaption, unk1, size, "
7359 // 8 9 10 11 12 13 14 15 16 17 18 19 20
7360 "Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
7361 // 21 22 23 24 25 26 27 28 29 30 31 32 33
7362 "Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
7363 "FROM gameobject_template");
7364
7365 if (!result)
7366 {
7367 LOG_WARN("server.loading", ">> Loaded 0 gameobject definitions. DB table `gameobject_template` is empty.");
7368 LOG_INFO("server.loading", " ");
7369 return;
7370 }
7371
7372 _gameObjectTemplateStore.rehash(result->GetRowCount());
7373 uint32 count = 0;
7374 do
7375 {
7376 Field* fields = result->Fetch();
7377
7378 uint32 entry = fields[0].Get<uint32>();
7379
7381
7382 got.entry = entry;
7383 got.type = uint32(fields[1].Get<uint8>());
7384 got.displayId = fields[2].Get<uint32>();
7385 got.name = fields[3].Get<std::string>();
7386 got.IconName = fields[4].Get<std::string>();
7387 got.castBarCaption = fields[5].Get<std::string>();
7388 got.unk1 = fields[6].Get<std::string>();
7389 got.size = fields[7].Get<float>();
7390
7391 for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i)
7392 got.raw.data[i] = fields[8 + i].Get<int32>(); // data1 and data6 can be -1
7393
7394 got.AIName = fields[32].Get<std::string>();
7395 got.ScriptId = GetScriptId(fields[33].Get<std::string>());
7396 got.IsForQuests = false;
7397
7398 // Checks
7399 if (!got.AIName.empty() && !sGameObjectAIRegistry->HasItem(got.AIName))
7400 {
7401 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has non-registered `AIName` '{}' set, removing", got.entry, got.AIName);
7402 }
7403
7404 switch (got.type)
7405 {
7406 case GAMEOBJECT_TYPE_DOOR: //0
7407 {
7408 if (got.door.lockId)
7409 CheckGOLockId(&got, got.door.lockId, 1);
7410 CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3);
7411 break;
7412 }
7413 case GAMEOBJECT_TYPE_BUTTON: //1
7414 {
7415 if (got.button.lockId)
7416 CheckGOLockId(&got, got.button.lockId, 1);
7417 CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4);
7418 break;
7419 }
7421 {
7422 if (got.questgiver.lockId)
7423 CheckGOLockId(&got, got.questgiver.lockId, 0);
7424 CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5);
7425 break;
7426 }
7427 case GAMEOBJECT_TYPE_CHEST: //3
7428 {
7429 if (got.chest.lockId)
7430 CheckGOLockId(&got, got.chest.lockId, 0);
7431
7432 CheckGOConsumable(&got, got.chest.consumable, 3);
7433
7434 if (got.chest.linkedTrapId) // linked trap
7435 CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7);
7436 break;
7437 }
7438 case GAMEOBJECT_TYPE_TRAP: //6
7439 {
7440 if (got.trap.lockId)
7441 CheckGOLockId(&got, got.trap.lockId, 0);
7442 break;
7443 }
7444 case GAMEOBJECT_TYPE_CHAIR: //7
7445 CheckAndFixGOChairHeightId(&got, got.chair.height, 1);
7446 break;
7448 {
7449 if (got.spellFocus.focusId)
7450 {
7451 if (!sSpellFocusObjectStore.LookupEntry(got.spellFocus.focusId))
7452 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but SpellFocus (Id: {}) not exist.",
7453 entry, got.type, got.spellFocus.focusId, got.spellFocus.focusId);
7454 }
7455
7456 if (got.spellFocus.linkedTrapId) // linked trap
7457 CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2);
7458 break;
7459 }
7460 case GAMEOBJECT_TYPE_GOOBER: //10
7461 {
7462 if (got.goober.lockId)
7463 CheckGOLockId(&got, got.goober.lockId, 0);
7464
7465 CheckGOConsumable(&got, got.goober.consumable, 3);
7466
7467 if (got.goober.pageId) // pageId
7468 {
7469 if (!GetPageText(got.goober.pageId))
7470 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data7={} but PageText (Entry {}) not exist.",
7471 entry, got.type, got.goober.pageId, got.goober.pageId);
7472 }
7473 CheckGONoDamageImmuneId(&got, got.goober.noDamageImmune, 11);
7474 if (got.goober.linkedTrapId) // linked trap
7475 CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12);
7476 break;
7477 }
7479 {
7480 if (got.areadamage.lockId)
7481 CheckGOLockId(&got, got.areadamage.lockId, 0);
7482 break;
7483 }
7484 case GAMEOBJECT_TYPE_CAMERA: //13
7485 {
7486 if (got.camera.lockId)
7487 CheckGOLockId(&got, got.camera.lockId, 0);
7488 break;
7489 }
7491 {
7492 if (got.moTransport.taxiPathId)
7493 {
7494 if (got.moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathId].empty())
7495 LOG_ERROR("sql.sql", "GameObject (Entry: {} GoType: {}) have data0={} but TaxiPath (Id: {}) not exist.",
7496 entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
7497 }
7498 if (uint32 transportMap = got.moTransport.mapID)
7499 _transportMaps.insert(transportMap);
7500 break;
7501 }
7503 break;
7505 {
7506 // always must have spell
7507 CheckGOSpellId(&got, got.spellcaster.spellId, 0);
7508 break;
7509 }
7510 case GAMEOBJECT_TYPE_FLAGSTAND: //24
7511 {
7512 if (got.flagstand.lockId)
7513 CheckGOLockId(&got, got.flagstand.lockId, 0);
7514 CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5);
7515 break;
7516 }
7518 {
7519 if (got.fishinghole.lockId)
7520 CheckGOLockId(&got, got.fishinghole.lockId, 4);
7521 break;
7522 }
7523 case GAMEOBJECT_TYPE_FLAGDROP: //26
7524 {
7525 if (got.flagdrop.lockId)
7526 CheckGOLockId(&got, got.flagdrop.lockId, 0);
7527 CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3);
7528 break;
7529 }
7531 CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
7532 break;
7533 }
7534
7535 ++count;
7536 } while (result->NextRow());
7537
7538 LOG_INFO("server.loading", ">> Loaded {} Game Object Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7539 LOG_INFO("server.loading", " ");
7540}
DBCStorage< SpellFocusObjectEntry > sSpellFocusObjectStore(SpellFocusObjectfmt)
#define sGameObjectAIRegistry
Definition GameObjectAIFactory.h:49
void CheckGONoDamageImmuneId(GameObjectTemplate *goTemplate, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7334
void CheckGOSpellId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7313
void CheckAndFixGOChairHeightId(GameObjectTemplate const *goInfo, uint32 const &dataN, uint32 N)
Definition ObjectMgr.cpp:7322
void CheckGOConsumable(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7343
void CheckGOLinkedTrapId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7303
void CheckGOLockId(GameObjectTemplate const *goInfo, uint32 dataN, uint32 N)
Definition ObjectMgr.cpp:7294
@ GAMEOBJECT_TYPE_CAMERA
Definition SharedDefines.h:1584
@ GAMEOBJECT_TYPE_BUTTON
Definition SharedDefines.h:1572
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition SharedDefines.h:1586
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition SharedDefines.h:1589
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition SharedDefines.h:1596
@ GAMEOBJECT_TYPE_FLAGDROP
Definition SharedDefines.h:1597
@ GAMEOBJECT_TYPE_SPELLCASTER
Definition SharedDefines.h:1593
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition SharedDefines.h:1595
@ GAMEOBJECT_TYPE_CHAIR
Definition SharedDefines.h:1578
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition SharedDefines.h:1583
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition SharedDefines.h:1603
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1571
#define MAX_GAMEOBJECT_DATA
Definition SharedDefines.h:1610
PageText const * GetPageText(uint32 pageEntry)
Definition ObjectMgr.cpp:5982
uint32 entry
Definition GameObjectData.h:32

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

◆ LoadGameObjectTemplateAddons()

void ObjectMgr::LoadGameObjectTemplateAddons ( )
7543{
7544 uint32 oldMSTime = getMSTime();
7545
7546 // 0 1 2 3 4 5 6 7 8
7547 QueryResult result = WorldDatabase.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3 FROM gameobject_template_addon");
7548
7549 if (!result)
7550 {
7551 LOG_WARN("server.loading", ">> Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
7552 LOG_INFO("server.loading", " ");
7553 return;
7554 }
7555
7556 uint32 count = 0;
7557 do
7558 {
7559 Field* fields = result->Fetch();
7560
7561 uint32 entry = fields[0].Get<uint32>();
7562
7563 GameObjectTemplate const* got = GetGameObjectTemplate(entry);
7564 if (!got)
7565 {
7566 LOG_ERROR("sql.sql",
7567 "GameObject template (Entry: {}) does not exist but has a record in `gameobject_template_addon`",
7568 entry);
7569 continue;
7570 }
7571
7573 gameObjectAddon.faction = uint32(fields[1].Get<uint16>());
7574 gameObjectAddon.flags = fields[2].Get<uint32>();
7575 gameObjectAddon.mingold = fields[3].Get<uint32>();
7576 gameObjectAddon.maxgold = fields[4].Get<uint32>();
7577
7578 for (uint32 i = 0; i < gameObjectAddon.artKits.size(); i++)
7579 {
7580 uint32 artKitID = fields[5 + i].Get<uint32>();
7581 if (!artKitID)
7582 continue;
7583
7584 if (!sGameObjectArtKitStore.LookupEntry(artKitID))
7585 {
7586 LOG_ERROR("sql.sql", "GameObject (Entry: {}) has invalid `artkit{}` {} defined, set to zero instead.", entry, i, artKitID);
7587 continue;
7588 }
7589
7590 gameObjectAddon.artKits[i] = artKitID;
7591 }
7592
7593 // checks
7594 if (gameObjectAddon.faction && !sFactionTemplateStore.LookupEntry(gameObjectAddon.faction))
7595 LOG_ERROR("sql.sql",
7596 "GameObject (Entry: {}) has invalid faction ({}) defined in `gameobject_template_addon`.",
7597 entry, gameObjectAddon.faction);
7598
7599 if (gameObjectAddon.maxgold > 0)
7600 {
7601 switch (got->type)
7602 {
7605 break;
7606 default:
7607 LOG_ERROR("sql.sql",
7608 "GameObject (Entry {} GoType: {}) cannot be looted but has maxgold set in `gameobject_template_addon`.",
7609 entry, got->type);
7610 break;
7611 }
7612 }
7613
7614 ++count;
7615 } while (result->NextRow());
7616
7617 LOG_INFO("server.loading", ">> Loaded {} Game Object Template Addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7618 LOG_INFO("server.loading", " ");
7619}
DBCStorage< GameObjectArtKitEntry > sGameObjectArtKitStore(GameObjectArtKitfmt)
Definition GameObjectData.h:666
uint32 mingold
Definition GameObjectData.h:670
uint32 flags
Definition GameObjectData.h:669
uint32 faction
Definition GameObjectData.h:668
std::array< uint32, 4 > artKits
Definition GameObjectData.h:672
uint32 maxgold
Definition GameObjectData.h:671

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

◆ LoadGameTele()

void ObjectMgr::LoadGameTele ( )
9084{
9085 uint32 oldMSTime = getMSTime();
9086
9087 _gameTeleStore.clear(); // for reload case
9088
9089 // 0 1 2 3 4 5 6
9090 QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
9091
9092 if (!result)
9093 {
9094 LOG_WARN("server.loading", ">> Loaded 0 GameTeleports. DB table `game_tele` is empty!");
9095 LOG_INFO("server.loading", " ");
9096 return;
9097 }
9098
9099 uint32 count = 0;
9100
9101 do
9102 {
9103 Field* fields = result->Fetch();
9104
9105 uint32 id = fields[0].Get<uint32>();
9106
9107 GameTele gt;
9108
9109 gt.position_x = fields[1].Get<float>();
9110 gt.position_y = fields[2].Get<float>();
9111 gt.position_z = fields[3].Get<float>();
9112 gt.orientation = fields[4].Get<float>();
9113 gt.mapId = fields[5].Get<uint16>();
9114 gt.name = fields[6].Get<std::string>();
9115
9116 if (!MapMgr::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
9117 {
9118 LOG_ERROR("sql.sql", "Wrong position for id {} (name: {}) in `game_tele` table, ignoring.", id, gt.name);
9119 continue;
9120 }
9121
9122 if (!Utf8toWStr(gt.name, gt.wnameLow))
9123 {
9124 LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_tele` table, ignoring.", id);
9125 continue;
9126 }
9127
9128 wstrToLower(gt.wnameLow);
9129
9130 _gameTeleStore[id] = gt;
9131
9132 ++count;
9133 } while (result->NextRow());
9134
9135 LOG_INFO("server.loading", ">> Loaded {} GameTeleports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9136 LOG_INFO("server.loading", " ");
9137}
float position_x
Definition ObjectMgr.h:134

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

◆ LoadGossipMenu()

void ObjectMgr::LoadGossipMenu ( )
9528{
9529 uint32 oldMSTime = getMSTime();
9530
9531 _gossipMenusStore.clear();
9532
9533 QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
9534
9535 if (!result)
9536 {
9537 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
9538 LOG_INFO("server.loading", " ");
9539 return;
9540 }
9541
9542 do
9543 {
9544 Field* fields = result->Fetch();
9545
9546 GossipMenus gMenu;
9547
9548 gMenu.MenuID = fields[0].Get<uint32>();
9549 gMenu.TextID = fields[1].Get<uint32>();
9550
9551 if (!GetGossipText(gMenu.TextID))
9552 {
9553 LOG_ERROR("sql.sql", "Table gossip_menu entry {} are using non-existing TextID {}", gMenu.MenuID, gMenu.TextID);
9554 continue;
9555 }
9556
9557 _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
9558 } while (result->NextRow());
9559
9560 LOG_INFO("server.loading", ">> Loaded {} gossip_menu entries in {} ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
9561 LOG_INFO("server.loading", " ");
9562}
GossipText const * GetGossipText(uint32 Text_ID) const
Definition ObjectMgr.cpp:6160
Definition ObjectMgr.h:625
uint32 TextID
Definition ObjectMgr.h:627
uint32 MenuID
Definition ObjectMgr.h:626

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

◆ LoadGossipMenuItems()

void ObjectMgr::LoadGossipMenuItems ( )
9565{
9566 uint32 oldMSTime = getMSTime();
9567
9568 _gossipMenuItemsStore.clear();
9569
9570 QueryResult result = WorldDatabase.Query(
9571 // 0 1 2 3 4 5 6 7 8 9 10 11 12
9572 "SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
9573 "FROM gossip_menu_option ORDER BY MenuID, OptionID");
9574
9575 if (!result)
9576 {
9577 LOG_WARN("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
9578 LOG_INFO("server.loading", " ");
9579 return;
9580 }
9581
9582 do
9583 {
9584 Field* fields = result->Fetch();
9585
9586 GossipMenuItems gMenuItem;
9587
9588 gMenuItem.MenuID = fields[0].Get<uint32>();
9589 gMenuItem.OptionID = fields[1].Get<uint16>();
9590 gMenuItem.OptionIcon = fields[2].Get<uint32>();
9591 gMenuItem.OptionText = fields[3].Get<std::string>();
9592 gMenuItem.OptionBroadcastTextID = fields[4].Get<uint32>();
9593 gMenuItem.OptionType = fields[5].Get<uint8>();
9594 gMenuItem.OptionNpcFlag = fields[6].Get<uint32>();
9595 gMenuItem.ActionMenuID = fields[7].Get<uint32>();
9596 gMenuItem.ActionPoiID = fields[8].Get<uint32>();
9597 gMenuItem.BoxCoded = fields[9].Get<bool>();
9598 gMenuItem.BoxMoney = fields[10].Get<uint32>();
9599 gMenuItem.BoxText = fields[11].Get<std::string>();
9600 gMenuItem.BoxBroadcastTextID = fields[12].Get<uint32>();
9601
9602 if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
9603 {
9604 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);
9605 gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
9606 }
9607
9609 {
9610 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
9611 gMenuItem.OptionBroadcastTextID = 0;
9612 }
9613
9614 if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
9615 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);
9616
9617 if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
9618 {
9619 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} use non-existing ActionPoiID {}, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
9620 gMenuItem.ActionPoiID = 0;
9621 }
9622
9623 if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
9624 {
9625 LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
9626 gMenuItem.BoxBroadcastTextID = 0;
9627 }
9628
9629 _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
9630 } while (result->NextRow());
9631
9632 LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
9633 LOG_INFO("server.loading", " ");
9634}
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:61
@ GOSSIP_ICON_MAX
Definition GossipDef.h:82
@ GOSSIP_OPTION_MAX
Definition GossipDef.h:56
PointOfInterest const * GetPointOfInterest(uint32 id) const
Definition ObjectMgr.h:928
BroadcastText const * GetBroadcastText(uint32 id) const
Definition ObjectMgr.h:1199
Definition ObjectMgr.h:607
uint8 OptionIcon
Definition ObjectMgr.h:610
uint32 BoxBroadcastTextID
Definition ObjectMgr.h:621
std::string OptionText
Definition ObjectMgr.h:611
uint32 ActionMenuID
Definition ObjectMgr.h:615
bool BoxCoded
Definition ObjectMgr.h:617
uint32 MenuID
Definition ObjectMgr.h:608
uint32 OptionNpcFlag
Definition ObjectMgr.h:614
uint32 ActionPoiID
Definition ObjectMgr.h:616
uint32 BoxMoney
Definition ObjectMgr.h:618
std::string BoxText
Definition ObjectMgr.h:619
uint32 OptionID
Definition ObjectMgr.h:609
uint32 OptionType
Definition ObjectMgr.h:613
uint32 OptionBroadcastTextID
Definition ObjectMgr.h:612

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

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

◆ LoadGossipText()

void ObjectMgr::LoadGossipText ( )
6169{
6170 uint32 oldMSTime = getMSTime();
6171
6172 QueryResult result = WorldDatabase.Query("SELECT ID, "
6173 "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
6174 "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
6175 "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
6176 "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
6177 "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
6178 "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
6179 "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
6180 "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
6181 "FROM npc_text");
6182
6183 if (!result)
6184 {
6185 LOG_WARN("server.loading", ">> Loaded 0 npc texts, table is empty!");
6186 LOG_INFO("server.loading", " ");
6187 return;
6188 }
6189
6190 _gossipTextStore.rehash(result->GetRowCount());
6191
6192 uint32 count = 0;
6193 uint8 cic;
6194
6195 do
6196 {
6197 cic = 0;
6198
6199 Field* fields = result->Fetch();
6200
6201 uint32 id = fields[cic++].Get<uint32>();
6202 if (!id)
6203 {
6204 LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore.");
6205 continue;
6206 }
6207
6208 GossipText& gText = _gossipTextStore[id];
6209
6210 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6211 {
6212 gText.Options[i].Text_0 = fields[cic++].Get<std::string>();
6213 gText.Options[i].Text_1 = fields[cic++].Get<std::string>();
6214 gText.Options[i].BroadcastTextID = fields[cic++].Get<uint32>();
6215 gText.Options[i].Language = fields[cic++].Get<uint8>();
6216 gText.Options[i].Probability = fields[cic++].Get<float>();
6217
6218 for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
6219 {
6220 gText.Options[i].Emotes[j]._Delay = fields[cic++].Get<uint16>();
6221 gText.Options[i].Emotes[j]._Emote = fields[cic++].Get<uint16>();
6222 }
6223 }
6224
6225 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
6226 {
6227 if (gText.Options[i].BroadcastTextID)
6228 {
6230 {
6231 LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID);
6232 gText.Options[i].BroadcastTextID = 0;
6233 }
6234 }
6235 }
6236
6237 count++;
6238 } while (result->NextRow());
6239
6240 LOG_INFO("server.loading", ">> Loaded {} Npc Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6241 LOG_INFO("server.loading", " ");
6242}
#define MAX_GOSSIP_TEXT_OPTIONS
Definition NPCHandler.h:42
#define MAX_GOSSIP_TEXT_EMOTES
Definition NPCHandler.h:30
std::string Text_0
Definition NPCHandler.h:34
QEmote Emotes[MAX_GOSSIP_TEXT_EMOTES]
Definition NPCHandler.h:39
uint32 Language
Definition NPCHandler.h:37
float Probability
Definition NPCHandler.h:38
uint32 BroadcastTextID
Definition NPCHandler.h:36
std::string Text_1
Definition NPCHandler.h:35
Definition NPCHandler.h:45
GossipTextOption Options[MAX_GOSSIP_TEXT_OPTIONS]
Definition NPCHandler.h:46
uint32 _Emote
Definition NPCHandler.h:26
uint32 _Delay
Definition NPCHandler.h:27

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

◆ LoadInstanceEncounters()

void ObjectMgr::LoadInstanceEncounters ( )
6076{
6077 uint32 oldMSTime = getMSTime();
6078
6079 // 0 1 2 3
6080 QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
6081 if (!result)
6082 {
6083 LOG_WARN("server.loading", ">> Loaded 0 instance encounters, table is empty!");
6084 LOG_INFO("server.loading", " ");
6085 return;
6086 }
6087
6088 uint32 count = 0;
6089 std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
6090 do
6091 {
6092 Field* fields = result->Fetch();
6093 uint32 entry = fields[0].Get<uint32>();
6094 uint8 creditType = fields[1].Get<uint8>();
6095 uint32 creditEntry = fields[2].Get<uint32>();
6096 uint32 lastEncounterDungeon = fields[3].Get<uint16>();
6097 DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
6098 if (!dungeonEncounter)
6099 {
6100 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid encounter id {}, skipped!", entry);
6101 continue;
6102 }
6103
6104 if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon))
6105 {
6106 LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter {} ({}) marked as final for invalid dungeon id {}, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
6107 continue;
6108 }
6109
6110 std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
6111 if (lastEncounterDungeon)
6112 {
6113 if (itr != dungeonLastBosses.end())
6114 {
6115 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]);
6116 continue;
6117 }
6118
6119 dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
6120 }
6121
6122 switch (creditType)
6123 {
6125 {
6126 CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
6127 if (!creatureInfo)
6128 {
6129 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
6130 continue;
6131 }
6132 const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
6133 break;
6134 }
6136 {
6137 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creditEntry);
6138 if (!spellInfo)
6139 {
6140 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry {}) linked to the encounter {} ({}), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
6141 continue;
6142 }
6143 const_cast<SpellInfo*>(spellInfo)->AttributesCu |= SPELL_ATTR0_CU_ENCOUNTER_REWARD;
6144 break;
6145 }
6146 default:
6147 LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type ({}) for encounter {} ({}), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
6148 continue;
6149 }
6150
6151 DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
6152 encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
6153 ++count;
6154 } while (result->NextRow());
6155
6156 LOG_INFO("server.loading", ">> Loaded {} Instance Encounters in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6157 LOG_INFO("server.loading", " ");
6158}
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition CreatureData.h:73
DBCStorage< DungeonEncounterEntry > sDungeonEncounterStore(DungeonEncounterfmt)
#define sLFGMgr
Definition LFGMgr.h:643
EncounterCreditType
Definition Map.h:157
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition Map.h:158
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition Map.h:159
std::list< DungeonEncounter const * > DungeonEncounterList
Definition ObjectMgr.h:711
@ SPELL_ATTR0_CU_ENCOUNTER_REWARD
Definition SpellInfo.h:207
Definition DBCStructure.h:866
Definition ObjectMgr.h:701

References _dungeonEncounterStore, CREATURE_FLAG_EXTRA_DUNGEON_BOSS, ENCOUNTER_CREDIT_CAST_SPELL, ENCOUNTER_CREDIT_KILL_CREATURE, Field::Get(), GetCreatureTemplate(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAKE_PAIR32(), sDungeonEncounterStore, sLFGMgr, SPELL_ATTR0_CU_ENCOUNTER_REWARD, sSpellMgr, and WorldDatabase.

◆ LoadInstanceTemplate()

void ObjectMgr::LoadInstanceTemplate ( )
6025{
6026 uint32 oldMSTime = getMSTime();
6027
6028 // 0 1 2 4
6029 QueryResult result = WorldDatabase.Query("SELECT map, parent, script, allowMount FROM instance_template");
6030
6031 if (!result)
6032 {
6033 LOG_WARN("server.loading", ">> Loaded 0 instance templates. DB table `instance_template` is empty!");
6034 LOG_INFO("server.loading", " ");
6035 return;
6036 }
6037
6038 uint32 count = 0;
6039 do
6040 {
6041 Field* fields = result->Fetch();
6042
6043 uint16 mapID = fields[0].Get<uint16>();
6044
6045 if (!MapMgr::IsValidMAP(mapID, true))
6046 {
6047 LOG_ERROR("sql.sql", "ObjectMgr::LoadInstanceTemplate: bad mapid {} for template!", mapID);
6048 continue;
6049 }
6050
6051 InstanceTemplate instanceTemplate;
6052
6053 instanceTemplate.AllowMount = fields[3].Get<bool>();
6054 instanceTemplate.Parent = uint32(fields[1].Get<uint16>());
6055 instanceTemplate.ScriptId = GetScriptId(fields[2].Get<std::string>());
6056
6057 _instanceTemplateStore[mapID] = instanceTemplate;
6058
6059 ++count;
6060 } while (result->NextRow());
6061
6062 LOG_INFO("server.loading", ">> Loaded {} Instance Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6063 LOG_INFO("server.loading", " ");
6064}
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition MapMgr.cpp:311
bool AllowMount
Definition Map.h:124
uint32 ScriptId
Definition Map.h:123

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

◆ LoadItemLocales()

void ObjectMgr::LoadItemLocales ( )
2789{
2790 uint32 oldMSTime = getMSTime();
2791
2792 _itemLocaleStore.clear(); // need for reload case
2793
2794 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
2795 if (!result)
2796 return;
2797
2798 do
2799 {
2800 Field* fields = result->Fetch();
2801
2802 uint32 ID = fields[0].Get<uint32>();
2803
2804 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
2805 if (locale == LOCALE_enUS)
2806 continue;
2807
2808 ItemLocale& data = _itemLocaleStore[ID];
2809 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
2810 AddLocaleString(fields[3].Get<std::string>(), locale, data.Description);
2811 } while (result->NextRow());
2812
2813 LOG_INFO("server.loading", ">> Loaded {} Item Locale Strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
2814}
Definition ItemTemplate.h:842
std::vector< std::string > Description
Definition ItemTemplate.h:844
std::vector< std::string > Name
Definition ItemTemplate.h:843

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

◆ LoadItemSetNameLocales()

void ObjectMgr::LoadItemSetNameLocales ( )
3463{
3464 uint32 oldMSTime = getMSTime();
3465
3466 _itemSetNameLocaleStore.clear(); // need for reload case
3467
3468 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
3469
3470 if (!result)
3471 return;
3472
3473 do
3474 {
3475 Field* fields = result->Fetch();
3476
3477 uint32 ID = fields[0].Get<uint32>();
3478
3479 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
3480 if (locale == LOCALE_enUS)
3481 continue;
3482
3484 AddLocaleString(fields[2].Get<std::string>(), locale, data.Name);
3485 } while (result->NextRow());
3486
3487 LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale Strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
3488}
Definition ItemTemplate.h:854
std::vector< std::string > Name
Definition ItemTemplate.h:855

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

◆ LoadItemSetNames()

void ObjectMgr::LoadItemSetNames ( )
3491{
3492 uint32 oldMSTime = getMSTime();
3493
3494 _itemSetNameStore.clear(); // needed for reload case
3495
3496 std::set<uint32> itemSetItems;
3497
3498 // fill item set member ids
3499 for (uint32 entryId = 0; entryId < sItemSetStore.GetNumRows(); ++entryId)
3500 {
3501 ItemSetEntry const* setEntry = sItemSetStore.LookupEntry(entryId);
3502 if (!setEntry)
3503 continue;
3504
3505 for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
3506 if (setEntry->itemId[i])
3507 itemSetItems.insert(setEntry->itemId[i]);
3508 }
3509
3510 // 0 1 2
3511 QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
3512
3513 if (!result)
3514 {
3515 LOG_WARN("server.loading", ">> Loaded 0 item set names. DB table `item_set_names` is empty.");
3516 LOG_INFO("server.loading", " ");
3517 return;
3518 }
3519
3520 _itemSetNameStore.rehash(result->GetRowCount());
3521 uint32 count = 0;
3522
3523 do
3524 {
3525 Field* fields = result->Fetch();
3526
3527 uint32 entry = fields[0].Get<uint32>();
3528 if (itemSetItems.find(entry) == itemSetItems.end())
3529 {
3530 LOG_ERROR("sql.sql", "Item set name (Entry: {}) not found in ItemSet.dbc, data useless.", entry);
3531 continue;
3532 }
3533
3534 ItemSetNameEntry& data = _itemSetNameStore[entry];
3535 data.name = fields[1].Get<std::string>();
3536
3537 uint32 invType = fields[2].Get<uint8>();
3538 if (invType >= MAX_INVTYPE)
3539 {
3540 LOG_ERROR("sql.sql", "Item set name (Entry: {}) has wrong InventoryType value ({})", entry, invType);
3541 invType = INVTYPE_NON_EQUIP;
3542 }
3543
3544 data.InventoryType = invType;
3545 itemSetItems.erase(entry);
3546 ++count;
3547 } while (result->NextRow());
3548
3549 if (!itemSetItems.empty())
3550 {
3551 ItemTemplate const* pProto;
3552 for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr)
3553 {
3554 uint32 entry = *itr;
3555 // add data from item_template if available
3556 pProto = GetItemTemplate(entry);
3557 if (pProto)
3558 {
3559 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, adding data from `item_template`.", entry);
3560 ItemSetNameEntry& data = _itemSetNameStore[entry];
3561 data.name = pProto->Name1;
3562 data.InventoryType = pProto->InventoryType;
3563 ++count;
3564 }
3565 else
3566 LOG_ERROR("sql.sql", "Item set part (Entry: {}) does not have entry in `item_set_names`, set will not display properly.", entry);
3567 }
3568 }
3569
3570 LOG_INFO("server.loading", ">> Loaded {} Item Set Names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3571 LOG_INFO("server.loading", " ");
3572}
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
#define MAX_ITEM_SET_ITEMS
Definition DBCStructure.h:1226
@ INVTYPE_NON_EQUIP
Definition ItemTemplate.h:256
#define MAX_INVTYPE
Definition ItemTemplate.h:287
Definition DBCStructure.h:1230
uint32 itemId[MAX_ITEM_SET_ITEMS]
Definition DBCStructure.h:1234
Definition ItemTemplate.h:848
uint32 InventoryType
Definition ItemTemplate.h:850
std::string name
Definition ItemTemplate.h:849
std::string Name1
Definition ItemTemplate.h:624
uint32 InventoryType
Definition ItemTemplate.h:632

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

◆ LoadItemTemplates()

void ObjectMgr::LoadItemTemplates ( )
2841{
2842 uint32 oldMSTime = getMSTime();
2843
2844 // 0 1 2 3 4 5 6 7 8 9 10 11 12
2845 QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, "
2846 // 13 14 15 16 17 18 19 20
2847 "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, "
2848 // 21 22 23 24 25 26 27
2849 "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, stat_type1, "
2850 // 28 29 30 31 32 33 34 35 36 37
2851 "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, "
2852 // 38 39 40 41 42 43 44 45 46
2853 "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, "
2854 // 47 48 49 50 51 52 53 54 55 56 57
2855 "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, "
2856 // 58 59 60 61 62 63 64 65 66 67
2857 "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, "
2858 // 68 69 70 71 72 73 74
2859 "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, "
2860 // 75 76 77 78 79 80 81
2861 "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, "
2862 // 82 83 84 85 86 87 88
2863 "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, "
2864 // 89 90 91 92 93 94 95
2865 "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, "
2866 // 96 97 98 99 100 101 102 103 104
2867 "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, "
2868 // 105 106 107 108 109 110 111 112 113 114 115 116
2869 "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, "
2870 // 117 118 119 120 121 122 123 124
2871 "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
2872 // 125 126 127 128 129 130 131 132
2873 "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
2874 // 133 134 135 136
2875 "FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
2876
2877 if (!result)
2878 {
2879 LOG_WARN("server.loading", ">> Loaded 0 item templates. DB table `item_template` is empty.");
2880 LOG_INFO("server.loading", " ");
2881 return;
2882 }
2883
2884 _itemTemplateStore.reserve(result->GetRowCount());
2885 uint32 count = 0;
2886 // original inspiration https://github.com/TrinityCore/TrinityCore/commit/0c44bd33ee7b42c924859139a9f4b04cf2b91261
2887 bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
2888
2889 do
2890 {
2891 Field* fields = result->Fetch();
2892
2893 uint32 entry = fields[0].Get<uint32>();
2894
2895 ItemTemplate& itemTemplate = _itemTemplateStore[entry];
2896
2897 itemTemplate.ItemId = entry;
2898 itemTemplate.Class = uint32(fields[1].Get<uint8>());
2899 itemTemplate.SubClass = uint32(fields[2].Get<uint8>());
2900 itemTemplate.SoundOverrideSubclass = int32(fields[3].Get<int8>());
2901 itemTemplate.Name1 = fields[4].Get<std::string>();
2902 itemTemplate.DisplayInfoID = fields[5].Get<uint32>();
2903 itemTemplate.Quality = uint32(fields[6].Get<uint8>());
2904 itemTemplate.Flags = ItemFlags(fields[7].Get<uint32>());
2905 itemTemplate.Flags2 = ItemFlags2(fields[8].Get<uint32>());
2906 itemTemplate.BuyCount = uint32(fields[9].Get<uint8>());
2907 itemTemplate.BuyPrice = int32(fields[10].Get<int64>());
2908 itemTemplate.SellPrice = uint32(fields[11].Get<uint32>());
2909 itemTemplate.InventoryType = uint32(fields[12].Get<uint8>());
2910 itemTemplate.AllowableClass = fields[13].Get<int32>();
2911 itemTemplate.AllowableRace = fields[14].Get<int32>();
2912 itemTemplate.ItemLevel = uint32(fields[15].Get<uint16>());
2913 itemTemplate.RequiredLevel = uint32(fields[16].Get<uint8>());
2914 itemTemplate.RequiredSkill = uint32(fields[17].Get<uint16>());
2915 itemTemplate.RequiredSkillRank = uint32(fields[18].Get<uint16>());
2916 itemTemplate.RequiredSpell = fields[19].Get<uint32>();
2917 itemTemplate.RequiredHonorRank = fields[20].Get<uint32>();
2918 itemTemplate.RequiredCityRank = fields[21].Get<uint32>();
2919 itemTemplate.RequiredReputationFaction = uint32(fields[22].Get<uint16>());
2920 itemTemplate.RequiredReputationRank = uint32(fields[23].Get<uint16>());
2921 itemTemplate.MaxCount = fields[24].Get<int32>();
2922 itemTemplate.Stackable = fields[25].Get<int32>();
2923 itemTemplate.ContainerSlots = uint32(fields[26].Get<uint8>());
2924
2925 uint8 statsCount = 0;
2926 while (statsCount < MAX_ITEM_PROTO_STATS)
2927 {
2928 uint32 statType = uint32(fields[27 + statsCount * 2].Get<uint8>());
2929 int32 statValue = fields[28 + statsCount * 2].Get<int32>();
2930 if (statType == 0)
2931 break;
2932
2933 itemTemplate.ItemStat[statsCount].ItemStatType = statType;
2934 itemTemplate.ItemStat[statsCount].ItemStatValue = statValue;
2935 statsCount++;
2936 }
2937 itemTemplate.StatsCount = statsCount;
2938
2939 itemTemplate.ScalingStatDistribution = uint32(fields[47].Get<uint16>());
2940 itemTemplate.ScalingStatValue = fields[48].Get<int32>();
2941
2942 for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
2943 {
2944 itemTemplate.Damage[i].DamageMin = fields[49 + i * 3].Get<float>();
2945 itemTemplate.Damage[i].DamageMax = fields[50 + i * 3].Get<float>();
2946 itemTemplate.Damage[i].DamageType = uint32(fields[51 + i * 3].Get<uint8>());
2947 }
2948
2949 itemTemplate.Armor = fields[55].Get<uint32>();
2950 itemTemplate.HolyRes = fields[56].Get<int32>();
2951 itemTemplate.FireRes = fields[57].Get<int32>();
2952 itemTemplate.NatureRes = fields[58].Get<int32>();
2953 itemTemplate.FrostRes = fields[59].Get<int32>();
2954 itemTemplate.ShadowRes = fields[60].Get<int32>();
2955 itemTemplate.ArcaneRes = fields[61].Get<int32>();
2956 itemTemplate.Delay = uint32(fields[62].Get<uint16>());
2957 itemTemplate.AmmoType = uint32(fields[63].Get<uint8>());
2958 itemTemplate.RangedModRange = fields[64].Get<float>();
2959
2960 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
2961 {
2962 itemTemplate.Spells[i].SpellId = fields[65 + i * 7 ].Get<int32>();
2963 itemTemplate.Spells[i].SpellTrigger = uint32(fields[66 + i * 7].Get<uint8>());
2964 itemTemplate.Spells[i].SpellCharges = int32(fields[67 + i * 7].Get<int16>());
2965 itemTemplate.Spells[i].SpellPPMRate = fields[68 + i * 7].Get<float>();
2966 itemTemplate.Spells[i].SpellCooldown = fields[69 + i * 7].Get<int32>();
2967 itemTemplate.Spells[i].SpellCategory = uint32(fields[70 + i * 7].Get<uint16>());
2968 itemTemplate.Spells[i].SpellCategoryCooldown = fields[71 + i * 7].Get<int32>();
2969 }
2970
2971 itemTemplate.Bonding = uint32(fields[100].Get<uint8>());
2972 itemTemplate.Description = fields[101].Get<std::string>();
2973 itemTemplate.PageText = fields[102].Get<uint32>();
2974 itemTemplate.LanguageID = uint32(fields[103].Get<uint8>());
2975 itemTemplate.PageMaterial = uint32(fields[104].Get<uint8>());
2976 itemTemplate.StartQuest = fields[105].Get<uint32>();
2977 itemTemplate.LockID = fields[106].Get<uint32>();
2978 itemTemplate.Material = int32(fields[107].Get<int8>());
2979 itemTemplate.Sheath = uint32(fields[108].Get<uint8>());
2980 itemTemplate.RandomProperty = fields[109].Get<int32>();
2981 itemTemplate.RandomSuffix = fields[110].Get<int32>();
2982 itemTemplate.Block = fields[111].Get<uint32>();
2983 itemTemplate.ItemSet = fields[112].Get<uint32>();
2984 itemTemplate.MaxDurability = uint32(fields[113].Get<uint16>());
2985 itemTemplate.Area = fields[114].Get<uint32>();
2986 itemTemplate.Map = uint32(fields[115].Get<uint16>());
2987 itemTemplate.BagFamily = fields[116].Get<uint32>();
2988 itemTemplate.TotemCategory = fields[117].Get<uint32>();
2989
2990 for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
2991 {
2992 itemTemplate.Socket[i].Color = uint32(fields[118 + i * 2].Get<uint8>());
2993 itemTemplate.Socket[i].Content = fields[119 + i * 2].Get<uint32>();
2994 }
2995
2996 itemTemplate.socketBonus = fields[124].Get<uint32>();
2997 itemTemplate.GemProperties = fields[125].Get<uint32>();
2998 itemTemplate.RequiredDisenchantSkill = uint32(fields[126].Get<int16>());
2999 itemTemplate.ArmorDamageModifier = fields[127].Get<float>();
3000 itemTemplate.Duration = fields[128].Get<uint32>();
3001 itemTemplate.ItemLimitCategory = uint32(fields[129].Get<int16>());
3002 itemTemplate.HolidayId = fields[130].Get<uint32>();
3003 itemTemplate.ScriptId = GetScriptId(fields[131].Get<std::string>());
3004 itemTemplate.DisenchantID = fields[132].Get<uint32>();
3005 itemTemplate.FoodType = uint32(fields[133].Get<uint8>());
3006 itemTemplate.MinMoneyLoot = fields[134].Get<uint32>();
3007 itemTemplate.MaxMoneyLoot = fields[135].Get<uint32>();
3008 itemTemplate.FlagsCu = ItemFlagsCustom(fields[136].Get<uint32>());
3009
3010 // Checks
3011 ItemEntry const* dbcitem = sItemStore.LookupEntry(entry);
3012
3013 if (!dbcitem)
3014 {
3015 LOG_DEBUG("sql.sql", "Item (Entry: {}) does not exist in item.dbc! (not correct id?).", entry);
3016 continue;
3017 }
3018
3019 if (enforceDBCAttributes)
3020 {
3021 if (itemTemplate.Class != dbcitem->ClassID)
3022 {
3023 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Class value ({}), must be ({}).", entry, itemTemplate.Class, dbcitem->ClassID);
3024 itemTemplate.Class = dbcitem->ClassID;
3025 }
3026 if (itemTemplate.SubClass != dbcitem->SubclassID)
3027 {
3028 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Subclass value ({}) for class {}, must be ({}).", entry, itemTemplate.SubClass, itemTemplate.Class, dbcitem->SubclassID);
3029 itemTemplate.SubClass = dbcitem->SubclassID;
3030 }
3031 if (itemTemplate.SoundOverrideSubclass != dbcitem->SoundOverrideSubclassID)
3032 {
3033 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct SoundOverrideSubclass ({}), must be {}.", entry, itemTemplate.SoundOverrideSubclass, dbcitem->SoundOverrideSubclassID);
3034 itemTemplate.SoundOverrideSubclass = dbcitem->SoundOverrideSubclassID;
3035 }
3036 if (itemTemplate.Material != dbcitem->Material)
3037 {
3038 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct material ({}), must be {}.", entry, itemTemplate.Material, dbcitem->Material);
3039 itemTemplate.Material = dbcitem->Material;
3040 }
3041 if (itemTemplate.InventoryType != dbcitem->InventoryType)
3042 {
3043 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong InventoryType value ({}), must be {}.", entry, itemTemplate.InventoryType, dbcitem->InventoryType);
3044 itemTemplate.InventoryType = dbcitem->InventoryType;
3045 }
3046 if (itemTemplate.DisplayInfoID != dbcitem->DisplayInfoID)
3047 {
3048 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have a correct display id ({}), must be {}.", entry, itemTemplate.DisplayInfoID, dbcitem->DisplayInfoID);
3049 itemTemplate.DisplayInfoID = dbcitem->DisplayInfoID;
3050 }
3051 if (itemTemplate.Sheath != dbcitem->SheatheType)
3052 {
3053 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Sheath ({}), must be {}.", entry, itemTemplate.Sheath, dbcitem->SheatheType);
3054 itemTemplate.Sheath = dbcitem->SheatheType;
3055 }
3056 }
3057
3058 if (itemTemplate.Quality >= MAX_ITEM_QUALITY)
3059 {
3060 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Quality value ({})", entry, itemTemplate.Quality);
3061 itemTemplate.Quality = ITEM_QUALITY_NORMAL;
3062 }
3063
3064 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_HORDE))
3065 {
3066 if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
3067 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
3068 LOG_ERROR("sql.sql", "Item (Entry: {}) has value ({}) in `AllowableRace` races, not compatible with ITEM_FLAG2_FACTION_HORDE ({}) in Flags field, item cannot be equipped or used by these races.",
3069 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_HORDE);
3070
3071 if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
3072 LOG_ERROR("sql.sql", "Item (Entry: {}) has value ({}) in `Flags2` flags (ITEM_FLAG2_FACTION_ALLIANCE) and ITEM_FLAG2_FACTION_HORDE ({}) in Flags field, this is a wrong combination.",
3074 }
3075 else if (itemTemplate.HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
3076 {
3077 if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
3078 if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
3079 LOG_ERROR("sql.sql", "Item (Entry: {}) has value ({}) in `AllowableRace` races, not compatible with ITEM_FLAG2_FACTION_ALLIANCE ({}) in Flags field, item cannot be equipped or used by these races.",
3080 entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_ALLIANCE);
3081 }
3082
3083 if (itemTemplate.BuyCount <= 0)
3084 {
3085 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong BuyCount value ({}), set to default(1).", entry, itemTemplate.BuyCount);
3086 itemTemplate.BuyCount = 1;
3087 }
3088
3089 if (itemTemplate.RequiredSkill >= MAX_SKILL_TYPE)
3090 {
3091 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RequiredSkill value ({})", entry, itemTemplate.RequiredSkill);
3092 itemTemplate.RequiredSkill = 0;
3093 }
3094
3095 {
3096 // can be used in equip slot, as page read use in inventory, or spell casting at use
3097 bool req = itemTemplate.InventoryType != INVTYPE_NON_EQUIP || itemTemplate.PageText;
3098 if (!req)
3099 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3100 {
3101 if (itemTemplate.Spells[j].SpellId)
3102 {
3103 req = true;
3104 break;
3105 }
3106 }
3107
3108 if (req)
3109 {
3110 if (!(itemTemplate.AllowableClass & CLASSMASK_ALL_PLAYABLE))
3111 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable classes ({}) in `AllowableClass` and can't be equipped or used.", entry, itemTemplate.AllowableClass);
3112
3113 if (!(itemTemplate.AllowableRace & RACEMASK_ALL_PLAYABLE))
3114 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have any playable races ({}) in `AllowableRace` and can't be equipped or used.", entry, itemTemplate.AllowableRace);
3115 }
3116 }
3117
3118 if (itemTemplate.RequiredSpell && !sSpellMgr->GetSpellInfo(itemTemplate.RequiredSpell))
3119 {
3120 LOG_ERROR("sql.sql", "Item (Entry: {}) has a wrong (non-existing) spell in RequiredSpell ({})", entry, itemTemplate.RequiredSpell);
3121 itemTemplate.RequiredSpell = 0;
3122 }
3123
3124 if (itemTemplate.RequiredReputationRank >= MAX_REPUTATION_RANK)
3125 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong reputation rank in RequiredReputationRank ({}), item can't be used.", entry, itemTemplate.RequiredReputationRank);
3126
3127 if (itemTemplate.RequiredReputationFaction)
3128 {
3129 if (!sFactionStore.LookupEntry(itemTemplate.RequiredReputationFaction))
3130 {
3131 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) faction in RequiredReputationFaction ({})", entry, itemTemplate.RequiredReputationFaction);
3132 itemTemplate.RequiredReputationFaction = 0;
3133 }
3134
3135 if (itemTemplate.RequiredReputationRank == MIN_REPUTATION_RANK)
3136 LOG_ERROR("sql.sql", "Item (Entry: {}) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", entry);
3137 }
3138
3139 if (itemTemplate.MaxCount < -1)
3140 {
3141 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in maxcount ({}), replace by value (-1) no storing limits.", entry, itemTemplate.MaxCount);
3142 itemTemplate.MaxCount = -1;
3143 }
3144
3145 if (itemTemplate.Stackable == 0)
3146 {
3147 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong value in stackable ({}), replace by default 1.", entry, itemTemplate.Stackable);
3148 itemTemplate.Stackable = 1;
3149 }
3150 else if (itemTemplate.Stackable < -1)
3151 {
3152 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large negative in stackable ({}), replace by value (-1) no stacking limits.", entry, itemTemplate.Stackable);
3153 itemTemplate.Stackable = -1;
3154 }
3155
3156 if (itemTemplate.ContainerSlots > MAX_BAG_SIZE)
3157 {
3158 LOG_ERROR("sql.sql", "Item (Entry: {}) has too large value in ContainerSlots ({}), replace by hardcoded limit ({}).", entry, itemTemplate.ContainerSlots, MAX_BAG_SIZE);
3159 itemTemplate.ContainerSlots = MAX_BAG_SIZE;
3160 }
3161
3162 for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
3163 {
3164 // for ItemStatValue != 0
3165 if (itemTemplate.ItemStat[j].ItemStatValue && itemTemplate.ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
3166 {
3167 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (non-existing?) stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3168 itemTemplate.ItemStat[j].ItemStatType = 0;
3169 }
3170
3171 switch (itemTemplate.ItemStat[j].ItemStatType)
3172 {
3175 // Skip warning for specific items: 13113 (Feathermoon Headdress - Blizzard oversight), 34967 (test item)
3176 if (entry != 13113 && entry != 34967)
3177 LOG_WARN("sql.sql", "Item (Entry: {}) has deprecated stat_type{} ({})", entry, j + 1, itemTemplate.ItemStat[j].ItemStatType);
3178
3179 break;
3180 default:
3181 break;
3182 }
3183 }
3184
3185 for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
3186 {
3187 if (itemTemplate.Damage[j].DamageType >= MAX_SPELL_SCHOOL)
3188 {
3189 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong dmg_type{} ({})", entry, j + 1, itemTemplate.Damage[j].DamageType);
3190 itemTemplate.Damage[j].DamageType = 0;
3191 }
3192 }
3193
3194 // special format
3195 if ((itemTemplate.Spells[0].SpellId == 483) || (itemTemplate.Spells[0].SpellId == 55884))
3196 {
3197 // spell_1
3198 if (itemTemplate.Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3199 {
3200 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);
3201 itemTemplate.Spells[0].SpellId = 0;
3202 itemTemplate.Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3203 itemTemplate.Spells[1].SpellId = 0;
3204 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3205 }
3206
3207 // spell_2 have learning spell
3208 if (itemTemplate.Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3209 {
3210 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);
3211 itemTemplate.Spells[0].SpellId = 0;
3212 itemTemplate.Spells[1].SpellId = 0;
3213 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3214 }
3215 else if (!itemTemplate.Spells[1].SpellId)
3216 {
3217 LOG_ERROR("sql.sql", "Item (Entry: {}) does not have an expected spell in spellid_{} in special learning format.", entry, 1 + 1);
3218 itemTemplate.Spells[0].SpellId = 0;
3219 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3220 }
3221 else if (itemTemplate.Spells[1].SpellId != -1)
3222 {
3223 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
3224 if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
3225 {
3226 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3227 itemTemplate.Spells[0].SpellId = 0;
3228 itemTemplate.Spells[1].SpellId = 0;
3229 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3230 }
3231 // allowed only in special format
3232 else if ((itemTemplate.Spells[1].SpellId == 483) || (itemTemplate.Spells[1].SpellId == 55884))
3233 {
3234 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
3235 itemTemplate.Spells[0].SpellId = 0;
3236 itemTemplate.Spells[1].SpellId = 0;
3237 itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3238 }
3239 }
3240
3241 // spell_3*, spell_4*, spell_5* is empty
3242 for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
3243 {
3244 if (itemTemplate.Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
3245 {
3246 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3247 itemTemplate.Spells[j].SpellId = 0;
3248 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3249 }
3250 else if (itemTemplate.Spells[j].SpellId != 0)
3251 {
3252 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong spell in spellid_{} ({}) for learning special format", entry, j + 1, itemTemplate.Spells[j].SpellId);
3253 itemTemplate.Spells[j].SpellId = 0;
3254 }
3255 }
3256 }
3257 // normal spell list
3258 else
3259 {
3260 for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
3261 {
3262 if (itemTemplate.Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || itemTemplate.Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
3263 {
3264 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong item spell trigger value in spelltrigger_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellTrigger);
3265 itemTemplate.Spells[j].SpellId = 0;
3266 itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
3267 }
3268
3269 if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
3270 {
3271 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
3272 if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
3273 {
3274 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3275 itemTemplate.Spells[j].SpellId = 0;
3276 }
3277 // allowed only in special format
3278 else if ((itemTemplate.Spells[j].SpellId == 483) || (itemTemplate.Spells[j].SpellId == 55884))
3279 {
3280 LOG_ERROR("sql.sql", "Item (Entry: {}) has broken spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
3281 itemTemplate.Spells[j].SpellId = 0;
3282 }
3283 }
3284 }
3285 }
3286
3287 if (itemTemplate.Bonding >= MAX_BIND_TYPE)
3288 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Bonding value ({})", entry, itemTemplate.Bonding);
3289
3290 if (itemTemplate.PageText && !GetPageText(itemTemplate.PageText))
3291 LOG_ERROR("sql.sql", "Item (Entry: {}) has non existing first page (Id:{})", entry, itemTemplate.PageText);
3292
3293 if (itemTemplate.LockID && !sLockStore.LookupEntry(itemTemplate.LockID))
3294 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LockID ({})", entry, itemTemplate.LockID);
3295
3296 if (itemTemplate.RandomProperty)
3297 {
3298 // To be implemented later
3299 if (itemTemplate.RandomProperty == -1)
3300 itemTemplate.RandomProperty = 0;
3301
3302 else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomProperty)))
3303 {
3304 LOG_ERROR("sql.sql", "Item (Entry: {}) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty ({})", entry, itemTemplate.RandomProperty);
3305 itemTemplate.RandomProperty = 0;
3306 }
3307 }
3308
3309 if (itemTemplate.RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomSuffix)))
3310 {
3311 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong RandomSuffix ({})", entry, itemTemplate.RandomSuffix);
3312 itemTemplate.RandomSuffix = 0;
3313 }
3314
3315 if (itemTemplate.ItemSet && !sItemSetStore.LookupEntry(itemTemplate.ItemSet))
3316 {
3317 LOG_ERROR("sql.sql", "Item (Entry: {}) have wrong ItemSet ({})", entry, itemTemplate.ItemSet);
3318 itemTemplate.ItemSet = 0;
3319 }
3320
3321 if (itemTemplate.Area && !sAreaTableStore.LookupEntry(itemTemplate.Area))
3322 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Area ({})", entry, itemTemplate.Area);
3323
3324 if (itemTemplate.Map && !sMapStore.LookupEntry(itemTemplate.Map))
3325 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong Map ({})", entry, itemTemplate.Map);
3326
3327 if (itemTemplate.BagFamily)
3328 {
3329 // check bits
3330 for (uint32 j = 0; j < sizeof(itemTemplate.BagFamily) * 8; ++j)
3331 {
3332 uint32 mask = 1 << j;
3333 if ((itemTemplate.BagFamily & mask) == 0)
3334 continue;
3335
3336 ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j + 1);
3337 if (!bf)
3338 {
3339 LOG_ERROR("sql.sql", "Item (Entry: {}) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", entry);
3340 itemTemplate.BagFamily &= ~mask;
3341 continue;
3342 }
3343
3345 {
3346 CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemTemplate.ItemId);
3347 if (!ctEntry)
3348 {
3349 LOG_ERROR("sql.sql", "Item (Entry: {}) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit", entry);
3350 itemTemplate.BagFamily &= ~mask;
3351 }
3352 }
3353 }
3354 }
3355
3356 if (itemTemplate.TotemCategory && !sTotemCategoryStore.LookupEntry(itemTemplate.TotemCategory))
3357 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong TotemCategory ({})", entry, itemTemplate.TotemCategory);
3358
3359 for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
3360 {
3361 if (itemTemplate.Socket[j].Color && (itemTemplate.Socket[j].Color & SOCKET_COLOR_ALL) != itemTemplate.Socket[j].Color)
3362 {
3363 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong socketColor_{} ({})", entry, j + 1, itemTemplate.Socket[j].Color);
3364 itemTemplate.Socket[j].Color = 0;
3365 }
3366 }
3367
3368 if (itemTemplate.GemProperties && !sGemPropertiesStore.LookupEntry(itemTemplate.GemProperties))
3369 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong GemProperties ({})", entry, itemTemplate.GemProperties);
3370
3371 if (itemTemplate.FoodType >= MAX_PET_DIET)
3372 {
3373 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong FoodType value ({})", entry, itemTemplate.FoodType);
3374 itemTemplate.FoodType = 0;
3375 }
3376
3377 if (itemTemplate.ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(itemTemplate.ItemLimitCategory))
3378 {
3379 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong LimitCategory value ({})", entry, itemTemplate.ItemLimitCategory);
3380 itemTemplate.ItemLimitCategory = 0;
3381 }
3382
3383 if (itemTemplate.HolidayId && !sHolidaysStore.LookupEntry(itemTemplate.HolidayId))
3384 {
3385 LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong HolidayId value ({})", entry, itemTemplate.HolidayId);
3386 itemTemplate.HolidayId = 0;
3387 }
3388
3389 if (itemTemplate.HasFlagCu(ITEM_FLAGS_CU_DURATION_REAL_TIME) && !itemTemplate.Duration)
3390 {
3391 LOG_ERROR("sql.sql", "Item (Entry {}) has flag ITEM_FLAGS_CU_DURATION_REAL_TIME but it does not have duration limit", entry);
3392 itemTemplate.FlagsCu = static_cast<ItemFlagsCustom>(static_cast<uint32>(itemTemplate.FlagsCu) & ~ITEM_FLAGS_CU_DURATION_REAL_TIME);
3393 }
3394
3395 // Set after checks to ensure valid item quality
3396 itemTemplate.BuyPrice *= sWorld->getRate(qualityToBuyValueConfig[itemTemplate.Quality]);
3397 itemTemplate.SellPrice *= sWorld->getRate(qualityToSellValueConfig[itemTemplate.Quality]);
3398
3399 // Fill categories map
3400 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
3401 if (itemTemplate.Spells[i].SpellId && itemTemplate.Spells[i].SpellCategory && itemTemplate.Spells[i].SpellCategoryCooldown)
3402 {
3403 SpellCategoryStore::iterator ct = sSpellsByCategoryStore.find(itemTemplate.Spells[i].SpellCategory);
3404 if (ct != sSpellsByCategoryStore.end())
3405 {
3406 ct->second.emplace(true, itemTemplate.Spells[i].SpellId);
3407 }
3408 else
3409 sSpellsByCategoryStore[itemTemplate.Spells[i].SpellCategory].emplace(true, itemTemplate.Spells[i].SpellId);
3410 }
3411
3412 ++count;
3413 } while (result->NextRow());
3414
3415 // pussywizard:
3416 {
3417 uint32 max = 0;
3418 for (ItemTemplateContainer::const_iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3419 if (itr->first > max)
3420 max = itr->first;
3421 if (max)
3422 {
3423 _itemTemplateStoreFast.clear();
3424 _itemTemplateStoreFast.resize(max + 1, nullptr);
3425 for (ItemTemplateContainer::iterator itr = _itemTemplateStore.begin(); itr != _itemTemplateStore.end(); ++itr)
3426 _itemTemplateStoreFast[itr->first] = &(itr->second);
3427 }
3428 }
3429
3430 // Check if item templates for DBC referenced character start outfit are present
3431 std::set<uint32> notFoundOutfit;
3432 for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i)
3433 {
3434 CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i);
3435 if (!entry)
3436 continue;
3437
3438 for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
3439 {
3440 if (entry->ItemId[j] <= 0)
3441 continue;
3442
3443 uint32 item_id = entry->ItemId[j];
3444
3445 if (!GetItemTemplate(item_id))
3446 notFoundOutfit.insert(item_id);
3447 }
3448 }
3449
3450 for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr)
3451 LOG_ERROR("sql.sql", "Item (Entry: {}) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr);
3452
3453 LOG_INFO("server.loading", ">> Loaded {} Item Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3454 LOG_INFO("server.loading", " ");
3455}
#define MAX_BAG_SIZE
Definition Bag.h:22
DBCStorage< ItemLimitCategoryEntry > sItemLimitCategoryStore(ItemLimitCategoryEntryfmt)
SpellCategoryStore sSpellsByCategoryStore
Definition DBCStores.cpp:152
DBCStorage< CharStartOutfitEntry > sCharStartOutfitStore(CharStartOutfitEntryfmt)
DBCStorage< LockEntry > sLockStore(LockEntryfmt)
DBCStorage< ItemBagFamilyEntry > sItemBagFamilyStore(ItemBagFamilyfmt)
DBCStorage< HolidaysEntry > sHolidaysStore(Holidaysfmt)
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< TotemCategoryEntry > sTotemCategoryStore(TotemCategoryEntryfmt)
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
DBCStorage< CurrencyTypesEntry > sCurrencyTypesStore(CurrencyTypesfmt)
#define MAX_OUTFIT_ITEMS
Definition DBCStructure.h:617
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_SPELL
Definition DisableMgr.h:28
uint32 GetItemEnchantMod(int32 entry)
Definition ItemEnchantmentMgr.cpp:84
ItemFlags2
Definition ItemTemplate.h:182
@ ITEM_FLAG2_FACTION_HORDE
Definition ItemTemplate.h:183
@ ITEM_FLAG2_FACTION_ALLIANCE
Definition ItemTemplate.h:184
@ ITEM_SPELLTRIGGER_LEARN_SPELL_ID
Definition ItemTemplate.h:88
@ ITEM_SPELLTRIGGER_ON_USE
Definition ItemTemplate.h:77
@ BAG_FAMILY_MASK_CURRENCY_TOKENS
Definition ItemTemplate.h:240
ItemFlags
Definition ItemTemplate.h:146
@ ITEM_MOD_SPELL_HEALING_DONE
Definition ItemTemplate.h:63
@ ITEM_MOD_SPELL_DAMAGE_DONE
Definition ItemTemplate.h:64
#define MAX_ITEM_PROTO_SOCKETS
Definition ItemTemplate.h:614
#define MAX_ITEM_PROTO_DAMAGES
Definition ItemTemplate.h:613
#define MAX_ITEM_PROTO_SPELLS
Definition ItemTemplate.h:615
ItemFlagsCustom
Definition ItemTemplate.h:218
@ ITEM_FLAGS_CU_DURATION_REAL_TIME
Definition ItemTemplate.h:219
#define SOCKET_COLOR_ALL
Definition ItemTemplate.h:252
#define MAX_BIND_TYPE
Definition ItemTemplate.h:103
#define MAX_ITEM_SPELLTRIGGER
Definition ItemTemplate.h:91
#define MAX_ITEM_PROTO_STATS
Definition ItemTemplate.h:616
#define MAX_ITEM_MOD
Definition ItemTemplate.h:73
ServerConfigs const qualityToSellValueConfig[MAX_ITEM_QUALITY]
Definition ObjectMgr.cpp:2828
ServerConfigs const qualityToBuyValueConfig[MAX_ITEM_QUALITY]
Definition ObjectMgr.cpp:2816
#define MAX_REPUTATION_RANK
Definition SharedDefines.h:256
#define MIN_REPUTATION_RANK
Definition SharedDefines.h:255
#define MAX_PET_DIET
Definition SharedDefines.h:3471
@ ITEM_QUALITY_NORMAL
Definition SharedDefines.h:341
#define MAX_ITEM_QUALITY
Definition SharedDefines.h:350
#define MAX_SKILL_TYPE
Definition SharedDefines.h:3258
@ ALLIANCE
Definition SharedDefines.h:779
@ HORDE
Definition SharedDefines.h:778
#define CLASSMASK_ALL_PLAYABLE
Definition SharedDefines.h:157
#define RACEMASK_ALL_PLAYABLE
Definition SharedDefines.h:97
@ CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES
Definition WorldConfig.h:98
Definition DBCStructure.h:620
int32 ItemId[MAX_OUTFIT_ITEMS]
Definition DBCStructure.h:626
Definition DBCStructure.h:835
Definition DBCStructure.h:907
Definition DBCStructure.h:1153
int32 SoundOverrideSubclassID
Definition DBCStructure.h:1145
uint32 SheatheType
Definition DBCStructure.h:1149
uint32 DisplayInfoID
Definition DBCStructure.h:1147
uint32 ClassID
Definition DBCStructure.h:1143
int32 Material
Definition DBCStructure.h:1146
uint32 SubclassID
Definition DBCStructure.h:1144
uint32 ItemId
Definition ItemTemplate.h:620

References _itemTemplateStore, _itemTemplateStoreFast, ALLIANCE, BAG_FAMILY_MASK_CURRENCY_TOKENS, ItemEntry::ClassID, CLASSMASK_ALL_PLAYABLE, CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES, DISABLE_TYPE_SPELL, ItemEntry::DisplayInfoID, Field::Get(), GetItemEnchantMod(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), GetPageText(), GetScriptId(), HORDE, ItemEntry::InventoryType, INVTYPE_NON_EQUIP, ITEM_FLAG2_FACTION_ALLIANCE, ITEM_FLAG2_FACTION_HORDE, ITEM_FLAGS_CU_DURATION_REAL_TIME, ITEM_MOD_SPELL_DAMAGE_DONE, ITEM_MOD_SPELL_HEALING_DONE, ITEM_QUALITY_NORMAL, ITEM_SPELLTRIGGER_LEARN_SPELL_ID, ITEM_SPELLTRIGGER_ON_USE, ItemTemplate::ItemId, CharStartOutfitEntry::ItemId, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARN, ItemEntry::Material, MAX_BAG_SIZE, MAX_BIND_TYPE, MAX_ITEM_MOD, MAX_ITEM_PROTO_DAMAGES, MAX_ITEM_PROTO_SOCKETS, MAX_ITEM_PROTO_SPELLS, MAX_ITEM_PROTO_STATS, MAX_ITEM_QUALITY, MAX_ITEM_SPELLTRIGGER, MAX_OUTFIT_ITEMS, MAX_PET_DIET, MAX_REPUTATION_RANK, MAX_SKILL_TYPE, MAX_SPELL_SCHOOL, MIN_REPUTATION_RANK, qualityToBuyValueConfig, qualityToSellValueConfig, RACEMASK_ALL_PLAYABLE, sAreaTableStore, sCharStartOutfitStore, sCurrencyTypesStore, sDisableMgr, sFactionStore, sGemPropertiesStore, ItemEntry::SheatheType, sHolidaysStore, sItemBagFamilyStore, sItemLimitCategoryStore, sItemRandomPropertiesStore, sItemRandomSuffixStore, sItemSetStore, sItemStore, sLockStore, sMapStore, SOCKET_COLOR_ALL, ItemEntry::SoundOverrideSubclassID, sSpellMgr, sSpellsByCategoryStore, sTotemCategoryStore, ItemEntry::SubclassID, sWorld, and WorldDatabase.

◆ LoadLinkedRespawn()

void ObjectMgr::LoadLinkedRespawn ( )
1903{
1904 uint32 oldMSTime = getMSTime();
1905
1906 _linkedRespawnStore.clear();
1907 // 0 1 2
1908 QueryResult result = WorldDatabase.Query("SELECT guid, linkedGuid, linkType FROM linked_respawn ORDER BY guid ASC");
1909
1910 if (!result)
1911 {
1912 LOG_WARN("server.loading", ">> Loaded 0 linked respawns. DB table `linked_respawn` is empty.");
1913 LOG_INFO("server.loading", " ");
1914 return;
1915 }
1916
1917 do
1918 {
1919 Field* fields = result->Fetch();
1920
1921 ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
1922 ObjectGuid::LowType linkedGuidLow = fields[1].Get<uint32>();
1923 uint8 linkType = fields[2].Get<uint8>();
1924
1925 ObjectGuid guid, linkedGuid;
1926 bool error = false;
1927 switch (linkType)
1928 {
1930 {
1931 const CreatureData* slave = GetCreatureData(guidLow);
1932 if (!slave)
1933 {
1934 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1935 error = true;
1936 break;
1937 }
1938
1939 const CreatureData* master = GetCreatureData(linkedGuidLow);
1940 if (!master)
1941 {
1942 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
1943 error = true;
1944 break;
1945 }
1946
1947 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1948 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1949 {
1950 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1951 error = true;
1952 break;
1953 }
1954
1955 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1956 {
1957 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1958 error = true;
1959 break;
1960 }
1961
1962 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
1963 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
1964 break;
1965 }
1966 case CREATURE_TO_GO:
1967 {
1968 const CreatureData* slave = GetCreatureData(guidLow);
1969 if (!slave)
1970 {
1971 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) {} not found in creature table", guidLow);
1972 error = true;
1973 break;
1974 }
1975
1976 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
1977 if (!master)
1978 {
1979 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
1980 error = true;
1981 break;
1982 }
1983
1984 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
1985 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
1986 {
1987 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
1988 error = true;
1989 break;
1990 }
1991
1992 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
1993 {
1994 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
1995 error = true;
1996 break;
1997 }
1998
1999 guid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, guidLow);
2000 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
2001 break;
2002 }
2003 case GO_TO_GO:
2004 {
2005 const GameObjectData* slave = GetGameObjectData(guidLow);
2006 if (!slave)
2007 {
2008 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
2009 error = true;
2010 break;
2011 }
2012
2013 const GameObjectData* master = GetGameObjectData(linkedGuidLow);
2014 if (!master)
2015 {
2016 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (linkedGuid) {} not found in gameobject table", linkedGuidLow);
2017 error = true;
2018 break;
2019 }
2020
2021 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2022 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2023 {
2024 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2025 error = true;
2026 break;
2027 }
2028
2029 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2030 {
2031 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Gameobject '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2032 error = true;
2033 break;
2034 }
2035
2036 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2037 linkedGuid = ObjectGuid::Create<HighGuid::GameObject>(master->id, linkedGuidLow);
2038 break;
2039 }
2040 case GO_TO_CREATURE:
2041 {
2042 const GameObjectData* slave = GetGameObjectData(guidLow);
2043 if (!slave)
2044 {
2045 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject (guid) {} not found in gameobject table", guidLow);
2046 error = true;
2047 break;
2048 }
2049
2050 const CreatureData* master = GetCreatureData(linkedGuidLow);
2051 if (!master)
2052 {
2053 LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) {} not found in creature table", linkedGuidLow);
2054 error = true;
2055 break;
2056 }
2057
2058 MapEntry const* const map = sMapStore.LookupEntry(master->mapid);
2059 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2060 {
2061 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2062 error = true;
2063 break;
2064 }
2065
2066 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2067 {
2068 LOG_ERROR("sql.sql", "LinkedRespawn: Gameobject '{}' linking to Creature '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2069 error = true;
2070 break;
2071 }
2072
2073 guid = ObjectGuid::Create<HighGuid::GameObject>(slave->id, guidLow);
2074 linkedGuid = ObjectGuid::Create<HighGuid::Unit>(master->id1, linkedGuidLow);
2075 break;
2076 }
2077 }
2078
2079 if (!error)
2080 _linkedRespawnStore[guid] = linkedGuid;
2081 } while (result->NextRow());
2082
2083 LOG_INFO("server.loading", ">> Loaded {} Linked Respawns In {} ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime));
2084 LOG_INFO("server.loading", " ");
2085}
Definition ObjectGuid.h:118
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 ( )
9224{
9225 uint32 oldMSTime = getMSTime();
9226
9227 _mailLevelRewardStore.clear(); // for reload case
9228
9229 // 0 1 2 3
9230 QueryResult result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
9231
9232 if (!result)
9233 {
9234 LOG_WARN("server.loading", ">> Loaded 0 level dependent mail rewards. DB table `mail_level_reward` is empty.");
9235 LOG_INFO("server.loading", " ");
9236 return;
9237 }
9238
9239 uint32 count = 0;
9240
9241 do
9242 {
9243 Field* fields = result->Fetch();
9244
9245 uint8 level = fields[0].Get<uint8>();
9246 uint32 raceMask = fields[1].Get<uint32>();
9247 uint32 mailTemplateId = fields[2].Get<uint32>();
9248 uint32 senderEntry = fields[3].Get<uint32>();
9249
9250 if (level > MAX_LEVEL)
9251 {
9252 LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level {} that more supported by client ({}), ignoring.", level, MAX_LEVEL);
9253 continue;
9254 }
9255
9256 if (!(raceMask & RACEMASK_ALL_PLAYABLE))
9257 {
9258 LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask ({}) for level {} that not include any player races, ignoring.", raceMask, level);
9259 continue;
9260 }
9261
9262 if (!sMailTemplateStore.LookupEntry(mailTemplateId))
9263 {
9264 LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId ({}) for level {} that invalid not include any player races, ignoring.", mailTemplateId, level);
9265 continue;
9266 }
9267
9268 if (!GetCreatureTemplate(senderEntry))
9269 {
9270 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);
9271 continue;
9272 }
9273
9274 _mailLevelRewardStore[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry));
9275
9276 ++count;
9277 } while (result->NextRow());
9278
9279 LOG_INFO("server.loading", ">> Loaded {} Level Dependent Mail Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9280 LOG_INFO("server.loading", " ");
9281}
#define MAX_LEVEL
Definition DBCEnums.h:39
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
Definition ObjectMgr.h:544

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

◆ LoadModuleStrings()

bool ObjectMgr::LoadModuleStrings ( )
8803{
8804 uint32 oldMSTime = getMSTime();
8805
8806 _moduleStringStore.clear(); // for reload case
8807 QueryResult result = WorldDatabase.Query("SELECT module, id, string FROM module_string");
8808 if (!result)
8809 {
8810 LOG_WARN("server.loading", ">> Loaded 0 module strings. DB table `module_string` is empty.");
8811 LOG_INFO("server.loading", " ");
8812 return false;
8813 }
8814
8815 do
8816 {
8817 Field* fields = result->Fetch();
8818
8819 std::string module = fields[0].Get<std::string>();
8820 uint32 id = fields[1].Get<uint32>();
8821
8822 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
8823 ModuleString& data = _moduleStringStore[pairKey];
8824
8825 AddLocaleString(fields[2].Get<std::string>(), LOCALE_enUS, data.Content);
8826 } while (result->NextRow());
8827
8828 LOG_INFO("server.loading", ">> Loaded {} Module Strings in {} ms", _moduleStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
8829 LOG_INFO("server.loading", " ");
8830
8831 return true;
8832}

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

◆ LoadModuleStringsLocale()

bool ObjectMgr::LoadModuleStringsLocale ( )
8835{
8836 uint32 oldMSTime = getMSTime();
8837
8838 QueryResult result = WorldDatabase.Query("SELECT module, id, locale, string FROM module_string_locale");
8839 if (!result)
8840 {
8841 LOG_WARN("server.loading", ">> Loaded 0 module strings locale. DB table `module_string_locale` is empty.");
8842 LOG_INFO("server.loading", " ");
8843 return false;
8844 }
8845
8846 uint32 localeCount = 0;
8847 do
8848 {
8849 Field* fields = result->Fetch();
8850
8851 std::string module = fields[0].Get<std::string>();
8852 uint32 id = fields[1].Get<uint32>();
8853
8854 std::pair<std::string, uint32> pairKey = std::make_pair(module, id);
8855 ModuleString& data = _moduleStringStore[pairKey];
8856
8857 ModuleStringContainer::iterator ms = _moduleStringStore.find(pairKey);
8858 if (ms == _moduleStringStore.end())
8859 {
8860 LOG_ERROR("sql.sql", "ModuleString (Module: {} Id: {}) found in table `module_string_locale` but does not exist in `module_string`. Skipped!", module, id);
8861 continue;
8862 }
8863
8864 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
8865 if (locale == LOCALE_enUS)
8866 continue;
8867
8868 AddLocaleString(fields[3].Get<std::string>(), locale, data.Content);
8869 localeCount++;
8870 } while (result->NextRow());
8871
8872 LOG_INFO("server.loading", ">> Loaded {} Module Strings Locales in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
8873 LOG_INFO("server.loading", " ");
8874
8875 return true;
8876}

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

◆ LoadNPCSpellClickSpells()

void ObjectMgr::LoadNPCSpellClickSpells ( )
8156{
8157 uint32 oldMSTime = getMSTime();
8158
8159 _spellClickInfoStore.clear();
8160 // 0 1 2 3
8161 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells");
8162
8163 if (!result)
8164 {
8165 LOG_WARN("server.loading", ">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
8166 LOG_INFO("server.loading", " ");
8167 return;
8168 }
8169
8170 uint32 count = 0;
8171
8172 do
8173 {
8174 Field* fields = result->Fetch();
8175
8176 uint32 npc_entry = fields[0].Get<uint32>();
8177 CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
8178 if (!cInfo)
8179 {
8180 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown creature_template {}. Skipping entry.", npc_entry);
8181 continue;
8182 }
8183
8184 uint32 spellid = fields[1].Get<uint32>();
8185 SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
8186 if (!spellinfo)
8187 {
8188 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown spellid {}. Skipping entry.", spellid);
8189 continue;
8190 }
8191
8192 uint8 userType = fields[3].Get<uint16>();
8193 if (userType >= SPELL_CLICK_USER_MAX)
8194 LOG_ERROR("sql.sql", "Table npc_spellclick_spells references unknown user type {}. Skipping entry.", uint32(userType));
8195
8196 uint8 castFlags = fields[2].Get<uint8>();
8197 SpellClickInfo info;
8198 info.spellId = spellid;
8199 info.castFlags = castFlags;
8200 info.userType = SpellClickUserTypes(userType);
8201 _spellClickInfoStore.insert(SpellClickInfoContainer::value_type(npc_entry, info));
8202
8203 ++count;
8204 } while (result->NextRow());
8205
8206 // all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
8207 // NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
8209 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
8210 {
8211 if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(itr->second.Entry) == _spellClickInfoStore.end())
8212 {
8213 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);
8214 const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
8215 }
8216 }
8217
8218 LOG_INFO("server.loading", ">> Loaded {} Spellclick Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8219 LOG_INFO("server.loading", " ");
8220}
SpellClickUserTypes
Definition SharedDefines.h:691
@ SPELL_CLICK_USER_MAX
Definition SharedDefines.h:696
@ UNIT_NPC_FLAG_SPELLCLICK
Definition UnitDefines.h:343
Definition ObjectMgr.h:399
uint32 spellId
Definition ObjectMgr.h:400

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

◆ LoadNpcTextLocales()

void ObjectMgr::LoadNpcTextLocales ( )
6245{
6246 uint32 oldMSTime = getMSTime();
6247
6248 _npcTextLocaleStore.clear(); // need for reload case
6249
6250 QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
6251 // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
6252 "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 "
6253 "FROM npc_text_locale");
6254
6255 if (!result)
6256 return;
6257
6258 do
6259 {
6260 Field* fields = result->Fetch();
6261
6262 uint32 ID = fields[0].Get<uint32>();
6263
6264 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6265 if (locale == LOCALE_enUS)
6266 continue;
6267
6269 for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
6270 {
6271 AddLocaleString(fields[2 + i * 2].Get<std::string>(), locale, data.Text_0[i]);
6272 AddLocaleString(fields[3 + i * 2].Get<std::string>(), locale, data.Text_1[i]);
6273 }
6274 } while (result->NextRow());
6275
6276 LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale Strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6277}
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 ( )
5992{
5993 uint32 oldMSTime = getMSTime();
5994
5995 _pageTextLocaleStore.clear(); // need for reload case
5996
5997 // 0 1 2
5998 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
5999
6000 if (!result)
6001 {
6002 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text_locale` is empty!");
6003 LOG_INFO("server.loading", " ");
6004 return;
6005 }
6006
6007 do
6008 {
6009 Field* fields = result->Fetch();
6010
6011 uint32 ID = fields[0].Get<uint32>();
6012
6013 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
6014 if (locale == LOCALE_enUS)
6015 continue;
6016
6018 AddLocaleString(fields[2].Get<std::string>(), locale, data.Text);
6019 } while (result->NextRow());
6020
6021 LOG_INFO("server.loading", ">> Loaded {} Page Text Locale Strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6022}
Definition NPCHandler.h:50
std::vector< std::string > Text
Definition NPCHandler.h:51

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

◆ LoadPageTexts()

void ObjectMgr::LoadPageTexts ( )
5942{
5943 uint32 oldMSTime = getMSTime();
5944
5945 // 0 1 2
5946 QueryResult result = WorldDatabase.Query("SELECT ID, Text, NextPageID FROM page_text");
5947
5948 if (!result)
5949 {
5950 LOG_WARN("server.loading", ">> Loaded 0 page texts. DB table `page_text` is empty!");
5951 LOG_INFO("server.loading", " ");
5952 return;
5953 }
5954
5955 uint32 count = 0;
5956 do
5957 {
5958 Field* fields = result->Fetch();
5959
5960 PageText& pageText = _pageTextStore[fields[0].Get<uint32>()];
5961
5962 pageText.Text = fields[1].Get<std::string>();
5963 pageText.NextPage = fields[2].Get<uint32>();
5964
5965 ++count;
5966 } while (result->NextRow());
5967
5968 for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
5969 {
5970 if (itr->second.NextPage)
5971 {
5972 PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
5973 if (itr2 == _pageTextStore.end())
5974 LOG_ERROR("sql.sql", "Page text (Id: {}) has not existing next page (Id: {})", itr->first, itr->second.NextPage);
5975 }
5976 }
5977
5978 LOG_INFO("server.loading", ">> Loaded {} Page Texts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5979 LOG_INFO("server.loading", " ");
5980}
Definition ObjectMgr.h:58
std::string Text
Definition ObjectMgr.h:59
uint32 NextPage
Definition ObjectMgr.h:60

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

◆ LoadPetLevelInfo()

void ObjectMgr::LoadPetLevelInfo ( )
3731{
3732 uint32 oldMSTime = getMSTime();
3733
3734 // 0 1 2 3 4 5 6 7 8 9 10 11
3735 QueryResult result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor, min_dmg, max_dmg FROM pet_levelstats");
3736
3737 if (!result)
3738 {
3739 LOG_WARN("server.loading", ">> Loaded 0 level pet stats definitions. DB table `pet_levelstats` is empty.");
3740 LOG_INFO("server.loading", " ");
3741 return;
3742 }
3743
3744 uint32 count = 0;
3745
3746 do
3747 {
3748 Field* fields = result->Fetch();
3749
3750 uint32 creature_id = fields[0].Get<uint32>();
3751 if (!GetCreatureTemplate(creature_id))
3752 {
3753 LOG_ERROR("sql.sql", "Wrong creature id {} in `pet_levelstats` table, ignoring.", creature_id);
3754 continue;
3755 }
3756
3757 uint32 current_level = fields[1].Get<uint8>();
3758 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
3759 {
3760 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
3761 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
3762 else
3763 {
3764 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `pet_levelstats` table, ignoring.", current_level);
3765 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
3766 }
3767 continue;
3768 }
3769 else if (current_level < 1)
3770 {
3771 LOG_ERROR("sql.sql", "Wrong (<1) level {} in `pet_levelstats` table, ignoring.", current_level);
3772 continue;
3773 }
3774
3775 PetLevelInfo*& pInfoMapEntry = _petInfoStore[creature_id];
3776
3777 if (!pInfoMapEntry)
3778 pInfoMapEntry = new PetLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
3779
3780 // data for level 1 stored in [0] array element, ...
3781 PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
3782
3783 pLevelInfo->health = fields[2].Get<uint32>();
3784 pLevelInfo->mana = fields[3].Get<uint32>();
3785 pLevelInfo->armor = fields[9].Get<uint32>();
3786 pLevelInfo->min_dmg = fields[10].Get<uint32>();
3787 pLevelInfo->max_dmg = fields[11].Get<uint32>();
3788 for (uint8 i = 0; i < MAX_STATS; i++)
3789 {
3790 pLevelInfo->stats[i] = fields[i + 4].Get<uint32>();
3791 }
3792
3793 ++count;
3794 } while (result->NextRow());
3795
3796 // Fill gaps and check integrity
3797 for (PetLevelInfoContainer::iterator itr = _petInfoStore.begin(); itr != _petInfoStore.end(); ++itr)
3798 {
3799 PetLevelInfo* pInfo = itr->second;
3800
3801 // fatal error if no level 1 data
3802 if (!pInfo || pInfo[0].health == 0)
3803 {
3804 LOG_ERROR("sql.sql", "Creature {} does not have pet stats data for Level 1!", itr->first);
3805 exit(1);
3806 }
3807
3808 // fill level gaps
3809 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
3810 {
3811 if (pInfo[level].health == 0)
3812 {
3813 LOG_ERROR("sql.sql", "Creature {} has no data for Level {} pet stats data, using data of Level {}.", itr->first, level + 1, level);
3814 pInfo[level] = pInfo[level - 1];
3815 }
3816 }
3817 }
3818
3819 LOG_INFO("server.loading", ">> Loaded {} Level Pet Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3820 LOG_INFO("server.loading", " ");
3821}
#define STRONG_MAX_LEVEL
Definition DBCEnums.h:43
#define MAX_STATS
Definition SharedDefines.h:276
Definition ObjectMgr.h:529
uint32 max_dmg
Definition ObjectMgr.h:540
uint32 mana
Definition ObjectMgr.h:537
uint32 min_dmg
Definition ObjectMgr.h:539
uint32 health
Definition ObjectMgr.h:536
std::array< uint32, MAX_STATS > stats
Definition ObjectMgr.h:535
uint32 armor
Definition ObjectMgr.h:538

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

◆ LoadPetNames()

void ObjectMgr::LoadPetNames ( )
7662{
7663 uint32 oldMSTime = getMSTime();
7664 // 0 1 2
7665 QueryResult result = WorldDatabase.Query("SELECT word, entry, half FROM pet_name_generation");
7666
7667 if (!result)
7668 {
7669 LOG_WARN("server.loading", ">> Loaded 0 pet name parts. DB table `pet_name_generation` is empty!");
7670 LOG_INFO("server.loading", " ");
7671 return;
7672 }
7673
7674 uint32 count = 0;
7675
7676 do
7677 {
7678 Field* fields = result->Fetch();
7679 std::string word = fields[0].Get<std::string>();
7680 uint32 entry = fields[1].Get<uint32>();
7681 bool half = fields[2].Get<bool>();
7682 if (half)
7683 _petHalfName1[entry].push_back(word);
7684 else
7685 _petHalfName0[entry].push_back(word);
7686 ++count;
7687 } while (result->NextRow());
7688
7689 LOG_INFO("server.loading", ">> Loaded {} Pet Name Parts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7690 LOG_INFO("server.loading", " ");
7691}

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

◆ LoadPetNamesLocales()

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

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

◆ LoadPetNumber()

void ObjectMgr::LoadPetNumber ( )
7694{
7695 uint32 oldMSTime = getMSTime();
7696
7697 QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
7698 if (result)
7699 {
7700 Field* fields = result->Fetch();
7701 _hiPetNumber = fields[0].Get<uint32>() + 1;
7702 }
7703
7704 LOG_INFO("server.loading", ">> Loaded The Max Pet Number: {} in {} ms", _hiPetNumber - 1, GetMSTimeDiffToNow(oldMSTime));
7705 LOG_INFO("server.loading", " ");
7706}

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

◆ LoadPlayerInfo()

void ObjectMgr::LoadPlayerInfo ( )
3870{
3871 // Load playercreate
3872 {
3873 uint32 oldMSTime = getMSTime();
3874 // 0 1 2 3 4 5 6
3875 QueryResult result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
3876
3877 if (!result)
3878 {
3879 LOG_INFO("server.loading", " ");
3880 LOG_WARN("server.loading", ">> Loaded 0 player create definitions. DB table `playercreateinfo` is empty.");
3881 exit(1);
3882 }
3883 else
3884 {
3885 uint32 count = 0;
3886
3887 do
3888 {
3889 Field* fields = result->Fetch();
3890
3891 uint32 current_race = fields[0].Get<uint8>();
3892 uint32 current_class = fields[1].Get<uint8>();
3893 uint32 mapId = fields[2].Get<uint16>();
3894 uint32 areaId = fields[3].Get<uint32>(); // zone
3895 float positionX = fields[4].Get<float>();
3896 float positionY = fields[5].Get<float>();
3897 float positionZ = fields[6].Get<float>();
3898 float orientation = fields[7].Get<float>();
3899
3900 if (current_race >= MAX_RACES)
3901 {
3902 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3903 continue;
3904 }
3905
3906 ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
3907 if (!rEntry)
3908 {
3909 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo` table, ignoring.", current_race);
3910 continue;
3911 }
3912
3913 if (current_class >= MAX_CLASSES)
3914 {
3915 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3916 continue;
3917 }
3918
3919 if (!sChrClassesStore.LookupEntry(current_class))
3920 {
3921 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo` table, ignoring.", current_class);
3922 continue;
3923 }
3924
3925 // accept DB data only for valid position (and non instanceable)
3926 if (!MapMgr::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation))
3927 {
3928 LOG_ERROR("sql.sql", "Wrong home position for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3929 continue;
3930 }
3931
3932 if (sMapStore.LookupEntry(mapId)->Instanceable())
3933 {
3934 LOG_ERROR("sql.sql", "Home position in instanceable map for class {} race {} pair in `playercreateinfo` table, ignoring.", current_class, current_race);
3935 continue;
3936 }
3937
3938 PlayerInfo* info = new PlayerInfo();
3939 info->mapId = mapId;
3940 info->areaId = areaId;
3941 info->positionX = positionX;
3942 info->positionY = positionY;
3943 info->positionZ = positionZ;
3944 info->orientation = orientation;
3945 info->displayId_m = rEntry->model_m;
3946 info->displayId_f = rEntry->model_f;
3947 _playerInfo[current_race][current_class] = info;
3948
3949 ++count;
3950 } while (result->NextRow());
3951
3952 LOG_INFO("server.loading", ">> Loaded {} Player Create Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3953 LOG_INFO("server.loading", " ");
3954 }
3955 }
3956
3957 // Load playercreate items
3958 LOG_INFO("server.loading", "Loading Player Create Items Data...");
3959 {
3960 uint32 oldMSTime = getMSTime();
3961 // 0 1 2 3
3962 QueryResult result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
3963
3964 if (!result)
3965 {
3966 LOG_WARN("server.loading", ">> Loaded 0 Custom Player Create Items. DB Table `playercreateinfo_item` Is Empty.");
3967 LOG_INFO("server.loading", " ");
3968 }
3969 else
3970 {
3971 uint32 count = 0;
3972
3973 do
3974 {
3975 Field* fields = result->Fetch();
3976
3977 uint32 current_race = fields[0].Get<uint8>();
3978 if (current_race >= MAX_RACES)
3979 {
3980 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_item` table, ignoring.", current_race);
3981 continue;
3982 }
3983
3984 uint32 current_class = fields[1].Get<uint8>();
3985 if (current_class >= MAX_CLASSES)
3986 {
3987 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_item` table, ignoring.", current_class);
3988 continue;
3989 }
3990
3991 uint32 item_id = fields[2].Get<uint32>();
3992
3993 if (!GetItemTemplate(item_id))
3994 {
3995 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);
3996 continue;
3997 }
3998
3999 int32 amount = fields[3].Get<int32>();
4000
4001 if (!amount)
4002 {
4003 LOG_ERROR("sql.sql", "Item id {} (class {} race {}) have amount == 0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class);
4004 continue;
4005 }
4006
4007 if (!current_race || !current_class)
4008 {
4009 uint32 min_race = current_race ? current_race : 1;
4010 uint32 max_race = current_race ? current_race + 1 : MAX_RACES;
4011 uint32 min_class = current_class ? current_class : 1;
4012 uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
4013 for (uint32 r = min_race; r < max_race; ++r)
4014 for (uint32 c = min_class; c < max_class; ++c)
4015 PlayerCreateInfoAddItemHelper(r, c, item_id, amount);
4016 }
4017 else
4018 PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount);
4019
4020 ++count;
4021 } while (result->NextRow());
4022
4023 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Items in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4024 LOG_INFO("server.loading", " ");
4025 }
4026 }
4027
4028 // Load playercreate skills
4029 LOG_INFO("server.loading", "Loading Player Create Skill Data...");
4030 {
4031 uint32 oldMSTime = getMSTime();
4032
4033 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, skill, `rank` FROM playercreateinfo_skills");
4034
4035 if (!result)
4036 {
4037 LOG_WARN("server.loading", ">> Loaded 0 Player Create Skills. DB Table `playercreateinfo_skills` Is Empty.");
4038 }
4039 else
4040 {
4041 uint32 count = 0;
4042
4043 do
4044 {
4045 Field* fields = result->Fetch();
4046 uint32 raceMask = fields[0].Get<uint32>();
4047 uint32 classMask = fields[1].Get<uint32>();
4049 skill.SkillId = fields[2].Get<uint16>();
4050 skill.Rank = fields[3].Get<uint16>();
4051
4052 if (skill.Rank >= MAX_SKILL_STEP)
4053 {
4054 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);
4055 continue;
4056 }
4057
4058 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
4059 {
4060 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_skills` table, ignoring.", raceMask);
4061 continue;
4062 }
4063
4064 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4065 {
4066 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_skills` table, ignoring.", classMask);
4067 continue;
4068 }
4069
4070 if (!sSkillLineStore.LookupEntry(skill.SkillId))
4071 {
4072 LOG_ERROR("sql.sql", "Wrong skill id {} in `playercreateinfo_skills` table, ignoring.", skill.SkillId);
4073 continue;
4074 }
4075
4076 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
4077 {
4078 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4079 {
4080 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4081 {
4082 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4083 {
4084 if (!GetSkillRaceClassInfo(skill.SkillId, raceIndex, classIndex))
4085 continue;
4086
4087 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4088 {
4089 info->skills.push_back(skill);
4090 ++count;
4091 }
4092 }
4093 }
4094 }
4095 }
4096 } while (result->NextRow());
4097
4098 LOG_INFO("server.loading", ">> Loaded {} Player Create Skills in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4099 LOG_INFO("server.loading", " ");
4100 }
4101 }
4102
4103 // Load playercreate spells
4104 LOG_INFO("server.loading", "Loading Player Create Spell Data...");
4105 {
4106 uint32 oldMSTime = getMSTime();
4107
4108 QueryResult result = WorldDatabase.Query("SELECT racemask, classmask, Spell FROM playercreateinfo_spell_custom");
4109
4110 if (!result)
4111 {
4112 LOG_WARN("server.loading", ">> Loaded 0 player create spells. DB table `playercreateinfo_spell_custom` is empty.");
4113 }
4114 else
4115 {
4116 uint32 count = 0;
4117
4118 do
4119 {
4120 Field* fields = result->Fetch();
4121 uint32 raceMask = fields[0].Get<uint32>();
4122 uint32 classMask = fields[1].Get<uint32>();
4123 uint32 spellId = fields[2].Get<uint32>();
4124
4125 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
4126 {
4127 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_spell_custom` table, ignoring.", raceMask);
4128 continue;
4129 }
4130
4131 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4132 {
4133 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_spell_custom` table, ignoring.", classMask);
4134 continue;
4135 }
4136
4137 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
4138 {
4139 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4140 {
4141 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4142 {
4143 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4144 {
4145 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4146 {
4147 info->customSpells.push_back(spellId);
4148 ++count;
4149 }
4150 }
4151 }
4152 }
4153 }
4154 } while (result->NextRow());
4155
4156 LOG_INFO("server.loading", ">> Loaded {} Custom Player Create Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4157 LOG_INFO("server.loading", " ");
4158 }
4159 }
4160
4161 // Load playercreate cast spell
4162 LOG_INFO("server.loading", "Loading Player Create Cast Spell Data...");
4163 {
4164 uint32 oldMSTime = getMSTime();
4165
4166 QueryResult result = WorldDatabase.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
4167
4168 if (!result)
4169 {
4170 LOG_WARN("server.loading", ">> Loaded 0 Player Create Cast Spells. DB Table `playercreateinfo_cast_spell` Is Empty.");
4171 }
4172 else
4173 {
4174 uint32 count = 0;
4175
4176 do
4177 {
4178 Field* fields = result->Fetch();
4179 uint32 raceMask = fields[0].Get<uint32>();
4180 uint32 classMask = fields[1].Get<uint32>();
4181 uint32 spellId = fields[2].Get<uint32>();
4182
4183 if (raceMask != 0 && !(raceMask & RACEMASK_ALL_PLAYABLE))
4184 {
4185 LOG_ERROR("sql.sql", "Wrong race mask {} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
4186 continue;
4187 }
4188
4189 if (classMask != 0 && !(classMask & CLASSMASK_ALL_PLAYABLE))
4190 {
4191 LOG_ERROR("sql.sql", "Wrong class mask {} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
4192 continue;
4193 }
4194
4195 for (uint32 raceIndex = RACE_HUMAN; raceIndex < MAX_RACES; ++raceIndex)
4196 {
4197 if (raceMask == 0 || ((1 << (raceIndex - 1)) & raceMask))
4198 {
4199 for (uint32 classIndex = CLASS_WARRIOR; classIndex < MAX_CLASSES; ++classIndex)
4200 {
4201 if (classMask == 0 || ((1 << (classIndex - 1)) & classMask))
4202 {
4203 if (PlayerInfo* info = _playerInfo[raceIndex][classIndex])
4204 {
4205 info->castSpells.push_back(spellId);
4206 ++count;
4207 }
4208 }
4209 }
4210 }
4211 }
4212 } while (result->NextRow());
4213
4214 LOG_INFO("server.loading", ">> Loaded {} Player Create Cast Spells in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4215 LOG_INFO("server.loading", " ");
4216 }
4217 }
4218
4219 // Load playercreate actions
4220 LOG_INFO("server.loading", "Loading Player Create Action Data...");
4221 {
4222 uint32 oldMSTime = getMSTime();
4223
4224 // 0 1 2 3 4
4225 QueryResult result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
4226
4227 if (!result)
4228 {
4229 LOG_WARN("server.loading", ">> Loaded 0 Player Create Actions. DB Table `playercreateinfo_action` Is Empty.");
4230 LOG_INFO("server.loading", " ");
4231 }
4232 else
4233 {
4234 uint32 count = 0;
4235
4236 do
4237 {
4238 Field* fields = result->Fetch();
4239
4240 uint32 current_race = fields[0].Get<uint8>();
4241 if (current_race >= MAX_RACES)
4242 {
4243 LOG_ERROR("sql.sql", "Wrong race {} in `playercreateinfo_action` table, ignoring.", current_race);
4244 continue;
4245 }
4246
4247 uint32 current_class = fields[1].Get<uint8>();
4248 if (current_class >= MAX_CLASSES)
4249 {
4250 LOG_ERROR("sql.sql", "Wrong class {} in `playercreateinfo_action` table, ignoring.", current_class);
4251 continue;
4252 }
4253
4254 if (PlayerInfo* info = _playerInfo[current_race][current_class])
4255 info->action.push_back(PlayerCreateInfoAction(fields[2].Get<uint16>(), fields[3].Get<uint32>(), fields[4].Get<uint16>()));
4256
4257 ++count;
4258 } while (result->NextRow());
4259
4260 LOG_INFO("server.loading", ">> Loaded {} Player Create Actions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4261 LOG_INFO("server.loading", " ");
4262 }
4263 }
4264
4265 // Loading levels data (class/race dependent)
4266 LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
4267 {
4268 struct RaceStats
4269 {
4270 int16 StatModifier[MAX_STATS];
4271 };
4272
4273 std::array<RaceStats, MAX_RACES> raceStatModifiers;
4274
4275 uint32 oldMSTime = getMSTime();
4276
4277 // 0 1 2 3 4 5
4278 QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
4279
4280 if (!raceStatsResult)
4281 {
4282 LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
4283 LOG_INFO("server.loading", " ");
4284 exit(1);
4285 }
4286
4287 do
4288 {
4289 Field* fields = raceStatsResult->Fetch();
4290
4291 uint32 current_race = fields[0].Get<uint8>();
4292 if (current_race >= MAX_RACES)
4293 {
4294 LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
4295 continue;
4296 }
4297
4298 for (uint32 i = 0; i < MAX_STATS; ++i)
4299 raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
4300
4301 } while (raceStatsResult->NextRow());
4302
4303 // 0 1 2 3 4 5 6 7 8
4304 QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit, BaseHP, BaseMana FROM player_class_stats");
4305
4306 if (!result)
4307 {
4308 LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
4309 exit(1);
4310 }
4311
4312 uint32 count = 0;
4313
4314 do
4315 {
4316 Field* fields = result->Fetch();
4317
4318 uint32 current_class = fields[0].Get<uint8>();
4319 if (current_class >= MAX_CLASSES)
4320 {
4321 LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
4322 continue;
4323 }
4324
4325 uint32 current_level = fields[1].Get<uint8>();
4326 if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4327 {
4328 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4329 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4330 else
4331 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
4332
4333 continue;
4334 }
4335
4336 for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
4337 {
4338 if (PlayerInfo* info = _playerInfo[race][current_class])
4339 {
4340 if (!info->levelInfo)
4341 info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
4342
4343 PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4344 for (int i = 0; i < MAX_STATS; ++i)
4345 levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
4346 }
4347 }
4348
4349 PlayerClassInfo* info = _playerClassInfo[current_class];
4350 if (!info)
4351 {
4352 info = new PlayerClassInfo();
4354 _playerClassInfo[current_class] = info;
4355 }
4356
4357 PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
4358
4359 levelInfo.basehealth = fields[7].Get<uint32>();
4360 levelInfo.basemana = fields[8].Get<uint32>();
4361
4362 ++count;
4363 } while (result->NextRow());
4364
4365 // Fill gaps and check integrity
4366 for (int race = 0; race < MAX_RACES; ++race)
4367 {
4368 // skip non existed races
4369 if (!sChrRacesStore.LookupEntry(race))
4370 continue;
4371
4372 for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
4373 {
4374 // skip non existed classes
4375 if (!sChrClassesStore.LookupEntry(class_))
4376 continue;
4377
4378 PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
4379 PlayerInfo* info = _playerInfo[race][class_];
4380 if (!info)
4381 continue;
4382
4383 // skip expansion races if not playing with expansion
4384 if (sWorld->getIntConfig(CONFIG_EXPANSION) < EXPANSION_THE_BURNING_CRUSADE && (race == RACE_BLOODELF || race == RACE_DRAENEI))
4385 continue;
4386
4387 // skip expansion classes if not playing with expansion
4389 continue;
4390
4391 // fatal error if no initial stats data
4392 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))
4393 {
4394 LOG_ERROR("sql.sql", "Race {} class {} initial level does not have stats data!", race, class_);
4395 exit(1);
4396 }
4397
4398 // fatal error if no initial health/mana data
4399 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))
4400 {
4401 LOG_ERROR("sql.sql", "Class {} initial level does not have health/mana data!", class_);
4402 exit(1);
4403 }
4404
4405 // fill level gaps for stats
4406 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4407 {
4408 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))
4409 {
4410 LOG_ERROR("sql.sql", "Race {} class {} level {} does not have stats data. Using stats data of level {}.", race, class_, level + 1, level);
4411 info->levelInfo[level] = info->levelInfo[level - 1];
4412 }
4413 }
4414
4415 // fill level gaps for health/mana
4416 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4417 {
4418 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))
4419 {
4420 LOG_ERROR("sql.sql", "Class {} level {} does not have health/mana data. Using stats data of level {}.", class_, level + 1, level);
4421 pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1];
4422 }
4423 }
4424 }
4425 }
4426
4427 LOG_INFO("server.loading", ">> Loaded {} Level Stats Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4428 LOG_INFO("server.loading", " ");
4429 }
4430
4431 // Loading xp per level data
4432 LOG_INFO("server.loading", "Loading Player Create XP Data...");
4433 {
4434 uint32 oldMSTime = getMSTime();
4435
4436 _playerXPperLevel.resize(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
4437 for (uint8 level = 0; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4438 _playerXPperLevel[level] = 0;
4439
4440 // 0 1
4441 QueryResult result = WorldDatabase.Query("SELECT Level, Experience FROM player_xp_for_level");
4442
4443 if (!result)
4444 {
4445 LOG_WARN("server.loading", ">> Loaded 0 xp for level definitions. DB table `player_xp_for_level` is empty.");
4446 LOG_INFO("server.loading", " ");
4447 exit(1);
4448 }
4449
4450 uint32 count = 0;
4451
4452 do
4453 {
4454 Field* fields = result->Fetch();
4455
4456 uint32 current_level = fields[0].Get<uint8>();
4457 uint32 current_xp = fields[1].Get<uint32>();
4458
4459 if (current_level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
4460 {
4461 if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
4462 LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level);
4463 else
4464 {
4465 LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_xp_for_levels` table, ignoring.", current_level);
4466 ++count; // make result loading percent "expected" correct in case disabled detail mode for example.
4467 }
4468 continue;
4469 }
4470 //PlayerXPperLevel
4471 _playerXPperLevel[current_level] = current_xp;
4472 ++count;
4473 } while (result->NextRow());
4474
4475 // fill level gaps
4476 for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
4477 {
4478 if (_playerXPperLevel[level] == 0)
4479 {
4480 LOG_ERROR("sql.sql", "Level {} does not have XP for level data. Using data of level [{}] + 100.", level + 1, level);
4481 _playerXPperLevel[level] = _playerXPperLevel[level - 1] + 100;
4482 }
4483 }
4484
4485 LOG_INFO("server.loading", ">> Loaded {} XP For Level Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
4486 LOG_INFO("server.loading", " ");
4487 }
4488}
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition DBCStores.cpp:895
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
#define MAX_SKILL_STEP
Definition DBCStructure.h:1578
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:146
@ RACE_DRAENEI
Definition SharedDefines.h:81
@ RACE_BLOODELF
Definition SharedDefines.h:80
@ RACE_HUMAN
Definition SharedDefines.h:71
@ EXPANSION_THE_BURNING_CRUSADE
Definition SharedDefines.h:54
@ EXPANSION_WRATH_OF_THE_LICH_KING
Definition SharedDefines.h:55
@ CONFIG_START_HEROIC_PLAYER_LEVEL
Definition WorldConfig.h:193
@ CONFIG_START_PLAYER_LEVEL
Definition WorldConfig.h:192
@ CONFIG_EXPANSION
Definition WorldConfig.h:229
void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count)
Definition ObjectMgr.cpp:3835
Definition DBCStructure.h:679
uint32 model_f
Definition DBCStructure.h:685
uint32 model_m
Definition DBCStructure.h:684
Definition Player.h:277
uint32 basehealth
Definition Player.h:279
uint32 basemana
Definition Player.h:280
Definition Player.h:303
Definition Player.h:315
uint16 SkillId
Definition Player.h:316
float orientation
Definition Player.h:332
uint16 displayId_m
Definition Player.h:333
float positionX
Definition Player.h:329
uint32 areaId
Definition Player.h:328
float positionY
Definition Player.h:330
float positionZ
Definition Player.h:331
uint32 mapId
Definition Player.h:327
uint16 displayId_f
Definition Player.h:334
Definition Player.h:291

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

◆ LoadPlayerShapeshiftModels()

void ObjectMgr::LoadPlayerShapeshiftModels ( )
1829{
1830 uint32 oldMSTime = getMSTime();
1831
1832 QueryResult result = WorldDatabase.Query("SELECT ShapeshiftID, RaceID, CustomizationID, GenderID, ModelID from player_shapeshift_model");
1833
1834 if (!result)
1835 {
1836 LOG_INFO("server.loading", ">> Loaded 0 player shapeshift model records. DB table `player_shapeshift_model` is empty.");
1837 return;
1838 }
1839
1840 uint32 count = 0;
1841 do
1842 {
1843 Field* fields = result->Fetch();
1844
1845 ShapeshiftForm shapeshiftForm = ShapeshiftForm(fields[0].Get<uint8>());
1846 uint8 race = fields[1].Get<uint8>();
1847 uint8 customizationID = fields[2].Get<uint8>();
1848 uint8 genderID = Gender(fields[3].Get<uint8>());
1849 uint32 modelId = fields[4].Get<uint32>();
1850
1851 ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race);
1852 if (!raceEntry)
1853 {
1854 LOG_ERROR("sql.sql", "Race {} defined in `player_shapeshift_model` does not exists, skipped.", uint32(race));
1855 continue;
1856 }
1857
1858 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(modelId);
1859 if (!displayEntry)
1860 {
1861 LOG_ERROR("sql.sql", "ShapeshiftForm: {}, Race: {} defined in `player_shapeshift_model` has non-existing model ({}), skipped.", shapeshiftForm, race, modelId);
1862 continue;
1863 }
1864
1865 _playerShapeshiftModel[std::make_tuple(shapeshiftForm, race, customizationID, genderID)] = modelId;
1866 ++count;
1867 } while (result->NextRow());
1868
1869 LOG_INFO("server.loading", ">> Loaded {} player totem model records in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1870 LOG_INFO("server.loading", " ");
1871}
Gender
Definition SharedDefines.h:60
ShapeshiftForm
Definition UnitDefines.h:68

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

◆ LoadPlayerTotemModels()

void ObjectMgr::LoadPlayerTotemModels ( )
1770{
1771 uint32 oldMSTime = getMSTime();
1772
1773 QueryResult result = WorldDatabase.Query("SELECT TotemID, RaceID, ModelID from player_totem_model");
1774
1775 if (!result)
1776 {
1777 LOG_INFO("server.loading", ">> Loaded 0 player totem model records. DB table `player_totem_model` is empty.");
1778 return;
1779 }
1780
1781 uint32 count = 0;
1782 do
1783 {
1784 Field* fields = result->Fetch();
1785
1786 SummonSlot totemSlot = SummonSlot(fields[0].Get<uint8>());
1787 uint8 race = fields[1].Get<uint8>();
1788 uint32 displayId = fields[2].Get<uint32>();
1789
1790 if (totemSlot < SUMMON_SLOT_TOTEM_FIRE || totemSlot >= MAX_TOTEM_SLOT)
1791 {
1792 LOG_ERROR("sql.sql", "Wrong TotemSlot {} in `player_totem_model` table, skipped.", totemSlot);
1793 continue;
1794 }
1795
1796 ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race);
1797 if (!raceEntry)
1798 {
1799 LOG_ERROR("sql.sql", "Race {} defined in `player_totem_model` does not exists, skipped.", uint32(race));
1800 continue;
1801 }
1802
1803 CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(displayId);
1804 if (!displayEntry)
1805 {
1806 LOG_ERROR("sql.sql", "TotemSlot: {} defined in `player_totem_model` has non-existing model ({}), skipped.", totemSlot, displayId);
1807 continue;
1808 }
1809
1810 _playerTotemModel[std::make_pair(totemSlot, Races(race))] = displayId;
1811 ++count;
1812 } while (result->NextRow());
1813
1814 LOG_INFO("server.loading", ">> Loaded {} player totem model records in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1815 LOG_INFO("server.loading", " ");
1816}
#define MAX_TOTEM_SLOT
Definition SharedDefines.h:3562
SummonSlot
Definition SharedDefines.h:3550
Races
Definition SharedDefines.h:69

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

◆ LoadPointOfInterestLocales()

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

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

◆ LoadPointsOfInterest()

void ObjectMgr::LoadPointsOfInterest ( )
8025{
8026 uint32 oldMSTime = getMSTime();
8027
8028 _pointsOfInterestStore.clear(); // need for reload case
8029
8030 uint32 count = 0;
8031
8032 // 0 1 2 3 4 5 6
8033 QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
8034
8035 if (!result)
8036 {
8037 LOG_WARN("server.loading", ">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
8038 LOG_INFO("server.loading", " ");
8039 return;
8040 }
8041
8042 do
8043 {
8044 Field* fields = result->Fetch();
8045
8046 uint32 point_id = fields[0].Get<uint32>();
8047
8048 PointOfInterest POI;
8049 POI.ID = point_id;
8050 POI.PositionX = fields[1].Get<float>();
8051 POI.PositionY = fields[2].Get<float>();
8052 POI.Icon = fields[3].Get<uint32>();
8053 POI.Flags = fields[4].Get<uint32>();
8054 POI.Importance = fields[5].Get<uint32>();
8055 POI.Name = fields[6].Get<std::string>();
8056
8057 if (!Acore::IsValidMapCoord(POI.PositionX, POI.PositionY))
8058 {
8059 LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: {}) have invalid coordinates (X: {} Y: {}), ignored.", point_id, POI.PositionX, POI.PositionY);
8060 continue;
8061 }
8062
8063 _pointsOfInterestStore[point_id] = POI;
8064
8065 ++count;
8066 } while (result->NextRow());
8067
8068 LOG_INFO("server.loading", ">> Loaded {} Points of Interest Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8069 LOG_INFO("server.loading", " ");
8070}
bool IsValidMapCoord(float c)
Definition GridDefines.h:210
Definition ObjectMgr.h:589
uint32 ID
Definition ObjectMgr.h:590

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

◆ LoadProfanityNamesFromDB()

void ObjectMgr::LoadProfanityNamesFromDB ( )
8447{
8448 uint32 oldMSTime = getMSTime();
8449
8450 _profanityNamesStore.clear(); // need for reload case
8451
8452 QueryResult result = CharacterDatabase.Query("SELECT name FROM profanity_name");
8453
8454 if (!result)
8455 {
8456 LOG_WARN("server.loading", ">> Loaded 0 profanity names. DB table `profanity_name` is empty!");
8457 return;
8458 }
8459
8460 uint32 count = 0;
8461
8462 Field* fields;
8463 do
8464 {
8465 fields = result->Fetch();
8466 std::string name = fields[0].Get<std::string>();
8467
8468 std::wstring wstr;
8469 if (!Utf8toWStr (name, wstr))
8470 {
8471 LOG_ERROR("sql.sql", "Table `profanity_name` have invalid name: {}", name);
8472 continue;
8473 }
8474
8475 wstrToLower(wstr);
8476
8477 _profanityNamesStore.insert(wstr);
8478 ++count;
8479 } while (result->NextRow());
8480
8481 LOG_INFO("server.loading", ">> Loaded {} profanity names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8482}

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

◆ LoadProfanityNamesFromDBC()

void ObjectMgr::LoadProfanityNamesFromDBC ( )
8485{
8486 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_PROFANITY))
8487 {
8488 LOG_WARN("server.loading", ">> Loaded 0 profanity names from DBC. Config option disabled.");
8489 return;
8490 }
8491
8492 uint32 oldMSTime = getMSTime();
8493
8494 uint32 count = 0;
8495
8496 for (NamesProfanityEntry const* profanityStore : sNamesProfanityStore)
8497 {
8498 std::wstring wstr;
8499
8500 Utf8toWStr(profanityStore->Pattern, wstr);
8501
8502 // DBC does not have clean entries, remove the junk.
8503 boost::algorithm::replace_all(wstr, "\\<", "");
8504 boost::algorithm::replace_all(wstr, "\\>", "");
8505
8506 _profanityNamesStore.insert(wstr);
8507 count++;
8508 }
8509
8510 LOG_INFO("server.loading", ">> Loaded {} profanity names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8511 LOG_INFO("server.loading", " ");
8512}
DBCStorage< NamesProfanityEntry > sNamesProfanityStore(NamesProfanityfmt)
@ CONFIG_STRICT_NAMES_PROFANITY
Definition WorldConfig.h:142
Definition DBCStructure.h:1403

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

◆ LoadQuestAreaTriggers()

void ObjectMgr::LoadQuestAreaTriggers ( )
6403{
6404 uint32 oldMSTime = getMSTime();
6405
6406 _questAreaTriggerStore.clear(); // need for reload case
6407
6408 QueryResult result = WorldDatabase.Query("SELECT id, quest FROM areatrigger_involvedrelation");
6409
6410 if (!result)
6411 {
6412 LOG_WARN("server.loading", ">> Loaded 0 quest trigger points. DB table `areatrigger_involvedrelation` is empty.");
6413 LOG_INFO("server.loading", " ");
6414 return;
6415 }
6416
6417 uint32 count = 0;
6418
6419 do
6420 {
6421 ++count;
6422
6423 Field* fields = result->Fetch();
6424
6425 uint32 trigger_ID = fields[0].Get<uint32>();
6426 uint32 quest_ID = fields[1].Get<uint32>();
6427
6428 AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
6429 if (!atEntry)
6430 {
6431 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", trigger_ID);
6432 continue;
6433 }
6434
6435 Quest const* quest = GetQuestTemplate(quest_ID);
6436
6437 if (!quest)
6438 {
6439 LOG_ERROR("sql.sql", "Table `areatrigger_involvedrelation` has record (id: {}) for not existing quest {}", trigger_ID, quest_ID);
6440 continue;
6441 }
6442
6444 {
6445 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);
6446
6447 // this will prevent quest completing without objective
6448 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
6449
6450 // continue; - quest modified to required objective and trigger can be allowed.
6451 }
6452
6453 _questAreaTriggerStore[trigger_ID] = quest_ID;
6454 } while (result->NextRow());
6455
6456 LOG_INFO("server.loading", ">> Loaded {} Quest Trigger Points in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6457 LOG_INFO("server.loading", " ");
6458}
@ QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT
Definition QuestDef.h:161
Definition QuestDef.h:210
bool HasSpecialFlag(uint32 flag) const
Definition QuestDef.h:224

References _questAreaTriggerStore, Field::Get(), GetAreaTrigger(), getMSTime(), GetMSTimeDiffToNow(), GetQuestTemplate(), Quest::HasSpecialFlag(), LOG_ERROR, LOG_INFO, LOG_WARN, QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT, and WorldDatabase.

◆ LoadQuestGreetings()

void ObjectMgr::LoadQuestGreetings ( )
6479{
6480 uint32 oldMSTime = getMSTime();
6481
6482 _questGreetingStore.clear(); // For reload case
6483
6484 // 0 1 2 3 4
6485 QueryResult result = WorldDatabase.Query("SELECT ID, Type, GreetEmoteType, GreetEmoteDelay, Greeting FROM quest_greeting");
6486 if (!result)
6487 {
6488 LOG_WARN("server.loading", ">> Loaded 0 quest greetings. DB table `quest_greeting` is empty.");
6489 return;
6490 }
6491
6492 do
6493 {
6494 Field* fields = result->Fetch();
6495
6496 uint32 id = fields[0].Get<uint32>();
6497 uint8 type = fields[1].Get<uint8>();
6498 switch (type)
6499 {
6500 case 0: // Creature
6501 if (!GetCreatureTemplate(id))
6502 {
6503 LOG_ERROR("sql.sql", "Table `quest_greeting`: creature template entry {} does not exist.", id);
6504 continue;
6505 }
6506 break;
6507 case 1: // GameObject
6508 if (!GetGameObjectTemplate(id))
6509 {
6510 LOG_ERROR("sql.sql", "Table `quest_greeting`: gameobject template entry {} does not exist.", id);
6511 continue;
6512 }
6513 break;
6514 default:
6515 LOG_ERROR("sql.sql", "Table `quest_greeting` has unknown type {} for id {}, skipped.", type, id);
6516 continue;
6517 }
6518
6519 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6520 QuestGreeting& data = _questGreetingStore[pairKey];
6521
6522 data.EmoteType = fields[2].Get<uint16>();
6523 data.EmoteDelay = fields[3].Get<uint32>();
6524 AddLocaleString(fields[4].Get<std::string>(), LOCALE_enUS, data.Greeting);
6525 }
6526 while (result->NextRow());
6527
6528 LOG_INFO("server.loading", ">> Loaded {} quest_greeting in {} ms", _questGreetingStore.size(), GetMSTimeDiffToNow(oldMSTime));
6529 LOG_INFO("server.loading", " ");
6530}
Definition ObjectMgr.h:600
uint32 EmoteDelay
Definition ObjectMgr.h:602
std::vector< std::string > Greeting
Definition ObjectMgr.h:603
uint16 EmoteType
Definition ObjectMgr.h:601

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

◆ LoadQuestGreetingsLocales()

void ObjectMgr::LoadQuestGreetingsLocales ( )
6533{
6534 uint32 oldMSTime = getMSTime();
6535
6536 // 0 1 2 3
6537 QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale");
6538 if (!result)
6539 {
6540 LOG_WARN("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty.");
6541 return;
6542 }
6543
6544 uint32 localeCount = 0;
6545 do
6546 {
6547 Field* fields = result->Fetch();
6548
6549 uint32 id = fields[0].Get<uint32>();
6550 uint8 type = fields[1].Get<uint8>();
6551 switch (type)
6552 {
6553 case 0: // Creature
6554 if (!GetCreatureTemplate(id))
6555 {
6556 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: creature template entry {} does not exist.", id);
6557 continue;
6558 }
6559 break;
6560 case 1: // GameObject
6561 if (!GetGameObjectTemplate(id))
6562 {
6563 LOG_ERROR("sql.sql", "Table `quest_greeting_locale`: gameobject template entry {} does not exist.", id);
6564 continue;
6565 }
6566 break;
6567 default:
6568 continue;
6569 }
6570
6571 std::pair<uint32, uint8> pairKey = std::make_pair(id, type);
6572 QuestGreeting& data = _questGreetingStore[pairKey];
6573
6574 QuestGreetingContainer::iterator qgc = _questGreetingStore.find(pairKey);
6575 if (qgc == _questGreetingStore.end())
6576 {
6577 LOG_ERROR("sql.sql", "QuestGreeting (Id: {} Type: {}) found in table `quest_greeting_locale` but does not exist in `quest_greeting`. Skipped!", id, type);
6578 continue;
6579 }
6580
6581 LocaleConstant locale = GetLocaleByName(fields[2].Get<std::string>());
6582 if (locale == LOCALE_enUS)
6583 continue;
6584
6585 AddLocaleString(fields[3].Get<std::string>(), locale, data.Greeting);
6586 localeCount++;
6587 } while (result->NextRow());
6588
6589 LOG_INFO("server.loading", ">> Loaded {} quest greeting Locale Strings in {} ms", localeCount, GetMSTimeDiffToNow(oldMSTime));
6590 LOG_INFO("server.loading", " ");
6591}

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

◆ LoadQuestLocales()

void ObjectMgr::LoadQuestLocales ( )
5363{
5364 uint32 oldMSTime = getMSTime();
5365
5366 _questLocaleStore.clear(); // need for reload case
5367
5368 // 0 1 2 3 4 5 6 7 8 9 10
5369 QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
5370
5371 if (!result)
5372 return;
5373
5374 do
5375 {
5376 Field* fields = result->Fetch();
5377
5378 uint32 ID = fields[0].Get<uint32>();
5379
5380 LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
5381 if (locale == LOCALE_enUS)
5382 continue;
5383
5384 QuestLocale& data = _questLocaleStore[ID];
5385 AddLocaleString(fields[2].Get<std::string>(), locale, data.Title);
5386 AddLocaleString(fields[3].Get<std::string>(), locale, data.Details);
5387 AddLocaleString(fields[4].Get<std::string>(), locale, data.Objectives);
5388 AddLocaleString(fields[5].Get<std::string>(), locale, data.AreaDescription);
5389 AddLocaleString(fields[6].Get<std::string>(), locale, data.CompletedText);
5390
5391 for (uint8 i = 0; i < 4; ++i)
5392 AddLocaleString(fields[i + 7].Get<std::string>(), locale, data.ObjectiveText[i]);
5393 } while (result->NextRow());
5394
5395 LOG_INFO("server.loading", ">> Loaded {} Quest Locale Strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
5396}
Definition QuestDef.h:183
std::vector< std::string > AreaDescription
Definition QuestDef.h:191
std::vector< std::string > CompletedText
Definition QuestDef.h:192
std::vector< std::string > Title
Definition QuestDef.h:186
std::vector< std::string > Objectives
Definition QuestDef.h:188
std::vector< std::vector< std::string > > ObjectiveText
Definition QuestDef.h:193
std::vector< std::string > Details
Definition QuestDef.h:187

References _questLocaleStore, AddLocaleString(), QuestLocale::AreaDescription, QuestLocale::CompletedText, QuestLocale::Details, Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), LOCALE_enUS, LOG_INFO, QuestLocale::Objectives, QuestLocale::ObjectiveText, QuestLocale::Title, and WorldDatabase.

◆ LoadQuestMoneyRewards()

void ObjectMgr::LoadQuestMoneyRewards ( )
10432{
10433 uint32 oldMSTime = getMSTime();
10434
10435 _questMoneyRewards.clear();
10436
10437 // 0 1 2 3 4 5 6 7 8 9 10
10438 QueryResult result = WorldDatabase.Query("SELECT `Level`, Money0, Money1, Money2, Money3, Money4, Money5, Money6, Money7, Money8, Money9 FROM `quest_money_reward` ORDER BY `Level`");
10439 if (!result)
10440 {
10441 LOG_WARN("server.loading", ">> Loaded 0 quest money rewards. DB table `quest_money_reward` is empty.");
10442 return;
10443 }
10444
10445 uint32 count = 0;
10446 do
10447 {
10448 Field* fields = result->Fetch();
10449 uint32 Level = fields[0].Get<uint32>();
10450
10451 QuestMoneyRewardArray& questMoneyReward = _questMoneyRewards[Level];
10452 questMoneyReward.fill(0);
10453
10454 for (uint8 i = 0; i < MAX_QUEST_MONEY_REWARDS; ++i)
10455 {
10456 questMoneyReward[i] = fields[1 + i].Get<uint32>();
10457 ++count;
10458 }
10459 } while (result->NextRow());
10460
10461 LOG_INFO("server.loading", ">> Loaded {} Quest Money Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
10462 LOG_INFO("server.loading", " ");
10463}
std::array< uint32, MAX_QUEST_MONEY_REWARDS > QuestMoneyRewardArray
Definition ObjectMgr.h:719

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

◆ LoadQuestOfferRewardLocale()

void ObjectMgr::LoadQuestOfferRewardLocale ( )
6594{
6595 uint32 oldMSTime = getMSTime();
6596
6597 _questOfferRewardLocaleStore.clear(); // need for reload case
6598
6599 // 0 1 2
6600 QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
6601 if (!result)
6602 return;
6603
6604 do
6605 {
6606 Field* fields = result->Fetch();
6607
6608 uint32 id = fields[0].Get<uint32>();
6609 std::string localeName = fields[1].Get<std::string>();
6610
6611 LocaleConstant locale = GetLocaleByName(localeName);
6612 if (locale == LOCALE_enUS)
6613 continue;
6614
6616 AddLocaleString(fields[2].Get<std::string>(), locale, data.RewardText);
6617 } while (result->NextRow());
6618
6619 LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward Locale Strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6620}
Definition QuestDef.h:202
std::vector< std::string > RewardText
Definition QuestDef.h:203

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

◆ LoadQuestPOI()

void ObjectMgr::LoadQuestPOI ( )
8073{
8074 if (!sWorld->getBoolConfig(CONFIG_QUEST_POI_ENABLED))
8075 {
8076 LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. Disabled by config.");
8077 LOG_INFO("server.loading", " ");
8078 return;
8079 }
8080
8081 uint32 oldMSTime = getMSTime();
8082
8083 _questPOIStore.clear(); // need for reload case
8084
8085 uint32 count = 0;
8086
8087 // 0 1 2 3 4 5 6 7
8088 QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID");
8089
8090 if (!result)
8091 {
8092 LOG_WARN("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
8093 LOG_INFO("server.loading", " ");
8094 return;
8095 }
8096
8097 // 0 1 2 3
8098 QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
8099
8100 std::vector<std::vector<std::vector<QuestPOIPoint> > > POIs;
8101
8102 if (points)
8103 {
8104 // The first result should have the highest questId
8105 Field* fields = points->Fetch();
8106 uint32 questIdMax = fields[0].Get<uint32>();
8107 POIs.resize(questIdMax + 1);
8108
8109 do
8110 {
8111 fields = points->Fetch();
8112
8113 uint32 questId = fields[0].Get<uint32>();
8114 uint32 id = fields[1].Get<uint32>();
8115 int32 x = fields[2].Get<int32>();
8116 int32 y = fields[3].Get<int32>();
8117
8118 if (POIs[questId].size() <= id + 1)
8119 POIs[questId].resize(id + 10);
8120
8121 QuestPOIPoint point(x, y);
8122 POIs[questId][id].push_back(point);
8123 } while (points->NextRow());
8124 }
8125
8126 do
8127 {
8128 Field* fields = result->Fetch();
8129
8130 uint32 questId = fields[0].Get<uint32>();
8131 uint32 id = fields[1].Get<uint32>();
8132 int32 objIndex = fields[2].Get<int32>();
8133 uint32 mapId = fields[3].Get<uint32>();
8134 uint32 WorldMapAreaId = fields[4].Get<uint32>();
8135 uint32 FloorId = fields[5].Get<uint32>();
8136 uint32 unk3 = fields[6].Get<uint32>();
8137 uint32 unk4 = fields[7].Get<uint32>();
8138
8139 QuestPOI POI(id, objIndex, mapId, WorldMapAreaId, FloorId, unk3, unk4);
8140 if (questId < POIs.size() && id < POIs[questId].size())
8141 {
8142 POI.points = POIs[questId][id];
8143 _questPOIStore[questId].push_back(POI);
8144 }
8145 else
8146 LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest {} POI id {}", questId, id);
8147
8148 ++count;
8149 } while (result->NextRow());
8150
8151 LOG_INFO("server.loading", ">> Loaded {} Quest POI definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8152 LOG_INFO("server.loading", " ");
8153}
@ CONFIG_QUEST_POI_ENABLED
Definition WorldConfig.h:135
Definition ObjectMgr.h:639
Definition ObjectMgr.h:648

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
8243{
8244 uint32 oldMSTime = getMSTime();
8245
8246 map.clear(); // need for reload case
8247
8248 uint32 count = 0;
8249
8250 QueryResult result = WorldDatabase.Query("SELECT id, quest, pool_entry FROM {} qr LEFT JOIN pool_quest pq ON qr.quest = pq.entry", table);
8251
8252 if (!result)
8253 {
8254 LOG_WARN("server.loading", ">> Loaded 0 quest relations from `{}`, table is empty.", table);
8255 LOG_INFO("server.loading", " ");
8256 return;
8257 }
8258
8259 PooledQuestRelation* poolRelationMap = go ? &sPoolMgr->mQuestGORelation : &sPoolMgr->mQuestCreatureRelation;
8260 if (starter)
8261 poolRelationMap->clear();
8262
8263 do
8264 {
8265 uint32 id = result->Fetch()[0].Get<uint32>();
8266 uint32 quest = result->Fetch()[1].Get<uint32>();
8267 uint32 poolId = result->Fetch()[2].Get<uint32>();
8268
8269 if (_questTemplates.find(quest) == _questTemplates.end())
8270 {
8271 LOG_ERROR("sql.sql", "Table `{}`: Quest {} listed for entry {} does not exist.", table, quest, id);
8272 continue;
8273 }
8274
8275 if (!poolId || !starter)
8276 map.insert(QuestRelations::value_type(id, quest));
8277 else if (starter)
8278 poolRelationMap->insert(PooledQuestRelation::value_type(quest, id));
8279
8280 ++count;
8281 } while (result->NextRow());
8282
8283 LOG_INFO("server.loading", ">> Loaded {} Quest Relations From {} in {} ms", count, table, GetMSTimeDiffToNow(oldMSTime));
8284 LOG_INFO("server.loading", " ");
8285}
#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 ( )
6623{
6624 uint32 oldMSTime = getMSTime();
6625
6626 _questRequestItemsLocaleStore.clear(); // need for reload case
6627
6628 // 0 1 2
6629 QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale");
6630 if (!result)
6631 return;
6632
6633 do
6634 {
6635 Field* fields = result->Fetch();
6636
6637 uint32 id = fields[0].Get<uint32>();
6638 std::string localeName = fields[1].Get<std::string>();
6639
6640 LocaleConstant locale = GetLocaleByName(localeName);
6641 if (locale == LOCALE_enUS)
6642 continue;
6643
6645 AddLocaleString(fields[2].Get<std::string>(), locale, data.CompletionText);
6646 } while (result->NextRow());
6647
6648 LOG_INFO("server.loading", ">> Loaded {} Quest Request Items Locale Strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
6649}
Definition QuestDef.h:197
std::vector< std::string > CompletionText
Definition QuestDef.h:198

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

◆ LoadQuests()

void ObjectMgr::LoadQuests ( )
4595{
4596 uint32 oldMSTime = getMSTime();
4597
4598 // For reload case
4599 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4600 delete itr->second;
4601 _questTemplates.clear();
4602
4603 mExclusiveQuestGroups.clear();
4604
4605 QueryResult result = WorldDatabase.Query("SELECT "
4606 //0 1 2 3 4 5 6 7 8
4607 "ID, QuestType, QuestLevel, MinLevel, QuestSortID, QuestInfoID, SuggestedGroupNum, TimeAllowed, AllowableRaces,"
4608 // 9 10 11 12
4609 "RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2, "
4610 // 13 14 15 16 17 18 19 20
4611 "RewardNextQuest, RewardXPDifficulty, RewardMoney, RewardMoneyDifficulty, RewardDisplaySpell, RewardSpell, RewardHonor, RewardKillHonor, "
4612 // 21 22 23 24 25 26
4613 "StartItem, Flags, RewardTitle, RequiredPlayerKills, RewardTalents, RewardArenaPoints, "
4614 // 27 28 29 30 31 32 33 34
4615 "RewardItem1, RewardAmount1, RewardItem2, RewardAmount2, RewardItem3, RewardAmount3, RewardItem4, RewardAmount4, "
4616 // 35 36 37 38 39 40 41 42 43 44 45 46
4617 "RewardChoiceItemID1, RewardChoiceItemQuantity1, RewardChoiceItemID2, RewardChoiceItemQuantity2, RewardChoiceItemID3, RewardChoiceItemQuantity3, RewardChoiceItemID4, RewardChoiceItemQuantity4, RewardChoiceItemID5, RewardChoiceItemQuantity5, RewardChoiceItemID6, RewardChoiceItemQuantity6, "
4618 // 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
4619 "RewardFactionID1, RewardFactionValue1, RewardFactionOverride1, RewardFactionID2, RewardFactionValue2, RewardFactionOverride2, RewardFactionID3, RewardFactionValue3, RewardFactionOverride3, RewardFactionID4, RewardFactionValue4, RewardFactionOverride4, RewardFactionID5, RewardFactionValue5, RewardFactionOverride5,"
4620 // 61 63 64 65
4621 "POIContinent, POIx, POIy, POIPriority, "
4622 // 66 67 68 69 70
4623 "LogTitle, LogDescription, QuestDescription, AreaDescription, QuestCompletionLog, "
4624 // 71 72 73 74 75 76 77 78
4625 "RequiredNpcOrGo1, RequiredNpcOrGo2, RequiredNpcOrGo3, RequiredNpcOrGo4, RequiredNpcOrGoCount1, RequiredNpcOrGoCount2, RequiredNpcOrGoCount3, RequiredNpcOrGoCount4, "
4626 // 79 80 81 82 83 84 85 86
4627 "ItemDrop1, ItemDrop2, ItemDrop3, ItemDrop4, ItemDropQuantity1, ItemDropQuantity2, ItemDropQuantity3, ItemDropQuantity4, "
4628 // 87 88 89 90 91 92 93 94 95 96 97 98
4629 "RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
4630 // 99 100 101 102 103
4631 "Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4"
4632 " FROM quest_template");
4633 if (!result)
4634 {
4635 LOG_WARN("server.loading", ">> Loaded 0 quests definitions. DB table `quest_template` is empty.");
4636 LOG_INFO("server.loading", " ");
4637 return;
4638 }
4639
4640 // create multimap previous quest for each existed quest
4641 // some quests can have many previous maps set by NextQuestId in previous quest
4642 // for example set of race quests can lead to single not race specific quest
4643 do
4644 {
4645 Field* fields = result->Fetch();
4646
4647 Quest* newQuest = new Quest(fields);
4648 _questTemplates[newQuest->GetQuestId()] = newQuest;
4649 } while (result->NextRow());
4650
4651 // pussywizard:
4652 {
4653 uint32 max = 0;
4654 for (QuestMap::const_iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4655 if (itr->first > max)
4656 max = itr->first;
4657 if (max)
4658 {
4659 _questTemplatesFast.clear();
4660 _questTemplatesFast.resize(max + 1, nullptr);
4661 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4662 _questTemplatesFast[itr->first] = itr->second;
4663 }
4664 }
4665
4666 for (QuestMap::iterator itr = _questTemplates.begin(); itr != _questTemplates.end(); ++itr)
4667 itr->second->InitializeQueryData();
4668
4669 std::map<uint32, uint32> usedMailTemplates;
4670
4671 // Load `quest_details`
4672 // 0 1 2 3 4 5 6 7 8
4673 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4 FROM quest_details");
4674
4675 if (!result)
4676 {
4677 LOG_WARN("server.loading", ">> Loaded 0 quest details. DB table `quest_details` is empty.");
4678 }
4679 else
4680 {
4681 do
4682 {
4683 Field* fields = result->Fetch();
4684 uint32 questId = fields[0].Get<uint32>();
4685
4686 auto itr = _questTemplates.find(questId);
4687 if (itr != _questTemplates.end())
4688 itr->second->LoadQuestDetails(fields);
4689 else
4690 LOG_ERROR("sql.sql", "Table `quest_details` has data for quest {} but such quest does not exist", questId);
4691 } while (result->NextRow());
4692 }
4693
4694 // Load `quest_request_items`
4695 // 0 1 2 3
4696 result = WorldDatabase.Query("SELECT ID, EmoteOnComplete, EmoteOnIncomplete, CompletionText FROM quest_request_items");
4697
4698 if (!result)
4699 {
4700 LOG_WARN("server.loading", ">> Loaded 0 quest request items. DB table `quest_request_items` is empty.");
4701 }
4702 else
4703 {
4704 do
4705 {
4706 Field* fields = result->Fetch();
4707 uint32 questId = fields[0].Get<uint32>();
4708
4709 auto itr = _questTemplates.find(questId);
4710 if (itr != _questTemplates.end())
4711 itr->second->LoadQuestRequestItems(fields);
4712 else
4713 LOG_ERROR("sql.sql", "Table `quest_request_items` has data for quest {} but such quest does not exist", questId);
4714 } while (result->NextRow());
4715 }
4716
4717 // Load `quest_offer_reward`
4718 // 0 1 2 3 4 5 6 7 8 9
4719 result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4, RewardText FROM quest_offer_reward");
4720
4721 if (!result)
4722 {
4723 LOG_WARN("server.loading", ">> Loaded 0 quest reward emotes. DB table `quest_offer_reward` is empty.");
4724 }
4725 else
4726 {
4727 do
4728 {
4729 Field* fields = result->Fetch();
4730 uint32 questId = fields[0].Get<uint32>();
4731
4732 auto itr = _questTemplates.find(questId);
4733 if (itr != _questTemplates.end())
4734 itr->second->LoadQuestOfferReward(fields);
4735 else
4736 LOG_ERROR("sql.sql", "Table `quest_offer_reward` has data for quest {} but such quest does not exist", questId);
4737 } while (result->NextRow());
4738 }
4739
4740 // Load `quest_template_addon`
4741 // 0 1 2 3 4 5 6 7 8
4742 result = WorldDatabase.Query("SELECT ID, MaxLevel, AllowableClasses, SourceSpellID, PrevQuestID, NextQuestID, ExclusiveGroup, RewardMailTemplateID, RewardMailDelay, "
4743 //9 10 11 12 13 14 15 16 17
4744 "RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, RewardMailSenderEntry, SpecialFlags FROM quest_template_addon LEFT JOIN quest_mail_sender ON Id=QuestId");
4745
4746 if (!result)
4747 {
4748 LOG_WARN("server.loading", ">> Loaded 0 quest template addons. DB table `quest_template_addon` is empty.");
4749 }
4750 else
4751 {
4752 do
4753 {
4754 Field* fields = result->Fetch();
4755 uint32 questId = fields[0].Get<uint32>();
4756
4757 auto itr = _questTemplates.find(questId);
4758 if (itr != _questTemplates.end())
4759 itr->second->LoadQuestTemplateAddon(fields);
4760 else
4761 LOG_ERROR("sql.sql", "Table `quest_template_addon` has data for quest {} but such quest does not exist", questId);
4762 } while (result->NextRow());
4763 }
4764
4765 // Post processing
4766 for (QuestMap::iterator iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter)
4767 {
4768 // skip post-loading checks for disabled quests
4769 if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr))
4770 continue;
4771
4772 Quest* qinfo = iter->second;
4773
4774 // additional quest integrity checks (GO, creature_template and item_template must be loaded already)
4775
4776 if (qinfo->GetQuestMethod() >= 3)
4777 LOG_ERROR("sql.sql", "Quest {} has `Method` = {}, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod());
4778
4780 {
4781 LOG_ERROR("sql.sql", "Quest {} has `SpecialFlags` = {} > max allowed value. Correct `SpecialFlags` to value <= {}",
4784 }
4785
4786 if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY)
4787 {
4788 LOG_ERROR("sql.sql", "Weekly Quest {} is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId());
4789 qinfo->Flags &= ~QUEST_FLAGS_DAILY;
4790 }
4791
4792 if (qinfo->Flags & QUEST_FLAGS_DAILY)
4793 {
4795 {
4796 LOG_ERROR("sql.sql", "Daily Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4798 }
4799 }
4800
4801 if (qinfo->Flags & QUEST_FLAGS_WEEKLY)
4802 {
4804 {
4805 LOG_ERROR("sql.sql", "Weekly Quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4807 }
4808 }
4809
4811 {
4813 {
4814 LOG_ERROR("sql.sql", "Monthly quest {} not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
4816 }
4817 }
4818
4819 if (qinfo->Flags & QUEST_FLAGS_TRACKING)
4820 {
4821 // at auto-reward can be rewarded only RewardChoiceItemId[0]
4822 for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j )
4823 {
4824 if (uint32 id = qinfo->RewardChoiceItemId[j])
4825 {
4826 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item from `RewardChoiceItemId{}` can't be rewarded with quest flag QUEST_FLAGS_TRACKING.",
4827 qinfo->GetQuestId(), j + 1, id, j + 1);
4828 // no changes, quest ignore this data
4829 }
4830 }
4831 }
4832
4833 // client quest log visual (area case)
4834 if (qinfo->ZoneOrSort > 0)
4835 {
4836 if (!sAreaTableStore.LookupEntry(qinfo->ZoneOrSort))
4837 {
4838 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (zone case) but zone with this id does not exist.",
4839 qinfo->GetQuestId(), qinfo->ZoneOrSort);
4840 // no changes, quest not dependent from this value but can have problems at client
4841 }
4842 }
4843 // client quest log visual (sort case)
4844 if (qinfo->ZoneOrSort < 0)
4845 {
4846 QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort));
4847 if (!qSort)
4848 {
4849 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} (sort case) but quest sort with this id does not exist.",
4850 qinfo->GetQuestId(), qinfo->ZoneOrSort);
4851 // 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)
4852 }
4853 //check for proper RequiredSkillId value (skill case)
4854 if (uint32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
4855 {
4856 if (qinfo->RequiredSkillId != skill_id)
4857 {
4858 LOG_ERROR("sql.sql", "Quest {} has `ZoneOrSort` = {} but `RequiredSkillId` does not have a corresponding value ({}).",
4859 qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id);
4860 //override, and force proper value here?
4861 }
4862 }
4863 }
4864
4865 // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class
4866 if (qinfo->RequiredClasses)
4867 {
4869 {
4870 LOG_ERROR("sql.sql", "Quest {} does not contain any playable classes in `RequiredClasses` ({}), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses);
4871 qinfo->RequiredClasses = 0;
4872 }
4873 }
4874 // AllowableRaces, can be 0/RACEMASK_ALL_PLAYABLE to allow any race
4875 if (qinfo->AllowableRaces)
4876 {
4877 if (!(qinfo->AllowableRaces & RACEMASK_ALL_PLAYABLE))
4878 {
4879 LOG_ERROR("sql.sql", "Quest {} does not contain any playable races in `AllowableRaces` ({}), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->AllowableRaces);
4880 qinfo->AllowableRaces = 0;
4881 }
4882 }
4883 // RequiredSkillId, can be 0
4884 if (qinfo->RequiredSkillId)
4885 {
4886 if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId))
4887 {
4888 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillId` = {} but this skill does not exist",
4889 qinfo->GetQuestId(), qinfo->RequiredSkillId);
4890 }
4891 }
4892
4893 if (qinfo->RequiredSkillPoints)
4894 {
4895 if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue())
4896 {
4897 LOG_ERROR("sql.sql", "Quest {} has `RequiredSkillPoints` = {} but max possible skill is {}, quest can't be done.",
4898 qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue());
4899 // no changes, quest can't be done for this requirement
4900 }
4901 }
4902 // else Skill quests can have 0 skill level, this is ok
4903
4904 if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2))
4905 {
4906 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId2` = {} but faction template {} does not exist, quest can't be done.",
4907 qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2);
4908 // no changes, quest can't be done for this requirement
4909 }
4910
4911 if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1))
4912 {
4913 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionId1` = {} but faction template {} does not exist, quest can't be done.",
4914 qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1);
4915 // no changes, quest can't be done for this requirement
4916 }
4917
4918 if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction))
4919 {
4920 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepFaction` = {} but faction template {} does not exist, quest can't be done.",
4921 qinfo->GetQuestId(), qinfo->RequiredMinRepFaction, qinfo->RequiredMinRepFaction);
4922 // no changes, quest can't be done for this requirement
4923 }
4924
4925 if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction))
4926 {
4927 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepFaction` = {} but faction template {} does not exist, quest can't be done.",
4928 qinfo->GetQuestId(), qinfo->RequiredMaxRepFaction, qinfo->RequiredMaxRepFaction);
4929 // no changes, quest can't be done for this requirement
4930 }
4931
4933 {
4934 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but max reputation is {}, quest can't be done.",
4936 // no changes, quest can't be done for this requirement
4937 }
4938
4939 if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue)
4940 {
4941 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} and `RequiredMinRepValue` = {}, quest can't be done.",
4942 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue, qinfo->RequiredMinRepValue);
4943 // no changes, quest can't be done for this requirement
4944 }
4945
4946 if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0)
4947 {
4948 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue1` = {} but `RequiredFactionId1` is 0, value has no effect",
4949 qinfo->GetQuestId(), qinfo->RequiredFactionValue1);
4950 // warning
4951 }
4952
4953 if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0)
4954 {
4955 LOG_ERROR("sql.sql", "Quest {} has `RequiredFactionValue2` = {} but `RequiredFactionId2` is 0, value has no effect",
4956 qinfo->GetQuestId(), qinfo->RequiredFactionValue2);
4957 // warning
4958 }
4959
4960 if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue != 0)
4961 {
4962 LOG_ERROR("sql.sql", "Quest {} has `RequiredMinRepValue` = {} but `RequiredMinRepFaction` is 0, value has no effect",
4963 qinfo->GetQuestId(), qinfo->RequiredMinRepValue);
4964 // warning
4965 }
4966
4967 if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue != 0)
4968 {
4969 LOG_ERROR("sql.sql", "Quest {} has `RequiredMaxRepValue` = {} but `RequiredMaxRepFaction` is 0, value has no effect",
4970 qinfo->GetQuestId(), qinfo->RequiredMaxRepValue);
4971 // warning
4972 }
4973
4974 if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId))
4975 {
4976 LOG_ERROR("sql.sql", "Quest {} has `RewardTitleId` = {} but CharTitle Id {} does not exist, quest can't be rewarded with title.",
4977 qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId());
4978 qinfo->RewardTitleId = 0;
4979 // quest can't reward this title
4980 }
4981
4982 if (qinfo->StartItem)
4983 {
4984 if (!GetItemTemplate(qinfo->StartItem))
4985 {
4986 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but item with entry {} does not exist, quest can't be done.",
4987 qinfo->GetQuestId(), qinfo->StartItem, qinfo->StartItem);
4988 qinfo->StartItem = 0; // quest can't be done for this requirement
4989 }
4990 else if (qinfo->StartItemCount == 0)
4991 {
4992 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = {} but `StartItemCount` = 0, set to 1 but need fix in DB.",
4993 qinfo->GetQuestId(), qinfo->StartItem);
4994 qinfo->StartItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB
4995 }
4996 }
4997 else if (qinfo->StartItemCount > 0)
4998 {
4999 LOG_ERROR("sql.sql", "Quest {} has `StartItem` = 0 but `StartItemCount` = {}, useless value.",
5000 qinfo->GetQuestId(), qinfo->StartItemCount);
5001 qinfo->StartItemCount = 0; // no quest work changes in fact
5002 }
5003
5004 if (qinfo->SourceSpellid)
5005 {
5006 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid);
5007 if (!spellInfo)
5008 {
5009 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} doesn't exist, quest can't be done.",
5010 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
5011 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
5012 }
5013 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5014 {
5015 LOG_ERROR("sql.sql", "Quest {} has `SourceSpellid` = {} but spell {} is broken, quest can't be done.",
5016 qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
5017 qinfo->SourceSpellid = 0; // quest can't be done for this requirement
5018 }
5019 }
5020
5021 for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
5022 {
5023 uint32 id = qinfo->RequiredItemId[j];
5024 if (id)
5025 {
5026 if (qinfo->RequiredItemCount[j] == 0)
5027 {
5028 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but `RequiredItemCount{}` = 0, quest can't be done.",
5029 qinfo->GetQuestId(), j + 1, id, j + 1);
5030 // no changes, quest can't be done for this requirement
5031 }
5032
5034
5035 if (!GetItemTemplate(id))
5036 {
5037 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = {} but item with entry {} does not exist, quest can't be done.",
5038 qinfo->GetQuestId(), j + 1, id, id);
5039 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
5040 }
5041 }
5042 else if (qinfo->RequiredItemCount[j] > 0)
5043 {
5044 LOG_ERROR("sql.sql", "Quest {} has `RequiredItemId{}` = 0 but `RequiredItemCount{}` = {}, quest can't be done.",
5045 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredItemCount[j]);
5046 qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
5047 }
5048 }
5049
5050 for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
5051 {
5052 uint32 id = qinfo->ItemDrop[j];
5053 if (id)
5054 {
5055 if (!GetItemTemplate(id))
5056 {
5057 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = {} but item with entry {} does not exist, quest can't be done.",
5058 qinfo->GetQuestId(), j + 1, id, id);
5059 // no changes, quest can't be done for this requirement
5060 }
5061 }
5062 else
5063 {
5064 if (qinfo->ItemDropQuantity[j] > 0)
5065 {
5066 LOG_ERROR("sql.sql", "Quest {} has `ItemDrop{}` = 0 but `ItemDropQuantity{}` = {}.",
5067 qinfo->GetQuestId(), j + 1, j + 1, qinfo->ItemDropQuantity[j]);
5068 // no changes, quest ignore this data
5069 }
5070 }
5071 }
5072
5073 for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
5074 {
5075 int32 id = qinfo->RequiredNpcOrGo[j];
5076 if (id < 0 && !GetGameObjectTemplate(-id))
5077 {
5078 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but gameobject {} does not exist, quest can't be done.",
5079 qinfo->GetQuestId(), j + 1, id, uint32(-id));
5080 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
5081 }
5082
5083 if (id > 0 && !GetCreatureTemplate(id))
5084 {
5085 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but creature with entry {} does not exist, quest can't be done.",
5086 qinfo->GetQuestId(), j + 1, id, uint32(id));
5087 qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
5088 }
5089
5090 if (id)
5091 {
5092 // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast
5093
5095
5096 if (!qinfo->RequiredNpcOrGoCount[j])
5097 {
5098 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = {} but `RequiredNpcOrGoCount{}` = 0, quest can't be done.",
5099 qinfo->GetQuestId(), j + 1, id, j + 1);
5100 // no changes, quest can be incorrectly done, but we already report this
5101 }
5102 }
5103 else if (qinfo->RequiredNpcOrGoCount[j] > 0)
5104 {
5105 LOG_ERROR("sql.sql", "Quest {} has `RequiredNpcOrGo{}` = 0 but `RequiredNpcOrGoCount{}` = {}.",
5106 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RequiredNpcOrGoCount[j]);
5107 // no changes, quest ignore this data
5108 }
5109 }
5110
5111 for (uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j)
5112 {
5113 uint32 id = qinfo->RewardChoiceItemId[j];
5114 if (id)
5115 {
5116 if (!GetItemTemplate(id))
5117 {
5118 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
5119 qinfo->GetQuestId(), j + 1, id, id);
5120 qinfo->RewardChoiceItemId[j] = 0; // no changes, quest will not reward this
5121 }
5122
5123 if (!qinfo->RewardChoiceItemCount[j])
5124 {
5125 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = {} but `RewardChoiceItemCount{}` = 0, quest can't be done.",
5126 qinfo->GetQuestId(), j + 1, id, j + 1);
5127 // no changes, quest can't be done
5128 }
5129 }
5130 else if (qinfo->RewardChoiceItemCount[j] > 0)
5131 {
5132 LOG_ERROR("sql.sql", "Quest {} has `RewardChoiceItemId{}` = 0 but `RewardChoiceItemCount{}` = {}.",
5133 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardChoiceItemCount[j]);
5134 // no changes, quest ignore this data
5135 }
5136 }
5137
5138 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
5139 {
5140 if (!qinfo->RewardItemId[0] && qinfo->RewardItemId[j])
5141 {
5142 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId1` but has `RewardItem{}`. Reward item will not be loaded.",
5143 qinfo->GetQuestId(), j + 1);
5144 }
5145 if (!qinfo->RewardItemId[1] && j > 1 && qinfo->RewardItemId[j])
5146 {
5147 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId2` but has `RewardItem{}`. Reward item will not be loaded.",
5148 qinfo->GetQuestId(), j + 1);
5149 }
5150 if (!qinfo->RewardItemId[2] && j > 2 && qinfo->RewardItemId[j])
5151 {
5152 LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId3` but has `RewardItem{}`. Reward item will not be loaded.",
5153 qinfo->GetQuestId(), j + 1);
5154 }
5155 }
5156
5157 for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
5158 {
5159 uint32 id = qinfo->RewardItemId[j];
5160 if (id)
5161 {
5162 if (!GetItemTemplate(id))
5163 {
5164 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but item with entry {} does not exist, quest will not reward this item.",
5165 qinfo->GetQuestId(), j + 1, id, id);
5166 qinfo->RewardItemId[j] = 0; // no changes, quest will not reward this item
5167 }
5168
5169 if (!qinfo->RewardItemIdCount[j])
5170 {
5171 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = {} but `RewardItemIdCount{}` = 0, quest will not reward this item.",
5172 qinfo->GetQuestId(), j + 1, id, j + 1);
5173 // no changes
5174 }
5175 }
5176 else if (qinfo->RewardItemIdCount[j] > 0)
5177 {
5178 LOG_ERROR("sql.sql", "Quest {} has `RewardItemId{}` = 0 but `RewardItemIdCount{}` = {}.",
5179 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardItemIdCount[j]);
5180 // no changes, quest ignore this data
5181 }
5182 }
5183
5184 for (uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j)
5185 {
5186 if (qinfo->RewardFactionId[j])
5187 {
5188 if (std::abs(qinfo->RewardFactionValueId[j]) > 9)
5189 {
5190 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]);
5191 }
5192 if (!sFactionStore.LookupEntry(qinfo->RewardFactionId[j]))
5193 {
5194 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]);
5195 qinfo->RewardFactionId[j] = 0; // quest will not reward this
5196 }
5197 }
5198
5199 else if (qinfo->RewardFactionValueIdOverride[j] != 0)
5200 {
5201 LOG_ERROR("sql.sql", "Quest {} has `RewardFactionId{}` = 0 but `RewardFactionValueIdOverride{}` = {}.",
5202 qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewardFactionValueIdOverride[j]);
5203 // no changes, quest ignore this data
5204 }
5205 }
5206
5207 if (qinfo->RewardDisplaySpell)
5208 {
5209 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell);
5210
5211 if (!spellInfo)
5212 {
5213 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} does not exist, spell removed as display reward.",
5214 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5215 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5216 }
5217
5218 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5219 {
5220 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is broken, quest will not have a spell reward.",
5221 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5222 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5223 }
5224
5225 else if (GetTalentSpellCost(qinfo->RewardDisplaySpell))
5226 {
5227 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5228 qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell);
5229 qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest
5230 }
5231 }
5232
5233 if (qinfo->RewardSpell > 0)
5234 {
5235 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell);
5236
5237 if (!spellInfo)
5238 {
5239 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} does not exist, quest will not have a spell reward.",
5240 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5241 qinfo->RewardSpell = 0; // no spell will be casted on player
5242 }
5243
5244 else if (!SpellMgr::ComputeIsSpellValid(spellInfo))
5245 {
5246 LOG_ERROR("sql.sql", "Quest {} has `RewardSpell` = {} but spell {} is broken, quest will not have a spell reward.",
5247 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5248 qinfo->RewardSpell = 0; // no spell will be casted on player
5249 }
5250
5251 else if (GetTalentSpellCost(qinfo->RewardSpell))
5252 {
5253 LOG_ERROR("sql.sql", "Quest {} has `RewardDisplaySpell` = {} but spell {} is talent, quest will not have a spell reward.",
5254 qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
5255 qinfo->RewardSpell = 0; // no spell will be casted on player
5256 }
5257 }
5258
5259 if (qinfo->RewardMailTemplateId)
5260 {
5261 if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId))
5262 {
5263 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} does not exist, quest will not have a mail reward.",
5264 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId);
5265 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5266 qinfo->RewardMailDelay = 0; // no mail will send to player
5267 qinfo->RewardMailSenderEntry = 0;
5268 }
5269 else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end())
5270 {
5271 std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId);
5272 LOG_ERROR("sql.sql", "Quest {} has `RewardMailTemplateId` = {} but mail template {} already used for quest {}, quest will not have a mail reward.",
5273 qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second);
5274 qinfo->RewardMailTemplateId = 0; // no mail will send to player
5275 qinfo->RewardMailDelay = 0; // no mail will send to player
5276 qinfo->RewardMailSenderEntry = 0;
5277 }
5278 else
5279 usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId();
5280 }
5281
5282 if (qinfo->RewardNextQuest)
5283 {
5284 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->RewardNextQuest);
5285 if (qNextItr == _questTemplates.end())
5286 {
5287 LOG_ERROR("sql.sql", "Quest {} has `RewardNextQuest` = {} but quest {} does not exist, quest chain will not work.",
5288 qinfo->GetQuestId(), qinfo->RewardNextQuest, qinfo->RewardNextQuest);
5289 qinfo->RewardNextQuest = 0;
5290 }
5291 else
5292 qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId());
5293 }
5294
5295 // fill additional data stores
5296 if (qinfo->PrevQuestId)
5297 {
5298 if (_questTemplates.find(std::abs(qinfo->GetPrevQuestId())) == _questTemplates.end())
5299 {
5300 LOG_ERROR("sql.sql", "Quest {} has PrevQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId());
5301 }
5302 else
5303 {
5304 qinfo->prevQuests.push_back(qinfo->PrevQuestId);
5305 }
5306 }
5307
5308 if (qinfo->NextQuestId)
5309 {
5310 QuestMap::iterator qNextItr = _questTemplates.find(qinfo->GetNextQuestId());
5311 if (qNextItr == _questTemplates.end())
5312 {
5313 LOG_ERROR("sql.sql", "Quest {} has NextQuestId {}, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId());
5314 }
5315 else
5316 qNextItr->second->prevQuests.push_back(static_cast<int32>(qinfo->GetQuestId()));
5317 }
5318
5319 if (qinfo->ExclusiveGroup)
5320 mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
5321 if (qinfo->TimeAllowed)
5323 if (qinfo->RequiredPlayerKills)
5325 }
5326
5327 // check QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
5328 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
5329 {
5330 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
5331 if (!spellInfo)
5332 continue;
5333
5334 for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
5335 {
5336 if (spellInfo->Effects[j].Effect != SPELL_EFFECT_QUEST_COMPLETE)
5337 continue;
5338
5339 uint32 quest_id = spellInfo->Effects[j].MiscValue;
5340
5341 Quest const* quest = GetQuestTemplate(quest_id);
5342
5343 // some quest referenced in spells not exist (outdated spells)
5344 if (!quest)
5345 continue;
5346
5348 {
5349 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);
5350
5351 // this will prevent quest completing without objective
5352 // xinef: remove this, leave error but do not break the quest
5353 // const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5354 }
5355 }
5356 }
5357
5358 LOG_INFO("server.loading", ">> Loaded {} Quests Definitions in {} ms", (unsigned long)_questTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
5359 LOG_INFO("server.loading", " ");
5360}
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
DBCStorage< QuestSortEntry > sQuestSortStore(QuestSortEntryfmt)
@ DISABLE_TYPE_QUEST
Definition DisableMgr.h:29
#define QUEST_REWARDS_COUNT
Definition QuestDef.h:39
#define QUEST_ITEM_OBJECTIVES_COUNT
Definition QuestDef.h:36
#define QUEST_OBJECTIVES_COUNT
Definition QuestDef.h:35
@ QUEST_FLAGS_TRACKING
Definition QuestDef.h:142
@ QUEST_FLAGS_DAILY
Definition QuestDef.h:144
@ QUEST_FLAGS_WEEKLY
Definition QuestDef.h:147
#define QUEST_REPUTATIONS_COUNT
Definition QuestDef.h:41
#define QUEST_SOURCE_ITEM_IDS_COUNT
Definition QuestDef.h:37
#define QUEST_REWARD_CHOICES_COUNT
Definition QuestDef.h:38
@ QUEST_SPECIAL_FLAGS_CAST
Definition QuestDef.h:165
@ QUEST_SPECIAL_FLAGS_TIMED
Definition QuestDef.h:178
@ QUEST_SPECIAL_FLAGS_DELIVER
Definition QuestDef.h:175
@ QUEST_SPECIAL_FLAGS_REPEATABLE
Definition QuestDef.h:160
@ QUEST_SPECIAL_FLAGS_KILL
Definition QuestDef.h:177
@ QUEST_SPECIAL_FLAGS_DB_ALLOWED
Definition QuestDef.h:171
@ QUEST_SPECIAL_FLAGS_SPEAKTO
Definition QuestDef.h:176
@ QUEST_SPECIAL_FLAGS_MONTHLY
Definition QuestDef.h:164
@ QUEST_SPECIAL_FLAGS_PLAYER_KILL
Definition QuestDef.h:179
@ SPELL_EFFECT_QUEST_COMPLETE
Definition SharedDefines.h:805
uint32 SkillByQuestSort(int32 QuestSort)
Definition SharedDefines.h:3280
ExclusiveQuestGroups mExclusiveQuestGroups
Definition ObjectMgr.h:1146
uint32 ItemDropQuantity[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition QuestDef.h:303
uint32 RewardMailDelay
Definition QuestDef.h:394
uint32 RewardMailSenderEntry
Definition QuestDef.h:402
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:304
uint32 RequiredMaxRepFaction
Definition QuestDef.h:399
uint32 SourceSpellid
Definition QuestDef.h:389
uint32 RequiredMinRepFaction
Definition QuestDef.h:397
int32 RequiredFactionValue2
Definition QuestDef.h:355
int32 RequiredFactionValue1
Definition QuestDef.h:353
int32 ZoneOrSort
Definition QuestDef.h:347
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:305
uint32 StartItemCount
Definition QuestDef.h:401
void SetSpecialFlag(uint32 flag)
Definition QuestDef.h:225
uint32 GetCharTitleId() const
Definition QuestDef.h:253
uint32 RewardTitleId
Definition QuestDef.h:359
uint32 RewardItemIdCount[QUEST_REWARDS_COUNT]
Definition QuestDef.h:309
uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT]
Definition QuestDef.h:306
uint32 NextQuestId
Definition QuestDef.h:391
uint32 RewardMailTemplateId
Definition QuestDef.h:393
uint32 ItemDrop[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition QuestDef.h:302
int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT]
Definition QuestDef.h:312
uint32 RequiredSkillPoints
Definition QuestDef.h:396
int32 RewardSpell
Definition QuestDef.h:378
uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]
Definition QuestDef.h:307
uint32 AllowableRaces
Definition QuestDef.h:351
uint32 RewardNextQuest
Definition QuestDef.h:363
uint32 RequiredPlayerKills
Definition QuestDef.h:360
int32 GetPrevQuestId() const
Definition QuestDef.h:249
uint32 StartItem
Definition QuestDef.h:365
uint32 GetQuestId() const
Definition QuestDef.h:228
int32 RequiredMaxRepValue
Definition QuestDef.h:400
uint32 RequiredClasses
Definition QuestDef.h:388
uint32 Flags
Definition QuestDef.h:358
uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]
Definition QuestDef.h:301
uint32 TimeAllowed
Definition QuestDef.h:357
uint32 RequiredFactionId1
Definition QuestDef.h:352
uint32 RequiredFactionId2
Definition QuestDef.h:354
PrevQuests prevQuests
Definition QuestDef.h:324
uint32 RewardDisplaySpell
Definition QuestDef.h:377
uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]
Definition QuestDef.h:300
int32 PrevQuestId
Definition QuestDef.h:390
uint32 GetNextQuestId() const
Definition QuestDef.h:250
uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT]
Definition QuestDef.h:310
int32 ExclusiveGroup
Definition QuestDef.h:392
uint32 RequiredSkillId
Definition QuestDef.h:395
int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT]
Definition QuestDef.h:311
uint32 RewardItemId[QUEST_REWARDS_COUNT]
Definition QuestDef.h:308
uint32 GetQuestMethod() const
Definition QuestDef.h:229
int32 RequiredMinRepValue
Definition QuestDef.h:398
uint32 SpecialFlags
Definition QuestDef.h:403
static const int32 Reputation_Cap
Definition ReputationMgr.h:67
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:393
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(), GetCreatureTemplate(), GetGameObjectTemplate(), GetItemTemplate(), getMSTime(), GetMSTimeDiffToNow(), Quest::GetNextQuestId(), Quest::GetPrevQuestId(), Quest::GetQuestId(), Quest::GetQuestMethod(), GetQuestTemplate(), GetTalentSpellCost(), Quest::HasSpecialFlag(), SpellInfo::Id, Quest::ItemDrop, Quest::ItemDropQuantity, LOG_ERROR, LOG_INFO, LOG_WARN, MAX_SPELL_EFFECTS, mExclusiveQuestGroups, Quest::NextQuestId, Quest::PrevQuestId, Quest::prevQuests, QUEST_FLAGS_DAILY, QUEST_FLAGS_TRACKING, QUEST_FLAGS_WEEKLY, QUEST_ITEM_OBJECTIVES_COUNT, QUEST_OBJECTIVES_COUNT, QUEST_REPUTATIONS_COUNT, QUEST_REWARD_CHOICES_COUNT, QUEST_REWARDS_COUNT, QUEST_SOURCE_ITEM_IDS_COUNT, QUEST_SPECIAL_FLAGS_CAST, QUEST_SPECIAL_FLAGS_DB_ALLOWED, QUEST_SPECIAL_FLAGS_DELIVER, QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT, QUEST_SPECIAL_FLAGS_KILL, QUEST_SPECIAL_FLAGS_MONTHLY, QUEST_SPECIAL_FLAGS_PLAYER_KILL, QUEST_SPECIAL_FLAGS_REPEATABLE, QUEST_SPECIAL_FLAGS_SPEAKTO, QUEST_SPECIAL_FLAGS_TIMED, RACEMASK_ALL_PLAYABLE, ReputationMgr::Reputation_Cap, Quest::RequiredClasses, Quest::RequiredFactionId1, Quest::RequiredFactionId2, Quest::RequiredFactionValue1, Quest::RequiredFactionValue2, Quest::RequiredItemCount, Quest::RequiredItemId, Quest::RequiredMaxRepFaction, Quest::RequiredMaxRepValue, Quest::RequiredMinRepFaction, Quest::RequiredMinRepValue, Quest::RequiredNpcOrGo, Quest::RequiredNpcOrGoCount, Quest::RequiredPlayerKills, Quest::RequiredSkillId, Quest::RequiredSkillPoints, Quest::RewardChoiceItemCount, Quest::RewardChoiceItemId, Quest::RewardDisplaySpell, Quest::RewardFactionId, Quest::RewardFactionValueId, Quest::RewardFactionValueIdOverride, Quest::RewardItemId, Quest::RewardItemIdCount, Quest::RewardMailDelay, Quest::RewardMailSenderEntry, Quest::RewardMailTemplateId, Quest::RewardNextQuest, Quest::RewardSpell, Quest::RewardTitleId, sAreaTableStore, sCharTitlesStore, sDisableMgr, Quest::SetSpecialFlag(), sFactionStore, SkillByQuestSort(), sMailTemplateStore, 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
957 {
958 LOG_INFO("server.loading", "Loading GO Start Quest Data...");
960 LOG_INFO("server.loading", "Loading GO End Quest Data...");
962 LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
964 LOG_INFO("server.loading", "Loading Creature End Quest Data...");
966 }
void LoadCreatureQuestEnders()
Definition ObjectMgr.cpp:8329
void LoadGameobjectQuestEnders()
Definition ObjectMgr.cpp:8301
void LoadGameobjectQuestStarters()
Definition ObjectMgr.cpp:8287
void LoadCreatureQuestStarters()
Definition ObjectMgr.cpp:8315

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

◆ LoadReferenceVendor()

int ObjectMgr::LoadReferenceVendor ( int32  vendor,
int32  item_id,
std::set< uint32 > *  skip_vendors 
)
9438{
9439 // find all items from the reference vendor
9441 stmt->SetData(0, uint32(item));
9442 PreparedQueryResult result = WorldDatabase.Query(stmt);
9443
9444 if (!result)
9445 return 0;
9446
9447 uint32 count = 0;
9448 do
9449 {
9450 Field* fields = result->Fetch();
9451
9452 int32 item_id = fields[0].Get<int32>();
9453
9454 // if item is a negative, its a reference
9455 if (item_id < 0)
9456 count += LoadReferenceVendor(vendor, -item_id, skip_vendors);
9457 else
9458 {
9459 int32 maxcount = fields[1].Get<uint8>();
9460 uint32 incrtime = fields[2].Get<uint32>();
9461 uint32 ExtendedCost = fields[3].Get<uint32>();
9462
9463 if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, nullptr, skip_vendors))
9464 continue;
9465
9466 VendorItemData& vList = _cacheVendorItemStore[vendor];
9467
9468 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9469 ++count;
9470 }
9471 } while (result->NextRow());
9472
9473 return count;
9474}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
@ WORLD_SEL_NPC_VENDOR_REF
Definition WorldDatabase.h:45
bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player *player=nullptr, std::set< uint32 > *skip_vendors=nullptr, uint32 ORnpcflag=0) const
Definition ObjectMgr.cpp:9677
int LoadReferenceVendor(int32 vendor, int32 item_id, std::set< uint32 > *skip_vendors)
Definition ObjectMgr.cpp:9437

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 ( )
7834{
7835 uint32 oldMSTime = getMSTime();
7836
7837 // For reload case
7838 _repOnKillStore.clear();
7839
7840 uint32 count = 0;
7841
7842 // 0 1 2
7843 QueryResult result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2, "
7844 // 3 4 5 6 7 8 9
7845 "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
7846 "FROM creature_onkill_reputation");
7847
7848 if (!result)
7849 {
7850 LOG_WARN("server.loading", ">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
7851 LOG_INFO("server.loading", " ");
7852 return;
7853 }
7854
7855 do
7856 {
7857 Field* fields = result->Fetch();
7858
7859 uint32 creature_id = fields[0].Get<uint32>();
7860
7861 ReputationOnKillEntry repOnKill;
7862 repOnKill.RepFaction1 = fields[1].Get<int16>();
7863 repOnKill.RepFaction2 = fields[2].Get<int16>();
7864 repOnKill.IsTeamAward1 = fields[3].Get<bool>();
7865 repOnKill.ReputationMaxCap1 = fields[4].Get<uint8>();
7866 repOnKill.RepValue1 = fields[5].Get<float>();
7867 repOnKill.IsTeamAward2 = fields[6].Get<bool>();
7868 repOnKill.ReputationMaxCap2 = fields[7].Get<uint8>();
7869 repOnKill.RepValue2 = fields[8].Get<float>();
7870 repOnKill.TeamDependent = fields[9].Get<uint8>();
7871
7872 if (!GetCreatureTemplate(creature_id))
7873 {
7874 LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry ({}), skipped", creature_id);
7875 continue;
7876 }
7877
7878 if (repOnKill.RepFaction1)
7879 {
7880 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.RepFaction1);
7881 if (!factionEntry1)
7882 {
7883 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction1);
7884 continue;
7885 }
7886 }
7887
7888 if (repOnKill.RepFaction2)
7889 {
7890 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.RepFaction2);
7891 if (!factionEntry2)
7892 {
7893 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `creature_onkill_reputation`", repOnKill.RepFaction2);
7894 continue;
7895 }
7896 }
7897
7898 _repOnKillStore[creature_id] = repOnKill;
7899
7900 ++count;
7901 } while (result->NextRow());
7902
7903 LOG_INFO("server.loading", ">> Loaded {} Creature Award Reputation Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7904 LOG_INFO("server.loading", " ");
7905}
Definition ObjectMgr.h:569
uint32 RepFaction1
Definition ObjectMgr.h:570

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

◆ LoadReputationRewardRate()

void ObjectMgr::LoadReputationRewardRate ( )
7746{
7747 uint32 oldMSTime = getMSTime();
7748
7749 _repRewardRateStore.clear(); // for reload case
7750
7751 uint32 count = 0; // 0 1 2 3 4 5 6 7
7752 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");
7753 if (!result)
7754 {
7755 LOG_INFO("server.loading", ">> Loaded `reputation_reward_rate`, table is empty!");
7756 return;
7757 }
7758
7759 do
7760 {
7761 Field* fields = result->Fetch();
7762
7763 uint32 factionId = fields[0].Get<uint32>();
7764
7765 RepRewardRate repRate;
7766
7767 repRate.questRate = fields[1].Get<float>();
7768 repRate.questDailyRate = fields[2].Get<float>();
7769 repRate.questWeeklyRate = fields[3].Get<float>();
7770 repRate.questMonthlyRate = fields[4].Get<float>();
7771 repRate.questRepeatableRate = fields[5].Get<float>();
7772 repRate.creatureRate = fields[6].Get<float>();
7773 repRate.spellRate = fields[7].Get<float>();
7774
7775 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7776 if (!factionEntry)
7777 {
7778 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_reward_rate`", factionId);
7779 continue;
7780 }
7781
7782 if (repRate.questRate < 0.0f)
7783 {
7784 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_rate with invalid rate {}, skipping data for faction {}", repRate.questRate, factionId);
7785 continue;
7786 }
7787
7788 if (repRate.questDailyRate < 0.0f)
7789 {
7790 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_daily_rate with invalid rate {}, skipping data for faction {}", repRate.questDailyRate, factionId);
7791 continue;
7792 }
7793
7794 if (repRate.questWeeklyRate < 0.0f)
7795 {
7796 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_weekly_rate with invalid rate {}, skipping data for faction {}", repRate.questWeeklyRate, factionId);
7797 continue;
7798 }
7799
7800 if (repRate.questMonthlyRate < 0.0f)
7801 {
7802 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_monthly_rate with invalid rate {}, skipping data for faction {}", repRate.questMonthlyRate, factionId);
7803 continue;
7804 }
7805
7806 if (repRate.questRepeatableRate < 0.0f)
7807 {
7808 LOG_ERROR("sql.sql", "Table reputation_reward_rate has quest_repeatable_rate with invalid rate {}, skipping data for faction {}", repRate.questRepeatableRate, factionId);
7809 continue;
7810 }
7811
7812 if (repRate.creatureRate < 0.0f)
7813 {
7814 LOG_ERROR("sql.sql", "Table reputation_reward_rate has creature_rate with invalid rate {}, skipping data for faction {}", repRate.creatureRate, factionId);
7815 continue;
7816 }
7817
7818 if (repRate.spellRate < 0.0f)
7819 {
7820 LOG_ERROR("sql.sql", "Table reputation_reward_rate has spell_rate with invalid rate {}, skipping data for faction {}", repRate.spellRate, factionId);
7821 continue;
7822 }
7823
7824 _repRewardRateStore[factionId] = repRate;
7825
7826 ++count;
7827 } while (result->NextRow());
7828
7829 LOG_INFO("server.loading", ">> Loaded {} Reputation Reward Rate in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
7830 LOG_INFO("server.loading", " ");
7831}
Definition ObjectMgr.h:558
float questRate
Definition ObjectMgr.h:559

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

◆ LoadReputationSpilloverTemplate()

void ObjectMgr::LoadReputationSpilloverTemplate ( )
7908{
7909 uint32 oldMSTime = getMSTime();
7910
7911 _repSpilloverTemplateStore.clear(); // for reload case
7912
7913 uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
7914 QueryResult result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4, faction5, rate_5, rank_5, faction6, rate_6, rank_6 FROM reputation_spillover_template");
7915
7916 if (!result)
7917 {
7918 LOG_INFO("server.loading", ">> Loaded `reputation_spillover_template`, table is empty.");
7919 LOG_INFO("server.loading", " ");
7920 return;
7921 }
7922
7923 do
7924 {
7925 Field* fields = result->Fetch();
7926
7927 uint32 factionId = fields[0].Get<uint16>();
7928
7929 RepSpilloverTemplate repTemplate;
7930
7931 repTemplate.faction[0] = fields[1].Get<uint16>();
7932 repTemplate.faction_rate[0] = fields[2].Get<float>();
7933 repTemplate.faction_rank[0] = fields[3].Get<uint8>();
7934 repTemplate.faction[1] = fields[4].Get<uint16>();
7935 repTemplate.faction_rate[1] = fields[5].Get<float>();
7936 repTemplate.faction_rank[1] = fields[6].Get<uint8>();
7937 repTemplate.faction[2] = fields[7].Get<uint16>();
7938 repTemplate.faction_rate[2] = fields[8].Get<float>();
7939 repTemplate.faction_rank[2] = fields[9].Get<uint8>();
7940 repTemplate.faction[3] = fields[10].Get<uint16>();
7941 repTemplate.faction_rate[3] = fields[11].Get<float>();
7942 repTemplate.faction_rank[3] = fields[12].Get<uint8>();
7943 repTemplate.faction[4] = fields[13].Get<uint16>();
7944 repTemplate.faction_rate[4] = fields[14].Get<float>();
7945 repTemplate.faction_rank[4] = fields[15].Get<uint8>();
7946 repTemplate.faction[5] = fields[16].Get<uint16>();
7947 repTemplate.faction_rate[5] = fields[17].Get<float>();
7948 repTemplate.faction_rank[5] = fields[18].Get<uint8>();
7949
7950 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
7951
7952 if (!factionEntry)
7953 {
7954 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", factionId);
7955 continue;
7956 }
7957
7958 if (factionEntry->team == 0)
7959 {
7960 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} in `reputation_spillover_template` does not belong to any team, skipping", factionId);
7961 continue;
7962 }
7963
7964 for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
7965 {
7966 if (repTemplate.faction[i])
7967 {
7968 FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
7969
7970 if (!factionSpillover)
7971 {
7972 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);
7973 continue;
7974 }
7975
7976 if (factionSpillover->reputationListID < 0)
7977 {
7978 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);
7979 continue;
7980 }
7981
7982 if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
7983 {
7984 LOG_ERROR("sql.sql", "Rank {} used in `reputation_spillover_template` for spillover faction {} is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
7985 continue;
7986 }
7987 }
7988 }
7989
7990 FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
7991 if (repTemplate.faction[0] && !factionEntry0)
7992 {
7993 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
7994 continue;
7995 }
7996 FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
7997 if (repTemplate.faction[1] && !factionEntry1)
7998 {
7999 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
8000 continue;
8001 }
8002 FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
8003 if (repTemplate.faction[2] && !factionEntry2)
8004 {
8005 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
8006 continue;
8007 }
8008 FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
8009 if (repTemplate.faction[3] && !factionEntry3)
8010 {
8011 LOG_ERROR("sql.sql", "Faction (faction.dbc) {} does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
8012 continue;
8013 }
8014
8015 _repSpilloverTemplateStore[factionId] = repTemplate;
8016
8017 ++count;
8018 } while (result->NextRow());
8019
8020 LOG_INFO("server.loading", ">> Loaded {} Reputation Spillover Template in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8021 LOG_INFO("server.loading", " ");
8022}
#define MAX_SPILLOVER_FACTIONS
Definition SharedDefines.h:258
int32 reputationListID
Definition DBCStructure.h:909
Definition ObjectMgr.h:582
uint32 faction[MAX_SPILLOVER_FACTIONS]
Definition ObjectMgr.h:583

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

◆ LoadReservedPlayerNamesDB()

void ObjectMgr::LoadReservedPlayerNamesDB ( )
8344{
8345 uint32 oldMSTime = getMSTime();
8346
8347 _reservedNamesStore.clear(); // need for reload case
8348
8349 QueryResult result = CharacterDatabase.Query("SELECT name FROM reserved_name");
8350
8351 if (!result)
8352 {
8353 LOG_WARN("server.loading", ">> Loaded 0 reserved names. DB table `reserved_name` is empty!");
8354 return;
8355 }
8356
8357 uint32 count = 0;
8358
8359 Field* fields;
8360 do
8361 {
8362 fields = result->Fetch();
8363 std::string name = fields[0].Get<std::string>();
8364
8365 std::wstring wstr;
8366 if (!Utf8toWStr (name, wstr))
8367 {
8368 LOG_ERROR("sql.sql", "Table `reserved_name` have invalid name: {}", name);
8369 continue;
8370 }
8371
8372 wstrToLower(wstr);
8373
8374 _reservedNamesStore.insert(wstr);
8375 ++count;
8376 } while (result->NextRow());
8377
8378 LOG_INFO("server.loading", ">> Loaded {} reserved names from DB in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8379}

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

◆ LoadReservedPlayerNamesDBC()

void ObjectMgr::LoadReservedPlayerNamesDBC ( )
8382{
8383 if (!sWorld->getBoolConfig(CONFIG_STRICT_NAMES_RESERVED))
8384 {
8385 LOG_WARN("server.loading", ">> Loaded 0 reserved names from DBC. Config option disabled.");
8386 return;
8387 }
8388
8389 uint32 oldMSTime = getMSTime();
8390
8391 uint32 count = 0;
8392
8393 for (NamesReservedEntry const* reservedStore : sNamesReservedStore)
8394 {
8395 std::wstring wstr;
8396
8397 Utf8toWStr(reservedStore->Pattern, wstr);
8398
8399 // DBC does not have clean entries, remove the junk.
8400 boost::algorithm::replace_all(wstr, "\\<", "");
8401 boost::algorithm::replace_all(wstr, "\\>", "");
8402
8403 _reservedNamesStore.insert(wstr);
8404 count++;
8405 }
8406
8407 LOG_INFO("server.loading", ">> Loaded {} reserved names from DBC in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
8408 LOG_INFO("server.loading", " ");
8409}
DBCStorage< NamesReservedEntry > sNamesReservedStore(NamesReservedfmt)
@ CONFIG_STRICT_NAMES_RESERVED
Definition WorldConfig.h:141
Definition DBCStructure.h:1396

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

◆ LoadScriptNames()

void ObjectMgr::LoadScriptNames ( )
9758{
9759 uint32 oldMSTime = getMSTime();
9760
9761 // We insert an empty placeholder here so we can use the
9762 // script id 0 as dummy for "no script found".
9763 _scriptNamesStore.emplace_back("");
9764
9765 QueryResult result = WorldDatabase.Query(
9766 "SELECT DISTINCT(ScriptName) FROM achievement_criteria_data WHERE ScriptName <> '' AND type = 11 "
9767 "UNION "
9768 "SELECT DISTINCT(ScriptName) FROM battleground_template WHERE ScriptName <> '' "
9769 "UNION "
9770 "SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' "
9771 "UNION "
9772 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
9773 "UNION "
9774 "SELECT DISTINCT(ScriptName) FROM gameobject WHERE ScriptName <> '' "
9775 "UNION "
9776 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
9777 "UNION "
9778 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
9779 "UNION "
9780 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
9781 "UNION "
9782 "SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
9783 "UNION "
9784 "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' "
9785 "UNION "
9786 "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' "
9787 "UNION "
9788 "SELECT DISTINCT(ScriptName) FROM conditions WHERE ScriptName <> '' "
9789 "UNION "
9790 "SELECT DISTINCT(ScriptName) FROM outdoorpvp_template WHERE ScriptName <> '' "
9791 "UNION "
9792 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
9793
9794 if (!result)
9795 {
9796 LOG_INFO("server.loading", " ");
9797 LOG_ERROR("sql.sql", ">> Loaded empty set of Script Names!");
9798 return;
9799 }
9800
9801 _scriptNamesStore.reserve(result->GetRowCount() + 1);
9802
9803 do
9804 {
9805 _scriptNamesStore.push_back((*result)[0].Get<std::string>());
9806 } while (result->NextRow());
9807
9808 std::sort(_scriptNamesStore.begin(), _scriptNamesStore.end());
9809 LOG_INFO("server.loading", ">> Loaded {} ScriptNames in {} ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
9810 LOG_INFO("server.loading", " ");
9811}

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

◆ LoadScripts()

void ObjectMgr::LoadScripts ( ScriptsType  type)
private
5399{
5400 uint32 oldMSTime = getMSTime();
5401
5402 ScriptMapMap* scripts = GetScriptsMapByType(type);
5403 if (!scripts)
5404 return;
5405
5406 std::string tableName = GetScriptsTableNameByType(type);
5407 if (tableName.empty())
5408 return;
5409
5410 if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
5411 return;
5412
5413 LOG_INFO("server.loading", "Loading {}...", tableName);
5414
5415 scripts->clear(); // need for reload support
5416
5417 bool isSpellScriptTable = (type == SCRIPTS_SPELL);
5418 // 0 1 2 3 4 5 6 7 8 9
5419 QueryResult result = WorldDatabase.Query("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5420
5421 if (!result)
5422 {
5423 LOG_WARN("server.loading", ">> Loaded 0 script definitions. DB table `{}` is empty!", tableName);
5424 LOG_INFO("server.loading", " ");
5425 return;
5426 }
5427
5428 uint32 count = 0;
5429
5430 do
5431 {
5432 Field* fields = result->Fetch();
5433 ScriptInfo tmp;
5434 tmp.type = type;
5435 tmp.id = fields[0].Get<uint32>();
5436 if (isSpellScriptTable)
5437 tmp.id |= fields[10].Get<uint8>() << 24;
5438 tmp.delay = fields[1].Get<uint32>();
5439 tmp.command = ScriptCommands(fields[2].Get<uint32>());
5440 tmp.Raw.nData[0] = fields[3].Get<uint32>();
5441 tmp.Raw.nData[1] = fields[4].Get<uint32>();
5442 tmp.Raw.nData[2] = fields[5].Get<int32>();
5443 tmp.Raw.fData[0] = fields[6].Get<float>();
5444 tmp.Raw.fData[1] = fields[7].Get<float>();
5445 tmp.Raw.fData[2] = fields[8].Get<float>();
5446 tmp.Raw.fData[3] = fields[9].Get<float>();
5447
5448 // generic command args check
5449 switch (tmp.command)
5450 {
5452 {
5454 {
5455 LOG_ERROR("sql.sql", "Table `{}` has invalid talk type (datalong = {}) in SCRIPT_COMMAND_TALK for script id {}",
5456 tableName, tmp.Talk.ChatType, tmp.id);
5457 continue;
5458 }
5460 {
5461 LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}",
5462 tableName, tmp.Talk.TextID, tmp.id);
5463 continue;
5464 }
5465 break;
5466 }
5467
5469 {
5470 if (!sEmotesStore.LookupEntry(tmp.Emote.EmoteID))
5471 {
5472 LOG_ERROR("sql.sql", "Table `{}` has invalid emote id (datalong = {}) in SCRIPT_COMMAND_EMOTE for script id {}",
5473 tableName, tmp.Emote.EmoteID, tmp.id);
5474 continue;
5475 }
5476 break;
5477 }
5478
5480 {
5481 if (!sMapStore.LookupEntry(tmp.TeleportTo.MapID))
5482 {
5483 LOG_ERROR("sql.sql", "Table `{}` has invalid map (Id: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5484 tableName, tmp.TeleportTo.MapID, tmp.id);
5485 continue;
5486 }
5487
5489 {
5490 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TELEPORT_TO for script id {}",
5491 tableName, tmp.TeleportTo.DestX, tmp.TeleportTo.DestY, tmp.TeleportTo.DestZ, tmp.TeleportTo.Orientation, tmp.id);
5492 continue;
5493 }
5494 break;
5495 }
5496
5498 {
5499 Quest const* quest = GetQuestTemplate(tmp.QuestExplored.QuestID);
5500 if (!quest)
5501 {
5502 LOG_ERROR("sql.sql", "Table `{}` has invalid quest (ID: {}) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id {}",
5503 tableName, tmp.QuestExplored.QuestID, tmp.id);
5504 continue;
5505 }
5506
5508 {
5509 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.",
5510 tableName, tmp.QuestExplored.QuestID, tmp.id);
5511
5512 // this will prevent quest completing without objective
5513 const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT);
5514
5515 // continue; - quest objective requirement set and command can be allowed
5516 }
5517
5519 {
5520 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 {}",
5521 tableName, tmp.QuestExplored.Distance, tmp.id);
5522 continue;
5523 }
5524
5526 {
5527 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",
5529 continue;
5530 }
5531
5533 {
5534 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",
5535 tableName, tmp.QuestExplored.Distance, tmp.id, INTERACTION_DISTANCE);
5536 continue;
5537 }
5538
5539 break;
5540 }
5541
5543 {
5545 {
5546 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_KILL_CREDIT for script id {}",
5547 tableName, tmp.KillCredit.CreatureEntry, tmp.id);
5548 continue;
5549 }
5550 break;
5551 }
5552
5554 {
5556 if (!data)
5557 {
5558 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5559 tableName, tmp.RespawnGameobject.GOGuid, tmp.id);
5560 continue;
5561 }
5562
5563 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5564 if (!info)
5565 {
5566 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5567 tableName, tmp.RespawnGameobject.GOGuid, data->id, tmp.id);
5568 continue;
5569 }
5570
5571 if (info->type == GAMEOBJECT_TYPE_FISHINGNODE ||
5573 info->type == GAMEOBJECT_TYPE_DOOR ||
5574 info->type == GAMEOBJECT_TYPE_BUTTON ||
5575 info->type == GAMEOBJECT_TYPE_TRAP)
5576 {
5577 LOG_ERROR("sql.sql", "Table `{}` have gameobject type ({}) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id {}",
5578 tableName, info->entry, tmp.id);
5579 continue;
5580 }
5581 break;
5582 }
5583
5585 {
5587 {
5588 LOG_ERROR("sql.sql", "Table `{}` has invalid coordinates (X: {} Y: {} Z: {} O: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5590 continue;
5591 }
5592
5594 if (!GetCreatureTemplate(entry))
5595 {
5596 LOG_ERROR("sql.sql", "Table `{}` has invalid creature (Entry: {}) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id {}",
5597 tableName, tmp.TempSummonCreature.CreatureEntry, tmp.id);
5598 continue;
5599 }
5600 break;
5601 }
5602
5605 {
5607 if (!data)
5608 {
5609 LOG_ERROR("sql.sql", "Table `{}` has invalid gameobject (GUID: {}) in {} for script id {}",
5610 tableName, tmp.ToggleDoor.GOGuid, GetScriptCommandName(tmp.command), tmp.id);
5611 continue;
5612 }
5613
5614 GameObjectTemplate const* info = GetGameObjectTemplate(data->id);
5615 if (!info)
5616 {
5617 LOG_ERROR("sql.sql", "Table `{}` has gameobject with invalid entry (GUID: {} Entry: {}) in {} for script id {}",
5618 tableName, tmp.ToggleDoor.GOGuid, data->id, GetScriptCommandName(tmp.command), tmp.id);
5619 continue;
5620 }
5621
5622 if (info->type != GAMEOBJECT_TYPE_DOOR)
5623 {
5624 LOG_ERROR("sql.sql", "Table `{}` has gameobject type ({}) non supported by command {} for script id {}",
5625 tableName, info->entry, GetScriptCommandName(tmp.command), tmp.id);
5626 continue;
5627 }
5628
5629 break;
5630 }
5631
5633 {
5634 if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
5635 {
5636 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5637 tableName, tmp.RemoveAura.SpellID, tmp.id);
5638 continue;
5639 }
5640 if (tmp.RemoveAura.Flags & ~0x1) // 1 bits (0, 1)
5641 {
5642 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in datalong2 ({}) in SCRIPT_COMMAND_REMOVE_AURA for script id {}",
5643 tableName, tmp.RemoveAura.Flags, tmp.id);
5644 continue;
5645 }
5646 break;
5647 }
5648
5650 {
5651 if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
5652 {
5653 LOG_ERROR("sql.sql", "Table `{}` using non-existent spell (id: {}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5654 tableName, tmp.CastSpell.SpellID, tmp.id);
5655 continue;
5656 }
5657 if (tmp.CastSpell.Flags > 4) // targeting type
5658 {
5659 LOG_ERROR("sql.sql", "Table `{}` using unknown target in datalong2 ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5660 tableName, tmp.CastSpell.Flags, tmp.id);
5661 continue;
5662 }
5663 if (tmp.CastSpell.Flags != 4 && tmp.CastSpell.CreatureEntry & ~0x1) // 1 bit (0, 1)
5664 {
5665 LOG_ERROR("sql.sql", "Table `{}` using unknown flags in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5666 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5667 continue;
5668 }
5669 else if (tmp.CastSpell.Flags == 4 && !GetCreatureTemplate(tmp.CastSpell.CreatureEntry))
5670 {
5671 LOG_ERROR("sql.sql", "Table `{}` using invalid creature entry in dataint ({}) in SCRIPT_COMMAND_CAST_SPELL for script id {}",
5672 tableName, tmp.CastSpell.CreatureEntry, tmp.id);
5673 continue;
5674 }
5675 break;
5676 }
5677
5679 {
5681 {
5682 LOG_ERROR("sql.sql", "Table `{}` has nonexistent item (entry: {}) in SCRIPT_COMMAND_CREATE_ITEM for script id {}",
5683 tableName, tmp.CreateItem.ItemEntry, tmp.id);
5684 continue;
5685 }
5686 if (!tmp.CreateItem.Amount)
5687 {
5688 LOG_ERROR("sql.sql", "Table `{}` SCRIPT_COMMAND_CREATE_ITEM but amount is {} for script id {}",
5689 tableName, tmp.CreateItem.Amount, tmp.id);
5690 continue;
5691 }
5692 break;
5693 }
5694 default:
5695 break;
5696 }
5697
5698 if (scripts->find(tmp.id) == scripts->end())
5699 {
5700 ScriptMap emptyMap;
5701 (*scripts)[tmp.id] = emptyMap;
5702 }
5703 (*scripts)[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
5704
5705 ++count;
5706 } while (result->NextRow());
5707
5708 LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5709 LOG_INFO("server.loading", " ");
5710}
@ CHAT_TYPE_WHISPER
Definition CreatureData.h:421
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
#define INTERACTION_DISTANCE
Definition ObjectDefines.h:24
std::multimap< uint32, ScriptInfo > ScriptMap
Definition ObjectMgr.h:386
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition ObjectMgr.cpp:83
ScriptCommands
Definition ObjectMgr.h:92
@ SCRIPT_COMMAND_EMOTE
Definition ObjectMgr.h:94
@ SCRIPT_COMMAND_CREATE_ITEM
Definition ObjectMgr.h:110
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition ObjectMgr.h:105
@ SCRIPT_COMMAND_CAST_SPELL
Definition ObjectMgr.h:108
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition ObjectMgr.h:102
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition ObjectMgr.h:100
@ SCRIPT_COMMAND_TALK
Definition ObjectMgr.h:93
@ SCRIPT_COMMAND_OPEN_DOOR
Definition ObjectMgr.h:104
@ SCRIPT_COMMAND_TELEPORT_TO
Definition ObjectMgr.h:99
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition ObjectMgr.h:103
@ SCRIPT_COMMAND_KILL_CREDIT
Definition ObjectMgr.h:101
@ SCRIPT_COMMAND_REMOVE_AURA
Definition ObjectMgr.h:107
std::string GetScriptCommandName(ScriptCommands command)
Definition ObjectMgr.cpp:103
std::map< uint32, ScriptMap > ScriptMapMap
Definition ObjectMgr.h:387
std::string GetScriptsTableNameByType(ScriptsType type)
Definition ObjectMgr.cpp:63
@ SCRIPTS_SPELL
Definition ObjectMgr.h:149
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1588
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3434
Definition ObjectMgr.h:191
float Orientation
Definition ObjectMgr.h:251
uint32 Flags
Definition ObjectMgr.h:208
struct ScriptInfo::@268::@272 Emote
ScriptsType type
Definition ObjectMgr.h:192
uint32 QuestID
Definition ObjectMgr.h:256
struct ScriptInfo::@268::@283 CastSpell
int32 TextID
Definition ObjectMgr.h:209
float DestX
Definition ObjectMgr.h:230
uint32 ItemEntry
Definition ObjectMgr.h:317
struct ScriptInfo::@268::@279 RespawnGameobject
uint32 ChatType
Definition ObjectMgr.h:207
struct ScriptInfo::@268::@281 ToggleDoor
uint32 id
Definition ObjectMgr.h:193
uint32 delay
Definition ObjectMgr.h:194
float fData[4]
Definition ObjectMgr.h:202
struct ScriptInfo::@268::@285 CreateItem
struct ScriptInfo::@268::@278 KillCredit
float PosY
Definition ObjectMgr.h:279
ScriptCommands command
Definition ObjectMgr.h:195
float DestY
Definition ObjectMgr.h:231
uint32 MapID
Definition ObjectMgr.h:244
uint32 nData[3]
Definition ObjectMgr.h:201
struct ScriptInfo::@268::@271 Talk
struct ScriptInfo::@268::@282 RemoveAura
float PosZ
Definition ObjectMgr.h:280
struct ScriptInfo::@268::@276 TeleportTo
float PosX
Definition ObjectMgr.h:278
struct ScriptInfo::@268::@270 Raw
uint32 Distance
Definition ObjectMgr.h:257
uint32 SpellID
Definition ObjectMgr.h:295
float DestZ
Definition ObjectMgr.h:232
struct ScriptInfo::@268::@280 TempSummonCreature
struct ScriptInfo::@268::@277 QuestExplored
uint32 GOGuid
Definition ObjectMgr.h:268
uint32 CreatureEntry
Definition ObjectMgr.h:262
uint32 Amount
Definition ObjectMgr.h:318
uint32 EmoteID
Definition ObjectMgr.h:214

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

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

◆ LoadSpellScriptNames()

void ObjectMgr::LoadSpellScriptNames ( )
5812{
5813 uint32 oldMSTime = getMSTime();
5814
5815 _spellScriptsStore.clear(); // need for reload case
5816
5817 QueryResult result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
5818
5819 if (!result)
5820 {
5821 LOG_WARN("server.loading", ">> Loaded 0 spell script names. DB table `spell_script_names` is empty!");
5822 LOG_INFO("server.loading", " ");
5823 return;
5824 }
5825
5826 uint32 count = 0;
5827
5828 do
5829 {
5830 Field* fields = result->Fetch();
5831
5832 int32 spellId = fields[0].Get<int32>();
5833 std::string scriptName = fields[1].Get<std::string>();
5834
5835 bool allRanks = false;
5836 if (spellId <= 0)
5837 {
5838 allRanks = true;
5839 spellId = -spellId;
5840 }
5841
5842 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5843 if (!spellInfo)
5844 {
5845 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) does not exist in `Spell.dbc`.", scriptName, fields[0].Get<int32>());
5846 continue;
5847 }
5848
5849 if (allRanks)
5850 {
5851 if (sSpellMgr->GetFirstSpellInChain(spellId) != uint32(spellId))
5852 {
5853 LOG_ERROR("sql.sql", "Scriptname: `{}` spell (spell_id:{}) is not first rank of spell.", scriptName, fields[0].Get<int32>());
5854 continue;
5855 }
5856 while (spellInfo)
5857 {
5858 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5859 spellInfo = spellInfo->GetNextRankSpell();
5860 }
5861 }
5862 else
5863 _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
5864 ++count;
5865 } while (result->NextRow());
5866
5867 LOG_INFO("server.loading", ">> Loaded {} spell script names in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5868 LOG_INFO("server.loading", " ");
5869}
SpellInfo const * GetNextRankSpell() const
Definition SpellInfo.cpp:2409

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

◆ LoadSpellScripts()

void ObjectMgr::LoadSpellScripts ( )
5713{
5715
5716 // check ids
5717 for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
5718 {
5719 uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
5720 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5721
5722 if (!spellInfo)
5723 {
5724 LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
5725 continue;
5726 }
5727
5728 SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
5729 if (uint32(i) >= MAX_SPELL_EFFECTS)
5730 {
5731 LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
5732 }
5733
5734 //check for correct spellEffect
5735 if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
5736 LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
5737 }
5738}
ScriptMapMap sSpellScripts
Definition ObjectMgr.cpp:59
SpellEffIndex
Definition SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:792
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:866

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 ( )
6652{
6653 uint32 oldMSTime = getMSTime();
6654
6655 _tavernAreaTriggerStore.clear(); // need for reload case
6656
6657 QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
6658
6659 if (!result)
6660 {
6661 LOG_WARN("server.loading", ">> Loaded 0 tavern triggers. DB table `areatrigger_tavern` is empty.");
6662 LOG_INFO("server.loading", " ");
6663 return;
6664 }
6665
6666 uint32 count = 0;
6667
6668 do
6669 {
6670 ++count;
6671
6672 Field* fields = result->Fetch();
6673
6674 uint32 Trigger_ID = fields[0].Get<uint32>();
6675
6676 AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
6677 if (!atEntry)
6678 {
6679 LOG_ERROR("sql.sql", "Area trigger (ID:{}) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
6680 continue;
6681 }
6682
6683 uint32 faction = fields[1].Get<uint32>();
6684
6685 _tavernAreaTriggerStore.emplace(Trigger_ID, faction);
6686 } while (result->NextRow());
6687
6688 LOG_INFO("server.loading", ">> Loaded {} Tavern Triggers in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
6689 LOG_INFO("server.loading", " ");
6690}

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

◆ LoadTempSummons()

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

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

◆ LoadTrainers()

void ObjectMgr::LoadTrainers ( )
9284{
9285 uint32 oldMSTime = getMSTime();
9286
9287 // For reload case
9288 _trainers.clear();
9289
9290 std::unordered_map<int32, std::vector<Trainer::Spell>> spellsByTrainer;
9291 if (QueryResult trainerSpellsResult = WorldDatabase.Query("SELECT TrainerId, SpellId, MoneyCost, ReqSkillLine, ReqSkillRank, ReqAbility1, ReqAbility2, ReqAbility3, ReqLevel FROM trainer_spell"))
9292 {
9293 do
9294 {
9295 Field* fields = trainerSpellsResult->Fetch();
9296
9297 Trainer::Spell spell;
9298 uint32 trainerId = fields[0].Get<uint32>();
9299 spell.SpellId = fields[1].Get<uint32>();
9300 spell.MoneyCost = fields[2].Get<uint32>();
9301 spell.ReqSkillLine = fields[3].Get<uint32>();
9302 spell.ReqSkillRank = fields[4].Get<uint32>();
9303 spell.ReqAbility[0] = fields[5].Get<uint32>();
9304 spell.ReqAbility[1] = fields[6].Get<uint32>();
9305 spell.ReqAbility[2] = fields[7].Get<uint32>();
9306 spell.ReqLevel = fields[8].Get<uint8>();
9307
9308 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.SpellId);
9309 if (!spellInfo)
9310 {
9311 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: {}) for TrainerId {}, ignoring", spell.SpellId, trainerId);
9312 continue;
9313 }
9314
9315 if (GetTalentSpellCost(spell.SpellId))
9316 {
9317 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: {}) which is a talent, for TrainerId {}, ignoring", spell.SpellId, trainerId);
9318 continue;
9319 }
9320
9321 if (spell.ReqSkillLine && !sSkillLineStore.LookupEntry(spell.ReqSkillLine))
9322 {
9323 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing skill (ReqSkillLine: {}) for TrainerId {} and SpellId {}, ignoring",
9324 spell.ReqSkillLine, spell.SpellId, trainerId);
9325 continue;
9326 }
9327
9328 bool allReqValid = true;
9329 for (std::size_t i = 0; i < spell.ReqAbility.size(); ++i)
9330 {
9331 uint32 requiredSpell = spell.ReqAbility[i];
9332 if (requiredSpell && !sSpellMgr->GetSpellInfo(requiredSpell))
9333 {
9334 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (ReqAbility {} : {}) for TrainerId {} and SpellId {}, ignoring",
9335 i + 1, requiredSpell, trainerId, spell.SpellId);
9336 allReqValid = false;
9337 }
9338 }
9339
9340 if (!allReqValid)
9341 continue;
9342
9343 spellsByTrainer[trainerId].push_back(spell);
9344 } while (trainerSpellsResult->NextRow());
9345 }
9346
9347 if (QueryResult trainersResult = WorldDatabase.Query("SELECT Id, Type, Requirement, Greeting FROM trainer"))
9348 {
9349 do
9350 {
9351 Field* fields = trainersResult->Fetch();
9352
9353 uint32 trainerId = fields[0].Get<uint32>();
9354 Trainer::Type trainerType = Trainer::Type(fields[1].Get<uint8>());
9355 uint32 requirement = fields[2].Get<uint32>();
9356 std::string greeting = fields[3].Get<std::string>();
9357 std::vector<Trainer::Spell> spells;
9358 auto spellsItr = spellsByTrainer.find(trainerId);
9359 if (spellsItr != spellsByTrainer.end())
9360 {
9361 spells = std::move(spellsItr->second);
9362 spellsByTrainer.erase(spellsItr);
9363 }
9364
9365 _trainers.emplace(std::piecewise_construct, std::forward_as_tuple(trainerId), std::forward_as_tuple(trainerId, trainerType, requirement, std::move(greeting), std::move(spells)));
9366 } while (trainersResult->NextRow());
9367 }
9368
9369 for (auto const& unusedSpells : spellsByTrainer)
9370 {
9371 for (Trainer::Spell const& unusedSpell : unusedSpells.second)
9372 {
9373 LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing trainer (TrainerId: {}) for SpellId {}, ignoring", unusedSpells.first, unusedSpell.SpellId);
9374 }
9375 }
9376
9377 if (QueryResult trainerLocalesResult = WorldDatabase.Query("SELECT Id, locale, Greeting_lang FROM trainer_locale"))
9378 {
9379 do
9380 {
9381 Field* fields = trainerLocalesResult->Fetch();
9382 uint32 trainerId = fields[0].Get<uint32>();
9383 std::string localeName = fields[1].Get<std::string>();
9384
9385 LocaleConstant locale = GetLocaleByName(localeName);
9386 if (locale == LOCALE_enUS)
9387 continue;
9388
9390 trainer->AddGreetingLocale(locale, fields[2].Get<std::string>());
9391 else
9392 LOG_ERROR("sql.sql", "Table `trainer_locale` references non-existing trainer (TrainerId: {}) for locale %s, ignoring",
9393 trainerId, localeName.c_str());
9394 } while (trainerLocalesResult->NextRow());
9395 }
9396
9397 LOG_INFO("server.loading", ">> Loaded {} Trainers in {} ms", _trainers.size(), GetMSTimeDiffToNow(oldMSTime));
9398}
Definition Trainer.h:66
Type
Definition Trainer.h:32
Definition Trainer.h:54
uint32 ReqSkillLine
Definition Trainer.h:57
std::array< uint32, 3 > ReqAbility
Definition Trainer.h:59
uint8 ReqLevel
Definition Trainer.h:60
uint32 ReqSkillRank
Definition Trainer.h:58
uint32 SpellId
Definition Trainer.h:55
uint32 MoneyCost
Definition Trainer.h:56

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

◆ LoadVehicleAccessories()

void ObjectMgr::LoadVehicleAccessories ( )
3631{
3632 uint32 oldMSTime = getMSTime();
3633
3634 _vehicleAccessoryStore.clear(); // needed for reload case
3635
3636 uint32 count = 0;
3637
3638 // 0 1 2 3 4 5
3639 QueryResult result = WorldDatabase.Query("SELECT `guid`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_accessory`");
3640
3641 if (!result)
3642 {
3643 LOG_WARN("server.loading", ">> Loaded 0 Vehicle Accessories in {} ms", GetMSTimeDiffToNow(oldMSTime));
3644 LOG_INFO("server.loading", " ");
3645 return;
3646 }
3647
3648 do
3649 {
3650 Field* fields = result->Fetch();
3651
3652 uint32 uiGUID = fields[0].Get<uint32>();
3653 uint32 uiAccessory = fields[1].Get<uint32>();
3654 int8 uiSeat = int8(fields[2].Get<int16>());
3655 bool bMinion = fields[3].Get<bool>();
3656 uint8 uiSummonType = fields[4].Get<uint8>();
3657 uint32 uiSummonTimer = fields[5].Get<uint32>();
3658
3659 if (!GetCreatureTemplate(uiAccessory))
3660 {
3661 LOG_ERROR("sql.sql", "Table `vehicle_accessory`: Accessory {} does not exist.", uiAccessory);
3662 continue;
3663 }
3664
3665 _vehicleAccessoryStore[uiGUID].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3666
3667 ++count;
3668 } while (result->NextRow());
3669
3670 LOG_INFO("server.loading", ">> Loaded {} Vehicle Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3671 LOG_INFO("server.loading", " ");
3672}
Definition VehicleDefines.h:115

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

◆ LoadVehicleSeatAddon()

void ObjectMgr::LoadVehicleSeatAddon ( )
3675{
3676 uint32 oldMSTime = getMSTime();
3677
3678 _vehicleSeatAddonStore.clear(); // needed for reload case
3679
3680 uint32 count = 0;
3681
3682 // 0 1 2 3 4 5 6
3683 QueryResult result = WorldDatabase.Query("SELECT `SeatEntry`, `SeatOrientation`, `ExitParamX`, `ExitParamY`, `ExitParamZ`, `ExitParamO`, `ExitParamValue` FROM `vehicle_seat_addon`");
3684
3685 if (!result)
3686 {
3687 LOG_ERROR("server.loading", ">> Loaded 0 vehicle seat addons. DB table `vehicle_seat_addon` is empty.");
3688 return;
3689 }
3690
3691 do
3692 {
3693 Field* fields = result->Fetch();
3694
3695 uint32 seatID = fields[0].Get<uint32>();
3696 float orientation = fields[1].Get<float>();
3697 float exitX = fields[2].Get<float>();
3698 float exitY = fields[3].Get<float>();
3699 float exitZ = fields[4].Get<float>();
3700 float exitO = fields[5].Get<float>();
3701 uint8 exitParam = fields[6].Get<uint8>();
3702
3703 if (!sVehicleSeatStore.LookupEntry(seatID))
3704 {
3705 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} does not exist in VehicleSeat.dbc. Skipping entry.", seatID);
3706 continue;
3707 }
3708
3709 // Sanitizing values
3710 if (orientation > float(M_PI * 2))
3711 {
3712 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid angle offset value ({}). Set Value to 0.", seatID, orientation);
3713 orientation = 0.0f;
3714 }
3715
3717 {
3718 LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid exit parameter value ({}). Setting to 0 (none).", seatID, exitParam);
3719 continue;
3720 }
3721
3722 _vehicleSeatAddonStore[seatID] = VehicleSeatAddon(orientation, exitX, exitY, exitZ, exitO, exitParam);
3723
3724 ++count;
3725 } while (result->NextRow());
3726
3727 LOG_INFO("server.loading", ">> Loaded {} Vehicle Seat Addon entries in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3728}
DBCStorage< VehicleSeatEntry > sVehicleSeatStore(VehicleSeatEntryfmt)
Definition VehicleDefines.h:86

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

◆ LoadVehicleTemplateAccessories()

void ObjectMgr::LoadVehicleTemplateAccessories ( )
3575{
3576 uint32 oldMSTime = getMSTime();
3577
3578 _vehicleTemplateAccessoryStore.clear(); // needed for reload case
3579
3580 uint32 count = 0;
3581
3582 // 0 1 2 3 4 5
3583 QueryResult result = WorldDatabase.Query("SELECT `entry`, `accessory_entry`, `seat_id`, `minion`, `summontype`, `summontimer` FROM `vehicle_template_accessory`");
3584
3585 if (!result)
3586 {
3587 LOG_WARN("server.loading", ">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
3588 LOG_INFO("server.loading", " ");
3589 return;
3590 }
3591
3592 do
3593 {
3594 Field* fields = result->Fetch();
3595
3596 uint32 uiEntry = fields[0].Get<uint32>();
3597 uint32 uiAccessory = fields[1].Get<uint32>();
3598 int8 uiSeat = int8(fields[2].Get<int8>());
3599 bool bMinion = fields[3].Get<bool>();
3600 uint8 uiSummonType = fields[4].Get<uint8>();
3601 uint32 uiSummonTimer = fields[5].Get<uint32>();
3602
3603 if (!GetCreatureTemplate(uiEntry))
3604 {
3605 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} does not exist.", uiEntry);
3606 continue;
3607 }
3608
3609 if (!GetCreatureTemplate(uiAccessory))
3610 {
3611 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: Accessory {} does not exist.", uiAccessory);
3612 continue;
3613 }
3614
3615 if (_spellClickInfoStore.find(uiEntry) == _spellClickInfoStore.end())
3616 {
3617 LOG_ERROR("sql.sql", "Table `vehicle_template_accessory`: creature template entry {} has no data in npc_spellclick_spells", uiEntry);
3618 continue;
3619 }
3620
3621 _vehicleTemplateAccessoryStore[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
3622
3623 ++count;
3624 } while (result->NextRow());
3625
3626 LOG_INFO("server.loading", ">> Loaded {} Vehicle Template Accessories in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
3627 LOG_INFO("server.loading", " ");
3628}

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

◆ LoadVendors()

void ObjectMgr::LoadVendors ( )
9477{
9478 uint32 oldMSTime = getMSTime();
9479
9480 // For reload case
9481 for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
9482 itr->second.Clear();
9483 _cacheVendorItemStore.clear();
9484
9485 std::set<uint32> skip_vendors;
9486
9487 QueryResult result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor ORDER BY entry, slot ASC, item, ExtendedCost");
9488 if (!result)
9489 {
9490 LOG_INFO("server.loading", " ");
9491 LOG_WARN("server.loading", ">> Loaded 0 Vendors. DB table `npc_vendor` is empty!");
9492 return;
9493 }
9494
9495 uint32 count = 0;
9496
9497 do
9498 {
9499 Field* fields = result->Fetch();
9500
9501 uint32 entry = fields[0].Get<uint32>();
9502 int32 item_id = fields[1].Get<int32>();
9503
9504 // if item is a negative, its a reference
9505 if (item_id < 0)
9506 count += LoadReferenceVendor(entry, -item_id, &skip_vendors);
9507 else
9508 {
9509 uint32 maxcount = fields[2].Get<uint8>();
9510 uint32 incrtime = fields[3].Get<uint32>();
9511 uint32 ExtendedCost = fields[4].Get<uint32>();
9512
9513 if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, nullptr, &skip_vendors))
9514 continue;
9515
9516 VendorItemData& vList = _cacheVendorItemStore[entry];
9517
9518 vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
9519 ++count;
9520 }
9521 } while (result->NextRow());
9522
9523 LOG_INFO("server.loading", ">> Loaded {} Vendors in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
9524 LOG_INFO("server.loading", " ");
9525}

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

◆ LoadWaypointScripts()

void ObjectMgr::LoadWaypointScripts ( )
5785{
5787
5788 std::set<uint32> actionSet;
5789
5790 for (ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
5791 actionSet.insert(itr->first);
5792
5794 PreparedQueryResult result = WorldDatabase.Query(stmt);
5795
5796 if (result)
5797 {
5798 do
5799 {
5800 Field* fields = result->Fetch();
5801 uint32 action = fields[0].Get<uint32>();
5802
5803 actionSet.erase(action);
5804 } while (result->NextRow());
5805 }
5806
5807 for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr)
5808 LOG_ERROR("sql.sql", "There is no waypoint which links to the waypoint script {}", *itr);
5809}
ScriptMapMap sWaypointScripts
Definition ObjectMgr.cpp:61
@ SCRIPTS_WAYPOINT
Definition ObjectMgr.h:151
@ WORLD_SEL_WAYPOINT_DATA_ACTION
Definition WorldDatabase.h:69

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

◆ NewGOData()

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

References _gameObjectDataStore.

Referenced by AddGOData().

◆ NewOrExistCreatureData()

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

References _creatureDataStore.

Referenced by AddCreData().

◆ PlayerCreateInfoAddItemHelper()

void ObjectMgr::PlayerCreateInfoAddItemHelper ( uint32  race_,
uint32  class_,
uint32  itemId,
int32  count 
)
private
3836{
3837 if (!_playerInfo[race_][class_])
3838 return;
3839
3840 if (count > 0)
3841 _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
3842 else
3843 {
3844 if (count < -1)
3845 LOG_ERROR("sql.sql", "Invalid count {} specified on item {} be removed from original player create info (use -1)!", count, itemId);
3846
3847 for (uint32 gender = 0; gender < GENDER_NONE; ++gender)
3848 {
3849 if (CharStartOutfitEntry const* entry = GetCharStartOutfitEntry(race_, class_, gender))
3850 {
3851 bool found = false;
3852 for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x)
3853 {
3854 if (entry->ItemId[x] > 0 && uint32(entry->ItemId[x]) == itemId)
3855 {
3856 found = true;
3857 const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0;
3858 break;
3859 }
3860 }
3861
3862 if (!found)
3863 LOG_ERROR("sql.sql", "Item {} specified to be removed from original create info not found in dbc!", itemId);
3864 }
3865 }
3866 }
3867}
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition DBCStores.cpp:842
Definition Player.h:267
PlayerCreateInfoItems item
Definition Player.h:335

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 
)
2469{
2470 uint8 mask = data->spawnMask;
2471 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2472 {
2473 if (mask & 1)
2474 {
2475 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2476 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2477 cell_guids.creatures.erase(guid);
2478 }
2479 }
2480}

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

Referenced by DeleteCreatureData().

◆ RemoveGameobjectFromGrid()

void ObjectMgr::RemoveGameobjectFromGrid ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
2775{
2776 uint8 mask = data->spawnMask;
2777 for (uint8 i = 0; mask != 0; i++, mask >>= 1)
2778 {
2779 if (mask & 1)
2780 {
2781 GridCoord gridCoord = Acore::ComputeGridCoord(data->posX, data->posY);
2782 CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapid, i)][gridCoord.GetId()];
2783 cell_guids.gameobjects.erase(guid);
2784 }
2785 }
2786}

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

Referenced by DeleteGOData().

◆ RemoveVendorItem()

bool ObjectMgr::RemoveVendorItem ( uint32  entry,
uint32  item,
bool  persist = true 
)
9656{
9657 CacheVendorItemContainer::iterator iter = _cacheVendorItemStore.find(entry);
9658 if (iter == _cacheVendorItemStore.end())
9659 return false;
9660
9661 if (!iter->second.RemoveItem(item))
9662 return false;
9663
9664 if (persist)
9665 {
9667
9668 stmt->SetData(0, entry);
9669 stmt->SetData(1, item);
9670
9671 WorldDatabase.Execute(stmt);
9672 }
9673
9674 return true;
9675}
@ WORLD_DEL_NPC_VENDOR
Definition WorldDatabase.h:44

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

◆ ReturnOrDeleteOldMails()

void ObjectMgr::ReturnOrDeleteOldMails ( bool  serverUp)
6280{
6281 uint32 oldMSTime = getMSTime();
6282
6283 time_t curTime = GameTime::GetGameTime().count();
6284
6286 stmt->SetData(0, uint32(curTime));
6287 PreparedQueryResult result = CharacterDatabase.Query(stmt);
6288 if (!result)
6289 return;
6290
6291 std::map<uint32 /*messageId*/, MailItemInfoVec> itemsCache;
6292 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS);
6293 stmt->SetData(0, uint32(curTime));
6294 if (PreparedQueryResult items = CharacterDatabase.Query(stmt))
6295 {
6296 MailItemInfo item;
6297 do
6298 {
6299 Field* fields = items->Fetch();
6300 item.item_guid = fields[0].Get<uint32>();
6301 item.item_template = fields[1].Get<uint32>();
6302 uint32 mailId = fields[2].Get<uint32>();
6303 itemsCache[mailId].push_back(item);
6304 } while (items->NextRow());
6305 }
6306
6307 uint32 deletedCount = 0;
6308 uint32 returnedCount = 0;
6309 do
6310 {
6311 Field* fields = result->Fetch();
6312 Mail* m = new Mail;
6313 m->messageID = fields[0].Get<uint32>();
6314 m->messageType = fields[1].Get<uint8>();
6315 m->sender = fields[2].Get<uint32>();
6316 m->receiver = fields[3].Get<uint32>();
6317 bool has_items = fields[4].Get<bool>();
6318 m->expire_time = time_t(fields[5].Get<uint32>());
6319 m->deliver_time = time_t(0);
6320 m->stationery = fields[6].Get<uint8>();
6321 m->checked = fields[7].Get<uint8>();
6322 m->mailTemplateId = fields[8].Get<int16>();
6323
6324 Player* player = nullptr;
6325 if (serverUp)
6327
6328 if (player) // don't modify mails of a logged in player
6329 {
6330 delete m;
6331 continue;
6332 }
6333
6334 // Delete or return mail
6335 if (has_items)
6336 {
6337 // read items from cache
6338 m->items.swap(itemsCache[m->messageID]);
6339
6340 // If it is mail from non-player, or if it's already return mail, it shouldn't be returned, but deleted
6341 if (!m->IsSentByPlayer() || m->IsSentByGM() || (m->IsCODPayment() || m->IsReturnedMail()))
6342 {
6343 for (auto const& mailedItem : m->items)
6344 {
6345 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
6346 stmt->SetData(0, mailedItem.item_guid);
6347 CharacterDatabase.Execute(stmt);
6348 }
6349
6350 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
6351 stmt->SetData(0, m->messageID);
6352 CharacterDatabase.Execute(stmt);
6353 }
6354 else
6355 {
6356 // Mail will be returned
6357 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_RETURNED);
6358 stmt->SetData(0, m->receiver);
6359 stmt->SetData(1, m->sender);
6360 stmt->SetData(2, uint32(curTime + 30 * DAY));
6361 stmt->SetData(3, uint32(curTime));
6363 stmt->SetData(5, m->messageID);
6364 CharacterDatabase.Execute(stmt);
6365 for (auto const& mailedItem : m->items)
6366 {
6367 // Update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete
6368 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_MAIL_ITEM_RECEIVER);
6369 stmt->SetData(0, m->sender);
6370 stmt->SetData(1, mailedItem.item_guid);
6371 CharacterDatabase.Execute(stmt);
6372
6373 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
6374 stmt->SetData(0, m->sender);
6375 stmt->SetData(1, mailedItem.item_guid);
6376 CharacterDatabase.Execute(stmt);
6377 }
6378
6379 // xinef: update global data
6380 sCharacterCache->IncreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->sender));
6381 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6382
6383 delete m;
6384 ++returnedCount;
6385 continue;
6386 }
6387 }
6388
6389 sCharacterCache->DecreaseCharacterMailCount(ObjectGuid(HighGuid::Player, m->receiver));
6390
6391 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
6392 stmt->SetData(0, m->messageID);
6393 CharacterDatabase.Execute(stmt);
6394 delete m;
6395 ++deletedCount;
6396 } while (result->NextRow());
6397
6398 LOG_INFO("server.loading", ">> Processed {} expired mails: {} deleted and {} returned in {} ms", deletedCount + returnedCount, deletedCount, returnedCount, GetMSTimeDiffToNow(oldMSTime));
6399 LOG_INFO("server.loading", " ");
6400}
#define sCharacterCache
Definition CharacterCache.h:83
@ CHAR_UPD_ITEM_OWNER
Definition CharacterDatabase.h:118
@ CHAR_DEL_ITEM_INSTANCE
Definition CharacterDatabase.h:127
@ CHAR_UPD_MAIL_RETURNED
Definition CharacterDatabase.h:116
@ CHAR_SEL_EXPIRED_MAIL
Definition CharacterDatabase.h:114
@ CHAR_SEL_EXPIRED_MAIL_ITEMS
Definition CharacterDatabase.h:115
@ CHAR_DEL_MAIL_BY_ID
Definition CharacterDatabase.h:110
@ CHAR_DEL_MAIL_ITEM_BY_ID
Definition CharacterDatabase.h:382
@ CHAR_UPD_MAIL_ITEM_RECEIVER
Definition CharacterDatabase.h:117
std::vector< MailItemInfo > MailItemInfoVec
Definition Mail.h:164
@ MAIL_CHECK_MASK_RETURNED
Definition Mail.h:48
Definition Player.h:1063
Seconds GetGameTime()
Definition GameTime.cpp:38
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition ObjectAccessor.cpp:251
Definition Mail.h:160
ObjectGuid::LowType item_guid
Definition Mail.h:161
uint32 item_template
Definition Mail.h:162
Definition Mail.h:167
bool IsSentByGM() const
Definition Mail.h:208
bool IsCODPayment() const
Definition Mail.h:209
ObjectGuid::LowType receiver
Definition Mail.h:173
uint8 messageType
Definition Mail.h:169
bool IsSentByPlayer() const
Definition Mail.h:207
uint32 messageID
Definition Mail.h:168
time_t expire_time
Definition Mail.h:178
uint32 sender
Definition Mail.h:172
uint8 stationery
Definition Mail.h:170
std::vector< MailItemInfo > items
Definition Mail.h:176
time_t deliver_time
Definition Mail.h:179
bool IsReturnedMail() const
Definition Mail.h:210
uint32 checked
Definition Mail.h:182
uint16 mailTemplateId
Definition Mail.h:171

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

◆ SetCreatureLinkedRespawn()

bool ObjectMgr::SetCreatureLinkedRespawn ( ObjectGuid::LowType  guid,
ObjectGuid::LowType  linkedGuid 
)
2088{
2089 if (!guidLow)
2090 return false;
2091
2092 CreatureData const* master = GetCreatureData(guidLow);
2093 ObjectGuid guid = ObjectGuid::Create<HighGuid::Unit>(master->id1, guidLow);
2094
2095 if (!linkedGuidLow) // we're removing the linking
2096 {
2097 _linkedRespawnStore.erase(guid);
2099 stmt->SetData(0, guidLow);
2100 WorldDatabase.Execute(stmt);
2101 return true;
2102 }
2103
2104 CreatureData const* slave = GetCreatureData(linkedGuidLow);
2105 if (!slave)
2106 {
2107 LOG_ERROR("sql.sql", "Creature '{}' linking to non-existent creature '{}'.", guidLow, linkedGuidLow);
2108 return false;
2109 }
2110
2111 MapEntry const* map = sMapStore.LookupEntry(master->mapid);
2112 if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
2113 {
2114 LOG_ERROR("sql.sql", "Creature '{}' linking to '{}' on an unpermitted map.", guidLow, linkedGuidLow);
2115 return false;
2116 }
2117
2118 if (!(master->spawnMask & slave->spawnMask)) // they must have a possibility to meet (normal/heroic difficulty)
2119 {
2120 LOG_ERROR("sql.sql", "LinkedRespawn: Creature '{}' linking to '{}' with not corresponding spawnMask", guidLow, linkedGuidLow);
2121 return false;
2122 }
2123
2124 ObjectGuid linkedGuid = ObjectGuid::Create<HighGuid::Unit>(slave->id1, linkedGuidLow);
2125
2126 _linkedRespawnStore[guid] = linkedGuid;
2128 stmt->SetData(0, guidLow);
2129 stmt->SetData(1, linkedGuidLow);
2130 WorldDatabase.Execute(stmt);
2131 return true;
2132}
@ 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
1326{ DBCLocaleIndex = locale; }

References DBCLocaleIndex.

◆ SetHighestGuids()

void ObjectMgr::SetHighestGuids ( )
7162{
7163 QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
7164 if (result)
7165 GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].Get<uint32>() + 1);
7166
7167 result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
7168 if (result)
7169 GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].Get<uint32>() + 1);
7170
7171 // Cleanup other tables from not existed guids ( >= _hiItemGuid)
7172 CharacterDatabase.Execute("DELETE FROM character_inventory WHERE item >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7173 CharacterDatabase.Execute("DELETE FROM mail_items WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7174 CharacterDatabase.Execute("DELETE FROM auctionhouse WHERE itemguid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7175 CharacterDatabase.Execute("DELETE FROM guild_bank_item WHERE item_guid >= '{}'", GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed()); // One-time query
7176
7177 result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
7178 if (result)
7179 GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].Get<uint32>() + 1);
7180
7181 result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
7182 if (result)
7183 _auctionId = (*result)[0].Get<uint32>() + 1;
7184
7185 result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
7186 if (result)
7187 _mailId = (*result)[0].Get<uint32>() + 1;
7188
7189 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
7190 if (result)
7191 sArenaTeamMgr->SetNextArenaTeamId((*result)[0].Get<uint32>() + 1);
7192
7193 result = CharacterDatabase.Query("SELECT MAX(fight_id) FROM log_arena_fights");
7194 if (result)
7195 sArenaTeamMgr->SetLastArenaLogId((*result)[0].Get<uint32>());
7196
7197 result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
7198 if (result)
7199 _equipmentSetGuid = (*result)[0].Get<uint64>() + 1;
7200
7201 result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
7202 if (result)
7203 sGuildMgr->SetNextGuildId((*result)[0].Get<uint32>() + 1);
7204
7205 result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
7206 if (result)
7207 _creatureSpawnId = (*result)[0].Get<uint32>() + 1;
7208
7209 result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
7210 if (result)
7211 _gameObjectSpawnId = (*result)[0].Get<uint32>() + 1;
7212}
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sGuildMgr
Definition GuildMgr.h:51

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

◆ ValidateSpellScripts()

void ObjectMgr::ValidateSpellScripts ( )
5872{
5873 uint32 oldMSTime = getMSTime();
5874
5875 if (_spellScriptsStore.empty())
5876 {
5877 LOG_INFO("server.loading", ">> Validated 0 scripts.");
5878 LOG_INFO("server.loading", " ");
5879 return;
5880 }
5881
5882 uint32 count = 0;
5883
5884 for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
5885 {
5886 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
5887 std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
5888 sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
5889 itr = _spellScriptsStore.upper_bound(itr->first);
5890
5891 for (std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
5892 {
5893 SpellScript* spellScript = sitr->first->GetSpellScript();
5894 AuraScript* auraScript = sitr->first->GetAuraScript();
5895 bool valid = true;
5896 if (!spellScript && !auraScript)
5897 {
5898 LOG_ERROR("sql.sql", "Functions GetSpellScript() and GetAuraScript() of script `{}` do not return objects - script skipped", GetScriptName(sitr->second->second));
5899 valid = false;
5900 }
5901 if (spellScript)
5902 {
5903 spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5904 spellScript->_Register();
5905 if (!spellScript->_Validate(spellInfo))
5906 valid = false;
5907 delete spellScript;
5908 }
5909 if (auraScript)
5910 {
5911 auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
5912 auraScript->_Register();
5913 if (!auraScript->_Validate(spellInfo))
5914 valid = false;
5915 delete auraScript;
5916 }
5917 if (!valid)
5918 {
5919 _spellScriptsStore.erase(sitr->second);
5920 }
5921 }
5922 ++count;
5923 }
5924
5925 LOG_INFO("server.loading", ">> Validated {} scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
5926 LOG_INFO("server.loading", " ");
5927}
Definition SpellScript.h:517
bool _Validate(SpellInfo const *entry) override
Definition SpellScript.cpp:662
std::string const & GetScriptName(uint32 id) const
Definition ObjectMgr.cpp:9813
Definition SpellScript.h:182
bool _Validate(SpellInfo const *entry) override
Definition SpellScript.cpp:316
virtual void _Register()
Definition SpellScript.cpp:45
virtual void _Init(std::string const *scriptname, uint32 spellId)
Definition SpellScript.cpp:59

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

Friends And Related Symbol Documentation

◆ PlayerDumpReader

friend class PlayerDumpReader
friend

Member Data Documentation

◆ _accessRequirementStore

DungeonProgressionRequirementsContainer ObjectMgr::_accessRequirementStore
private

◆ _acoreStringStore

AcoreStringContainer ObjectMgr::_acoreStringStore
private

Referenced by GetAcoreString(), and LoadAcoreStrings().

◆ _areaTriggerScriptStore

AreaTriggerScriptContainer ObjectMgr::_areaTriggerScriptStore
private

◆ _areaTriggerStore

AreaTriggerContainer ObjectMgr::_areaTriggerStore
private

Referenced by GetAreaTrigger(), and LoadAreaTriggers().

◆ _areaTriggerTeleportStore

◆ _auctionId

uint32 ObjectMgr::_auctionId
private

◆ _baseXPTable

BaseXPContainer ObjectMgr::_baseXPTable
private

Referenced by GetBaseXP(), and LoadExplorationBaseXP().

◆ _broadcastTextStore

BroadcastTextContainer ObjectMgr::_broadcastTextStore
private

◆ _cacheVendorItemStore

◆ _creatureAddonStore

CreatureAddonContainer ObjectMgr::_creatureAddonStore
private

◆ _creatureBaseStatsStore

CreatureBaseStatsContainer ObjectMgr::_creatureBaseStatsStore
private

◆ _creatureCustomIDsStore

CreatureCustomIDsContainer ObjectMgr::_creatureCustomIDsStore
private

◆ _creatureDataStore

◆ _creatureDefaultTrainers

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

◆ _creatureLocaleStore

CreatureLocaleContainer ObjectMgr::_creatureLocaleStore
private

◆ _creatureModelStore

CreatureModelContainer ObjectMgr::_creatureModelStore
private

◆ _creatureMovementOverrides

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

◆ _creatureQuestInvolvedRelations

◆ _creatureQuestItemStore

CreatureQuestItemMap ObjectMgr::_creatureQuestItemStore
private

◆ _creatureQuestRelations

QuestRelations ObjectMgr::_creatureQuestRelations
private

◆ _creatureSparringStore

CreatureSparringContainer ObjectMgr::_creatureSparringStore
private

◆ _creatureSpawnId

ObjectGuid::LowType ObjectMgr::_creatureSpawnId
private

◆ _creatureTemplateAddonStore

CreatureAddonContainer ObjectMgr::_creatureTemplateAddonStore
private

◆ _creatureTemplateStore

◆ _creatureTemplateStoreFast

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

◆ _difficultyEntries

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

◆ _dungeonEncounterStore

DungeonEncounterContainer ObjectMgr::_dungeonEncounterStore
private

◆ _emptyCellObjectGuids

CellObjectGuids ObjectMgr::_emptyCellObjectGuids
private

Referenced by GetGridObjectGuids().

◆ _emptyCellObjectGuidsMap

CellObjectGuidsMap ObjectMgr::_emptyCellObjectGuidsMap
private

Referenced by GetMapObjectGuids().

◆ _equipmentInfoStore

EquipmentInfoContainer ObjectMgr::_equipmentInfoStore
private

◆ _equipmentSetGuid

uint64 ObjectMgr::_equipmentSetGuid
private

◆ _fishingBaseForAreaStore

◆ _gameObjectAddonStore

GameObjectAddonContainer ObjectMgr::_gameObjectAddonStore
private

◆ _gameObjectDataStore

GameObjectDataContainer ObjectMgr::_gameObjectDataStore
private

◆ _gameObjectLocaleStore

GameObjectLocaleContainer ObjectMgr::_gameObjectLocaleStore
private

◆ _gameObjectQuestItemStore

GameObjectQuestItemMap ObjectMgr::_gameObjectQuestItemStore
private

◆ _gameObjectSpawnId

ObjectGuid::LowType ObjectMgr::_gameObjectSpawnId
private

◆ _gameObjectTemplateAddonStore

GameObjectTemplateAddonContainer ObjectMgr::_gameObjectTemplateAddonStore
private

◆ _gameObjectTemplateStore

GameObjectTemplateContainer ObjectMgr::_gameObjectTemplateStore
private

◆ _gameTeleStore

◆ _goQuestInvolvedRelations

QuestRelations ObjectMgr::_goQuestInvolvedRelations
private

◆ _goQuestRelations

QuestRelations ObjectMgr::_goQuestRelations
private

◆ _gossipMenuItemsLocaleStore

GossipMenuItemsLocaleContainer ObjectMgr::_gossipMenuItemsLocaleStore
private

◆ _gossipMenuItemsStore

◆ _gossipMenusStore

GossipMenusContainer ObjectMgr::_gossipMenusStore
private

◆ _gossipTextStore

GossipTextContainer ObjectMgr::_gossipTextStore
private

Referenced by GetGossipText(), and LoadGossipText().

◆ _guidGenerators

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

◆ _hasDifficultyEntries

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

Referenced by CheckCreatureTemplate().

◆ _hiPetNumber

uint32 ObjectMgr::_hiPetNumber
private

Referenced by GeneratePetNumber(), and LoadPetNumber().

◆ _hiPetNumberMutex

std::mutex ObjectMgr::_hiPetNumberMutex
private

Referenced by GeneratePetNumber().

◆ _instanceTemplateStore

InstanceTemplateContainer ObjectMgr::_instanceTemplateStore
private

◆ _itemLocaleStore

ItemLocaleContainer ObjectMgr::_itemLocaleStore
private

Referenced by GetItemLocale(), and LoadItemLocales().

◆ _itemSetNameLocaleStore

ItemSetNameLocaleContainer ObjectMgr::_itemSetNameLocaleStore
private

◆ _itemSetNameStore

ItemSetNameContainer ObjectMgr::_itemSetNameStore
private

◆ _itemTemplateStore

ItemTemplateContainer ObjectMgr::_itemTemplateStore
private

◆ _itemTemplateStoreFast

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

◆ _linkedRespawnStore

LinkedRespawnContainer ObjectMgr::_linkedRespawnStore
private

◆ _mailId

uint32 ObjectMgr::_mailId
private

Referenced by GenerateMailID(), and SetHighestGuids().

◆ _mailIdMutex

std::mutex ObjectMgr::_mailIdMutex
private

Referenced by GenerateMailID().

◆ _mailLevelRewardStore

MailLevelRewardContainer ObjectMgr::_mailLevelRewardStore
private

◆ _mapObjectGuidsStore

◆ _moduleStringStore

ModuleStringContainer ObjectMgr::_moduleStringStore
private

◆ _npcTextLocaleStore

NpcTextLocaleContainer ObjectMgr::_npcTextLocaleStore
private

◆ _pageTextLocaleStore

PageTextLocaleContainer ObjectMgr::_pageTextLocaleStore
private

◆ _pageTextStore

PageTextContainer ObjectMgr::_pageTextStore
private

Referenced by GetPageText(), and LoadPageTexts().

◆ _petHalfLocaleName0

HalfNameContainerLocale ObjectMgr::_petHalfLocaleName0
private

◆ _petHalfLocaleName1

HalfNameContainerLocale ObjectMgr::_petHalfLocaleName1
private

◆ _petHalfName0

HalfNameContainer ObjectMgr::_petHalfName0
private

Referenced by GeneratePetName(), and LoadPetNames().

◆ _petHalfName1

HalfNameContainer ObjectMgr::_petHalfName1
private

Referenced by GeneratePetName(), and LoadPetNames().

◆ _petInfoStore

PetLevelInfoContainer ObjectMgr::_petInfoStore
private

◆ _playerClassInfo

◆ _playerInfo

◆ _playerShapeshiftModel

PlayerShapeshiftModelMap ObjectMgr::_playerShapeshiftModel
private

◆ _playerTotemModel

PlayerTotemModelMap ObjectMgr::_playerTotemModel
private

◆ _playerXPperLevel

PlayerXPperLevel ObjectMgr::_playerXPperLevel
private

Referenced by GetXPForLevel(), and LoadPlayerInfo().

◆ _pointOfInterestLocaleStore

PointOfInterestLocaleContainer ObjectMgr::_pointOfInterestLocaleStore
private

◆ _pointsOfInterestStore

PointOfInterestContainer ObjectMgr::_pointsOfInterestStore
private

◆ _profanityNamesStore

◆ _questAreaTriggerStore

QuestAreaTriggerContainer ObjectMgr::_questAreaTriggerStore
private

◆ _questGreetingStore

QuestGreetingContainer ObjectMgr::_questGreetingStore
private

◆ _questLocaleStore

QuestLocaleContainer ObjectMgr::_questLocaleStore
private

Referenced by GetQuestLocale(), and LoadQuestLocales().

◆ _questMoneyRewards

QuestMoneyRewardStore ObjectMgr::_questMoneyRewards
private

◆ _questOfferRewardLocaleStore

QuestOfferRewardLocaleContainer ObjectMgr::_questOfferRewardLocaleStore
private

◆ _questPOIStore

QuestPOIContainer ObjectMgr::_questPOIStore
private

Referenced by GetQuestPOIVector(), and LoadQuestPOI().

◆ _questRequestItemsLocaleStore

QuestRequestItemsLocaleContainer ObjectMgr::_questRequestItemsLocaleStore
private

◆ _questTemplates

QuestMap ObjectMgr::_questTemplates
private

◆ _questTemplatesFast

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

Referenced by GetQuestTemplate(), and LoadQuests().

◆ _repOnKillStore

RepOnKillContainer ObjectMgr::_repOnKillStore
private

◆ _repRewardRateStore

RepRewardRateContainer ObjectMgr::_repRewardRateStore
private

◆ _repSpilloverTemplateStore

RepSpilloverTemplateContainer ObjectMgr::_repSpilloverTemplateStore
private

◆ _reservedNamesStore

◆ _scriptNamesStore

ScriptNameContainer ObjectMgr::_scriptNamesStore
private

◆ _spellClickInfoStore

◆ _spellScriptsStore

SpellScriptsContainer ObjectMgr::_spellScriptsStore
private

◆ _tavernAreaTriggerStore

TavernAreaTriggerContainer ObjectMgr::_tavernAreaTriggerStore
private

◆ _tempSummonDataStore

TempSummonDataContainer ObjectMgr::_tempSummonDataStore
private

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

Referenced by GetSummonGroup(), and LoadTempSummons().

◆ _trainers

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

Referenced by GetTrainer(), and LoadTrainers().

◆ _transportMaps

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

◆ _vehicleAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleAccessoryStore
private

◆ _vehicleSeatAddonStore

VehicleSeatAddonContainer ObjectMgr::_vehicleSeatAddonStore
private

◆ _vehicleTemplateAccessoryStore

VehicleAccessoryContainer ObjectMgr::_vehicleTemplateAccessoryStore
private

◆ DBCLocaleIndex

LocaleConstant ObjectMgr::DBCLocaleIndex
private

◆ FactionChangeAchievements

CharacterConversionMap ObjectMgr::FactionChangeAchievements

◆ FactionChangeItems

CharacterConversionMap ObjectMgr::FactionChangeItems

Referenced by LoadFactionChangeItems().

◆ FactionChangeQuests

CharacterConversionMap ObjectMgr::FactionChangeQuests

Referenced by LoadFactionChangeQuests().

◆ FactionChangeReputation

CharacterConversionMap ObjectMgr::FactionChangeReputation

◆ FactionChangeSpells

CharacterConversionMap ObjectMgr::FactionChangeSpells

Referenced by LoadFactionChangeSpells().

◆ FactionChangeTitles

CharacterConversionMap ObjectMgr::FactionChangeTitles

Referenced by LoadFactionChangeTitles().

◆ GameobjectInstanceSavedStateList

std::vector<GameobjectInstanceSavedState> ObjectMgr::GameobjectInstanceSavedStateList
private

◆ mExclusiveQuestGroups

ExclusiveQuestGroups ObjectMgr::mExclusiveQuestGroups

Referenced by LoadQuests().


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