--- deliantra/server/common/los.C 2008/12/04 22:32:41 1.35 +++ deliantra/server/common/los.C 2008/12/08 15:40:13 1.36 @@ -34,7 +34,6 @@ */ #define SPACE_BLOCK 0.5 -#define MAX_DARKNESS_LOS 4 /* 4 == totally dark */ typedef struct blstr { @@ -197,7 +196,7 @@ * code wants the los to start from the 0,0 * and not be relative to middle of los array. */ - op->contr->blocked_los[ax][ay] = 100; + op->contr->blocked_los[ax][ay] = LOS_BLOCKED; set_wall (op, dx, dy); } } @@ -235,10 +234,9 @@ * whatever has set this space to be blocked has done the work and already * done the dependency chain. */ - if (op->contr->blocked_los[ax][ay] == 100) + if (op->contr->blocked_los[ax][ay] == LOS_BLOCKED) return; - if (get_map_flags (op->map, NULL, op->x + x - MAP_CLIENT_X / 2, op->y + y - MAP_CLIENT_Y / 2, NULL, NULL) & (P_BLOCKSVIEW | P_OUT_OF_MAP)) set_wall (op, x, y); } @@ -327,14 +325,14 @@ for (int distance = 0; distance <= MAX_LIGHT_RADIUS * 3 / 2; ++distance) { // max intensity - int intensity = min (MAX_DARKNESS_LOS, abs (radius) + 1); + int intensity = min (LOS_MAX, abs (radius) + 1); // actual intensity intensity = max (0, lerp_rd (distance, 0, abs (radius) + 1, intensity, 0)); darkness [radius + MAX_LIGHT_RADIUS][distance] = radius < 0 ? min (3, intensity) - : MAX_DARKNESS_LOS - intensity; + : LOS_MAX - intensity; } } } darkness_init; @@ -350,7 +348,7 @@ /* If the player can see in the dark, lower the darklevel for him */ if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) - darklevel -= MAX_DARKNESS_LOS / 2; + darklevel -= LOS_MAX / 2; /* add light, by finding all (non-null) nearby light sources, then * mark those squares specially. If the darklevel<1, there is no @@ -372,8 +370,8 @@ /* first, make everything totally dark */ for (x = 0; x < op->contr->ns->mapx; x++) for (y = 0; y < op->contr->ns->mapy; y++) - if (op->contr->blocked_los[x][y] != 100) - op->contr->blocked_los[x][y] = MAX_DARKNESS_LOS; + if (op->contr->blocked_los[x][y] != LOS_BLOCKED) + op->contr->blocked_los[x][y] = LOS_MAX; int half_x = op->contr->ns->mapx / 2; int half_y = op->contr->ns->mapy / 2; @@ -417,7 +415,7 @@ for (int ax = max (0, basex - light); ax <= min (basex + light, op->contr->ns->mapx - 1); ax++) for (int ay = max (0, basey - light); ay <= min (basey + light, op->contr->ns->mapy - 1); ay++) - if (op->contr->blocked_los[ax][ay] != 100) + if (op->contr->blocked_los[ax][ay] != LOS_BLOCKED) min_it (op->contr->blocked_los[ax][ay], darkness_table [idistance (ax - basex, ay - basey)]); } } @@ -444,7 +442,7 @@ for (int ax = max (0, basex + light); ax <= min (basex - light, op->contr->ns->mapx - 1); ax++) for (int ay = max (0, basey + light); ay <= min (basey - light, op->contr->ns->mapy - 1); ay++) - if (op->contr->blocked_los[ax][ay] != 100) + if (op->contr->blocked_los[ax][ay] != LOS_BLOCKED) max_it (op->contr->blocked_los[ax][ay], darkness_table [idistance (ax - basex, ay - basey)]); } } @@ -454,21 +452,19 @@ */ if (op->map->outdoor && darklevel > MAX_DARKNESS - 3) { - if (op->contr->blocked_los[op->contr->ns->mapx / 2][op->contr->ns->mapy / 2] > (MAX_DARKNESS - 3)) - op->contr->blocked_los[op->contr->ns->mapx / 2][op->contr->ns->mapy / 2] = MAX_DARKNESS - 3; + if (op->contr->blocked_los[op->contr->ns->mapx / 2][op->contr->ns->mapy / 2] > (LOS_MAX - 3)) + op->contr->blocked_los[op->contr->ns->mapx / 2][op->contr->ns->mapy / 2] = LOS_MAX - 3; for (x = -1; x <= 1; x++) for (y = -1; y <= 1; y++) - { - if (op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] > (MAX_DARKNESS - 2)) - op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] = MAX_DARKNESS - 2; - } + if (op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] > (LOS_MAX - 2)) + op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] = LOS_MAX - 2; } /* grant some vision to the player, based on the darklevel */ for (x = darklevel - MAX_DARKNESS; x < MAX_DARKNESS + 1 - darklevel; x++) for (y = darklevel - MAX_DARKNESS; y < MAX_DARKNESS + 1 - darklevel; y++) - if (!(op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] == 100)) + if (!(op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] == LOS_BLOCKED)) op->contr->blocked_los[x + op->contr->ns->mapx / 2][y + op->contr->ns->mapy / 2] -= max (0, 6 - darklevel - max (abs (x), abs (y))); } @@ -485,7 +481,7 @@ for (x = 0; x < op->contr->ns->mapx; x++) for (y = 0; y < op->contr->ns->mapy; y++) - op->contr->blocked_los[x][y] = 100; + op->contr->blocked_los[x][y] = LOS_BLOCKED; op->contr->blocked_los[op->contr->ns->mapx / 2][op->contr->ns->mapy / 2] = 0; }