Subversion Repositories spk

Rev

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

Rev 168 Rev 170
Line 389... Line 389...
389
					else if ( cmd == "modifieddisabled" )
389
					else if ( cmd == "modifieddisabled" )
390
						packageFile->SetModifiedEnabled(false);
390
						packageFile->SetModifiedEnabled(false);
391
					else if ( cmd == "icon" )
391
					else if ( cmd == "icon" )
392
					{
392
					{
393
						C_File *icon = new C_File(rest.tokens(" ", 2));
393
						C_File *icon = new C_File(rest.tokens(" ", 2));
394
						packageFile->SetIcon(icon, rest.token(" ", 1));
394
						packageFile->setIcon(icon, rest.token(" ", 1));
395
					}
395
					}
396
					else
396
					else
397
						packageFile->ParseValueLine(line);
397
						packageFile->ParseValueLine(line);
398
				}
398
				}
399
				else if ( iStatus == READ_SCRIPTFILE )
399
				else if ( iStatus == READ_SCRIPTFILE )
Line 1597... Line 1597...
1597
							}
1597
							}
1598
						}
1598
						}
1599
					}
1599
					}
1600
 
1600
 
1601
					// now remove the files
1601
					// now remove the files
1602
					C_File *m = package->FindMatchingMod(f->Data());
1602
					C_File *m = package->findMatchingMod(f->Data());
1603
					RemoveFile(f->Data(), errors);
1603
					RemoveFile(f->Data(), errors);
1604
					m_lFiles.remove(f->Data());
1604
					m_lFiles.remove(f->Data());
1605
					f->ChangeData(NULL);
1605
					f->ChangeData(NULL);
1606
					if ( m )
1606
					if ( m )
1607
					{
1607
					{
Line 1616... Line 1616...
1616
				else
1616
				else
1617
				{
1617
				{
1618
					if ( f->Data()->GetBaseName().Left(5).Compare("fake_") )
1618
					if ( f->Data()->GetBaseName().Left(5).Compare("fake_") )
1619
					{
1619
					{
1620
						shuffle = true;
1620
						shuffle = true;
1621
						C_File *match = package->FindMatchingMod(f->Data());
1621
						C_File *match = package->findMatchingMod(f->Data());
1622
						Utils::String next = Utils::String::PadNumber(this->FindNextFakePatch(), 2);
1622
						Utils::String next = Utils::String::PadNumber(this->FindNextFakePatch(), 2);
1623
						
1623
						
1624
						CyString oldFilePointer = f->Data()->GetFilePointer();
1624
						CyString oldFilePointer = f->Data()->GetFilePointer();
1625
						f->Data()->setDir("");
1625
						f->Data()->setDir("");
1626
						f->Data()->changeBaseName(next);
1626
						f->Data()->changeBaseName(next);
Line 1636... Line 1636...
1636
								match->setFilename(m_sCurrentDir + "/" + match->getNameDirectory(package));
1636
								match->setFilename(m_sCurrentDir + "/" + match->getNameDirectory(package));
1637
						}
1637
						}
1638
					}
1638
					}
1639
					else
1639
					else
1640
					{
1640
					{
1641
						C_File *match = package->FindMatchingMod(f->Data());
1641
						C_File *match = package->findMatchingMod(f->Data());
1642
 
1642
 
1643
						f->Data()->setDir("");
1643
						f->Data()->setDir("");
1644
						if ( CFileIO(f->Data()->GetFilePointer()).Rename(m_sCurrentDir + "/" + f->Data()->getNameDirectory(package)) )
1644
						if ( CFileIO(f->Data()->GetFilePointer()).Rename(m_sCurrentDir + "/" + f->Data()->getNameDirectory(package)) )
1645
							f->Data()->setFilename(m_sCurrentDir + "/" + f->Data()->getNameDirectory(package));
1645
							f->Data()->setFilename(m_sCurrentDir + "/" + f->Data()->getNameDirectory(package));
1646
						if ( match )
1646
						if ( match )
Line 1664... Line 1664...
1664
			CDirIO(m_sCurrentDir).removeDir("Mods/temp");
1664
			CDirIO(m_sCurrentDir).removeDir("Mods/temp");
1665
		}
1665
		}
1666
	}
1666
	}
1667
 
1667
 
1668
	// if theres an icon, write it
1668
	// if theres an icon, write it
1669
	if ( package->GetIcon() )
1669
	if (package->icon())
1670
	{
1670
	{
1671
		CLog::log(CLog::Log_Install, 3, "Checking to install icon display file");
1671
		CLog::log(CLog::Log_Install, 3, "Checking to install icon display file");
1672
		C_File *icon = package->GetIcon();
1672
		C_File *icon = package->icon();
1673
		if ( !icon->GetData() || !icon->GetDataSize() ) {
1673
		if ( !icon->GetData() || !icon->GetDataSize() ) {
1674
			package->SetIcon(NULL, "");
1674
			package->setIcon(NULL, "");
1675
			CLog::log(CLog::Log_Install, 2, "Unable to extract icon, clearing");
1675
			CLog::log(CLog::Log_Install, 2, "Unable to extract icon, clearing");
1676
		}
1676
		}
1677
		else
1677
		else
1678
		{
1678
		{
1679
			CDirIO Dir(m_sCurrentDir);
1679
			CDirIO Dir(m_sCurrentDir);
Line 1690... Line 1690...
1690
			}
1690
			}
1691
 
1691
 
1692
			if ( ready )
1692
			if ( ready )
1693
			{
1693
			{
1694
				if ( !icon->UncompressData() )
1694
				if ( !icon->UncompressData() )
1695
					package->SetIcon(NULL, "");
1695
					package->setIcon(NULL, "");
1696
				else
1696
				else
1697
				{
1697
				{
1698
					CFileIO iconFile(m_sCurrentDir + "/PluginManager/Icons/" + package->author() + "_" + package->name() + "." + package->iconExt());
1698
					CFileIO iconFile(m_sCurrentDir + "/PluginManager/Icons/" + package->author() + "_" + package->name() + "." + package->iconExt());
1699
					if ( iconFile.WriteData((const char *)icon->GetData(), icon->GetDataSize()) )
1699
					if ( iconFile.WriteData((const char *)icon->GetData(), icon->GetDataSize()) )
1700
					{
1700
					{
1701
						icon->SetFilename(CyString(package->author()) + "_" + package->name() + "." + package->iconExt());
1701
						icon->setFilename(package->author() + "_" + package->name() + "." + package->iconExt());
1702
						icon->SetFullDir(m_sCurrentDir + "/PluginManager/Icons");
1702
						icon->setFullDir(m_sCurrentDir + "/PluginManager/Icons");
1703
					}
1703
					}
1704
					else
1704
					else
1705
						package->SetIcon(NULL, "");
1705
						package->setIcon(NULL, "");
1706
				}
1706
				}
1707
			}
1707
			}
1708
 
1708
 
1709
			if ( package->GetIcon() )
1709
			if (package->icon())
1710
				package->GetIcon()->DeleteData();
1710
				package->icon()->DeleteData();
1711
		}
1711
		}
