Subversion Repositories spk

Rev

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

Rev 209 Rev 210
Line 197... Line 197...
197
 
197
 
198
int CBaseFile::CheckFile(const Utils::WString &filename, float *version )
198
int CBaseFile::CheckFile(const Utils::WString &filename, float *version )
199
{
199
{
200
	CFileIO File(filename);
200
	CFileIO File(filename);
201
	if ( !File.startRead() ) return 0;
201
	if ( !File.startRead() ) return 0;
202
	Utils::String line = File.readEndOfLineStr();
202
	Utils::WString line = File.readEndOfLine();
203
	Utils::String type = line.token(";", 1);
203
	Utils::WString type = line.token(L";", 1);
204
	File.close();
204
	File.close();
205
 
205
 
206
	// check for old version
206
	// check for old version
207
	if ( line.left(3) == "HiP" ) return SPKFILE_OLD;
207
	if ( line.left(3) == L"HiP" ) return SPKFILE_OLD;
208
 
208
 
209
	// check for format
209
	// check for format
210
	if ( version ) *version = line.token(";", 2);
210
	if ( version ) *version = line.token(L";", 2);
211
 
211
 
212
	if ( type == "BaseCycrow" )	return SPKFILE_BASE;
212
	if ( type == L"BaseCycrow" )	return SPKFILE_BASE;
213
	if ( type == "SPKCycrow" )	return SPKFILE_SINGLE;
213
	if ( type == L"SPKCycrow" )	return SPKFILE_SINGLE;
214
	if ( type == "XSPCycrow" )	return SPKFILE_SINGLESHIP;
214
	if ( type == L"XSPCycrow" )	return SPKFILE_SINGLESHIP;
215
	if ( type == "MSPKCycrow" )	return SPKFILE_MULTI;
215
	if ( type == L"MSPKCycrow" )	return SPKFILE_MULTI;
216
	return SPKFILE_INVALID;
216
	return SPKFILE_INVALID;
217
}
217
}
218
 
218
 
219
void CBaseFile::ClearFileData()
219
void CBaseFile::ClearFileData()
220
{
220
{
Line 368... Line 368...
368
	_addFile(newfile);
368
	_addFile(newfile);
369
 
369
 
370
	return newfile;
370
	return newfile;
371
}
371
}
372
 
372
 
373
bool CBaseFile::addFileNow(const Utils::String &file, const Utils::String &dir, FileType type, CProgressInfo* progress)
373
bool CBaseFile::addFileNow(const Utils::WString &file, const Utils::WString &dir, FileType type, CProgressInfo* progress)
374
{
374
{
375
	C_File* f = addFile(file, dir, type);
375
	C_File* f = addFile(file, dir, type);
376
	if (!f->ReadFromFile())
376
	if (!f->ReadFromFile())
377
		return false;
377
		return false;
378
 
378
 
Line 449... Line 449...
449
			return f;
449
			return f;
450
	}
450
	}
451
	return NULL;
451
	return NULL;
452
}
452
}
453
 
453
 
454
bool CBaseFile::removeFile(const Utils::String& file, FileType type, const Utils::String& dir, int game)
454
bool CBaseFile::removeFile(const Utils::WString& file, FileType type, const Utils::WString& dir, int game)
455
{
455
{
456
	C_File* f = findFile(file, type, dir, game);
456
	C_File* f = findFile(file, type, dir, game);
457
	if (!f)
457
	if (!f)
458
		return false;
458
		return false;
459
	return removeFile(f);
459
	return removeFile(f);
Line 1015... Line 1015...
1015
	}
1015
	}
1016
 
1016
 
1017
	return true;
1017
	return true;
1018
}
1018
}
1019
 
1019
 
1020
Utils::String CBaseFile::_install_adjustFilepointer(C_File *pFile, bool bEnabled, const Utils::WString &sDestination)
1020
Utils::WString CBaseFile::_install_adjustFilepointer(C_File *pFile, bool bEnabled, const Utils::WString &sDestination)
1021
{
1021
{
1022
	Utils::WString filename = sDestination;
1022
	Utils::WString filename = sDestination;
1023
	if ( !filename.empty() ) filename += L"/";
1023
	if ( !filename.empty() ) filename += L"/";
1024
 
1024
 
1025
	if ( (IsPatch()) && (pFile->fileType() == FILETYPE_MOD) )
1025
	if ( (IsPatch()) && (pFile->fileType() == FILETYPE_MOD) )
Line 1049... Line 1049...
1049
		pFile->SetDisabled(true);
1049
		pFile->SetDisabled(true);
1050
	}
1050
	}
1051
 
1051
 
1052
	CLog::logf(CLog::Log_Install, 2, "Adjusting the file pointer to correct install destintation, %s", pFile->filePointer().c_str());
1052
	CLog::logf(CLog::Log_Install, 2, "Adjusting the file pointer to correct install destintation, %s", pFile->filePointer().c_str());
1053
 
1053
 
1054
	return filename.toString();
1054
	return filename;
1055
}
1055
}
1056
 
1056
 
