summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/losparam.cc
blob: 52a2856c801ff057d76d631f9b1aecbef02c6021 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 *  File:       losparam.h
 *  Summary:    Parameters for the LOS algorithm
 */

#include "AppHdr.h"
REVISION("$Rev$");

#include "losparam.h"

#include "cloud.h"
#include "externs.h"
#include "los.h"
#include "stuff.h"
#include "terrain.h"

opacity_type opacity_default::operator()(const coord_def& p) const
{
    int m;
    dungeon_feature_type f = env.grid(p);
    if (feat_is_opaque(f))
        return OPC_OPAQUE;
    else if (is_opaque_cloud(env.cgrid(p)))
        return OPC_HALF;
    else if (f == DNGN_TREES)
        return OPC_HALF;
    else if ((m = mgrd(p)) != NON_MONSTER && menv[m].type == MONS_BUSH)
        return OPC_HALF;
    else
        return OPC_CLEAR;
}

opacity_type opacity_fullyopaque::operator()(const coord_def& p) const
{
    if (feat_is_opaque(env.grid(p)))
        return OPC_OPAQUE;
    else
        return OPC_CLEAR;
}

// Make anything solid block in addition to normal LOS.
// XXX: Are trees, bushes solid?
opacity_type opacity_solid::operator()(const coord_def& p) const
{
    int m;
    dungeon_feature_type f = env.grid(p);
    if (feat_is_solid(f))
        return OPC_OPAQUE;
    else if (is_opaque_cloud(env.cgrid(p)))
        return OPC_HALF;
    else if (f == DNGN_TREES)
        return OPC_HALF;
    else if ((m = mgrd(p)) != NON_MONSTER && menv[m].type == MONS_BUSH)
        return OPC_HALF;
    else
        return OPC_CLEAR;
}

// LOS bounded by fixed presquared radius.
bool bounds_radius_sq::operator()(const coord_def& p) const
{
    return (p.abs() <= radius_sq);
}

// LOS bounded by current global LOS radius.
bool bounds_los_radius::operator()(const coord_def& p) const
{
    return (p.abs() <= get_los_radius_squared());
}