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.

96 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implementation of CPlayerSpecifics
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "PlayerSpecifics.h"
  14. #include "PlayerReport.h"
  15. //------------------------------------------------------------------------------------------------------
  16. // Function: CPlayerSpecifics::init
  17. // Purpose: intializes the object
  18. //------------------------------------------------------------------------------------------------------
  19. void CPlayerSpecifics::init()
  20. {
  21. }
  22. //------------------------------------------------------------------------------------------------------
  23. // Function: CPlayerSpecifics::generate
  24. // Purpose: generates intermediate data from match info
  25. //------------------------------------------------------------------------------------------------------
  26. void CPlayerSpecifics::generate()
  27. {
  28. }
  29. //------------------------------------------------------------------------------------------------------
  30. // Function: CPlayerSpecifics::writeHTML
  31. // Purpose: writes out html based on the intermediate data generated by generate()
  32. // Input: html - the html file to output to
  33. //------------------------------------------------------------------------------------------------------
  34. void CPlayerSpecifics::writeHTML(CHTMLFile& html)
  35. {
  36. int numteams=0;
  37. for (int t=0;t<MAX_TEAMS;t++)
  38. if (g_pMatchInfo->teamExists(t)) numteams++;
  39. html.write("<table cols=%li cellspacing=0 border=0 cellpadding=10 bordercolor=black>\n",numteams);
  40. CPlayerListIterator i;
  41. //multimap<double,CPlayer,greater<double> > ranksort;
  42. //split playerlist into teams;
  43. multimap<double,CPlayer,greater<double> > rankedteams[MAX_TEAMS];
  44. for (i=g_pMatchInfo->playerBegin();i!=g_pMatchInfo->playerEnd();++i)
  45. {
  46. PID pid=(*i).first;
  47. CPlayer p=(*i).second;
  48. for (int t=0;t<MAX_TEAMS;t++)
  49. {
  50. if (p.teams.contains(t))
  51. {
  52. double rank=p.perteam[t].rank();
  53. pair<double,CPlayer> insertme(rank,p);
  54. rankedteams[t].insert(insertme);
  55. }
  56. }
  57. }
  58. while(!rankedteams[0].empty() || !rankedteams[1].empty() || !rankedteams[2].empty() || !rankedteams[3].empty())
  59. {
  60. html.write("<tr>\n");
  61. int t;
  62. for (t=0;t<MAX_TEAMS;t++)
  63. {
  64. if (!g_pMatchInfo->teamExists(t))
  65. continue;
  66. html.write("<td width=250 valign=top>");
  67. if (rankedteams[t].begin()==rankedteams[t].end())
  68. continue;
  69. else
  70. {
  71. CPlayer& plr=(*(rankedteams[t].begin())).second;
  72. CPlayerReport cpr(&plr,t);
  73. cpr.writeHTML(html);
  74. rankedteams[t].erase(rankedteams[t].begin());
  75. //break;
  76. }
  77. html.write("</td>\n");
  78. }
  79. html.write("</tr>\n");
  80. }
  81. html.write("</table>");
  82. }