TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LFGQueue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
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 
23 namespace lfg
24 {
25 
27 {
35  LFG_COMPATIBLES_WITH_LESS_PLAYERS, // Values under this = not compatible (do not modify order)
37  LFG_COMPATIBLES_MATCH // Must be the last one
38 };
39 
41 {
43  LfgCompatibilityData(LfgCompatibility _compatibility): compatibility(_compatibility) { }
44  LfgCompatibilityData(LfgCompatibility _compatibility, LfgRolesMap const& _roles):
45  compatibility(_compatibility), roles(_roles) { }
46 
49 };
50 
53 {
56  { }
57 
58  LfgQueueData(time_t _joinTime, LfgDungeonSet const& _dungeons, LfgRolesMap const& _roles):
60  dps(LFG_DPS_NEEDED), dungeons(_dungeons), roles(_roles)
61  { }
62 
63  time_t joinTime;
69  std::string bestCompatible;
70 };
71 
73 {
74  LfgWaitTime(): time(-1), number(0) { }
77 };
78 
79 typedef std::map<uint32, LfgWaitTime> LfgWaitTimesContainer;
80 typedef std::map<std::string, LfgCompatibilityData> LfgCompatibleContainer;
81 typedef std::map<ObjectGuid, LfgQueueData> LfgQueueDataContainer;
82 
87 {
88  public:
89 
90  // Add/Remove from queue
91  std::string GetDetailedMatchRoles(GuidList const& check) const;
92  void AddToQueue(ObjectGuid guid);
93  void RemoveFromQueue(ObjectGuid guid);
94  void AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap);
95  void RemoveQueueData(ObjectGuid guid);
96 
97  // Update Timers (when proposal success)
98  void UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId);
99  void UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId);
100  void UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId);
101  void UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId);
102 
103  // Update Queue timers
104  void UpdateQueueTimers(uint8 queueId, time_t currTime);
105  time_t GetJoinTime(ObjectGuid guid) const;
106 
107  // Find new group
108  uint8 FindGroups();
109 
110  // Just for debugging purposes
111  std::string DumpQueueInfo() const;
112  std::string DumpCompatibleInfo(bool full = false) const;
113 
114  private:
115  void SetQueueUpdateData(std::string const& strGuids, LfgRolesMap const& proposalRoles);
116 
117  void AddToNewQueue(ObjectGuid guid);
118  void AddToCurrentQueue(ObjectGuid guid);
119  void RemoveFromNewQueue(ObjectGuid guid);
120  void RemoveFromCurrentQueue(ObjectGuid guid);
121 
122  void SetCompatibles(std::string const& key, LfgCompatibility compatibles);
123  LfgCompatibility GetCompatibles(std::string const& key);
124  void RemoveFromCompatibles(ObjectGuid guid);
125 
126  void SetCompatibilityData(std::string const& key, LfgCompatibilityData const& compatibles);
127  LfgCompatibilityData* GetCompatibilityData(std::string const& key);
128  void FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue);
129  void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles);
130 
131  LfgCompatibility FindNewGroups(GuidList& check, GuidList& all);
132  LfgCompatibility CheckCompatibility(GuidList check);
133 
134  // Queue
135  LfgQueueDataContainer QueueDataStore;
136  LfgCompatibleContainer CompatibleMapStore;
137 
138  LfgWaitTimesContainer waitTimesAvgStore;
139  LfgWaitTimesContainer waitTimesTankStore;
140  LfgWaitTimesContainer waitTimesHealerStore;
141  LfgWaitTimesContainer waitTimesDpsStore;
144 };
145 
146 } // namespace lfg
147 
148 #endif
LfgWaitTimesContainer waitTimesHealerStore
Average wait time to find a group queuing as healer.
Definition: LFGQueue.h:140
LfgCompatibility
Definition: LFGQueue.h:26
Definition: LFGQueue.h:34
LfgQueueDataContainer QueueDataStore
Queued groups.
Definition: LFGQueue.h:135
LfgWaitTimesContainer waitTimesAvgStore
Average wait time to find a group queuing as multiple roles.
Definition: LFGQueue.h:138
GuidList newToQueueStore
New groups to add to queue.
Definition: LFGQueue.h:143
Stores player or group queue info.
Definition: LFGQueue.h:52
Definition: LFGQueue.h:36
arena_t NULL
Definition: jemalloc_internal.h:624
std::map< std::string, LfgCompatibilityData > LfgCompatibleContainer
Definition: LFGQueue.h:80
GuidList currentQueueStore
Ordered list. Used to find groups.
Definition: LFGQueue.h:142
LfgCompatibilityData(LfgCompatibility _compatibility)
Definition: LFGQueue.h:43
int32 time
Wait time.
Definition: LFGQueue.h:75
uint8 healers
Healers needed.
Definition: LFGQueue.h:65
bool all(float x)
Definition: g3dmath.h:431
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:333
Definition: LFG.cpp:22
LfgDungeonSet dungeons
Selected Player/Group Dungeon/s.
Definition: LFGQueue.h:67
Definition: LFG.h:29
Definition: LFG.h:30
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition: LFG.h:115
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
LfgCompatibleContainer CompatibleMapStore
Compatible dungeons.
Definition: LFGQueue.h:136
time_t joinTime
Player queue join time (to calculate wait times)
Definition: LFGQueue.h:63
LfgWaitTimesContainer waitTimesDpsStore
Average wait time to find a group queuing as dps.
Definition: LFGQueue.h:141
LfgCompatibility compatibility
Definition: LFGQueue.h:47
Definition: LFGQueue.h:37
LfgWaitTime()
Definition: LFGQueue.h:74
uint8 dps
Dps needed.
Definition: LFGQueue.h:66
std::map< uint32, LfgWaitTime > LfgWaitTimesContainer
Definition: LFGQueue.h:79
Definition: LFGQueue.h:33
Definition: LFGQueue.h:86
Definition: LFGQueue.h:72
Definition: LFG.h:31
LfgCompatibilityData()
Definition: LFGQueue.h:42
uint8 tanks
Tanks needed.
Definition: LFGQueue.h:64
#define TC_GAME_API
Definition: Define.h:134
Definition: LFGQueue.h:32
uint8_t uint8
Definition: Define.h:152
LfgCompatibilityData(LfgCompatibility _compatibility, LfgRolesMap const &_roles)
Definition: LFGQueue.h:44
LfgQueueData(time_t _joinTime, LfgDungeonSet const &_dungeons, LfgRolesMap const &_roles)
Definition: LFGQueue.h:58
Definition: ObjectGuid.h:189
LfgWaitTimesContainer waitTimesTankStore
Average wait time to find a group queuing as tank.
Definition: LFGQueue.h:139
T check(T value)
Definition: format.h:305
LfgRolesMap roles
Definition: LFGQueue.h:48
std::string bestCompatible
Best compatible combination of people queued.
Definition: LFGQueue.h:69
Definition: LFGQueue.h:28
LfgRolesMap roles
Selected Player Role/s.
Definition: LFGQueue.h:68
LfgQueueData()
Definition: LFGQueue.h:54
uint32 number
Number of people used to get that wait time.
Definition: LFGQueue.h:76
std::map< ObjectGuid, LfgQueueData > LfgQueueDataContainer
Definition: LFGQueue.h:81
Definition: LFGQueue.h:40