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

Function add_tileref

win/share/tilemap.c:1486–1525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1484}
1485
1486void
1487add_tileref(
1488 int n,
1489 int glyphref,
1490 enum tilesrc src,
1491 int entrynum,
1492 const char *nam,
1493 const char *prefix)
1494{
1495 struct tiles_used temp = { 0 };
1496 static const char ellipsis[] = "...";
1497 char buf[BUFSZ];
1498
1499 if (!tilelist[n]) {
1500 if ((tilelist[n] = malloc(sizeof temp)) != 0) {
1501 tilelist[n]->tilenum = n;
1502 tilelist[n]->src = src;
1503 tilelist[n]->file_entry = entrynum;
1504 /* leave room for trailing "...nnnn" */
1505 Snprintf(tilelist[n]->tilenam, sizeof tilelist[n]->tilenam - 7,
1506 "%s%s", prefix, nam);
1507 tilelist[n]->references[0] = '\0';
1508 } else {
1509 Fprintf(stderr, "tilemap malloc failure %zu bytes\n",
1510 sizeof temp);
1511 exit(EXIT_FAILURE);
1512 }
1513 }
1514 Snprintf(temp.references,
1515 sizeof temp.references - 7, /* room for "...nnnn" */
1516 "%s%s%d", tilelist[n]->references,
1517 (tilelist[n]->references[0] != '\0') ? ", " : "", glyphref);
1518 Snprintf(buf, sizeof buf, "...%4d", glyphref);
1519 Snprintf(tilelist[n]->references, sizeof tilelist[n]->references, "%s%s",
1520 temp.references,
1521 (strlen(temp.references) >= (sizeof temp.references - 7) - 1)
1522 ? buf
1523 : "");
1524 nhUse(ellipsis);
1525}
1526
1527void
1528dump_tilerefs(FILE * fp)

Callers 1

init_tilemapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected