1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-30 19:52:17 +01:00

IPluginManager's API is now a little more sane (people complained about byref pointers)

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40483
This commit is contained in:
David Anderson 2007-10-08 18:51:51 +00:00
parent b94553edb0
commit 540267578a
3 changed files with 30 additions and 16 deletions

View File

@ -122,13 +122,13 @@ namespace SourceMM
/**
* @brief Returns information about a plugin
*
* @param id Id of plugin
* @param file Pointer to file string by reference
* @param status By reference status of plugin
* @param source By reference source of plugin
* @return True on success, false if not found
* @param id Id of plugin
* @param file Pointer to store filename pointer, or NULL to ignore.
* @param status Pointer to store status, or NULL to ignore.
* @param source Pointer to store source, or NULL to ignore.
* @return True on success, false if not found
*/
virtual bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source) =0;
virtual bool Query(PluginId id, const char **file, Pl_Status *status, PluginId *source) =0;
/**
* @brief Checks another plugin's QueryRunning() status.
@ -144,10 +144,10 @@ namespace SourceMM
* @brief Returns the handle of a plugin (OS dependent meaning)
*
* @param id Id of plugin
* @param handle By reference handle of plugin, if any
* @param handle Pointer to store handle pointer, or NULL to ignore.
* @return True if plugin id is valid, false otherwise
*/
virtual bool QueryHandle(PluginId id, void *&handle) =0;
virtual bool QueryHandle(PluginId id, void **handle) =0;
};
}

View File

@ -623,7 +623,7 @@ bool CPluginManager::UnloadAll()
return status;
}
bool CPluginManager::Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source)
bool CPluginManager::Query(PluginId id, const char **file, Pl_Status *status, PluginId *source)
{
CPlugin *pl = FindById(id);
@ -632,9 +632,20 @@ bool CPluginManager::Query(PluginId id, const char *&file, Pl_Status &status, Pl
return false;
}
file = pl->m_File.c_str();
status = pl->m_Status;
source = pl->m_Source;
if (file != NULL)
{
*file = pl->m_File.c_str();
}
if (status != NULL)
{
*status = pl->m_Status;
}
if (source != NULL)
{
*source = pl->m_Source;
}
return true;
}
@ -655,7 +666,7 @@ bool CPluginManager::QueryRunning(PluginId id, char *error, size_t maxlength)
return pl->m_API->QueryRunning(error, maxlength);
}
bool CPluginManager::QueryHandle(PluginId id, void *&handle)
bool CPluginManager::QueryHandle(PluginId id, void **handle)
{
CPlugin *pl = FindById(id);
@ -664,7 +675,10 @@ bool CPluginManager::QueryHandle(PluginId id, void *&handle)
return false;
}
handle = static_cast<void *>(pl->m_Lib);
if (handle)
{
*handle = static_cast<void *>(pl->m_Lib);
}
return true;
}

View File

@ -104,9 +104,9 @@ public:
bool UnloadAll();
void SetAlias(const char *alias, const char *value);
public:
bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source);
bool Query(PluginId id, const char **file, Pl_Status *status, PluginId *source);
bool QueryRunning(PluginId id, char *error, size_t maxlength);
bool QueryHandle(PluginId id, void *&handle);
bool QueryHandle(PluginId id, void **handle);
void AddPluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
void AddPluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);