[7645] Fixed problems wit temporary unsummoned pets and cleanup code.
[AHbot.git] / src / game / GameEventMgr.h
bloba05f07767d3b82a4f61dc3076ea34897ba854480
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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.
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.
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
19 #ifndef MANGOS_GAMEEVENT_MGR_H
20 #define MANGOS_GAMEEVENT_MGR_H
22 #include "Common.h"
23 #include "SharedDefines.h"
24 #include "Platform/Define.h"
25 #include "Policies/Singleton.h"
27 #define max_ge_check_delay 86400 // 1 day in seconds
29 class Creature;
30 class GameObject;
32 struct GameEventData
34 GameEventData() : start(1),end(0),occurence(0),length(0) {}
35 time_t start;
36 time_t end;
37 uint32 occurence;
38 uint32 length;
39 uint32 holiday_id;
40 std::string description;
42 bool isValid() const { return length > 0; }
45 struct ModelEquip
47 uint32 modelid;
48 uint32 equipment_id;
49 uint32 modelid_prev;
50 uint32 equipement_id_prev;
53 class GameEventMgr
55 public:
56 GameEventMgr();
57 ~GameEventMgr() {};
58 typedef std::set<uint16> ActiveEvents;
59 typedef std::vector<GameEventData> GameEventDataMap;
60 ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
61 GameEventDataMap const& GetEventMap() const { return mGameEvent; }
62 bool CheckOneGameEvent(uint16 entry) const;
63 uint32 NextCheck(uint16 entry) const;
64 void LoadFromDB();
65 uint32 Update();
66 bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); }
67 uint32 Initialize();
68 void StartEvent(uint16 event_id, bool overwrite = false);
69 void StopEvent(uint16 event_id, bool overwrite = false);
70 private:
71 void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
72 void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); }
73 void ApplyNewEvent(uint16 event_id);
74 void UnApplyEvent(uint16 event_id);
75 void GameEventSpawn(int16 event_id);
76 void GameEventUnspawn(int16 event_id);
77 void ChangeEquipOrModel(int16 event_id, bool activate);
78 void UpdateEventQuests(uint16 event_id, bool Activate);
79 protected:
80 typedef std::list<uint32> GuidList;
81 typedef std::list<uint16> IdList;
82 typedef std::vector<GuidList> GameEventGuidMap;
83 typedef std::vector<IdList> GameEventIdMap;
84 typedef std::pair<uint32, ModelEquip> ModelEquipPair;
85 typedef std::list<ModelEquipPair> ModelEquipList;
86 typedef std::vector<ModelEquipList> GameEventModelEquipMap;
87 typedef std::pair<uint32, uint32> QuestRelation;
88 typedef std::list<QuestRelation> QuestRelList;
89 typedef std::vector<QuestRelList> GameEventQuestMap;
90 GameEventQuestMap mGameEventQuests;
91 GameEventModelEquipMap mGameEventModelEquip;
92 GameEventGuidMap mGameEventCreatureGuids;
93 GameEventGuidMap mGameEventGameobjectGuids;
94 GameEventIdMap mGameEventPoolIds;
95 GameEventDataMap mGameEvent;
96 ActiveEvents m_ActiveEvents;
97 bool isSystemInit;
100 #define gameeventmgr MaNGOS::Singleton<GameEventMgr>::Instance()
102 MANGOS_DLL_SPEC bool IsHolidayActive(HolidayIds id);
104 #endif