Difference between revisions of "Source:NetHack 3.1.0/rip.c"
Jump to navigation
Jump to search
m (Automated source code upload) |
Kernigh bot (talk | contribs) m (NetHack 3.1.0/rip.c moved to Source:NetHack 3.1.0/rip.c: Robot: moved page) |
(No difference)
|
Revision as of 07:25, 4 March 2008
Below is the full text to rip.c from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/rip.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: @(#)rip.c 3.1 91/08/05 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #include "hack.h" 6. 7. static void FDECL(center, (int, char *)); 8. 9. extern const char *killed_by_prefix[]; 10. 11. static const char *rip_txt[] = { 12. " ----------", 13. " / \\", 14. " / REST \\", 15. " / IN \\", 16. " / PEACE \\", 17. " / \\", 18. " | |", /* Name of player */ 19. " | |", /* Amount of $ */ 20. " | |", /* Type of death */ 21. " | |", /* . */ 22. " | |", /* . */ 23. " | |", /* . */ 24. " | 1001 |", /* Real year of death */ 25. " *| * * * | *", 26. " _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 27. 0 28. }; 29. 30. #define STONE_LINE_CENT 28 /* char[] element of center of stone face */ 31. #define STONE_LINE_LEN 16 /* # chars that fit on one line 32. * (note 1 ' ' border) 33. */ 34. #define NAME_LINE 6 /* *char[] line # for player name */ 35. #define GOLD_LINE 7 /* *char[] line # for amount of gold */ 36. #define DEATH_LINE 8 /* *char[] line # for death description */ 37. #define YEAR_LINE 12 /* *char[] line # for year */ 38. 39. char **rip; 40. 41. static void 42. center(line, text) 43. int line; 44. char *text; 45. { 46. register char *ip,*op; 47. ip = text; 48. op = &rip[line][STONE_LINE_CENT - ((strlen(text)+1)>>1)]; 49. while(*ip) *op++ = *ip++; 50. } 51. 52. void 53. outrip(how, tmpwin) 54. int how; 55. winid tmpwin; 56. { 57. register char **dp; 58. register char *dpx; 59. char buf[BUFSZ]; 60. register int x; 61. int line; 62. 63. rip = dp = (char **) alloc(sizeof(rip_txt)); 64. if (!dp) return; 65. for (x = 0; rip_txt[x]; x++) { 66. dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1)); 67. if (!dp[x]) return; 68. Strcpy(dp[x], rip_txt[x]); 69. } 70. dp[x] = (char *)0; 71. 72. /* Put name on stone */ 73. Sprintf(buf, "%s", plname); 74. buf[STONE_LINE_LEN] = 0; 75. center(NAME_LINE, buf); 76. 77. /* Put $ on stone */ 78. Sprintf(buf, "%ld Au", u.ugold); 79. buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */ 80. center(GOLD_LINE, buf); 81. 82. /* Put together death description */ 83. switch (killer_format) { 84. default: impossible("bad killer format?"); 85. case KILLED_BY_AN: 86. Strcpy(buf, killed_by_prefix[how]); 87. Strcat(buf, an(killer)); 88. break; 89. case KILLED_BY: 90. Strcpy(buf, killed_by_prefix[how]); 91. Strcat(buf, killer); 92. break; 93. case NO_KILLER_PREFIX: 94. Strcpy(buf, killer); 95. break; 96. } 97. 98. /* Put death type on stone */ 99. for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) { 100. register int i,i0; 101. char tmpchar; 102. 103. if ( (i0=strlen(dpx)) > STONE_LINE_LEN) { 104. for(i = STONE_LINE_LEN; 105. ((i0 > STONE_LINE_LEN) && i); i--) 106. if(dpx[i] == ' ') i0 = i; 107. if(!i) i0 = STONE_LINE_LEN; 108. } 109. tmpchar = dpx[i0]; 110. dpx[i0] = 0; 111. center(line, dpx); 112. if (tmpchar != ' ') { 113. dpx[i0] = tmpchar; 114. dpx= &dpx[i0]; 115. } else dpx= &dpx[i0+1]; 116. } 117. 118. /* Put year on stone */ 119. Sprintf(buf, "%4d", getyear()); 120. center(YEAR_LINE, buf); 121. 122. putstr(tmpwin, 0, ""); 123. for(; *dp; dp++) 124. putstr(tmpwin, 0, *dp); 125. 126. putstr(tmpwin, 0, ""); 127. putstr(tmpwin, 0, ""); 128. } 129. 130. /*rip.c*/