Added replicate and notify parameters to ResetConVar() - these were already available for SetConVarX()
Added replicate and notify parameters to ResetConVar() - these were already available for SetConVarX()
1.1 --- a/core/smn_console.cpp Fri Aug 10 05:59:03 2007 +0000
1.2 +++ b/core/smn_console.cpp Fri Aug 10 09:16:58 2007 +0000
1.3 @@ -360,6 +360,35 @@
1.4 return 1;
1.5 }
1.6
1.7 +static cell_t sm_ResetConVar(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_HandleSys.ReadHandle(hndl, g_ConVarManager.GetHandleType(), NULL, (void **)&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 + pConVar->Revert();
1.20 +
1.21 + /* Should we replicate it? */
1.22 + if (params[2] && pConVar->IsBitSet(FCVAR_REPLICATED))
1.23 + {
1.24 + ReplicateConVar(pConVar);
1.25 + }
1.26 +
1.27 + /* Should we notify clients? */
1.28 + if (params[3] && pConVar->IsBitSet(FCVAR_NOTIFY))
1.29 + {
1.30 + NotifyConVar(pConVar);
1.31 + }
1.32 +
1.33 + return 1;
1.34 +}
1.35 +
1.36 static cell_t sm_GetConVarFlags(IPluginContext *pContext, const cell_t *params)
1.37 {
1.38 Handle_t hndl = static_cast<Handle_t>(params[1]);
1.39 @@ -470,23 +499,6 @@
1.40 return 1;
1.41 }
1.42
1.43 -static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params)
1.44 -{
1.45 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.46 - HandleError err;
1.47 - ConVar *pConVar;
1.48 -
1.49 - if ((err=g_HandleSys.ReadHandle(hndl, g_ConVarManager.GetHandleType(), NULL, (void **)&pConVar))
1.50 - != HandleError_None)
1.51 - {
1.52 - return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err);
1.53 - }
1.54 -
1.55 - pConVar->Revert();
1.56 -
1.57 - return 1;
1.58 -}
1.59 -
1.60 static bool s_QueryAlreadyWarned = false;
1.61
1.62 static cell_t sm_QueryClientConVar(IPluginContext *pContext, const cell_t *params)
1.63 @@ -961,10 +973,10 @@
1.64 {"SetConVarString", sm_SetConVarString},
1.65 {"GetConVarFlags", sm_GetConVarFlags},
1.66 {"SetConVarFlags", sm_SetConVarFlags},
1.67 + {"ResetConVar", sm_ResetConVar},
1.68 {"GetConVarName", sm_GetConVarName},
1.69 {"GetConVarBounds", sm_GetConVarBounds},
1.70 {"SetConVarBounds", sm_SetConVarBounds},
1.71 - {"ResetConVar", sm_ResetConVar},
1.72 {"QueryClientConVar", sm_QueryClientConVar},
1.73 {"RegServerCmd", sm_RegServerCmd},
1.74 {"RegConsoleCmd", sm_RegConsoleCmd},
2.1 --- a/plugins/include/console.inc Fri Aug 10 05:59:03 2007 +0000
2.2 +++ b/plugins/include/console.inc Fri Aug 10 09:16:58 2007 +0000
2.3 @@ -469,6 +469,20 @@
2.4 native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
2.5
2.6 /**
2.7 + * Resets the console variable to its default value.
2.8 + *
2.9 + * @param convar Handle to the convar.
2.10 + * @param replicate If set to true, the new convar value will be set on all clients.
2.11 + * This will only work if the convar has the FCVAR_REPLICATED flag
2.12 + * and actually exists on clients.
2.13 + * @param notify If set to true, clients will be notified that the convar has changed.
2.14 + * This will only work if the convar has the FCVAR_NOTIFY flag.
2.15 + * @noreturn
2.16 + * @error Invalid or corrupt Handle.
2.17 + */
2.18 +native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
2.19 +
2.20 +/**
2.21 * Returns the bitstring of flags on a console variable.
2.22 *
2.23 * @param convar Handle to the convar.
2.24 @@ -521,15 +535,6 @@
2.25 */
2.26 native GetConVarName(Handle:convar, const String:name[], maxlength);
2.27
2.28 -/**
2.29 - * Resets the console variable to its default value.
2.30 - *
2.31 - * @param convar Handle to the convar.
2.32 - * @noreturn
2.33 - * @error Invalid or corrupt Handle.
2.34 - */
2.35 -native ResetConVar(Handle:convar);
2.36 -
2.37 funcenum ConVarQueryFinished
2.38 {
2.39 /**