Subversion Repositories spk

Rev

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

Rev 184 Rev 185
Line 972... Line 972...
972
	if ( package->GetType() == TYPE_SPK )
972
	if ( package->GetType() == TYPE_SPK )
973
	{
973
	{
974
		CSpkFile *spk = (CSpkFile *)package;
974
		CSpkFile *spk = (CSpkFile *)package;
975
		if ( spk->GetScriptType() == CSpkFile::SCRIPTTYPE_CUSTOM )
975
		if ( spk->GetScriptType() == CSpkFile::SCRIPTTYPE_CUSTOM )
976
		{
976
		{
977
			CyString type = spk->GetScriptTypeString(44);
977
			Utils::String type = spk->GetScriptTypeString(44);
978
			if ( type.Compare("Ship Upgrade") )
978
			if ( type.Compare("Ship Upgrade") )
979
				spk->SetScriptType(CSpkFile::SCRIPTTYPE_SHIPUPGRADE);
979
				spk->SetScriptType(CSpkFile::SCRIPTTYPE_SHIPUPGRADE);
980
			else if ( type.Compare("Trade Script") )
980
			else if ( type.Compare("Trade Script") )
981
				spk->SetScriptType(CSpkFile::SCRIPTTYPE_TRADE);
981
				spk->SetScriptType(CSpkFile::SCRIPTTYPE_TRADE);
982
			else if ( type.Compare("Fleet Management") )
982
			else if ( type.Compare("Fleet Management") )
Line 2594... Line 2594...
2594
	// if both exists, lets rename them
2594
	// if both exists, lets rename them
2595
	if ( catFile.exists() && datFile.exists() )
2595
	if ( catFile.exists() && datFile.exists() )
2596
	{
2596
	{
2597
		CLog::log(CLog::Log_Directory, 3, "Creating pluginmanagerfake.txt file to add to Fake Patch");
2597
		CLog::log(CLog::Log_Directory, 3, "Creating pluginmanagerfake.txt file to add to Fake Patch");
2598
		// we need to add the plugin manager file in
2598
		// we need to add the plugin manager file in
2599
		CyString file = m_sTempDir;
2599
		Utils::String file = m_sTempDir;
2600
		if ( !file.Empty() )
2600
		if ( !file.empty() )
2601
			file += "/";
2601
			file += "/";
2602
		file += "pluginmanagerfake.txt";
2602
		file += "pluginmanagerfake.txt";
2603
		file = file.FindReplace("\\", "/");
2603
		file = file.findReplace("\\", "/");
2604
		CFileIO fakeFile(file);
2604
		CFileIO fakeFile(file);
2605
		std::vector<Utils::String> lines;
2605
		std::vector<Utils::String> lines;
2606
		lines.push_back("//pluginmanager fake patch");
2606
		lines.push_back("//pluginmanager fake patch");
2607
		CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt file to add to Fake Patch");
2607
		CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt file to add to Fake Patch");
2608
		if ( !fakeFile.writeFile(&lines) ) {
2608
		if ( !fakeFile.writeFile(&lines) ) {
Line 5693... Line 5693...
5693
}
5693
}
5694
 
5694
 
5695
Utils::String parseXmlText(const Utils::String &str)
5695
Utils::String parseXmlText(const Utils::String &str)
5696
{
5696
{
5697
	Utils::String newStr(str);
5697
	Utils::String newStr(str);
5698
	CyStringList changes;
5698
	Utils::CStringList changes;
5699
 
5699
 
5700
	// find all XML commands, &<command>;
5700
	// find all XML commands, &<command>;
5701
	Utils::String sStr = str;
5701
	Utils::String sStr = str;
5702
	Utils::String::size_type pos = sStr.find_first_of("&", 0);
5702
	Utils::String::size_type pos = sStr.find_first_of("&", 0);
5703
	while ( pos != Utils::String::npos ) {
5703
	while ( pos != Utils::String::npos ) {
Line 5707... Line 5707...
5707
		if ( colonPos != Utils::String::npos && colonPos < spacePos ) {
5707
		if ( colonPos != Utils::String::npos && colonPos < spacePos ) {
5708
			// replace with <::command::> so they the & doesn't get replaced
5708
			// replace with <::command::> so they the & doesn't get replaced
5709
			Utils::String repStr = sStr.substr(pos, (colonPos + 1) - pos);
5709
			Utils::String repStr = sStr.substr(pos, (colonPos + 1) - pos);
5710
			Utils::String repWithStr = "<::" + sStr.substr(pos + 1, colonPos - pos - 1) + "::>";
5710
			Utils::String repWithStr = "<::" + sStr.substr(pos + 1, colonPos - pos - 1) + "::>";
5711
			newStr = newStr.findReplace(repStr, repWithStr);
5711
			newStr = newStr.findReplace(repStr, repWithStr);
5712
			changes.PushBack(CyString(repStr), CyString(repWithStr));
5712
			changes.pushBack(repStr, repWithStr);
5713
		}
5713
		}
5714
 
5714
 
5715
		// find the next command
5715
		// find the next command
5716
		pos = sStr.find_first_of("&", pos + 1);
5716
		pos = sStr.find_first_of("&", pos + 1);
5717
	}
5717
	}
5718
 
5718
 
5719
	// replace the & now
5719
	// replace the & now
5720
	newStr = newStr.findReplace("&", "&amp;");
5720
	newStr = newStr.findReplace("&", "&amp;");
5721
 
5721
 
5722
	// restore the commands
5722
	// restore the commands
5723
	for ( SStringList *strNode = changes.Head(); strNode; strNode = strNode->next ) {
5723
	for(auto itr = changes.begin(); itr != changes.end(); itr++)
5724
		newStr = newStr.findReplace(strNode->data.ToString(), strNode->str.ToString());
5724
		newStr = newStr.findReplace((*itr)->data, (*itr)->str);
5725
	}
-
 
5726
 
5725
 
5727
	return newStr;
5726
	return newStr;
5728
}
5727
}
5729
 
5728
 
5730
Utils::String CPackages::ConvertTextString(const Utils::String &sText)
5729
Utils::String CPackages::ConvertTextString(const Utils::String &sText)
Line 7767... Line 7766...
7767
		package = new CSpkFile();
7766
		package = new CSpkFile();
7768
 
7767
 
7769
	if ( compression != -1 )
7768
	if ( compression != -1 )
7770
		package->SetDataCompression(compression);
7769
		package->SetDataCompression(compression);
7771
 
7770
 
7772
	CyString ftpaddr;
7771
	Utils::String ftpaddr;
7773
	CyString ftpuser;
7772
	Utils::String ftpuser;
7774
	CyString ftppass;
7773
	Utils::String ftppass;
7775
	CyString ftpdir;
7774
	Utils::String ftpdir;
7776
	Utils::String sMainGame;
7775
	Utils::String sMainGame;
7777
	Utils::CStringList otherGames;
7776
	Utils::CStringList otherGames;
7778
	Utils::CStringList gameAddons;
7777
	Utils::CStringList gameAddons;
7779
	for (unsigned int i = 0; i < m_gameExe.gameCount(); ++i)
7778
	for (unsigned int i = 0; i < m_gameExe.gameCount(); ++i)
7780
	{
7779
	{
Line 7906... Line 7905...
7906
	{
7905
	{
7907
		for (auto itr = package->autoExporter()->begin(); itr != package->autoExporter()->end(); itr++)
7906
		for (auto itr = package->autoExporter()->begin(); itr != package->autoExporter()->end(); itr++)
7908
			package->saveToArchive(itr->second, itr->first, &m_gameExe);
7907
			package->saveToArchive(itr->second, itr->first, &m_gameExe);
7909
	}
7908
	}
7910
 
7909
 
7911
	if ( !ftpaddr.Empty() )
7910
	if ( !ftpaddr.empty() )
7912
	{
7911
	{
7913
		if ( !ftpuser.Empty() )
7912
		if ( !ftpuser.empty() )
7914
		{
7913
		{
7915
			if ( !ftppass.Empty() )
7914
			if ( !ftppass.empty() )
7916
				ftpaddr = ftpuser + ":" + ftppass + "@" + ftpaddr;
7915
				ftpaddr = ftpuser + ":" + ftppass + "@" + ftpaddr;
7917
			else
7916
			else
7918
				ftpaddr = ftpuser + "@" + ftpaddr;
7917
				ftpaddr = ftpuser + "@" + ftpaddr;
7919
		}
7918
		}
7920
 
7919
 
7921
		if ( !ftpdir.Empty() )
7920
		if ( !ftpdir.empty() )
7922
			ftpaddr += ftpdir;
7921
			ftpaddr += ftpdir;
7923
 
7922
 
7924
		package->setFtpAddr(ftpaddr.ToString());
7923
		package->setFtpAddr(ftpaddr);
7925
	}
7924
	}
7926
 
7925
 
7927
	return package;
7926
	return package;
7928
}
7927
}
7929
 
7928
 
Line 8277... Line 8276...
8277
 
8276
 
8278
		// extract 1 at a time
8277
		// extract 1 at a time
8279
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8278
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8280
		{
8279
		{
8281
			SInCatFile *f = cat.GetFile(i);
8280
			SInCatFile *f = cat.GetFile(i);
8282
			CyString sF = f->sFile;
8281
			Utils::String sF = f->sFile;
8283
			// is a text file
8282
			// is a text file
8284
			sF = sF.FindReplace("\\", "/");
8283
			sF = sF.findReplace("\\", "/");
8285
			if ( !sF.GetToken("/", 1, 1).Compare("t") )
8284
			if ( !sF.token("/", 1).Compare("t") )
8286
				continue;
8285
				continue;
8287
 
8286
 
8288
			Utils::String baseFile = CFileIO(sF).baseName();
8287
			Utils::String baseFile = CFileIO(sF).baseName();
8289
			// check language
8288
			// check language
8290
			int lang = 0;
8289
			int lang = 0;
Line 8405... Line 8404...
8405
 
8404
 
8406
FileType CPackages::adjustFileType(const Utils::String &file, FileType filetype) const
8405
FileType CPackages::adjustFileType(const Utils::String &file, FileType filetype) const
8407
{
8406
{
8408
	CFileIO File(file);
8407
	CFileIO File(file);
8409
	Utils::String dir = File.GetDirIO().topDir();
8408
	Utils::String dir = File.GetDirIO().topDir();
8410
	CyString basename = File.baseName();
8409
	Utils::String basename = File.baseName();
8411
 
8410
 
8412
	Utils::String ext = File.extension();
8411
	Utils::String ext = File.extension();
8413
 
8412
 
8414
	// mod files
8413
	// mod files
8415
	if (ext.Compare("cat") || ext.Compare("dat"))
8414
	if (ext.Compare("cat") || ext.Compare("dat"))
Line 8417... Line 8416...
8417
	// check for text files
8416
	// check for text files
8418
	if ( File.filename().isin("-L") && File.filename().left(4).isNumber() )
8417
	if ( File.filename().isin("-L") && File.filename().left(4).isNumber() )
8419
		return FILETYPE_TEXT;
8418
		return FILETYPE_TEXT;
8420
	if ( File.baseName().Compare("conversations") )
8419
	if ( File.baseName().Compare("conversations") )
8421
		return FILETYPE_TEXT;
8420
		return FILETYPE_TEXT;
8422
	if ( basename.Length() <= 4 && basename.IsNumber() && (File.isFileExtension("xml") || File.isFileExtension("pck")) )
8421
	if ( basename.length() <= 4 && basename.isNumber() && (File.isFileExtension("xml") || File.isFileExtension("pck")) )
8423
		return FILETYPE_TEXT;
8422
		return FILETYPE_TEXT;
8424
	// X2/X3 text file
8423
	// X2/X3 text file
8425
	if ( basename.Length() >= 5 && basename.Length() <= 8 && ((int)File.baseName()) )
8424
	if ( basename.length() >= 5 && basename.length() <= 8 && ((int)File.baseName()) )
8426
		return FILETYPE_TEXT;
8425
		return FILETYPE_TEXT;
8427
	if ( filetype == FILETYPE_TEXT ) // should no longer be anything text
8426
	if ( filetype == FILETYPE_TEXT ) // should no longer be anything text
8428
		return FILETYPE_SCRIPT;
8427
		return FILETYPE_SCRIPT;
8429
	if ( File.isFileExtension("wav") || File.isFileExtension("mp3") )
8428
	if ( File.isFileExtension("wav") || File.isFileExtension("mp3") )
8430
		return FILETYPE_SOUND;
8429
		return FILETYPE_SOUND;
Line 9278... Line 9277...
9278
 
9277
 
9279
		HeaderData.CmtBuf=NULL;
9278
		HeaderData.CmtBuf=NULL;
9280
		memset(&OpenArchiveData.Reserved,0,sizeof(OpenArchiveData.Reserved));
9279
		memset(&OpenArchiveData.Reserved,0,sizeof(OpenArchiveData.Reserved));
9281
 
9280
 
9282
		while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0) {
9281
		while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0) {
9283
			if ( CyString(HeaderData.FileName).Compare("pluginmanager.txt") ) {
9282
			if ( Utils::String(HeaderData.FileName).Compare("pluginmanager.txt") ) {
9284
				toInstall = false;
9283
				toInstall = false;
9285
				break;
9284
				break;
9286
			}
9285
			}
9287
		}
9286
		}
9288
		RARCloseArchive(hArcData);
9287
		RARCloseArchive(hArcData);
Line 9411... Line 9410...
9411
 
9410
 
9412
 
9411
 
9413
		char *iBuf = new char[ze.unc_size];
9412
		char *iBuf = new char[ze.unc_size];
9414
		UnzipItem(hz, zi, iBuf, ze.unc_size);
9413
		UnzipItem(hz, zi, iBuf, ze.unc_size);
9415
 
9414
 
9416
		Utils::String Name(CyString(ze.name).ToString());
9415
		Utils::String Name(ze.name);
9417
 
9416
 
9418
		// if its the data file, dont add it, but extract to get settings from
9417
		// if its the data file, dont add it, but extract to get settings from
9419
		if ( Name.Compare("pluginmanager.txt") )
9418
		if ( Name.Compare("pluginmanager.txt") )
9420
		{
9419
		{
9421
			this->readArchiveData(iBuf, ze.unc_size, archive);
9420
			this->readArchiveData(iBuf, ze.unc_size, archive);