Subversion Repositories spk

Rev

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

Rev 179 Rev 181
Line 908... Line 908...
908
			for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
908
			for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
909
				if ( node->Data()->fullDir().contains("::") ) {
909
				if ( node->Data()->fullDir().contains("::") ) {
910
					if (CFileIO(node->Data()->fullDir().token("::", 1)).filename().Compare("PlugMan_Fake.cat") ) {
910
					if (CFileIO(node->Data()->fullDir().token("::", 1)).filename().Compare("PlugMan_Fake.cat") ) {
911
						Utils::String filename = node->Data()->filePointer().token("::", 2);
911
						Utils::String filename = node->Data()->filePointer().token("::", 2);
912
						filename = filename.findReplace("/", "\\");
912
						filename = filename.findReplace("/", "\\");
913
						if ( openFile.FindData(filename) )
913
						if ( openFile.findData(filename) )
914
							++count;
914
							++count;
915
						else
915
						else
916
							++noncount;
916
							++noncount;
917
					}
917
					}
918
				}
918
				}
Line 933... Line 933...
933
	if ( catFile.exists() && CFileIO::Exists(m_sCurrentDir + "/" + filename.ToString() + ".dat"))
933
	if ( catFile.exists() && CFileIO::Exists(m_sCurrentDir + "/" + filename.ToString() + ".dat"))
934
	{
934
	{
935
		CCatFile openFile;
935
		CCatFile openFile;
936
		if ( openFile.open(catFile.fullFilename(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
936
		if ( openFile.open(catFile.fullFilename(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
937
		{
937
		{
938
			if ( openFile.FindData("PlugMan\\TFake.pck") )
938
			if ( openFile.findData("PlugMan\\TFake.pck") )
939
				return true;
939
				return true;
940
			if ( openFile.FindData("pluginmanagerfake.pck") )
940
			if ( openFile.findData("pluginmanagerfake.pck") )
941
				return true;
941
				return true;
942
		}
942
		}
943
	}
943
	}
944
 
944
 
945
	return false;
945
	return false;
Line 1405... Line 1405...
1405
			// check if its already in the fake patch
1405
			// check if its already in the fake patch
1406
			if ( f->Data()->fullDir().contains("::") ) {
1406
			if ( f->Data()->fullDir().contains("::") ) {
1407
				continue;
1407
				continue;
1408
			}
1408
			}
1409
			Utils::String toFile;
1409
			Utils::String toFile;
1410
			if ( cat.AppendFile(f->Data()->filePointer(), f->Data()->getNameDirectory(pPackage), true, (m_iGameFlags & EXEFLAG_NOXOR) ? false : true, &toFile) ) {
1410
			if ( cat.appendFile(f->Data()->filePointer(), f->Data()->getNameDirectory(pPackage), true, (m_iGameFlags & EXEFLAG_NOXOR) ? false : true, &toFile) ) {
1411
				CLog::logf(CLog::Log_Install, 2, "Adding file: %s into the fake patch", f->Data()->getNameDirectory(pPackage).c_str());
1411
				CLog::logf(CLog::Log_Install, 2, "Adding file: %s into the fake patch", f->Data()->getNameDirectory(pPackage).c_str());
1412
				CFileIO::Remove(f->Data()->filePointer());
1412
				CFileIO::Remove(f->Data()->filePointer());
1413
				f->Data()->setFilename(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat::" + toFile);
1413
				f->Data()->setFilename(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat::" + toFile);
1414
			}
1414
			}
1415
		}
1415
		}
Line 1593... Line 1593...
1593
						if ( catTo.open(findMatching->filePointer(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
1593
						if ( catTo.open(findMatching->filePointer(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
1594
						{
1594
						{
1595
							for (unsigned int i = 0; i < catFrom.GetNumFiles(); i++ )
1595
							for (unsigned int i = 0; i < catFrom.GetNumFiles(); i++ )
1596
							{
1596
							{
1597
								SInCatFile *c = catFrom.GetFile(i);								 
1597
								SInCatFile *c = catFrom.GetFile(i);								 
1598
								catTo.AppendFile(f->Data()->filePointer() + "::" + c->sFile, c->sFile);
1598
								catTo.appendFile(f->Data()->filePointer() + "::" + c->sFile, c->sFile);
1599
							}
1599
							}
1600
						}
1600
						}
1601
					}
1601
					}
1602
 
1602
 
1603
					// now remove the files
1603
					// now remove the files
Line 5091... Line 5091...
5091
		CFileIO CatFile(file->filePointer().token("::", 1));
5091
		CFileIO CatFile(file->filePointer().token("::", 1));
5092
		if ( CatFile.exists() ) {
5092
		if ( CatFile.exists() ) {
5093
			CCatFile cat;
5093
			CCatFile cat;
5094
			if ( cat.open(CatFile.fullFilename(), this->getAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
5094
			if ( cat.open(CatFile.fullFilename(), this->getAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
5095
				Utils::String fileName = file->filePointer().token("::", 2);
5095
				Utils::String fileName = file->filePointer().token("::", 2);
5096
				if ( cat.FindData(fileName) ) {
5096
				if ( cat.findData(fileName) ) {
5097
					if ( cat.removeFile(fileName) ) {
5097
					if ( cat.removeFile(fileName) ) {
5098
						this->AddLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
5098
						this->AddLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
5099
					}
5099
					}
5100
					else {
5100
					else {
5101
						this->AddLogEntry(SPKINSTALL_DELETEFILE_FAIL, remFileStr, errors);
5101
						this->AddLogEntry(SPKINSTALL_DELETEFILE_FAIL, remFileStr, errors);
Line 5449... Line 5449...
5449
				continue;
5449
				continue;
5450
 
5450
 
5451
			CCatFile catFile;
5451
			CCatFile catFile;
5452
			if (catFile.open(file->filePointer(), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5452
			if (catFile.open(file->filePointer(), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5453
			{
5453
			{
5454
				if (catFile.ExtractFile(aFilename, aTo))
5454
				if (catFile.extractFile(aFilename, aTo))
5455
					return 1;
5455
					return 1;
5456
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5456
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5457
				{
5457
				{
5458
					if (catFile.ExtractFile(aFilename))
5458
					if (catFile.extractFile(aFilename))
5459
						return -1;
5459
						return -1;
5460
				}
5460
				}
5461
 
5461
 
5462
			}
5462
			}
5463
		}
5463
		}
Line 5467... Line 5467...
5467
		if (CFileIO::Exists(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat"))
5467
		if (CFileIO::Exists(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat"))
5468
		{
5468
		{
5469
			CCatFile catFile;
5469
			CCatFile catFile;
5470
			if (catFile.open(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat", addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5470
			if (catFile.open(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat", addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5471
			{
5471
			{
5472
				if (catFile.ExtractFile(aFilename, aTo))
5472
				if (catFile.extractFile(aFilename, aTo))
5473
					return 1;
5473
					return 1;
5474
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5474
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5475
				{
5475
				{
5476
					if (catFile.ExtractFile(aFilename))
5476
					if (catFile.extractFile(aFilename))
5477
						return -1;
5477
						return -1;
5478
				}
5478
				}
5479
			}
5479
			}
5480
		}
5480
		}
5481
	}
5481
	}
Line 5493... Line 5493...
5493
	{
5493
	{
5494
		CCatFile catFile;
5494
		CCatFile catFile;
5495
		if (catFile.open((dir + "/" + Utils::String::PadNumber(catNumber, 2) + ".cat"), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5495
		if (catFile.open((dir + "/" + Utils::String::PadNumber(catNumber, 2) + ".cat"), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5496
		{
5496
		{
5497
			// check for the file
5497
			// check for the file
5498
			if (catFile.ExtractFile(aFilename, aTo))
5498
			if (catFile.extractFile(aFilename, aTo))
5499
				return 1;
5499
				return 1;
5500
			if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5500
			if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5501
			{
5501
			{
5502
				if (catFile.ExtractFile(aFilename))
5502
				if (catFile.extractFile(aFilename))
5503
					return -1;
5503
					return -1;
5504
			}
5504
			}
5505
		}
5505
		}
5506
	}
5506
	}
5507
 
5507
 
Line 5521... Line 5521...
5521
		// lets extract the ware file
5521
		// lets extract the ware file
5522
		char wareType = CPackages::ConvertWareTypeBack(i);
5522
		char wareType = CPackages::ConvertWareTypeBack(i);
5523
		Utils::String wareFile = "TWare";
5523
		Utils::String wareFile = "TWare";
5524
		wareFile += (char)UPPER(wareType);
5524
		wareFile += (char)UPPER(wareType);
5525
 
5525
 
5526
		CyString openFile;
5526
		Utils::String openFile;
5527
 
5527
 
5528
		int e;
5528
		int e;
5529
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + "/TWareT.txt") )
5529
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + "/TWareT.txt") )
5530
			openFile = m_sTempDir + "/TWareT.txt";
5530
			openFile = m_sTempDir + "/TWareT.txt";
5531
		else {
5531
		else {
Line 5534... Line 5534...
5534
				openFile = m_sTempDir + "/" + wareFile + ".txt";
5534
				openFile = m_sTempDir + "/" + wareFile + ".txt";
5535
			else if ( e == -2 )
5535
			else if ( e == -2 )
5536
				openFile = wareFile + ".txt";
5536
				openFile = wareFile + ".txt";
5537
		}
5537
		}
5538
 
5538
 
5539
		if ( !openFile.Empty() )
5539
		if ( !openFile.empty() )
5540
		{
5540
		{
5541
			// read the file into memory
5541
			// read the file into memory
5542
			Utils::CStringList wareLines;
5542
			Utils::CStringList wareLines;
5543
			size_t oldSize = -1;
5543
			size_t oldSize = -1;
5544
			int version = -1;
5544
			int version = -1;
Line 7711... Line 7711...
7711
		CCatFile catFile;
7711
		CCatFile catFile;
7712
		int error = catFile.open(m_sCurrentDir + "/mods/PluginManager.cat", this->getAddonDir(), CATREAD_CATDECRYPT, true);
7712
		int error = catFile.open(m_sCurrentDir + "/mods/PluginManager.cat", this->getAddonDir(), CATREAD_CATDECRYPT, true);
7713
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7713
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7714
		{
7714
		{
7715
			// it it wrote ok, remove the old ones
7715
			// it it wrote ok, remove the old ones
7716
			if ( !catFile.AppendFile(File->fullFilename(), filename, true, true) )
7716
			if ( !catFile.appendFile(File->fullFilename(), filename, true, true) )
7717
				return false;
7717
				return false;
7718
			return true;
7718
			return true;
7719
		}
7719
		}
7720
	}
7720
	}
7721
	else
7721
	else
Line 8391... Line 8391...
8391
	{
8391
	{
8392
		CCatFile cat;
8392
		CCatFile cat;
8393
		if ( cat.open(file.ToString(), this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8393
		if ( cat.open(file.ToString(), this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8394
			return false;
8394
			return false;
8395
 
8395
 
8396
		if ( !cat.ExtractFile("types\\TShips.pck", m_sTempDir + "/tships.txt") )
8396
		if ( !cat.extractFile("types\\TShips.pck", m_sTempDir + "/tships.txt") )
8397
			return false;
8397
			return false;
8398
 
8398
 
8399
		File.open(m_sTempDir + "/tships.txt");
8399
		File.open(m_sTempDir + "/tships.txt");
8400
		deleteFile = true;
8400
		deleteFile = true;
8401
	}
8401
	}
Line 8523... Line 8523...
8523
 
8523
 
8524
			if ( lang != m_iLanguage )
8524
			if ( lang != m_iLanguage )
8525
				continue;
8525
				continue;
8526
 
8526
 
8527
			// now extract and parse
8527
			// now extract and parse
8528
			if ( cat.ExtractFile(f->sFile, m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml") )
8528
			if ( cat.extractFile(f->sFile, m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml") )
8529
			{
8529
			{
8530
				if ( this->ReadTextPage(m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml", list, search, page) )
8530
				if ( this->ReadTextPage(m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml", list, search, page) )
8531
					done = true;
8531
					done = true;
8532
			}
8532
			}
8533
		}
8533
		}
Line 8745... Line 8745...
8745
	for(auto itr = list.begin(); itr != list.end(); itr++)
8745
	for(auto itr = list.begin(); itr != list.end(); itr++)
8746
	{		
8746
	{		
8747
		int status = (*itr)->data.toInt();
8747
		int status = (*itr)->data.toInt();
8748
		if ( status == 1 )
8748
		if ( status == 1 )
8749
		{
8749
		{
8750
			if ( !newCat.WriteFromCat(mod1, (*itr)->str) )
8750
			if ( !newCat.writeFromCat(mod1, (*itr)->str) )
8751
			{
8751
			{
8752
				if ( cantMerge )
8752
				if ( cantMerge )
8753
					cantMerge->PushBack(CyString((*itr)->str), "1");
8753
					cantMerge->PushBack(CyString((*itr)->str), "1");
8754
			}
8754
			}
8755
		}
8755
		}
8756
		else if ( status == 2 )
8756
		else if ( status == 2 )
8757
		{
8757
		{
8758
			if ( !newCat.WriteFromCat(mod2, (*itr)->str) )
8758
			if ( !newCat.writeFromCat(mod2, (*itr)->str) )
8759
			{
8759
			{
8760
				if ( cantMerge )
8760
				if ( cantMerge )
8761
					cantMerge->PushBack(CyString((*itr)->str), "2");
8761
					cantMerge->PushBack(CyString((*itr)->str), "2");
8762
			}
8762
			}
8763
		}
8763
		}
Line 8770... Line 8770...
8770
				else if ( cantMerge )
8770
				else if ( cantMerge )
8771
					cantMerge->PushBack(CyString((*itr)->str), "-1");
8771
					cantMerge->PushBack(CyString((*itr)->str), "-1");
8772
			}
8772
			}
8773
			else
8773
			else
8774
			{
8774
			{
8775
				if ( !newCat.WriteFromCat(mod1, (*itr)->str) )
8775
				if ( !newCat.writeFromCat(mod1, (*itr)->str) )
8776
				{
8776
				{
8777
					if ( cantMerge )
8777
					if ( cantMerge )
8778
						cantMerge->PushBack(CyString((*itr)->str), "1");
8778
						cantMerge->PushBack(CyString((*itr)->str), "1");
8779
				}
8779
				}
8780
			}
8780
			}
Line 9787... Line 9787...
9787
			Utils::String file = f->filePointer().token("::", 2);
9787
			Utils::String file = f->filePointer().token("::", 2);
9788
 
9788
 
9789
			if ( CFileIO::Exists(modFile)) {
9789
			if ( CFileIO::Exists(modFile)) {
9790
				CCatFile catFile;
9790
				CCatFile catFile;
9791
				if ( catFile.open(modFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
9791
				if ( catFile.open(modFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
9792
					if ( catFile.FindData(file) )
9792
					if ( catFile.findData(file) )
9793
						exists = true;
9793
						exists = true;
9794
				}
9794
				}
9795
			}
9795
			}
9796
		}
9796
		}
9797
		else {
9797
		else {