hedgewars/uAILandMarks.pas
author Wuzzy <Wuzzy2@mail.ru>
Thu, 03 May 2018 22:12:13 +0200
changeset 13377 57e15407804d
parent 10017 de822cd3df3a
permissions -rw-r--r--
Continental supplies: Fix continent ammo tooltip containing annoying "use of this weapon does not end turn"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
     1
unit uAILandMarks;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
     2
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
     3
interface
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7850
diff changeset
     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
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
     8
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
     9
procedure addMark(X, Y: LongInt; mark: byte);
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    10
function  checkMark(X, Y: LongInt; mark: byte) : boolean;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    11
procedure clearAllMarks;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    12
procedure clearMarks(mark: byte);
7850
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7787
diff changeset
    13
procedure setAILandMarks;
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    14
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    15
procedure initModule;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    16
procedure freeModule;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    17
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    18
implementation
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    19
uses uVariables;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    20
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    21
const gr = 2;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    22
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    23
var marks: array of array of byte;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    24
    WIDTH, HEIGHT: Longword;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    25
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    26
procedure addMark(X, Y: LongInt; mark: byte);
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    27
begin
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    28
    if((X and LAND_WIDTH_MASK) = 0) and ((Y and LAND_HEIGHT_MASK) = 0) then
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    29
        begin
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    30
        X:= X shr gr;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    31
        Y:= Y shr gr;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    32
        marks[Y, X]:= marks[Y, X] or mark
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    33
        end
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    34
end;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    35
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    36
function  checkMark(X, Y: LongInt; mark: byte) : boolean;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    37
begin
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7850
diff changeset
    38
    checkMark:= ((X and LAND_WIDTH_MASK) = 0)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7850
diff changeset
    39
        and ((Y and LAND_HEIGHT_MASK) = 0)
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    40
        and ((marks[Y shr gr, X shr gr] and mark) <> 0)
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    41
end;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    42
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    43
procedure clearAllMarks;
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7850
diff changeset
    44
var
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    45
    Y, X: Longword;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    46
begin
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    47
    for Y:= 0 to Pred(HEIGHT) do
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    48
        for X:= 0 to Pred(WIDTH) do
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    49
            marks[Y, X]:= 0
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    50
end;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    51
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    52
procedure clearMarks(mark: byte);
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7850
diff changeset
    53
var
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    54
    Y, X: Longword;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    55
begin
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    56
    for Y:= 0 to Pred(HEIGHT) do
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    57
        for X:= 0 to Pred(WIDTH) do
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    58
            marks[Y, X]:= marks[Y, X] and (not mark)
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    59
end;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    60
7850
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7787
diff changeset
    61
procedure setAILandMarks;
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    62
begin
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    63
    WIDTH:= LAND_WIDTH shr gr;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    64
    HEIGHT:= LAND_HEIGHT shr gr;
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7850
diff changeset
    65
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    66
    SetLength(marks, HEIGHT, WIDTH);
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    67
end;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    68
7850
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7787
diff changeset
    69
procedure initModule;
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7787
diff changeset
    70
begin
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7787
diff changeset
    71
end;
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7787
diff changeset
    72
7483
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    73
procedure freeModule;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    74
begin
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    75
    SetLength(marks, 0, 0);
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    76
end;
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    77
d479b98d38f7 unbreak AI. remove inits from uLand
nemo
parents: 7433
diff changeset
    78
end.