Below is the full text to pline.c from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/pline.c#line123]], for example.
The latest source code for vanilla NetHack is at Source code.
The NetHack General Public License applies to screenshots, source code and other content from NetHack. |
1. /* SCCS Id: @(#)pline.c 3.4 1999/11/28 */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */ 6. #include "hack.h" 7. #include "epri.h" 8. #ifdef WIZARD 9. #include "edog.h" 10. #endif 11. 12. #ifdef OVLB 13. 14. static boolean no_repeat = FALSE; 15. 16. static char *FDECL(You_buf, (int)); 17. 18. /*VARARGS1*/ 19. /* Note that these declarations rely on knowledge of the internals 20. * of the variable argument handling stuff in "tradstdc.h" 21. */ 22. 23. #if defined(USE_STDARG) || defined(USE_VARARGS) 24. static void FDECL(vpline, (const char *, va_list)); 25. 26. void 27. pline VA_DECL(const char *, line) 28. VA_START(line); 29. VA_INIT(line, char *); 30. vpline(line, VA_ARGS); 31. VA_END(); 32. } 33. 34. # ifdef USE_STDARG 35. static void 36. vpline(const char *line, va_list the_args) { 37. # else 38. static void 39. vpline(line, the_args) const char *line; va_list the_args; { 40. # endif 41. 42. #else /* USE_STDARG | USE_VARARG */ 43. 44. #define vpline pline 45. 46. void 47. pline VA_DECL(const char *, line) 48. #endif /* USE_STDARG | USE_VARARG */ 49. 50. char pbuf[BUFSZ]; 51. /* Do NOT use VA_START and VA_END in here... see above */ 52. 53. if (!line || !*line) return; 54. if (index(line, '%')) { 55. Vsprintf(pbuf,line,VA_ARGS); 56. line = pbuf; 57. } 58. if (!iflags.window_inited) { 59. raw_print(line); 60. return; 61. } 62. #ifndef MAC 63. if (no_repeat && !strcmp(line, toplines)) 64. return; 65. #endif /* MAC */ 66. if (vision_full_recalc) vision_recalc(0); 67. if (u.ux) flush_screen(1); /* %% */ 68. putstr(WIN_MESSAGE, 0, line); 69. } 70. 71. /*VARARGS1*/ 72. void 73. Norep VA_DECL(const char *, line) 74. VA_START(line); 75. VA_INIT(line, const char *); 76. no_repeat = TRUE; 77. vpline(line, VA_ARGS); 78. no_repeat = FALSE; 79. VA_END(); 80. return; 81. } 82. 83. /* work buffer for You(), &c and verbalize() */ 84. static char *you_buf = 0; 85. static int you_buf_siz = 0; 86. 87. static char * 88. You_buf(siz) 89. int siz; 90. { 91. if (siz > you_buf_siz) { 92. if (you_buf) free((genericptr_t) you_buf); 93. you_buf_siz = siz + 10; 94. you_buf = (char *) alloc((unsigned) you_buf_siz); 95. } 96. return you_buf; 97. } 98. 99. void 100. free_youbuf() 101. { 102. if (you_buf) free((genericptr_t) you_buf), you_buf = (char *)0; 103. you_buf_siz = 0; 104. } 105. 106. /* `prefix' must be a string literal, not a pointer */ 107. #define YouPrefix(pointer,prefix,text) \ 108. Strcpy((pointer = You_buf((int)(strlen(text) + sizeof prefix))), prefix) 109. 110. #define YouMessage(pointer,prefix,text) \ 111. strcat((YouPrefix(pointer, prefix, text), pointer), text) 112. 113. /*VARARGS1*/ 114. void 115. You VA_DECL(const char *, line) 116. char *tmp; 117. VA_START(line); 118. VA_INIT(line, const char *); 119. vpline(YouMessage(tmp, "You ", line), VA_ARGS); 120. VA_END(); 121. } 122. 123. /*VARARGS1*/ 124. void 125. Your VA_DECL(const char *,line) 126. char *tmp; 127. VA_START(line); 128. VA_INIT(line, const char *); 129. vpline(YouMessage(tmp, "Your ", line), VA_ARGS); 130. VA_END(); 131. } 132. 133. /*VARARGS1*/ 134. void 135. You_feel VA_DECL(const char *,line) 136. char *tmp; 137. VA_START(line); 138. VA_INIT(line, const char *); 139. vpline(YouMessage(tmp, "You feel ", line), VA_ARGS); 140. VA_END(); 141. } 142. 143. 144. /*VARARGS1*/ 145. void 146. You_cant VA_DECL(const char *,line) 147. char *tmp; 148. VA_START(line); 149. VA_INIT(line, const char *); 150. vpline(YouMessage(tmp, "You can't ", line), VA_ARGS); 151. VA_END(); 152. } 153. 154. /*VARARGS1*/ 155. void 156. pline_The VA_DECL(const char *,line) 157. char *tmp; 158. VA_START(line); 159. VA_INIT(line, const char *); 160. vpline(YouMessage(tmp, "The ", line), VA_ARGS); 161. VA_END(); 162. } 163. 164. /*VARARGS1*/ 165. void 166. There VA_DECL(const char *,line) 167. char *tmp; 168. VA_START(line); 169. VA_INIT(line, const char *); 170. vpline(YouMessage(tmp, "There ", line), VA_ARGS); 171. VA_END(); 172. } 173. 174. /*VARARGS1*/ 175. void 176. You_hear VA_DECL(const char *,line) 177. char *tmp; 178. VA_START(line); 179. VA_INIT(line, const char *); 180. if (Underwater) 181. YouPrefix(tmp, "You barely hear ", line); 182. else if (u.usleep) 183. YouPrefix(tmp, "You dream that you hear ", line); 184. else 185. YouPrefix(tmp, "You hear ", line); 186. vpline(strcat(tmp, line), VA_ARGS); 187. VA_END(); 188. } 189. 190. /*VARARGS1*/ 191. void 192. verbalize VA_DECL(const char *,line) 193. char *tmp; 194. if (!flags.soundok) return; 195. VA_START(line); 196. VA_INIT(line, const char *); 197. tmp = You_buf((int)strlen(line) + sizeof "\"\""); 198. Strcpy(tmp, "\""); 199. Strcat(tmp, line); 200. Strcat(tmp, "\""); 201. vpline(tmp, VA_ARGS); 202. VA_END(); 203. } 204. 205. /*VARARGS1*/ 206. /* Note that these declarations rely on knowledge of the internals 207. * of the variable argument handling stuff in "tradstdc.h" 208. */ 209. 210. #if defined(USE_STDARG) || defined(USE_VARARGS) 211. static void FDECL(vraw_printf,(const char *,va_list)); 212. 213. void 214. raw_printf VA_DECL(const char *, line) 215. VA_START(line); 216. VA_INIT(line, char *); 217. vraw_printf(line, VA_ARGS); 218. VA_END(); 219. } 220. 221. # ifdef USE_STDARG 222. static void 223. vraw_printf(const char *line, va_list the_args) { 224. # else 225. static void 226. vraw_printf(line, the_args) const char *line; va_list the_args; { 227. # endif 228. 229. #else /* USE_STDARG | USE_VARARG */ 230. 231. void 232. raw_printf VA_DECL(const char *, line) 233. #endif 234. /* Do NOT use VA_START and VA_END in here... see above */ 235. 236. if(!index(line, '%')) 237. raw_print(line); 238. else { 239. char pbuf[BUFSZ]; 240. Vsprintf(pbuf,line,VA_ARGS); 241. raw_print(pbuf); 242. } 243. } 244. 245. 246. /*VARARGS1*/ 247. void 248. impossible VA_DECL(const char *, s) 249. VA_START(s); 250. VA_INIT(s, const char *); 251. if (program_state.in_impossible) 252. panic("impossible called impossible"); 253. program_state.in_impossible = 1; 254. { 255. char pbuf[BUFSZ]; 256. Vsprintf(pbuf,s,VA_ARGS); 257. paniclog("impossible", pbuf); 258. } 259. vpline(s,VA_ARGS); 260. pline("Program in disorder - perhaps you'd better #quit."); 261. program_state.in_impossible = 0; 262. VA_END(); 263. } 264. 265. const char * 266. align_str(alignment) 267. aligntyp alignment; 268. { 269. switch ((int)alignment) { 270. case A_CHAOTIC: return "chaotic"; 271. case A_NEUTRAL: return "neutral"; 272. case A_LAWFUL: return "lawful"; 273. case A_NONE: return "unaligned"; 274. } 275. return "unknown"; 276. } 277. 278. void 279. mstatusline(mtmp) 280. register struct monst *mtmp; 281. { 282. aligntyp alignment; 283. char info[BUFSZ], monnambuf[BUFSZ]; 284. 285. if (mtmp->ispriest || mtmp->data == &mons[PM_ALIGNED_PRIEST] 286. || mtmp->data == &mons[PM_ANGEL]) 287. alignment = EPRI(mtmp)->shralign; 288. else 289. alignment = mtmp->data->maligntyp; 290. alignment = (alignment > 0) ? A_LAWFUL : 291. (alignment < 0) ? A_CHAOTIC : 292. A_NEUTRAL; 293. 294. info[0] = 0; 295. if (mtmp->mtame) { Strcat(info, ", tame"); 296. #ifdef WIZARD 297. if (wizard) { 298. Sprintf(eos(info), " (%d", mtmp->mtame); 299. if (!mtmp->isminion) 300. Sprintf(eos(info), "; hungry %ld; apport %d", 301. EDOG(mtmp)->hungrytime, EDOG(mtmp)->apport); 302. Strcat(info, ")"); 303. } 304. #endif 305. } 306. else if (mtmp->mpeaceful) Strcat(info, ", peaceful"); 307. else if (mtmp->mtraitor) Strcat(info, ", traitor"); 308. if (mtmp->meating) Strcat(info, ", eating"); 309. if (mtmp->mcan) Strcat(info, ", cancelled"); 310. if (mtmp->mconf) Strcat(info, ", confused"); 311. if (mtmp->mblinded || !mtmp->mcansee) 312. Strcat(info, ", blind"); 313. if (mtmp->mstun) Strcat(info, ", stunned"); 314. if (mtmp->msleeping) Strcat(info, ", asleep"); 315. #if 0 /* unfortunately mfrozen covers temporary sleep and being busy 316. (donning armor, for instance) as well as paralysis */ 317. else if (mtmp->mfrozen) Strcat(info, ", paralyzed"); 318. #else 319. else if (mtmp->mfrozen || !mtmp->mcanmove) 320. Strcat(info, ", can't move"); 321. #endif 322. /* [arbitrary reason why it isn't moving] */ 323. else if (mtmp->mstrategy & STRAT_WAITMASK) 324. Strcat(info, ", meditating"); 325. else if (mtmp->mflee) { Strcat(info, ", scared"); 326. #ifdef WIZARD 327. if (wizard) Sprintf(eos(info), " (%d)", mtmp->mfleetim); 328. #endif 329. } 330. if (mtmp->mtrapped) Strcat(info, ", trapped"); 331. if (mtmp->mspeed) Strcat(info, 332. mtmp->mspeed == MFAST ? ", fast" : 333. mtmp->mspeed == MSLOW ? ", slow" : 334. ", ???? speed"); 335. if (mtmp->mundetected) Strcat(info, ", concealed"); 336. if (mtmp->minvis) Strcat(info, ", invisible"); 337. if (mtmp == u.ustuck) Strcat(info, 338. (sticks(youmonst.data)) ? ", held by you" : 339. u.uswallow ? (is_animal(u.ustuck->data) ? 340. ", swallowed you" : 341. ", engulfed you") : 342. ", holding you"); 343. #ifdef STEED 344. if (mtmp == u.usteed) Strcat(info, ", carrying you"); 345. #endif 346. 347. /* avoid "Status of the invisible newt ..., invisible" */ 348. /* and unlike a normal mon_nam, use "saddled" even if it has a name */ 349. Strcpy(monnambuf, x_monnam(mtmp, ARTICLE_THE, (char *)0, 350. (SUPPRESS_IT|SUPPRESS_INVISIBLE), FALSE)); 351. 352. pline("Status of %s (%s): Level %d HP %d(%d) Pw %d(%d) AC %d%s.", 353. monnambuf, 354. align_str(alignment), 355. mtmp->m_lev, 356. mtmp->mhp, 357. mtmp->mhpmax, 358. mtmp->m_en, 359. mtmp->m_enmax, 360. find_mac(mtmp), 361. info); 362. } 363. 364. void 365. ustatusline() 366. { 367. char info[BUFSZ]; 368. 369. info[0] = '\0'; 370. if (Sick) { 371. Strcat(info, ", dying from"); 372. if (u.usick_type & SICK_VOMITABLE) 373. Strcat(info, " food poisoning"); 374. if (u.usick_type & SICK_NONVOMITABLE) { 375. if (u.usick_type & SICK_VOMITABLE) 376. Strcat(info, " and"); 377. Strcat(info, " illness"); 378. } 379. } 380. if (Stoned) Strcat(info, ", solidifying"); 381. if (Slimed) Strcat(info, ", becoming slimy"); 382. if (Strangled) Strcat(info, ", being strangled"); 383. if (Vomiting) Strcat(info, ", nauseated"); /* !"nauseous" */ 384. if (Confusion) Strcat(info, ", confused"); 385. if (Blind) { 386. Strcat(info, ", blind"); 387. if (u.ucreamed) { 388. if ((long)u.ucreamed < Blinded || Blindfolded 389. || !haseyes(youmonst.data)) 390. Strcat(info, ", cover"); 391. Strcat(info, "ed by sticky goop"); 392. } /* note: "goop" == "glop"; variation is intentional */ 393. } 394. if (Stunned) Strcat(info, ", stunned"); 395. #ifdef STEED 396. if (!u.usteed) 397. #endif 398. if (Wounded_legs) { 399. const char *what = body_part(LEG); 400. if ((Wounded_legs & BOTH_SIDES) == BOTH_SIDES) 401. what = makeplural(what); 402. Sprintf(eos(info), ", injured %s", what); 403. } 404. if (Glib) Sprintf(eos(info), ", slippery %s", 405. makeplural(body_part(HAND))); 406. if (u.utrap) Strcat(info, ", trapped"); 407. if (Fast) Strcat(info, Very_fast ? 408. ", very fast" : ", fast"); 409. if (u.uundetected) Strcat(info, ", concealed"); 410. if (Invis) Strcat(info, ", invisible"); 411. if (u.ustuck) { 412. if (sticks(youmonst.data)) 413. Strcat(info, ", holding "); 414. else 415. Strcat(info, ", held by "); 416. Strcat(info, mon_nam(u.ustuck)); 417. } 418. 419. pline("Status of %s (%s%s): Level %d HP %d(%d) Pw %d(%d) AC %d%s.", 420. plname, 421. (u.ualign.record >= 20) ? "piously " : 422. (u.ualign.record > 13) ? "devoutly " : 423. (u.ualign.record > 8) ? "fervently " : 424. (u.ualign.record > 3) ? "stridently " : 425. (u.ualign.record == 3) ? "" : 426. (u.ualign.record >= 1) ? "haltingly " : 427. (u.ualign.record == 0) ? "nominally " : 428. "insufficiently ", 429. align_str(u.ualign.type), 430. Upolyd ? mons[u.umonnum].mlevel : u.ulevel, 431. Upolyd ? u.mh : u.uhp, 432. Upolyd ? u.mhmax : u.uhpmax, 433. u.uen, 434. u.uenmax, 435. u.uac, 436. info); 437. } 438. 439. void 440. self_invis_message() 441. { 442. pline("%s %s.", 443. Hallucination ? "Far out, man! You" : "Gee! All of a sudden, you", 444. See_invisible ? "can see right through yourself" : 445. "can't see yourself"); 446. } 447. 448. #endif /* OVLB */ 449. /*pline.c*/