- Removed GetConVarMin/Max() and replaced them with GetConVarBounds()
- Added SetConVarBounds() to set convar constraints after convar has already been created --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40720
This commit is contained in:
+26
-4
@@ -200,8 +200,14 @@ protected:
|
||||
static IConCommandBaseAccessor *s_pAccessor;
|
||||
|
||||
public: // Hackalicous
|
||||
int GetFlags() { return m_nFlags; }
|
||||
void SetFlags(int flags) { m_nFlags = flags; }
|
||||
inline int GetFlags()
|
||||
{
|
||||
return m_nFlags;
|
||||
}
|
||||
inline void SetFlags(int flags)
|
||||
{
|
||||
m_nFlags = flags;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -246,7 +252,10 @@ private:
|
||||
FnCommandCompletionCallback m_fnCompletionCallback;
|
||||
bool m_bHasCompletionCallback;
|
||||
public: // Hackalicous
|
||||
FnCommandCallback GetCallback() { return m_fnCommandCallback; }
|
||||
inline FnCommandCallback GetCallback()
|
||||
{
|
||||
return m_fnCommandCallback;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -360,7 +369,20 @@ private:
|
||||
// Call this function when ConVar changes
|
||||
FnChangeCallback m_fnChangeCallback;
|
||||
public: // Hackalicous
|
||||
FnChangeCallback GetCallback() { return m_fnChangeCallback; }
|
||||
inline FnChangeCallback GetCallback()
|
||||
{
|
||||
return m_fnChangeCallback;
|
||||
}
|
||||
inline void SetMin(bool set, float min)
|
||||
{
|
||||
m_bHasMin = set;
|
||||
m_fMinVal = min;
|
||||
}
|
||||
inline void SetMax(bool set, float max)
|
||||
{
|
||||
m_bHasMax = set;
|
||||
m_fMaxVal = max;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+39
-20
@@ -22,6 +22,12 @@
|
||||
#include "sm_stringutil.h"
|
||||
#include "PlayerManager.h"
|
||||
|
||||
enum ConVarBounds
|
||||
{
|
||||
ConVarBound_Upper = 0,
|
||||
ConVarBound_Lower
|
||||
};
|
||||
|
||||
static cell_t sm_CreateConVar(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name, *defaultVal, *helpText;
|
||||
@@ -261,7 +267,7 @@ static cell_t sm_SetConVarFlags(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetConVarMin(IPluginContext *pContext, const cell_t *params)
|
||||
static cell_t sm_GetConVarBounds(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
@@ -274,18 +280,28 @@ static cell_t sm_GetConVarMin(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
|
||||
cell_t *addr;
|
||||
bool hasMin;
|
||||
float min;
|
||||
bool hasBound;
|
||||
float bound;
|
||||
|
||||
pContext->LocalToPhysAddr(params[2], &addr);
|
||||
switch (params[2])
|
||||
{
|
||||
case ConVarBound_Upper:
|
||||
hasBound = pConVar->GetMax(bound);
|
||||
break;
|
||||
case ConVarBound_Lower:
|
||||
hasBound = pConVar->GetMin(bound);
|
||||
break;
|
||||
default:
|
||||
return pContext->ThrowNativeError("Invalid ConVarBounds value %d");
|
||||
}
|
||||
|
||||
pContext->LocalToPhysAddr(params[3], &addr);
|
||||
*addr = sp_ftoc(bound);
|
||||
|
||||
hasMin = pConVar->GetMin(min);
|
||||
*addr = sp_ftoc(min);
|
||||
|
||||
return hasMin;
|
||||
return hasBound;
|
||||
}
|
||||
|
||||
static cell_t sm_GetConVarMax(IPluginContext *pContext, const cell_t *params)
|
||||
static cell_t sm_SetConVarBounds(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
@@ -297,16 +313,19 @@ static cell_t sm_GetConVarMax(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
cell_t *addr;
|
||||
bool hasMax;
|
||||
float max;
|
||||
switch (params[2])
|
||||
{
|
||||
case ConVarBound_Upper:
|
||||
pConVar->SetMax(params[3] ? true : false, sp_ctof(params[4]));
|
||||
break;
|
||||
case ConVarBound_Lower:
|
||||
pConVar->SetMin(params[3] ? true : false, sp_ctof(params[4]));
|
||||
break;
|
||||
default:
|
||||
return pContext->ThrowNativeError("Invalid ConVarBounds value %d");
|
||||
}
|
||||
|
||||
pContext->LocalToPhysAddr(params[2], &addr);
|
||||
|
||||
hasMax = pConVar->GetMax(max);
|
||||
*addr = sp_ftoc(max);
|
||||
|
||||
return hasMax;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetConVarName(IPluginContext *pContext, const cell_t *params)
|
||||
@@ -630,8 +649,8 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"GetConVarFlags", sm_GetConVarFlags},
|
||||
{"SetConVarFlags", sm_SetConVarFlags},
|
||||
{"GetConVarName", sm_GetConVarName},
|
||||
{"GetConVarMin", sm_GetConVarMin},
|
||||
{"GetConVarMax", sm_GetConVarMax},
|
||||
{"GetConVarBounds", sm_GetConVarBounds},
|
||||
{"SetConVarBounds", sm_SetConVarBounds},
|
||||
{"ResetConVar", sm_ResetConVar},
|
||||
{"QueryClientConVar", sm_QueryClientConVar},
|
||||
{"RegServerCmd", sm_RegServerCmd},
|
||||
|
||||
Reference in New Issue
Block a user