1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/sourcemm/metamod_plugins.cpp Thu Oct 04 20:15:25 2007 +0000
1.3 @@ -0,0 +1,747 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * ======================================================
1.7 + * Metamod:Source
1.8 + * Copyright (C) 2004-2007 AlliedModders LLC and authors.
1.9 + * All rights reserved.
1.10 + * ======================================================
1.11 + *
1.12 + * This software is provided 'as-is', without any express or implied warranty.
1.13 + * In no event will the authors be held liable for any damages arising from
1.14 + * the use of this software.
1.15 + *
1.16 + * Permission is granted to anyone to use this software for any purpose,
1.17 + * including commercial applications, and to alter it and redistribute it
1.18 + * freely, subject to the following restrictions:
1.19 + *
1.20 + * 1. The origin of this software must not be misrepresented; you must not
1.21 + * claim that you wrote the original software. If you use this software in a
1.22 + * product, an acknowledgment in the product documentation would be
1.23 + * appreciated but is not required.
1.24 + * 2. Altered source versions must be plainly marked as such, and must not be
1.25 + * misrepresented as being the original software.
1.26 + * 3. This notice may not be removed or altered from any source distribution.
1.27 + *
1.28 + * Version: $Id$
1.29 + */
1.30 +
1.31 +#if defined _DEBUG
1.32 +#define DEBUG2
1.33 +#undef _DEBUG
1.34 +#endif
1.35 +#include "metamod.h"
1.36 +#include "metamod_plugins.h"
1.37 +#include "metamod_util.h"
1.38 +#if defined DEBUG2
1.39 +#undef DEBUG2
1.40 +#define _DEBUG
1.41 +#endif
1.42 +
1.43 +/**
1.44 + * @brief Implements functions from CPlugin.h
1.45 + * @file CPlugin.cpp
1.46 + */
1.47 +
1.48 +using namespace SourceMM;
1.49 +
1.50 +#define ITER_PLEVENT(evn, plid) \
1.51 + CPluginManager::CPlugin *_Xpl; \
1.52 + SourceHook::List<IMetamodListener *>::iterator event; \
1.53 + IMetamodListener *api; \
1.54 + for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++) { \
1.55 + _Xpl = (*iter); \
1.56 + if (_Xpl->m_Id == plid) \
1.57 + continue; \
1.58 + for (event=_Xpl->m_Events.begin(); event!=_Xpl->m_Events.end(); event++) { \
1.59 + api = (*event); \
1.60 + api->evn(plid); \
1.61 + } \
1.62 + }
1.63 +
1.64 +CPluginManager g_PluginMngr;
1.65 +
1.66 +CPluginManager::CPluginManager()
1.67 +{
1.68 + m_LastId = Pl_MinId;
1.69 + m_AllLoaded = false;
1.70 +}
1.71 +
1.72 +CPluginManager::~CPluginManager()
1.73 +{
1.74 + SourceHook::List<CNameAlias *>::iterator iter;
1.75 +
1.76 + for (iter = m_Aliases.begin(); iter != m_Aliases.end(); iter++)
1.77 + {
1.78 + delete (*iter);
1.79 + }
1.80 +
1.81 + m_Aliases.clear();
1.82 +}
1.83 +
1.84 +const char *CPluginManager::LookupAlias(const char *alias)
1.85 +{
1.86 + SourceHook::List<CNameAlias *>::iterator iter;
1.87 + CNameAlias *p;
1.88 +
1.89 + for (iter = m_Aliases.begin(); iter != m_Aliases.end(); iter++)
1.90 + {
1.91 + p = (*iter);
1.92 + if (p->alias.compare(alias) == 0)
1.93 + {
1.94 + return p->value.c_str();
1.95 + }
1.96 + }
1.97 +
1.98 + return NULL;
1.99 +}
1.100 +
1.101 +SourceHook::List<SourceMM::CNameAlias *>::iterator CPluginManager::_alias_begin()
1.102 +{
1.103 + return m_Aliases.begin();
1.104 +}
1.105 +
1.106 +SourceHook::List<SourceMM::CNameAlias *>::iterator CPluginManager::_alias_end()
1.107 +{
1.108 + return m_Aliases.end();
1.109 +}
1.110 +
1.111 +void CPluginManager::SetAlias(const char *alias, const char *value)
1.112 +{
1.113 + SourceHook::List<CNameAlias *>::iterator iter;
1.114 + CNameAlias *p;
1.115 +
1.116 + for (iter = m_Aliases.begin(); iter != m_Aliases.end(); iter++)
1.117 + {
1.118 + p = (*iter);
1.119 + if (p->alias.compare(alias) == 0)
1.120 + {
1.121 + if (value[0] == '\0')
1.122 + {
1.123 + iter = m_Aliases.erase(iter);
1.124 + return;
1.125 + }
1.126 + else
1.127 + {
1.128 + p->value.assign(value);
1.129 + return;
1.130 + }
1.131 + }
1.132 + }
1.133 +
1.134 + if (value[0] != '\0')
1.135 + {
1.136 + p = new CNameAlias;
1.137 +
1.138 + p->alias.assign(alias);
1.139 + p->value.assign(value);
1.140 +
1.141 + m_Aliases.push_back(p);
1.142 + }
1.143 +}
1.144 +
1.145 +CPluginManager::CPlugin::CPlugin() : m_Id(0), m_Source(0), m_API(NULL), m_Lib(NULL)
1.146 +{
1.147 +
1.148 +}
1.149 +
1.150 +PluginId CPluginManager::Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen)
1.151 +{
1.152 + already = false;
1.153 + //Check if we're about to reload an old plugin
1.154 + PluginIter i = m_Plugins.begin();
1.155 + while (i != m_Plugins.end())
1.156 + {
1.157 + if ((*i) && UTIL_PathCmp(file, (*i)->m_File.c_str()))
1.158 + {
1.159 + if ((*i)->m_Status < Pl_Paused)
1.160 + {
1.161 + //Attempt to load the plugin again
1.162 + already = true;
1.163 + i = m_Plugins.erase(i);
1.164 + continue;
1.165 + }
1.166 + else
1.167 + {
1.168 + //No need to load it
1.169 + already = true;
1.170 + return (*i)->m_Id;
1.171 + }
1.172 + }
1.173 + i++;
1.174 + }
1.175 +
1.176 + CPlugin *pl = _Load(file, source, error, maxlen);
1.177 +
1.178 + if (!pl)
1.179 + {
1.180 + return Pl_BadLoad;
1.181 + }
1.182 +
1.183 + ITER_PLEVENT(OnPluginLoad, pl->m_Id);
1.184 +
1.185 + return pl->m_Id;
1.186 +}
1.187 +
1.188 +CPluginManager::CPlugin *CPluginManager::FindById(PluginId id)
1.189 +{
1.190 + PluginIter i;
1.191 +
1.192 + for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
1.193 + {
1.194 + if ( (*i)->m_Id == id )\
1.195 + {
1.196 + return (*i);
1.197 + }
1.198 + }
1.199 +
1.200 + return NULL;
1.201 +}
1.202 +
1.203 +void CPluginManager::SetAllLoaded()
1.204 +{
1.205 + m_AllLoaded = true;
1.206 + PluginIter i;
1.207 +
1.208 + for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
1.209 + {
1.210 + if ( (*i) && (*i)->m_Status == Pl_Running && (*i)->m_API )
1.211 + {
1.212 + //API 4 is when we added this callback
1.213 + //Min version is now 5, so we ignore this check
1.214 + //if ( (*i)->m_API->GetApiVersion() >= 004 )
1.215 + (*i)->m_API->AllPluginsLoaded();
1.216 + }
1.217 + }
1.218 +}
1.219 +
1.220 +bool CPluginManager::Pause(PluginId id, char *error, size_t maxlen)
1.221 +{
1.222 + CPlugin *pl = FindById(id);
1.223 +
1.224 + if (!pl)
1.225 + {
1.226 + UTIL_Format(error, maxlen, "Plugin id not found");
1.227 + return false;
1.228 + }
1.229 +
1.230 + bool ret;
1.231 +
1.232 + if ((ret=_Pause(pl, error, maxlen)) == true)
1.233 + {
1.234 + ITER_PLEVENT(OnPluginPause, pl->m_Id);
1.235 + }
1.236 +
1.237 + return ret;
1.238 +}
1.239 +
1.240 +bool CPluginManager::Unpause(PluginId id, char *error, size_t maxlen)
1.241 +{
1.242 + CPlugin *pl = FindById(id);
1.243 +
1.244 + if (!pl)
1.245 + {
1.246 + UTIL_Format(error, maxlen, "Plugin id not found");
1.247 + return false;
1.248 + }
1.249 +
1.250 + bool ret;
1.251 +
1.252 + if ( (ret=_Unpause(pl, error, maxlen)) == true )
1.253 + {
1.254 + ITER_PLEVENT(OnPluginUnpause, pl->m_Id);
1.255 + }
1.256 +
1.257 + return ret;
1.258 +}
1.259 +
1.260 +bool CPluginManager::Unload(PluginId id, bool force, char *error, size_t maxlen)
1.261 +{
1.262 + CPlugin *pl = FindById(id);
1.263 +
1.264 + if (!pl)
1.265 + {
1.266 + UTIL_Format(error, maxlen, "Plugin %d not found", id);
1.267 + return false;
1.268 + }
1.269 +
1.270 + bool ret;
1.271 + PluginId old_id = pl->m_Id;
1.272 + if ( (ret=_Unload(pl, force, error, maxlen)) == true )
1.273 + {
1.274 + ITER_PLEVENT(OnPluginUnload, old_id);
1.275 + }
1.276 +
1.277 + return ret;
1.278 +}
1.279 +
1.280 +bool CPluginManager::Retry(PluginId id, char *error, size_t len)
1.281 +{
1.282 + PluginIter i;
1.283 + char buffer[64];
1.284 + for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
1.285 + {
1.286 + if ( (*i) && (*i)->m_Id == id )
1.287 + {
1.288 + if ( (*i)->m_Status >= Pl_Paused)
1.289 + {
1.290 + UTIL_Format(error, len, "Plugin %d is already running.", id);
1.291 + return false;
1.292 + }
1.293 + CPlugin *pl = _Load((*i)->m_File.c_str(), Pl_Console, error, len);
1.294 + if (!pl)
1.295 + {
1.296 + return false;
1.297 + }
1.298 + if (pl->m_Status >= Pl_Paused)
1.299 + {
1.300 + //Now it gets crazy... unload the original copy.
1.301 + _Unload( (*i), true, buffer, sizeof(buffer)-1 );
1.302 +
1.303 + //Set the new copy's id
1.304 + pl->m_Id = id;
1.305 +
1.306 + //We just wasted an id... reclaim it
1.307 + m_LastId--;
1.308 +
1.309 + return true;
1.310 + }
1.311 + else
1.312 + {
1.313 + //don't really care about the buffer here
1.314 + _Unload(pl, true, buffer, sizeof(buffer)-1);
1.315 +
1.316 + //We just wasted an id... reclaim it
1.317 + m_LastId--;
1.318 + return false;
1.319 + }
1.320 + }
1.321 + }
1.322 +
1.323 + UTIL_Format(error, len, "Plugin %d not found,", id);
1.324 + return false;
1.325 +}
1.326 +
1.327 +CPluginManager::CPlugin *CPluginManager::FindByAPI(ISmmPlugin *api)
1.328 +{
1.329 + PluginIter i;
1.330 +
1.331 + //don't find bad plugins!
1.332 + if (!api)
1.333 + {
1.334 + return NULL;
1.335 + }
1.336 +
1.337 + for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
1.338 + {
1.339 + if ((*i)->m_API == api)
1.340 + {
1.341 + return (*i);
1.342 + }
1.343 + }
1.344 +
1.345 + return NULL;
1.346 +}
1.347 +
1.348 +int CPluginManager::GetPluginCount()
1.349 +{
1.350 + return (int)m_Plugins.size();
1.351 +}
1.352 +
1.353 +const char *CPluginManager::GetStatusText(CPlugin *pl)
1.354 +{
1.355 + switch (pl->m_Status)
1.356 + {
1.357 + case Pl_NotFound:
1.358 + return "NOFILE";
1.359 + case Pl_Error:
1.360 + return "ERROR";
1.361 + case Pl_Refused:
1.362 + return "FAILED";
1.363 + case Pl_Paused:
1.364 + return "PAUSED";
1.365 + case Pl_Running:
1.366 + {
1.367 + if (pl->m_API && pl->m_API->QueryRunning(NULL, 0))
1.368 + {
1.369 + return "STOPPED";
1.370 + } else {
1.371 + return "RUNNING";
1.372 + }
1.373 + }
1.374 + default:
1.375 + return "-";
1.376 + }
1.377 +}
1.378 +
1.379 +CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
1.380 +{
1.381 + FILE *fp;
1.382 + CPlugin *pl;
1.383 +
1.384 + pl = new CPlugin();
1.385 + *error = '\0';
1.386 +
1.387 + //Add plugin to list
1.388 + pl->m_Id = m_LastId;
1.389 + pl->m_File.assign(file);
1.390 + m_Plugins.push_back(pl);
1.391 + m_LastId++;
1.392 +
1.393 + //Check if the file even exists
1.394 + fp = fopen(file, "r");
1.395 + if (!fp)
1.396 + {
1.397 + if (error)
1.398 + {
1.399 + UTIL_Format(error, maxlen, "File not found: %s", file);
1.400 + }
1.401 + pl->m_Status = Pl_NotFound;
1.402 + }
1.403 +
1.404 + if (fp)
1.405 + {
1.406 + fclose(fp);
1.407 + fp = NULL;
1.408 +
1.409 + //Load the file
1.410 + pl->m_Lib = dlmount(file);
1.411 + if (!pl->m_Lib)
1.412 + {
1.413 + if (error)
1.414 + {
1.415 + UTIL_Format(error, maxlen, "%s", dlerror());
1.416 + }
1.417 + pl->m_Status = Pl_Error;
1.418 + }
1.419 + else
1.420 + {
1.421 + CreateInterfaceFn pfn = (CreateInterfaceFn)(dlsym(pl->m_Lib, PL_EXPOSURE_C));
1.422 + if (!pfn)
1.423 + {
1.424 + if (error)
1.425 + {
1.426 + UTIL_Format(error, maxlen, "Function %s not found", PL_EXPOSURE_C);
1.427 + }
1.428 + pl->m_Status = Pl_Error;
1.429 + }
1.430 + else
1.431 + {
1.432 + pl->m_API = static_cast<ISmmPlugin *>((pfn)(PLAPI_NAME, NULL));
1.433 + if (!pl->m_API)
1.434 + {
1.435 + if (error)
1.436 + {
1.437 + UTIL_Format(error, maxlen, "Failed to get API");
1.438 + }
1.439 + pl->m_Status = Pl_Error;
1.440 + }
1.441 + else
1.442 + {
1.443 + int api = pl->m_API->GetApiVersion();
1.444 + if (api < PLAPI_MIN_VERSION)
1.445 + {
1.446 + if (error)
1.447 + {
1.448 + UTIL_Format(error, maxlen, "Plugin API %d is out of date with required minimum (%d)", api, PLAPI_MIN_VERSION);
1.449 + }
1.450 + pl->m_Status = Pl_Error;
1.451 + }
1.452 + else if (api > PLAPI_VERSION)
1.453 + {
1.454 + if (error)
1.455 + {
1.456 + UTIL_Format(error, maxlen, "Plugin API %d is newer than internal version (%d)", api, PLAPI_VERSION);
1.457 + }
1.458 + pl->m_Status = Pl_Error;
1.459 + }
1.460 + else
1.461 + {
1.462 + if (pl->m_API->Load(pl->m_Id, &g_Metamod, error, maxlen, m_AllLoaded))
1.463 + {
1.464 + pl->m_Status = Pl_Running;
1.465 + if (m_AllLoaded)
1.466 + {
1.467 + //API 4 is when we added this callback
1.468 + //Removing this code as the min version is now 5
1.469 + //if (pl->m_API->GetApiVersion() >= 4)
1.470 + pl->m_API->AllPluginsLoaded();
1.471 + }
1.472 + }
1.473 + else
1.474 + {
1.475 + pl->m_Status = Pl_Refused;
1.476 + }
1.477 + }
1.478 + }
1.479 + }
1.480 + }
1.481 + }
1.482 +
1.483 + if (pl->m_Lib && (pl->m_Status < Pl_Paused))
1.484 + {
1.485 + pl->m_Events.clear();
1.486 + g_SourceHook.UnloadPlugin(pl->m_Id);
1.487 + UnregAllConCmds(pl);
1.488 +
1.489 + dlclose(pl->m_Lib);
1.490 + pl->m_Lib = NULL;
1.491 + pl->m_API = NULL;
1.492 + }
1.493 +
1.494 + return pl;
1.495 +}
1.496 +
1.497 +bool CPluginManager::_Unload(CPluginManager::CPlugin *pl, bool force, char *error, size_t maxlen)
1.498 +{
1.499 + if (error)
1.500 + {
1.501 + *error = '\0';
1.502 + }
1.503 +
1.504 + if (pl->m_API && pl->m_Lib)
1.505 + {
1.506 + //Note, we'll always tell the plugin it will be unloading...
1.507 + if (pl->m_API->Unload(error, maxlen) || force)
1.508 + {
1.509 + //Make sure to detach it from sourcehook!
1.510 + g_SourceHook.UnloadPlugin(pl->m_Id);
1.511 +
1.512 + pl->m_Events.clear();
1.513 +
1.514 + UnregAllConCmds(pl);
1.515 +
1.516 + //Clean up the DLL
1.517 + dlclose(pl->m_Lib);
1.518 + pl->m_Lib = NULL;
1.519 + pl->m_API = NULL;
1.520 +
1.521 + //Remove the plugin from the list
1.522 + PluginIter i;
1.523 + for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
1.524 + {
1.525 + if ( (*i)->m_Id == pl->m_Id )
1.526 + {
1.527 + i = m_Plugins.erase(i);
1.528 + break;
1.529 + }
1.530 + }
1.531 + //Free its memory
1.532 + delete pl;
1.533 +
1.534 + return true;
1.535 + }
1.536 + } else {
1.537 + //The plugin is not valid, and let's just remove it from the list anyway
1.538 + PluginIter i;
1.539 + for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
1.540 + {
1.541 + if ( (*i)->m_Id == pl->m_Id )
1.542 + {
1.543 + i = m_Plugins.erase(i);
1.544 + break;
1.545 + }
1.546 + }
1.547 + delete pl;
1.548 +
1.549 + return true;
1.550 + }
1.551 +
1.552 + return false;
1.553 +}
1.554 +
1.555 +bool CPluginManager::_Pause(CPluginManager::CPlugin *pl, char *error, size_t maxlen)
1.556 +{
1.557 + if (error)
1.558 + {
1.559 + *error = '\0';
1.560 + }
1.561 +
1.562 + if (pl->m_Status != Pl_Running || !pl->m_API)
1.563 + {
1.564 + if (error)
1.565 + {
1.566 + UTIL_Format(error, maxlen, "Plugin cannot be paused");
1.567 + }
1.568 + }
1.569 + else
1.570 + {
1.571 + if (pl->m_API->Pause(error, maxlen))
1.572 + {
1.573 + g_SourceHook.PausePlugin(pl->m_Id);
1.574 + pl->m_Status = Pl_Paused;
1.575 +
1.576 + return true;
1.577 + }
1.578 + }
1.579 +
1.580 + return false;
1.581 +}
1.582 +
1.583 +bool CPluginManager::_Unpause(CPluginManager::CPlugin *pl, char *error, size_t maxlen)
1.584 +{
1.585 + if (error)
1.586 + {
1.587 + *error = '\0';
1.588 + }
1.589 +
1.590 + if (pl->m_Status != Pl_Paused || !pl->m_API)
1.591 + {
1.592 + if (error)
1.593 + {
1.594 + UTIL_Format(error, maxlen, "Plugin cannot be unpaused");
1.595 + }
1.596 + }
1.597 + else
1.598 + {
1.599 + if (pl->m_API->Unpause(error, maxlen))
1.600 + {
1.601 + g_SourceHook.UnpausePlugin(pl->m_Id);
1.602 + pl->m_Status = Pl_Running;
1.603 +
1.604 + return true;
1.605 + }
1.606 + }
1.607 +
1.608 + return false;
1.609 +}
1.610 +
1.611 +bool CPluginManager::UnloadAll()
1.612 +{
1.613 + PluginIter i;
1.614 +
1.615 + char error[128];
1.616 + bool status = true;
1.617 +
1.618 + while ((i = m_Plugins.begin()) != m_Plugins.end())
1.619 + {
1.620 + if ( !_Unload( (*i), true, error, sizeof(error)) )
1.621 + {
1.622 + status = false;
1.623 + }
1.624 + }
1.625 +
1.626 + return status;
1.627 +}
1.628 +
1.629 +bool CPluginManager::Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source)
1.630 +{
1.631 + CPlugin *pl = FindById(id);
1.632 +
1.633 + if (!pl)
1.634 + {
1.635 + return false;
1.636 + }
1.637 +
1.638 + file = pl->m_File.c_str();
1.639 + status = pl->m_Status;
1.640 + source = pl->m_Source;
1.641 +
1.642 + return true;
1.643 +}
1.644 +
1.645 +bool CPluginManager::QueryRunning(PluginId id, char *error, size_t maxlength)
1.646 +{
1.647 + CPlugin *pl = FindById(id);
1.648 +
1.649 + if (!pl || !pl->m_API)
1.650 + {
1.651 + if (error)
1.652 + {
1.653 + UTIL_Format(error, maxlength, "Plugin not valid");
1.654 + }
1.655 + return false;
1.656 + }
1.657 +
1.658 + return pl->m_API->QueryRunning(error, maxlength);
1.659 +}
1.660 +
1.661 +bool CPluginManager::QueryHandle(PluginId id, void *&handle)
1.662 +{
1.663 + CPlugin *pl = FindById(id);
1.664 +
1.665 + if (!pl)
1.666 + {
1.667 + return false;
1.668 + }
1.669 +
1.670 + handle = static_cast<void *>(pl->m_Lib);
1.671 +
1.672 + return true;
1.673 +}
1.674 +
1.675 +PluginIter CPluginManager::_begin()
1.676 +{
1.677 + return m_Plugins.begin();
1.678 +}
1.679 +
1.680 +PluginIter CPluginManager::_end()
1.681 +{
1.682 + return m_Plugins.end();
1.683 +}
1.684 +
1.685 +void CPluginManager::AddPluginCvar(ISmmPlugin *api, ConCommandBase *pCvar)
1.686 +{
1.687 + CPlugin *pl = FindByAPI(api);
1.688 +
1.689 + if (!pl)
1.690 + {
1.691 + return;
1.692 + }
1.693 +
1.694 + pl->m_Cvars.push_back(pCvar);
1.695 +}
1.696 +
1.697 +void CPluginManager::AddPluginCmd(ISmmPlugin *api, ConCommandBase *pCmd)
1.698 +{
1.699 + CPlugin *pl = FindByAPI(api);
1.700 +
1.701 + if (!pl)
1.702 + {
1.703 + return;
1.704 + }
1.705 +
1.706 + pl->m_Cmds.push_back(pCmd);
1.707 +}
1.708 +
1.709 +void CPluginManager::RemovePluginCvar(ISmmPlugin *api, ConCommandBase *pCvar)
1.710 +{
1.711 + CPlugin *pl = FindByAPI(api);
1.712 +
1.713 + if (!pl)
1.714 + {
1.715 + return;
1.716 + }
1.717 +
1.718 + pl->m_Cvars.remove(pCvar);
1.719 +}
1.720 +
1.721 +void CPluginManager::RemovePluginCmd(ISmmPlugin *api, ConCommandBase *pCmd)
1.722 +{
1.723 + CPlugin *pl = FindByAPI(api);
1.724 +
1.725 + if (!pl)
1.726 + {
1.727 + return;
1.728 + }
1.729 +
1.730 + pl->m_Cmds.remove(pCmd);
1.731 +}
1.732 +
1.733 +void CPluginManager::UnregAllConCmds(CPlugin *pl)
1.734 +{
1.735 + SourceHook::List<ConCommandBase *>::iterator i;
1.736 +
1.737 + /* :TODO: */
1.738 + for (i=pl->m_Cvars.begin(); i!=pl->m_Cvars.end(); i++)
1.739 + {
1.740 + g_Metamod.UnregisterConCommandBase(pl->m_Id, (*i) );
1.741 + }
1.742 + pl->m_Cvars.clear();
1.743 +
1.744 + for (i=pl->m_Cmds.begin(); i!=pl->m_Cmds.end(); i++)
1.745 + {
1.746 + g_Metamod.UnregisterConCommandBase(pl->m_Id, (*i) );
1.747 + }
1.748 + pl->m_Cmds.clear();
1.749 +}
1.750 +