… | |
… | |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <cmath> |
25 | #include <cmath> |
26 | |
26 | |
27 | #define SEE_IN_DARK_RADIUS 3 |
27 | #define SEE_IN_DARK_RADIUS 2 |
28 | |
28 | |
29 | // los flags |
29 | // los flags |
30 | enum { |
30 | enum { |
31 | FLG_XI = 0x01, // we have an x-parent |
31 | FLG_XI = 0x01, // we have an x-parent |
32 | FLG_YI = 0x02, // we have an y-parent |
32 | FLG_YI = 0x02, // we have an y-parent |
… | |
… | |
120 | los [LOS_X0 + (half_x + 1)][dy + LOS_Y0].flags = FLG_QUEUED; |
120 | los [LOS_X0 + (half_x + 1)][dy + LOS_Y0].flags = FLG_QUEUED; |
121 | |
121 | |
122 | // now reset the los area and also add blocked flags |
122 | // now reset the los area and also add blocked flags |
123 | // which supposedly is faster than doing it inside the |
123 | // which supposedly is faster than doing it inside the |
124 | // spiral path algorithm below, except when very little |
124 | // spiral path algorithm below, except when very little |
125 | // area is visible, in which case it is slower, evening |
125 | // area is visible, in which case it is slower. which evens |
126 | // out los calculation times between large and small los maps. |
126 | // out los calculation times between large and small los maps. |
127 | // apply_lights also iterates over this area, maybe these |
127 | // apply_lights also iterates over this area, maybe these |
128 | // two passes could be combined somehow. |
128 | // two passes could be combined somehow. |
129 | unordered_mapwalk (pl->observe, -half_x, -half_y, half_x, half_y) |
129 | unordered_mapwalk (pl->observe, -half_x, -half_y, half_x, half_y) |
130 | { |
130 | { |
… | |
… | |
266 | if (dx <= 0) enqueue (dx - 1, dy, FLG_XI); |
266 | if (dx <= 0) enqueue (dx - 1, dy, FLG_XI); |
267 | if (dy >= 0) enqueue (dx, dy + 1, FLG_YI); |
267 | if (dy >= 0) enqueue (dx, dy + 1, FLG_YI); |
268 | if (dy <= 0) enqueue (dx, dy - 1, FLG_YI); |
268 | if (dy <= 0) enqueue (dx, dy - 1, FLG_YI); |
269 | } |
269 | } |
270 | } |
270 | } |
271 | } |
|
|
272 | |
|
|
273 | /* returns true if op carries one or more lights |
|
|
274 | * This is a trivial function now days, but it used to |
|
|
275 | * be a bit longer. Probably better for callers to just |
|
|
276 | * check the op->glow_radius instead of calling this. |
|
|
277 | */ |
|
|
278 | int |
|
|
279 | has_carried_lights (const object *op) |
|
|
280 | { |
|
|
281 | /* op may glow! */ |
|
|
282 | if (op->glow_radius > 0) |
|
|
283 | return 1; |
|
|
284 | |
|
|
285 | return 0; |
|
|
286 | } |
271 | } |
287 | |
272 | |
288 | /* radius, distance => lightness adjust */ |
273 | /* radius, distance => lightness adjust */ |
289 | static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; |
274 | static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; |
290 | static sint8 vision_atten[MAX_DARKNESS + SEE_IN_DARK_RADIUS + 1][(MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2 + 1]; |
275 | static sint8 vision_atten[MAX_DARKNESS + SEE_IN_DARK_RADIUS + 1][(MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2 + 1]; |