Subversion Repositories spk

Rev

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

Rev 210 Rev 212
Line 220... Line 220...
220
	}
220
	}
221
	else
221
	else
222
		m_pGameVFS.LoadFilesystem(m_sCurrentDir, 0);
222
		m_pGameVFS.LoadFilesystem(m_sCurrentDir, 0);
223
}
223
}
224
 
224
 
225
bool CPackages::isOldDir(const Utils::String &dir)
225
bool CPackages::isOldDir(const Utils::WString &dir)
226
{
226
{
227
	bool oldPlugin = false;
227
	bool oldPlugin = false;
228
 
228
 
229
	CFileIO datFile(dir + "/PluginManager/pluginmanager.dat");
229
	CFileIO datFile(dir + L"/PluginManager/pluginmanager.dat");
230
	if ( datFile.exists() )
230
	if ( datFile.exists() )
231
	{
231
	{
232
		std::vector<Utils::String> *readFile = datFile.readLines();
232
		std::vector<Utils::WString> readFile;
233
		if ( readFile )
233
		if(datFile.readLines(readFile))
234
		{
234
		{
235
			for ( int i = 0; i < (int)readFile->size(); i++ )
235
			for ( int i = 0; i < (int)readFile.size(); i++ )
236
			{
236
			{
237
				Utils::String line(readFile->at(i));
237
				Utils::WString line(readFile.at(i));
238
				Utils::String cmd = line.token(":", 1);
238
				Utils::WString cmd = line.token(L":", 1);
239
				if ( cmd.Compare("<script>") || cmd.Compare("</scripts>") )
239
				if ( cmd.Compare(L"<script>") || cmd.Compare(L"</scripts>") )
240
					break;
240
					break;
241
				else if ( cmd.Compare("spkinstaller") || cmd.Compare("globalfiles") )
241
				else if ( cmd.Compare(L"spkinstaller") || cmd.Compare(L"globalfiles") )
242
					break;
242
					break;
243
				else if ( cmd.Compare("pluginmanager") )
243
				else if ( cmd.Compare(L"pluginmanager") )
244
				{
244
				{
245
					oldPlugin = true;
245
					oldPlugin = true;
246
					break;
246
					break;
247
				}
247
				}
248
			}
248
			}
249
 
-
 
250
			delete readFile;
-
 
251
		}
249
		}
252
	}
250
	}
253
 
251
 
254
	return oldPlugin;
252
	return oldPlugin;
255
}
253
}
Line 625... Line 623...
625
	readAvailablePackages();
623
	readAvailablePackages();
626
 
624
 
627
	// check the purged time
625
	// check the purged time
628
	this->PurgeGameObjects();
626
	this->PurgeGameObjects();
629
 
627
 
630
	m_bLoaded = true;
628
	m_bLoaded = true;
631
 
629
 
632
	return true;
630
	return true;
633
}
631
}
634
 
632
 
635
void CPackages::RemoveCreatedFiles()
633
void CPackages::RemoveCreatedFiles()
636
{
634
{
Line 651... Line 649...
651
	Utils::WString logDir = logDirectory();
649
	Utils::WString logDir = logDirectory();
652
	CFileIO LogFile(logDir + L"/log0" + Utils::WString::PadNumber(PMTEXTFILE, 4) + L".txt");
650
	CFileIO LogFile(logDir + L"/log0" + Utils::WString::PadNumber(PMTEXTFILE, 4) + L".txt");
653
	if ( LogFile.exists() )
651
	if ( LogFile.exists() )
654
	{
652
	{
655
		// read the log file to memory
653
		// read the log file to memory
656
		std::vector<Utils::String> *lines = LogFile.readLines();
654
		std::vector<Utils::WString> lines;
657
		if ( lines )
655
		if(LogFile.readLines(lines))
658
		{
656
		{
659
			for ( int i = 0; i < (int)lines->size(); i++ )
657
			for ( int i = 0; i < (int)lines.size(); i++ )
660
			{
658
			{
661
				Utils::String line(lines->at(i));
659
				Utils::WString line(lines.at(i));
662
				Utils::String start = line.token(":", 1).toLower();
660
				Utils::WString start = line.token(L":", 1).toLower();
663
				Utils::String rest = line.token(":", 2).removeFirstSpace();
661
				Utils::WString rest = line.token(L":", 2).removeFirstSpace();
664
				if ( start.Compare("purged") )
662
				if ( start.Compare(L"purged") )
665
				{
663
				{
666
					long time = rest.toLong();
664
					long time = rest.toLong();
667
					if ( time == m_iLastUpdated )
665
					if ( time == m_iLastUpdated )
668
					{
666
					{
669
						this->PurgeWares();
667
						this->PurgeWares();
670
						this->PurgeShips();
668
						this->PurgeShips();
671
						this->removeUninstallScripts();
669
						this->removeUninstallScripts();
672
					}
670
					}
673
				}
671
				}
674
			}
672
			}
675
 
-
 
676
			delete lines;
-
 
677
		}
673
		}
678
		// remove the log file
674
		// remove the log file
679
		LogFile.remove();
675
		LogFile.remove();
680
	}
676
	}
681
}
677
}
Line 691... Line 687...
691
			if ( !w ) continue;
687
			if ( !w ) continue;
692
			if ( w->iType == WARETYPE_DELETED )
688
			if ( w->iType == WARETYPE_DELETED )
693
				w->iType = WARETYPE_NONE;
689
				w->iType = WARETYPE_NONE;
694
		}
690
		}
695
		m_lGameWares[i].RemoveEmpty();
691
		m_lGameWares[i].RemoveEmpty();
696
	}
692
	}
697
}
693
}
698
 
694
 
699
void CPackages::PurgeShips()
695
void CPackages::PurgeShips()
700
{
696
{
701
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
697
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
702
	{
698
	{
703
		if ( !node->Data() )
699
		if ( !node->Data() )
704
			continue;
700
			continue;
705
		if ( node->Data()->iType == WARETYPE_DELETED )
701
		if ( node->Data()->iType == WARETYPE_DELETED )
706
			node->Data()->iType = WARETYPE_NONE;
702
			node->Data()->iType = WARETYPE_NONE;
707
	}
703
	}
708
	m_lGameShips.RemoveEmpty();
704
	m_lGameShips.RemoveEmpty();
709
}
705
}
710
 
