AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
LootMgr.cpp File Reference
#include "LootMgr.h"
#include "Containers.h"
#include "DisableMgr.h"
#include "Group.h"
#include "ItemEnchantmentMgr.h"
#include "Log.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "Util.h"
#include "World.h"

Go to the source code of this file.

Classes

struct  LootGroupInvalidSelector
 
class  LootTemplate::LootGroup
 

Functions

ByteBufferoperator<< (ByteBuffer &b, LootItem const &li)
 
ByteBufferoperator<< (ByteBuffer &b, LootView const &lv)
 
void LoadLootTemplates_Creature ()
 
void LoadLootTemplates_Disenchant ()
 
void LoadLootTemplates_Fishing ()
 
void LoadLootTemplates_Gameobject ()
 
void LoadLootTemplates_Item ()
 
void LoadLootTemplates_Milling ()
 
void LoadLootTemplates_Pickpocketing ()
 
void LoadLootTemplates_Prospecting ()
 
void LoadLootTemplates_Mail ()
 
void LoadLootTemplates_Skinning ()
 
void LoadLootTemplates_Spell ()
 
void LoadLootTemplates_Player ()
 
void LoadLootTemplates_Reference ()
 

Variables

ServerConfigs const qualityToRate []
 
LootStore LootTemplates_Creature ("creature_loot_template", "creature entry", true)
 
LootStore LootTemplates_Disenchant ("disenchant_loot_template", "item disenchant id", true)
 
LootStore LootTemplates_Fishing ("fishing_loot_template", "area id", true)
 
LootStore LootTemplates_Gameobject ("gameobject_loot_template", "gameobject entry", true)
 
LootStore LootTemplates_Item ("item_loot_template", "item entry", true)
 
LootStore LootTemplates_Mail ("mail_loot_template", "mail template id", false)
 
LootStore LootTemplates_Milling ("milling_loot_template", "item entry (herb)", true)
 
LootStore LootTemplates_Pickpocketing ("pickpocketing_loot_template", "creature pickpocket lootid", true)
 
LootStore LootTemplates_Prospecting ("prospecting_loot_template", "item entry (ore)", true)
 
LootStore LootTemplates_Reference ("reference_loot_template", "reference id", false)
 
LootStore LootTemplates_Skinning ("skinning_loot_template", "creature skinning id", true)
 
LootStore LootTemplates_Spell ("spell_loot_template", "spell id (random item creating)", false)
 
LootStore LootTemplates_Player ("player_loot_template", "team id", true)
 

Function Documentation

◆ LoadLootTemplates_Creature()

