Subversion Repositories spk

Rev

Rev 31 | Rev 39 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31 Rev 35
Line 1367... Line 1367...
1367
	if ( !m_sDescription.Empty() )
1367
	if ( !m_sDescription.Empty() )
1368
		return m_sDescription;
1368
		return m_sDescription;
1369
	return this->GetShipName(lang);
1369
	return this->GetShipName(lang);
1370
}
1370
}
1371
 
1371
 
1372
bool CXspFile::StartExtractShip(CCatFile *catFile, CCatFile *secondCatFile, CyString id, CProgressInfo *progress)
1372
bool CXspFile::startExtractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *pProgress)
1373
{
1373
{
1374
	id.RemoveChar('\r');
1374
	m_sID = sId.removeChar('\r');
1375
	while ( id.Right(1) == ";" )
1375
	while ( m_sID.right(1) == ";" )
1376
		id.Truncate((int)id.Length() - 1);
-
 
1377
	m_sID = id.ToString();
1376
		m_sID.truncate(-1);
-
 
1377
 
1378
	m_sData = catFile->GetTShipsEntry(id).ToString();
1378
	m_sData = pVfs->getTShipsEntry(m_sID);
1379
 
1379
 
1380
	// get scene files
1380
	// get scene files
1381
	if ( progress ) progress->UpdateStatus(IMPORTSHIP_SCENE);
1381
	if ( pProgress ) pProgress->UpdateStatus(IMPORTSHIP_SCENE);
1382
	if ( !this->ExtractSceneFiles(catFile, secondCatFile) )
1382
	if ( !this->extractSceneFiles(pVfs) )
1383
		return false;
1383
		return false;
1384
 
1384
 
1385
	return true;
1385
	return true;
1386
}
1386
}
1387
 
1387
 
1388
bool CXspFile::StartExtractShip(CyString catFile, CyString secondCatFile, CyString id, CProgressInfo *progress)
-
 
1389
{
-
 
1390
	CCatFile cat;
-
 
1391
	if ( cat.Open(catFile, "", CATREAD_CATDECRYPT, false) != CATERR_NONE ) {
-
 
1392
		if ( !secondCatFile.Empty() ) { 
-
 
1393
			CCatFile secondCat;
-
 
1394
			if ( secondCat.Open(secondCatFile, "", CATREAD_CATDECRYPT, false) != CATERR_NONE ) {
-
 
1395
				return this->StartExtractShip(&cat, &secondCat, id, progress);
-
 
1396
			}
-
 
1397
			return this->StartExtractShip(&cat, NULL, id, progress);
-
 
1398
		}
-
 
1399
	}
-
 
1400
 
-
 
1401
	return false;
-
 
1402
}
-
 
1403
 
-
 