1712
	}
1712
	}
1713
 
1713
 
1714
	// remove all data
1714
	// remove all data
1715
	CLog::log(CLog::Log_Install, 3, "Clearing all unneeded file data");
1715
	CLog::log(CLog::Log_Install, 3, "Clearing all unneeded file data");
Line 1758... Line 1758...
1758
				m_lFiles.remove(f, false);
1758
				m_lFiles.remove(f, false);
1759
 
1759
 
1760
				// if its a readme file, then check if its in the new package
1760
				// if its a readme file, then check if its in the new package
1761
				bool dontRemove = false;
1761
				bool dontRemove = false;
1762
				if ( f->GetFileType() == FILETYPE_README ) {
1762
				if ( f->GetFileType() == FILETYPE_README ) {
1763
					if ( package->FindFile(f->filename(), FILETYPE_README) )
1763
					if ( package->findFile(f->filename(), FILETYPE_README) )
1764
						dontRemove = true;
1764
						dontRemove = true;
1765
				}
1765
				}
1766
 
1766
 
1767
				// remove from hard drive
1767
				// remove from hard drive
1768
				if ( !dontRemove && RemoveFile(f, errors) )
1768
				if ( !dontRemove && RemoveFile(f, errors) )
Line 2858... Line 2858...
2858
		if ( !package->IsEnabled() )
2858
		if ( !package->IsEnabled() )
2859
			lines.pushBack("Disabled");
2859
			lines.pushBack("Disabled");
2860
		if ( !package->IsModifiedEnabled() )
2860
		if ( !package->IsModifiedEnabled() )
2861
			lines.pushBack("ModifiedDisabled");
2861
			lines.pushBack("ModifiedDisabled");
2862
 
2862
 
2863
		if ( package->GetIcon() )
2863
		if (package->icon())
2864
			lines.pushBack("Icon: " + package->iconExt() + " " + package->GetIcon()->filePointer() );
2864
			lines.pushBack("Icon: " + package->iconExt() + " " + package->icon()->filePointer() );
2865
 
2865
 
2866
		Utils::String fileline("Files:");
2866
		Utils::String fileline("Files:");
2867
		for ( CListNode<C_File> *fn = package->GetFileList()->Front(); fn; fn = fn->next() )
2867
		for ( CListNode<C_File> *fn = package->GetFileList()->Front(); fn; fn = fn->next() )
2868
		{
2868
		{
2869
			C_File *f = fn->Data();
2869
			C_File *f = fn->Data();
Line 3672... Line 3672...
3672
	{
3672
	{
3673
		if ( package->AnyGameCompatability() )
3673
		if ( package->AnyGameCompatability() )
3674
		{
3674
		{
3675
			if ( (check & IC_WRONGGAME) && (!package->CheckGameCompatability(m_iGame)) )
3675
			if ( (check & IC_WRONGGAME) && (!package->CheckGameCompatability(m_iGame)) )
3676
				return INSTALLCHECK_WRONGGAME;
3676
				return INSTALLCHECK_WRONGGAME;
3677
			else if ( (check & IC_WRONGVERSION) && (!package->CheckGameVersionCompatability(m_iGame, m_sGameVersion, m_iGameVersion)) )
3677
			else if ( (check & IC_WRONGVERSION) && (!package->checkGameVersionCompatability(m_iGame, m_sGameVersion, m_iGameVersion)) )
3678
				return INSTALLCHECK_WRONGVERSION;
3678
				return INSTALLCHECK_WRONGVERSION;
3679
		}
3679
		}
3680
	}
3680
	}
3681
 
3681
 
3682
	// check for modified
3682
	// check for modified
Line 3902... Line 3902...
3902
 
3902
 
3903
	return true;
3903
	return true;
3904
 
3904
 
3905
}
3905
}
3906
 
3906
 
3907
int CPackages::getDownloadableDependacies(CBaseFile* p, std::vector<const SAvailablePackage*>& list, bool onlyEnabled, bool includePrepared) const
3907
size_t CPackages::getDownloadableDependacies(CBaseFile* p, std::vector<const SAvailablePackage*>& list, bool onlyEnabled, bool includePrepared) const
3908
{
3908
{
3909
	size_t count = 0;
3909
	size_t count = 0;
3910
	CLinkList<SNeededLibrary>* neededList = p->GetNeededLibraries();
3910
	CLinkList<SNeededLibrary>* neededList = p->GetNeededLibraries();
3911
	if (neededList)
3911
	if (neededList)
3912
	{
3912
	{
Line 6124... Line 6124...
6124
 
6124
 
6125
		Utils::String sTextCount((long)textCount);
6125
		Utils::String sTextCount((long)textCount);
6126
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)start) + "\">" + this->ConvertTextString(p->name()) + "</t>");
6126
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)start) + "\">" + this->ConvertTextString(p->name()) + "</t>");
6127
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)(start + 1)) + "\">" + this->ConvertTextString(p->author()) + "</t>");
6127
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)(start + 1)) + "\">" + this->ConvertTextString(p->author()) + "</t>");
6128
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)(start + 2)) + "\">" + this->ConvertTextString(p->version()) + "</t>");
6128
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)(start + 2)) + "\">" + this->ConvertTextString(p->version()) + "</t>");
6129
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)(start + 3)) + "\">" + this->ConvertTextString(p->GetLanguageName(lang).ToString()) + "</t>");
6129
		writeData.push_back("		<t id=\"" + Utils::String::Number((long)(start + 3)) + "\">" + this->ConvertTextString(p->getLanguageName(lang)) + "</t>");
