Subversion Repositories spk

Rev

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

Rev 210 Rev 211
Line 660... Line 660...
660
/*
660
/*
661
	Func:   CreateFilesLine
661
	Func:   CreateFilesLine
662
	Return: String - returns the full string for files list
662
	Return: String - returns the full string for files list
663
	Desc:   Creates a signle line list of all the files
663
	Desc:   Creates a signle line list of all the files
664
*/
664
*/
665
Utils::String CBaseFile::createFilesLine(SSPKHeader2 *header, CProgressInfo* progress) const
665
Utils::WString CBaseFile::createFilesLine(SSPKHeader2 *header, CProgressInfo* progress) const
666
{
666
{
667
	Utils::WString line;
667
	Utils::WString line;
668
 
668
 
669
	if (progress)
669
	if (progress)
670
	{
670
	{
Line 745... Line 745...
745
			++header->iNumFiles;
745
			++header->iNumFiles;
746
			header->lFullSize += (file->GetDataSize() + 4);
746
			header->lFullSize += (file->GetDataSize() + 4);
747
		}
747
		}
748
	}
748
	}
749
 
749
 
750
	return line.toString();
750
	return line;
751
}
751
}
752
 
752
 
753
/*
753
/*
754
######################################################################################
754
######################################################################################
755
##########							Reading Functions			    		##########
755
##########							Reading Functions			    		##########
Line 1112... Line 1112...
1112
		else {
1112
		else {
1113
			Utils::WString to = pCheckFile->getDirectory(this);
1113
			Utils::WString to = pCheckFile->getDirectory(this);
1114
			CDirIO Dir(sDestination);
1114
			CDirIO Dir(sDestination);
1115
			if ( !Dir.exists(to) ) {
1115
			if ( !Dir.exists(to) ) {
1116
				if ( !Dir.create ( to ) ) {
1116
				if ( !Dir.create ( to ) ) {
1117
					if ( errorStr )	errorStr->pushBack(to.toString(), ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
1117
					if ( errorStr )	errorStr->pushBack(to, ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
1118
					return false;
1118
					return false;
1119
				}
1119
				}
1120
				if ( errorStr )	errorStr->pushBack(to.toString(), ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
1120
				if ( errorStr )	errorStr->pushBack(to, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
1121
			}
1121
			}
1122
 
1122
 
1123
			Utils::WString destfile = sDestination + L"/" + pCheckFile->getNameDirectory(this);
1123
			Utils::WString destfile = sDestination + L"/" + pCheckFile->getNameDirectory(this);
1124
			if ( CFileIO::Exists(destfile) ) CFileIO::Remove(destfile);
1124
			if ( CFileIO::Exists(destfile) ) CFileIO::Remove(destfile);
1125
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->filePointer().c_str(), destfile.c_str());
1125
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->filePointer().c_str(), destfile.c_str());
Line 1325... Line 1325...
1325
					CLog::log(CLog::Log_Install, 2, "Copying data into existing file");
1325
					CLog::log(CLog::Log_Install, 2, "Copying data into existing file");
1326
				}
1326
				}
1327
 
1327
 
1328
				Utils::WString fpointer = fit->filePointer();
1328
				Utils::WString fpointer = fit->filePointer();
1329
				_iLastError = SPKERR_CREATEDIRECTORY;
1329
				_iLastError = SPKERR_CREATEDIRECTORY;
1330
				Utils::WString dir = CFileIO(fit->filePointer()).dir().toString();
1330
				Utils::WString dir = CFileIO(fit->filePointer()).dir();
1331
 
1331
 
1332
				dir = dir.findRemove(destdir);
1332
				dir = dir.findRemove(destdir);
1333
				if (!dir.empty() && (dir[0] == '/' || dir[0] == '\\')) 
1333
				if (!dir.empty() && (dir[0] == '/' || dir[0] == '\\')) 
1334
					dir.erase(0, 1);
1334
					dir.erase(0, 1);
1335
 
1335
 
Line 1437... Line 1437...
1437
		}
1437
		}
1438
	}
1438
	}
1439
	else if ( first.Compare(L"Game:") )
1439
	else if ( first.Compare(L"Game:") )
1440
		this->AddGameCompatability(rest, L"");
1440
		this->AddGameCompatability(rest, L"");
1441
	else if ( first.Compare(L"GameCompat:") )
1441
	else if ( first.Compare(L"GameCompat:") )
1442
		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2).toString());
1442
		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2));
1443
	else if ( first.Compare(L"GameCompatExact:") )
1443
	else if ( first.Compare(L"GameCompatExact:") )
1444
		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2).toString());
1444
		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2));
1445
	else if ( first.Compare(L"Date:") )				this->setCreationDate(rest);
1445
	else if ( first.Compare(L"Date:") )				this->setCreationDate(rest);
1446
	else if ( first.Compare(L"WebAddress:") )		this->setWebAddress(rest);
1446
	else if ( first.Compare(L"WebAddress:") )		this->setWebAddress(rest);
1447
	else if ( first.Compare(L"WebSite:") )			this->setWebSite(rest);
1447
	else if ( first.Compare(L"WebSite:") )			this->setWebSite(rest);
1448
	else if ( first.Compare(L"Email:") )				this->setEmail(rest);
1448
	else if ( first.Compare(L"Email:") )				this->setEmail(rest);
1449
	else if ( first.Compare(L"WebMirror1:") || first.Compare(L"Mirror1:") || first.Compare(L"WebMirror:") )
1449
	else if ( first.Compare(L"WebMirror1:") || first.Compare(L"Mirror1:") || first.Compare(L"WebMirror:") )
1450
		this->addWebMirror(rest.toString());
1450
		this->addWebMirror(rest);
1451
	else if ( first.Compare(L"WebMirror2:") || first.Compare(L"Mirror2:") )
1451
	else if ( first.Compare(L"WebMirror2:") || first.Compare(L"Mirror2:") )
1452
		this->addWebMirror(rest.toString());
1452
		this->addWebMirror(rest);
1453
	else if ( first.Compare(L"PluginType:") )		this->setPluginType(rest);
1453
	else if ( first.Compare(L"PluginType:") )		this->setPluginType(rest);
1454
	else if ( first.Compare(L"Desc:") )				this->setDescription(rest);
1454
	else if ( first.Compare(L"Desc:") )				this->setDescription(rest);
1455
	else if ( first.Compare(L"UninstallAfter:") )	this->addUninstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
1455
	else if ( first.Compare(L"UninstallAfter:") )	this->addUninstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
1456
	else if ( first.Compare(L"UninstallBefore:") )	this->addUninstallText(parseLanguage(rest.token(L"|", 1)), true, rest.tokens(L"|", 2));
1456
	else if ( first.Compare(L"UninstallBefore:") )	this->addUninstallText(parseLanguage(rest.token(L"|", 1)), true, rest.tokens(L"|", 2));
1457
	else if ( first.Compare(L"InstallAfter:") )		this->addInstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
1457
	else if ( first.Compare(L"InstallAfter:") )		this->addInstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
Line 1638... Line 1638...
1638
/*
1638
/*
1639
	Func:   ParseFiles
1639
	Func:   ParseFiles
1640
	Input:  String - values in one long line
1640
	Input:  String - values in one long line
1641
	Desc:   splits the files data into each line to read the data
1641
	Desc:   splits the files data into each line to read the data
1642
*/
1642
*/
1643
void CBaseFile::_readFiles(const Utils::String &values)
1643
void CBaseFile::_readFiles(const Utils::WString &values)
1644
{
1644
{
1645
	int num = 0;
1645
	std::vector<Utils::WString> lines;
1646
	Utils::String *lines = values.tokenise(";\n", &num);
1646
	values.tokenise(L"\n";, lines);
1647
 
1647
 
1648
	for (int i = 0; i < num; i++)
1648
	for (size_t i = 0; i < lines.size(); i++)
1649
		_parseFilesLine(lines[i]);
1649
		_parseFilesLine(lines[i]);
1650
 
-
 
1651
	CLEANSPLIT(lines, num)
-
 
1652
}
1650
}
1653
 
