mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Core/Disables): Implement DISABLE_TYPE_GAME_EVENT (#9099)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "DisableMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "MMapFactory.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "OutdoorPvP.h"
|
||||
@@ -41,7 +42,7 @@ namespace DisableMgr
|
||||
|
||||
DisableMap m_DisableMap;
|
||||
|
||||
uint8 MAX_DISABLE_TYPES = 9;
|
||||
uint8 MAX_DISABLE_TYPES = 10;
|
||||
}
|
||||
|
||||
void LoadDisables()
|
||||
@@ -237,6 +238,31 @@ namespace DisableMgr
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_GAME_EVENT:
|
||||
{
|
||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
|
||||
|
||||
if (entry < 1 || entry >= events.size())
|
||||
{
|
||||
LOG_ERROR("disable", "Event entry %u from `disables` does not exist, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
GameEventData const& eventData = events[entry];
|
||||
if (!eventData.isValid())
|
||||
{
|
||||
LOG_ERROR("disable", "Event entry %u from `disables` does not exist, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
|
||||
if (activeEvents.find(entry) != activeEvents.end())
|
||||
{
|
||||
sGameEventMgr->StopEvent(entry);
|
||||
LOG_INFO("disable", "Event entry %u was stopped because it has been disabled.", entry);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -366,6 +392,8 @@ namespace DisableMgr
|
||||
return flags & itr->second.flags;
|
||||
case DISABLE_TYPE_GO_LOS:
|
||||
return true;
|
||||
case DISABLE_TYPE_GAME_EVENT:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,7 @@ enum DisableType
|
||||
DISABLE_TYPE_VMAP = 6,
|
||||
DISABLE_TYPE_GO_LOS = 7,
|
||||
DISABLE_TYPE_LFG_MAP = 8,
|
||||
DISABLE_TYPE_GAME_EVENT = 9
|
||||
};
|
||||
|
||||
enum SpellDisableTypes
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -36,6 +36,7 @@ Copied events should probably have a new owner
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "CalendarMgr.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
@@ -156,6 +157,11 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
|
||||
{
|
||||
HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry);
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_GAME_EVENT, sGameEventMgr->GetHolidayEventId(holiday->Id), nullptr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
data << uint32(holiday->Id); // m_ID
|
||||
data << uint32(holiday->Region); // m_region, might be looping
|
||||
data << uint32(holiday->Looping); // m_looping, might be region
|
||||
|
||||
Reference in New Issue
Block a user