[2] | 1 | /* |
---|
| 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
| 4 | * This program is free software; you can redistribute it and/or modify |
---|
| 5 | * it under the terms of the GNU General Public License as published by |
---|
| 6 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | * (at your option) any later version. |
---|
| 8 | * |
---|
| 9 | * This program is distributed in the hope that it will be useful, |
---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | * GNU General Public License for more details. |
---|
| 13 | * |
---|
| 14 | * You should have received a copy of the GNU General Public License |
---|
| 15 | * along with this program; if not, write to the Free Software |
---|
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #ifndef MANGOS_GAMEEVENT_H |
---|
| 20 | #define MANGOS_GAMEEVENT_H |
---|
| 21 | |
---|
| 22 | #include "Platform/Define.h" |
---|
| 23 | #include "Creature.h" |
---|
| 24 | #include "GameObject.h" |
---|
| 25 | |
---|
| 26 | #define max_ge_check_delay 86400 // 1 day in seconds |
---|
| 27 | |
---|
| 28 | struct GameEventData |
---|
| 29 | { |
---|
| 30 | GameEventData() : start(1),end(0),occurence(0),length(0) {} |
---|
| 31 | time_t start; |
---|
| 32 | time_t end; |
---|
| 33 | uint32 occurence; |
---|
| 34 | uint32 length; |
---|
| 35 | std::string description; |
---|
| 36 | |
---|
| 37 | bool isValid() const { return length > 0; } |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | struct ModelEquip |
---|
| 41 | { |
---|
| 42 | uint32 modelid; |
---|
| 43 | uint32 equipment_id; |
---|
| 44 | uint32 modelid_prev; |
---|
| 45 | uint32 equipement_id_prev; |
---|
| 46 | }; |
---|
| 47 | |
---|
| 48 | class GameEvent |
---|
| 49 | { |
---|
| 50 | public: |
---|
| 51 | GameEvent(); |
---|
| 52 | ~GameEvent() {}; |
---|
| 53 | typedef std::set<uint16> ActiveEvents; |
---|
| 54 | typedef std::vector<GameEventData> GameEventDataMap; |
---|
| 55 | ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; } |
---|
| 56 | GameEventDataMap const& GetEventMap() const { return mGameEvent; } |
---|
| 57 | bool CheckOneGameEvent(uint16 entry) const; |
---|
| 58 | uint32 NextCheck(uint16 entry) const; |
---|
| 59 | void LoadFromDB(); |
---|
| 60 | uint32 Update(); |
---|
| 61 | bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); } |
---|
| 62 | uint32 Initialize(); |
---|
| 63 | void StartEvent(uint16 event_id, bool overwrite = false); |
---|
| 64 | void StopEvent(uint16 event_id, bool overwrite = false); |
---|
| 65 | private: |
---|
| 66 | void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } |
---|
| 67 | void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } |
---|
| 68 | void ApplyNewEvent(uint16 event_id); |
---|
| 69 | void UnApplyEvent(uint16 event_id); |
---|
| 70 | void GameEventSpawn(int16 event_id); |
---|
| 71 | void GameEventUnspawn(int16 event_id); |
---|
| 72 | void ChangeEquipOrModel(int16 event_id, bool activate); |
---|
| 73 | void UpdateEventQuests(uint16 event_id, bool Activate); |
---|
| 74 | protected: |
---|
| 75 | typedef std::list<uint32> GuidList; |
---|
| 76 | typedef std::vector<GuidList> GameEventGuidMap; |
---|
| 77 | typedef std::pair<uint32, ModelEquip> ModelEquipPair; |
---|
| 78 | typedef std::list<ModelEquipPair> ModelEquipList; |
---|
| 79 | typedef std::vector<ModelEquipList> GameEventModelEquipMap; |
---|
| 80 | typedef std::pair<uint32, uint32> QuestRelation; |
---|
| 81 | typedef std::list<QuestRelation> QuestRelList; |
---|
| 82 | typedef std::vector<QuestRelList> GameEventQuestMap; |
---|
| 83 | GameEventQuestMap mGameEventQuests; |
---|
| 84 | GameEventModelEquipMap mGameEventModelEquip; |
---|
| 85 | GameEventGuidMap mGameEventCreatureGuids; |
---|
| 86 | GameEventGuidMap mGameEventGameobjectGuids; |
---|
| 87 | GameEventDataMap mGameEvent; |
---|
| 88 | ActiveEvents m_ActiveEvents; |
---|
| 89 | bool isSystemInit; |
---|
| 90 | }; |
---|
| 91 | |
---|
| 92 | #define gameeventmgr MaNGOS::Singleton<GameEvent>::Instance() |
---|
| 93 | #endif |
---|