chore(Core/EventMgr): Align code to Code standard & improve LoadFromDB function (#21151)

Co-authored-by: Jelle Meeus <sogladev@gmail.com>
Co-authored-by: Ludwig <sudlud@users.noreply.github.com>
This commit is contained in:
Exitare
2025-02-07 05:25:07 -08:00
committed by GitHub
parent 2e91c83433
commit ff4d1ef053
10 changed files with 1068 additions and 991 deletions
@@ -267,6 +267,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE, "DELETE FROM game_event_condition_save WHERE eventEntry = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE, "DELETE FROM game_event_condition_save WHERE eventEntry = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_GAME_EVENT_CONDITION_SAVE, "DELETE FROM game_event_condition_save WHERE eventEntry = ? AND condition_id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GAME_EVENT_CONDITION_SAVE, "DELETE FROM game_event_condition_save WHERE eventEntry = ? AND condition_id = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_GAME_EVENT_CONDITION_SAVE, "INSERT INTO game_event_condition_save (eventEntry, condition_id, done) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_GAME_EVENT_CONDITION_SAVE, "INSERT INTO game_event_condition_save (eventEntry, condition_id, done) VALUES (?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_GAME_EVENT_CONDITION_SAVE_DATA, "SELECT eventEntry, condition_id, done FROM game_event_condition_save", CONNECTION_SYNCH);
PrepareStatement(CHAR_SEL_GAME_EVENT_SAVE_DATA, "SELECT eventEntry, state, next_start FROM game_event_save", CONNECTION_SYNCH);
// Petitions // Petitions
PrepareStatement(CHAR_DEL_ALL_PETITION_SIGNATURES, "DELETE FROM petition_sign WHERE playerguid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ALL_PETITION_SIGNATURES, "DELETE FROM petition_sign WHERE playerguid = ?", CONNECTION_ASYNC);
@@ -218,6 +218,8 @@ enum CharacterDatabaseStatements : uint32
CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE, CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE,
CHAR_DEL_GAME_EVENT_CONDITION_SAVE, CHAR_DEL_GAME_EVENT_CONDITION_SAVE,
CHAR_INS_GAME_EVENT_CONDITION_SAVE, CHAR_INS_GAME_EVENT_CONDITION_SAVE,
CHAR_SEL_GAME_EVENT_CONDITION_SAVE_DATA,
CHAR_SEL_GAME_EVENT_SAVE_DATA,
CHAR_INS_ARENA_TEAM, CHAR_INS_ARENA_TEAM,
CHAR_INS_ARENA_TEAM_MEMBER, CHAR_INS_ARENA_TEAM_MEMBER,
@@ -84,6 +84,21 @@ void WorldDatabaseConnection::DoPrepareStatements()
PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id1, id2, id3, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id1, id2, id3, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH);
PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id1, id2, id3, map, spawnMask, phaseMask, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id1, id2, id3, map, spawnMask, phaseMask, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_GAME_EVENTS, "SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_PREREQUISITE_DATA, "SELECT eventEntry, prerequisite_event FROM game_event_prerequisite", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_CREATURE_DATA, "SELECT guid, eventEntry FROM game_event_creature", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_DATA, "SELECT guid, eventEntry FROM game_event_gameobject", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA, "SELECT creature.guid, creature.id1, creature.id2, creature.id3, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_DATA, "SELECT id, quest, eventEntry FROM game_event_creature_quest", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_QUEST_DATA, "SELECT id, quest, eventEntry FROM game_event_gameobject_quest", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_CONDITION_DATA, "SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_CONDITION_DATA, "SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_NPC_FLAGS, "SELECT guid, eventEntry, npcflag FROM game_event_npcflag", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_SEASONAL_RELATIONS, "SELECT questId, eventEntry FROM game_event_seasonal_questrelation", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_BATTLEGROUND_DATA, "SELECT eventEntry, bgflag FROM game_event_battleground_holiday", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_POOL_DATA, "SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_ARENA_SEASON, "SELECT eventEntry FROM game_event_arena_seasons WHERE season = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAME_EVENT_HOLIDAY_DATES, "SELECT id, date_id, date_value, holiday_duration FROM holiday_dates", CONNECTION_SYNCH);
PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_GAME_EVENT_NPC_VENDOR, "SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost FROM game_event_npc_vendor ORDER BY guid, slot ASC", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_NPC_VENDOR, "SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost FROM game_event_npc_vendor ORDER BY guid, slot ASC", CONNECTION_SYNCH);
@@ -90,6 +90,21 @@ enum WorldDatabaseStatements : uint32
WORLD_SEL_CREATURE_NEAREST, WORLD_SEL_CREATURE_NEAREST,
WORLD_SEL_GAMEOBJECT_TARGET, WORLD_SEL_GAMEOBJECT_TARGET,
WORLD_INS_CREATURE, WORLD_INS_CREATURE,
WORLD_SEL_GAME_EVENTS,
WORLD_SEL_GAME_EVENT_PREREQUISITE_DATA,
WORLD_SEL_GAME_EVENT_CREATURE_DATA,
WORLD_SEL_GAME_EVENT_GAMEOBJECT_DATA,
WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA,
WORLD_SEL_GAME_EVENT_QUEST_DATA,
WORLD_SEL_GAME_EVENT_GAMEOBJECT_QUEST_DATA,
WORLD_SEL_GAME_EVENT_QUEST_CONDITION_DATA,
WORLD_SEL_GAME_EVENT_CONDITION_DATA,
WORLD_SEL_GAME_EVENT_NPC_FLAGS,
WORLD_SEL_GAME_EVENT_QUEST_SEASONAL_RELATIONS,
WORLD_SEL_GAME_EVENT_BATTLEGROUND_DATA,
WORLD_SEL_GAME_EVENT_POOL_DATA,
WORLD_SEL_GAME_EVENT_ARENA_SEASON,
WORLD_SEL_GAME_EVENT_HOLIDAY_DATES,
WORLD_DEL_GAME_EVENT_CREATURE, WORLD_DEL_GAME_EVENT_CREATURE,
WORLD_DEL_GAME_EVENT_MODEL_EQUIP, WORLD_DEL_GAME_EVENT_MODEL_EQUIP,
WORLD_SEL_GAME_EVENT_NPC_VENDOR, WORLD_SEL_GAME_EVENT_NPC_VENDOR,
@@ -6066,7 +6066,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3
GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
{ {
if (uint32(events[*itr].holiday_id) == proto->HolidayId) if (uint32(events[*itr].HolidayId) == proto->HolidayId)
{ {
remove = false; remove = false;
break; break;
File diff suppressed because it is too large Load Diff
+86 -72
View File
@@ -38,17 +38,17 @@ enum GameEventState
struct GameEventFinishCondition struct GameEventFinishCondition
{ {
float reqNum; // required number // use float, since some events use percent float ReqNum; // required number // use float, since some events use percent
float done; // done number float Done; // done number
uint32 max_world_state; // max resource count world state update id uint32 MaxWorldState; // max resource count world state update id
uint32 done_world_state; // done resource count world state update id uint32 DoneWorldState; // done resource count world state update id
}; };
struct GameEventQuestToEventConditionNum struct GameEventQuestToEventConditionNum
{ {
uint16 event_id; uint16 EventId;
uint32 condition; uint32 Condition;
float num; float Num;
}; };
typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventConditionMap; typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventConditionMap;
@@ -56,37 +56,37 @@ typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventCon
struct GameEventData struct GameEventData
{ {
GameEventData() = default; GameEventData() = default;
uint32 eventId; uint32 EventId;
time_t start{1}; // occurs after this time time_t Start{1}; // occurs after this time
time_t end{0}; // occurs before 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 time_t NextStart{0}; // after this time the follow-up events count this phase completed
uint32 occurence{0}; // time between end and start uint32 Occurence{0}; // time between end and start
uint32 length{0}; // length of the event (minutes) after finishing all conditions uint32 Length{0}; // length of the event (minutes) after finishing all conditions
HolidayIds holiday_id{HOLIDAY_NONE}; HolidayIds HolidayId{HOLIDAY_NONE};
uint8 holidayStage; uint8 HolidayStage;
GameEventState state{GAMEEVENT_NORMAL}; // state of the game event, these are saved into the game_event table on change! GameEventState State{GAMEEVENT_NORMAL}; // state of the game event, these are saved into the game_event table on change!
GameEventConditionMap conditions; // conditions to finish GameEventConditionMap Conditions; // conditions to finish
std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event std::set<uint16 /*gameevent id*/> PrerequisiteEvents; // events that must be completed before starting this event
std::string description; std::string Description;
uint8 announce; // if 0 dont announce, if 1 announce, if 2 take config value uint8 Announce; // if 0 dont announce, if 1 announce, if 2 take config value
[[nodiscard]] bool isValid() const { return length > 0 || state > GAMEEVENT_NORMAL; } [[nodiscard]] bool isValid() const { return Length > 0 || State > GAMEEVENT_NORMAL; }
}; };
struct ModelEquip struct ModelEquip
{ {
uint32 modelid; uint32 ModelId;
uint32 modelid_prev; uint32 ModelIdPrev;
uint8 equipment_id; uint8 EquipmentId;
uint8 equipement_id_prev; uint8 EquipementIdPrev;
}; };
struct NPCVendorEntry struct NPCVendorEntry
{ {
uint32 entry; // creature entry uint32 Entry; // creature entry
uint32 item; // item id uint32 Item; // item id
int32 maxcount; // 0 for infinite int32 MaxCount; // 0 for infinite
uint32 incrtime; // time for restore items amount if maxcount != 0 uint32 Incrtime; // time for restore items amount if maxcount != 0
uint32 ExtendedCost; uint32 ExtendedCost;
}; };
@@ -105,46 +105,62 @@ public:
typedef std::set<uint16> ActiveEvents; typedef std::set<uint16> ActiveEvents;
typedef std::vector<GameEventData> GameEventDataMap; typedef std::vector<GameEventData> GameEventDataMap;
[[nodiscard]] ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; } [[nodiscard]] ActiveEvents const& GetActiveEventList() const { return _activeEvents; }
[[nodiscard]] GameEventDataMap const& GetEventMap() const { return mGameEvent; } [[nodiscard]] GameEventDataMap const& GetEventMap() const { return _gameEvent; }
[[nodiscard]] bool CheckOneGameEvent(uint16 entry) const; [[nodiscard]] bool CheckOneGameEvent(uint16 entry) const;
[[nodiscard]] uint32 NextCheck(uint16 entry) const; [[nodiscard]] uint32 NextCheck(uint16 entry) const;
void LoadFromDB(); void LoadFromDB();
void LoadHolidayDates(); void LoadHolidayDates();
uint32 Update(); uint32 Update();
bool IsActiveEvent(uint16 event_id) { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); } bool IsActiveEvent(uint16 eventId) { return (_activeEvents.find(eventId) != _activeEvents.end()); }
uint32 StartSystem(); uint32 StartSystem();
void Initialize(); void Initialize();
void StartArenaSeason(); void StartArenaSeason();
void StartInternalEvent(uint16 event_id); void StartInternalEvent(uint16 eventId);
bool StartEvent(uint16 event_id, bool overwrite = false); bool StartEvent(uint16 eventId, bool overwrite = false);
void StopEvent(uint16 event_id, bool overwrite = false); void StopEvent(uint16 eventId, bool overwrite = false);
void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions void HandleQuestComplete(uint32 questId); // called on world event type quest completions
uint32 GetNPCFlag(Creature* cr); uint32 GetNPCFlag(Creature* cr);
// Load the game event npc vendor table from the DB // Load the game event npc vendor table from the DB
void LoadEventVendors(); void LoadEventVendors();
[[nodiscard]] uint32 GetHolidayEventId(uint32 holidayId) const; [[nodiscard]] uint32 GetHolidayEventId(uint32 holidayId) const;
private: private:
void SendWorldStateUpdate(Player* player, uint16 event_id); void LoadEvents();
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } void LoadEventSaveData();
void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } void LoadEventPrerequisiteData();
void ApplyNewEvent(uint16 event_id); void LoadEventCreatureData();
void UnApplyEvent(uint16 event_id); void LoadEventGameObjectData();
void GameEventSpawn(int16 event_id); void LoadEventModelEquipmentChangeData();
void GameEventUnspawn(int16 event_id); void LoadEventQuestData();
void ChangeEquipOrModel(int16 event_id, bool activate); void LoadEventGameObjectQuestData();
void UpdateEventQuests(uint16 event_id, bool activate); void LoadEventQuestConditionData();
void UpdateWorldStates(uint16 event_id, bool Activate); void LoadEventConditionData();
void UpdateEventNPCFlags(uint16 event_id); void LoadEventConditionSaveData();
void UpdateEventNPCVendor(uint16 event_id, bool activate); void LoadEventNPCFlags();
void LoadEventSeasonalQuestRelations();
void LoadEventBattlegroundData();
void LoadEventPoolData();
void SendWorldStateUpdate(Player* player, uint16 eventId);
void AddActiveEvent(uint16 eventId) { _activeEvents.insert(eventId); }
void RemoveActiveEvent(uint16 eventId) { _activeEvents.erase(eventId); }
void ApplyNewEvent(uint16 eventId);
void UnApplyEvent(uint16 eventId);
void GameEventSpawn(int16 eventId);
void GameEventUnspawn(int16 eventId);
void ChangeEquipOrModel(int16 eventId, bool activate);
void UpdateEventQuests(uint16 eventId, bool activate);
void UpdateWorldStates(uint16 eventId, bool Activate);
void UpdateEventNPCFlags(uint16 eventId);
void UpdateEventNPCVendor(uint16 eventId, bool activate);
void UpdateBattlegroundSettings(); void UpdateBattlegroundSettings();
void RunSmartAIScripts(uint16 event_id, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI void RunSmartAIScripts(uint16 eventId, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI
bool CheckOneGameEventConditions(uint16 event_id); bool CheckOneGameEventConditions(uint16 eventId);
void SaveWorldEventStateToDB(uint16 event_id); void SaveWorldEventStateToDB(uint16 eventId);
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); bool HasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 eventId);
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); bool HasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 eventId);
bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id); bool HasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 eventId);
bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id); bool HasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 eventId);
void SetHolidayEventTime(GameEventData& event); void SetHolidayEventTime(GameEventData& event);
typedef std::list<ObjectGuid::LowType> GuidLowList; typedef std::list<ObjectGuid::LowType> GuidLowList;
@@ -165,29 +181,27 @@ private:
typedef std::vector<NPCFlagList> GameEventNPCFlagMap; typedef std::vector<NPCFlagList> GameEventNPCFlagMap;
typedef std::vector<uint32> GameEventBitmask; typedef std::vector<uint32> GameEventBitmask;
typedef std::unordered_map<uint32, std::vector<uint32>> GameEventSeasonalQuestsMap; typedef std::unordered_map<uint32, std::vector<uint32>> GameEventSeasonalQuestsMap;
GameEventQuestMap mGameEventCreatureQuests; GameEventQuestMap _gameEventCreatureQuests;
GameEventQuestMap mGameEventGameObjectQuests; GameEventQuestMap _gameEventGameObjectQuests;
GameEventNPCVendorMap mGameEventVendors; GameEventNPCVendorMap _gameEventVendors;
GameEventModelEquipMap mGameEventModelEquip; GameEventModelEquipMap _gameEventModelEquip;
//GameEventGuidMap mGameEventCreatureGuids; GameEventIdMap _gameEventPoolIds;
//GameEventGuidMap mGameEventGameobjectGuids; GameEventDataMap _gameEvent;
GameEventIdMap mGameEventPoolIds; GameEventBitmask _gameEventBattlegroundHolidays;
GameEventDataMap mGameEvent; QuestIdToEventConditionMap _questToEventConditions;
GameEventBitmask mGameEventBattlegroundHolidays; GameEventNPCFlagMap _gameEventNPCFlags;
QuestIdToEventConditionMap mQuestToEventConditions; ActiveEvents _activeEvents;
GameEventNPCFlagMap mGameEventNPCFlags; bool _isSystemInit;
ActiveEvents m_ActiveEvents;
bool isSystemInit;
GameEventSeasonalQuestsMap _gameEventSeasonalQuestsMap; GameEventSeasonalQuestsMap _gameEventSeasonalQuestsMap;
public: public:
GameEventGuidMap mGameEventCreatureGuids; GameEventGuidMap GameEventCreatureGuids;
GameEventGuidMap mGameEventGameobjectGuids; GameEventGuidMap GameEventGameobjectGuids;
std::vector<uint32> modifiedHolidays; std::vector<uint32> ModifiedHolidays;
}; };
#define sGameEventMgr GameEventMgr::instance() #define sGameEventMgr GameEventMgr::instance()
bool IsHolidayActive(HolidayIds id); bool IsHolidayActive(HolidayIds id);
bool IsEventActive(uint16 event_id); bool IsEventActive(uint16 eventId);
#endif #endif
+2 -2
View File
@@ -153,8 +153,8 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
data.append(dataBuffer); data.append(dataBuffer);
/// @todo: Fix this, how we do know how many and what holidays to send? /// @todo: Fix this, how we do know how many and what holidays to send?
data << uint32(sGameEventMgr->modifiedHolidays.size()); data << uint32(sGameEventMgr->ModifiedHolidays.size());
for (uint32 entry : sGameEventMgr->modifiedHolidays) for (uint32 entry : sGameEventMgr->ModifiedHolidays)
{ {
HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry); HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry);
+12 -12
View File
@@ -68,9 +68,9 @@ public:
GameEventData const& eventData = events[eventId]; GameEventData const& eventData = events[eventId];
if (handler->GetSession()) if (handler->GetSession())
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description, active); handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.Description, active);
else else
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description, active); handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.Description, active);
++counter; ++counter;
} }
@@ -104,17 +104,17 @@ public:
bool active = activeEvents.find(eventId) != activeEvents.end(); bool active = activeEvents.find(eventId) != activeEvents.end();
std::string activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : ""; std::string activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : "";
std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.start)); std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.Start));
std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.end)); std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.End));
uint32 delay = sGameEventMgr->NextCheck(eventId); uint32 delay = sGameEventMgr->NextCheck(eventId);
time_t nextTime = GameTime::GetGameTime().count() + delay; time_t nextTime = GameTime::GetGameTime().count() + delay;
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? Acore::Time::TimeToTimestampStr(Seconds(nextTime)) : "-"; std::string nextStr = nextTime >= eventData.Start && nextTime < eventData.End ? Acore::Time::TimeToTimestampStr(Seconds(nextTime)) : "-";
std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true); std::string occurenceStr = secsToTimeString(eventData.Occurence * MINUTE, true);
std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true); std::string lengthStr = secsToTimeString(eventData.Length * MINUTE, true);
handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.description, activeStr, handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.Description, activeStr,
startTimeStr, endTimeStr, occurenceStr, lengthStr, startTimeStr, endTimeStr, occurenceStr, lengthStr,
nextStr); nextStr);
@@ -141,11 +141,11 @@ public:
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
if (activeEvents.find(eventId) != activeEvents.end()) if (activeEvents.find(eventId) != activeEvents.end())
{ {
handler->SendErrorMessage(LANG_EVENT_ALREADY_ACTIVE, uint16(eventId), eventData.description); handler->SendErrorMessage(LANG_EVENT_ALREADY_ACTIVE, uint16(eventId), eventData.Description);
return false; return false;
} }
handler->PSendSysMessage(LANG_EVENT_STARTED, uint16(eventId), eventData.description); handler->PSendSysMessage(LANG_EVENT_STARTED, uint16(eventId), eventData.Description);
sGameEventMgr->StartEvent(eventId, true); sGameEventMgr->StartEvent(eventId, true);
return true; return true;
} }
@@ -171,11 +171,11 @@ public:
if (activeEvents.find(eventId) == activeEvents.end()) if (activeEvents.find(eventId) == activeEvents.end())
{ {
handler->SendErrorMessage(LANG_EVENT_NOT_ACTIVE, uint16(eventId), eventData.description); handler->SendErrorMessage(LANG_EVENT_NOT_ACTIVE, uint16(eventId), eventData.Description);
return false; return false;
} }
handler->PSendSysMessage(LANG_EVENT_STOPPED, uint16(eventId), eventData.description); handler->PSendSysMessage(LANG_EVENT_STOPPED, uint16(eventId), eventData.Description);
sGameEventMgr->StopEvent(eventId, true); sGameEventMgr->StopEvent(eventId, true);
return true; return true;
} }
+3 -17
View File
@@ -269,17 +269,13 @@ public:
static bool HandleLookupEventCommand(ChatHandler* handler, Tail namePart) static bool HandleLookupEventCommand(ChatHandler* handler, Tail namePart)
{ {
if (namePart.empty()) if (namePart.empty())
{
return false; return false;
}
std::wstring wNamePart; std::wstring wNamePart;
// converting string that we try to find to lower case // converting string that we try to find to lower case
if (!Utf8toWStr(namePart, wNamePart)) if (!Utf8toWStr(namePart, wNamePart))
{
return false; return false;
}
wstrToLower(wNamePart); wstrToLower(wNamePart);
@@ -294,11 +290,9 @@ public:
{ {
GameEventData const& eventData = events[id]; GameEventData const& eventData = events[id];
std::string descr = eventData.description; std::string descr = eventData.Description;
if (descr.empty()) if (descr.empty())
{
continue; continue;
}
if (Utf8FitTo(descr, wNamePart)) if (Utf8FitTo(descr, wNamePart))
{ {
@@ -311,25 +305,17 @@ public:
std::string active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : ""; std::string active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : "";
if (handler->GetSession()) if (handler->GetSession())
{ handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.Description, active);
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description, active);
}
else else
{ handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.Description, active);
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description, active);
}
if (!found) if (!found)
{
found = true; found = true;
}
} }
} }
if (!found) if (!found)
{
handler->SendSysMessage(LANG_NOEVENTFOUND); handler->SendSysMessage(LANG_NOEVENTFOUND);
}
return true; return true;
} }