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

Function wish_history_add

src/zap.c:6226–6255  ·  view source on GitHub ↗

add string to wish history list */

Source from the content-addressed store, hash-verified

6224
6225/* add string to wish history list */
6226void
6227wish_history_add(char *buf)
6228{
6229#ifdef DEBUG
6230 int i;
6231
6232 if (!wizard)
6233 return;
6234
6235 for (i = 0; i < MAX_WISH_HISTORY; i++) {
6236 int idx = (wish_history_idx + i) % MAX_WISH_HISTORY;
6237
6238 if (!wish_history[idx])
6239 continue;
6240 if (!strncmpi(wish_history[idx], buf, strlen(wish_history[idx])))
6241 break;
6242
6243 }
6244
6245 if (i == MAX_WISH_HISTORY) {
6246 int idx = (wish_history_idx + i) % MAX_WISH_HISTORY;
6247
6248 if (wish_history[idx])
6249 free(wish_history[idx]);
6250 wish_history[idx] = (char *) alloc(strlen(buf) + 1);
6251 strcpy(wish_history[idx], buf);
6252 wish_history_idx = (wish_history_idx + 1) % MAX_WISH_HISTORY;
6253 }
6254#endif /* DEBUG */
6255}
6256
6257/* release any old wish text; called from freedynamicdata(save.c) */
6258void

Callers 2

proc_wizkit_lineFunction · 0.85
makewishFunction · 0.85

Calls 2

strncmpiFunction · 0.70
allocFunction · 0.70

Tested by

no test coverage detected