Subversion Repositories spk

Rev

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

Rev 206 Rev 207
Line 1416... Line 1416...
1416
	Func:   ParseValueLine
1416
	Func:   ParseValueLine
1417
	Input:  String - single line from a file to set
1417
	Input:  String - single line from a file to set
1418
	Return: Boolean - returns true if value exists
1418
	Return: Boolean - returns true if value exists
1419
	Desc:   Reads the line and assigns the parameters for the file
1419
	Desc:   Reads the line and assigns the parameters for the file
1420
*/
1420
*/
1421
bool CBaseFile::ParseValueLine(const Utils::String &sLine)
1421
bool CBaseFile::parseValueLine(const Utils::WString &sLine)
1422
{
1422
{
1423
	Utils::String first = sLine.token(" ", 1);
1423
	Utils::WString first = sLine.token(L" ", 1);
1424
	Utils::String rest  = sLine.tokens(" ", 2);
1424
	Utils::WString rest  = sLine.tokens(L" ", 2);
1425
 
1425
 
1426
	if ( first.Compare("Name:") )					this->setName(rest);
1426
	if ( first.Compare(L"Name:") )					this->setName(rest);
1427
	else if ( first.Compare("Author:") )			this->setAuthor(rest);
1427
	else if ( first.Compare(L"Author:") )			this->setAuthor(rest);
1428
	else if ( first.Compare("Version:") )			this->setVersion(rest);
1428
	else if ( first.Compare(L"Version:") )			this->setVersion(rest);
1429
	else if ( first.Compare("fGameVersion:") ) {
1429
	else if ( first.Compare(L"fGameVersion:") ) {
1430
		if ( m_lGames.Back() ) {
1430
		if ( m_lGames.Back() ) {
1431
			m_lGames.Back()->Data()->sVersion = rest.toWString();
1431
			m_lGames.Back()->Data()->sVersion = rest;
1432
		}
1432
		}
1433
	}
1433
	}
1434
	else if ( first.Compare("GameVersion:") ) {
1434
	else if ( first.Compare(L"GameVersion:") ) {
1435
		if ( m_lGames.Back() ) {
1435
		if ( m_lGames.Back() ) {
1436
			m_lGames.Back()->Data()->iVersion = rest.toInt();
1436
			m_lGames.Back()->Data()->iVersion = rest.toInt();
1437
		}
1437
		}
1438
	}
1438
	}
1439
	else if ( first.Compare("Game:") )
1439
	else if ( first.Compare(L"Game:") )
1440
		this->AddGameCompatability(rest, "");
1440
		this->AddGameCompatability(rest, L"");
1441
	else if ( first.Compare("GameCompat:") )
1441
	else if ( first.Compare(L"GameCompat:") )
1442
		this->AddGameCompatability(rest.token(" ", 1), rest.tokens(" ", 2));
1442
		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2).toString());
1443
	else if ( first.Compare("GameCompatExact:") )
1443
	else if ( first.Compare(L"GameCompatExact:") )
1444
		this->AddGameCompatability(rest.token(" ", 1), rest.tokens(" ", 2));
1444
		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2).toString());
1445
	else if ( first.Compare("Date:") )				this->setCreationDate(rest);
1445
	else if ( first.Compare(L"Date:") )				this->setCreationDate(rest);
1446
	else if ( first.Compare("WebAddress:") )		this->setWebAddress(rest);
1446
	else if ( first.Compare(L"WebAddress:") )		this->setWebAddress(rest);
1447
	else if ( first.Compare("WebSite:") )			this->setWebSite(rest);
1447
	else if ( first.Compare(L"WebSite:") )			this->setWebSite(rest);
1448
	else if ( first.Compare("Email:") )				this->setEmail(rest);
1448
	else if ( first.Compare(L"Email:") )				this->setEmail(rest);
1449
	else if ( first.Compare("WebMirror1:") || first.Compare("Mirror1:") || first.Compare("WebMirror:") )
