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.

66 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Quickplay related code shared between GC and client
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "tf_quickplay_shared.h"
  9. //-----------------------------------------------------------------------------
  10. extern const char k_szQuickplayFAQ_URL[] = "https://support.steampowered.com/kb_article.php?ref=2825-AFGJ-3513";
  11. //
  12. // MvM Missions
  13. //
  14. CMvMMissionSet::CMvMMissionSet() { Clear(); }
  15. CMvMMissionSet::CMvMMissionSet( const CMvMMissionSet &x ) { m_bits = x.m_bits; }
  16. CMvMMissionSet::~CMvMMissionSet() {}
  17. void CMvMMissionSet::operator=( const CMvMMissionSet &x ) { m_bits = x.m_bits; }
  18. void CMvMMissionSet::Clear() { m_bits = 0; }
  19. bool CMvMMissionSet::operator==( const CMvMMissionSet &x ) const { return m_bits == x.m_bits; }
  20. void CMvMMissionSet::SetMissionBySchemaIndex( int idxMission, bool flag )
  21. {
  22. Assert( idxMission >= 0 && idxMission < GetItemSchema()->GetMvmMissions().Count() );
  23. uint64 mask = ( (uint64)1 << (unsigned)idxMission );
  24. if ( flag )
  25. m_bits |= mask;
  26. else
  27. m_bits &= ~mask;
  28. }
  29. bool CMvMMissionSet::GetMissionBySchemaIndex( int idxMission ) const
  30. {
  31. // Bogus index?
  32. if ( idxMission == k_iMvmMissionIndex_NotInSchema )
  33. return false;
  34. if ( idxMission < 0 || idxMission >= GetItemSchema()->GetMvmMissions().Count() )
  35. {
  36. Assert( idxMission >= 0 );
  37. Assert( idxMission < GetItemSchema()->GetMvmMissions().Count() );
  38. return false;
  39. }
  40. // Check the bit
  41. uint64 mask = ( (uint64)1 << (unsigned)idxMission );
  42. return ( m_bits & mask ) != 0;
  43. }
  44. void CMvMMissionSet::Intersect( const CMvMMissionSet &x )
  45. {
  46. m_bits &= x.m_bits;
  47. }
  48. bool CMvMMissionSet::HasIntersection( const CMvMMissionSet &x ) const
  49. {
  50. return ( m_bits & x.m_bits ) != 0;
  51. }
  52. bool CMvMMissionSet::IsEmpty() const
  53. {
  54. return ( m_bits == 0 );
  55. }