6130
 
6130
 
6131
		CLinkList<SSettingType> *settings = spk->GetSettingsList();
6131
		CLinkList<SSettingType> *settings = spk->GetSettingsList();
6132
		if ( settings && settings->size() )
6132
		if ( settings && settings->size() )
6133
		{
6133
		{
6134
			writeData.push_back(Utils::String("		<t id=\"") + (long)(start + 4) + "\">" + (long)settings->size() + "</t>");
6134
			writeData.push_back(Utils::String("		<t id=\"") + (long)(start + 4) + "\">" + (long)settings->size() + "</t>");
Line 6691... Line 6691...
6691
		SGameShip *s = node->Data();
6691
		SGameShip *s = node->Data();
6692
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6692
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6693
			continue;
6693
			continue;
6694
 
6694
 
6695
		// no dummies to add?
6695
		// no dummies to add?
6696
		if ( !s->pPackage->AnyAnimations() )
6696
		if ( !s->pPackage->anyAnimations() )
6697
			continue;
6697
			continue;
6698
		found = true;
6698
		found = true;
6699
		break;
6699
		break;
6700
	}
6700
	}
6701
 
6701
 
6702
	if ( !found )
6702
	if ( !found )
6703
		return;
6703
		return;
6704
 
6704
 
6705
	CyStringList aniList;
6705
	Utils::CStringList aniList;
6706
	int e = ExtractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6706
	int e = ExtractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6707
	if ( e )
6707
	if ( e )
6708
	{
6708
	{
6709
		CFileIO File;
6709
		CFileIO File;
6710
		if ( File.open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
6710
		if ( File.open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
Line 6713... Line 6713...
6713
			if ( lines )
6713
			if ( lines )
6714
			{
6714
			{
6715
				for ( int j = 0; j < (int)lines->size(); j++ )
6715
				for ( int j = 0; j < (int)lines->size(); j++ )
6716
				{
6716
				{
6717
					Utils::String line(lines->at(j));
6717
					Utils::String line(lines->at(j));
6718
					aniList.PushBack(CyString(line));
6718
					aniList.pushBack(line);
6719
				}
6719
				}
6720
 
6720
 
6721
				delete lines;
6721
				delete lines;
6722
			}
6722
			}
6723
 
6723
 
6724
			File.remove();
6724
			File.remove();
6725
		}
6725
		}
6726
	}
6726
	}
6727
 
6727
 
6728
	CyStringList parsedAniList;
6728
	Utils::CStringList parsedAniList;
6729
	CXspFile::ReadAnimations(&aniList, &parsedAniList, 0);
6729
	CXspFile::ReadAnimations(aniList, parsedAniList, 0);
6730
 
6730
 
6731
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6731
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6732
	{
6732
	{
6733
		SGameShip *s = node->Data();
6733
		SGameShip *s = node->Data();
6734
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6734
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6735
			continue;
6735
			continue;
6736
 
6736
 
6737
		// no dummies to add?
6737
		// no dummies to add?
6738
		if ( !s->pPackage->AnyAnimations() )
6738
		if ( !s->pPackage->anyAnimations() )
6739
			continue;
6739
			continue;
6740
 
6740
 
6741
		// add each dummy to list
6741
		// add each dummy to list
6742
		for ( SStringList *strNode = s->pPackage->GetAnimations()->Head(); strNode; strNode = strNode->;next )
6742
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6743
			parsedAniList.PushBack(strNode->str);
6743
			parsedAniList.pushBack((*itr)->str);
6744
	}
6744
	}
6745
 
6745
 
6746
	// format the list with added spaces
6746
	// format the list with added spaces
6747
	CyStringList formatedAniList;
6747
	Utils::CStringList formatedAniList;
6748
	int lineCount = -1;
6748
	int lineCount = -1;
6749
	for ( SStringList *strNode = parsedAniList.Head(); strNode; strNode = strNode->;next )
6749
	for(auto itr = parsedAniList.begin(); itr != parsedAniList.end(); itr++)
