1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-31 20:52:18 +01:00

Fixed retry command

Fixed ids starting at 3 (changed Pl_MinId)
Doxyfile is no longer subdir based

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4030
This commit is contained in:
David Anderson 2005-04-19 07:41:07 +00:00
parent 3122e9a843
commit 49c7a8c7ca
7 changed files with 64 additions and 30 deletions

View File

@ -142,6 +142,49 @@ bool CPluginManager::Unload(PluginId id, bool force, char *error, size_t maxlen)
return _Unload(pl, force, error, maxlen); return _Unload(pl, force, error, maxlen);
} }
bool CPluginManager::Retry(PluginId id, char *error, size_t len)
{
PluginIter i;
char buffer[64];
for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
{
if ( (*i) && (*i)->m_Id == id )
{
if ( (*i)->m_Status >= Pl_Paused)
{
snprintf(error, len, "Plugin %d is already running.", id);
return false;
}
CPlugin *pl = _Load((*i)->m_File.c_str(), Pl_Console, error, len);
if (!pl)
return false;
if (pl->m_Status >= Pl_Paused)
{
//Now it gets crazy... unload the original copy.
_Unload( (*i), true, buffer, sizeof(buffer)-1 );
//Set the new copy's id
pl->m_Id = id;
//We just wasted an id... reclaim it
m_LastId--;
return true;
} else {
//don't really care about the buffer here
_Unload(pl, true, buffer, sizeof(buffer)-1);
//We just wasted an id... reclaim it
m_LastId--;
return false;
}
}
}
snprintf(error, len, "Plugin %d not found,", id);
return false;
}
CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen) CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
{ {
FILE *fp; FILE *fp;

View File

@ -65,6 +65,16 @@ namespace SourceMM
*/ */
CPlugin *FindById(PluginId id); CPlugin *FindById(PluginId id);
/**
* @brief Attempts to reload a failed plugin
*
* @param id Id of plugin
* @param error Error message buffer
* @param len Maximum length of buffer
* @return True on success, false otherwise
*/
bool Retry(PluginId id, char *error, size_t len);
//Internal iterators //Internal iterators
std::list<SourceMM::CPluginManager::CPlugin *>::iterator _begin(); std::list<SourceMM::CPluginManager::CPlugin *>::iterator _begin();
std::list<SourceMM::CPluginManager::CPlugin *>::iterator _end(); std::list<SourceMM::CPluginManager::CPlugin *>::iterator _end();

View File

@ -36,12 +36,12 @@ enum Pl_Status
enum enum
{ {
Pl_BadLoad=0, Pl_BadLoad=0,
Pl_Console, Pl_Console=-1,
Pl_File, Pl_File=-2,
Pl_MinId, Pl_MinId=1,
}; };
typedef unsigned int PluginId; typedef int PluginId;
struct factories; struct factories;
class ISmmPluginManager class ISmmPluginManager

View File

@ -32,7 +32,7 @@ struct factories
}; };
class ISmmAPI; class ISmmAPI;
typedef unsigned int PluginId; typedef int PluginId;
class ISmmPlugin class ISmmPlugin
{ {

View File

@ -6,7 +6,7 @@
PROJECT_NAME = SourceMM PROJECT_NAME = SourceMM
PROJECT_NUMBER = 1.00 PROJECT_NUMBER = 1.00
OUTPUT_DIRECTORY = c:\temp\smm-dox OUTPUT_DIRECTORY = c:\temp\smm-dox
CREATE_SUBDIRS = YES CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES USE_WINDOWS_ENCODING = YES
BRIEF_MEMBER_DESC = YES BRIEF_MEMBER_DESC = YES

View File

@ -301,34 +301,15 @@ CON_COMMAND(meta, "Metamod:Source Menu")
if (args >= 3) if (args >= 3)
{ {
int id = atoi(e->Cmd_Argv(2)); int id = atoi(e->Cmd_Argv(2));
SourceMM::CPluginManager::CPlugin *pl;
pl = g_PluginMngr.FindById(id);
if (!pl)
{
Msg("Plugin %d not found.\n", id);
return;
}
if (pl->m_Status >= Pl_Paused)
{
Msg("Plugin %d is already loaded.\n");
return;
}
PluginId plid;
char error[255]; char error[255];
bool already;
plid = g_PluginMngr.Load(pl->m_File.c_str(), Pl_Console, already, error, sizeof(error)-1); if (!g_PluginMngr.Retry(id, error, sizeof(error)-1))
if (plid < Pl_MinId)
{ {
Msg("Failed to reload plugin %d: (%s).\n", id, error); Msg("Error reloading plugin: %s\n", error);
return; return;
} }
Msg("Plugin %d successfully reloaded as plugin %d.\n", id, plid); Msg("Plugin %d successfully reloaded.\n", id);
return; return;
} else { } else {

View File

@ -87,7 +87,7 @@
AdditionalDependencies="tier0.lib vstdlib.lib" AdditionalDependencies="tier0.lib vstdlib.lib"
OutputFile="$(OutDir)/server.dll" OutputFile="$(OutDir)/server.dll"
LinkIncremental="1" LinkIncremental="1"
GenerateDebugInformation="FALSE" GenerateDebugInformation="TRUE"
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"