Subversion Repositories spk

Rev

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

Rev 126 Rev 127
Line 331... Line 331...
331
						{
331
						{
332
							origName = fileName.token("O#", 2);
332
							origName = fileName.token("O#", 2);
333
							fileName = fileName.token("O#", 1);
333
							fileName = fileName.token("O#", 1);
334
						}
334
						}
335
 
335
 
336
						C_File *newFile = new C_File( m_sCurrentDir + fileName );
336
						C_File *newFile = new C_File(m_sCurrentDir.ToString() + fileName);
337
						newFile->SetGame(game);
337
						newFile->setGame(game);
338
						newFile->SetOriginalName(origName);
338
						newFile->SetOriginalName(origName);
339
						newFile->SetDisabled(disabled);
339
						newFile->SetDisabled(disabled);
340
						newFile->SetFileType(line.token(":", 1).toLong());
340
						newFile->setFileType((FileType)line.token(":", 1).toLong());
341
						newFile->SetCreationTime((time_t)line.token(":", 2).toLong());
341
						newFile->SetCreationTime((time_t)line.token(":", 2).toLong());
342
						newFile->SetDir(line.token(":", 3));
342
						newFile->SetDir(line.token(":", 3));
343
						if ( line.token(":", 4).toLong() )
343
						if ( line.token(":", 4).toLong() )
344
							newFile->SetShared(true);
344
							newFile->SetShared(true);
345
						newFile->UpdateSigned();
345
						newFile->UpdateSigned();
Line 373... Line 373...
373
						packageFile->SetEnabled(false);
373
						packageFile->SetEnabled(false);
374
					else if ( cmd == "modifieddisabled" )
374
					else if ( cmd == "modifieddisabled" )
375
						packageFile->SetModifiedEnabled(false);
375
						packageFile->SetModifiedEnabled(false);
376
					else if ( cmd == "icon" )
376
					else if ( cmd == "icon" )
377
					{
377
					{
378
						C_File *icon = new C_File(CyString(rest.tokens(" ", 2)));
378
						C_File *icon = new C_File(rest.tokens(" ", 2));
379
						packageFile->SetIcon(icon, rest.token(" ", 1));
379
						packageFile->SetIcon(icon, rest.token(" ", 1));
380
					}
380
					}
381
					else
381
					else
382
						packageFile->ParseValueLine(line);
382
						packageFile->ParseValueLine(line);
383
				}
383
				}
Line 706... Line 706...
706
	Utils::String logDir = m_sCurrentDir.ToString();
706
	Utils::String logDir = m_sCurrentDir.ToString();
707
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG ) {
707
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG ) {
708
		SGameExe *exe = m_gameExe.GetGame(m_iGame - 1);
708
		SGameExe *exe = m_gameExe.GetGame(m_iGame - 1);
709
		if ( exe ) {
709
		if ( exe ) {
710
			if ( !exe->sMyDoc.empty() )
710
			if ( !exe->sMyDoc.empty() )
711
				logDir = m_sMyDoc.ToString() + "/" + exe->sMyDoc;
711
				logDir = m_sMyDoc + "/" + exe->sMyDoc;
712
		}
712
		}
713
	}
713
	}
714
 
714
 
715
	return logDir;
715
	return logDir;
716
}
716
}
Line 722... Line 722...
722
	{
722
	{
723
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
723
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
724
		if ( exe )
724
		if ( exe )
725
		{
725
		{
726
			if ( !exe->sMyDoc.empty() )
726
			if ( !exe->sMyDoc.empty() )
727
				logDir = m_sMyDoc.ToString() + "/" + exe->sMyDoc;
727
				logDir = m_sMyDoc + "/" + exe->sMyDoc;
728
		}
728
		}
729
	}
729
	}
730
 
730
 
731
	return CFileIO(logDir).fullFilename();
731
	return CFileIO(logDir).fullFilename();
732
}
732
}
Line 1380... Line 1380...
1380
	if ( CCatFile::Opened(cat.open((m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ToString(), this->getAddonDir(), CATREAD_DAT)) ) {
1380
	if ( CCatFile::Opened(cat.open((m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ToString(), this->getAddonDir(), CATREAD_DAT)) ) {
1381
		for ( CListNode<C_File> *f = pPackage->GetFileList()->Front(); f; f = f->next() ) {
1381
		for ( CListNode<C_File> *f = pPackage->GetFileList()->Front(); f; f = f->next() ) {
1382
			if ( f->Data()->GetFileType() != FILETYPE_SHIPSCENE && f->Data()->GetFileType() != FILETYPE_COCKPITSCENE && f->Data()->GetFileType() != FILETYPE_SHIPMODEL && f->Data()->GetFileType() != FILETYPE_SHIPOTHER ) {
1382
			if ( f->Data()->GetFileType() != FILETYPE_SHIPSCENE && f->Data()->GetFileType() != FILETYPE_COCKPITSCENE && f->Data()->GetFileType() != FILETYPE_SHIPMODEL && f->Data()->GetFileType() != FILETYPE_SHIPOTHER ) {
1383
				continue;
1383
				continue;
1384
			}
1384
			}
1385
			if ( CCatFile::IsAddonDir(f->Data()->GetNameDirectory(pPackage)) ) {
1385
			if ( CCatFile::IsAddonDir(f->Data()->GetNameDirectory(pPackage).ToString()) ) {
1386
				continue;
1386
				continue;
1387
			}
1387
			}
1388
			// check if its already in the fake patch
1388
			// check if its already in the fake patch
1389
			if ( f->Data()->GetFullDir().IsIn("::") ) {
1389
			if ( f->Data()->GetFullDir().IsIn("::") ) {
1390
				continue;
1390
				continue;
Line 4600... Line 4600...
4600
	}
4600
	}
4601
 
4601
 
4602
	for(std::vector<CyString>::iterator it = frontLines.begin(); it != frontLines.end(); ++it)
4602
	for(std::vector<CyString>::iterator it = frontLines.begin(); it != frontLines.end(); ++it)
4603
		lines->insert(lines->begin(), *it);
4603
		lines->insert(lines->begin(), *it);
4604
 
4604
 
4605
	addFile = new C_File(newFilename + ".xml");
4605
	addFile = new C_File(newFilename.ToString() + ".xml");
4606
	addFile->SetFileType(FILETYPE_TEXT);
4606
	addFile->SetFileType(FILETYPE_TEXT);
4607
 
4607
 
4608
	CFileIO writeFile(m_sCurrentDir + "/" + addFile->GetNameDirectory(NULL));
4608
	CFileIO writeFile(m_sCurrentDir + "/" + addFile->GetNameDirectory(NULL));
4609
	if ( writeFile.WriteFile(lines) )
4609
	if ( writeFile.WriteFile(lines) )
4610
	{
4610
	{
Line 4805... Line 4805...
4805
	int num = 0;
4805
	int num = 0;
4806
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
4806
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
4807
		node->Data()->SetNum(num++);
4807
		node->Data()->SetNum(num++);
4808
}
4808
}
4809
 
4809
 
4810
CyString CPackages::FindDataDir(CyString dir, CyString sFile)
4810
Utils::String CPackages::findDataDir(const Utils::String &dir, const Utils::String &file)
4811
{
4811
{
4812
	CDirIO Dir(dir.ToString());
4812
	CDirIO Dir(dir);
4813
	Utils::String file = sFile.ToString();
-
 
4814
 
4813
 
4815
	// data files could be in 4 places depending on what program is used, check for all of these
4814
	// data files could be in 4 places depending on what program is used, check for all of these
4816
	if ( Dir.exists(file) )
4815
	if (Dir.exists(file))
4817
		return Dir.file(file);
4816
		return Dir.file(file);
4818
	else if ( Dir.exists("Data/" + file) )
4817
	else if (Dir.exists("Data/" + file))
4819
		return Dir.file("Data/" + file);
4818
		return Dir.file("Data/" + file);
4820
	else if ( Dir.exists("../" + file) )
4819
	else if (Dir.exists("../" + file))
4821
		return Dir.file("../" + file);
4820
		return Dir.file("../" + file);
4822
	else if ( Dir.exists("../Data/" + file) )
4821
	else if (Dir.exists("../Data/" + file))
4823
		return Dir.file("../Data/" + file);
4822
		return Dir.file("../Data/" + file);
4824
 
4823
 
4825
	return NullString;
4824
	return Utils::String::Null();
4826
}
4825
}
4827
 
4826
 
4828
void CPackages::Startup(CyString dir, CyString tempDir, CyString myDoc, CyString mod)
4827
void CPackages::startup(const Utils::String &dir, const Utils::String &tempDir, const Utils::String &myDoc)
4829
{
4828
{
4830
	this->SetTempDirectory(tempDir);
4829
	this->setTempDirectory(tempDir);
4831
	this->SetMyDocuments(myDoc);
4830
	this->setMyDocuments(myDoc);
4832
 
-
 
4833
	m_sSetMod = mod;
-
 
4834
 
4831
 
4835
	// need to read the game exe versions
4832
	// need to read the game exe versions
4836
	m_gameExe.Reset();
4833
	m_gameExe.Reset();
4837
 
4834
 
4838
	CyString exeFile = this->FindDataDir(dir, "exe");
4835
	Utils::String exeFile = this->findDataDir(dir, "exe");
4839
 
4836
 
4840
	// if file exists, read it, otherwise, just add
4837
	// if file exists, read it, otherwise, just add
4841
	if ( !exeFile.Empty() && CFileIO(exeFile).ExistsOld() )
4838
	if (!exeFile.empty() && CFileIO::Exists(exeFile))
4842
		m_gameExe.ReadFile(exeFile.ToString());
4839
		m_gameExe.ReadFile(exeFile);
4843
	else
4840
	else
4844
	{
4841
	{
4845
		m_gameExe.ParseExe("x2.exe|0:5:NOSAVESUBDIR:HKCU/Software/EgoSoftware/X2/ModName:X2 The Threat:!GAMEDIR!:2:1604608!2150400:1.4 Artifical Life:1974272:1.5 Uplink");
4842
		m_gameExe.ParseExe("x2.exe|0:5:NOSAVESUBDIR:HKCU/Software/EgoSoftware/X2/ModName:X2 The Threat:!GAMEDIR!:2:1604608!2150400:1.4 Artifical Life:1974272:1.5 Uplink");
4846
		m_gameExe.ParseExe("x3.exe|30:5:0:HKCU/Software/Egosoft/X3/ModName:X3 Reunion:Egosoft/X3:2:2347008:2.0 Bala Gi:2367488!2375680:2.5 Uplink");
4843
		m_gameExe.ParseExe("x3.exe|30:5:0:HKCU/Software/Egosoft/X3/ModName:X3 Reunion:Egosoft/X3:2:2347008:2.0 Bala Gi:2367488!2375680:2.5 Uplink");
4847
		m_gameExe.ParseExe("x3tc.exe|35:5:NO_XOR|TC_TEXT|MYDOCLOG:HKCU/Software/Egosoft/X3TC/ModName:X3 Terran Conflict:Egosoft/X3TC:3:1933464!1933520:2.0 Aldrin Expansion:-1:2.5 A New Home (Superbox):-1:3.0 Balance of Power");
4844
		m_gameExe.ParseExe("x3tc.exe|35:5:NO_XOR|TC_TEXT|MYDOCLOG:HKCU/Software/Egosoft/X3TC/ModName:X3 Terran Conflict:Egosoft/X3TC:3:1933464!1933520:2.0 Aldrin Expansion:-1:2.5 A New Home (Superbox):-1:3.0 Balance of Power");
4848
		m_gameExe.ParseExe("x3ap.exe|38:2:NO_XOR|TC_TEXT|MYDOCLOG|ADDON:HKCU/Software/Egosoft/X3AP/ModName:X3 Albion Prelude:Egosoft/X3AP:addon!x3tc.exe:3:-1:2.0 The War Continues:-1:2.5 Operation Loose Ends:-1:3.0 Shady Business");
4845
		m_gameExe.ParseExe("x3ap.exe|38:2:NO_XOR|TC_TEXT|MYDOCLOG|ADDON:HKCU/Software/Egosoft/X3AP/ModName:X3 Albion Prelude:Egosoft/X3AP:addon!x3tc.exe:3:-1:2.0 The War Continues:-1:2.5 Operation Loose Ends:-1:3.0 Shady Business");
4849
	}
4846
	}
4850
}
4847
}
-
 
4848
void CPackages::startup(const Utils::String &dir, const Utils::String &tempDir, const Utils::String &myDoc, const Utils::String &mod)
-
 
4849
{
-
 
4850
	startup(dir, tempDir, myDoc);
-
 
4851
	m_sSetMod = mod;
-
 
4852
}
-
 
4853
void CPackages::Startup(CyString dir, CyString tempDir, CyString myDoc, CyString mod)
-
 
4854
{
-
 
4855
	startup(dir.ToString(), tempDir.ToString(), myDoc.ToString(), mod.ToString());
-
 
4856
}
4851
 
4857
 
4852
int CPackages::GetGameLanguage() const
4858
int CPackages::GetGameLanguage() const
4853
{
4859
{
4854
	return this->GetGameLanguage(m_sCurrentDir.ToString());
4860
	return this->GetGameLanguage(m_sCurrentDir.ToString());
4855
}
4861
}
Line 7465... Line 7471...
7465
	}
7471
	}
7466
 
7472
 
7467
	return NULL;
7473
	return NULL;
7468
}
7474
}
7469
 
7475
 
-
 
7476
bool CPackages::generatePackagerScript(CBaseFile *baseFile, bool wildcard, Utils::CStringList *list, int game, bool datafile) const
-
 
7477
{	
-
 
7478
	if (!baseFile)
-
 
7479
		return false;
-
 
7480
 
-
 
7481
	Utils::CStringList gameAddons;
-
 
7482
	for (unsigned int i = 0; i < m_gameExe.gameCount(); ++i)
-
 
7483
	{
-
 
7484
		SGameExe *exe = m_gameExe.GetGame(i);
-
 
7485
		if (!exe->sAddon.empty())
-
 
7486
			gameAddons.pushBack(Utils::String::Number(i + 1), exe->sAddon);
-
 
7487
	}
-
 
7488
 
-
 
7489
	return baseFile->GeneratePackagerScript(wildcard, list, game, gameAddons, datafile);
-
 
7490
}
-
 
7491
 
7470
CBaseFile *CPackages::LoadPackagerScript(CyString filename, int compression, CyString (*askFunc)(CyString), CyStringList *malformedLines, CyStringList *unknownCommands, CyStringList *variables)
7492
CBaseFile *CPackages::LoadPackagerScript(CyString filename, int compression, Utils::String (*askFunc)(const Utils::String &), CyStringList *malformedLines, CyStringList *unknownCommands, CyStringList *variables)
7471
{
7493
{
7472
	// check the file exists
7494
	// check the file exists
7473
	if ( !CFileIO::Exists(filename.ToString()) )
7495
	if ( !CFileIO::Exists(filename.ToString()) )
7474
		return NULL;
7496
		return NULL;
7475
 
7497
 
Line 7539... Line 7561...
7539
	CyString ftpuser;
7561
	CyString ftpuser;
7540
	CyString ftppass;
7562
	CyString ftppass;
7541
	CyString ftpdir;
7563
	CyString ftpdir;
7542
	Utils::String sMainGame;
7564
	Utils::String sMainGame;
7543
	Utils::CStringList otherGames;
7565
	Utils::CStringList otherGames;
-
 
7566
	Utils::CStringList gameAddons;
-
 
7567
	for (unsigned int i = 0; i < m_gameExe.gameCount(); ++i)
-
 
7568
	{
-
 
7569
		SGameExe *exe = m_gameExe.GetGame(i);
-
 
7570
		if (!exe->sAddon.empty())
-
 
7571
			gameAddons.pushBack(Utils::String::Number(i + 1), exe->sAddon);
-
 
7572
	}
7544
 
7573
 
7545
	// now lets read the rest of the day
7574
	// now lets read the rest of the day
7546
	CyStringList listVaribles;
7575
	CyStringList listVaribles;
7547
	for ( Utils::SStringList *line = fileData.first(); line; line = fileData.next() )
7576
	for ( Utils::SStringList *line = fileData.first(); line; line = fileData.next() )
7548
	{
7577
	{
Line 7571... Line 7600...
7571
					}
7600
					}
7572
				}
7601
				}
7573
			}
7602
			}
7574
 
7603
 
7575
			//check for the built in varibles
7604
			//check for the built in varibles
7576
			if ( rest.isin("$ASK") )
7605
			if ( rest.contains("$ASK") )
7577
			{
7606
			{
7578
				Utils::String replace = "$ASK";
7607
				Utils::String replace = "$ASK";
7579
				Utils::String result;
7608
				Utils::String result;
7580
 
7609
 
7581
				if ( askFunc )
7610
				if ( askFunc )
7582
					result = askFunc(CyString(cmd)).ToString();
7611
					result = askFunc(cmd);
7583
 
7612
 
7584
				if ( rest.isin("$ASK(") )
7613
				if ( rest.contains("$ASK(") )
7585
				{
7614
				{
7586
					replace = rest.tokens("$ASK(", 2).token(")", 1);
7615
					replace = rest.tokens("$ASK(", 2).token(")", 1);
7587
					if ( result.empty() )
7616
					if ( result.empty() )
7588
						result = replace;
7617
						result = replace;
7589
					replace = "$ASK(" + replace + ")";
7618
					replace = "$ASK(" + replace + ")";
Line 7603... Line 7632...
7603
					rest = rest.findReplace("$DATE", result);
7632
					rest = rest.findReplace("$DATE", result);
7604
			}
7633
			}
7605
			// mydocuments
7634
			// mydocuments
7606
			if ( rest.isin("$MYDOCUMENTS") )
7635
			if ( rest.isin("$MYDOCUMENTS") )
7607
			{
7636
			{
7608
				if ( !m_sMyDoc.Empty() )
7637
				if ( !m_sMyDoc.empty() )
7609
					rest = rest.findReplace("$MYDOCUMENTS", m_sMyDoc.ToString());
7638
					rest = rest.findReplace("$MYDOCUMENTS", m_sMyDoc);
7610
			}
7639
			}
7611
 
7640
 
7612
			// current path
7641
			// current path
7613
			if ( rest.isin("$PATH") )
7642
			if ( rest.isin("$PATH") )
7614
			{
7643
			{
Line 7628... Line 7657...
7628
				ftpdir = rest;
7657
				ftpdir = rest;
7629
			else if ( cmd.Compare("MultiGames") ) {
7658
			else if ( cmd.Compare("MultiGames") ) {
7630
				sMainGame = rest.token(" ", 1);
7659
				sMainGame = rest.token(" ", 1);
7631
				otherGames.tokenise(rest.tokens(" ", 2), " ");
7660
				otherGames.tokenise(rest.tokens(" ", 2), " ");
7632
			}
7661
			}
7633
			else if ( !package->LoadPackageData(cmd, rest, sMainGame, otherGames) )
7662
			else if ( !package->LoadPackageData(cmd, rest, sMainGame, otherGames, gameAddons) )
7634
			{
7663
			{
7635
				if ( unknownCommands )
7664
				if ( unknownCommands )
7636
					unknownCommands->PushBack(CyString(cmd), CyString(rest));
7665
					unknownCommands->PushBack(CyString(cmd), CyString(rest));
7637
			}
7666
			}
7638
		}
7667
		}
7639
	}
7668
	}
7640
 
7669
 
7641
	if ( package->filename().empty() )
7670
	if ( package->filename().empty() )
7642
		package->LoadPackageData("AutoSave", "$AUTOSAVE", sMainGame, otherGames);
7671
		package->LoadPackageData("AutoSave", "$AUTOSAVE", sMainGame, otherGames, gameAddons);
7643
 
7672
 
7644
	if ( !ftpaddr.Empty() )
7673
	if ( !ftpaddr.Empty() )
7645
	{
7674
	{
7646
		if ( !ftpuser.Empty() )
7675
		if ( !ftpuser.Empty() )
7647
		{
7676
		{
Line 7777... Line 7806...
7777
		deleteFile = true;
7806
		deleteFile = true;
7778
	}
7807
	}
7779
	// otherwise its a normal file
7808
	// otherwise its a normal file
7780
	else if ( CFileIO(file).CheckFileExtension("pck") )
7809
	else if ( CFileIO(file).CheckFileExtension("pck") )
7781
	{
7810
	{
7782
		C_File f(file);
7811
		C_File f(file.ToString());
7783
		if ( !f.ReadFromFile() )
7812
		if ( !f.ReadFromFile() )
7784
			return false;
7813
			return false;
7785
		f.UnPCKFile();
7814
		f.UnPCKFile();
7786
 
7815
 
7787
		f.SetFilename(m_sTempDir + "/tships.txt");
7816
		f.SetFilename(m_sTempDir + "/tships.txt");
Line 7914... Line 7943...
7914
		return done;
7943
		return done;
7915
	}
7944
	}
7916
	// otherwise its a normal file
7945
	// otherwise its a normal file
7917
	else if ( CFileIO(file).CheckFileExtension("pck") )
7946
	else if ( CFileIO(file).CheckFileExtension("pck") )
7918
	{
7947
	{
7919
		C_File f(file);
7948
		C_File f(file.ToString());
7920
		if ( !f.ReadFromFile() )
7949
		if ( !f.ReadFromFile() )
7921
			return false;
7950
			return false;
7922
		f.UnPCKFile();
7951
		f.UnPCKFile();
7923
 
7952
 
7924
		f.SetFilename(m_sTempDir + "/textfile.xml");
7953
		f.SetFilename(m_sTempDir + "/textfile.xml");
Line 8606... Line 8635...
8606
}
8635
}
8607
 
8636
 
8608
void CPackages::ReadArchiveData(const char *buf, size_t len, CBaseFile *archive)
8637
void CPackages::ReadArchiveData(const char *buf, size_t len, CBaseFile *archive)
8609
{
8638
{
8610
	Utils::CStringList otherGames;
8639
	Utils::CStringList otherGames;
-
 
8640
	Utils::CStringList gameAddons;
-
 
8641
	for (unsigned int i = 0; i < m_gameExe.gameCount(); ++i)
-
 
8642
	{
-
 
8643
		SGameExe *exe = m_gameExe.GetGame(i);
-
 
8644
		if (!exe->sAddon.empty())
-
 
8645
			gameAddons.pushBack(Utils::String::Number(i + 1), exe->sAddon);
-
 
8646
	}
8611
 
8647
 
8612
	CyString data(buf);
8648
	CyString data(buf);
8613
	int max;
8649
	int max;
8614
	CyString *str = data.SplitToken("\n", &max);
8650
	CyString *str = data.SplitToken("\n", &max);
8615
	if ( str && max )
8651
	if ( str && max )
Line 8650... Line 8686...
8650
			}
8686
			}
8651
 
8687
 
8652
			// now check type name
8688
			// now check type name
8653
			int filetype = GetFileTypeFromString(checkType);
8689
			int filetype = GetFileTypeFromString(checkType);
8654
			if ( filetype == -1 )
8690
			if ( filetype == -1 )
8655
				archive->LoadPackageData(first.ToString(), rest.ToString(), Utils::String::Null(), otherGames);
8691
				archive->LoadPackageData(first.ToString(), rest.ToString(), Utils::String::Null(), otherGames, gameAddons);
8656
		}
8692
		}
8657
	}
8693
	}
8658
 
8694
 
8659
	CLEANSPLIT(str, max)
8695
	CLEANSPLIT(str, max)
8660
}
8696
}