--- deliantra/server/common/los.C 2009/11/03 23:44:20 1.63 +++ deliantra/server/common/los.C 2009/11/04 17:24:00 1.64 @@ -126,7 +126,7 @@ // out los calculation times between large and small los maps. // apply_lights also iterates over this area, maybe these // two passes could be combined somehow. - unordered_mapwalk (pl->observe, -half_x, -half_y, half_x, half_y) + unordered_mapwalk (pl->viewpoint, -half_x, -half_y, half_x, half_y) { los_info &l = los [LOS_X0 + dx][LOS_Y0 + dy]; l.flags = m->at (nx, ny).flags () & P_BLOCKSVIEW ? FLG_BLOCKED : 0; @@ -303,12 +303,21 @@ } } los_init; +// brighten area, ignore los +sint8 +los_brighten_nolos (sint8 b, sint8 l) +{ + return min (b, l); +} + +// brighten area, but respect los sint8 los_brighten (sint8 b, sint8 l) { return b == LOS_BLOCKED ? b : min (b, l); } +// darken area, respect los sint8 los_darken (sint8 b, sint8 l) { @@ -343,19 +352,20 @@ static void apply_lights (player *pl) { - object *op = pl->observe; + object *op = pl->viewpoint; int darklevel = op->map->darklevel (); + maptile::outdoor_darkness = 4;//D int half_x = pl->ns->mapx / 2; int half_y = pl->ns->mapy / 2; int pass2 = 0; // negative lights have an extra pass - maprect *rects = pl->observe->map->split_to_tiles ( - pl->observe->x - half_x - MAX_LIGHT_RADIUS, - pl->observe->y - half_y - MAX_LIGHT_RADIUS, - pl->observe->x + half_x + MAX_LIGHT_RADIUS + 1, - pl->observe->y + half_y + MAX_LIGHT_RADIUS + 1 + maprect *rects = pl->viewpoint->map->split_to_tiles ( + pl->viewpoint->x - half_x - MAX_LIGHT_RADIUS, + pl->viewpoint->y - half_y - MAX_LIGHT_RADIUS, + pl->viewpoint->x + half_x + MAX_LIGHT_RADIUS + 1, + pl->viewpoint->y + half_y + MAX_LIGHT_RADIUS + 1 ); /* If the player can see in the dark, increase light/vision radius */ @@ -389,7 +399,7 @@ else { light = clamp (light + bonus, 0, MAX_LIGHT_RADIUS); - apply_light (pl, dx - pl->observe->x, dy - pl->observe->y, light, light_atten [light + MAX_LIGHT_RADIUS]); + apply_light (pl, dx - pl->viewpoint->x, dy - pl->viewpoint->y, light, light_atten [light + MAX_LIGHT_RADIUS]); } } @@ -410,6 +420,10 @@ } } + // when we fly high, we have some minimum viewable area around us, like x-ray + if (op->move_type & MOVE_FLY_HIGH) + apply_light (pl, 0, 0, 9, vision_atten [9]); + // possibly do 2nd pass for rare negative glow radii // for effect, those are always considered to be stronger than anything else // but they can't darken a place completely @@ -424,7 +438,7 @@ if (expect_false (light < 0)) { light = clamp (light - bonus, 0, MAX_DARKNESS); - apply_light (pl, dx - pl->observe->x, dy - pl->observe->y, -light, light_atten [light + MAX_LIGHT_RADIUS]); + apply_light (pl, dx - pl->viewpoint->x, dy - pl->viewpoint->y, -light, light_atten [light + MAX_LIGHT_RADIUS]); } } } @@ -452,7 +466,7 @@ if (ob->flag [FLAG_WIZLOOK]) clear_los (0); - else if (observe->flag [FLAG_BLIND]) /* player is blind */ + else if (viewpoint->flag [FLAG_BLIND]) /* player is blind */ { clear_los (); blinded_sight (this); @@ -464,7 +478,7 @@ apply_lights (this); } - if (observe->flag [FLAG_XRAYS]) + if (viewpoint->flag [FLAG_XRAYS]) for (int dx = -2; dx <= 2; dx++) for (int dy = -2; dy <= 2; dy++) min_it (los[dx + LOS_X0][dy + LOS_Y0], 1);