| 589 | } |
| 590 | |
| 591 | DISABLE_WARNING_FORMAT_NONLITERAL |
| 592 | |
| 593 | /* coordinate formatting for 'whatis_coord' option */ |
| 594 | char * |
| 595 | coord_desc(coordxy x, coordxy y, char *outbuf, char cmode) |
| 596 | { |
| 597 | static char screen_fmt[16]; /* [12] suffices: "[%02d,%02d]" */ |
| 598 | int dx, dy; |
| 599 | |
| 600 | outbuf[0] = '\0'; |
| 601 | switch (cmode) { |
| 602 | default: |
| 603 | break; |
| 604 | case GPCOORDS_COMFULL: |
| 605 | case GPCOORDS_COMPASS: |
| 606 | /* "east", "3s", "2n,4w" */ |
| 607 | dx = x - u.ux; |
| 608 | dy = y - u.uy; |
| 609 | Sprintf(outbuf, "(%s)", |
| 610 | dxdy_to_dist_descr(dx, dy, cmode == GPCOORDS_COMFULL)); |
| 611 | break; |
| 612 | case GPCOORDS_MAP: /* x,y */ |
| 613 | /* upper left corner of map is <1,0>; |
| 614 | with default COLNO,ROWNO lower right corner is <79,20> */ |
| 615 | Sprintf(outbuf, "<%d,%d>", x, y); |
| 616 | break; |
| 617 | case GPCOORDS_SCREEN: /* y+2,x */ |
| 618 | /* for normal map sizes, force a fixed-width formatting so that |
| 619 | /m, /M, /o, and /O output lines up cleanly; map sizes bigger |
| 620 | than Nx999 or 999xM will still work, but not line up like normal |
| 621 | when displayed in a column setting. |
| 622 | |
| 623 | The (100) is placed in brackets below to mark the [: "03"] as |
| 624 | explicit compile-time dead code for clang */ |
| 625 | if (!*screen_fmt) |
| 626 | Sprintf(screen_fmt, "[%%%sd,%%%sd]", |
| 627 | (ROWNO - 1 + 2 < (100)) ? "02" : "03", |
| 628 | (COLNO - 1 < (100)) ? "02" : "03"); |
| 629 | /* map line 0 is screen row 2; |
| 630 | map column 0 isn't used, map column 1 is screen column 1 */ |
| 631 | Sprintf(outbuf, screen_fmt, y + 2, x); |
| 632 | break; |
| 633 | } |
| 634 | return outbuf; |
| 635 | } |
| 636 | |
| 637 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 638 |
no test coverage detected