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.

143 lines
6.7 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #include "mm_title.h"
  7. #include "matchext_swarm.h"
  8. #include "swarm.spa.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. TitleDataFieldsDescription_t const * CMatchTitle::DescribeTitleDataStorage()
  12. {
  13. #define TD_ENTRY( szName, nTD, eDataType, numBytesOffset ) \
  14. { szName, TitleDataFieldsDescription_t::nTD, TitleDataFieldsDescription_t::eDataType, numBytesOffset }
  15. static TitleDataFieldsDescription_t tdfd[] =
  16. {
  17. #if 0
  18. // ACHIEVEMENTS
  19. TD_ENTRY( "TD2.COUNT.ACH_BEAT_CAMPAIGNS_EXPERT_MODE", DB_TD2, DT_U8, offsetof( TitleData2, iCountBeatCampaignsExpertMode ) ),
  20. TD_ENTRY( "TD2.COUNT.ACH_CUT_OFF_HEADS_MELEE", DB_TD2, DT_U8, offsetof( TitleData2, iCountCutOffHeadsMelee ) ),
  21. TD_ENTRY( "TD2.COUNT.ACH_KILL_WITH_EVERY_MELEE", DB_TD2, DT_U8, offsetof( TitleData2, iCountKillWithEveryMelee ) ),
  22. TD_ENTRY( "TD2.COUNT.ACH_KILL_INFECTED_WITH_CHAINSAW", DB_TD2, DT_U8, offsetof( TitleData2, iCountKillInfectedWithChainsaw ) ),
  23. TD_ENTRY( "TD2.COUNT.ACH_RES_SURVIVORS_WITH_DEFIB", DB_TD2, DT_U8, offsetof( TitleData2, iCountResSurvivorsWithDefib ) ),
  24. TD_ENTRY( "TD2.COUNT.ACH_SPEED_REVIVE_WITH_ADRENALINE", DB_TD2, DT_U8, offsetof( TitleData2, iCountSpeedReviveWithAdrenaline ) ),
  25. TD_ENTRY( "TD2.COUNT.ACH_IGNITE_INFECTED_FIRE_AMMO", DB_TD2, DT_U8, offsetof( TitleData2, iCountIgniteInfectedFireAmmo ) ),
  26. TD_ENTRY( "TD2.COUNT.ACH_KILL_EVERY_UNCOMMON_INFECTED", DB_TD2, DT_U8, offsetof( TitleData2, iCountKillEveryUncommonInfected ) ),
  27. TD_ENTRY( "TD2.COUNT.ACH_KILL_SUBMERGED_MUDMEN", DB_TD2, DT_U8, offsetof( TitleData2, iCountKillSubmergedMudmen ) ),
  28. TD_ENTRY( "TD2.COUNT.ACH_COLLECT_CEDA_VIALS", DB_TD2, DT_U8, offsetof( TitleData2, iCountCollectCEDAVials ) ),
  29. TD_ENTRY( "TD2.COUNT.ACH_SCAVENGE_COLLECT_CAN_GRIND", DB_TD2, DT_U8, offsetof( TitleData2, iCountScavengeCollectCanGrind ) ),
  30. TD_ENTRY( "TD2.COUNT.ACH_SCAVENGE_CAN_DROP_GRIND", DB_TD2, DT_U8, offsetof( TitleData2, iCountScavengeCanDropGrind ) ),
  31. TD_ENTRY( "TD2.COUNT.ACH_HONK_A_CLOWNS_NOSE", DB_TD2, DT_U8, offsetof( TitleData2, iCountHonkAClownsNose ) ),
  32. TD_ENTRY( "TD2.COMP.ACH_BEAT_CAMPAIGNS_EXPERT_MODE", DB_TD2, DT_U8, offsetof( TitleData2, iCompBeatCampaignsExpertMode ) ),
  33. TD_ENTRY( "TD2.COMP.ACH_KILL_WITH_EVERY_MELEE", DB_TD2, DT_U16, offsetof( TitleData2, iCompKillWithEveryMelee ) ),
  34. TD_ENTRY( "TD2.COMP.ACH_KILL_EVERY_UNCOMMON_INFECTED", DB_TD2, DT_U16, offsetof( TitleData2, iCompKillEveryUncommonInfected ) ),
  35. // AVATAR AWARDS
  36. TD_ENTRY( "TD2.COUNT.ASSET_MED_KIT", DB_TD2, DT_U8, offsetof( TitleData2, iCountBeatCampaignsAnyMode ) ),
  37. TD_ENTRY( "TD2.COMP.ASSET_MED_KIT", DB_TD2, DT_U8, offsetof( TitleData2, iCompBeatCampaignsAnyMode ) ),
  38. TD_ENTRY( "TD2.COUNT.ASSET_PIPE_BOMB", DB_TD2, DT_U16, offsetof( TitleData2, iCountKillTenThousandZombies ) ),
  39. TD_ENTRY( "TD2.COUNT.ASSET_GAS_CAN", DB_TD2, DT_U8, offsetof( TitleData2, iCountWinScavengerMatches ) ),
  40. TD_ENTRY( "TD2.COUNT.ASSET_FRYING_PAN", DB_TD2, DT_U8, offsetof( TitleData2, iCountWinVersusMatches ) ),
  41. // ZOMBIE PANEL SEEN COUNTS
  42. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_INTRO", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelIntro ) ),
  43. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_SMOKER", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelSmoker ) ),
  44. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_BOOMER", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelBoomer ) ),
  45. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_HUNTER", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelHunter ) ),
  46. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_SPITTER", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelSpitter ) ),
  47. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_JOCKEY", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelJockey ) ),
  48. TD_ENTRY( "TD2.COUNT.ZOMBIE_PANEL_CHARGER", DB_TD2, DT_U8, offsetof( TitleData2, iCountZombiePanelCharger ) ),
  49. #endif
  50. // END MARKER
  51. TD_ENTRY( NULL, DB_TD1, DT_U8, 0 )
  52. };
  53. #undef TD_ENTRY
  54. return tdfd;
  55. }
  56. TitleAchievementsDescription_t const * CMatchTitle::DescribeTitleAchievements()
  57. {
  58. static TitleAchievementsDescription_t tad[] =
  59. {
  60. #include "swarm.xhelp.achtitledesc.txt"
  61. // END MARKER
  62. { NULL, 0 }
  63. };
  64. return tad;
  65. }
  66. TitleAvatarAwardsDescription_t const * CMatchTitle::DescribeTitleAvatarAwards()
  67. {
  68. static TitleAvatarAwardsDescription_t taad[] =
  69. {
  70. #include "swarm.xhelp.avawtitledesc.txt"
  71. // END MARKER
  72. { NULL, 0 }
  73. };
  74. return taad;
  75. }
  76. // Title leaderboards
  77. KeyValues * CMatchTitle::DescribeTitleLeaderboard( char const *szLeaderboardView )
  78. {
  79. // Check if this is a survival leaderboard
  80. if ( char const *szSurvivalMap = StringAfterPrefix( szLeaderboardView, "survival_" ) )
  81. {
  82. if ( IsX360() )
  83. {
  84. // Find the corresponding record in the mission script
  85. KeyValues *pSettings = new KeyValues( "settings" );
  86. KeyValues::AutoDelete autodelete_pSettings( pSettings );
  87. pSettings->SetString( "game/mode", "survival" );
  88. KeyValues *pMissionInfo = NULL;
  89. KeyValues *pMapInfo = g_pMatchExtSwarm->GetMapInfoByBspName( pSettings, szSurvivalMap, &pMissionInfo );
  90. if ( !pMapInfo || !pMissionInfo )
  91. return NULL;
  92. // Find the leaderboard description in the map info
  93. KeyValues *pLbDesc = pMapInfo->FindKey( "x360leaderboard" );
  94. if ( !pLbDesc )
  95. return NULL;
  96. // Insert the required keys
  97. pLbDesc = pLbDesc->MakeCopy();
  98. static KeyValues *s_pRatingKey = KeyValues::FromString( ":rating", // X360 leaderboards are rated
  99. " name besttime " // game name of the rating field is "besttime"
  100. " type uint64 " // type is uint64
  101. " rule max" // rated field must be greater than cached value so that it can be written
  102. );
  103. pLbDesc->AddSubKey( s_pRatingKey->MakeCopy() );
  104. pLbDesc->SetString( "besttime/type", "uint64" );
  105. return pLbDesc;
  106. }
  107. if ( IsPC() )
  108. {
  109. KeyValues *pSettings = KeyValues::FromString( "SteamLeaderboard",
  110. " :score besttime " // :score is the leaderboard value mapped to game name "besttime"
  111. );
  112. pSettings->SetInt( ":sort", k_ELeaderboardSortMethodDescending ); // Sort order when fetching and displaying leaderboard data
  113. pSettings->SetInt( ":format", k_ELeaderboardDisplayTypeTimeMilliSeconds ); // Note: this is actually 1/100th seconds type, Steam change pending
  114. pSettings->SetInt( ":upload", k_ELeaderboardUploadScoreMethodKeepBest ); // Upload method when writing to leaderboard
  115. return pSettings;
  116. }
  117. }
  118. return NULL;
  119. }