Dedent a huge block of code.
This commit is contained in:
parent
370710c0ff
commit
2b3da56fb5
@ -1142,70 +1142,69 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass
|
|||||||
for (uint32_t i=0; i<num; i++)
|
for (uint32_t i=0; i<num; i++)
|
||||||
{
|
{
|
||||||
if (pBase->GetPubvarByIndex(i, &pubvar) != SP_ERROR_NONE)
|
if (pBase->GetPubvarByIndex(i, &pubvar) != SP_ERROR_NONE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strncmp(pubvar->name, "__ext_", 6) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ext = (_ext *)pubvar->offs;
|
||||||
|
if (pBase->LocalToString(ext->file, &file) != SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(pubvar->name, "__ext_", 6) == 0)
|
if (pBase->LocalToString(ext->name, &name) != SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
ext = (_ext *)pubvar->offs;
|
continue;
|
||||||
if (pBase->LocalToString(ext->file, &file) != SP_ERROR_NONE)
|
}
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
/* Attempt to auto-load if necessary */
|
||||||
|
if (ext->autoload)
|
||||||
{
|
{
|
||||||
continue;
|
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
|
||||||
|
bool bErrorOnMissing = ext->required ? true : false;
|
||||||
|
g_Extensions.LoadAutoExtension(path, bErrorOnMissing);
|
||||||
}
|
}
|
||||||
if (pBase->LocalToString(ext->name, &name) != SP_ERROR_NONE)
|
}
|
||||||
|
else if (pass == 2)
|
||||||
|
{
|
||||||
|
/* Is this required? */
|
||||||
|
if (ext->required)
|
||||||
{
|
{
|
||||||
continue;
|
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
|
||||||
}
|
if ((pExt = g_Extensions.FindExtensionByFile(path)) == NULL)
|
||||||
if (pass == 1)
|
|
||||||
{
|
|
||||||
/* Attempt to auto-load if necessary */
|
|
||||||
if (ext->autoload)
|
|
||||||
{
|
{
|
||||||
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
|
pExt = g_Extensions.FindExtensionByName(name);
|
||||||
bool bErrorOnMissing = ext->required ? true : false;
|
|
||||||
g_Extensions.LoadAutoExtension(path, bErrorOnMissing);
|
|
||||||
}
|
}
|
||||||
}
|
/* :TODO: should we bind to unloaded extensions?
|
||||||
else if (pass == 2)
|
* Currently the extension manager will ignore this.
|
||||||
{
|
*/
|
||||||
/* Is this required? */
|
if (!pExt || !pExt->IsRunning(NULL, 0))
|
||||||
if (ext->required)
|
|
||||||
{
|
{
|
||||||
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
|
if (error)
|
||||||
if ((pExt = g_Extensions.FindExtensionByFile(path)) == NULL)
|
|
||||||
{
|
{
|
||||||
pExt = g_Extensions.FindExtensionByName(name);
|
ke::SafeSprintf(error, maxlength, "Required extension \"%s\" file(\"%s\") not running", name, file);
|
||||||
}
|
|
||||||
/* :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);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_Extensions.BindChildPlugin(pExt, pPlugin);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IPluginFunction *pFunc;
|
g_Extensions.BindChildPlugin(pExt, pPlugin);
|
||||||
char buffer[64];
|
}
|
||||||
ke::SafeSprintf(buffer, sizeof(buffer), "__ext_%s_SetNTVOptional", &pubvar->name[6]);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IPluginFunction *pFunc;
|
||||||
|
char buffer[64];
|
||||||
|
ke::SafeSprintf(buffer, sizeof(buffer), "__ext_%s_SetNTVOptional", &pubvar->name[6]);
|
||||||
|
|
||||||
if ((pFunc = pBase->GetFunctionByName(buffer)) != NULL)
|
if ((pFunc = pBase->GetFunctionByName(buffer)) != NULL)
|
||||||
{
|
{
|
||||||
cell_t res;
|
cell_t res;
|
||||||
if (pFunc->Execute(&res) != SP_ERROR_NONE) {
|
if (pFunc->Execute(&res) != SP_ERROR_NONE) {
|
||||||
if (error)
|
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;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user