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

Function do_statusline2

src/botl.c:100–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100char *
101do_statusline2(void)
102{
103 static char newbot2[BUFSZ], /* MAXCO: botl.h */
104 /* dungeon location (and gold), hero health (HP, PW, AC),
105 experience (HD if poly'd, else Exp level and maybe Exp points),
106 time (in moves), varying number of status conditions */
107 dloc[QBUFSZ], hlth[QBUFSZ], expr[QBUFSZ],
108 tmmv[QBUFSZ], cond[QBUFSZ], vers[QBUFSZ];
109 char *nb;
110 size_t dln, dx, hln, xln, tln, cln, vrn;
111 int hp, hpmax, cap;
112 long money;
113
114 if (suppress_map_output())
115 return strcpy(newbot2, "");
116
117 /*
118 * Various min(x,9999)'s are to avoid having excessive values
119 * violate the field width assumptions in botl.h and should not
120 * impact normal play. Particularly 64-bit long for gold which
121 * could require many more digits if someone figures out a way
122 * to get and carry a really large (or negative) amount of it.
123 * Turn counter is also long, but we'll risk that.
124 */
125
126 /* dungeon location plus gold */
127 (void) describe_level(dloc, 1); /* includes at least one trailing space */
128 if ((money = money_cnt(gi.invent)) < 0L)
129 money = 0L; /* ought to issue impossible() and then discard gold */
130 Sprintf(eos(dloc), "%s:%-2ld", /* strongest hero can lift ~300000 gold */
131 (iflags.in_dumplog || iflags.invis_goldsym) ? "$"
132 : encglyph(objnum_to_glyph(GOLD_PIECE)),
133 min(money, 999999L));
134 dln = strlen(dloc);
135 /* '$' encoded as \GXXXXNNNN is 9 chars longer than display will need */
136 dx = strstri(dloc, "\\G") ? 9 : 0;
137
138 /* health and armor class (has trailing space for AC 0..9) */
139 hp = Upolyd ? u.mh : u.uhp;
140 hpmax = Upolyd ? u.mhmax : u.uhpmax;
141 if (hp < 0)
142 hp = 0;
143 Sprintf(hlth, "HP:%d(%d) Pw:%d(%d) AC:%-2d",
144 min(hp, 9999), min(hpmax, 9999),
145 min(u.uen, 9999), min(u.uenmax, 9999), u.uac);
146 hln = strlen(hlth);
147
148 /* experience */
149 if (Upolyd)
150 Sprintf(expr, "HD:%d", mons[u.umonnum].mlevel);
151 else if (flags.showexp)
152 Sprintf(expr, "Xp:%d/%-1ld", u.ulevel, u.uexp);
153 else
154 Sprintf(expr, "Xp:%d", u.ulevel);
155 xln = strlen(expr);
156
157 /* time/move counter */

Callers 2

dump_everythingFunction · 0.85
botFunction · 0.85

Calls 10

suppress_map_outputFunction · 0.85
describe_levelFunction · 0.85
money_cntFunction · 0.85
eosFunction · 0.85
encglyphFunction · 0.85
strstriFunction · 0.85
near_capacityFunction · 0.85
status_versionFunction · 0.85
mungspacesFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected