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.

79 lines
1.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "quakedef.h"
  9. #include "tier1/strtools.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //char *date = "Nov 07 1998"; // "Oct 24 1996";
  13. char *date = __DATE__ ;
  14. char *mon[12] =
  15. { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  16. char mond[12] =
  17. { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  18. class CBuildNumber
  19. {
  20. public:
  21. CBuildNumber( void )
  22. {
  23. ComputeBuildNumber();
  24. }
  25. // returns days since Nov 07 1998
  26. int GetBuildNumber( void )
  27. {
  28. return m_nBuildNumber;
  29. }
  30. private:
  31. void ComputeBuildNumber( void )
  32. {
  33. int m = 0;
  34. int d = 0;
  35. int y = 0;
  36. for (m = 0; m < 11; m++)
  37. {
  38. if (Q_strncasecmp( &date[0], mon[m], 3 ) == 0)
  39. break;
  40. d += mond[m];
  41. }
  42. d += atoi( &date[4] ) - 1;
  43. y = atoi( &date[7] ) - 1900;
  44. m_nBuildNumber = d + (int)((y - 1) * 365.25);
  45. if (((y % 4) == 0) && m > 1)
  46. {
  47. m_nBuildNumber += 1;
  48. }
  49. //m_nBuildNumber -= 34995; // Oct 24 1996
  50. m_nBuildNumber -= 35739; // Nov 7 1998 (HL1 Gold Date)
  51. }
  52. int m_nBuildNumber;
  53. };
  54. // Singleton
  55. static CBuildNumber g_BuildNumber;
  56. //-----------------------------------------------------------------------------
  57. // Purpose: Only compute build number the first time we run the app
  58. // Output : int
  59. //-----------------------------------------------------------------------------
  60. int build_number( void )
  61. {
  62. return g_BuildNumber.GetBuildNumber();
  63. }