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

Function init_tiles

win/X11/winmap.c:385–700  ·  view source on GitHub ↗

* Open and read the tile file. Return TRUE if there were no problems. * Return FALSE otherwise. */

Source from the content-addressed store, hash-verified

383 * Return FALSE otherwise.
384 */
385static boolean
386init_tiles(struct xwindow *wp)
387{
388#ifdef USE_XPM
389 XpmAttributes attributes;
390 int errorcode;
391#else
392 FILE *fp = (FILE *) 0;
393 x11_header header;
394 unsigned char *cp, *colormap = (unsigned char *) 0;
395 unsigned char *tb, *tile_bytes = (unsigned char *) 0;
396 int size;
397 XColor *colors = (XColor *) 0;
398 unsigned i;
399 int x, y;
400 int bitmap_pad;
401 int ddepth;
402#endif
403 char buf[BUFSZ];
404 Display *dpy = XtDisplay(toplevel);
405 Screen *screen = DefaultScreenOfDisplay(dpy);
406 struct map_info_t *map_info = (struct map_info_t *) 0;
407 struct tile_map_info_t *tile_info = (struct tile_map_info_t *) 0;
408 unsigned int image_height = 0, image_width = 0;
409 boolean result = TRUE;
410 XGCValues values;
411 XtGCMask mask;
412
413 /* already have tile information */
414 if (tile_pixmap != None)
415 goto tiledone;
416
417 map_info = wp->map_information;
418 tile_info = &map_info->tile_map;
419 (void) memset((genericptr_t) tile_info, 0,
420 sizeof (struct tile_map_info_t));
421
422 /* no tile file name, no tile information */
423 if (!appResources.tile_file[0]) {
424 result = FALSE;
425 goto tiledone;
426 }
427
428#ifdef USE_XPM
429 attributes.valuemask = XpmCloseness;
430 attributes.closeness = 25000;
431
432 errorcode = XpmReadFileToImage(dpy, appResources.tile_file, &tile_image,
433 0, &attributes);
434
435 if (errorcode == XpmColorFailed) {
436 Sprintf(buf, "Insufficient colors available to load %s.",
437 appResources.tile_file);
438 X11_raw_print(buf);
439 X11_raw_print("Try closing other colorful applications and restart.");
440 X11_raw_print("Attempting to load with inferior colors.");
441 attributes.closeness = 50000;
442 errorcode = XpmReadFileToImage(dpy, appResources.tile_file,

Callers 1

create_map_windowFunction · 0.85

Calls 8

X11_raw_printFunction · 0.85
freadFunction · 0.85
fprintfFunction · 0.85
nhApproxColorFunction · 0.85
fcloseFunction · 0.85
fopen_datafileFunction · 0.50
allocFunction · 0.50
impossibleFunction · 0.50

Tested by

no test coverage detected