Added experimental code for cvar management
authorDavid Anderson <dvander@alliedmods.net>
Mon May 16 20:15:57 2005 +0000 (2005-05-16)
changeset 64ad98b9f2d80c
parent 63 ee7abd0da4dd
child 65 27c4d32394a6
Added experimental code for cvar management
sourcemm/CSmmAPI.cpp
sourcemm/CSmmAPI.h
sourcemm/ISmmAPI.h
sourcemm/concommands.cpp
sourcemm/concommands.h
sourcemm/sourcemm.h
sourcemm/version.rc
     1.1 --- a/sourcemm/CSmmAPI.cpp	Fri May 06 09:44:41 2005 +0000
     1.2 +++ b/sourcemm/CSmmAPI.cpp	Mon May 16 20:15:57 2005 +0000
     1.3 @@ -10,6 +10,7 @@
     1.4  
     1.5  #include "CSmmAPI.h"
     1.6  #include "sourcemm.h"
     1.7 +#include "concommands.h"
     1.8  
     1.9  /**
    1.10   * @brief Implementation of main API interface
    1.11 @@ -86,3 +87,14 @@
    1.12  {
    1.13  	return m_Res;
    1.14  }
    1.15 +
    1.16 +IConCommandBaseAccessor *CSmmAPI::GetCvarBaseAccessor()
    1.17 +{
    1.18 +	return static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor);
    1.19 +}
    1.20 +
    1.21 +void CSmmAPI::UnregisterCvar(ConCommandBase *pCvar)
    1.22 +{
    1.23 +	g_SMConVarAccessor.Unregister(pCvar);
    1.24 +}
    1.25 +
     2.1 --- a/sourcemm/CSmmAPI.h	Fri May 06 09:44:41 2005 +0000
     2.2 +++ b/sourcemm/CSmmAPI.h	Mon May 16 20:15:57 2005 +0000
     2.3 @@ -34,6 +34,8 @@
     2.4  		CGlobalVars *pGlobals();
     2.5  		void SetLastMetaReturn(META_RES res);
     2.6  		META_RES GetLastMetaReturn();
     2.7 +		IConCommandBaseAccessor *GetCvarBaseAccessor();
     2.8 +		void UnregisterCvar(ConCommandBase *pCvar);
     2.9  	private:
    2.10  		META_RES m_Res;
    2.11  	};
     3.1 --- a/sourcemm/ISmmAPI.h	Fri May 06 09:44:41 2005 +0000
     3.2 +++ b/sourcemm/ISmmAPI.h	Mon May 16 20:15:57 2005 +0000
     3.3 @@ -18,6 +18,7 @@
     3.4  
     3.5  #include <interface.h>
     3.6  #include <eiface.h>
     3.7 +#include <convar.h>
     3.8  #include <sourcehook/sourcehook.h>
     3.9  #include "IPluginManager.h"
    3.10  
    3.11 @@ -38,6 +39,10 @@
    3.12  	virtual CGlobalVars *pGlobals() =0;
    3.13  	virtual void SetLastMetaReturn(META_RES res) =0;
    3.14  	virtual META_RES GetLastMetaReturn() =0;
    3.15 +public:
    3.16 +	//Added in 1.00-RC2 to solve concommand problems
    3.17 +	virtual IConCommandBaseAccessor *GetCvarBaseAccessor() =0;
    3.18 +	virtual void UnregisterCvar(ConCommandBase *pCvar) =0;
    3.19  };
    3.20  
    3.21  #endif //_INCLUDE_ISMM_API_H
     4.1 --- a/sourcemm/concommands.cpp	Fri May 06 09:44:41 2005 +0000
     4.2 +++ b/sourcemm/concommands.cpp	Mon May 16 20:15:57 2005 +0000
     4.3 @@ -43,6 +43,34 @@
     4.4  	}
     4.5  }
     4.6  
     4.7 +void SMConVarAccessor::Unregister(ConCommandBase *pCvar)
     4.8 +{
     4.9 +	ICvar *cv = g_Engine.icvar;
    4.10 +
    4.11 +	ConCommandBase *ptr = cv->GetCommands();
    4.12 +
    4.13 +	if (ptr == pCvar && ptr->GetNext())
    4.14 +	{
    4.15 +		//we're at the beginning of the list
    4.16 +		*ptr = *(ptr->GetNext());
    4.17 +		return;
    4.18 +	}
    4.19 +
    4.20 +	while (ptr)
    4.21 +	{
    4.22 +		ConCommandBase *pNext = const_cast<ConCommandBase *>(ptr->GetNext());
    4.23 +		if (pNext == pCvar)
    4.24 +			break;
    4.25 +		ptr = pNext;
    4.26 +	}
    4.27 +
    4.28 +	if (ptr)
    4.29 +	{
    4.30 +		ptr->SetNext(const_cast<ConCommandBase *>(pCvar->GetNext()));
    4.31 +		pCvar->SetNext(NULL);
    4.32 +	}
    4.33 +}
    4.34 +
    4.35  ConVar metamod_version("metamod_version", SOURCEMM_VERSION, FCVAR_REPLICATED | FCVAR_SPONLY, "Metamod:Source Version");
    4.36  
    4.37  CON_COMMAND(meta, "Metamod:Source Menu")
     5.1 --- a/sourcemm/concommands.h	Fri May 06 09:44:41 2005 +0000
     5.2 +++ b/sourcemm/concommands.h	Mon May 16 20:15:57 2005 +0000
     5.3 @@ -28,6 +28,7 @@
     5.4  public:
     5.5  	virtual bool RegisterConCommandBase(ConCommandBase *pCommand);
     5.6  	void MarkCommandsAsGameDLL();
     5.7 +	void Unregister(ConCommandBase *pCvar);
     5.8  };
     5.9  
    5.10  extern SMConVarAccessor g_SMConVarAccessor;
     6.1 --- a/sourcemm/sourcemm.h	Fri May 06 09:44:41 2005 +0000
     6.2 +++ b/sourcemm/sourcemm.h	Mon May 16 20:15:57 2005 +0000
     6.3 @@ -26,7 +26,7 @@
     6.4  #include "oslink.h"
     6.5  #include "util.h"
     6.6  
     6.7 -#define		SOURCEMM_VERSION	"1.00-RC1"
     6.8 +#define		SOURCEMM_VERSION	"1.00-RC2"
     6.9  #define		SOURCEMM_DATE		__DATE__
    6.10  
    6.11  /**
     7.1 --- a/sourcemm/version.rc	Fri May 06 09:44:41 2005 +0000
     7.2 +++ b/sourcemm/version.rc	Mon May 16 20:15:57 2005 +0000
     7.3 @@ -27,8 +27,8 @@
     7.4  //
     7.5  
     7.6  VS_VERSION_INFO VERSIONINFO
     7.7 - FILEVERSION 1,0,0,1
     7.8 - PRODUCTVERSION 1,0,0,1
     7.9 + FILEVERSION 1,0,0,2
    7.10 + PRODUCTVERSION 1,0,0,2
    7.11   FILEFLAGSMASK 0x17L
    7.12  #ifdef _DEBUG
    7.13   FILEFLAGS 0x1L
    7.14 @@ -45,12 +45,12 @@
    7.15          BEGIN
    7.16              VALUE "Comments", "Metamod: Source"
    7.17              VALUE "FileDescription", "Metamod: Source"
    7.18 -            VALUE "FileVersion", "1.00-RC1"
    7.19 +            VALUE "FileVersion", "1.00-RC2"
    7.20              VALUE "InternalName", "sourcemm"
    7.21              VALUE "LegalCopyright", "Copyright (c) 2004-2005, Metamod: Source Development Team"
    7.22              VALUE "OriginalFilename", "server.dll"
    7.23              VALUE "ProductName", "Metamod: Source"
    7.24 -            VALUE "ProductVersion", "1.00-RC1"
    7.25 +            VALUE "ProductVersion", "1.00-RC2"
    7.26          END
    7.27      END
    7.28      BLOCK "VarFileInfo"