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.

72 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implementation of CSentryRebuildAward
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "SentryRebuildAward.h"
  14. //------------------------------------------------------------------------------------------------------
  15. // Function: CSentryRebuildAward::getWinner
  16. // Purpose: scans to find whose sentry guns were built the most often
  17. //------------------------------------------------------------------------------------------------------
  18. void CSentryRebuildAward::getWinner()
  19. {
  20. CEventListIterator it;
  21. for (it=g_pMatchInfo->eventList()->begin(); it != g_pMatchInfo->eventList()->end(); ++it)
  22. {
  23. if ((*it)->getType()==CLogEvent::BUILD)
  24. {
  25. string built=(*it)->getArgument(1)->getStringValue();
  26. if (stricmp(built.c_str(),"sentry") == 0)
  27. {
  28. PID builder=(*it)->getArgument(0)->asPlayerGetPID();
  29. numbuilds[builder]++;
  30. winnerID=builder;
  31. fNoWinner=false;
  32. }
  33. }
  34. }
  35. map<PID,int>::iterator builditer;
  36. for (builditer=numbuilds.begin();builditer!=numbuilds.end();++builditer)
  37. {
  38. int currID=(*builditer).first;
  39. if (numbuilds[currID]>numbuilds[winnerID])
  40. winnerID=currID;
  41. }
  42. }
  43. //------------------------------------------------------------------------------------------------------
  44. // Function: CSentryRebuildAward::noWinner
  45. // Purpose: writes html indicating that no one built any sentries
  46. // Input: html - the html file to write to
  47. //------------------------------------------------------------------------------------------------------
  48. void CSentryRebuildAward::noWinner(CHTMLFile& html)
  49. {
  50. html.write("No sentries were built during this match.");
  51. }
  52. //------------------------------------------------------------------------------------------------------
  53. // Function: CSentryRebuildAward::extendedinfo
  54. // Purpose: reports how many times the winner had to rebuild their sentry
  55. // Input: html - the html file to write to
  56. //------------------------------------------------------------------------------------------------------
  57. void CSentryRebuildAward::extendedinfo(CHTMLFile& html)
  58. {
  59. if (numbuilds[winnerID] == 1)
  60. html.write("No one had to rebuild a sentry gun in this match.!",winnerName.c_str());
  61. else
  62. html.write("%s had to build a sentry gun %li times!",winnerName.c_str(),numbuilds[winnerID]);
  63. }