1404
bool CXspFile::ExtractShip(CCatFile *catFile, CyString id, CProgressInfo *progress)
1388
bool CXspFile::extractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *progress)
1405
{
1389
{
1406
	if ( !this->StartExtractShip(catFile, NULL, id, progress) )
1390
	if ( !this->startExtractShip(pVfs, sId, progress) )
1407
		return false;
1391
		return false;
1408
 
1392
 
1409
	// read the scene file and get the files list
1393
	// read the scene file and get the files list
1410
	if ( !this->ProcessSceneFiles(catFile, NULL, progress) )
1394
	if ( !this->processSceneFiles(pVfs, progress) )
1411
		return false;
1395
		return false;
1412
 
1396
 
1413
	// pack all the ship files
1397
	// pack all the ship files
1414
	this->PackAllFiles();
1398
	this->PackAllFiles();
1415
 
1399
 
1416
	return true;
1400
	return true;
1417
}
-
 
1418
 
-
 
1419
bool CXspFile::ExtractShip(CyString catFile, CyString id, CProgressInfo *progress)
-
 
1420
{
-
 
1421
	CCatFile cat;
-
 
1422
	if ( cat.Open(catFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
-
 
1423
		return ExtractShip(&cat, id, progress);
-
 
1424
 
-
 
1425
	return false;
-
 
1426
}
-
 
1427
 
-
 
1428
C_File *CXspFile::ExtractFileToPackage(CCatFile *catFile, CyString file, int type, CyString addAs)
-
 
1429
{
-
 
1430
	if ( catFile->ExtractFile(file, "tmp") )
-
 
1431
	{
-
 
1432
		CFileIO File("tmp");
-
 
1433
 
-
 
1434
		C_File *f = this->AddFile(CFileIO(addAs.Empty() ? file : addAs).GetFilename(), CFileIO(addAs.Empty() ? file : addAs).GetDir(), type);
-
 
1435
		if ( f )
-
 
1436
		{
-
 
1437
			if ( f->ReadFromFile("tmp") )
-
 
1438
			{
-
 
1439
				File.Remove();
-
 
1440
				return f;
-
 
1441
			}
-
 
1442
		}
-
 
1443
 
-
 
1444
		File.Remove();
-
 
1445
	}
-
 
1446
	return NULL;
-
 
1447
}
-
 
1448
 
-
 
1449
bool CXspFile::ExtractSceneFiles(CCatFile *catFile, CCatFile *secondCat)
-
 
1450
{
-
 
1451
	m_pSceneFile = this->ExtractFileToPackage(catFile, CyString("objects\\") + m_sData.token(";", 17) + ".pbd", FILETYPE_SHIPSCENE, CyString("objects\\") + m_sData.token(";", 17) + ".bod");
-
 
1452
	if ( !m_pSceneFile ) m_pSceneFile = this->ExtractFileToPackage(catFile, CyString("objects\\") + m_sData.token(";", 17) + ".bod", FILETYPE_SHIPSCENE);
-
 
1453
	if ( !m_pSceneFile && secondCat ) m_pSceneFile = this->ExtractFileToPackage(secondCat, CyString("objects\\") + m_sData.token(";", 17) + ".pbd", FILETYPE_SHIPSCENE, CyString("objects\\") + m_sData.token(";", 17) + ".bod");
-
 
1454
	if ( !m_pSceneFile && secondCat) m_pSceneFile = this->ExtractFileToPackage(secondCat, CyString("objects\\") + m_sData.token(";", 17) + ".bod", FILETYPE_SHIPSCENE);
-
 
1455
 
-
 
1456
	if ( !m_pSceneFile ) {
-
 
1457
		return false;
-
 
1458
	}
-
 
1459
 
-
 
1460
	m_pCockpitFile = this->ExtractFileToPackage(catFile, CyString("objects\\") + m_sData.token(";", 18) + ".pbd", FILETYPE_COCKPITSCENE, CyString("objects\\") + m_sData.token(";", 18) + ".bod");
-
 
1461
	if ( !m_pCockpitFile ) m_pCockpitFile = this->ExtractFileToPackage(catFile, CyString("objects\\") + m_sData.token(";", 18) + ".bod", FILETYPE_COCKPITSCENE);
-
 
1462
	if ( !m_pCockpitFile && secondCat ) m_pCockpitFile = this->ExtractFileToPackage(secondCat, CyString("objects\\") + m_sData.token(";", 18) + ".pbd", FILETYPE_COCKPITSCENE, CyString("objects\\") + m_sData.token(";", 18) + ".bod");
-
 
1463
	if ( !m_pCockpitFile && secondCat ) m_pCockpitFile = this->ExtractFileToPackage(secondCat, CyString("objects\\") + m_sData.token(";", 18) + ".bod", FILETYPE_COCKPITSCENE);
-
 
1464
	return true;
-
 
1465
}
1401
}
1466
 
1402
 
1467
bool CXspFile::ExtractSceneFiles(CyString catFile, CyString secondCatFile)
1403
bool CXspFile::extractSceneFiles(CVirtualFileSystem *pVfs)
1468
{
1404
{
1469
	CCatFile cat;
-
 
1470
	if ( cat.Open(catFile, ";", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
1405
	m_pSceneFile = pVfs->extractGameFileToPackage(this, "objects\\" + m_sData.token(";", 17) + ".pbd", FILETYPE_SHIPSCENE, "objects\\" + m_sData.token(";", 17) + ".bod";);
1471
		CCatFile secondCat;
-
 
1472
		if ( !secondCatFile.Empty() ) {
1406
	if ( !m_pSceneFile ) return false;
1473
			if ( cat.Open(secondCatFile, ";", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
1407
	m_pCockpitFile = pVfs->extractGameFileToPackage(this, "objects\\" + m_sData.token(";", 18) + ".pbd", FILETYPE_COCKPITSCENE, "objects\\" + m_sData.token(";", 18) + ".bod";);
1474
				return ExtractSceneFiles(&cat, &secondCat);
-
 
1475
			}
-
 
1476
		}
-
 
1477
		return ExtractSceneFiles(&cat, NULL);
-
 
1478
	}
1408
 
1479
	return false;
1409
	return true;
1480
}
1410
}
1481
 
1411
 
1482
CyStringList *CXspFile::ReadSceneModels()
1412
CyStringList *CXspFile::ReadSceneModels()
1483
{
1413
{
1484
	// read the scene file
1414
	// read the scene file
1485
	if ( !m_pSceneFile )
1415
	if ( !m_pSceneFile )
1486
		m_pSceneFile = this->GetFirstFile(FILETYPE_SHIPSCENE);
1416
		m_pSceneFile = this->GetFirstFile(FILETYPE_SHIPSCENE);
Line 1500... Line 1430...
1500
		memcpy(data, m_pSceneFile->GetData(), m_pSceneFile->GetDataSize());
1430
		memcpy(data, m_pSceneFile->GetData(), m_pSceneFile->GetDataSize());
1501
		deleteData = true;
1431
		deleteData = true;
1502
	}
1432
	}
1503
 
1433
 
1504
	if ( data && datasize )
1434
	if ( data && datasize )
1505
	{
1435
	{
1506
		if ( m_pSceneFile->CheckPackedExtension() )
1436
		if ( m_pSceneFile->CheckPackedExtension() )
1507
			data = UnPCKData(data, datasize, &datasize);
1437
			data = UnPCKData(data, datasize, &datasize);
1508
	}
1438
	}
1509
 
1439
 
1510
	if ( !data || !datasize )
1440
	if ( !data || !datasize )
Line 1524... Line 1454...
1524
		if ( !newline && !online )
1454
		if ( !newline && !online )
1525
		{
1455
		{
1526
			if ( c == '\n' )
1456
			if ( c == '\n' )
1527
				newline = true;
1457
				newline = true;
1528
			continue;
1458
			continue;
1529
		}
1459
		}
1530
 
1460
 
1531
		if ( newline )
1461
		if ( newline )
1532
		{
1462
		{
1533
			if ( c == ' ' || c == 9 || c == '\n' || c == '\r' )
1463
			if ( c == ' ' || c == 9 || c == '\n' || c == '\r' )
1534
				continue;
1464
				continue;
Line 1547... Line 1477...
1547
		}
1477
		}
1548
		// this line is out model
1478
		// this line is out model
1549
		else if ( online )
1479
		else if ( online )
1550
		{
1480
		{
1551
			if ( c == 'B' || c == 'b' )
1481
			if ( c == 'B' || c == 'b' )
1552
			{
1482
			{
1553
				while(data[pos] == ' ') pos++;
1483
				while(data[pos] == ' ') pos++;
1554
				unsigned char *line = (data + pos);
1484
				unsigned char *line = (data + pos);
1555
				while(data[pos] != ';') pos++;
1485
				while(data[pos] != ';') pos++;
1556
				data[pos] = '\0';
1486
				data[pos] = '\0';
1557
 
1487
 
1558
				lModels->PushBack((char *)line);
1488
				lModels->PushBack((char *)line);
1559
				online = false;
1489
				online = false;
1560
			}
1490
			}
1561
		}
1491
		}
1562
	}
1492
	}
1563
 
1493
 
1564
	if ( deleteData )
1494
	if ( deleteData )
1565
		delete data;
1495
		delete data;
1566
 
1496
 
1567
	return lModels;
1497
	return lModels;
1568
}
1498
}
1569
 
