MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / Load

Method Load

core/sourcemm_api.cpp:68–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66ConVar sourcemod_version("sourcemod_version", SOURCEMOD_VERSION, FCVAR_SPONLY|FCVAR_NOTIFY, "SourceMod Version");
67
68bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
69{
70 PLUGIN_SAVEVARS();
71
72 GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
73#if SOURCE_ENGINE == SE_SDK2013
74 // Shim to avoid hooking shims
75 engine = (IVEngineServer *)ismm->GetEngineFactory()("VEngineServer023", nullptr);
76 if (!engine)
77 {
78 engine = (IVEngineServer *)ismm->GetEngineFactory()("VEngineServer022", nullptr);
79 if (!engine)
80 {
81 engine = (IVEngineServer *)ismm->GetEngineFactory()("VEngineServer021", nullptr);
82 if (!engine)
83 {
84 if (error && maxlen)
85 {
86 ismm->Format(error, maxlen, "Could not find interface: VEngineServer023 or VEngineServer022");
87 }
88 return false;
89 }
90 }
91 }
92#else
93 GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
94#endif
95 GET_V_IFACE_CURRENT(GetServerFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
96 GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
97 GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
98 GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
99 GET_V_IFACE_CURRENT(GetFileSystemFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
100 GET_V_IFACE_CURRENT(GetEngineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
101#if SOURCE_ENGINE >= SE_ORANGEBOX
102 GET_V_IFACE_CURRENT(GetServerFactory, servertools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION);
103#endif
104 GET_V_IFACE_CURRENT(GetEngineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
105
106 /* :TODO: Make this optional and... make it find earlier versions [?] */
107 GET_V_IFACE_CURRENT(GetServerFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
108
109 if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
110 {
111 if (error)
112 {
113 ke::SafeSprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
114 }
115 return false;
116 }
117
118 gpGlobals = ismm->GetCGlobals();
119
120 ismm->AddListener(this, this);
121
122 if ((vsp_interface = g_SMAPI->GetVSPInfo(&vsp_version)) == NULL)
123 {
124 g_SMAPI->EnableVSPListener();
125 }

Callers 1

LoadMMSPluginMethod · 0.45

Calls 3

FormatMethod · 0.80
AddListenerMethod · 0.80
InitializeSourceModMethod · 0.80

Tested by

no test coverage detected