diag.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. /* =============================================================================
  2. * PROGRAM: ularn
  3. * FILENAME: diag.c
  4. *
  5. * DESCRIPTION:
  6. * Diagnostic dump module.
  7. *
  8. * =============================================================================
  9. * EXPORTED VARIABLES
  10. *
  11. * None
  12. *
  13. * =============================================================================
  14. * EXPORTED FUNCTIONS
  15. *
  16. * diag - Print diagnostic information
  17. *
  18. * =============================================================================
  19. */
  20. #include "diag.h"
  21. #include "dungeon.h"
  22. #include "header.h"
  23. #include "itm.h"
  24. #include "monster.h"
  25. #include "player.h"
  26. #include "potion.h"
  27. #include "scroll.h"
  28. #include "spell.h"
  29. #include "ularn_game.h"
  30. #include "ularn_win.h"
  31. /* =============================================================================
  32. * Local variables
  33. */
  34. /*
  35. * Character attribute strings.
  36. * The strings must match the order of the AttributeType enumeration
  37. */
  38. static char *cdef[] = {"STRENGTH",
  39. "INTELLIGENCE",
  40. "WISDOM",
  41. "CONSTITUTION",
  42. "DEXTERITY",
  43. "CHARISMA",
  44. "HPMAX",
  45. "HP",
  46. "GOLD",
  47. "EXPERIENCE",
  48. "LEVEL",
  49. "REGEN",
  50. "WCLASS",
  51. "AC",
  52. "BANKACCOUNT",
  53. "SPELLMAX",
  54. "SPELLS",
  55. "ENERGY",
  56. "ECOUNTER",
  57. "MOREDEFENSES",
  58. "WEAR",
  59. "PROTECTIONTIME",
  60. "WIELD",
  61. "AMULET",
  62. "REGENCOUNTER",
  63. "MOREDAM",
  64. "DEXCOUNT",
  65. "STRCOUNT",
  66. "BLINDCOUNT",
  67. "CAVELEVEL",
  68. "CONFUSE",
  69. "ALTPRO",
  70. "HERO",
  71. "CHARMCOUNT",
  72. "INVISIBILITY",
  73. "CANCELLATION",
  74. "HASTESELF",
  75. "EYEOFLARN",
  76. "AGGRAVATE ",
  77. "GLOBE",
  78. "TELEFLAG",
  79. "SLAYING",
  80. "NEGATESPIRIT",
  81. "SCAREMONST ",
  82. "AWARENESS",
  83. "HOLDMONST",
  84. "TIMESTOP",
  85. "HASTEMONST",
  86. "CUBEofUNDEAD",
  87. "GIANTSTR",
  88. "FIRERESISTANCE",
  89. "BESSMANN",
  90. "NOTHEFT",
  91. "HARDGAME",
  92. "",
  93. "",
  94. "",
  95. "",
  96. "",
  97. "VORPAL",
  98. "LANCEDEATH",
  99. "SPIRITPRO",
  100. "UNDEADPRO",
  101. "SHIELD ",
  102. "STEALTH",
  103. "ITCHING",
  104. "LAUGHING",
  105. "DRAINSTRENGTH",
  106. "CLUMSINESS",
  107. "INFEEBLEMENT",
  108. "HALFDAM",
  109. "SEEINVISIBLE",
  110. "FILLROOM",
  111. "",
  112. "SPHCAST",
  113. "WTW",
  114. "STREXTRA",
  115. "TMP",
  116. "LIFEPROT",
  117. "ORB",
  118. "ELVUP",
  119. "ELVDOWN",
  120. "HAND",
  121. "CUBEUNDEAD",
  122. "DRAGSLAY",
  123. "NEGATE",
  124. "URN",
  125. "LAMP",
  126. "TALISMAN",
  127. "WAND",
  128. "STAFF",
  129. "DEVICE",
  130. "SLASH",
  131. "ELVEN",
  132. "VORP",
  133. "SLAY",
  134. "PAD",
  135. "COKED",
  136. "",
  137. ""};
  138. /*
  139. * Names for inventory items
  140. */
  141. static char *ivendef[] = {"",
  142. "OALTAR",
  143. "OTHRONE",
  144. "OORB",
  145. "OPIT",
  146. "OSTAIRSUP",
  147. "OELEVATORUP",
  148. "OFOUNTAIN",
  149. "OSTATUE",
  150. "OTELEPORTER",
  151. "OSCHOOL",
  152. "OMIRROR",
  153. "ODNDSTORE",
  154. "OSTAIRSDOWN",
  155. "OELEVATORDOWN",
  156. "OBANK2",
  157. "OBANK",
  158. "ODEADFOUNTAIN",
  159. "OGOLDPILE",
  160. "OOPENDOOR",
  161. "OCLOSEDDOOR",
  162. "OWALL",
  163. "OTRAPARROW",
  164. "OTRAPARROWIV",
  165. "OLARNEYE",
  166. "OPLATE",
  167. "OCHAIN",
  168. "OLEATHER",
  169. "ORING",
  170. "OSTUDLEATHER",
  171. "OSPLINT",
  172. "OPLATEARMOR",
  173. "OSSPLATE",
  174. "OSHIELD",
  175. "OSWORDofSLASHING",
  176. "OHAMMER",
  177. "OSWORD",
  178. "O2SWORD",
  179. "OSPEAR",
  180. "ODAGGER",
  181. "OBATTLEAXE",
  182. "OLONGSWORD",
  183. "OFLAIL",
  184. "OLANCE",
  185. "ORINGOFEXTRA",
  186. "OREGENRING",
  187. "OPROTRING",
  188. "OENERGYRING",
  189. "ODEXRING",
  190. "OSTRRING",
  191. "OCLEVERRING",
  192. "ODAMRING",
  193. "OBELT",
  194. "OSCROLL",
  195. "OPOTION",
  196. "OBOOK",
  197. "OCHEST",
  198. "OAMULET",
  199. "OORBOFDRAGON",
  200. "OSPIRITSCARAB",
  201. "OCUBEofUNDEAD",
  202. "ONOTHEFT",
  203. "ODIAMOND",
  204. "ORUBY",
  205. "OEMERALD",
  206. "OSAPPHIRE",
  207. "OENTRANCE",
  208. "OVOLDOWN",
  209. "OVOLUP",
  210. "OHOME",
  211. "OMAXGOLD",
  212. "OKGOLD",
  213. "ODGOLD",
  214. "OIVDARTRAP",
  215. "ODARTRAP",
  216. "OTRAPDOOR",
  217. "OIVTRAPDOOR",
  218. "OTRADEPOST",
  219. "OIVTELETRAP",
  220. "ODEADTHRONE",
  221. "OANNIHILATION",
  222. "OTHRONE2",
  223. "OLRS",
  224. "OCOOKIE",
  225. "OURN",
  226. "OBRASSLAMP",
  227. "OHANDofFEAR",
  228. "OSPHTALISMAN",
  229. "OWWAND",
  230. "OPSTAFF",
  231. "OVORPAL",
  232. "OSLAYER",
  233. "OELVENCHAIN",
  234. "OSPEED",
  235. "OACID",
  236. "OHASH",
  237. "OSHROOMS",
  238. "OCOKE",
  239. "OPAD",
  240. ""};
  241. /*
  242. * Pointer to the debug output file
  243. */
  244. static FILE *dfile;
  245. /* =============================================================================
  246. * Local functions
  247. */
  248. /* =============================================================================
  249. * FUNCTION: drawdiagscreen
  250. *
  251. * DESCRIPTION:
  252. * Draw the ASCII map to the diag file.
  253. *
  254. * PARAMETERS:
  255. *
  256. * None.
  257. *
  258. * RETURN VALUE:
  259. *
  260. * None.
  261. */
  262. static void diagdrawscreen(void) {
  263. int i, j;
  264. MonsterIdType Monst;
  265. /* east west walls of this line */
  266. for (i = 0; i < MAXY; i++) {
  267. for (j = 0; j < MAXX; j++) {
  268. Monst = mitem[j][i].mon;
  269. if (Monst != MONST_NONE)
  270. fprintf(dfile, "%c", monstnamelist[Monst]);
  271. else
  272. fprintf(dfile, "%c", objnamelist[(int)item[j][i]]);
  273. }
  274. fprintf(dfile, "\n");
  275. }
  276. }
  277. /* =============================================================================
  278. * Exported functions
  279. */
  280. /* =============================================================================
  281. * FUNCTION: diag
  282. */
  283. void diag(void) {
  284. int i, j;
  285. MonsterIdType Monst;
  286. if ((dfile = fopen(diagfile, "w")) == (FILE *)NULL)
  287. return;
  288. Print("\nDiagnosing . . .\n");
  289. fprintf(dfile, "\n-------- Beginning of DIAG diagnostics ---------\n\n");
  290. fprintf(dfile, "Hit points: %2ld(%2ld)\n", c[HP], c[HPMAX]);
  291. fprintf(dfile,
  292. "gold: %ld Experience: %ld Character level: %ld Level in caverns: "
  293. "%d\n",
  294. (long)c[GOLD], (long)c[EXPERIENCE], (long)c[LEVEL], level);
  295. fprintf(dfile, "\nFor the c[] array:\n");
  296. fflush(dfile);
  297. for (j = 0; j < 100; j++)
  298. fprintf(dfile, "c[%d]\t%-20s\t= %ld\n", j, cdef[j], c[j]);
  299. fprintf(dfile, "\n\n");
  300. fflush(dfile);
  301. fprintf(dfile, "Inventory\n");
  302. for (j = 0; j < IVENSIZE; j++) {
  303. fprintf(dfile, "iven[%d] %-12s = %d", j, ivendef[(int)iven[j]], iven[j]);
  304. fprintf(dfile, "\t%s", objectname[(int)iven[j]]);
  305. fprintf(dfile, "\t+ %d\n", ivenarg[j]);
  306. }
  307. fprintf(dfile, "\nHere are the maps:\n\n");
  308. i = level;
  309. for (j = 0; j < NLEVELS; j++) {
  310. newcavelevel(j);
  311. fprintf(dfile, "\n---------------------------------------------------------"
  312. "----------\n");
  313. fprintf(dfile, "Map %s level %d\n", levelname[level], level);
  314. fprintf(dfile, "-----------------------------------------------------------"
  315. "--------\n");
  316. diagdrawscreen();
  317. fflush(dfile);
  318. }
  319. level = (char)i;
  320. getlevel();
  321. fprintf(dfile, "\n\nNow for the monster data:\n\n");
  322. fprintf(dfile, "\nTotal types of monsters: %d\n\n", MAXMONST + 8);
  323. fprintf(dfile,
  324. " Monster Name LEV AC DAM ATT GOLD HP EXP\n");
  325. fprintf(
  326. dfile,
  327. "-----------------------------------------------------------------\n");
  328. fflush(dfile);
  329. for (Monst = MONST_NONE; Monst < MONST_COUNT; Monst++) {
  330. fprintf(dfile, "%19s %2d %3d ", monster[Monst].name, monster[Monst].level,
  331. monster[Monst].armorclass);
  332. fprintf(dfile, " %3d %3d ", monster[Monst].damage, monster[Monst].attack);
  333. fprintf(dfile, "%6d %3d %6ld\n", monster[Monst].gold,
  334. monster[Monst].hitpoints, (long)monster[Monst].experience);
  335. fflush(dfile);
  336. }
  337. fprintf(dfile, "\nAvailable potions:\n\n");
  338. for (i = 0; i < MAXPOTION; i++)
  339. fprintf(dfile, "%20s\n", &potionname[i][1]);
  340. fflush(dfile);
  341. fprintf(dfile, "\nAvailable scrolls:\n\n");
  342. for (i = 0; i < MAXSCROLL; i++)
  343. fprintf(dfile, "%20s\n", &scrollname[i][1]);
  344. fflush(dfile);
  345. fprintf(dfile, "\nSpell list:\n\n");
  346. fprintf(dfile, "spell# name description\n");
  347. fprintf(dfile, "-------------------------------------------------\n\n");
  348. for (j = 0; j < SPELL_COUNT; j++) {
  349. fprintf(dfile, "%-10s", spelcode[j]);
  350. fprintf(dfile, " %21s\n", spelname[j]);
  351. fprintf(dfile, "%s\n", speldescript[j]);
  352. }
  353. fflush(dfile);
  354. fprintf(dfile, "\nObject list\n\n");
  355. fprintf(dfile, "\nj \tObject \tName\n");
  356. fprintf(dfile, "---------------------------------\n");
  357. for (j = 0; j < OCOUNT; j++) {
  358. fprintf(dfile, "%d \t%c \t%s\n", j, objnamelist[j], objectname[j]);
  359. }
  360. fflush(dfile);
  361. fprintf(dfile, "\n-------- End of DIAG diagnostics ---------\n");
  362. fflush(dfile);
  363. fclose(dfile);
  364. Print("\nDone Diagnosing.\n");
  365. }