Skip to content

Commit

Permalink
Simplify pass 2 of LoadOrRequireExtensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvander committed Sep 21, 2015
1 parent 23290b3 commit e559e6f
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions core/logic/PluginSys.cpp
Expand Up @@ -1160,42 +1160,25 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass
}
} else if (pass == 2) {
/* Is this required? */
if (ext->required)
{
if (ext->required) {
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
IExtension *pExt;
if ((pExt = g_Extensions.FindExtensionByFile(path)) == NULL)
{
IExtension *pExt = g_Extensions.FindExtensionByFile(path);
if (!pExt)
pExt = g_Extensions.FindExtensionByName(name);
}
/* :TODO: should we bind to unloaded extensions?
* Currently the extension manager will ignore this.
*/
if (!pExt || !pExt->IsRunning(NULL, 0))
{
if (error)
{
ke::SafeSprintf(error, maxlength, "Required extension \"%s\" file(\"%s\") not running", name, file);
}

if (!pExt || !pExt->IsRunning(nullptr, 0)) {
ke::SafeSprintf(error, maxlength, "Required extension \"%s\" file(\"%s\") not running", name, file);
return false;
}
else
{
g_Extensions.BindChildPlugin(pExt, pPlugin);
}
}
else
{
IPluginFunction *pFunc;
g_Extensions.BindChildPlugin(pExt, pPlugin);
} else {
char buffer[64];
ke::SafeSprintf(buffer, sizeof(buffer), "__ext_%s_SetNTVOptional", &pubvar->name[6]);

if ((pFunc = pBase->GetFunctionByName(buffer)) != NULL)
{
if (IPluginFunction *pFunc = pBase->GetFunctionByName(buffer)) {
cell_t res;
if (pFunc->Execute(&res) != SP_ERROR_NONE) {
if (error)
ke::SafeSprintf(error, maxlength, "Fatal error during plugin initialization (ext req)");
ke::SafeSprintf(error, maxlength, "Fatal error during plugin initialization (ext req)");
return false;
}
}
Expand Down

0 comments on commit e559e6f

Please sign in to comment.