X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_basic.pas;h=22e318ab4a442a24e36759d25e764053a2011e03;hb=0e101bd452c40da601236aaa2dd4106be47ddce1;hp=e9412a38ee528f62e349972148444b0c239b8426;hpb=d7d166dc3cd287276202e862746208892c4cc89f;p=d2df-sdl.git diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas index e9412a3..22e318a 100644 --- a/src/game/g_basic.pas +++ b/src/game/g_basic.pas @@ -1,9 +1,8 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,10 +18,12 @@ unit g_basic; interface uses - wadreader, g_phys; + utils, g_phys; const GAME_VERSION = '0.667'; + GAME_BUILDDATE = {$I %DATE%}; + GAME_BUILDTIME = {$I %TIME%}; UID_GAME = 1; UID_PLAYER = 2; UID_MONSTER = 3; @@ -72,22 +73,23 @@ 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): SArray; -procedure Sort(var a: SArray); +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; function InWArray(a: Word; arr: WArray): Boolean; -function InSArray(a: string; arr: SArray): Boolean; +function InSArray(a: string; arr: SSArray): Boolean; function GetPos(UID: Word; o: PObj): Boolean; -function parse(s: string): SArray; -function parse2(s: string; delim: Char): SArray; +function parse(s: string): SSArray; +function parse2(s: string; delim: Char): SSArray; function g_GetFileTime(fileName: String): Integer; function g_SetFileTime(fileName: String; time: Integer): Boolean; -procedure SortSArray(var S: SArray); +procedure SortSArray(var S: SSArray); function b_Text_Format(S: string): string; function b_Text_Unformat(S: string): string; - +function b_Text_Wrap(S: string; LineLen: Integer): string; +function b_Text_LineCount(S: string): Integer; var gmon_dbg_los_enabled: Boolean = true; @@ -95,7 +97,7 @@ var implementation uses - Math, e_log, g_map, g_gfx, g_player, SysUtils, MAPDEF, + Math, geom, e_log, g_map, g_gfx, g_player, SysUtils, MAPDEF, StrUtils, e_graphics, g_monsters, g_items, g_game; function g_PatchLength(X1, Y1, X2, Y2: Integer): Word; @@ -559,13 +561,17 @@ begin end;} function g_CollideLine(x1, y1, x2, y2, rX, rY: Integer; rWidth, rHeight: Word): Boolean; +{ var i: Integer; dx, dy: Integer; Xerr, Yerr: Integer; incX, incY: Integer; x, y, d: Integer; +} begin + result := lineAABBIntersects(x1, y1, x2, y2, rX, rY, rWidth, rHeight); +{ Result := True; Xerr := 0; @@ -604,6 +610,7 @@ begin end; Result := False; +} end; function GetStr(var Str: string): string; @@ -621,7 +628,7 @@ begin end; end; -{function GetLines(Text: string; MaxChars: Word): SArray; +{function GetLines(Text: string; MaxChars: Word): SSArray; var a: Integer; b: array of string; @@ -668,7 +675,7 @@ begin end; end;} -function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SArray; +function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SSArray; function TextLen(Text: string): Word; var @@ -682,6 +689,7 @@ var b: array of string; str: string; begin +{ SetLength(Result, 0); SetLength(b, 0); @@ -708,7 +716,7 @@ begin if TextLen(str) > MaxWidth then begin // Òåêóùàÿ ñòðîêà ñëèøêîì äëèííàÿ => ðàçáèâàåì - while str <> '' do + while (str[0] <> #0) and (str <> '') do begin SetLength(Result, Length(Result)+1); @@ -734,9 +742,11 @@ begin Result[High(Result)] := str; end; end; +} + Result := nil end; -procedure Sort(var a: SArray); +procedure Sort(var a: SSArray); var i, j: Integer; s: string; @@ -929,7 +939,7 @@ begin end; end; -function InSArray(a: string; arr: SArray): Boolean; +function InSArray(a: string; arr: SSArray): Boolean; var b: Integer; begin @@ -978,7 +988,7 @@ begin Result := True; end; -function parse(s: String): SArray; +function parse(s: String): SSArray; var a: Integer; begin @@ -1004,7 +1014,7 @@ begin end; end; -function parse2(s: string; delim: Char): SArray; +function parse2(s: string; delim: Char): SSArray; var a: Integer; begin @@ -1059,7 +1069,7 @@ begin CloseFile(F); end; -procedure SortSArray(var S: SArray); +procedure SortSArray(var S: SSArray); var b: Boolean; i: Integer; @@ -1168,4 +1178,19 @@ begin end; end; +function b_Text_Wrap(S: string; LineLen: Integer): string; +begin + Result := WrapText(S, ''#10, [#10, ' ', '-'], LineLen); +end; + +function b_Text_LineCount(S: string): Integer; +var + I: Integer; +begin + Result := IfThen(S = '', 0, 1); + for I := 1 to High(S) do + if S[I] = #10 then + Inc(Result); +end; + end.