Subversion Repositories spk

Rev

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

Rev 58 Rev 68
Line 1769... Line 1769...
1769
		{
1769
		{
1770
			remove = true;
1770
			remove = true;
1771
			file = "tmp";
1771
			file = "tmp";
1772
		}
1772
		}
1773
	}
1773
	}
-
 
1774
 
-
 
1775
	std::wfstream fileStream(file.c_str());
-
 
1776
	if ( fileStream.is_open() ) {
-
 
1777
		while(!fileStream.eof()) {
-
 
1778
			std::wstring line;
-
 
1779
			std::getline(fileStream, line);
-
 
1780
			int i =0;
-
 
1781
		}
-
 
1782
		fileStream.close();
-
 
1783
	}
-
 
1784
 
1774
 
1785
 
1775
	FILE *fid = fopen(file.c_str(), "r");
1786
	FILE *fid = fopen(file.c_str(), "r");
1776
	if ( fid )
1787
	if ( fid )
1777
	{
1788
	{
1778
		bool ret = this->AddTextFromFile(fid, textId);
1789
		bool ret = this->AddTextFromFile(fid, textId);
1779
		fclose(fid);
1790
		fclose(fid);
1780
 
1791
 
1781
		if ( remove ) CFileIO::Remove(file);
1792
		if ( remove ) CFileIO::Remove(file);
1782
		_changed();
1793
		_changed();
1783
		return ret;
1794
		return ret;
1784
	}
1795
	}
1785
 
1796
 
Line 1791... Line 1802...
1791
	CFileIO File(filename);
1802
	CFileIO File(filename);
1792
	if ( File.exists() )
1803
	if ( File.exists() )
1793
	{
1804
	{
1794
		Utils::String sSection;
1805
		Utils::String sSection;
1795
		int section = 0;
1806
		int section = 0;
1796
		CyStringList *lines = File.ReadLinesStr();
1807
		CyStringList *lines = File.ReadLinesStr();
1797
		for ( SStringList *node = lines->Head(); node; node = node->next )
1808
		for ( SStringList *node = lines->Head(); node; node = node->next )
1798
		{
1809
		{
1799
			node->str.RemoveChar(9);
1810
			node->str.RemoveChar(9);
1800
			node->str.RemoveChar('\r');
1811
			node->str.RemoveChar('\r');
1801
			node->str.RemoveFirstSpace();
1812
			node->str.RemoveFirstSpace();
1802
			if ( node->str.Empty() )
1813
			if ( node->str.Empty() )
1803
				continue;
1814
				continue;
1804
			if ( node->str[0] == '/' )
1815
			if ( node->str[0] == '/' )
1805
				continue;
1816
				continue;
1806
			
1817
			
Line 1822... Line 1833...
1822
						if (strs[i].Empty() )
1833
						if (strs[i].Empty() )
1823
							continue;
1834
							continue;
1824
						if ( sceneModels->FindString(strs[i]) )
1835
						if ( sceneModels->FindString(strs[i]) )
1825
							this->AddBody(sSection, strs[i].ToString());
1836
							this->AddBody(sSection, strs[i].ToString());
1826
						--section;
1837
						--section;
1827
					}
1838
					}
1828
				}
1839
				}
1829
				CLEANSPLIT(strs, max)
1840
				CLEANSPLIT(strs, max)
1830
			}
1841
			}
1831
		}
1842
		}
1832
		delete lines;
1843
		delete lines;
1833
		return true;
1844
		return true;
Line 1876... Line 1887...
1876
			}
1887
			}
1877
		}
1888
		}
1878
 
1889
 
1879
		delete lines;
1890
		delete lines;
1880
		return true;
1891
		return true;
1881
	}
1892
	}
1882
	return false;
1893
	return false;
1883
}
1894
}
1884
 
1895
 