6750
	{
6750
	{
6751
		// format the comment to match the line number
6751
		// format the comment to match the line number
6752
		lineCount++;
6752
		lineCount++;
6753
		CyString oldComment = strNode->str.GetToken("//", 2);
6753
		Utils::String oldComment = (*itr)->str.tokens("//", 2);
6754
		CyString comment = CyString("//") + CyString::Number(lineCount);
6754
		Utils::String comment = "//" + Utils::String::Number(lineCount);
6755
		if ( !oldComment.Empty() )
6755
		if (!oldComment.empty())
6756
		{
6756
		{
6757
			comment += " ";
6757
			comment += " ";
6758
			oldComment.RemoveFirstSpace();
6758
			oldComment.removeFirstSpace();
6759
			if ( oldComment.GetToken(" ", 1, 1).IsNumber() )
6759
			if ( oldComment.token(" ", 1).isNumber() )
6760
				comment += oldComment.GetToken(" ", 2);
6760
				comment += oldComment.tokens(" ", 2);
6761
			else
6761
			else
6762
				comment += oldComment;
6762
				comment += oldComment;
6763
		}
6763
		}
6764
		CyString line = strNode->str.GetToken("//", 1, 1);
6764
		Utils::String line = (*itr)->str.token("//", 1);
6765
 
6765
 
6766
		// split into seperate lines
6766
		// split into seperate lines
6767
		CyString first = line.GetToken(";", 1, 1);
6767
		Utils::String first = line.token(";", 1);
6768
		if ( first.Compare("TAT_TAGSINGLESTEP") )
6768
		if ( first.Compare("TAT_TAGSINGLESTEP") )
6769
		{
6769
		{
6770
			formatedAniList.PushBack(line.GetToken(";", 1, 5) + ";");
6770
			formatedAniList.pushBack(line.tokens(";", 1, 5) + ";");
6771
			int max;
6771
			int max;
6772
			CyString *sLines = line.GetToken(";", 6).SplitToken(";", &max);
6772
			Utils::String *sLines = line.tokens(";", 6).tokenise(";", &max);
6773
			if ( max && sLines )
6773
			if ( max && sLines )
6774
			{
6774
			{
6775
				if ( sLines[max - 1].Empty() )
6775
				if ( sLines[max - 1].empty() )
6776
					--max; // remove the last ";"
6776
					--max; // remove the last ";"
6777
 
6777
 
6778
				for ( int i = 0; i < max; i++ )
6778
				for ( int i = 0; i < max; i++ )
6779
				{
6779
				{
6780
					CyString l = CyString("\t") + sLines[i] + ";";
6780
					Utils::String l = "\t" + sLines[i] + ";";
6781
					if ( i == (max - 1) )
6781
					if ( i == (max - 1) )
6782
						formatedAniList.PushBack(l + comment);
6782
						formatedAniList.pushBack(l + comment);
6783
					else
6783
					else
6784
						formatedAniList.PushBack(l);
6784
						formatedAniList.pushBack(l);
6785
				}
6785
				}
6786
			}
6786
			}
6787
			CLEANSPLIT(sLines, max);
6787
			CLEANSPLIT(sLines, max);
6788
		}
6788
		}
6789
		else if ( (first.Compare("TAT_TAGONESHOT") || first.Compare("TAT_TAGLOOP")) && (line.IsIn("TATF_COORDS")) )
6789
		else if ( (first.Compare("TAT_TAGONESHOT") || first.Compare("TAT_TAGLOOP")) && (line.contains("TATF_COORDS")) )
6790
		{
6790
		{
6791
			formatedAniList.PushBack(line.GetToken(";", 1, 5) + ";");
6791
			formatedAniList.pushBack(line.tokens(";", 1, 5) + ";");
6792
			int max;
6792
			int max;
6793
			CyString *sLines = line.GetToken(";", 6).SplitToken(";", &max);
6793
			Utils::String *sLines = line.tokens(";", 6).tokenise(";", &max);
6794
			if ( max && sLines )
6794
			if ( max && sLines )
6795
			{
6795
			{
6796
				if ( sLines[max - 1].Empty() )
6796
				if ( sLines[max - 1].empty() )
6797
					--max; // remove the last ";"
6797
					--max; // remove the last ";"
6798
 
6798
 
6799
				CyString prevLine;
6799
				Utils::String prevLine;
6800
				for ( int i = 0; i < max; i++ )
6800
				for ( int i = 0; i < max; i++ )
6801
				{
6801
				{
6802
					CyString l = sLines[i] + ";";
6802
					Utils::String l = sLines[i] + ";";
6803
					if ( l.IsIn("TATF_COORDS") && !prevLine.Empty() )
6803
					if ( l.contains("TATF_COORDS") && !prevLine.empty() )
6804
					{
6804
					{
6805
						formatedAniList.PushBack(CyString("\t") + prevLine);
6805
						formatedAniList.pushBack("\t" + prevLine);
6806
						prevLine = "";
6806
						prevLine = "";
6807
					}
6807
					}
6808
					prevLine += l;
6808
					prevLine += l;
6809
				}
6809
				}
6810
 
6810
 
6811
				if ( !prevLine.Empty() )
6811
				if ( !prevLine.empty() )
6812
					formatedAniList.PushBack(CyString("\t") + prevLine + comment);
6812
					formatedAniList.pushBack("\t" + prevLine + comment);
6813
 
6813
 
6814
			}
6814
			}
6815
			CLEANSPLIT(sLines, max);
6815
			CLEANSPLIT(sLines, max);
6816
		}
6816
		}
6817
		else
6817
		else
6818
			formatedAniList.PushBack(line + comment);
6818
			formatedAniList.pushBack(line + comment);
6819
	}
6819
	}
6820
 
6820
 
6821
	formatedAniList.PushFront(CyString::Number(parsedAniList.Count()) + ";");
6821
	formatedAniList.pushFront(Utils::String::Number(parsedAniList.size()) + ";");
6822
	formatedAniList.PushFront(CyString(";// Animations, created by SPK Libraries V") + CyString::CreateFromFloat(GetLibraryVersion(), 2));
6822
	formatedAniList.pushFront(";// Animations, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6823
 
6823
 
6824
	// write the file to disk
6824
	// write the file to disk
6825
	CFileIO WriteFile(m_sTempDir + "/Animations.txt");
6825
	CFileIO WriteFile(m_sTempDir + "/Animations.txt");
6826
	if ( WriteFile.WriteFile(&formatedAniList) )
6826
	if ( WriteFile.writeFile(&formatedAniList) )
6827
	{
6827
	{
6828
		this->PackFile(&WriteFile, "types\\Animations.pck");
6828
		this->PackFile(&WriteFile, "types\\Animations.pck");
6829
		WriteFile.remove();
6829
		WriteFile.remove();
6830
	}
6830
	}
6831
}
6831
}
Line 6842... Line 6842...
6842
		SGameShip *s = node->Data();
6842
		SGameShip *s = node->Data();
