Subversion Repositories spk

Rev

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

Rev 113 Rev 114
Line 1940... Line 1940...
1940
{
1940
{
1941
	if ( !olddata || !size )
1941
	if ( !olddata || !size )
1942
		return false;
1942
		return false;
1943
 
1943
 
1944
	size_t startLine = 0;
1944
	size_t startLine = 0;
1945
	CyString line;
1945
	Utils::String line;
1946
	size_t pos = 0;
1946
	size_t pos = 0;
1947
 
1947
 
1948
	unsigned char *data = new unsigned char[size];
1948
	unsigned char *data = new unsigned char[size];
1949
	memcpy(data, olddata, size);
1949
	memcpy(data, olddata, size);
1950
 
1950
 
Line 1952... Line 1952...
1952
	{
1952
	{
1953
		if ( data[pos] == '\n' )
1953
		if ( data[pos] == '\n' )
1954
		{
1954
		{
1955
			data[pos] = '\0';
1955
			data[pos] = '\0';
1956
			line = (char *)(data + startLine);
1956
			line = (char *)(data + startLine);
1957
			line.RemoveChar(9);
1957
			line.removeChar(9);
1958
			line.RemoveChar('\r');
1958
			line.removeChar('\r');
1959
			line.RemoveFirstSpace();
1959
			line.removeFirstSpace();
1960
 
1960
 
1961
			if ( !line.Empty() && line[0] != '/' )
1961
			if ( !line.empty() && line[0] != '/' )
1962
			{
1962
			{
1963
				CyString first = line.GetToken(":", 1, 1);
1963
				Utils::String first = line.token(":", 1);
1964
				if ( first.Compare("MATERIAL6") )
1964
				if ( first.Compare("MATERIAL6") )
1965
				{
1965
				{
1966
					int max;
1966
					int max;
-
 
1967
					Utils::String material = line.tokens(":", 2);
1967
					CyString *strs = line.GetToken(":", 2).SplitToken("; ", &max);
1968
					Utils::String *strs = material.tokens(";", 6).tokenise("; ", &max);
1968
 
1969
 
-
 
1970
					int num = material.token(";", 5);
1969
					if ( strs && max >= 2)
1971
					if ( strs && max >= 2)
1970
					{
1972
					{
-
 
1973
						for(int i = 0; i < max; i++) {
-
 
1974
							Utils::String type = strs[i].token(";", 1);
-
 
1975
							Utils::String valtype = strs[i].token(";", 2);			
-
 
1976
							if ( valtype.Compare("SPTYPE_STRING") ) {
-
 
1977
								Utils::String file = strs[i].token(";", 3);
-
 
1978
								list->PushBack(CyString(file), "", true);
-
 
1979
							}
-
 
1980
						}
-
 
1981
/*
1971
						for ( int i = 2; i < max; i++ )
1982
						for ( int i = 2; i < max; i++ )
1972
						{
1983
						{
1973
							CyString s = strs[i];
1984
							Utils::String s = strs[i];
1974
							if ( s.IsIn(";") )
1985
							if ( s.isin(";") )
1975
								s = s.GetToken(";", 1, 1);
1986
								s = s.token(";", 1);
1976
							if ( !s.IsNumber() && !s.Compare("NULL") && s.IsIn(".") )
1987
							if ( !s.isNumber() && !s.Compare("NULL") && s.isin(".") )
1977
								list->PushBack(s, "", true);
1988
								list->PushBack(s, "", true);
1978
						}
1989
						}
-
 
1990
						*/
1979
					}
1991
					}
1980
 
1992
 
1981
					CLEANSPLIT(strs, max)
1993
					CLEANSPLIT(strs, max)
1982
				}
1994
				}
1983
			}
1995
			}
1984
 
1996
 
1985
			startLine = pos + 1;
1997
			startLine = pos + 1;
1986
		}
1998
		}
1987
	}
1999
	}
Line 1998... Line 2010...
1998
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
2010
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
1999
	{
2011
	{
2000
		C_File *f = node->Data();
2012
		C_File *f = node->Data();
2001
		if ( f->GetFileType() != FILETYPE_SHIPMODEL )
2013
		if ( f->GetFileType() != FILETYPE_SHIPMODEL )
2002
			continue;
2014
			continue;
2003
 
2015
 
-
 
2016
		unsigned char *data = NULL;
-
 
2017
		size_t size;
-
 
2018
 
2004
		// cant do these yet
2019
		// cant do these yet
2005
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("bob") )
2020
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("bob") )
2006
		{
2021
		{
2007
			if ( !f->BobDecompile() )
2022
			if ( !f->BobDecompile() ) {
-
 
2023
				// search for the pbd or bod files that match and use them instead
-
 
2024
				Utils::String file;
-
 
2025
 
-
 
2026
				file = CFileIO(f->GetNameDirectory(NULL)).ChangeFileExtension("pbd").ToString();
-
 
2027
				file = pVfs->ExtractGameFile(file, CPackages::tempDirectory() + "tmp.tmp");
-
 
2028
	
-
 
2029
				if ( file.empty() ) {
-
 
2030
					file = CFileIO(f->GetNameDirectory(NULL)).ChangeFileExtension("bod").ToString();
-
 
2031
					file = pVfs->ExtractGameFile(file, CPackages::tempDirectory() + "tmp.tmp");
-
 
2032
				}
-
 
2033
 
-
 
2034
				if ( !file.empty() ) {
-
 
2035
					CFileIO File(file);
-
 
2036
					if ( File.exists() ) {
-
 
2037
						data = File.readAll(&size);
-
 
2038
						File.remove();
-
 
2039
					}
-
 
2040
				}
-
 
2041
 
-
 
2042
				if ( data && size ) 
-
 
2043
					this->GetTextureList(&lTextures, data, size);
2008
				continue;
2044
				continue;
-
 
2045
			}
2009
		}
2046
		}
2010
 
2047
 
2011
		if ( !f->GetData() )
2048
		if ( !f->GetData() )
2012
		{
2049
		{
2013
			if ( !f->ReadFromFile() )
2050
			if ( !f->ReadFromFile() )
2014
				continue;
2051
				continue;
2015
		}
2052
		}
2016
 
2053
 
2017
		unsigned char *data = NULL;
-
 
2018
		size_t size;
-
 
2019
 
2054
 
2020
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("pbd") )
2055
		if ( f->CheckFileExt("pbb") || f->CheckFileExt("pbd") )
2021
			data = f->UnPCKFile(&size);
2056
			data = f->UnPCKFile(&size);
2022
		else
2057
		else
2023
		{
2058
		{
Line 2028... Line 2063...
2028
		this->GetTextureList(&lTextures, data, size);
2063
		this->GetTextureList(&lTextures, data, size);
2029
	}
2064
	}
2030
 
2065
 
2031
	for ( SStringList *node = lTextures.Head(); node; node = node->next )
2066
	for ( SStringList *node = lTextures.Head(); node; node = node->next )
2032
	{
2067
	{
-
 
2068
		CFileIO F(node->str);
2033
		if ( CFileIO(node->str).CheckFileExtension("dds") )
2069
		if ( F.CheckFileExtension("fx") ) {
-
 
2070
			pVfs->extractGameFileToPackage(this, "shader\\1_1\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
-
 
2071
			pVfs->extractGameFileToPackage(this, "shader\\1_4\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
-
 
2072
			pVfs->extractGameFileToPackage(this, "shader\\2_0\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
-
 
2073
			pVfs->extractGameFileToPackage(this, "shader\\2_a\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
-
 
2074
			pVfs->extractGameFileToPackage(this, "shader\\2_b\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
2034
			pVfs->extractGameFileToPackage(this, "dds\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
2075
			pVfs->extractGameFileToPackage(this, "shader\\3_0\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
-
 
2076
		}
2035
		else 
2077
		else {
-
 
2078
			if ( !pVfs->extractGameFileToPackage(this, "dds\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER) ) {
-
 
2079
				if ( F.CheckFileExtension("dds") )
-
 
2080
					pVfs->extractGameFileToPackage(this, "dds\\" + Utils::String(node->str.ToString()).token(".", -1), FILETYPE_SHIPOTHER);
-
 
2081
				else {
-
 
2082
					if ( !pVfs->extractGameFileToPackage(this, "dds\\" + Utils::String(node->str.ToString()) + ".dds", FILETYPE_SHIPOTHER) )
2036
			pVfs->extractGameFileToPackage(this, "textures\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
2083
						pVfs->extractGameFileToPackage(this, "textures\\" + Utils::String(node->str.ToString()), FILETYPE_SHIPOTHER);
-
 
2084
				}
-
 
2085
			}
-
 
2086
		}
2037
	}
2087
	}
2038
}
2088
}
2039
 
2089
 
2040
bool CXspFile::AddTextFromFile(const Utils::String &sFile, int textId)
2090
bool CXspFile::AddTextFromFile(const Utils::String &sFile, int textId)
2041
{
2091
{