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

Function curses_status_update

win/curses/cursstat.c:137–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135static int changed_fields = 0;
136
137DISABLE_WARNING_FORMAT_NONLITERAL
138
139void
140curses_status_update(
141 int fldidx,
142 genericptr_t ptr,
143 int chg UNUSED,
144 int percent,
145 int color_and_attr,
146 unsigned long *colormasks)
147{
148 long *condptr = (long *) ptr;
149 char *text = (char *) ptr;
150
151 if (fldidx != BL_FLUSH) {
152 if (fldidx < 0 || fldidx >= MAXBLSTATS) {
153 /* panic immediately sets gb.bot_disabled to avoid bot() */
154 panic("curses_status_update(%d)", fldidx);
155 }
156 changed_fields |= (1 << fldidx);
157 *status_vals[fldidx] = '\0';
158 if (!status_activefields[fldidx])
159 return;
160 if (fldidx == BL_CONDITION) {
161 curses_condition_bits = *condptr;
162 curses_colormasks = colormasks;
163 } else {
164 /*
165 * status_vals[] are used for horizontal orientation
166 * (wide lines of multiple short values).
167 * status_vals_long[] are used for vertical orientation
168 * (narrow-ish lines of one long value each [mostly]
169 * and get constructed at need from status_vals[] rather
170 * than the original values passed to status_update()).
171 */
172 if (fldidx == BL_GOLD) {
173 /* decode once instead of every time it's displayed */
174 status_vals[BL_GOLD][0] = ' ';
175 text = decode_mixed(&status_vals[BL_GOLD][1], text);
176 nhUse(text);
177 } else if ((fldidx == BL_HUNGER || fldidx == BL_CAP)
178 && (!*text || !strcmp(text, " "))) {
179 /* fieldfmt[] is " %s"; avoid lone space when empty */
180 *status_vals[fldidx] = '\0';
181 } else {
182 Sprintf(status_vals[fldidx],
183 (fldidx == BL_TITLE && iflags.wc2_hitpointbar)
184 ? "%-30.30s" : status_fieldfmt[fldidx]
185 ? status_fieldfmt[fldidx] : "%s",
186 text);
187 /* strip trailing spaces; core ought to do this for us */
188 if (fldidx == BL_HUNGER || fldidx == BL_LEVELDESC)
189 (void) trimspaces(status_vals[fldidx]);
190 }
191
192 /* status_vals_long[] used to be set up here even when not
193 in use; it has been moved to curs_vert_status_vals() */
194 vert_status_dirty = 1;

Callers

nothing calls this directly

Calls 5

decode_mixedFunction · 0.85
trimspacesFunction · 0.85
critically_low_hpFunction · 0.85
draw_statusFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected