feat(Core/Disables): Implement DISABLE_TYPE_GAME_EVENT (#9099)

This commit is contained in:
Skjalf
2021-11-10 15:06:46 -03:00
committed by GitHub
parent c519dc5738
commit 855f098a57
5 changed files with 60 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
*/
#include "BattlegroundMgr.h"
#include "DisableMgr.h"
#include "GameEventMgr.h"
#include "GameObjectAI.h"
#include "GossipDef.h"
@@ -136,6 +137,11 @@ void GameEventMgr::StartInternalEvent(uint16 event_id)
bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
{
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_GAME_EVENT, event_id, nullptr) && !overwrite)
{
return false;
}
GameEventData& data = mGameEvent[event_id];
if (data.state == GAMEEVENT_NORMAL || data.state == GAMEEVENT_INTERNAL)
{
@@ -251,6 +257,7 @@ void GameEventMgr::LoadFromDB()
}
GameEventData& pGameEvent = mGameEvent[event_id];
pGameEvent.eventId = fields[0].GetUInt32();
uint64 starttime = fields[1].GetUInt64();
pGameEvent.start = time_t(starttime);
uint64 endtime = fields[2].GetUInt64();
@@ -1852,6 +1859,21 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event)
}
}
uint32 GameEventMgr::GetHolidayEventId(uint32 holidayId) const
{
auto const events = sGameEventMgr->GetEventMap();
for (auto const& eventEntry : events)
{
if (eventEntry.holiday_id == holidayId)
{
return eventEntry.eventId;
}
}
return 0;
}
bool IsHolidayActive(HolidayIds id)
{
if (id == HOLIDAY_NONE)

View File

@@ -55,6 +55,7 @@ typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventCon
struct GameEventData
{
GameEventData() { }
uint32 eventId;
time_t start{1}; // occurs after this time
time_t end{0}; // occurs before this time
time_t nextstart{0}; // after this time the follow-up events count this phase completed
@@ -119,6 +120,7 @@ public:
void StopEvent(uint16 event_id, bool overwrite = false);
void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions
uint32 GetNPCFlag(Creature* cr);
[[nodiscard]] uint32 GetHolidayEventId(uint32 holidayId) const;
private:
void SendWorldStateUpdate(Player* player, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }