Subversion Repositories spk

Rev

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

Rev 207 Rev 208
Line 1675... Line 1675...
1675
int CBaseFile::_read_Header(CFileIO &File, int iReadType, int iMaxProgress, CProgressInfo *pProgress)
1675
int CBaseFile::_read_Header(CFileIO &File, int iReadType, int iMaxProgress, CProgressInfo *pProgress)
1676
{
1676
{
1677
	int doneLen = 0;
1677
	int doneLen = 0;
1678
 
1678
 
1679
	// read data to memory
1679
	// read data to memory
1680
	unsigned char *readData;
1680
	unsigned char *readData = 0;
1681
	try {
1681
	try {
1682
		readData = new unsigned char[m_SHeader.lValueCompressSize];
1682
		readData = new unsigned char[m_SHeader.lValueCompressSize];
1683
	}
1683
	}
1684
	catch (std::exception &e) {
1684
	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());
1685
		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
1686
		return -1;
1686
		return -1;
1687
	}
1687
	}
1688
 
1688
 
-
 
1689
	if (!readData)
-
 
1690
		return -1;
-
 
1691
 
1689
	unsigned char size[4];
1692
	unsigned char size[4];
1690
	File.read(size, 4);
1693
	File.read(size, 4);
1691
	File.read(readData, m_SHeader.lValueCompressSize);
1694
	File.read(readData, m_SHeader.lValueCompressSize);
1692
 
1695
 
1693
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
1696
	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
Line 1698... Line 1701...
1698
		try {
1701
		try {
1699
			unsigned char *uncompr = new unsigned char[uncomprLen];
1702
			unsigned char *uncompr = new unsigned char[uncomprLen];
1700
			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader.lValueCompressSize );
1703
			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader.lValueCompressSize );
1701
			// update the progress for each section
1704
			// update the progress for each section
1702
			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1705
			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
-
 
1706
			if (err == Z_OK) 
-
 
1707
			{
1703
			if ( err == Z_OK ) this->_readValues((char *)uncompr);
1708
				std::string data((char*)uncompr);
-
 
1709
				_readValues(std::wstring(data.begin(), data.end()));
-
 
1710
			}
1704
			doneLen = uncomprLen;
1711
			doneLen = uncomprLen;
1705
			delete uncompr;
1712
			delete []uncompr;
1706
		}
1713
		}
1707
		catch (std::exception &e) {
1714
		catch (std::exception &e) {
1708
			CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
1715
			CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
1709
			delete []readData;
1716
			delete []readData;
1710
			return -1;
1717
			return -1;
Line 1713... Line 1720...
1713
	else if ( m_SHeader.iValueCompression == SPKCOMPRESS_7ZIP ) {
1720
	else if ( m_SHeader.iValueCompression == SPKCOMPRESS_7ZIP ) {
1714
		long len = uncomprLen;
1721
		long len = uncomprLen;
1715
		unsigned char *compr = LZMADecode_C ( readData, m_SHeader.lValueCompressSize, (size_t*)&len, NULL );
1722
		unsigned char *compr = LZMADecode_C ( readData, m_SHeader.lValueCompressSize, (size_t*)&len, NULL );
1716
		// update the progress for each section
1723
		// update the progress for each section
1717
		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1724
		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
1718
 
1725
 
-
 
1726
		if (compr) 
-
 
1727
		{
1719
		if ( compr ) _readValues((char *)compr);
1728
			std::string data((char*)compr);
-
 
1729
			_readValues(std::wstring(data.begin(), data.end()));
-
 
1730
		}
1720
	}
1731
	}
1721
	// no compression
1732
	// no compression
1722
	else
1733
	else
-
 
1734
	{
1723
		_readValues((char *)readData);
1735
		std::string data((char*)readData);
-
 
1736
		_readValues(std::wstring(data.begin(), data.end()));
-
 
1737
	}
1724
 
1738
 
1725
	delete []readData;
1739
	delete []readData;
1726
 
1740
 
1727
	return doneLen;
1741
	return doneLen;
1728
}
1742
}
1729
 
1743
 
1730
int CBaseFile::_read_FileHeader(CFileIO &File, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress)
1744
int CBaseFile::_read_FileHeader(CFileIO &File, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress)
1731
{
1745
{
1732
	unsigned char *readData;
1746
	unsigned char *readData;
1733
	try {
1747
	try {
1734
		readData = new unsigned char[m_SHeader2.lSize];
1748
		readData = new unsigned char[m_SHeader2.lSize];
Line 1771... Line 1785...
1771
		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(5, iMaxProgress);
1785
		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(5, iMaxProgress);
1772
		if ( compr ) _readFiles((char *)compr);
1786
		if ( compr ) _readFiles((char *)compr);
1773
	}
1787
	}
1774
	else
1788
	else
1775
		_readFiles((char *)readData);
1789
		_readFiles((char *)readData);
1776
 
1790
 
1777
	delete []readData;
1791
	delete []readData;
1778
	return true;
1792
	return true;
1779
}
1793
}
1780
 
1794
 
1781
bool CBaseFile::readFile(CFileIO &File, int readtype, CProgressInfo *progress)
1795
bool CBaseFile::readFile(CFileIO &File, int readtype, CProgressInfo *progress)
Line 1817... Line 1831...
1817
	long numfiles = m_lFiles.size();
1831
	long numfiles = m_lFiles.size();
1818
	if ( m_pIconFile ) ++numfiles;
1832
	if ( m_pIconFile ) ++numfiles;
1819
	if ( m_SHeader2.iNumFiles != numfiles ) {
1833
	if ( m_SHeader2.iNumFiles != numfiles ) {
1820
		_iLastError = SPKERR_FILEMISMATCH;
1834
		_iLastError = SPKERR_FILEMISMATCH;
1821
		return false;
1835
		return false;
1822
	}
1836
	}
1823
 
1837
 
1824
	// update the progress for each section
1838
	// update the progress for each section
1825
	if ( readtype != SPKREAD_ALL && progress )	progress->UpdateProgress(6, maxProgress);
1839
	if ( readtype != SPKREAD_ALL && progress )	progress->UpdateProgress(6, maxProgress);
1826
 
1840
 
1827
	if ( readtype == SPKREAD_ALL ) {
1841
	if ( readtype == SPKREAD_ALL ) {
1828
		int fileCount = 2;
1842
		int fileCount = 2;
1829
		if ( m_pIconFile ) m_pIconFile->readFromFile(File, m_pIconFile->GetDataSize());
1843
		if ( m_pIconFile ) m_pIconFile->readFromFile(File, m_pIconFile->GetDataSize());
1830
 
1844
 
1831
		// ok finally we need to read all the file
1845
		// ok finally we need to read all the file
1832
		for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
1846
		for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
1833
			node->Data()->readFromFile(File, node->Data()->GetDataSize());
1847
			node->Data()->readFromFile(File, node->Data()->GetDataSize());
1834
			if ( progress )	progress->UpdateProgress(fileCount++, m_lFiles.size() + 2);
1848
			if ( progress )	progress->UpdateProgress(fileCount++, m_lFiles.size() + 2);
1835
		}
1849
		}
Line 1839... Line 1853...
1839
 
1853
 
1840
	return true;
1854
	return true;
1841
}
1855
}
1842
 
1856
 
1843
bool CBaseFile::IsMod()
1857
bool CBaseFile::IsMod()
1844
{
1858
{
1845
	// check for any mod files that are not fake patchs
1859
	// check for any mod files that are not fake patchs
1846
	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
1860
	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
1847
	{
1861
	{
1848
		C_File *f = fNode->Data();
1862
		C_File *f = fNode->Data();
1849
		if ( f->GetFileType() != FILETYPE_MOD )
1863
		if ( f->GetFileType() != FILETYPE_MOD )
1850
			continue;
1864
			continue;
1851
 
1865
 
1852
		if ( !f->IsFakePatch() )
1866
		if ( !f->IsFakePatch() )
1853
			return true;
1867
			return true;
1854
	}
1868
	}
1855
 
1869
 
1856
	return false;
1870
	return false;
1857
}
1871
}
1858
 
1872
 
1859
bool CBaseFile::IsFakePatch() const
1873
bool CBaseFile::IsFakePatch() const
1860
{
1874
{
1861
	// check for any mod files that are not fake patchs
1875
	// check for any mod files that are not fake patchs
1862
	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
1876
	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
1863
	{
1877
	{
1864
		C_File *f = fNode->Data();
1878
		C_File *f = fNode->Data();
1865
		if ( f->GetFileType() != FILETYPE_MOD )
1879
		if ( f->GetFileType() != FILETYPE_MOD )
1866
			continue;
1880
			continue;
1867
 
1881
 
1868
		if ( f->IsFakePatch() )
1882
		if ( f->IsFakePatch() )
1869
			return true;
1883
			return true;
1870
	}
1884
	}
1871
 
1885
 
1872
	return false;
1886
	return false;
1873
}
1887
}
1874
 
1888
 
Line 1882... Line 1896...
1882
	if ( !this->webAddress().empty() )	values += L"WebAddress: "	+ this->webAddress()	+ L"\n";
1896
	if ( !this->webAddress().empty() )	values += L"WebAddress: "	+ this->webAddress()	+ L"\n";
1883
	if ( !this->webSite().empty() )		values += L"WebSite: "		+ this->webSite()		+ L"\n";
1897
	if ( !this->webSite().empty() )		values += L"WebSite: "		+ this->webSite()		+ L"\n";
1884
	if ( !this->email().empty() )		values += L"Email: "		+ this->email()			+ L"\n";
1898
	if ( !this->email().empty() )		values += L"Email: "		+ this->email()			+ L"\n";
1885
	if ( !this->forumLink().empty() )	values += L"ForumLink: "	+ this->forumLink()		+ L"\n";
1899
	if ( !this->forumLink().empty() )	values += L"ForumLink: "	+ this->forumLink()		+ L"\n";
1886
 
1900
 
1887
	for(auto itr = _lMirrors.begin(); itr != _lMirrors.end(); itr++)
1901
	for(auto itr = webMirrors().begin(); itr != webMirrors().end(); itr++)
1888
		values += Utils::WString(L"WebMirror: ") + (*itr)->str.toWString() + L"\n";
1902
		values += Utils::WString(L"WebMirror: ") + (*itr)->str + L"\n";
1889
	if ( !this->description().empty() ) {
1903
	if ( !this->description().empty() ) {
1890
		Utils::WString desc = this->description();
1904
		Utils::WString desc = this->description();
1891
		desc = desc.findReplace(L"<newline>", L"<br>");
1905
		desc = desc.findReplace(L"<newline>", L"<br>");
1892
		desc = desc.findReplace(L"\n", "L<br>");
1906
		desc = desc.findReplace(L"\n", "L<br>");
1893
		desc.remove(L'\r');
1907
		desc.remove(L'\r');
Line 1966... Line 1980...
1966
	if ( fileheader == SPKCOMPRESS_7ZIP )
1980
	if ( fileheader == SPKCOMPRESS_7ZIP )
1967
		fileheader = SPKCOMPRESS_ZLIB;
1981
		fileheader = SPKCOMPRESS_ZLIB;
1968
 
1982
 
1969
	// get the script values
1983
	// get the script values
1970
	Utils::WString values = this->createValuesLine();
1984
	Utils::WString values = this->createValuesLine();
-
 
1985
	std::string sValues(values.begin(), values.end());
1971
 
1986
 
1972
	// compress the values
1987
	// compress the values
1973
	int valueUncomprLen = (int)values.length();
1988
	int valueUncomprLen = (int)strlen(sValues.c_str());
1974
	unsigned long valueComprLen = 0;
1989
	unsigned long valueComprLen = 0;
1975
	unsigned char *valueCompr = NULL;
1990
	unsigned char *valueCompr = NULL;
1976
	bool compressed = false;
1991
	bool compressed = false;
-
 
1992
 
1977
	if ( valueheader == SPKCOMPRESS_ZLIB )
1993
	if ( valueheader == SPKCOMPRESS_ZLIB )
1978
	{
1994
	{
1979
		valueComprLen = valueUncomprLen;
1995
		valueComprLen = valueUncomprLen;
1980
		if ( valueComprLen < 100 )
1996
		if ( valueComprLen < 100 )
1981
			valueComprLen = 200;
1997
			valueComprLen = 200;
1982
		else if ( valueComprLen < 1000 )
1998
		else if ( valueComprLen < 1000 )
1983
			valueComprLen *= 2;
1999
			valueComprLen *= 2;
1984
 
2000
 
1985
		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
2001
		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
1986
		int err = compress ( (unsigned char *)valueCompr, &valueComprLen, (const unsigned char *)values.c_str(), (unsigned long)values.length(), 0 );
2002
		int err = compress ( (unsigned char *)valueCompr, &valueComprLen, (const unsigned char *)sValues.c_str(), (unsigned long)strlen(sValues.c_str()), 0 );
1987
		if ( err == Z_OK )
2003
		if ( err == Z_OK )
1988
			compressed = true;
2004
			compressed = true;
1989
	}
2005
	}
1990
 
2006
 
1991
	if ( !compressed )
2007
	if ( !compressed )
1992
	{
2008
	{
1993
		valueComprLen = valueUncomprLen;
2009
		valueComprLen = valueUncomprLen;
1994
		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
2010
		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
1995
		memcpy ( valueCompr, values.c_str(), valueComprLen );
2011
		memcpy ( valueCompr, sValues.c_str(), valueComprLen );
1996
		valueheader = SPKCOMPRESS_NONE;
2012
		valueheader = SPKCOMPRESS_NONE;
1997
	}
2013
	}
1998
 
2014
 
1999
	// write the main header to the file
2015
	// write the main header to the file
2000
	if ( !this->writeHeader(file, valueheader, valueComprLen) )	return false;
2016
	if ( !this->writeHeader(file, valueheader, valueComprLen) )	return false;
Line 2425... Line 2441...
2425
 
2441
 
2426
	if ( !m_lGames.empty() ) {
2442
	if ( !m_lGames.empty() ) {
2427
		list->pushBack("# The game version the script is for <game> <version> (can have multiple games)");
2443
		list->pushBack("# The game version the script is for <game> <version> (can have multiple games)");
2428
		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
2444
		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
2429
			if (game > 0 && g->iGame != game)
2445
			if (game > 0 && g->iGame != game)
2430
				continue;
2446
				continue;
2431
 
2447
 
2432
			Utils::WString game = CBaseFile::ConvertGameToString(g->iGame);
2448
			Utils::WString game = CBaseFile::ConvertGameToString(g->iGame);
2433
 
2449
 
2434
			if ( !g->sVersion.empty() )
2450
			if ( !g->sVersion.empty() )
2435
			{
2451
			{
2436
				game += L" ";
2452
				game += L" ";
2437
				game += g->sVersion;
2453
				game += g->sVersion;
2438
			}
2454
			}
Line 2473... Line 2489...
2473
	}
2489
	}
2474
 
2490
 
2475
	if ( !this->email().empty() ) {
2491
	if ( !this->email().empty() ) {
2476
		list->pushBack("# The email address of the author, to allow users to contract if needed");
2492
		list->pushBack("# The email address of the author, to allow users to contract if needed");
2477
		list->pushBack("Email: " + this->email().toString());
2493
		list->pushBack("Email: " + this->email().toString());
2478
		list->pushBack("");
2494
		list->pushBack("");
2479
	}
2495
	}
2480
 
2496
 
2481
	if (_lMirrors.size())
2497
	if (webMirrors().size())
2482
	{
2498
	{
2483
		list->pushBack("# A link to the mirror address for the update file, can have many of these");
2499
		list->pushBack("# A link to the mirror address for the update file, can have many of these");
2484
		for(auto itr = _lMirrors.begin(); itr != _lMirrors.end(); itr++)
2500
		for(auto itr = webMirrors().begin(); itr != webMirrors().end(); itr++)
2485
			list->pushBack(Utils::String("WebMirror: ") + (*itr)->str);
2501
			list->pushBack(Utils::String("WebMirror: ") + (*itr)->str.toString());
2486
		list->pushBack("");
2502
		list->pushBack("");
2487
	}
2503
	}
2488
 
2504
 
2489
	if ( m_bAutoGenerateUpdateFile )
2505
	if ( m_bAutoGenerateUpdateFile )
2490
	{
2506
	{
Line 2524... Line 2540...
2524
			list->pushBack((L"# " + installText + L" Texts, display text before and/or after " + installText + L"ing to inform the use of special conditions").toString());
2540
			list->pushBack((L"# " + installText + L" Texts, display text before and/or after " + installText + L"ing to inform the use of special conditions").toString());
2525
			for ( unsigned int i = 0; i < pText->count(); i++ ) {
2541
			for ( unsigned int i = 0; i < pText->count(); i++ ) {
2526
				long iLang = pText->language(i);
2542
				long iLang = pText->language(i);
2527
				if ( !pText->getBefore(iLang).empty() )	list->pushBack((installText + "Before: " + iLang + L" " + pText->getBefore(iLang)).toString());
2543
				if ( !pText->getBefore(iLang).empty() )	list->pushBack((installText + "Before: " + iLang + L" " + pText->getBefore(iLang)).toString());
2528
				if ( !pText->getAfter(iLang).empty()  )	list->pushBack((installText + "After: " + iLang + L" " + pText->getAfter(iLang)).toString());
2544
				if ( !pText->getAfter(iLang).empty()  )	list->pushBack((installText + "After: " + iLang + L" " + pText->getAfter(iLang)).toString());
2529
			}
2545
			}
2530
			list->pushBack("");
2546
			list->pushBack("");
2531
		}
2547
		}
2532
	}
2548
	}
2533
 
2549
 
2534
	list->pushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2550
	list->pushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
Line 2616... Line 2632...
2616
				}
2632
				}
2617
			}
2633
			}
2618
		}
2634
		}
2619
 
2635
 
2620
		if ( !done )
2636
		if ( !done )
2621
			name += f->Data()->getNameDirectory(this);
2637
			name += f->Data()->getNameDirectory(this);
2622
 
2638
 
2623
		if ( !f->Data()->dir().empty() )
2639
		if ( !f->Data()->dir().empty() )
2624
		{
2640
		{
2625
			name += L"|";
2641
			name += L"|";
2626
			name += f->Data()->dir();
2642
			name += f->Data()->dir();
2627
		}
2643
		}
Line 2639... Line 2655...
2639
						first = false;
2655
						first = false;
2640
					else
2656
					else
2641
						s += "|";
2657
						s += "|";
2642
					s += CBaseFile::ConvertGameToString(i);
2658
					s += CBaseFile::ConvertGameToString(i);
2643
				}
2659
				}
2644
			}
2660
			}
2645
		}
2661
		}
2646
 
2662
 
2647
		s += L" " + name;
2663
		s += L" " + name;
2648
		if(!files.contains(s))
2664
		if(!files.contains(s))
2649
			files.pushBack(s, f->Data()->fileTypeString());
2665
			files.pushBack(s, f->Data()->fileTypeString());
2650
	}
2666
	}
2651
 
2667
 
Line 2688... Line 2704...
2688
		if ( node->Data()->iGame == 0 )
2704
		if ( node->Data()->iGame == 0 )
2689
			foundAll = true;
2705
			foundAll = true;
2690
		else if ( node->Data()->iGame == game ) { // now check the version
2706
		else if ( node->Data()->iGame == game ) { // now check the version
2691
			if ( node->Data()->sVersion.empty() ) {
2707
			if ( node->Data()->sVersion.empty() ) {
2692
				if (node->Data()->sVersion.compareVersion(sVersion) == COMPARE_OLDER)
2708
				if (node->Data()->sVersion.compareVersion(sVersion) == COMPARE_OLDER)
2693
					return false;
2709
					return false;
2694
				return true;
2710
				return true;
2695
			}
2711
			}
2696
			else {
2712
			else {
2697
				if ( node->Data()->iVersion > iVersion )
2713
				if ( node->Data()->iVersion > iVersion )
2698
					return false;
2714
					return false;
Line 2804... Line 2820...
2804
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"zip").toString());
2820
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"zip").toString());
2805
		else if (sFirst.Compare(L"AutoRarExport"))
2821
		else if (sFirst.Compare(L"AutoRarExport"))
2806
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"rar").toString());
2822
			this->setExportFilename(CFileIO(filename).changeFileExtension(L"rar").toString());
2807
		else
2823
		else
2808
			this->setFilename(filename);
2824
			this->setFilename(filename);
2809
	}
2825
	}
2810
	else if (sFirst.Compare(L"WebSite"))		this->setWebSite(sRest.toString());
2826
	else if (sFirst.Compare(L"WebSite"))		this->setWebSite(sRest.toString());
2811
	else if (sFirst.Compare(L"ForumLink") || sFirst.Compare("Forum")) this->setForumLink(sRest.toString());
2827
	else if (sFirst.Compare(L"ForumLink") || sFirst.Compare("Forum")) this->setForumLink(sRest.toString());
2812
	else if (sFirst.Compare(L"Email"))			this->setEmail(sRest.toString());
2828
	else if (sFirst.Compare(L"Email"))			this->setEmail(sRest.toString());
2813
	else if (sFirst.Compare(L"WebAddress"))		this->setWebAddress(sRest.toString());
2829
	else if (sFirst.Compare(L"WebAddress"))		this->setWebAddress(sRest.toString());
2814
	else if (sFirst.Compare(L"WebMirror"))
2830
	else if (sFirst.Compare(L"WebMirror"))
Line 2850... Line 2866...
2850
	else if (sFirst.Compare(L"CombineGameFiles"))
2866
	else if (sFirst.Compare(L"CombineGameFiles"))
2851
		_bCombineFiles = sRest.Compare(L"true") || sRest.Compare(L"yes") || sRest.toInt();
2867
		_bCombineFiles = sRest.Compare(L"true") || sRest.Compare(L"yes") || sRest.toInt();
2852
	else if (sFirst.Compare(L"UpdateFile"))
2868
	else if (sFirst.Compare(L"UpdateFile"))
2853
		this->createUpdateFile(sRest);
2869
		this->createUpdateFile(sRest);
2854
	else if (sFirst.Compare(L"ExportZip"))
2870
	else if (sFirst.Compare(L"ExportZip"))
2855
	{
2871
	{
2856
		Utils::WString ext = L"zip";
2872
		Utils::WString ext = L"zip";
2857
		Utils::WString game = sRest.word(1);
2873
		Utils::WString game = sRest.word(1);
2858
		Utils::WString file = _replaceFilename(CFileIO(sRest.words(2)).fullFilename());
2874
		Utils::WString file = _replaceFilename(CFileIO(sRest.words(2)).fullFilename());
2859
		if (game.contains(L"|"))
2875
		if (game.contains(L"|"))
2860
		{
2876
		{
2861
			std::vector<Utils::WString> games;
2877
			std::vector<Utils::WString> games;
2862
			if(game.tokenise(L"|", games))
2878
			if(game.tokenise(L"|", games))
2863
			{
2879
			{
2864
				for (size_t i = 0; i < games.size(); ++i)
2880
				for (size_t i = 0; i < games.size(); ++i)
2865
				{
2881
				{
2866
					unsigned int g = CBaseFile::GetGameFromString(games[i].toString());
2882
					unsigned int g = CBaseFile::GetGameFromString(games[i].toString());
2867
					Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2883
					Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2868
					this->addAutoExport(g, filename.toString());
2884
					this->addAutoExport(g, filename.toString());
2869
				}
2885
				}
2870
			}
2886
			}
2871
		}
2887
		}
2872
		else
2888
		else
2873
		{
2889
		{
2874
			unsigned int g = CBaseFile::GetGameFromString(game.toString());
2890
			unsigned int g = CBaseFile::GetGameFromString(game.toString());
2875
			Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2891
			Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
2876
			this->addAutoExport(g, filename.toString());
2892
			this->addAutoExport(g, filename.toString());
2877
		}
2893
		}
2878
	}
2894
	}
2879
	else if (sFirst.Compare(L"Extract"))
2895
	else if (sFirst.Compare(L"Extract"))
2880
	{
2896
	{
2881
		Utils::WString game = sRest.word(1);
2897
		Utils::WString game = sRest.word(1);
2882
		Utils::WString dir = CDirIO(sRest.words(2)).dir();
2898
		Utils::WString dir = CDirIO(sRest.words(2)).dir();
2883
		if (game.contains(L"|"))
2899
		if (game.contains(L"|"))
Line 2989... Line 3005...
2989
					C_File *newfile = this->appendFile(file, filetype, addGame, packed, dir);
3005
					C_File *newfile = this->appendFile(file, filetype, addGame, packed, dir);
2990
					if (newfile && progress)
3006
					if (newfile && progress)
2991
						progress->UpdateFile(newfile);
3007
						progress->UpdateFile(newfile);
2992
					if ( newfile )
3008
					if ( newfile )
2993
						newfile->SetShared(shared);
3009
						newfile->SetShared(shared);
2994
				}
3010
				}
2995
			}
3011
			}
2996
		}
3012
		}
2997
	}
3013
	}
2998
	else
3014
	else
2999
	{
3015
	{
3000
		unsigned int addGame = game;
3016
		unsigned int addGame = game;
Line 3064... Line 3080...
3064
	return NULL;
3080
	return NULL;
3065
}
3081
}
3066
 
3082
 
3067
 
3083
 
3068
void CBaseFile::convertNormalMod(C_File *f, const Utils::String &to) const
3084
void CBaseFile::convertNormalMod(C_File *f, const Utils::String &to) const
3069
{
3085
{
3070
	C_File *match = this->findMatchingMod(f);
3086
	C_File *match = this->findMatchingMod(f);
3071
	if ( match )
3087
	if ( match )
3072
	{
3088
	{
3073
		// file link
3089
		// file link
3074
		if ( !match->GetData() )
3090
		if ( !match->GetData() )
3075
			match->ReadFromFile();
3091
			match->ReadFromFile();
3076
		match->changeBaseName(to);
3092
		match->changeBaseName(to);
3077
	}
3093
	}
3078
 
3094
 
3079
	// file link
3095
	// file link
3080
	if ( !f->GetData() )
3096
	if ( !f->GetData() )
3081
		f->ReadFromFile();
3097
		f->ReadFromFile();
3082
 
3098
 
3083
	f->changeBaseName(to);
3099
	f->changeBaseName(to);
3084
}
3100
}
3085
 
3101
 