706
 
711
Utils::WString CPackages::logDirectory()
707
Utils::WString CPackages::logDirectory()
712
{
708
{
713
	Utils::WString logDir = m_sCurrentDir;
709
	Utils::WString logDir = m_sCurrentDir;
714
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG ) {
710
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG ) {
715
		SGameExe *exe = m_gameExe.game(m_iGame - 1);
711
		SGameExe *exe = m_gameExe.game(m_iGame - 1);
Line 730... Line 726...
730
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
726
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
731
		if ( exe )
727
		if ( exe )
732
		{
728
		{
733
			if ( !exe->sMyDoc.empty() )
729
			if ( !exe->sMyDoc.empty() )
734
				logDir = m_sMyDoc + L"/" + exe->sMyDoc;
730
				logDir = m_sMyDoc + L"/" + exe->sMyDoc;
735
		}
731
		}
736
	}
732
	}
737
 
733
 
738
	return CFileIO(logDir).fullFilename();
734
	return CFileIO(logDir).fullFilename();
739
}
735
}
740
 
736
 
741
Utils::WString CPackages::saveDirectory()
737
Utils::WString CPackages::saveDirectory()
742
{
738
{
743
	Utils::WString logDir = this->logDirectory();
739
	Utils::WString logDir = this->logDirectory();
744
	if ( m_iGameFlags & EXEFLAG_NOSAVESUBDIR )
740
	if ( m_iGameFlags & EXEFLAG_NOSAVESUBDIR )
745
		return logDir;
741
		return logDir;
746
 
742
 
747
	return logDir + L"/save";
743
	return logDir + L"/save";
748
}
744
}
749
 
745
 
750
bool CPackages::ReadyFakePatch()
746
bool CPackages::ReadyFakePatch()
751
{
747
{
752
	// already exists, lets skip it
748
	// already exists, lets skip it
753
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() && CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
749
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() && CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
754
		return true;
750
		return true;
Line 756... Line 752...
756
	// if only one of them exists, lets remove them
752
	// if only one of them exists, lets remove them
757
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() )
753
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() )
758
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat");
754
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat");
759
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
755
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
760
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat");
756
		CFileIO::Remove(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat");
761
 
757
 
762
	// fake patch is not being used
758
	// fake patch is not being used
763
	if ( m_iFakePatch < 0 ) return true;
759
	if ( m_iFakePatch < 0 ) return true;
764
	// now lets find the fake patch
760
	// now lets find the fake patch
765
	Utils::WString useFile;
761
	Utils::WString useFile;
766
	if ( m_iFakePatch > 0 )
762
	if ( m_iFakePatch > 0 )
767
	{
763
	{
768
		Utils::WString file = Utils::WString::PadNumber(m_iFakePatch, 2);
764
		Utils::WString file = Utils::WString::PadNumber(m_iFakePatch, 2);
769
		if (checkValidPluginManagerFile(file))
765
		if (checkValidPluginManagerFile(file))
770
			useFile = file;
766
			useFile = file;
771
		else if (checkIfPluginManagerFile(file))
767
		else if (checkIfPluginManagerFile(file))
772
			useFile = file;
768
			useFile = file;
773
	}
769
	}
774
 
770
 
775
	if ( useFile.empty() )
771
	if ( useFile.empty() )
776
	{
772
	{
777
		int nextfree = this->findNextFakePatch();
773
		int nextfree = this->findNextFakePatch();
778
		--nextfree; // gets the end fake patch
774
		--nextfree; // gets the end fake patch
Line 780... Line 776...
780
		// work backwards till we find a valid one
776
		// work backwards till we find a valid one
781
		while ( nextfree > m_iMaxPatch )
777
		while ( nextfree > m_iMaxPatch )
782
		{
778
		{
783
			Utils::WString file = Utils::WString::PadNumber(nextfree, 2);
779
			Utils::WString file = Utils::WString::PadNumber(nextfree, 2);
784
			if (checkValidPluginManagerFile(file))
780
			if (checkValidPluginManagerFile(file))
785
			{
781
			{
786
				useFile = file;
782
				useFile = file;
787
				break;
783
				break;
788
			}
784
			}
789
			--nextfree;
785
			--nextfree;
790
		}
786
		}
Line 828... Line 824...
828
						continue;
824
						continue;
829
					if ((*itr)->sFile.Compare(useAddonDir.toString() + "t\\44" + Utils::String::PadNumber(PMTEXTFILE, 4) + ".pck"))
825
					if ((*itr)->sFile.Compare(useAddonDir.toString() + "t\\44" + Utils::String::PadNumber(PMTEXTFILE, 4) + ".pck"))
830
						continue;
826
						continue;
831
					if ((*itr)->sFile.Compare(useAddonDir.toString() + "t\\" + Utils::String::PadNumber(PMTEXTFILE, 4) + "-L044.pck"))
827
					if ((*itr)->sFile.Compare(useAddonDir.toString() + "t\\" + Utils::String::PadNumber(PMTEXTFILE, 4) + "-L044.pck"))
832
						continue;
828
						continue;
833
 
829
 
834
					found = true;
830
					found = true;
835
					break;
831
					break;
836
				}
832
				}
837
			}
833
			}
838
 
834
 
Line 1022... Line 1018...
1022
			Utils::String model = data.token(";", i);
1018
			Utils::String model = data.token(";", i);
1023
			Utils::String modelExt = model.right(4);
1019
			Utils::String modelExt = model.right(4);
1024
			// check file extension
1020
			// check file extension
1025
			if ( modelExt.Compare(".bod") || modelExt.Compare(".pbd") )
1021
			if ( modelExt.Compare(".bod") || modelExt.Compare(".pbd") )
1026
				data = data.replaceToken(";", i, model.left(-4));
1022
				data = data.replaceToken(";", i, model.left(-4));
1027
		}
1023
		}
1028
 
1024
 
1029
		xsp->SetShipData(data);
1025
		xsp->SetShipData(data);
1030
	}
1026
	}
1031
 