1499
 
1570
void CXspFile::ExtractDummies(CCatFile *catFile, CCatFile *secondCat, CyStringList *sceneModels, bool add)
1500
void CXspFile::extractDummies(CVirtualFileSystem *pVfs, CyStringList *sceneModels, bool add)
1571
{
1501
{
1572
	if ( !sceneModels ) return;
1502
	if ( !sceneModels ) return;
1573
 
1503
 
1574
	bool extracted = false;
1504
	bool extracted = false;
1575
	if ( catFile->ExtractFile("types/dummies.pck", "tmp") ) extracted = true;
1505
	if ( pVfs->ExtractGameFile("types/dummies.pck", "tmp") ) {
1576
	else if ( secondCat && secondCat->ExtractFile("types/dummies.pck", "tmp") ) extracted = true;
-
 
1577
 
-
 
1578
	if ( extracted ) {
-
 
1579
		CFileIO File("tmp");
1506
		CFileIO File("tmp");
1580
		if ( File.Exists() )
1507
		if ( File.Exists() )
1581
		{
1508
		{
1582
			CyString section;
1509
			CyString section;
1583
			int secCount = 0;
1510
			int secCount = 0;
Line 1629... Line 1556...
1629
			File.Remove();
1556
			File.Remove();
1630
		}
1557
		}
1631
	}
1558
	}
1632
}
1559
}
1633
 
