Subversion Repositories spk

Rev

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

Rev 84 Rev 85
Line 671... Line 671...
671
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() )
671
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() )
672
		CFileIO::Remove(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.cat");
672
		CFileIO::Remove(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.cat");
673
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
673
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
674
		CFileIO::Remove(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.dat");
674
		CFileIO::Remove(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.dat");
675
 
675
 
-
 
676
	// fake patch is not being used
-
 
677
	if ( m_iFakePatch < 0 ) return true;
676
	// now lets find the fake patch
678
	// now lets find the fake patch
677
	CyString useFile;
679
	CyString useFile;
678
	if ( m_iFakePatch > 0 )
680
	if ( m_iFakePatch > 0 )
679
	{
681
	{
680
		CyString file = CyString::Number(m_iFakePatch).PadNumber(2);
682
		CyString file = CyString::Number(m_iFakePatch).PadNumber(2);
Line 774... Line 776...
774
		}
776
		}
775
 
777
 
776
		// if we're here, we tryed, and failed
778
		// if we're here, we tryed, and failed
777
		return false;
779
		return false;
778
	}
780
	}
-
 
781
	// no files found, but we have a fake patch ? restore from backup
-
 
782
	else if ( m_iFakePatch > 0 ) {
-
 
783
		CLog::log(CLog::Log_Directory, 1, "PlugMan FakePatch seems to be missing (" + Utils::String::Number(m_iFakePatch) + "), Restoring from backup");
-
 
784
		CFileIO catFile(m_sCurrentDir + "/PluginManager/Backup/PlugMan_Fake.cat");
-
 
785
		if ( catFile.exists() ) {
-
 
786
			catFile.copy(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.cat");
-
 
787
			CFileIO datFile(m_sCurrentDir + "/PluginManager/Backup/PlugMan_Fake.dat");
-
 
788
			if ( datFile.exists() ) datFile.copy(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.dat");
-
 
789
		}
-
 
790
	}
779
 
791
 
780
	// otherwise we didn't need to (hopefully)
792
	// otherwise we didn't need to (hopefully)
781
	return true;
793
	return true;
782
}
794
}
783
 
795
 
Line 790... Line 802...
790
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
802
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
791
	{
803
	{
792
		CCatFile openFile;
804
		CCatFile openFile;
793
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
805
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
794
		{
806
		{
-
 
807
//			if ( openFile.internaldatFilename().Compare("PlugMan_Fake.dat") ) return true;
795
			int count = 0;
808
			int count = 0;
796
			int noncount = 0;
809
			int noncount = 0;
797
 
810
 
798
			// check for some of the files
811
			// check for some of the files
799
			for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
812
			for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
Line 817... Line 830...
817
	return found;
830
	return found;
818
}
831
}
819
 
832
 
820
bool CPackages::CheckValidPluginManagerFile(CyString filename)
833
bool CPackages::CheckValidPluginManagerFile(CyString filename)
821
{
834
{
822
	bool found = false;
-
 
823
 
-
 
824
	// both the cat file and dat file exists, lets open it
835
	// both the cat file and dat file exists, lets open it
825
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
836
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
826
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
837
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
827
	{
838
	{
828
		CCatFile openFile;
839
		CCatFile openFile;
Line 833... Line 844...
833
			if ( openFile.FindData("pluginmanagerfake.pck") )
844
			if ( openFile.FindData("pluginmanagerfake.pck") )
834
				return true;
845
				return true;
835
		}
846
		}
836
	}
847
	}
837
 
848
 
838
	return found;
849
	return false;
839
}
850
}
840
 
851
 
841
/**
852
/**
842
 * Converts a package in old format
853
 * Converts a package in old format
843
 *
854
 *
Line 1367... Line 1378...
1367
			}
1378
			}
1368
		}
1379
		}
1369
	}
1380
	}
1370
}
1381
}
1371
 
1382
 
1372
bool CPackages::InstallPackage ( CBaseFile *package, CyStringList *errors, CProgressInfo *progress, bool disabled )
1383
bool CPackages::_checkForDisable(CBaseFile *package, bool disabled, CBaseFile *oldPackage)
1373
{
1384
{
1374
	CLog::logf(CLog::Log_Install, 1, "Starting to install new package, %s by %s (Version: %s)", package->name().c_str(), package->author().c_str(), package->version().c_str());
-
 
1375
	// first check if we are installed a mod
-
 
1376
	bool prevDisabled = disabled;
1385
	bool prevDisabled = disabled;
-
 
1386
 
-
 
1387
	// first check if we are installed a mod
1377
	if ( package->IsMod() && m_pEnabledMod && !m_bForceModInstall ) {
1388
	if ( package->IsMod() && m_pEnabledMod && !m_bForceModInstall ) {
1378
		disabled = true;
1389
		disabled = true;
1379
		CLog::log(CLog::Log_Install, 2, "Package is a mod and another mod is already enabled, setting to disabled");
1390
		CLog::log(CLog::Log_Install, 2, "Package is a mod and another mod is already enabled, setting to disabled");
1380
	}
1391
	}
1381
	// if vanilla nad package aint signed
1392
	// if vanilla nad package aint signed
Line 1389... Line 1400...
1389
		disabled = true;
1400
		disabled = true;
1390
		CLog::log(CLog::Log_Install, 2, "Dependacies missing for package, setting to disabled");
1401
		CLog::log(CLog::Log_Install, 2, "Dependacies missing for package, setting to disabled");
1391
	}
1402
	}
1392
 
1403
 
1393
	// search for an old version
1404
	// search for an old version
1394
	CBaseFile *oldPackage = FindPackage(package);
-
 
1395
	if ( oldPackage && oldPackage == m_pEnabledMod && disabled )
1405
	if ( oldPackage && oldPackage == m_pEnabledMod && disabled )
1396
		disabled = prevDisabled;
1406
		disabled = prevDisabled;
1397
 
1407
 
-
 
1408
	return disabled;
-
 
1409
}
-
 
1410
 
-
 
1411
bool CPackages::InstallPackage ( CBaseFile *package, CyStringList *errors, CProgressInfo *progress, bool disabled )
-
 
1412
{
-
 
1413
	CLog::logf(CLog::Log_Install, 1, "Starting to install new package, %s by %s (Version: %s)", package->name().c_str(), package->author().c_str(), package->version().c_str());
-
 
1414
	
-
 
1415
	CBaseFile *oldPackage = FindPackage(package);
-
 
1416
	disabled = _checkForDisable(package, disabled, oldPackage);
-
 
1417
 
1398
	// update packages must have an old package installed already (should have been checked for already)
1418
	// update packages must have an old package installed already (should have been checked for already)
1399
	if ( package->GetType() == TYPE_SPK )
1419
	if ( package->GetType() == TYPE_SPK )
1400
	{
1420
	{
1401
		if ( ((CSpkFile *)package)->IsPackageUpdate() )
1421
		if ( ((CSpkFile *)package)->IsPackageUpdate() )
1402
		{
1422
		{
Line 1705... Line 1725...
1705
			if ( !f->GetUsed() )
1725
			if ( !f->GetUsed() )
1706
			{
1726
			{
1707
				// remove from file list
1727
				// remove from file list
1708
				m_lFiles.remove(f, false);
1728
				m_lFiles.remove(f, false);
1709
 
1729
 
-
 
1730
				// if its a readme file, then check if its in the new package
-
 
1731
				bool dontRemove = false;
-
 
1732
				if ( f->GetFileType() == FILETYPE_README ) {
-
 
1733
					if ( package->FindFile(f->GetFilename(), FILETYPE_README) )
-
 
1734
						dontRemove = true;
-
 
1735
				}
-
 
1736
 
1710
				// remove from hard drive
1737
				// remove from hard drive
1711
				if ( RemoveFile(f, errors) )
1738
				if ( !dontRemove && RemoveFile(f, errors) )
1712
				{
1739
				{
1713
					CLog::logf(CLog::Log_Install, 1, "Removed unused file: %s", f->GetFilePointer().c_str());
1740
					CLog::logf(CLog::Log_Install, 1, "Removed unused file: %s", f->GetFilePointer().c_str());
1714
					// if a fake patch, we need to shufle
1741
					// if a fake patch, we need to shufle
1715
					if ( f->IsFakePatch() )
1742
					if ( f->IsFakePatch() )
1716
						shuffle = true;
1743
						shuffle = true;
Line 2560... Line 2587...
2560
		CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt file to add to Fake Patch");
2587
		CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt file to add to Fake Patch");
2561
		if ( !fakeFile.WriteFile(&lines) ) {
2588
		if ( !fakeFile.WriteFile(&lines) ) {
2562
			CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt failed!!");
2589
			CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt failed!!");
2563
		}
2590
		}
2564
		else {
2591
		else {
-
 
2592
/*
2565
			CLog::log(CLog::Log_Directory, 2, "Adding TFake.pck file into FakePatch");
2593
			CLog::log(CLog::Log_Directory, 2, "Adding TFake.pck file into FakePatch");
2566
			CCatFile fakePatch;
2594
			CCatFile fakePatch;
2567
			if ( fakePatch.Open(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat", this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE )
2595
			if ( fakePatch.Open(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat", this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE )
2568
			{
2596
			{
2569
				if ( fakePatch.AppendFile(file.ToString(), "PlugMan\\TFake.pck") )
2597
				if ( fakePatch.AppendFile(file.ToString(), "PlugMan\\TFake.pck") )
2570
					fakePatch.WriteCatFile();
2598
					fakePatch.WriteCatFile();
-
 
2599
			}	*/		
2571
			}
2600
		}
-
 
2601
 
-
 
2602
		// backup existing mod files incase something happens to them
-
 
2603
		if ( !datFile.exists() || !catFile.exists() ) {
-
 
2604
			CLog::log(CLog::Log_Directory, 2, Utils::String("ERROR: ") + (!catFile.exists() ? "cat" : "dat") + " file appears to be missing");
2572
		}
2605
		}
-
 
2606
		else {
-
 
2607
			catFile.GetDirIO().Create("Backup");
-
 
2608
			catFile.copy(catFile.dir() + "/Backup/" + catFile.filename());
-
 
2609
			datFile.copy(datFile.dir() + "/Backup/" + datFile.filename());
-
 
2610
		}
-
 
2611
 
2573
 
2612
 
2574
		// find next available fake patch
2613
		// find next available fake patch
2575
		m_iFakePatch = this->FindNextFakePatch();
2614
		m_iFakePatch = this->FindNextFakePatch();
2576
		CLog::log(CLog::Log_Directory, 2, "Finding next available fake patch number: " + (long)m_iFakePatch);
2615
		CLog::log(CLog::Log_Directory, 2, "Finding next available fake patch number: " + (long)m_iFakePatch);
2577
 
2616