sourcemm/CPlugin.cpp
changeset 29 10e6dc40505e
parent 19 774dd1f7210f
child 51 7985801b5b42
     1.1 --- a/sourcemm/CPlugin.cpp	Tue Apr 19 06:29:27 2005 +0000
     1.2 +++ b/sourcemm/CPlugin.cpp	Tue Apr 19 07:41:07 2005 +0000
     1.3 @@ -142,6 +142,49 @@
     1.4  	return _Unload(pl, force, error, maxlen);
     1.5  }
     1.6  
     1.7 +bool CPluginManager::Retry(PluginId id, char *error, size_t len)
     1.8 +{
     1.9 +	PluginIter i;
    1.10 +	char buffer[64];
    1.11 +	for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
    1.12 +	{
    1.13 +		if ( (*i) && (*i)->m_Id == id )
    1.14 +		{
    1.15 +			if ( (*i)->m_Status >= Pl_Paused)
    1.16 +			{
    1.17 +				snprintf(error, len, "Plugin %d is already running.", id);
    1.18 +				return false;
    1.19 +			}
    1.20 +			CPlugin *pl = _Load((*i)->m_File.c_str(), Pl_Console, error, len);
    1.21 +			if (!pl)
    1.22 +				return false;
    1.23 +			if (pl->m_Status >= Pl_Paused)
    1.24 +			{
    1.25 +				//Now it gets crazy... unload the original copy.
    1.26 +				_Unload( (*i), true, buffer, sizeof(buffer)-1 );
    1.27 +				
    1.28 +				//Set the new copy's id
    1.29 +				pl->m_Id = id;
    1.30 +
    1.31 +				//We just wasted an id... reclaim it
    1.32 +				m_LastId--;
    1.33 +				
    1.34 +				return true;
    1.35 +			} else {
    1.36 +				//don't really care about the buffer here
    1.37 +				_Unload(pl, true, buffer, sizeof(buffer)-1);
    1.38 +
    1.39 +				//We just wasted an id... reclaim it
    1.40 +				m_LastId--;
    1.41 +				return false;
    1.42 +			}
    1.43 +		}
    1.44 +	}
    1.45 +
    1.46 +	snprintf(error, len, "Plugin %d not found,", id);
    1.47 +	return false;
    1.48 +}
    1.49 +
    1.50  CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
    1.51  {
    1.52  	FILE *fp;