This repository has been archived by the owner on Apr 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
plugin.cpp
65 lines (56 loc) · 2.22 KB
/
plugin.cpp
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
#include <ISmmPlugin.h>
PLUGIN_GLOBALVARS();
SH_DECL_HOOK0(IServerGameDLL, GetTickInterval, const, 0, float);
#ifndef TICK_INTERVAL
# ifdef TICK_RATE
# define TICK_INTERVAL (1.0f/TICK_RATE)
# else
# define TICK_INTERVAL 0.008
# endif
#endif
float Hook_GetTickInterval()
{
RETURN_META_VALUE(MRES_SUPERCEDE, TICK_INTERVAL);
}
class TickRatePlugin : public ISmmPlugin
{
public:
bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
bool Unload(char *error, size_t maxlen);
public:
const char *GetAuthor();
const char *GetName();
const char *GetDescription();
const char *GetURL();
const char *GetLicense();
const char *GetVersion();
const char *GetDate();
const char *GetLogTag();
};
TickRatePlugin g_TickRatePlugin;
PLUGIN_EXPOSE(TickRatePlugin, g_TickRatePlugin);
IServerGameDLL *server = NULL;
bool TickRatePlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
#if defined METAMOD_PLAPI_VERSION
GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#else
GET_V_IFACE_ANY(serverFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#endif
SH_ADD_HOOK_STATICFUNC(IServerGameDLL, GetTickInterval, server, Hook_GetTickInterval, false);
return true;
}
bool TickRatePlugin::Unload(char *error, size_t maxlen)
{
SH_REMOVE_HOOK_STATICFUNC(IServerGameDLL, GetTickInterval, server, Hook_GetTickInterval, false);
return true;
}
const char *TickRatePlugin::GetLicense() { return "MIT"; }
const char *TickRatePlugin::GetVersion() { return "0.1.0"; }
const char *TickRatePlugin::GetDate() { return __DATE__; }
const char *TickRatePlugin::GetLogTag() { return "mms-unlocked-tickrate"; }
const char *TickRatePlugin::GetAuthor() { return "ldesgoui"; }
const char *TickRatePlugin::GetDescription() { return "Force a server's tickrate"; }
const char *TickRatePlugin::GetName() { return "Unlocked Tickrate"; }
const char *TickRatePlugin::GetURL() { return "https://github.com/ldesgoui/mms-unlocked-tickrate"; }