1885
bool CXspFile::extractCockpits(CVirtualFileSystem *pVfs)
1896
bool CXspFile::extractCockpits(CVirtualFileSystem *pVfs)
1886
{
1897
{
1887
	if ( !pVfs->ExtractGameFile("types/TCockpits.pck", "tmp").empty() ) {
1898
	if ( !pVfs->ExtractGameFile("types/TCockpits.pck", "tmp").empty() ) {
Line 1923... Line 1934...
1923
	bool added = false;
1934
	bool added = false;
1924
 
1935
 
1925
	Utils::String shipName;
1936
	Utils::String shipName;
1926
	Utils::String shipDesc;
1937
	Utils::String shipDesc;
1927
 
1938
 
-
 
1939
	int lastAddedGameID = 0;
-
 
1940
	int currentGameID = 0;
1928
	int lang = 0;
1941
	int lang = 0;
1929
	bool inpage = false;
1942
	bool inpage = false;
1930
	while ( !feof(id) )
1943
	while ( !feof(id) )
1931
	{
1944
	{
1932
		if ( !shipName.empty() && !shipDesc.empty() )
1945
		if ( !shipName.empty() && !shipDesc.empty() )
1933
		{
1946
		{
1934
			added = true;
1947
			added = true;
1935
			break;
1948
			break;
1936
		}
1949
		}
1937
 
1950
 
1938
		line.readToEndOfLine(id, 0, false);
1951
		line.readToEndOfLine(id, 0, false);
1939
		line.removeChar(9);
1952
		line.removeChar(9);
1940
		line.removeChar('\r');
1953
		line.removeChar('\r');
1941
		line.removeFirstSpace();
1954
		line.removeFirstSpace();
1942
 
1955
 
1943
		if ( inpage )
1956
		if ( inpage )
1944
		{
1957
		{
1945
			if ( line.left(6).Compare("</page") )
1958
			if ( line.left(6).Compare("</page") ) {
-
 
1959
				inpage = false;
1946
				break;
1960
				continue;
-
 
1961
			}
1947
 
1962
 
1948
			// find matching id
1963
			// find matching id
1949
			if ( line.left(6).Compare("<t id=") )
1964
			if ( line.left(6).Compare("<t id=") )
1950
			{
1965
			{
1951
				int pos = line.findPos("id=\"", 0);
1966
				int pos = line.findPos("id=\"", 0);
1952
				if ( pos != -1 )
1967
				if ( pos != -1 )
1953
				{
1968
				{
-
 
1969
					pos += 4;
1954
					int endpos = line.findPos("\"", pos + 5);
1970
					int endpos = line.findPos("\"", pos);
1955
					if ( endpos != -1 )
1971
					if ( endpos != -1 )
1956
					{
1972
					{
1957
						int id = line.mid(pos + 5, endpos);
1973
						int id = line.mid(pos, endpos);
1958
						if ( id == textId || id == (textId + 1) )
1974
						if ( id == textId || id == (textId + 1) )
1959
						{
1975
						{
1960
							pos = line.findPos(">", endpos);
1976
							pos = line.findPos(">", endpos);
1961
							if ( pos != -1 )
1977
							if ( pos != -1 )
1962
							{
1978
							{
1963
								endpos = line.findPos("</t>", pos);
1979
								endpos = line.findPos("</t>", pos);
1964
								if ( endpos != -1 )
1980
								if ( endpos != -1 )
1965
								{
1981
								{
1966
									if ( id == textId )
1982
									if ( id == textId )
1967
										shipName = line.mid(pos + 2, endpos - (pos + 1));
1983
										shipName = line.mid(pos + 1, endpos);
1968
									else
1984
									else
1969
										shipDesc = line.mid(pos + 2, endpos - (pos + 1));
1985
										shipDesc = line.mid(pos + 1, endpos);
-
 
1986
									lastAddedGameID = currentGameID;
1970
								}
1987
								}
1971
							}
1988
							}
1972
						}
1989
						}
1973
					}
1990
					}
1974
				}
1991
				}
Line 1979... Line 1996...
1979
			if ( line.left(8).Compare("<page id") )
1996
			if ( line.left(8).Compare("<page id") )
1980
			{
1997
			{
1981
				int pos = line.findPos("id=\"");
1998
				int pos = line.findPos("id=\"");
1982
				if ( pos != -1 )
1999
				if ( pos != -1 )
1983
				{
2000
				{
-
 
2001
					pos += 4;
1984
					int endpos = line.findPos("\"", pos + 5);
2002
					int endpos = line.findPos("\"", pos);
1985
					if ( endpos != -1 )
2003
					if ( endpos != -1 )
1986
					{
2004
					{
1987
						Utils::String sId = line.mid(pos + 5, endpos - (pos + 4));
2005
						Utils::String sId = line.mid(pos, endpos);
1988
						int id = sId;
2006
						int id = sId;
-
 
2007
						if ( sId.length() > 4 ) {
-
 
2008
							id = sId.right(4);
-
 
2009
							currentGameID = sId.left(sId.length() - 4);
-
 
2010
						}
-
 
2011
 
1989
						if ( id == 17 || ((int)sId.right(4)) == 17 )
2012
						if ( currentGameID >= lastAddedGameID && id == 17 )
1990
							inpage = true;
2013
							inpage = true;
1991
					}
2014
					}
1992
				}
2015
				}
1993
			}
2016
			}
1994
		}
2017
		}
1995
		else if ( line.left(12).Compare("<language id") )
2018
		else if ( line.left(12).Compare("<language id") )
1996
		{
2019
		{
1997
			int pos = line.findPos("id=\"");
2020
			int pos = line.findPos("id=\"");
1998
			if ( pos != -1 )
2021
			if ( pos != -1 )
1999
			{
2022
			{
-
 
2023
				// move past the id=
-
 
2024
				pos += 4;
-
 
2025
 
-
 
2026
				Utils::String s = line.right(-pos);
-
 
2027
				Utils::String s2 = line.mid(pos, -1);
2000
				int endpos = line.findPos("\"", pos + 5);
2028
				int endpos = line.findPos("\"", pos);
2001
				if ( endpos != -1 )
2029
				if ( endpos != -1 )
2002
					lang = line.mid(pos + 5, endpos - (pos + 4));
2030
					lang = line.mid(pos, endpos);
2003
			}
2031
			}
2004
		}
2032
		}
2005
	}
2033
	}
2006
 
2034
 
2007
	// incase we only found the shipname
2035
	// incase we only found the shipname