TrinityCore
Loading...
Searching...
No Matches
LFGQueue.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _LFGQUEUE_H
19#define _LFGQUEUE_H
20
21#include "LFG.h"
22#include <list>
23
24namespace lfg
25{
26
40
51
54{
56
57 LfgQueueData(time_t _joinTime, LfgDungeonSet const& _dungeons, LfgRolesMap const& _roles):
59 dps(LFG_DPS_NEEDED), dungeons(_dungeons), roles(_roles)
60 { }
61
62 time_t joinTime;
68 std::string bestCompatible;
69};
70
77
78typedef std::map<uint32, LfgWaitTime> LfgWaitTimesContainer;
79typedef std::map<std::string, LfgCompatibilityData> LfgCompatibleContainer;
80typedef std::map<ObjectGuid, LfgQueueData> LfgQueueDataContainer;
81
86{
87 public:
89 LFGQueue(LFGQueue const&) = delete;
90 LFGQueue(LFGQueue&& other) noexcept;
91 LFGQueue& operator=(LFGQueue const&) = delete;
92 LFGQueue& operator=(LFGQueue&& right) noexcept;
94
95 // Add/Remove from queue
96 std::string GetDetailedMatchRoles(GuidList const& check) const;
97 void AddToQueue(ObjectGuid guid, bool reAdd = false);
98 void RemoveFromQueue(ObjectGuid guid);
99 void AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap);
100 void RemoveQueueData(ObjectGuid guid);
101
102 // Update Timers (when proposal success)
103 void UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId);
104 void UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId);
105 void UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId);
106 void UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId);
107
108 // Update Queue timers
109 void UpdateQueueTimers(uint8 queueId, time_t currTime);
110 time_t GetJoinTime(ObjectGuid guid) const;
111
112 // Find new group
113 uint8 FindGroups();
114
115 // Just for debugging purposes
116 std::string DumpQueueInfo() const;
117 std::string DumpCompatibleInfo(bool full = false) const;
118
119 private:
120 void AddToNewQueue(ObjectGuid guid);
121 void AddToCurrentQueue(ObjectGuid guid);
122 void AddToFrontCurrentQueue(ObjectGuid guid);
123 void RemoveFromNewQueue(ObjectGuid guid);
124 void RemoveFromCurrentQueue(ObjectGuid guid);
125
126 void SetCompatibles(std::string const& key, LfgCompatibility compatibles);
127 LfgCompatibility GetCompatibles(std::string const& key);
128 void RemoveFromCompatibles(ObjectGuid guid);
129
130 void SetCompatibilityData(std::string const& key, LfgCompatibilityData const& compatibles);
131 LfgCompatibilityData* GetCompatibilityData(std::string const& key);
132 void FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue);
133 void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles);
134
135 LfgCompatibility FindNewGroups(GuidList& check, GuidList& all);
136 LfgCompatibility CheckCompatibility(GuidList check);
137
138 // Queue
141
148};
149
150} // namespace lfg
151
152#endif
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
LfgQueueDataContainer QueueDataStore
Queued groups.
Definition LFGQueue.h:139
LFGQueue(LFGQueue const &)=delete
LFGQueue(LFGQueue &&other) noexcept
LFGQueue & operator=(LFGQueue const &)=delete
LfgCompatibleContainer CompatibleMapStore
Compatible dungeons.
Definition LFGQueue.h:140
LfgWaitTimesContainer waitTimesTankStore
Average wait time to find a group queuing as tank.
Definition LFGQueue.h:143
LfgWaitTimesContainer waitTimesAvgStore
Average wait time to find a group queuing as multiple roles.
Definition LFGQueue.h:142
GuidList currentQueueStore
Ordered list. Used to find groups.
Definition LFGQueue.h:146
LFGQueue & operator=(LFGQueue &&right) noexcept
GuidList newToQueueStore
New groups to add to queue.
Definition LFGQueue.h:147
LfgWaitTimesContainer waitTimesDpsStore
Average wait time to find a group queuing as dps.
Definition LFGQueue.h:145
LfgWaitTimesContainer waitTimesHealerStore
Average wait time to find a group queuing as healer.
Definition LFGQueue.h:144
Definition LFG.cpp:24
std::map< std::string, LfgCompatibilityData > LfgCompatibleContainer
Definition LFGQueue.h:79
@ LFG_HEALERS_NEEDED
Definition LFG.h:33
@ LFG_TANKS_NEEDED
Definition LFG.h:32
@ LFG_DPS_NEEDED
Definition LFG.h:34
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition LFG.h:135
LfgCompatibility
Definition LFGQueue.h:28
@ LFG_COMPATIBLES_WITH_LESS_PLAYERS
Definition LFGQueue.h:36
@ LFG_INCOMPATIBLES_HAS_IGNORES
Definition LFGQueue.h:33
@ LFG_INCOMPATIBLES_MULTIPLE_LFG_GROUPS
Definition LFGQueue.h:32
@ LFG_INCOMPATIBLES_NO_DUNGEONS
Definition LFGQueue.h:35
@ LFG_COMPATIBILITY_PENDING
Definition LFGQueue.h:29
@ LFG_COMPATIBLES_MATCH
Definition LFGQueue.h:38
@ LFG_INCOMPATIBLES_TOO_MUCH_PLAYERS
Definition LFGQueue.h:31
@ LFG_INCOMPATIBLES_WRONG_GROUP_SIZE
Definition LFGQueue.h:30
@ LFG_INCOMPATIBLES_NO_ROLES
Definition LFGQueue.h:34
@ LFG_COMPATIBLES_BAD_STATES
Definition LFGQueue.h:37
std::map< uint32, LfgWaitTime > LfgWaitTimesContainer
Definition LFGQueue.h:78
std::set< uint32 > LfgDungeonSet
Definition LFG.h:132
std::map< ObjectGuid, LfgQueueData > LfgQueueDataContainer
Definition LFGQueue.h:80
LfgCompatibility compatibility
Definition LFGQueue.h:48
LfgCompatibilityData(LfgCompatibility _compatibility, LfgRolesMap const &_roles)
Definition LFGQueue.h:45
LfgCompatibilityData(LfgCompatibility _compatibility)
Definition LFGQueue.h:44
Stores player or group queue info.
Definition LFGQueue.h:54
LfgRolesMap roles
Selected Player Role/s.
Definition LFGQueue.h:67
time_t joinTime
Player queue join time (to calculate wait times)
Definition LFGQueue.h:62
std::string bestCompatible
Best compatible combination of people queued.
Definition LFGQueue.h:68
uint8 tanks
Tanks needed.
Definition LFGQueue.h:63
LfgDungeonSet dungeons
Selected Player/Group Dungeon/s.
Definition LFGQueue.h:66
uint8 healers
Healers needed.
Definition LFGQueue.h:64
LfgQueueData(time_t _joinTime, LfgDungeonSet const &_dungeons, LfgRolesMap const &_roles)
Definition LFGQueue.h:57
uint8 dps
Dps needed.
Definition LFGQueue.h:65
int32 time
Wait time.
Definition LFGQueue.h:74
uint32 number
Number of people used to get that wait time.
Definition LFGQueue.h:75