1560
 
1634
void CXspFile::ExtractComponants(CCatFile *catFile, CyStringList *sceneModels)
1561
void CXspFile::extractComponants(CVirtualFileSystem *pVfs, CyStringList *sceneModels)
1635
{
1562
{
1636
	if ( !sceneModels ) return;
1563
	if ( !sceneModels ) return;
1637
	if ( catFile->ExtractFile("types/components.pck", "tmp") )
1564
	if ( pVfs->ExtractGameFile("types/components.pck", "tmp") )
1638
	{
1565
	{
1639
		CFileIO File("tmp");
1566
		CFileIO File("tmp");
1640
		if ( File.Exists() )
1567
		if ( File.Exists() )
1641
		{
1568
		{
1642
			CyString file;
1569
			CyString file;
Line 1733... Line 1660...
1733
	delete [] data;
1660
	delete [] data;
1734
 
1661
 
1735
	return true;
1662
	return true;
1736
}
1663
}
1737
 
1664
 
1738
void CXspFile::ExtractTextures(CCatFile *catFile, CCatFile *secondCatFile)
1665
void CXspFile::extractTextures(CVirtualFileSystem *pVfs)
1739
{
1666
{
1740
	CyStringList lTextures;
1667
	CyStringList lTextures;
1741
 
1668
 
1742
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
1669
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
1743
	{
1670
	{
Line 1745... Line 1672...
1745
		if ( f->GetFileType() != FILETYPE_SHIPMODEL )
1672
		if ( f->GetFileType() != FILETYPE_SHIPMODEL )
1746
			continue;
1673
			continue;
1747
 
1674
 
1748
		// cant do these yet
1675
		// cant do these yet
1749
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("bob") )
1676
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("bob") )
1750
		{
1677
		{
1751
			if ( !f->BobDecompile() )
1678
			if ( !f->BobDecompile() )
1752
				continue;
1679
				continue;
1753
		}
1680
		}
1754
 
1681
 
1755
		if ( !f->GetData() )
1682
		if ( !f->GetData() )
1756
		{
1683
		{
1757
			if ( !f->ReadFromFile() )
1684
			if ( !f->ReadFromFile() )
1758
				continue;
1685
				continue;
1759
		}
1686
		}
1760
 
1687
 
1761
		unsigned char *data = NULL;
1688
		unsigned char *data = NULL;
1762
		size_t size;
1689
		size_t size;
1763
 
1690
 
1764
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("pbd") )
1691
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("pbd") )
1765
			data = f->UnPCKFile(&size);
1692
			data = f->UnPCKFile(&size);
1766
		else
1693
		else
1767
		{
1694
		{
1768
			data = f->GetData();
1695
			data = f->GetData();
1769
			size = f->GetDataSize();
1696
			size = f->GetDataSize();
1770
		}
1697
		}
1771
 
1698
 
1772
		this->GetTextureList(&lTextures, data, size);
1699
		this->GetTextureList(&lTextures, data, size);
1773
	}
1700
	}
1774
 
1701
 
1775
	for ( SStringList *node = lTextures.Head(); node; node = node->next )
1702
	for ( SStringList *node = lTextures.Head(); node; node = node->next )
1776
	{
1703
	{
1777
		if ( CFileIO(node->str).CheckFileExtension("dds") ) {
1704
		if ( CFileIO(node->str).CheckFileExtension("dds") )
1778
			if ( !this-&gt;ExtractFileToPackage(catFile, CyString(";dds\\&quot;) + node->str, FILETYPE_SHIPOTHER) ) {
1705
			pVfs->extractGameFileToPackage(this, &quot;dds\\&quot; + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
1779
				if ( secondCatFile ) this->ExtractFileToPackage(secondCatFile, CyString("dds\\") + node->str, FILETYPE_SHIPOTHER);
-
 
1780
			}
-
 
1781
		}
-
 
1782
		else {
1706
		else 
1783
			if ( !this-&gt;ExtractFileToPackage(catFile, CyString(";textures\\&quot;) + node->str, FILETYPE_SHIPOTHER) ) {
1707
			pVfs->extractGameFileToPackage(this, &quot;textures\\&quot; + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
1784
				if ( secondCatFile ) this->ExtractFileToPackage(secondCatFile, CyString("textures\\") + node->str, FILETYPE_SHIPOTHER);
-
 
1785
			}
-
 
1786
		}
-
 
1787
	}
1708
	}
1788
}
1709
}
1789
 
1710
 
1790
bool CXspFile::AddTextFromFile(CyString file, int textId)
1711
bool CXspFile::AddTextFromFile(CyString file, int textId)
1791
{
1712
{
Line 1910... Line 1831...
1910
		return true;
1831
		return true;
1911
	}
1832
	}
1912
	return false;
1833
	return false;
1913
}
1834
}
1914
 
1835
 
1915
bool CXspFile::ExtractCockpits(CCatFile *catFile, CCatFile *secondCatFile)
1836
bool CXspFile::extractCockpits(CVirtualFileSystem *pVfs)
1916
{
1837
{
1917
	bool extracted = catFile-&gt;ExtractFile(&quot;types/TCockpits.pck", ";tmp");
1838
	if ( pVfs-&gt;ExtractGameFile(&quot;types/TCockpits.pck", ";tmp") ) {
1918
	if ( !extracted && secondCatFile ) extracted = secondCatFile->ExtractFile("types/TCockpits.pck", "tmp");
-
 
1919
 
-
 
1920
	if ( extracted ) {
-
 
1921
		bool ret = this->ImportCockpits("tmp");
1839
		bool ret = this->ImportCockpits("tmp");
1922
		CFileIO("tmp").Remove();
1840
		CFileIO("tmp").Remove();
1923
 
1841
 
1924
		return ret;
1842
		return ret;
1925
	}
1843
	}
1926
 
1844
 
1927
	return false;
1845
	return false;
1928
}
1846
}
1929
 
1847
 
1930
bool CXspFile::ExtractBodies(CCatFile *catFile, CCatFile *secondCatFile, CyStringList *sceneModels)
1848
bool CXspFile::extractBodies(CVirtualFileSystem *pVfs, CyStringList *sceneModels)
1931
{
1849
{
1932
	if ( !sceneModels ) return false;
1850
	if ( !sceneModels ) return false;
1933
 
1851
 
1934
	bool extracted = catFile-&gt;ExtractFile(&quot;types/Bodies.pck", ";tmp");
1852
	if ( pVfs-&gt;ExtractGameFile(&quot;types/Bodies.pck", ";tmp") ) {
1935
	if ( !extracted && secondCatFile ) extracted = secondCatFile->ExtractFile("types/Bodies.pck", "tmp");
-
 
1936
 
-
 
1937
	if ( extracted ) {
-
 
1938
		bool ret = this->ImportBodies(sceneModels, "tmp");
1853
		bool ret = this->ImportBodies(sceneModels, "tmp");
1939
		CFileIO("tmp").Remove();
1854
		CFileIO("tmp").Remove();
1940
 
1855
 
1941
		return ret;
1856
		return ret;
1942
	}
1857
	}
1943
 
1858
 
1944
	return false;
1859
	return false;
1945
}
1860
}
Line 1952... Line 1867...
1952
	if ( textId <= 0 )
1867
	if ( textId <= 0 )
1953
		return false;
1868
		return false;
1954
 
1869
 
1955
	CyString line;
1870
	CyString line;
1956
	if ( !id )
1871
	if ( !id )
1957
		return false;
1872
		return false;
1958
 
1873
 
1959
	bool added = false;
1874
	bool added = false;
1960
 
1875
 
1961
	CyString shipName;
1876
	CyString shipName;
1962
	CyString shipDesc;
1877
	CyString shipDesc;
1963
 
1878
 
1964
	int lang = 0;
1879
	int lang = 0;
1965
	bool inpage = false;
1880
	bool inpage = false;
Line 2075... Line 1990...
2075
			CFileIO("tmp").Remove();
1990
			CFileIO("tmp").Remove();
2076
		}
1991
		}
2077
	}
1992
	}
2078
}
1993
}
2079
 
1994
 
2080
bool CXspFile::ProcessSceneFileSection(int section, CCatFile *catFile, CCatFile *secondCatFile, CyStringList *lModels, CProgressInfo *progress)
1995
bool CXspFile::processSceneFileSection(int section, CVirtualFileSystem *pVfs, CyStringList *lModels, CProgressInfo *progress)
2081
{
1996
{
2082
	if ( progress ) progress->UpdateStatus(section);
1997
	if ( progress ) progress->UpdateStatus(section);
2083
 
1998
 
2084
	switch ( section )
1999
	switch ( section )
2085
	{
2000
	{
2086
		case IMPORTSHIP_COMPONANT:
2001
		case IMPORTSHIP_COMPONANT:
2087
			if ( !lModels ) return false;
2002
			if ( !lModels ) return false;
2088
			this->ExtractComponants(catFile, lModels);
2003
			this->extractComponants(pVfs, lModels);
2089
			break;
2004
			break;
2090
 
2005
 
2091
		case IMPORTSHIP_MODELS:
2006
		case IMPORTSHIP_MODELS:
2092
			{
2007
			{
2093
				if ( !lModels ) return false;
2008
				if ( !lModels ) return false;
2094
				for ( SStringList *node = lModels->Head(); node; node = node->next )
2009
				for ( SStringList *node = lModels->Head(); node; node = node->next )
2095
				{
2010
				{
2096
					if ( node->str.IsNumber() ) // count be componants or dummy
2011
					if ( node->str.IsNumber() ) // count be componants or dummy
2097
						continue;
2012
						continue;
2098
					if ( this->ExtractFileToPackage(catFile, CyString("objects\\") + node->str + ".pbb", FILETYPE_SHIPMODEL, CyString("objects\\") + node->str + ".bob") )
2013
					if ( pVfs->extractGameFileToPackage(this, "objects\\" + Utils::String(node->str.ToString()) + ".pbb", FILETYPE_SHIPMODEL, "objects\\" + Utils::String(node->str.ToString()) + ".bob") )
2099
						continue;
2014
						continue;
2100
					if ( this->ExtractFileToPackage(catFile, CyString("objects\\") + node->str + ".pbd", FILETYPE_SHIPMODEL, CyString("objects\\") + node->str + ".bod") )
2015
					if ( pVfs->extractGameFileToPackage(this, "objects\\" + Utils::String(node->str.ToString()) + ".pbd", FILETYPE_SHIPMODEL, "objects\\" + Utils::String(node->str.ToString()) + ".bod") )
2101
						continue;
2016
						continue;
2102
					if ( this->ExtractFileToPackage(catFile, CyString("objects\\") + node->str + ".bob", FILETYPE_SHIPMODEL) )
-
 
2103
						continue;
-
 
2104
					if ( this->ExtractFileToPackage(catFile, CyString("objects\\") + node->str + ".bod", FILETYPE_SHIPMODEL) )
-
 
2105
						continue;
-
 
2106
					if ( secondCatFile ) {
-
 
2107
						if ( this->ExtractFileToPackage(secondCatFile, CyString("objects\\") + node->str + ".pbb", FILETYPE_SHIPMODEL, CyString("objects\\") + node->str + ".bob") )
-
 
2108
							continue;
-
 
2109
						if ( this->ExtractFileToPackage(secondCatFile, CyString("objects\\") + node->str + ".pbd", FILETYPE_SHIPMODEL, CyString("objects\\") + node->str + ".bod") )
-
 
2110
							continue;
-
 
2111
						if ( this->ExtractFileToPackage(secondCatFile, CyString("objects\\") + node->str + ".bob", FILETYPE_SHIPMODEL) )
-
 
2112
							continue;
-
 
2113
						if ( this->ExtractFileToPackage(secondCatFile, CyString("objects\\") + node->str + ".bod", FILETYPE_SHIPMODEL) )
-
 
2114
							continue;
-
 
2115
					}
-
 
2116
				}
2017
				}
2117
			}
2018
			}
2118
			break;
2019
			break;
2119
 
2020
 
2120
		case IMPORTSHIP_DUMMIES:
2021
		case IMPORTSHIP_DUMMIES:
2121
			if ( !lModels ) return false;
2022
			if ( !lModels ) return false;
2122
			this->ExtractDummies(catFile, secondCatFile, lModels, true);
2023
			this->extractDummies(pVfs, lModels, true);
2123
			break;
2024
			break;
2124
 
2025
 
2125
		// extract the textures
2026
		// extract the textures
2126
		case IMPORTSHIP_TEXTURES:
2027
		case IMPORTSHIP_TEXTURES:
2127
			this->ExtractTextures(catFile, secondCatFile);
2028
			this->extractTextures(pVfs);
2128
			break;
2029
			break;
2129
 
2030
 
2130
		case IMPORTSHIP_TEXTS:
2031
		case IMPORTSHIP_TEXTS:
2131
			// extract the text file entries
2032
			// extract the text file entries
2132
			this->ExtractTexts(catFile, secondCatFile, m_sData.token(";", 7));
2033
			pVfs->extractTexts(this, m_sData.token(";", 7));
2133
			break;
2034
			break;
2134
 
2035
 
2135
		case IMPORTSHIP_BODIES:
2036
		case IMPORTSHIP_BODIES:
2136
			// extract the bodies entries
2037
			// extract the bodies entries
2137
			if ( !lModels ) return false;
2038
			if ( !lModels ) return false;
2138
			this->ExtractBodies(catFile, secondCatFile, lModels);
2039
			this->extractBodies(pVfs, lModels);
2139
			break;
2040
			break;
2140
 
2041
 
2141
		case IMPORTSHIP_COCKPITS:
2042
		case IMPORTSHIP_COCKPITS:
2142
			// extract the cockpit entries
2043
			// extract the cockpit entries
2143
			this->ExtractCockpits(catFile, secondCatFile);
2044
			this->extractCockpits(pVfs);
2144
			break;
2045
			break;
2145
	}
2046
	}
2146
 
2047
 
2147
	return true;
2048
	return true;
2148
}
2049
}
2149
 
2050
 
2150
bool CXspFile::ProcessSceneFiles(CCatFile *catFile, CCatFile *secondCatFile, CProgressInfo *progress)
2051
bool CXspFile::processSceneFiles(CVirtualFileSystem *pVfs, CProgressInfo *progress)
2151
{
2052
{
2152
	// now lets parse our files
2053
	// now lets parse our files
2153
	if ( progress ) progress->UpdateStatus(IMPORTSHIP_EXTRACTSCENE);
2054
	if ( progress ) progress->UpdateStatus(IMPORTSHIP_EXTRACTSCENE);
2154
	CyStringList *lModels = this->ReadSceneModels();
2055
	CyStringList *lModels = this->ReadSceneModels();
2155
	if ( !lModels )
2056
	if ( !lModels )
2156
		return false;
2057
		return false;
2157
 
2058
 
2158
	// extract componants, and add extra items to list
2059
	// extract componants, and add extra items to list
2159
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_COMPONANT, catFile, secondCatFile, lModels, progress) )
2060
	if ( !this->processSceneFileSection(IMPORTSHIP_COMPONANT, pVfs, lModels, progress) )
2160
		return false;
2061
		return false;
2161
 
2062
 
2162
	//lets first find any model files
2063
	//lets first find any model files
2163
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_MODELS, catFile, secondCatFile, lModels, progress) )
2064
	if ( !this->processSceneFileSection(IMPORTSHIP_MODELS, pVfs, lModels, progress) )
