static cell_t sm_GetConVarBounds(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = static_cast<Handle_t>(params[1]); HandleError err; ConVar *pConVar; if ((err=g_ConVarManager.ReadConVarHandle(hndl, &pConVar)) != HandleError_None) { return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err); } cell_t *addr; bool hasBound; float bound; 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); return hasBound; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void ConVar_PrintDescription( const ConCommandBase *pVar ) { bool bMin, bMax; float fMin, fMax; const char *pStr; assert( pVar ); Color clr; clr.SetColor( 255, 100, 100, 255 ); if ( !pVar->IsCommand() ) { ConVar *var = ( ConVar * )pVar; const ConVar_ServerBounded *pBounded = dynamic_cast<const ConVar_ServerBounded*>( var ); bMin = var->GetMin( fMin ); bMax = var->GetMax( fMax ); const char *value = NULL; char tempVal[ 32 ]; if ( pBounded || var->IsFlagSet( FCVAR_NEVER_AS_STRING ) ) { value = tempVal; int intVal = pBounded ? pBounded->GetInt() : var->GetInt(); float floatVal = pBounded ? pBounded->GetFloat() : var->GetFloat(); if ( fabs( (float)intVal - floatVal ) < 0.000001 ) { Q_snprintf( tempVal, sizeof( tempVal ), "%d", intVal ); } else { Q_snprintf( tempVal, sizeof( tempVal ), "%f", floatVal ); } } else { value = var->GetString(); } if ( value ) { ConColorMsg( clr, "\"%s\" = \"%s\"", var->GetName(), value ); if ( stricmp( value, var->GetDefault() ) ) { ConMsg( " ( def. \"%s\" )", var->GetDefault() ); } } if ( bMin ) { ConMsg( " min. %f", fMin ); } if ( bMax ) { ConMsg( " max. %f", fMax ); } ConMsg( "\n" ); // Handled virtualized cvars. if ( pBounded && fabs( pBounded->GetFloat() - var->GetFloat() ) > 0.0001f ) { ConColorMsg( clr, "** NOTE: The real value is %.3f but the server has temporarily restricted it to %.3f **\n", var->GetFloat(), pBounded->GetFloat() ); } } else { ConCommand *var = ( ConCommand * )pVar; ConColorMsg( clr, "\"%s\"\n", var->GetName() ); } ConVar_PrintFlags( pVar ); pStr = pVar->GetHelpText(); if ( pStr && pStr[0] ) { ConMsg( " - %s\n", pStr ); } }