Subversion Repositories spk

Rev

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

Rev 171 Rev 173
Line 5422... Line 5422...
5422
	}
5422
	}
5423
 
5423
 
5424
	return count;
5424
	return count;
5425
}
5425
}
5426
 
5426
 
5427
int CPackages::ExtractGameFile(CyString aFilename, CyString aTo, CyString dir, CyString addon)
5427
int CPackages::extractGameFile(const Utils::String &aFilename, const Utils::String &aTo, const Utils::String &aDir, const Utils::String &addon) const
5428
{
5428
{
5429
	// first check the enabled mod
5429
	// first check the enabled mod
-
 
5430
	Utils::String dir = aDir;
5430
	if ( dir.Empty() )
5431
	if (dir.empty())
5431
		dir = m_sCurrentDir;
5432
		dir = m_sCurrentDir;
5432
 
5433
 
5433
	CyString addonDir = addon;
5434
	Utils::String addonDir = addon;
5434
	if ( addonDir.Empty() ) addonDir = this->GetAddonDir(dir);
5435
	if (addonDir.empty()) addonDir = this->getAddonDir(dir);
5435
 
5436
 
5436
	if ( m_pEnabledMod && m_pEnabledMod->AnyFileType(FILETYPE_MOD) )
5437
	if (m_pEnabledMod && m_pEnabledMod->AnyFileType(FILETYPE_MOD))
5437
	{
5438
	{
5438
		for ( C_File *file = m_pEnabledMod->GetFirstFile(FILETYPE_MOD); file; file = m_pEnabledMod->GetNextFile(file) )
5439
		for (C_File* file = m_pEnabledMod->GetFirstFile(FILETYPE_MOD); file; file = m_pEnabledMod->GetNextFile(file))
5439
		{
5440
		{
5440
			if ( !file->CheckFileExt("cat") )
5441
			if (!file->CheckFileExt("cat"))
5441
				continue;
5442
				continue;
5442
 
5443
 
5443
			CCatFile catFile;
5444
			CCatFile catFile;
5444
			if ( catFile.open(file->filePointer(), addonDir.ToString(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
5445
			if (catFile.open(file->filePointer(), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5445
			{
5446
			{
5446
				if ( catFile.ExtractFile(aFilename, aTo) )
5447
				if (catFile.ExtractFile(aFilename, aTo))
5447
					return 1;
5448
					return 1;
5448
				if ( catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR )
5449
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5449
				{
5450
				{
5450
					if ( catFile.ExtractFile(aFilename) )
5451
					if (catFile.ExtractFile(aFilename))
5451
						return -1;
-
 
5452
				}
-
 
5453
 
-
 
5454
			}
-
 
5455
		}
-
 
5456
	}
-
 
5457
	else if ( !m_sSetMod.empty() )
-
 
5458
	{
-
 
5459
		if ( CFileIO::Exists(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat"))
-
 
5460
		{
-
 
5461
			CCatFile catFile;
-
 
5462
			if (catFile.open(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat", addonDir.ToString(), CATREAD_CATDECRYPT, false) == CATERR_NONE)
-
 
5463
			{
-
 
5464
				if ( catFile.ExtractFile(aFilename, aTo) )
-
 
5465
					return 1;
-
 
5466
				if ( catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR )
-
 
5467
				{
-
 
5468
					if ( catFile.ExtractFile(aFilename) )
-
 
5469
						return -1;
5452
						return -1;
5470
				}
5453
				}
-
 
5454
 
5471
			}
5455
			}
-
 
5456
		}
-
 
5457
	}
-
 
5458
	else if (!m_sSetMod.empty())
-
 
5459
	{
-
 
5460
		if (CFileIO::Exists(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat"))
-
 
5461
		{
-
 
5462
			CCatFile catFile;
-
 
5463
			if (catFile.open(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat", addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
-
 
5464
			{
-
 
5465
				if (catFile.ExtractFile(aFilename, aTo))
-
 
5466
					return 1;
-
 
5467
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
-
 
5468
				{
-
 
5469
					if (catFile.ExtractFile(aFilename))
-
 
5470
						return -1;
-
 
5471
				}
-
 
5472
			}
5472
		}
5473
		}
5473
	}
5474
	}
5474
 
5475
 
5475
	// find the highest cat number
5476
	// find the highest cat number
5476
	int catNumber = 1;
5477
	int catNumber = 1;
5477
	while ( CFileIO(dir + ";/"; + CyString::Number(catNumber).PadNumber(2) + ".cat").ExistsOld() &;& catNumber < 99 )
5478
	while (CFileIO::Exists(dir + ";/"; + Utils::String::PadNumber(catNumber, 2) + ".cat") &&; catNumber < 99)
5478
		++catNumber;
5479
		++catNumber;
5479
 
5480
 
5480
	// get the last one, not the next free one
5481
	// get the last one, not the next free one
5481
	--catNumber;
5482
	--catNumber;
5482
 
5483
 
5483
	// work backwards until we find the file
5484
	// work backwards until we find the file
5484
	for ( ; catNumber; catNumber-- )
5485
	for (; catNumber; catNumber--)
5485
	{
5486
	{
5486
		CCatFile catFile;
5487
		CCatFile catFile;
5487
		if (catFile.open((dir + "/" + CyString::Number(catNumber).PadNumber(2) + ";.cat").ToString(), addonDir.ToString(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
5488
		if (catFile.open((dir + "/" + Utils::String::PadNumber(catNumber, 2) + ";.cat"), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5488
		{
5489
		{
5489
			// check for the file
5490
			// check for the file
5490
			if ( catFile.ExtractFile(aFilename, aTo) )
5491
			if (catFile.ExtractFile(aFilename, aTo))
5491
				return 1;
5492
				return 1;
5492
			if ( catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR )
5493
			if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5493
			{
5494
			{
5494
				if ( catFile.ExtractFile(aFilename) )
5495
				if (catFile.ExtractFile(aFilename))
5495
					return -1;
5496
					return -1;
5496
			}
5497
			}
5497
		}
5498
		}
5498
	}
5499
	}
5499
 
5500
 
5500
	return 0;
5501
	return 0;
5501
}
5502
}
5502
 
5503
 
5503
void CPackages::CreateWareFiles()
5504
void CPackages::CreateWareFiles()
5504
{
5505
{
Line 5512... Line 5513...
5512
 
5513
 
5513
		// lets extract the ware file
5514
		// lets extract the ware file
5514
		char wareType = CPackages::ConvertWareTypeBack(i);
5515
		char wareType = CPackages::ConvertWareTypeBack(i);
5515
		Utils::String wareFile = "TWare";
5516
		Utils::String wareFile = "TWare";
5516
		wareFile += (char)UPPER(wareType);
5517
		wareFile += (char)UPPER(wareType);
5517
 
5518
 
5518
		CyString openFile;
5519
		CyString openFile;
5519
 
5520
 
5520
		int e;
5521
		int e;
5521
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + "/TWareT.txt") )
5522
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + "/TWareT.txt") )
5522
			openFile = m_sTempDir + "/TWareT.txt";
5523
			openFile = m_sTempDir + "/TWareT.txt";
Line 5541... Line 5542...
5541
			if ( lines )
5542
			if ( lines )
5542
			{
5543
			{
5543
				for(auto itr = lines->begin(); itr != lines->end(); itr++)
5544
				for(auto itr = lines->begin(); itr != lines->end(); itr++)
5544
				{
5545
				{
5545
					Utils::String line((*itr)->str);
5546
					Utils::String line((*itr)->str);
5546
					line.removeFirstSpace();
5547
					line.removeFirstSpace();
5547
					line.removeChar(9);
5548
					line.removeChar(9);
5548
					line.removeChar('\r');
5549
					line.removeChar('\r');
5549
					if ( line.empty() )
5550
					if ( line.empty() )
5550
						continue;
5551
						continue;
5551
					if ( line[0] == '/' )
5552
					if ( line[0] == '/' )
5552
						continue;
5553
						continue;
5553
 
5554
 
5554
					if ( oldSize == -1 )
5555
					if ( oldSize == -1 )
5555
					{
5556
					{
5556
						version = line.token(";", 1).toInt();
5557
						version = line.token(";", 1).toInt();
5557
						oldSize = line.token(";", 2).toInt();
5558
						oldSize = line.token(";", 2).toInt();
5558
					}
5559
					}
Line 5566... Line 5567...
5566
							break;
5567
							break;
5567
					}
5568
					}
5568
				}
5569
				}
5569
 
5570
 
5570
				delete lines;
5571
				delete lines;
5571
 
5572
 
5572
				// apply the buffer
5573
				// apply the buffer
5573
				if ( m_iWareBuffer[i] <= 0 )
5574
				if ( m_iWareBuffer[i] <= 0 )
5574
					m_iWareBuffer[i] = wareLines.size() + 10;
5575
					m_iWareBuffer[i] = wareLines.size() + 10;
5575
				// last resort, readjust the buffer
5576
				// last resort, readjust the buffer
5576
				else if ( wareLines.size() > static_cast<size_t>(m_iWareBuffer[i]) )
5577
				else if ( wareLines.size() > static_cast<size_t>(m_iWareBuffer[i]) )
Line 5590... Line 5591...
5590
						continue;
5591
						continue;
5591
					else if ( w->iType == WARETYPE_DISABLED )
5592
					else if ( w->iType == WARETYPE_DISABLED )
5592
					{
5593
					{
5593
						create = true;
5594
						create = true;
5594
						wareLines.pushBack("27;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;" + w->sWareName + "_DISABLED;");
5595
						wareLines.pushBack("27;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;" + w->sWareName + "_DISABLED;");
5595
					}
5596
					}
5596
					else if ( w->iType == WARETYPE_DELETED || !w->pWare )
5597
					else if ( w->iType == WARETYPE_DELETED || !w->pWare )
5597
					{
5598
					{
5598
						create = true;
5599
						create = true;
5599
						wareLines.pushBack("27;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;SS_WARE_DELETED;");
5600
						wareLines.pushBack("27;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;SS_WARE_DELETED;");
5600
					}
5601
					}
Line 5735... Line 5736...
5735
			CFileIO readFile((e == -1) ? "TWareT.txt" : m_sTempDir + "/TWareT.txt");
5736
			CFileIO readFile((e == -1) ? "TWareT.txt" : m_sTempDir + "/TWareT.txt");
5736
			std::vector<Utils::String> *lines = readFile.readLines();
5737
			std::vector<Utils::String> *lines = readFile.readLines();
5737
			if ( lines )
5738
			if ( lines )
5738
			{
5739
			{
5739
				for ( int i = 0; i < (int)lines->size(); i++ )
5740
				for ( int i = 0; i < (int)lines->size(); i++ )
5740
				{
5741
				{
5741
					Utils::String line(lines->at(i));
5742
					Utils::String line(lines->at(i));
5742
					line.removeFirstSpace();
5743
					line.removeFirstSpace();
5743
					line.removeChar('\r');
5744
					line.removeChar('\r');
5744
					line.removeChar(9);
5745
					line.removeChar(9);
5745
					if ( line[0] == '/' )
5746
					if ( line[0] == '/' )
Line 5832... Line 5833...
5832
						{
5833
						{
5833
							for (size_t i = (maxsize + empEntries); i < wareLines.size(); i++)
5834
							for (size_t i = (maxsize + empEntries); i < wareLines.size(); i++)
5834
							{
5835
							{
5835
								auto node = wareLines.get(i);
5836
								auto node = wareLines.get(i);
5836
								addAfter.pushBack(node->str);
5837
								addAfter.pushBack(node->str);
5837
							}
5838
							}
5838
						}
5839
						}
5839
 
5840
 
5840
						// no remove them all
5841
						// no remove them all
5841
						while (wareLines.size() > maxsize)
5842
						while (wareLines.size() > maxsize)
5842
							wareLines.removeAt(wareLines.size() - 1);
5843
							wareLines.removeAt(wareLines.size() - 1);
5843
					}
5844
					}
5844
					else if ( m_iGame == GAME_X3TC || m_iGame == GAME_X3AP || m_iGame == GAME_X3FL) // check if old emp is included, and convert it
5845
					else if ( m_iGame == GAME_X3TC || m_iGame == GAME_X3AP || m_iGame == GAME_X3FL) // check if old emp is included, and convert it
Line 6606... Line 6607...
6606
	if ( !found )
6607
	if ( !found )
6607
		return;
6608
		return;
6608
 
6609
 
6609
	CyStringList cutList;
6610
	CyStringList cutList;
6610
	int e = ExtractGameFile("types/CutData.pck", m_sTempDir + "/CutData.txt");
6611
	int e = ExtractGameFile("types/CutData.pck", m_sTempDir + "/CutData.txt");
6611
	if ( e )
6612
	if ( e )
6612
	{
6613
	{
6613
		CFileIO File;
6614
		CFileIO File;
6614
		if ( File.open((e == -1) ? "CutData.txt" : m_sTempDir + "/CutData.txt") )
6615
		if ( File.open((e == -1) ? "CutData.txt" : m_sTempDir + "/CutData.txt") )
6615
		{
6616
		{
6616
			std::vector<Utils::String> *lines = File.readLines();
6617
			std::vector<Utils::String> *lines = File.readLines();
6617
			if ( lines )
6618
			if ( lines )
6618
			{
6619
			{
Line 6655... Line 6656...
6655
			continue;
6656
			continue;
6656
 
6657
 
6657
		// add each dummy to list
6658
		// add each dummy to list
6658
		auto& list = s->pPackage->getCutData();
6659
		auto& list = s->pPackage->getCutData();
6659
		for(auto itr = list.begin(); itr != list.end(); itr++)
6660
		for(auto itr = list.begin(); itr != list.end(); itr++)
6660
		{
6661
		{
6661
			Utils::String str = (*itr)->str;
6662
			Utils::String str = (*itr)->str;
6662
			str.removeChar(' ');
6663
			str.removeChar(' ');
6663
			if ( str.right(1) != ";" )
6664
			if ( str.right(1) != ";" )
6664
				str += ";";
6665
				str += ";";
6665
			cutList.PushBack(CyString(str), true);
6666
			cutList.PushBack(CyString(str), true);
6666
		}
6667
		}
6667
	}
6668
	}
Line 6802... Line 6803...
6802
					Utils::String l = sLines[i] + ";";
6803
					Utils::String l = sLines[i] + ";";
6803
					if ( l.contains("TATF_COORDS") && !prevLine.empty() )
6804
					if ( l.contains("TATF_COORDS") && !prevLine.empty() )
6804
					{
6805
					{
6805
						formatedAniList.pushBack("\t" + prevLine);
6806
						formatedAniList.pushBack("\t" + prevLine);
6806
						prevLine = "";
6807
						prevLine = "";
6807
					}
6808
					}
6808
					prevLine += l;
6809
					prevLine += l;
6809
				}
6810
				}
6810
 
6811
 
6811
				if ( !prevLine.empty() )
6812
				if ( !prevLine.empty() )
6812
					formatedAniList.pushBack("\t" + prevLine + comment);
6813
					formatedAniList.pushBack("\t" + prevLine + comment);
Line 6825... Line 6826...
6825
	CFileIO WriteFile(m_sTempDir + "/Animations.txt");
6826
	CFileIO WriteFile(m_sTempDir + "/Animations.txt");
6826
	if ( WriteFile.writeFile(&formatedAniList) )
6827
	if ( WriteFile.writeFile(&formatedAniList) )
6827
	{
6828
	{
6828
		this->PackFile(&WriteFile, "types\\Animations.pck");
6829
		this->PackFile(&WriteFile, "types\\Animations.pck");
6829
		WriteFile.remove();
6830
		WriteFile.remove();
6830
	}
6831
	}
6831
}
6832
}
6832
 
6833
 
6833
void CPackages::CreateBodies()
6834
void CPackages::CreateBodies()
6834
{
6835
{
6835
	// first check we have any ships
6836
	// first check we have any ships
Line 6849... Line 6850...
6849
		found = true;
6850
		found = true;
6850
		break;
6851
		break;
6851
	}
6852
	}
6852
 
6853
 
6853
	if ( !found )
6854
	if ( !found )
6854
		return;
6855
		return;
6855
 
6856
 
6856
	// lets read our current bodies file
6857
	// lets read our current bodies file
6857
	CLinkList<SBodies> bodiesList;
6858
	CLinkList<SBodies> bodiesList;
6858
	SBodies *currentSection = NULL;
6859
	SBodies *currentSection = NULL;
6859
	int e = ExtractGameFile("types/Bodies.pck", m_sTempDir + "/Bodies.txt");
6860
	int e = ExtractGameFile("types/Bodies.pck", m_sTempDir + "/Bodies.txt");
6860
	if ( e )
6861
	if ( e )
Line 6994... Line 6995...
6994
			continue;
6995
			continue;
6995
 
6996
 
6996
		// get the name of the start to use
6997
		// get the name of the start to use
6997
		CyString name = p->GetCustomStartName();
6998
		CyString name = p->GetCustomStartName();
6998
		if ( name.Empty() )
6999
		if ( name.Empty() )
6999
			continue;
7000
			continue;
7000
 
7001
 
7001
		// find if maps file exists
7002
		// find if maps file exists
7002
		CyStringList createFiles;
7003
		CyStringList createFiles;
7003
		createFiles.PushBack(name, "maps/x3_universe");
7004
		createFiles.PushBack(name, "maps/x3_universe");
7004
		createFiles.PushBack(name, "types/Jobs");
7005
		createFiles.PushBack(name, "types/Jobs");
7005
		createFiles.PushBack(name, "types/JobWings");
7006
		createFiles.PushBack(name, "types/JobWings");
Line 7090... Line 7091...
7090
							insection = line.token(";", 2).toInt();
7091
							insection = line.token(";", 2).toInt();
7091
 
7092
 
7092
							// search for the sections
7093
							// search for the sections
7093
							currentSection = NULL;
7094
							currentSection = NULL;
7094
							for ( CListNode<SComponantEntry> *node = dummyList.Front(); node; node = node->next() )
7095
							for ( CListNode<SComponantEntry> *node = dummyList.Front(); node; node = node->next() )
7095
							{
7096
							{
7096
								SComponantEntry *d = node->Data();
7097
								SComponantEntry *d = node->Data();
7097
								if ( d->sSection.Compare(CyString(section)) )
7098
								if ( d->sSection.Compare(CyString(section)) )
7098
								{
7099
								{
7099
									currentSection = node->Data();
7100
									currentSection = node->Data();
7100
									break;
7101
									break;
Line 7187... Line 7188...
7187
					if ( !found2 )
7188
					if ( !found2 )
7188
					{
7189
					{
7189
						found2 = new SComponantEntry2;
7190
						found2 = new SComponantEntry2;
7190
						found2->sSection = dummy->sSection2;
7191
						found2->sSection = dummy->sSection2;
7191
						found->lEntries.push_back(found2);
7192
						found->lEntries.push_back(found2);
7192
					}
7193
					}
7193
					else
7194
					else
7194
					{
7195
					{
7195
						bool f = false;
7196
						bool f = false;
7196
						for ( SStringList *strNode = found2->lEntries.Head(); strNode; strNode = strNode->next )
7197
						for ( SStringList *strNode = found2->lEntries.Head(); strNode; strNode = strNode->next )
7197
						{
7198
						{
Line 7282... Line 7283...
7282
 
7283
 
7283
	return true;
7284
	return true;
7284
}
7285
}
7285
 
7286
 
7286
int CPackages::_warePriceOverride(enum WareTypes type, int pos, const Utils::String &id)
7287
int CPackages::_warePriceOverride(enum WareTypes type, int pos, const Utils::String &id)
7287
{
7288
{
7288
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
7289
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
7289
		if ( node->Data()->type == type ) {
7290
		if ( node->Data()->type == type ) {
7290
			if ( node->Data()->type == Ware_Custom && id.Compare(node->Data()->id) ) return node->Data()->relval;
7291
			if ( node->Data()->type == Ware_Custom && id.Compare(node->Data()->id) ) return node->Data()->relval;
7291
			else if ( node->Data()->type != Ware_Custom && node->Data()->pos == pos ) return node->Data()->relval;
7292
			else if ( node->Data()->type != Ware_Custom && node->Data()->pos == pos ) return node->Data()->relval;
7292
		}
7293
		}
7293
	}
7294
	}
7294
	return 0;
7295
	return 0;
7295
}
7296
}
7296
 
7297
 
7297
bool CPackages::_wareNotoOverride(enum WareTypes type, int pos, const Utils::String &id, int *noto)
7298
bool CPackages::_wareNotoOverride(enum WareTypes type, int pos, const Utils::String &id, int *noto)
7298
{
7299
{
7299
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
7300
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
7300
		if ( node->Data()->type == type && node->Data()->bNotority ) {
7301
		if ( node->Data()->type == type && node->Data()->bNotority ) {
7301
			if ( node->Data()->type == Ware_Custom && !id.Compare(node->Data()->id) ) continue;
7302
			if ( node->Data()->type == Ware_Custom && !id.Compare(node->Data()->id) ) continue;
7302
			else if ( node->Data()->type != Ware_Custom && node->Data()->pos != pos ) continue;
7303
			else if ( node->Data()->type != Ware_Custom && node->Data()->pos != pos ) continue;
7303
		
7304
		
7304
			(*noto) = node->Data()->notority;
7305
			(*noto) = node->Data()->notority;
7305
			return true;
7306
			return true;
7306
		}
7307
		}
7307
	}
7308
	}
7308
	return false;
7309
	return false;
7309
}
7310
}
7310
 
7311
 
7311
void CPackages::_removeWareOverride(enum WareTypes type, int pos, const Utils::String &id)
7312
void CPackages::_removeWareOverride(enum WareTypes type, int pos, const Utils::String &id)
7312
{
7313
{
Line 7331... Line 7332...
7331
}
7332
}
7332
 
7333
 
7333
int CPackages::builtInWareOveridePrice(int id)
7334
int CPackages::builtInWareOveridePrice(int id)
7334
{
7335
{
7335
	return _warePriceOverride(Ware_BuiltIn, id, Utils::String::Null()); 
7336
	return _warePriceOverride(Ware_BuiltIn, id, Utils::String::Null()); 
7336
}
7337
}
7337
 
7338
 
7338
bool CPackages::builtInWareOverideNoto(int id, int *noto)
7339
bool CPackages::builtInWareOverideNoto(int id, int *noto)
7339
{
7340
{
7340
	return _wareNotoOverride(Ware_BuiltIn, id, Utils::String::Null(), noto);
7341
	return _wareNotoOverride(Ware_BuiltIn, id, Utils::String::Null(), noto);
7341
}
7342
}
7342
 
7343
 
Line 7344... Line 7345...
7344
{
7345
{
7345
	return _warePriceOverride(Ware_Custom, 0, id); 
7346
	return _warePriceOverride(Ware_Custom, 0, id); 
7346
}
7347
}
7347
 
7348
 
7348
bool CPackages::customWareOverideNoto(const Utils::String &id, int *noto)
7349
bool CPackages::customWareOverideNoto(const Utils::String &id, int *noto)
7349
{
7350
{
7350
	return _wareNotoOverride(Ware_Custom, 0, id, noto);
7351
	return _wareNotoOverride(Ware_Custom, 0, id, noto);
7351
}
7352
}
7352
 
7353
 
7353
void CPackages::removeEmpOverride(int pos)
7354
void CPackages::removeEmpOverride(int pos)
7354
{
7355
{
Line 7356... Line 7357...
7356
}
7357
}
7357
 
7358
 
7358
void CPackages::removeBuiltinWareOverride(int pos)
7359
void CPackages::removeBuiltinWareOverride(int pos)
7359
{
7360
{
7360
	_removeWareOverride(Ware_BuiltIn, pos, Utils::String::Null());
7361
	_removeWareOverride(Ware_BuiltIn, pos, Utils::String::Null());
7361
}
7362
}
7362
 
7363
 
7363
void CPackages::removeCustomWareOverride(const Utils::String &id)
7364
void CPackages::removeCustomWareOverride(const Utils::String &id)
7364
{
7365
{
7365
	_removeWareOverride(Ware_Custom, 0, id);
7366
	_removeWareOverride(Ware_Custom, 0, id);
7366
}
7367
}
7367
 
7368
 
7368
 
7369
 
7369
bool CPackages::ReadGlobals(CyStringList &globals)
7370
bool CPackages::readGlobals(Utils::CStringList &globals) const
7370
{
7371
{
7371
	int e = ExtractGameFile("types/Globals.pck", m_sTempDir);
7372
	int e = extractGameFile("types/Globals.pck", m_sTempDir);
7372
	if ( e )
7373
	if ( e )
7373
	{
7374
	{
7374
		CFileIO File((e == -1) ? "Globals.txt" : m_sTempDir + "/Globals.txt");
7375
		CFileIO File((e == -1) ? "Globals.txt" : m_sTempDir + "/Globals.txt");
7375
		if ( File.exists() )
7376
		if ( File.exists() )
7376
		{
7377
		{
7377
			CyStringList *lines = File.ReadLinesStr();
7378
			std::vector<Utils::String> lines;
7378
			if ( lines )
7379
			if(File.readLines(lines))
7379
			{
7380
			{
7380
				int entries = -1;
7381
				int entries = -1;
7381
				for ( SStringList *str = lines->Head(); str; str = str->;next )
7382
				for(auto itr = lines.begin(); itr != lines.end(); itr++)
7382
				{
7383
				{
7383
					str->str.RemoveChar(&apos;\r');
7384
					Utils::String str = itr->remove(&apos;\r').remove(9);
7384
					str->str.RemoveChar(9);
-
 
7385
					str->str.RemoveFirstSpace();
7385
					str.removeFirstSpace();
7386
 
7386
 
7387
					if ( str->str.Empty() )
7387
					if ( str.empty() )
7388
						continue;
-
 
7389
					if ( str->str[0] == '/' )
-
 
7390
						continue;
7388
						continue;
-
 
7389
					if ( str[0] == '/' )
-
 
7390
						continue;
7391
 
7391
 
7392
					// remove comments
7392
					// remove comments
7393
					CyString l = str->str;
-
 
7394
					if ( l.IsIn("/") ) 
7393
					if (str.contains("/") ) 
7395
						l = l.GetToken("/", 1, 1);
7394
						str = str.token("/", 1);
7396
 
7395
 
7397
					if ( entries == -1 )
7396
					if ( entries == -1 )
7398
						entries = l.GetToken(";", 1, 1).ToInt();
7397
						entries = str.token(";", 1).toInt();
7399
					else
7398
					else
7400
						globals.PushBack(l.GetToken(";", 1, 1), l.GetToken(";", 2, 2));
7399
						globals.pushBack(str.token(";", 1), str.token(";", 2));
7401
				}
7400
				}
7402
 
-
 
7403
				delete lines;
-
 
7404
 
7401
 
7405
				return true;
7402
				return true;
7406
			}
7403
			}
7407
		}
7404
		}
7408
	}
7405
	}
7409
 
7406
 
7410
	return false;
7407
	return false;
7411
}
7408
}
7412
 
7409
 
7413
void CPackages::CreateGlobals()
7410
void CPackages::CreateGlobals()
7414
{
7411
{
7415
	if ( m_lGlobals.empty() )
7412
	if ( m_lGlobals.empty() )
7416
		return; // no global settings
7413
		return; // no global settings
7417
 
7414
 
7418
	CyStringList globals;
7415
	Utils::CStringList globals;
7419
	if ( ReadGlobals(globals) )
7416
	if (readGlobals(globals))
7420
	{
7417
	{
7421
		// apply out settings
7418
		// apply out settings
7422
		for(auto itr = m_lGlobals.begin(); itr != m_lGlobals.end(); itr++)
7419
		for(auto itr = m_lGlobals.begin(); itr != m_lGlobals.end(); itr++)
7423
		{
-
 
7424
			SStringList *found = globals.FindString((*itr)->str);
-
 
7425
			if ( found )
-
 
7426
				found->data = (*itr)->data;
7420
			globals.changeData((*itr)->str, (*itr)->data);
7427
		}
-
 
7428
 
7421
 
7429
		// now write it
7422
		// now write it
7430
		CyStringList writeList;
7423
		Utils::CStringList writeList;
7431
		for ( SStringList *str = globals.Head(); str; str = str->;next )
7424
		for(auto itr = globals.begin(); itr != globals.end(); itr++)
7432
			writeList.PushBack(str-&gt;str + &quot;;" + str->data + ";");
7425
			writeList.pushBack((*itr)-&gt;str + &quot;;" + (*itr)->data + ";");
7433
		
7426
		
7434
		// finally, write the file
7427
		// finally, write the file
7435
		writeList.PushFront(CyString::Number(writeList.Count()) + "; /globals amount", "");
7428
		writeList.pushFront(Utils::String::Number(writeList.size()) + "; /globals amount", "");
7436
		writeList.PushFront(CyString("// Globals file, created by SPK Libraries V") + CyString::CreateFromFloat(GetLibraryVersion(), 2), "");
7429
		writeList.pushFront("// Globals file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2), "");
7437
 
7430
 
7438
		CFileIO WriteFile(m_sTempDir + "/Globals.txt");
7431
		CFileIO WriteFile(m_sTempDir + "/Globals.txt");
7439
		if ( WriteFile.WriteFile(&writeList) )
7432
		if ( WriteFile.writeFile(&writeList) )
7440
		{
7433
		{
7441
			this->PackFile(&WriteFile, "types/Globals.pck");
7434
			this->PackFile(&WriteFile, "types/Globals.pck");
7442
			WriteFile.remove();
7435
			WriteFile.remove();
7443
		}
7436
		}
7444
	}
7437
	}
Line 7460... Line 7453...
7460
			CyString id = str->str.GetToken(";", 19, 19);
7453
			CyString id = str->str.GetToken(";", 19, 19);
7461
			Cockpits.pushBack(id.ToString());
7454
			Cockpits.pushBack(id.ToString());
7462
		}
7455
		}
7463
 
7456
 
7464
		delete cockpitList;
7457
		delete cockpitList;
7465
	}
7458
	}
7466
 
7459
 
7467
	CLinkList<SGameShip> shipOverrides;
7460
	CLinkList<SGameShip> shipOverrides;
7468
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
7461
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
7469
	{
7462
	{
7470
		if ( node->Data()->iType != WARETYPE_ADDED || !node->Data()->pPackage )
7463
		if ( node->Data()->iType != WARETYPE_ADDED || !node->Data()->pPackage )
7471
			continue;		
7464
			continue;		
Line 7604... Line 7597...
7604
	}
7597
	}
7605
 
7598
 
7606
}
7599
}
7607
 
7600
 
7608
bool CPackages::PackFile(CyString filename)
7601
bool CPackages::PackFile(CyString filename)
7609
{
7602
{
7610
	// compress the file
7603
	// compress the file
7611
	CFileIO File(filename);
7604
	CFileIO File(filename);
7612
	size_t fileSize;
7605
	size_t fileSize;
7613
	char *fileData = File.ReadToData(&fileSize);
7606
	char *fileData = File.ReadToData(&fileSize);
7614
 
7607
 
7615
	if ( fileData && fileSize)
7608
	if ( fileData && fileSize)
7616
	{
7609
	{
Line 7703... Line 7696...
7703
 
7696
 
7704
bool CPackages::PackFile(CFileIO *File, CyString sFilename)
7697
bool CPackages::PackFile(CFileIO *File, CyString sFilename)
7705
{
7698
{
7706
	Utils::String filename = sFilename.FindReplace("\\", "/").ToString();
7699
	Utils::String filename = sFilename.FindReplace("\\", "/").ToString();
7707
	if ( m_iGame == GAME_X3 )
7700
	if ( m_iGame == GAME_X3 )
7708
	{
7701
	{
7709
		CCatFile catFile;
7702
		CCatFile catFile;
7710
		int error = catFile.open(m_sCurrentDir + "/mods/PluginManager.cat", this->getAddonDir(), CATREAD_CATDECRYPT, true);
7703
		int error = catFile.open(m_sCurrentDir + "/mods/PluginManager.cat", this->getAddonDir(), CATREAD_CATDECRYPT, true);
7711
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7704
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7712
		{
7705
		{
7713
			// it it wrote ok, remove the old ones
7706
			// it it wrote ok, remove the old ones
Line 7758... Line 7751...
7758
	{
7751
	{
7759
		// read the dummies
7752
		// read the dummies
7760
		CFileIO File;
7753
		CFileIO File;
7761
		if ( File.open((e == -1) ? "TCockpits.txt" : m_sTempDir + "/TCockpits.txt") )
7754
		if ( File.open((e == -1) ? "TCockpits.txt" : m_sTempDir + "/TCockpits.txt") )
7762
		{
7755
		{
7763
			CyStringList *lines = File.ReadLinesStr();
7756
			std::vector<Utils::String> lines;
7764
			if ( lines )
7757
			if(File.readLines(lines))
7765
			{
7758
			{
7766
				int count = -1;
7759
				int count = -1;
7767
				for ( SStringList *str = lines->Head(); str; str = str->;next )
7760
				for(auto itr = lines.begin(); itr != lines.end(); itr++)
7768
				{
7761
				{
7769
					CyString line(str->str);
7762
					Utils::String line(*itr);
7770
					line.RemoveChar('\r');
7763
					line.removeChar('\r');
7771
					line.RemoveChar(9);
7764
					line.removeChar(9);
7772
					line = line.RemoveFirstSpace();
7765
					line = line.removeFirstSpace();
7773
					line = line.RemoveEndSpace();
7766
					line = line.removeEndSpace();
7774
					if ( line.Empty() )
7767
					if ( line.empty() )
7775
						continue;
7768
						continue;
7776
					if ( line[0] == '/' )
7769
					if ( line[0] == '/' )
7777
						continue;
7770
						continue;
7778
 
7771
 
7779
					if ( count == -1 )
7772
					if ( count == -1 )
7780
					{
7773
					{
7781
						fileType = line.GetToken(";", 1, 1).ToInt();
7774
						fileType = line.token(";", 1).toInt();
7782
						count = line.GetToken(";", 2, 2).ToInt();
7775
						count = line.token(";", 2).toInt();
7783
					}
7776
					}
7784
					else
7777
					else
7785
					{
7778
					{
7786
						while ( !line.Empty() )
7779
						while ( !line.empty() )
7787
						{
7780
						{
7788
							CyString data = line.GetToken(";", 1, 19);
7781
							Utils::String data = line.tokens(";", 1, 19);
7789
							cockpitList->PushBack(data + ";");
7782
							cockpitList->PushBack(CyString(data + ";"));
7790
							line = line.DelToken(";", 1, 19);
7783
							line = line.remTokens(";", 1, 19);
7791
 
7784
 
7792
							--count;
7785
							--count;
7793
							if ( count < 1 )
7786
							if ( count < 1 )
7794
								break;
7787
								break;
7795
						}
7788
						}
7796
					}
7789
					}
7797
				}
7790
				}
7798
 
-
 
7799
				delete lines;
-
 
7800
			}
7791
			}
7801
 
7792
 
7802
			File.remove();
7793
			File.remove();
7803
		}
7794
		}
7804
 
7795
 
Line 7808... Line 7799...
7808
			SGameShip *s = node->Data();
7799
			SGameShip *s = node->Data();
7809
			if ( s->iType != WARETYPE_ADDED || !s->pPackage )
7800
			if ( s->iType != WARETYPE_ADDED || !s->pPackage )
7810
				continue;
7801
				continue;
7811
 
7802
 
7812
			if ( !s->pPackage->AnyCockpits() )
7803
			if ( !s->pPackage->AnyCockpits() )
7813
				continue;
7804
				continue;
7814
 
7805
 
7815
			for ( CListNode<SCockpit> *cn = s->pPackage->GetCockpits()->Front(); cn; cn = cn->next() )
7806
			for ( CListNode<SCockpit> *cn = s->pPackage->GetCockpits()->Front(); cn; cn = cn->next() )
7816
			{
7807
			{
7817
				bool foundEntry = false;
7808
				bool foundEntry = false;
7818
				CyString cockpitStr = cn->Data()->sCockpit;
7809
				CyString cockpitStr = cn->Data()->sCockpit;
7819
				// search for matching game entry
7810
				// search for matching game entry
Line 8367... Line 8358...
8367
	// now check it exists
8358
	// now check it exists
8368
	if ( !File.exists() )
8359
	if ( !File.exists() )
8369
		return false;
8360
		return false;
8370
 
8361
 
8371
	// now read the file for the correct contents
8362
	// now read the file for the correct contents
8372
	CyStringList *lines = File.ReadLinesStr();
8363
	std::vector<Utils::String> lines;
8373
	if ( !lines )
8364
	if (!File.readLines(lines))
8374
		return false;
8365
		return false;
8375
 
8366
 
8376
	// check that one of the lines is correct
8367
	// check that one of the lines is correct
8377
	for ( SStringList *s = lines->Head(); s; s = s->;next )
8368
	for(auto itr = lines.begin(); itr != lines.end(); itr++)
8378
	{
8369
	{
8379
		if ( s->str == "testing access rights" )
8370
		if ( *itr == "testing access rights" )
8380
		{
-
 
8381
			delete lines;
-
 
8382
			return true;
8371
			return true;
8383
		}
-
 
8384
	}
8372
	}
8385
 
-
 
8386
	delete lines;
-
 
8387
 
8373
 
8388
	return false;
8374
	return false;
8389
}
8375
}
8390
 
8376
 
8391
bool CPackages::LoadShipData(CyString file, CyStringList *list)
8377
bool CPackages::LoadShipData(CyString file, CyStringList *list)
8392
{
8378
{
8393
	CFileIO File;
8379
	CFileIO File;
8394
	bool deleteFile = false;
8380
	bool deleteFile = false;
8395
 
8381
 
8396
	// load from cat file
8382
	// load from cat file
8397
	if ( CFileIO(file).isFileExtension("cat") )
8383
	if ( CFileIO(file).isFileExtension("cat") )
8398
	{
8384
	{
8399
		CCatFile cat;
8385
		CCatFile cat;
8400
		if ( cat.open(file.ToString(), this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8386
		if ( cat.open(file.ToString(), this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8401
			return false;
8387
			return false;
8402
 
8388
 
8403
		if ( !cat.ExtractFile("types\\TShips.pck", m_sTempDir + "/tships.txt") )
8389
		if ( !cat.ExtractFile("types\\TShips.pck", m_sTempDir + "/tships.txt") )
8404
			return false;
8390
			return false;
8405
 
8391
 
8406
		File.open(m_sTempDir + "/tships.txt");
8392
		File.open(m_sTempDir + "/tships.txt");
8407
		deleteFile = true;
8393
		deleteFile = true;
8408
	}
8394
	}
8409
	// otherwise its a normal file
8395
	// otherwise its a normal file
8410
	else if ( CFileIO(file).isFileExtension("pck") )
8396
	else if ( CFileIO(file).isFileExtension("pck") )
8411
	{
8397
	{
8412
		C_File f(file.ToString());
8398
		C_File f(file.ToString());
8413
		if ( !f.ReadFromFile() )
8399
		if ( !f.ReadFromFile() )
8414
			return false;
8400
			return false;
8415
		f.UnPCKFile();
8401
		f.UnPCKFile();
8416
 
8402
 
Line 8426... Line 8412...
8426
 
8412
 
8427
	if ( !File.exists() )
8413
	if ( !File.exists() )
8428
		return false;
8414
		return false;
8429
 
8415
 
8430
	bool ret = false;
8416
	bool ret = false;
8431
	CyStringList *lines = File.ReadLinesStr();
8417
	std::vector<Utils::String> lines;
8432
	if ( lines )
8418
	if(File.readLines(lines))
8433
	{
8419
	{
8434
		bool readFirst = false;
8420
		bool readFirst = false;
8435
		for ( SStringList *str = lines->Head(); str; str = str->;next )
8421
		for(auto itr = lines.begin(); itr != lines.end(); itr++)
8436
		{
8422
		{
8437
			if ( str->str.Empty() )
8423
			if ( itr->empty() )
8438
				continue;
8424
				continue;
8439
			str->str.RemoveChar(&apos;\r');
8425
			Utils::String str = itr->remove(&apos;\r').remove(9);
8440
			str->str.RemoveChar(9);
-
 
8441
			str->str.RemoveFirstSpace();
8426
			str = str.removeFirstSpace();
8442
			if ( str->str.Empty() )
8427
			if ( str.empty() )
8443
				continue;
8428
				continue;
8444
			if ( str->str[0] == '/&apos; || str->str[0] == '#' )
8429
			if ( str[0] == '/&apos; || str[0] == '#' )
8445
				continue;
8430
				continue;
8446
 
8431
 
8447
			if ( !readFirst )
8432
			if ( !readFirst )
8448
				readFirst = true;
8433
				readFirst = true;
8449
			else
8434
			else
8450
			{
8435
			{
8451
				CyString t = str->str.GetToken(";", -2);
8436
				Utils::String t = str.tokens(";", -2);
8452
				while ( t.Right(1) == ";" )
8437
				while ( t.right(1) == ";" )
8453
					t.Truncate((int)t.Length() - 1);
8438
					t.truncate((int)t.length() - 1);
8454
				list->PushBack(t, str->str);
8439
				list->PushBack(CyString(t), CyString(str));
8455
			}
8440
			}
8456
		}
8441
		}
8457
 
8442
 
8458
		delete lines;
-
 
8459
		ret = true;
8443
		ret = true;
8460
	}
8444
	}
8461
 
8445
 
8462
	if ( deleteFile )
8446
	if ( deleteFile )
8463
		File.remove();
8447
		File.remove();
Line 8473... Line 8457...
8473
 
8457
 
8474
	CShipData data;
8458
	CShipData data;
8475
	for ( SStringList *str = list->Head(); str; str = str->next )
8459
	for ( SStringList *str = list->Head(); str; str = str->next )
8476
	{
8460
	{
8477
		if ( str->str.Compare(id) )
8461
		if ( str->str.Compare(id) )
8478
		{
8462
		{
8479
			delete list;
8463
			delete list;
8480
			return str->data;
8464
			return str->data;
8481
		}
8465
		}
8482
	}
8466
	}
8483
 
8467
 
8484
	delete list;
8468
	delete list;
8485
	return NullString;
8469
	return NullString;
8486
}
8470
}
8487
 
8471
 
8488
CyStringList *CPackages::LoadShipData(CyString file)
8472
CyStringList *CPackages::LoadShipData(CyString file)
8489
{
8473
{
Line 8500... Line 8484...
8500
	CFileIO File;
8484
	CFileIO File;
8501
	bool deleteFile = false;
8485
	bool deleteFile = false;
8502
 
8486
 
8503
	// read all text files from mod
8487
	// read all text files from mod
8504
	if ( CFileIO(file).isFileExtension("cat") )
8488
	if ( CFileIO(file).isFileExtension("cat") )
8505
	{
8489
	{
8506
		bool done = false;
8490
		bool done = false;
8507
 
8491
 
8508
		CCatFile cat;
8492
		CCatFile cat;
8509
		if ( cat.open(file.ToString(), this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8493
		if ( cat.open(file.ToString(), this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8510
			return false;
8494
			return false;
8511
 
8495
 
8512
		// extract 1 at a time
8496
		// extract 1 at a time
8513
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8497
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8514
		{
8498
		{
8515
			SInCatFile *f = cat.GetFile(i);
8499
			SInCatFile *f = cat.GetFile(i);
8516
			CyString sF = f->sFile;
8500
			CyString sF = f->sFile;
8517
			// is a text file
8501
			// is a text file
8518
			sF = sF.FindReplace("\\", "/");
8502
			sF = sF.FindReplace("\\", "/");
8519
			if ( !sF.GetToken("/", 1, 1).Compare("t") )
8503
			if ( !sF.GetToken("/", 1, 1).Compare("t") )
8520
				continue;
8504
				continue;
8521
 
8505
 
8522
			CyString baseFile = CFileIO(sF.ToString()).baseName();
8506
			CyString baseFile = CFileIO(sF.ToString()).baseName();
8523
			// check language
8507
			// check language
8524
			int lang = 0;
8508
			int lang = 0;
8525
			if ( baseFile.FindPos("-L") != -1 ) // new language file
8509
			if ( baseFile.FindPos("-L") != -1 ) // new language file
8526
				lang = baseFile.Right(3).ToInt();
8510
				lang = baseFile.Right(3).ToInt();
8527
			else
8511
			else
8528
			{
8512
			{
8529
				baseFile.Truncate((int)baseFile.Length() - 4);
8513
				baseFile.Truncate((int)baseFile.Length() - 4);
8530
				lang = baseFile.ToInt();
8514
				lang = baseFile.ToInt();
8531
			}
8515
			}
8532
 
8516
 
8533
			if ( lang != m_iLanguage )
8517
			if ( lang != m_iLanguage )
8534
				continue;
8518
				continue;
8535
 
8519
 
8536
			// now extract and parse
8520
			// now extract and parse
8537
			if ( cat.ExtractFile(f->sFile, m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml") )
8521
			if ( cat.ExtractFile(f->sFile, m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml") )
Line 8563... Line 8547...
8563
 
8547
 
8564
	if ( !File.exists() )
8548
	if ( !File.exists() )
8565
		return false;
8549
		return false;
8566
 
8550
 
8567
	// open and read file
8551
	// open and read file
8568
	CyStringList *lines = File.ReadLinesStr();
8552
	std::vector<Utils::String> lines;
8569
	if ( !lines )
8553
	if(!File.readLines(lines))
8570
		return false;
8554
		return false;
8571
 
8555
 
8572
	bool inPage = false;
8556
	bool inPage = false;
8573
	for ( SStringList *str = lines->Head(); str; str = str->;next )
8557
	for(auto itr = lines.begin(); itr != lines.end(); itr++)
8574
	{
8558
	{
8575
		// search for page
8559
		// search for page
8576
		if ( !inPage )
8560
		if ( !inPage )
8577
		{
8561
		{
8578
			if ( str->str.FindPos("<page") > -1 )
8562
			if (itr->findPos("<page") > -1 )
8579
			{
8563
			{
8580
				// find the page id
8564
				// find the page id
8581
				int pos = str->str.FindPos("\"");
8565
				int pos = itr->findPos("\"");
8582
				if ( pos > -1 )
8566
				if ( pos > -1 )
8583
				{
8567
				{
8584
					int endpos = str->str.FindPos("\"", pos + 1);
8568
					int endpos = itr->findPos("\"", pos + 1);
8585
					if ( endpos > -1 )
8569
					if ( endpos > -1 )
8586
					{
8570
					{
8587
						CyString p = str->str.Mid(pos + 2, endpos - pos - 1);
8571
						Utils::String p = itr->mid(pos + 2, endpos - pos - 1);
8588
						if ( p.Length() > 4 )
8572
						if ( p.length() > 4 )
8589
							p = p.Right(4);
8573
							p = p.right(4);
8590
						int checkPage = p.ToInt();
8574
						int checkPage = p.toInt();
8591
						if ( checkPage == page )
8575
						if ( checkPage == page )
8592
							inPage = true;
8576
							inPage = true;
8593
					}
8577
					}
8594
				}
8578
				}
8595
			}
8579
			}
8596
 
8580
 
8597
		}
8581
		}
8598
		// add each id
8582
		// add each id
8599
		else
8583
		else
8600
		{
8584
		{
8601
			if ( str->str.FindPos("</page") > -1 )
8585
			if (itr->findPos("</page") > -1 )
8602
				break;
8586
				break;
8603
 
8587
 
8604
			if ( str->str.FindPos("<t id") > -1 )
8588
			if (itr->findPos("<t id") > -1 )
8605
			{
8589
			{
8606
				int pos = str->str.FindPos("\"");
8590
				int pos = itr->findPos("\"");
8607
				if ( pos > -1 )
8591
				if ( pos > -1 )
8608
				{
8592
				{
8609
					int endpos = str->str.FindPos("\"", pos + 1);
8593
					int endpos = itr->findPos("\"", pos + 1);
8610
					if ( endpos > -1 )
8594
					if ( endpos > -1 )
8611
					{
8595
					{
8612
						int id = str->str.Mid(pos + 2, endpos - pos - 1).ToInt();
8596
						int id = itr->mid(pos + 2, endpos - pos - 1).toInt();
8613
						pos = str->str.FindPos(">", endpos);
8597
						pos = itr->findPos(">", endpos);
8614
						if ( pos > -1 )
8598
						if ( pos > -1 )
8615
						{
8599
						{
8616
							++pos;
8600
							++pos;
8617
							endpos = str->str.FindPos("</", pos);
8601
							endpos = itr->findPos("</", pos);
8618
							if ( endpos > -1 )
8602
							if ( endpos > -1 )
8619
							{
8603
							{
8620
								CyString text = str->str.Mid(pos + 1, endpos - pos);
8604
								Utils::String text = itr->mid(pos + 1, endpos - pos);
8621
								while ( text.FindPos('(') != -1 && text.FindPos(')') != -1 )
8605
								while ( text.findPos('(') != -1 && text.findPos(')') != -1 )
8622
								{
8606
								{
8623
									int s = text.FindPos('(');
8607
									int s = text.findPos('(');
8624
									text = text.Erase(s, text.FindPos(')') - s + 1);
8608
									text = text.erase(s, text.findPos(')') - s + 1);
8625
								}
8609
								}
8626
								list->PushBack(CyString::Number(id), text, search);
8610
								list->PushBack(CyString::Number(id), CyString(text), search);
8627
							}
8611
							}
8628
						}
8612
						}
8629
					}
8613
					}
8630
				}
8614
				}
8631
			}
8615
			}
8632
		}
8616
		}
8633
	}
8617
	}
8634
 
-
 
8635
	delete lines;
-
 
8636
 
8618
 
8637
	return true;
8619
	return true;
8638
}
8620
}
8639
 
8621
 
8640
CyStringList *CPackages::ReadTextPage(CyString file, bool search, int page)
8622
CyStringList *CPackages::ReadTextPage(CyString file, bool search, int page)