author | Gianfranco Costamagna <costamagnagianfranco@yahoo.it> |
Mon, 05 Jan 2015 16:29:27 +0100 | |
changeset 10776 | 56e401fb45ea |
parent 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
7483 | 1 |
unit uAILandMarks; |
2 |
||
3 |
interface |
|
10017 | 4 |
const |
7787
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); |
|
7850 | 13 |
procedure setAILandMarks; |
7483 | 14 |
|
15 |
procedure initModule; |
|
16 |
procedure freeModule; |
|
17 |
||
18 |
implementation |
|
19 |
uses uVariables; |
|
20 |
||
21 |
const gr = 2; |
|
22 |
||
23 |
var marks: array of array of byte; |
|
24 |
WIDTH, HEIGHT: Longword; |
|
25 |
||
26 |
procedure addMark(X, Y: LongInt; mark: byte); |
|
27 |
begin |
|
28 |
if((X and LAND_WIDTH_MASK) = 0) and ((Y and LAND_HEIGHT_MASK) = 0) then |
|
29 |
begin |
|
30 |
X:= X shr gr; |
|
31 |
Y:= Y shr gr; |
|
32 |
marks[Y, X]:= marks[Y, X] or mark |
|
33 |
end |
|
34 |
end; |
|
35 |
||
36 |
function checkMark(X, Y: LongInt; mark: byte) : boolean; |
|
37 |
begin |
|
10017 | 38 |
checkMark:= ((X and LAND_WIDTH_MASK) = 0) |
39 |
and ((Y and LAND_HEIGHT_MASK) = 0) |
|
7483 | 40 |
and ((marks[Y shr gr, X shr gr] and mark) <> 0) |
41 |
end; |
|
42 |
||
43 |
procedure clearAllMarks; |
|
10017 | 44 |
var |
7483 | 45 |
Y, X: Longword; |
46 |
begin |
|
47 |
for Y:= 0 to Pred(HEIGHT) do |
|
48 |
for X:= 0 to Pred(WIDTH) do |
|
49 |
marks[Y, X]:= 0 |
|
50 |
end; |
|
51 |
||
52 |
procedure clearMarks(mark: byte); |
|
10017 | 53 |
var |
7483 | 54 |
Y, X: Longword; |
55 |
begin |
|
56 |
for Y:= 0 to Pred(HEIGHT) do |
|
57 |
for X:= 0 to Pred(WIDTH) do |
|
58 |
marks[Y, X]:= marks[Y, X] and (not mark) |
|
59 |
end; |
|
60 |
||
7850 | 61 |
procedure setAILandMarks; |
7483 | 62 |
begin |
63 |
WIDTH:= LAND_WIDTH shr gr; |
|
64 |
HEIGHT:= LAND_HEIGHT shr gr; |
|
10017 | 65 |
|
7483 | 66 |
SetLength(marks, HEIGHT, WIDTH); |
67 |
end; |
|
68 |
||
7850 | 69 |
procedure initModule; |
70 |
begin |
|
71 |
end; |
|
72 |
||
7483 | 73 |
procedure freeModule; |
74 |
begin |
|
75 |
SetLength(marks, 0, 0); |
|
76 |
end; |
|
77 |
||
78 |
end. |