void LoadLootTemplates_Creature ( )
1911{
1912 LOG_INFO("server.loading", "Loading Creature Loot Templates...");
1913
1914 uint32 oldMSTime = getMSTime();
1915
1916 LootIdSet lootIdSet, lootIdSetUsed;
1918
1919 // Remove real entries and check loot existence
1920 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
1921 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
1922 {
1923 if (uint32 lootid = itr->second.lootid)
1924 {
1925 if (lootIdSet.find(lootid) == lootIdSet.end())
1926 LootTemplates_Creature.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
1927 else
1928 lootIdSetUsed.insert(lootid);
1929 }
1930 }
1931
1932 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
1933 lootIdSet.erase(*itr);
1934
1935 // output error for any still listed (not referenced from appropriate table) ids
1937
1938 if (count)
1939 LOG_INFO("server.loading", ">> Loaded {} Creature Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1940 else
1941 LOG_WARN("server.loading", ">> Loaded 0 creature loot templates. DB table `creature_loot_template` is empty");
1942
1943 LOG_INFO("server.loading", " ");
1944}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:287
std::uint32_t uint32
Definition Define.h:107
#define LOG_INFO(filterType__,...)
Definition Log.h:153
#define LOG_WARN(filterType__,...)
Definition Log.h:149
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
std::set< uint32 > LootIdSet
Definition LootMgr.h:204
#define sObjectMgr
Definition ObjectMgr.h:1723
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
uint32 LoadAndCollectLootIds(LootIdSet &ids_set)
Definition LootMgr.cpp:267
void ReportNonExistingId(uint32 lootId) const
Definition LootMgr.cpp:290
void ReportUnusedIds(LootIdSet const &ids_set) const
Definition LootMgr.cpp:283

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Creature, LootStore::ReportNonExistingId(), LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesCreatureCommand(), and LoadLootTables().

◆ LoadLootTemplates_Disenchant()

void LoadLootTemplates_Disenchant ( )
1947{
1948 LOG_INFO("server.loading", "Loading Disenchanting Loot Templates...");
1949
1950 uint32 oldMSTime = getMSTime();
1951
1952 LootIdSet lootIdSet, lootIdSetUsed;
1954
1955 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
1956 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
1957 {
1958 if (uint32 lootid = itr->second.DisenchantID)
1959 {
1960 if (lootIdSet.find(lootid) == lootIdSet.end())
1962 else
1963 lootIdSetUsed.insert(lootid);
1964 }
1965 }
1966
1967 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
1968 lootIdSet.erase(*itr);
1969
1970 // output error for any still listed (not referenced from appropriate table) ids
1972
1973 if (count)
1974 LOG_INFO("server.loading", ">> Loaded {} disenchanting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1975 else
1976 LOG_WARN("server.loading", ">> Loaded 0 disenchanting loot templates. DB table `disenchant_loot_template` is empty");
1977 LOG_INFO("server.loading", " ");
1978}
std::unordered_map< uint32, ItemTemplate > ItemTemplateContainer
Definition ItemTemplate.h:831
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Disenchant, LootStore::ReportNonExistingId(), LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesDisenchantCommand(), and LoadLootTables().

◆ LoadLootTemplates_Fishing()

void LoadLootTemplates_Fishing ( )
1981{
1982 LOG_INFO("server.loading", "Loading Fishing Loot Templates...");
1983
1984 uint32 oldMSTime = getMSTime();
1985
1986 LootIdSet lootIdSet;
1988
1989 // remove real entries and check existence loot
1990 for (uint32 i = 1; i < sAreaTableStore.GetNumRows(); ++i)
1991 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i))
1992 if (lootIdSet.find(areaEntry->ID) != lootIdSet.end())
1993 lootIdSet.erase(areaEntry->ID);
1994
1995 // output error for any still listed (not referenced from appropriate table) ids
1997
1998 if (count)
1999 LOG_INFO("server.loading", ">> Loaded {} Fishing Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2000 else
2001 LOG_WARN("server.loading", ">> Loaded 0 fishing loot templates. DB table `fishing_loot_template` is empty");
2002
2003 LOG_INFO("server.loading", " ");
2004}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true)
Definition DBCStructure.h:519

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Fishing, LootStore::ReportUnusedIds(), and sAreaTableStore.

Referenced by reload_commandscript::HandleReloadLootTemplatesFishingCommand(), and LoadLootTables().

◆ LoadLootTemplates_Gameobject()

