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.

119 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implementation of CAllPlayersStats
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "AllPlayersStats.h"
  14. #include "PlayerReport.h"
  15. #include "TextFile.h"
  16. //------------------------------------------------------------------------------------------------------
  17. // Function: CAllPlayersStats::init
  18. // Purpose: intializes the object
  19. //------------------------------------------------------------------------------------------------------
  20. void CAllPlayersStats::init()
  21. {
  22. }
  23. //------------------------------------------------------------------------------------------------------
  24. // Function: CAllPlayersStats::generate
  25. // Purpose: generates intermediate data from match info
  26. //------------------------------------------------------------------------------------------------------
  27. void CAllPlayersStats::generate()
  28. {
  29. }
  30. //------------------------------------------------------------------------------------------------------
  31. // Function: CAllPlayersStats::writeHTML
  32. // Purpose: writes out html based on the intermediate data generated by generate()
  33. // Input: html - the html file to output to
  34. //------------------------------------------------------------------------------------------------------
  35. void CAllPlayersStats::writeHTML(CHTMLFile& html)
  36. {
  37. string filename;
  38. bool result=g_pApp->os->findfirstfile("*.tfs",filename);
  39. if (!result)
  40. return;
  41. multimap<double,CPlrPersist,greater<double> > ranksort;
  42. html.write("<table cols=1 cellspacing=0 border=0 cellpadding=10 bordercolor=black>\n");
  43. while(1)
  44. {
  45. CTextFile f(filename);
  46. pair<double,CPlrPersist> insertme;
  47. insertme.second.read(f);
  48. insertme.first=insertme.second.rank();
  49. ranksort.insert(insertme);
  50. if (!g_pApp->os->findnextfile(filename))
  51. break;
  52. }
  53. g_pApp->os->findfileclose();
  54. multimap<double,CPlrPersist,greater<double> >::iterator rankit=ranksort.begin();
  55. for (rankit;rankit!=ranksort.end();++rankit)
  56. {
  57. bool rowstarted=false;
  58. //double rank=rankit->first;
  59. CPlrPersist* pcpp=&(rankit->second);
  60. time_t cutoff=g_pMatchInfo->logOpenTime() - g_pApp->getCutoffSeconds();
  61. if (pcpp->lastplayed >= cutoff || !g_pApp->eliminateOldPlayers)
  62. {
  63. if (!rowstarted)
  64. {
  65. rowstarted=true;
  66. html.write("<tr>\n");
  67. }
  68. html.write("<td width=300 valign=top>");
  69. CPlayerReport pr(pcpp);
  70. pr.writeHTML(html);
  71. html.write("</td>\n");
  72. }
  73. if (++rankit==ranksort.end())
  74. {
  75. if (rowstarted)
  76. html.write("</tr>\n");
  77. break;
  78. }
  79. //double rank=rankit->first;
  80. CPlrPersist* pcpp2=&(rankit->second);
  81. if (pcpp->lastplayed >= cutoff || !g_pApp->eliminateOldPlayers)
  82. {
  83. if (!rowstarted)
  84. {
  85. rowstarted=true;
  86. html.write("<tr>\n");
  87. }
  88. html.write("<td width=300 valign=top>");
  89. CPlayerReport pr2(pcpp2);
  90. pr2.writeHTML(html);
  91. html.write("</td>\n");
  92. }
  93. if (rowstarted)
  94. html.write("</tr>\n");
  95. }
  96. html.write("</table>");
  97. }