Subversion Repositories spk

Rev

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

Rev 215 Rev 216
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
	Utils::String		sSection;
19
	Utils::WString		sSection;
20
	Utils::CStringList	lEntries;
20
	Utils::WStringList	lEntries;
21
} SDummyEntry;
21
} SDummyEntry;
22
 
22
 
23
typedef struct SComponantEntry2 {
23
typedef struct SComponantEntry2 {
24
	Utils::String		sSection;
24
	Utils::WString		sSection;
25
	Utils::CStringList	lEntries;
25
	Utils::WStringList	lEntries;
26
} SComponantEntry2;
26
} SComponantEntry2;
27
 
27
 
28
typedef struct SComponantEntry {
28
typedef struct SComponantEntry {
29
	Utils::String		sSection;
29
	Utils::WString		sSection;
30
	CLinkList<SComponantEntry2>	lEntries;
30
	CLinkList<SComponantEntry2>	lEntries;
31
} SComponantEntry;
31
} SComponantEntry;
32
 
32
 
33
Utils::WString CPackages::m_sTempDir;
33
Utils::WString CPackages::m_sTempDir;
34
 
34
 
Line 6190... Line 6190...
6190
	{
6190
	{
6191
		// read the dummies
6191
		// read the dummies
6192
		CFileIO File;
6192
		CFileIO File;
6193
		if ( File.open((e == -1) ? L"Dummies.txt" : m_sTempDir + L"/Dummies.txt") )
6193
		if ( File.open((e == -1) ? L"Dummies.txt" : m_sTempDir + L"/Dummies.txt") )
6194
		{
6194
		{
6195
			std::vector<Utils::String> lines;
6195
			std::vector<Utils::WString> lines;
6196
			if(File.readLines(lines))
6196
			if(File.readLines(lines))
6197
			{
6197
			{
6198
				int insection = 0;
6198
				int insection = 0;
6199
				SDummyEntry *currentSection = NULL;
6199
				SDummyEntry *currentSection = NULL;
6200
				for ( int j = 0; j < (int)lines.size(); j++ )
6200
				for ( int j = 0; j < (int)lines.size(); j++ )
6201
				{
6201
				{
6202
					Utils::String line(lines.at(j));
6202
					Utils::WString line(lines.at(j));
6203
					line.removeChar(9);
6203
					line.removeChar(9);
6204
					line.removeChar('\r');
6204
					line.removeChar('\r');
6205
					line.removeFirstSpace();
6205
					line.removeFirstSpace();
6206
					line.removeEndSpace();
6206
					line.removeEndSpace();
6207
					if ( line.empty() )
6207
					if ( line.empty() )
Line 6212... Line 6212...
6212
					// read the section, first entry is section, second is size
6212
					// read the section, first entry is section, second is size
6213
					while ( !line.empty() )
6213
					while ( !line.empty() )
6214
					{
6214
					{
6215
						if ( !insection )
6215
						if ( !insection )
6216
						{
6216
						{
6217
							Utils::String section = line.token(";", 1);
6217
							Utils::WString section = line.token(L";", 1);
6218
							insection = line.token(";", 2).toInt();
6218
							insection = line.token(L";", 2).toInt();
6219
 
6219
 
6220
							// search for the sections
6220
							// search for the sections
6221
							currentSection = NULL;
6221
							currentSection = NULL;
6222
							for ( CListNode<SDummyEntry> *node = dummyList.Front(); node; node = node->next() )
6222
							for ( CListNode<SDummyEntry> *node = dummyList.Front(); node; node = node->next() )
6223
							{
6223
							{
Line 6235... Line 6235...
6235
								currentSection->sSection = section;
6235
								currentSection->sSection = section;
6236
								dummyList.push_back(currentSection);
6236
								dummyList.push_back(currentSection);
6237
							}
6237
							}
6238
 
6238
 
6239
							// we have some more ?
6239
							// we have some more ?
6240
							line = line.remTokens(";", 1, 2);
6240
							line = line.remTokens(L";", 1, 2);
6241
						}
6241
						}
6242
						else
6242
						else
6243
						{
6243
						{
6244
							--insection;
6244
							--insection;
6245
							// check the last entry for number of states
6245
							// check the last entry for number of states
6246
							if ( currentSection->sSection.Compare("SDTYPE_GUN") )
6246
							if ( currentSection->sSection.Compare(L"SDTYPE_GUN") )
6247
							{
6247
							{
6248
								int states = line.token(";", 3).toInt();
6248
								int states = line.token(L";", 3).toInt();
6249
								int parts = line.token(";", 4 + (states * 2)).toInt();
6249
								int parts = line.token(L";", 4 + (states * 2)).toInt();
6250
								Utils::String data = line.tokens(";", 1, 4 + (states * 2) + (parts * 2)) + ";";
6250
								Utils::WString data = line.tokens(L";", 1, 4 + (states * 2) + (parts * 2)) + L";";
6251
								currentSection->lEntries.pushBack(data);
6251
								currentSection->lEntries.pushBack(data);
6252
 
6252
 
6253
								// remove done
6253
								// remove done
6254
								line = line.remTokens(";", 1, 4 + (states * 2) + (parts * 2));
6254
								line = line.remTokens(L";", 1, 4 + (states * 2) + (parts * 2));
6255
							}
6255
							}
6256
							else
6256
							else
6257
							{
6257
							{
6258
								int states = line.token(";", 3).toInt();
6258
								int states = line.token(L";", 3).toInt();
6259
								Utils::String data = line.tokens(";", 1, 3 + (states * 2)) + ";";
6259
								Utils::WString data = line.tokens(L";", 1, 3 + (states * 2)) + L";";
6260
								currentSection->lEntries.pushBack(data);
6260
								currentSection->lEntries.pushBack(data);
6261
 
6261
 
6262
								// remove done
6262
								// remove done
6263
								line = line.remTokens(";", 1, 3 + (states * 2));
6263
								line = line.remTokens(L";", 1, 3 + (states * 2));
6264
							}
6264
							}
6265
						}
6265
						}
6266
					}
6266
					}
6267
				}
6267
				}
6268
			}
6268
			}
Line 6304... Line 6304...
6304
				else
6304
				else
6305
				{
6305
				{
6306
					bool f = false;
6306
					bool f = false;
6307
					for(auto itr = found->lEntries.begin(); itr != found->lEntries.end(); itr++)
6307
					for(auto itr = found->lEntries.begin(); itr != found->lEntries.end(); itr++)
6308
					{
6308
					{
6309
						if ((*itr)->str.token(";", 1).Compare(dummy->sData.token(";", 1)))
6309
						if ((*itr)->str.token(L";", 1).Compare(dummy->sData.token(L";", 1)))
6310
						{
6310
						{
6311
							f = true;
6311
							f = true;
6312
							break;
6312
							break;
6313
						}
6313
						}
6314
					}
6314
					}
Line 6320... Line 6320...
6320
				found->lEntries.pushBack(dummy->sData);
6320
				found->lEntries.pushBack(dummy->sData);
6321
			}
6321
			}
6322
		}
6322
		}
6323
 
6323
 
6324
		// finally, write the file
6324
		// finally, write the file
6325
		std::vector<Utils::String> lines;
6325
		std::vector<Utils::WString> lines;
6326
		lines.push_back("// Dummies file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6326
		lines.push_back(L"// Dummies file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
6327
		for ( SDummyEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
6327
		for ( SDummyEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
6328
		{
6328
		{
6329
			lines.push_back("");
6329
			lines.push_back(L"");
6330
			lines.push_back("// Section: " + dummy->sSection + " Entries: " + Utils::String::Number((long)dummy->lEntries.size()));
6330
			lines.push_back(L"// Section: " + dummy->sSection + L" Entries: " + Utils::WString::Number((long)dummy->lEntries.size()));
6331
			lines.push_back(dummy->sSection + ";" + Utils::String::Number(dummy->lEntries.size()) + ";");
6331
			lines.push_back(dummy->sSection + L";" + Utils::WString::Number(dummy->lEntries.size()) + L";");
6332
			for(auto itr = dummy->lEntries.begin(); itr != dummy->lEntries.end(); itr++)
6332
			for(auto itr = dummy->lEntries.begin(); itr != dummy->lEntries.end(); itr++)
6333
			{
6333
			{
6334
				Utils::String strLine = (*itr)->str;
6334
				Utils::WString strLine = (*itr)->str;
6335
				strLine.removeChar(9);
6335
				strLine.removeChar(9);
6336
				strLine.removeChar('\r');
6336
				strLine.removeChar('\r');
6337
				strLine.removeEndSpace();
6337
				strLine.removeEndSpace();
6338
				strLine.removeFirstSpace();
6338
				strLine.removeFirstSpace();
6339
				strLine = strLine.findReplace("<::PiPe::>", "|");
6339
				strLine = strLine.findReplace(L"<::PiPe::>", L"|");
6340
				if ( strLine.right(1) != ";" )
6340
				if ( strLine.right(1) != L";" )
6341
					strLine += ";";
6341
					strLine += L";";
6342
				lines.push_back(strLine);
6342
				lines.push_back(strLine);
6343
			}
6343
			}
6344
		}
6344
		}
6345
		lines.push_back("");
6345
		lines.push_back(L"");
6346
 
6346
 
6347
		// write the file to disk
6347
		// write the file to disk
6348
		CFileIO WriteFile(m_sTempDir + L"/dummies.txt");
6348
		CFileIO WriteFile(m_sTempDir + L"/dummies.txt");
6349
		if ( WriteFile.writeFile(&lines) )
6349
		if ( WriteFile.writeFile(lines) )
6350
		{
6350
		{
6351
			this->packFile(&WriteFile, L"types\\dummies.pck");
6351
			this->packFile(&WriteFile, L"types\\dummies.pck");
6352
			WriteFile.remove();
6352
			WriteFile.remove();
6353
		}
6353
		}
6354
	}
6354
	}
Line 6375... Line 6375...
6375
	}
6375
	}
6376
 
6376
 
6377
	if ( !found )
6377
	if ( !found )
6378
		return;
6378
		return;
6379
 
6379
 
6380
	std::vector<Utils::String> cutList;
6380
	std::vector<Utils::WString> cutList;
6381
	int e = extractGameFile(L"types/CutData.pck", m_sTempDir + L"/CutData.txt");
6381
	int e = extractGameFile(L"types/CutData.pck", m_sTempDir + L"/CutData.txt");
6382
	if ( e )
6382
	if ( e )
6383
	{
6383
	{
6384
		CFileIO File;
6384
		CFileIO File;
6385
		if ( File.open((e == -1) ? L"CutData.txt" : m_sTempDir + L"/CutData.txt") )
6385
		if ( File.open((e == -1) ? L"CutData.txt" : m_sTempDir + L"/CutData.txt") )
6386
		{
6386
		{
6387
 
-
 
6388
			std::vector<Utils::String> lines;
6387
			std::vector<Utils::WString> lines;
6389
			if(File.readLines(lines))
6388
			if(File.readLines(lines))
6390
			{
6389
			{
6391
				int entries = -1;
6390
				int entries = -1;
6392
				for ( int j = 0; j < (int)lines.size(); j++ )
6391
				for ( int j = 0; j < (int)lines.size(); j++ )
6393
				{
6392
				{
6394
					Utils::String line(lines.at(j));
6393
					Utils::WString line(lines.at(j));
6395
					line.removeChar(9);
6394
					line.removeChar(9);
6396
					line.removeChar('\r');
6395
					line.removeChar('\r');
6397
					line.removeChar(' ');
6396
					line.removeChar(' ');
6398
					if ( line.empty() || line[0] == '/' )
6397
					if ( line.empty() || line[0] == '/' )
6399
						continue;
6398
						continue;
6400
					if ( entries == -1 )
6399
					if ( entries == -1 )
6401
						entries = line.token(";", 1).toInt();
6400
						entries = line.token(L";", 1).toInt();
6402
					else
6401
					else
6403
					{
6402
					{
6404
						if ( line.right(1) != ";" )
6403
						if ( line.right(1) != L";" )
6405
							line += ";";
6404
							line += L";";
6406
						cutList.push_back(line);
6405
						cutList.push_back(line);
6407
						if ( static_cast<int>(cutList.size()) == entries)
6406
						if ( static_cast<int>(cutList.size()) == entries)
6408
							break;
6407
							break;
6409
					}
6408
					}
6410
				}
6409
				}
Line 6426... Line 6425...
6426
 
6425
 
6427
		// add each dummy to list
6426
		// add each dummy to list
6428
		auto& list = s->pPackage->getCutData();
6427
		auto& list = s->pPackage->getCutData();
6429
		for(auto itr = list.begin(); itr != list.end(); itr++)
6428
		for(auto itr = list.begin(); itr != list.end(); itr++)
6430
		{
6429
		{
6431
			Utils::String str = (*itr)->str;
6430
			Utils::WString str = (*itr)->str;
6432
			str.removeChar(' ');
6431
			str.removeChar(' ');
6433
			if ( str.right(1) != ";" )
6432
			if ( str.right(1) != L";" )
6434
				str += ";";
6433
				str += L";";
6435
			if(std::find(cutList.begin(), cutList.end(), str) == cutList.end())
6434
			if(std::find(cutList.begin(), cutList.end(), str) == cutList.end())
6436
				cutList.push_back(str);
6435
				cutList.push_back(str);
6437
		}
6436
		}
6438
	}
6437
	}
6439
 
6438
 
6440
	cutList.insert(cutList.begin(), Utils::String::Number(cutList.size()) + ";");
6439
	cutList.insert(cutList.begin(), Utils::WString::Number(cutList.size()) + ";");
6441
	cutList.insert(cutList.begin(), "/cut id;filename (leave blank to use id)");
6440
	cutList.insert(cutList.begin(), L"/cut id;filename (leave blank to use id)");
6442
	cutList.insert(cutList.begin(), "// Cut Data file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6441
	cutList.insert(cutList.begin(), L"// Cut Data file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
6443
 
6442
 
6444
	// write the file to disk
6443
	// write the file to disk
6445
	CFileIO WriteFile(m_sTempDir + L"/CutData.txt");
6444
	CFileIO WriteFile(m_sTempDir + L"/CutData.txt");
6446
	if ( WriteFile.writeFile(&cutList) )
6445
	if ( WriteFile.writeFile(cutList) )
6447
	{
6446
	{
6448
		this->packFile(&WriteFile, L"types\\CutData.pck");
6447
		this->packFile(&WriteFile, L"types\\CutData.pck");
6449
		WriteFile.remove();
6448
		WriteFile.remove();
6450
	}
6449
	}
6451
}
6450
}
Line 6507... Line 6506...
6507
		if ( !s->pPackage->anyAnimations() )
6506
		if ( !s->pPackage->anyAnimations() )
6508
			continue;
6507
			continue;
6509
 
6508
 
6510
		// add each dummy to list
6509
		// add each dummy to list
6511
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6510
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6512
			parsedAniList.pushBack((*itr)->str);
6511
			parsedAniList.pushBack((*itr)->str.toString());
6513
	}
6512
	}
6514
 
6513
 
6515
	// format the list with added spaces
6514
	// format the list with added spaces
6516
	Utils::CStringList formatedAniList;
6515
	Utils::CStringList formatedAniList;
6517
	int lineCount = -1;
6516
	int lineCount = -1;
Line 6686... Line 6685...
6686
			continue;
6685
			continue;
6687
 
6686
 
6688
		// add each dummy to list
6687
		// add each dummy to list
6689
		for(auto itr = s->pPackage->getBodies().begin(); itr != s->pPackage->getBodies().end(); itr++)
6688
		for(auto itr = s->pPackage->getBodies().begin(); itr != s->pPackage->getBodies().end(); itr++)
6690
		{
6689
		{
6691
			Utils::String section = (*itr)->str.token(";", 1);
6690
			Utils::WString section = (*itr)->str.token(L";", 1);
6692
			Utils::String body = (*itr)->str.tokens(";", 2).remove(' ');
6691
			Utils::WString body = (*itr)->str.tokens(L";", 2).remove(' ');
6693
			if ( body.right(1) != ";" )
6692
			if ( body.right(1) != L";" )
6694
				body += ";";
6693
				body += L";";
6695
 
6694
 
6696
			// find the section to add into
6695
			// find the section to add into
6697
			SBodies *foundSection = NULL;
6696
			SBodies *foundSection = NULL;
6698
			for ( CListNode<SBodies> *checkBody = bodiesList.Front(); checkBody; checkBody = checkBody->next() )
6697
			for ( CListNode<SBodies> *checkBody = bodiesList.Front(); checkBody; checkBody = checkBody->next() )
6699
			{
6698
			{
Line 6705... Line 6704...
6705
			}
6704
			}
6706
 
6705
 
6707
			if ( !foundSection )
6706
			if ( !foundSection )
6708
			{
6707
			{
6709
				foundSection = new SBodies;
6708
				foundSection = new SBodies;
6710
				foundSection->sSection = section.toWString();
6709
				foundSection->sSection = section;
6711
				bodiesList.push_back(foundSection);
6710
				bodiesList.push_back(foundSection);
6712
			}
6711
			}
6713
			if(!foundSection->lEntries.contains(body))
6712
			if(!foundSection->lEntries.contains(body))
6714
				foundSection->lEntries.pushBack(body);
6713
				foundSection->lEntries.pushBack(body);
6715
		}
6714
		}
Line 6761... Line 6760...
6761
		// only use custom starts
6760
		// only use custom starts
6762
		if ( !p->IsCustomStart() )
6761
		if ( !p->IsCustomStart() )
6763
			continue;
6762
			continue;
6764
 
6763
 
6765
		// get the name of the start to use
6764
		// get the name of the start to use
6766
		Utils::String name = p->GetCustomStartName();
6765
		Utils::WString name = p->customStartName();
6767
		if ( name.empty() )
6766
		if ( name.empty() )
6768
			continue;
6767
			continue;
6769
 
6768
 
6770
		// find if maps file exists
6769
		// find if maps file exists
6771
		Utils::WStringList createFiles;
6770
		Utils::WStringList createFiles;
Line 6824... Line 6823...
6824
	{
6823
	{
6825
		// read the dummies
6824
		// read the dummies
6826
		CFileIO File;
6825
		CFileIO File;
6827
		if ( File.open((e == -1) ? L"Components.txt" : m_sTempDir + L"/Components.txt") )
6826
		if ( File.open((e == -1) ? L"Components.txt" : m_sTempDir + L"/Components.txt") )
6828
		{
6827
		{
6829
			std::vector<Utils::String> *lines = File.readLines();
6828
			std::vector<Utils::WString> lines;
6830
			if ( lines )
6829
			if(File.readLines(lines))
6831
			{
6830
			{
6832
				int insection = 0;
6831
				int insection = 0;
6833
				int insubsection = 0;
6832
				int insubsection = 0;
6834
				SComponantEntry *currentSection = NULL;
6833
				SComponantEntry *currentSection = NULL;
6835
				SComponantEntry2 *currentSubSection = NULL;
6834
				SComponantEntry2 *currentSubSection = NULL;
6836
				for ( int j = 0; j < (int)lines->size(); j++ )
6835
				for ( int j = 0; j < (int)lines.size(); j++ )
6837
				{
6836
				{
6838
					Utils::String line(lines->at(j));
6837
					Utils::WString line(lines.at(j));
6839
					if ( line[0] == '/' )
6838
					if ( line[0] == '/' )
6840
						continue;
6839
						continue;
6841
					line.removeChar('\r');
6840
					line.removeChar('\r');
6842
					line = line.removeFirstSpace();
6841
					line = line.removeFirstSpace();
6843
					line = line.removeEndSpace();
6842
					line = line.removeEndSpace();
Line 6852... Line 6851...
6852
						if ( line.empty() )
6851
						if ( line.empty() )
6853
							break;
6852
							break;
6854
 
6853
 
6855
						if ( !insection && !insubsection )
6854
						if ( !insection && !insubsection )
6856
						{
6855
						{
6857
							Utils::String section = line.token(";", 1);
6856
							Utils::WString section = line.token(L";", 1);
6858
							insection = line.token(";", 2).toInt();
6857
							insection = line.token(L";", 2).toInt();
6859
 
6858
 
6860
							// search for the sections
6859
							// search for the sections
6861
							currentSection = NULL;
6860
							currentSection = NULL;
6862
							for ( CListNode<SComponantEntry> *node = dummyList.Front(); node; node = node->next() )
6861
							for ( CListNode<SComponantEntry> *node = dummyList.Front(); node; node = node->next() )
6863
							{
6862
							{
Line 6875... Line 6874...
6875
								currentSection->sSection = section;
6874
								currentSection->sSection = section;
6876
								dummyList.push_back(currentSection);
6875
								dummyList.push_back(currentSection);
6877
							}
6876
							}
6878
 
6877
 
6879
							// we have some more ?
6878
							// we have some more ?
6880
							line = line.remTokens(";", 1, 2);
6879
							line = line.remTokens(L";", 1, 2);
6881
						}
6880
						}
6882
						else if ( !insubsection )
6881
						else if ( !insubsection )
6883
						{
6882
						{
6884
							--insection;
6883
							--insection;
6885
							Utils::String section = line.token(";", 1);
6884
							Utils::WString section = line.token(L";", 1);
6886
							insubsection = line.token(";", 2).toInt();
6885
							insubsection = line.token(L";", 2).toInt();
6887
 
6886
 
6888
							currentSubSection = new SComponantEntry2;
6887
							currentSubSection = new SComponantEntry2;
6889
							currentSubSection->sSection = section;
6888
							currentSubSection->sSection = section;
6890
							currentSection->lEntries.push_back(currentSubSection);
6889
							currentSection->lEntries.push_back(currentSubSection);
6891
 
6890
 
6892
							line = line.remTokens(";", 1, 2);
6891
							line = line.remTokens(L";", 1, 2);
6893
						}
6892
						}
6894
						else
6893
						else
6895
						{
6894
						{
6896
							--insubsection;
6895
							--insubsection;
6897
							line = line.remove(' ');
6896
							line = line.remove(' ');
6898
							if(!currentSubSection->lEntries.contains(line))
6897
							if(!currentSubSection->lEntries.contains(line))
6899
								currentSubSection->lEntries.pushBack(line);
6898
								currentSubSection->lEntries.pushBack(line);
6900
							line = "";
6899
							line = L"";
6901
						}
6900
						}
6902
					}
6901
					}
6903
				}
6902
				}
6904
 
-
 
6905
				delete lines;
-
 
6906
			}
6903
			}
6907
 
6904
 
6908
			File.remove();
6905
			File.remove();
6909
		}
6906
		}
6910
 
6907
 
Line 6980... Line 6977...
6980
				found2->lEntries.pushBack(dummy->sData.remove(' '));
6977
				found2->lEntries.pushBack(dummy->sData.remove(' '));
6981
			}
6978
			}
6982
		}
6979
		}
