1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
293 | op->contr->blocked_los[dx][dy] = -1; |
294 | op->contr->blocked_los[dx][dy] = -1; |
294 | } |
295 | } |
295 | } |
296 | } |
296 | } |
297 | } |
297 | |
298 | |
298 | if (MAP_DARKNESS (op->map) > 0) /* player is on a dark map */ |
299 | if (op->map->darkness > 0) /* player is on a dark map */ |
299 | expand_lighted_sight (op); |
300 | expand_lighted_sight (op); |
300 | |
301 | |
301 | |
302 | |
302 | /* clear mark squares */ |
303 | /* clear mark squares */ |
303 | for (x = 0; x < op->contr->ns->mapx; x++) |
304 | for (x = 0; x < op->contr->ns->mapx; x++) |
… | |
… | |
330 | { |
331 | { |
331 | int x, y, darklevel, ax, ay, basex, basey, mflags, light, x1, y1; |
332 | int x, y, darklevel, ax, ay, basex, basey, mflags, light, x1, y1; |
332 | maptile *m = op->map; |
333 | maptile *m = op->map; |
333 | sint16 nx, ny; |
334 | sint16 nx, ny; |
334 | |
335 | |
335 | darklevel = MAP_DARKNESS (m); |
336 | darklevel = m->darkness; |
336 | |
337 | |
337 | /* If the player can see in the dark, lower the darklevel for him */ |
338 | /* If the player can see in the dark, lower the darklevel for him */ |
338 | if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) |
339 | if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) |
339 | darklevel -= 2; |
340 | darklevel -= 2; |
340 | |
341 | |
… | |
… | |
349 | /* Do a sanity check. If not valid, some code below may do odd |
350 | /* Do a sanity check. If not valid, some code below may do odd |
350 | * things. |
351 | * things. |
351 | */ |
352 | */ |
352 | if (darklevel > MAX_DARKNESS) |
353 | if (darklevel > MAX_DARKNESS) |
353 | { |
354 | { |
354 | LOG (llevError, "Map darkness for %s on %s is too high (%d)\n", &op->name, op->map->path, darklevel); |
355 | LOG (llevError, "Map darkness for %s on %s is too high (%d)\n", &op->name, &op->map->path, darklevel); |
355 | darklevel = MAX_DARKNESS; |
356 | darklevel = MAX_DARKNESS; |
356 | } |
357 | } |
357 | |
358 | |
358 | /* First, limit player furthest (unlighted) vision */ |
359 | /* First, limit player furthest (unlighted) vision */ |
359 | for (x = 0; x < op->contr->ns->mapx; x++) |
360 | for (x = 0; x < op->contr->ns->mapx; x++) |
… | |
… | |
579 | * and then add the players location, which gives |
580 | * and then add the players location, which gives |
580 | * a distance. |
581 | * a distance. |
581 | */ |
582 | */ |
582 | else if (pl->ob->map == map->tile_map[0]) |
583 | else if (pl->ob->map == map->tile_map[0]) |
583 | { |
584 | { |
584 | if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (y + MAP_HEIGHT (map->tile_map[0]) - pl->ob->y) <= pl->ns->mapy / 2)) |
585 | if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (y + map->tile_map[0]->height - pl->ob->y) <= pl->ns->mapy / 2)) |
585 | pl->do_los = 1; |
586 | pl->do_los = 1; |
586 | } |
587 | } |
587 | else if (pl->ob->map == map->tile_map[2]) |
588 | else if (pl->ob->map == map->tile_map[2]) |
588 | { |
589 | { |
589 | if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y + MAP_HEIGHT (map) - y) <= pl->ns->mapy / 2)) |
590 | if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y + map->height - y) <= pl->ns->mapy / 2)) |
590 | pl->do_los = 1; |
591 | pl->do_los = 1; |
591 | } |
592 | } |
592 | else if (pl->ob->map == map->tile_map[1]) |
593 | else if (pl->ob->map == map->tile_map[1]) |
593 | { |
594 | { |
594 | if ((abs (pl->ob->x + MAP_WIDTH (map) - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) |
595 | if ((abs (pl->ob->x + map->width - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) |
595 | pl->do_los = 1; |
596 | pl->do_los = 1; |
596 | } |
597 | } |
597 | else if (pl->ob->map == map->tile_map[3]) |
598 | else if (pl->ob->map == map->tile_map[3]) |
598 | { |
599 | { |
599 | if ((abs (x + MAP_WIDTH (map->tile_map[3]) - pl->ob->x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) |
600 | if ((abs (x + map->tile_map[3]->width - pl->ob->x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) |
600 | pl->do_los = 1; |
601 | pl->do_los = 1; |
601 | } |
602 | } |
602 | } |
603 | } |
603 | } |
604 | } |
604 | |
605 | |