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 ( )
1965{
1966 LOG_INFO("server.loading", "Loading Creature Loot Templates...");
1967
1968 uint32 oldMSTime = getMSTime();
1969
1970 LootIdSet lootIdSet, lootIdSetUsed;
1972
1973 // Remove real entries and check loot existence
1974 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
1975 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
1976 {
1977 if (uint32 lootid = itr->second.lootid)
1978 {
1979 if (lootIdSet.find(lootid) == lootIdSet.end())
1980 LootTemplates_Creature.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
1981 else
1982 lootIdSetUsed.insert(lootid);
1983 }
1984 }
1985
1986 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
1987 lootIdSet.erase(*itr);
1988
1989 // output error for any still listed (not referenced from appropriate table) ids
1991
1992 if (count)
1993 LOG_INFO("server.loading", ">> Loaded {} Creature Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1994 else
1995 LOG_WARN("server.loading", ">> Loaded 0 creature loot templates. DB table `creature_loot_template` is empty");
1996
1997 LOG_INFO("server.loading", " ");
1998}
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition CreatureData.h:292
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:1650
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 ( )
2001{
2002 LOG_INFO("server.loading", "Loading Disenchanting Loot Templates...");
2003
2004 uint32 oldMSTime = getMSTime();
2005
2006 LootIdSet lootIdSet, lootIdSetUsed;
2008
2009 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2010 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2011 {
2012 if (uint32 lootid = itr->second.DisenchantID)
2013 {
2014 if (lootIdSet.find(lootid) == lootIdSet.end())
2016 else
2017 lootIdSetUsed.insert(lootid);
2018 }
2019 }
2020
2021 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2022 lootIdSet.erase(*itr);
2023
2024 // output error for any still listed (not referenced from appropriate table) ids
2026
2027 if (count)
2028 LOG_INFO("server.loading", ">> Loaded {} disenchanting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2029 else
2030 LOG_WARN("server.loading", ">> Loaded 0 disenchanting loot templates. DB table `disenchant_loot_template` is empty");
2031 LOG_INFO("server.loading", " ");
2032}
std::unordered_map< uint32, ItemTemplate > ItemTemplateContainer
Definition ItemTemplate.h:834
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 ( )
2035{
2036 LOG_INFO("server.loading", "Loading Fishing Loot Templates...");
2037
2038 uint32 oldMSTime = getMSTime();
2039
2040 LootIdSet lootIdSet;
2042
2043 // remove real entries and check existence loot
2044 for (uint32 i = 1; i < sAreaTableStore.GetNumRows(); ++i)
2045 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i))
2046 if (lootIdSet.find(areaEntry->ID) != lootIdSet.end())
2047 lootIdSet.erase(areaEntry->ID);
2048
2049 // output error for any still listed (not referenced from appropriate table) ids
2051
2052 if (count)
2053 LOG_INFO("server.loading", ">> Loaded {} Fishing Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2054 else
2055 LOG_WARN("server.loading", ">> Loaded 0 fishing loot templates. DB table `fishing_loot_template` is empty");
2056
2057 LOG_INFO("server.loading", " ");
2058}
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 ( )
2061{
2062 LOG_INFO("server.loading", "Loading Gameobject Loot Templates...");
2063
2064 uint32 oldMSTime = getMSTime();
2065
2066 LootIdSet lootIdSet, lootIdSetUsed;
2068
2069 // remove real entries and check existence loot
2070 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
2071 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
2072 {
2073 if (uint32 lootid = itr->second.GetLootId())
2074 {
2075 if (lootIdSet.find(lootid) == lootIdSet.end())
2076 LootTemplates_Gameobject.ReportNonExistingId(lootid, "Gameobject", itr->second.entry);
2077 else
2078 lootIdSetUsed.insert(lootid);
2079 }
2080 }
2081
2082 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2083 lootIdSet.erase(*itr);
2084
2085 // output error for any still listed (not referenced from appropriate table) ids
2087
2088 if (count)
2089 LOG_INFO("server.loading", ">> Loaded {} Gameobject Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2090 else
2091 LOG_WARN("server.loading", ">> Loaded 0 gameobject loot templates. DB table `gameobject_loot_template` is empty");
2092
2093 LOG_INFO("server.loading", " ");
2094}
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 ( )
2097{
2098 LOG_INFO("server.loading", "Loading Item Loot Templates...");
2099
2100 uint32 oldMSTime = getMSTime();
2101
2102 LootIdSet lootIdSet;
2104
2105 // remove real entries and check existence loot
2106 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2107 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2108 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.HasFlag(ITEM_FLAG_HAS_LOOT))
2109 lootIdSet.erase(itr->second.ItemId);
2110
2111 // output error for any still listed (not referenced from appropriate table) ids
2113
2114 if (count)
2115 LOG_INFO("server.loading", ">> Loaded {} item loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2116 else
2117 LOG_WARN("server.loading", ">> Loaded 0 item loot templates. DB table `item_loot_template` is empty");
2118
2119 LOG_INFO("server.loading", " ");
2120}
@ 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 ( )
2221{
2222 LOG_INFO("server.loading", "Loading Mail Loot Templates...");
2223
2224 uint32 oldMSTime = getMSTime();
2225
2226 LootIdSet lootIdSet;
2228
2229 // remove real entries and check existence loot
2230 for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
2231 if (sMailTemplateStore.LookupEntry(i))
2232 if (lootIdSet.find(i) != lootIdSet.end())
2233 lootIdSet.erase(i);
2234
2235 // output error for any still listed (not referenced from appropriate table) ids
2237
2238 if (count)
2239 LOG_INFO("server.loading", ">> Loaded {} mail loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2240 else
2241 LOG_WARN("server.loading", ">> Loaded 0 mail loot templates. DB table `mail_loot_template` is empty");
2242
2243 LOG_INFO("server.loading", " ");
2244}
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 ( )
2123{
2124 LOG_INFO("server.loading", "Loading Milling Loot Templates...");
2125
2126 uint32 oldMSTime = getMSTime();
2127
2128 LootIdSet lootIdSet;
2130
2131 // remove real entries and check existence loot
2132 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2133 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2134 {
2135 if (!itr->second.HasFlag(ITEM_FLAG_IS_MILLABLE))
2136 continue;
2137
2138 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2139 lootIdSet.erase(itr->second.ItemId);
2140 }
2141
2142 // output error for any still listed (not referenced from appropriate table) ids
2144
2145 if (count)
2146 LOG_INFO("server.loading", ">> Loaded {} milling loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2147 else
2148 LOG_WARN("server.loading", ">> Loaded 0 milling loot templates. DB table `milling_loot_template` is empty");
2149
2150 LOG_INFO("server.loading", " ");
2151}
@ 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 ( )
2154{
2155 LOG_INFO("server.loading", "Loading Pickpocketing Loot Templates...");
2156
2157 uint32 oldMSTime = getMSTime();
2158
2159 LootIdSet lootIdSet, lootIdSetUsed;
2161
2162 // Remove real entries and check loot existence
2163 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2164 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2165 {
2166 if (uint32 lootid = itr->second.pickpocketLootId)
2167 {
2168 if (lootIdSet.find(lootid) == lootIdSet.end())
2169 LootTemplates_Pickpocketing.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2170 else
2171 lootIdSetUsed.insert(lootid);
2172 }
2173 }
2174
2175 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2176 lootIdSet.erase(*itr);
2177
2178 // output error for any still listed (not referenced from appropriate table) ids
2180
2181 if (count)
2182 LOG_INFO("server.loading", ">> Loaded {} pickpocketing loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2183 else
2184 LOG_WARN("server.loading", ">> Loaded 0 pickpocketing loot templates. DB table `pickpocketing_loot_template` is empty");
2185
2186 LOG_INFO("server.loading", " ");
2187}
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 ( )
2326{
2327 LOG_INFO("server.loading", "Loading Player Loot Templates...");
2328
2329 uint32 oldMSTime = getMSTime();
2330
2331 LootIdSet lootIdSet;
2333
2334 if (count)
2335 {
2336 LOG_INFO("server.loading", ">> Loaded {} player loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2337 }
2338 else
2339 {
2340 LOG_WARN("server.loading", ">> Loaded 0 player loot templates. DB table `player_loot_template` is empty");
2341 }
2342
2343 LOG_INFO("server.loading", " ");
2344}
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 ( )
2190{
2191 LOG_INFO("server.loading", "Loading Prospecting Loot Templates...");
2192
2193 uint32 oldMSTime = getMSTime();
2194
2195 LootIdSet lootIdSet;
2197
2198 // remove real entries and check existence loot
2199 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2200 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2201 {
2202 if (!itr->second.HasFlag(ITEM_FLAG_IS_PROSPECTABLE))
2203 continue;
2204
2205 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2206 lootIdSet.erase(itr->second.ItemId);
2207 }
2208
2209 // output error for any still listed (not referenced from appropriate table) ids
2211
2212 if (count)
2213 LOG_INFO("server.loading", ">> Loaded {} prospecting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2214 else
2215 LOG_WARN("server.loading", ">> Loaded 0 prospecting loot templates. DB table `prospecting_loot_template` is empty");
2216
2217 LOG_INFO("server.loading", " ");
2218}
@ 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 ( )
2347{
2348 LOG_INFO("server.loading", "Loading Reference Loot Templates...");
2349
2350 uint32 oldMSTime = getMSTime();
2351
2352 LootIdSet lootIdSet;
2354
2355 // check references and remove used
2367
2368 // output error for any still listed ids (not referenced from any loot table)
2370
2371 LOG_INFO("server.loading", ">> Loaded reference loot templates in {} ms", GetMSTimeDiffToNow(oldMSTime));
2372 LOG_INFO("server.loading", " ");
2373}
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 ( )
2247{
2248 LOG_INFO("server.loading", "Loading Skinning Loot Templates...");
2249
2250 uint32 oldMSTime = getMSTime();
2251
2252 LootIdSet lootIdSet, lootIdSetUsed;
2254
2255 // remove real entries and check existence loot
2256 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2257 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2258 {
2259 if (uint32 lootid = itr->second.SkinLootId)
2260 {
2261 if (lootIdSet.find(lootid) == lootIdSet.end())
2262 LootTemplates_Skinning.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2263 else
2264 lootIdSetUsed.insert(lootid);
2265 }
2266 }
2267
2268 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2269 lootIdSet.erase(*itr);
2270
2271 // output error for any still listed (not referenced from appropriate table) ids
2273
2274 if (count)
2275 LOG_INFO("server.loading", ">> Loaded {} skinning loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2276 else
2277 LOG_WARN("server.loading", ">> Loaded 0 skinning loot templates. DB table `skinning_loot_template` is empty");
2278
2279 LOG_INFO("server.loading", " ");
2280}

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 ( )
2283{
2284 LOG_INFO("server.loading", "Loading Spell Loot Templates...");
2285
2286 uint32 oldMSTime = getMSTime();
2287
2288 LootIdSet lootIdSet;
2290
2291 // remove real entries and check existence loot
2292 for (uint32 spell_id = 1; spell_id < sSpellMgr->GetSpellInfoStoreSize(); ++spell_id)
2293 {
2294 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
2295 if (!spellInfo)
2296 continue;
2297
2298 // possible cases
2299 if (!spellInfo->IsLootCrafting())
2300 continue;
2301
2302 if (lootIdSet.find(spell_id) == lootIdSet.end())
2303 {
2304 // not report about not trainable spells (optionally supported by DB)
2305 // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example
2307 {
2308 LootTemplates_Spell.ReportNonExistingId(spell_id, "Spell", spellInfo->Id);
2309 }
2310 }
2311 else
2312 lootIdSet.erase(spell_id);
2313 }
2314
2315 // output error for any still listed (not referenced from appropriate table) ids
2317
2318 if (count)
2319 LOG_INFO("server.loading", ">> Loaded {} spell loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2320 else
2321 LOG_WARN("server.loading", ">> Loaded 0 spell loot templates. DB table `spell_loot_template` is empty");
2322 LOG_INFO("server.loading", " ");
2323}
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false)
@ SPELL_ATTR0_IS_TRADESKILL
Definition SharedDefines.h:387
@ SPELL_ATTR0_NOT_SHAPESHIFTED
Definition SharedDefines.h:398
#define sSpellMgr
Definition SpellMgr.h:825
Definition SpellInfo.h:316
uint32 Id
Definition SpellInfo.h:320
bool IsLootCrafting() const
Definition SpellInfo.cpp:925
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:415

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 
)
994{
995 b << uint32(li.itemid);
996 b << uint32(li.count); // nr of items of this type
997 b << uint32(sObjectMgr->GetItemTemplate(li.itemid)->DisplayInfoID);
998 b << uint32(li.randomSuffix);
999 b << uint32(li.randomPropertyId);
1000 //b << uint8(0); // slot type - will send after this function call
1001 return b;
1002}

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

◆ operator<<() [2/2]

ByteBuffer & operator<< ( ByteBuffer b,
LootView const &  lv 
)
1005{
1006 if (lv.permission == NONE_PERMISSION)
1007 {
1008 b << uint32(0); //gold
1009 b << uint8(0); // item count
1010 return b; // nothing output more
1011 }
1012
1013 Loot& l = lv.loot;
1014
1015 uint8 itemsShown = 0;
1016
1017 b << uint32(l.gold); //gold
1018
1019 std::size_t count_pos = b.wpos(); // pos of item count byte
1020 b << uint8(0); // item count placeholder
1021
1022 switch (lv.permission)
1023 {
1024 case GROUP_PERMISSION:
1025 case MASTER_PERMISSION:
1027 {
1028 bool isMasterLooter = lv.viewer->GetGroup() && lv.viewer->GetGroup()->GetMasterLooterGuid() == lv.viewer->GetGUID();
1029
1030 // if you are not the round-robin group looter, you can only see
1031 // blocked rolled items and quest items, and !ffa items
1032 for (uint8 i = 0; i < l.items.size(); ++i)
1033 {
1034 if (!l.items[i].is_looted && !l.items[i].freeforall && (l.items[i].conditions.empty() || isMasterLooter) && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1035 {
1036 uint8 slot_type = 0;
1037
1038 if (l.items[i].is_blocked) // for ML & restricted is_blocked = !is_underthreshold
1039 {
1040 switch (lv.permission)
1041 {
1042 case GROUP_PERMISSION:
1043 slot_type = LOOT_SLOT_TYPE_ROLL_ONGOING;
1044 break;
1045 case MASTER_PERMISSION:
1046 {
1047 if (lv.viewer->GetGroup())
1048 {
1049 if (lv.viewer->GetGroup()->GetMasterLooterGuid() == lv.viewer->GetGUID())
1050 slot_type = LOOT_SLOT_TYPE_MASTER;
1051 else
1052 slot_type = LOOT_SLOT_TYPE_LOCKED;
1053 }
1054 break;
1055 }
1057 slot_type = LOOT_SLOT_TYPE_LOCKED;
1058 break;
1059 default:
1060 continue;
1061 }
1062 }
1063 else if (l.items[i].rollWinnerGUID)
1064 {
1065 if (l.items[i].rollWinnerGUID == lv.viewer->GetGUID())
1066 slot_type = LOOT_SLOT_TYPE_OWNER;
1067 else
1068 continue;
1069 }
1070 else if (!l.roundRobinPlayer || lv.viewer->GetGUID() == l.roundRobinPlayer || !l.items[i].is_underthreshold)
1071 {
1072 // no round robin owner or he has released the loot
1073 // or it IS the round robin group owner
1074 // => item is lootable
1075 slot_type = LOOT_SLOT_TYPE_ALLOW_LOOT;
1076 }
1077 else
1078 // item shall not be displayed.
1079 continue;
1080
1081 b << uint8(i) << l.items[i];
1082 b << uint8(slot_type);
1083 ++itemsShown;
1084 }
1085 }
1086 break;
1087 }
1089 {
1090 for (uint8 i = 0; i < l.items.size(); ++i)
1091 {
1092 if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1093 {
1094 if (l.roundRobinPlayer && lv.viewer->GetGUID() != l.roundRobinPlayer)
1095 // item shall not be displayed.
1096 continue;
1097
1098 b << uint8(i) << l.items[i];
1100 ++itemsShown;
1101 }
1102 }
1103 break;
1104 }
1105 case ALL_PERMISSION:
1106 case OWNER_PERMISSION:
1107 {
1109 for (uint8 i = 0; i < l.items.size(); ++i)
1110 {
1111 if (!l.items[i].is_looted && !l.items[i].freeforall && l.items[i].conditions.empty() && l.items[i].AllowedForPlayer(lv.viewer, l.sourceWorldObjectGUID))
1112 {
1113 b << uint8(i) << l.items[i];
1114 b << uint8(slot_type);
1115 ++itemsShown;
1116 }
1117 }
1118 break;
1119 }
1120 default:
1121 return b;
1122 }
1123
1125
1126 // Xinef: items that do not follow loot rules need this
1127 LootSlotType partySlotType = lv.permission == MASTER_PERMISSION ? LOOT_SLOT_TYPE_MASTER : slotType;
1128
1129 QuestItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems();
1130 QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID());
1131 if (q_itr != lootPlayerQuestItems.end())
1132 {
1133 QuestItemList* q_list = q_itr->second;
1134 for (QuestItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
1135 {
1136 LootItem& item = l.quest_items[qi->index];
1137 if (!qi->is_looted && !item.is_looted)
1138 {
1139 bool showInLoot = true;
1140 bool hasQuestForItem = lv.viewer->HasQuestForItem(item.itemid, 0, false, &showInLoot);
1141 if (!hasQuestForItem)
1142 {
1143 if (!showInLoot)
1144 {
1145 const_cast<QuestItem*>(&(*qi))->is_looted = true;
1146 if (!item.freeforall)
1147 {
1148 item.is_looted = true;
1149 }
1150 continue;
1151 }
1152
1153 b << uint8(l.items.size() + (qi - q_list->begin()));
1154 b << item;
1156 }
1157 else
1158 {
1159 b << uint8(l.items.size() + (qi - q_list->begin()));
1160 b << item;
1161
1162 if (item.follow_loot_rules)
1163 {
1164 switch (lv.permission)
1165 {
1166 case MASTER_PERMISSION:
1168 break;
1170 b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
1171 break;
1172 case GROUP_PERMISSION:
1174 if (!item.is_blocked)
1176 else
1178 break;
1179 default:
1180 b << uint8(slotType);
1181 break;
1182 }
1183 }
1184 else if (!item.freeforall)
1185 b << uint8(partySlotType);
1186 else
1187 b << uint8(slotType);
1188 }
1189
1190 ++itemsShown;
1191 }
1192 }
1193 }
1194
1195 QuestItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems();
1196 QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID());
1197 if (ffa_itr != lootPlayerFFAItems.end())
1198 {
1199 QuestItemList* ffa_list = ffa_itr->second;
1200 for (QuestItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
1201 {
1202 LootItem& item = l.items[fi->index];
1203 if (!fi->is_looted && !item.is_looted)
1204 {
1205 b << uint8(fi->index);
1206 b << item;
1207 // Xinef: Here are FFA items, so dont use owner permision
1208 b << uint8(LOOT_SLOT_TYPE_ALLOW_LOOT /*slotType*/);
1209 ++itemsShown;
1210 }
1211 }
1212 }
1213
1214 QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems();
1215 QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID());
1216 if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
1217 {
1218 QuestItemList* conditional_list = nn_itr->second;
1219 for (QuestItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
1220 {
1221 LootItem& item = l.items[ci->index];
1222 if (!ci->is_looted && !item.is_looted)
1223 {
1224 b << uint8(ci->index);
1225 b << item;
1226 if (item.follow_loot_rules)
1227 {
1228 switch (lv.permission)
1229 {
1230 case MASTER_PERMISSION:
1232 break;
1234 b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
1235 break;
1236 case GROUP_PERMISSION:
1238 if (!item.is_blocked)
1240 else
1242 break;
1243 default:
1244 b << uint8(slotType);
1245 break;
1246 }
1247 }
1248 else if (!item.freeforall)
1249 b << uint8(partySlotType);
1250 else
1251 b << uint8(slotType);
1252 ++itemsShown;
1253 }
1254 }
1255 }
1256
1257 //update number of items shown
1258 b.put<uint8>(count_pos, itemsShown);
1259
1260 return b;
1261}
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

LootStore LootTemplates_Item("item_loot_template", "item entry", true) ( "item_loot_template"  ,
"item entry"  ,
true   
)

◆ 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

LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true) ( "skinning_loot_template"  ,
"creature skinning id"  ,
true   
)

◆ 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:394
@ RATE_DROP_ITEM_LEGENDARY
Definition WorldConfig.h:396
@ RATE_DROP_ITEM_POOR
Definition WorldConfig.h:391
@ RATE_DROP_ITEM_UNCOMMON
Definition WorldConfig.h:393
@ RATE_DROP_ITEM_EPIC
Definition WorldConfig.h:395
@ RATE_DROP_ITEM_ARTIFACT
Definition WorldConfig.h:397
@ RATE_DROP_ITEM_NORMAL
Definition WorldConfig.h:392
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};