X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_basic.pas;h=d58e487a8d9edb6b0c97a12ee3ff90eb0695a628;hb=f356426288dc03a804636aaa21c0d7e049e628ac;hp=1ed87abd9145fba8dbf04b0875b590d38dbb7d2f;hpb=3c277b2aaae8425a26b2d3badc2f6bf5ad2fd817;p=d2df-sdl.git diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas index 1ed87ab..d58e487 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; @@ -73,8 +76,6 @@ function Sign(A: Single): ShortInt; overload; function PointToRect(X, Y, X1, Y1: Integer; Width, Height: Word): Integer; function GetAngle(baseX, baseY, pointX, PointY: Integer): SmallInt; function GetAngle2(vx, vy: Integer): SmallInt; -function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SSArray; -procedure Sort(var a: SSArray); function Sscanf(const s: string; const fmt: string; const Pointers: array of Pointer): Integer; function InDWArray(a: DWORD; arr: DWArray): Boolean; @@ -98,7 +99,34 @@ implementation uses Math, geom, e_log, g_map, g_gfx, g_player, SysUtils, MAPDEF, - StrUtils, e_graphics, g_monsters, g_items, g_game; + StrUtils, 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_HASH%} <> '' 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 @@ -628,58 +656,6 @@ begin end; end; -function GetLines (Text: string; FontID: DWORD; MaxWidth: Word): SSArray; - var i, j, len, lines: Integer; w, cw, ch: Word; skip: Boolean; -begin - result := nil; lines := 0; w := 0; - j := 1; i := 1; len := Length(Text); - while i <= len do - begin - e_CharFont_GetSize(FontID, '' + Text[i], cw, ch); - if (i >= len) or (w + cw >= MaxWidth) then - begin - skip := (i < len) and (Text[i] <> ' '); - if skip then - begin - // alt: while (i >= j) and (Text[i] <> ' ') do Dec(i); - while (i <= len) and (Text[i] <> ' ') do Inc(i); - end; - while (i >= j) and (Text[i] = ' ') do Dec(i); - (* --- *) - SetLength(result, lines + 1); - result[lines] := Copy(Text, j, i - j + 1); - Inc(lines); - (* --- *) - if skip then - begin - while (i <= len) and (Text[i] = ' ') do Inc(i); - Inc(i); - end; - j := i + 1; - w := 0 - end; - Inc(w, cw); - Inc(i) - end; -end; - -procedure Sort(var a: SSArray); -var - i, j: Integer; - s: string; -begin - if a = nil then Exit; - - for i := High(a) downto Low(a) do - for j := Low(a) to High(a)-1 do - if LowerCase(a[j]) > LowerCase(a[j+1]) then - begin - s := a[j]; - a[j] := a[j+1]; - a[j+1] := s; - end; -end; - function Sscanf(const s: String; const fmt: String; const Pointers: array of Pointer): Integer; var