1057
C_File *CBaseFile::_install_checkFile(C_File *pFile, Utils::WStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
1057
C_File *CBaseFile::_install_checkFile(C_File *pFile, Utils::WStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
1058
{
1058
{
1059
	if ( !pFile->IsFakePatch() && pFile->GetFileType() != FILETYPE_README )
1059
	if ( !pFile->IsFakePatch() && pFile->GetFileType() != FILETYPE_README )
Line 1367... Line 1367...
1367
	Func:   ParseHeader
1367
	Func:   ParseHeader
1368
	Input:  Header String - string formated directly from the file
1368
	Input:  Header String - string formated directly from the file
1369
	Return: Boolean - If string is a valid header
1369
	Return: Boolean - If string is a valid header
1370
	Desc:   Splits up the main header string to get all required settings
1370
	Desc:   Splits up the main header string to get all required settings
1371
*/
1371
*/
1372
bool CBaseFile::_parseHeader(const Utils::String &header)
1372
bool CBaseFile::_parseHeader(const Utils::WString &header)
1373
{
1373
{
1374
	if ( !this->_checkHeader(header.token(";", 1)))
1374
	if ( !this->_checkHeader(header.token(L";", 1)))
1375
		return false;
1375
		return false;
1376
 
1376
 
1377
	m_SHeader.fVersion = header.token(";", 2).toFloat();
1377
	m_SHeader.fVersion = header.token(L";", 2).toFloat();
1378
	if ( m_SHeader.fVersion > FILEVERSION )
1378
	if ( m_SHeader.fVersion > FILEVERSION )
1379
		return false;
1379
		return false;
1380
 
1380
 
1381
	m_SHeader.iValueCompression = header.token(";", 3).toInt();
1381
	m_SHeader.iValueCompression = header.token(L";", 3).toInt();
1382
	m_SHeader.lValueCompressSize = header.token(";", 4).toLong();
1382
	m_SHeader.lValueCompressSize = header.token(L";", 4).toLong();
1383
 
1383
 
1384
	return true;
1384
	return true;
1385
}
1385
}
1386
 
1386
 
1387
bool CBaseFile::_checkHeader(const Utils::String header) const
1387
bool CBaseFile::_checkHeader(const Utils::WString &header) const
1388
{
1388
{
1389
	if ( header.Compare("BaseCycrow") )
1389
	if ( header.Compare(L"BaseCycrow") )
1390
		return true;
1390
		return true;
1391
	return false;
1391
	return false;
1392
}
1392
}
1393
 
1393
 
1394
/*
1394
/*
1395
	Func:   ParseFileHeader
1395
	Func:   ParseFileHeader
1396
	Input:  Header String - string formated directly from the file
1396
	Input:  Header String - string formated directly from the file
1397
	Return: Boolean - If string is a valid header
1397
	Return: Boolean - If string is a valid header
1398
	Desc:   Splits up the file header string to get all required settings
1398
	Desc:   Splits up the file header string to get all required settings
1399
*/
1399
*/
1400
bool CBaseFile::_parseFileHeader(const Utils::String &header)
1400
bool CBaseFile::_parseFileHeader(const Utils::WString &header)
1401
{
1401
{
1402
	if (header.token(";", 1) != "FileHeader")
1402
	if (header.token(L";", 1) != L"FileHeader")
1403
		return false;
1403
		return false;
1404
 
1404
 
1405
	m_SHeader2.iNumFiles = header.token(";", 2).toInt();
1405
	m_SHeader2.iNumFiles = header.token(L";", 2).toInt();
1406
	m_SHeader2.lSize = header.token(";", 3).toInt();
1406
	m_SHeader2.lSize = header.token(L";", 3).toInt();
1407
	m_SHeader2.lFullSize = header.token(";", 4).toInt();
1407
	m_SHeader2.lFullSize = header.token(L";", 4).toInt();
1408
	m_SHeader2.iFileCompression = header.token(";", 5).toInt();
1408
	m_SHeader2.iFileCompression = header.token(L";", 5).toInt();
1409
	m_SHeader2.iDataCompression = header.token(";", 6).toInt();
1409
	m_SHeader2.iDataCompression = header.token(L";", 6).toInt();
1410
 
1410
 
1411
	return true;
1411
	return true;
1412
}
1412
}
1413
 
1413
 
1414
 
1414
 
Line 1506... Line 1506...
1506
	Func:   ParseFilesLine
1506
	Func:   ParseFilesLine
1507
	Input:  String - single line from a file to set
1507
	Input:  String - single line from a file to set
1508
	Return: Boolean - returns true if value exists
1508
	Return: Boolean - returns true if value exists
1509
	Desc:   Reads the line and assigns the parameters for the file
1509
	Desc:   Reads the line and assigns the parameters for the file
1510
*/
1510
*/
1511
bool CBaseFile::_parseFilesLine(const Utils::String &line)
1511
bool CBaseFile::_parseFilesLine(const Utils::WString &line)
1512
{
1512
{
1513
	if ( !line.contains(":") )
1513
	if ( !line.contains(L":") )
1514
		return false;
1514
		return false;
1515
 
1515
 
1516
	Utils::String command = line.token(":", 1);
1516
	Utils::WString command = line.token(L":", 1);
1517
 
1517
 
1518
	long size = line.token(":", 2).toInt();
1518
	long size = line.token(L":", 2).toInt();
1519
	long usize = line.token(":", 3).toInt ();
1519
	long usize = line.token(L":", 3).toInt ();
1520
	long compression = line.token(":", 4).toInt ();
1520
	long compression = line.token(L":", 4).toInt ();
1521
 
1521
 
1522
	if ( command == "Icon" )
1522
	if ( command == L"Icon" )
1523
	{
1523
	{
1524
		_sIconExt = line.token(":", 5).toWString();
1524
		_sIconExt = line.token(L":", 5);
1525
		m_pIconFile = new C_File ();
1525
		m_pIconFile = new C_File ();
1526
		m_pIconFile->SetDataSize ( size - 4 );
1526
		m_pIconFile->SetDataSize ( size - 4 );
1527
		m_pIconFile->SetDataCompression ( compression );
1527
		m_pIconFile->SetDataCompression ( compression );
1528
		m_pIconFile->SetUncompressedDataSize ( usize );
1528
		m_pIconFile->SetUncompressedDataSize ( usize );
1529
 
1529
 
1530
		return true;
1530
		return true;
1531
	}
1531
	}
1532
 
1532
 
1533
	time_t time = line.token(":", 5).toLong();
1533
	time_t time = line.token(L":", 5).toLong();
1534
	bool compressToFile = (line.token(":", 6).toInt() == 1) ? true : false;
1534
	bool compressToFile = (line.token(L":", 6).toInt() == 1) ? true : false;
1535
	Utils::String name  = line.token(":", 7);
1535
	Utils::WString name  = line.token(L":", 7);
1536
	Utils::String dir = line.token(":", 8);
1536
	Utils::WString dir = line.token(L":", 8);
1537
 
1537
 
1538
	if ( name.empty() )
1538
	if ( name.empty() )
1539
		return true;
1539
		return true;
1540
 
1540
 
1541
	bool shared = false;
1541
	bool shared = false;
1542
	if ( command.left(1) == "$" )
1542
	if ( command.left(1) == L"$" )
1543
	{
1543
	{
1544
		shared = true;
1544
		shared = true;
1545
		command.erase(0, 1);
1545
		command.erase(0, 1);
1546
	}
1546
	}
1547
 
1547
 
1548
	FileType type = FILETYPE_UNKNOWN;
1548
	FileType type = FILETYPE_UNKNOWN;
1549
	if ( command == "Script" )
1549
	if ( command == L"Script" )
1550
		type = FILETYPE_SCRIPT;
1550
		type = FILETYPE_SCRIPT;
1551
	else if ( command == "Text" )
1551
	else if ( command == L"Text" )
1552
		type = FILETYPE_TEXT;
1552
		type = FILETYPE_TEXT;
1553
	else if ( command == "Readme" )
1553
	else if ( command == L"Readme" )
1554
		type = FILETYPE_README;
1554
		type = FILETYPE_README;
1555
	else if ( command == "Map" )
1555
	else if ( command == L"Map" )
1556
		type = FILETYPE_MAP;
1556
		type = FILETYPE_MAP;
1557
	else if ( command == "Mod" )
1557
	else if ( command == L"Mod" )
1558
		type = FILETYPE_MOD;
1558
		type = FILETYPE_MOD;
1559
	else if ( command == "Uninstall" )
1559
	else if ( command == L"Uninstall" )
1560
		type = FILETYPE_UNINSTALL;
1560
		type = FILETYPE_UNINSTALL;
1561
	else if ( command == "Sound" )
1561
	else if ( command == L"Sound" )
1562
		type = FILETYPE_SOUND;
1562
		type = FILETYPE_SOUND;
1563
	else if ( command == "Mission" )
1563
	else if ( command == L"Mission" )
1564
		type = FILETYPE_MISSION;
1564
		type = FILETYPE_MISSION;
1565
	else if ( command == "Extra" )
1565
	else if ( command == L"Extra" )
1566
		type = FILETYPE_EXTRA;
1566
		type = FILETYPE_EXTRA;
1567
	else if ( command == "Screen" )
1567
	else if ( command == L"Screen" )
1568
		type = FILETYPE_SCREEN;
1568
		type = FILETYPE_SCREEN;
1569
	else if ( command == "Backup" )
1569
	else if ( command == L"Backup" )
1570
		type = FILETYPE_BACKUP;
1570
		type = FILETYPE_BACKUP;
1571
	else if ( command == "Advert" )
1571
	else if ( command == L"Advert" )
1572
		type = FILETYPE_ADVERT;
1572
		type = FILETYPE_ADVERT;
1573
	else if ( command == "ShipScene" )
1573
	else if ( command == L"ShipScene" )
1574
		type = FILETYPE_SHIPSCENE;
1574
		type = FILETYPE_SHIPSCENE;
1575
	else if ( command == "CockpitScene" )
1575
	else if ( command == L"CockpitScene" )
1576
		type = FILETYPE_COCKPITSCENE;
1576
		type = FILETYPE_COCKPITSCENE;
1577
	else if ( command == "ShipOther" )
1577
	else if ( command == L"ShipOther" )
1578
		type = FILETYPE_SHIPOTHER;
1578
		type = FILETYPE_SHIPOTHER;
1579
	else if ( command == "ShipModel" )
1579
	else if ( command == L"ShipModel" )
1580
		type = FILETYPE_SHIPMODEL;
1580
		type = FILETYPE_SHIPMODEL;
1581
 
1581
 
1582
	if (type == FILETYPE_UNKNOWN)
1582
	if (type == FILETYPE_UNKNOWN)
1583
		return false;
1583
		return false;
1584
 
1584
 
1585
	C_File *file = new C_File();
1585
	C_File *file = new C_File();
1586
 
1586
 
1587
	if (dir.left(5).Compare("GAME_")) {
1587
	if (dir.left(5).Compare(L"GAME_")) {
1588
		unsigned int iGame = dir.token("_", 2).toInt();
1588
		unsigned int iGame = dir.token(L"_", 2).toInt();
1589
		if (!iGame)
1589
		if (!iGame)
1590
			file->setGame(0);
1590
			file->setGame(0);
1591
		else
1591
		else
1592
			file->setGame(1 << 31 | 1 << iGame);
1592
			file->setGame(1 << 31 | 1 << iGame);
1593
		dir = Utils::String::Null();
1593
		dir = Utils::WString::Null();
1594
	} 
1594
	} 
1595
	else if ( line.countToken(":") >= 9 ) 
1595
	else if ( line.countToken(L":") >= 9 ) 
1596
	{
1596
	{
1597
		Utils::String game = line.token(":", 9);
1597
		Utils::WString game = line.token(L":", 9);
1598
		if (game.contains("_"))
1598
		if (game.contains(L"_"))
1599
		{
1599
		{
1600
			unsigned int iGame = game.token("_", 2).toInt();
1600
			unsigned int iGame = game.token(L"_", 2).toInt();
1601
			if (iGame)
1601
			if (iGame)
1602
				file->setGame(1 << 31 | 1 << iGame);
1602
				file->setGame(1 << 31 | 1 << iGame);
1603
			else
1603
			else
1604
				file->setGame(0);
1604
				file->setGame(0);
1605
		}
1605
		}
Line 1613... Line 1613...
1613
			else
1613
			else
1614
				file->setGame(1 << 31 | 1 << iGame);
1614
				file->setGame(1 << 31 | 1 << iGame);
1615
		}
1615
		}
1616
	}
1616
	}
1617
 
1617
 
1618
	if (dir.Compare("NULL")) {
1618
	if (dir.Compare(L"NULL")) {
1619
		dir = Utils::String::Null();
1619
		dir = Utils::WString::Null();
1620
	}
1620
	}
1621
 
1621
 
1622
	file->setFileType(type);
1622
	file->setFileType(type);
1623
	file->SetCreationTime ( time );
1623
	file->SetCreationTime ( time );
1624
	file->setName(name);
1624
	file->setName(name);
Line 1658... Line 1658...
1658
	Input:  filename - the name of the file to open and read
1658
	Input:  filename - the name of the file to open and read
1659
			readdata - If falses, dont read the files to memory, just read the headers and values
1659
			readdata - If falses, dont read the files to memory, just read the headers and values
1660
	Return: boolean - return ture if acceptable format
1660
	Return: boolean - return ture if acceptable format
1661
	Desc:   Opens and reads the spk file and loads all data into class
1661
	Desc:   Opens and reads the spk file and loads all data into class
1662
*/
1662
*/
1663
bool CBaseFile::readFile(const Utils::String &filename, int readtype, CProgressInfo *progress)
1663
bool CBaseFile::readFile(const Utils::WString &filename, int readtype, CProgressInfo *progress)
1664
{
1664
{
1665
	CFileIO File(filename);
1665
	CFileIO File(filename);
1666
	if ( !File.startRead() ) return false;
1666
	if ( !File.startRead() ) return false;
1667
 
1667
 
1668
	bool ret = this->readFile(File, readtype, progress);
1668
	bool ret = this->readFile(File, readtype, progress);
Line 1877... Line 1877...
1877
 
1877
 
1878
	return true;
1878
	return true;
1879
}
1879
}
1880
 
1880
 
1881
bool CBaseFile::IsMod()
1881
bool CBaseFile::IsMod()
1882
{
1882
{
1883
	// check for any mod files that are not fake patchs
1883
	// check for any mod files that are not fake patchs
1884
	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
1884
	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
1885
	{
1885
	{
1886
		C_File *f = fNode->Data();
1886
		C_File *f = fNode->Data();
1887
		if ( f->GetFileType() != FILETYPE_MOD )
1887
		if ( f->GetFileType() != FILETYPE_MOD )
1888
			continue;
1888
			continue;
1889
 
1889
 
1890
		if ( !f->IsFakePatch() )
1890
		if ( !f->IsFakePatch() )
1891
			return true;
1891
			return true;
1892
	}
1892
	}
Line 1939... Line 1939...
1939
			values += Utils::WString(L"GameCompat: ") + (long)gc->Data()->iGame + L" " + (long)gc->Data()->iVersion + L"\n";
1939
			values += Utils::WString(L"GameCompat: ") + (long)gc->Data()->iGame + L" " + (long)gc->Data()->iVersion + L"\n";
1940
	}
1940
	}
1941
 
1941
 
1942
	if (computeSigned(true))
1942
	if (computeSigned(true))
1943
		values += L"Signed\n";
1943
		values += L"Signed\n";
1944
 
1944
 
1945
	for ( int j = 0; j < 2; j++ ) {
1945
	for ( int j = 0; j < 2; j++ ) {
1946
		const CInstallText *text;
1946
		const CInstallText *text;
1947
		Utils::WString textStart;
1947
		Utils::WString textStart;
1948
		switch(j) {
1948
		switch(j) {
1949
			case 0:	textStart = L"Uninstall"; text = this->uninstallText(); break;
1949
			case 0:	textStart = L"Uninstall"; text = this->uninstallText(); break;
1950
			case 1: textStart = L"Install"; text = this->installText(); break;
1950
			case 1: textStart = L"Install"; text = this->installText(); break;
1951
		}
1951
		}
1952
		for ( unsigned int i = 0; i < text->count(); i++ ) {
1952
		for ( unsigned int i = 0; i < text->count(); i++ ) {
1953
			int iLang = text->language(i);
1953
			int iLang = text->language(i);
1954
			if ( !text->getBefore(iLang).empty() ) values += textStart + L"Before: " + (long)iLang + L"|" + text->getBefore(iLang) + L"\n";
1954
			if ( !text->getBefore(iLang).empty() ) values += textStart + L"Before: " + (long)iLang + L"|" + text->getBefore(iLang) + L"\n";
1955
			if ( !text->getAfter(iLang).empty() ) values += textStart + L"After: " + (long)iLang + L"|" + text->getAfter(iLang) + L"\n";
1955
			if ( !text->getAfter(iLang).empty() ) values += textStart + L"After: " + (long)iLang + L"|" + text->getAfter(iLang) + L"\n";
1956
		}
1956
		}
Line 1970... Line 1970...
1970
 
1970
 
1971
	for (auto itr = _lFakePatchBefore.begin(); itr != _lFakePatchBefore.end(); itr++)
1971
	for (auto itr = _lFakePatchBefore.begin(); itr != _lFakePatchBefore.end(); itr++)
1972
		values += L"FakePatchBefore: " + (*itr)->str + L"||" + (*itr)->data + L"\n";
1972
		values += L"FakePatchBefore: " + (*itr)->str + L"||" + (*itr)->data + L"\n";
1973
	for (auto itr = _lFakePatchAfter.begin(); itr != _lFakePatchAfter.end(); itr++)
1973
	for (auto itr = _lFakePatchAfter.begin(); itr != _lFakePatchAfter.end(); itr++)
1974
		values += L"FakePatchAfter: " + (*itr)->str + L"||" + (*itr)->data + L"\n";
1974
		values += L"FakePatchAfter: " + (*itr)->str + L"||" + (*itr)->data + L"\n";
1975
 
1975
 
1976
	values += Utils::WString(L"PluginType: ") + (long)this->pluginType() + L"\n";
1976
	values += Utils::WString(L"PluginType: ") + (long)this->pluginType() + L"\n";
1977
 
1977
 
1978
	return values;
1978
	return values;
1979
}
1979
}
1980
 
1980
 
Line 1982... Line 1982...
1982
/*
1982
/*
1983
	Func:   WriteFile
1983
	Func:   WriteFile
1984
	Input:  filename - The filename of the spk file to write to
1984
	Input:  filename - The filename of the spk file to write to
1985
	Desc:   Writes the data to an spk file
1985
	Desc:   Writes the data to an spk file
1986
*/
1986
*/
1987
bool CBaseFile::writeFile(const Utils::String &filename, CProgressInfo *progress) const
1987
bool CBaseFile::writeFile(const Utils::WString &filename, CProgressInfo *progress) const
1988
{
1988
{
1989
	CFileIO File(filename);
1989
	CFileIO File(filename);
1990
	if ( File.startWrite() ) return writeData(File, progress);
1990
	if ( File.startWrite() ) return writeData(File, progress);
1991
	return false;
1991
	return false;
1992
}
1992
}
Line 2032... Line 2032...
2032
	{
2032
	{
2033
		valueComprLen = valueUncomprLen;
2033
		valueComprLen = valueUncomprLen;
2034
		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
2034
		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
2035
		memcpy ( valueCompr, (const unsigned char *)data, valueComprLen );
2035
		memcpy ( valueCompr, (const unsigned char *)data, valueComprLen );
2036
		valueheader = SPKCOMPRESS_NONE;
2036
		valueheader = SPKCOMPRESS_NONE;
2037
	}
2037
	}
2038
 
2038
 
2039
	// write the main header to the file
2039
	// write the main header to the file
2040
	if ( !this->writeHeader(file, valueheader, valueComprLen) )	return false;
2040
	if ( !this->writeHeader(file, valueheader, valueComprLen) )	return false;
2041
 
2041
 
2042
	// write the compressed data to file
2042
	// write the compressed data to file
2043
	file.put(static_cast<unsigned char>(valueUncomprLen >> 24));
2043
	file.put(static_cast<unsigned char>(valueUncomprLen >> 24));
Line 2129... Line 2129...
2129
			}
2129
			}
2130
 
2130
 
2131
			if ( progress ) progress->IncDone((int)writeSize);
2131
			if ( progress ) progress->IncDone((int)writeSize);
2132
		}
2132
		}
