MCPcopy Create free account
hub / github.com/NetHack/NetHack / parse_id

Function parse_id

src/glyphs.c:823–1162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

821}
822
823staticfn int
824parse_id(
825 const char *id,
826 struct find_struct *findwhat)
827{
828 FILE *fp = (FILE *) 0;
829 int i = 0, j, mnum, glyph,
830 pm_offset = 0, oc_offset = 0, cmap_offset = 0,
831 pm_count = 0, oc_count = 0, cmap_count = 0;
832 boolean skip_base = FALSE, skip_this_one = FALSE, dump_ids = FALSE,
833 filling_cache = FALSE, is_S = FALSE, is_G = FALSE;
834 char buf[4][QBUFSZ];
835
836 if (findwhat->findtype == find_nothing && findwhat->restype) {
837 if (findwhat->restype == res_dump_glyphids) {
838 if (findwhat->reserved) {
839 fp = (FILE *) findwhat->reserved;
840 dump_ids = TRUE;
841 } else {
842 return 0;
843 }
844 }
845 if (findwhat->restype == res_fill_cache) {
846 if (findwhat->reserved
847 && findwhat->reserved == (genericptr_t) glyphid_cache) {
848 filling_cache = TRUE;
849 } else {
850 return 0;
851 }
852 }
853 }
854
855 is_G = (id && id[0] == 'G' && id[1] == '_');
856 is_S = (id && id[0] == 'S' && id[1] == '_');
857
858 if ((is_G && !glyphid_cache) || filling_cache || dump_ids || is_S) {
859 while (loadsyms[i].range) {
860 if (!pm_offset && loadsyms[i].range == SYM_MON)
861 pm_offset = i;
862 if (!pm_count && pm_offset && loadsyms[i].range != SYM_MON)
863 pm_count = i - pm_offset;
864 if (!oc_offset && loadsyms[i].range == SYM_OC)
865 oc_offset = i;
866 if (!oc_count && oc_offset && loadsyms[i].range != SYM_OC)
867 oc_count = i - oc_offset;
868 if (!cmap_offset && loadsyms[i].range == SYM_PCHAR)
869 cmap_offset = i;
870 if (!cmap_count && cmap_offset && loadsyms[i].range != SYM_PCHAR)
871 cmap_count = i - cmap_offset;
872 i++;
873 }
874 }
875 if (is_G || filling_cache || dump_ids) {
876 if (!filling_cache && id && glyphid_cache) {
877 int val = find_glyph_in_cache(id);
878 if (val >= 0) {
879 findwhat->findtype = find_glyph;
880 findwhat->val = val;

Callers 3

glyph_find_coreFunction · 0.85
fill_glyphid_cacheFunction · 0.85
dump_all_glyphidsFunction · 0.85

Calls 4

find_glyph_in_cacheFunction · 0.85
fix_glyphnameFunction · 0.85
add_glyph_to_cacheFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected