Fixed a bug where turning in a quest involving multiple rewards would sometimes not reward the items due to a faulty bag space check. Fixes #3.
This commit is contained in:
parent
087d00960c
commit
168ffc3dbb
@ -12318,42 +12318,52 @@ bool Player::CanRewardQuest(Quest const* pQuest, bool msg) const
|
|||||||
|
|
||||||
bool Player::CanRewardQuest(Quest const* pQuest, uint32 reward, bool msg) const
|
bool Player::CanRewardQuest(Quest const* pQuest, uint32 reward, bool msg) const
|
||||||
{
|
{
|
||||||
// prevent receive reward with quest items in bank or for not completed quest
|
bool result;
|
||||||
if (!CanRewardQuest(pQuest, msg))
|
uint32 numOptionalRewards;
|
||||||
{ return false; }
|
uint32 numRewards;
|
||||||
|
uint32 requiredSlots;
|
||||||
|
InventoryResult iRes;
|
||||||
|
|
||||||
if (pQuest->GetRewChoiceItemsCount() > 0)
|
requiredSlots = 0;
|
||||||
{
|
result = CanRewardQuest(pQuest, msg);
|
||||||
if (pQuest->RewChoiceItemId[reward])
|
if (result)
|
||||||
{
|
{
|
||||||
ItemPosCountVec dest;
|
ItemPosCountVec destActual;
|
||||||
InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward]);
|
numOptionalRewards = pQuest->GetRewChoiceItemsCount();
|
||||||
if (res != EQUIP_ERR_OK)
|
numRewards = pQuest->GetRewItemsCount();
|
||||||
{
|
// Only ONE optional reward can be selected
|
||||||
SendEquipError(res, NULL, NULL, pQuest->RewChoiceItemId[reward]);
|
requiredSlots = numRewards + 1;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pQuest->GetRewItemsCount() > 0)
|
if (numRewards > 0 || numOptionalRewards > 0)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i)
|
if (pQuest->RewChoiceItemId[reward])
|
||||||
{
|
{
|
||||||
if (pQuest->RewItemId[i])
|
ItemPosCountVec dest;
|
||||||
{
|
iRes = CanStoreNewItem(0, 0, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward]);
|
||||||
ItemPosCountVec dest;
|
if (iRes != EQUIP_ERR_OK)
|
||||||
InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i]);
|
goto CANT_EQUIP;
|
||||||
if (res != EQUIP_ERR_OK)
|
}
|
||||||
{
|
for (uint32 i = 0; i < numRewards; ++i)
|
||||||
SendEquipError(res, NULL, NULL);
|
{
|
||||||
return false;
|
if (pQuest->RewItemId[i])
|
||||||
}
|
{
|
||||||
}
|
ItemPosCountVec dest;
|
||||||
}
|
iRes = CanStoreNewItem(0, 0, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i]);
|
||||||
}
|
if (iRes != EQUIP_ERR_OK)
|
||||||
|
goto CANT_EQUIP;
|
||||||
return true;
|
}
|
||||||
|
}
|
||||||
|
// We use 2586 (Gamemaster's Robes) as the item ID so that we can verify that the slots can be filled for all selected quest rewards
|
||||||
|
iRes = CanStoreNewItem(0, 0, destActual, 2586, requiredSlots);
|
||||||
|
CANT_EQUIP:
|
||||||
|
if (iRes != EQUIP_ERR_OK)
|
||||||
|
{
|
||||||
|
SendEquipError(iRes, 0, 0);
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendPetTameFailure(PetTameFailureReason reason)
|
void Player::SendPetTameFailure(PetTameFailureReason reason)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user