6983
 
6980
 
6984
		// finally, write the file
6981
		// finally, write the file
6985
		std::vector<Utils::String> lines;
6982
		std::vector<Utils::WString> lines;
6986
		lines.push_back("// Components file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6983
		lines.push_back(L"// Components file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
6987
		for ( SComponantEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
6984
		for ( SComponantEntry *dummy = dummyList.First(); dummy; dummy = dummyList.Next() )
6988
		{
6985
		{
6989
			lines.push_back("");
6986
			lines.push_back(L"");
6990
			lines.push_back("// Section: " + dummy->sSection + " Entries: " + Utils::String::Number((long)dummy->lEntries.size()));
6987
			lines.push_back(L"// Section: " + dummy->sSection + L" Entries: " + Utils::WString::Number((long)dummy->lEntries.size()));
6991
			lines.push_back(dummy->sSection + ";" + Utils::String::Number(dummy->lEntries.size()) + ";");
6988
			lines.push_back(dummy->sSection + L";" + Utils::WString::Number(dummy->lEntries.size()) + L";");
6992
			for ( CListNode<SComponantEntry2> *comp = dummy->lEntries.Front(); comp; comp = comp->next() )
6989
			for ( CListNode<SComponantEntry2> *comp = dummy->lEntries.Front(); comp; comp = comp->next() )
6993
			{
6990
			{
6994
				lines.push_back(comp->Data()->sSection + ";" + Utils::String::Number((long)comp->Data()->lEntries.size()) + ";");
6991
				lines.push_back(comp->Data()->sSection + L";" + Utils::WString::Number((long)comp->Data()->lEntries.size()) + L";");
6995
				for(auto itr = comp->Data()->lEntries.begin(); itr != comp->Data()->lEntries.end(); itr++)
6992
				for(auto itr = comp->Data()->lEntries.begin(); itr != comp->Data()->lEntries.end(); itr++)
6996
				{
6993
				{
6997
					Utils::String cStr = (*itr)->str;
6994
					Utils::WString cStr = (*itr)->str;
6998
					cStr.removeEndSpace();
6995
					cStr.removeEndSpace();
6999
					cStr.removeChar(9);
6996
					cStr.removeChar(9);
7000
					cStr.removeChar('\r');
6997
					cStr.removeChar('\r');
7001
					if ( cStr.right(1) != ";" )
6998
					if ( cStr.right(1) != L";" )
7002
						cStr += ";";
6999
						cStr += L";";
7003
					lines.push_back(cStr);
7000
					lines.push_back(cStr);
7004
				}
7001
				}
7005
			}
7002
			}
7006
		}
7003
		}
7007
 
7004
 
7008
		// write the file to disk
7005
		// write the file to disk
7009
		CFileIO WriteFile(m_sTempDir + L"/Components.txt");
7006
		CFileIO WriteFile(m_sTempDir + L"/Components.txt");
7010
		if ( WriteFile.writeFile(&lines) )
7007
		if ( WriteFile.writeFile(lines) )
7011
		{
7008
		{
7012
			this->packFile(&WriteFile, L"types\\Components.pck");
7009
			this->packFile(&WriteFile, L"types\\Components.pck");
7013
			WriteFile.remove();
7010
			WriteFile.remove();
7014
		}
7011
		}
7015
	}
7012
	}
Line 7211... Line 7208...
7211
	// no ships ?
7208
	// no ships ?
7212
	if ( m_lGameShips.empty() )
7209
	if ( m_lGameShips.empty() )
7213
		return;
7210
		return;
7214
 
7211
 
7215
	// get the cockpit list to match with ships turrets
7212
	// get the cockpit list to match with ships turrets
7216
	Utils::CStringList Cockpits;
7213
	Utils::WStringList Cockpits;
7217
	Utils::CStringList cockpitList;
7214
	Utils::WStringList cockpitList;
7218
	if(_createCockpits(cockpitList))
7215
	if(_createCockpits(cockpitList))
7219
	{
7216
	{
7220
		for(auto itr = cockpitList.begin(); itr != cockpitList.end(); itr++)
7217
		for(auto itr = cockpitList.begin(); itr != cockpitList.end(); itr++)
7221
		{
7218
		{
7222
			Utils::String id = (*itr)->str.token(";", 19);
7219
			Utils::WString id = (*itr)->str.token(L";", 19);
7223
			Cockpits.pushBack(id);
7220
			Cockpits.pushBack(id);
7224
		}
7221
		}
7225
	}
7222
	}
7226
 
7223
 
7227
	CLinkList<SGameShip> shipOverrides;
7224
	CLinkList<SGameShip> shipOverrides;
Line 7237... Line 7234...
7237
	// read the existing tships file
7234
	// read the existing tships file
7238
	int e = extractGameFile(L"types/TShips.pck", m_sTempDir + L"/TShips.txt");
7235
	int e = extractGameFile(L"types/TShips.pck", m_sTempDir + L"/TShips.txt");
7239
	if ( e )
7236
	if ( e )
7240
	{
7237
	{
7241
		int fileType = 51;
7238
		int fileType = 51;
7242
		std::vector<Utils::String> tshipsList;
7239
		std::vector<Utils::WString> tshipsList;
7243
 
7240
 
7244
		// if we have no buffer, lets create one
7241
		// if we have no buffer, lets create one
7245
		CFileIO File;
7242
		CFileIO File;
7246
		if ( File.open((e == -1) ? L"TShips.txt" : m_sTempDir + L"/TShips.txt") )
7243
		if ( File.open((e == -1) ? L"TShips.txt" : m_sTempDir + L"/TShips.txt") )
7247
		{
7244
		{
7248
			int shiptext = SHIPSTARTTEXT;
7245
			int shiptext = SHIPSTARTTEXT;
7249
 
7246
 
7250
			std::vector<Utils::String> *lines = File.readLines();
7247
			std::vector<Utils::WString> lines;
7251
			if ( lines )
7248
			if(File.readLines(lines))
7252
			{
7249
			{
7253
				int count = -1;
7250
				int count = -1;
7254
				for ( int j = 0; j < (int)lines->size(); j++ )
7251
				for ( int j = 0; j < (int)lines.size(); j++ )
7255
				{
7252
				{
7256
					Utils::String line(lines->at(j));
7253
					Utils::WString line(lines.at(j));
7257
					if ( line[0] == '/' )
7254
					if ( line[0] == '/' )
7258
						continue;
7255
						continue;
7259
					line.removeChar('\r');
7256
					line.removeChar('\r');
7260
					line.removeChar(9);
7257
					line.removeChar(9);
7261
					line = line.removeFirstSpace();
7258
					line = line.removeFirstSpace();
Line 7263... Line 7260...
7263
					if ( line.empty() )
7260
					if ( line.empty() )
7264
						continue;
7261
						continue;
7265
 
7262
 
7266
					if ( count == -1 )
7263
					if ( count == -1 )
7267
					{
7264
					{
7268
						fileType = line.token(";", 1).toInt();
7265
						fileType = line.token(L";", 1).toInt();
7269
						count = line.token(";", 2).toInt();
7266
						count = line.token(L";", 2).toInt();
7270
					}
7267
					}
7271
					else
7268
					else
7272
					{
7269
					{
7273
						if ( line.right(1) != ";" )
7270
						if ( line.right(1) != L";" )
7274
							line += ";";
7271
							line += L";";
7275
 
7272
 
7276
						// check for any ship overrides
7273
						// check for any ship overrides
7277
						bool added = false;
7274
						bool added = false;
7278
						if ( !shipOverrides.empty() )
7275
						if ( !shipOverrides.empty() )
7279
						{
7276
						{
Line 7302... Line 7299...
7302
						--count;
7299
						--count;
7303
						if ( count < 0 )
7300
						if ( count < 0 )
7304
							break;
7301
							break;
7305
					}
7302
					}
7306
				}
7303
				}
7307
 
-
 
7308
				delete lines;
-
 
7309
 
-
 
7310
			}
7304
			}
7311
 
7305
 
7312
			File.remove();
7306
			File.remove();
7313
 
7307
 
7314
			// assign the ship buffer
7308
			// assign the ship buffer
Line 7316... Line 7310...
7316
				m_iShipBuffer = tshipsList.size() + 15;
7310
				m_iShipBuffer = tshipsList.size() + 15;
7317
			// there seems to be too many additional entries, we have no choise but to change the buffer
7311
			// there seems to be too many additional entries, we have no choise but to change the buffer
7318
			else if ( static_cast<size_t>(m_iShipBuffer) <= tshipsList.size() )
7312
			else if ( static_cast<size_t>(m_iShipBuffer) <= tshipsList.size() )
7319
				m_iShipBuffer = tshipsList.size() + 15;
7313
				m_iShipBuffer = tshipsList.size() + 15;
7320
 
7314
 
7321
			Utils::String bufferStart;
7315
			Utils::WString bufferStart;
7322
			if ( m_iGame == GAME_X3 )
7316
			if ( m_iGame == GAME_X3 )
7323
				bufferStart = "0;0;0;0;0;2;499999;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0.049988;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;4;1;0;0;0;0;0;0;2092;1;1;-1;0;0;1;1;0;1;1;1;0;0;0;;-1;0;0;0;0;0;0;0;0;0;";
7317
				bufferStart = L"0;0;0;0;0;2;499999;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0.049988;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;4;1;0;0;0;0;0;0;2092;1;1;-1;0;0;1;1;0;1;1;1;0;0;0;;-1;0;0;0;0;0;0;0;0;0;";
7324
			else
7318
			else
7325
				bufferStart = "0;0;0;0;0;SG_SH_M5;499999;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0.049988;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;4;1;0;0;0;0;0;0;OBJ_BEACON;1;1;-1;0;0;1;1;0;1;1;1;0;0;0;;-1;0;0;0;0;0;0;0;0;0;";
7319
				bufferStart = L"0;0;0;0;0;SG_SH_M5;499999;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0.049988;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;4;1;0;0;0;0;0;0;OBJ_BEACON;1;1;-1;0;0;1;1;0;1;1;1;0;0;0;;-1;0;0;0;0;0;0;0;0;0;";
7326
			// add the buffers now
7320
			// add the buffers now
7327
			for ( int i = tshipsList.size(); i < m_iShipBuffer; i++ )
7321
			for ( int i = tshipsList.size(); i < m_iShipBuffer; i++ )
7328
				tshipsList.push_back(bufferStart + "SHIP_BUFFER;");
7322
				tshipsList.push_back(bufferStart + L"SHIP_BUFFER;");
7329
 
7323
 
7330
			// now lets add our tships line
7324
			// now lets add our tships line
7331
			for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
7325
			for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
7332
			{
7326
			{
7333
				SGameShip *s = node->Data();
7327
				SGameShip *s = node->Data();
Line 7341... Line 7335...
7341
						shiptext += 2;
7335
						shiptext += 2;
7342
 
7336
 
7343
					tshipsList.push_back(s->pPackage->formatShipData(Cockpits, &s->iText, m_iGame));
7337
					tshipsList.push_back(s->pPackage->formatShipData(Cockpits, &s->iText, m_iGame));
7344
				}
7338
				}
7345
				else if ( s->iType == WARETYPE_DELETED )
7339
				else if ( s->iType == WARETYPE_DELETED )
7346
					tshipsList.push_back(bufferStart + "SHIP_DELETED;");
7340
					tshipsList.push_back(bufferStart + L"SHIP_DELETED;");
7347
				else if ( s->iType == WARETYPE_DISABLED )
7341
				else if ( s->iType == WARETYPE_DISABLED )
7348
					tshipsList.push_back(bufferStart + "SHIP_DISABLED;");
7342
					tshipsList.push_back(bufferStart + L"SHIP_DISABLED;");
7349
				else
7343
				else
7350
					tshipsList.push_back(bufferStart + "SHIP_SPACER;");
7344
					tshipsList.push_back(bufferStart + L"SHIP_SPACER;");
7351
			}
7345
			}
7352
 
7346
 
7353
			// finally, write the file
7347
			// finally, write the file
7354
			tshipsList.insert(tshipsList.begin(), Utils::String::Number(fileType) + ";" + Utils::String::Number(tshipsList.size()) + ";");
7348
			tshipsList.insert(tshipsList.begin(), Utils::WString::Number(fileType) + L";" + Utils::WString::Number(tshipsList.size()) + L";");
7355
			tshipsList.insert(tshipsList.begin(), "// TShips file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
7349
			tshipsList.insert(tshipsList.begin(), L"// TShips file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
7356
 
7350
 
7357
			CFileIO WriteFile(m_sTempDir + L"/TShips.txt");
7351
			CFileIO WriteFile(m_sTempDir + L"/TShips.txt");
7358
			if ( WriteFile.writeFile(&tshipsList) )
7352
			if ( WriteFile.writeFile(tshipsList) )
7359
			{
7353
			{
7360
				this->packFile(&WriteFile, L"types/TShips.pck");
7354
				this->packFile(&WriteFile, L"types/TShips.pck");
7361
				WriteFile.remove();
7355
				WriteFile.remove();
7362
			}
7356
			}
7363
		}
7357
		}
7364
	}
7358
	}
7365
 
-
 
7366
}
7359
}
7367
 
7360
 
7368
bool CPackages::packFile(const Utils::WString &filename) const
7361
bool CPackages::packFile(const Utils::WString &filename) const
7369
{
7362
{
7370
	// compress the file
7363
	// compress the file
Line 7501... Line 7494...
7501
	}
7494
	}
7502
 
7495
 
7503
	return false;
7496
	return false;
7504
}
7497
}
7505
 
