--- deliantra/server/common/los.C 2008/12/23 22:04:17 1.50 +++ deliantra/server/common/los.C 2008/12/24 01:37:23 1.51 @@ -24,6 +24,8 @@ #include #include +#define SEE_IN_DARK_RADIUS 3 + // los flags enum { FLG_XI = 0x01, // we have an x-parent @@ -282,7 +284,7 @@ /* radius, distance => lightness adjust */ static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; -static sint8 vision_atten[MAX_DARKNESS + 1][MAX_DARKNESS * 3 / 2 + 1]; +static sint8 vision_atten[MAX_DARKNESS + SEE_IN_DARK_RADIUS + 1][(MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2 + 1]; static struct los_init { @@ -307,11 +309,9 @@ } /* for general vision */ - for (int radius = 0; radius <= MAX_DARKNESS; ++radius) - for (int distance = 0; distance <= MAX_DARKNESS * 3 / 2; ++distance) - { - vision_atten [radius][distance] = distance <= radius ? 3 : 4; - } + for (int radius = 0; radius <= MAX_DARKNESS + SEE_IN_DARK_RADIUS; ++radius) + for (int distance = 0; distance <= (MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2; ++distance) + vision_atten [radius][distance] = distance <= radius ? 3 : 4; } } los_init; @@ -358,10 +358,6 @@ object *op = pl->observe; int darklevel = op->map->darklevel (); - /* If the player can see in the dark, lower the darklevel for him */ - if (op->flag [FLAG_SEE_IN_DARK]) - darklevel = max (0, darklevel - 2); - int half_x = pl->ns->mapx / 2; int half_y = pl->ns->mapy / 2; @@ -401,6 +397,10 @@ { int light = clamp (MAX_DARKNESS - darklevel, 0, MAX_DARKNESS); + /* If the player can see in the dark, lower the darklevel for him */ + if (op->flag [FLAG_SEE_IN_DARK]) + light += SEE_IN_DARK_RADIUS; + apply_light (pl, 0, 0, light, vision_atten [light]); } }