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

Function SM_LoadExtension

public/mms_sample_ext/sm_ext.cpp:39–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37MyExtension g_SMExt;
38
39bool SM_LoadExtension(char *error, size_t maxlength)
40{
41 if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
42 SOURCEMOD_INTERFACE_EXTENSIONS,
43 NULL,
44 NULL))
45 == NULL)
46 {
47 if (error && maxlength)
48 {
49 UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
50 }
51 return false;
52 }
53
54 /* This could be more dynamic */
55 char path[256];
56 g_SMAPI->PathFormat(path,
57 sizeof(path),
58 "addons/myplugin/bin/myplugin%s",
59#if defined __linux__
60 "_i486.so"
61#else
62 ".dll"
63#endif
64 );
65
66 if ((myself = smexts->LoadExternal(&g_SMExt,
67 path,
68 "myplugin_mm.ext",
69 error,
70 maxlength))
71 == NULL)
72 {
73 SM_UnsetInterfaces();
74 return false;
75 }
76
77 return true;
78}
79
80void SM_UnloadExtension()
81{

Callers 1

BindToSourcemodMethod · 0.85

Calls 4

SM_UnsetInterfacesFunction · 0.85
PathFormatMethod · 0.80
LoadExternalMethod · 0.80
UTIL_FormatFunction · 0.70

Tested by

no test coverage detected