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

Function formatkiller

src/topten.c:89–162  ·  view source on GitHub ↗

"killed by",&c ["an"] 'svk.killer.name' */

Source from the content-addressed store, hash-verified

87
88/* "killed by",&c ["an"] 'svk.killer.name' */
89void
90formatkiller(
91 char *buf,
92 unsigned siz,
93 int how,
94 boolean incl_helpless)
95{
96 static NEARDATA const char *const killed_by_prefix[] = {
97 /* DIED, CHOKING, POISONING, STARVING, */
98 "killed by ", "choked on ", "poisoned by ", "died of ",
99 /* DROWNING, BURNING, DISSOLVED, CRUSHING, */
100 "drowned in ", "burned by ", "dissolved in ", "crushed to death by ",
101 /* STONING, TURNED_SLIME, GENOCIDED, */
102 "petrified by ", "turned to slime by ", "killed by ",
103 /* PANICKED, TRICKED, QUIT, ESCAPED, ASCENDED */
104 "", "", "", "", ""
105 };
106 unsigned l;
107 char c, *kname = svk.killer.name;
108
109 buf[0] = '\0'; /* lint suppression */
110 switch (svk.killer.format) {
111 default:
112 impossible("bad killer format? (%d)", svk.killer.format);
113 FALLTHROUGH;
114 /*FALLTHRU*/
115 case NO_KILLER_PREFIX:
116 break;
117 case KILLED_BY_AN:
118 kname = an(kname);
119 FALLTHROUGH;
120 /*FALLTHRU*/
121 case KILLED_BY:
122 (void) strncat(buf, killed_by_prefix[how], siz - 1);
123 l = Strlen(buf);
124 buf += l, siz -= l;
125 break;
126 }
127 /* Copy kname into buf[].
128 * Object names and named fruit have already been sanitized, but
129 * monsters can have "called 'arbitrary text'" attached to them,
130 * so make sure that that text can't confuse field splitting when
131 * record, logfile, or xlogfile is re-read at some later point.
132 */
133 while (--siz > 0) {
134 c = *kname++;
135 if (!c)
136 break;
137 else if (c == ',')
138 c = ';';
139 /* 'xlogfile' doesn't really need protection for '=', but
140 fixrecord.awk for corrupted 3.6.0 'record' does (only
141 if using xlogfile rather than logfile to repair record) */
142 else if (c == '=')
143 c = '_';
144 /* tab is not possible due to use of mungspaces() when naming;
145 it would disrupt xlogfile parsing if it were present */
146 else if (c == '\t')

Callers 14

UseRIPMethod · 0.85
mswin_outripFunction · 0.85
calculate_rip_textFunction · 0.85
amii_outripFunction · 0.85
savebonesFunction · 0.85
doneFunction · 0.85
really_doneFunction · 0.85
genl_outripFunction · 0.85
writexlentryFunction · 0.85
toptenFunction · 0.85
print_mapseenFunction · 0.85
gnome_outripFunction · 0.85

Calls 2

anFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected