Initial import of convar stuff

1) Natives to create, find, set, and get convars
2) "cvars" option added to sm menu
3) Some internal additions to CPlugin to store a convar list
Still some things left to do...

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40463
This commit is contained in:
Scott Ehlert
2007-02-08 21:41:28 +00:00
parent 471da79fa5
commit fdba3e1f66
13 changed files with 1306 additions and 4 deletions
+16 -1
View File
@@ -504,11 +504,26 @@ size_t CPlugin::GetLangFileCount() const
return m_PhraseFiles.size();
}
unsigned int CPlugin::GetFileByIndex(unsigned int index) const
unsigned int CPlugin::GetLangFileByIndex(unsigned int index) const
{
return m_PhraseFiles.at(index);
}
void CPlugin::AddConVar(ConVar *convar)
{
m_ConVarList.push_back(convar);
}
size_t CPlugin::GetConVarCount() const
{
return m_ConVarList.size();
}
ConVar *CPlugin::GetConVarByIndex(size_t index) const
{
return m_ConVarList.at(index);
}
/*******************
* PLUGIN ITERATOR *
*******************/
+26 -1
View File
@@ -28,6 +28,7 @@
#include "sm_trie.h"
#include "sourcemod.h"
#include <IRootConsoleMenu.h>
#include "convar_sm.h"
using namespace SourceHook;
@@ -191,7 +192,7 @@ public:
/**
* Get language file index based on the vector index.
*/
unsigned int GetFileByIndex(unsigned int index) const;
unsigned int GetLangFileByIndex(unsigned int index) const;
public:
/**
* Returns the modification time during last plugin load.
@@ -207,6 +208,21 @@ public:
* Returns true if the plugin was running, but is now invalid.
*/
bool WasRunning();
/**
* Adds a convar to the plugin's list
*/
void AddConVar(ConVar *convar);
/**
* Get convar count for this plugin.
*/
size_t GetConVarCount() const;
/**
* Get convar pointer based on the vector index.
*/
ConVar *GetConVarByIndex(size_t index) const;
protected:
void UpdateInfo();
void SetTimeStamp(time_t t);
@@ -224,6 +240,7 @@ private:
Handle_t m_handle;
bool m_WasRunning;
CVector<unsigned int> m_PhraseFiles;
CVector<ConVar *> m_ConVarList;
};
class CPluginManager :
@@ -316,6 +333,14 @@ public:
*/
CPlugin *GetPluginByOrder(int num);
/**
* Internal version of FindPluginByContext()
*/
inline CPlugin *GetPluginByCtx(const sp_context_t *ctx)
{
return reinterpret_cast<CPlugin *>(ctx->user[SM_CONTEXTVAR_MYSELF]);
}
/**
* Gets status text for a status code
*/