1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
18 interface
20 uses
23 const
35 type
97 var
100 implementation
102 uses
106 {$PUSH}
110 begin
117 else
122 begin
126 else
128 else
131 {$POP}
134 begin
139 begin
140 result := g_Map_CollidePanel(X, Y, Width, Height, (PANEL_WALL or PANEL_CLOSEDOOR or PANEL_OPENDOOR), false);
142 (*
143 var
144 a: Integer;
145 begin
146 Result := False;
148 if gWalls = nil then
149 Exit;
151 for a := 0 to High(gWalls) do
152 if gWalls[a].Enabled and
153 not ( ((Y + Height <= gWalls[a].Y) or
154 (Y >= gWalls[a].Y + gWalls[a].Height)) or
155 ((X + Width <= gWalls[a].X) or
156 (X >= gWalls[a].X + gWalls[a].Width)) ) then
157 begin
158 Result := True;
159 Exit;
160 end;
161 end;
162 *)
165 var
167 begin
175 begin
177 Exit;
183 var
186 (*
187 i: Integer;
188 dx, dy: Integer;
189 Xerr, Yerr, d: LongWord;
190 incX, incY: Integer;
191 x, y: Integer;
192 *)
193 begin
194 (*
195 result := False;
197 Assert(gCollideMap <> nil, 'g_TraceVector: gCollideMap = nil');
199 Xerr := 0;
200 Yerr := 0;
201 dx := X2-X1;
202 dy := Y2-Y1;
204 if dx > 0 then incX := 1 else if dx < 0 then incX := -1 else incX := 0;
205 if dy > 0 then incY := 1 else if dy < 0 then incY := -1 else incY := 0;
207 dx := abs(dx);
208 dy := abs(dy);
210 if dx > dy then d := dx else d := dy;
212 x := X1;
213 y := Y1;
215 for i := 1 to d do
216 begin
217 Inc(Xerr, dx);
218 Inc(Yerr, dy);
219 if Xerr>d then
220 begin
221 Dec(Xerr, d);
222 Inc(x, incX);
223 end;
224 if Yerr > d then
225 begin
226 Dec(Yerr, d);
227 Inc(y, incY);
228 end;
230 if (y > gMapInfo.Height-1) or
231 (y < 0) or (x > gMapInfo.Width-1) or (x < 0) then
232 Exit;
233 if ByteBool(gCollideMap[y, x] and MARK_BLOCKED) then
234 Exit;
235 end;
237 Result := True;
238 *)
240 // `true` if no obstacles
248 var
251 begin
255 UID_PLAYER:
256 begin
257 repeat
265 begin
267 Break;
272 UID_MONSTER:
273 begin
274 //FIXME!!!
276 begin
285 begin
287 Result := UID_GAME
288 else
290 Result := UID_PLAYER
291 else
297 begin
306 begin
315 begin
323 begin
324 //Result := not (((Y2 <= Y3) or (Y1 >= Y4)) or ((X2 <= X3) or (X1 >= X4)));
329 begin
337 begin
342 begin
347 begin
352 begin
357 begin
362 begin
367 begin
372 begin
377 begin
382 begin
387 begin
392 begin
397 begin
402 begin
407 begin
412 begin
417 begin
424 const
426 begin
433 begin
436 // D(0;H) --- C(W;H)
441 else
446 end
447 else
453 else
458 end
460 begin
462 Result := -Y
463 else
472 const
474 var
476 begin
486 begin
491 begin
493 Exit;
503 var
506 begin
520 var
523 begin
529 else
542 {function g_CollideLine(x1, y1, x2, y2, rX, rY: Integer; rWidth, rHeight: Word): Boolean;
543 const
544 table: array[0..8, 0..8] of Byte =
545 ((0, 0, 3, 3, 1, 2, 2, 0, 1),
546 (0, 0, 0, 0, 4, 7, 2, 0, 1),
547 (3, 0, 0, 0, 4, 4, 1, 3, 1),
548 (3, 0, 0, 0, 0, 0, 5, 6, 1),
549 (1, 4, 4, 0, 0, 0, 5, 5, 1),
550 (2, 7, 4, 0, 0, 0, 0, 0, 1),
551 (2, 2, 1, 5, 5, 0, 0, 0, 1),
552 (0, 0, 3, 6, 5, 0, 0, 0, 1),
553 (1, 1, 1, 1, 1, 1, 1, 1, 1));
555 function GetClass(x, y: Integer): Byte;
556 begin
557 if y < rY then
558 begin
559 if x < rX then Result := 7
560 else if x < rX+rWidth then Result := 0
561 else Result := 1;
562 end
563 else if y < rY+rHeight then
564 begin
565 if x < rX then Result := 6
566 else if x < rX+rWidth then Result := 8
567 else Result := 2;
568 end
569 else
570 begin
571 if x < rX then Result := 5
572 else if x < rX+rWidth then Result := 4
573 else Result := 3;
574 end;
575 end;
577 begin
578 case table[GetClass(x1, y1), GetClass(x2, y2)] of
579 0: Result := False;
580 1: Result := True;
581 2: Result := Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1));
582 3: Result := Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1));
583 4: Result := Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1));
584 5: Result := Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1));
585 6: Result := (Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1))) and
586 (Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1)));
587 7: Result := (Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1))) and
588 (Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1)));
589 else Result := False;
590 end;
591 end;}
594 {
595 var
596 i: Integer;
597 dx, dy: Integer;
598 Xerr, Yerr: Integer;
599 incX, incY: Integer;
600 x, y, d: Integer;
601 }
602 begin
604 {
605 Result := True;
607 Xerr := 0;
608 Yerr := 0;
609 dx := X2-X1;
610 dy := Y2-Y1;
612 if dx > 0 then incX := 1 else if dx < 0 then incX := -1 else incX := 0;
613 if dy > 0 then incY := 1 else if dy < 0 then incY := -1 else incY := 0;
615 dx := abs(dx);
616 dy := abs(dy);
618 if dx > dy then d := dx else d := dy;
620 x := X1;
621 y := Y1;
623 for i := 1 to d+1 do
624 begin
625 Inc(Xerr, dx);
626 Inc(Yerr, dy);
627 if Xerr > d then
628 begin
629 Dec(Xerr, d);
630 Inc(x, incX);
631 end;
632 if Yerr > d then
633 begin
634 Dec(Yerr, d);
635 Inc(y, incY);
636 end;
638 if (x >= rX) and (x <= (rX + rWidth - 1)) and
639 (y >= rY) and (y <= (rY + rHeight - 1)) then Exit;
640 end;
642 Result := False;
643 }
647 var
649 begin
653 begin
657 Exit;
665 begin
671 begin
673 result := w
676 begin
679 // e_LogWritefln('GetLines @%s len=%s [%s]', [MaxWidth, len, Text]);
681 begin
682 (* --- Get longest possible sequence --- *)
684 (* --- Do not include part of word --- *)
687 (* --- Do not include spaces --- *)
689 (* --- Add line --- *)
692 // e_LogWritefln(' -> (%s:%s::%s) [%s]', [j, i, GetWidth(j, i), result[lines]]);
694 (* --- Skip spaces --- *)
701 var
704 begin
710 begin
719 var
726 begin
732 begin
741 begin
748 begin
757 begin
763 begin
772 begin
781 begin
785 begin
789 Break;
792 begin
800 Break;
804 Break;
809 begin
816 begin
820 vtInteger :
821 begin
823 begin
827 end
828 else
829 Break;
832 vtExtended :
833 begin
835 begin
839 end
840 else
841 Break;
844 vtString :
845 begin
847 begin
850 end
851 else
852 Break;
856 Break;
862 var
864 begin
871 begin
873 Exit;
878 var
880 begin
887 begin
889 Exit;
894 var
896 begin
905 begin
907 Exit;
912 var
915 begin
919 UID_PLAYER:
920 begin
928 UID_MONSTER:
929 begin
943 var
945 begin
948 Exit;
951 begin
954 begin
963 Break;
969 var
971 begin
976 begin
979 begin
986 Break;
992 var
994 begin
996 begin
998 Exit;
1008 var
1010 begin
1012 begin
1014 Exit;
1024 var
1028 begin
1029 repeat
1042 var
1045 begin
1050 begin
1052 begin
1055 continue;
1058 begin
1080 else
1084 end else
1087 // reset to white at end
1092 var
1095 begin
1099 begin
1101 begin
1103 continue;
1106 begin
1108 continue;
1111 begin
1123 else
1127 end else
1133 begin
1138 var
1140 begin