2164
		return false;
2065
		return false;
2165
 
2066
 
2166
	// extract the dummies
2067
	// extract the dummies
2167
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_DUMMIES, catFile, secondCatFile, lModels, progress) )
2068
	if ( !this->processSceneFileSection(IMPORTSHIP_DUMMIES, pVfs, lModels, progress) )
2168
		return false;
2069
		return false;
2169
 
2070
 
2170
	// extract the textures
2071
	// extract the textures
2171
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_TEXTURES, catFile, secondCatFile, lModels, progress) )
2072
	if ( !this->processSceneFileSection(IMPORTSHIP_TEXTURES, pVfs, lModels, progress) )
2172
		return false;
2073
		return false;
2173
 
2074
 
2174
	// extract the text file entries
2075
	// extract the text file entries
2175
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_TEXTS, catFile, secondCatFile, lModels, progress) )
2076
	if ( !this->processSceneFileSection(IMPORTSHIP_TEXTS, pVfs, lModels, progress) )
2176
		return false;
2077
		return false;
2177
 
2078
 
2178
	// extract the bodies entries
2079
	// extract the bodies entries
2179
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_BODIES, catFile, secondCatFile, lModels, progress) )
2080
	if ( !this->processSceneFileSection(IMPORTSHIP_BODIES, pVfs, lModels, progress) )
