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.

67 lines
1.8 KiB

  1. /// @file response_system.cpp
  2. /// This file defines the editor's version
  3. /// of a response-system.
  4. #ifndef CS_RESPONSE_SYSTEM_H
  5. #define CS_RESPONSE_SYSTEM_H
  6. #include "UtlSortVector.h"
  7. class ResponseSystemImplementationCLI : public ResponseRules::CResponseSystem
  8. {
  9. public:
  10. #pragma region Overrides on CResponseSystem
  11. /// From ResponseRules::CResponseSystem.
  12. /// There, it returns the filename to load; here
  13. /// it is NULL, since the file comes from the editor
  14. /// dialog.
  15. virtual const char *GetScriptFile( void ) ;
  16. virtual void PrecacheResponses( bool bEnable );
  17. virtual void Release();
  18. inline void LoadFromFile( const char *filename );
  19. #pragma endregion
  20. int CountRules() ;
  21. /// USed to return a sorted list of all rules matching the criteria in order of score (not just the best)
  22. struct RuleAndScorePair_t
  23. {
  24. ResponseRules::ResponseRulePartition::tIndex ruleidx;
  25. float score;
  26. RuleAndScorePair_t( const ResponseRules::ResponseRulePartition::tIndex &_idx, float _score ) : ruleidx(_idx), score(_score) {};
  27. RuleAndScorePair_t( ) : ruleidx(ResponseRules::ResponseRulePartition::InvalidIdx()) {};
  28. struct LessFunc
  29. {
  30. // actually "more" since sort from best to worst score
  31. bool Less( const RuleAndScorePair_t & lhs, const RuleAndScorePair_t & rhs, void *pContext )
  32. {
  33. if ( lhs.score == rhs.score )
  34. {
  35. return lhs.ruleidx < rhs.ruleidx;
  36. }
  37. else
  38. {
  39. return lhs.score > rhs.score;
  40. }
  41. }
  42. };
  43. };
  44. typedef CUtlSortVector<RuleAndScorePair_t, RuleAndScorePair_t::LessFunc> FindAllRulesRetval_t;
  45. void FindAllRulesMatchingCriteria( FindAllRulesRetval_t* RESTRICT outputList,
  46. const ResponseRules::CriteriaSet& set, ResponseRules::IResponseFilter *pFilter = NULL );
  47. };
  48. inline void ResponseSystemImplementationCLI::LoadFromFile( const char *filename )
  49. {
  50. Clear();
  51. return LoadRuleSet( filename );
  52. }
  53. #endif