Core/SAI: Code improvements to SMART_ACTION_RANDOM_SOUND

Warning fixes and extra sanity checks

Ref #16376

(cherry picked from commit 77087db793)
This commit is contained in:
DDuarte
2016-01-26 03:37:07 +00:00
committed by Shauren
parent c457de1e80
commit 252220ed6e
3 changed files with 32 additions and 29 deletions

View File

@@ -841,12 +841,20 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return false;
break;
case SMART_ACTION_RANDOM_SOUND:
for (uint8 i = 0; i < SMART_ACTION_PARAM_COUNT - 1; i++)
{
if (std::all_of(e.action.randomSound.sounds.begin(), e.action.randomSound.sounds.end(), [](uint32 sound) { return sound == 0; }))
{
if (e.action.randomSound.sound[i] && !IsSoundValid(e, e.action.randomSound.sound[i]))
return false;
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u does not have any non-zero sound",
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
return false;
}
for (uint32 sound : e.action.randomSound.sounds)
if (sound && !IsSoundValid(e, sound))
return false;
break;
}
case SMART_ACTION_CAST:
{
if (!IsSpellValid(e, e.action.cast.spell))