From 027ace8eccb0dc4c1d5ff8796b238d5b1fbbcfed Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 6 Nov 2019 17:50:28 +0300 Subject: [PATCH] add more info about game build to log and window title --- src/game/g_basic.pas | 30 ++++++++++++++++++++++++++++++ src/game/g_main.pas | 2 ++ src/game/sdl/g_system.pas | 15 ++++++++++++--- src/game/sdl2/g_system.pas | 15 ++++++++++++--- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas index 92a7955..7024514 100644 --- a/src/game/g_basic.pas +++ b/src/game/g_basic.pas @@ -38,6 +38,9 @@ type DWArray = array of DWORD; String20 = String[20]; +function g_GetBuilderName (): AnsiString; +function g_GetBuildHash (full: Boolean = True): AnsiString; + function g_CreateUID(UIDType: Byte): Word; function g_GetUIDType(UID: Word): Byte; function g_Collide(X1, Y1: Integer; Width1, Height1: Word; @@ -100,6 +103,33 @@ uses Math, geom, e_log, g_map, g_gfx, g_player, SysUtils, MAPDEF, StrUtils, e_graphics, g_monsters, g_items, g_game; +{$PUSH} +{$WARN 2054 OFF} // unknwon env var +{$WARN 6018 OFF} // unreachable code +function g_GetBuilderName (): AnsiString; +begin + if {$I %D2DF_BUILD_USER%} <> '' then + result := {$I %D2DF_BUILD_USER%} // custom + else if {$I %USER%} <> '' then + result := {$I %USER%} // unix username + else if {$I %USERNAME%} <> '' then + result := {$I %USERNAME%} // windows username + else + result := 'unknown' +end; + +function g_GetBuildHash (full: Boolean = True): AnsiString; +begin + if {$I %D2DF_BUILD_USER%} <> '' then + if full then + result := {$I %D2DF_BUILD_HASH%} + else + result := Copy({$I %D2DF_BUILD_HASH%}, 1, 7) + else + result := 'custom build' +end; +{$POP} + function g_PatchLength(X1, Y1, X2, Y2: Integer): Word; begin Result := Min(Round(Hypot(Abs(X2-X1), Abs(Y2-Y1))), 65535); diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 9fadc1b..8142dd8 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -436,6 +436,8 @@ begin e_InitWritelnDriver(); e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify); e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify); + e_WriteLog('Build hash: ' + g_GetBuildHash(), TMsgType.Notify); + e_WriteLog('Build by: ' + g_GetBuilderName(), TMsgType.Notify); e_LogWritefln('Force bin dir: %s', [forceBinDir], TMsgType.Notify); e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify); diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index 4cb69f9..bdb4add 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -43,10 +43,10 @@ implementation SysUtils, SDL, Math, {$INCLUDE ../nogl/noGLuses.inc} e_log, e_graphics, e_input, e_sound, - g_options, g_window, g_console, g_game, g_menu, g_gui, g_main; + g_options, g_window, g_console, g_game, g_menu, g_gui, g_main, g_basic; const - GameTitle = 'Doom 2D: Forever (SDL 1.2)'; + GameTitle = 'Doom 2D: Forever (SDL 1.2, %s)'; var userResize: Boolean; @@ -89,6 +89,15 @@ implementation g_Game_ClearLoading; end; + function GetTitle (): PChar; + var info: AnsiString; + begin + info := g_GetBuildHash(false); + if info = 'custom build' then + info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME; + result := PChar(Format(GameTitle, [info])) + end; + function InitWindow (w, h, bpp: Integer; fullScreen: Boolean): Boolean; var flags: Uint32; begin @@ -112,7 +121,7 @@ implementation {$IFDEF NOGL_INIT} nogl_Init; {$ENDIF} - SDL_WM_SetCaption(GameTitle, nil); + SDL_WM_SetCaption(GetTitle(), nil); UpdateSize(w, h); result := True end diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index f46c327..6750d68 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -46,10 +46,10 @@ implementation {$IFDEF ENABLE_HOLMES} g_holmes, sdlcarcass, fui_ctls, {$ENDIF} - g_touch, g_options, g_window, g_console, g_game, g_menu, g_gui, g_main; + g_touch, g_options, g_window, g_console, g_game, g_menu, g_gui, g_main, g_basic; const - GameTitle = 'Doom 2D: Forever (SDL 2)'; + GameTitle = 'Doom 2D: Forever (SDL 2, %s)'; var window: PSDL_Window; @@ -98,6 +98,15 @@ implementation {$ENDIF} end; + function GetTitle (): PChar; + var info: AnsiString; + begin + info := g_GetBuildHash(false); + if info = 'custom build' then + info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME; + result := PChar(Format(GameTitle, [info])) + end; + function InitWindow (w, h, bpp: Integer; fullScreen: Boolean): Boolean; var flags: UInt32; begin @@ -122,7 +131,7 @@ implementation {$ENDIF} flags := SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE; if fullScreen then flags := flags or SDL_WINDOW_FULLSCREEN; - window := SDL_CreateWindow(GameTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, flags); + window := SDL_CreateWindow(GetTitle(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, flags); if window <> nil then begin context := SDL_GL_CreateContext(window); -- 2.29.2