2180
		return false;
2081
		return false;
2181
 
2082
 
2182
	// extract the cockpit entries
2083
	// extract the cockpit entries
2183
	if ( !this->ProcessSceneFileSection(IMPORTSHIP_COCKPITS, catFile, secondCatFile, lModels, progress) )
2084
	if ( !this->processSceneFileSection(IMPORTSHIP_COCKPITS, pVfs, lModels, progress) )
2184
		return false;
2085
		return false;
2185
 
2086
 
2186
	delete lModels;
2087
	delete lModels;
2187
 
2088
 
2188
	return true;
2089
	return true;
2189
}
2090
}
2190
 
2091
 
2191
bool CXspFile::ProcessSceneFiles(CyString catFile, CyString secondCatFile, CProgressInfo *progress)
-
 
2192
{
-
 
2193
	CCatFile cat;
-
 
2194
	if ( cat.Open(catFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
-
 
2195
		CCatFile secondCat;
-
 
2196
		if ( secondCat.Open(catFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
-
 
2197
			return ProcessSceneFiles(&cat, &secondCat, progress);
-
 
2198
		}
-
 
2199
		return ProcessSceneFiles(&cat, NULL, progress);
-
 
2200
	}
-
 
2201
 
2092
 
2202
	return false;
-
 
2203
}
-
 
2204
 
-
 
2205
void CXspFile::PackAllFiles()
2093
void CXspFile::PackAllFiles()
2206
{
2094
{
2207
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
2095
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
2208
	{
2096
	{
2209
		C_File *f = node->Data();
2097
		C_File *f = node->Data();
2210
		if ( f->GetFileType() == FILETYPE_SHIPSCENE || f->GetFileType() == FILETYPE_COCKPITSCENE || f->GetFileType() == FILETYPE_SHIPMODEL || f->GetFileType() == FILETYPE_SHIPOTHER )
2098
		if ( f->GetFileType() == FILETYPE_SHIPSCENE || f->GetFileType() == FILETYPE_COCKPITSCENE || f->GetFileType() == FILETYPE_SHIPMODEL || f->GetFileType() == FILETYPE_SHIPOTHER )
2211
		{
2099
		{
2212
			if ( f->CheckFileExt("bod") )
2100
			if ( f->CheckFileExt("bod") )
2213
			{
2101
			{
2214
				if ( f->PCKFile() )
2102
				if ( f->PCKFile() )
2215
					f->ChangeFileExt("pbd");
2103
					f->ChangeFileExt("pbd");
2216
			}
2104
			}
2217
			else if ( f->CheckFileExt("bob") )
2105
			else if ( f->CheckFileExt("bob") )
2218
			{
2106
			{
2219
				if ( f->PCKFile() )
2107
				if ( f->PCKFile() )
2220
					f->ChangeFileExt("pbb");
2108
					f->ChangeFileExt("pbb");
2221
			}
2109
			}
2222
		}
2110
		}
2223
	}
2111
	}
Line 2236... Line 2124...
2236
		for ( int i = 0; i < 6; i++ )
2124
		for ( int i = 0; i < 6; i++ )
2237
		{
2125
		{
2238
			CyString tId = m_sData.token(";", 32 + (i * 2));
2126
			CyString tId = m_sData.token(";", 32 + (i * 2));
2239
			if ( tId.IsNumber() && tId.ToInt() == c->iIndex )
2127
			if ( tId.IsNumber() && tId.ToInt() == c->iIndex )
2240
				m_sData = m_sData.replaceToken(";", 32 + (i * 2), (id + "(" + CyString::Number(c->iIndex) + ")").c_str());
2128
				m_sData = m_sData.replaceToken(";", 32 + (i * 2), (id + "(" + CyString::Number(c->iIndex) + ")").c_str());
2241
		}
2129
		}
2242
	}
2130
	}
2243
}
2131
}
2244
 
2132
 
2245
CyString CXspFile::FormatShipData(CyStringList *cockpits, int *text, int game)
2133
CyString CXspFile::FormatShipData(CyStringList *cockpits, int *text, int game)
2246
{
2134
{
2247
	CyString data = (game == GAME_X3) ? this->GetX3ShipData() : this->GetTCShipData();
2135
	CyString data = (game == GAME_X3) ? this->GetX3ShipData() : this->GetTCShipData();
Line 2284... Line 2172...
2284
	if ( data.Right(1) != ";" )
2172
	if ( data.Right(1) != ";" )
2285
		data += ";";
2173
		data += ";";
2286
 
2174
 
2287
	return data;
2175
	return data;
2288
}
2176
}
-
 
2177