Subversion Repositories spk

Rev

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

Rev 183 Rev 184
Line 14... Line 14...
14
 
14
 
15
enum {READ_START, READ_GLOBAL, READ_SCRIPT, READ_SCRIPTFILE, READ_WARES};
15
enum {READ_START, READ_GLOBAL, READ_SCRIPT, READ_SCRIPTFILE, READ_WARES};
16
enum { EXTRACT, TEST, PRINT, LIST };
16
enum { EXTRACT, TEST, PRINT, LIST };
17
 
17
 
18
typedef struct SDummyEntry {
18
typedef struct SDummyEntry {
19
	CyString		sSection;
19
	Utils::String		sSection;
20
	CyStringList	lEntries;
20
	Utils::CStringList	lEntries;
21
} SDummyEntry;
21
} SDummyEntry;
22
 
22
 
23
typedef struct SComponantEntry2 {
23
typedef struct SComponantEntry2 {
24
	CyString		sSection;
24
	Utils::String		sSection;
25
	CyStringList	lEntries;
25
	Utils::CStringList	lEntries;
26
} SComponantEntry2;
26
} SComponantEntry2;
27
 
27
 
28
typedef struct SComponantEntry {
28
typedef struct SComponantEntry {
29
	CyString		sSection;
29
	Utils::String		sSection;
30
	CLinkList<SComponantEntry2>	lEntries;
30
	CLinkList<SComponantEntry2>	lEntries;
31
} SComponantEntry;
31
} SComponantEntry;
32
 
32
 
33
Utils::String CPackages::m_sTempDir;
33
Utils::String CPackages::m_sTempDir;
34
 
34
 
Line 5847... Line 5847...
5847
	writeData.push_back("<language id=\"" + Utils::String::Number(lang) + "\">");
5847
	writeData.push_back("<language id=\"" + Utils::String::Number(lang) + "\">");
5848
 
5848
 
5849
	if ( !gameNumber )
5849
	if ( !gameNumber )
