diff --git a/include/nsc.h b/include/nsc.h index a5597274..caf06da3 100644 --- a/include/nsc.h +++ b/include/nsc.h @@ -240,5 +240,6 @@ extern char *nstr_comp_val(char *, struct valstr*, int); extern int nstr_coerce_val(struct valstr *, nsc_type, char *); extern int nstr_exec(struct nscstr *, int, void *); extern void nstr_exec_val(struct valstr *, natid, void *, nsc_type); +extern char *symbol_by_value(int, struct symbol *); #endif /* _NSC_H_ */ diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index 5cf70aac..78853dcb 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -680,3 +680,15 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want) val->val_type = valtype; } + +char * +symbol_by_value(int key, struct symbol *table) +{ + int i; + + for (i = 0; table[i].name; i++) + if (key == table[i].value) + return table[i].name; + + return NULL; +} diff --git a/src/lib/subs/show.c b/src/lib/subs/show.c index d8ca82f7..dd0cde22 100644 --- a/src/lib/subs/show.c +++ b/src/lib/subs/show.c @@ -54,6 +54,7 @@ #include "file.h" #include "nat.h" #include "prototypes.h" +#include "nsc.h" struct look_list { union { @@ -125,18 +126,6 @@ make_new_list(int tlev, int type) sort_lookup_list(); } -static char * -lookup(int key, struct symbol *table) -{ - int i; - - for (i = 0; table[i].name; i++) - if (key == table[i].value) - return table[i].name; - - return NULL; -} - void show_bridge(int tlev) { @@ -224,7 +213,7 @@ show_nuke_capab(int tlev) for (i = j = 0; i < 32; i++) { if (!(np->n_flags & bit(i))) continue; - if (NULL != (p = lookup(bit(i), nuke_chr_flags))) { + if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) { if (j++ > 0) pr(" "); pr(p); @@ -338,7 +327,7 @@ show_ship_capab(int tlev) for (j = n = 0; j < 32; j++) { if (!(mp->m_flags & bit(j))) continue; - if (NULL != (p = lookup(bit(j), ship_chr_flags))) { + if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) { if (n++ > 0) pr(" "); pr(p); @@ -389,7 +378,7 @@ show_plane_capab(int tlev) for (i = n = 0; i < 32; i++) { if (!(pp->pl_flags & bit(i))) continue; - if (NULL != (p = lookup(bit(i), plane_chr_flags))) { + if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) { if (n++ > 0) pr(" "); pr(p); @@ -462,7 +451,7 @@ show_land_capab(int tlev) for (j = n = 0; j < 32; j++) { if (!(lcp->l_flags & bit(j))) continue; - if (NULL != (p = lookup(bit(j), land_chr_flags))) { + if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) { if (n++ > 0) pr(" "); pr(p);