3086
void CBaseFile::convertAutoText(C_File *f) const
3102
void CBaseFile::convertAutoText(C_File *f) const
3087
{
3103
{
3088
	Utils::WString to;
3104
	Utils::WString to;
3089
	if ( f->baseName().contains(L"-L") )
3105
	if ( f->baseName().contains(L"-L") )
3090
		to = L"0000-L" + f->baseName().token(L"-L", 2);
3106
		to = L"0000-L" + f->baseName().token(L"-L", 2);
3091
	else if ( f->baseName().contains("-l") )
3107
	else if ( f->baseName().contains("-l") )
3092
		to = L"0000-L" + f->baseName().token(L"-l", 2);
3108
		to = L"0000-L" + f->baseName().token(L"-l", 2);
Line 3094... Line 3110...
3094
		to = f->baseName().left(-4) + L"0000";
3110
		to = f->baseName().left(-4) + L"0000";
3095
 
3111
 
3096
	// file link
3112
	// file link
3097
	if ( !f->GetData() )
3113
	if ( !f->GetData() )
3098
		f->ReadFromFile();
3114
		f->ReadFromFile();
3099
 
3115
 
3100
	f->changeBaseName(to);
3116
	f->changeBaseName(to);
3101
}
3117
}
3102
 
3118
 
3103
void CBaseFile::convertFakePatch(C_File *f) const
3119
void CBaseFile::convertFakePatch(C_File *f) const
3104
{
3120
{
3105
	// find next available fake patch
3121
	// find next available fake patch
3106
	int num = 0;
3122
	int num = 0;
3107
 
3123
 
3108
	bool found = true;
3124
	bool found = true;
3109
	while ( found )
3125
	while ( found )
3110
	{
3126
	{
3111
		++num;
3127
		++num;
3112
		found = false;
3128
		found = false;
Line 3125... Line 3141...
3125
		}
3141
		}
3126
	}
3142
	}
3127
 
3143
 
3128
	Utils::String to = Utils::String::PadNumber(num, 2);
3144
	Utils::String to = Utils::String::PadNumber(num, 2);
3129
	C_File *match = this->findMatchingMod(f);
3145
	C_File *match = this->findMatchingMod(f);
3130
 
3146
 
3131
	// file link
3147
	// file link
3132
	if ( !f->GetData() )
3148
	if ( !f->GetData() )
3133
		f->ReadFromFile();
3149
		f->ReadFromFile();
3134
 
3150
 
3135
	f->changeBaseName(to);
3151
	f->changeBaseName(to);
Line 3171... Line 3187...
3171
	// need to edit the file
3187
	// need to edit the file
3172
	if (f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL)
3188
	if (f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL)
3173
		f->renameScript(baseName);
3189
		f->renameScript(baseName);
3174
 
3190
 
3175
	f->changeBaseName(baseName);
3191
	f->changeBaseName(baseName);
3176
}
-
 
3177
 
-
 
3178
void CBaseFile::addWebMirror(const Utils::String& str) 
-
 
3179
{ 
-
 
3180
	if (!_lMirrors.contains(str))
-
 
3181
	{
-
 
3182
		_lMirrors.pushBack(str, "");
-
 
3183
		_changed();
-
 
3184
	}
-
 
3185
}
-
 
3186
 
-
 
3187
void CBaseFile::removeWebMirror(const Utils::String& str) 
-
 
3188
{ 
-
 
3189
	_lMirrors.remove(str, true); 
-
 
3190
	_changed(); 
-
 
3191
}
3192
}
3192
 
3193
 
3193
Utils::WString CBaseFile::createUpdateFile(const Utils::WString &dir) const
3194
Utils::WString CBaseFile::createUpdateFile(const Utils::WString &dir) const
3194
{
3195
{
3195
	Utils::WString file = this->getNameValidFile() + L"_" + this->author() + L".dat";
3196
	Utils::WString file = this->getNameValidFile() + L"_" + this->author() + L".dat";