Core/Conditions: Prevent unneccessary copying condition list on every check
This commit is contained in:
@@ -252,9 +252,9 @@ ConditionList ConditionMgr::GetConditionReferences(uint32 refId)
|
|||||||
return conditions;
|
return conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConditionMgr::IsPlayerMeetToConditionList(Player* player, const ConditionList& conditions, Unit* invoker)
|
bool ConditionMgr::IsPlayerMeetToConditionList(Player* player, ConditionList const& conditions, Unit* invoker /*= NULL*/)
|
||||||
{
|
{
|
||||||
std::map<uint32, bool>ElseGroupMap;
|
std::map<uint32, bool> ElseGroupMap;
|
||||||
for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
|
for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
|
||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditionList condType: %u val1: %u", (*i)->mConditionType, (*i)->mConditionValue1);
|
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditionList condType: %u val1: %u", (*i)->mConditionType, (*i)->mConditionValue1);
|
||||||
@@ -295,19 +295,19 @@ bool ConditionMgr::IsPlayerMeetToConditionList(Player* player, const ConditionLi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConditionMgr::IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* invoker)
|
bool ConditionMgr::IsPlayerMeetToConditions(Player* player, ConditionList const& conditions, Unit* invoker /*= NULL*/)
|
||||||
{
|
{
|
||||||
if (conditions.empty())
|
if (conditions.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(player)
|
if (player)
|
||||||
player->m_ConditionErrorMsgId = 0;
|
player->m_ConditionErrorMsgId = 0;
|
||||||
|
|
||||||
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditions");
|
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditions");
|
||||||
bool result = IsPlayerMeetToConditionList(player, conditions, invoker);
|
bool result = IsPlayerMeetToConditionList(player, conditions, invoker);
|
||||||
|
|
||||||
if (player && player->m_ConditionErrorMsgId && player->GetSession() && !result)
|
if (player && player->m_ConditionErrorMsgId && player->GetSession() && !result)
|
||||||
player->GetSession()->SendNotification(player->m_ConditionErrorMsgId);//m_ConditionErrorMsgId is set only if a condition was not met
|
player->GetSession()->SendNotification(player->m_ConditionErrorMsgId); //m_ConditionErrorMsgId is set only if a condition was not met
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class ConditionMgr
|
|||||||
bool isConditionTypeValid(Condition* cond);
|
bool isConditionTypeValid(Condition* cond);
|
||||||
ConditionList GetConditionReferences(uint32 refId);
|
ConditionList GetConditionReferences(uint32 refId);
|
||||||
|
|
||||||
bool IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* invoker = NULL);
|
bool IsPlayerMeetToConditions(Player* player, ConditionList const& conditions, Unit* invoker = NULL);
|
||||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
||||||
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ class ConditionMgr
|
|||||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
||||||
bool addToGossipMenus(Condition* cond);
|
bool addToGossipMenus(Condition* cond);
|
||||||
bool addToGossipMenuItems(Condition* cond);
|
bool addToGossipMenuItems(Condition* cond);
|
||||||
bool IsPlayerMeetToConditionList(Player* player, const ConditionList& conditions, Unit* invoker = NULL);
|
bool IsPlayerMeetToConditionList(Player* player, ConditionList const& conditions, Unit* invoker = NULL);
|
||||||
|
|
||||||
bool isGroupable(ConditionSourceType sourceType) const
|
bool isGroupable(ConditionSourceType sourceType) const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user