7483
|
1 |
unit uAILandMarks;
|
|
2 |
|
|
3 |
interface
|
|
4 |
const markWasHere = $01;
|
|
5 |
|
|
6 |
procedure addMark(X, Y: LongInt; mark: byte);
|
|
7 |
function checkMark(X, Y: LongInt; mark: byte) : boolean;
|
|
8 |
procedure clearAllMarks;
|
|
9 |
procedure clearMarks(mark: byte);
|
|
10 |
|
|
11 |
procedure initModule;
|
|
12 |
procedure freeModule;
|
|
13 |
|
|
14 |
implementation
|
|
15 |
uses uVariables;
|
|
16 |
|
|
17 |
const gr = 2;
|
|
18 |
|
|
19 |
var marks: array of array of byte;
|
|
20 |
WIDTH, HEIGHT: Longword;
|
|
21 |
|
|
22 |
procedure addMark(X, Y: LongInt; mark: byte);
|
|
23 |
begin
|
|
24 |
if((X and LAND_WIDTH_MASK) = 0) and ((Y and LAND_HEIGHT_MASK) = 0) then
|
|
25 |
begin
|
|
26 |
X:= X shr gr;
|
|
27 |
Y:= Y shr gr;
|
|
28 |
marks[Y, X]:= marks[Y, X] or mark
|
|
29 |
end
|
|
30 |
end;
|
|
31 |
|
|
32 |
function checkMark(X, Y: LongInt; mark: byte) : boolean;
|
|
33 |
begin
|
|
34 |
checkMark:= ((X and LAND_WIDTH_MASK) = 0)
|
|
35 |
and ((Y and LAND_HEIGHT_MASK) = 0)
|
|
36 |
and ((marks[Y shr gr, X shr gr] and mark) <> 0)
|
|
37 |
end;
|
|
38 |
|
|
39 |
procedure clearAllMarks;
|
|
40 |
var
|
|
41 |
Y, X: Longword;
|
|
42 |
begin
|
|
43 |
for Y:= 0 to Pred(HEIGHT) do
|
|
44 |
for X:= 0 to Pred(WIDTH) do
|
|
45 |
marks[Y, X]:= 0
|
|
46 |
end;
|
|
47 |
|
|
48 |
procedure clearMarks(mark: byte);
|
|
49 |
var
|
|
50 |
Y, X: Longword;
|
|
51 |
begin
|
|
52 |
for Y:= 0 to Pred(HEIGHT) do
|
|
53 |
for X:= 0 to Pred(WIDTH) do
|
|
54 |
marks[Y, X]:= marks[Y, X] and (not mark)
|
|
55 |
end;
|
|
56 |
|
|
57 |
|
|
58 |
procedure initModule;
|
|
59 |
begin
|
|
60 |
WIDTH:= LAND_WIDTH shr gr;
|
|
61 |
HEIGHT:= LAND_HEIGHT shr gr;
|
|
62 |
|
|
63 |
SetLength(marks, HEIGHT, WIDTH);
|
|
64 |
end;
|
|
65 |
|
|
66 |
procedure freeModule;
|
|
67 |
begin
|
|
68 |
SetLength(marks, 0, 0);
|
|
69 |
end;
|
|
70 |
|
|
71 |
end.
|