Source:NetHack 3.1.0/pline.c
Revision as of 07:15, 4 March 2008 by Kernigh bot (talk | contribs) (NetHack 3.1.0/pline.c moved to Source:NetHack 3.1.0/pline.c: Robot: moved page)
Below is the full text to pline.c from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/pline.c#line123]], for example.
Warning! This is the source code from an old release. For the latest release, see Source code
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* SCCS Id: @(#)pline.c 3.1 92/11/20 */ 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. 9. #ifndef OVLB 10. STATIC_DCL boolean no_repeat; 11. #else /* OVLB */ 12. STATIC_OVL boolean no_repeat = FALSE; 13. #endif /* OVLB */ 14. 15. #ifdef OVLB 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. Strcpy(pbuf,line); 56. else 57. Vsprintf(pbuf,line,VA_ARGS); 58. if(!flags.window_inited) { 59. raw_print(pbuf); 60. return; 61. } 62. #ifndef MAC 63. if(no_repeat && !strcmp(pbuf, 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, pbuf); 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(), Your(), and verbalize() */ 84. static char *you_buf = 0; 85. static int you_buf_siz = 0; 86. 87. static char * 88. You_buf(siz) int siz; { 89. if (siz > you_buf_siz) { 90. if (you_buf_siz > 0) free((genericptr_t) you_buf); 91. you_buf_siz = siz + 10; 92. you_buf = (char *) alloc((unsigned) you_buf_siz); 93. } 94. return you_buf; 95. } 96. 97. /*VARARGS1*/ 98. void 99. You VA_DECL(const char *, line) 100. char *tmp; 101. VA_START(line); 102. VA_INIT(line, const char *); 103. tmp = You_buf((int)strlen(line) + 5); 104. Strcpy(tmp, "You "); 105. Strcat(tmp, line); 106. vpline(tmp, VA_ARGS); 107. VA_END(); 108. } 109. 110. /*VARARGS1*/ 111. void 112. Your VA_DECL(const char *,line) 113. char *tmp; 114. VA_START(line); 115. VA_INIT(line, const char *); 116. tmp = You_buf((int)strlen(line) + 6); 117. Strcpy(tmp, "Your "); 118. Strcat(tmp, line); 119. vpline(tmp, VA_ARGS); 120. VA_END(); 121. } 122. 123. /*VARARGS1*/ 124. void 125. verbalize VA_DECL(const char *,line) 126. char *tmp; 127. if (!flags.soundok) return; 128. VA_START(line); 129. VA_INIT(line, const char *); 130. tmp = You_buf((int)strlen(line) + 3); 131. Strcpy(tmp, "\""); 132. Strcat(tmp, line); 133. Strcat(tmp, "\""); 134. vpline(tmp, VA_ARGS); 135. VA_END(); 136. } 137. 138. /*VARARGS1*/ 139. /* Note that these declarations rely on knowledge of the internals 140. * of the variable argument handling stuff in "tradstdc.h" 141. */ 142. 143. #if defined(USE_STDARG) || defined(USE_VARARGS) 144. static void FDECL(vraw_printf,(const char *,va_list)); 145. 146. void 147. raw_printf VA_DECL(const char *, line) 148. VA_START(line); 149. VA_INIT(line, char *); 150. vraw_printf(line, VA_ARGS); 151. VA_END(); 152. } 153. 154. # ifdef USE_STDARG 155. static void 156. vraw_printf(const char *line, va_list the_args) { 157. # else 158. static void 159. vraw_printf(line, the_args) const char *line; va_list the_args; { 160. # endif 161. 162. #else /* USE_STDARG | USE_VARARG */ 163. 164. void 165. raw_printf VA_DECL(const char *, line) 166. #endif 167. /* Do NOT use VA_START and VA_END in here... see above */ 168. 169. if(!index(line, '%')) 170. raw_print(line); 171. else { 172. char pbuf[BUFSZ]; 173. Vsprintf(pbuf,line,VA_ARGS); 174. raw_print(pbuf); 175. } 176. } 177. 178. 179. /*VARARGS1*/ 180. void 181. impossible VA_DECL(const char *, s) 182. VA_START(s); 183. VA_INIT(s, const char *); 184. vpline(s,VA_ARGS); 185. pline("Program in disorder - perhaps you'd better Quit."); 186. VA_END(); 187. } 188. 189. const char * 190. align_str(alignment) 191. aligntyp alignment; 192. { 193. switch ((int)alignment) { 194. case A_CHAOTIC: return "chaotic"; 195. case A_NEUTRAL: return "neutral"; 196. case A_LAWFUL: return "lawful"; 197. case A_NONE: return "unaligned"; 198. } 199. return "unknown"; 200. } 201. 202. void 203. mstatusline(mtmp) 204. register struct monst *mtmp; 205. { 206. aligntyp alignment; 207. 208. if (mtmp->ispriest || mtmp->data == &mons[PM_ALIGNED_PRIEST] 209. || mtmp->data == &mons[PM_ANGEL]) 210. alignment = EPRI(mtmp)->shralign; 211. else 212. alignment = mtmp->data->maligntyp; 213. 214. alignment = (alignment > 0) ? A_LAWFUL : 215. (alignment < 0) ? A_CHAOTIC : 216. A_NEUTRAL; 217. pline("Status of %s (%s): Level %d Gold %lu HP %d(%d) AC %d%s%s", 218. mon_nam(mtmp), 219. align_str(alignment), 220. mtmp->m_lev, 221. mtmp->mgold, 222. mtmp->mhp, 223. mtmp->mhpmax, 224. find_mac(mtmp), 225. mtmp->mcan ? ", cancelled" : "" , 226. mtmp->mtame ? ", tame" : ""); 227. } 228. 229. void 230. ustatusline() 231. { 232. pline("Status of %s (%s%s): Level %d Gold %lu HP %d(%d) AC %d", 233. plname, 234. (u.ualign.record >= 20) ? "piously " : 235. (u.ualign.record > 13) ? "devoutly " : 236. (u.ualign.record > 8) ? "fervently " : 237. (u.ualign.record > 3) ? "stridently " : 238. (u.ualign.record == 3) ? "" : 239. (u.ualign.record >= 1) ? "haltingly " : 240. (u.ualign.record == 0) ? "nominally " : 241. "insufficiently ", 242. align_str(u.ualign.type), 243. # ifdef POLYSELF 244. u.mtimedone ? mons[u.umonnum].mlevel : u.ulevel, 245. u.ugold, 246. u.mtimedone ? u.mh : u.uhp, 247. u.mtimedone ? u.mhmax : u.uhpmax, 248. # else 249. u.ulevel, 250. u.ugold, 251. u.uhp, 252. u.uhpmax, 253. # endif 254. u.uac); 255. } 256. 257. #endif /* OVLB */ 258. 259. /*pline.c*/