1027
 
1032
	// any extra files that are in director folder
1028
	// any extra files that are in director folder
1033
	if ( package->AnyFileType(FILETYPE_EXTRA) )
1029
	if ( package->AnyFileType(FILETYPE_EXTRA) )
Line 1313... Line 1309...
1313
			return NULL;
1309
			return NULL;
1314
	}
1310
	}
1315
 
1311
 
1316
	if ( progress )
1312
	if ( progress )
1317
		progress->SecondHalf();
1313
		progress->SecondHalf();
1318
 
1314
 
1319
	// now uncomress all files
1315
	// now uncomress all files
1320
	if ( !(flags & READFLAG_NOUNCOMPRESS) )
1316
	if ( !(flags & READFLAG_NOUNCOMPRESS) )
1321
		installFile->UncompressAllFiles(progress);
1317
		installFile->UncompressAllFiles(progress);
1322
 
1318
 
1323
	this->ConvertOldPackage (installFile);
1319
	this->ConvertOldPackage (installFile);
Line 1508... Line 1504...
1508
 
1504
 
1509
	_pOriginalFiles->installed(package);
1505
	_pOriginalFiles->installed(package);
1510
 
1506
 
1511
	// if we're installing an addon, lets use the fake patch method for object files
1507
	// if we're installing an addon, lets use the fake patch method for object files
1512
	if ( m_iGameFlags & EXEFLAG_ADDON ) this->_addToFakePatch(package);
1508
	if ( m_iGameFlags & EXEFLAG_ADDON ) this->_addToFakePatch(package);
1513
 
1509
 
1514
	bool shuffle = package->anyFakePatchOrder();
1510
	bool shuffle = package->anyFakePatchOrder();
1515
 
1511
 
1516
	// merge the update into the old package
1512
	// merge the update into the old package
1517
	bool dontAdd = false;
1513
	bool dontAdd = false;
1518
	if ( package->GetType() == TYPE_SPK )
1514
	if ( package->GetType() == TYPE_SPK )
Line 1531... Line 1527...
1531
					continue;
1527
					continue;
1532
 
1528
 
1533
				// if fake patch, find first fake patch in package
1529
				// if fake patch, find first fake patch in package
1534
				C_File *findMatching = NULL;
1530
				C_File *findMatching = NULL;
1535
				if ( f->Data()->baseName().left(5).Compare("fake_") )
1531
				if ( f->Data()->baseName().left(5).Compare("fake_") )
1536
				{
1532
				{
1537
					for ( CListNode<C_File> *node = oldPackage->GetFileList()->Front(); node; node = node->next() )
1533
					for ( CListNode<C_File> *node = oldPackage->GetFileList()->Front(); node; node = node->next() )
1538
					{
1534
					{
1539
						if ( !node->Data() )
1535
						if ( !node->Data() )
1540
							continue;
1536
							continue;
1541
						if ( node->Data()->GetFileType() != FILETYPE_MOD )
1537
						if ( node->Data()->GetFileType() != FILETYPE_MOD )
1542
							continue;
1538
							continue;
1543
						// we only need the cat file
1539
						// we only need the cat file
1544
						if ( !node->Data()->checkFileExt("cat") )
1540
						if ( !node->Data()->checkFileExt("cat") )
1545
							continue;
1541
							continue;
1546
						if ( !node->Data()->IsFakePatch() )
1542
						if ( !node->Data()->IsFakePatch() )
1547
							continue;
1543
							continue;
1548
 
1544
 
1549
						findMatching = node->Data();
1545
						findMatching = node->Data();
1550
						break;
1546
						break;
1551
					}
1547
					}
1552
				}
1548
				}
1553
				// otherwise, just add to the mod of the same name
1549
				// otherwise, just add to the mod of the same name
Line 1565... Line 1561...
1565
 
1561
 
1566
						if ( node->Data()->name().Compare(f->Data()->name()) )
1562
						if ( node->Data()->name().Compare(f->Data()->name()) )
1567
						{
1563
						{
1568
							findMatching = node->Data();
1564
							findMatching = node->Data();
1569
							break;
1565
							break;
1570
						}
1566
						}
1571
					}
1567
					}
1572
				}
1568
				}
1573
 
1569
 
1574
				if ( findMatching )
1570
				if ( findMatching )