2133
	}
2133
	}
2134
 
2134
 
2135
	return true;
2135
	return true;
2136
}
-
 
2137
 
-
 
2138
bool CBaseFile::extractFile(C_File *file, const Utils::String &dir, bool includedir, CProgressInfo *progress)
-
 
2139
{
-
 
2140
	if (ReadFileToMemory(file))
-
 
2141
	{
-
 
2142
		// now finally, uncompress the file
-
 
2143
		long len = 0;
-
 
2144
		unsigned char *data = file->UncompressData(&len, progress);
-
 
2145
		if (!data)
-
 
2146
		{
-
 
2147
			// attempt a file decompress
-
 
2148
			if (file->GetCompressionType() == SPKCOMPRESS_7ZIP)
-
 
2149
			{
-
 
2150
				if (file->uncompressToFile(dir, this, includedir, progress))
-
 
2151
					return true;
-
 
2152
			}
-
 
2153
			return false;
-
 
2154
		}
-
 
2155
 
-
 
2156
		if (!file->writeToDir(dir, this, includedir, Utils::String::Null(), data, len))
-
 
2157
			return false;
-
 
2158
 
-
 
2159
		return true;
-
 
2160
 
-
 
2161
	}
-
 
2162
	else
-
 
2163
		return false;
-
 
2164
}
2136
}
-
 
2137
 
-
 
2138
bool CBaseFile::extractFile(C_File *file, const Utils::WString &dir, bool includedir, CProgressInfo *progress)
-
 
2139
{
-
 
2140
	if (ReadFileToMemory(file))
-
 
2141
	{
-
 
2142
		// now finally, uncompress the file
-
 
2143
		long len = 0;
-
 
2144
		unsigned char *data = file->UncompressData(&len, progress);
-
 
2145
		if (!data)
-
 
2146
		{
-
 
2147
			// attempt a file decompress
-
 
2148
			if (file->GetCompressionType() == SPKCOMPRESS_7ZIP)
-
 
2149
			{
-
 
2150
				if (file->uncompressToFile(dir, this, includedir, progress))
-
 
2151
					return true;
-
 
2152
			}
-
 
2153
			return false;
-
 
2154
		}
-
 
2155
 
-
 
2156
		if (!file->writeToDir(dir, this, includedir, Utils::WString::Null(), data, len))
-
 
2157
			return false;
-
 
2158
 
-
 
2159
		return true;
-
 
2160
 
-
 
2161
	}
-
 
2162
	else
-
 
2163
		return false;
-
 
2164
}
2165
bool CBaseFile::extractFile(C_File *file, const Utils::String &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
2165
bool CBaseFile::extractFile(C_File *file, const Utils::WString &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
2166
{
2166
{
2167
	if (ReadFileToMemory(file))
2167
	if (ReadFileToMemory(file))
2168
	{
2168
	{
2169
		CDirIO Dir(dir);
2169
		CDirIO Dir(dir);
2170
		Utils::WString addonDir;
2170
		Utils::WString addonDir;
Line 2189... Line 2189...
2189
		if (!data)
2189
		if (!data)
2190
		{
2190
		{
2191
			// attempt a file decompress
2191
			// attempt a file decompress
2192
			if (file->GetCompressionType() == SPKCOMPRESS_7ZIP)
2192
			if (file->GetCompressionType() == SPKCOMPRESS_7ZIP)
2193
			{
2193
			{
2194
				if (file->uncompressToFile(Dir.dir().toString(), this, includedir, progress))
2194
				if (file->uncompressToFile(Dir.dir(), this, includedir, progress))
2195
					return true;
2195
					return true;
2196
			}
2196
			}
2197
			return false;
2197
			return false;
2198
		}
2198
		}
2199
 
2199
 
2200
		if (!file->writeToDir(Dir.dir().toString(), this, includedir, Utils::String::Null(), data, len))
2200
		if (!file->writeToDir(Dir.dir(), this, includedir, Utils::WString::Null(), data, len))
2201
			return false;
2201
			return false;
2202
 
2202
 
2203
		return true;
2203
		return true;
2204
 
2204
 
2205
	}
2205
	}
2206
	else
2206
	else
2207
		return false;
2207
		return false;
2208
}
2208
}
2209
 
2209
 
2210
bool CBaseFile::extractFile(int filenum, const Utils::String &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
2210
bool CBaseFile::extractFile(int filenum, const Utils::WString &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
2211
{
2211
{
2212
	// invalid valus
2212
	// invalid valus
2213
	if (filenum < 0)
2213
	if (filenum < 0)
2214
		return false;
2214
		return false;
2215
	// out of range
2215
	// out of range
2216
	if (filenum > m_lFiles.size())
2216
	if (filenum > m_lFiles.size())
2217
		return false;
2217
		return false;
2218
 
2218
 
2219
	// get the file pointer
2219
	// get the file pointer
2220
	C_File *file = m_lFiles.Get(filenum);
2220
	C_File *file = m_lFiles.Get(filenum);
2221
	return extractFile(file, dir, game, gameAddons, includedir, progress);
2221
	return extractFile(file, dir, game, gameAddons, includedir, progress);
2222
}
2222
}
2223
 
2223
 
2224
bool CBaseFile::extractFile(int filenum, const Utils::String &dir, bool includedir, CProgressInfo *progress)
2224
bool CBaseFile::extractFile(int filenum, const Utils::WString &dir, bool includedir, CProgressInfo *progress)
2225
{
2225
{
2226
	// invalid valus
2226
	// invalid valus
2227
	if (filenum < 0)
2227
	if (filenum < 0)
2228
		return false;
2228
		return false;
2229
	// out of range
2229
	// out of range
2230
	if (filenum > m_lFiles.size())
2230
	if (filenum > m_lFiles.size())
2231
		return false;
2231
		return false;
2232
 
2232
 
2233
	// get the file pointer
2233
	// get the file pointer
2234
	C_File *file = m_lFiles.Get(filenum);
2234
	C_File *file = m_lFiles.Get(filenum);
2235
	return extractFile(file, dir, includedir, progress);
2235
	return extractFile(file, dir, includedir, progress);
2236
}
2236
}
2237
 
2237
 
2238
bool CBaseFile::extractAll(const Utils::String &dir, int game, const Utils::CStringList &gameAddons, bool includedir, CProgressInfo *progress)
2238
bool CBaseFile::extractAll(const Utils::WString &dir, int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
2239
{
2239
{
2240
	// no file to read from
2240
	// no file to read from
2241
	if (this->filename().empty())
2241
	if (this->filename().empty())
2242
		return false;
2242
		return false;
2243
 
2243
 
Line 2266... Line 2266...
2266
 
2266
 
2267
		if (progress)	
2267
		if (progress)	
2268
			progress->UpdateFile(fit);
2268
			progress->UpdateFile(fit);
2269
 
2269
 
2270
		CDirIO Dir(dir);
2270
		CDirIO Dir(dir);
2271
		Utils::String addonDir;
2271
		Utils::WString addonDir;
2272
		if (fit->isFileInAddon())
2272
		if (fit->isFileInAddon())
2273
		{
2273
		{
2274
			int addonGame = fit->getForSingleGame();
2274
			int addonGame = fit->getForSingleGame();
2275
			if (!addonGame) addonGame = game;
2275
			if (!addonGame) addonGame = game;
2276
 
2276
 
2277
			if (addonGame > 0)
2277
			if (addonGame > 0)
2278
				addonDir = gameAddons.findString(Utils::String::Number(addonGame));
2278
				addonDir = gameAddons.findString(Utils::WString::Number(addonGame));
2279
		}
2279
		}
2280
 
2280
 
2281
		if (!addonDir.empty())
2281
		if (!addonDir.empty())
2282
			Dir.cd(addonDir);
2282
			Dir.cd(addonDir);
2283
 
2283
 
Line 2285... Line 2285...
2285
		Dir.create(fit->getDirectory(this));
2285
		Dir.create(fit->getDirectory(this));
2286
 
2286
 
2287
		long size = 0;
2287
		long size = 0;
2288
		unsigned char *data = fit->UncompressData(&size, progress);
2288
		unsigned char *data = fit->UncompressData(&size, progress);
2289
		if ((!data) && (fit->GetCompressionType() == SPKCOMPRESS_7ZIP)) {
2289
		if ((!data) && (fit->GetCompressionType() == SPKCOMPRESS_7ZIP)) {
2290
			if (!fit->uncompressToFile(Dir.dir().toString(), this, includedir, progress)) return false;
2290
			if (!fit->uncompressToFile(Dir.dir(), this, includedir, progress)) return false;
2291
		}
2291
		}
2292
		else if ((!data) || (!fit->writeToDir(Dir.dir().toString(), this, includedir, Utils::String::Null(), data, size))) return false;
2292
		else if ((!data) || (!fit->writeToDir(Dir.dir(), this, includedir, Utils::WString::Null(), data, size))) return false;
2293
	}
2293
	}
2294
 
2294
 
2295
	delete File;
2295
	delete File;
2296
	return true;
2296
	return true;
2297
}
2297
}
Line 2423... Line 2423...
2423
 
2423
 
2424
	if ( !version.empty() )	this->addNeededLibrary(L"<package>", L"<author>", version);
2424
	if ( !version.empty() )	this->addNeededLibrary(L"<package>", L"<author>", version);
2425
}
2425
}
2426
 
2426
 
2427
 
2427
 
2428
bool CBaseFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile)
2428
bool CBaseFile::GeneratePackagerScript(bool wildcard, Utils::WStringList *list, int game, const Utils::WStringList &gameAddons, bool datafile)
2429
{
2429
{
2430
	list->pushBack("#");
2430
	list->pushBack(L"#");
2431
	list->pushBack("# Packager Script");
2431
	list->pushBack(L"# Packager Script");
2432
	list->pushBack("# -- Generated by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2) + " --");
2432
	list->pushBack(L"# -- Generated by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2) + L" --");
2433
	list->pushBack("#");
2433
	list->pushBack(L"#");
2434
	list->pushBack("");
2434
	list->pushBack(L"");
2435
	if ( !datafile )
2435
	if ( !datafile )
2436
	{
2436
	{
2437
		list->pushBack("# Variable for your game directory, where to get files from");
2437
		list->pushBack(L"# Variable for your game directory, where to get files from");
2438
		list->pushBack("# $PATH variable is used to get the current path");
2438
		list->pushBack(L"# $PATH variable is used to get the current path");
2439
		list->pushBack("Variable: $GAMEDIR $PATH");
2439
		list->pushBack(L"Variable: $GAMEDIR $PATH");
2440
		list->pushBack("");
2440
		list->pushBack(L"");
2441
	}
2441
	}
2442
	list->pushBack("# The name of the script");
2442
	list->pushBack(L"# The name of the script");
2443
	list->pushBack("Name: " + this->name().toString());
2443
	list->pushBack(L"Name: " + this->name());
2444
	list->pushBack("");
2444
	list->pushBack(L"");
2445
	list->pushBack("# The author of the script, ie, you");
2445
	list->pushBack(L"# The author of the script, ie, you");
2446
	list->pushBack("Author: " + this->author().toString());
2446
	list->pushBack(L"Author: " + this->author());
2447
	list->pushBack("");
2447
	list->pushBack(L"");
2448
	list->pushBack("# The creation data, when it was created");
2448
	list->pushBack(L"# The creation data, when it was created");
2449
	if ( datafile )
2449
	if ( datafile )
2450
		list->pushBack("Date: " + this->creationDate().toString());
2450
		list->pushBack(L"Date: " + this->creationDate());
2451
	else {
2451
	else {
2452
		list->pushBack("# $DATE variable is used to get the current date");
2452
		list->pushBack(L"# $DATE variable is used to get the current date");
2453
		list->pushBack("Date: $DATE");
2453
		list->pushBack(L"Date: $DATE");
2454
	}
2454
	}
2455
	list->pushBack("");
2455
	list->pushBack(L"");
2456
	list->pushBack("# The version of script");
2456
	list->pushBack(L"# The version of script");
2457
	if ( datafile )
2457
	if ( datafile )
2458
		list->pushBack("Version: " + this->version().toString());
2458
		list->pushBack(L"Version: " + this->version());
2459
	else
2459
	else
2460
	{
2460
	{
2461
		list->pushBack("# $ASK variable is used to get an input when creating");
2461
		list->pushBack(L"# $ASK variable is used to get an input when creating");
2462
		list->pushBack("Version: $ASK");
2462
		list->pushBack(L"Version: $ASK");
2463
	}
2463
	}
2464
	list->pushBack("");
2464
	list->pushBack(L"");
2465
 
2465
 
2466
	if ( !m_lGames.empty() ) {
2466
	if ( !m_lGames.empty() ) {
2467
		list->pushBack("# The game version the script is for <game> <version> (can have multiple games)");
2467
		list->pushBack(L"# The game version the script is for <game> <version> (can have multiple games)");
2468
		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
2468
		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
2469
			if (game > 0 && g->iGame != game)
2469
			if (game > 0 && g->iGame != game)
2470
				continue;
2470
				continue;
2471
 
2471
 
2472
			Utils::WString game = CBaseFile::ConvertGameToString(g->iGame);
2472
			Utils::WString game = CBaseFile::ConvertGameToString(g->iGame);
Line 2480... Line 2480...
2480
			{
2480
			{
2481
				game += L" ";
2481
				game += L" ";
2482
				game += (long)g->iVersion;
2482
				game += (long)g->iVersion;
2483
			}
2483
			}
2484
 
2484
 
2485
			list->pushBack("Game: " + game.toString());
2485
			list->pushBack(L"Game: " + game);
2486
		}
2486
		}
2487
 
2487
 
2488
		list->pushBack("");
2488
		list->pushBack(L"");
2489
	}
2489
	}
2490
 
2490
 
2491
	if ( !this->description().empty() ) {
2491
	if ( !this->description().empty() ) {
2492
		list->pushBack("# The description of the script, displays when installing");
2492
		list->pushBack(L"# The description of the script, displays when installing");
2493
		list->pushBack("Description: " + this->description().toString());
2493
		list->pushBack(L"Description: " + this->description());
2494
		list->pushBack("");
2494
		list->pushBack(L"");
2495
	}
2495
	}
2496
 
2496
 
2497
	if ( !this->webSite().empty() ) {
2497
	if ( !this->webSite().empty() ) {
2498
		list->pushBack("# A link to the website for the script, ie for an online help page");
2498
		list->pushBack(L"# A link to the website for the script, ie for an online help page");
2499
		list->pushBack("WebSite: " + this->webSite().toString());
2499
		list->pushBack(L"WebSite: " + this->webSite());
2500
		list->pushBack("");
2500
		list->pushBack(L"");
2501
	}
2501
	}
2502
 
2502
 
2503
	if ( !this->forumLink().empty() ) {
2503
	if ( !this->forumLink().empty() ) {
2504
		list->pushBack("# A direct link to the thread in the egosoft forum");
2504
		list->pushBack(L"# A direct link to the thread in the egosoft forum");
2505
		list->pushBack("ForumLink: " + this->forumLink().toString());
2505
		list->pushBack(L"ForumLink: " + this->forumLink());
2506
		list->pushBack("");
2506
		list->pushBack(L"");
2507
	}
2507
	}
2508
 
2508
 
2509
	if ( !this->webAddress().empty() ) {
2509
	if ( !this->webAddress().empty() ) {
2510
		list->pushBack("# A link to the address for the update file");
2510
		list->pushBack(L"# A link to the address for the update file");
2511
		list->pushBack("WebAddress: " + this->webAddress().toString());
2511
		list->pushBack(L"WebAddress: " + this->webAddress());
2512
		list->pushBack("");
2512
		list->pushBack(L"");
2513
	}
2513
	}
2514
 
2514
 
2515
	if ( !this->email().empty() ) {
2515
	if ( !this->email().empty() ) {
2516
		list->pushBack("# The email address of the author, to allow users to contract if needed");
2516
		list->pushBack(L"# The email address of the author, to allow users to contract if needed");
2517
		list->pushBack("Email: " + this->email().toString());
2517
		list->pushBack(L"Email: " + this->email());
2518
		list->pushBack("");
2518
		list->pushBack(L"");
2519
	}
2519
	}
2520
 
2520
 
2521
	if (webMirrors().size())
2521
	if (webMirrors().size())
2522
	{
2522
	{
2523
		list->pushBack("# A link to the mirror address for the update file, can have many of these");
2523
		list->pushBack(L"# A link to the mirror address for the update file, can have many of these");
2524
		for(auto itr = webMirrors().begin(); itr != webMirrors().end(); itr++)
2524
		for(auto itr = webMirrors().begin(); itr != webMirrors().end(); itr++)
2525
			list->pushBack(Utils::String("WebMirror: ") + (*itr)->str.toString());
2525
			list->pushBack(Utils::WString(L"WebMirror: ") + (*itr)->str);
2526
		list->pushBack("");
2526
		list->pushBack(L"");
2527
	}
2527
	}
2528
 
2528
 
2529
	if ( m_bAutoGenerateUpdateFile )
2529
	if ( m_bAutoGenerateUpdateFile )
2530
	{
2530
	{
2531
		list->pushBack("# Auto generate the package update file when created");
2531
		list->pushBack(L"# Auto generate the package update file when created");
2532
		list->pushBack("GenerateUpdateFile");
2532
		list->pushBack(L"GenerateUpdateFile");
2533
	}
2533
	}
2534
 
2534
 
2535
	if ( m_lNeededLibrarys.size() )
2535
	if ( m_lNeededLibrarys.size() )
2536
	{
2536
	{
2537
		list->pushBack("# Needed Library dependacies, require these to be installed");
2537
		list->pushBack(L"# Needed Library dependacies, require these to be installed");
2538
		for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
2538
		for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
2539
			list->pushBack((L"Depend: " + node->Data()->sName + L"|" + node->Data()->sMinVersion + L"|" + node-&gt;Data()->sAuthor).toString());
2539
			list->pushBack(L"Depend: " + node->Data()->sName + L"|" + node->Data()->sMinVersion + L&quot;|" + node->;Data()->sAuthor);
2540
 
2540
 
2541
		list->pushBack("");
2541
		list->pushBack(L"");
2542
	}
2542
	}
2543
 
2543
 
2544
	if ( !_noRatings() )
2544
	if ( !_noRatings() )
2545
	{
2545
	{
2546
		list->pushBack("# Ratings Values, 0 to 5, <ease> <changing> <recommended>");
2546
		list->pushBack(L"# Ratings Values, 0 to 5, <ease> <changing> <recommended>");
2547
		list->pushBack(Utils::String("Ratings: ") + (long)easeOfUse() + " " + (long)gameChanging() + " " + (long)recommended());
2547
		list->pushBack(Utils::WString(L"Ratings: ") + (long)easeOfUse() + L" " + (long)gameChanging() + L" " + (long)recommended());
2548
		list->pushBack("");
2548
		list->pushBack(L"");
2549
	}
2549
	}
2550
 
2550
 
2551
	if (namesList()->size())
2551
	if (namesList()->size())
2552
	{
2552
	{
2553
		list->pushBack("# Package names, uses different names for different languages");
2553
		list->pushBack(L"# Package names, uses different names for different languages");
2554
		for(auto itr = namesList()->begin(); itr != namesList()->end(); itr++)
2554
		for(auto itr = namesList()->begin(); itr != namesList()->end(); itr++)
2555
			list->pushBack((Utils::WString("ScriptName: ") + (long)(*itr)->iLanguage + L" " + (*itr)->sName).toString());
2555
			list->pushBack(Utils::WString("ScriptName: ") + (long)(*itr)->iLanguage + L" " + (*itr)->sName);
2556
		list->pushBack("");
2556
		list->pushBack(L"");
2557
	}
2557
	}
2558
 
2558
 
2559
	for ( int j = 0; j < 2; j++ ) {
2559
	for ( int j = 0; j < 2; j++ ) {
2560
		Utils::WString installText = (j == 0) ? L"Install" : L"Uninstall";
2560
		Utils::WString installText = (j == 0) ? L"Install" : L"Uninstall";
2561
		const CInstallText *pText = (j == 0) ? this->installText() : this->uninstallText();
2561
		const CInstallText *pText = (j == 0) ? this->installText() : this->uninstallText();
2562
		if ( pText->any() )
2562
		if ( pText->any() )
2563
		{
2563
		{
2564
			list->pushBack((L"# " + installText + L" Texts, display text before and/or after " + installText + L"ing to inform the use of special conditions").toString());
2564
			list->pushBack(L"# " + installText + L" Texts, display text before and/or after " + installText + L"ing to inform the use of special conditions");
2565
			for ( unsigned int i = 0; i < pText->count(); i++ ) {
2565
			for ( unsigned int i = 0; i < pText->count(); i++ ) {
2566
				long iLang = pText->language(i);
2566
				long iLang = pText->language(i);
2567
				if ( !pText->getBefore(iLang).empty() )	list->pushBack((installText + &quot;Before: " + iLang + L" " + pText->getBefore(iLang)).toString());
2567
				if ( !pText->getBefore(iLang).empty() )	list->pushBack(installText + &quot;Before: " + iLang + L" " + pText->getBefore(iLang));
2568
				if ( !pText->getAfter(iLang).empty()  )	list->pushBack((installText + &quot;After: " + iLang + L" " + pText->getAfter(iLang)).toString());
2568
				if ( !pText->getAfter(iLang).empty()  )	list->pushBack(installText + &quot;After: " + iLang + L" " + pText->getAfter(iLang));
2569
			}
2569
			}
2570
			list->pushBack("");
2570
			list->pushBack(L"");
2571
		}
2571
		}
2572
	}
2572
	}
2573
 
2573
 
2574
	list->pushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2574
	list->pushBack(L"# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2575
	switch ( this->pluginType() )
2575
	switch ( this->pluginType() )
2576
	{
2576
	{
2577
		case PLUGIN_NORMAL:
2577
		case PLUGIN_NORMAL:
2578
			list->pushBack("PluginType: Normal");
2578
			list->pushBack(L"PluginType: Normal");
2579
			break;
2579
			break;
2580
		case PLUGIN_STABLE:
2580
		case PLUGIN_STABLE:
2581
			list->pushBack("PluginType: Stable");
2581
			list->pushBack(L"PluginType: Stable");
2582
			break;
2582
			break;
2583
		case PLUGIN_EXPERIMENTAL:
2583
		case PLUGIN_EXPERIMENTAL:
2584
			list->pushBack("PluginType: Experimental");
2584
			list->pushBack(L"PluginType: Experimental");
2585
			break;
2585
			break;
2586
		case PLUGIN_CHEAT:
2586
		case PLUGIN_CHEAT:
2587
			list->pushBack("PluginType: Cheat");
2587
			list->pushBack(L"PluginType: Cheat");
2588
			break;
2588
			break;
2589
		case PLUGIN_MOD:
2589
		case PLUGIN_MOD:
2590
			list->pushBack("PluginType: Mod");
2590
			list->pushBack(L"PluginType: Mod");
2591
			break;
2591
			break;
2592
	}
2592
	}
2593
	list->pushBack("");
2593
	list->pushBack(L"");
2594
 
2594
 
2595
	return true;
2595
	return true;
2596
}
2596
}
2597
 
2597
 
2598
bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons)
2598
bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, Utils::WStringList *list, int game, const Utils::WStringList &gameAddons)
2599
{
2599
{
2600
	// now do files and wildcards
2600
	// now do files and wildcards
2601
	Utils::WStringList files;
2601
	Utils::WStringList files;
2602
	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
2602
	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
2603
	{
2603
	{
Line 2618... Line 2618...
2618
			}
2618
			}
2619
		}
2619
		}
2620
 
2620
 
2621
		if (foundGame)
2621
		if (foundGame)
2622
		{
2622
		{
2623
			Utils::WString str = gameAddons.findString(Utils::String::Number(foundGame));
2623
			Utils::WString str = gameAddons.findString(Utils::WString::Number(foundGame));
2624
			if(!str.empty())
2624
			if(!str.empty())
2625
				name += str + L"/";
2625
				name += str + L"/";
2626
		}
2626
		}
2627
 
2627
 
2628
		bool done = false;
2628
		bool done = false;
Line 2676... Line 2676...
2676
				if (f->Data()->game() & 1 << i)
2676
				if (f->Data()->game() & 1 << i)
2677
				{
2677
				{
2678
					if (first)
2678
					if (first)
2679
						first = false;
2679
						first = false;
2680
					else
2680
					else
2681
						s += "|";
2681
						s += L"|";
2682
					s += CBaseFile::ConvertGameToString(i);
2682
					s += CBaseFile::ConvertGameToString(i);
2683
				}
2683
				}
2684
			}
2684
			}
2685
		}
2685
		}
2686
 
2686
 
Line 2690... Line 2690...
2690
	}
2690
	}