5850
		writeData.push_back("	<page id=\"" + Utils::String::Number(PMTEXTFILE) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5850
		writeData.push_back("	<page id=\"" + Utils::String::Number(PMTEXTFILE) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5851
	else
5851
	else
5852
		writeData.push_back("	<page id=\"" + (long)gameNumber + Utils::String::PadNumber(PMTEXTFILE, 4) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5852
		writeData.push_back("	<page id=\"" + Utils::String::Number(gameNumber) + Utils::String::PadNumber(PMTEXTFILE, 4) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5853
 
5853
 
5854
	// write the heading
5854
	// write the heading
5855
	int start = 10000;
5855
	int start = 10000;
5856
	writeData.push_back("		<t id=\"1\">" + Utils::String::Number(m_iLastUpdated) + "</t>");
5856
	writeData.push_back("		<t id=\"1\">" + Utils::String::Number(m_iLastUpdated) + "</t>");
5857
	writeData.push_back("		<t id=\"2\">" + Utils::String::Number(this->countPackages(TYPE_SPK, true)) + "</t>");
5857
	writeData.push_back("		<t id=\"2\">" + Utils::String::Number(this->countPackages(TYPE_SPK, true)) + "</t>");
Line 6218... Line 6218...
6218
	{
6218
	{
6219
		// read the dummies
6219
		// read the dummies
6220
		CFileIO File;
6220
		CFileIO File;
6221
		if ( File.open((e == -1) ? "Dummies.txt" : m_sTempDir + "/Dummies.txt") )
6221
		if ( File.open((e == -1) ? "Dummies.txt" : m_sTempDir + "/Dummies.txt") )
6222
		{
6222
		{
6223
			std::vector<Utils::String> *lines = File.readLines();
6223
			std::vector<Utils::String> lines;
6224
			if ( lines )
6224
			if(File.readLines(lines))
6225
			{
6225
			{
6226
				int insection = 0;
6226
				int insection = 0;
6227
				SDummyEntry *currentSection = NULL;
6227
				SDummyEntry *currentSection = NULL;
6228
				for ( int j = 0; j < (int)lines->size(); j++ )
6228
				for ( int j = 0; j < (int)lines.size(); j++ )
6229
				{
6229
				{
6230
					Utils::String line(lines->at(j));
6230
					Utils::String line(lines.at(j));
6231
					line.removeChar(9);
6231
					line.removeChar(9);
6232
					line.removeChar('\r');
6232
					line.removeChar('\r');
6233
					line.removeFirstSpace();
6233
					line.removeFirstSpace();
6234
					line.removeEndSpace();
6234
					line.removeEndSpace();
6235
					if ( line.empty() )
6235
					if ( line.empty() )
6236
						continue;
6236
						continue;
6237
					if ( line[0] == '/' )
6237
					if ( line[0] == '/' )
6238
						continue;
6238
						continue;
6239
 
6239
 
6240
					// read the section, first entry is section, second is size
6240
					// read the section, first entry is section, second is size
6241
					while ( !line.empty() )
6241
					while ( !line.empty() )
6242
					{
6242
					{
6243
						if ( !insection )
6243
						if ( !insection )
6244
						{
6244
						{
6245
							CyString section = line.token(";", 1);
6245
							Utils::String section = line.token(";", 1);
6246
							insection = line.token(";", 2).toInt();
6246
							insection = line.token(";", 2).toInt();
6247
 
6247
 
6248
							// search for the sections
6248
							// search for the sections
6249
							currentSection = NULL;
6249
							currentSection = NULL;
6250
							for ( CListNode<SDummyEntry> *node = dummyList.Front(); node; node = node->next() )
6250
							for ( CListNode<SDummyEntry> *node = dummyList.Front(); node; node = node->next() )
Line 6274... Line 6274...
6274
							if ( currentSection->sSection.Compare("SDTYPE_GUN") )
6274
							if ( currentSection->sSection.Compare("SDTYPE_GUN") )
6275
							{
6275
							{
6276
								int states = line.token(";", 3).toInt();
6276
								int states = line.token(";", 3).toInt();
6277
								int parts = line.token(";", 4 + (states * 2)).toInt();
6277
								int parts = line.token(";", 4 + (states * 2)).toInt();
6278
								Utils::String data = line.tokens(";", 1, 4 + (states * 2) + (parts * 2)) + ";";
6278
								Utils::String data = line.tokens(";", 1, 4 + (states * 2) + (parts * 2)) + ";";
6279
								currentSection->lEntries.PushBack(CyString(data));
6279
								currentSection->lEntries.pushBack(data);
6280
 
6280
 
6281
								// remove done
6281
								// remove done
6282
								line = line.remTokens(";", 1, 4 + (states * 2) + (parts * 2));
6282
								line = line.remTokens(";", 1, 4 + (states * 2) + (parts * 2));
6283
							}
6283
							}
6284
							else
6284
							else
6285
							{
6285
							{
6286
								int states = line.token(";", 3).toInt();
6286
								int states = line.token(";", 3).toInt();
6287
								Utils::String data = line.tokens(";", 1, 3 + (states * 2)) + ";";
6287
								Utils::String data = line.tokens(";", 1, 3 + (states * 2)) + ";";
6288
								currentSection->lEntries.PushBack(CyString(data));
6288
								currentSection->lEntries.pushBack(data);
6289
 
6289
 
6290
								// remove done
6290
								// remove done
6291
								line = line.remTokens(";", 1, 3 + (states * 2));
6291
								line = line.remTokens(";", 1, 3 + (states * 2));
6292
							}
6292
							}
6293
						}
6293
						}
6294
					}
6294
					}
6295
				}
6295
				}
6296
 
-
 
6297
				delete lines;
-
 
6298
			}
6296
			}
6299
 
6297
 
6300
			File.remove();
6298
			File.remove();
6301
		}
6299
		}
6302
 
6300
 
6303
		// add the new entries for the ships
6301
		// add the new entries for the ships
6304
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6302
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6305
		{
6303
		{
6306
			SGameShip *s = node->Data();
6304
			SGameShip *s = node->Data();
6307
			if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6305
			if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6308
				continue;
6306
				continue;
6309
 
6307
 
6310
			// no dummies to add?
6308
			// no dummies to add?
6311
			if ( !s->pPackage->AnyDummies() )
6309
			if ( !s->pPackage->AnyDummies() )
6312
				continue;
6310
				continue;
6313
 
6311
 
Line 6315... Line 6313...
6315
			for ( CListNode<SDummy> *dNode = s->pPackage->GetDummies()->Front(); dNode; dNode = dNode->next() )
6313
			for ( CListNode<SDummy> *dNode = s->pPackage->GetDummies()->Front(); dNode; dNode = dNode->next() )
6316
			{
6314
			{
6317
				SDummy *dummy = dNode->Data();
6315
				SDummy *dummy = dNode->Data();
6318
				SDummyEntry *found = NULL;
6316
				SDummyEntry *found = NULL;
6319
				for ( CListNode<SDummyEntry> *eNode = dummyList.Front(); eNode; eNode = eNode->next() )
6317
				for ( CListNode<SDummyEntry> *eNode = dummyList.Front(); eNode; eNode = eNode->next() )
6320
				{
6318
				{
6321
					if ( eNode->Data()->sSection.Compare(CyString(dummy->sSection)) )
6319
					if ( eNode->Data()->sSection.Compare(dummy->sSection) )
6322
					{
6320
					{
6323
						found = eNode->Data();
6321
						found = eNode->Data();
6324
						break;
6322
						break;
6325
					}
6323
					}
6326
				}
6324
				}
6327
				if ( !found )
6325
				if ( !found )
6328
				{
6326
				{
6329
					found = new SDummyEntry;
6327
					found = new SDummyEntry;
6330
					found->sSection = dummy->sSection;
6328
					found->sSection = dummy->sSection;
6331
					dummyList.push_back(found);
6329
					dummyList.push_back(found);
6332
				}
6330
				}
6333
				// check if its already on the list
6331
				// check if its already on the list
6334
				else
6332
				else
6335
				{
6333
				{
6336
					bool f = false;
6334
					bool f = false;
6337
					for ( SStringList *strNode = found->lEntries.Head(); strNode; strNode = strNode->next )
6335
					for(auto itr = found->lEntries.begin(); itr != found->lEntries.end(); itr++)
6338
					{
6336
					{
6339
						if ( strNode->str.GetToken(";", 1, 1).Compare(CyString(dummy->sData.token(&quot;;", 1))) )
6337
						if ((*itr)->str.token(";", 1).Compare(dummy->sData.token(&quot;;", 1)))
6340
						{
6338
						{
6341
							f = true;
6339
							f = true;
6342
							break;
6340
							break;
6343
						}
6341
						}
6344
					}
6342
					}
6345
 
6343
 
6346
					if ( f )
6344
					if ( f )
6347
						continue;
6345
						continue;
6348
				}
6346
				}
6349
 
6347
 
6350
				found->lEntries.PushBack(CyString(dummy->sData));
6348
				found->lEntries.pushBack(dummy->sData);
6351
			}
6349
			}
6352
		}
6350
		}
6353
 
6351
 
6354
		// finally, write the file
6352
		// finally, write the file
6355
		std::vector<Utils::String> lines;
6353
		std::vector<Utils::String> lines;
6356
		lines.push_back("// Dummies file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6354
		lines.push_back("// Dummies file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6357
		for ( SDummyEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
6355
		for ( SDummyEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
6358
		{
6356
		{
6359
			lines.push_back("");
6357
			lines.push_back("");
6360
			lines.push_back("// Section: " + dummy->sSection.ToString() + " Entries: " + Utils::String::Number((long)dummy->lEntries.Count()));
6358
			lines.push_back("// Section: " + dummy->sSection + " Entries: " + Utils::String::Number((long)dummy->lEntries.size()));
6361
			lines.push_back(dummy->sSection.ToString() + ";" + Utils::String::Number(dummy->lEntries.Count()) + ";");
6359
			lines.push_back(dummy->sSection + ";" + Utils::String::Number(dummy->lEntries.size()) + ";");
6362
			for ( SStringList *str = dummy->lEntries.Head(); str; str = str->next )
6360
			for(auto itr = dummy->lEntries.begin(); itr != dummy->lEntries.end(); itr++)
6363
			{
6361
			{
6364
				Utils::String strLine = str->str.ToString();
6362
				Utils::String strLine = (*itr)->str;
6365
				strLine.removeChar(9);
6363
				strLine.removeChar(9);
6366
				strLine.removeChar('\r');
6364
				strLine.removeChar('\r');
6367
				strLine.removeEndSpace();
6365
				strLine.removeEndSpace();
6368
				strLine.removeFirstSpace();
6366
				strLine.removeFirstSpace();
6369
				strLine = strLine.findReplace("<::PiPe::>", "|");
6367
				strLine = strLine.findReplace("<::PiPe::>", "|");
6370
				if ( strLine.right(1) != ";" )
6368
				if ( strLine.right(1) != ";" )
6371
					strLine += ";";
6369
					strLine += ";";
6372
				lines.push_back(strLine);
6370
				lines.push_back(strLine);
6373
			}
6371
			}
6374
		}
6372
		}
6375
		lines.push_back("");
6373
		lines.push_back("");
6376
 
6374
 
6377
		// write the file to disk
6375
		// write the file to disk
6378
		CFileIO WriteFile(m_sTempDir + "/dummies.txt");
6376
		CFileIO WriteFile(m_sTempDir + "/dummies.txt");
6379
		if ( WriteFile.writeFile(&lines) )
6377
		if ( WriteFile.writeFile(&lines) )
Line 6383... Line 6381...
6383
		}
6381
		}
6384
	}
6382
	}
6385
}
6383
}
6386
 
6384
 
6387
void CPackages::CreateCutData()
6385
void CPackages::CreateCutData()
6388
{
6386
{
6389
	// first check we have any ships
6387
	// first check we have any ships
6390
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
6388
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
6391
		return;
6389
		return;
6392
 
6390
 
6393
	bool found = false;
6391
	bool found = false;
6394
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6392
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6395
	{
6393
	{
6396
		SGameShip *s = node->Data();
6394
		SGameShip *s = node->Data();
6397
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6395
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6398
			continue;
6396
			continue;
6399
 
6397
 
6400
		// no dummies to add?
6398
		// no dummies to add?
6401
		if ( !s->pPackage->anyCutData() )
6399
		if ( !s->pPackage->anyCutData() )
6402
			continue;
6400
			continue;
6403
		found = true;
6401
		found = true;
Line 6475... Line 6473...
6475
	CFileIO WriteFile(m_sTempDir + "/CutData.txt");
6473
	CFileIO WriteFile(m_sTempDir + "/CutData.txt");
6476
	if ( WriteFile.writeFile(&cutList) )
6474
	if ( WriteFile.writeFile(&cutList) )
6477
	{
6475
	{
6478
		this->packFile(&WriteFile, "types\\CutData.pck");
6476
		this->packFile(&WriteFile, "types\\CutData.pck");
6479
		WriteFile.remove();
6477
		WriteFile.remove();
6480
	}
6478
	}
6481
}
6479
}
6482
 
6480
 
6483
void CPackages::CreateAnimations()
6481
void CPackages::CreateAnimations()
6484
{
6482
{
6485
	// first check we have any ships
6483
	// first check we have any ships
Line 6489... Line 6487...
6489
	bool found = false;
6487
	bool found = false;
6490
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6488
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6491
	{
6489
	{
6492
		SGameShip *s = node->Data();
6490
		SGameShip *s = node->Data();
6493
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6491
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6494
			continue;
6492
			continue;
6495
 
6493
 
6496
		// no dummies to add?
6494
		// no dummies to add?
6497
		if ( !s->pPackage->anyAnimations() )
6495
		if ( !s->pPackage->anyAnimations() )
6498
			continue;
6496
			continue;
6499
		found = true;
6497
		found = true;
6500
		break;
6498
		break;
6501
	}
6499
	}
6502
 
6500
 
6503
	if ( !found )
6501
	if ( !found )
6504
		return;
6502
		return;
6505
 
6503
 
6506
	Utils::CStringList aniList;
6504
	Utils::CStringList aniList;
6507
	int e = extractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6505
	int e = extractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6508
	if ( e )
6506
	if ( e )
6509
	{
6507
	{
6510
		CFileIO File;
6508
		CFileIO File;
Line 6516... Line 6514...
6516
				for ( int j = 0; j < (int)lines->size(); j++ )
6514
				for ( int j = 0; j < (int)lines->size(); j++ )
6517
				{
6515
				{
6518
					Utils::String line(lines->at(j));
6516
					Utils::String line(lines->at(j));
6519
					aniList.pushBack(line);
6517
					aniList.pushBack(line);
6520
				}
6518
				}
6521
 
6519
 
6522
				delete lines;
6520
				delete lines;
6523
			}
6521
			}
6524
 
6522
 
6525
			File.remove();
6523
			File.remove();
6526
		}
6524
		}
6527
	}
6525
	}
6528
 
6526
 
6529
	Utils::CStringList parsedAniList;
6527
	Utils::CStringList parsedAniList;
6530
	CXspFile::ReadAnimations(aniList, parsedAniList, 0);
6528
	CXspFile::ReadAnimations(aniList, parsedAniList, 0);
6531
 
6529
 
6532
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6530
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6533
	{
6531
	{
6534
		SGameShip *s = node->Data();
6532
		SGameShip *s = node->Data();
6535
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6533
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6536
			continue;
6534
			continue;
6537
 
6535
 
6538
		// no dummies to add?
6536
		// no dummies to add?
6539
		if ( !s->pPackage->anyAnimations() )
6537
		if ( !s->pPackage->anyAnimations() )
6540
			continue;
6538
			continue;
6541
 
6539
 
6542
		// add each dummy to list
6540
		// add each dummy to list
6543
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6541
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6544
			parsedAniList.pushBack((*itr)->str);
6542
			parsedAniList.pushBack((*itr)->str);
6545
	}
6543
	}
6546
 
6544
 
Line 6557... Line 6555...
6557
		{
6555
		{
6558
			comment += " ";
6556
			comment += " ";
6559
			oldComment.removeFirstSpace();
6557
			oldComment.removeFirstSpace();
6560
			if ( oldComment.token(" ", 1).isNumber() )
6558
			if ( oldComment.token(" ", 1).isNumber() )
6561
				comment += oldComment.tokens(" ", 2);
6559
				comment += oldComment.tokens(" ", 2);
6562
			else
6560
			else
6563
				comment += oldComment;
6561
				comment += oldComment;
6564
		}
6562
		}
6565
		Utils::String line = (*itr)->str.token("//", 1);
6563
		Utils::String line = (*itr)->str.token("//", 1);
6566
 
6564
 
6567
		// split into seperate lines
6565
		// split into seperate lines
Line 6731... Line 6729...
6731
			{
6729
			{
6732
				if ( checkBody->Data()->sSection.Compare(section))
6730
				if ( checkBody->Data()->sSection.Compare(section))
6733
				{
6731
				{
6734
					foundSection = checkBody->Data();
6732
					foundSection = checkBody->Data();
6735
					break;
6733
					break;
6736
				}
6734
				}
6737
			}
6735
			}
6738
 
6736
 
6739
			if ( !foundSection )
6737
			if ( !foundSection )
6740
			{
6738
			{
6741
				foundSection = new SBodies;
6739
				foundSection = new SBodies;
6742
				foundSection->sSection = section;
6740
				foundSection->sSection = section;
6743
				bodiesList.push_back(foundSection);
6741
				bodiesList.push_back(foundSection);
6744
			}
6742
			}
6745
			if(!foundSection->lEntries.contains(body))
6743
			if(!foundSection->lEntries.contains(body))
6746
				foundSection->lEntries.pushBack(body);
6744
				foundSection->lEntries.pushBack(body);
6747
		}
6745
		}
6748
	}
6746
	}
6749
 
6747
 
6750
	// now write the file
6748
	// now write the file
6751
	std::vector<Utils::String> writeList;
6749
	std::vector<Utils::String> writeList;
6752
	// the header first
6750
	// the header first
6753
	writeList.push_back("// Bodies file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6751
	writeList.push_back("// Bodies file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6754
	writeList.push_back("//body type;num bodies;");
6752
	writeList.push_back("//body type;num bodies;");
6755
	writeList.push_back("//[body id/name]");
6753
	writeList.push_back("//[body id/name]");
6756
 
6754
 
6757
	// now our sections
6755
	// now our sections
6758
	for ( SBodies *bSection = bodiesList.First(); bSection; bSection = bodiesList.Next() )
6756
	for ( SBodies *bSection = bodiesList.First(); bSection; bSection = bodiesList.Next() )
6759
	{
6757
	{
6760
		writeList.push_back("");
6758
		writeList.push_back("");
6761
		writeList.push_back("// Section: " + bSection->sSection);
6759
		writeList.push_back("// Section: " + bSection->sSection);
6762
		writeList.push_back(bSection->sSection + ";" + Utils::String::Number(bSection->lEntries.size()) + ";");
6760
		writeList.push_back(bSection->sSection + ";" + Utils::String::Number(bSection->lEntries.size()) + ";");
6763
		for(auto itr = bSection->lEntries.begin(); itr != bSection->lEntries.end(); itr++)
6761
		for(auto itr = bSection->lEntries.begin(); itr != bSection->lEntries.end(); itr++)
6764
		{
6762
		{
Line 6775... Line 6773...
6775
	CFileIO WriteFile(m_sTempDir + "/Bodies.txt");
6773
	CFileIO WriteFile(m_sTempDir + "/Bodies.txt");
6776
	if ( WriteFile.writeFile(&writeList) )
6774
	if ( WriteFile.writeFile(&writeList) )
6777
	{
6775
	{
6778
		this->packFile(&WriteFile, "types\\Bodies.pck");
6776
		this->packFile(&WriteFile, "types\\Bodies.pck");
6779
		WriteFile.remove();
6777
		WriteFile.remove();
6780
	}
6778
	}
6781
}
6779
}
6782
 
6780
 
6783
void CPackages::CreateCustomStarts()
6781
void CPackages::CreateCustomStarts()
6784
{
6782
{
6785
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
6783
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
6786
	{
6784
	{
Line 6892... Line 6890...
6892
							// search for the sections
6890
							// search for the sections
6893
							currentSection = NULL;
6891
							currentSection = NULL;
6894
							for ( CListNode<SComponantEntry> *node = dummyList.Front(); node; node = node->next() )
6892
							for ( CListNode<SComponantEntry> *node = dummyList.Front(); node; node = node->next() )
6895
							{
6893
							{
6896
								SComponantEntry *d = node->Data();
6894
								SComponantEntry *d = node->Data();
6897
								if ( d->sSection.Compare(CyString(section)) )
6895
								if ( d->sSection.Compare(section) )
6898
								{
6896
								{
6899
									currentSection = node->Data();
6897
									currentSection = node->Data();
6900
									break;
6898
									break;
6901
								}
6899
								}
6902
							}
6900
							}
6903
 
6901
 
6904
							if ( !currentSection )
6902
							if ( !currentSection )
6905
							{
6903
							{
6906
								currentSection = new SComponantEntry;
6904
								currentSection = new SComponantEntry;
6907
								currentSection->sSection = section;
6905
								currentSection->sSection = section;
6908
								dummyList.push_back(currentSection);
6906
								dummyList.push_back(currentSection);
6909
							}
6907
							}
6910
 
6908
 
6911
							// we have some more ?
6909
							// we have some more ?
6912
							line = line.remTokens(";", 1, 2);
6910
							line = line.remTokens(";", 1, 2);
6913
						}
6911
						}
6914
						else if ( !insubsection )
6912
						else if ( !insubsection )
6915
						{
6913
						{
6916
							--insection;
6914
							--insection;
6917
							Utils::String section = line.token(";", 1);
6915
							Utils::String section = line.token(";", 1);
6918
							insubsection = line.token(";", 2).toInt();
6916
							insubsection = line.token(";", 2).toInt();
Line 6924... Line 6922...
6924
							line = line.remTokens(";", 1, 2);
6922
							line = line.remTokens(";", 1, 2);
6925
						}
6923
						}
6926
						else
6924
						else
6927
						{
6925
						{
6928
							--insubsection;
6926
							--insubsection;
-
 
6927
							line = line.remove(' ');
-
 
6928
							if(!currentSubSection->lEntries.contains(line))
6929
							currentSubSection->lEntries.PushBack(CyString(line.remove(' ')), true);
6929
								currentSubSection->lEntries.pushBack(line);
6930
							line = "";
6930
							line = "";
6931
						}
6931
						}
6932
					}
6932
					}
6933
				}
6933
				}
6934
 
6934
 
Line 6955... Line 6955...
6955
				SComponent *dummy = dNode->Data();
6955
				SComponent *dummy = dNode->Data();
6956
				SComponantEntry *found = NULL;
6956
				SComponantEntry *found = NULL;
6957
				SComponantEntry2 *found2 = NULL;
6957
				SComponantEntry2 *found2 = NULL;
6958
				for ( CListNode<SComponantEntry> *eNode = dummyList.Front(); eNode; eNode = eNode->next() )
6958
				for ( CListNode<SComponantEntry> *eNode = dummyList.Front(); eNode; eNode = eNode->next() )
6959
				{
6959
				{
6960
					if ( eNode->Data()->sSection.Compare(CyString(dummy->sSection)) )
6960
					if ( eNode->Data()->sSection.Compare(dummy->sSection) )
6961
					{
6961
					{
6962
						found = eNode->Data();
6962
						found = eNode->Data();
6963
						break;
6963
						break;
6964
					}
6964
					}
6965
				}
6965
				}
Line 6975... Line 6975...
6975
				// else check for the 2nd section
6975
				// else check for the 2nd section
6976
				else
6976
				else
6977
				{
6977
				{
6978
					for ( CListNode<SComponantEntry2> *cNode = found->lEntries.Front(); cNode; cNode = cNode->next() )
6978
					for ( CListNode<SComponantEntry2> *cNode = found->lEntries.Front(); cNode; cNode = cNode->next() )
6979
					{
6979
					{
6980
						if ( cNode->Data()->sSection.Compare(CyString(dummy->sSection2)) )
6980
						if ( cNode->Data()->sSection.Compare(dummy->sSection2) )
6981
						{
6981
						{
6982
							found2 = cNode->Data();
6982
							found2 = cNode->Data();
6983
							break;
6983
							break;
6984
						}
6984
						}
6985
					}
6985
					}
Line 6991... Line 6991...
6991
						found->lEntries.push_back(found2);
6991
						found->lEntries.push_back(found2);
6992
					}
6992
					}
6993
					else
6993
					else
6994
					{
6994
					{
6995
						bool f = false;
6995
						bool f = false;
6996
						for ( SStringList *strNode = found2->lEntries.Head(); strNode; strNode = strNode->next )
6996
						for(auto itr = found2->lEntries.begin(); itr != found2->lEntries.end(); itr++)
6997
						{
6997
						{
6998
							if ( dummy->sData.remove(' ').Compare(strNode->str.ToString()) )
6998
							if ( dummy->sData.remove(' ').Compare((*itr)->str) )
6999
							{
6999
							{
7000
								f = true;
7000
								f = true;
7001
								break;
7001
								break;
7002
							}
7002
							}
7003
						}
7003
						}
Line 7005... Line 7005...
7005
						if ( f )
7005
						if ( f )
7006
							continue;
7006
							continue;
7007
					}
7007
					}
7008
				}
7008
				}
7009
 
7009
 
7010
				found2->lEntries.PushBack(CyString(dummy->sData.remove(' ')));
7010
				found2->lEntries.pushBack(dummy->sData.remove(' '));
7011
			}
7011
			}
7012
		}
7012
		}
7013
 
7013
 
7014
		// finally, write the file
7014
		// finally, write the file
7015
		std::vector<Utils::String> lines;
7015
		std::vector<Utils::String> lines;
7016
		lines.push_back("// Components file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
7016
		lines.push_back("// Components file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
7017
		for ( SComponantEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
7017
		for ( SComponantEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
7018
		{
7018
		{
7019
			lines.push_back("");
7019
			lines.push_back("");
7020
			lines.push_back("// Section: " + dummy->sSection.ToString() + " Entries: " + Utils::String::Number((long)dummy->lEntries.size()));
7020
			lines.push_back("// Section: " + dummy->sSection + " Entries: " + Utils::String::Number((long)dummy->lEntries.size()));
7021
			lines.push_back(dummy->sSection.ToString() + ";" + Utils::String::Number(dummy->lEntries.size()) + ";");
7021
			lines.push_back(dummy->sSection + ";" + Utils::String::Number(dummy->lEntries.size()) + ";");
7022
			for ( CListNode<SComponantEntry2> *comp = dummy->lEntries.Front(); comp; comp = comp->next() )
7022
			for ( CListNode<SComponantEntry2> *comp = dummy->lEntries.Front(); comp; comp = comp->next() )
7023
			{
7023
			{
7024
				lines.push_back(comp->Data()->sSection.ToString() + ";" + Utils::String::Number((long)comp->Data()->lEntries.Count()) + ";");
7024
				lines.push_back(comp->Data()->sSection + ";" + Utils::String::Number((long)comp->Data()->lEntries.size()) + ";");
7025
				for ( SStringList *str = comp->Data()->lEntries.Head(); str; str = str->next )
7025
				for(auto itr = comp->Data()->lEntries.begin(); itr != comp->Data()->lEntries.end(); itr++)
7026
				{
7026
				{
7027
					Utils::String cStr = str->str.ToString();
7027
					Utils::String cStr = (*itr)->str;
7028
					cStr.removeEndSpace();
7028
					cStr.removeEndSpace();
7029
					cStr.removeChar(9);
7029
					cStr.removeChar(9);
7030
					cStr.removeChar('\r');
7030
					cStr.removeChar('\r');
7031
					if ( cStr.right(1) != ";" )
7031
					if ( cStr.right(1) != ";" )
7032
						cStr += ";";
7032
						cStr += ";";
Line 7968... Line 7968...
7968
	}
7968
	}
7969
 
7969
 
7970
	return count;
7970
	return count;
7971
}
7971
}
7972
int CPackages::findPackageDirectories(CLinkList<CBaseFile> &packages, const Utils::String &dir)
7972
int CPackages::findPackageDirectories(CLinkList<CBaseFile> &packages, const Utils::String &dir)
7973
{
7973
{
7974
	CDirIO Dir(dir);
7974
	CDirIO Dir(dir);
7975
	int count = 0;
7975
	int count = 0;
7976
	Utils::CStringList files;
7976
	Utils::CStringList files;
7977
	if (Dir.dirList(files))
7977
	if (Dir.dirList(files))
7978
	{
7978
	{
7979
		for (auto itr = files.begin(); itr != files.end(); itr++)
7979
		for (auto itr = files.begin(); itr != files.end(); itr++)
Line 8640... Line 8640...
8640
			for(auto itr = fromList.begin(); itr != fromList.end(); itr++)
8640
			for(auto itr = fromList.begin(); itr != fromList.end(); itr++)
8641
			{
8641
			{
8642
				Utils::String fromFile = (*itr)->str;
8642
				Utils::String fromFile = (*itr)->str;
8643
				fromFile = fromFile.findReplace("\\", "/");
8643
				fromFile = fromFile.findReplace("\\", "/");
8644
				fromFile = fromFile.findReplace("//", "/");
8644
				fromFile = fromFile.findReplace("//", "/");
8645
				for (auto toItr = toList.begin(); itr != toList.end(); itr++)
8645
				for (auto toItr = toList.begin(); toItr != toList.end(); toItr++)
8646
				{
8646
				{
8647
					Utils::String toFile = (*toItr)->str;
8647
					Utils::String toFile = (*toItr)->str;
8648
					toFile = toFile.findReplace("\\", "/");
8648
					toFile = toFile.findReplace("\\", "/");
8649
					toFile = toFile.findReplace("//", "/");
8649
					toFile = toFile.findReplace("//", "/");
8650
					if ( fromFile.Compare(toFile) )
8650
					if ( fromFile.Compare(toFile) )
8651
					{
8651
					{
8652
						if ( list )
8652
						if ( list )
8653
							list->pushBack(from->filename() + "::" + (*itr)->str, to->filename() + "::" + (*itr)->str);
8653
							list->pushBack(from->filename() + "::" + fromFile, to->filename() + "::" + toFile);
8654
						else
8654
						else
8655
							return true;
8655
							return true;
8656
					}
8656
					}
8657
				}
8657
				}
8658
			}
8658
			}
Line 8671... Line 8671...
8671
	if ( !from->IsEnabled() || !to->IsEnabled() ) return false;
8671
	if ( !from->IsEnabled() || !to->IsEnabled() ) return false;
8672
	if ( !from->AnyFileType(FILETYPE_MOD) ) return false;
8672
	if ( !from->AnyFileType(FILETYPE_MOD) ) return false;
8673
	if ( !to->AnyFileType(FILETYPE_MOD) ) return false;
8673
	if ( !to->AnyFileType(FILETYPE_MOD) ) return false;
8674
 
8674
 
8675
	if ( from == to ) return false; // cant have incompatabilities to itself
8675
	if ( from == to ) return false; // cant have incompatabilities to itself
-
 
8676
 
-
 
8677
	// check if one is a depencacy of the other
-
 
8678
	if (from->IsPackageNeeded(to->name(), to->author())) return false;
-
 
8679
	if (to->IsPackageNeeded(from->name(), from->author())) return false;
-
 
8680
	// check if one is directly connected
-
 
8681
	if (from->type() == BaseFileType::TYPE_SPK)
-
 
8682
	{
-
 
8683
		CSpkFile* fromSpk = dynamic_cast<CSpkFile*>(from);
-
 
8684
		if (fromSpk->isAnotherMod())
-
 
8685
		{
-
 
8686
			if (fromSpk->otherName().Compare(to->name()) && fromSpk->otherAuthor().Compare(to->author()))
-
 
8687
				return false;
-
 
8688
		}
-
 
8689
	}
-
 
8690
	if (to->type() == BaseFileType::TYPE_SPK)
-
 
8691
	{
-
 
8692
		CSpkFile* toSpk = dynamic_cast<CSpkFile*>(to);
-
 
8693
		if (toSpk->isAnotherMod())
-
 
8694
		{
-
 
8695
			if (toSpk->otherName().Compare(from->name()) && toSpk->otherAuthor().Compare(from->author()))
-
 
8696
				return false;
-
 
8697
		}
-
 
8698
	}
8676
 
8699
 
8677
	int count = 0;
8700
	int count = 0;
8678
	for ( C_File *f = from->GetFirstFile(FILETYPE_MOD); f; f = from->GetNextFile(f) )
8701
	for ( C_File *f = from->GetFirstFile(FILETYPE_MOD); f; f = from->GetNextFile(f) )
8679
	{
8702
	{
8680
		if ( !f->IsFakePatch() ) continue;
8703
		if ( !f->IsFakePatch() ) continue;