Merge branch 'fix-comprevision-replays' into 'master'

Stricter compbranch and comprevision

Closes #398

See merge request KartKrew/Kart!864
This commit is contained in:
toaster 2023-01-06 15:13:46 +00:00
commit 8cf5ebd564
10 changed files with 38 additions and 18 deletions

View file

@ -11,8 +11,9 @@ include(GitUtilities)
git_current_branch(SRB2_COMP_BRANCH)
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED)
git_summary(revision)
string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_REVISION "${revision}")
git_latest_commit(SRB2_COMP_REVISION)
git_subject(subject)
string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_NOTE "${subject}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE None)

View file

@ -50,8 +50,8 @@ function(git_working_tree_dirty variable)
endif()
endfunction()
function(git_summary variable)
_git_easy_command(log -1 "--format=%h %s")
function(git_subject variable)
_git_easy_command(log -1 --format=%s)
endfunction()
function(get_git_dir variable)

View file

@ -11,6 +11,7 @@
#include "config.h"
const char *compbranch = SRB2_COMP_BRANCH;
const char *comprevision = SRB2_COMP_REVISION;
const char *compnote = SRB2_COMP_NOTE;
const char *comptype = CMAKE_BUILD_TYPE;
const int compoptimized = SRB2_COMP_OPTIMIZED;

View file

@ -13,6 +13,7 @@
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
#define SRB2_COMP_NOTE "${SRB2_COMP_NOTE}"
// This is done with configure_file instead of defines in order to avoid
// recompiling the whole target whenever the working directory state changes
#cmakedefine SRB2_COMP_UNCOMMITTED

View file

@ -1189,6 +1189,17 @@ D_ConvertVersionNumbers (void)
#endif
}
const char *D_GetFancyBranchName(void)
{
if (!strcmp(compbranch, ""))
{
// \x8b = aqua highlight
return "\x8b" "detached HEAD" "\x80";
}
return compbranch;
}
//
// D_SRB2Main
//
@ -1206,12 +1217,6 @@ void D_SRB2Main(void)
/* break the version string into version numbers, for netplay */
D_ConvertVersionNumbers();
if (!strcmp(compbranch, ""))
{
// \x8b = aqua highlight
compbranch = "\x8b" "detached HEAD" "\x80";
}
#ifdef DEVELOP
D_AbbrevCommit();
#endif

View file

@ -42,6 +42,8 @@ void D_SRB2Loop(void) FUNCNORETURN;
//
void D_SRB2Main(void);
const char *D_GetFancyBranchName(void);
// Called by IO functions when input is detected.
void D_PostEvent(const event_t *ev);
#if defined (PC_DOS) && !defined (DOXYGEN)

View file

@ -4772,9 +4772,9 @@ static void Command_ListDoomednums_f(void)
static void Command_Version_f(void)
{
#ifdef DEVELOP
CONS_Printf("Ring Racers %s %s (%s %s)\n", compbranch, comprevision, compdate, comptime);
CONS_Printf("Ring Racers %s %s %s (%s %s)\n", D_GetFancyBranchName(), comprevision, compnote, compdate, comptime);
#else
CONS_Printf("Ring Racers %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch);
CONS_Printf("Ring Racers %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, D_GetFancyBranchName());
#endif
// Base library

View file

@ -663,9 +663,16 @@ UINT32 quickncasehash (const char *p, size_t n)
#define PUNCTUATION "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
// Compile date and time and revision.
extern const char *compdate, *comptime, *comprevision, *compbranch;
extern int compuncommitted, compoptimized;
extern const char *comptype;
extern const char
*compdate,
*comptime,
*comprevision,
*compbranch,
*compnote,
*comptype;
extern int
compuncommitted,
compoptimized;
// Disabled code and code under testing
// None of these that are disabled in the normal build are guaranteed to work perfectly

View file

@ -1913,8 +1913,8 @@ void F_VersionDrawer(void)
addtext(V_ALLOWLOWERCASE|V_REDMAP, "Netgame host for testers");
addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", compdate));
#elif defined(DEVELOP)
addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, comprevision);
addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, compbranch);
addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s %s", comprevision, compnote));
addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, D_GetFancyBranchName());
#else // Regular build
addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", VERSIONSTRING));
#endif

View file

@ -7177,7 +7177,10 @@ static void P_InitGametype(void)
int parts;
#ifdef DEVELOP
sprintf(ver, "%s-%s", compbranch, comprevision);
if (strcmp(compbranch, ""))
sprintf(ver, "%s-%s", compbranch, comprevision);
else
strcpy(ver, comprevision);
#else
strcpy(ver, VERSIONSTRING);
#endif