Only show extensions that failed to load if the extension is required.
This commit is contained in:
parent
89732f7935
commit
51cea0e04e
@ -43,8 +43,9 @@
|
|||||||
CExtensionManager g_Extensions;
|
CExtensionManager g_Extensions;
|
||||||
IdentityType_t g_ExtType;
|
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_pAPI = NULL;
|
||||||
m_pIdentToken = NULL;
|
m_pIdentToken = NULL;
|
||||||
unload_code = 0;
|
unload_code = 0;
|
||||||
@ -62,7 +63,7 @@ CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filena
|
|||||||
m_pAPI = pAPI;
|
m_pAPI = pAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLocalExtension::CLocalExtension(const char *filename)
|
CLocalExtension::CLocalExtension(const char *filename, bool bRequired)
|
||||||
{
|
{
|
||||||
m_PlId = 0;
|
m_PlId = 0;
|
||||||
m_pLib = NULL;
|
m_pLib = NULL;
|
||||||
@ -139,7 +140,7 @@ CLocalExtension::CLocalExtension(const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
Initialize(filename, path);
|
Initialize(filename, path, bRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRemoteExtension::Load(char *error, size_t maxlength)
|
bool CRemoteExtension::Load(char *error, size_t maxlength)
|
||||||
@ -505,6 +506,11 @@ void CExtension::AddLibrary(const char *library)
|
|||||||
m_Libraries.push_back(library);
|
m_Libraries.push_back(library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CExtension::IsRequired()
|
||||||
|
{
|
||||||
|
return m_bRequired;
|
||||||
|
}
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* EXTENSION MANAGER *
|
* EXTENSION MANAGER *
|
||||||
*********************/
|
*********************/
|
||||||
@ -597,7 +603,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn
|
|||||||
}
|
}
|
||||||
|
|
||||||
char error[256];
|
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
|
/* We put us in the list beforehand so extensions that check for each other
|
||||||
* won't recursively load each other.
|
* won't recursively load each other.
|
||||||
@ -959,7 +965,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++)
|
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||||
{
|
{
|
||||||
pExt = (*iter);
|
pExt = (*iter);
|
||||||
if (pExt->IsLoaded())
|
if (pExt->IsLoaded())
|
||||||
@ -977,9 +983,16 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
|||||||
const char *descr = pAPI->GetExtensionDescription();
|
const char *descr = pAPI->GetExtensionDescription();
|
||||||
rootmenu->ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
|
rootmenu->ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else if (pExt->IsRequired())
|
||||||
|
{
|
||||||
rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
|
rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pExt->IsLoaded() || pExt->IsRequired())
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
void AddPlugin(CPlugin *pPlugin);
|
void AddPlugin(CPlugin *pPlugin);
|
||||||
void MarkAllLoaded();
|
void MarkAllLoaded();
|
||||||
void AddLibrary(const char *library);
|
void AddLibrary(const char *library);
|
||||||
|
bool IsRequired();
|
||||||
public:
|
public:
|
||||||
virtual bool Load(char *error, size_t maxlength);
|
virtual bool Load(char *error, size_t maxlength);
|
||||||
virtual bool IsLoaded() =0;
|
virtual bool IsLoaded() =0;
|
||||||
@ -87,7 +88,7 @@ public:
|
|||||||
virtual bool Reload(char *error, size_t maxlength) =0;
|
virtual bool Reload(char *error, size_t maxlength) =0;
|
||||||
virtual bool IsSameFile(const char* file) =0;
|
virtual bool IsSameFile(const char* file) =0;
|
||||||
protected:
|
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);
|
bool PerformAPICheck(char *error, size_t maxlength);
|
||||||
void CreateIdentity();
|
void CreateIdentity();
|
||||||
void DestroyIdentity();
|
void DestroyIdentity();
|
||||||
@ -104,12 +105,13 @@ protected:
|
|||||||
List<String> m_Libraries;
|
List<String> m_Libraries;
|
||||||
unsigned int unload_code;
|
unsigned int unload_code;
|
||||||
bool m_bFullyLoaded;
|
bool m_bFullyLoaded;
|
||||||
|
bool m_bRequired;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CLocalExtension : public CExtension
|
class CLocalExtension : public CExtension
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CLocalExtension(const char *filename);
|
CLocalExtension(const char *filename, bool bRequired = true);
|
||||||
public:
|
public:
|
||||||
bool Load(char *error, size_t maxlength);
|
bool Load(char *error, size_t maxlength);
|
||||||
bool IsLoaded();
|
bool IsLoaded();
|
||||||
|
Loading…
Reference in New Issue
Block a user