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() )
Line 6240... Line 6240...
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
 
Line 6316... Line 6314...
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
				}
Line 6332... Line 6330...
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(";", 1))) )
6337
						if ((*itr)->str.token(";", 1).Compare(dummy->sData.token(";", 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::>", "|");
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
							}
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 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 8672... Line 8672...
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
 
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
	}
-
 
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;
8681
		if ( f->fileExt().Compare("dat") ) continue;
8704
		if ( f->fileExt().Compare("dat") ) continue;