[11077] Game event fixes and condition improvments.

* At game events table loading checked not only allowed event ids range but also event existance.
* Renamed CONDITION_ACTIVE_EVENT -> CONDITION_ACTIVE_GAME_EVENT
* Implemented new conditions:
   - CONDITION_NOT_ACTIVE_GAME_EVENT
   - CONDITION_ACTIVE_HOLIDAY
   - CONDITION_NOT_ACTIVE_HOLIDAY

Recomended use holiday version where possible as more portable.
This commit is contained in:
VladimirMangos 2011-01-28 23:29:04 +03:00
parent 84dd2e4393
commit 2fd536fe43
9 changed files with 90 additions and 62 deletions

View file

@ -7562,7 +7562,7 @@ bool PlayerCondition::Meets(Player const * player) const
}
case CONDITION_NO_AURA:
return !player->HasAura(value1, SpellEffectIndex(value2));
case CONDITION_ACTIVE_EVENT:
case CONDITION_ACTIVE_GAME_EVENT:
return sGameEventMgr.IsActiveEvent(value1);
case CONDITION_AREA_FLAG:
{
@ -7643,6 +7643,12 @@ bool PlayerCondition::Meets(Player const * player) const
return player->HasItemCount(value1, value2, true);
case CONDITION_NOITEM_WITH_BANK:
return !player->HasItemCount(value1, value2, true);
case CONDITION_NOT_ACTIVE_GAME_EVENT:
return !sGameEventMgr.IsActiveEvent(value1);
case CONDITION_ACTIVE_HOLIDAY:
return sGameEventMgr.IsActiveHoliday(HolidayIds(value1));
case CONDITION_NOT_ACTIVE_HOLIDAY:
return !sGameEventMgr.IsActiveHoliday(HolidayIds(value1));
default:
return false;
}
@ -7791,10 +7797,10 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
}
break;
}
case CONDITION_ACTIVE_EVENT:
case CONDITION_ACTIVE_GAME_EVENT:
case CONDITION_NOT_ACTIVE_GAME_EVENT:
{
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
if (value1 >=events.size() || !events[value1].isValid())
if (!sGameEventMgr.IsValidEvent(value1))
{
sLog.outErrorDb("Active event (%u) condition requires existing event id (%u), skipped", condition, value1);
return false;
@ -7891,6 +7897,16 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
break;
}
case CONDITION_ACTIVE_HOLIDAY:
case CONDITION_NOT_ACTIVE_HOLIDAY:
{
if (!sHolidaysStore.LookupEntry(value1))
{
sLog.outErrorDb("Active holiday (%u) condition requires existing holiday id (%u), skipped", condition, value1);
return false;
}
break;
}
case CONDITION_NONE:
break;
}