6843
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6843
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6844
			continue;
6844
			continue;
6845
 
6845
 
6846
		// no dummies to add?
6846
		// no dummies to add?
6847
		if ( !s->pPackage->AnyBodies() )
6847
		if ( !s->pPackage->anyBodies() )
6848
			continue;
6848
			continue;
6849
		found = true;
6849
		found = true;
6850
		break;
6850
		break;
6851
	}
6851
	}
6852
 
6852
 
Line 6911... Line 6911...
6911
		SGameShip *s = node->Data();
6911
		SGameShip *s = node->Data();
6912
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6912
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6913
			continue;
6913
			continue;
6914
 
6914
 
6915
		// no dummies to add?
6915
		// no dummies to add?
6916
		if ( !s->pPackage->AnyBodies() )
6916
		if ( !s->pPackage->anyBodies() )
6917
			continue;
6917
			continue;
6918
 
6918
 
6919
		// add each dummy to list
6919
		// add each dummy to list
6920
		for ( SStringList *strNode = s->pPackage->GetBodies()->Head(); strNode; strNode = strNode->;next )
6920
		for(auto itr = s->pPackage->getBodies().begin(); itr != s->pPackage->getBodies().end(); itr++)
6921
		{
6921
		{
6922
			CyString section = strNode-&gt;str.GetToken(";", 1, 1);
6922
			Utils::String section = (*itr)-&gt;str.token(";", 1);
6923
			CyString body = strNode->str.GetToken(";", 2).Remove(' ');
6923
			Utils::String body = (*itr)->str.tokens(";", 2).remove(' ');
6924
			if ( body.Right(1) != ";" )
6924
			if ( body.right(1) != ";" )
6925
				body += ";";
6925
				body += ";";
6926
 
6926
 
6927
			// find the section to add into
6927
			// find the section to add into
6928
			SBodies *foundSection = NULL;
6928
			SBodies *foundSection = NULL;
6929
			for ( CListNode<SBodies> *checkBody = bodiesList.Front(); checkBody; checkBody = checkBody->next() )
6929
			for ( CListNode<SBodies> *checkBody = bodiesList.Front(); checkBody; checkBody = checkBody->next() )
6930
			{
6930
			{
6931
				if ( checkBody->Data()->sSection.Compare(section.ToString()))
6931
				if ( checkBody->Data()->sSection.Compare(section))
6932
				{
6932
				{
6933
					foundSection = checkBody->Data();
6933
					foundSection = checkBody->Data();
6934
					break;
6934
					break;
6935
				}
6935
				}
6936
			}
6936
			}
6937
 
6937
 
6938
			if ( !foundSection )
6938
			if ( !foundSection )
6939
			{
6939
			{
6940
				foundSection = new SBodies;
6940
				foundSection = new SBodies;
6941
				foundSection->sSection = section.ToString();
6941
				foundSection->sSection = section;
6942
				bodiesList.push_back(foundSection);
6942
				bodiesList.push_back(foundSection);
6943
			}
6943
			}
6944
			if(!foundSection->lEntries.contains(body.ToString()))
6944
			if(!foundSection->lEntries.contains(body))
6945
				foundSection->lEntries.pushBack(body.ToString());
6945
				foundSection->lEntries.pushBack(body);
6946
		}
6946
		}
6947
	}
6947
	}
6948
 
6948
 
6949
	// now write the file
6949
	// now write the file
6950
	std::vector<Utils::String> writeList;
6950
	std::vector<Utils::String> writeList;
Line 7005... Line 7005...
7005
		createFiles.PushBack(name, "types/JobWings");
7005
		createFiles.PushBack(name, "types/JobWings");
7006
 
7006
 
7007
		for ( SStringList *str = createFiles.Head(); str; str = str->next )
7007
		for ( SStringList *str = createFiles.Head(); str; str = str->next )