2691
 
2691
 
2692
 
2692
 
2693
	if ( !files.empty() )
2693
	if ( !files.empty() )
2694
	{
2694
	{
2695
		list->pushBack("# Files List, all the files to add, can include wild cards");
2695
		list->pushBack(L"# Files List, all the files to add, can include wild cards");
2696
		for(auto itr = files.begin(); itr != files.end(); itr++)
2696
		for(auto itr = files.begin(); itr != files.end(); itr++)
2697
			list->pushBack((*itr)->data.toString() + ": " + (*itr)->str.toString());
2697
			list->pushBack((*itr)->data + L": " + (*itr)->str);
2698
		list->pushBack("");
2698
		list->pushBack(L"");
2699
	}
2699
	}
2700
 
2700
 
2701
	return true;
2701
	return true;
2702
}
2702
}
2703
 
2703
 
2704
Utils::WString CBaseFile::getAutosaveName() const
2704
Utils::WString CBaseFile::getAutosaveName() const
2705
{
2705
{
2706
	return this->name() + L"-V" + this->version() + L"-" + this->creationDate().findReplace("/", ".");
2706
	return this->name() + L"-V" + this->version() + L"-" + this->creationDate().findReplace(L"/", L".");
2707
}
2707
}
2708
 
2708
 
2709
bool CBaseFile::CheckGameCompatability(int game)
2709
bool CBaseFile::CheckGameCompatability(int game)
2710
{
2710
{
2711
	if ( m_lGames.empty() )
2711
	if ( m_lGames.empty() )
Line 2765... Line 2765...
2765
	}
2765
	}
2766
 
2766
 
2767
	return NULL;
2767
	return NULL;
2768
}
2768
}
2769
 
2769
 
2770
void CBaseFile::AddGameCompatability(int game, const Utils::String &version)
2770
void CBaseFile::AddGameCompatability(int game, const Utils::WString &version)
2771
{
2771
{
2772
	// first check if we already have it on the list
2772
	// first check if we already have it on the list
2773
	SGameCompat *Found = this->GetGameCompatability(game);
2773
	SGameCompat *Found = this->GetGameCompatability(game);
2774
	if ( !Found ) {
2774
	if ( !Found ) {
2775
		Found = new SGameCompat;
2775
		Found = new SGameCompat;
2776
		m_lGames.push_back(Found);
2776
		m_lGames.push_back(Found);
2777
	}
2777
	}
2778
 
2778
 
2779
	Found->iGame = game;
2779
	Found->iGame = game;
2780
	Found->iVersion = -1;
2780
	Found->iVersion = -1;
2781
	Found->sVersion = "";
2781
	Found->sVersion = L"";
2782
 
2782
 
2783
	if ( version.isin(".") || !version.isNumber() )
2783
	if ( version.contains(L".") || !version.isNumber() )
2784
		Found->sVersion = version.toWString();
2784
		Found->sVersion = version;
2785
	else
2785
	else
2786
		Found->iVersion = version.toWString();
2786
		Found->iVersion = version;
2787
	_changed();
2787
	_changed();
2788
}
2788
}
2789
 
