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.

90 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "tf_duel_summary.h"
  9. #include "gcsdk/enumutils.h"
  10. using namespace GCSDK;
  11. #ifdef GC
  12. IMPLEMENT_CLASS_MEMPOOL( CTFDuelSummary, 1000, UTLMEMORYPOOL_GROW_SLOW );
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. bool CTFDuelSummary::BYieldingAddInsertToTransaction( GCSDK::CSQLAccess & sqlAccess )
  16. {
  17. CSchDuelSummary schDuelSummary;
  18. WriteToRecord( &schDuelSummary );
  19. return CSchemaSharedObjectHelper::BYieldingAddInsertToTransaction( sqlAccess, &schDuelSummary );
  20. }
  21. bool CTFDuelSummary::BYieldingAddWriteToTransaction( GCSDK::CSQLAccess & sqlAccess, const CUtlVector< int > &fields )
  22. {
  23. CSchDuelSummary schDuelSummary;
  24. WriteToRecord( &schDuelSummary );
  25. CColumnSet csDatabaseDirty( schDuelSummary.GetPSchema()->GetRecordInfo() );
  26. csDatabaseDirty.MakeEmpty();
  27. FOR_EACH_VEC( fields, nField )
  28. {
  29. switch ( fields[nField] )
  30. {
  31. case CSOTFDuelSummary::kLastDuelAccountIdFieldNumber: csDatabaseDirty.BAddColumn( CSchDuelSummary::k_iField_unLastDuelAccountID ); break;
  32. case CSOTFDuelSummary::kLastDuelTimestampFieldNumber: csDatabaseDirty.BAddColumn( CSchDuelSummary::k_iField_rtLastDuelTimestamp ); break;
  33. case CSOTFDuelSummary::kLastDuelStatusFieldNumber: csDatabaseDirty.BAddColumn( CSchDuelSummary::k_iField_eLastDuelStatus ); break;
  34. case CSOTFDuelSummary::kDuelLossesFieldNumber: csDatabaseDirty.BAddColumn( CSchDuelSummary::k_iField_unDuelLosses ); break;
  35. case CSOTFDuelSummary::kDuelWinsFieldNumber: csDatabaseDirty.BAddColumn( CSchDuelSummary::k_iField_unDuelWins ); break;
  36. }
  37. }
  38. return CSchemaSharedObjectHelper::BYieldingAddWriteToTransaction( sqlAccess, &schDuelSummary, csDatabaseDirty );
  39. }
  40. bool CTFDuelSummary::BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess & sqlAccess )
  41. {
  42. CSchDuelSummary schDuelSummary;
  43. WriteToRecord( &schDuelSummary );
  44. return CSchemaSharedObjectHelper::BYieldingAddRemoveToTransaction( sqlAccess, &schDuelSummary );
  45. }
  46. void CTFDuelSummary::WriteToRecord( CSchDuelSummary *pDuelSummary ) const
  47. {
  48. pDuelSummary->m_unAccountID = Obj().account_id();
  49. pDuelSummary->m_unDuelWins = Obj().duel_wins();
  50. pDuelSummary->m_unDuelLosses = Obj().duel_losses();
  51. pDuelSummary->m_unLastDuelAccountID = Obj().last_duel_account_id();
  52. pDuelSummary->m_rtLastDuelTimestamp = Obj().last_duel_timestamp();
  53. pDuelSummary->m_eLastDuelStatus = Obj().last_duel_status();
  54. }
  55. void CTFDuelSummary::ReadFromRecord( const CSchDuelSummary & duelSummary )
  56. {
  57. Obj().set_account_id( duelSummary.m_unAccountID );
  58. Obj().set_duel_wins( duelSummary.m_unDuelWins );
  59. Obj().set_duel_losses( duelSummary.m_unDuelLosses );
  60. Obj().set_last_duel_account_id( duelSummary.m_unLastDuelAccountID );
  61. Obj().set_last_duel_timestamp( duelSummary.m_rtLastDuelTimestamp );
  62. Obj().set_last_duel_status( duelSummary.m_eLastDuelStatus );
  63. }
  64. ENUMSTRINGS_START( eDuelEndReason )
  65. { kDuelEndReason_DuelOver, "Complete" },
  66. { kDuelEndReason_PlayerDisconnected, "Player Disconnected" },
  67. { kDuelEndReason_PlayerSwappedTeams, "Player Swapped Teams" },
  68. { kDuelEndReason_LevelShutdown, "Level Shutdown" },
  69. { kDuelEndReason_ScoreTiedAtZero, "Tied" },
  70. { kDuelEndReason_PlayerKicked, "Player Kicked" },
  71. { kDuelEndReason_PlayerForceSwappedTeams, "Forced to Swap Teams" },
  72. { kDuelEndReason_ScoreTied, "Tied" },
  73. ENUMSTRINGS_END( eDuelEndReason )
  74. #endif