Subversion Repositories spk

Rev

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

Rev 226 Rev 227
Line 744... Line 744...
744
}
744
}
745
 
745
 
746
bool CPackages::ReadyFakePatch()
746
bool CPackages::ReadyFakePatch()
747
{
747
{
748
	// already exists, lets skip it
748
	// already exists, lets skip it
749
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() && CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
749
	if ( CFileIO::Exists(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat") && CFileIO::Exists(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat") )
750
		return true;
750
		return true;
751
 
751
 
752
	// if only one of them exists, lets remove them
752
	// if only one of them exists, lets remove them
753
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() )
753
	if ( CFileIO::Exists(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat") )
754
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat");
754
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat");
755
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
755
	if ( CFileIO::Exists(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat") )
756
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat");
756
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat");
757
 
757
 
758
	// fake patch is not being used
758
	// fake patch is not being used
759
	if ( m_iFakePatch < 0 ) return true;
759
	if ( m_iFakePatch < 0 ) return true;
760
	// now lets find the fake patch
760
	// now lets find the fake patch
Line 1391... Line 1391...
1391
			if ( f->Data()->fullDir().contains(L"::") ) {
1391
			if ( f->Data()->fullDir().contains(L"::") ) {
1392
				continue;
1392
				continue;
1393
			}
1393
			}
1394
			Utils::WString toFile;
1394
			Utils::WString toFile;
1395
			if ( cat.appendFile(f->Data()->filePointer(), f->Data()->getNameDirectory(pPackage), true, (m_iGameFlags & EXEFLAG_NOXOR) ? false : true, &toFile) ) {
1395
			if ( cat.appendFile(f->Data()->filePointer(), f->Data()->getNameDirectory(pPackage), true, (m_iGameFlags & EXEFLAG_NOXOR) ? false : true, &toFile) ) {
1396
				CLog::logf(CLog::Log_Install, 2, "Adding file: %s into the fake patch", f->Data()->getNameDirectory(pPackage).c_str());
1396
				CLog::logf(CLog::Log_Install, 2, L"Adding file: %s into the fake patch", f->Data()->getNameDirectory(pPackage).c_str());
1397
				CFileIO::Remove(f->Data()->filePointer());
1397
				CFileIO::Remove(f->Data()->filePointer());
1398
				f->Data()->setFilename(m_sCurrentDir + L"/PluginManager/PlugMan_Fake.cat::" + toFile);
1398
				f->Data()->setFilename(m_sCurrentDir + L"/PluginManager/PlugMan_Fake.cat::" + toFile);
1399
			}
1399
			}
1400
		}
1400
		}
1401
	}
1401
	}
Line 1435... Line 1435...
1435
}
1435
}
1436
 
1436
 
1437
 
1437
 
1438
bool CPackages::installPackage(CBaseFile *package, Utils::WStringList *errors, CProgressInfo *progress, bool disabled)
1438
bool CPackages::installPackage(CBaseFile *package, Utils::WStringList *errors, CProgressInfo *progress, bool disabled)
1439
{
1439
{
1440
	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());
1440
	CLog::logf(CLog::Log_Install, 1, L"Starting to install new package, %s by %s (Version: %s)", package->name().c_str(), package->author().c_str(), package->version().c_str());
1441
	
1441
	
1442
	CBaseFile *oldPackage = findPackage(package);
1442
	CBaseFile *oldPackage = findPackage(package);
1443
	disabled = _checkForDisable(package, disabled, oldPackage);
1443
	disabled = _checkForDisable(package, disabled, oldPackage);
1444
 
1444
 
1445
	// update packages must have an old package installed already (should have been checked for already)
1445
	// update packages must have an old package installed already (should have been checked for already)
Line 1458... Line 1458...
1458
				if ( f->Data()->GetFileType() != FILETYPE_MOD )
1458
				if ( f->Data()->GetFileType() != FILETYPE_MOD )
1459
					continue;
1459
					continue;
1460
 
1460
 
1461
				f->Data()->setDir(L"temp");
1461
				f->Data()->setDir(L"temp");
1462
				if ( f->Data()->IsFakePatch() ) {
1462
				if ( f->Data()->IsFakePatch() ) {
1463
					CLog::logf(CLog::Log_Install, 2, "Moving fake package to temporary location to preper for update, %s", f->Data()->filePointer().c_str());
1463
					CLog::logf(CLog::Log_Install, 2, L"Moving fake package to temporary location to preper for update, %s", f->Data()->filePointer().c_str());
1464
					f->Data()->setName(L"Fake_" + f->Data()->name());
1464
					f->Data()->setName(L"Fake_" + f->Data()->name());
1465
				}
1465
				}
1466
			}
