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

Function fopen_text_file

win/share/tiletext.c:383–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383boolean
384fopen_text_file(const char *filename, const char *type)
385{
386 const char *p;
387 int i;
388
389 if (tile_file != (FILE *) 0) {
390 Fprintf(stderr, "can only open one text file at a time\n");
391 return FALSE;
392 }
393
394 tile_file = fopen(filename, type);
395 if (tile_file == (FILE *) 0) {
396 Fprintf(stderr, "cannot open text file %s\n", filename);
397 return FALSE;
398 }
399
400 p = strrchr(filename, '/');
401 if (p)
402 p++;
403 else
404 p = filename;
405
406 tile_set = 0;
407 for (i = 0; i < SIZE(text_sets); i++) {
408 if (!strcmp(p, text_sets[i]))
409 tile_set = i;
410 }
411 tile_set_indx = 0;
412
413 if (!strcmp(type, RDTMODE)) {
414 /* Fill placeholder with noise */
415 if (!placeholder_init) {
416 placeholder_init++;
417 for (i = 0; i < (int) sizeof placeholder; i++)
418 ((char *) placeholder)[i] = i % 256;
419 }
420
421 read_text_colormap(tile_file);
422 if (!colorsinmainmap)
423 init_colormap();
424 else
425 merge_colormap();
426 return TRUE;
427 } else if (!strcmp(type, WRTMODE)) {
428 if (!colorsinmainmap) {
429 Fprintf(stderr, "no colormap set yet\n");
430 return FALSE;
431 }
432 return (write_text_colormap(tile_file));
433 } else {
434 Fprintf(stderr, "bad mode (%s) for fopen_text_file\n", type);
435 return FALSE;
436 }
437}
438
439boolean
440read_text_tile(pixel (*pixels)[TILE_X])

Callers 9

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
process_fileFunction · 0.85
mainFunction · 0.85
TilePickerTabMethod · 0.85
saveMethod · 0.85
mainFunction · 0.85
txt2iff.cFile · 0.85

Calls 5

strrchrFunction · 0.85
read_text_colormapFunction · 0.85
init_colormapFunction · 0.85
merge_colormapFunction · 0.85
write_text_colormapFunction · 0.85

Tested by

no test coverage detected