About: Source:NetHack 3.0.0/makedefs.c   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Below is the full text to makedefs.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/makedefs.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code

AttributesValues
rdfs:label
  • Source:NetHack 3.0.0/makedefs.c
rdfs:comment
  • Below is the full text to makedefs.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/makedefs.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code
dcterms:subject
dbkwik:nethack/pro...iPageUsesTemplate
abstract
  • Below is the full text to makedefs.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/makedefs.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 2. /* NetHack may be freely redistributed. See license for details. */ 3. /* makedefs.c - NetHack version 3.0 */ 4. 5. #define MAKEDEFS_C 6. 7. #define EXTERN_H 8. #include "config.h" 9. #include "permonst.h" 10. #include "objclass.h" 11. #ifdef NULL 12. #undef NULL 13. #endif /* NULL */ 14. #define NULL ((genericptr_t)0) 15. 16. #ifndef LINT 17. static const char SCCS_Id[] = "@(#)makedefs.c 3.0 89/01/10"; 18. #endif 19. 20. #ifdef MSDOS 21. # define freopen _freopen 22. # undef exit 23. extern void exit P((int)); 24. # define RDMODE "r" 25. # define WRMODE "w" 26. #else 27. # define RDMODE "r+" 28. # define WRMODE "w+" 29. #endif 30. #if defined(SYSV) || defined(GENIX) || defined(UNIXDEBUG) 31. void rename(); 32. #endif 33. #ifdef AMIGA 34. # undef freopen 35. # undef printf 36. # undef puts 37. # undef fflush 38. # define fflush FFLUSH 39. # undef fputs 40. # undef fprintf 41. #endif 42. 43. /* construct definitions of object constants */ 44. 45. #ifdef AMIGA 46. # define MONST_FILE "include:pm.h" 47. # define ONAME_FILE "include:onames.h" 48. # define TRAP_FILE "include:trap.h" 49. # define DATE_FILE "include:date.h" 50. # define DATA_FILE "auxil:data" 51. # define RUMOR_FILE "auxil:rumors" 52. #else 53. # define MONST_FILE "../include/pm.h" 54. # define ONAME_FILE "../include/onames.h" 55. # define TRAP_FILE "../include/trap.h" 56. # define DATE_FILE "../include/date.h" 57. # define DATA_FILE "../auxil/data" 58. # define RUMOR_FILE "../auxil/rumors" 59. #endif 60. 61. char in_line[256]; 62. extern char *gets P((char *)); 63. void do_objs(), do_traps(), do_data(), do_date(), do_permonst(), do_rumors(); 64. char *limit P((char *,boolean)); 65. FILE *_freopen(); 66. 67. int 68. main(argc, argv) 69. int argc; 70. char *argv[]; 71. { 72. char *option; 73. 74. if(argc == 2) { 75. option = argv[1]; 76. switch (option[1]) { 77. 78. case 'o': 79. case 'O': do_objs(); 80. break; 81. case 't': 82. case 'T': do_traps(); 83. break; 84. 85. case 'd': 86. case 'D': do_data(); 87. break; 88. 89. case 'v': 90. case 'V': do_date(); 91. break; 92. 93. case 'p': 94. case 'P': do_permonst(); 95. break; 96. 97. case 'r': 98. case 'R': do_rumors(); 99. break; 100. 101. default: 102. (void) fprintf(stderr, "Unknown option '%c'. ", option[1]); 103. (void) fflush(stderr); 104. exit(1); 105. } 106. exit(0); 107. } else (void) fprintf(stderr, "Bad arg count (%d). ", argc-1); 108. (void) fflush(stderr); 109. exit(1); 110. /*NOTREACHED*/ 111. #ifdef MSDOS 112. return 0; 113. #endif 114. } 115. 116. void 117. do_traps() { 118. int ntrap; 119. char tempfile[30]; 120. 121. Sprintf(tempfile, "makedefs.%d", getpid()); 122. if(freopen(tempfile, WRMODE, stdout) == (FILE *)0) { 123. perror(tempfile); 124. exit(1); 125. } 126. 127. if(freopen(TRAP_FILE, RDMODE, stdin) == (FILE *)0) { 128. perror(TRAP_FILE); 129. exit(1); 130. } 131. 132. while(gets(in_line) != NULL) { 133. (void) puts(in_line); 134. if(!strncmp(in_line, "/* DO NOT REMOVE THIS LINE */", 29)) break; 135. } 136. ntrap = 10; 137. Printf(" "); 138. Printf("#define MGTRP %d ", ntrap++); 139. Printf("#define SQBRD %d ", ntrap++); 140. Printf("#define WEB %d ", ntrap++); 141. Printf("#define SPIKED_PIT %d ", ntrap++); 142. Printf("#define LEVEL_TELEP %d ", ntrap++); 143. #ifdef SPELLS 144. Printf("#define ANTI_MAGIC %d ", ntrap++); 145. #endif 146. Printf("#define RUST_TRAP %d ", ntrap++); 147. #ifdef POLYSELF 148. Printf("#define POLY_TRAP %d ", ntrap++); 149. #endif 150. Printf("#define LANDMINE %d ", ntrap++); 151. Printf(" #define TRAPNUM %d ", ntrap); 152. Printf(" #endif /* TRAP_H /**/ "); 153. (void) fclose(stdin); 154. (void) fclose(stdout); 155. #ifdef MSDOS 156. remove(TRAP_FILE); 157. #endif 158. rename(tempfile, TRAP_FILE); 159. return; 160. } 161. 162. 163. void 164. do_rumors(){ 165. char infile[30]; 166. FILE *freopen(); 167. long true_rumor_size; 168. 169. if(freopen(RUMOR_FILE, WRMODE, stdout) == (FILE *)0) { 170. perror(RUMOR_FILE); 171. exit(1); 172. } 173. 174. Sprintf(infile, "%s.tru", RUMOR_FILE); 175. if(freopen(infile, RDMODE, stdin) == (FILE *)0) { 176. perror(infile); 177. exit(1); 178. } 179. 180. /* get size of true rumors file */ 181. (void) fseek(stdin, 0L, 2); 182. true_rumor_size = ftell(stdin); 183. (void) fwrite((genericptr_t)&true_rumor_size,sizeof(long),1,stdout); 184. (void) fseek(stdin, 0L, 0); 185. 186. /* copy true rumors */ 187. while(gets(in_line) != NULL) (void) puts(in_line); 188. 189. Sprintf(infile, "%s.fal", RUMOR_FILE); 190. if(freopen(infile, RDMODE, stdin) == (FILE *)0) { 191. perror(infile); 192. exit(1); 193. } 194. 195. /* copy false rumors */ 196. while(gets(in_line) != NULL) (void) puts(in_line); 197. 198. (void) fclose(stdin); 199. (void) fclose(stdout); 200. return; 201. } 202. 203. #ifdef SYSV 204. extern long time(); 205. #endif 206. 207. void 208. do_date(){ 209. long clock; 210. char cbuf[30], *c; 211. 212. if(freopen(DATE_FILE, WRMODE, stdout) == (FILE *)0) { 213. perror(DATE_FILE); 214. exit(1); 215. } 216. Printf("/* SCCS Id: @(#)date.h 3.0 88/11/20 */ "); 217. 218. (void) time(&clock); 219. Strcpy(cbuf, ctime(&clock)); 220. for(c = cbuf; *c != ' '; c++); *c = 0; /* strip off the ' ' */ 221. Printf("const char datestring[] = \"%s\"; ", cbuf); 222. 223. (void) fclose(stdout); 224. return; 225. } 226. 227. void 228. do_data(){ 229. char tempfile[30]; 230. 231. Sprintf(tempfile, "%s.base", DATA_FILE); 232. if(freopen(tempfile, RDMODE, stdin) == (FILE *)0) { 233. perror(tempfile); 234. exit(1); 235. } 236. 237. if(freopen(DATA_FILE, WRMODE, stdout) == (FILE *)0) { 238. perror(DATA_FILE); 239. exit(1); 240. } 241. 242. while(gets(in_line) != NULL) { 243. #ifdef SINKS 244. if(!strcmp(in_line, "# a corridor")) 245. Printf("# a corridor (or a kitchen sink) "); 246. else 247. #endif 248. #ifdef ALTARS 249. if(!strcmp(in_line, "_ an iron chain")) 250. Printf("_ an iron chain (or an altar) "); 251. else 252. #endif 253. #ifdef SPELLS 254. if(!strcmp(in_line, "+ a door")) 255. Printf("+ a door (or a spell book) "); 256. else 257. #endif 258. #ifdef FOUNTAINS 259. if(!strcmp(in_line, "} water filled area")) { 260. (void) puts(in_line); 261. Printf("{ a fountain "); 262. } else 263. #endif 264. #ifdef THRONES 265. if(!strcmp(in_line, "^ a trap")) { 266. (void) puts(in_line); 267. Printf("\\ an opulent throne "); 268. } else 269. #endif 270. if(!strcmp(in_line, "; a giant eel")) { 271. (void) puts(in_line); 272. #ifdef WORM 273. Printf("~ the tail of a long worm "); 274. #endif 275. #ifdef GOLEMS 276. Printf("' a golem "); 277. Printf(" These creatures, not quite living but not really nonliving "); 278. Printf(" either, are created from inanimate materials by powerful "); 279. Printf(" mages or priests. "); 280. #endif 281. } else 282. (void) puts(in_line); 283. } 284. (void) fclose(stdin); 285. (void) fclose(stdout); 286. return; 287. } 288. 289. void 290. do_permonst() { 291. 292. int i; 293. char *c; 294. 295. if(freopen(MONST_FILE, WRMODE, stdout) == (FILE *)0) { 296. perror(MONST_FILE); 297. exit(1); 298. } 299. Printf("/* SCCS Id: @(#)pm.h 3.0 88/11/20 */ "); 300. Printf("#ifndef PM_H #define PM_H "); 301. 302. for(i = 0; mons[i].mlet; i++) { 303. Printf(" #define PM_"); 304. for(c = mons[i].mname; *c; c++) { 305. if((*c >= 'a') && (*c <= 'z')) *c -= (char)('a' - 'A'); 306. else if(*c == ' ' || *c == '-') *c = '_'; 307. } 308. Printf("%s %d", mons[i].mname, i); 309. } 310. Printf(" #define NUMMONS %d ", i); 311. Printf(" #endif /* PM_H /**/ "); 312. (void) fclose(stdout); 313. return; 314. } 315. 316. static char temp[32]; 317. 318. char * 319. limit(name,pref) /* limit a name to 30 characters length */ 320. char *name; 321. boolean pref; 322. { 323. (void) strncpy(temp, name, pref ? 26 : 30); 324. temp[pref ? 26 : 30] = 0; 325. return temp; 326. } 327. 328. void 329. do_objs() { 330. 331. register int i = 0, sum = 0; 332. register char *c; 333. #ifdef SPELLS 334. register int nspell = 0; 335. #endif 336. register boolean prefix = 0; 337. register char let = '\0'; 338. boolean sumerr = FALSE; 339. 340. if(freopen(ONAME_FILE, WRMODE, stdout) == (FILE *)0) { 341. perror(ONAME_FILE); 342. exit(1); 343. } 344. Printf("/* SCCS Id: @(#)onames.h 3.0 89/01/10 */ "); 345. Printf("#ifndef ONAMES_H #define ONAMES_H "); 346. 347. for(i = 0; !i || objects[i].oc_olet != ILLOBJ_SYM; i++) { 348. if (!(c = objects[i].oc_name)) continue; 349. 350. /* make sure probabilities add up to 1000 */ 351. if(objects[i].oc_olet != let) { 352. if (sum && sum != 1000) { 353. (void) fprintf(stderr, "prob error for %c (%d%%)", let, sum); 354. (void) fflush(stderr); 355. sumerr = TRUE; 356. } 357. let = objects[i].oc_olet; 358. sum = 0; 359. } 360. 361. for(; *c; c++) { 362. if((*c >= 'a') && (*c <= 'z')) *c -= (char)('a' - 'A'); 363. else if(*c == ' ' || *c == '-') *c = '_'; 364. } 365. 366. switch (let) { 367. case WAND_SYM: 368. Printf("#define WAN_"); prefix = 1; break; 369. case RING_SYM: 370. Printf("#define RIN_"); prefix = 1; break; 371. case POTION_SYM: 372. Printf("#define POT_"); prefix = 1; break; 373. #ifdef SPELLS 374. case SPBOOK_SYM: 375. Printf("#define SPE_"); prefix = 1; nspell++; break; 376. #endif 377. case SCROLL_SYM: 378. Printf("#define SCR_"); prefix = 1; break; 379. case GEM_SYM: 380. /* avoid trouble with stupid C preprocessors */ 381. if(objects[i].oc_material == GLASS) { 382. Printf("/* #define %s %d */ ", objects[i].oc_name, i); 383. continue; 384. } 385. default: 386. Printf("#define "); 387. } 388. Printf("%s %d ", limit(objects[i].oc_name, prefix), i); 389. prefix = 0; 390. 391. sum += objects[i].oc_prob; 392. } 393. Printf("#define LAST_GEM (JADE+1) "); 394. #ifdef SPELLS 395. Printf("#define MAXSPELL %d ", nspell+1); 396. #endif 397. Printf("#define NROFOBJECTS %d ", i-1); 398. Printf(" #endif /* ONAMES_H /**/ "); 399. (void) fclose(stdout); 400. if (sumerr) exit(1); 401. return; 402. } 403. 404. #if defined(SYSV) || defined(GENIX) || defined(UNIXDEBUG) 405. void 406. rename(oldname, newname) 407. char *oldname, *newname; 408. { 409. if (strcmp(oldname, newname)) { 410. (void) unlink(newname); 411. (void) link(oldname, newname); 412. (void) unlink(oldname); 413. } 414. return; 415. } 416. #endif 417. 418. #ifdef MSDOS 419. # ifndef AMIGA 420. /* Get around bug in freopen when opening for writing */ 421. /* Supplied by Nathan Glasser (nathan@mit-eddie) */ 422. #undef freopen 423. FILE * 424. _freopen(fname, fmode, fp) 425. char *fname, *fmode; 426. FILE *fp; 427. { 428. if (!strncmp(fmode,"w",1)) 429. { 430. FILE *tmpfp; 431. 432. if ((tmpfp = fopen(fname,fmode)) == (FILE *)0) 433. return (FILE *)0; 434. if (dup2(fileno(tmpfp),fileno(fp)) < 0) 435. return (FILE *)0; 436. (void) fclose(tmpfp); 437. return fp; 438. } 439. else 440. return freopen(fname,fmode,fp); 441. } 442. # endif /* AMIGA */ 443. 444. # if defined(__TURBOC__) || defined(AMIGA) 445. int 446. getpid() 447. { 448. return 1; 449. } 450. # endif 451. #endif /* MSDOS */
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software