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.

73 lines
1.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "rrbase.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include <tier0/memdbgon.h>
  10. #if RR_CONCEPTS_ARE_STRINGS
  11. #pragma error("RR_CONCEPTS_ARE_STRINGS no longer supported")
  12. #else
  13. using namespace ResponseRules;
  14. // Used to turn ad-hoc concept from strings into numbers.
  15. CRR_ConceptSymbolTable *g_pRRConceptTable = NULL;
  16. // Q&D hack to defer initialization of concept table until I can figure out where it
  17. // really needs to come from.
  18. static void InitializeRRConceptTable()
  19. {
  20. if (g_pRRConceptTable == NULL)
  21. {
  22. g_pRRConceptTable = new CRR_ConceptSymbolTable( 64, 64, true );
  23. }
  24. }
  25. // construct from string
  26. CRR_Concept::CRR_Concept(const char *fromString)
  27. {
  28. InitializeRRConceptTable();
  29. m_iConcept = g_pRRConceptTable->AddString(fromString);
  30. }
  31. CRR_Concept &CRR_Concept::operator=(const char *fromString)
  32. {
  33. InitializeRRConceptTable();
  34. m_iConcept = g_pRRConceptTable->AddString(fromString);
  35. return *this;
  36. }
  37. bool CRR_Concept::operator==(const char *pszConcept)
  38. {
  39. int otherConcept = g_pRRConceptTable->Find(pszConcept);
  40. return ( otherConcept != UTL_INVAL_SYMBOL && otherConcept == m_iConcept );
  41. }
  42. const char *CRR_Concept::GetStringConcept() const
  43. {
  44. InitializeRRConceptTable();
  45. AssertMsg( m_iConcept.IsValid(), "AI Concept has invalid string symbol.\n" );
  46. const char * retval = g_pRRConceptTable->String(m_iConcept);
  47. AssertMsg( retval, "An RR_Concept couldn't find its string in the symbol table!\n" );
  48. if (retval == NULL)
  49. {
  50. Warning( "An RR_Concept couldn't find its string in the symbol table!\n" );
  51. retval = "";
  52. }
  53. return retval;
  54. }
  55. const char *CRR_Concept::GetStringForGenericId(tGenericId genericId)
  56. {
  57. InitializeRRConceptTable();
  58. return g_pRRConceptTable->String(genericId);
  59. }
  60. #endif