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

Function ttyinv_remove_data

win/tty/wintty.c:3002–3046  ·  view source on GitHub ↗

discard perminvent window or erase it and set remembered data to spaces */

Source from the content-addressed store, hash-verified

3000
3001/* discard perminvent window or erase it and set remembered data to spaces */
3002static void
3003ttyinv_remove_data(struct WinDesc *cw, boolean destroy)
3004{
3005 if (!cw) {
3006 impossible("Removing ttyinv data for nonexistent perm invent window?");
3007 return;
3008 }
3009
3010 if (cw->cells) {
3011 int r, c;
3012
3013 for (r = 0; r < cw->maxrow; r++) {
3014 if (cw->cells[r]) {
3015 for (c = 0; c < cw->maxcol; c++) {
3016 struct tty_perminvent_cell *invcell = &cw->cells[r][c];
3017
3018 /* glyph is a flag indicating whether content union
3019 contains a glyph_info structure or just a char */
3020 if (invcell->glyph)
3021 free((genericptr_t) invcell->content.gi);
3022 *invcell = emptyttycell; /* sets glyph flag to 0 */
3023 if (!destroy) { /* erasing */
3024 invcell->content.ttychar = ' ';
3025 invcell->text = 1;
3026 invcell->refresh = 1; /* full redraw wanted */
3027 }
3028 }
3029 if (destroy)
3030 free((genericptr_t) cw->cells[r]),
3031 cw->cells[r] = (struct tty_perminvent_cell *) 0;
3032 }
3033 }
3034 if (destroy) {
3035 free((genericptr_t) cw->cells),
3036 cw->cells = (struct tty_perminvent_cell **) 0;
3037 cw->rows = cw->cols = 0;
3038 }
3039 }
3040 if (destroy) {
3041 cw->maxrow = cw->maxcol = 0;
3042 /*WIN_INVEN = WIN_ERR;*/ /* caller's responsibility */
3043 done_tty_perm_invent_init = FALSE;
3044 }
3045 ttyinv_slots_used = 0; /* reset: inuse_only isn't using any slots */
3046}
3047
3048static void
3049ttyinv_add_menu(

Callers 2

tty_clear_nhwindowFunction · 0.85
tty_destroy_nhwindowFunction · 0.85

Calls 1

impossibleFunction · 0.50

Tested by

no test coverage detected