Files
xash3d-fwgs/public/build.c
2025-11-11 06:59:41 +05:00

79 lines
1.6 KiB
C

/*
build.c - returns a engine build number
Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include <stdio.h>
#include "crtlib.h"
#include "buildenums.h"
static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int Q_buildnum_iso( const char *date )
{
int y, m, d, b, i;
if( sscanf( date, "%d-%d-%d", &y, &m, &d ) != 3 || y <= 1900 || m <= 0 || d <= 0 )
return -1;
// fixup day and month
m--;
d--;
for( i = 0; i < m; i++ )
d += mond[i];
y -= 1900;
b = d + (int)((y - 1) * 365.25f );
if((( y % 4 ) == 0 ) && m > 1 )
b += 1;
b -= 41728; // Apr 1 2015
return b;
}
/*
===============
Q_buildnum
returns days since Apr 1 2015
===============
*/
int Q_buildnum( void )
{
static int b = 0;
if( b ) return b;
b = Q_buildnum_iso( g_buildcommit_date );
return b;
}
/*
=============
Q_buildnum_compat
Returns a Xash3D build number. This is left for compability with original Xash3D.
IMPORTANT: this value must be changed ONLY after updating to newer Xash3D base
IMPORTANT: this value must be acquired through "build" cvar.
=============
*/
int Q_buildnum_compat( void )
{
// do not touch this! Only author of Xash3D can increase buildnumbers!
return 4529;
}