From 40cde0ff369262a54691e1660882d0c4f99eb8d8 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 6 Nov 2009 02:34:49 +0300 Subject: [PATCH] [8779] Not output error at empty item loot for mail template at mail creating. --- src/game/Creature.cpp | 14 +++++++------- src/game/GameObject.cpp | 6 ++---- src/game/LootMgr.cpp | 11 +++++++---- src/game/LootMgr.h | 2 +- src/game/Mail.cpp | 3 ++- src/shared/revision_nr.h | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 48215ef84..7ef4f89ae 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1526,29 +1526,29 @@ float Creature::GetAttackDistance(Unit const* pl) const void Creature::setDeathState(DeathState s) { - if((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault)) + if ((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault)) { m_deathTimer = m_corpseDelay*IN_MILISECONDS; // always save boss respawn time at death to prevent crash cheating - if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) + if (sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) SaveRespawnTime(); if (canFly() && FallGround()) return; - if(!IsStopped()) + if (!IsStopped()) StopMoving(); } Unit::setDeathState(s); - if(s == JUST_DIED) + if (s == JUST_DIED) { SetTargetGUID(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); - if(!isPet() && GetCreatureInfo()->SkinLootId) - if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) ) + if (!isPet() && GetCreatureInfo()->SkinLootId) + if (LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId)) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); if (canFly() && FallGround()) @@ -1557,7 +1557,7 @@ void Creature::setDeathState(DeathState s) SetNoSearchAssistance(false); Unit::setDeathState(CORPSE); } - if(s == JUST_ALIVED) + if (s == JUST_ALIVED) { SetHealth(GetMaxHealth()); SetLootRecipient(NULL); diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 78d9f3dbe..b5fe2cf0a 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -488,10 +488,8 @@ void GameObject::getFishLoot(Loot *fishloot, Player* loot_owner) GetZoneAndAreaId(zone,subzone); // if subzone loot exist use it - if(LootTemplates_Fishing.HaveLootFor(subzone)) - fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner,true); - // else use zone loot - else + if (!fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true)) + // else use zone loot (must exist in like case) fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner,true); } diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 203bc24df..504b55112 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -386,18 +386,19 @@ void Loot::AddItem(LootStoreItem const & item) } // Calls processor of corresponding LootTemplate (which handles everything including references) -void Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal) +bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError) { // Must be provided if(!loot_owner) - return; + return false; LootTemplate const* tab = store.GetLootFor(loot_id); if (!tab) { - sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.",store.GetName(),loot_id); - return; + if (!noEmptyError) + sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.",store.GetName(),loot_id); + return false; } items.reserve(MAX_NR_LOOT_ITEMS); @@ -416,6 +417,8 @@ void Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, // ... for personal loot else FillNotNormalLootFor(loot_owner); + + return true; } void Loot::FillNotNormalLootFor(Player* pl) diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 88c7280b5..9263e323b 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -284,7 +284,7 @@ struct Loot void RemoveLooter(uint64 GUID) { PlayersLooting.erase(GUID); } void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); - void FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal); + bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false); // Inserts the item into the loot (called by LootTemplate processors) void AddItem(LootStoreItem const & item); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index c2bd28d4a..67aabcd06 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -837,7 +837,8 @@ void MailDraft::prepareItems(Player* receiver) Loot mailLoot; - mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver,true); + // can be empty + mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver, true, true); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); for(uint32 i = 0; m_items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c3180d79d..da5c412c2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8778" + #define REVISION_NR "8779" #endif // __REVISION_NR_H__ -- 2.11.4.GIT