MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadITLFile

Method LoadITLFile

editor/WorldTexturesDialog.cpp:1584–1700  ·  view source on GitHub ↗

Opens a ITL text file and individually adds each on of those bitmaps as a texture

Source from the content-addressed store, hash-verified

1582
1583// Opens a ITL text file and individually adds each on of those bitmaps as a texture
1584int CWorldTexturesDialog::LoadITLFile(char *filename, int type) {
1585 CFILE *infile;
1586 char name[PAGENAME_LEN];
1587 uint32_t i, done = 0, total = 0;
1588 char cur_name[100];
1589 int tex_handle, tex_list[200];
1590 int c = 1, finding_name = 1;
1591
1592 ASSERT(filename != NULL);
1593
1594 infile = (CFILE *)cfopen(filename, "rt");
1595 if (!infile) {
1596 mprintf(0, "Couldn't load ITL file %s!\n", filename);
1597 return -1;
1598 }
1599
1600 mprintf(0, "Loading ITL file %s\n", name);
1601
1602 while (!done) {
1603 char curline[200];
1604 char texname[200];
1605
1606 if (cfeof(infile)) {
1607 done = 1;
1608 continue;
1609 }
1610
1611 // Read a line and parse it
1612 cf_ReadString(curline, 200, infile);
1613
1614 if (curline[0] == ';' || curline[1] == ';' || curline[0] == ' ' || curline[1] == ' ' || curline[0] == '\n')
1615 continue;
1616 else {
1617 int lastslash = -1;
1618 char bmname[200];
1619
1620 strcpy(texname, curline);
1621
1622 for (i = 0; i < strlen(curline); i++)
1623 if (curline[i] == '\\')
1624 lastslash = i;
1625
1626 if (lastslash == -1) {
1627 for (i = 0; i < strlen(filename); i++)
1628 if (filename[i] == '\\')
1629 lastslash = i;
1630
1631 ASSERT(lastslash != -1);
1632
1633 strcpy(bmname, filename);
1634 bmname[lastslash + 1] = 0;
1635 strcat(bmname, curline);
1636 } else
1637 strcpy(bmname, curline);
1638
1639 // Try and load this file
1640
1641 int bm = LoadTextureImage(bmname, 0, type, 0);

Callers

nothing calls this directly

Calls 9

cfopenFunction · 0.85
cfeofFunction · 0.85
cf_ReadStringFunction · 0.85
LoadTextureImageFunction · 0.85
AllocTextureFunction · 0.85
FindTextureNameFunction · 0.85
mng_AllocTrackLockFunction · 0.85
cfcloseFunction · 0.85
bm_SaveFileBitmapFunction · 0.85

Tested by

no test coverage detected