7008
		{
7008
		{
7009
			Utils::String dir = CFileIO(str->data).dir();
7009
			Utils::String dir = CFileIO(str->data).dir();
7010
			int type = FILETYPE_EXTRA;
7010
			FileType type = FileType::FILETYPE_EXTRA;
7011
			if ( dir.Compare("maps") )
7011
			if ( dir.Compare("maps") )
7012
				type = FILETYPE_MAP;
7012
				type = FileType::FILETYPE_MAP;
7013
 
7013
 
7014
			if ( !p->FindFile(str->str + ".xml", type) &&amp; !p->FindFile(str-&gt;str + &quot;.pck", type) )
7014
			if ( !p->findFile(str->str.ToString() + ".xml", type) &&amp; !p->findFile(str-&gt;str.ToString() + &quot;.pck", type))
7015
			{
7015
			{
7016
				// create a maps files
7016
				// create a maps files
7017
				int e = this->ExtractGameFile(str->data + ".pck", m_sTempDir + "/" + str->data.ToString() + ".pck");
7017
				int e = this->ExtractGameFile(str->data + ".pck", m_sTempDir + "/" + str->data.ToString() + ".pck");
7018
				if ( e )
7018
				if ( e )
7019
				{
7019
				{
Line 7449... Line 7449...
7449
	// no ships ?
7449
	// no ships ?
7450
	if ( m_lGameShips.empty() )
7450
	if ( m_lGameShips.empty() )
7451
		return;
7451
		return;
7452
 
7452
 
7453
	// get the cockpit list to match with ships turrets
7453
	// get the cockpit list to match with ships turrets
7454
	CyStringList Cockpits;
7454
	Utils::CStringList Cockpits;
7455
	CyStringList *cockpitList = this->CreateCockpits();
7455
	CyStringList *cockpitList = this->CreateCockpits();
7456
	if ( cockpitList )
7456
	if ( cockpitList )
7457
	{
7457
	{
7458
		for ( SStringList *str = cockpitList->Head(); str; str = str->next )
7458
		for ( SStringList *str = cockpitList->Head(); str; str = str->next )
7459
		{
7459
		{
7460
			CyString id = str->str.GetToken(";", 19, 19);
7460
			CyString id = str->str.GetToken(";", 19, 19);
7461
			Cockpits.PushBack(id);
7461
			Cockpits.pushBack(id.ToString());
7462
		}
7462
		}
7463
 
7463
 
7464
		delete cockpitList;
7464
		delete cockpitList;
7465
	}
7465
	}
7466
 
7466
 
Line 7516... Line 7516...
7516
						// check for any ship overrides
7516
						// check for any ship overrides
7517
						bool added = false;
7517
						bool added = false;
7518
						if ( !shipOverrides.empty() )
7518
						if ( !shipOverrides.empty() )
7519
						{
7519
						{
7520
							CShipData shipData;
7520
							CShipData shipData;
7521
							if ( shipData.ReadShipData(line) )
7521
							if ( shipData.readShipData(line) )
7522
							{
7522
							{
7523
								for ( CListNode<SGameShip> *node = shipOverrides.Front(); node; node = node->next() )
7523
								for ( CListNode<SGameShip> *node = shipOverrides.Front(); node; node = node->next() )
7524
								{
7524
								{
7525
									SGameShip *s = node->Data();
7525
									SGameShip *s = node->Data();
7526
									if ( !s->pPackage->GetShipID().Compare(shipData.sID.ToString()) )
7526
									if ( !s->pPackage->GetShipID().Compare(shipData.sID) )
7527
										continue;
7527
										continue;
7528
									s->iText = shiptext;
7528
									s->iText = shiptext;
7529
									if ( !s->pPackage->GetOriginalDescription() )
7529
									if ( !s->pPackage->GetOriginalDescription() )
7530
										shiptext += 2;
7530
										shiptext += 2;
7531
									s->iPos = tshipsList.Count();
7531
									s->iPos = tshipsList.Count();
7532
									added = true;
7532
									added = true;
7533
									tshipsList.PushBack(CyString(s->pPackage->FormatShipData(&Cockpits, &s->iText, m_iGame)));
7533
									tshipsList.PushBack(CyString(s->pPackage->formatShipData(Cockpits, &s->iText, m_iGame)));
7534
									shipOverrides.remove(node);
7534
									shipOverrides.remove(node);
7535
									break;
7535
									break;
7536
								}
7536
								}
7537
							}
7537
							}
7538
						}
7538
						}
Line 7578... Line 7578...
7578
				{
7578
				{
7579
					s->iText = shiptext;
7579
					s->iText = shiptext;
7580
					if ( !s->pPackage->GetOriginalDescription() )
7580
					if ( !s->pPackage->GetOriginalDescription() )
7581
						shiptext += 2;
7581
						shiptext += 2;
7582
 
7582
 
7583
					tshipsList.PushBack(CyString(s->pPackage->FormatShipData(&Cockpits, &s->iText, m_iGame)));
7583
					tshipsList.PushBack(CyString(s->pPackage->formatShipData(Cockpits, &s->iText, m_iGame)));
7584
				}
7584
				}
7585
				else if ( s->iType == WARETYPE_DELETED )
7585
				else if ( s->iType == WARETYPE_DELETED )
7586
					tshipsList.PushBack(bufferStart + "SHIP_DELETED;");
7586
					tshipsList.PushBack(bufferStart + "SHIP_DELETED;");
7587
				else if ( s->iType == WARETYPE_DISABLED )
7587
				else if ( s->iType == WARETYPE_DISABLED )
7588
					tshipsList.PushBack(bufferStart + "SHIP_DISABLED;");
7588
					tshipsList.PushBack(bufferStart + "SHIP_DISABLED;");
Line 8104... Line 8104...
8104
	if (package->autoExtraction())
8104
	if (package->autoExtraction())
8105
	{
8105
	{
8106
		for (auto itr = package->autoExtraction()->begin(); itr != package->autoExtraction()->end(); itr++)
8106
		for (auto itr = package->autoExtraction()->begin(); itr != package->autoExtraction()->end(); itr++)
8107
		{
8107
		{
8108
			unsigned int game = itr->first;
8108
			unsigned int game = itr->first;
8109
			for (auto node = package->fileList()->Front(); node; node = node->next())
8109
			for (auto node = package->fileList().Front(); node; node = node->next())
8110
			{
8110
			{
8111
				C_File *f = node->Data();
8111
				C_File *f = node->Data();
8112
				if (f->game() && f->game() != GAME_ALLNEW && !(f->game() & (1 << game)))
8112
				if (f->game() && f->game() != GAME_ALLNEW && !(f->game() & (1 << game)))
8113
					continue;
8113
					continue;
8114
				package->extractFile(f, itr->second, game, gameAddons);
8114
				package->extractFile(f, itr->second, game, gameAddons);
Line 8133... Line 8133...
8133
		}
8133
		}
8134
 
8134
 
8135
		if ( !ftpdir.Empty() )
8135
		if ( !ftpdir.Empty() )
8136
			ftpaddr += ftpdir;
8136
			ftpaddr += ftpdir;
8137
 
8137
 
8138
		package->SetFtpAddr(ftpaddr);
8138
		package->setFtpAddr(ftpaddr.ToString());
8139
	}
8139
	}
8140
 
8140
 
8141
	return package;
8141
	return package;
8142
}
8142
}
8143
 
8143
 
Line 8250... Line 8250...
8250
			{
8250
			{
8251
				delete p;
8251
				delete p;
8252
				continue;
8252
				continue;
8253
			}
8253
			}
8254
			
8254
			
8255
			if (p->GetIcon())
8255
			if (p->icon())
8256
			{
8256
			{
8257
				bool addedIcon = false;
8257
				bool addedIcon = false;
8258
				p->ReadIconFileToMemory();
8258
				p->ReadIconFileToMemory();
8259
				p->GetIcon()->setFilename(this->tempDirectory().findReplace("\\", "/") + "/" + p->author() + "_" + p->name() + "." + p->iconExt());
8259
				p->icon()->setFilename(this->tempDirectory().findReplace("\\", "/") + "/" + p->author() + "_" + p->name() + "." + p->iconExt());
8260
				p->GetIcon()->setFullDir(this->tempDirectory());
8260
				p->icon()->setFullDir(this->tempDirectory());
8261
				if (p->GetIcon()->UncompressData())
8261
				if (p->icon()->UncompressData())
8262
				{
8262
				{
8263
					if (p->GetIcon()->writeFilePointer())
8263
					if (p->icon()->writeFilePointer())
8264
						addedIcon = true;
8264
						addedIcon = true;
8265
				}
8265
				}
8266
 
8266
 
8267
				if (!addedIcon)
8267
				if (!addedIcon)
8268
					p->SetIcon(NULL, "");
8268
					p->setIcon(NULL, "");
8269
			}
8269
			}
8270
 
8270
 
8271
			// get an advert to display
8271
			// get an advert to display
8272
			if (p->GetFirstFile(FILETYPE_ADVERT))
8272
			if (p->GetFirstFile(FILETYPE_ADVERT))
8273
			{
8273
			{
Line 8645... Line 8645...
8645
 
8645
 
8646
	delete list;
8646
	delete list;
8647
	return NULL;
8647
	return NULL;
8648
}
8648
}
8649
 
8649
 
8650
int CPackages::AdjustFileType(CyString file, int filetype)
8650
FileType CPackages::adjustFileType(const Utils::String &file, FileType filetype) const
8651
{
8651
{
8652
	CFileIO File(file);
8652
	CFileIO File(file);
8653
	Utils::String dir = File.GetDirIO().topDir();
8653
	Utils::String dir = File.GetDirIO().topDir();
8654
	CyString basename = File.baseName();
8654
	CyString basename = File.baseName();
8655
 
8655
 
Line 9359... Line 9359...
9359
			if(!list->contains(node->Data()->webAddress()))
9359
			if(!list->contains(node->Data()->webAddress()))
9360
				list->pushBack(node->Data()->webAddress());
9360
				list->pushBack(node->Data()->webAddress());
9361
		}
9361
		}
9362
		if ( node->Data()->anyWebMirrors() )
9362
		if ( node->Data()->anyWebMirrors() )
9363
		{
9363
		{
9364
			auto l = node->Data()->getWebMirrors();
9364
			auto &l = node->Data()->webMirrors();
9365
			for (auto itr = l->begin(); itr != l->end(); itr++)
9365
			for (auto itr = l.begin(); itr != l.end(); itr++)
9366
			{
9366
			{
9367
				if(!list->contains((*itr)->str))
9367
				if(!list->contains((*itr)->str))
9368
					list->pushBack((*itr)->str);
9368
					list->pushBack((*itr)->str);
9369
			}
9369
			}
9370
		}
9370
		}
Line 9546... Line 9546...
9546
		{
9546
		{
9547
			if ( fileName.Compare("pluginmanager.txt") )
9547
			if ( fileName.Compare("pluginmanager.txt") )
9548
				this->ReadArchiveData(File.fullFilename(), archive);
9548
				this->ReadArchiveData(File.fullFilename(), archive);
9549
			else
9549
			else
9550
			{
9550
			{
9551
				CyString extradir;
9551
				Utils::String extradir;
9552
				int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
9552
				int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
9553
				// check for special file types
9553
				// check for special file types
9554
				C_File *f = NULL;
9554
				C_File *f = NULL;
9555
 
9555
 
9556
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9556
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9557
					f = archive->AddFile(CFileIO(fileName).filename(), "", FILETYPE_SCRIPT);
9557
					f = archive->addFile(CFileIO(fileName).filename(), "", FILETYPE_SCRIPT);
9558
					if ( f ) {
9558
					if ( f ) {
9559
						f->ReadFromFile(File.fullFilename());
9559
						f->ReadFromFile(File.fullFilename());
9560
					}
9560
					}
9561
					type = FILETYPE_UNINSTALL;
9561
					type = FILETYPE_UNINSTALL;
9562
				}
9562
				}
9563
 
9563
 
9564
				if ( type == -1 )
9564
				if ( type == -1 )
9565
					f = archive->AddFile(CFileIO(fileName).filename(), CFileIO(fileName).dir(), FILETYPE_EXTRA);
9565
					f = archive->addFile(CFileIO(fileName).filename(), CFileIO(fileName).dir(), FILETYPE_EXTRA);
9566
				else
9566
				else
9567
					f = archive->AddFile(CFileIO(fileName).filename(), extradir, type);
9567
					f = archive->addFile(CFileIO(fileName).filename(), extradir, static_cast<FileType>(type));
9568
				f->ReadFromFile(File.fullFilename());
9568
				f->ReadFromFile(File.fullFilename());
9569
			}
9569
			}
9570
 
9570
 
9571
			File.remove();
9571
			File.remove();
9572
		}
9572
		}
Line 9629... Line 9629...
9629
 
9629
 
9630
 
9630
 
9631
		char *iBuf = new char[ze.unc_size];
9631
		char *iBuf = new char[ze.unc_size];
9632
		UnzipItem(hz, zi, iBuf, ze.unc_size);
9632
		UnzipItem(hz, zi, iBuf, ze.unc_size);
9633
 
9633
 
9634
		CyString Name(ze.name);
9634
		Utils::String Name(CyString(ze.name).ToString());
9635
 
9635
 
9636
		// if its the data file, dont add it, but extract to get settings from
9636
		// if its the data file, dont add it, but extract to get settings from
9637
		if ( Name.Compare("pluginmanager.txt") )
9637
		if ( Name.Compare("pluginmanager.txt") )
9638
		{
9638
		{
9639
			this->ReadArchiveData(iBuf, ze.unc_size, archive);
9639
			this->ReadArchiveData(iBuf, ze.unc_size, archive);
9640
			delete[] iBuf;
9640
			delete[] iBuf;
9641
		}
9641
		}
9642
		else
9642
		else
9643
		{
9643
		{
9644
			CyString extradir;
9644
			Utils::String extradir;
9645
			int type = SPK::GetAutomaticFiletype(Name, &extradir, true);
9645
			int type = SPK::GetAutomaticFiletype(Name, &extradir, true);
9646
 
9646
 
9647
			C_File *f = NULL;
9647
			C_File *f = NULL;
9648
 
9648
 
9649
			Utils::String filename = CFileIO(Name).filename();
9649
			Utils::String filename = CFileIO(Name).filename();
9650
			Utils::String dir = CFileIO(Name).dir();
9650
			Utils::String dir = CFileIO(Name).dir();
9651
 
9651
 
9652
			// check for special file types
9652
			// check for special file types
9653
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9653
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9654
				f = archive->AddFile(filename, dir, FILETYPE_SCRIPT);
9654
				f = archive->addFile(filename, dir, FILETYPE_SCRIPT);
9655
				if ( f ) {
9655
				if ( f ) {
9656
					f->copyData((const unsigned char *)iBuf, ze.unc_size);
9656
					f->copyData((const unsigned char *)iBuf, ze.unc_size);
9657
				}
9657
				}
9658
				type = FILETYPE_UNINSTALL;
9658
				type = FILETYPE_UNINSTALL;
9659
			}
9659
			}
Line 9667... Line 9667...
9667
				if (g != -1)
9667
				if (g != -1)
9668
					game = g + 1;
9668
					game = g + 1;
9669
			}
9669
			}
9670
 
9670
 
9671
			if ( type == -1 )
9671
			if ( type == -1 )
9672
				f = archive->AddFile(filename, dir, FILETYPE_EXTRA, game);
9672
				f = archive->addFile(filename, dir, FILETYPE_EXTRA, game);
9673
			else
9673
			else
9674
				f = archive->AddFile(filename, extradir, type, game);
9674
				f = archive->addFile(filename, extradir, static_cast<FileType>(type), game);
9675
 
9675
 
9676
			if ( f )
9676
			if ( f )
9677
				f->SetData((const unsigned char *)iBuf, ze.unc_size);
9677
				f->SetData((const unsigned char *)iBuf, ze.unc_size);
9678
			else
9678
			else
9679
				delete[] iBuf;
9679
				delete[] iBuf;
Line 9788... Line 9788...
9788
	int count = 0;
9788
	int count = 0;
9789
	for ( CListNode<C_File> *fn = m_lFiles.Front(); fn; fn = fn->next() )
9789
	for ( CListNode<C_File> *fn = m_lFiles.Front(); fn; fn = fn->next() )
9790
	{
9790
	{
9791
		C_File *f = fn->Data();
9791
		C_File *f = fn->Data();
9792
		bool exists = false;
9792
		bool exists = false;
9793
		if ( f->GetFilePointer().IsIn("::") ) {
9793
		if ( f->filePointer().contains("::") ) {
9794
			CyString modFile = f->GetFilePointer().GetToken("::", 1, 1);
9794
			Utils::String modFile = f->filePointer().token("::", 1);
9795
			CyString file = f->GetFilePointer().GetToken("::", 2, 2);
9795
			Utils::String file = f->filePointer().token("::", 2);
9796
 
9796
 
9797
			if ( CFileIO(modFile).ExistsOld() ) {
9797
			if ( CFileIO::Exists(modFile)) {
9798
				CCatFile catFile;
9798
				CCatFile catFile;
9799
				if ( catFile.open(modFile.ToString(), "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
9799
				if ( catFile.open(modFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
9800
					if ( catFile.FindData(file) )
9800
					if ( catFile.FindData(file) )
9801
						exists = true;
9801
						exists = true;
9802
				}
9802
				}
9803
			}
9803
			}
9804
		}
9804
		}
9805
		else {
9805
		else {
9806
			exists = CFileIO(f->GetFilePointer()).ExistsOld();
9806
			exists = CFileIO::Exists(f->filePointer());
9807
		}
9807
		}
9808
 
9808
 
9809
		if ( !exists )
9809
		if ( !exists )
9810
		{
9810
		{
9811
			++count;
9811
			++count;
9812
			if ( missingFiles )
9812
			if ( missingFiles )
9813
			{
9813
			{
9814
				CyString packages;
9814
				Utils::String packages;
9815
				if ( getPackages )
9815
				if ( getPackages )
9816
				{
9816
				{
9817
					for ( CListNode<CBaseFile> *p = m_lPackages.Front(); p; p = p->next() )
9817
					for ( CListNode<CBaseFile> *p = m_lPackages.Front(); p; p = p->next() )
9818
					{
9818
					{
9819
						CBaseFile *package = p->Data();
9819
						CBaseFile *package = p->Data();
9820
						if ( package->IsFileAdded(f) )
9820
						if ( package->IsFileAdded(f) )
9821
						{
9821
						{
9822
							if ( !packages.Empty() )
9822
							if ( !packages.empty() )
9823
								packages += "\n";
9823
								packages += "\n";
9824
							packages += package->GetFullPackageName(m_iLanguage);
9824
							packages += package->getFullPackageName(m_iLanguage);
9825
						}
9825
						}
9826
					}
9826
					}
9827
				}
9827
				}
9828
				CyString filename = f->GetFilePointer();
9828
				Utils::String filename = f->filePointer();
9829
				filename = filename.Remove(m_sCurrentDir);
9829
				filename = filename.findRemove(m_sCurrentDir);
9830
				missingFiles->PushBack(filename, packages, false);
9830
				missingFiles->PushBack(CyString(filename), CyString(packages), false);
9831
			}
9831
			}
9832
		}
9832
		}
9833
	}
9833
	}
9834
	return count;
9834
	return count;
9835
}
9835
}