1575
				{
1571
				{
1576
					// copy accross all mods
1572
					// copy accross all mods
1577
					CCatFile catTo, catFrom;
1573
					CCatFile catTo, catFrom;
Line 1591... Line 1587...
1591
					C_File *m = package->findMatchingMod(f->Data());
1587
					C_File *m = package->findMatchingMod(f->Data());
1592
					removeFile(f->Data(), errors);
1588
					removeFile(f->Data(), errors);
1593
					m_lFiles.remove(f->Data());
1589
					m_lFiles.remove(f->Data());
1594
					f->ChangeData(NULL);
1590
					f->ChangeData(NULL);
1595
					if ( m )
1591
					if ( m )
1596
					{
1592
					{
1597
						int pos = package->GetFileList()->FindPos(m);
1593
						int pos = package->GetFileList()->FindPos(m);
1598
						removeFile(m, errors);
1594
						removeFile(m, errors);
1599
						m_lFiles.remove(m);
1595
						m_lFiles.remove(m);
1600
						if ( pos != -1 )
1596
						if ( pos != -1 )
1601
							package->GetFileList()->GetNode(pos)->ChangeData(NULL);
1597
							package->GetFileList()->GetNode(pos)->ChangeData(NULL);
Line 1603... Line 1599...
1603
				}
1599
				}
1604
				// no matching file, then we shall just renaming back
1600
				// no matching file, then we shall just renaming back
1605
				else
1601
				else
1606
				{
1602
				{
1607
					if ( f->Data()->baseName().left(5).Compare("fake_") )
1603
					if ( f->Data()->baseName().left(5).Compare("fake_") )
1608
					{
1604
					{
1609
						shuffle = true;
1605
						shuffle = true;
1610
						C_File *match = package->findMatchingMod(f->Data());
1606
						C_File *match = package->findMatchingMod(f->Data());
1611
						Utils::String next = Utils::String::PadNumber(this->findNextFakePatch(), 2);
1607
						Utils::String next = Utils::String::PadNumber(this->findNextFakePatch(), 2);
1612
						
1608
						
1613
						Utils::WString oldFilePointer = f->Data()->filePointer();
1609
						Utils::WString oldFilePointer = f->Data()->filePointer();
1614
						f->Data()->setDir(L"");
1610
						f->Data()->setDir(L"");
1615
						f->Data()->changeBaseName(next);
1611
						f->Data()->changeBaseName(next);
Line 1800... Line 1796...
1800
 
1796
 
1801
	CLog::log(CLog::Log_Install, 1, "Saving data to file");
1797
	CLog::log(CLog::Log_Install, 1, "Saving data to file");
1802
	this->WriteData();
1798
	this->WriteData();
1803
 
1799
 
1804
	CLog::log(CLog::Log_Install, 1, "Installation Finished");
1800
	CLog::log(CLog::Log_Install, 1, "Installation Finished");
1805
	return true;
1801
	return true;
1806
}
1802
}
1807
 
1803
 
1808
bool CPackages::uninstallPreparedPackages(Utils::WStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *uninstalledPackages, CLinkList<CBaseFile> *disabledPackages)
1804
bool CPackages::uninstallPreparedPackages(Utils::WStringList *errors, CProgressInfo *progress, CLinkList<CBaseFile> *uninstalledPackages, CLinkList<CBaseFile> *disabledPackages)
1809
{
1805
{
1810
	if ( m_lInstallList.empty() ) return false;
1806
	if ( m_lInstallList.empty() ) return false;
1811
 
1807
 
1812
	// update the used status, excluding all packages we are about to remove
1808
	// update the used status, excluding all packages we are about to remove
Line 1827... Line 1823...
1827
		// disable any dependants
1823
		// disable any dependants
1828
		if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
1824
		if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
1829
		{
1825
		{
1830
			CLinkList<CBaseFile> depList;
1826
			CLinkList<CBaseFile> depList;
1831
			if ( this->GetDependacyList(p, &depList) )
1827
			if ( this->GetDependacyList(p, &depList) )
1832
			{
1828
			{
1833
				for ( CBaseFile *depP = depList.First(); depP; depP = depList.Next() )
1829
				for ( CBaseFile *depP = depList.First(); depP; depP = depList.Next() )
1834
				{
1830
				{
1835
					if ( depP->IsEnabled() )
1831
					if ( depP->IsEnabled() )
1836
						this->PrepareDisablePackage(depP);
1832
						this->PrepareDisablePackage(depP);
1837
				}
1833
				}
Line 1839... Line 1835...
1839
				if ( m_lDisableList.size() )
1835
				if ( m_lDisableList.size() )
1840
					this->disablePreparedPackages(errors, progress, disabledPackages);
1836
					this->disablePreparedPackages(errors, progress, disabledPackages);
1841
			}
1837
			}
1842
		}
1838
		}
1843
	}
1839
	}
1844
 
1840
 
1845
	// interate through all the files in the package
1841
	// interate through all the files in the package
1846
	int fileCount = 0;
1842
	int fileCount = 0;
1847
	for ( CListNode<C_File> *node = fileList.Front(); node; node = node->next() )
1843
	for ( CListNode<C_File> *node = fileList.Front(); node; node = node->next() )
1848
	{
1844
	{
1849
		C_File *f = node->Data();
1845
		C_File *f = node->Data();
Line 1851... Line 1847...
1851
		// display progress if needed
1847
		// display progress if needed
1852
		if ( progress )
1848
		if ( progress )
1853
		{
1849
		{
1854
			progress->UpdateProgress(fileCount++, maxFiles);
1850
			progress->UpdateProgress(fileCount++, maxFiles);
1855
			progress->UpdateFile(f);
1851
			progress->UpdateFile(f);
1856
		}
1852
		}
1857
 
1853
 
1858
		// skip uninstall files
1854
		// skip uninstall files
1859
		if ( f->GetFileType() == FILETYPE_UNINSTALL )
1855
		if ( f->GetFileType() == FILETYPE_UNINSTALL )
1860
		{
1856
		{
1861
			uninstallFiles.push_back(f);
1857
			uninstallFiles.push_back(f);
Line 1864... Line 1860...
1864
 
1860
 
1865
		// only delete files that are not used
1861
		// only delete files that are not used
1866
		// if its a shared file, we skip it
1862
		// if its a shared file, we skip it
1867
		if ( f->getUsed() || f->IsShared() )
1863
		if ( f->getUsed() || f->IsShared() )
1868
			continue;
1864
			continue;
1869
 
1865
 
1870
		if ( f->GetFileType() == FILETYPE_README )
1866
		if ( f->GetFileType() == FILETYPE_README )
1871
			readme = true;
1867
			readme = true;
1872
		else if ( f->GetFileType() == FILETYPE_UNINSTALL || f->GetFileType() == FILETYPE_MAP || f->GetFileType() == FILETYPE_SOUND || f->GetFileType() == FILETYPE_EXTRA || f->GetFileType() == FILETYPE_SHIPSCENE || f->GetFileType() == FILETYPE_COCKPITSCENE || f->GetFileType() == FILETYPE_SHIPOTHER || f->GetFileType() == FILETYPE_SHIPMODEL || f->GetFileType() == FILETYPE_ADVERT )
1868
		else if ( f->GetFileType() == FILETYPE_UNINSTALL || f->GetFileType() == FILETYPE_MAP || f->GetFileType() == FILETYPE_SOUND || f->GetFileType() == FILETYPE_EXTRA || f->GetFileType() == FILETYPE_SHIPSCENE || f->GetFileType() == FILETYPE_COCKPITSCENE || f->GetFileType() == FILETYPE_SHIPOTHER || f->GetFileType() == FILETYPE_SHIPMODEL || f->GetFileType() == FILETYPE_ADVERT )
1873
		{
1869
		{
1874
			Utils::WString dir = f->getDirectory(NULL);
1870
			Utils::WString dir = f->getDirectory(NULL);
Line 1900... Line 1896...
1900
		// check for fake patchs
1896
		// check for fake patchs
1901
		if ( f->IsFakePatch() )
1897
		if ( f->IsFakePatch() )
1902
			shuffle = true;
1898
			shuffle = true;
1903
		else if ( f->isAutoTextFile() )
1899
		else if ( f->isAutoTextFile() )
1904
			shuffle = true;
1900
			shuffle = true;
1905
 
1901
 
1906
		// remove the file from the main list as swell
1902
		// remove the file from the main list as swell
1907
		m_lFiles.remove(f, false);
1903
		m_lFiles.remove(f, false);
1908
		delete f;
1904
		delete f;
1909
	}
1905
	}
1910
 
1906
 
Line 1949... Line 1945...
1949
			newFile->SetCreationTime(uf->GetCreationTime());
1945
			newFile->SetCreationTime(uf->GetCreationTime());
1950
 
1946
 
1951
			// other installed packages use this file as well, copy it
1947
			// other installed packages use this file as well, copy it
1952
			Utils::WString newFilename = m_sCurrentDir + L"/" + newFile->getNameDirectory(NULL);
1948
			Utils::WString newFilename = m_sCurrentDir + L"/" + newFile->getNameDirectory(NULL);
1953
			CFileIO file(uf->filePointer());
1949
			CFileIO file(uf->filePointer());
1954
 
1950
 
1955
			if ( uf->getUsed() )
1951
			if ( uf->getUsed() )
1956
			{
1952
			{
1957
				if ( file.copy(newFilename) )
1953
				if ( file.copy(newFilename) )
1958
					this->addLogEntry(SPKINSTALL_UNINSTALL_COPY, newFile->getNameDirectory(NULL), errors);
1954
					this->addLogEntry(SPKINSTALL_UNINSTALL_COPY, newFile->getNameDirectory(NULL), errors);
1959
				else
1955
				else
Line 1997... Line 1993...
1997
				// not found, so add it
1993
				// not found, so add it
1998
				if ( !found )
1994
				if ( !found )
1999
					m_lUninstallFiles.push_back(newFile);
1995
					m_lUninstallFiles.push_back(newFile);
2000
				else
1996
				else
2001
					delete newFile;
1997
					delete newFile;
2002
			}
1998
			}
2003
		}
1999
		}
2004
	}
2000
	}
2005
 
2001
 
2006
	uninstallFiles.clear();
2002
	uninstallFiles.clear();
2007
 
2003
 
2008
	// remove all directies that we're not using
2004
	// remove all directies that we're not using
2009
	if ( readme )
2005
	if ( readme )
2010
	{
2006
	{
2011
		removeDirs.pushBack(L"PluginManager/Readme");
2007
		removeDirs.pushBack(L"PluginManager/Readme");
2012
		removeDirs.pushBack(L"Readme");
2008
		removeDirs.pushBack(L"Readme");
2013
	}
2009
	}
2014
	if ( original ) {
2010
	if ( original ) {
2015
		removeDirs.pushBack(L"PluginManager/Original/Replacements");
2011
		removeDirs.pushBack(L"PluginManager/Original/Replacements");
2016
		removeDirs.pushBack(L"PluginManager/Original");
2012
		removeDirs.pushBack(L"PluginManager/Original");
2017
	}
2013
	}
2018
	removeDirs.pushBack(L"PluginManager/Disabled");
2014
	removeDirs.pushBack(L"PluginManager/Disabled");
Line 2044... Line 2040...
2044
	// add all children
2040
	// add all children
2045
	CLinkList<CBaseFile> children;
2041
	CLinkList<CBaseFile> children;
2046
	if ( this->GetChildPackages(package, &children, true) )
2042
	if ( this->GetChildPackages(package, &children, true) )
2047
	{
2043
	{
2048
		for ( CBaseFile *p = children.First(); p; p = children.Next() )
2044
		for ( CBaseFile *p = children.First(); p; p = children.Next() )
2049
		{
2045
		{
2050
			if ( !m_lInstallList.FindData(p) )
2046
			if ( !m_lInstallList.FindData(p) )
2051
				m_lInstallList.push_back(p);
2047
				m_lInstallList.push_back(p);
2052
		}
2048
		}
2053
	}
2049
	}
2054
}
2050
}
Line 2056... Line 2052...
2056
bool CPackages::PrepareEnablePackage(CBaseFile *package)
2052
bool CPackages::PrepareEnablePackage(CBaseFile *package)
2057
{
2053
{
2058
	ClearError();
2054
	ClearError();
2059
 
2055
 
2060
	if ( package->GetParent() && !package->GetParent()->IsEnabled() )
2056
	if ( package->GetParent() && !package->GetParent()->IsEnabled() )
2061
	{
2057
	{
2062
		m_iError = PKERR_NOPARENT;
2058
		m_iError = PKERR_NOPARENT;
2063
		return false;
2059
		return false;
2064
	}
2060
	}
2065
 
2061
 
2066
	if ( m_bVanilla && !package->IsSigned() )
2062
	if ( m_bVanilla && !package->IsSigned() )
Line 2093... Line 2089...
2093
			// add all disabled packages to list
2089
			// add all disabled packages to list
2094
			for ( CBaseFile *p = childList.First(); p; p = childList.Next() )
2090
			for ( CBaseFile *p = childList.First(); p; p = childList.Next() )
2095
			{
2091
			{
2096
				if ( !p->IsEnabled() )
2092
				if ( !p->IsEnabled() )
2097
					m_lEnableList.push_back(p);
2093
					m_lEnableList.push_back(p);
2098
			}
2094
			}
2099
		}
2095
		}
2100
	}
2096
	}
