Improved OnCriteriaCheck hook, passing information about criteria_id
OnCheck without criteria_id is deprecated but still available
This commit is contained in:
@@ -358,7 +358,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
|
|||||||
return false;
|
return false;
|
||||||
return target->getGender() == gender.gender;
|
return target->getGender() == gender.gender;
|
||||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT:
|
case ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT:
|
||||||
return sScriptMgr->OnCriteriaCheck(ScriptId, const_cast<Player*>(source), const_cast<Unit*>(target));
|
return sScriptMgr->OnCriteriaCheck(ScriptId, const_cast<Player*>(source), const_cast<Unit*>(target), criteria_id);
|
||||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY:
|
case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY:
|
||||||
if (source->GetMap()->IsRaid())
|
if (source->GetMap()->IsRaid())
|
||||||
if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0))
|
if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0))
|
||||||
|
|||||||
@@ -1148,13 +1148,13 @@ void ScriptMgr::OnShutdown()
|
|||||||
FOREACH_SCRIPT(WorldScript)->OnShutdown();
|
FOREACH_SCRIPT(WorldScript)->OnShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target)
|
bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target, uint32 criteria_id)
|
||||||
{
|
{
|
||||||
ASSERT(source);
|
ASSERT(source);
|
||||||
// target can be NULL.
|
// target can be NULL.
|
||||||
|
|
||||||
GET_SCRIPT_RET(AchievementCriteriaScript, scriptId, tmpscript, false);
|
GET_SCRIPT_RET(AchievementCriteriaScript, scriptId, tmpscript, false);
|
||||||
return tmpscript->OnCheck(source, target);
|
return tmpscript->OnCheck(source, target, criteria_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
|
|||||||
@@ -747,7 +747,11 @@ class AchievementCriteriaScript : public ScriptObject
|
|||||||
bool IsDatabaseBound() const { return true; }
|
bool IsDatabaseBound() const { return true; }
|
||||||
|
|
||||||
// Called when an additional criteria is checked.
|
// Called when an additional criteria is checked.
|
||||||
virtual bool OnCheck(Player* source, Unit* target) = 0;
|
virtual bool OnCheck(Player* source, Unit* target, uint32 /*criteria_id*/) {
|
||||||
|
return OnCheck(source, target);
|
||||||
|
}
|
||||||
|
// deprecated/legacy
|
||||||
|
virtual bool OnCheck(Player* /*source*/, Unit* /*target*/) { return true; };
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerScript : public ScriptObject
|
class PlayerScript : public ScriptObject
|
||||||
@@ -1176,7 +1180,7 @@ class ScriptMgr
|
|||||||
|
|
||||||
public: /* AchievementCriteriaScript */
|
public: /* AchievementCriteriaScript */
|
||||||
|
|
||||||
bool OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target);
|
bool OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target, uint32 criteria_id);
|
||||||
|
|
||||||
public: /* PlayerScript */
|
public: /* PlayerScript */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user