1651
 
1654
 
1652
 
1655
 
1653
 
1656
/*
1654
/*
Line 1678... Line 1676...
1678
 
1676
 
1679
	// read data to memory
1677
	// read data to memory
1680
	unsigned char *readData = 0;
1678
	unsigned char *readData = 0;
1681
	try {
1679
	try {
1682
		readData = new unsigned char[m_SHeader.lValueCompressSize];
1680
		readData = new unsigned char[m_SHeader.lValueCompressSize];
1683
	}
1681
	}
1684
	catch (std::exception &e) {
1682
	catch (std::exception &e) {
1685
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
1683
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
1686
		return -1;
1684
		return -1;
1687
	}
1685
	}
1688
 
1686
 
1689
	if (!readData)
1687
	if (!readData)
1690
		return -1;
1688
		return -1;
1691
 
1689
 
1692
	unsigned char size[4];
1690
	unsigned char size[4];
1693
	File.read(size, 4);
1691
	File.read(size, 4);
1694
	File.read(readData, m_SHeader.lValueCompressSize);
1692
	File.read(readData, m_SHeader.lValueCompressSize);
1695
 
1693
 
1696
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1694
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1697
 
1695
 
1698
	// check for zlib compression
1696
	// check for zlib compression
1699
	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
1697
	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
1700
		// uncomress the data
1698
		// uncomress the data
1701
		try {
1699
		try {
1702
			unsigned char *uncompr = new unsigned char[uncomprLen];
1700
			unsigned char *uncompr = new unsigned char[uncomprLen];
1703
			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader.lValueCompressSize );
1701
			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader.lValueCompressSize );
1704
			// update the progress for each section
1702
			// update the progress for each section
1705
			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1703
			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1706
			if (err == Z_OK) 
1704
			if (err == Z_OK) 
1707
			{
1705
			{
1708
				if (m_SHeader.fVersion <= 4.3f)
1706
				if (m_SHeader.fVersion < 4.4f)
1709
				{
1707
				{
1710
					std::string data((const char*)uncompr);
1708
					std::string data((const char*)uncompr);
1711
					_readValues(std::wstring(data.begin(), data.end()));
1709
					_readValues(std::wstring(data.begin(), data.end()));
1712
				}
1710
				}
1713
				else
1711
				else
Line 1731... Line 1729...
1731
		// update the progress for each section
1729
		// update the progress for each section
1732
		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1730
		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1733
 
1731
 
1734
		if (compr) 
1732
		if (compr) 
1735
		{
1733
		{
1736
			if (m_SHeader.fVersion <= 4.3f)
1734
			if (m_SHeader.fVersion <= 4.4f)
1737
			{
1735
			{
1738
				std::string data((const char*)compr);
1736
				std::string data((const char*)compr);
1739
				_readValues(std::wstring(data.begin(), data.end()));
1737
				_readValues(std::wstring(data.begin(), data.end()));
1740
			}
1738
			}
1741
			else
1739
			else
Line 1746... Line 1744...
1746
		}
1744
		}
1747
	}
1745
	}
1748
	// no compression
1746
	// no compression
1749
	else
1747
	else
1750
	{
1748
	{
1751
		if (m_SHeader.fVersion <= 4.3f)
1749
		if (m_SHeader.fVersion <= 4.4f)
1752
		{
1750
		{
1753
			std::string data((const char*)readData);
1751
			std::string data((const char*)readData);
1754
			_readValues(std::wstring(data.begin(), data.end()));
1752
			_readValues(std::wstring(data.begin(), data.end()));
1755
		}
1753
		}
1756
		else
1754
		else
Line 1789... Line 1787...
1789
		try {
1787
		try {
1790
			unsigned char *uncompr = new unsigned char[uncomprLen];
1788
			unsigned char *uncompr = new unsigned char[uncomprLen];
1791
			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader2.lSize );
1789
			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader2.lSize );
1792
			// update the progress for each section
1790
			// update the progress for each section
1793
			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(5, iMaxProgress);
1791
			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(5, iMaxProgress);
-
 
1792
			if (err == Z_OK)
-
 
1793
			{
-
 
1794
//#pragma warning(disable:4244)
-
 
1795
				if (m_SHeader.fVersion < 4.4f)
-
 
1796
				{
1794
			if ( err == Z_OK ) _readFiles((char *)uncompr);
1797
					std::string data((char*)uncompr);
-
 
1798
					_readFiles(std::wstring(data.begin(), data.end()));
-
 
1799
				}
-
 
1800
				else
-
 
1801
				{
-
 
1802
					std::wstring data((wchar_t*)uncompr);
-
 
1803
					_readFiles(data);
-
 
1804
				}
-
 
1805
//#pragma warning(enable:4244)
-
 
1806
			}
1795
			delete uncompr;
1807
			delete[] uncompr;
1796
		}
1808
		}
1797
		catch (std::exception &e) {
1809
		catch (std::exception &e) {
1798
			CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
1810
			CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
1799
			delete []readData;
1811
			delete []readData;
1800
			return -1;
1812
			return -1;
Line 2048... Line 2060...
2048
	free ( valueCompr );
2060
	free ( valueCompr );
2049
 
2061
 
2050
	// now compress the files header
2062
	// now compress the files header
2051
	// create the files values
2063
	// create the files values
2052
	SSPKHeader2 header;
2064
	SSPKHeader2 header;
2053
	Utils::String files = createFilesLine(&header, progress);
2065
	Utils::WString files = createFilesLine(&header, progress);
2054
	
2066
	
2055
	// compress the files values
2067
	// compress the files values
2056
	long fileUncomprLen = (long)files.length(), fileComprLen = fileUncomprLen;
2068
	long fileUncomprLen = (long)((wcslen(files.c_str()) * sizeof(wchar_t)) / sizeof(char)), fileComprLen = fileUncomprLen;
2057
	unsigned char *fileCompr = NULL;
2069
	unsigned char *fileCompr = NULL;
2058
 
2070
 
2059
	compressed = false;
2071
	compressed = false;
2060
	if ( fileUncomprLen )
2072
	if ( fileUncomprLen )
2061
	{
2073
	{
Line 2064... Line 2076...
2064
			if ( fileComprLen < 100 )
2076
			if ( fileComprLen < 100 )
2065
				fileComprLen = 200;
2077
				fileComprLen = 200;
2066
			else if ( fileComprLen < 1000 )
2078
			else if ( fileComprLen < 1000 )
2067
				fileComprLen *= 2;
2079
				fileComprLen *= 2;
2068
			fileCompr = (unsigned char *)calloc((unsigned int)fileComprLen, 1);
2080
			fileCompr = (unsigned char *)calloc((unsigned int)fileComprLen, 1);
2069
			int err = compress ( (unsigned char *)fileCompr, (unsigned long *)&fileComprLen, (const unsigned char *)files.c_str(), (unsigned long)files.length(), 0 );
2081
			int err = compress ( (unsigned char *)fileCompr, (unsigned long *)&fileComprLen, (const unsigned char *)files.c_str(), (unsigned long)fileUncomprLen, 0 );
2070
			if ( err == Z_OK )
2082
			if ( err == Z_OK )
2071
				compressed = true;
2083
				compressed = true;
2072
		}
2084
		}
2073
	}
2085
	}
2074
 
2086
 
2075
	// if unable to compress, store it as plain text
2087
	// if unable to compress, store it as plain text
2076
	if ( !compressed )
2088
	if ( !compressed )
2077
	{
2089
	{
2078
		fileComprLen = fileUncomprLen;
2090
		fileComprLen = fileUncomprLen;
2079
		fileCompr = (unsigned char *)calloc((unsigned int)fileComprLen, 1);
2091
		fileCompr = (unsigned char *)calloc((unsigned int)fileComprLen, 1);
2080
		memcpy ( fileCompr, files.c_str(), fileComprLen );
2092
		memcpy ( fileCompr, (const unsigned char *)files.c_str(), fileComprLen );
2081
		fileheader = SPKCOMPRESS_NONE;
2093
		fileheader = SPKCOMPRESS_NONE;
2082
	}
2094
	}
2083
 
2095
 
2084
	// now write the file header
2096
	// now write the file header
2085
	header.lSize = fileComprLen;
2097
	header.lSize = fileComprLen;
Line 2813... Line 2825...
2813
	else if (sFirst.Compare(L"ScriptName"))			addName(parseLanguage(sRest.token(L" ", 1)), sRest.tokens(L" ", 2));
2825
	else if (sFirst.Compare(L"ScriptName"))			addName(parseLanguage(sRest.token(L" ", 1)), sRest.tokens(L" ", 2));
2814
	else if (sFirst.Compare(L"UninstallBefore"))	this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
2826
	else if (sFirst.Compare(L"UninstallBefore"))	this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
2815
	else if (sFirst.Compare(L"UninstallAfter"))		this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
2827
	else if (sFirst.Compare(L"UninstallAfter"))		this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
2816
	else if (sFirst.Compare(L"InstallBefore"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
2828
	else if (sFirst.Compare(L"InstallBefore"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
2817
	else if (sFirst.Compare(L"InstallAfter"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
2829
	else if (sFirst.Compare(L"InstallAfter"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
2818
	else if (sFirst.Compare(L"Date"))				this->setCreationDate(sRest.toString());
2830
	else if (sFirst.Compare(L"Date"))				this->setCreationDate(sRest);
2819
	else if (sFirst.Compare(L"Version"))			this->setVersion(sRest.toString());
2831
	else if (sFirst.Compare(L"Version"))			this->setVersion(sRest);
2820
	else if (sFirst.Compare(L"GameVersion"))
2832
	else if (sFirst.Compare(L"GameVersion"))
2821
		this->AddGameCompatability(-1, sRest.toString());
2833
		this->AddGameCompatability(-1, sRest);
2822
	else if (sFirst.Compare(L"PluginType")) {
2834
	else if (sFirst.Compare(L"PluginType")) {
2823
		if (sRest.isNumber())						this->setPluginType(sRest);
2835
		if (sRest.isNumber())						this->setPluginType(sRest);
2824
		else if (sRest.Compare(L"Normal"))			this->setPluginType(PLUGIN_NORMAL);
2836
		else if (sRest.Compare(L"Normal"))			this->setPluginType(PLUGIN_NORMAL);
2825
		else if (sRest.Compare(L"Stable"))			this->setPluginType(PLUGIN_STABLE);
2837
		else if (sRest.Compare(L"Stable"))			this->setPluginType(PLUGIN_STABLE);
2826
		else if (sRest.Compare(L"Experimental"))	this->setPluginType(PLUGIN_EXPERIMENTAL);
2838
		else if (sRest.Compare(L"Experimental"))	this->setPluginType(PLUGIN_EXPERIMENTAL);
Line 2831... Line 2843...
2831
	else if (sFirst.Compare(L"GenerateUpdateFile"))
2843
	else if (sFirst.Compare(L"GenerateUpdateFile"))
2832
		m_bAutoGenerateUpdateFile = true;
2844
		m_bAutoGenerateUpdateFile = true;
2833
	else if (sFirst.Compare(L"Game"))
2845
	else if (sFirst.Compare(L"Game"))
2834
	{
2846
	{
2835
		Utils::WString sGame = sRest.token(L" ", 1);
2847
		Utils::WString sGame = sRest.token(L" ", 1);
2836
		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame.toString()), sRest.token(L" ", 2).toString());
2848
		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame), sRest.token(L" ", 2));
2837
	}
2849
	}
2838
	else if (sFirst.Compare(L"Description"))		this->setDescription(sRest.toString());
2850
	else if (sFirst.Compare(L"Description"))		this->setDescription(sRest);
2839
	else if (sFirst.Compare(L"AutoSave") || sFirst.Compare(L"AutoExport") || sFirst.Compare(L"AutoRarExport") || sFirst.Compare(L"AutoZipExport"))
2851
	else if (sFirst.Compare(L"AutoSave") || sFirst.Compare(L"AutoExport") || sFirst.Compare(L"AutoRarExport") || sFirst.Compare(L"AutoZipExport"))
2840
	{
2852
	{
2841
		Utils::WString filename = _replaceFilename(sRest);
2853
		Utils::WString filename = _replaceFilename(sRest);
2842
 
2854
 
2843
		if (sFirst.Compare(L"AutoZipExport") || sFirst.Compare(L"AutoExport"))
2855
		if (sFirst.Compare(L"AutoZipExport") || sFirst.Compare(L"AutoExport"))
2844
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"zip").toString());
2856
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"zip"));
2845
		else if (sFirst.Compare(L"AutoRarExport"))
2857
		else if (sFirst.Compare(L"AutoRarExport"))
2846
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"rar").toString());
2858
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"rar"));
2847
		else
2859
		else
2848
			this->setFilename(filename);
2860
			this->setFilename(filename);
2849
	}
2861
	}
2850
	else if (sFirst.Compare(L"WebSite"))		this->setWebSite(sRest.toString());
2862
	else if (sFirst.Compare(L"WebSite"))		this->setWebSite(sRest);
2851
	else if (sFirst.Compare(L"ForumLink") || sFirst.Compare("Forum")) this->setForumLink(sRest.toString());
2863
	else if (sFirst.Compare(L"ForumLink") || sFirst.Compare("Forum")) this->setForumLink(sRest);
2852
	else if (sFirst.Compare(L"Email"))			this->setEmail(sRest.toString());
2864
	else if (sFirst.Compare(L"Email"))			this->setEmail(sRest);
2853
	else if (sFirst.Compare(L"WebAddress"))		this->setWebAddress(sRest.toString());
2865
	else if (sFirst.Compare(L"WebAddress"))		this->setWebAddress(sRest);
2854
	else if (sFirst.Compare(L"WebMirror"))
2866
	else if (sFirst.Compare(L"WebMirror"))
2855
		this->addWebMirror(sRest.toString());
2867
		this->addWebMirror(sRest);
2856
	else if (sFirst.Compare(L"WebMirror1"))
2868
	else if (sFirst.Compare(L"WebMirror1"))
2857
		this->addWebMirror(sRest.toString());
2869
		this->addWebMirror(sRest);
2858
	else if (sFirst.Compare(L"WebMirror2"))
2870
	else if (sFirst.Compare(L"WebMirror2"))
2859
		this->addWebMirror(sRest.toString());
2871
		this->addWebMirror(sRest);
2860
	else if (sFirst.Compare(L"Ftp"))
2872
	else if (sFirst.Compare(L"Ftp"))
2861
		_sFtpAddr = sRest;
2873
		_sFtpAddr = sRest;
2862
	else if (sFirst.Compare(L"Ratings"))		_setRatings(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.token(L" ", 3));
2874
	else if (sFirst.Compare(L"Ratings"))		_setRatings(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.token(L" ", 3));
2863
	else if (sFirst.Compare(L"EaseOfUse"))		setEaseOfUse(sRest);
2875
	else if (sFirst.Compare(L"EaseOfUse"))		setEaseOfUse(sRest);
2864
	else if (sFirst.Compare(L"GameChanging"))	setGameChanging(sRest);
2876
	else if (sFirst.Compare(L"GameChanging"))	setGameChanging(sRest);
Line 2867... Line 2879...
2867
	{
2879
	{
2868
		Utils::WString version = sRest.token(L"|", 2);
2880
		Utils::WString version = sRest.token(L"|", 2);
2869
		Utils::WString name = sRest.token(L"|", 1);
2881
		Utils::WString name = sRest.token(L"|", 1);
2870
		Utils::WString author = sRest.tokens(L"|", 3);
2882
		Utils::WString author = sRest.tokens(L"|", 3);
2871
 
2883
 
2872
		this->addNeededLibrary(name, author, version.toString());
2884
		this->addNeededLibrary(name, author, version);
2873
	}
2885
	}
2874
	else if (sFirst.Compare(L"DependPackage"))
2886
	else if (sFirst.Compare(L"DependPackage"))
2875
	{
2887
	{
2876
		CPackages p;
2888
		CPackages p;
2877
		CBaseFile *spk = p.openPackage(sRest, 0, 0, SPKREAD_VALUES);
2889
		CBaseFile *spk = p.openPackage(sRest, 0, 0, SPKREAD_VALUES);
Line 2883... Line 2895...
2883
	}
2895
	}
2884
	else if (sFirst.Compare(L"Icon"))
2896
	else if (sFirst.Compare(L"Icon"))
2885
	{
2897
	{
2886
		C_File *icon = new C_File(sRest);
2898
		C_File *icon = new C_File(sRest);
2887
		if (icon->ReadFromFile())
2899
		if (icon->ReadFromFile())
2888
			this->setIcon(icon, CFileIO(sRest).extension().toString());
2900
			this->setIcon(icon, CFileIO(sRest).extension());
2889
	}
2901
	}
2890
	else if (sFirst.Compare(L"CombineGameFiles"))
2902
	else if (sFirst.Compare(L"CombineGameFiles"))
2891
		_bCombineFiles = sRest.Compare(L"true") || sRest.Compare(L"yes") || sRest.toInt();
2903
		_bCombineFiles = sRest.Compare(L"true") || sRest.Compare(L"yes") || sRest.toInt();
2892
	else if (sFirst.Compare(L"UpdateFile"))
2904
	else if (sFirst.Compare(L"UpdateFile"))
2893
		this->createUpdateFile(sRest);
2905
		this->createUpdateFile(sRest);
Line 2901... Line 2913...
2901
			std::vector<Utils::WString> games;
2913
			std::vector<Utils::WString> games;
2902
			if(game.tokenise(L"|", games))
2914
			if(game.tokenise(L"|", games))
2903
			{
2915
			{
2904
				for (size_t i = 0; i < games.size(); ++i)
2916
				for (size_t i = 0; i < games.size(); ++i)
2905
				{
2917
				{
2906
					unsigned int g = CBaseFile::GetGameFromString(games[i].toString());
2918
					unsigned int g = CBaseFile::GetGameFromString(games[i]);
2907
					Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2919
					Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2908
					this->addAutoExport(g, filename.toString());
2920
					this->addAutoExport(g, filename);
2909
				}
2921
				}
2910
			}
2922
			}
2911
		}
2923
		}
2912
		else
2924
		else
2913
		{
2925
		{
2914
			unsigned int g = CBaseFile::GetGameFromString(game.toString());
2926
			unsigned int g = CBaseFile::GetGameFromString(game);
2915
			Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2927
			Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2916
			this->addAutoExport(g, filename.toString());
2928
			this->addAutoExport(g, filename);
2917
		}
2929
		}
2918
	}
2930
	}
2919
	else if (sFirst.Compare(L"Extract"))
2931
	else if (sFirst.Compare(L"Extract"))
2920
	{
2932
	{
2921
		Utils::WString game = sRest.word(1);
2933
		Utils::WString game = sRest.word(1);
Line 2924... Line 2936...
2924
		{
2936
		{
2925
			std::vector<Utils::WString> games;
2937
			std::vector<Utils::WString> games;
2926
			if (game.tokenise(L"|", games))
2938
			if (game.tokenise(L"|", games))
2927
			{
2939
			{
2928
				for(size_t i = 0; i < games.size(); ++i)
2940
				for(size_t i = 0; i < games.size(); ++i)
2929
					this->addAutoExtract(CBaseFile::GetGameFromString(games[i].toString()), dir.toString());
2941
					this->addAutoExtract(CBaseFile::GetGameFromString(games[i]), dir);
2930
			}
2942
			}
2931
		}
2943
		}
2932
		else
2944
		else
2933
			this->addAutoExtract(CBaseFile::GetGameFromString(game.toString()), dir.toString());
2945
			this->addAutoExtract(CBaseFile::GetGameFromString(game), dir);
2934
	}
2946
	}
2935
	else
2947
	else
2936
	{
2948
	{
2937
		Utils::WString checkType = sFirst;
2949
		Utils::WString checkType = sFirst;
2938
		bool shared = false;
2950
		bool shared = false;
Line 2962... Line 2974...
2962
void CBaseFile::addFileScript(FileType filetype, bool shared, bool packed, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
2974
void CBaseFile::addFileScript(FileType filetype, bool shared, bool packed, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
2963
{
2975
{
2964
	Utils::WString dir;
2976
	Utils::WString dir;
2965
	Utils::WString rest = sRest;
2977
	Utils::WString rest = sRest;
2966
 
2978
 
2967
	unsigned int mainGame = CBaseFile::GetGameFromString(sMainGame.toString());
2979
	unsigned int mainGame = CBaseFile::GetGameFromString(sMainGame);
2968
	unsigned int game = 0;
2980
	unsigned int game = 0;
2969
	if ( rest.token(L" ", 1).left(4).Compare(L"GAME") ) {
2981
	if ( rest.token(L" ", 1).left(4).Compare(L"GAME") ) {
2970
		Utils::WString gameStr = rest.token(L" ", 2);
2982
		Utils::WString gameStr = rest.token(L" ", 2);
2971
		if (gameStr.contains(L"|"))
2983
		if (gameStr.contains(L"|"))
2972
		{
2984
		{
2973
			std::vector<Utils::WString> games;
2985
			std::vector<Utils::WString> games;
2974
			gameStr.tokenise(L"|", games);
2986
			gameStr.tokenise(L"|", games);
2975
			for (size_t i = 0; i < games.size(); ++i)
2987
			for (size_t i = 0; i < games.size(); ++i)
2976
			{
2988
			{
2977
				unsigned int g = CBaseFile::GetGameFromString(games[i].toString());
2989
				unsigned int g = CBaseFile::GetGameFromString(games[i]);
2978
				if (g)
2990
				if (g)
2979
					game |= 1 << g;
2991
					game |= 1 << g;
2980
			}
2992
			}
2981
		}
2993
		}
2982
		else
2994
		else
2983
		{
2995
		{
2984
			unsigned int g = CBaseFile::GetGameFromString(gameStr.toString());
2996
			unsigned int g = CBaseFile::GetGameFromString(gameStr);
2985
			if (g)
2997
			if (g)
2986
				game = 1 << g;
2998
				game = 1 << g;
2987
		}
2999
		}
2988
		rest = rest.tokens(L" ", 3);
3000
		rest = rest.tokens(L" ", 3);
2989
	}
3001
	}
Line 3016... Line 3028...
3016
						CFileIO F(file);
3028
						CFileIO F(file);
3017
						for(Utils::WString g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3029
						for(Utils::WString g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3018
							Utils::WString checkDir = F.dir() + L"/" + g;
3030
							Utils::WString checkDir = F.dir() + L"/" + g;
3019
							if ( CDirIO(checkDir).exists(F.filename()) ) {
3031
							if ( CDirIO(checkDir).exists(F.filename()) ) {
3020
								addGame = mainGame;
3032
								addGame = mainGame;
3021
								C_File *newfile = this->appendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g.toString()), packed, dir);
3033
								C_File *newfile = this->appendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g), packed, dir);
3022
								if (newfile && progress)
3034
								if (newfile && progress)
3023
									progress->UpdateFile(newfile);
3035
									progress->UpdateFile(newfile);
3024
								if ( newfile ) newfile->SetShared(shared);
3036
								if ( newfile ) newfile->SetShared(shared);
3025
							}
3037
							}
3026
						}
3038
						}
Line 3043... Line 3055...
3043
			CFileIO F(rest);
3055
			CFileIO F(rest);
3044
			for(Utils::WString g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3056
			for(Utils::WString g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3045
				Utils::WString checkDir = F.dir() + L"/" + g;
3057
				Utils::WString checkDir = F.dir() + L"/" + g;
3046
				if ( CDirIO(checkDir).exists(F.filename()) ) {
3058
				if ( CDirIO(checkDir).exists(F.filename()) ) {
3047
					addGame = mainGame;
3059
					addGame = mainGame;
3048
					C_File *newfile = this->appendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g.toString()), packed, dir);
3060
					C_File *newfile = this->appendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g), packed, dir);
3049
					if (newfile && progress)
3061
					if (newfile && progress)
3050
						progress->UpdateFile(newfile);
3062
						progress->UpdateFile(newfile);
3051
					if ( newfile ) newfile->SetShared(shared);
3063
					if ( newfile ) newfile->SetShared(shared);
3052
				}
3064
				}
3053
			}
3065
			}
Line 3148... Line 3160...
3148
	bool found = true;
3160
	bool found = true;
3149
	while ( found )
3161
	while ( found )
3150
	{
3162
	{
3151
		++num;
3163
		++num;
3152
		found = false;
3164
		found = false;
3153
		Utils::String find = Utils::String::PadNumber(num, 2);
3165
		Utils::WString find = Utils::WString::PadNumber(num, 2);
3154
		for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
3166
		for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
3155
		{
3167
		{
3156
			if ( node->Data()->GetFileType() != FILETYPE_MOD )
3168
			if ( node->Data()->GetFileType() != FILETYPE_MOD )
3157
				continue;
3169
				continue;
3158
			if ( !node->Data()->IsFakePatch() )
3170
			if ( !node->Data()->IsFakePatch() )
Line 3163... Line 3175...
3163
				break;
3175
				break;
3164
			}
3176
			}
3165
		}
3177
		}
3166
	}
3178
	}
3167
 
3179
 
3168
	Utils::String to = Utils::String::PadNumber(num, 2);
3180
	Utils::WString to = Utils::WString::PadNumber(num, 2);
3169
	C_File *match = this->findMatchingMod(f);
3181
	C_File *match = this->findMatchingMod(f);
3170
 
3182
 
3171
	// file link
3183
	// file link
3172
	if ( !f->GetData() )
3184
	if ( !f->GetData() )
3173
		f->ReadFromFile();
3185
		f->ReadFromFile();
Line 3437... Line 3449...
3437
	}
3449
	}
3438
 
3450
 
3439
	return false;
3451
	return false;
3440
}
3452
}
3441
 
3453
 
3442
Utils::String builtInWares()
3454
Utils::WString builtInWares()
3443
{
3455
{
3444
	Utils::String str;
3456
	Utils::WString str;
3445
	str += "28;0;0;0;0;59;5753;0;35714;1;1;0;35714;-100000;0;0;SS_WARE_SW_NEW1;\n";
3457
	str += L"28;0;0;0;0;59;5753;0;35714;1;1;0;35714;-100000;0;0;SS_WARE_SW_NEW1;\n";
3446
	str += "28;0;0;0;0;60;5763;0;33232;1;1;0;33232;0;1043;0;SS_WARE_SW_NEW2;\n";
3458
	str += L"28;0;0;0;0;60;5763;0;33232;1;1;0;33232;0;1043;0;SS_WARE_SW_NEW2;\n";
3447
	str += "28;0;0;0;0;61;5773;0;21428;1;1;0;21428;0;1043;0;SS_WARE_SW_NEW3;\n";
3459
	str += L"28;0;0;0;0;61;5773;0;21428;1;1;0;21428;0;1043;0;SS_WARE_SW_NEW3;\n";
3448
	str += "28;0;0;0;0;62;5783;0;56;1;1;0;56;-100000;0;0;SS_WARE_SW_NEW4;\n";
3460
	str += L"28;0;0;0;0;62;5783;0;56;1;1;0;56;-100000;0;0;SS_WARE_SW_NEW4;\n";
3449
	str += "28;0;0;0;0;63;5793;0;88;1;1;0;88;-100000;0;0;SS_WARE_SW_NEW5;\n";
3461
	str += L"28;0;0;0;0;63;5793;0;88;1;1;0;88;-100000;0;0;SS_WARE_SW_NEW5;\n";
3450
	str += "28;0;0;0;0;64;5803;0;283;1;1;0;283;-100000;0;0;SS_WARE_SW_NEW6;\n";
3462
	str += L"28;0;0;0;0;64;5803;0;283;1;1;0;283;-100000;0;0;SS_WARE_SW_NEW6;\n";
3451
	str += "28;0;0;0;0;65;5813;0;383;1;1;0;383;-100000;0;0;SS_WARE_SW_NEW7;\n";
3463
	str += L"28;0;0;0;0;65;5813;0;383;1;1;0;383;-100000;0;0;SS_WARE_SW_NEW7;\n";
3452
	str += "28;0;0;0;0;66;5823;0;1389;1;1;0;1389;-100000;1043;0;SS_WARE_SW_NEW8;\n";
3464
	str += L"28;0;0;0;0;66;5823;0;1389;1;1;0;1389;-100000;1043;0;SS_WARE_SW_NEW8;\n";
3453
	str += "28;0;0;0;0;67;5833;0;3396;1;1;0;3396;-100000;0;0;SS_WARE_SW_NEW9;\n";
3465
	str += L"28;0;0;0;0;67;5833;0;3396;1;1;0;3396;-100000;0;0;SS_WARE_SW_NEW9;\n";
3454
	str += "28;0;0;0;0;68;5843;0;4215;1;1;0;4215;-100000;0;0;SS_WARE_SW_NEW10;\n";
3466
	str += L"28;0;0;0;0;68;5843;0;4215;1;1;0;4215;-100000;0;0;SS_WARE_SW_NEW10;\n";
3455
	str += "28;0;0;0;0;69;5853;0;5635;1;1;0;5635;-100000;0;0;SS_WARE_SW_NEW11;\n";
3467
	str += L"28;0;0;0;0;69;5853;0;5635;1;1;0;5635;-100000;0;0;SS_WARE_SW_NEW11;\n";
3456
	str += "28;0;0;0;0;70;5863;0;65735;1;1;0;65735;-100000;0;0;SS_WARE_SW_NEW12;\n";
3468
	str += L"28;0;0;0;0;70;5863;0;65735;1;1;0;65735;-100000;0;0;SS_WARE_SW_NEW12;\n";
3457
	str += "28;0;0;0;0;71;5873;0;17857;1;1;0;17857;333;1043;0;SS_WARE_SW_NEW13;\n";
3469
	str += L"28;0;0;0;0;71;5873;0;17857;1;1;0;17857;333;1043;0;SS_WARE_SW_NEW13;\n";
3458
	str += "28;0;0;0;0;72;5883;0;21428;1;1;0;21428;0;1043;0;SS_WARE_SW_NEW14;\n";
3470
	str += L"28;0;0;0;0;72;5883;0;21428;1;1;0;21428;0;1043;0;SS_WARE_SW_NEW14;\n";
3459
	str += "28;0;0;0;0;73;5893;0;324515;1;1;0;324515;-100000;0;0;SS_WARE_SW_NEW15;\n";
3471
	str += L"28;0;0;0;0;73;5893;0;324515;1;1;0;324515;-100000;0;0;SS_WARE_SW_NEW15;\n";
3460
	str += "28;0;0;0;0;74;5903;0;638508;1;1;0;638508;-100000;0;0;SS_WARE_SW_NEW16;\n";
3472
	str += L"28;0;0;0;0;74;5903;0;638508;1;1;0;638508;-100000;0;0;SS_WARE_SW_NEW16;\n";
3461
	str += "28;0;0;0;0;75;5913;0;225755;1;1;0;225755;-100000;0;0;SS_WARE_SW_NEW17;\n";
3473
	str += L"28;0;0;0;0;75;5913;0;225755;1;1;0;225755;-100000;0;0;SS_WARE_SW_NEW17;\n";
3462
	str += "28;0;0;0;0;76;5923;0;1931535;1;1;0;1931535;1000;0;0;SS_WARE_SW_NEW18;\n";
3474
	str += L"28;0;0;0;0;76;5923;0;1931535;1;1;0;1931535;1000;0;0;SS_WARE_SW_NEW18;\n";
3463
	str += "28;0;0;0;0;77;5933;0;2209150;1;1;0;2209150;-100000;0;0;SS_WARE_SW_NEW19;\n";
3475
	str += L"28;0;0;0;0;77;5933;0;2209150;1;1;0;2209150;-100000;0;0;SS_WARE_SW_NEW19;\n";
3464
	str += "28;0;0;0;0;78;5943;0;6727565;1;1;0;6727565;-100000;0;0;SS_WARE_SW_NEW20;\n";
3476
	str += L"28;0;0;0;0;78;5943;0;6727565;1;1;0;6727565;-100000;0;0;SS_WARE_SW_NEW20;\n";
3465
	str += "28;0;0;0;0;85;9999;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_1;\n";
3477
	str += L"28;0;0;0;0;85;9999;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_1;\n";
3466
	str += "28;0;0;0;0;86;15053;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_2;\n";
3478
	str += L"28;0;0;0;0;86;15053;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_2;\n";
3467
	str += "28;0;0;0;0;87;15063;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_3;\n";
3479
	str += L"28;0;0;0;0;87;15063;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_3;\n";
3468
	str += "28;0;0;0;0;88;15073;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_4;\n";
3480
	str += L"28;0;0;0;0;88;15073;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_4;\n";
3469
	str += "28;0;0;0;0;89;15083;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_5;\n";
3481
	str += L"28;0;0;0;0;89;15083;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_5;\n";
3470
	str += "28;0;0;0;0;90;15093;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_6;\n";
3482
	str += L"28;0;0;0;0;90;15093;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_6;\n";
3471
 
3483
 
3472
	return str;
3484
	return str;
3473
}
3485
}
3474
 
3486
 
3475
void CBaseFile::_addWaresToList(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &wares, enum WareTypes eType)
3487
void CBaseFile::_addWaresToList(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &wares, enum WareTypes eType)