author | koda |
Tue, 23 Oct 2012 15:52:06 +0100 | |
changeset 7801 | 7222dd855540 |
parent 7787 | 67c96b9c179c |
child 7850 | fcbb024090a4 |
permissions | -rw-r--r-- |
7483 | 1 |
unit uAILandMarks; |
2 |
||
3 |
interface |
|
7787
67c96b9c179c
Mark places where tried to jump, avoid too much of thinking
unc0rr
parents:
7483
diff
changeset
|
4 |
const |
67c96b9c179c
Mark places where tried to jump, avoid too much of thinking
unc0rr
parents:
7483
diff
changeset
|
5 |
markWalkedHere = $01; |
67c96b9c179c
Mark places where tried to jump, avoid too much of thinking
unc0rr
parents:
7483
diff
changeset
|
6 |
markHJumped = $02; |
67c96b9c179c
Mark places where tried to jump, avoid too much of thinking
unc0rr
parents:
7483
diff
changeset
|
7 |
markLJumped = $04; |
7483 | 8 |
|
9 |
procedure addMark(X, Y: LongInt; mark: byte); |
|
10 |
function checkMark(X, Y: LongInt; mark: byte) : boolean; |
|
11 |
procedure clearAllMarks; |
|
12 |
procedure clearMarks(mark: byte); |
|
13 |
||
14 |
procedure initModule; |
|
15 |
procedure freeModule; |
|
16 |
||
17 |
implementation |
|
18 |
uses uVariables; |
|
19 |
||
20 |
const gr = 2; |
|
21 |
||
22 |
var marks: array of array of byte; |
|
23 |
WIDTH, HEIGHT: Longword; |
|
24 |
||
25 |
procedure addMark(X, Y: LongInt; mark: byte); |
|
26 |
begin |
|
27 |
if((X and LAND_WIDTH_MASK) = 0) and ((Y and LAND_HEIGHT_MASK) = 0) then |
|
28 |
begin |
|
29 |
X:= X shr gr; |
|
30 |
Y:= Y shr gr; |
|
31 |
marks[Y, X]:= marks[Y, X] or mark |
|
32 |
end |
|
33 |
end; |
|
34 |
||
35 |
function checkMark(X, Y: LongInt; mark: byte) : boolean; |
|
36 |
begin |
|
37 |
checkMark:= ((X and LAND_WIDTH_MASK) = 0) |
|
38 |
and ((Y and LAND_HEIGHT_MASK) = 0) |
|
39 |
and ((marks[Y shr gr, X shr gr] and mark) <> 0) |
|
40 |
end; |
|
41 |
||
42 |
procedure clearAllMarks; |
|
43 |
var |
|
44 |
Y, X: Longword; |
|
45 |
begin |
|
46 |
for Y:= 0 to Pred(HEIGHT) do |
|
47 |
for X:= 0 to Pred(WIDTH) do |
|
48 |
marks[Y, X]:= 0 |
|
49 |
end; |
|
50 |
||
51 |
procedure clearMarks(mark: byte); |
|
52 |
var |
|
53 |
Y, X: Longword; |
|
54 |
begin |
|
55 |
for Y:= 0 to Pred(HEIGHT) do |
|
56 |
for X:= 0 to Pred(WIDTH) do |
|
57 |
marks[Y, X]:= marks[Y, X] and (not mark) |
|
58 |
end; |
|
59 |
||
60 |
||
61 |
procedure initModule; |
|
62 |
begin |
|
63 |
WIDTH:= LAND_WIDTH shr gr; |
|
64 |
HEIGHT:= LAND_HEIGHT shr gr; |
|
65 |
||
66 |
SetLength(marks, HEIGHT, WIDTH); |
|
67 |
end; |
|
68 |
||
69 |
procedure freeModule; |
|
70 |
begin |
|
71 |
SetLength(marks, 0, 0); |
|
72 |
end; |
|
73 |
||
74 |
end. |