2789
 
2790
Utils::WString CBaseFile::_replaceFilename(const Utils::WString &fname)
2790
Utils::WString CBaseFile::_replaceFilename(const Utils::WString &fname)
2791
{
2791
{
Line 2856... Line 2856...
2856
	else if (sFirst.Compare(L"WebMirror1"))
2856
	else if (sFirst.Compare(L"WebMirror1"))
2857
		this->addWebMirror(sRest.toString());
2857
		this->addWebMirror(sRest.toString());
2858
	else if (sFirst.Compare(L"WebMirror2"))
2858
	else if (sFirst.Compare(L"WebMirror2"))
2859
		this->addWebMirror(sRest.toString());
2859
		this->addWebMirror(sRest.toString());
2860
	else if (sFirst.Compare(L"Ftp"))
2860
	else if (sFirst.Compare(L"Ftp"))
2861
		_sFtpAddr = sRest.toString();
2861
		_sFtpAddr = sRest;
2862
	else if (sFirst.Compare(L"Ratings"))		_setRatings(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.token(L" ", 3));
2862
	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);
2863
	else if (sFirst.Compare(L"EaseOfUse"))		setEaseOfUse(sRest);
2864
	else if (sFirst.Compare(L"GameChanging"))	setGameChanging(sRest);
2864
	else if (sFirst.Compare(L"GameChanging"))	setGameChanging(sRest);
2865
	else if (sFirst.Compare(L"Recommended"))	setRecommended(sRest);
2865
	else if (sFirst.Compare(L"Recommended"))	setRecommended(sRest);
2866
	else if (sFirst.Compare(L"Depend"))
2866
	else if (sFirst.Compare(L"Depend"))
Line 3103... Line 3103...
3103
	}
