Added GetConVarDefault() native (bug 4502, r=dvander).
authorScott Ehlert <ds@alliedmods.net>
Tue Jul 06 17:32:58 2010 -0500 (2010-07-06)
changeset 307152e383b58df7
parent 3070 dc361050274d
child 3072 db9f0f574251
Added GetConVarDefault() native (bug 4502, r=dvander).
core/smn_console.cpp
plugins/include/console.inc
     1.1 --- a/core/smn_console.cpp	Fri Jul 02 18:17:16 2010 -0700
     1.2 +++ b/core/smn_console.cpp	Tue Jul 06 17:32:58 2010 -0500
     1.3 @@ -509,6 +509,24 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t GetConVarDefault(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	Handle_t hndl = static_cast<Handle_t>(params[1]);
    1.10 +	HandleError err;
    1.11 +	ConVar *pConVar;
    1.12 +
    1.13 +	if ((err=g_ConVarManager.ReadConVarHandle(hndl, &pConVar))
    1.14 +		!= HandleError_None)
    1.15 +	{
    1.16 +		return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err);
    1.17 +	}
    1.18 +
    1.19 +	size_t bytes;
    1.20 +	pContext->StringToLocalUTF8(params[2], params[3], pConVar->GetDefault(), &bytes);
    1.21 +
    1.22 +	return bytes;
    1.23 +}
    1.24 +
    1.25  static cell_t sm_GetConVarFlags(IPluginContext *pContext, const cell_t *params)
    1.26  {
    1.27  	Handle_t hndl = static_cast<Handle_t>(params[1]);
    1.28 @@ -1406,6 +1424,7 @@
    1.29  	{"GetConVarBounds",		sm_GetConVarBounds},
    1.30  	{"SetConVarBounds",		sm_SetConVarBounds},
    1.31  	{"QueryClientConVar",	sm_QueryClientConVar},
    1.32 +	{"GetConVarDefault",	GetConVarDefault},
    1.33  	{"RegServerCmd",		sm_RegServerCmd},
    1.34  	{"RegConsoleCmd",		sm_RegConsoleCmd},
    1.35  	{"GetCmdArgString",		sm_GetCmdArgString},
     2.1 --- a/plugins/include/console.inc	Fri Jul 02 18:17:16 2010 -0700
     2.2 +++ b/plugins/include/console.inc	Tue Jul 06 17:32:58 2010 -0500
     2.3 @@ -594,6 +594,17 @@
     2.4  native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
     2.5  
     2.6  /**
     2.7 + * Retrieves the default string value of a console variable.
     2.8 + *
     2.9 + * @param convar		Handle to the convar.
    2.10 + * @param default		Buffer to store the default value of the convar.
    2.11 + * @param maxlength		Maximum length of string buffer.
    2.12 + * @return				Number of bytes written to the buffer (UTF-8 safe).
    2.13 + * @error				Invalid or corrupt Handle.
    2.14 + */
    2.15 +native GetConVarDefault(Handle:convar, String:default[], maxlength);
    2.16 +
    2.17 +/**
    2.18   * Returns the bitstring of flags on a console variable.
    2.19   *
    2.20   * @param convar		Handle to the convar.