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.

68 lines
1.5 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef EXT_KEYVALUES_H
  7. #define EXT_KEYVALUES_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "mm_framework.h"
  12. #include "matchmaking/mm_helpers.h"
  13. #define KeyValuesAddDefaultValue( kv, szKeyName, defValue, fnSet ) \
  14. ( (kv)->FindKey( szKeyName ) ? (1) : ( (kv)->fnSet( szKeyName, defValue ), 1 ) )
  15. #define KeyValuesAddDefaultString( kv, szKeyName, defValue ) \
  16. KeyValuesAddDefaultValue( kv, szKeyName, defValue, SetString )
  17. //
  18. // ContextValue_t allows for quick mapping from strings to title-defined values
  19. // in title specific code.
  20. //
  21. // static ContextValue_t values[] = {
  22. // { "=INGAME", CONTEXT_GAME_STATE_INGAME },
  23. // { "=INFINALE", CONTEXT_GAME_STATE_INFINALE },
  24. // { NULL, CONTEXT_GAME_STATE_INLOBBY },
  25. // };
  26. // SetAllUsersContext( CONTEXT_GAME_STATE, values->ScanValues( szValue ) );
  27. struct ContextValue_t
  28. {
  29. char const *m_szValue;
  30. unsigned int m_dwValue;
  31. inline unsigned int ScanValues( char const *szValue )
  32. {
  33. ContextValue_t const *p = this;
  34. for ( ; p->m_szValue; ++ p )
  35. {
  36. if ( !Q_stricmp( p->m_szValue, szValue ) )
  37. break;
  38. }
  39. return p->m_dwValue;
  40. }
  41. };
  42. //
  43. // Rule evaluation
  44. //
  45. class IPropertyRule
  46. {
  47. public:
  48. virtual bool ApplyRuleUint64( uint64 uiBase, uint64 &uiNew ) = 0;
  49. virtual bool ApplyRuleFloat( float flBase, float &flNew ) = 0;
  50. };
  51. IPropertyRule * GetRuleByName( char const *szRuleName );
  52. #endif