3103
	}
3104
	return NULL;
3104
	return NULL;
3105
}
3105
}
3106
 
3106
 
3107
 
3107
 
3108
void CBaseFile::convertNormalMod(C_File *f, const Utils::String &to) const
3108
void CBaseFile::convertNormalMod(C_File *f, const Utils::WString &to) const
3109
{
3109
{
3110
	C_File *match = this->findMatchingMod(f);
3110
	C_File *match = this->findMatchingMod(f);
3111
	if ( match )
3111
	if ( match )
3112
	{
3112
	{
3113
		// file link
3113
		// file link
Line 3197... Line 3197...
3197
	}
3197
	}
3198
 
3198
 
3199
	return NULL;
3199
	return NULL;
3200
}
3200
}
3201
 
3201
 
3202
void CBaseFile::renameFile(C_File *f, const Utils::String &baseName) const
3202
void CBaseFile::renameFile(C_File *f, const Utils::WString &baseName) const
3203
{
3203
{
3204
	if ( f->GetFileType() == FILETYPE_MOD )
3204
	if ( f->GetFileType() == FILETYPE_MOD )
3205
	{
3205
	{
3206
		C_File *match = this->findMatchingMod(f);
3206
		C_File *match = this->findMatchingMod(f);
3207
		if ( match )
3207
		if ( match )
Line 3274... Line 3274...
3274
	}
3274
	}
3275
 
3275
 
3276
	return Utils::WString::Number((long)error);
3276
	return Utils::WString::Number((long)error);
3277
}
3277
}
3278
 
3278
 
3279
bool CBaseFile::saveToArchive(const Utils::String &filename, int game, const CGameExe *exes, CProgressInfo *progress)
3279
bool CBaseFile::saveToArchive(const Utils::WString &filename, int game, const CGameExe *exes, CProgressInfo *progress)
3280
{
3280
{
3281
	CDirIO Dir(CFileIO(filename).dir());
3281
	CDirIO Dir(CFileIO(filename).dir());
3282
	if (!Dir.exists())
3282
	if (!Dir.exists())
3283
		Dir.create();
3283
		Dir.create();
3284
 
3284
 
3285
	TCHAR buf[5000];
-
 
3286
	wsprintf(buf, L"%hs", filename.c_str());
-
 
3287
 
-
 
3288
	HZIP hz = CreateZip(buf, 0);
3285
	HZIP hz = CreateZip(filename.c_str(), 0);
3289
	if (!hz) return false;
3286
	if (!hz) return false;
3290
 
3287
 
3291
	// read files and compress
3288
	// read files and compress
3292
	ReadAllFilesToMemory();
3289
	ReadAllFilesToMemory();
3293
	if (!UncompressAllFiles(progress))
3290
	if (!UncompressAllFiles(progress))
Line 3352... Line 3349...
3352
 
3349
 
3353
	// if its a ship, then add any generated files
3350
	// if its a ship, then add any generated files
3354
	this->addGeneratedFiles(hz);
3351
	this->addGeneratedFiles(hz);
3355
 
3352
 
3356
	// add the data file
3353
	// add the data file
3357
	Utils::CStringList list;
3354
	Utils::WStringList list;
3358
	Utils::CStringList addons;
3355
	Utils::WStringList addons;
3359
	if ( this->GeneratePackagerScript(false, &list, game, addons, true) )
3356
	if ( this->GeneratePackagerScript(false, &list, game, addons, true) )
3360
	{
3357
	{
3361
		if ( CFileIO("test.tmp").writeFile(&list) )
3358
		if ( CFileIO(L"test.tmp").writeFile(&list) )
3362
		{
3359
		{
3363
			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
3360
			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
3364
			CFileIO::Remove("test.tmp");
3361
			CFileIO::Remove(L"test.tmp");
3365
		}
3362
		}
3366
	}
3363
	}
3367
 
3364
 
3368
	CloseZip(hz);
3365
	CloseZip(hz);
3369
 
3366
 
3370
	return true;
3367
	return true;
3371
}
3368
}
3372
 
3369
 
3373
int CBaseFile::GetGameFromString(const Utils::String &sGame)
3370
int CBaseFile::GetGameFromString(const Utils::WString &sGame)
3374
{
3371
{
3375
	int iGame = GAME_ALL;
3372
	int iGame = GAME_ALL;
3376
	if ( sGame.Compare("ALL") )
3373
	if ( sGame.Compare(L"ALL") )
3377
		iGame = GAME_ALL;
3374
		iGame = GAME_ALL;
3378
	else if ( sGame.Compare("X3") )
3375
	else if ( sGame.Compare(L"X3") )
3379
		iGame = GAME_X3;
3376
		iGame = GAME_X3;
3380
	else if ( sGame.Compare("X2") )
3377
	else if ( sGame.Compare(L"X2") )
3381
		iGame = GAME_X2;
3378
		iGame = GAME_X2;
3382
	else if ( sGame.Compare("X3TC") )
3379
	else if ( sGame.Compare(L"X3TC") )
3383
		iGame = GAME_X3TC;
3380
		iGame = GAME_X3TC;
3384
	else if (sGame.Compare("X3AP"))
3381
	else if (sGame.Compare(L"X3AP"))
3385
		iGame = GAME_X3AP;
3382
		iGame = GAME_X3AP;
3386
	else if (sGame.Compare("X3FL"))
3383
	else if (sGame.Compare(L"X3FL"))
3387
		iGame = GAME_X3FL;
3384
		iGame = GAME_X3FL;
3388
	else if ( sGame.isNumber() )
3385
	else if ( sGame.isNumber() )
3389
		iGame = sGame;
3386
		iGame = sGame;
3390
 
3387
 
3391
	return iGame;
3388
	return iGame;