Subversion Repositories spk

Rev

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

Rev 50 Rev 52
Line 667... Line 667...
667
	}
667
	}
668
 
668
 
669
	return "Unknown";
669
	return "Unknown";
670
}
670
}
671
 
671
 
672
bool CXspFile::WriteHeader(FILE *id, int valueheader, int valueComprLen)
672
bool CXspFile::WriteHeader(CFileIO &file, int valueheader, int valueComprLen)
673
{
673
{
674
	fprintf ( id, "XSPCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen );
674
	return file.write("XSPCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen);
675
	if ( ferror(id) )
-
 
676
		return false;
-
 
677
	return true;
-
 
678
}
675
}
679
 
676
 
680
bool CXspFile::CheckHeader(const Utils::String header) const
677
bool CXspFile::CheckHeader(const Utils::String header) const
681
{
678
{
682
	if ( header.Compare("XSPCycrow") )
679
	if ( header.Compare("XSPCycrow") )
Line 1511... Line 1508...
1511
	if ( cuts.empty() ) return;
1508
	if ( cuts.empty() ) return;
1512
 
1509
 
1513
	if ( !pVfs->ExtractGameFile("types/CutData.pck", "tmp") ) return;
1510
	if ( !pVfs->ExtractGameFile("types/CutData.pck", "tmp") ) return;
1514
	
1511
	
1515
	CFileIO File("tmp");
1512
	CFileIO File("tmp");
1516
	if ( !File.Exists() ) return;
1513
	if ( !File.exists() ) return;
1517
	
1514
	
1518
	CyStringList *lines = File.ReadLinesStr();
1515
	CyStringList *lines = File.ReadLinesStr();
1519
	int count = -1;
1516
	int count = -1;
1520
	for ( SStringList *node = lines->Head(); node; node = node->next ) {
1517
	for ( SStringList *node = lines->Head(); node; node = node->next ) {
1521
		Utils::String line = node->str.ToString();
1518
		Utils::String line = node->str.ToString();
Line 1552... Line 1549...
1552
	if ( !sceneModels ) return;
1549
	if ( !sceneModels ) return;
1553
 
1550
 
1554
	bool extracted = false;
1551
	bool extracted = false;
1555
	if ( pVfs->ExtractGameFile("types/dummies.pck", "tmp") ) {
1552
	if ( pVfs->ExtractGameFile("types/dummies.pck", "tmp") ) {
1556
		CFileIO File("tmp");
1553
		CFileIO File("tmp");
1557
		if ( File.Exists() )
1554
		if ( File.exists() )
1558
		{
1555
		{
1559
			Utils::String section;
1556
			Utils::String section;
1560
			int secCount = 0;
1557
			int secCount = 0;
1561
			CyStringList *lines = File.ReadLinesStr();
1558
			CyStringList *lines = File.ReadLinesStr();
1562
			for ( SStringList *node = lines->Head(); node; node = node->next )
1559
			for ( SStringList *node = lines->Head(); node; node = node->next )
Line 1601... Line 1598...
1601
 
1598
 
1602
				}
1599
				}
1603
			}
1600
			}
1604
 
1601
 
1605
			delete lines;
1602
			delete lines;
1606
			File.Remove();
1603
			File.remove();
1607
		}
1604
		}
1608
	}
1605
	}
1609
}
1606
}
1610
 
1607
 
1611
void CXspFile::extractComponants(CVirtualFileSystem *pVfs, CyStringList *sceneModels)
1608
void CXspFile::extractComponants(CVirtualFileSystem *pVfs, CyStringList *sceneModels)
1612
{
1609
{
1613
	if ( !sceneModels ) return;
1610
	if ( !sceneModels ) return;
1614
	if ( pVfs->ExtractGameFile("types/components.pck", "tmp") )
1611
	if ( pVfs->ExtractGameFile("types/components.pck", "tmp") )
1615
	{
1612
	{
1616
		CFileIO File("tmp");
1613
		CFileIO File("tmp");
1617
		if ( File.Exists() )
1614
		if ( File.exists() )
1618
		{
1615
		{
1619
			Utils::String file;
1616
			Utils::String file;
1620
			Utils::String section;
1617
			Utils::String section;
1621
			int secCount = 0;
1618
			int secCount = 0;
1622
			int secCount2 = 0;
1619
			int secCount2 = 0;
Line 1650... Line 1647...
1650
					--secCount;
1647
					--secCount;
1651
				}
1648
				}
1652
			}
1649
			}
1653
 
1650
 
1654
			delete lines;
1651
			delete lines;
1655
			File.Remove();
1652
			File.remove();
1656
		}
1653
		}
1657
	}
1654
	}
1658
}
1655
}
1659
 
1656
 
1660
bool CXspFile::GetTextureList(CyStringList *list, const unsigned char *olddata, size_t size)
1657
bool CXspFile::GetTextureList(CyStringList *list, const unsigned char *olddata, size_t size)
Line 1779... Line 1776...
1779
	if ( fid )
1776
	if ( fid )
