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 1770... Line 1770...
1770
			remove = true;
1770
			remove = true;
1771
			file = "tmp";
1771
			file = "tmp";
1772
		}
1772
		}
1773
	}
1773
	}
1774
 
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
 
-
 
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);
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() )
Line 1940... Line 1953...
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