From 51cea0e04eab2dae06987ea2f4735e17eaafb7d3 Mon Sep 17 00:00:00 2001 From: Ruben Gonzalez Date: Thu, 30 Nov 2017 12:57:12 -0500 Subject: [PATCH] Only show extensions that failed to load if the extension is required. --- core/logic/ExtensionSys.cpp | 25 +++++++++++++++++++------ core/logic/ExtensionSys.h | 6 ++++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/core/logic/ExtensionSys.cpp b/core/logic/ExtensionSys.cpp index de08d10f..5fba8873 100644 --- a/core/logic/ExtensionSys.cpp +++ b/core/logic/ExtensionSys.cpp @@ -43,8 +43,9 @@ CExtensionManager g_Extensions; IdentityType_t g_ExtType; -void CExtension::Initialize(const char *filename, const char *path) +void CExtension::Initialize(const char *filename, const char *path, bool bRequired) { + m_bRequired = bRequired; m_pAPI = NULL; m_pIdentToken = NULL; unload_code = 0; @@ -62,7 +63,7 @@ CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filena m_pAPI = pAPI; } -CLocalExtension::CLocalExtension(const char *filename) +CLocalExtension::CLocalExtension(const char *filename, bool bRequired) { m_PlId = 0; m_pLib = NULL; @@ -139,7 +140,7 @@ CLocalExtension::CLocalExtension(const char *filename) } found: - Initialize(filename, path); + Initialize(filename, path, bRequired); } bool CRemoteExtension::Load(char *error, size_t maxlength) @@ -505,6 +506,11 @@ void CExtension::AddLibrary(const char *library) m_Libraries.push_back(library); } +bool CExtension::IsRequired() +{ + return m_bRequired; +} + /********************* * EXTENSION MANAGER * *********************/ @@ -597,7 +603,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn } char error[256]; - CExtension *p = new CLocalExtension(path); + CExtension *p = new CLocalExtension(path, bErrorOnMissing); /* We put us in the list beforehand so extensions that check for each other * won't recursively load each other. @@ -959,7 +965,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand break; } } - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++) + for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { pExt = (*iter); if (pExt->IsLoaded()) @@ -977,9 +983,16 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand const char *descr = pAPI->GetExtensionDescription(); rootmenu->ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr); } - } else { + } + else if (pExt->IsRequired()) + { rootmenu->ConsolePrint("[%02d] file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str()); } + + if (pExt->IsLoaded() || pExt->IsRequired()) + { + num++; + } } return; } diff --git a/core/logic/ExtensionSys.h b/core/logic/ExtensionSys.h index be310494..6687057c 100644 --- a/core/logic/ExtensionSys.h +++ b/core/logic/ExtensionSys.h @@ -80,6 +80,7 @@ public: void AddPlugin(CPlugin *pPlugin); void MarkAllLoaded(); void AddLibrary(const char *library); + bool IsRequired(); public: virtual bool Load(char *error, size_t maxlength); virtual bool IsLoaded() =0; @@ -87,7 +88,7 @@ public: virtual bool Reload(char *error, size_t maxlength) =0; virtual bool IsSameFile(const char* file) =0; protected: - void Initialize(const char *filename, const char *path); + void Initialize(const char *filename, const char *path, bool bRequired = true); bool PerformAPICheck(char *error, size_t maxlength); void CreateIdentity(); void DestroyIdentity(); @@ -104,12 +105,13 @@ protected: List m_Libraries; unsigned int unload_code; bool m_bFullyLoaded; + bool m_bRequired; }; class CLocalExtension : public CExtension { public: - CLocalExtension(const char *filename); + CLocalExtension(const char *filename, bool bRequired = true); public: bool Load(char *error, size_t maxlength); bool IsLoaded();