MCPcopy Create free account
hub / github.com/NetHack/NetHack / Gem_outrip

Function Gem_outrip

outdated/win/gem/wingem.c:1039–1099  ·  view source on GitHub ↗
(w, how, when)

Source from the content-addressed store, hash-verified

1037char **rip_line = 0;
1038
1039void
1040Gem_outrip(w, how, when)
1041winid w;
1042int how;
1043time_t when;
1044{
1045/* Code from X11 windowport */
1046#define STONE_LINE_LEN 15 /* # chars that fit on one line */
1047#define NAME_LINE 0 /* line # for player name */
1048#define GOLD_LINE 1 /* line # for amount of gold */
1049#define DEATH_LINE 2 /* line # for death description */
1050#define YEAR_LINE 6 /* line # for year */
1051 char buf[BUFSZ];
1052 char *dpx;
1053 int line;
1054 long year;
1055
1056 if (!rip_line) {
1057 int i;
1058 rip_line = (char **) malloc((YEAR_LINE + 1) * sizeof(char *));
1059 for (i = 0; i < YEAR_LINE + 1; i++) {
1060 rip_line[i] =
1061 (char *) malloc((STONE_LINE_LEN + 1) * sizeof(char));
1062 }
1063 }
1064 /* Follows same algorithm as genl_outrip() */
1065 /* Put name on stone */
1066 Sprintf(rip_line[NAME_LINE], "%s", svp.plname);
1067 /* Put $ on stone */
1068 Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);
1069 /* Put together death description */
1070 formatkiller(buf, sizeof buf, how, FALSE);
1071
1072 /* Put death type on stone */
1073 for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
1074 register int i, i0;
1075 char tmpchar;
1076 if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
1077 for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
1078 if (dpx[i] == ' ')
1079 i0 = i;
1080 if (!i)
1081 i0 = STONE_LINE_LEN;
1082 }
1083 tmpchar = dpx[i0];
1084 dpx[i0] = 0;
1085 strcpy(rip_line[line], dpx);
1086 if (tmpchar != ' ') {
1087 dpx[i0] = tmpchar;
1088 dpx = &dpx[i0];
1089 } else
1090 dpx = &dpx[i0 + 1];
1091 }
1092 /* Put year on stone */
1093 year = yyyymmdd(when) / 10000L;
1094 Sprintf(rip_line[YEAR_LINE], "%4ld", year);
1095
1096 mar_set_text_to_rip(w);

Callers

nothing calls this directly

Calls 3

formatkillerFunction · 0.85
yyyymmddFunction · 0.85
mar_set_text_to_ripFunction · 0.85

Tested by

no test coverage detected