mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
Rebase resync
This commit is contained in:
parent
a0797532e8
commit
1997c1e903
3106 changed files with 11118 additions and 627576 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -127,19 +127,19 @@ void LootStore::LoadLootTable()
|
|||
continue; // error already printed to log/console.
|
||||
}
|
||||
|
||||
if (mincountOrRef < 0 && conditionId)
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' entry %u mincountOrRef %i < 0 and not allowed has condition, skipped", GetName(), entry, mincountOrRef);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (conditionId)
|
||||
{
|
||||
const PlayerCondition* condition = sConditionStorage.LookupEntry<PlayerCondition>(conditionId);
|
||||
if (!condition)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` for entry %u, item %u has condition_id %u that does not exist in `conditions`, ignoring", GetName(), entry, item, conditionId);
|
||||
conditionId = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mincountOrRef < 0 && !PlayerCondition::CanBeUsedWithoutPlayer(conditionId))
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' entry %u mincountOrRef %i < 0 and has condition %u that requires a player and is not supported, skipped", GetName(), entry, mincountOrRef, conditionId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +166,6 @@ void LootStore::LoadLootTable()
|
|||
// Adds current row to the template
|
||||
tab->second->AddEntry(storeitem);
|
||||
++count;
|
||||
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
|
|
@ -410,10 +409,10 @@ LootItem::LootItem(uint32 itemid_, uint8 type_, uint32 count_, uint32 randomSuff
|
|||
}
|
||||
|
||||
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
|
||||
bool LootItem::AllowedForPlayer(Player const* player) const
|
||||
bool LootItem::AllowedForPlayer(Player const* player, WorldObject const* lootTarget) const
|
||||
{
|
||||
// DB conditions check
|
||||
if (conditionId && !sObjectMgr.IsPlayerMeetToNEWCondition(player, conditionId))
|
||||
if (conditionId && !sObjectMgr.IsPlayerMeetToCondition(conditionId, player, player->GetMap(), lootTarget, CONDITION_FROM_LOOT))
|
||||
return false;
|
||||
|
||||
if (type == LOOT_ITEM_TYPE_ITEM)
|
||||
|
|
@ -450,7 +449,7 @@ bool LootItem::AllowedForPlayer(Player const* player) const
|
|||
|
||||
if (!player->isGameMaster())
|
||||
{
|
||||
if (currency->ID == CURRENCY_CONQUEST_ARENA_META || currency->ID == CURRENCY_CONQUEST_BG_META)
|
||||
if (currency->Category == CURRENCY_CATEGORY_META)
|
||||
return false;
|
||||
|
||||
if (currency->Category == CURRENCY_CATEGORY_ARCHAEOLOGY && !player->HasSkill(SKILL_ARCHAEOLOGY))
|
||||
|
|
@ -461,10 +460,10 @@ bool LootItem::AllowedForPlayer(Player const* player) const
|
|||
return true;
|
||||
}
|
||||
|
||||
LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Player* viewer, bool condition_ok /*= false*/) const
|
||||
LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Player* viewer, WorldObject const* lootTarget, bool condition_ok /*= false*/) const
|
||||
{
|
||||
// ignore currencies, looted items, FFA (each player get own copy) and not allowed items
|
||||
if (currency || is_looted || freeforall || (conditionId && !condition_ok) || !AllowedForPlayer(viewer))
|
||||
if (currency || is_looted || freeforall || (conditionId && !condition_ok) || !AllowedForPlayer(viewer, lootTarget))
|
||||
return MAX_LOOT_SLOT_TYPE;
|
||||
|
||||
switch (permission)
|
||||
|
|
@ -575,7 +574,7 @@ QuestItemList* Loot::FillCurrencyLoot(Player* player)
|
|||
for (uint8 i = 0; i < items.size(); ++i)
|
||||
{
|
||||
LootItem& item = items[i];
|
||||
if (!item.is_looted && item.currency && item.AllowedForPlayer(player))
|
||||
if (!item.is_looted && item.currency && item.AllowedForPlayer(player, m_lootTarget))
|
||||
{
|
||||
ql->push_back(QuestItem(i));
|
||||
++unlootedCount;
|
||||
|
|
@ -598,7 +597,7 @@ QuestItemList* Loot::FillFFALoot(Player* player)
|
|||
for (uint8 i = 0; i < items.size(); ++i)
|
||||
{
|
||||
LootItem& item = items[i];
|
||||
if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player))
|
||||
if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player, m_lootTarget))
|
||||
{
|
||||
ql->push_back(QuestItem(i));
|
||||
++unlootedCount;
|
||||
|
|
@ -622,7 +621,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
|
|||
for (uint8 i = 0; i < m_questItems.size(); ++i)
|
||||
{
|
||||
LootItem& item = m_questItems[i];
|
||||
if (!item.is_looted && item.AllowedForPlayer(player))
|
||||
if (!item.is_looted && item.AllowedForPlayer(player, m_lootTarget))
|
||||
{
|
||||
ql->push_back(QuestItem(i));
|
||||
|
||||
|
|
@ -656,7 +655,7 @@ QuestItemList* Loot::FillNonQuestNonFFANonCurrencyConditionalLoot(Player* player
|
|||
for (uint8 i = 0; i < items.size(); ++i)
|
||||
{
|
||||
LootItem& item = items[i];
|
||||
if (!item.is_looted && !item.freeforall && !item.currency && item.conditionId && item.AllowedForPlayer(player))
|
||||
if (!item.is_looted && !item.freeforall && !item.currency && item.conditionId && item.AllowedForPlayer(player, m_lootTarget))
|
||||
{
|
||||
ql->push_back(QuestItem(i));
|
||||
if (!item.is_counted)
|
||||
|
|
@ -877,7 +876,8 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
|
|||
uint8 itemsShown = 0;
|
||||
uint8 currenciesShown = 0;
|
||||
|
||||
b << uint32(l.gold); // gold
|
||||
// gold
|
||||
b << uint32(l.gold);
|
||||
|
||||
size_t count_pos = b.wpos(); // pos of item count byte
|
||||
b << uint8(0); // item count placeholder
|
||||
|
|
@ -886,7 +886,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
|
|||
|
||||
for (uint8 i = 0; i < l.items.size(); ++i)
|
||||
{
|
||||
LootSlotType slot_type = l.items[i].GetSlotTypeForSharedLoot(lv.permission, lv.viewer);
|
||||
LootSlotType slot_type = l.items[i].GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget());
|
||||
if (slot_type >= MAX_LOOT_SLOT_TYPE)
|
||||
continue;
|
||||
|
||||
|
|
@ -904,7 +904,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
|
|||
{
|
||||
LootItem& item = l.items[ci->index];
|
||||
|
||||
LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, !ci->is_looted);
|
||||
LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget(), !ci->is_looted);
|
||||
if (slot_type >= MAX_LOOT_SLOT_TYPE)
|
||||
continue;
|
||||
|
||||
|
|
@ -1147,6 +1147,10 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
|
|||
if (!Referenced)
|
||||
continue; // Error message already printed at loading stage
|
||||
|
||||
// Check condition
|
||||
if (i->conditionId && !sObjectMgr.IsPlayerMeetToCondition(i->conditionId, NULL, NULL, loot.GetLootTarget(), CONDITION_FROM_REFERING_LOOT))
|
||||
continue;
|
||||
|
||||
for (uint32 loop = 0; loop < i->maxcount; ++loop) // Ref multiplicator
|
||||
Referenced->Process(loot, store, rate, i->group);
|
||||
}
|
||||
|
|
@ -1257,7 +1261,7 @@ void LoadLootTemplates_Creature()
|
|||
LootTemplates_Creature.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sCreatureStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
|
||||
{
|
||||
|
|
@ -1287,7 +1291,7 @@ void LoadLootTemplates_Disenchant()
|
|||
LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
|
||||
{
|
||||
|
|
@ -1332,17 +1336,14 @@ void LoadLootTemplates_Gameobject()
|
|||
LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
|
||||
for (SQLStorageBase::SQLSIterator<GameObjectInfo> itr = sGOStorage.getDataBegin<GameObjectInfo>(); itr < sGOStorage.getDataEnd<GameObjectInfo>(); ++itr)
|
||||
{
|
||||
if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
|
||||
if (uint32 lootid = itr->GetLootId())
|
||||
{
|
||||
if (uint32 lootid = gInfo->GetLootId())
|
||||
{
|
||||
if (ids_set.find(lootid) == ids_set.end())
|
||||
LootTemplates_Gameobject.ReportNotExistedId(lootid);
|
||||
else
|
||||
ids_setUsed.insert(lootid);
|
||||
}
|
||||
if (ids_set.find(lootid) == ids_set.end())
|
||||
LootTemplates_Gameobject.ReportNotExistedId(lootid);
|
||||
else
|
||||
ids_setUsed.insert(lootid);
|
||||
}
|
||||
}
|
||||
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
|
||||
|
|
@ -1358,7 +1359,7 @@ void LoadLootTemplates_Item()
|
|||
LootTemplates_Item.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
|
||||
{
|
||||
|
|
@ -1383,7 +1384,7 @@ void LoadLootTemplates_Milling()
|
|||
LootTemplates_Milling.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i);
|
||||
if (!proto)
|
||||
|
|
@ -1408,7 +1409,7 @@ void LoadLootTemplates_Pickpocketing()
|
|||
LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sCreatureStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
|
||||
{
|
||||
|
|
@ -1434,7 +1435,7 @@ void LoadLootTemplates_Prospecting()
|
|||
LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i);
|
||||
if (!proto)
|
||||
|
|
@ -1474,7 +1475,7 @@ void LoadLootTemplates_Skinning()
|
|||
LootTemplates_Skinning.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
|
||||
for (uint32 i = 1; i < sCreatureStorage.GetMaxEntry(); ++i)
|
||||
{
|
||||
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue