Subversion Repositories spk

Rev

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

Rev 47 Rev 48
Line 28... Line 28...
28
}
28
}
29
 
29
 
30
CArchiveFile::CArchiveFile() : CBaseFile ()
30
CArchiveFile::CArchiveFile() : CBaseFile ()
31
{
31
{
32
	SetDefaults ();
32
	SetDefaults ();
33
 
-
 
34
	m_iType = TYPE_ARCHIVE;
-
 
35
}
33
}
36
 
34
 
37
void CBaseFile::SetDefaults ()
35
void CBaseFile::SetDefaults ()
38
{
36
{
39
	_setDefaults();
37
	_setDefaults();
Line 45... Line 43...
45
	m_SHeader2.iFileCompression = SPKCOMPRESS_ZLIB;
43
	m_SHeader2.iFileCompression = SPKCOMPRESS_ZLIB;
46
	m_SHeader2.iDataCompression = SPKCOMPRESS_LZMA;
44
	m_SHeader2.iDataCompression = SPKCOMPRESS_LZMA;
47
	m_pParent = NULL;
45
	m_pParent = NULL;
48
	m_bChanged = false;
46
	m_bChanged = false;
49
	m_bUpdate = false;
47
	m_bUpdate = false;
50
	m_iPluginType = PLUGIN_NORMAL;
-
 
51
 
48
 
52
	ClearError();
49
	ClearError();
53
 
50
 
54
	m_iLoadError = 0;
51
	m_iLoadError = 0;
55
 
52
 
Line 60... Line 57...
60
}
57
}
61
 
58
 
62
CBaseFile::CBaseFile()
59
CBaseFile::CBaseFile()
63
{
60
{
64
	SetDefaults ();
61
	SetDefaults ();
65
 
-
 
66
	m_iType = TYPE_BASE;
-
 
67
}
62
}
68
CBaseFile::~CBaseFile()
63
CBaseFile::~CBaseFile()
69
{
64
{
70
	Delete();
65
	Delete();
71
}
66
}
Line 1397... Line 1392...
1397
		m_sEmail = rest;
1392
		m_sEmail = rest;
1398
	else if ( first.Compare("WebMirror1:") || first.Compare("Mirror1:") || first.Compare("WebMirror:") )
1393
	else if ( first.Compare("WebMirror1:") || first.Compare("Mirror1:") || first.Compare("WebMirror:") )
1399
		this->AddWebMirror(rest);
1394
		this->AddWebMirror(rest);
1400
	else if ( first.Compare("WebMirror2:") || first.Compare("Mirror2:") )
1395
	else if ( first.Compare("WebMirror2:") || first.Compare("Mirror2:") )
1401
		this->AddWebMirror(rest);
1396
		this->AddWebMirror(rest);
1402
	else if ( first.Compare("PluginType:") )
1397
	else if ( first.Compare("PluginType:") )		this->setPluginType(rest);
1403
		m_iPluginType = rest;
-
 
1404
	else if ( first.Compare("Desc:") )
1398
	else if ( first.Compare("Desc:") )				this->setDescription(rest);
1405
	{
-
 
1406
		m_sDescription = rest;
-
 
1407
		m_sDescription.RemoveFirstChar('\n');
-
 
1408
		m_sDescription.RemoveFirstChar('\r');
-
 
1409
		m_sDescription.RemoveFirstSpace();
-
 
1410
		m_sDescription = m_sDescription.FindReplace(""", "\"");
-
 
1411
		m_sDescription = m_sDescription.FindReplace(">", ">");
-
 
1412
		m_sDescription = m_sDescription.FindReplace("&lt;", "<");
-
 
1413
		m_sDescription = m_sDescription.FindReplace("&amp;", "&");
-
 
1414
		m_sDescription = m_sDescription.FindReplace("<newline>", "\n");
-
 
1415
		m_sDescription = m_sDescription.FindReplace("<br>", "\n");
-
 
1416
 
-
 
1417
		if ( m_sDescription.Left(6).lower() == "<html>" )
-
 
1418
		{
-
 
1419
			int foundFirst = -1;
-
 
1420
			int pos = 0;
-
 
1421
			while ( foundFirst == -1 )
-
 
1422
			{
-
 
1423
				pos = m_sDescription.FindPos(">", pos);
-
 
1424
 
-
 
1425
				pos++;
-
 
1426
				if ( pos >= (int)m_sDescription.Length() )
-
 
1427
					break;
-
 
1428
				char c = m_sDescription[pos];
-
 
1429
 
-
 
1430
				if ( c != '<' )
-
 
1431
					foundFirst = pos;
-
 
1432
			}
-
 
1433
 
-
 
1434
			if ( foundFirst == -1 )
-
 
1435
				m_sDescription = "";
-
 
1436
			else
-
 
1437
			{
-
 
1438
				CyString firstStr = m_sDescription.Left(foundFirst);
-
 
1439
				firstStr.FindRemove("<br />");
-
 
1440
				firstStr.FindRemove("<br/>");
-
 
1441
				CyString lastStr = m_sDescription.Right(m_sDescription.Length() - foundFirst);
-
 
1442
 
-
 
1443
				m_sDescription = firstStr + lastStr;
-
 
1444
			}
-
 
1445
		}
-
 
1446
	}
-
 
1447
	else if ( first.Compare("UninstallAfter:") )	this->addUninstallText(ParseInstallText(rest.token("|", 1)), false, rest.tokens("|", 2));
1399
	else if ( first.Compare("UninstallAfter:") )	this->addUninstallText(ParseLanguage(rest.token("|", 1)), false, rest.tokens("|", 2));
1448
	else if ( first.Compare("UninstallBefore:") )	this->addUninstallText(ParseInstallText(rest.token("|", 1)), true, rest.tokens("|", 2));
1400
	else if ( first.Compare("UninstallBefore:") )	this->addUninstallText(ParseLanguage(rest.token("|", 1)), true, rest.tokens("|", 2));
1449
	else if ( first.Compare("InstallAfter:") )		this->addInstallText(ParseInstallText(rest.token("|", 1)), false, rest.tokens("|", 2));
1401
	else if ( first.Compare("InstallAfter:") )		this->addInstallText(ParseLanguage(rest.token("|", 1)), false, rest.tokens("|", 2));
1450
	else if ( first.Compare("InstallBefore:") )		this->addInstallText(ParseInstallText(rest.token("|", 1)), true, rest.tokens("|", 2));
1402
	else if ( first.Compare("InstallBefore:") )		this->addInstallText(ParseLanguage(rest.token("|", 1)), true, rest.tokens("|", 2));
1451
	else if ( first.Compare("ScriptName:") )
1403
	else if ( first.Compare("ScriptName:") )
1452
		AddLanguageName(ParseLanguage(rest.token(":", 1)), rest.token(":", 2));
1404
		AddLanguageName(ParseLanguage(rest.token(":", 1)), rest.token(":", 2));
1453
	else if ( first.Compare("GameChanging:") )	this->setGameChanging(rest);
1405
	else if ( first.Compare("GameChanging:") )		this->setGameChanging(rest);
1454
	else if ( first.Compare("EaseOfUse:") )		this->setEaseOfUse(rest);
1406
	else if ( first.Compare("EaseOfUse:") )			this->setEaseOfUse(rest);
1455
	else if ( first.Compare("Recommended:") )	this->setRecommended(rest);
1407
	else if ( first.Compare("Recommended:") )		this->setRecommended(rest);
1456
	else if ( first.Compare("NeededLibrary:") )
1408
	else if ( first.Compare("NeededLibrary:") )
1457
		this->AddNeededLibrary(rest.token("||", 1), rest.token("||", 2), rest.token("||", 3));
1409
		this->AddNeededLibrary(rest.token("||", 1), rest.token("||", 2), rest.token("||", 3));
1458
	else if ( first.Compare("FakePatchBefore:") )
1410
	else if ( first.Compare("FakePatchBefore:") )
1459
		this->AddFakePatchOrder(false, rest.token("||", 1), rest.token("||", 2));
1411
		this->AddFakePatchOrder(false, rest.token("||", 1), rest.token("||", 2));
1460
	else if ( first.Compare("FakePatchAfter:") )
1412
	else if ( first.Compare("FakePatchAfter:") )
Line 1465... Line 1417...
1465
		return false;
1417
		return false;
1466
 
1418
 
1467
	return true;
1419
	return true;
1468
}
1420
}
1469
 
1421
 
1470
int CBaseFile::ParseLanguage(CyString lang)
1422
int CBaseFile::ParseLanguage(const Utils::String &lang) const
1471
{
1423
{
1472
	int langID = lang.ToInt();
1424
	int langID = lang;
1473
 
-
 
1474
	if ( !langID )
1425
	if ( !langID ) {
1475
	{
-
 
1476
		lang = lang.ToLower();
-
 
1477
		if ( lang == "english" )
1426
		if ( lang.Compare("english") )		return 44;
1478
			return 44;
-
 
1479
		else if ( lang == "default" )
1427
		else if ( lang.Compare("default") )	return 0;
1480
			return 0;
-
 
1481
		else if ( lang == "german" )
1428
		else if ( lang.Compare("german") )	return 49;
1482
			return 49;
-
 
1483
		else if ( lang == "russian" )
1429
		else if ( lang.Compare("russian") )	return 7;
1484
			return 7;
-
 
1485
		else if ( lang == "spanish" )
1430
		else if ( lang.Compare("spanish") )	return 34;
1486
			return 34;
-
 
1487
		else if ( lang == "french" )
1431
		else if ( lang.Compare("french") )	return 33;
1488
			return 33;
-
 
1489
	}
1432
	}
1490
 
1433
 
1491
	return langID;
1434
	return langID;
1492
}
1435
}
1493
 
1436
 
1494
 
-
 
1495
int CBaseFile::ParseInstallText(const Utils::String &lang)
-
 
1496
{
-
 
1497
	return this->ParseLanguage(lang);
-
 
1498
}
-
 
1499
 
-
 
1500
 
-
 
1501
/*
1437
/*
1502
	Func:   ReadValues
1438
	Func:   ReadValues
1503
	Input:  String - values in one long line
1439
	Input:  String - values in one long line
1504
	Desc:   splits the values data into each line to read the data
1440
	Desc:   splits the values data into each line to read the data
1505
*/
1441
*/
Line 1858... Line 1794...
1858
		values += Utils::String("WebSite: ") + m_sWebSite.ToString() + "\n";
1794
		values += Utils::String("WebSite: ") + m_sWebSite.ToString() + "\n";
1859
	if ( !m_sEmail.Empty() )
1795
	if ( !m_sEmail.Empty() )
1860
		values += Utils::String("Email: ") + m_sEmail.ToString() + "\n";
1796
		values += Utils::String("Email: ") + m_sEmail.ToString() + "\n";
1861
	for ( SStringList *str = m_lMirrors.Head(); str; str = str->next )
1797
	for ( SStringList *str = m_lMirrors.Head(); str; str = str->next )
1862
		values += Utils::String("WebMirror: ") + str->str.ToString() + "\n";
1798
		values += Utils::String("WebMirror: ") + str->str.ToString() + "\n";
1863
	if ( !m_sDescription.Empty() )
1799
	if ( !this->description().empty() ) {
1864
	{
-
 
1865
		Utils::String desc = m_sDescription.ToString();
1800
		Utils::String desc = this->description();
1866
		desc = desc.findReplace("<newline>", "<br>");
1801
		desc = desc.findReplace("<newline>", "<br>");
1867
		desc = desc.findReplace("\n", "<br>");
1802
		desc = desc.findReplace("\n", "<br>");
1868
		desc.remove('\r');
1803
		desc.remove('\r');
1869
		values += "Desc: " + desc + "\n";
1804
		values += "Desc: " + desc + "\n";
1870
	}
1805
	}
Line 1910... Line 1845...
1910
	for ( SStringList *fpbNode = m_lFakePatchBefore.Head(); fpbNode; fpbNode = fpbNode->next )
1845
	for ( SStringList *fpbNode = m_lFakePatchBefore.Head(); fpbNode; fpbNode = fpbNode->next )
1911
		values += (CyString("FakePatchBefore: ") + fpbNode->str + "||" + fpbNode->data + "\n").ToString();
1846
		values += (CyString("FakePatchBefore: ") + fpbNode->str + "||" + fpbNode->data + "\n").ToString();
1912
	for ( SStringList *fpaNode = m_lFakePatchAfter.Head(); fpaNode; fpaNode = fpaNode->next )
1847
	for ( SStringList *fpaNode = m_lFakePatchAfter.Head(); fpaNode; fpaNode = fpaNode->next )
1913
		values += (CyString("FakePatchAfter: ") + fpaNode->str + "||" + fpaNode->data + "\n").ToString();
1848
		values += (CyString("FakePatchAfter: ") + fpaNode->str + "||" + fpaNode->data + "\n").ToString();
1914
 
1849
 
1915
	values += Utils::String("PluginType: ") + (long)m_iPluginType + "\n";
1850
	values += Utils::String("PluginType: ") + (long)this->pluginType() + "\n";
1916
 
1851
 
1917
	return values;
1852
	return values;
1918
}
1853
}
1919
 
1854
 
1920
 
1855
 
Line 2425... Line 2360...
2425
		}
2360
		}
2426
 
2361
 
2427
		list->PushBack("");
2362
		list->PushBack("");
2428
	}
2363
	}
2429
 
2364
 
2430
	if ( !m_sDescription.Empty() )
2365
	if ( !this->description().empty() ) {
2431
	{
-
 
2432
		list->PushBack("# The description of the script, displays when installing");
2366
		list->PushBack("# The description of the script, displays when installing");
2433
		list->PushBack(CyString("Description: ") + m_sDescription);
2367
		list->PushBack(CyString("Description: ") + this->description());
2434
		list->PushBack("");
2368
		list->PushBack("");
2435
	}
2369
	}
2436
 
2370
 
2437
	if ( !m_sWebSite.Empty() )
2371
	if ( !m_sWebSite.Empty() )
2438
	{
2372
	{
Line 2514... Line 2448...
2514
			list->PushBack("");
2448
			list->PushBack("");
2515
		}
2449
		}
2516
	}
2450
	}
2517
 
2451
 
2518
	list->PushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2452
	list->PushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2519
	switch ( this->GetPluginType() )
2453
	switch ( this->pluginType() )
2520
	{
2454
	{
2521
		case PLUGIN_NORMAL:
2455
		case PLUGIN_NORMAL:
2522
			list->PushBack("PluginType: Normal");
2456
			list->PushBack("PluginType: Normal");
2523
			break;
2457
			break;
2524
		case PLUGIN_STABLE:
2458
		case PLUGIN_STABLE:
Line 2711... Line 2645...
2711
	// old version
2645
	// old version
2712
	else if ( sFirst.Compare("GameVersion") )
2646
	else if ( sFirst.Compare("GameVersion") )
2713
		this->AddGameCompatability(-1, sRest);
2647
		this->AddGameCompatability(-1, sRest);
2714
	else if ( sFirst.Compare("PluginType") )
2648
	else if ( sFirst.Compare("PluginType") )
2715
	{
2649
	{
2716
		if ( sRest.isNumber() )
-
 
2717
			this->SetPluginType(sRest);
2650
		if ( sRest.isNumber() )						this->setPluginType(sRest);
2718
		else if ( sRest.Compare("Normal") )
-
 
2719
			this->SetPluginType(PLUGIN_NORMAL);
2651
		else if ( sRest.Compare("Normal") )			this->setPluginType(PLUGIN_NORMAL);
2720
		else if ( sRest.Compare("Stable") )
-
 
2721
			this->SetPluginType(PLUGIN_STABLE);
2652
		else if ( sRest.Compare("Stable") )			this->setPluginType(PLUGIN_STABLE);
2722
		else if ( sRest.Compare("Experimental") )
-
 
2723
			this->SetPluginType(PLUGIN_EXPERIMENTAL);
2653
		else if ( sRest.Compare("Experimental") )	this->setPluginType(PLUGIN_EXPERIMENTAL);
2724
		else if ( sRest.Compare("Cheat") )
-
 
2725
			this->SetPluginType(PLUGIN_CHEAT);
2654
		else if ( sRest.Compare("Cheat") )			this->setPluginType(PLUGIN_CHEAT);
2726
		else if ( sRest.Compare("Mod") )
-
 
2727
			this->SetPluginType(PLUGIN_MOD);
2655
		else if ( sRest.Compare("Mod") )			this->setPluginType(PLUGIN_MOD);
2728
	}
2656
	}
2729
	// new version
2657
	// new version
2730
	else if ( sFirst.Compare("GenerateUpdateFile") )
2658
	else if ( sFirst.Compare("GenerateUpdateFile") )
2731
		m_bAutoGenerateUpdateFile = true;
2659
		m_bAutoGenerateUpdateFile = true;
2732
	else if ( sFirst.Compare("Game") )
2660
	else if ( sFirst.Compare("Game") )
2733
	{
2661
	{
2734
		Utils::String sGame = sRest.token(" ", 1);
2662
		Utils::String sGame = sRest.token(" ", 1);
2735
		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame), sRest.token(" ", 2));
2663
		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame), sRest.token(" ", 2));
2736
	}
2664
	}
2737
	else if ( sFirst.Compare("Description") )
2665
	else if ( sFirst.Compare("Description") )		this->setDescription(sRest);
2738
		m_sDescription = sRest;
-
 
2739
	else if ( sFirst.Compare("AutoSave") || sFirst.Compare("AutoExport") || sFirst.Compare("AutoRarExport") || sFirst.Compare("AutoZipExport") )
2666
	else if ( sFirst.Compare("AutoSave") || sFirst.Compare("AutoExport") || sFirst.Compare("AutoRarExport") || sFirst.Compare("AutoZipExport") )
2740
	{
2667
	{
2741
		CyString filename = sRest;
2668
		CyString filename = sRest;
2742
		CyString name = m_sName;
2669
		CyString name = m_sName;
2743
		CyString author = m_sAuthor;
2670
		CyString author = m_sAuthor;
2744
		CyString cdate = m_sCreationDate;
2671
		CyString cdate = m_sCreationDate;
2745
		cdate = cdate.FindReplace("/", ".").Remove(" ");
2672
		cdate = cdate.FindReplace("/", ".").Remove(" ");
2746
		if ( filename.IsIn("$AUTOSAVE") )
2673
		if ( filename.IsIn("$AUTOSAVE") )
2747
		{
2674
		{
2748
			if ( m_iType == TYPE_XSP )
2675
			if ( this->GetType() )
2749
				filename.FindReplace("$AUTOSAVE", "$NAME-V$VERSION-$CDATE.xsp");
2676
				filename.FindReplace("$AUTOSAVE", "$NAME-V$VERSION-$CDATE.xsp");
2750
			else
2677
			else
2751
				filename.FindReplace("$AUTOSAVE", "$NAME-V$VERSION-$CDATE.spk");
2678
				filename.FindReplace("$AUTOSAVE", "$NAME-V$VERSION-$CDATE.spk");
2752
		}
2679
		}
2753
		if ( filename.IsIn("$NAME") )
2680
		if ( filename.IsIn("$NAME") )