Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #include "extkeyvalues.h"
  7. #include <ctype.h>
  8. #include "fmtstr.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //
  12. // Rule evaluation
  13. //
  14. static class CPropertyRule_Max : public IPropertyRule
  15. {
  16. public:
  17. virtual bool ApplyRuleUint64( uint64 uiBase, uint64 &uiNew )
  18. {
  19. bool bResult = ( uiNew > uiBase );
  20. uiNew = MAX( uiNew, uiBase );
  21. return bResult;
  22. }
  23. virtual bool ApplyRuleFloat( float flBase, float &flNew )
  24. {
  25. bool bResult = ( flNew > flBase );
  26. flNew = MAX( flNew, flBase );
  27. return bResult;
  28. }
  29. }
  30. g_PropertyRule_Max;
  31. static class CPropertyRule_None : public IPropertyRule
  32. {
  33. public:
  34. virtual bool ApplyRuleUint64( uint64 uiBase, uint64 &uiNew ) { return true; }
  35. virtual bool ApplyRuleFloat( float flBase, float &flNew ) { return true; }
  36. }
  37. g_PropertyRule_None;
  38. IPropertyRule * GetRuleByName( char const *szRuleName )
  39. {
  40. if ( !Q_stricmp( szRuleName, "max" ) )
  41. return &g_PropertyRule_Max;
  42. return &g_PropertyRule_None;
  43. }