1780
	{
1777
	{
1781
		bool ret = this->AddTextFromFile(fid, textId);
1778
		bool ret = this->AddTextFromFile(fid, textId);
1782
		fclose(fid);
1779
		fclose(fid);
1783
 
1780
 
1784
		if ( remove )
-
 
1785
			CFileIO(file).Remove();
1781
		if ( remove ) CFileIO::Remove(file);
1786
		_changed();
1782
		_changed();
1787
		return ret;
1783
		return ret;
1788
	}
1784
	}
1789
 
1785
 
1790
	return false;
1786
	return false;
1791
}
1787
}
1792
 
1788
 
1793
bool CXspFile::ImportBodies(CyStringList *sceneModels, const Utils::String &filename)
1789
bool CXspFile::ImportBodies(CyStringList *sceneModels, const Utils::String &filename)
1794
{
1790
{
1795
	CFileIO File(filename);
1791
	CFileIO File(filename);
1796
	if ( File.Exists() )
1792
	if ( File.exists() )
1797
	{
1793
	{
1798
		Utils::String sSection;
1794
		Utils::String sSection;
1799
		int section = 0;
1795
		int section = 0;
1800
		CyStringList *lines = File.ReadLinesStr();
1796
		CyStringList *lines = File.ReadLinesStr();
1801
		for ( SStringList *node = lines->Head(); node; node = node->next )
1797
		for ( SStringList *node = lines->Head(); node; node = node->next )
Line 1841... Line 1837...
1841
}
1837
}
1842
 
1838
 
1843
bool CXspFile::ImportCockpits(const Utils::String &filename)
1839
bool CXspFile::ImportCockpits(const Utils::String &filename)
1844
{
1840
{
1845
	CFileIO File(filename);
1841
	CFileIO File(filename);
1846
	if ( File.Exists() )
1842
	if ( File.exists() )
1847
	{
1843
	{
1848
		CyStringList *lines = File.ReadLinesStr();
1844
		CyStringList *lines = File.ReadLinesStr();
1849
		int entries = 0;
1845
		int entries = 0;
1850
		for ( SStringList *node = lines->Head(); node; node = node->next )
1846
		for ( SStringList *node = lines->Head(); node; node = node->next )
1851
		{
1847
		{
Line 1888... Line 1884...
1888
 
1884
 
1889
bool CXspFile::extractCockpits(CVirtualFileSystem *pVfs)
1885
bool CXspFile::extractCockpits(CVirtualFileSystem *pVfs)
1890
{
1886
{
1891
	if ( pVfs->ExtractGameFile("types/TCockpits.pck", "tmp") ) {
1887
	if ( pVfs->ExtractGameFile("types/TCockpits.pck", "tmp") ) {
1892
		bool ret = this->ImportCockpits("tmp");
1888
		bool ret = this->ImportCockpits("tmp");
1893
		CFileIO("tmp").Remove();
1889
		CFileIO::Remove("tmp");
1894
 
1890
 
1895
		return ret;
1891
		return ret;
1896
	}
1892
	}
1897
 
1893
 
1898
	return false;
1894
	return false;
Line 1902... Line 1898...
1902
{
1898
{
1903
	if ( !sceneModels ) return false;
1899
	if ( !sceneModels ) return false;
1904
 
1900
 
1905
	if ( pVfs->ExtractGameFile("types/Bodies.pck", "tmp") ) {
1901
	if ( pVfs->ExtractGameFile("types/Bodies.pck", "tmp") ) {
1906
		bool ret = this->ImportBodies(sceneModels, "tmp");
1902
		bool ret = this->ImportBodies(sceneModels, "tmp");
1907
		CFileIO("tmp").Remove();
1903
		CFileIO::Remove("tmp");
1908
 
1904
 
1909
		return ret;
1905
		return ret;
1910
	}
1906
	}
1911
 
1907
 
1912
	return false;
1908
	return false;
Line 2037... Line 2033...
2037
		// extract the text file and read in the data
2033
		// extract the text file and read in the data
2038
		bool extracted = catFile->ExtractFile(f->sFile, "tmp");
2034
		bool extracted = catFile->ExtractFile(f->sFile, "tmp");
2039
		if ( !extracted && secondCatFile ) extracted = secondCatFile->ExtractFile(f->sFile, "tmp");
2035
		if ( !extracted && secondCatFile ) extracted = secondCatFile->ExtractFile(f->sFile, "tmp");
2040
		if ( extracted ) {
2036
		if ( extracted ) {
2041
			this->AddTextFromFile("tmp", textId);
2037
			this->AddTextFromFile("tmp", textId);
2042
			CFileIO("tmp").Remove();
2038
			CFileIO::Remove("tmp");
2043
		}
2039
		}
2044
	}
2040
	}
2045
}
2041
}
2046
 
2042
 
2047
bool CXspFile::processSceneFileSection(int section, CVirtualFileSystem *pVfs, CyStringList *lModels, CProgressInfo *progress)
2043
bool CXspFile::processSceneFileSection(int section, CVirtualFileSystem *pVfs, CyStringList *lModels, CProgressInfo *progress)