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

static Rates const qualityToRate [MAX_ITEM_QUALITY]
 
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 ( )
1962{
1963 LOG_INFO("server.loading", "Loading Creature Loot Templates...");
1964
1965 uint32 oldMSTime = getMSTime();
1966
1967 LootIdSet lootIdSet, lootIdSetUsed;
1969
1970 // Remove real entries and check loot existence
1971 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
1972 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
1973 {
1974 if (uint32 lootid = itr->second.lootid)
1975 {
1976 if (lootIdSet.find(lootid) == lootIdSet.end())
1977 LootTemplates_Creature.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
1978 else
1979 lootIdSetUsed.insert(lootid);
1980 }
1981 }
1982
1983 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
1984 lootIdSet.erase(*itr);
1985
1986 // output error for any still listed (not referenced from appropriate table) ids
1988
1989 if (count)
1990 LOG_INFO("server.loading", ">> Loaded {} Creature Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1991 else
1992 LOG_WARN("server.loading", ">> Loaded 0 creature loot templates. DB table `creature_loot_template` is empty");
1993
1994 LOG_INFO("server.loading", " ");
1995}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
std::uint32_t uint32
Definition: Define.h:107
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
std::set< uint32 > LootIdSet
Definition: LootMgr.h:204
#define sObjectMgr
Definition: ObjectMgr.h:1632
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: CreatureData.h:292
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 ( )
1998{
1999 LOG_INFO("server.loading", "Loading Disenchanting Loot Templates...");
2000
2001 uint32 oldMSTime = getMSTime();
2002
2003 LootIdSet lootIdSet, lootIdSetUsed;
2005
2006 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2007 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2008 {
2009 if (uint32 lootid = itr->second.DisenchantID)
2010 {
2011 if (lootIdSet.find(lootid) == lootIdSet.end())
2013 else
2014 lootIdSetUsed.insert(lootid);
2015 }
2016 }
2017
2018 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2019 lootIdSet.erase(*itr);
2020
2021 // output error for any still listed (not referenced from appropriate table) ids
2023
2024 if (count)
2025 LOG_INFO("server.loading", ">> Loaded {} disenchanting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2026 else
2027 LOG_WARN("server.loading", ">> Loaded 0 disenchanting loot templates. DB table `disenchant_loot_template` is empty");
2028 LOG_INFO("server.loading", " ");
2029}
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
std::unordered_map< uint32, ItemTemplate > ItemTemplateContainer
Definition: ItemTemplate.h:835

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 ( )
2032{
2033 LOG_INFO("server.loading", "Loading Fishing Loot Templates...");
2034
2035 uint32 oldMSTime = getMSTime();
2036
2037 LootIdSet lootIdSet;
2039
2040 // remove real entries and check existence loot
2041 for (uint32 i = 1; i < sAreaTableStore.GetNumRows(); ++i)
2042 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i))
2043 if (lootIdSet.find(areaEntry->ID) != lootIdSet.end())
2044 lootIdSet.erase(areaEntry->ID);
2045
2046 // output error for any still listed (not referenced from appropriate table) ids
2048
2049 if (count)
2050 LOG_INFO("server.loading", ">> Loaded {} Fishing Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2051 else
2052 LOG_WARN("server.loading", ">> Loaded 0 fishing loot templates. DB table `fishing_loot_template` is empty");
2053
2054 LOG_INFO("server.loading", " ");
2055}
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true)
Definition: DBCStructure.h:518

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 ( )
2058{
2059 LOG_INFO("server.loading", "Loading Gameobject Loot Templates...");
2060
2061 uint32 oldMSTime = getMSTime();
2062
2063 LootIdSet lootIdSet, lootIdSetUsed;
2065
2066 // remove real entries and check existence loot
2067 GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
2068 for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
2069 {
2070 if (uint32 lootid = itr->second.GetLootId())
2071 {
2072 if (lootIdSet.find(lootid) == lootIdSet.end())
2073 LootTemplates_Gameobject.ReportNonExistingId(lootid, "Gameobject", itr->second.entry);
2074 else
2075 lootIdSetUsed.insert(lootid);
2076 }
2077 }
2078
2079 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2080 lootIdSet.erase(*itr);
2081
2082 // output error for any still listed (not referenced from appropriate table) ids
2084
2085 if (count)
2086 LOG_INFO("server.loading", ">> Loaded {} Gameobject Loot Templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2087 else
2088 LOG_WARN("server.loading", ">> Loaded 0 gameobject loot templates. DB table `gameobject_loot_template` is empty");
2089
2090 LOG_INFO("server.loading", " ");
2091}
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
std::unordered_map< uint32, GameObjectTemplate > GameObjectTemplateContainer
Definition: GameObject.h:43

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 ( )
2094{
2095 LOG_INFO("server.loading", "Loading Item Loot Templates...");
2096
2097 uint32 oldMSTime = getMSTime();
2098
2099 LootIdSet lootIdSet;
2101
2102 // remove real entries and check existence loot
2103 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2104 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2105 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.HasFlag(ITEM_FLAG_HAS_LOOT))
2106 lootIdSet.erase(itr->second.ItemId);
2107
2108 // output error for any still listed (not referenced from appropriate table) ids
2110
2111 if (count)
2112 LOG_INFO("server.loading", ">> Loaded {} item loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2113 else
2114 LOG_WARN("server.loading", ">> Loaded 0 item loot templates. DB table `item_loot_template` is empty");
2115
2116 LOG_INFO("server.loading", " ");
2117}
LootStore LootTemplates_Item("item_loot_template", "item entry", true)
@ ITEM_FLAG_HAS_LOOT
Definition: ItemTemplate.h:149

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 ( )
2218{
2219 LOG_INFO("server.loading", "Loading Mail Loot Templates...");
2220
2221 uint32 oldMSTime = getMSTime();
2222
2223 LootIdSet lootIdSet;
2225
2226 // remove real entries and check existence loot
2227 for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
2228 if (sMailTemplateStore.LookupEntry(i))
2229 if (lootIdSet.find(i) != lootIdSet.end())
2230 lootIdSet.erase(i);
2231
2232 // output error for any still listed (not referenced from appropriate table) ids
2234
2235 if (count)
2236 LOG_INFO("server.loading", ">> Loaded {} mail loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2237 else
2238 LOG_WARN("server.loading", ">> Loaded 0 mail loot templates. DB table `mail_loot_template` is empty");
2239
2240 LOG_INFO("server.loading", " ");
2241}
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 ( )
2120{
2121 LOG_INFO("server.loading", "Loading Milling Loot Templates...");
2122
2123 uint32 oldMSTime = getMSTime();
2124
2125 LootIdSet lootIdSet;
2127
2128 // remove real entries and check existence loot
2129 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2130 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2131 {
2132 if (!itr->second.HasFlag(ITEM_FLAG_IS_MILLABLE))
2133 continue;
2134
2135 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2136 lootIdSet.erase(itr->second.ItemId);
2137 }
2138
2139 // output error for any still listed (not referenced from appropriate table) ids
2141
2142 if (count)
2143 LOG_INFO("server.loading", ">> Loaded {} milling loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2144 else
2145 LOG_WARN("server.loading", ">> Loaded 0 milling loot templates. DB table `milling_loot_template` is empty");
2146
2147 LOG_INFO("server.loading", " ");
2148}
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true)
@ ITEM_FLAG_IS_MILLABLE
Definition: ItemTemplate.h:176

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 ( )
2151{
2152 LOG_INFO("server.loading", "Loading Pickpocketing Loot Templates...");
2153
2154 uint32 oldMSTime = getMSTime();
2155
2156 LootIdSet lootIdSet, lootIdSetUsed;
2158
2159 // Remove real entries and check loot existence
2160 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2161 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2162 {
2163 if (uint32 lootid = itr->second.pickpocketLootId)
2164 {
2165 if (lootIdSet.find(lootid) == lootIdSet.end())
2166 LootTemplates_Pickpocketing.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2167 else
2168 lootIdSetUsed.insert(lootid);
2169 }
2170 }
2171
2172 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2173 lootIdSet.erase(*itr);
2174
2175 // output error for any still listed (not referenced from appropriate table) ids
2177
2178 if (count)
2179 LOG_INFO("server.loading", ">> Loaded {} pickpocketing loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2180 else
2181 LOG_WARN("server.loading", ">> Loaded 0 pickpocketing loot templates. DB table `pickpocketing_loot_template` is empty");
2182
2183 LOG_INFO("server.loading", " ");
2184}
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 ( )
2323{
2324 LOG_INFO("server.loading", "Loading Player Loot Templates...");
2325
2326 uint32 oldMSTime = getMSTime();
2327
2328 LootIdSet lootIdSet;
2330
2331 if (count)
2332 {
2333 LOG_INFO("server.loading", ">> Loaded {} player loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2334 }
2335 else
2336 {
2337 LOG_WARN("server.loading", ">> Loaded 0 player loot templates. DB table `player_loot_template` is empty");
2338 }
2339
2340 LOG_INFO("server.loading", " ");
2341}
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 ( )
2187{
2188 LOG_INFO("server.loading", "Loading Prospecting Loot Templates...");
2189
2190 uint32 oldMSTime = getMSTime();
2191
2192 LootIdSet lootIdSet;
2194
2195 // remove real entries and check existence loot
2196 ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
2197 for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
2198 {
2199 if (!itr->second.HasFlag(ITEM_FLAG_IS_PROSPECTABLE))
2200 continue;
2201
2202 if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
2203 lootIdSet.erase(itr->second.ItemId);
2204 }
2205
2206 // output error for any still listed (not referenced from appropriate table) ids
2208
2209 if (count)
2210 LOG_INFO("server.loading", ">> Loaded {} prospecting loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2211 else
2212 LOG_WARN("server.loading", ">> Loaded 0 prospecting loot templates. DB table `prospecting_loot_template` is empty");
2213
2214 LOG_INFO("server.loading", " ");
2215}
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true)
@ ITEM_FLAG_IS_PROSPECTABLE
Definition: ItemTemplate.h:165

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 ( )
2344{
2345 LOG_INFO("server.loading", "Loading Reference Loot Templates...");
2346
2347 uint32 oldMSTime = getMSTime();
2348
2349 LootIdSet lootIdSet;
2351
2352 // check references and remove used
2364
2365 // output error for any still listed ids (not referenced from any loot table)
2367
2368 LOG_INFO("server.loading", ">> Loaded reference loot templates in {} ms", GetMSTimeDiffToNow(oldMSTime));
2369 LOG_INFO("server.loading", " ");
2370}
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 ( )
2244{
2245 LOG_INFO("server.loading", "Loading Skinning Loot Templates...");
2246
2247 uint32 oldMSTime = getMSTime();
2248
2249 LootIdSet lootIdSet, lootIdSetUsed;
2251
2252 // remove real entries and check existence loot
2253 CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
2254 for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
2255 {
2256 if (uint32 lootid = itr->second.SkinLootId)
2257 {
2258 if (lootIdSet.find(lootid) == lootIdSet.end())
2259 LootTemplates_Skinning.ReportNonExistingId(lootid, "Creature", itr->second.Entry);
2260 else
2261 lootIdSetUsed.insert(lootid);
2262 }
2263 }
2264
2265 for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr)
2266 lootIdSet.erase(*itr);
2267
2268 // output error for any still listed (not referenced from appropriate table) ids
2270
2271 if (count)
2272 LOG_INFO("server.loading", ">> Loaded {} skinning loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2273 else
2274 LOG_WARN("server.loading", ">> Loaded 0 skinning loot templates. DB table `skinning_loot_template` is empty");
2275
2276 LOG_INFO("server.loading", " ");
2277}

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 ( )
2280{
2281 LOG_INFO("server.loading", "Loading Spell Loot Templates...");
2282
2283 uint32 oldMSTime = getMSTime();
2284
2285 LootIdSet lootIdSet;
2287
2288 // remove real entries and check existence loot
2289 for (uint32 spell_id = 1; spell_id < sSpellMgr->GetSpellInfoStoreSize(); ++spell_id)
2290 {
2291 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
2292 if (!spellInfo)
2293 continue;
2294
2295 // possible cases
2296 if (!spellInfo->IsLootCrafting())
2297 continue;
2298
2299 if (lootIdSet.find(spell_id) == lootIdSet.end())
2300 {
2301 // not report about not trainable spells (optionally supported by DB)
2302 // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example
2304 {
2305 LootTemplates_Spell.ReportNonExistingId(spell_id, "Spell", spellInfo->Id);
2306 }
2307 }
2308 else
2309 lootIdSet.erase(spell_id);
2310 }
2311
2312 // output error for any still listed (not referenced from appropriate table) ids
2314
2315 if (count)
2316 LOG_INFO("server.loading", ">> Loaded {} spell loot templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
2317 else
2318 LOG_WARN("server.loading", ">> Loaded 0 spell loot templates. DB table `spell_loot_template` is empty");
2319 LOG_INFO("server.loading", " ");
2320}
#define sSpellMgr
Definition: SpellMgr.h:825
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
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 
)
988{
989 b << uint32(li.itemid);
990 b << uint32(li.count); // nr of items of this type
991 b << uint32(sObjectMgr->GetItemTemplate(li.itemid)->DisplayInfoID);
992 b << uint32(li.randomSuffix);
993 b << uint32(li.randomPropertyId);
994 //b << uint8(0); // slot type - will send after this function call
995 return b;
996}

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

◆ operator<<() [2/2]

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

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

Rates const qualityToRate[MAX_ITEM_QUALITY]
static
Initial value:
=
{
}
@ RATE_DROP_ITEM_RARE
Definition: IWorld.h:440
@ RATE_DROP_ITEM_LEGENDARY
Definition: IWorld.h:442
@ RATE_DROP_ITEM_POOR
Definition: IWorld.h:437
@ RATE_DROP_ITEM_UNCOMMON
Definition: IWorld.h:439
@ RATE_DROP_ITEM_EPIC
Definition: IWorld.h:441
@ RATE_DROP_ITEM_ARTIFACT
Definition: IWorld.h:443
@ RATE_DROP_ITEM_NORMAL
Definition: IWorld.h:438