1449
	else if ( first.Compare(L"WebMirror1:") || first.Compare(L"Mirror1:") || first.Compare(L"WebMirror:") )
1450
		this->addWebMirror(rest);
1450
		this->addWebMirror(rest.toString());
1451
	else if ( first.Compare("WebMirror2:") || first.Compare("Mirror2:") )
1451
	else if ( first.Compare(L"WebMirror2:") || first.Compare(L"Mirror2:") )
1452
		this->addWebMirror(rest);
1452
		this->addWebMirror(rest.toString());
1453
	else if ( first.Compare("PluginType:") )		this->setPluginType(rest);
1453
	else if ( first.Compare(L"PluginType:") )		this->setPluginType(rest);
1454
	else if ( first.Compare("Desc:") )				this->setDescription(rest);
1454
	else if ( first.Compare(L"Desc:") )				this->setDescription(rest);
1455
	else if ( first.Compare("UninstallAfter:") )	this->addUninstallText(ParseLanguage(rest.token("|", 1)), false, rest.tokens("|", 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("UninstallBefore:") )	this->addUninstallText(ParseLanguage(rest.token("|", 1)), true, rest.tokens("|", 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("InstallAfter:") )		this->addInstallText(ParseLanguage(rest.token("|", 1)), false, rest.tokens("|", 2));
1457
	else if ( first.Compare(L"InstallAfter:") )		this->addInstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
1458
	else if ( first.Compare("InstallBefore:") )		this->addInstallText(ParseLanguage(rest.token("|", 1)), true, rest.tokens("|", 2));
1458
	else if ( first.Compare(L"InstallBefore:") )	this->addInstallText(parseLanguage(rest.token(L"|", 1)), true, rest.tokens(L"|", 2));
1459
	else if ( first.Compare("ScriptName:") )		addName(ParseLanguage(rest.token(":", 1)), rest.token(":", 2));
1459
	else if ( first.Compare(L"ScriptName:") )		addName(parseLanguage(rest.token(L":", 1)), rest.token(L":", 2));
1460
	else if ( first.Compare("GameChanging:") )		this->setGameChanging(rest);
1460
	else if ( first.Compare(L"GameChanging:") )		this->setGameChanging(rest);
1461
	else if ( first.Compare("EaseOfUse:") )			this->setEaseOfUse(rest);
1461
	else if ( first.Compare(L"EaseOfUse:") )		this->setEaseOfUse(rest);
1462
	else if ( first.Compare("Recommended:") )		this->setRecommended(rest);
1462
	else if ( first.Compare(L"Recommended:") )		this->setRecommended(rest);
1463
	else if ( first.Compare("NeededLibrary:") )
1463
	else if ( first.Compare(L"NeededLibrary:") )
1464
		this->addNeededLibrary(rest.token("||", 1), rest.token("||", 2), rest.token("||", 3));
1464
		this->addNeededLibrary(rest.token(L"||", 1), rest.token(L"||", 2), rest.token(L"||", 3));
1465
	else if ( first.Compare("FakePatchBefore:") )
1465
	else if ( first.Compare(L"FakePatchBefore:") )
1466
		this->addFakePatchOrder(false, rest.token("||", 1), rest.token("||", 2));
1466
		this->addFakePatchOrder(false, rest.token(L"||", 1), rest.token(L"||", 2));
1467
	else if ( first.Compare("FakePatchAfter:") )
1467
	else if ( first.Compare(L"FakePatchAfter:") )
1468
		this->addFakePatchOrder(true, rest.token("||", 1), rest.token("||", 2));
1468
		this->addFakePatchOrder(true, rest.token(L"||", 1), rest.token(L"||", 2));
1469
	else if ( first.Compare("ForumLink:") )			this->setForumLink(rest);
1469
	else if ( first.Compare(L"ForumLink:") )			this->setForumLink(rest);
1470
	else
1470
	else
1471
		return false;
1471
		return false;
1472
 
1472
 
1473
	return true;
1473
	return true;
1474
}
1474
}
1475
 
1475
 
1476
int CBaseFile::ParseLanguage(const Utils::String &lang) const
1476
int CBaseFile::parseLanguage(const Utils::WString &lang) const
1477
{
1477
{
1478
	int langID = lang;
1478
	int langID = lang;
1479
	if ( !langID ) {
1479
	if ( !langID ) {
1480
		if ( lang.Compare("english") )		return 44;
1480
		if (lang.Compare(L"english"))		return 44;
1481
		else if ( lang.Compare("default") )	return 0;
1481
		else if (lang.Compare(L"default"))	return 0;
1482
		else if ( lang.Compare("german") )	return 49;
1482
		else if (lang.Compare(L"german"))	return 49;
1483
		else if ( lang.Compare("russian") )	return 7;
1483
		else if (lang.Compare(L"russian"))	return 7;
1484
		else if ( lang.Compare("spanish") )	return 34;
1484
		else if (lang.Compare(L"spanish"))	return 34;
1485
		else if ( lang.Compare("french") )	return 33;
1485
		else if (lang.Compare(L"french"))	return 33;
1486
	}
1486
	}
1487
 
1487
 
1488
	return langID;
1488
	return langID;
1489
}
1489
}
1490
 
1490
 
1491
/*
1491
/*
1492
	Func:   ReadValues
1492
	Func:   ReadValues
1493
	Input:  String - values in one long line
1493
	Input:  String - values in one long line
1494
	Desc:   splits the values data into each line to read the data
1494
	Desc:   splits the values data into each line to read the data
1495
*/
1495
*/
1496
void CBaseFile::_readValues(const Utils::String &values)
1496
void CBaseFile::_readValues(const Utils::WString &values)
1497
{
1497
{
1498
	int num = 0;
-
 
1499
	Utils::String *lines = values.tokenise("\n", &num);
-
 
1500
 
-
 
1501
	for ( int i = 0; i < num; i++ )
1498
	std::vector<Utils::WString> lines;
1502
		ParseValueLine(lines[i]);
1499
	values.tokenise(L"\n", lines);
1503
 
1500
 
-
 
1501
	for (size_t i = 0; i < lines.size(); i++)
1504
	CLEANSPLIT(lines, num)
1502
		parseValueLine(lines[i]);
1505
}
1503
}
1506
 
1504
 
