summaryrefslogtreecommitdiff
path: root/hammer/buildnum.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/buildnum.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'hammer/buildnum.cpp')
-rw-r--r--hammer/buildnum.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/hammer/buildnum.cpp b/hammer/buildnum.cpp
new file mode 100644
index 0000000..e1a7458
--- /dev/null
+++ b/hammer/buildnum.cpp
@@ -0,0 +1,52 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//===========================================================================//
+#include <stdlib.h>
+#include <string.h>
+#include "tier1/strtools.h"
+
+// char *date = "Oct 24 1996";
+char *date = __DATE__ ;
+
+char *mon[12] =
+{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+char mond[12] =
+{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+// returns days since Oct 24 1996
+int build_number( void )
+{
+ int m = 0;
+ int d = 0;
+ int y = 0;
+ static int b = 0;
+
+ if (b != 0)
+ return b;
+
+ for (m = 0; m < 11; m++)
+ {
+ if ( Q_strnicmp( &date[0], mon[m], 3 ) == 0 )
+ break;
+ d += mond[m];
+ }
+
+ d += atoi( &date[4] ) - 1;
+
+ y = atoi( &date[7] ) - 1900;
+
+ b = d + (int)((y - 1) * 365.25);
+
+ if (((y % 4) == 0) && m > 1)
+ {
+ b += 1;
+ }
+
+ b -= 34995; // Oct 24 1996
+
+ return b;
+}