This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lobbymgr.h
195 lines (164 loc) · 5.46 KB
/
lobbymgr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/**
* =============================================================================
* D2Lobby2
* Copyright (C) 2023 Nicholas Hastings
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0 or later, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, you are also granted permission to link the code
* of this program (as well as its derivative works) to "Dota 2," the
* "Source Engine, and any Game MODs that run on software by the Valve Corporation.
* You must obey the GNU General Public License in all respects for all other
* code used. Additionally, this exception is granted to all derivative works.
*/
#pragma once
#include "pluginsystem.h"
#include "constants.h"
#include <generated_proto/dota_gcmessages_common.pb.h>
#include <generated_proto/dota_gcmessages_server.pb.h>
#include <vector>
class LobbyManager : public IPluginSystem
{
public:
virtual const char *GetName() const override { return "Lobby Manager"; }
virtual bool OnLoad() override;
virtual void OnUnload() override;
public:
bool AddRadiantPlayer(const CSteamID &steamId, const char *pszName, const char *pszHero);
bool AddDirePlayer(const CSteamID &steamId, const char *pszName, const char *pszHero);
bool AddSpectatorPlayer(const CSteamID &steamId, const char *pszName);
void SetSeriesData(DotaSeriesType type, uint8 radiantWins, uint8 direWins);
void SetMatchId(uint64 id);
uint32 GetGameMode() const { return m_GameMode; }
void SetGameMode(uint32 mode);
void SetMatchType(uint32 matchType);
CSteamID MemberSteamIdFromAccountId(AccountID_t id);
void CheckInjectLobby();
DOTA_GameState GetGameState() const { return m_Lobby.game_state(); }
void GetPlayersWithoutHeroPicks(CUtlVector<CSteamID> &out);
int GetPlayerTeam(const CSteamID &steamId);
void UpdatePlayerName(const CSteamID &steamId, const char *pszName);
void EnterPostGame(EMatchOutcome outcome);
void FinalizeLobby();
void DeleteLobby();
void PrintDebug();
void HandleConnectedPlayers(const CMsgConnectedPlayers &msg);
// These are probably redundant but I'm tired of this player count boooog
void OnPlayerConnected(const CSteamID &steamId);
void OnPlayerDisconnected(const CSteamID &steamId);
const char *GetPlayerHero(const CSteamID &steamId);
int GetConnectedPlayerCount() const;
void GetNotConnectedPlayerNames(char *pszNames, size_t len);
bool Hook_LobbyAllowsCheats() const;
inline int MatchPlayerCount() const
{
return m_Lobby.members().size();
}
inline uint64 MatchId() const
{
return m_MatchId;
}
inline const google::protobuf::RepeatedPtrField<CDOTALobbyMember> &LobbyMembers()
{
return m_Lobby.members();
}
private:
void PopulateLobbyData();
void SendLobbySOUpdate();
private:
class Player
{
public:
Player(CSteamID steamId, const char *pszName, const char *pszHero = nullptr)
{
m_SteamId = steamId;
Q_strncpy(m_szName, pszName, sizeof(m_szName));
if (pszHero)
{
Q_strncpy(m_szHero, pszHero, sizeof(m_szHero));
}
else
{
m_szHero[0] = 0;
}
}
public:
inline CSteamID SteamId() const
{
return m_SteamId;
}
inline const char *Name() const
{
return m_szName;
}
inline const char *Hero() const
{
if (m_szHero[0])
return m_szHero;
else
return nullptr;
}
private:
CSteamID m_SteamId;
char m_szName[kMaxPlayerNameLength];
char m_szHero[64];
};
struct SeriesData
{
DotaSeriesType Type;
uint8 RadiantWins;
uint8 DireWins;
};
private:
bool m_bLobbyInjected = false;
std::vector<Player *> m_RadiantPlayers;
std::vector<Player *> m_DirePlayers;
std::vector<Player *> m_SpectatorPlayers;
SeriesData m_SeriesData;
uint64 m_MatchId = 0;
uint32 m_GameMode = DOTA_GAMEMODE_AP;
CSODOTALobby_LobbyType m_LobbyType = CSODOTALobby_LobbyType_CASUAL_1V1_MATCH;
/*
Auto-end after everyone on a team gone for 5m
CSODOTALobby_LobbyType_CASUAL_MATCH
CSODOTALobby_LobbyType_COOP_BOT_MATCH
CSODOTALobby_LobbyType_LEGACY_SOLO_QUEUE_MATCH
CSODOTALobby_LobbyType_COMPETITIVE_MATCH
CSODOTALobby_LobbyType_CASUAL_1V1_MATCH
"GG" works
CSODOTALobby_LobbyType_TOURNAMENT
CSODOTALobby_LobbyType_LEGACY_TEAM_MATCH
CSODOTALobby_LobbyType_CASUAL_1V1_MATCH
CSODOTALobby_LobbyType_LOCAL_BOT_MATCH
Pause limiting works
CSODOTALobby_LobbyType_CASUAL_MATCH
CSODOTALobby_LobbyType_COOP_BOT_MATCH
CSODOTALobby_LobbyType_LEGACY_TEAM_MATCH
CSODOTALobby_LobbyType_LEGACY_SOLO_QUEUE_MATCH
CSODOTALobby_LobbyType_COMPETITIVE_MATCH
CSODOTALobby_LobbyType_CASUAL_1V1_MATCH
CSODOTALobby_LobbyType_WEEKEND_TOURNEY
*/
private:
CSODOTALobby m_Lobby;
public:
CSODOTALobby m_CustomLobby;
private:
CMsgSOIDOwner m_LobbyOwner;
const uint64 k_LobbyId = 24210021764591890;
const int k_LobbySOType = 2004;
const int k_LobbyOwnerType = 3;
uint64 s_LobbyVersion = 24210021764591896;
};
extern LobbyManager g_LobbyMgr;