This repository has been archived by the owner on Nov 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
d2fixups.h
105 lines (89 loc) · 3.55 KB
/
d2fixups.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
/**
* =============================================================================
* D2Fixups
* Copyright (C) 2013 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.
*/
#ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
#define _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
#include <ISmmPlugin.h>
#include <igameevents.h>
#include <steam_gameserver.h>
#include <isteamgamecoordinator.h>
#include <sh_list.h>
enum GameLibraryType
{
Engine,
Server,
};
struct LibraryInfo
{
void *base;
size_t size;
};
class D2Fixups : public ISmmPlugin,
public IGameEventListener2
{
public: // ISmmPlugin
bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
bool Unload(char *error, size_t maxlen);
const char *GetAuthor();
const char *GetName();
const char *GetDescription();
const char *GetURL();
const char *GetLicense();
const char *GetVersion();
const char *GetDate();
const char *GetLogTag();
public: // IGameEventListener2
void FireGameEvent(IGameEvent *pEvent);
private:
bool InitGlobals(char *error, size_t maxlen);
void InitHooks();
void ShutdownHooks();
void UnhookGC();
public:
static bool GetLibraryInfo(GameLibraryType type, LibraryInfo &libraryInfo);
static void *FindPatchAddress(const char *sig, size_t len, GameLibraryType type);
static void *ResolveSymbol(const char *symbol, GameLibraryType type);
static void RefreshWaitForPlayersCount();
private:
bool Hook_SteamIDAllowedToConnect(const CSteamID &steamId) const;
bool Hook_IsServerLocalOnly();
bool Hook_GameInit();
bool Hook_LevelInit(const char *pMapName, const char *pMapEntities, const char *pOldLevel, const char *pLandmarkName, bool loadGame, bool background);
bool Hook_LevelInit_Post(const char *pMapName, const char *pMapEntities, const char *pOldLevel, const char *pLandmarkName, bool loadGame, bool background);
void Hook_GameServerSteamAPIActivated();
int Hook_GetServerVersion();
EGCResults Hook_RetrieveMessage(uint32 *punMsgType, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize);
EGCResults Hook_RetrieveMessagePost(uint32 *punMsgType, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize);
void Hook_OnBotDisconnect(int reason);
void Event_PlayerConnect(IGameEvent *pEvent);
void Event_PlayerDisconnect(IGameEvent *pEvent);
private:
bool m_bPretendToBeLocal;
int m_iCheatGameVersionCount;
int m_iRetrieveMsgHook;
int m_iRetrieveMsgHookPost;
SourceHook::List<int> m_GlobalHooks;
};
PLUGIN_GLOBALVARS();
#endif //_INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_