mirror of
https://github.com/yquake2/ctf.git
synced 2024-11-21 19:31:05 +00:00
Use SOURCE_DATE_EPOCH for reproducible build
Similar to https://github.com/yquake2/yquake2/pull/142 in the yquake2 engine/base game. Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
parent
ca0e44b2a4
commit
3e82fe1ef2
2 changed files with 15 additions and 4 deletions
7
Makefile
7
Makefile
|
@ -70,6 +70,13 @@ endif
|
|||
|
||||
# ----------
|
||||
|
||||
# https://reproducible-builds.org/specs/source-date-epoch/
|
||||
ifdef SOURCE_DATE_EPOCH
|
||||
CFLAGS += -DBUILD_DATE=\"$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +"%b %_d %Y" | sed -e 's/ /\\ /g')\"
|
||||
endif
|
||||
|
||||
# ----------
|
||||
|
||||
# Builds everything
|
||||
all: ctf
|
||||
|
||||
|
|
12
src/g_save.c
12
src/g_save.c
|
@ -28,6 +28,10 @@
|
|||
|
||||
#include "header/local.h"
|
||||
|
||||
#ifndef BUILD_DATE
|
||||
#define BUILD_DATE __DATE__
|
||||
#endif
|
||||
|
||||
field_t fields[] = {
|
||||
{"classname", FOFS(classname), F_LSTRING},
|
||||
{"origin", FOFS(s.origin), F_VECTOR},
|
||||
|
@ -141,7 +145,7 @@ void
|
|||
InitGame(void)
|
||||
{
|
||||
gi.dprintf("Game is starting up.\n");
|
||||
gi.dprintf("Game is ctf built on %s.\n", GAMEVERSION, __DATE__);
|
||||
gi.dprintf("Game is ctf built on %s.\n", GAMEVERSION, BUILD_DATE);
|
||||
|
||||
gun_x = gi.cvar("gun_x", "0", 0);
|
||||
gun_y = gi.cvar("gun_y", "0", 0);
|
||||
|
@ -157,7 +161,7 @@ InitGame(void)
|
|||
/* latched vars */
|
||||
sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
|
||||
gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH);
|
||||
gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH);
|
||||
gi.cvar("gamedate", BUILD_DATE, CVAR_SERVERINFO | CVAR_LATCH);
|
||||
maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
|
||||
deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH);
|
||||
coop = gi.cvar("coop", "0", CVAR_LATCH);
|
||||
|
@ -493,7 +497,7 @@ WriteGame(char *filename, qboolean autosave)
|
|||
}
|
||||
|
||||
memset(str, 0, sizeof(str));
|
||||
strcpy(str, __DATE__);
|
||||
strcpy(str, BUILD_DATE);
|
||||
fwrite(str, sizeof(str), 1, f);
|
||||
|
||||
game.autosaved = autosave;
|
||||
|
@ -526,7 +530,7 @@ ReadGame(char *filename)
|
|||
|
||||
fread(str, sizeof(str), 1, f);
|
||||
|
||||
if (strcmp(str, __DATE__))
|
||||
if (strcmp(str, BUILD_DATE))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an older version.\n");
|
||||
|
|
Loading…
Reference in a new issue