… | |
… | |
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 | |
… | |
… | |
390 | |
384 | |
391 | /* range_scroll is only used for controlling golems. If the |
385 | /* range_scroll is only used for controlling golems. If the |
392 | * the player does not have a golem, reset some things. |
386 | * the player does not have a golem, reset some things. |
393 | */ |
387 | */ |
394 | case range_golem: |
388 | case range_golem: |
395 | if (pl->contr->ranges[range_golem] != NULL) |
389 | if (object *golem = pl->contr->ranges[range_golem]) |
396 | sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name); |
390 | sprintf (obuf, "Range: golem (%s)", &golem->name); |
397 | else |
391 | else |
398 | { |
392 | { |
399 | pl->contr->shoottype = range_none; |
393 | pl->contr->shoottype = range_none; |
400 | strcpy (obuf, "Range: nothing"); |
394 | strcpy (obuf, "Range: nothing"); |
401 | } |
395 | } |
… | |
… | |
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 | |
|
|
424 | // formerly a macro, used only by magic map, so optimised it out |
|
|
425 | static inline faceidx |
|
|
426 | GET_MAP_FACE (maptile *m, int x, int y, int layer) |
|
|
427 | { |
|
|
428 | if (object *op = GET_MAP_FACE_OBJ (m, x, y, layer)) |
|
|
429 | return op->face; |
|
|
430 | else |
|
|
431 | return 0; |
|
|
432 | } |
430 | |
433 | |
431 | /** |
434 | /** |
432 | * Helper for magic map creation. |
435 | * Helper for magic map creation. |
433 | * |
436 | * |
434 | * Takes a player, the map_mark array and an x and y starting position. |
437 | * Takes a player, the map_mark array and an x and y starting position. |
… | |
… | |
443 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
446 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
444 | { |
447 | { |
445 | int x, y, dx, dy, mflags; |
448 | int x, y, dx, dy, mflags; |
446 | sint16 nx, ny; |
449 | sint16 nx, ny; |
447 | maptile *mp; |
450 | maptile *mp; |
448 | facetile *f; |
|
|
449 | |
451 | |
450 | for (dx = -1; dx <= 1; dx++) |
452 | for (dx = -1; dx <= 1; dx++) |
451 | { |
453 | { |
452 | for (dy = -1; dy <= 1; dy++) |
454 | for (dy = -1; dy <= 1; dy++) |
453 | { |
455 | { |
… | |
… | |
465 | if (mflags & P_OUT_OF_MAP) |
467 | if (mflags & P_OUT_OF_MAP) |
466 | continue; |
468 | continue; |
467 | |
469 | |
468 | if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) |
470 | if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) |
469 | { |
471 | { |
470 | f = GET_MAP_FACE (mp, nx, ny, 0); |
472 | int f = GET_MAP_FACE (mp, nx, ny, 0); |
471 | if (f == blank_face) |
473 | if (f == blank_face) |
|
|
474 | { |
472 | f = GET_MAP_FACE (mp, nx, ny, 1); |
475 | f = GET_MAP_FACE (mp, nx, ny, 1); |
473 | if (f == blank_face) |
476 | if (f == blank_face) |
474 | f = GET_MAP_FACE (mp, nx, ny, 2); |
477 | f = GET_MAP_FACE (mp, nx, ny, 2); |
|
|
478 | } |
|
|
479 | |
|
|
480 | int magicmap = faces [f].magicmap; |
475 | |
481 | |
476 | /* Should probably have P_NO_MAGIC here also, but then shops don't |
482 | /* Should probably have P_NO_MAGIC here also, but then shops don't |
477 | * work. |
483 | * work. |
478 | */ |
484 | */ |
479 | if (mflags & P_BLOCKSVIEW) |
485 | if (mflags & P_BLOCKSVIEW) |
480 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | (f ? f->magicmap : 0); |
486 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | magicmap; |
481 | else |
487 | else |
482 | { |
488 | { |
483 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f ? f->magicmap : 0); |
489 | 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); |
490 | magic_mapping_mark_recursive (pl, map_mark, x, y); |
485 | } |
491 | } |
486 | } |
492 | } |
487 | } |
493 | } |
488 | } |
494 | } |
489 | } |
495 | } |
490 | |
|
|
491 | |
496 | |
492 | /** |
497 | /** |
493 | * Creates magic map for player. |
498 | * Creates magic map for player. |
494 | * |
499 | * |
495 | * Note: For improved magic mapping display, the space that blocks |
500 | * Note: For improved magic mapping display, the space that blocks |
… | |
… | |
502 | * is for open spaces. map_mark should already have been initialised |
507 | * is for open spaces. map_mark should already have been initialised |
503 | * to zero before this is called. |
508 | * to zero before this is called. |
504 | * strength is an initial strength*2 rectangular area that we automatically |
509 | * strength is an initial strength*2 rectangular area that we automatically |
505 | * see in/penetrate through. |
510 | * see in/penetrate through. |
506 | */ |
511 | */ |
507 | |
|
|
508 | void |
512 | void |
509 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
513 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
510 | { |
514 | { |
511 | int x, y, mflags; |
515 | int x, y, mflags; |
512 | sint16 nx, ny; |
516 | sint16 nx, ny; |
513 | maptile *mp; |
517 | maptile *mp; |
514 | facetile *f; |
|
|
515 | |
518 | |
516 | for (x = -strength; x < strength; x++) |
519 | for (x = -strength; x < strength; x++) |
517 | { |
520 | { |
518 | for (y = -strength; y < strength; y++) |
521 | for (y = -strength; y < strength; y++) |
519 | { |
522 | { |
520 | mp = pl->map; |
523 | mp = pl->map; |
521 | nx = pl->x + x; |
524 | nx = pl->x + x; |
522 | ny = pl->y + y; |
525 | ny = pl->y + y; |
|
|
526 | |
523 | mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); |
527 | mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); |
524 | if (mflags & P_OUT_OF_MAP) |
528 | if (mflags & P_OUT_OF_MAP) |
525 | continue; |
529 | continue; |
526 | else |
530 | |
|
|
531 | int f = GET_MAP_FACE (mp, nx, ny, 0); |
|
|
532 | if (f == blank_face) |
527 | { |
533 | { |
528 | f = GET_MAP_FACE (mp, nx, ny, 0); |
|
|
529 | if (f == blank_face) |
|
|
530 | f = GET_MAP_FACE (mp, nx, ny, 1); |
534 | f = GET_MAP_FACE (mp, nx, ny, 1); |
531 | if (f == blank_face) |
535 | if (f == blank_face) |
532 | f = GET_MAP_FACE (mp, nx, ny, 2); |
536 | f = GET_MAP_FACE (mp, nx, ny, 2); |
533 | } |
537 | } |
534 | |
538 | |
|
|
539 | int magicmap = faces [f].magicmap; |
|
|
540 | |
535 | if (mflags & P_BLOCKSVIEW) |
541 | if (mflags & P_BLOCKSVIEW) |
536 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | (f ? f->magicmap : 0); |
542 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | magicmap; |
537 | else |
543 | else |
538 | { |
544 | { |
539 | map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f ? f->magicmap : 0); |
545 | 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); |
546 | magic_mapping_mark_recursive (pl, map_mark, x, y); |
541 | } |
547 | } |
542 | } |
548 | } |
543 | } |
549 | } |
544 | } |
550 | } |