diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index c200eddb257..8067341b43b 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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 { |