1466
			}
1467
		}
1467
		}
1468
	}
1468
	}
Line 1480... Line 1480...
1480
 
1480
 
1481
	// install all the files
1481
	// install all the files
1482
	CLog::log(CLog::Log_Install, 3, L"Checking for any existing files");
1482
	CLog::log(CLog::Log_Install, 3, L"Checking for any existing files");
1483
	if ( oldPackage )
1483
	if ( oldPackage )
1484
	{
1484
	{
1485
		CLog::logf(CLog::Log_Install, 3, "Excluding existing package (%s) from file check list", oldPackage->version().c_str());
1485
		CLog::logf(CLog::Log_Install, 3, L"Excluding existing package (%s) from file check list", oldPackage->version().c_str());
1486
		CLinkList<CBaseFile> excludeList;
1486
		CLinkList<CBaseFile> excludeList;
1487
		excludeList.push_back(oldPackage);
1487
		excludeList.push_back(oldPackage);
1488
		this->UpdateUsedFiles(&excludeList, true);
1488
		this->UpdateUsedFiles(&excludeList, true);
1489
	}
1489
	}
1490
	else
1490
	else
Line 1750... Line 1750...
1750
				}
1750
				}
1751
 
1751
 
1752
				// remove from hard drive
1752
				// remove from hard drive
1753
				if ( !dontRemove && removeFile(f, errors) )
1753
				if ( !dontRemove && removeFile(f, errors) )
