| 1 | /* |
|---|
| 2 | * ArcEmu MMORPG Server |
|---|
| 3 | * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> |
|---|
| 4 | * Copyright (C) 2008-2010 <http://www.ArcEmu.org/> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software: you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU Affero General Public License as published by |
|---|
| 8 | * the Free Software Foundation, either version 3 of the License, or |
|---|
| 9 | * any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU Affero General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU Affero General Public License |
|---|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | * |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | enum LFGTypes |
|---|
| 22 | { |
|---|
| 23 | LFG_NONE = 0, |
|---|
| 24 | LFG_INSTANCE = 1, |
|---|
| 25 | LFG_RAID = 2, |
|---|
| 26 | LFG_QUEST = 3, |
|---|
| 27 | LFG_ZONE = 4, |
|---|
| 28 | LFG_HEROIC_DUNGEON = 5, // from client |
|---|
| 29 | LFG_ANY_DUNGEON = 6, |
|---|
| 30 | LFG_ANY_HEROIC_DUNGEON = 7, |
|---|
| 31 | LFG_DAILY_DUNGEON = 8, |
|---|
| 32 | LFG_DAILY_HEROIC_DUNGEON = 9, |
|---|
| 33 | }; |
|---|
| 34 | |
|---|
| 35 | #define MAX_DUNGEONS 257+1 // check max entry's +1 on lfgdungeons.dbc |
|---|
| 36 | #define MAX_LFG_QUEUE_ID 3 |
|---|
| 37 | #define LFG_MATCH_TIMEOUT 30 // in seconds |
|---|
| 38 | |
|---|
| 39 | class LfgMatch; |
|---|
| 40 | class LfgMgr : public Singleton < LfgMgr >, EventableObject |
|---|
| 41 | { |
|---|
| 42 | public: |
|---|
| 43 | |
|---|
| 44 | typedef list<Player*> LfgPlayerList; |
|---|
| 45 | |
|---|
| 46 | LfgMgr(); |
|---|
| 47 | ~LfgMgr(); |
|---|
| 48 | |
|---|
| 49 | bool AttemptLfgJoin(Player * pl, uint32 LfgDungeonId); |
|---|
| 50 | void SetPlayerInLFGqueue(Player *pl,uint32 LfgDungeonId); |
|---|
| 51 | void SetPlayerInLfmList(Player * pl, uint32 LfgDungeonId); |
|---|
| 52 | void RemovePlayerFromLfgQueue(Player *pl,uint32 LfgDungeonId); |
|---|
| 53 | void RemovePlayerFromLfgQueues(Player * pl); |
|---|
| 54 | void RemovePlayerFromLfmList(Player * pl, uint32 LfmDungeonId); |
|---|
| 55 | void UpdateLfgQueue(uint32 LfgDungeonId); |
|---|
| 56 | void SendLfgList(Player * plr, uint32 Dungeon); |
|---|
| 57 | |
|---|
| 58 | int32 event_GetInstanceId() { return -1; } |
|---|
| 59 | |
|---|
| 60 | protected: |
|---|
| 61 | |
|---|
| 62 | LfgPlayerList m_lookingForGroup[MAX_DUNGEONS]; |
|---|
| 63 | LfgPlayerList m_lookingForMore[MAX_DUNGEONS]; |
|---|
| 64 | Mutex m_lock; |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | }; |
|---|
| 68 | |
|---|
| 69 | class LfgMatch |
|---|
| 70 | { |
|---|
| 71 | public: |
|---|
| 72 | set<Player*> PendingPlayers; |
|---|
| 73 | set<Player*> AcceptedPlayers; |
|---|
| 74 | Mutex lock; |
|---|
| 75 | uint32 DungeonId; |
|---|
| 76 | Group * pGroup; |
|---|
| 77 | |
|---|
| 78 | LfgMatch(uint32 did) : DungeonId(did),pGroup(NULL) { } |
|---|
| 79 | }; |
|---|
| 80 | |
|---|
| 81 | extern uint32 LfgDungeonTypes[MAX_DUNGEONS]; |
|---|
| 82 | |
|---|
| 83 | #define sLfgMgr LfgMgr::getSingleton() |
|---|