1507
/*
1505
/*
1508
	Func:   ParseFilesLine
1506
	Func:   ParseFilesLine
1509
	Input:  String - single line from a file to set
1507
	Input:  String - single line from a file to set
Line 1872... Line 1870...
1872
	}
1870
	}
1873
 
1871
 
1874
	return false;
1872
	return false;
1875
}
1873
}
1876
 
1874
 
1877
Utils::String CBaseFile::createValuesLine () const
1875
Utils::WString CBaseFile::createValuesLine () const
1878
{
1876
{
1879
	Utils::WString values(L"Name: ");
1877
	Utils::WString values(L"Name: ");
1880
	values += this->name() + L"\n";
1878
	values += this->name() + L"\n";
1881
	values += L"Author: " + this->author() + L"\n";
1879
	values += L"Author: " + this->author() + L"\n";
1882
	values += L"Version: " + this->version() + L"\n";
1880
	values += L"Version: " + this->version() + L"\n";
Line 1931... Line 1929...
1931
		SNeededLibrary *l = libNode->Data();
1929
		SNeededLibrary *l = libNode->Data();
1932
		values += L"NeededLibrary: " + l->sName + L"||" + l->sAuthor + L"||" + l->sMinVersion + L"\n";
1930
		values += L"NeededLibrary: " + l->sName + L"||" + l->sAuthor + L"||" + l->sMinVersion + L"\n";
1933
	}
1931
	}
1934
 
1932
 
1935
	for (auto itr = _lFakePatchBefore.begin(); itr != _lFakePatchBefore.end(); itr++)
1933
	for (auto itr = _lFakePatchBefore.begin(); itr != _lFakePatchBefore.end(); itr++)
1936
		values += L"FakePatchBefore: " + (*itr)->str.toWString() + L";||" + (*itr)->data.toWString() + L"\n";
1934
		values += L"FakePatchBefore: " + (*itr)->str + L";||" + (*itr)->data + L"\n";
1937
	for (auto itr = _lFakePatchAfter.begin(); itr != _lFakePatchAfter.end(); itr++)
1935
	for (auto itr = _lFakePatchAfter.begin(); itr != _lFakePatchAfter.end(); itr++)
1938
		values += L"FakePatchAfter: " + (*itr)->str.toWString() + L";||" + (*itr)->data.toWString() + L"\n";
1936
		values += L"FakePatchAfter: " + (*itr)->str + L";||" + (*itr)->data + L"\n";
1939
 
1937
 
1940
	values += Utils::WString(L"PluginType: ") + (long)this->pluginType() + L"\n";
1938
	values += Utils::WString(L"PluginType: ") + (long)this->pluginType() + L"\n";
1941
 
1939
 
1942
	return values.toString();
1940
	return values;
1943
}
1941
}
1944
 
1942
 
1945
 
1943
 
1946
/*
1944
/*
1947
	Func:   WriteFile
1945
	Func:   WriteFile
Line 1967... Line 1965...
1967
		valueheader = SPKCOMPRESS_ZLIB;
1965
		valueheader = SPKCOMPRESS_ZLIB;
1968
	if ( fileheader == SPKCOMPRESS_7ZIP )
1966
	if ( fileheader == SPKCOMPRESS_7ZIP )
1969
		fileheader = SPKCOMPRESS_ZLIB;
1967
		fileheader = SPKCOMPRESS_ZLIB;
1970
 
1968
 
1971
	// get the script values
1969
	// get the script values
1972
	Utils::String values = this->createValuesLine();
1970
	Utils::WString values = this->createValuesLine();
1973
 
1971
 
1974
	// compress the values
1972
	// compress the values
1975
	int valueUncomprLen = (int)values.length();
1973
	int valueUncomprLen = (int)values.length();
1976
	unsigned long valueComprLen = 0;
1974
	unsigned long valueComprLen = 0;
1977
	unsigned char *valueCompr = NULL;
1975
	unsigned char *valueCompr = NULL;
Line 2310... Line 2308...
2310
	}
2308
	}
2311
 
2309
 
2312
	return NULL;
2310
	return NULL;
2313
}
2311
}
2314
 
2312
 
2315
void CBaseFile::removeFakePatchOrder(const Utils::String &scriptName, const Utils::String &author)
2313
void CBaseFile::removeFakePatchOrder(const Utils::WString &scriptName, const Utils::WString &author)
2316
{
2314
{
2317
	removeFakePatchOrder(true, scriptName, author);
2315
	removeFakePatchOrder(true, scriptName, author);
2318
	removeFakePatchOrder(false, scriptName, author);
2316
	removeFakePatchOrder(false, scriptName, author);
2319
}
2317
}
2320
void CBaseFile::removeFakePatchOrder(bool after, const Utils::String &scriptName, const Utils::String &author)
2318
void CBaseFile::removeFakePatchOrder(bool after, const Utils::WString &scriptName, const Utils::WString &author)
2321
{
2319
{
2322
	Utils::CStringList *list;
2320
	Utils::WStringList *list;
2323
	if ( after )
2321
	if ( after )
2324
		list = &_lFakePatchAfter;
2322
		list = &_lFakePatchAfter;
2325
	else
2323
	else
2326
		list = &_lFakePatchBefore;
2324
		list = &_lFakePatchBefore;
2327
 
2325
 
Line 2331... Line 2329...
2331
		list->removeAt(found);
2329
		list->removeAt(found);
2332
		found = list->findStringAndData(scriptName, author);
2330
		found = list->findStringAndData(scriptName, author);
2333
	}
2331
	}
2334
}
2332
}
2335
 
2333
 
2336
void CBaseFile::addFakePatchOrder(bool after, const Utils::String &scriptName, const Utils::String &author)
2334
void CBaseFile::addFakePatchOrder(bool after, const Utils::WString &scriptName, const Utils::WString &author)
2337
{
2335
{
2338
	Utils::CStringList *list;
2336
	Utils::WStringList *list;
2339
	if ( after )
2337
	if ( after )
2340
		list = &_lFakePatchAfter;
2338
		list = &_lFakePatchAfter;
2341
	else
2339
	else
2342
		list = &_lFakePatchBefore;
2340
		list = &_lFakePatchBefore;
2343
 
2341
 
Line 2768... Line 2766...
2768
 
2766
 
2769
	return filename;
2767
	return filename;
2770
}
2768
}
2771
bool CBaseFile::loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
2769
bool CBaseFile::loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
2772
{
2770
{
2773
	if (sFirst.Compare(L"Name"))					this->setName(sRest.toString());
2771
	if (sFirst.Compare(L"Name"))					this->setName(sRest);
2774
	else if (sFirst.Compare(L"Author"))				this->setAuthor(sRest.toString());
2772
	else if (sFirst.Compare(L"Author"))				this->setAuthor(sRest);
2775
	else if (sFirst.Compare(L"ScriptName"))			addName(ParseLanguage(sRest.token(L" ", 1).toString()), sRest.tokens(L" ", 2).toString());
2773
	else if (sFirst.Compare(L"ScriptName"))			addName(parseLanguage(sRest.token(L" ", 1)), sRest.tokens(L" ", 2));
2776
	else if (sFirst.Compare(L"UninstallBefore"))	this->addUninstallText(ParseLanguage(sRest.token(L" ", 1).toString()), true, sRest.tokens(L" ", 2).toString());
2774
	else if (sFirst.Compare(L"UninstallBefore"))	this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
2777
	else if (sFirst.Compare(L"UninstallAfter"))		this->addUninstallText(ParseLanguage(sRest.token(L" ", 1).toString()), false, sRest.tokens(L" ", 2).toString());
2775
	else if (sFirst.Compare(L"UninstallAfter"))		this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
2778
	else if (sFirst.Compare(L"InstallBefore"))		this->addInstallText(ParseLanguage(sRest.token(L" ", 1).toString()), true, sRest.tokens(L" ", 2).toString());
2776
	else if (sFirst.Compare(L"InstallBefore"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
2779
	else if (sFirst.Compare(L"InstallAfter"))		this->addInstallText(ParseLanguage(sRest.token(L" ", 1).toString()), false, sRest.tokens(L" ", 2).toString());
2777
	else if (sFirst.Compare(L"InstallAfter"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
2780
	else if (sFirst.Compare(L"Date"))				this->setCreationDate(sRest.toString());
2778
	else if (sFirst.Compare(L"Date"))				this->setCreationDate(sRest.toString());
2781
	else if (sFirst.Compare(L"Version"))			this->setVersion(sRest.toString());
2779
	else if (sFirst.Compare(L"Version"))			this->setVersion(sRest.toString());
2782
	else if (sFirst.Compare(L"GameVersion"))
2780
	else if (sFirst.Compare(L"GameVersion"))
2783
		this->AddGameCompatability(-1, sRest.toString());
2781
		this->AddGameCompatability(-1, sRest.toString());
2784
	else if (sFirst.Compare(L"PluginType")) {
2782
	else if (sFirst.Compare(L"PluginType")) {