mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-19 08:52:34 +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:
parent
3122e9a843
commit
49c7a8c7ca
@ -142,6 +142,49 @@ bool CPluginManager::Unload(PluginId id, bool force, char *error, size_t 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)
|
||||
{
|
||||
FILE *fp;
|
||||
|
@ -65,6 +65,16 @@ namespace SourceMM
|
||||
*/
|
||||
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
|
||||
std::list<SourceMM::CPluginManager::CPlugin *>::iterator _begin();
|
||||
std::list<SourceMM::CPluginManager::CPlugin *>::iterator _end();
|
||||
|
@ -36,12 +36,12 @@ enum Pl_Status
|
||||
enum
|
||||
{
|
||||
Pl_BadLoad=0,
|
||||
Pl_Console,
|
||||
Pl_File,
|
||||
Pl_MinId,
|
||||
Pl_Console=-1,
|
||||
Pl_File=-2,
|
||||
Pl_MinId=1,
|
||||
};
|
||||
|
||||
typedef unsigned int PluginId;
|
||||
typedef int PluginId;
|
||||
struct factories;
|
||||
|
||||
class ISmmPluginManager
|
||||
|
@ -32,7 +32,7 @@ struct factories
|
||||
};
|
||||
|
||||
class ISmmAPI;
|
||||
typedef unsigned int PluginId;
|
||||
typedef int PluginId;
|
||||
|
||||
class ISmmPlugin
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
PROJECT_NAME = SourceMM
|
||||
PROJECT_NUMBER = 1.00
|
||||
OUTPUT_DIRECTORY = c:\temp\smm-dox
|
||||
CREATE_SUBDIRS = YES
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
|
@ -301,34 +301,15 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
||||
if (args >= 3)
|
||||
{
|
||||
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];
|
||||
bool already;
|
||||
|
||||
plid = g_PluginMngr.Load(pl->m_File.c_str(), Pl_Console, already, error, sizeof(error)-1);
|
||||
if (plid < Pl_MinId)
|
||||
if (!g_PluginMngr.Retry(id, error, sizeof(error)-1))
|
||||
{
|
||||
Msg("Failed to reload plugin %d: (%s).\n", id, error);
|
||||
Msg("Error reloading plugin: %s\n", error);
|
||||
return;
|
||||
}
|
||||
|
||||
Msg("Plugin %d successfully reloaded as plugin %d.\n", id, plid);
|
||||
Msg("Plugin %d successfully reloaded.\n", id);
|
||||
|
||||
return;
|
||||
} else {
|
||||
@ -350,7 +331,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
||||
Msg(" load - Load a plugin\n");
|
||||
Msg(" pause - Pause a running plugin\n");
|
||||
Msg(" refresh - Reparse plugins file\n");
|
||||
Msg(" retry - Attempt to reload a plugin\n");
|
||||
Msg(" retry - Attempt to reload a plugin\n");
|
||||
Msg(" unload - Unload a loaded plugin\n");
|
||||
Msg(" unpause - Unpause a paused plugin\n");
|
||||
Msg(" version - Version information\n");
|
||||
|
@ -87,7 +87,7 @@
|
||||
AdditionalDependencies="tier0.lib vstdlib.lib"
|
||||
OutputFile="$(OutDir)/server.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="FALSE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user