void LoadLootTemplates_Gameobject ( )
2007{
2008 LOG_INFO("server.loading", "Loading Gameobject Loot Templates...");
2009
2010 uint32 oldMSTime = getMSTime();
2011
2012 LootIdSet lootIdSet, lootIdSetUsed;
2014
2015 // remove real entries and check existence loot
2016 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
2017 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
2018 {
2019 if (uint32 lootid = itr->second.GetLootId())
2020 {
2021 if (lootIdSet.find(lootid) == lootIdSet.end())
2022 LootTemplates_Gameobject.ReportNonExistingId(lootid, "Gameobject", itr->second.entry);
2023 else
2024 lootIdSetUsed.insert(lootid);
2025 }
2026 }
2027
2028 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2029 lootIdSet.erase(*itr);
2030
2031 // output error for any still listed (not referenced from appropriate table) ids
2033
2034 if (count)
2035 LOG_INFO("server.loading", ">> Loaded {} Gameobject Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2036 else
2037 LOG_WARN("server.loading", ">> Loaded 0 gameobject loot templates. DB table `gameobject_loot_template` is empty");
2038
2039 LOG_INFO("server.loading", " ");
2040}
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition GameObject.h:42
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Gameobject, LootStore::ReportNonExistingId(), LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesGameobjectCommand(), and LoadLootTables().

◆ LoadLootTemplates_Item()

void LoadLootTemplates_Item ( )
2043{
2044 LOG_INFO("server.loading", "Loading Item Loot Templates...");
2045
2046 uint32 oldMSTime = getMSTime();
2047
2048 LootIdSet lootIdSet;
2050
2051 // remove real entries and check existence loot
2052 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2053 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2054 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.HasFlag(ITEM_FLAG_HAS_LOOT))
2055 lootIdSet.erase(itr->second.ItemId);
2056
2057 // output error for any still listed (not referenced from appropriate table) ids
2059
2060 if (count)
2061 LOG_INFO("server.loading", ">> Loaded {} item loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2062 else
2063 LOG_WARN("server.loading", ">> Loaded 0 item loot templates. DB table `item_loot_template` is empty");
2064
2065 LOG_INFO("server.loading", " ");
2066}
@ ITEM_FLAG_HAS_LOOT
Definition ItemTemplate.h:149
LootStore LootTemplates_Item("item_loot_template", "item entry", true)

References getMSTime(), GetMSTimeDiffToNow(), ITEM_FLAG_HAS_LOOT, LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Item, LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesItemCommand(), and LoadLootTables().

◆ LoadLootTemplates_Mail()

void LoadLootTemplates_Mail ( )
2167{
2168 LOG_INFO("server.loading", "Loading Mail Loot Templates...");
2169
2170 uint32 oldMSTime = getMSTime();
2171
2172 LootIdSet lootIdSet;
2174
2175 // remove real entries and check existence loot
2176 for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
2177 if (sMailTemplateStore.LookupEntry(i))
2178 if (lootIdSet.find(i) != lootIdSet.end())
2179 lootIdSet.erase(i);
2180
2181 // output error for any still listed (not referenced from appropriate table) ids
2183
2184 if (count)
2185 LOG_INFO("server.loading", ">> Loaded {} mail loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2186 else
2187 LOG_WARN("server.loading", ">> Loaded 0 mail loot templates. DB table `mail_loot_template` is empty");
2188
2189 LOG_INFO("server.loading", " ");
2190}
DBCStorage< MailTemplateEntry > sMailTemplateStore(MailTemplateEntryfmt)
LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false)

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Mail, LootStore::ReportUnusedIds(), and sMailTemplateStore.

Referenced by reload_commandscript::HandleReloadLootTemplatesMailCommand(), and LoadLootTables().

◆ LoadLootTemplates_Milling()

void LoadLootTemplates_Milling ( )
2069{
2070 LOG_INFO("server.loading", "Loading Milling Loot Templates...");
2071
2072 uint32 oldMSTime = getMSTime();
2073
2074 LootIdSet lootIdSet;
2076
2077 // remove real entries and check existence loot
2078 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2079 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2080 {
2081 if (!itr->second.HasFlag(ITEM_FLAG_IS_MILLABLE))
2082 continue;
2083
2084 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2085 lootIdSet.erase(itr->second.ItemId);
2086 }
2087
2088 // output error for any still listed (not referenced from appropriate table) ids
2090
2091 if (count)
2092 LOG_INFO("server.loading", ">> Loaded {} milling loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2093 else
2094 LOG_WARN("server.loading", ">> Loaded 0 milling loot templates. DB table `milling_loot_template` is empty");
2095
2096 LOG_INFO("server.loading", " ");
2097}
@ ITEM_FLAG_IS_MILLABLE
Definition ItemTemplate.h:176
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true)

References getMSTime(), GetMSTimeDiffToNow(), ITEM_FLAG_IS_MILLABLE, LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Milling, LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesMillingCommand(), and LoadLootTables().

◆ LoadLootTemplates_Pickpocketing()

void LoadLootTemplates_Pickpocketing ( )
2100{
2101 LOG_INFO("server.loading", "Loading Pickpocketing Loot Templates...");
2102
2103 uint32 oldMSTime = getMSTime();
2104
2105 LootIdSet lootIdSet, lootIdSetUsed;
2107
2108 // Remove real entries and check loot existence
2109 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2110 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2111 {
2112 if (uint32 lootid = itr->second.pickpocketLootId)
2113 {
2114 if (lootIdSet.find(lootid) == lootIdSet.end())
2115 LootTemplates_Pickpocketing.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2116 else
2117 lootIdSetUsed.insert(lootid);
2118 }
2119 }
2120
2121 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2122 lootIdSet.erase(*itr);
2123
2124 // output error for any still listed (not referenced from appropriate table) ids
2126
2127 if (count)
2128 LOG_INFO("server.loading", ">> Loaded {} pickpocketing loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2129 else
2130 LOG_WARN("server.loading", ">> Loaded 0 pickpocketing loot templates. DB table `pickpocketing_loot_template` is empty");
2131
2132 LOG_INFO("server.loading", " ");
2133}
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true)

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Pickpocketing, LootStore::ReportNonExistingId(), LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesPickpocketingCommand(), and LoadLootTables().

◆ LoadLootTemplates_Player()

void LoadLootTemplates_Player ( )
2272{
2273 LOG_INFO("server.loading", "Loading Player Loot Templates...");
2274
2275 uint32 oldMSTime = getMSTime();
2276
2277 LootIdSet lootIdSet;
2279
2280 if (count)
2281 {
2282 LOG_INFO("server.loading", ">> Loaded {} player loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2283 }
2284 else
2285 {
2286 LOG_WARN("server.loading", ">> Loaded 0 player loot templates. DB table `player_loot_template` is empty");
2287 }
2288
2289 LOG_INFO("server.loading", " ");
2290}
LootStore LootTemplates_Player("player_loot_template", "team id", true)

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, and LootTemplates_Player.

Referenced by reload_commandscript::HandleReloadLootTemplatesPlayerCommand(), and LoadLootTables().

◆ LoadLootTemplates_Prospecting()

void LoadLootTemplates_Prospecting ( )
2136{
2137 LOG_INFO("server.loading", "Loading Prospecting Loot Templates...");
2138
2139 uint32 oldMSTime = getMSTime();
2140
2141 LootIdSet lootIdSet;
2143
2144 // remove real entries and check existence loot
2145 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2146 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2147 {
2148 if (!itr->second.HasFlag(ITEM_FLAG_IS_PROSPECTABLE))
2149 continue;
2150
2151 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2152 lootIdSet.erase(itr->second.ItemId);
2153 }
2154
2155 // output error for any still listed (not referenced from appropriate table) ids
2157
2158 if (count)
2159 LOG_INFO("server.loading", ">> Loaded {} prospecting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2160 else
2161 LOG_WARN("server.loading", ">> Loaded 0 prospecting loot templates. DB table `prospecting_loot_template` is empty");
2162
2163 LOG_INFO("server.loading", " ");
2164}
@ ITEM_FLAG_IS_PROSPECTABLE
Definition ItemTemplate.h:165
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true)

References getMSTime(), GetMSTimeDiffToNow(), ITEM_FLAG_IS_PROSPECTABLE, LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Prospecting, LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesProspectingCommand(), and LoadLootTables().

◆ LoadLootTemplates_Reference()

void LoadLootTemplates_Reference ( )
2293{
2294 LOG_INFO("server.loading", "Loading Reference Loot Templates...");
2295
2296 uint32 oldMSTime = getMSTime();
2297
2298 LootIdSet lootIdSet;
2300
2301 // check references and remove used
2313
2314 // output error for any still listed ids (not referenced from any loot table)
2316
2317 LOG_INFO("server.loading", ">> Loaded reference loot templates in {} ms", GetMSTimeDiffToNow(oldMSTime));
2318 LOG_INFO("server.loading", " ");
2319}
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true)
LootStore LootTemplates_Reference("reference_loot_template", "reference id", false)
void CheckLootRefs(LootIdSet *ref_set=nullptr) const
Definition LootMgr.cpp:277

References LootStore::CheckLootRefs(), getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LootTemplates_Creature, LootTemplates_Disenchant, LootTemplates_Fishing, LootTemplates_Gameobject, LootTemplates_Item, LootTemplates_Mail, LootTemplates_Milling, LootTemplates_Pickpocketing, LootTemplates_Prospecting, LootTemplates_Reference, LootTemplates_Skinning, and LootStore::ReportUnusedIds().

Referenced by reload_commandscript::HandleReloadLootTemplatesReferenceCommand(), and LoadLootTables().

◆ LoadLootTemplates_Skinning()

void LoadLootTemplates_Skinning ( )
2193{
2194 LOG_INFO("server.loading", "Loading Skinning Loot Templates...");
2195
2196 uint32 oldMSTime = getMSTime();
2197
2198 LootIdSet lootIdSet, lootIdSetUsed;
2200
2201 // remove real entries and check existence loot
2202 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2203 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2204 {
2205 if (uint32 lootid = itr->second.SkinLootId)
2206 {
2207 if (lootIdSet.find(lootid) == lootIdSet.end())
2208 LootTemplates_Skinning.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2209 else
2210 lootIdSetUsed.insert(lootid);
2211 }
2212 }
2213
2214 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2215 lootIdSet.erase(*itr);
2216
2217 // output error for any still listed (not referenced from appropriate table) ids
2219
2220 if (count)
2221 LOG_INFO("server.loading", ">> Loaded {} skinning loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2222 else
2223 LOG_WARN("server.loading", ">> Loaded 0 skinning loot templates. DB table `skinning_loot_template` is empty");
2224
2225 LOG_INFO("server.loading", " ");
2226}

References getMSTime(), GetMSTimeDiffToNow(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Skinning, LootStore::ReportNonExistingId(), LootStore::ReportUnusedIds(), and sObjectMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesSkinningCommand(), and LoadLootTables().

◆ LoadLootTemplates_Spell()

void LoadLootTemplates_Spell ( )
2229{
2230 LOG_INFO("server.loading", "Loading Spell Loot Templates...");
2231
2232 uint32 oldMSTime = getMSTime();
2233
2234 LootIdSet lootIdSet;
2236
2237 // remove real entries and check existence loot
2238 for (uint32 spell_id = 1; spell_id < sSpellMgr->GetSpellInfoStoreSize(); ++spell_id)
2239 {
2240 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
2241 if (!spellInfo)
2242 continue;
2243
2244 // possible cases
2245 if (!spellInfo->IsLootCrafting())
2246 continue;
2247
2248 if (lootIdSet.find(spell_id) == lootIdSet.end())
2249 {
2250 // not report about not trainable spells (optionally supported by DB)
2251 // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example
2253 {
2254 LootTemplates_Spell.ReportNonExistingId(spell_id, "Spell", spellInfo->Id);
2255 }
2256 }
2257 else
2258 lootIdSet.erase(spell_id);
2259 }
2260
2261 // output error for any still listed (not referenced from appropriate table) ids
2263
2264 if (count)
2265 LOG_INFO("server.loading", ">> Loaded {} spell loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2266 else
2267 LOG_WARN("server.loading", ">> Loaded 0 spell loot templates. DB table `spell_loot_template` is empty");
2268 LOG_INFO("server.loading", " ");
2269}
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false)
@ SPELL_ATTR0_IS_TRADESKILL
Definition SharedDefines.h:375
@ SPELL_ATTR0_NOT_SHAPESHIFTED
Definition SharedDefines.h:386
#define sSpellMgr
Definition SpellMgr.h:836
Definition SpellInfo.h:340
uint32 Id
Definition SpellInfo.h:344
bool IsLootCrafting() const
Definition SpellInfo.cpp:957
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:441

References getMSTime(), GetMSTimeDiffToNow(), SpellInfo::HasAttribute(), SpellInfo::Id, SpellInfo::IsLootCrafting(), LootStore::LoadAndCollectLootIds(), LOG_INFO, LOG_WARN, LootTemplates_Spell, LootStore::ReportNonExistingId(), LootStore::ReportUnusedIds(), SPELL_ATTR0_IS_TRADESKILL, SPELL_ATTR0_NOT_SHAPESHIFTED, and sSpellMgr.

Referenced by reload_commandscript::HandleReloadLootTemplatesSpellCommand(), and LoadLootTables().

◆ operator<<() [1/2]

ByteBuffer & operator<< ( ByteBuffer b,
LootItem const &  li 
)
964{
965 b << uint32(li.itemid);
966 b << uint32(li.count); // nr of items of this type
967 b << uint32(sObjectMgr->GetItemTemplate(li.itemid)->DisplayInfoID);
968 b << uint32(li.randomSuffix);
969 b << uint32(li.randomPropertyId);
970 //b << uint8(0); // slot type - will send after this function call
971 return b;
972}

References LootItem::count, LootItem::itemid, LootItem::randomPropertyId, LootItem::randomSuffix, and sObjectMgr.

◆ operator<<() [2/2]

ByteBuffer & operator<< ( ByteBuffer b,
LootView const &  lv 
)
975{
976 if (lv.permission == NONE_PERMISSION)
977 {
978 b << uint32(0); //gold
979 b << uint8(0); // item count
980 return b; // nothing output more
981 }
982
983 Loot& l = lv.loot;
984
985 uint8 itemsShown = 0;
986
987 b << uint32(l.gold); //gold
988
989 std::size_t count_pos = b.wpos(); // pos of item count byte
990 b << uint8(0); // item count placeholder
991
992 switch (lv.permission)
993 {
994 case GROUP_PERMISSION:
997 {
998 bool isMasterLooter = lv.viewer->GetGroup() && lv.viewer->GetGroup()->GetMasterLooterGuid() == lv.viewer->GetGUID();
999
1000 // if you are not the round-robin group looter, you can only see
1001 // blocked rolled items and quest items, and !ffa items
1002 for (uint8 i = 0; i < l.items.size(); ++i)
1003 {
1004 if (!l.items[i].is_looted && !l.items[i].freeforall && (l.items[i].conditions.empty() || isMasterLooter) && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1005 {
1006 uint8 slot_type = 0;
1007
1008 if (l.items[i].is_blocked) // for ML & restricted is_blocked = !is_underthreshold
1009 {
1010 switch (lv.permission)
1011 {
1012 case GROUP_PERMISSION:
1013 slot_type = LOOT_SLOT_TYPE_ROLL_ONGOING;
1014 break;
1015 case MASTER_PERMISSION:
1016 {
1017 if (lv.viewer->GetGroup())
1018 {
1019 if (lv.viewer->GetGroup()->GetMasterLooterGuid() == lv.viewer->GetGUID())
1020 slot_type = LOOT_SLOT_TYPE_MASTER;
1021 else
1022 slot_type = LOOT_SLOT_TYPE_LOCKED;
1023 }
1024 break;
1025 }
1027 slot_type = LOOT_SLOT_TYPE_LOCKED;
1028 break;
1029 default:
1030 continue;
1031 }
1032 }
1033 else if (l.items[i].rollWinnerGUID)
1034 {
1035 if (l.items[i].rollWinnerGUID == lv.viewer->GetGUID())
1036 slot_type = LOOT_SLOT_TYPE_OWNER;
1037 else
1038 continue;
1039 }
1040 else if (!l.roundRobinPlayer || lv.viewer->GetGUID() == l.roundRobinPlayer || !l.items[i].is_underthreshold)
1041 {
1042 // no round robin owner or he has released the loot
1043 // or it IS the round robin group owner
1044 // => item is lootable
1045 slot_type = LOOT_SLOT_TYPE_ALLOW_LOOT;
1046 }
1047 else
1048 // item shall not be displayed.
1049 continue;
1050
1051 b << uint8(i) << l.items[i];
1052 b << uint8(slot_type);
1053 ++itemsShown;
1054 }
1055 }
1056 break;
1057 }
1059 {
1060 for (uint8 i = 0; i < l.items.size(); ++i)
1061 {
1062 if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1063 {
1064 if (l.roundRobinPlayer && lv.viewer->GetGUID() != l.roundRobinPlayer)
1065 // item shall not be displayed.
1066 continue;
1067
1068 b << uint8(i) << l.items[i];
1070 ++itemsShown;
1071 }
1072 }
1073 break;
1074 }
1075 case ALL_PERMISSION:
1076 case OWNER_PERMISSION:
1077 {
1079 for (uint8 i = 0; i < l.items.size(); ++i)
1080 {
1081 if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1082 {
1083 b << uint8(i) << l.items[i];
1084 b << uint8(slot_type);
1085 ++itemsShown;
1086 }
1087 }
1088 break;
1089 }
1090 default:
1091 return b;
1092 }
1093
1095
1096 // Xinef: items that do not follow loot rules need this
1097 LootSlotType partySlotType = lv.permission == MASTER_PERMISSION ? LOOT_SLOT_TYPE_MASTER : slotType;
1098
1099 QuestItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems();
1100 QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID());
1101 if (q_itr != lootPlayerQuestItems.end())
1102 {
1103 QuestItemList* q_list = q_itr->second;
1104 for (QuestItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
1105 {
1106 LootItem& item = l.quest_items[qi->index];
1107 if (!qi->is_looted && !item.is_looted)
1108 {
1109 bool showInLoot = true;
1110 bool hasQuestForItem = lv.viewer->HasQuestForItem(item.itemid, 0, false, &showInLoot);
1111 if (!hasQuestForItem)
1112 {
1113 if (!showInLoot)
1114 {
1115 const_cast<QuestItem*>(&(*qi))->is_looted = true;
1116 if (!item.freeforall)
1117 {
1118 item.is_looted = true;
1119 }
1120 continue;
1121 }
1122
1123 b << uint8(l.items.size() + (qi - q_list->begin()));
1124 b << item;
1126 }
1127 else
1128 {
1129 b << uint8(l.items.size() + (qi - q_list->begin()));
1130 b << item;
1131
1132 if (item.follow_loot_rules)
1133 {
1134 switch (lv.permission)
1135 {
1136 case MASTER_PERMISSION:
1138 break;
1140 b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
1141 break;
1142 case GROUP_PERMISSION:
1144 if (!item.is_blocked)
1146 else
1148 break;
1149 default:
1150 b << uint8(slotType);
1151 break;
1152 }
1153 }
1154 else if (!item.freeforall)
1155 b << uint8(partySlotType);
1156 else
1157 b << uint8(slotType);
1158 }
1159
1160 ++itemsShown;
1161 }
1162 }
1163 }
1164
1165 QuestItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems();
1166 QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID());
1167 if (ffa_itr != lootPlayerFFAItems.end())
1168 {
1169 QuestItemList* ffa_list = ffa_itr->second;
1170 for (QuestItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
1171 {
1172 LootItem& item = l.items[fi->index];
1173 if (!fi->is_looted && !item.is_looted)
1174 {
1175 b << uint8(fi->index);
1176 b << item;
1177 // Xinef: Here are FFA items, so dont use owner permision
1178 b << uint8(LOOT_SLOT_TYPE_ALLOW_LOOT /*slotType*/);
1179 ++itemsShown;
1180 }
1181 }
1182 }
1183
1184 QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems();
1185 QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID());
1186 if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
1187 {
1188 QuestItemList* conditional_list = nn_itr->second;
1189 for (QuestItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
1190 {
1191 LootItem& item = l.items[ci->index];
1192 if (!ci->is_looted && !item.is_looted)
1193 {
1194 b << uint8(ci->index);
1195 b << item;
1196 if (item.follow_loot_rules)
1197 {
1198 switch (lv.permission)
1199 {
1200 case MASTER_PERMISSION:
1202 break;
1204 b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
1205 break;
1206 case GROUP_PERMISSION:
1208 if (!item.is_blocked)
1210 else
1212 break;
1213 default:
1214 b << uint8(slotType);
1215 break;
1216 }
1217 }
1218 else if (!item.freeforall)
1219 b << uint8(partySlotType);
1220 else
1221 b << uint8(slotType);
1222 ++itemsShown;
1223 }
1224 }
1225 }
1226
1227 //update number of items shown
1228 b.put<uint8>(count_pos, itemsShown);
1229
1230 return b;
1231}
std::uint8_t uint8
Definition Define.h:109
@ OWNER_PERMISSION
Definition LootMgr.h:72
@ ALL_PERMISSION
Definition LootMgr.h:67
@ RESTRICTED_PERMISSION
Definition LootMgr.h:70
@ NONE_PERMISSION
Definition LootMgr.h:73
@ ROUND_ROBIN_PERMISSION
Definition LootMgr.h:71
@ MASTER_PERMISSION
Definition LootMgr.h:69
@ GROUP_PERMISSION
Definition LootMgr.h:68
std::map< ObjectGuid, QuestItemList * > QuestItemMap
Definition LootMgr.h:200
LootSlotType
Definition LootMgr.h:113
@ LOOT_SLOT_TYPE_MASTER
Definition LootMgr.h:116
@ LOOT_SLOT_TYPE_ROLL_ONGOING
Definition LootMgr.h:115
@ LOOT_SLOT_TYPE_ALLOW_LOOT
Definition LootMgr.h:114
@ LOOT_SLOT_TYPE_OWNER
Definition LootMgr.h:118
@ LOOT_SLOT_TYPE_LOCKED
Definition LootMgr.h:117
std::vector< QuestItem > QuestItemList
Definition LootMgr.h:198
std::size_t wpos() const
Definition ByteBuffer.h:330
void put(std::size_t pos, T value)
Definition ByteBuffer.h:137
Definition LootMgr.h:154
uint32 itemid
Definition LootMgr.h:155
bool is_looted
Definition LootMgr.h:163
bool freeforall
Definition LootMgr.h:165
Definition LootMgr.h:313
ObjectGuid sourceWorldObjectGUID
Definition LootMgr.h:330
ObjectGuid roundRobinPlayer
Definition LootMgr.h:324
uint32 gold
Definition LootMgr.h:322
QuestItemMap const & GetPlayerQuestItems() const
Definition LootMgr.h:316
std::vector< LootItem > items
Definition LootMgr.h:320
QuestItemMap const & GetPlayerFFAItems() const
Definition LootMgr.h:317
QuestItemMap const & GetPlayerNonQuestNonFFAConditionalItems() const
Definition LootMgr.h:318
std::vector< LootItem > quest_items
Definition LootMgr.h:321
Definition LootMgr.h:185

Variable Documentation

◆ LootTemplates_Creature

◆ LootTemplates_Disenchant

LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true) ( "disenchant_loot_template"  ,
"item disenchant id"  ,
true   
)

◆ LootTemplates_Fishing

LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true) ( "fishing_loot_template"  ,
"area id"  ,
true   
)

◆ LootTemplates_Gameobject

LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true) ( "gameobject_loot_template"  ,
"gameobject entry"  ,
true   
)

◆ LootTemplates_Item

◆ LootTemplates_Mail

LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false) ( "mail_loot_template"  ,
"mail template id"  ,
false   
)

◆ LootTemplates_Milling

LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true) ( "milling_loot_template"  ,
"item entry (herb)"  ,
true   
)

