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

Function vpline

src/pline.c:152–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152staticfn void
153vpline(const char *line, va_list the_args)
154{
155 static int in_pline = 0;
156 char pbuf[BIGBUFSZ]; /* will get chopped down to BUFSZ-1 if longer */
157 int ln;
158 int msgtyp;
159 boolean no_repeat;
160 coord a11y_mesgxy;
161
162 a11y_mesgxy = a11y.msg_loc; /* save a11y.msg_loc before reseting it */
163 /* always reset a11y.msg_loc whether we end up using it or not */
164 a11y.msg_loc.x = a11y.msg_loc.y = 0;
165
166 if (!line || !*line)
167 return;
168#ifdef HANGUPHANDLING
169 if (program_state.done_hup)
170 return;
171#endif
172 if (program_state.wizkit_wishing)
173 return;
174
175 /* when accessiblemsg is set and a11y.msg_loc is nonzero, use the latter
176 to insert a location prefix in front of current message */
177 if (a11y.accessiblemsg && isok(a11y_mesgxy.x, a11y_mesgxy.y)) {
178 char *tmp, *dirstr, dirstrbuf[QBUFSZ];
179
180 dirstr = coord_desc(a11y_mesgxy.x, a11y_mesgxy.y, dirstrbuf,
181 ((iflags.getpos_coords == GPCOORDS_NONE)
182 ? GPCOORDS_COMFULL : iflags.getpos_coords));
183 tmp = (char *) alloc(strlen(line) + sizeof ": " + strlen(dirstr));
184 Strcpy(tmp, dirstr);
185 Strcat(tmp, ": ");
186 Strcat(tmp, line);
187 vpline(tmp, the_args);
188 free((genericptr_t) tmp);
189 return;
190 }
191
192 if (!strchr(line, '%')) {
193 /* format does not specify any substitutions; use it as-is */
194 ln = (int) strlen(line);
195 } else if (line[0] == '%' && line[1] == 's' && !line[2]) {
196 /* "%s" => single string; skip format and use its first argument;
197 unlike with the format, it is irrelevant whether the argument
198 contains any percent signs */
199 line = va_arg(the_args, const char *); /*VA_NEXT(line,const char *);*/
200 ln = (int) strlen(line);
201 } else {
202 /* perform printf() formatting */
203 ln = vsnprintf(pbuf, sizeof pbuf, line, the_args);
204 line = pbuf;
205 /* note: 'ln' is number of characters attempted, not necessarily
206 strlen(line); that matters for the overflow check; if we avoid
207 the extremely-too-long panic then 'ln' will be actual length */
208 }
209 if (ln > (int) sizeof pbuf - 1) /* extremely too long */

Callers 15

plineFunction · 0.85
pline_dirFunction · 0.85
pline_xyFunction · 0.85
pline_monFunction · 0.85
customplineFunction · 0.85
urgent_plineFunction · 0.85
NorepFunction · 0.85
YouFunction · 0.85
YourFunction · 0.85
You_feelFunction · 0.85
You_cantFunction · 0.85
pline_TheFunction · 0.85

Calls 12

isokFunction · 0.85
coord_descFunction · 0.85
dumplogmsgFunction · 0.85
raw_printFunction · 0.85
msgtype_typeFunction · 0.85
maybe_play_soundFunction · 0.85
vision_recalcFunction · 0.85
flush_screenFunction · 0.85
putmesgFunction · 0.85
execplinehandlerFunction · 0.85
allocFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected