Skip to content

Commit

Permalink
add git hash to console
Browse files Browse the repository at this point in the history
  • Loading branch information
Razish committed Sep 30, 2023
1 parent 7a903fc commit 0c5f500
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
13 changes: 11 additions & 2 deletions code/client/cl_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "qcommon/stringed_ingame.h"
#include "qcommon/stv_version.h"
#include "qcommon/q_version.h"

int g_console_field_width = 78;

Expand Down Expand Up @@ -567,11 +568,19 @@ void Con_DrawSolidConsole( float frac )
re.SetColor( console_color );
re.DrawStretchPic( 0, y, SCREEN_WIDTH, 2, 0, 0, 0, 0, cls.whiteShader );

i = strlen( Q3_VERSION );
i = strlen( JK_VERSION );

for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
(lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), Q3_VERSION[x] );
(lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), JK_VERSION[x] );
}

const char *revision = "revision: " GIT_HASH;
i = strlen(revision);

for (x = 0; x < i; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - (i - x + 1) * SMALLCHAR_WIDTH,
(lines - (SMALLCHAR_HEIGHT * 2 + SMALLCHAR_HEIGHT / 2)), revision[x] );
}

// draw the text
Expand Down
4 changes: 2 additions & 2 deletions code/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ Com_Init
void Com_Init( char *commandLine ) {
char *s;

Com_Printf( "%s %s %s\n", Q3_VERSION, PLATFORM_STRING, SOURCE_DATE );
Com_Printf( "%s %s %s\n", JK_VERSION, PLATFORM_STRING, SOURCE_DATE );

try {
Com_InitZoneMemory();
Expand Down Expand Up @@ -1128,7 +1128,7 @@ void Com_Init( char *commandLine ) {
Cmd_AddCommand ("freeze", Com_Freeze_f);
}

s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, SOURCE_DATE );
s = va("%s %s %s", JK_VERSION, PLATFORM_STRING, SOURCE_DATE );
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
com_revision = Cvar_Get ("com_revision", GIT_HASH, CVAR_ROM | CVAR_SERVERINFO );

Expand Down
6 changes: 3 additions & 3 deletions code/qcommon/stv_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "../win32/AutoVersion.h"

#ifdef _DEBUG
#define Q3_VERSION "(debug)OpenJK: v" VERSION_STRING_DOTTED
#define JK_VERSION "(debug)OpenJK: v" VERSION_STRING_DOTTED
#elif defined FINAL_BUILD
#define Q3_VERSION "OpenJK: v" VERSION_STRING_DOTTED
#define JK_VERSION "OpenJK: v" VERSION_STRING_DOTTED
#else
#define Q3_VERSION "(internal)OpenJK: v" VERSION_STRING_DOTTED
#define JK_VERSION "(internal)OpenJK: v" VERSION_STRING_DOTTED
#endif
// end

Expand Down
6 changes: 3 additions & 3 deletions code/ui/ui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ void UI_FreeAllSpecies( void )
UI_FreeSpecies(&uiInfo.playerSpecies[i]);
}
free(uiInfo.playerSpecies);

uiInfo.playerSpeciesCount = 0;
uiInfo.playerSpecies = NULL;
}
Expand Down Expand Up @@ -3696,9 +3696,9 @@ static void UI_Version(rectDef_t *rect, float scale, vec4_t color, int iFontInde
{
int width;

width = DC->textWidth(Q3_VERSION, scale, 0);
width = DC->textWidth(JK_VERSION, scale, 0);

DC->drawText(rect->x - width, rect->y, scale, color, Q3_VERSION, 0, ITEM_TEXTSTYLE_SHADOWED, iFontIndex);
DC->drawText(rect->x - width, rect->y, scale, color, JK_VERSION, 0, ITEM_TEXTSTYLE_SHADOWED, iFontIndex);
}

/*
Expand Down
9 changes: 9 additions & 0 deletions codemp/client/cl_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "cl_cgameapi.h"
#include "qcommon/stringed_ingame.h"
#include "qcommon/game_version.h"
#include "qcommon/q_version.h"


int g_console_field_width = 78;
Expand Down Expand Up @@ -743,6 +744,14 @@ void Con_DrawSolidConsole( float frac ) {
(lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), JK_VERSION[x] );
}

const char *revision = "revision: " GIT_HASH;
i = strlen( revision );

for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
(lines-(SMALLCHAR_HEIGHT*2+SMALLCHAR_HEIGHT/2)), revision[x] );
}


// draw the text
con.vislines = lines;
Expand Down

0 comments on commit 0c5f500

Please sign in to comment.