Removed error when optional ext dep is missing (bug 5112, r=fyren).

This commit is contained in:
Nicholas Hastings 2011-10-11 22:51:24 -04:00
parent 67163e14e6
commit 776889cfbb
3 changed files with 16 additions and 5 deletions

View File

@ -372,6 +372,11 @@ const char *CExtension::GetFilename()
return m_RealFile.c_str(); return m_RealFile.c_str();
} }
const char *CExtension::GetPath() const
{
return m_Path.c_str();
}
IdentityToken_t *CExtension::GetIdentity() IdentityToken_t *CExtension::GetIdentity()
{ {
return m_pIdentToken; return m_pIdentToken;
@ -580,7 +585,7 @@ void CExtensionManager::TryAutoload()
} }
} }
IExtension *CExtensionManager::LoadAutoExtension(const char *path) IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOnMissing)
{ {
/* Remove platform extension if it's there. Compat hack. */ /* Remove platform extension if it's there. Compat hack. */
const char *ext = g_LibSys.GetFileExtension(path); const char *ext = g_LibSys.GetFileExtension(path);
@ -589,7 +594,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path)
char path2[PLATFORM_MAX_PATH]; char path2[PLATFORM_MAX_PATH];
UTIL_Format(path2, sizeof(path2), "%s", path); UTIL_Format(path2, sizeof(path2), "%s", path);
path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
return LoadAutoExtension(path2); return LoadAutoExtension(path2, bErrorOnMissing);
} }
IExtension *pAlready; IExtension *pAlready;
@ -607,8 +612,12 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path)
m_Libs.push_back(p); m_Libs.push_back(p);
if (!p->Load(error, sizeof(error)) || !p->IsLoaded()) if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
{
if (bErrorOnMissing || g_LibSys.IsPathFile(p->GetPath()))
{ {
g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error); g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
}
p->SetError(error); p->SetError(error);
} }

View File

@ -66,6 +66,7 @@ public:
public: //IExtension public: //IExtension
IExtensionInterface *GetAPI(); IExtensionInterface *GetAPI();
const char *GetFilename(); const char *GetFilename();
const char *GetPath() const;
IdentityToken_t *GetIdentity(); IdentityToken_t *GetIdentity();
ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface); ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface); bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
@ -163,7 +164,7 @@ public: //IPluginsListener
public: //IRootConsoleCommand public: //IRootConsoleCommand
void OnRootConsoleCommand(const char *cmdname, const CCommand &command); void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
public: public:
IExtension *LoadAutoExtension(const char *path); IExtension *LoadAutoExtension(const char *path, bool bErrorOnMissing=true);
void BindDependency(IExtension *pOwner, IfaceInfo *pInfo); void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
void AddInterface(IExtension *pOwner, SMInterface *pInterface); void AddInterface(IExtension *pOwner, SMInterface *pInterface);
void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin); void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin);

View File

@ -1308,7 +1308,8 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass
if (ext->autoload) if (ext->autoload)
{ {
g_LibSys.PathFormat(path, PLATFORM_MAX_PATH, "%s", file); g_LibSys.PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
g_Extensions.LoadAutoExtension(path); bool bErrorOnMissing = ext->required ? true : false;
g_Extensions.LoadAutoExtension(path, bErrorOnMissing);
} }
} }
else if (pass == 2) else if (pass == 2)