… | |
… | |
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 | { |
… | |
… | |
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 | } |
271 | } |
272 | |
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 | } |
|
|
287 | |
|
|
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]; |
291 | |
276 | |
292 | static struct los_init |
277 | static struct los_init |
… | |
… | |
502 | * map is the map that changed, x and y are the coordinates. |
487 | * map is the map that changed, x and y are the coordinates. |
503 | */ |
488 | */ |
504 | void |
489 | void |
505 | update_all_los (const maptile *map, int x, int y) |
490 | update_all_los (const maptile *map, int x, int y) |
506 | { |
491 | { |
|
|
492 | // no need to do anything if we don't have darkness |
|
|
493 | if (map->darklevel () <= 0) |
|
|
494 | return; |
|
|
495 | |
507 | map->at (x, y).invalidate (); |
496 | map->at (x, y).invalidate (); |
508 | |
497 | |
509 | for_all_players (pl) |
498 | for_all_players (pl) |
510 | { |
499 | { |
511 | /* Player should not have a null map, but do this |
500 | /* Player should not have a null map, but do this |
… | |
… | |
522 | * player can't be on another map that may be closer, |
511 | * player can't be on another map that may be closer, |
523 | * so by setting it up this way, we trim processing |
512 | * so by setting it up this way, we trim processing |
524 | * some. |
513 | * some. |
525 | */ |
514 | */ |
526 | if (pl->ob->map == map) |
515 | if (pl->ob->map == map) |
527 | { |
|
|
528 | if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) |
516 | if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) |
529 | pl->do_los = 1; |
517 | pl->do_los = 1; |
530 | } |
|
|
531 | |
518 | |
532 | /* Now we check to see if player is on adjacent |
519 | /* Now we check to see if player is on adjacent |
533 | * maps to the one that changed and also within |
520 | * maps to the one that changed and also within |
534 | * view. The tile_maps[] could be null, but in that |
521 | * view. The tile_maps[] could be null, but in that |
535 | * case it should never match the pl->ob->map, so |
522 | * case it should never match the pl->ob->map, so |