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.

519 lines
24 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "tf_ladder_data.h"
  9. #include "gcsdk/enumutils.h"
  10. #ifdef CLIENT_DLL
  11. #include "econ/confirm_dialog.h"
  12. #include "tf_matchmaking_shared.h"
  13. #include "c_tf_player.h"
  14. #endif
  15. using namespace GCSDK;
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Get player's ladder stat data by steamID. Returns nullptr if it doesn't exist
  18. //-----------------------------------------------------------------------------
  19. CSOTFLadderData *YieldingGetPlayerLadderDataBySteamID( const CSteamID &steamID, EMatchGroup nMatchGroup )
  20. {
  21. #ifdef GC_DLL
  22. GCSDK::CGCSharedObjectCache *pSOCache = GGCEcon()->YieldingFindOrLoadSOCache( steamID );
  23. #else
  24. GCSDK::CGCClientSharedObjectCache *pSOCache = GCClientSystem()->GetSOCache( steamID );
  25. #endif
  26. if ( pSOCache )
  27. {
  28. auto *pTypeCache = pSOCache->FindTypeCache( CSOTFLadderData::k_nTypeID );
  29. if ( pTypeCache )
  30. {
  31. for ( uint32 i = 0; i < pTypeCache->GetCount(); ++i )
  32. {
  33. CSOTFLadderData *pLadderData = (CSOTFLadderData*)pTypeCache->GetObject( i );
  34. if ( nMatchGroup == (EMatchGroup)pLadderData->Obj().match_group() )
  35. {
  36. return pLadderData;
  37. }
  38. }
  39. }
  40. }
  41. return nullptr;
  42. }
  43. #if !defined( GC )
  44. //-----------------------------------------------------------------------------
  45. // Purpose: Get the local player's Ladder Data. Returns NULL if it doesn't exist (no GC)
  46. //-----------------------------------------------------------------------------
  47. CSOTFLadderData *GetLocalPlayerLadderData( EMatchGroup nMatchGroup )
  48. {
  49. if ( steamapicontext && steamapicontext->SteamUser() )
  50. {
  51. return YieldingGetPlayerLadderDataBySteamID( steamapicontext->SteamUser()->GetSteamID(), nMatchGroup );
  52. }
  53. return NULL;
  54. }
  55. #endif // !GC
  56. //-----------------------------------------------------------------------------
  57. // Purpose:
  58. //-----------------------------------------------------------------------------
  59. CSOTFLadderData::CSOTFLadderData()
  60. {
  61. Obj().set_account_id( 0 );
  62. Obj().set_match_group( k_nMatchGroup_Invalid );
  63. Obj().set_season_id( 1 );
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Purpose:
  67. //-----------------------------------------------------------------------------
  68. CSOTFLadderData::CSOTFLadderData( uint32 unAccountID, EMatchGroup eMatchGroup )
  69. {
  70. Obj().set_account_id( unAccountID );
  71. Obj().set_match_group( eMatchGroup );
  72. Obj().set_season_id( 1 );
  73. }
  74. #ifdef GC
  75. IMPLEMENT_CLASS_MEMPOOL( CSOTFLadderData, 1000, UTLMEMORYPOOL_GROW_SLOW );
  76. IMPLEMENT_CLASS_MEMPOOL( CSOTFMatchResultPlayerInfo, 1000, UTLMEMORYPOOL_GROW_SLOW );
  77. // memdbgon must be the last include file in a .cpp file!!!
  78. #include "tier0/memdbgon.h"
  79. bool CSOTFLadderData::BIsKeyLess( const CSharedObject & soRHS ) const
  80. {
  81. Assert( GetTypeID() == soRHS.GetTypeID() );
  82. const CSOTFLadderPlayerStats &obj = Obj();
  83. const CSOTFLadderPlayerStats &rhs = ( static_cast< const CSOTFLadderData & >( soRHS ) ).Obj();
  84. if ( obj.account_id() < rhs.account_id() ) return true;
  85. if ( obj.account_id() > rhs.account_id() ) return false;
  86. if ( obj.match_group() < rhs.match_group() ) return true;
  87. if ( obj.match_group() > rhs.match_group() ) return false;
  88. return obj.season_id() < rhs.season_id();
  89. }
  90. //-----------------------------------------------------------------------------
  91. bool CSOTFLadderData::BYieldingAddInsertToTransaction( GCSDK::CSQLAccess & sqlAccess )
  92. {
  93. CSchLadderData schLadderData;
  94. WriteToRecord( &schLadderData );
  95. return CSchemaSharedObjectHelper::BYieldingAddInsertToTransaction( sqlAccess, &schLadderData );
  96. }
  97. //-----------------------------------------------------------------------------
  98. // Purpose:
  99. //-----------------------------------------------------------------------------
  100. bool CSOTFLadderData::BYieldingAddWriteToTransaction( GCSDK::CSQLAccess & sqlAccess, const CUtlVector< int > &fields )
  101. {
  102. CSchLadderData schLadderData;
  103. WriteToRecord( &schLadderData );
  104. CColumnSet csDatabaseDirty( schLadderData.GetPSchema()->GetRecordInfo() );
  105. csDatabaseDirty.MakeEmpty();
  106. FOR_EACH_VEC( fields, nField )
  107. {
  108. switch ( fields[nField] )
  109. {
  110. case CSOTFLadderPlayerStats::kAccountIdFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unAccountID ); break;
  111. case CSOTFLadderPlayerStats::kMatchGroupFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_nMatchGroup ); break;
  112. case CSOTFLadderPlayerStats::kSeasonIdFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unSeasonID ); break;
  113. case CSOTFLadderPlayerStats::kRankFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unRank ); break;
  114. case CSOTFLadderPlayerStats::kHighestRankFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unHighestRank ); break;
  115. case CSOTFLadderPlayerStats::kExperienceFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unExperience ); break;
  116. case CSOTFLadderPlayerStats::kLastAckdExperienceFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unLastAckdExperience ); break;
  117. case CSOTFLadderPlayerStats::kGamesFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unGames ); break;
  118. case CSOTFLadderPlayerStats::kScoreFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unScore ); break;
  119. case CSOTFLadderPlayerStats::kKillsFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unKills ); break;
  120. case CSOTFLadderPlayerStats::kDeathsFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unDeaths ); break;
  121. case CSOTFLadderPlayerStats::kDamageFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unDamage ); break;
  122. case CSOTFLadderPlayerStats::kHealingFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unHealing ); break;
  123. case CSOTFLadderPlayerStats::kSupportFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unSupport ); break;
  124. case CSOTFLadderPlayerStats::kScoreBronzeFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unScoreBronze ); break;
  125. case CSOTFLadderPlayerStats::kScoreSilverFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unScoreSilver ); break;
  126. case CSOTFLadderPlayerStats::kScoreGoldFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unScoreGold ); break;
  127. case CSOTFLadderPlayerStats::kKillsBronzeFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unKillsBronze ); break;
  128. case CSOTFLadderPlayerStats::kKillsSilverFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unKillsSilver ); break;
  129. case CSOTFLadderPlayerStats::kKillsGoldFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unKillsGold ); break;
  130. case CSOTFLadderPlayerStats::kDamageBronzeFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unDamageBronze ); break;
  131. case CSOTFLadderPlayerStats::kDamageSilverFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unDamageSilver ); break;
  132. case CSOTFLadderPlayerStats::kDamageGoldFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unDamageGold ); break;
  133. case CSOTFLadderPlayerStats::kHealingBronzeFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unHealingBronze ); break;
  134. case CSOTFLadderPlayerStats::kHealingSilverFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unHealingSilver ); break;
  135. case CSOTFLadderPlayerStats::kHealingGoldFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unHealingGold ); break;
  136. case CSOTFLadderPlayerStats::kSupportBronzeFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unSupportBronze ); break;
  137. case CSOTFLadderPlayerStats::kSupportSilverFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unSupportSilver ); break;
  138. case CSOTFLadderPlayerStats::kSupportGoldFieldNumber: csDatabaseDirty.BAddColumn( CSchLadderData::k_iField_unSupportGold ); break;
  139. default:
  140. Assert( false );
  141. }
  142. }
  143. return CSchemaSharedObjectHelper::BYieldingAddWriteToTransaction( sqlAccess, &schLadderData, csDatabaseDirty );
  144. }
  145. //-----------------------------------------------------------------------------
  146. bool CSOTFLadderData::BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess & sqlAccess )
  147. {
  148. CSchLadderData schLadderData;
  149. WriteToRecord( &schLadderData );
  150. return CSchemaSharedObjectHelper::BYieldingAddRemoveToTransaction( sqlAccess, &schLadderData );
  151. }
  152. //-----------------------------------------------------------------------------
  153. void CSOTFLadderData::WriteToRecord( CSchLadderData *pLadderData ) const
  154. {
  155. pLadderData->m_unAccountID = Obj().account_id();
  156. pLadderData->m_nMatchGroup = (int16)Obj().match_group();
  157. pLadderData->m_unSeasonID = (uint16)Obj().season_id();
  158. pLadderData->m_unRank = (uint16)Obj().rank();
  159. pLadderData->m_unHighestRank = (uint16)Obj().highest_rank();
  160. pLadderData->m_unExperience = Obj().experience();
  161. pLadderData->m_unLastAckdExperience = Obj().last_ackd_experience();
  162. pLadderData->m_unGames = Obj().games();
  163. pLadderData->m_unScore = Obj().score();
  164. pLadderData->m_unKills = Obj().kills();
  165. pLadderData->m_unDeaths = Obj().deaths();
  166. pLadderData->m_unDamage = Obj().damage();
  167. pLadderData->m_unHealing = Obj().healing();
  168. pLadderData->m_unSupport = Obj().support();
  169. pLadderData->m_unScoreBronze = (uint16)Obj().score_bronze();
  170. pLadderData->m_unScoreSilver = (uint16)Obj().score_silver();
  171. pLadderData->m_unScoreGold = (uint16)Obj().score_gold();
  172. pLadderData->m_unKillsBronze = (uint16)Obj().score_bronze();
  173. pLadderData->m_unKillsSilver = (uint16)Obj().score_silver();
  174. pLadderData->m_unKillsGold = (uint16)Obj().score_gold();
  175. pLadderData->m_unDamageBronze = (uint16)Obj().damage_bronze();
  176. pLadderData->m_unDamageSilver = (uint16)Obj().damage_silver();
  177. pLadderData->m_unDamageGold = (uint16)Obj().damage_gold();
  178. pLadderData->m_unHealingBronze = (uint16)Obj().healing_bronze();
  179. pLadderData->m_unHealingSilver = (uint16)Obj().healing_silver();
  180. pLadderData->m_unHealingGold = (uint16)Obj().healing_gold();
  181. pLadderData->m_unSupportBronze = (uint16)Obj().support_bronze();
  182. pLadderData->m_unSupportSilver = (uint16)Obj().support_silver();
  183. pLadderData->m_unSupportGold = (uint16)Obj().support_gold();
  184. }
  185. //-----------------------------------------------------------------------------
  186. // Purpose:
  187. //-----------------------------------------------------------------------------
  188. void CSOTFLadderData::ReadFromRecord( const CSchLadderData &ladderData )
  189. {
  190. Obj().set_account_id( ladderData.m_unAccountID );
  191. Obj().set_match_group( ladderData.m_nMatchGroup );
  192. Obj().set_season_id( 1 ); // TODO: GetSeasonID()
  193. Obj().set_rank( ladderData.m_unRank );
  194. Obj().set_highest_rank( ladderData.m_unHighestRank );
  195. Obj().set_experience( ladderData.m_unExperience );
  196. Obj().set_last_ackd_experience( ladderData.m_unLastAckdExperience );
  197. Obj().set_games( ladderData.m_unGames );
  198. Obj().set_score( ladderData.m_unScore );
  199. Obj().set_kills( ladderData.m_unKills );
  200. Obj().set_deaths( ladderData.m_unDeaths );
  201. Obj().set_damage( ladderData.m_unDamage );
  202. Obj().set_healing( ladderData.m_unHealing );
  203. Obj().set_support( ladderData.m_unSupport );
  204. Obj().set_score_bronze( ladderData.m_unScoreBronze );
  205. Obj().set_score_silver( ladderData.m_unScoreSilver );
  206. Obj().set_score_gold( ladderData.m_unScoreGold );
  207. Obj().set_kills_bronze( ladderData.m_unKillsBronze );
  208. Obj().set_kills_silver( ladderData.m_unKillsSilver );
  209. Obj().set_kills_gold( ladderData.m_unKillsGold );
  210. Obj().set_damage_bronze( ladderData.m_unDamageBronze );
  211. Obj().set_damage_silver( ladderData.m_unDamageSilver);
  212. Obj().set_damage_gold( ladderData.m_unDamageGold );
  213. Obj().set_healing_bronze( ladderData.m_unHealingBronze );
  214. Obj().set_healing_silver( ladderData.m_unHealingSilver );
  215. Obj().set_healing_gold( ladderData.m_unHealingGold );
  216. Obj().set_support_bronze( ladderData.m_unSupportBronze );
  217. Obj().set_support_silver( ladderData.m_unSupportSilver );
  218. Obj().set_support_gold( ladderData.m_unSupportGold );
  219. }
  220. #endif // GC
  221. #if !defined( GC )
  222. void GetLocalPlayerMatchHistory( EMatchGroup nMatchGroup, CUtlVector < CSOTFMatchResultPlayerStats > &vecMatchesOut )
  223. {
  224. if ( steamapicontext && steamapicontext->SteamUser() )
  225. {
  226. CSteamID steamID = steamapicontext->SteamUser()->GetSteamID();
  227. GCSDK::CGCClientSharedObjectCache *pSOCache = GCClientSystem()->GetSOCache( steamID );
  228. if ( pSOCache )
  229. {
  230. GCSDK::CGCClientSharedObjectTypeCache *pTypeCache = pSOCache->FindTypeCache( CSOTFMatchResultPlayerInfo::k_nTypeID );
  231. if ( pTypeCache )
  232. {
  233. for ( uint32 i = 0; i < pTypeCache->GetCount(); ++i )
  234. {
  235. CSOTFMatchResultPlayerInfo *pMatchStats = (CSOTFMatchResultPlayerInfo*)pTypeCache->GetObject( i );
  236. if ( nMatchGroup == (EMatchGroup)pMatchStats->Obj().match_group() )
  237. {
  238. vecMatchesOut.AddToTail( pMatchStats->Obj() );
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. #endif // !GC
  246. //-----------------------------------------------------------------------------
  247. // Purpose:
  248. //-----------------------------------------------------------------------------
  249. CSOTFMatchResultPlayerInfo::CSOTFMatchResultPlayerInfo()
  250. {
  251. Obj().set_account_id( 0 );
  252. }
  253. #ifdef GC
  254. //-----------------------------------------------------------------------------
  255. // Purpose:
  256. //-----------------------------------------------------------------------------
  257. CSOTFMatchResultPlayerInfo::CSOTFMatchResultPlayerInfo( uint32 unAccountID )
  258. {
  259. Obj().set_match_id( 0 );
  260. Obj().set_account_id( unAccountID );
  261. Obj().set_match_group( k_nMatchGroup_Invalid );
  262. Obj().set_endtime( 0 );
  263. Obj().set_season_id( 1 );
  264. Obj().set_status( 0 );
  265. Obj().set_party_id( 0 );
  266. Obj().set_team( 0 );
  267. Obj().set_score( 0 );
  268. Obj().set_ping( 0 );
  269. Obj().set_flags( 0 );
  270. Obj().set_display_rating( 0 );
  271. Obj().set_display_rating_change( 0 );
  272. Obj().set_rank( 0 );
  273. Obj().set_classes_played( 0 );
  274. Obj().set_kills( 0 );
  275. Obj().set_deaths( 0 );
  276. Obj().set_damage( 0 );
  277. Obj().set_healing( 0 );
  278. Obj().set_support( 0 );
  279. Obj().set_score_medal( 0 );
  280. Obj().set_kills_medal( 0 );
  281. Obj().set_damage_medal( 0 );
  282. Obj().set_healing_medal( 0 );
  283. Obj().set_support_medal( 0 );
  284. Obj().set_map_index( 0 );
  285. }
  286. bool CSOTFMatchResultPlayerInfo::BIsKeyLess( const CSharedObject & soRHS ) const
  287. {
  288. Assert( GetTypeID() == soRHS.GetTypeID() );
  289. const CSOTFMatchResultPlayerStats &obj = Obj();
  290. const CSOTFMatchResultPlayerStats &rhs = ( static_cast<const CSOTFMatchResultPlayerInfo &>( soRHS ) ).Obj();
  291. Assert( obj.account_id() == obj.account_id() );
  292. if ( obj.match_group() < rhs.match_group() ) return true;
  293. if ( obj.match_group() > rhs.match_group() ) return false;
  294. return obj.season_id() < rhs.season_id();
  295. }
  296. //-----------------------------------------------------------------------------
  297. // Purpose:
  298. //-----------------------------------------------------------------------------
  299. bool CSOTFMatchResultPlayerInfo::BYieldingAddInsertToTransaction( GCSDK::CSQLAccess & sqlAccess )
  300. {
  301. CSchMatchResultPlayerInfo schMatchInfo;
  302. WriteToRecord( &schMatchInfo );
  303. return CSchemaSharedObjectHelper::BYieldingAddInsertToTransaction( sqlAccess, &schMatchInfo );
  304. }
  305. //-----------------------------------------------------------------------------
  306. // Purpose:
  307. //-----------------------------------------------------------------------------
  308. bool CSOTFMatchResultPlayerInfo::BYieldingAddWriteToTransaction( GCSDK::CSQLAccess & sqlAccess, const CUtlVector< int > &fields )
  309. {
  310. CSchMatchResultPlayerInfo schMatchInfo;
  311. WriteToRecord( &schMatchInfo );
  312. CColumnSet csDatabaseDirty( schMatchInfo.GetPSchema()->GetRecordInfo() );
  313. csDatabaseDirty.MakeEmpty();
  314. FOR_EACH_VEC( fields, nField )
  315. {
  316. switch ( fields[nField] )
  317. {
  318. case CSOTFMatchResultPlayerStats::kMatchIdFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unMatchID ); break;
  319. case CSOTFMatchResultPlayerStats::kAccountIdFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unAccountID ); break;
  320. case CSOTFMatchResultPlayerStats::kMatchGroupFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_nMatchGroup ); break;
  321. case CSOTFMatchResultPlayerStats::kEndtimeFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_RTime32Stamp ); break;
  322. case CSOTFMatchResultPlayerStats::kSeasonIdFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unSeasonID ); break;
  323. case CSOTFMatchResultPlayerStats::kStatusFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unStatus ); break;
  324. case CSOTFMatchResultPlayerStats::kPartyIdFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unPartyID ); break;
  325. case CSOTFMatchResultPlayerStats::kTeamFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unTeam ); break;
  326. case CSOTFMatchResultPlayerStats::kScoreFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unScore ); break;
  327. case CSOTFMatchResultPlayerStats::kPingFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unPing ); break;
  328. case CSOTFMatchResultPlayerStats::kFlagsFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unFlags ); break;
  329. case CSOTFMatchResultPlayerStats::kDisplayRatingFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unDisplayRating ); break;
  330. case CSOTFMatchResultPlayerStats::kDisplayRatingChangeFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_nDisplayRatingChange ); break;
  331. case CSOTFMatchResultPlayerStats::kRankFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unRank ); break;
  332. case CSOTFMatchResultPlayerStats::kClassesPlayedFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unClassesPlayed ); break;
  333. case CSOTFMatchResultPlayerStats::kKillsFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unKills ); break;
  334. case CSOTFMatchResultPlayerStats::kDeathsFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unDeaths ); break;
  335. case CSOTFMatchResultPlayerStats::kDamageFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unDamage ); break;
  336. case CSOTFMatchResultPlayerStats::kHealingFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unHealing ); break;
  337. case CSOTFMatchResultPlayerStats::kSupportFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unSupport ); break;
  338. case CSOTFMatchResultPlayerStats::kScoreMedalFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unScoreMedal ); break;
  339. case CSOTFMatchResultPlayerStats::kKillsMedalFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unKillsMedal ); break;
  340. case CSOTFMatchResultPlayerStats::kDamageMedalFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unDamageMedal ); break;
  341. case CSOTFMatchResultPlayerStats::kHealingMedalFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unHealingMedal ); break;
  342. case CSOTFMatchResultPlayerStats::kSupportMedalFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unSupportMedal ); break;
  343. case CSOTFMatchResultPlayerStats::kMapIndexFieldNumber: csDatabaseDirty.BAddColumn( CSchMatchResultPlayerInfo::k_iField_unMapIndex ); break;
  344. default:
  345. Assert( false );
  346. }
  347. }
  348. return CSchemaSharedObjectHelper::BYieldingAddWriteToTransaction( sqlAccess, &schMatchInfo, csDatabaseDirty );
  349. }
  350. //-----------------------------------------------------------------------------
  351. // Purpose:
  352. //-----------------------------------------------------------------------------
  353. bool CSOTFMatchResultPlayerInfo::BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess & sqlAccess )
  354. {
  355. CSchMatchResultPlayerInfo schMatchInfo;
  356. WriteToRecord( &schMatchInfo );
  357. return CSchemaSharedObjectHelper::BYieldingAddRemoveToTransaction( sqlAccess, &schMatchInfo );
  358. }
  359. //-----------------------------------------------------------------------------
  360. // Purpose:
  361. //-----------------------------------------------------------------------------
  362. void CSOTFMatchResultPlayerInfo::WriteToRecord( CSchMatchResultPlayerInfo *pMatchInfo ) const
  363. {
  364. pMatchInfo->m_unMatchID = Obj().match_id();
  365. pMatchInfo->m_unAccountID = Obj().account_id();
  366. pMatchInfo->m_nMatchGroup = (int16)Obj().match_group();
  367. pMatchInfo->m_RTime32Stamp = Obj().endtime();
  368. pMatchInfo->m_unSeasonID = (uint16)Obj().season_id();
  369. pMatchInfo->m_unStatus = (uint16)Obj().status();
  370. pMatchInfo->m_unPartyID = Obj().party_id();
  371. pMatchInfo->m_unTeam = (uint16)Obj().team();
  372. pMatchInfo->m_unScore = (uint16)Obj().score();
  373. pMatchInfo->m_unPing = (uint16)Obj().ping();
  374. pMatchInfo->m_unFlags = Obj().flags();
  375. pMatchInfo->m_unDisplayRating = Obj().display_rating();
  376. pMatchInfo->m_nDisplayRatingChange = Obj().display_rating_change();
  377. pMatchInfo->m_unRank = (uint16)Obj().rank();
  378. pMatchInfo->m_unClassesPlayed = Obj().classes_played();
  379. pMatchInfo->m_unKills = (uint16)Obj().kills();
  380. pMatchInfo->m_unDeaths = (uint16)Obj().deaths();
  381. pMatchInfo->m_unDamage = Obj().damage();
  382. pMatchInfo->m_unHealing = Obj().healing();
  383. pMatchInfo->m_unSupport = Obj().support();
  384. pMatchInfo->m_unScoreMedal = (uint8)Obj().score_medal();
  385. pMatchInfo->m_unKillsMedal = (uint8)Obj().kills_medal();
  386. pMatchInfo->m_unDamageMedal = (uint8)Obj().damage_medal();
  387. pMatchInfo->m_unHealingMedal = (uint8)Obj().healing_medal();
  388. pMatchInfo->m_unSupportMedal = (uint8)Obj().support_medal();
  389. pMatchInfo->m_unMapIndex = (uint16)Obj().map_index();
  390. }
  391. //-----------------------------------------------------------------------------
  392. // Purpose:
  393. //-----------------------------------------------------------------------------
  394. void CSOTFMatchResultPlayerInfo::ReadFromRecord( const CSchMatchResultPlayerInfo &matchInfo )
  395. {
  396. Obj().set_match_id( matchInfo.m_unMatchID );
  397. Obj().set_account_id( matchInfo.m_unAccountID );
  398. Obj().set_match_group( matchInfo.m_nMatchGroup );
  399. Obj().set_endtime( matchInfo.m_RTime32Stamp );
  400. Obj().set_season_id( matchInfo.m_unSeasonID );
  401. Obj().set_status( matchInfo.m_unStatus );
  402. Obj().set_party_id( matchInfo.m_unPartyID );
  403. Obj().set_team( matchInfo.m_unTeam );
  404. Obj().set_score( matchInfo.m_unScore );
  405. Obj().set_ping( matchInfo.m_unPing );
  406. Obj().set_flags( matchInfo.m_unFlags );
  407. Obj().set_display_rating( matchInfo.m_unDisplayRating );
  408. Obj().set_display_rating_change( matchInfo.m_nDisplayRatingChange );
  409. Obj().set_rank( matchInfo.m_unRank );
  410. Obj().set_classes_played( matchInfo.m_unClassesPlayed );
  411. Obj().set_kills( matchInfo.m_unKills );
  412. Obj().set_deaths( matchInfo.m_unDeaths );
  413. Obj().set_damage( matchInfo.m_unDamage );
  414. Obj().set_healing( matchInfo.m_unHealing );
  415. Obj().set_support( matchInfo.m_unSupport );
  416. Obj().set_score_medal( matchInfo.m_unScoreMedal );
  417. Obj().set_kills_medal( matchInfo.m_unKillsMedal );
  418. Obj().set_damage_medal( matchInfo.m_unDamageMedal );
  419. Obj().set_healing_medal( matchInfo.m_unHealingMedal );
  420. Obj().set_support_medal( matchInfo.m_unSupportMedal );
  421. Obj().set_map_index( matchInfo.m_unMapIndex );
  422. }
  423. //-----------------------------------------------------------------------------
  424. //
  425. //-----------------------------------------------------------------------------
  426. class CGCMatchHistoryLoad : public CGCEconJob
  427. {
  428. public:
  429. CGCMatchHistoryLoad( CGCEcon *pGC ) : CGCEconJob( pGC ) {}
  430. bool BYieldingRunJobFromMsg( GCSDK::IMsgNetPacket *pNetPacket );
  431. };
  432. //-----------------------------------------------------------------------------
  433. // Purpose:
  434. //-----------------------------------------------------------------------------
  435. bool CGCMatchHistoryLoad::BYieldingRunJobFromMsg( IMsgNetPacket *pNetPacket )
  436. {
  437. CProtoBufMsg < CMsgGCMatchHistoryLoad > msg( pNetPacket );
  438. const CSteamID steamID( msg.Hdr().client_steam_id() );
  439. if ( !steamID.IsValid() || !steamID.BIndividualAccount() )
  440. return true;
  441. CTFSharedObjectCache *pSOCache = GGCTF()->YieldingGetLockedTFSOCache( steamID, __FILE__, __LINE__ );
  442. if ( !pSOCache )
  443. return true;
  444. CScopedSteamIDLock playerLock;
  445. playerLock.MarkLocked( steamID );
  446. pSOCache->BYieldingLoadMatchHistoryObjects( true );
  447. return true;
  448. }
  449. GC_REG_JOB( CGCEcon, CGCMatchHistoryLoad, "CGCMatchHistoryLoad", k_EMsgGCMatchHistoryLoad, k_EServerTypeGC );
  450. #endif // GC