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

Function mar_create_window

outdated/win/gem/wingem1.c:2447–2507  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

2445}
2446
2447winid
2448mar_create_window(type)
2449int type;
2450{
2451 winid newid;
2452 static char name[] = "Gem";
2453 int i;
2454 struct gw *p_Gw = &Gem_nhwindow[0];
2455
2456 for (newid = 0; p_Gw->gw_type && newid < MAXWIN; newid++, p_Gw++)
2457 ;
2458
2459 switch (type) {
2460 case NHW_MESSAGE:
2461 message_line = (char **) m_alloc(msg_anz * sizeof(char *));
2462 message_age = (int *) m_alloc(msg_anz * sizeof(int));
2463 for (i = 0; i < msg_anz; i++) {
2464 message_age[i] = FALSE;
2465 message_line[i] = (char *) m_alloc((MSGLEN + 1) * sizeof(char));
2466 *message_line[i] = 0;
2467 }
2468 dr_msg = new_dirty_rect(10);
2469 if (!dr_msg)
2470 panic("Memory allocation failure (dr_msg)");
2471 break;
2472 case NHW_STATUS:
2473 status_line = (char **) m_alloc(2 * sizeof(char *));
2474 for (i = 0; i < 2; i++) {
2475 status_line[i] = (char *) m_alloc(status_w * sizeof(char));
2476 memset(status_line[i], 0, status_w);
2477 }
2478 dr_stat = new_dirty_rect(10);
2479 if (!dr_stat)
2480 panic("Memory allocation failure (dr_stat)");
2481 break;
2482 case NHW_MAP:
2483 map_glyphs = (char **) m_alloc((long) ROWNO * sizeof(char *));
2484 for (i = 0; i < ROWNO; i++) {
2485 map_glyphs[i] = (char *) m_alloc((long) COLNO * sizeof(char));
2486 *map_glyphs[i] = map_glyphs[i][COLNO - 1] = 0;
2487 }
2488 dr_map = new_dirty_rect(10);
2489 if (!dr_map)
2490 panic("Memory allocation failure (dr_map)");
2491
2492 mar_clear_map();
2493 break;
2494 case NHW_MENU:
2495 case NHW_TEXT: /* They are no more treated as dialog */
2496 break;
2497 default:
2498 p_Gw->gw_window = open_window(
2499 "Sonst", name, NULL, NULL, NAME | MOVER | CLOSER, 0, 0, 0, NULL,
2500 &p_Gw->gw_place, NULL, NULL, NULL, XM_TOP | XM_BOTTOM | XM_SIZE);
2501 break;
2502 }
2503
2504 p_Gw->gw_type = type;

Callers 1

Gem_create_nhwindowFunction · 0.85

Calls 4

m_allocFunction · 0.85
new_dirty_rectFunction · 0.85
mar_clear_mapFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected