diff --git a/core/ExtensionSys.cpp b/core/ExtensionSys.cpp index 9679d002..f414590b 100644 --- a/core/ExtensionSys.cpp +++ b/core/ExtensionSys.cpp @@ -372,6 +372,11 @@ const char *CExtension::GetFilename() return m_RealFile.c_str(); } +const char *CExtension::GetPath() const +{ + return m_Path.c_str(); +} + IdentityToken_t *CExtension::GetIdentity() { 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. */ const char *ext = g_LibSys.GetFileExtension(path); @@ -589,7 +594,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path) char path2[PLATFORM_MAX_PATH]; UTIL_Format(path2, sizeof(path2), "%s", path); path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; - return LoadAutoExtension(path2); + return LoadAutoExtension(path2, bErrorOnMissing); } IExtension *pAlready; @@ -608,7 +613,11 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path) if (!p->Load(error, sizeof(error)) || !p->IsLoaded()) { - g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error); + if (bErrorOnMissing || g_LibSys.IsPathFile(p->GetPath())) + { + g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error); + } + p->SetError(error); } diff --git a/core/ExtensionSys.h b/core/ExtensionSys.h index a670273c..c1c50744 100644 --- a/core/ExtensionSys.h +++ b/core/ExtensionSys.h @@ -66,6 +66,7 @@ public: public: //IExtension IExtensionInterface *GetAPI(); const char *GetFilename(); + const char *GetPath() const; IdentityToken_t *GetIdentity(); ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface); bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface); @@ -163,7 +164,7 @@ public: //IPluginsListener public: //IRootConsoleCommand void OnRootConsoleCommand(const char *cmdname, const CCommand &command); public: - IExtension *LoadAutoExtension(const char *path); + IExtension *LoadAutoExtension(const char *path, bool bErrorOnMissing=true); void BindDependency(IExtension *pOwner, IfaceInfo *pInfo); void AddInterface(IExtension *pOwner, SMInterface *pInterface); void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin); diff --git a/core/PluginSys.cpp b/core/PluginSys.cpp index c5c2551e..9fb0b23b 100644 --- a/core/PluginSys.cpp +++ b/core/PluginSys.cpp @@ -1308,7 +1308,8 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass if (ext->autoload) { 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)