forked from hereisderek/SourceMod.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSMJS_Interfaces.cpp
More file actions
49 lines (42 loc) · 2.05 KB
/
SMJS_Interfaces.cpp
File metadata and controls
49 lines (42 loc) · 2.05 KB
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
#include "SMJS_Interfaces.h"
#include "extension.h"
IServerGameClients *serverClients;
ICvar *icvar;
ISmmPluginManager *g_pMMPlugins;
CGlobalVars *gpGlobals;
IGameEventManager2 *gameevents;
SourceHook::CallClass<IVEngineServer> *enginePatch;
SourceHook::CallClass<IServerGameDLL> *gamedllPatch;
IUniformRandomStream *engrandom;
IPlayerInfoManager *playerinfo;
IBaseFileSystem *basefilesystem;
IEngineSound *enginesound;
// IServerPluginHelpers *serverpluginhelpers;
IServerPluginCallbacks *vsp_interface;
IServerTools *serverTools;
SourceMod::ISDKTools *sdkTools;
SourceMod::IBinTools *binTools;
bool SMJS_InitInterfaces(ISmmAPI *ismm, char *error, size_t maxlen, bool late){
GET_V_IFACE_CURRENT(GetServerFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
GET_V_IFACE_CURRENT(GetEngineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
//GET_V_IFACE_CURRENT(GetEngineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
GET_V_IFACE_CURRENT(GetServerFactory, serverTools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION);
/* :TODO: Make this optional and... make it find earlier versions [?] */
GET_V_IFACE_CURRENT(GetServerFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
gpGlobals = ismm->GetCGlobals();
if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL){
if (error){
snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
}
return false;
}
return true;
}
void SMJS_InitLateInterfaces(){
SM_GET_LATE_IFACE(SDKTOOLS, sdkTools);
SM_GET_LATE_IFACE(BINTOOLS, binTools);
}