diff options
Diffstat (limited to 'board.c')
-rw-r--r-- | board.c | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -14,10 +14,16 @@ int SECTORS[] = { 20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, int SECTOR_INDS[NUM_SECTORS]; double SECTOR_ANGLES[NUM_SECTORS]; -char *RING_NAMES[] = { - FOREACH_RING(GEN_RING_STRING) +static const char *SECTOR_NAMES[] = { + FOREACH_SECTOR(GEN_SECTOR_STR) + FOREACH_SECTOR(GEN_SECTOR_STR_D) + FOREACH_SECTOR(GEN_SECTOR_STR_T) +}; +static const char *RING_NAMES[] = { + FOREACH_RING(GEN_RING_STR) "OUT" }; + double OUTER_DISTS[] = { FOREACH_RING(GEN_RING_OUTER_DIST) }; @@ -70,22 +76,17 @@ struct segment get_segment(struct pcoords c) .ring = get_ring(c.r) }; } -char *segment_name(struct segment seg) +const char *segment_name(struct segment seg) { - char *str = malloc(SEGMENT_MAX_LEN); - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" if (seg.ring == R_BULL || seg.ring == R_25 || seg.ring == R_OUT) - strncpy(str, RING_NAMES[seg.ring], SEGMENT_MAX_LEN); - else - snprintf(str, SEGMENT_MAX_LEN, - (seg.ring == R_TREBLE ? "T%d" : - (seg.ring == R_DOUBLE ? "D%d" : "%d")), - seg.sector); -#pragma GCC diagnostic pop - - return str; + return RING_NAMES[seg.ring]; + + int ind = seg.sector - 1; + if (seg.ring == R_DOUBLE) + ind += 20; + else if (seg.ring == R_TREBLE) + ind += 40; + return SECTOR_NAMES[ind]; } int segment_points(struct segment seg) |