2101
 
2097
 
2102
	m_bRemoveDir = true;
2098
	m_bRemoveDir = true;
2103
 
2099
 
2104
	return true;
2100
	return true;
2105
}
2101
}
Line 2290... Line 2286...
2290
			return L'm';
2286
			return L'm';
2291
		case WARES_TECH:
2287
		case WARES_TECH:
2292
			return L't';
2288
			return L't';
2293
		case WARES_NATURAL:
2289
		case WARES_NATURAL:
2294
			return L'n';
2290
			return L'n';
2295
	}
2291
	}
2296
	return L't';
2292
	return L't';
2297
}
2293
}
2298
int CPackages::ConvertWareType(wchar_t w)
2294
int CPackages::ConvertWareType(wchar_t w)
2299
{
2295
{
2300
	switch ( LOWER(w) )
2296
	switch ( LOWER(w) )
Line 2327... Line 2323...
2327
	for ( CListNode<CBaseFile> *pNode = m_lPackages.Front(); pNode; pNode = pNode->next() )
2323
	for ( CListNode<CBaseFile> *pNode = m_lPackages.Front(); pNode; pNode = pNode->next() )
2328
	{
2324
	{
2329
		if ( pNode->Data()->GetType() != TYPE_XSP )
2325
		if ( pNode->Data()->GetType() != TYPE_XSP )
2330
			continue;
2326
			continue;
2331
		CXspFile *p = (CXspFile *)pNode->Data();
2327
		CXspFile *p = (CXspFile *)pNode->Data();
2332
 
2328
 
2333
		bool found = false;
2329
		bool found = false;
2334
		for ( CListNode<SGameShip> *wNode = m_lGameShips.Front(); wNode; wNode = wNode->next() )
2330
		for ( CListNode<SGameShip> *wNode = m_lGameShips.Front(); wNode; wNode = wNode->next() )
2335
		{
2331
		{
2336
			if ( wNode->Data()->sShipID.Compare(p->GetShipID().c_str()) )
2332
			if ( wNode->Data()->sShipID.Compare(p->GetShipID().c_str()) )
2337
			{
2333
			{
Line 2363... Line 2359...
2363
			}
2359
			}
2364
		}
2360
		}
2365
 
2361
 
2366
		// none found, create one
2362
		// none found, create one
2367
		if ( !gw )
2363
		if ( !gw )
2368
		{
2364
		{
2369
			gw = new SGameShip;
2365
			gw = new SGameShip;
2370
			gw->sShipID = p->GetShipID().toWString();
2366
			gw->sShipID = p->GetShipID().toWString();
2371
			gw->sShipClass = p->GetShipClass().toWString();
2367
			gw->sShipClass = p->GetShipClass().toWString();
2372
			gw->pPackage = p;
2368
			gw->pPackage = p;
2373
			m_lGameShips.push_back(gw);
2369
			m_lGameShips.push_back(gw);
Line 2387... Line 2383...
2387
		}
2383
		}
2388
	}
2384
	}
2389
 
2385
 
2390
	// find any new wares to add to the list
2386
	// find any new wares to add to the list
2391
	for ( CListNode<CBaseFile> *pNode = m_lPackages.Front(); pNode; pNode = pNode->next() )
2387
	for ( CListNode<CBaseFile> *pNode = m_lPackages.Front(); pNode; pNode = pNode->next() )
2392
	{
2388
	{
2393
		if ( pNode->Data()->GetType() != TYPE_SPK )
2389
		if ( pNode->Data()->GetType() != TYPE_SPK )
2394
			continue;
2390
			continue;
2395
		CSpkFile *p = (CSpkFile *)pNode->Data();
2391
		CSpkFile *p = (CSpkFile *)pNode->Data();
2396
 
2392
 
2397
		for ( CListNode<SWares> *node = p->GetWaresList()->Front(); node; node = node->next() )
2393
		for ( CListNode<SWares> *node = p->GetWaresList()->Front(); node; node = node->next() )
Line 2582... Line 2578...
2582
		if ( !catFile.remove() ) return false;
2578
		if ( !catFile.remove() ) return false;
2583
	}
2579
	}
2584
	else if ( !catFile.exists() && datFile.exists() ) {
2580
	else if ( !catFile.exists() && datFile.exists() ) {
2585
		CLog::log(CLog::Log_Directory, 1, "WARNING: cat/dat file mismatch, cat file seems to be missing, removing dat file");
2581
		CLog::log(CLog::Log_Directory, 1, "WARNING: cat/dat file mismatch, cat file seems to be missing, removing dat file");
2586
		if ( !datFile.remove() ) return false;
2582
		if ( !datFile.remove() ) return false;
2587
	}
2583
	}
2588
 
2584
 
2589
	// if both exists, lets rename them
2585
	// if both exists, lets rename them
2590
	if ( catFile.exists() && datFile.exists() )
2586
	if ( catFile.exists() && datFile.exists() )
2591
	{
2587
	{
2592
		CLog::log(CLog::Log_Directory, 3, "Creating pluginmanagerfake.txt file to add to Fake Patch");
2588
		CLog::log(CLog::Log_Directory, 3, "Creating pluginmanagerfake.txt file to add to Fake Patch");
Line 2595... Line 2591...
2595
		if ( !file.empty() )
2591
		if ( !file.empty() )
2596
			file += L"/";
2592
			file += L"/";
2597
		file += L"pluginmanagerfake.txt";
2593
		file += L"pluginmanagerfake.txt";
2598
		file = file.findReplace(L"\\", L"/");
2594
		file = file.findReplace(L"\\", L"/");
2599
		CFileIO fakeFile(file);
2595
		CFileIO fakeFile(file);
2600
		std::vector<Utils::String> lines;
2596
		std::vector<Utils::WString> lines;
2601
		lines.push_back("//pluginmanager fake patch");
2597
		lines.push_back(L"//pluginmanager fake patch");
2602
		CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt file to add to Fake Patch");
2598
		CLog::log(CLog::Log_Directory, 3, L"Writing pluginmanagerfake.txt file to add to Fake Patch");
2603
		if ( !fakeFile.writeFile(&lines) ) {
2599
		if ( !fakeFile.writeFile(lines) ) {
2604
			CLog::log(CLog::Log_Directory, 3, "Writing pluginmanagerfake.txt failed!!");
2600
			CLog::log(CLog::Log_Directory, 3, L"Writing pluginmanagerfake.txt failed!!");
2605
		}
2601
		}
2606
		else {
2602
		else {
2607
/*
2603
/*
2608
			CLog::log(CLog::Log_Directory, 2, "Adding TFake.pck file into FakePatch");
2604
			CLog::log(CLog::Log_Directory, 2, "Adding TFake.pck file into FakePatch");
2609
			CCatFile fakePatch;
2605
			CCatFile fakePatch;
Line 4144... Line 4140...
4144
	{
4140
	{
4145
		C_File *file = node->Data();
4141
		C_File *file = node->Data();
4146
 
4142
 
4147
		// only do marked shared files
4143
		// only do marked shared files
4148
		if ( !file->IsShared() )
4144
		if ( !file->IsShared() )
4149
			continue;
4145
			continue;
4150
 
4146
 
4151
		// only do ones that are no longer needed
4147
		// only do ones that are no longer needed
4152
		if ( file->getUsed() )
4148
		if ( file->getUsed() )
4153
			continue;
4149
			continue;
4154
 
4150
 
4155
		return true;
4151
		return true;
Line 4167... Line 4163...
4167
		// only do files that are enabled
4163
		// only do files that are enabled
4168
		if ( f->IsDisabled() )
4164
		if ( f->IsDisabled() )
4169
			continue;
4165
			continue;
4170
 
4166
 
4171
		if ( f->GetFileType() != FILETYPE_TEXT )
4167
		if ( f->GetFileType() != FILETYPE_TEXT )
4172
			continue;
4168
			continue;
4173
 
4169
 
4174
		// check if the file is an auto text file
4170
		// check if the file is an auto text file
4175
		if ( !f->isAutoTextFile() )
4171
		if ( !f->isAutoTextFile() )
4176
			continue;
4172
			continue;
4177
 
4173
 
4178
		// we need to rename it
4174
		// we need to rename it
Line 4190... Line 4186...
4190
			else
4186
			else
4191
				this->addLogEntry(SPKINSTALL_AUTOTEXT_FAIL, f->name() + L"~" + newName, errors);
4187
				this->addLogEntry(SPKINSTALL_AUTOTEXT_FAIL, f->name() + L"~" + newName, errors);
4192
		}
4188
		}
4193
	}
4189
	}
4194
}
4190
}
4195
 
4191
 
4196
/**
4192
/**
4197
 * Shuffle Fake Patches
4193
 * Shuffle Fake Patches
4198
 *
4194
 *
4199
 * Rename the fake patches so they are always in sequence to be loaded into the game
4195
 * Rename the fake patches so they are always in sequence to be loaded into the game
4200
 *
4196
 *
Line 4223... Line 4219...
4223
		if (p->AnyDependacies())
4219
		if (p->AnyDependacies())
4224
		{
4220
		{
4225
			for (SNeededLibrary* nl = p->GetNeededLibraries()->First(); nl; nl = p->GetNeededLibraries()->Next())
4221
			for (SNeededLibrary* nl = p->GetNeededLibraries()->First(); nl; nl = p->GetNeededLibraries()->Next())
4226
			{
4222
			{
4227
				auto package = findPackage(nl->sName, nl->sAuthor);
4223
				auto package = findPackage(nl->sName, nl->sAuthor);
4228
				if (package)
4224
				if (package)
4229
				{
4225
				{
4230
					packagesBefore.insert(package);
4226
					packagesBefore.insert(package);
4231
					packagesAfter[p].insert(package);
4227
					packagesAfter[p].insert(package);
4232
				}
4228
				}
4233
			}
4229
			}
4234
		}
4230
		}
4235
		CSpkFile* spk = dynamic_cast<CSpkFile*>(p);
4231
		CSpkFile* spk = dynamic_cast<CSpkFile*>(p);
4236
		if (spk)
4232
		if (spk)
4237
		{
4233
		{
4238
			if (spk->IsAnotherMod())
4234
			if (spk->IsAnotherMod())
4239
			{
4235
			{
4240
				auto package = findPackage(spk->otherName(), spk->otherAuthor());
4236
				auto package = findPackage(spk->otherName(), spk->otherAuthor());
4241
				if (package)
4237
				if (package)
4242
				{
4238
				{
4243
					packagesBefore.insert(package);
4239
					packagesBefore.insert(package);
4244
					packagesAfter[p].insert(package);
4240
					packagesAfter[p].insert(package);
4245
				}
4241
				}
4246
			}
4242
			}
4247
		}
4243
		}
4248
 
4244
 
4249
		if (!p->getFakePatchBeforeOrder().empty())
4245
		if (!p->getFakePatchBeforeOrder().empty())
4250
		{
4246
		{
4251
			packagesBefore.insert(p);
4247
			packagesBefore.insert(p);
Line 4253... Line 4249...
4253
			for (auto itr = list.begin(); itr != list.end(); itr++)
4249
			for (auto itr = list.begin(); itr != list.end(); itr++)
4254
			{
4250
			{
4255
				auto package = findPackage((*itr)->str, (*itr)->data);
4251
				auto package = findPackage((*itr)->str, (*itr)->data);
4256
				if (package)				
4252
				if (package)				
4257
					packagesAfter[package].insert(p);
4253
					packagesAfter[package].insert(p);
4258
			}
4254
			}
4259
		}
4255
		}
4260
		if (!p->getFakePatchAfterOrder().empty())
4256
		if (!p->getFakePatchAfterOrder().empty())
4261
		{
4257
		{
4262
			auto& list = p->getFakePatchAfterOrder();
4258
			auto& list = p->getFakePatchAfterOrder();
4263
			for (auto itr = list.begin(); itr != list.end(); itr++)
4259
			for (auto itr = list.begin(); itr != list.end(); itr++)
4264
			{
4260
			{
4265
				auto package = findPackage((*itr)->str, (*itr)->data);
4261
				auto package = findPackage((*itr)->str, (*itr)->data);
4266
				if (package)
4262
				if (package)
4267
				{
4263
				{
4268
					packagesBefore.insert(package);
4264
					packagesBefore.insert(package);
4269
					packagesAfter[p].insert(package);
4265
					packagesAfter[p].insert(package);
4270
				}
4266
				}
4271
			}
4267
			}
4272
		}
4268
		}
4273
	}
4269
	}
4274
 
4270
 
4275
	auto addOrderedList = [](const std::vector<CBaseFile*>& addList, const Utils::WStringList& orderList, std::vector<CBaseFile*>& addTo, const CPackages *packages)
4271
	auto addOrderedList = [](const std::vector<CBaseFile*>& addList, const Utils::WStringList& orderList, std::vector<CBaseFile*>& addTo, const CPackages *packages)
4276
	{
4272
	{
Line 4290... Line 4286...
4290
			}
4286
			}
4291
		}
4287
		}
4292
 
4288
 
4293
		// now add all the others
4289
		// now add all the others
4294
		for (auto itr = addList.begin(); itr != addList.end(); itr++)
4290
		for (auto itr = addList.begin(); itr != addList.end(); itr++)
4295
		{
4291
		{
4296
			auto checkItr = std::find(addTo.begin(), addTo.end(), *itr);
4292
			auto checkItr = std::find(addTo.begin(), addTo.end(), *itr);
4297
			if (checkItr == addTo.end())
4293
			if (checkItr == addTo.end())
4298
				addTo.push_back(*itr);
4294
				addTo.push_back(*itr);
4299
		}
4295
		}
4300
	};
4296
	};
Line 4335... Line 4331...
4335
					}
4331
					}
4336
				}
4332
				}
4337
 
4333
 
4338
				if (!notAdded)
4334
				if (!notAdded)
4339
					packagesOrder.push_back(p);
4335
					packagesOrder.push_back(p);
4340
			}
4336
			}
4341
		}
4337
		}
4342
 
4338
 
4343
 
4339
 
4344
		// no valid packages left ? lets just add the rest
4340
		// no valid packages left ? lets just add the rest
4345
		if (packagesOrder.empty())
4341
		if (packagesOrder.empty())
4346
		{
4342
		{
4347
			for (auto itr = packagesBefore.begin(); itr != packagesBefore.end(); itr++)
4343
			for (auto itr = packagesBefore.begin(); itr != packagesBefore.end(); itr++)
4348
				packagesOrder.push_back(*itr);
4344
				packagesOrder.push_back(*itr);
Line 4531... Line 4527...
4531
			// it doen't, check if theres a dat file (incase of package error)
4527
			// it doen't, check if theres a dat file (incase of package error)
4532
			if ( !Dir.exists(checkStr + L".dat") )
4528
			if ( !Dir.exists(checkStr + L".dat") )
4533
				break;
4529
				break;
4534
		}
4530
		}
4535
		--check;
4531
		--check;
4536
	}
4532
	}
4537
 
4533
 
4538
	return check;
4534
	return check;
4539
}
4535
}
4540
 
4536
 
4541
/**
4537
/**
4542
 * Find next fake patch
4538
 * Find next fake patch
Line 4922... Line 4918...
4922
	int files = 0;
4918
	int files = 0;
4923
 
4919
 
4924
	// remove all files
4920
	// remove all files
4925
	int max = m_lFiles.size() + _pOriginalFiles->count() + m_lUninstallFiles.size();
4921
	int max = m_lFiles.size() + _pOriginalFiles->count() + m_lUninstallFiles.size();
4926
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
4922
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
4927
	{
4923
	{
4928
		// update the progress
4924
		// update the progress
4929
		if ( progress )
4925
		if ( progress )
4930
			progress->UpdateProgress(files, max);
4926
			progress->UpdateProgress(files, max);
4931
		++files;
4927
		++files;
4932
 
4928
 
4933
		removeFile(node->Data());
4929
		removeFile(node->Data());
4934
		delete node->Data();
4930
		delete node->Data();
Line 6476... Line 6472...
6476
 
6472
 
6477
	if ( !found )
6473
	if ( !found )
6478
		return;
6474
		return;
6479
 
6475
 
6480
	Utils::CStringList aniList;
6476
	Utils::CStringList aniList;
6481
	int e = extractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6477
	int e = extractGameFile(L"types/Animations.pck", m_sTempDir + L"/Animations.txt");
6482
	if ( e )
6478
	if ( e )
6483
	{
6479
	{
6484
		CFileIO File;
6480
		CFileIO File;
6485
		if ( File.open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
6481
		if ( File.open((e == -1) ? L"Animations.txt" : m_sTempDir + L"/Animations.txt") )
6486
		{
6482
		{
6487
			std::vector<Utils::String> *lines = File.readLines();
6483
			std::vector<Utils::WString> lines;
6488
			if ( lines )
6484
			if(File.readLines(lines))
6489
			{
6485
			{
6490
				for ( int j = 0; j < (int)lines->size(); j++ )
6486
				for ( int j = 0; j < (int)lines.size(); j++ )
6491
				{
6487
				{
6492
					Utils::String line(lines->at(j));
6488
					Utils::WString line(lines.at(j));
6493
					aniList.pushBack(line);
6489
					aniList.pushBack(line.toString());
6494
				}
6490
				}
6495
 
-
 
6496
				delete lines;
-
 
6497
			}
6491
			}
6498
 
6492
 
6499
			File.remove();
6493
			File.remove();
6500
		}
6494
		}
6501
	}
6495
	}
Line 6629... Line 6623...
6629
		return;
6623
		return;
6630
 
6624
 
6631
	// lets read our current bodies file
6625
	// lets read our current bodies file
6632
	CLinkList<SBodies> bodiesList;
6626
	CLinkList<SBodies> bodiesList;
6633
	SBodies *currentSection = NULL;
6627
	SBodies *currentSection = NULL;
6634
	int e = extractGameFile("types/Bodies.pck", m_sTempDir + "/Bodies.txt");
6628
	int e = extractGameFile(L"types/Bodies.pck", m_sTempDir + L"/Bodies.txt");
6635
	if ( e )
6629
	if ( e )
6636
	{
6630
	{
6637
		CFileIO File;
6631
		CFileIO File;
6638
		if ( File.open((e == -1) ? "Bodies.txt" : m_sTempDir + "/Bodies.txt") )
6632
		if ( File.open((e == -1) ? L"Bodies.txt" : m_sTempDir + L"/Bodies.txt") )
6639
		{
6633
		{
6640
			std::vector<Utils::String> *lines = File.readLines();
6634
			std::vector<Utils::String> *lines = File.readLines();
6641
			if ( lines )
6635
			if ( lines )
6642
			{
6636
			{
6643
				int entries = 0;
6637
				int entries = 0;