1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
25 GAME_VERSION
= '0.667';
31 UID_MAX_PLAYER
= $7FFF;
32 UID_MAX_MONSTER
= $FFFF;
35 TDirection
= (D_LEFT
, D_RIGHT
);
36 WArray
= array of Word;
37 DWArray
= array of DWORD
;
38 String20
= String[20];
40 function g_CreateUID(UIDType
: Byte): Word;
41 function g_GetUIDType(UID
: Word): Byte;
42 function g_Collide(X1
, Y1
: Integer; Width1
, Height1
: Word;
43 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
44 function g_CollideLine(x1
, y1
, x2
, y2
, rX
, rY
: Integer; rWidth
, rHeight
: Word): Boolean;
45 function g_CollidePoint(X
, Y
, X2
, Y2
: Integer; Width
, Height
: Word): Boolean;
46 function g_CollideLevel(X
, Y
: Integer; Width
, Height
: Word): Boolean;
47 function g_CollideAround(X1
, Y1
: Integer; Width1
, Height1
: Word;
48 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
49 function g_CollidePlayer(X
, Y
: Integer; Width
, Height
: Word): Boolean;
50 function g_PatchLength(X1
, Y1
, X2
, Y2
: Integer): Word;
51 function g_TraceVector(X1
, Y1
, X2
, Y2
: Integer): Boolean;
52 function g_GetAcidHit(X
, Y
: Integer; Width
, Height
: Word): Byte;
53 function g_Look(a
, b
: PObj
; d
: TDirection
): Boolean;
54 procedure IncMax(var A
: Integer; B
, Max
: Integer); overload
;
55 procedure IncMax(var A
: Single; B
, Max
: Single); overload
;
56 procedure IncMax(var A
: Integer; Max
: Integer); overload
;
57 procedure IncMax(var A
: Single; Max
: Single); overload
;
58 procedure IncMax(var A
: Word; B
, Max
: Word); overload
;
59 procedure IncMax(var A
: Word; Max
: Word); overload
;
60 procedure IncMax(var A
: SmallInt; B
, Max
: SmallInt); overload
;
61 procedure IncMax(var A
: SmallInt; Max
: SmallInt); overload
;
62 procedure DecMin(var A
: Integer; B
, Min
: Integer); overload
;
63 procedure DecMin(var A
: Single; B
, Min
: Single); overload
;
64 procedure DecMin(var A
: Integer; Min
: Integer); overload
;
65 procedure DecMin(var A
: Single; Min
: Single); overload
;
66 procedure DecMin(var A
: Word; B
, Min
: Word); overload
;
67 procedure DecMin(var A
: Word; Min
: Word); overload
;
68 procedure DecMin(var A
: Byte; B
, Min
: Byte); overload
;
69 procedure DecMin(var A
: Byte; Min
: Byte); overload
;
70 function Sign(A
: Integer): ShortInt; overload
;
71 function Sign(A
: Single): ShortInt; overload
;
72 function PointToRect(X
, Y
, X1
, Y1
: Integer; Width
, Height
: Word): Integer;
73 function GetAngle(baseX
, baseY
, pointX
, PointY
: Integer): SmallInt;
74 function GetAngle2(vx
, vy
: Integer): SmallInt;
75 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
76 procedure Sort(var a
: SArray
);
77 function Sscanf(const s
: string; const fmt
: string;
78 const Pointers
: array of Pointer): Integer;
79 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
80 function InWArray(a
: Word; arr
: WArray
): Boolean;
81 function InSArray(a
: string; arr
: SArray
): Boolean;
82 function GetPos(UID
: Word; o
: PObj
): Boolean;
83 function parse(s
: string): SArray
;
84 function parse2(s
: string; delim
: Char): SArray
;
85 function g_GetFileTime(fileName
: String): Integer;
86 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
87 procedure SortSArray(var S
: SArray
);
88 function b_Text_Format(S
: string): string;
89 function b_Text_Unformat(S
: string): string;
94 Math
, g_map
, g_gfx
, g_player
, SysUtils
, MAPDEF
,
95 StrUtils
, e_graphics
, g_monsters
, g_items
;
97 function g_PatchLength(X1
, Y1
, X2
, Y2
: Integer): Word;
99 Result
:= Min(Round(Hypot(Abs(X2
-X1
), Abs(Y2
-Y1
))), 65535);
102 function g_CollideLevel(X
, Y
: Integer; Width
, Height
: Word): Boolean;
104 result
:= g_Map_CollidePanel(X
, Y
, Width
, Height
, (PANEL_WALL
or PANEL_CLOSEDOOR
or PANEL_OPENDOOR
), false);
115 for a := 0 to High(gWalls) do
116 if gWalls[a].Enabled and
117 not ( ((Y + Height <= gWalls[a].Y) or
118 (Y >= gWalls[a].Y + gWalls[a].Height)) or
119 ((X + Width <= gWalls[a].X) or
120 (X >= gWalls[a].X + gWalls[a].Width)) ) then
128 function g_CollidePlayer(X
, Y
: Integer; Width
, Height
: Word): Boolean;
134 if gPlayers
= nil then Exit
;
136 for a
:= 0 to High(gPlayers
) do
137 if (gPlayers
[a
] <> nil) and gPlayers
[a
].Live
then
138 if gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
145 function g_TraceVector(X1
, Y1
, X2
, Y2
: Integer): Boolean;
149 Xerr
, Yerr
, d
: LongWord;
155 Assert(gCollideMap
<> nil, 'g_TraceVector: gCollideMap = nil');
162 if dx
> 0 then incX
:= 1 else if dx
< 0 then incX
:= -1 else incX
:= 0;
163 if dy
> 0 then incY
:= 1 else if dy
< 0 then incY
:= -1 else incY
:= 0;
168 if dx
> dy
then d
:= dx
else d
:= dy
;
188 if (y
> gMapInfo
.Height
-1) or
189 (y
< 0) or (x
> gMapInfo
.Width
-1) or (x
< 0) then
191 if ByteBool(gCollideMap
[y
, x
] and MARK_BLOCKED
) then
198 function g_CreateUID(UIDType
: Byte): Word;
209 Result
:= UID_MAX_GAME
+$1+Random(UID_MAX_PLAYER
-UID_MAX_GAME
+$1);
212 if gPlayers
<> nil then
213 for i
:= 0 to High(gPlayers
) do
214 if gPlayers
[i
] <> nil then
215 if Result
= gPlayers
[i
].UID
then
228 result
:= UID_MAX_PLAYER
+$1+Random(UID_MAX_MONSTER
-UID_MAX_GAME
-UID_MAX_PLAYER
+$1);
229 if (g_Monsters_ByUID(result
) = nil) then break
;
235 function g_GetUIDType(UID
: Word): Byte;
237 if UID
<= UID_MAX_GAME
then
240 if UID
<= UID_MAX_PLAYER
then
243 Result
:= UID_MONSTER
;
246 function g_Collide(X1
, Y1
: Integer; Width1
, Height1
: Word;
247 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
249 Result
:= not ( ((Y1
+ Height1
<= Y2
) or
250 (Y2
+ Height2
<= Y1
)) or
251 ((X1
+ Width1
<= X2
) or
252 (X2
+ Width2
<= X1
)) );
255 function g_CollideAround(X1
, Y1
: Integer; Width1
, Height1
: Word;
256 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
258 Result
:= g_Collide(X1
, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
259 g_Collide(X1
+1, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
260 g_Collide(X1
-1, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
261 g_Collide(X1
, Y1
+1, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
262 g_Collide(X1
, Y1
-1, Width1
, Height1
, X2
, Y2
, Width2
, Height2
);
265 function c(X1
, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
: Integer): Boolean;
267 Result
:= not (((Y1
+ Height1
<= Y2
) or
268 (Y1
>= Y2
+ Height2
)) or
269 ((X1
+ Width1
<= X2
) or
270 (X1
>= X2
+ Width2
)));
273 function g_Collide2(X1
, Y1
, X2
, Y2
, X3
, Y3
, X4
, Y4
: Integer): Boolean;
275 //Result := not (((Y2 <= Y3) or (Y1 >= Y4)) or ((X2 <= X3) or (X1 >= X4)));
276 Result
:= c(X1
, Y1
, X2
-X1
, Y2
-Y1
, X3
, Y3
, X4
-X3
, Y4
-Y3
);
279 function g_CollidePoint(X
, Y
, X2
, Y2
: Integer; Width
, Height
: Word): Boolean;
283 Result
:= (x
>= 0) and (x
<= Width
) and
284 (y
>= 0) and (y
<= Height
);
287 procedure IncMax(var A
: Integer; B
, Max
: Integer);
289 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
292 procedure IncMax(var A
: Single; B
, Max
: Single);
294 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
297 procedure DecMin(var A
: Integer; B
, Min
: Integer);
299 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
302 procedure DecMin(var A
: Word; B
, Min
: Word);
304 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
307 procedure DecMin(var A
: Single; B
, Min
: Single);
309 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
312 procedure IncMax(var A
: Integer; Max
: Integer);
314 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
317 procedure IncMax(var A
: Single; Max
: Single);
319 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
322 procedure IncMax(var A
: Word; B
, Max
: Word);
324 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
327 procedure IncMax(var A
: Word; Max
: Word);
329 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
332 procedure IncMax(var A
: SmallInt; B
, Max
: SmallInt);
334 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
337 procedure IncMax(var A
: SmallInt; Max
: SmallInt);
339 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
342 procedure DecMin(var A
: Integer; Min
: Integer);
344 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
347 procedure DecMin(var A
: Single; Min
: Single);
349 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
352 procedure DecMin(var A
: Word; Min
: Word);
354 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
357 procedure DecMin(var A
: Byte; B
, Min
: Byte);
359 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
362 procedure DecMin(var A
: Byte; Min
: Byte); overload
;
364 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
367 function Sign(A
: Integer): ShortInt;
369 if A
< 0 then Result
:= -1
370 else if A
> 0 then Result
:= 1
374 function Sign(A
: Single): ShortInt;
378 if Abs(A
) < Eps
then Result
:= 0
379 else if A
< 0 then Result
:= -1
383 function PointToRect(X
, Y
, X1
, Y1
: Integer; Width
, Height
: Word): Integer;
385 X
:= X
-X1
; // A(0;0) --- B(W;0)
390 if Y
< 0 then // Ñëåâà ñâåðõó: ðàññòîÿíèå äî A
391 Result
:= Round(Hypot(X
, Y
))
393 if Y
> Height
then // Ñëåâà ñíèçó: ðàññòîÿíèå äî D
394 Result
:= Round(Hypot(X
, Y
-Height
))
395 else // Ñëåâà ïîñåðåäèíå: ðàññòîÿíèå äî AD
402 if y
< 0 then // Ñïðàâà ñâåðõó: ðàññòîÿíèå äî B
403 Result
:= Round(Hypot(X
, Y
))
405 if Y
> Height
then // Ñïðàâà ñíèçó: ðàññòîÿíèå äî C
406 Result
:= Round(Hypot(X
, Y
-Height
))
407 else // Ñïðàâà ïîñåðåäèíå: ðàññòîÿíèå äî BC
412 if Y
< 0 then // Ïîñåðåäèíå ñâåðõó: ðàññòîÿíèå äî AB
415 if Y
> Height
then // Ïîñåðåäèíå ñíèçó: ðàññòîÿíèå äî DC
417 else // Âíóòðè ïðÿìîóãîëüíèêà: ðàññòîÿíèå 0
422 function g_GetAcidHit(X
, Y
: Integer; Width
, Height
: Word): Byte;
424 tab
: array[0..3] of Byte = (0, 5, 10, 20);
430 if g_Map_CollidePanel(X
, Y
, Width
, Height
, PANEL_ACID1
, False) then a
:= a
or 1;
431 if g_Map_CollidePanel(X
, Y
, Width
, Height
, PANEL_ACID2
, False) then a
:= a
or 2;
436 function g_Look(a
, b
: PObj
; d
: TDirection
): Boolean;
438 if ((b
^.X
> a
^.X
) and (d
= D_LEFT
)) or
439 ((b
^.X
< a
^.X
) and (d
= D_RIGHT
)) then
445 Result
:= g_TraceVector(a
^.X
+a
^.Rect
.X
+(a
^.Rect
.Width
div 2),
446 a
^.Y
+a
^.Rect
.Y
+(a
^.Rect
.Height
div 2),
447 b
^.X
+b
^.Rect
.X
+(b
^.Rect
.Width
div 2),
448 b
^.Y
+b
^.Rect
.Y
+(b
^.Rect
.Height
div 2));
451 function GetAngle(baseX
, baseY
, pointX
, PointY
: Integer): SmallInt;
456 a
:= abs(pointX
-baseX
);
457 b
:= abs(pointY
-baseY
);
459 if a
= 0 then c
:= 90
460 else c
:= RadToDeg(ArcTan(b
/a
));
462 if pointY
< baseY
then c
:= -c
;
463 if pointX
> baseX
then c
:= 180-c
;
468 function GetAngle2(vx
, vy
: Integer): SmallInt;
479 c
:= RadToDeg(ArcTan(b
/a
));
491 {function g_CollideLine(x1, y1, x2, y2, rX, rY: Integer; rWidth, rHeight: Word): Boolean;
493 table: array[0..8, 0..8] of Byte =
494 ((0, 0, 3, 3, 1, 2, 2, 0, 1),
495 (0, 0, 0, 0, 4, 7, 2, 0, 1),
496 (3, 0, 0, 0, 4, 4, 1, 3, 1),
497 (3, 0, 0, 0, 0, 0, 5, 6, 1),
498 (1, 4, 4, 0, 0, 0, 5, 5, 1),
499 (2, 7, 4, 0, 0, 0, 0, 0, 1),
500 (2, 2, 1, 5, 5, 0, 0, 0, 1),
501 (0, 0, 3, 6, 5, 0, 0, 0, 1),
502 (1, 1, 1, 1, 1, 1, 1, 1, 1));
504 function GetClass(x, y: Integer): Byte;
508 if x < rX then Result := 7
509 else if x < rX+rWidth then Result := 0
512 else if y < rY+rHeight then
514 if x < rX then Result := 6
515 else if x < rX+rWidth then Result := 8
520 if x < rX then Result := 5
521 else if x < rX+rWidth then Result := 4
527 case table[GetClass(x1, y1), GetClass(x2, y2)] of
530 2: Result := Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1));
531 3: Result := Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1));
532 4: Result := Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1));
533 5: Result := Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1));
534 6: Result := (Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1))) and
535 (Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1)));
536 7: Result := (Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1))) and
537 (Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1)));
538 else Result := False;
542 function g_CollideLine(x1
, y1
, x2
, y2
, rX
, rY
: Integer; rWidth
, rHeight
: Word): Boolean;
557 if dx
> 0 then incX
:= 1 else if dx
< 0 then incX
:= -1 else incX
:= 0;
558 if dy
> 0 then incY
:= 1 else if dy
< 0 then incY
:= -1 else incY
:= 0;
563 if dx
> dy
then d
:= dx
else d
:= dy
;
583 if (x
>= rX
) and (x
<= (rX
+ rWidth
- 1)) and
584 (y
>= rY
) and (y
<= (rY
+ rHeight
- 1)) then Exit
;
590 function GetStr(var Str
: string): string;
595 for a
:= 1 to Length(Str
) do
596 if (a
= Length(Str
)) or (Str
[a
+1] = ' ') then
598 Result
:= Copy(Str
, 1, a
);
605 {function GetLines(Text: string; MaxChars: Word): SArray;
613 while Pos(' ', Text) <> 0 do Text := AnsiReplaceStr(Text, ' ', ' ');
617 SetLength(b, Length(b)+1);
618 b[High(b)] := GetStr(Text);
624 if a > High(b) then Break;
629 if Length(str) >= MaxChars then
633 SetLength(Result, Length(Result)+1);
634 Result[High(Result)] := Copy(str, 1, MaxChars);
635 Delete(str, 1, MaxChars);
641 while (a <= High(b)) and (Length(str+' '+b[a]) <= MaxChars) do
647 SetLength(Result, Length(Result)+1);
648 Result[High(Result)] := str;
652 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
654 function TextLen(Text: string): Word;
658 e_CharFont_GetSize(FontID
, Text, Result
, h
);
666 SetLength(Result
, 0);
671 // Óäàëÿåì ìíîæåñòâåííûå ïðîáåëû:
672 while Pos(' ', Text) <> 0 do
673 Text := AnsiReplaceStr(Text, ' ', ' ');
677 SetLength(b
, Length(b
)+1);
678 b
[High(b
)] := GetStr(Text);
690 if TextLen(str
) > MaxWidth
then
691 begin // Òåêóùàÿ ñòðîêà ñëèøêîì äëèííàÿ => ðàçáèâàåì
694 SetLength(Result
, Length(Result
)+1);
697 while (c
< Length(str
)) and
698 (TextLen(Copy(str
, 1, c
+1)) < MaxWidth
) do
701 Result
[High(Result
)] := Copy(str
, 1, c
);
705 else // Ñòðîêà íîðìàëüíîé äëèíû => ñîåäèíÿåì ñî ñëåäóþùèìè
707 while (a
<= High(b
)) and
708 (TextLen(str
+' '+b
[a
]) < MaxWidth
) do
714 SetLength(Result
, Length(Result
)+1);
715 Result
[High(Result
)] := str
;
720 procedure Sort(var a
: SArray
);
725 if a
= nil then Exit
;
727 for i
:= High(a
) downto Low(a
) do
728 for j
:= Low(a
) to High(a
)-1 do
729 if LowerCase(a
[j
]) > LowerCase(a
[j
+1]) then
737 function Sscanf(const s
: String; const fmt
: String;
738 const Pointers
: array of Pointer): Integer;
745 function GetInt(): Integer;
748 while (n
<= Length(s
)) and (s
[n
] = ' ') do
751 while (n
<= Length(s
)) and (s
[n
] in ['0'..'9', '+', '-']) do
757 Result
:= Length(s1
);
760 function GetFloat(): Integer;
763 while (n
<= Length(s
)) and (s
[n
] = ' ') do
766 while (n
<= Length(s
)) and //jd >= rather than >
767 (s
[n
] in ['0'..'9', '+', '-', '.', 'e', 'E']) do
773 Result
:= Length(s1
);
776 function GetString(): Integer;
779 while (n
<= Length(s
)) and (s
[n
] = ' ') do
782 while (n
<= Length(s
)) and (s
[n
] <> ' ') do
788 Result
:= Length(s1
);
791 function ScanStr(c
: Char): Boolean;
793 while (n
<= Length(s
)) and (s
[n
] <> c
) do
797 Result
:= (n
<= Length(s
));
800 function GetFmt(): Integer;
806 while (fmt
[m
] = ' ') and (m
< Length(fmt
)) do
808 if (m
>= Length(fmt
)) then
811 if (fmt
[m
] = '%') then
815 'd': Result
:= vtInteger
;
816 'f': Result
:= vtExtended
;
817 's': Result
:= vtString
;
823 if (not ScanStr(fmt
[m
])) then
835 for i
:= 0 to High(Pointers
) do
844 L
:= StrToIntDef(s1
, 0);
845 Move(L
, Pointers
[i
]^, SizeOf(LongInt));
854 if GetFloat() > 0 then
856 X
:= StrToFloatDef(s1
, 0.0);
857 Move(X
, Pointers
[i
]^, SizeOf(Extended
));
866 if GetString() > 0 then
868 Move(s1
, Pointers
[i
]^, Length(s1
)+1);
881 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
887 if arr
= nil then Exit
;
889 for b
:= 0 to High(arr
) do
897 function InWArray(a
: Word; arr
: WArray
): Boolean;
903 if arr
= nil then Exit
;
905 for b
:= 0 to High(arr
) do
913 function InSArray(a
: string; arr
: SArray
): Boolean;
919 if arr
= nil then Exit
;
921 a
:= AnsiLowerCase(a
);
923 for b
:= 0 to High(arr
) do
924 if AnsiLowerCase(arr
[b
]) = a
then
931 function GetPos(UID
: Word; o
: PObj
): Boolean;
938 case g_GetUIDType(UID
) of
941 p
:= g_Player_Get(UID
);
942 if p
= nil then Exit
;
943 if not p
.Live
then Exit
;
950 m
:= g_Monsters_ByUID(UID
);
951 if m
= nil then Exit
;
952 if not m
.Live
then Exit
;
962 function parse(s
: String): SArray
;
972 for a
:= 1 to Length(s
) do
973 if (s
[a
] = ',') or (a
= Length(s
)) then
975 SetLength(Result
, Length(Result
)+1);
978 Result
[High(Result
)] := Copy(s
, 1, a
-1)
980 Result
[High(Result
)] := s
;
988 function parse2(s
: string; delim
: Char): SArray
;
997 for a
:= 1 to Length(s
) do
998 if (s
[a
] = delim
) or (a
= Length(s
)) then
1000 SetLength(Result
, Length(Result
)+1);
1002 if s
[a
] = delim
then Result
[High(Result
)] := Copy(s
, 1, a
-1)
1003 else Result
[High(Result
)] := s
;
1011 function g_GetFileTime(fileName
: String): Integer;
1015 if not FileExists(fileName
) then
1021 AssignFile(F
, fileName
);
1023 Result
:= FileGetDate(TFileRec(F
).Handle
);
1027 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
1031 if (not FileExists(fileName
)) or (time
< 0) then
1037 AssignFile(F
, fileName
);
1039 Result
:= (FileSetDate(TFileRec(F
).Handle
, time
) = 0);
1043 procedure SortSArray(var S
: SArray
);
1051 for i
:= Low(S
) to High(S
) - 1 do
1052 if S
[i
] > S
[i
+ 1] then begin
1061 function b_Text_Format(S
: string): string;
1069 for I
:= 1 to Length(S
) do
1071 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1081 Result
:= Result
+ #10;
1083 Result
:= Result
+ #1;
1085 Result
:= Result
+ #2;
1087 Result
:= Result
+ #3;
1089 Result
:= Result
+ #4;
1091 Result
:= Result
+ #18;
1093 Result
:= Result
+ #19;
1095 Result
:= Result
+ #20;
1097 Result
:= Result
+ #21;
1099 Result
:= Result
+ '\';
1101 Result
:= Result
+ '\' + S
[I
];
1105 Result
:= Result
+ S
[I
];
1107 // reset to white at end
1108 if Rst
then Result
:= Result
+ #2;
1111 function b_Text_Unformat(S
: string): string;
1118 for I
:= 1 to Length(S
) do
1120 if S
[I
] in [#1, #2, #3, #4, #10, #18, #19, #20, #21] then
1125 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1142 '\': Result
:= Result
+ '\';
1144 Result
:= Result
+ '\' + S
[I
];
1148 Result
:= Result
+ S
[I
];