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) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | * |
8 | 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 |
9 | 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 |
10 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
11 | * (at your option) any later version. |
12 | |
12 | * |
13 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | |
17 | * |
18 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | * |
22 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /** |
25 | /** |
26 | * \file |
26 | * \file |
27 | * Basic client output functions. |
27 | * Basic client output functions. |
28 | * |
28 | * |
… | |
… | |
293 | */ |
293 | */ |
294 | |
294 | |
295 | void |
295 | void |
296 | new_info_map_except (int color, maptile * map, object *op, const char *str) |
296 | new_info_map_except (int color, maptile * map, object *op, const char *str) |
297 | { |
297 | { |
298 | player *pl; |
|
|
299 | |
|
|
300 | for_all_players (pl) |
298 | for_all_players (pl) |
301 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
299 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
302 | new_draw_info (color, 0, pl->ob, str); |
300 | new_draw_info (color, 0, pl->ob, str); |
303 | } |
301 | } |
304 | |
302 | |
… | |
… | |
307 | */ |
305 | */ |
308 | |
306 | |
309 | void |
307 | void |
310 | new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) |
308 | new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) |
311 | { |
309 | { |
312 | player *pl; |
|
|
313 | |
|
|
314 | for_all_players (pl) |
310 | for_all_players (pl) |
315 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
311 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
316 | new_draw_info (color, 0, pl->ob, str); |
312 | new_draw_info (color, 0, pl->ob, str); |
317 | } |
313 | } |
318 | |
314 | |
… | |
… | |
321 | */ |
317 | */ |
322 | |
318 | |
323 | void |
319 | void |
324 | new_info_map (int color, maptile * map, const char *str) |
320 | new_info_map (int color, maptile * map, const char *str) |
325 | { |
321 | { |
326 | player *pl; |
|
|
327 | |
|
|
328 | for_all_players (pl) |
322 | for_all_players (pl) |
329 | if (pl->ob != NULL && pl->ob->map == map) |
323 | if (pl->ob != NULL && pl->ob->map == map) |
330 | new_draw_info (color, 0, pl->ob, str); |
324 | new_draw_info (color, 0, pl->ob, str); |
331 | } |
325 | } |
332 | |
326 | |
… | |
… | |
425 | sprintf (buf, "Player: %s the %s", (const char *) pl->name, (const char *) pl->contr->title); |
419 | sprintf (buf, "Player: %s the %s", (const char *) pl->name, (const char *) pl->contr->title); |
426 | else |
420 | else |
427 | sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title); |
421 | sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title); |
428 | } |
422 | } |
429 | |
423 | |
430 | |
|
|
431 | /** |
424 | /** |
432 | * Helper for magic map creation. |
425 | * Helper for magic map creation. |
433 | * |
426 | * |
434 | * Takes a player, the map_mark array and an x and y starting position. |
427 | * Takes a player, the map_mark array and an x and y starting position. |
435 | * pl is the player. |
428 | * pl is the player. |
… | |
… | |
443 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
436 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
444 | { |
437 | { |
445 | int x, y, dx, dy, mflags; |
438 | int x, y, dx, dy, mflags; |
446 | sint16 nx, ny; |
439 | sint16 nx, ny; |
447 | maptile *mp; |
440 | maptile *mp; |
448 | New_Face *f; |
|
|
449 | |
441 | |
450 | for (dx = -1; dx <= 1; dx++) |
442 | for (dx = -1; dx <= 1; dx++) |
451 | { |
443 | { |
452 | for (dy = -1; dy <= 1; dy++) |
444 | for (dy = -1; dy <= 1; dy++) |
453 | { |
445 | { |
… | |
… | |
465 | if (mflags & P_OUT_OF_MAP) |
457 | if (mflags & P_OUT_OF_MAP) |
466 | continue; |
458 | continue; |
467 | |
459 | |
468 | if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) |
460 | if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) |
469 | { |
461 | { |
470 | f = GET_MAP_FACE (mp, nx, ny, 0); |
462 | int f = GET_MAP_FACE (mp, nx, ny, 0); |
471 | if (f == blank_face) |
463 | if (f == blank_face) |
|
|
464 | { |
472 | f = GET_MAP_FACE (mp, nx, ny, 1); |
465 | f = GET_MAP_FACE (mp, nx, ny, 1); |
473 | if (f == blank_face) |
466 | if (f == blank_face) |
474 | f = GET_MAP_FACE (mp, nx, ny, 2); |
467 | f = GET_MAP_FACE (mp, nx, ny, 2); |
|
|
468 | } |
|
|
469 | |
|
|
470 | int magicmap = faces [f].magicmap; |
475 | |
471 | |
476 | /* Should probably have P_NO_MAGIC here also, but then shops don't |
472 | /* Should probably have P_NO_MAGIC here also, but then shops don't |
477 | * work. |
473 | * work. |
478 | */ |
474 | */ |
479 | if (mflags & P_BLOCKSVIEW) |
475 | if (mflags & P_BLOCKSVIEW) |
480 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | (f ? f->magicmap : 0); |
476 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | magicmap; |
481 | else |
477 | else |
482 | { |
478 | { |
483 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f ? f->magicmap : 0); |
479 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | magicmap; |
484 | magic_mapping_mark_recursive (pl, map_mark, x, y); |
480 | magic_mapping_mark_recursive (pl, map_mark, x, y); |
485 | } |
481 | } |
486 | } |
482 | } |
487 | } |
483 | } |
488 | } |
484 | } |
489 | } |
485 | } |
490 | |
|
|
491 | |
486 | |
492 | /** |
487 | /** |
493 | * Creates magic map for player. |
488 | * Creates magic map for player. |
494 | * |
489 | * |
495 | * Note: For improved magic mapping display, the space that blocks |
490 | * Note: For improved magic mapping display, the space that blocks |
… | |
… | |
502 | * is for open spaces. map_mark should already have been initialised |
497 | * is for open spaces. map_mark should already have been initialised |
503 | * to zero before this is called. |
498 | * to zero before this is called. |
504 | * strength is an initial strength*2 rectangular area that we automatically |
499 | * strength is an initial strength*2 rectangular area that we automatically |
505 | * see in/penetrate through. |
500 | * see in/penetrate through. |
506 | */ |
501 | */ |
507 | |
|
|
508 | void |
502 | void |
509 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
503 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
510 | { |
504 | { |
511 | int x, y, mflags; |
505 | int x, y, mflags; |
512 | sint16 nx, ny; |
506 | sint16 nx, ny; |
513 | maptile *mp; |
507 | maptile *mp; |
514 | New_Face *f; |
|
|
515 | |
508 | |
516 | for (x = -strength; x < strength; x++) |
509 | for (x = -strength; x < strength; x++) |
517 | { |
510 | { |
518 | for (y = -strength; y < strength; y++) |
511 | for (y = -strength; y < strength; y++) |
519 | { |
512 | { |
520 | mp = pl->map; |
513 | mp = pl->map; |
521 | nx = pl->x + x; |
514 | nx = pl->x + x; |
522 | ny = pl->y + y; |
515 | ny = pl->y + y; |
|
|
516 | |
523 | mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); |
517 | mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); |
524 | if (mflags & P_OUT_OF_MAP) |
518 | if (mflags & P_OUT_OF_MAP) |
525 | continue; |
519 | continue; |
526 | else |
520 | |
|
|
521 | int f = GET_MAP_FACE (mp, nx, ny, 0); |
|
|
522 | if (f == blank_face) |
527 | { |
523 | { |
528 | f = GET_MAP_FACE (mp, nx, ny, 0); |
|
|
529 | if (f == blank_face) |
|
|
530 | f = GET_MAP_FACE (mp, nx, ny, 1); |
524 | f = GET_MAP_FACE (mp, nx, ny, 1); |
531 | if (f == blank_face) |
525 | if (f == blank_face) |
532 | f = GET_MAP_FACE (mp, nx, ny, 2); |
526 | f = GET_MAP_FACE (mp, nx, ny, 2); |
533 | } |
527 | } |
534 | |
528 | |
|
|
529 | int magicmap = faces [f].magicmap; |
|
|
530 | |
535 | if (mflags & P_BLOCKSVIEW) |
531 | if (mflags & P_BLOCKSVIEW) |
536 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | (f ? f->magicmap : 0); |
532 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | magicmap; |
537 | else |
533 | else |
538 | { |
534 | { |
539 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f ? f->magicmap : 0); |
535 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | magicmap; |
540 | magic_mapping_mark_recursive (pl, map_mark, x, y); |
536 | magic_mapping_mark_recursive (pl, map_mark, x, y); |
541 | } |
537 | } |
542 | } |
538 | } |
543 | } |
539 | } |
544 | } |
540 | } |