32 #define SPACE_BLOCK 0.5
43 #define SEE_IN_DARK_LEVELS 2
48 #define LOS_BLOCKED 100
49 #define LOS_NO_DARKNESS 0
84 for (i = 0; i <
index; i++) {
108 static const int block_x[3] = {
128 for (i = 0; i < 3; i++) {
156 l =
FABS(sqrt(d1)*s);
199 for (
int i = 0; i < at->
index; i++) {
200 int dx = at->
x[i], dy = at->
y[i];
210 if (x < 0 || x >=
pl->socket->mapx
211 || y < 0 || y >=
pl->socket->mapy
248 if (ax < 0 || ay < 0 || ax >=
op->contr->socket->mapx || ay >=
op->contr->socket->mapy)
294 for (
x = 1;
x <
op->contr->socket->mapx-1;
x++) {
295 for (
y = 1;
y <
op->contr->socket->mapy-1;
y++) {
299 op->x-
op->contr->socket->mapx/2+
x,
300 op->y-
op->contr->socket->mapy/2+
y,
303 for (i = 1; i <= 8; i += 1) {
322 for (
x = 0;
x <
op->contr->socket->mapx;
x++) {
323 for (
y = 0;
y <
op->contr->socket->mapy;
y++) {
348 if (
op->glow_radius > 0)
361 int x,
y, darklevel, ax, ay, basex, basey, mflags, light_radius, dark_change;
383 LOG(
llevError,
"Map darkness for %s on %s is too high (%d)\n",
op->name,
op->map->path, darklevel);
388 for (
x = 0;
x <
op->contr->socket->mapx;
x++)
389 for (
y = 0;
y <
op->contr->socket->mapy;
y++)
417 if (light_radius == 0)
420 for (ax = basex-light_radius; ax <= basex+light_radius; ax++) {
422 if (ax < 0 || ax >=
op->contr->socket->mapx)
425 for (ay = basey-light_radius; ay <= basey+light_radius; ay++) {
427 if (ay < 0 || ay >=
op->contr->socket->mapy)
443 if (light_radius > 0)
444 op->contr->blocked_los[ax][ay] -=
MAX((light_radius-
ihypot(x1, y1)), 0);
445 if (light_radius < 0)
446 op->contr->blocked_los[ax][ay] -=
MIN((light_radius+
ihypot(x1, y1)), 0);
458 if (
op->contr->blocked_los[
op->contr->socket->mapx/2][
op->contr->socket->mapy/2] > (
MAX_DARKNESS-3))
459 op->contr->blocked_los[
op->contr->socket->mapx/2][
op->contr->socket->mapy/2] =
MAX_DARKNESS-3;
462 for (
x = -1;
x <= 1;
x++) {
463 for (
y = -1;
y <= 1;
y++) {
464 if (
op->contr->blocked_los[
x+
op->contr->socket->mapx/2][
y+
op->contr->socket->mapy/2] > (
MAX_DARKNESS-2))
465 op->contr->blocked_los[
x+
op->contr->socket->mapx/2][
y+
op->contr->socket->mapy/2] =
MAX_DARKNESS-2;
475 if (!(
op->contr->blocked_los[
x+
op->contr->socket->mapx/2][
y+
op->contr->socket->mapy/2] ==
LOS_BLOCKED)) {
477 op->contr->blocked_los[
x+
op->contr->socket->mapx/2][
y+
op->contr->socket->mapy/2] -= dark_change;
495 for (
x = 0;
x <
pl->socket->mapx;
x++)
496 for (
y = 0;
y <
pl->socket->mapy;
y++)
510 int mapx, mapy, dx, dy,
x,
y;
522 mapx =
op->contr->socket->mapx;
523 mapy =
op->contr->socket->mapy;
571 if (
pl->ob->map ==
map)
614 if (
pl->ob->map ==
map) {
615 if ((abs(
pl->ob->x-
x) <=
pl->socket->mapx/2)
616 && (abs(
pl->ob->y-
y) <=
pl->socket->mapy/2))
635 else if (
pl->ob->map ==
map->tile_map[0]) {
636 if ((abs(
pl->ob->x-
x) <=
pl->socket->mapx/2)
639 }
else if (
pl->ob->map ==
map->tile_map[2]) {
640 if ((abs(
pl->ob->x-
x) <=
pl->socket->mapx/2)
643 }
else if (
pl->ob->map ==
map->tile_map[1]) {
645 && (abs(
pl->ob->y-
y) <=
pl->socket->mapy/2))
647 }
else if (
pl->ob->map ==
map->tile_map[3]) {
649 && (abs(
pl->ob->y-
y) <=
pl->socket->mapy/2))
669 snprintf(
buf,
sizeof(
buf),
"[fixed] ");
670 for (
x = 0;
x <
op->contr->socket->mapx;
x++) {
671 snprintf(buf2,
sizeof(buf2),
"%2d",
x);
672 strncat(
buf, buf2,
sizeof(
buf)-strlen(
buf)-1);
675 for (
y = 0;
y <
op->contr->socket->mapy;
y++) {
676 snprintf(
buf,
sizeof(
buf),
"[fixed]%2d:",
y);
677 for (
x = 0;
x <
op->contr->socket->mapx;
x++) {
678 snprintf(buf2,
sizeof(buf2),
" %1d",
op->contr->blocked_los[
x][
y] ==
LOS_BLOCKED ? 1 : 0);
679 strncat(
buf, buf2,
sizeof(
buf)-strlen(
buf)-1);
699 if (
pl->ob->map ==
op->map
700 &&
pl->ob->y-
pl->socket->mapy/2 <=
op->y
701 &&
pl->ob->y+
pl->socket->mapy/2 >=
op->y
702 &&
pl->ob->x-
pl->socket->mapx/2 <=
op->x
703 &&
pl->ob->x+
pl->socket->mapx/2 >=
op->x)
722 if (
pl->ob->map ==
op->map
723 &&
pl->ob->y-
pl->socket->mapy/2 <=
op->y
724 &&
pl->ob->y+
pl->socket->mapy/2 >=
op->y
725 &&
pl->ob->x-
pl->socket->mapx/2 <=
op->x
726 &&
pl->ob->x+
pl->socket->mapx/2 >=
op->x)