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
/
d2lobby.h
115 lines (101 loc) · 4.13 KB
/
d2lobby.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
/**
* =============================================================================
* 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 <ISmmPlugin.h>
#include <steam/steam_gameserver.h>
#include <igameeventsystem.h>
#include <vscript/ivscript.h>
#include <generated_proto/dota_gcmessages_common.pb.h>
#include <generated_proto/dota_gcmessages_server.pb.h>
#include <vector>
struct json_t;
class CMsgDOTAPlayerFailedToConnect;
class CMsgGameMatchSignOut;
#if defined WIN32 && !defined snprintf
#define snprintf _snprintf
#endif
class D2Lobby : public ISmmPlugin
{
public: // ISmmPlugin
bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
bool Unload(char *error, size_t maxlen);
bool Pause(char *error, size_t maxlen);
bool Unpause(char *error, size_t maxlen);
void AllPluginsLoaded();
const char *GetAuthor();
const char *GetName();
const char *GetDescription();
const char *GetURL();
const char *GetLicense();
const char *GetVersion();
const char *GetDate();
const char *GetLogTag();
private:
bool InitGlobals(char *error, size_t maxlen);
void InitHooks();
void ShutdownHooks();
void SendMatchData();
void BeginShutdown();
public:
void OnGCPlayerFailedToConnect(CMsgDOTAPlayerFailedToConnect &msg);
void OnLiveStatsUpdate(CMsgDOTALiveScoreboardUpdate &msg);
void OnGCMatchSignOut(CMsgGameMatchSignOut &msg);
public:
int Hook_GetBuildVersion() const;
void Hook_ServerHibernationUpdate(bool bHibernating);
void Hook_ServerHibernationUpdate_Post(bool bHibernating);
void Hook_GameServerSteamAPIActivated();
void Hook_PostEventAbstract_Local(CSplitScreenSlot, GameEventHandle_t__ *, const void *, unsigned long);
void Hook_PostEventAbstract(CSplitScreenSlot, bool, int, const unsigned char *, GameEventHandle_t__ *, const void *pData, unsigned long nSize, NetChannelBufType_t);
void Hook_PostEntityEventAbstract(const CBaseHandle &, GameEventHandle_t__ *, const void *pData, unsigned long nSize, NetChannelBufType_t);
void Hook_OnClientConnected(CEntityIndex index, int userId, const char *pszName, uint64 xuid, const char *pszNetworkID,
const char *pszAddress, bool bFakePlayer);
void Hook_ClientDisconnect(CEntityIndex index, int userId, /* ENetworkDisconnectionReason */ int reason,
const char *pszName, uint64 xuid, const char *pszNetworkID);
IScriptVM *Hook_CreateVM(ScriptLanguage_t lang);
void Hook_DestroyVM(IScriptVM *pVM);
void Hook_GameFrame(bool, bool, bool);
private:
json_t *m_MatchData;
std::vector<int> m_GlobalHooks;
DOTA_GameState m_GameState = DOTA_GAMERULES_STATE_INIT;
enum class ShutdownState
{
None,
PreShutdown,
ShuttingDown,
};
float m_flPreShutdownStartTime = 0.0f;
ShutdownState m_ShutdownState = ShutdownState::None;
};
extern D2Lobby g_D2Lobby;
extern IVEngineServer2 *engine;
extern ISource2Server *gamedll;
extern ISource2GameClients *serverclients;
extern ISteamHTTP *http;
extern IFileSystem *filesystem;
extern IScriptVM *scriptvm;
extern CSteamGameServerAPIContext steamctx;
PLUGIN_GLOBALVARS();