Team Fortress 2 Source Code as on 22/4/2020
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.

112 lines
4.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Interfaces of the CustomAwardTrigger tree. Both types of
  4. // Custom award triggers and their base class
  5. //
  6. // $Workfile: $
  7. // $Date: $
  8. //
  9. //------------------------------------------------------------------------------------------------------
  10. // $Log: $
  11. //
  12. // $NoKeywords: $
  13. //=============================================================================//
  14. #ifndef CUSTOMAWARDTRIGGERS_H
  15. #define CUSTOMAWARDTRIGGERS_H
  16. #ifdef WIN32
  17. #pragma once
  18. #endif
  19. #pragma warning(disable :4786)
  20. #include "TextFile.h"
  21. #include "LogEvent.h"
  22. #include <vector>
  23. #include <list>
  24. #include <map>
  25. using std::map;
  26. using std::list;
  27. using std::vector;
  28. using std::string;
  29. //------------------------------------------------------------------------------------------------------
  30. // Purpose: CCustomAwardTrigger is the base class for both types of award
  31. // triggers. An award trigger is an object that recognizes a certain type of event
  32. // in the log file, and if it matches that event, then it "triggers" and the custom
  33. // award which owns it increments the counter for the player who triggered the
  34. // trigger.
  35. //------------------------------------------------------------------------------------------------------
  36. class CCustomAwardTrigger
  37. {
  38. public:
  39. static CCustomAwardTrigger* readTrigger(CTextFile& f);
  40. int plrValue;
  41. int teamValue;
  42. map<string,string> extraProps;
  43. virtual bool matches(const CLogEvent* le)=0;
  44. virtual PID plrIDFromEvent(const CLogEvent* ple){return -1;}
  45. virtual string getTrackString(const CLogEvent* ple){return "";}
  46. CCustomAwardTrigger(int value, int tmVal, map<string,string> extras){plrValue=value;teamValue=tmVal;extraProps=extras;}
  47. };
  48. //------------------------------------------------------------------------------------------------------
  49. // Purpose: CBroadcastTrigger scans broadcast events for matching data
  50. //------------------------------------------------------------------------------------------------------
  51. class CBroadcastTrigger: public CCustomAwardTrigger
  52. {
  53. public:
  54. CBroadcastTrigger(int value, int teamValue, vector<string>& keys,map<string,string> extras);
  55. vector<string> broadcastStrings;
  56. virtual bool matches(const CLogEvent* le);
  57. virtual PID plrIDFromEvent(const CLogEvent* ple){return ple->getArgument(1)->asPlayerGetPID();}
  58. //this class doesn't need this function
  59. //virtual string getTrackString(const CLogEvent* ple){return "";}
  60. };
  61. //------------------------------------------------------------------------------------------------------
  62. // Purpose: CGoalTrigger scans goal activations for matching data
  63. //------------------------------------------------------------------------------------------------------
  64. class CGoalTrigger: public CCustomAwardTrigger
  65. {
  66. public:
  67. CGoalTrigger(int value, int teamValue, vector<string>& keys,map<string,string> extras);
  68. vector<string> goalNames;
  69. virtual bool matches(const CLogEvent* le);
  70. virtual PID plrIDFromEvent(const CLogEvent* ple){return ple->getArgument(0)->asPlayerGetPID();}
  71. //this class doesn't need this function
  72. //virtual string getTrackString(const CLogEvent* ple){return "";}
  73. };
  74. //------------------------------------------------------------------------------------------------------
  75. // Purpose: CFullSearchTrigger scans FullSearch activations for matching data
  76. //------------------------------------------------------------------------------------------------------
  77. class CFullSearchTrigger: public CCustomAwardTrigger
  78. {
  79. public:
  80. int regExpCompare(string exp,string cmp);
  81. map<string,string> varexpressions;
  82. CFullSearchTrigger(int value, int teamValue, vector<string>& ks,map<string,string> extras);
  83. vector<string> keys;
  84. string winnerVar;
  85. bool compare(string str_msg,string str_key,map<string,string>& varmatches);
  86. virtual bool matches(const CLogEvent* le);
  87. virtual PID plrIDFromEvent(const CLogEvent* ple);
  88. //this class does
  89. virtual string getTrackString(const CLogEvent* ple);
  90. };
  91. #endif // CUSTOMAWARDTRIGGERS_H