6a29d61ddb1505532e099efd91f378bd0480f7c9
10 GAME_VERSION
= '0.667';
16 UID_MAX_PLAYER
= $7FFF;
17 UID_MAX_MONSTER
= $FFFF;
20 TDirection
= (D_LEFT
, D_RIGHT
);
21 WArray
= array of Word;
22 DWArray
= array of DWORD
;
23 String20
= String[20];
25 function g_CreateUID(UIDType
: Byte): Word;
26 function g_GetUIDType(UID
: Word): Byte;
27 function g_Collide(X1
, Y1
: Integer; Width1
, Height1
: Word;
28 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
29 function g_CollideLine(x1
, y1
, x2
, y2
, rX
, rY
: Integer; rWidth
, rHeight
: Word): Boolean;
30 function g_CollidePoint(X
, Y
, X2
, Y2
: Integer; Width
, Height
: Word): Boolean;
31 function g_CollideLevel(X
, Y
: Integer; Width
, Height
: Word): Boolean;
32 function g_CollideAround(X1
, Y1
: Integer; Width1
, Height1
: Word;
33 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
34 function g_CollidePlayer(X
, Y
: Integer; Width
, Height
: Word): Boolean;
35 function g_CollideMonster(X
, Y
: Integer; Width
, Height
: Word): Boolean;
36 function g_CollideItem(X
, Y
: Integer; Width
, Height
: Word): Boolean;
37 function g_PatchLength(X1
, Y1
, X2
, Y2
: Integer): Word;
38 function g_TraceVector(X1
, Y1
, X2
, Y2
: Integer): Boolean;
39 function g_GetAcidHit(X
, Y
: Integer; Width
, Height
: Word): Byte;
40 function g_Look(a
, b
: PObj
; d
: TDirection
): Boolean;
41 procedure IncMax(var A
: Integer; B
, Max
: Integer); overload
;
42 procedure IncMax(var A
: Single; B
, Max
: Single); overload
;
43 procedure IncMax(var A
: Integer; Max
: Integer); overload
;
44 procedure IncMax(var A
: Single; Max
: Single); overload
;
45 procedure IncMax(var A
: Word; B
, Max
: Word); overload
;
46 procedure IncMax(var A
: Word; Max
: Word); overload
;
47 procedure IncMax(var A
: SmallInt; B
, Max
: SmallInt); overload
;
48 procedure IncMax(var A
: SmallInt; Max
: SmallInt); overload
;
49 procedure DecMin(var A
: Integer; B
, Min
: Integer); overload
;
50 procedure DecMin(var A
: Single; B
, Min
: Single); overload
;
51 procedure DecMin(var A
: Integer; Min
: Integer); overload
;
52 procedure DecMin(var A
: Single; Min
: Single); overload
;
53 procedure DecMin(var A
: Word; B
, Min
: Word); overload
;
54 procedure DecMin(var A
: Word; Min
: Word); overload
;
55 procedure DecMin(var A
: Byte; B
, Min
: Byte); overload
;
56 procedure DecMin(var A
: Byte; Min
: Byte); overload
;
57 function Sign(A
: Integer): ShortInt; overload
;
58 function Sign(A
: Single): ShortInt; overload
;
59 function PointToRect(X
, Y
, X1
, Y1
: Integer; Width
, Height
: Word): Integer;
60 function GetAngle(baseX
, baseY
, pointX
, PointY
: Integer): SmallInt;
61 function GetAngle2(vx
, vy
: Integer): SmallInt;
62 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
63 procedure Sort(var a
: SArray
);
64 function Sscanf(const s
: string; const fmt
: string;
65 const Pointers
: array of Pointer): Integer;
66 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
67 function InWArray(a
: Word; arr
: WArray
): Boolean;
68 function InSArray(a
: string; arr
: SArray
): Boolean;
69 function GetPos(UID
: Word; o
: PObj
): Boolean;
70 function parse(s
: string): SArray
;
71 function parse2(s
: string; delim
: Char): SArray
;
72 function g_GetFileTime(fileName
: String): Integer;
73 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
74 procedure SortSArray(var S
: SArray
);
75 function b_Text_Format(S
: string): string;
76 function b_Text_Unformat(S
: string): string;
81 Math
, g_map
, g_gfx
, g_player
, SysUtils
, MAPDEF
,
82 StrUtils
, e_graphics
, g_monsters
, g_items
;
84 function g_PatchLength(X1
, Y1
, X2
, Y2
: Integer): Word;
86 Result
:= Min(Round(Hypot(Abs(X2
-X1
), Abs(Y2
-Y1
))), 65535);
89 function g_CollideLevel(X
, Y
: Integer; Width
, Height
: Word): Boolean;
98 for a
:= 0 to High(gWalls
) do
99 if gWalls
[a
].Enabled
and
100 not ( ((Y
+ Height
<= gWalls
[a
].Y
) or
101 (Y
>= gWalls
[a
].Y
+ gWalls
[a
].Height
)) or
102 ((X
+ Width
<= gWalls
[a
].X
) or
103 (X
>= gWalls
[a
].X
+ gWalls
[a
].Width
)) ) then
110 function g_CollidePlayer(X
, Y
: Integer; Width
, Height
: Word): Boolean;
116 if gPlayers
= nil then Exit
;
118 for a
:= 0 to High(gPlayers
) do
119 if (gPlayers
[a
] <> nil) and gPlayers
[a
].Live
then
120 if gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
127 function g_CollideMonster(X
, Y
: Integer; Width
, Height
: Word): Boolean;
133 if gMonsters
= nil then Exit
;
135 for a
:= 0 to High(gMonsters
) do
136 if (gMonsters
[a
] <> nil) and gMonsters
[a
].Live
then
137 if g_Obj_Collide(X
, Y
, Width
, Height
, @gMonsters
[a
].Obj
) then
144 function g_CollideItem(X
, Y
: Integer; Width
, Height
: Word): Boolean;
153 for a
:= 0 to High(gItems
) do
154 if gItems
[a
].Live
then
155 if g_Obj_Collide(X
, Y
, Width
, Height
, @gItems
[a
].Obj
) then
162 function g_TraceVector(X1
, Y1
, X2
, Y2
: Integer): Boolean;
166 Xerr
, Yerr
, d
: LongWord;
172 Assert(gCollideMap
<> nil, 'g_TraceVector: gCollideMap = nil');
179 if dx
> 0 then incX
:= 1 else if dx
< 0 then incX
:= -1 else incX
:= 0;
180 if dy
> 0 then incY
:= 1 else if dy
< 0 then incY
:= -1 else incY
:= 0;
185 if dx
> dy
then d
:= dx
else d
:= dy
;
205 if (y
> gMapInfo
.Height
-1) or
206 (y
< 0) or (x
> gMapInfo
.Width
-1) or (x
< 0) then
208 if ByteBool(gCollideMap
[y
, x
] and MARK_BLOCKED
) then
215 function g_CreateUID(UIDType
: Byte): Word;
226 Result
:= UID_MAX_GAME
+$1+Random(UID_MAX_PLAYER
-UID_MAX_GAME
+$1);
229 if gPlayers
<> nil then
230 for i
:= 0 to High(gPlayers
) do
231 if gPlayers
[i
] <> nil then
232 if Result
= gPlayers
[i
].UID
then
243 Result
:= UID_MAX_PLAYER
+$1+Random(UID_MAX_MONSTER
-UID_MAX_GAME
-UID_MAX_PLAYER
+$1);
246 if gMonsters
<> nil then
247 for i
:= 0 to High(gMonsters
) do
248 if gMonsters
[i
] <> nil then
249 if Result
= gMonsters
[i
].UID
then
259 function g_GetUIDType(UID
: Word): Byte;
261 if UID
<= UID_MAX_GAME
then
264 if UID
<= UID_MAX_PLAYER
then
267 Result
:= UID_MONSTER
;
270 function g_Collide(X1
, Y1
: Integer; Width1
, Height1
: Word;
271 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
273 Result
:= not ( ((Y1
+ Height1
<= Y2
) or
274 (Y2
+ Height2
<= Y1
)) or
275 ((X1
+ Width1
<= X2
) or
276 (X2
+ Width2
<= X1
)) );
279 function g_CollideAround(X1
, Y1
: Integer; Width1
, Height1
: Word;
280 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
282 Result
:= g_Collide(X1
, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
283 g_Collide(X1
+1, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
284 g_Collide(X1
-1, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
285 g_Collide(X1
, Y1
+1, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
286 g_Collide(X1
, Y1
-1, Width1
, Height1
, X2
, Y2
, Width2
, Height2
);
289 function c(X1
, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
: Integer): Boolean;
291 Result
:= not (((Y1
+ Height1
<= Y2
) or
292 (Y1
>= Y2
+ Height2
)) or
293 ((X1
+ Width1
<= X2
) or
294 (X1
>= X2
+ Width2
)));
297 function g_Collide2(X1
, Y1
, X2
, Y2
, X3
, Y3
, X4
, Y4
: Integer): Boolean;
299 //Result := not (((Y2 <= Y3) or (Y1 >= Y4)) or ((X2 <= X3) or (X1 >= X4)));
300 Result
:= c(X1
, Y1
, X2
-X1
, Y2
-Y1
, X3
, Y3
, X4
-X3
, Y4
-Y3
);
303 function g_CollidePoint(X
, Y
, X2
, Y2
: Integer; Width
, Height
: Word): Boolean;
307 Result
:= (x
>= 0) and (x
<= Width
) and
308 (y
>= 0) and (y
<= Height
);
311 procedure IncMax(var A
: Integer; B
, Max
: Integer);
313 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
316 procedure IncMax(var A
: Single; B
, Max
: Single);
318 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
321 procedure DecMin(var A
: Integer; B
, Min
: Integer);
323 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
326 procedure DecMin(var A
: Word; B
, Min
: Word);
328 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
331 procedure DecMin(var A
: Single; B
, Min
: Single);
333 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
336 procedure IncMax(var A
: Integer; Max
: Integer);
338 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
341 procedure IncMax(var A
: Single; Max
: Single);
343 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
346 procedure IncMax(var A
: Word; B
, Max
: Word);
348 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
351 procedure IncMax(var A
: Word; Max
: Word);
353 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
356 procedure IncMax(var A
: SmallInt; B
, Max
: SmallInt);
358 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
361 procedure IncMax(var A
: SmallInt; Max
: SmallInt);
363 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
366 procedure DecMin(var A
: Integer; Min
: Integer);
368 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
371 procedure DecMin(var A
: Single; Min
: Single);
373 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
376 procedure DecMin(var A
: Word; Min
: Word);
378 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
381 procedure DecMin(var A
: Byte; B
, Min
: Byte);
383 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
386 procedure DecMin(var A
: Byte; Min
: Byte); overload
;
388 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
391 function Sign(A
: Integer): ShortInt;
393 if A
< 0 then Result
:= -1
394 else if A
> 0 then Result
:= 1
398 function Sign(A
: Single): ShortInt;
402 if Abs(A
) < Eps
then Result
:= 0
403 else if A
< 0 then Result
:= -1
407 function PointToRect(X
, Y
, X1
, Y1
: Integer; Width
, Height
: Word): Integer;
409 X
:= X
-X1
; // A(0;0) --- B(W;0)
414 if Y
< 0 then // Ñëåâà ñâåðõó: ðàññòîÿíèå äî A
415 Result
:= Round(Hypot(X
, Y
))
417 if Y
> Height
then // Ñëåâà ñíèçó: ðàññòîÿíèå äî D
418 Result
:= Round(Hypot(X
, Y
-Height
))
419 else // Ñëåâà ïîñåðåäèíå: ðàññòîÿíèå äî AD
426 if y
< 0 then // Ñïðàâà ñâåðõó: ðàññòîÿíèå äî B
427 Result
:= Round(Hypot(X
, Y
))
429 if Y
> Height
then // Ñïðàâà ñíèçó: ðàññòîÿíèå äî C
430 Result
:= Round(Hypot(X
, Y
-Height
))
431 else // Ñïðàâà ïîñåðåäèíå: ðàññòîÿíèå äî BC
436 if Y
< 0 then // Ïîñåðåäèíå ñâåðõó: ðàññòîÿíèå äî AB
439 if Y
> Height
then // Ïîñåðåäèíå ñíèçó: ðàññòîÿíèå äî DC
441 else // Âíóòðè ïðÿìîóãîëüíèêà: ðàññòîÿíèå 0
446 function g_GetAcidHit(X
, Y
: Integer; Width
, Height
: Word): Byte;
448 tab
: array[0..3] of Byte = (0, 5, 10, 20);
454 if g_Map_CollidePanel(X
, Y
, Width
, Height
, PANEL_ACID1
, False) then a
:= a
or 1;
455 if g_Map_CollidePanel(X
, Y
, Width
, Height
, PANEL_ACID2
, False) then a
:= a
or 2;
460 function g_Look(a
, b
: PObj
; d
: TDirection
): Boolean;
462 if ((b
^.X
> a
^.X
) and (d
= D_LEFT
)) or
463 ((b
^.X
< a
^.X
) and (d
= D_RIGHT
)) then
469 Result
:= g_TraceVector(a
^.X
+a
^.Rect
.X
+(a
^.Rect
.Width
div 2),
470 a
^.Y
+a
^.Rect
.Y
+(a
^.Rect
.Height
div 2),
471 b
^.X
+b
^.Rect
.X
+(b
^.Rect
.Width
div 2),
472 b
^.Y
+b
^.Rect
.Y
+(b
^.Rect
.Height
div 2));
475 function GetAngle(baseX
, baseY
, pointX
, PointY
: Integer): SmallInt;
480 a
:= abs(pointX
-baseX
);
481 b
:= abs(pointY
-baseY
);
483 if a
= 0 then c
:= 90
484 else c
:= RadToDeg(ArcTan(b
/a
));
486 if pointY
< baseY
then c
:= -c
;
487 if pointX
> baseX
then c
:= 180-c
;
492 function GetAngle2(vx
, vy
: Integer): SmallInt;
503 c
:= RadToDeg(ArcTan(b
/a
));
515 {function g_CollideLine(x1, y1, x2, y2, rX, rY: Integer; rWidth, rHeight: Word): Boolean;
517 table: array[0..8, 0..8] of Byte =
518 ((0, 0, 3, 3, 1, 2, 2, 0, 1),
519 (0, 0, 0, 0, 4, 7, 2, 0, 1),
520 (3, 0, 0, 0, 4, 4, 1, 3, 1),
521 (3, 0, 0, 0, 0, 0, 5, 6, 1),
522 (1, 4, 4, 0, 0, 0, 5, 5, 1),
523 (2, 7, 4, 0, 0, 0, 0, 0, 1),
524 (2, 2, 1, 5, 5, 0, 0, 0, 1),
525 (0, 0, 3, 6, 5, 0, 0, 0, 1),
526 (1, 1, 1, 1, 1, 1, 1, 1, 1));
528 function GetClass(x, y: Integer): Byte;
532 if x < rX then Result := 7
533 else if x < rX+rWidth then Result := 0
536 else if y < rY+rHeight then
538 if x < rX then Result := 6
539 else if x < rX+rWidth then Result := 8
544 if x < rX then Result := 5
545 else if x < rX+rWidth then Result := 4
551 case table[GetClass(x1, y1), GetClass(x2, y2)] of
554 2: Result := Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1));
555 3: Result := Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1));
556 4: Result := Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1));
557 5: Result := Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1));
558 6: Result := (Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1))) and
559 (Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1)));
560 7: Result := (Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1))) and
561 (Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1)));
562 else Result := False;
566 function g_CollideLine(x1
, y1
, x2
, y2
, rX
, rY
: Integer; rWidth
, rHeight
: Word): Boolean;
581 if dx
> 0 then incX
:= 1 else if dx
< 0 then incX
:= -1 else incX
:= 0;
582 if dy
> 0 then incY
:= 1 else if dy
< 0 then incY
:= -1 else incY
:= 0;
587 if dx
> dy
then d
:= dx
else d
:= dy
;
607 if (x
>= rX
) and (x
<= (rX
+ rWidth
- 1)) and
608 (y
>= rY
) and (y
<= (rY
+ rHeight
- 1)) then Exit
;
614 function GetStr(var Str
: string): string;
619 for a
:= 1 to Length(Str
) do
620 if (a
= Length(Str
)) or (Str
[a
+1] = ' ') then
622 Result
:= Copy(Str
, 1, a
);
629 {function GetLines(Text: string; MaxChars: Word): SArray;
637 while Pos(' ', Text) <> 0 do Text := AnsiReplaceStr(Text, ' ', ' ');
641 SetLength(b, Length(b)+1);
642 b[High(b)] := GetStr(Text);
648 if a > High(b) then Break;
653 if Length(str) >= MaxChars then
657 SetLength(Result, Length(Result)+1);
658 Result[High(Result)] := Copy(str, 1, MaxChars);
659 Delete(str, 1, MaxChars);
665 while (a <= High(b)) and (Length(str+' '+b[a]) <= MaxChars) do
671 SetLength(Result, Length(Result)+1);
672 Result[High(Result)] := str;
676 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
678 function TextLen(Text: string): Word;
682 e_CharFont_GetSize(FontID
, Text, Result
, h
);
690 SetLength(Result
, 0);
695 // Óäàëÿåì ìíîæåñòâåííûå ïðîáåëû:
696 while Pos(' ', Text) <> 0 do
697 Text := AnsiReplaceStr(Text, ' ', ' ');
701 SetLength(b
, Length(b
)+1);
702 b
[High(b
)] := GetStr(Text);
714 if TextLen(str
) > MaxWidth
then
715 begin // Òåêóùàÿ ñòðîêà ñëèøêîì äëèííàÿ => ðàçáèâàåì
718 SetLength(Result
, Length(Result
)+1);
721 while (c
< Length(str
)) and
722 (TextLen(Copy(str
, 1, c
+1)) < MaxWidth
) do
725 Result
[High(Result
)] := Copy(str
, 1, c
);
729 else // Ñòðîêà íîðìàëüíîé äëèíû => ñîåäèíÿåì ñî ñëåäóþùèìè
731 while (a
<= High(b
)) and
732 (TextLen(str
+' '+b
[a
]) < MaxWidth
) do
738 SetLength(Result
, Length(Result
)+1);
739 Result
[High(Result
)] := str
;
744 procedure Sort(var a
: SArray
);
749 if a
= nil then Exit
;
751 for i
:= High(a
) downto Low(a
) do
752 for j
:= Low(a
) to High(a
)-1 do
753 if LowerCase(a
[j
]) > LowerCase(a
[j
+1]) then
761 function Sscanf(const s
: String; const fmt
: String;
762 const Pointers
: array of Pointer): Integer;
769 function GetInt(): Integer;
772 while (n
<= Length(s
)) and (s
[n
] = ' ') do
775 while (n
<= Length(s
)) and (s
[n
] in ['0'..'9', '+', '-']) do
781 Result
:= Length(s1
);
784 function GetFloat(): Integer;
787 while (n
<= Length(s
)) and (s
[n
] = ' ') do
790 while (n
<= Length(s
)) and //jd >= rather than >
791 (s
[n
] in ['0'..'9', '+', '-', '.', 'e', 'E']) do
797 Result
:= Length(s1
);
800 function GetString(): Integer;
803 while (n
<= Length(s
)) and (s
[n
] = ' ') do
806 while (n
<= Length(s
)) and (s
[n
] <> ' ') do
812 Result
:= Length(s1
);
815 function ScanStr(c
: Char): Boolean;
817 while (n
<= Length(s
)) and (s
[n
] <> c
) do
821 Result
:= (n
<= Length(s
));
824 function GetFmt(): Integer;
830 while (fmt
[m
] = ' ') and (m
< Length(fmt
)) do
832 if (m
>= Length(fmt
)) then
835 if (fmt
[m
] = '%') then
839 'd': Result
:= vtInteger
;
840 'f': Result
:= vtExtended
;
841 's': Result
:= vtString
;
847 if (not ScanStr(fmt
[m
])) then
859 for i
:= 0 to High(Pointers
) do
868 L
:= StrToIntDef(s1
, 0);
869 Move(L
, Pointers
[i
]^, SizeOf(LongInt));
878 if GetFloat() > 0 then
880 X
:= StrToFloatDef(s1
, 0.0);
881 Move(X
, Pointers
[i
]^, SizeOf(Extended
));
890 if GetString() > 0 then
892 Move(s1
, Pointers
[i
]^, Length(s1
)+1);
905 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
911 if arr
= nil then Exit
;
913 for b
:= 0 to High(arr
) do
921 function InWArray(a
: Word; arr
: WArray
): Boolean;
927 if arr
= nil then Exit
;
929 for b
:= 0 to High(arr
) do
937 function InSArray(a
: string; arr
: SArray
): Boolean;
943 if arr
= nil then Exit
;
945 a
:= AnsiLowerCase(a
);
947 for b
:= 0 to High(arr
) do
948 if AnsiLowerCase(arr
[b
]) = a
then
955 function GetPos(UID
: Word; o
: PObj
): Boolean;
962 case g_GetUIDType(UID
) of
965 p
:= g_Player_Get(UID
);
966 if p
= nil then Exit
;
967 if not p
.Live
then Exit
;
974 m
:= g_Monsters_Get(UID
);
975 if m
= nil then Exit
;
976 if not m
.Live
then Exit
;
986 function parse(s
: String): SArray
;
996 for a
:= 1 to Length(s
) do
997 if (s
[a
] = ',') or (a
= Length(s
)) then
999 SetLength(Result
, Length(Result
)+1);
1002 Result
[High(Result
)] := Copy(s
, 1, a
-1)
1003 else // Êîíåö ñòðîêè
1004 Result
[High(Result
)] := s
;
1012 function parse2(s
: string; delim
: Char): SArray
;
1017 if s
= '' then Exit
;
1021 for a
:= 1 to Length(s
) do
1022 if (s
[a
] = delim
) or (a
= Length(s
)) then
1024 SetLength(Result
, Length(Result
)+1);
1026 if s
[a
] = delim
then Result
[High(Result
)] := Copy(s
, 1, a
-1)
1027 else Result
[High(Result
)] := s
;
1035 function g_GetFileTime(fileName
: String): Integer;
1039 if not FileExists(fileName
) then
1045 AssignFile(F
, fileName
);
1047 Result
:= FileGetDate(TFileRec(F
).Handle
);
1051 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
1055 if (not FileExists(fileName
)) or (time
< 0) then
1061 AssignFile(F
, fileName
);
1063 Result
:= (FileSetDate(TFileRec(F
).Handle
, time
) = 0);
1067 procedure SortSArray(var S
: SArray
);
1075 for i
:= Low(S
) to High(S
) - 1 do
1076 if S
[i
] > S
[i
+ 1] then begin
1085 function b_Text_Format(S
: string): string;
1093 for I
:= 1 to Length(S
) do
1095 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1105 Result
:= Result
+ #10;
1107 Result
:= Result
+ #1;
1109 Result
:= Result
+ #2;
1111 Result
:= Result
+ #3;
1113 Result
:= Result
+ #4;
1115 Result
:= Result
+ #18;
1117 Result
:= Result
+ #19;
1119 Result
:= Result
+ #20;
1121 Result
:= Result
+ #21;
1123 Result
:= Result
+ '\';
1125 Result
:= Result
+ '\' + S
[I
];
1129 Result
:= Result
+ S
[I
];
1131 // reset to white at end
1132 if Rst
then Result
:= Result
+ #2;
1135 function b_Text_Unformat(S
: string): string;
1142 for I
:= 1 to Length(S
) do
1144 if S
[I
] in [#1, #2, #3, #4, #10, #18, #19, #20, #21] then
1149 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1166 '\': Result
:= Result
+ '\';
1168 Result
:= Result
+ '\' + S
[I
];
1172 Result
:= Result
+ S
[I
];