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

Function curses_getmsghistory

win/curses/cursmesg.c:1008–1032  ·  view source on GitHub ↗

save/restore code retrieves one ^P message at a time during save and puts it into save file; if any new messages are added to the list while that is taking place, the results are likely to be scrambled */

Source from the content-addressed store, hash-verified

1006 puts it into save file; if any new messages are added to the list while
1007 that is taking place, the results are likely to be scrambled */
1008char *
1009curses_getmsghistory(boolean init)
1010{
1011 static int nxtidx;
1012 nhprev_mesg *mesg;
1013
1014 if (init)
1015 nxtidx = 0;
1016 else
1017 ++nxtidx;
1018
1019 if (nxtidx < num_messages) {
1020 /* we could encode mesg->turn with the text of the message,
1021 but then that text might need to be truncated, and more
1022 significantly, restoring the save file with another
1023 interface wouldn't know how find and decode or remove it;
1024 likewise, restoring another interface's save file with
1025 curses wouldn't find the expected turn info;
1026 so, we live without that */
1027 mesg = get_msg_line(FALSE, nxtidx);
1028 } else
1029 mesg = (nhprev_mesg *) 0;
1030
1031 return mesg ? mesg->str : (char *) 0;
1032}
1033
1034/*
1035 * This is called by the core savefile restore routines.

Callers

nothing calls this directly

Calls 1

get_msg_lineFunction · 0.85

Tested by

no test coverage detected