| 1027 | } |
| 1028 | |
| 1029 | staticfn void |
| 1030 | save_msghistory(NHFILE *nhfp) |
| 1031 | { |
| 1032 | char *msg; |
| 1033 | int msgcount = 0; |
| 1034 | int minusone = -1, msglen; |
| 1035 | boolean init = TRUE; |
| 1036 | |
| 1037 | if (update_file(nhfp)) { |
| 1038 | /* ask window port for each message in sequence */ |
| 1039 | while ((msg = getmsghistory(init)) != 0) { |
| 1040 | init = FALSE; |
| 1041 | msglen = (int) Strlen(msg); |
| 1042 | if (msglen < 1) |
| 1043 | continue; |
| 1044 | /* sanity: truncate if necessary (shouldn't happen); |
| 1045 | no need to modify msg[] since terminator isn't written */ |
| 1046 | if (msglen > BUFSZ - 1) |
| 1047 | msglen = BUFSZ - 1; |
| 1048 | Sfo_int(nhfp, &msglen, "msghistory-length"); |
| 1049 | Sfo_char(nhfp, msg, "msghistory-msg", msglen); |
| 1050 | ++msgcount; |
| 1051 | } |
| 1052 | Sfo_int(nhfp, &minusone, "msghistory-length"); |
| 1053 | } |
| 1054 | debugpline1("Stored %d messages into savefile.", msgcount); |
| 1055 | /* note: we don't attempt to handle release_data() here */ |
| 1056 | } |
| 1057 | |
| 1058 | /* also called by prscore(); this probably belongs in dungeon.c... */ |
| 1059 | void |
no test coverage detected