7498
 
7506
size_t CPackages::_createCockpits(Utils::CStringList &list)
7499
size_t CPackages::_createCockpits(Utils::WStringList &list)
7507
{
7500
{
7508
	// first check we have any ships
7501
	// first check we have any ships
7509
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
7502
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
7510
		return NULL;
7503
		return NULL;
7511
 
7504
 
Line 7516... Line 7509...
7516
	{
7509
	{
7517
		// read the dummies
7510
		// read the dummies
7518
		CFileIO File;
7511
		CFileIO File;
7519
		if ( File.open((e == -1) ? L"TCockpits.txt" : m_sTempDir + L"/TCockpits.txt") )
7512
		if ( File.open((e == -1) ? L"TCockpits.txt" : m_sTempDir + L"/TCockpits.txt") )
7520
		{
7513
		{
7521
			std::vector<Utils::String> lines;
7514
			std::vector<Utils::WString> lines;
7522
			if(File.readLines(lines))
7515
			if(File.readLines(lines))
7523
			{
7516
			{
7524
				int count = -1;
7517
				int count = -1;
7525
				for(auto itr = lines.begin(); itr != lines.end(); itr++)
7518
				for(auto itr = lines.begin(); itr != lines.end(); itr++)
7526
				{
7519
				{
7527
					Utils::String line(*itr);
7520
					Utils::WString line(*itr);
7528
					line.removeChar('\r');
7521
					line.removeChar('\r');
7529
					line.removeChar(9);
7522
					line.removeChar(9);
7530
					line = line.removeFirstSpace();
7523
					line = line.removeFirstSpace();
7531
					line = line.removeEndSpace();
7524
					line = line.removeEndSpace();
7532
					if ( line.empty() )
7525
					if ( line.empty() )
Line 7534... Line 7527...
7534
					if ( line[0] == '/' )
7527
					if ( line[0] == '/' )
7535
						continue;
7528
						continue;
7536
 
7529
 
7537
					if ( count == -1 )
7530
					if ( count == -1 )
7538
					{
7531
					{
7539
						fileType = line.token(";", 1).toInt();
7532
						fileType = line.token(L";", 1).toInt();
7540
						count = line.token(";", 2).toInt();
7533
						count = line.token(L";", 2).toInt();
7541
					}
7534
					}
7542
					else
7535
					else
7543
					{
7536
					{
7544
						while ( !line.empty() )
7537
						while ( !line.empty() )
7545
						{
7538
						{
7546
							Utils::String data = line.tokens(";", 1, 19);
7539
							Utils::WString data = line.tokens(L";", 1, 19);
7547
							list.pushBack(data + ";");
7540
							list.pushBack(data + L";");
7548
							line = line.remTokens(";", 1, 19);
7541
							line = line.remTokens(L";", 1, 19);
7549
 
7542
 
7550
							--count;
7543
							--count;
7551
							if ( count < 1 )
7544
							if ( count < 1 )
7552
								break;
7545
								break;
7553
						}
7546
						}
Line 7569... Line 7562...
7569
				continue;
7562
				continue;
7570
 
7563
 
7571
			for ( CListNode<SCockpit> *cn = s->pPackage->GetCockpits()->Front(); cn; cn = cn->next() )
7564
			for ( CListNode<SCockpit> *cn = s->pPackage->GetCockpits()->Front(); cn; cn = cn->next() )
7572
			{
7565
			{
7573
				bool foundEntry = false;
7566
				bool foundEntry = false;
7574
				Utils::String cockpitStr = cn->Data()->sCockpit;
7567
				Utils::WString cockpitStr = cn->Data()->sCockpit;
7575
				// search for matching game entry
7568
				// search for matching game entry
7576
				for ( CListNode<SWeaponMask> *wm = cn->Data()->lWeaponMask.Front(); wm; wm = wm->next() )
7569
				for ( CListNode<SWeaponMask> *wm = cn->Data()->lWeaponMask.Front(); wm; wm = wm->next() )
7577
				{
7570
				{
7578
					if ( wm->Data()->iGame == (m_iGame - 1) )
7571
					if ( wm->Data()->iGame == (m_iGame - 1) )
7579
					{
7572
					{
7580
						if ( wm->Data()->iMask != -1 )
7573
						if ( wm->Data()->iMask != -1 )
7581
							cockpitStr = cockpitStr.replaceToken(";", 9, Utils::String::Number(wm->Data()->iMask));
7574
							cockpitStr = cockpitStr.replaceToken(L";", 9, Utils::WString::Number(wm->Data()->iMask));
7582
						foundEntry = true;
7575
						foundEntry = true;
7583
						break;
7576
						break;
7584
					}
7577
					}
7585
				}
7578
				}
7586
 
7579
 
7587
				bool found = false;
7580
				bool found = false;
7588
				for(auto itr = list.begin(); itr != list.end(); itr++)
7581
				for(auto itr = list.begin(); itr != list.end(); itr++)
7589
				{
7582
				{
7590
					if ((*itr)->str.token(";", 19).Compare(cn->Data()->sCockpit.token(";", 19)))
7583
					if ((*itr)->str.token(L";", 19).Compare(cn->Data()->sCockpit.token(L";", 19)))
7591
					{
7584
					{
7592
						// only replace existing entry if we have sepeperate weapon masks set
7585
						// only replace existing entry if we have sepeperate weapon masks set
7593
						if ( foundEntry )
7586
						if ( foundEntry )
7594
							(*itr)->str = cockpitStr;
7587
							(*itr)->str = cockpitStr;
7595
						found = true;
7588
						found = true;
Line 7601... Line 7594...
7601
					list.pushBack(cockpitStr);
7594
					list.pushBack(cockpitStr);
7602
			}
7595
			}
7603
		}
7596
		}
7604
 
7597
 
7605
		// finally, write the file
7598
		// finally, write the file
7606
		list.pushFront(Utils::String::Number(fileType) + ";" + Utils::String::Number(list.size()) + ";");
7599
		list.pushFront(Utils::WString::Number(fileType) + L";" + Utils::WString::Number(list.size()) + L";");
7607
		list.pushFront("// TCockpits file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
7600
		list.pushFront(L"// TCockpits file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
7608
 
7601
 
7609
		CFileIO WriteFile(m_sTempDir + L"/TCockpits.txt");
7602
		CFileIO WriteFile(m_sTempDir + L"/TCockpits.txt");
7610
		if ( WriteFile.writeFile(&list) )
7603
		if ( WriteFile.writeFile(&list) )
7611
		{
7604
		{
7612
			this->packFile(&WriteFile, L"types\\TCockpits.pck");
7605
			this->packFile(&WriteFile, L"types\\TCockpits.pck");