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

Method RequireExtensions

core/logic/PluginSys.cpp:1226–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1224}
1225
1226bool CPluginManager::RequireExtensions(CPlugin *pPlugin)
1227{
1228 auto callback = [pPlugin]
1229 (const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool
1230 {
1231 /* Is this required? */
1232 if (ext.required) {
1233 char path[PLATFORM_MAX_PATH];
1234 libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", ext.file);
1235 IExtension *pExt = g_Extensions.FindExtensionByFile(path);
1236 if (!pExt)
1237 pExt = g_Extensions.FindExtensionByName(ext.name);
1238
1239 if (!pExt || !pExt->IsRunning(nullptr, 0)) {
1240 pPlugin->EvictWithError(Plugin_Failed, "Required extension \"%s\" file(\"%s\") not running", ext.name, ext.file);
1241 return false;
1242 }
1243 g_Extensions.BindChildPlugin(pExt, pPlugin);
1244 } else {
1245 char buffer[64];
1246 ke::SafeSprintf(buffer, sizeof(buffer), "__ext_%s_SetNTVOptional", &pubvar->name[6]);
1247
1248 if (IPluginFunction *pFunc = pPlugin->GetBaseContext()->GetFunctionByName(buffer)) {
1249 cell_t res;
1250 if (pFunc->Execute(&res) != SP_ERROR_NONE) {
1251 pPlugin->EvictWithError(Plugin_Failed, "Fatal error during plugin initialization (ext req)");
1252 return false;
1253 }
1254 }
1255 }
1256 return true;
1257 };
1258
1259 return pPlugin->ForEachExtVar(std::move(callback));
1260}
1261
1262CPlugin *CPluginManager::CompileAndPrep(const char *path)
1263{

Callers

nothing calls this directly

Calls 9

PathFormatMethod · 0.80
FindExtensionByFileMethod · 0.80
FindExtensionByNameMethod · 0.80
IsRunningMethod · 0.80
EvictWithErrorMethod · 0.80
BindChildPluginMethod · 0.80
GetBaseContextMethod · 0.80
ForEachExtVarMethod · 0.80
ExecuteMethod · 0.45

Tested by

no test coverage detected