nomenclature: glyphids

glyphids shall be known as glyphnames henceforth
glyphid_cache shall be known as glyphname_hashtable
This commit is contained in:
nhmall
2026-05-24 18:30:46 -04:00
parent 7996090a19
commit 7a38d29363
11 changed files with 123 additions and 123 deletions
+3 -3
View File
@@ -6170,10 +6170,10 @@ U+224B and the color represented by R-G-B value 0-0-160:
OPTIONS=glyph:G_pool/U+224B/0-0-160
.ft
.ED
The list of acceptable glyphid's can be produced by
\fBnethack \-\-dumpglyphids\fP.
The list of acceptable glyphnames can be produced by
\fBnethack \-\-dumpglyphnames\fP.
Individual NetHack glyphs can be specified using the G_ prefix,
or you can use an S_ symbol for a glyphid and store the custom
or you can use an S_ symbol for a glyphname and store the custom
representation for all NetHack glyphs that would map to that
particular symbol.
.pg
+3 -3
View File
@@ -6769,12 +6769,12 @@ U+224B and the color represented by R-G-B value 0-0-160:\\
OPTIONS=glyph:G_pool/U+224B/0-0-160
\end{verbatim}
The list of acceptable glyphid's can be produced by
The list of acceptable glyphnames can be produced by
\begin{verbatim}
nethack --glyphids
nethack --dumpglyphnames
\end{verbatim}
Individual NetHack glyphs can be specified using the G\textunderscore prefix,
or you can use an S\textunderscore symbol for a glyphid and store the custom
or you can use an S\textunderscore symbol for a glyphname and store the custom
representation for all NetHack glyphs that would map to that
particular symbol.
+1 -1
View File
@@ -344,7 +344,7 @@ struct instance_globals_d {
/* new */
boolean deferred_showpaths;
char *deferred_showpaths_dir;
boolean disable_glyphid_cache_prefill;
boolean disable_glyphname_hashtable_prefill;
boolean havestate;
};
+6 -6
View File
@@ -1183,16 +1183,16 @@ int set_map_customcolor(glyph_map *gm, uint32 nhcolor) NONNULLARG1;
extern int unicode_val(const char *);
extern int glyphrep(const char *) NONNULLARG1;
extern int match_glyph(char *) NONNULLARG1;
extern void dump_all_glyphids(FILE *fp) NONNULLARG1;
extern void wizcustom_glyphids(winid win);
extern void fill_glyphid_cache(void);
extern void free_glyphid_cache(void);
extern boolean glyphid_cache_status(void);
extern void dump_all_glyphnames(FILE *fp) NONNULLARG1;
extern void wizcustom_glyphnames(winid win);
extern void populate_glyphname_hashtable(void);
extern void empty_glyphname_hashtable(void);
extern boolean glyphname_hashtable_loaded(void);
extern void apply_customizations(enum graphics_sets which_set,
enum do_customizations docustomize);
extern void purge_custom_entries(enum graphics_sets which_set);
extern void purge_all_custom_entries(void);
extern void dump_glyphids(void);
extern void dump_glyphnames(void);
extern void clear_all_glyphmap_colors(void);
extern void reset_customcolors(void);
extern int glyph_to_cmap(int);
+2 -2
View File
@@ -313,7 +313,7 @@ static const struct instance_globals_d g_init_d = {
FALSE, /* decor_levitate_override */
FALSE, /* deferred_showpaths */
NULL, /* deferred_showpaths_dir */
FALSE, /* disable_glyphid_cache_prefill */
FALSE, /* disable_glyphname_hashtable_prefill */
TRUE, /* havestate*/
};
@@ -1186,7 +1186,7 @@ decl_globals_init(void)
gu.urole = urole_init_data;
gu.urace = urace_init_data;
#ifdef DISABLE_GLYPHID_CACHE_PREFILL
gd.disable_glyphid_cache_prefill = TRUE;
gd.disable_glyphname_hashtable_prefill = TRUE;
#endif
}
+4 -4
View File
@@ -40,7 +40,7 @@ static const struct early_opt earlyopts[] = {
#ifndef NODUMPENUMS
{ ARG_DUMPENUMS, "dumpenums", 9, FALSE },
#endif
{ ARG_DUMPGLYPHIDS, "dumpglyphids", 12, FALSE },
{ ARG_DUMPGLYPHIDS, "dumpglyphnames", 12, FALSE },
{ ARG_DUMPMONGEN, "dumpmongen", 10, FALSE },
{ ARG_DUMPWEIGHTS, "dumpweights", 11, FALSE },
#ifdef WIN32
@@ -530,7 +530,7 @@ argcheck(int argc, char *argv[], enum earlyarg e_arg)
return 2;
#endif
case ARG_DUMPGLYPHIDS:
dump_glyphids();
dump_glyphnames();
return 2;
case ARG_DUMPMONGEN:
dump_mongen();
@@ -803,9 +803,9 @@ dump_enums(void)
#endif /* NODUMPENUMS */
void
dump_glyphids(void)
dump_glyphnames(void)
{
dump_all_glyphids(stdout);
dump_all_glyphnames(stdout);
}
#endif /* !NODUMPENUMS */
+84 -84
View File
@@ -11,7 +11,7 @@ extern struct enum_dump objdump[];
#define Fprintf (void) fprintf
enum reserved_activities { res_nothing, res_dump_glyphids, res_fill_cache };
enum reserved_activities { res_nothing, res_dump_glyphnames, res_fill_hashtable };
enum things_to_find { find_nothing, find_pm, find_oc, find_cmap, find_glyph };
struct find_struct {
enum things_to_find findtype;
@@ -26,20 +26,20 @@ struct find_struct {
genericptr_t reserved;
};
static const struct find_struct zero_find = { 0 };
struct glyphid_cache_t {
struct glyphname_hashtable_entry_t {
int glyphnum;
char *id;
};
static struct glyphid_cache_t *glyphid_cache;
static unsigned glyphid_cache_lsize;
static size_t glyphid_cache_size;
static struct find_struct glyphcache_find, to_custom_symbol_find;
static struct glyphname_hashtable_entry_t *glyphname_hashtable_ptr;
static unsigned glyphname_hashtable_lsize;
static size_t glyphname_hashtable_size;
static struct find_struct glyphname_hashtable_find, to_custom_symbol_find;
static const long nonzero_black = CLR_BLACK | NH_BASIC_COLOR;
staticfn void init_glyph_cache(void);
staticfn void add_glyph_to_cache(int glyphnum, const char *id);
staticfn void init_glyphname_hashtable(void);
staticfn void add_glyph_to_glyphname_hashtable(int glyphnum, const char *id);
staticfn int find_glyph_in_cache(const char *id);
staticfn char *find_glyphid_in_cache_by_glyphnum(int glyphnum);
staticfn char *find_glyphname_in_hashtable_by_glyphnum(int glyphnum);
staticfn uint32 glyph_hash(const char *id);
staticfn void to_custom_symset_entry_callback(int glyph,
struct find_struct *findwhat);
@@ -114,18 +114,18 @@ glyphrep_to_custom_map_entries(
int *glyphptr)
{
to_custom_symbol_find = zero_find;
char buf[BUFSZ], *c_glyphid, *c_unicode, *c_colorval, *cp;
char buf[BUFSZ], *c_glyphname, *c_unicode, *c_colorval, *cp;
int reslt = 0;
long rgb = 0L;
boolean slash = FALSE, colon = FALSE;
if (!glyphid_cache)
if (!glyphname_hashtable_ptr)
reslt = 1; /* for debugger use only; no cache available */
nhUse(reslt);
Snprintf(buf, sizeof buf, "%s", op);
c_unicode = c_colorval = (char *) 0;
c_glyphid = cp = buf;
c_glyphname = cp = buf;
while (*cp) {
if (*cp == ':' || *cp == '/') {
if (*cp == ':') {
@@ -148,8 +148,8 @@ glyphrep_to_custom_map_entries(
}
}
/* some sanity checks */
if (c_glyphid && *c_glyphid == ' ')
c_glyphid++;
if (c_glyphname && *c_glyphname == ' ')
c_glyphname++;
if (c_colorval && *c_colorval == ' ')
c_colorval++;
if (c_unicode && *c_unicode == ' ') {
@@ -176,7 +176,7 @@ glyphrep_to_custom_map_entries(
to_custom_symbol_find.unicode_val = c_unicode;
to_custom_symbol_find.extraval = glyphptr;
to_custom_symbol_find.callback = to_custom_symset_entry_callback;
reslt = glyph_find_core(c_glyphid, &to_custom_symbol_find);
reslt = glyph_find_core(c_glyphname, &to_custom_symbol_find);
return reslt;
}
@@ -300,22 +300,22 @@ glyph_find_core(
void
fill_glyphid_cache(void)
populate_glyphname_hashtable(void)
{
int reslt = 0;
if (!glyphid_cache) {
init_glyph_cache();
if (!glyphname_hashtable_ptr) {
init_glyphname_hashtable();
}
if (glyphid_cache) {
glyphcache_find = zero_find;
glyphcache_find.findtype = find_nothing;
glyphcache_find.reserved = (genericptr_t) glyphid_cache;
glyphcache_find.restype = res_fill_cache;
reslt = parse_id((char *) 0, &glyphcache_find);
if (glyphname_hashtable_ptr) {
glyphname_hashtable_find = zero_find;
glyphname_hashtable_find.findtype = find_nothing;
glyphname_hashtable_find.reserved = (genericptr_t) glyphname_hashtable_ptr;
glyphname_hashtable_find.restype = res_fill_hashtable;
reslt = parse_id((char *) 0, &glyphname_hashtable_find);
if (!reslt) {
free_glyphid_cache();
glyphid_cache = (struct glyphid_cache_t *) 0;
empty_glyphname_hashtable();
glyphname_hashtable_ptr = (struct glyphname_hashtable_entry_t *) 0;
}
}
}
@@ -331,101 +331,101 @@ fill_glyphid_cache(void)
*/
staticfn void
init_glyph_cache(void)
init_glyphname_hashtable(void)
{
size_t glyph;
/* Cache size of power of 2 not less than 2*MAX_GLYPH */
glyphid_cache_lsize = 0;
glyphid_cache_size = 1;
while (glyphid_cache_size < 2*MAX_GLYPH) {
++glyphid_cache_lsize;
glyphid_cache_size <<= 1;
glyphname_hashtable_lsize = 0;
glyphname_hashtable_size = 1;
while (glyphname_hashtable_size < 2*MAX_GLYPH) {
++glyphname_hashtable_lsize;
glyphname_hashtable_size <<= 1;
}
glyphid_cache = (struct glyphid_cache_t *) alloc(
glyphid_cache_size * sizeof (struct glyphid_cache_t));
for (glyph = 0; glyph < glyphid_cache_size; ++glyph) {
glyphid_cache[glyph].glyphnum = 0;
glyphid_cache[glyph].id = (char *) 0;
glyphname_hashtable_ptr = (struct glyphname_hashtable_entry_t *) alloc(
glyphname_hashtable_size * sizeof (struct glyphname_hashtable_entry_t));
for (glyph = 0; glyph < glyphname_hashtable_size; ++glyph) {
glyphname_hashtable_ptr[glyph].glyphnum = 0;
glyphname_hashtable_ptr[glyph].id = (char *) 0;
}
}
void
free_glyphid_cache(void)
empty_glyphname_hashtable(void)
{
size_t idx;
if (!glyphid_cache)
if (!glyphname_hashtable_ptr)
return;
for (idx = 0; idx < glyphid_cache_size; ++idx) {
if (glyphid_cache[idx].id) {
free(glyphid_cache[idx].id);
glyphid_cache[idx].id = (char *) 0;
for (idx = 0; idx < glyphname_hashtable_size; ++idx) {
if (glyphname_hashtable_ptr[idx].id) {
free(glyphname_hashtable_ptr[idx].id);
glyphname_hashtable_ptr[idx].id = (char *) 0;
}
}
free(glyphid_cache);
glyphid_cache = (struct glyphid_cache_t *) 0;
free(glyphname_hashtable_ptr);
glyphname_hashtable_ptr = (struct glyphname_hashtable_entry_t *) 0;
}
staticfn void
add_glyph_to_cache(int glyphnum, const char *id)
add_glyph_to_glyphname_hashtable(int glyphnum, const char *id)
{
uint32 hash = glyph_hash(id);
size_t hash1 = (size_t) (hash & (glyphid_cache_size - 1));
size_t hash1 = (size_t) (hash & (glyphname_hashtable_size - 1));
size_t hash2 = (size_t)
(((hash >> glyphid_cache_lsize) & (glyphid_cache_size - 1)) | 1);
(((hash >> glyphname_hashtable_lsize) & (glyphname_hashtable_size - 1)) | 1);
size_t i = hash1;
do {
if (glyphid_cache[i].id == NULL) {
if (glyphname_hashtable_ptr[i].id == NULL) {
/* Empty bucket found */
glyphid_cache[i].id = dupstr(id);
glyphid_cache[i].glyphnum = glyphnum;
glyphname_hashtable_ptr[i].id = dupstr(id);
glyphname_hashtable_ptr[i].glyphnum = glyphnum;
return;
}
/* For speed, assume that no ID occurs twice */
i = (i + hash2) & (glyphid_cache_size - 1);
i = (i + hash2) & (glyphname_hashtable_size - 1);
} while (i != hash1);
/* This should never happen */
panic("glyphid_cache full");
panic("glyphname_hashtable_ptr full");
}
staticfn int
find_glyph_in_cache(const char *id)
{
uint32 hash = glyph_hash(id);
size_t hash1 = (size_t) (hash & (glyphid_cache_size - 1));
size_t hash1 = (size_t) (hash & (glyphname_hashtable_size - 1));
size_t hash2 = (size_t)
(((hash >> glyphid_cache_lsize) & (glyphid_cache_size - 1)) | 1);
(((hash >> glyphname_hashtable_lsize) & (glyphname_hashtable_size - 1)) | 1);
size_t i = hash1;
do {
if (glyphid_cache[i].id == NULL) {
if (glyphname_hashtable_ptr[i].id == NULL) {
/* Empty bucket found */
return -1;
}
if (strcmpi(id, glyphid_cache[i].id) == 0) {
if (strcmpi(id, glyphname_hashtable_ptr[i].id) == 0) {
/* Match found */
return glyphid_cache[i].glyphnum;
return glyphname_hashtable_ptr[i].glyphnum;
}
i = (i + hash2) & (glyphid_cache_size - 1);
i = (i + hash2) & (glyphname_hashtable_size - 1);
} while (i != hash1);
return -1;
}
staticfn char *
find_glyphid_in_cache_by_glyphnum(int glyphnum)
find_glyphname_in_hashtable_by_glyphnum(int glyphnum)
{
size_t idx;
if (!glyphid_cache)
if (!glyphname_hashtable_ptr)
return (char *) 0;
for (idx = 0; idx < glyphid_cache_size; ++idx) {
if (glyphid_cache[idx].glyphnum == glyphnum
&& glyphid_cache[idx].id != 0) {
for (idx = 0; idx < glyphname_hashtable_size; ++idx) {
if (glyphname_hashtable_ptr[idx].glyphnum == glyphnum
&& glyphname_hashtable_ptr[idx].id != 0) {
/* Match found */
return glyphid_cache[idx].id;
return glyphname_hashtable_ptr[idx].id;
}
}
return (char *) 0;
@@ -449,9 +449,9 @@ glyph_hash(const char *id)
}
boolean
glyphid_cache_status(void)
glyphname_hashtable_loaded(void)
{
return (glyphid_cache != 0);
return (glyphname_hashtable_ptr != 0);
}
int
@@ -471,7 +471,7 @@ glyphrep(const char *op)
{
int reslt = 0, glyph = NO_GLYPH;
if (!glyphid_cache)
if (!glyphname_hashtable_ptr)
reslt = 1; /* for debugger use only; no cache available */
nhUse(reslt);
reslt = glyphrep_to_custom_map_entries(op, &glyph);
@@ -794,26 +794,26 @@ purge_custom_entries(enum graphics_sets which_set)
}
void
dump_all_glyphids(FILE *fp)
dump_all_glyphnames(FILE *fp)
{
struct find_struct dump_glyphid_find = zero_find;
struct find_struct dump_glyphname_find = zero_find;
dump_glyphid_find.findtype = find_nothing;
dump_glyphid_find.reserved = (genericptr_t) fp;
dump_glyphid_find.restype = res_dump_glyphids;
(void) parse_id((char *) 0, &dump_glyphid_find);
dump_glyphname_find.findtype = find_nothing;
dump_glyphname_find.reserved = (genericptr_t) fp;
dump_glyphname_find.restype = res_dump_glyphnames;
(void) parse_id((char *) 0, &dump_glyphname_find);
}
void
wizcustom_glyphids(winid win)
wizcustom_glyphnames(winid win)
{
int glyphnum;
char *id;
if (!glyphid_cache)
if (!glyphname_hashtable_ptr)
return;
for (glyphnum = 0; glyphnum < MAX_GLYPH; ++glyphnum) {
id = find_glyphid_in_cache_by_glyphnum(glyphnum);
id = find_glyphname_in_hashtable_by_glyphnum(glyphnum);
if (id) {
wizcustom_callback(win, glyphnum, id);
}
@@ -834,7 +834,7 @@ parse_id(
char buf[4][QBUFSZ];
if (findwhat->findtype == find_nothing && findwhat->restype) {
if (findwhat->restype == res_dump_glyphids) {
if (findwhat->restype == res_dump_glyphnames) {
if (findwhat->reserved) {
fp = (FILE *) findwhat->reserved;
dump_ids = TRUE;
@@ -842,9 +842,9 @@ parse_id(
return 0;
}
}
if (findwhat->restype == res_fill_cache) {
if (findwhat->restype == res_fill_hashtable) {
if (findwhat->reserved
&& findwhat->reserved == (genericptr_t) glyphid_cache) {
&& findwhat->reserved == (genericptr_t) glyphname_hashtable_ptr) {
filling_cache = TRUE;
} else {
return 0;
@@ -855,7 +855,7 @@ parse_id(
is_G = (id && id[0] == 'G' && id[1] == '_');
is_S = (id && id[0] == 'S' && id[1] == '_');
if ((is_G && !glyphid_cache) || filling_cache || dump_ids || is_S) {
if ((is_G && !glyphname_hashtable_ptr) || filling_cache || dump_ids || is_S) {
while (loadsyms[i].range) {
if (!pm_offset && loadsyms[i].range == SYM_MON)
pm_offset = i;
@@ -873,7 +873,7 @@ parse_id(
}
}
if (is_G || filling_cache || dump_ids) {
if (!filling_cache && id && glyphid_cache) {
if (!filling_cache && id && glyphname_hashtable_ptr) {
int val = find_glyph_in_cache(id);
if (val >= 0) {
findwhat->findtype = find_glyph;
@@ -1112,7 +1112,7 @@ parse_id(
if (dump_ids) {
Fprintf(fp, "(%04d) %s\n", glyph, buf[0]);
} else if (filling_cache) {
add_glyph_to_cache(glyph, buf[0]);
add_glyph_to_glyphname_hashtable(glyph, buf[0]);
} else if (id) {
if (!strcmpi(id, buf[0])) {
findwhat->findtype = find_glyph;
@@ -1123,7 +1123,7 @@ parse_id(
}
}
}
} /* not glyphid_cache */
} /* not glyphname_hashtable_ptr */
} else if (is_S) {
/* cmap entries */
for (i = 0; i < cmap_count; ++i) {
+9 -9
View File
@@ -4224,11 +4224,11 @@ optfn_symset(
if (req == do_handler) {
int reslt;
if (!glyphid_cache_status())
fill_glyphid_cache();
if (!glyphname_hashtable_loaded())
populate_glyphname_hashtable();
reslt = handler_symset(optidx);
if (glyphid_cache_status())
free_glyphid_cache();
if (glyphname_hashtable_loaded())
empty_glyphname_hashtable();
/* apply_customizations(gc.currentgraphics,
(do_custom_colors | do_custom_symbols)); */
return reslt;
@@ -7152,9 +7152,9 @@ initoptions_init(void)
}
/* make any symbol parsing quicker, but only if
* gd.disable_glyphid_cache_prefill is not set to TRUE */
if (!glyphid_cache_status() && !gd.disable_glyphid_cache_prefill)
fill_glyphid_cache();
* gd.disable_glyphname_hashtable_prefill is not set to TRUE */
if (!glyphname_hashtable_loaded() && !gd.disable_glyphname_hashtable_prefill)
populate_glyphname_hashtable();
/* set up the command parsing */
reset_commands(TRUE); /* init */
@@ -7377,8 +7377,8 @@ initoptions_finish(void)
iflags.wc_ascii_map = FALSE, iflags.wc_tiled_map = TRUE;
#ifdef ENHANCED_SYMBOLS
if (glyphid_cache_status())
free_glyphid_cache();
if (glyphname_hashtable_loaded())
empty_glyphname_hashtable();
apply_customizations(gc.currentgraphics,
do_custom_symbols | do_custom_colors);
#endif
+2 -2
View File
@@ -1175,8 +1175,8 @@ freedynamicdata(void)
if (options_set_window_colors_flag)
options_free_window_colors();
if (glyphid_cache_status())
free_glyphid_cache();
if (glyphname_hashtable_loaded())
empty_glyphname_hashtable();
if (tnhfp) {
close_nhfile(tnhfp);
+4 -4
View File
@@ -1069,12 +1069,12 @@ do_symset(boolean rogueflag)
if (gs.symset[which_set].name) {
/* non-default symbols */
int ok;
if (!glyphid_cache_status()) {
fill_glyphid_cache();
if (!glyphname_hashtable_loaded()) {
populate_glyphname_hashtable();
}
ok = read_sym_file(which_set);
if (glyphid_cache_status()) {
free_glyphid_cache();
if (glyphname_hashtable_loaded()) {
empty_glyphname_hashtable();
}
if (ok) {
ready_to_switch = TRUE;
+5 -5
View File
@@ -1945,8 +1945,8 @@ wiz_custom(void)
#endif
menu_item *pick_list = (menu_item *) 0;
if (!glyphid_cache_status())
fill_glyphid_cache();
if (!glyphname_hashtable_loaded())
populate_glyphname_hashtable();
win = create_nhwindow(NHW_MENU);
start_menu(win, MENU_BEHAVE_STANDARD);
@@ -1964,7 +1964,7 @@ wiz_custom(void)
known_handling[gs.symset[PRIMARYSET].handling]);
}
Sprintf(buf, "%s", bufa);
wizcustom_glyphids(win);
wizcustom_glyphnames(win);
end_menu(win, bufa);
n = select_menu(win, PICK_NONE, &pick_list);
destroy_nhwindow(win);
@@ -1975,8 +1975,8 @@ wiz_custom(void)
#endif
if (n >= 1)
free((genericptr_t) pick_list);
if (glyphid_cache_status())
free_glyphid_cache();
if (glyphname_hashtable_loaded())
empty_glyphname_hashtable();
docrt();
} else
pline(unavailcmd, ecname_from_fn(wiz_custom));