make rank() static again
[NetHack.git] / src / drawing.c
blob7881e1f8e1865d0ee30149cd5e13577e81d9ba3c
1 /* NetHack 3.7 drawing.c $NHDT-Date: 1596498163 2020/08/03 23:42:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.78 $ */
2 /* Copyright (c) NetHack Development Team 1992. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #include "config.h"
6 #include "color.h"
7 #include "rm.h"
8 #include "objclass.h"
9 #include "wintype.h"
10 #include "sym.h"
12 extern const struct symparse loadsyms[];
13 extern const struct class_sym def_oc_syms[MAXOCLASSES];
14 extern const struct class_sym def_monsyms[MAXMCLASSES];
15 extern const uchar def_r_oc_syms[MAXOCLASSES];
17 /* Relevant header information in rm.h, objclass.h, sym.h, defsym.h. */
19 /* Default object class symbols. See objclass.h.
20 * {symbol, name, explain}
21 * name: used in object_detect().
22 * explain: used in do_look().
24 const struct class_sym def_oc_syms[MAXOCLASSES] = {
25 { '\0', "", "" }, /* placeholder for the "random class" */
26 #define OBJCLASS_DRAWING
27 #include "defsym.h"
28 #undef OBJCLASS_DRAWING
31 /* Default monster class symbols. See sym.h and defsym.h. */
32 const struct class_sym def_monsyms[MAXMCLASSES] = {
33 { '\0', "", "" },
34 #define MONSYMS_DRAWING
35 #include "defsym.h"
36 #undef MONSYMS_DRAWING
39 const struct symdef def_warnsyms[WARNCOUNT] = {
40 /* white warning */
41 { '0', "unknown creature causing you worry", CLR_WHITE },
42 /* pink warning */
43 { '1', "unknown creature causing you concern", CLR_RED },
44 /* red warning */
45 { '2', "unknown creature causing you anxiety", CLR_RED },
46 /* ruby warning */
47 { '3', "unknown creature causing you disquiet", CLR_RED },
48 /* purple warning */
49 { '4', "unknown creature causing you alarm", CLR_MAGENTA },
50 /* black warning */
51 { '5', "unknown creature causing you dread", CLR_BRIGHT_MAGENTA },
55 * Default screen symbols with explanations and colors.
57 * If adding to or removing from this list, please note that,
58 * for builds with tile support, there is an array called altlabels[] in
59 * win/share/tilemap.c that requires the same number of elements as
60 * this, in the same order. It is used for tile name matching when
61 * parsing other.txt because some of the useful tile names don't exist
62 * within NetHack itself.
64 const struct symdef defsyms[MAXPCHARS + 1] = {
65 #define PCHAR_DRAWING
66 #include "defsym.h"
67 #undef PCHAR_DRAWING
68 { 0, NULL, NO_COLOR }
71 /* default rogue level symbols */
72 const uchar def_r_oc_syms[MAXOCLASSES] = {
73 /* 0*/ '\0', ILLOBJ_SYM, WEAPON_SYM, ']', /* armor */
74 RING_SYM,
75 /* 5*/ ',', /* amulet */
76 TOOL_SYM, ':', /* food */
77 POTION_SYM, SCROLL_SYM,
78 /*10*/ SPBOOK_SYM, WAND_SYM,
79 GEM_SYM, /* gold -- yes it's the same as gems */
80 GEM_SYM, ROCK_SYM,
81 /*15*/ BALL_SYM, CHAIN_SYM, VENOM_SYM
85 * Convert the given character to an object class. If the character is not
86 * recognized, then MAXOCLASSES is returned. Used in detect.c, invent.c,
87 * objnam.c, options.c, pickup.c, sp_lev.c, lev_main.c, and tilemap.c.
89 int
90 def_char_to_objclass(char ch)
92 int i;
94 for (i = 1; i < MAXOCLASSES; i++)
95 if (ch == def_oc_syms[i].sym)
96 break;
97 return i;
101 * Convert a character into a monster class. This returns the _first_
102 * match made. If there are no matches, return MAXMCLASSES.
103 * Used in detect.c, options.c, read.c, sp_lev.c, and lev_main.c
106 def_char_to_monclass(char ch)
108 int i;
110 for (i = 1; i < MAXMCLASSES; i++)
111 if (ch == def_monsyms[i].sym)
112 break;
113 return i;
116 /* does 'ch' represent a furniture character? returns index into defsyms[] */
118 def_char_is_furniture(char ch)
120 /* note: these refer to defsyms[] order which is much different from
121 levl[][].typ order but both keep furniture in a contiguous block */
122 static const char first_furniture[] = "stair", /* "staircase up" */
123 last_furniture[] = "fountain";
124 int i;
125 boolean furniture = FALSE;
127 for (i = 0; i < MAXPCHARS; ++i) {
128 if (!furniture) {
129 if (!strncmp(defsyms[i].explanation, first_furniture, 5))
130 furniture = TRUE;
132 if (furniture) {
133 if (defsyms[i].sym == (uchar) ch)
134 return i;
135 if (!strcmp(defsyms[i].explanation, last_furniture))
136 break; /* reached last furniture */
139 return -1;
142 /*drawing.c*/