1754
				{
1754
				{
1755
					CLog::logf(CLog::Log_Install, 1, "Removed unused file: %s", f->filePointer().c_str());
1755
					CLog::logf(CLog::Log_Install, 1, L"Removed unused file: %s", f->filePointer().c_str());
1756
					// if a fake patch, we need to shufle
1756
					// if a fake patch, we need to shufle
1757
					if ( f->IsFakePatch() )
1757
					if ( f->IsFakePatch() )
1758
						shuffle = true;
1758
						shuffle = true;
1759
					else if ( f->isAutoTextFile() )
1759
					else if ( f->isAutoTextFile() )
1760
						shuffle = true;
1760
						shuffle = true;
Line 1778... Line 1778...
1778
	if ( package->GetType() == TYPE_SPK )
1778
	if ( package->GetType() == TYPE_SPK )
1779
	{
1779
	{
1780
		CSpkFile *spk = (CSpkFile *)package;
1780
		CSpkFile *spk = (CSpkFile *)package;
1781
		if ( spk->IsAnotherMod() ) {
1781
		if ( spk->IsAnotherMod() ) {
1782
			spk->SetParent((CSpkFile *)findSpkPackage(spk->otherName(), spk->otherAuthor()));
1782
			spk->SetParent((CSpkFile *)findSpkPackage(spk->otherName(), spk->otherAuthor()));
1783
			CLog::logf(CLog::Log_Install, 2, "Linking to parent package: %s by %s (Version: %s)", spk->name().c_str(), spk->author().c_str(), spk->version().c_str());
1783
			CLog::logf(CLog::Log_Install, 2, L"Linking to parent package: %s by %s (Version: %s)", spk->name().c_str(), spk->author().c_str(), spk->version().c_str());
1784
		}
1784
		}
1785
	}
1785
	}
1786
 
1786
 
1787
	// store enabled mod
1787
	// store enabled mod
1788
	if ( package->IsMod() && !disabled ) {
1788
	if ( package->IsMod() && !disabled ) {
Line 2861... Line 2861...
2861
		CLog::log(CLog::Log_IO, 2, L"Creating PluginManager directory");
2861
		CLog::log(CLog::Log_IO, 2, L"Creating PluginManager directory");
2862
 		Dir.create(L"PluginManager");
2862
 		Dir.create(L"PluginManager");
2863
	}
2863
	}
2864
 
2864
 
2865
	CLog::log(CLog::Log_IO, 2, L"Writing data file: " + m_sCurrentDir + L"/PluginManager/PluginManager.new");
2865
	CLog::log(CLog::Log_IO, 2, L"Writing data file: " + m_sCurrentDir + L"/PluginManager/PluginManager.new");
2866
	if ( !datFile.writeFile(&lines) )
2866
	if ( !datFile.writeFileUTF(lines) )
2867
		CLog::log(CLog::Log_IO, 1, L"ERROR: Failed to write data file");
2867
		CLog::log(CLog::Log_IO, 1, L"ERROR: Failed to write data file");
2868
	else {
2868
	else {
2869
		CLog::log(CLog::Log_IO, 2, L"Removing old data file: " + m_sCurrentDir + L"/PluginManager/PluginManager.dat");
2869
		CLog::log(CLog::Log_IO, 2, L"Removing old data file: " + m_sCurrentDir + L"/PluginManager/PluginManager.dat");
2870
		if ( !CFileIO::Exists(m_sCurrentDir + L"/PluginManager/PluginManager.dat") || CFileIO::Remove(m_sCurrentDir + L"/PluginManager/PluginManager.dat") ) {
2870
		if ( !CFileIO::Exists(m_sCurrentDir + L"/PluginManager/PluginManager.dat") || CFileIO::Remove(m_sCurrentDir + L"/PluginManager/PluginManager.dat") ) {
2871
			CLog::log(CLog::Log_IO, 2, L"Renaming data file: PluginManager.new => PluginManager.dat");
2871
			CLog::log(CLog::Log_IO, 2, L"Renaming data file: PluginManager.new => PluginManager.dat");
Line 5749... Line 5749...
5749
	writeData.push_back(L"<language id=\"" + Utils::WString::Number(lang) + L"\">");
5749
	writeData.push_back(L"<language id=\"" + Utils::WString::Number(lang) + L"\">");
5750
 
5750
 
5751
	if ( !gameNumber )
5751
	if ( !gameNumber )
5752
		writeData.push_back(L"	<page id=\"" + Utils::WString::Number(PMTEXTFILE) + L"\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5752
		writeData.push_back(L"	<page id=\"" + Utils::WString::Number(PMTEXTFILE) + L"\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5753
	else
5753
	else
5754
		writeData.push_back(L"	<page id=\"" + (long)gameNumber + Utils::WString::PadNumber(PMTEXTFILE, 4) + L"\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5754
		writeData.push_back(L"	<page id=\"" + Utils::WString::Number(gameNumber) + Utils::WString::PadNumber(PMTEXTFILE, 4) + L"\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5755
 
5755
 
5756
	writeData.push_back(L"		<t id=\"99998\">[author]Plugin Manager[/author]It appears the plugin manager hasn't been closed properly.  Make sure its closed before running the game otherwise things may not work correctly</t>");
5756
	writeData.push_back(L"		<t id=\"99998\">[author]Plugin Manager[/author]It appears the plugin manager hasn't been closed properly.  Make sure its closed before running the game otherwise things may not work correctly</t>");
5757
	writeData.push_back(L"		<t id=\"99999\">2</t>");	
5757
	writeData.push_back(L"		<t id=\"99999\">2</t>");	
5758
	writeData.push_back(L"	</page>");
5758
	writeData.push_back(L"	</page>");
5759
 
5759