ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/los.C
(Generate patch)

Comparing deliantra/server/common/los.C (file contents):
Revision 1.52 by root, Fri Dec 26 10:36:42 2008 UTC vs.
Revision 1.55 by root, Tue Jan 6 19:17:06 2009 UTC

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 */
278int
279has_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 */
289static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; 274static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1];
290static sint8 vision_atten[MAX_DARKNESS + SEE_IN_DARK_RADIUS + 1][(MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2 + 1]; 275static sint8 vision_atten[MAX_DARKNESS + SEE_IN_DARK_RADIUS + 1][(MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2 + 1];
291 276
292static struct los_init 277static 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 */
504void 489void
505update_all_los (const maptile *map, int x, int y) 490update_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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines