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 ( )
1893{
1894 LOG_INFO("server.loading", "Loading Creature Loot Templates...");
1895
1896 uint32 oldMSTime = getMSTime();
1897
1898 LootIdSet lootIdSet, lootIdSetUsed;
1900
1901 // Remove real entries and check loot existence
1902 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
1903 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
1904 {
1905 if (uint32 lootid = itr->second.lootid)
1906 {
1907 if (lootIdSet.find(lootid) == lootIdSet.end())
1908 LootTemplates_Creature.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
1909 else
1910 lootIdSetUsed.insert(lootid);
1911 }
1912 }
1913
1914 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
1915 lootIdSet.erase(*itr);
1916
1917 // output error for any still listed (not referenced from appropriate table) ids
1919
1920 if (count)
1921 LOG_INFO("server.loading", ">> Loaded {} Creature Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1922 else
1923 LOG_WARN("server.loading", ">> Loaded 0 creature loot templates. DB table `creature_loot_template` is empty");
1924
1925 LOG_INFO("server.loading", " ");
1926}
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:166
#define LOG_WARN(filterType__,...)
Definition Log.h:162
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
std::set< uint32 > LootIdSet
Definition LootMgr.h:204
#define sObjectMgr
Definition ObjectMgr.h:1712
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 ( )
1929{
1930 LOG_INFO("server.loading", "Loading Disenchanting Loot Templates...");
1931
1932 uint32 oldMSTime = getMSTime();
1933
1934 LootIdSet lootIdSet, lootIdSetUsed;
1936
1937 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
1938 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
1939 {
1940 if (uint32 lootid = itr->second.DisenchantID)
1941 {
1942 if (lootIdSet.find(lootid) == lootIdSet.end())
1944 else
1945 lootIdSetUsed.insert(lootid);
1946 }
1947 }
1948
1949 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
1950 lootIdSet.erase(*itr);
1951
1952 // output error for any still listed (not referenced from appropriate table) ids
1954
1955 if (count)
1956 LOG_INFO("server.loading", ">> Loaded {} disenchanting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1957 else
1958 LOG_WARN("server.loading", ">> Loaded 0 disenchanting loot templates. DB table `disenchant_loot_template` is empty");
1959 LOG_INFO("server.loading", " ");
1960}
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 ( )
1963{
1964 LOG_INFO("server.loading", "Loading Fishing Loot Templates...");
1965
1966 uint32 oldMSTime = getMSTime();
1967
1968 LootIdSet lootIdSet;
1970
1971 // remove real entries and check existence loot
1972 for (uint32 i = 1; i < sAreaTableStore.GetNumRows(); ++i)
1973 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i))
1974 if (lootIdSet.find(areaEntry->ID) != lootIdSet.end())
1975 lootIdSet.erase(areaEntry->ID);
1976
1977 // output error for any still listed (not referenced from appropriate table) ids
1979
1980 if (count)
1981 LOG_INFO("server.loading", ">> Loaded {} Fishing Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1982 else
1983 LOG_WARN("server.loading", ">> Loaded 0 fishing loot templates. DB table `fishing_loot_template` is empty");
1984
1985 LOG_INFO("server.loading", " ");
1986}
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 ( )
1989{
1990 LOG_INFO("server.loading", "Loading Gameobject Loot Templates...");
1991
1992 uint32 oldMSTime = getMSTime();
1993
1994 LootIdSet lootIdSet, lootIdSetUsed;
1996
1997 // remove real entries and check existence loot
1998 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
1999 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
2000 {
2001 if (uint32 lootid = itr->second.GetLootId())
2002 {
2003 if (lootIdSet.find(lootid) == lootIdSet.end())
2004 LootTemplates_Gameobject.ReportNonExistingId(lootid, "Gameobject", itr->second.entry);
2005 else
2006 lootIdSetUsed.insert(lootid);
2007 }
2008 }
2009
2010 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2011 lootIdSet.erase(*itr);
2012
2013 // output error for any still listed (not referenced from appropriate table) ids
2015
2016 if (count)
2017 LOG_INFO("server.loading", ">> Loaded {} Gameobject Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2018 else
2019 LOG_WARN("server.loading", ">> Loaded 0 gameobject loot templates. DB table `gameobject_loot_template` is empty");
2020
2021 LOG_INFO("server.loading", " ");
2022}
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 ( )
2025{
2026 LOG_INFO("server.loading", "Loading Item Loot Templates...");
2027
2028 uint32 oldMSTime = getMSTime();
2029
2030 LootIdSet lootIdSet;
2032
2033 // remove real entries and check existence loot
2034 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2035 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2036 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.HasFlag(ITEM_FLAG_HAS_LOOT))
2037 lootIdSet.erase(itr->second.ItemId);
2038
2039 // output error for any still listed (not referenced from appropriate table) ids
2041
2042 if (count)
2043 LOG_INFO("server.loading", ">> Loaded {} item loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2044 else
2045 LOG_WARN("server.loading", ">> Loaded 0 item loot templates. DB table `item_loot_template` is empty");
2046
2047 LOG_INFO("server.loading", " ");
2048}
@ 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 ( )
2149{
2150 LOG_INFO("server.loading", "Loading Mail Loot Templates...");
2151
2152 uint32 oldMSTime = getMSTime();
2153
2154 LootIdSet lootIdSet;
2156
2157 // remove real entries and check existence loot
2158 for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
2159 if (sMailTemplateStore.LookupEntry(i))
2160 if (lootIdSet.find(i) != lootIdSet.end())
2161 lootIdSet.erase(i);
2162
2163 // output error for any still listed (not referenced from appropriate table) ids
2165
2166 if (count)
2167 LOG_INFO("server.loading", ">> Loaded {} mail loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2168 else
2169 LOG_WARN("server.loading", ">> Loaded 0 mail loot templates. DB table `mail_loot_template` is empty");
2170
2171 LOG_INFO("server.loading", " ");
2172}
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 ( )
2051{
2052 LOG_INFO("server.loading", "Loading Milling Loot Templates...");
2053
2054 uint32 oldMSTime = getMSTime();
2055
2056 LootIdSet lootIdSet;
2058
2059 // remove real entries and check existence loot
2060 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2061 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2062 {
2063 if (!itr->second.HasFlag(ITEM_FLAG_IS_MILLABLE))
2064 continue;
2065
2066 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2067 lootIdSet.erase(itr->second.ItemId);
2068 }
2069
2070 // output error for any still listed (not referenced from appropriate table) ids
2072
2073 if (count)
2074 LOG_INFO("server.loading", ">> Loaded {} milling loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2075 else
2076 LOG_WARN("server.loading", ">> Loaded 0 milling loot templates. DB table `milling_loot_template` is empty");
2077
2078 LOG_INFO("server.loading", " ");
2079}
@ 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 ( )
2082{
2083 LOG_INFO("server.loading", "Loading Pickpocketing Loot Templates...");
2084
2085 uint32 oldMSTime = getMSTime();
2086
2087 LootIdSet lootIdSet, lootIdSetUsed;
2089
2090 // Remove real entries and check loot existence
2091 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2092 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2093 {
2094 if (uint32 lootid = itr->second.pickpocketLootId)
2095 {
2096 if (lootIdSet.find(lootid) == lootIdSet.end())
2097 LootTemplates_Pickpocketing.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2098 else
2099 lootIdSetUsed.insert(lootid);
2100 }
2101 }
2102
2103 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2104 lootIdSet.erase(*itr);
2105
2106 // output error for any still listed (not referenced from appropriate table) ids
2108
2109 if (count)
2110 LOG_INFO("server.loading", ">> Loaded {} pickpocketing loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2111 else
2112 LOG_WARN("server.loading", ">> Loaded 0 pickpocketing loot templates. DB table `pickpocketing_loot_template` is empty");
2113
2114 LOG_INFO("server.loading", " ");
2115}
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 ( )
2254{
2255 LOG_INFO("server.loading", "Loading Player Loot Templates...");
2256
2257 uint32 oldMSTime = getMSTime();
2258
2259 LootIdSet lootIdSet;
2261
2262 if (count)
2263 {
2264 LOG_INFO("server.loading", ">> Loaded {} player loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2265 }
2266 else
2267 {
2268 LOG_WARN("server.loading", ">> Loaded 0 player loot templates. DB table `player_loot_template` is empty");
2269 }
2270
2271 LOG_INFO("server.loading", " ");
2272}
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 ( )
2118{
2119 LOG_INFO("server.loading", "Loading Prospecting Loot Templates...");
2120
2121 uint32 oldMSTime = getMSTime();
2122
2123 LootIdSet lootIdSet;
2125
2126 // remove real entries and check existence loot
2127 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2128 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2129 {
2130 if (!itr->second.HasFlag(ITEM_FLAG_IS_PROSPECTABLE))
2131 continue;
2132
2133 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2134 lootIdSet.erase(itr->second.ItemId);
2135 }
2136
2137 // output error for any still listed (not referenced from appropriate table) ids
2139
2140 if (count)
2141 LOG_INFO("server.loading", ">> Loaded {} prospecting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2142 else
2143 LOG_WARN("server.loading", ">> Loaded 0 prospecting loot templates. DB table `prospecting_loot_template` is empty");
2144
2145 LOG_INFO("server.loading", " ");
2146}
@ 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 ( )
2275{
2276 LOG_INFO("server.loading", "Loading Reference Loot Templates...");
2277
2278 uint32 oldMSTime = getMSTime();
2279
2280 LootIdSet lootIdSet;
2282
2283 // check references and remove used
2295
2296 // output error for any still listed ids (not referenced from any loot table)
2298
2299 LOG_INFO("server.loading", ">> Loaded reference loot templates in {} ms", GetMSTimeDiffToNow(oldMSTime));
2300 LOG_INFO("server.loading", " ");
2301}
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 ( )
2175{
2176 LOG_INFO("server.loading", "Loading Skinning Loot Templates...");
2177
2178 uint32 oldMSTime = getMSTime();
2179
2180 LootIdSet lootIdSet, lootIdSetUsed;
2182
2183 // remove real entries and check existence loot
2184 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2185 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2186 {
2187 if (uint32 lootid = itr->second.SkinLootId)
2188 {
2189 if (lootIdSet.find(lootid) == lootIdSet.end())
2190 LootTemplates_Skinning.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2191 else
2192 lootIdSetUsed.insert(lootid);
2193 }
2194 }
2195
2196 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2197 lootIdSet.erase(*itr);
2198
2199 // output error for any still listed (not referenced from appropriate table) ids
2201
2202 if (count)
2203 LOG_INFO("server.loading", ">> Loaded {} skinning loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2204 else
2205 LOG_WARN("server.loading", ">> Loaded 0 skinning loot templates. DB table `skinning_loot_template` is empty");
2206
2207 LOG_INFO("server.loading", " ");
2208}

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 ( )
2211{
2212 LOG_INFO("server.loading", "Loading Spell Loot Templates...");
2213
2214 uint32 oldMSTime = getMSTime();
2215
2216 LootIdSet lootIdSet;
2218
2219 // remove real entries and check existence loot
2220 for (uint32 spell_id = 1; spell_id < sSpellMgr->GetSpellInfoStoreSize(); ++spell_id)
2221 {
2222 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
2223 if (!spellInfo)
2224 continue;
2225
2226 // possible cases
2227 if (!spellInfo->IsLootCrafting())
2228 continue;
2229
2230 if (lootIdSet.find(spell_id) == lootIdSet.end())
2231 {
2232 // not report about not trainable spells (optionally supported by DB)
2233 // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example
2235 {
2236 LootTemplates_Spell.ReportNonExistingId(spell_id, "Spell", spellInfo->Id);
2237 }
2238 }
2239 else
2240 lootIdSet.erase(spell_id);
2241 }
2242
2243 // output error for any still listed (not referenced from appropriate table) ids
2245
2246 if (count)
2247 LOG_INFO("server.loading", ">> Loaded {} spell loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2248 else
2249 LOG_WARN("server.loading", ">> Loaded 0 spell loot templates. DB table `spell_loot_template` is empty");
2250 LOG_INFO("server.loading", " ");
2251}
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 
)
946{
947 b << uint32(li.itemid);
948 b << uint32(li.count); // nr of items of this type
949 b << uint32(sObjectMgr->GetItemTemplate(li.itemid)->DisplayInfoID);
950 b << uint32(li.randomSuffix);
951 b << uint32(li.randomPropertyId);
952 //b << uint8(0); // slot type - will send after this function call
953 return b;
954}

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

◆ operator<<() [2/2]

ByteBuffer & operator<< ( ByteBuffer b,
LootView const &  lv 
)
957{
958 if (lv.permission == NONE_PERMISSION)
959 {
960 b << uint32(0); //gold
961 b << uint8(0); // item count
962 return b; // nothing output more
963 }
964
965 Loot& l = lv.loot;
966
967 uint8 itemsShown = 0;
968
969 b << uint32(l.gold); //gold
970
971 std::size_t count_pos = b.wpos(); // pos of item count byte
972 b << uint8(0); // item count placeholder
973
974 switch (lv.permission)
975 {
976 case GROUP_PERMISSION:
979 {
980 bool isMasterLooter = lv.viewer->GetGroup() && lv.viewer->GetGroup()->GetMasterLooterGuid() == lv.viewer->GetGUID();
981
982 // if you are not the round-robin group looter, you can only see
983 // blocked rolled items and quest items, and !ffa items
984 for (uint8 i = 0; i < l.items.size(); ++i)
985 {
986 if (!l.items[i].is_looted && !l.items[i].freeforall && (l.items[i].conditions.empty() || isMasterLooter) && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
987 {
988 uint8 slot_type = 0;
989
990 if (l.items[i].is_blocked) // for ML & restricted is_blocked = !is_underthreshold
991 {
992 switch (lv.permission)
993 {
994 case GROUP_PERMISSION:
995 slot_type = LOOT_SLOT_TYPE_ROLL_ONGOING;
996 break;
998 {
999 if (lv.viewer->GetGroup())
1000 {
1001 if (lv.viewer->GetGroup()->GetMasterLooterGuid() == lv.viewer->GetGUID())
1002 slot_type = LOOT_SLOT_TYPE_MASTER;
1003 else
1004 slot_type = LOOT_SLOT_TYPE_LOCKED;
1005 }
1006 break;
1007 }
1009 slot_type = LOOT_SLOT_TYPE_LOCKED;
1010 break;
1011 default:
1012 continue;
1013 }
1014 }
1015 else if (l.items[i].rollWinnerGUID)
1016 {
1017 if (l.items[i].rollWinnerGUID == lv.viewer->GetGUID())
1018 slot_type = LOOT_SLOT_TYPE_OWNER;
1019 else
1020 continue;
1021 }
1022 else if (!l.roundRobinPlayer || lv.viewer->GetGUID() == l.roundRobinPlayer || !l.items[i].is_underthreshold)
1023 {
1024 // no round robin owner or he has released the loot
1025 // or it IS the round robin group owner
1026 // => item is lootable
1027 slot_type = LOOT_SLOT_TYPE_ALLOW_LOOT;
1028 }
1029 else
1030 // item shall not be displayed.
1031 continue;
1032
1033 b << uint8(i) << l.items[i];
1034 b << uint8(slot_type);
1035 ++itemsShown;
1036 }
1037 }
1038 break;
1039 }
1041 {
1042 for (uint8 i = 0; i < l.items.size(); ++i)
1043 {
1044 if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1045 {
1046 if (l.roundRobinPlayer && lv.viewer->GetGUID() != l.roundRobinPlayer)
1047 // item shall not be displayed.
1048 continue;
1049
1050 b << uint8(i) << l.items[i];
1052 ++itemsShown;
1053 }
1054 }
1055 break;
1056 }
1057 case ALL_PERMISSION:
1058 case OWNER_PERMISSION:
1059 {
1061 for (uint8 i = 0; i < l.items.size(); ++i)
1062 {
1063 if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1064 {
1065 b << uint8(i) << l.items[i];
1066 b << uint8(slot_type);
1067 ++itemsShown;
1068 }
1069 }
1070 break;
1071 }
1072 default:
1073 return b;
1074 }
1075
1077
1078 // Xinef: items that do not follow loot rules need this
1079 LootSlotType partySlotType = lv.permission == MASTER_PERMISSION ? LOOT_SLOT_TYPE_MASTER : slotType;
1080
1081 QuestItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems();
1082 QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID());
1083 if (q_itr != lootPlayerQuestItems.end())
1084 {
1085 QuestItemList* q_list = q_itr->second;
1086 for (QuestItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
1087 {
1088 LootItem& item = l.quest_items[qi->index];
1089 if (!qi->is_looted && !item.is_looted)
1090 {
1091 bool showInLoot = true;
1092 bool hasQuestForItem = lv.viewer->HasQuestForItem(item.itemid, 0, false, &showInLoot);
1093 if (!hasQuestForItem)
1094 {
1095 if (!showInLoot)
1096 {
1097 const_cast<QuestItem*>(&(*qi))->is_looted = true;
1098 if (!item.freeforall)
1099 {
1100 item.is_looted = true;
1101 }
1102 continue;
1103 }
1104
1105 b << uint8(l.items.size() + (qi - q_list->begin()));
1106 b << item;
1108 }
1109 else
1110 {
1111 b << uint8(l.items.size() + (qi - q_list->begin()));
1112 b << item;
1113
1114 if (item.follow_loot_rules)
1115 {
1116 switch (lv.permission)
1117 {
1118 case MASTER_PERMISSION:
1120 break;
1122 b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
1123 break;
1124 case GROUP_PERMISSION:
1126 if (!item.is_blocked)
1128 else
1130 break;
1131 default:
1132 b << uint8(slotType);
1133 break;
1134 }
1135 }
1136 else if (!item.freeforall)
1137 b << uint8(partySlotType);
1138 else
1139 b << uint8(slotType);
1140 }
1141
1142 ++itemsShown;
1143 }
1144 }
1145 }
1146
1147 QuestItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems();
1148 QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID());
1149 if (ffa_itr != lootPlayerFFAItems.end())
1150 {
1151 QuestItemList* ffa_list = ffa_itr->second;
1152 for (QuestItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
1153 {
1154 LootItem& item = l.items[fi->index];
1155 if (!fi->is_looted && !item.is_looted)
1156 {
1157 b << uint8(fi->index);
1158 b << item;
1159 // Xinef: Here are FFA items, so dont use owner permision
1160 b << uint8(LOOT_SLOT_TYPE_ALLOW_LOOT /*slotType*/);
1161 ++itemsShown;
1162 }
1163 }
1164 }
1165
1166 QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems();
1167 QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID());
1168 if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
1169 {
1170 QuestItemList* conditional_list = nn_itr->second;
1171 for (QuestItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
1172 {
1173 LootItem& item = l.items[ci->index];
1174 if (!ci->is_looted && !item.is_looted)
1175 {
1176 b << uint8(ci->index);
1177 b << item;
1178 if (item.follow_loot_rules)
1179 {
1180 switch (lv.permission)
1181 {
1182 case MASTER_PERMISSION:
1184 break;
1186 b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
1187 break;
1188 case GROUP_PERMISSION:
1190 if (!item.is_blocked)
1192 else
1194 break;
1195 default:
1196 b << uint8(slotType);
1197 break;
1198 }
1199 }
1200 else if (!item.freeforall)
1201 b << uint8(partySlotType);
1202 else
1203 b << uint8(slotType);
1204 ++itemsShown;
1205 }
1206 }
1207 }
1208
1209 //update number of items shown
1210 b.put<uint8>(count_pos, itemsShown);
1211
1212 return b;
1213}
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:405
@ RATE_DROP_ITEM_LEGENDARY
Definition WorldConfig.h:407
@ RATE_DROP_ITEM_POOR
Definition WorldConfig.h:402
@ RATE_DROP_ITEM_UNCOMMON
Definition WorldConfig.h:404
@ RATE_DROP_ITEM_EPIC
Definition WorldConfig.h:406
@ RATE_DROP_ITEM_ARTIFACT
Definition WorldConfig.h:408
@ RATE_DROP_ITEM_NORMAL
Definition WorldConfig.h:403
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};