Core/Events: Fixed items removing from World Events. The items will be removed on first player's login after the end of the event. Also prevents using those items between the end and login of the player

This commit is contained in:
Lopin
2011-08-17 18:47:34 +02:00
parent 1c606d0d0c
commit 9e9a84cf0e
+32 -10
View File
@@ -11793,34 +11793,42 @@ InventoryResult Player::CanUseItem(Item *pItem, bool not_loading) const
return EQUIP_ERR_ITEM_NOT_FOUND;
}
InventoryResult Player::CanUseItem(ItemTemplate const *pProto) const
InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
{
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
if (pProto)
if (proto)
{
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeam() != HORDE)
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeam() != HORDE)
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
if (pProto->RequiredSkill != 0)
if (proto->RequiredSkill != 0)
{
if (GetSkillValue(pProto->RequiredSkill) == 0)
if (GetSkillValue(proto->RequiredSkill) == 0)
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
else if (GetSkillValue(pProto->RequiredSkill) < pProto->RequiredSkillRank)
else if (GetSkillValue(proto->RequiredSkill) < proto->RequiredSkillRank)
return EQUIP_ERR_CANT_EQUIP_SKILL;
}
if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell))
if (proto->RequiredSpell != 0 && !HasSpell(proto->RequiredSpell))
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
if (getLevel() < pProto->RequiredLevel)
if (getLevel() < proto->RequiredLevel)
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
// If World Event is not active, prevent using event dependant items
if (proto->HolidayId && !IsHolidayActive((HolidayIds)proto->HolidayId))
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
return EQUIP_ERR_OK;
}
return EQUIP_ERR_ITEM_NOT_FOUND;
}
@@ -17408,6 +17416,20 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
}
}
else if (proto->HolidayId)
{
remove = true;
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
{
if (events[*itr].holiday_id == proto->HolidayId)
{
remove = false;
break;
}
}
}
}
else
{