◆ LootTemplates_Pickpocketing

LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true) ( "pickpocketing_loot_template"  ,
"creature pickpocket lootid"  ,
true   
)

◆ LootTemplates_Player

LootStore LootTemplates_Player("player_loot_template", "team id", true) ( "player_loot_template"  ,
"team id"  ,
true   
)

◆ LootTemplates_Prospecting

LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true) ( "prospecting_loot_template"  ,
"item entry (ore)"  ,
true   
)

◆ LootTemplates_Reference

LootStore LootTemplates_Reference("reference_loot_template", "reference id", false) ( "reference_loot_template"  ,
"reference id"  ,
false   
)

◆ LootTemplates_Skinning

◆ LootTemplates_Spell

LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false) ( "spell_loot_template"  ,
"spell id (random item creating)"  ,
false   
)

◆ qualityToRate

ServerConfigs const qualityToRate[]
Initial value:
=
{
}
@ RATE_DROP_ITEM_RARE
Definition WorldConfig.h:403
@ RATE_DROP_ITEM_LEGENDARY
Definition WorldConfig.h:405
@ RATE_DROP_ITEM_POOR
Definition WorldConfig.h:400
@ RATE_DROP_ITEM_UNCOMMON
Definition WorldConfig.h:402
@ RATE_DROP_ITEM_EPIC
Definition WorldConfig.h:404
@ RATE_DROP_ITEM_ARTIFACT
Definition WorldConfig.h:406
@ RATE_DROP_ITEM_NORMAL
Definition WorldConfig.h:401
34{
35 RATE_DROP_ITEM_POOR, // ITEM_QUALITY_POOR
36 RATE_DROP_ITEM_NORMAL, // ITEM_QUALITY_NORMAL
37 RATE_DROP_ITEM_UNCOMMON, // ITEM_QUALITY_UNCOMMON
38 RATE_DROP_ITEM_RARE, // ITEM_QUALITY_RARE
39 RATE_DROP_ITEM_EPIC, // ITEM_QUALITY_EPIC
40 RATE_DROP_ITEM_LEGENDARY, // ITEM_QUALITY_LEGENDARY
41 RATE_DROP_ITEM_ARTIFACT, // ITEM_QUALITY_ARTIFACT
42};