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
	}
6355
}
6355
}
6356
 
6356
 
6357
void CPackages::CreateCutData()
6357
void CPackages::CreateCutData()
6358
{
6358
{
6359
	// first check we have any ships
6359
	// first check we have any ships
6360
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
6360
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
6361
		return;
6361
		return;
6362
 
6362
 
6363
	bool found = false;
6363
	bool found = false;
6364
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6364
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6365
	{
6365
	{
6366
		SGameShip *s = node->Data();
6366
		SGameShip *s = node->Data();
6367
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6367
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6368
			continue;
6368
			continue;
6369
 
6369
 
6370
		// no dummies to add?
6370
		// no dummies to add?
6371
		if ( !s->pPackage->anyCutData() )
6371
		if ( !s->pPackage->anyCutData() )
6372
			continue;
6372
			continue;
6373
		found = true;
6373
		found = true;
6374
		break;
6374
		break;
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
				}
6411
			}
6410
			}
6412
 
6411
 
6413
			File.remove();
6412
			File.remove();
6414
		}
6413
		}
6415
	}
6414
	}
6416
 
6415
 
6417
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6416
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6418
	{
6417
	{
6419
		SGameShip *s = node->Data();
6418
		SGameShip *s = node->Data();
6420
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6419
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6421
			continue;
6420
			continue;
6422
 
6421
 
6423
		// no dummies to add?
6422
		// no dummies to add?
6424
		if ( !s->pPackage->anyCutData() )
6423
		if ( !s->pPackage->anyCutData() )
6425
			continue;
6424
			continue;
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
}
6452
 
6451
 
6453
void CPackages::CreateAnimations()
6452
void CPackages::CreateAnimations()
6454
{
6453
{
6455
	// first check we have any ships
6454
	// first check we have any ships
6456
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
6455
	if ( m_lGameShips.empty() || !this->countPackages(TYPE_XSP, true) )
6457
		return;
6456
		return;
6458
 
6457
 
6459
	bool found = false;
6458
	bool found = false;
6460
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6459
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6461
	{
6460
	{
6462
		SGameShip *s = node->Data();
6461
		SGameShip *s = node->Data();
6463
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6462
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6464
			continue;
6463
			continue;
6465
 
6464
 
6466
		// no dummies to add?
6465
		// no dummies to add?
6467
		if ( !s->pPackage->anyAnimations() )
6466
		if ( !s->pPackage->anyAnimations() )
6468
			continue;
6467
			continue;
6469
		found = true;
6468
		found = true;
6470
		break;
6469
		break;
6471
	}
6470
	}
Line 6499... Line 6498...
6499
 
6498
 
6500
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6499
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6501
	{
6500
	{
6502
		SGameShip *s = node->Data();
6501
		SGameShip *s = node->Data();
6503
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6502
		if ( s->iType != WARETYPE_ADDED || !s->pPackage )
6504
			continue;
6503
			continue;
6505
 
6504
 
6506
		// no dummies to add?
6505
		// no dummies to add?
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 6533... Line 6532...
6533
		Utils::String line = (*itr)->str.token("//", 1);
6532
		Utils::String line = (*itr)->str.token("//", 1);
6534
 
6533
 
6535
		// split into seperate lines
6534
		// split into seperate lines
6536
		Utils::String first = line.token(";", 1);
6535
		Utils::String first = line.token(";", 1);
6537
		if ( first.Compare("TAT_TAGSINGLESTEP") )
6536
		if ( first.Compare("TAT_TAGSINGLESTEP") )
6538
		{
6537
		{
6539
			formatedAniList.pushBack(line.tokens(";", 1, 5) + ";");
6538
			formatedAniList.pushBack(line.tokens(";", 1, 5) + ";");
6540
			int max;
6539
			int max;
6541
			Utils::String *sLines = line.tokens(";", 6).tokenise(";", &max);
6540
			Utils::String *sLines = line.tokens(";", 6).tokenise(";", &max);
6542
			if ( max && sLines )
6541
			if ( max && sLines )
6543
			{
6542
			{
6544
				if ( sLines[max - 1].empty() )
6543
				if ( sLines[max - 1].empty() )
6545
					--max; // remove the last ";"
6544
					--max; // remove the last ";"
6546
 
6545
 
6547
				for ( int i = 0; i < max; i++ )
6546
				for ( int i = 0; i < max; i++ )
6548
				{
6547
				{
6549
					Utils::String l = "\t" + sLines[i] + ";";
6548
					Utils::String l = "\t" + sLines[i] + ";";
6550
					if ( i == (max - 1) )
6549
					if ( i == (max - 1) )
Line 6618... Line 6617...
6618
		found = true;
6617
		found = true;
6619
		break;
6618
		break;
6620
	}
6619
	}
6621
 
6620
 
6622
	if ( !found )
6621
	if ( !found )
6623
		return;
6622
		return;
6624
 
6623
 
6625
	// lets read our current bodies file
6624
	// lets read our current bodies file
6626
	CLinkList<SBodies> bodiesList;
6625
	CLinkList<SBodies> bodiesList;
6627
	SBodies *currentSection = NULL;
6626
	SBodies *currentSection = NULL;
6628
	int e = extractGameFile(L"types/Bodies.pck", m_sTempDir + L"/Bodies.txt");
6627
	int e = extractGameFile(L"types/Bodies.pck", m_sTempDir + L"/Bodies.txt");
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
			{
6700
				if ( checkBody->Data()->sSection.Compare(section))
6699
				if ( checkBody->Data()->sSection.Compare(section))
6701
				{
6700
				{
6702
					foundSection = checkBody->Data();
6701
					foundSection = checkBody->Data();
6703
					break;
6702
					break;
6704
				}
6703
				}
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 6800... Line 6799...
6800
 
6799
 
6801
void CPackages::addCreatedFile(const Utils::WString &sFile)
6800
void CPackages::addCreatedFile(const Utils::WString &sFile)
6802
{
6801
{
6803
	Utils::WString file = sFile.findRemove(m_sCurrentDir);
6802
	Utils::WString file = sFile.findRemove(m_sCurrentDir);
6804
	while ( file[0] == '/' )
6803
	while ( file[0] == '/' )
6805
		file.erase(0, 1);
6804
		file.erase(0, 1);
6806
	while ( file[0] == '\\' )
6805
	while ( file[0] == '\\' )
6807
		file.erase(0, 1);
6806
		file.erase(0, 1);
6808
 
6807
 
6809
	if(!_lCreatedFiles.contains(file, true))
6808
	if(!_lCreatedFiles.contains(file, true))
6810
		_lCreatedFiles.pushBack(file);
6809
		_lCreatedFiles.pushBack(file);
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 6929... Line 6926...
6929
				{
6926
				{
6930
					if ( eNode->Data()->sSection.Compare(dummy->sSection) )
6927
					if ( eNode->Data()->sSection.Compare(dummy->sSection) )
6931
					{
6928
					{
6932
						found = eNode->Data();
6929
						found = eNode->Data();
6933
						break;
6930
						break;
6934
					}
6931
					}
6935
				}
6932
				}
6936
				if ( !found )
6933
				if ( !found )
6937
				{
6934
				{
6938
					found = new SComponantEntry;
6935
					found = new SComponantEntry;
6939
					found->sSection = dummy->sSection;
6936
					found->sSection = dummy->sSection;
6940
					dummyList.push_back(found);
6937
					dummyList.push_back(found);
Line 6973... Line 6970...
6973
						}
6970
						}
6974
 
6971
 
6975
						if ( f )
6972
						if ( f )
6976
							continue;
6973
							continue;
6977
					}
6974
					}
6978
				}
6975
				}
6979
 
6976
 
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 7028... Line 7025...
7028
 
7025
 
7029
	return true;
7026
	return true;
7030
}
7027
}
7031
 
7028
 
7032
bool CPackages::readCommands(int iLang, CLinkList<SCommandSlot> &list)
7029
bool CPackages::readCommands(int iLang, CLinkList<SCommandSlot> &list)
7033
{
7030
{
7034
	if ( iLang == 0 ) iLang = m_iLanguage;
7031
	if ( iLang == 0 ) iLang = m_iLanguage;
7035
 
7032
 
7036
	for(CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next()) {
7033
	for(CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next()) {
7037
		if ( !node->Data()->IsEnabled() ) continue;
7034
		if ( !node->Data()->IsEnabled() ) continue;
7038
		node->Data()->readCommands(iLang, list);
7035
		node->Data()->readCommands(iLang, list);
7039
	}
7036
	}
7040
 
7037
 
7041
	return true;
7038
	return true;
7042
}
7039
}
7043
 
7040
 
7044
bool CPackages::readWingCommands(int iLang, CLinkList<SCommandSlot> &list)
7041
bool CPackages::readWingCommands(int iLang, CLinkList<SCommandSlot> &list)
7045
{
7042
{
7046
	if ( iLang == 0 ) iLang = m_iLanguage;
7043
	if ( iLang == 0 ) iLang = m_iLanguage;
7047
 
7044
 
7048
	for(CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next()) {
7045
	for(CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next()) {
7049
		if ( !node->Data()->IsEnabled() ) continue;
7046
		if ( !node->Data()->IsEnabled() ) continue;
7050
		node->Data()->readWingCommands(iLang, list);
7047
		node->Data()->readWingCommands(iLang, list);
7051
	}
7048
	}
7052
 
7049
 
7053
	return true;
7050
	return true;
7054
}
7051
}
7055
 
7052
 
7056
int CPackages::_warePriceOverride(enum WareTypes type, int pos, const Utils::WString &id)
7053
int CPackages::_warePriceOverride(enum WareTypes type, int pos, const Utils::WString &id)
7057
{
7054
{
7058
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
7055
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
7059
		if ( node->Data()->type == type ) {
7056
		if ( node->Data()->type == type ) {
7060
			if ( node->Data()->type == Ware_Custom && id.Compare(node->Data()->id) ) return node->Data()->relval;
7057
			if ( node->Data()->type == Ware_Custom && id.Compare(node->Data()->id) ) return node->Data()->relval;
Line 7089... Line 7086...
7089
		}
7086
		}
7090
	}
7087
	}
7091
}
7088
}
7092
 
7089
 
7093
int CPackages::empOveridePrice(int id)
7090
int CPackages::empOveridePrice(int id)
7094
{
7091
{
7095
	return _warePriceOverride(Ware_EMP, id, Utils::WString::Null()); 
7092
	return _warePriceOverride(Ware_EMP, id, Utils::WString::Null()); 
7096
}
7093
}
7097
 
7094
 
7098
bool CPackages::empOverideNoto(int id, int *noto)
7095
bool CPackages::empOverideNoto(int id, int *noto)
7099
{
7096
{
Line 7126... Line 7123...
7126
}
7123
}
7127
 
7124
 
7128
void CPackages::removeBuiltinWareOverride(int pos)
7125
void CPackages::removeBuiltinWareOverride(int pos)
7129
{
7126
{
7130
	_removeWareOverride(Ware_BuiltIn, pos, Utils::WString::Null());
7127
	_removeWareOverride(Ware_BuiltIn, pos, Utils::WString::Null());
7131
}
7128
}
7132
 
7129
 
7133
void CPackages::removeCustomWareOverride(const Utils::WString &id)
7130
void CPackages::removeCustomWareOverride(const Utils::WString &id)
7134
{
7131
{
7135
	_removeWareOverride(Ware_Custom, 0, id);
7132
	_removeWareOverride(Ware_Custom, 0, id);
7136
}
7133
}
7137
 
7134
 
Line 7184... Line 7181...
7184
	Utils::WStringList globals;
7181
	Utils::WStringList globals;
7185
	if (readGlobals(globals))
7182
	if (readGlobals(globals))
7186
	{
7183
	{
7187
		// apply out settings
7184
		// apply out settings
7188
		for(auto itr = _lGlobals.begin(); itr != _lGlobals.end(); itr++)
7185
		for(auto itr = _lGlobals.begin(); itr != _lGlobals.end(); itr++)
7189
			globals.changeData((*itr)->str, (*itr)->data);
7186
			globals.changeData((*itr)->str, (*itr)->data);
7190
 
7187
 
7191
		// now write it
7188
		// now write it
7192
		Utils::WStringList writeList;
7189
		Utils::WStringList writeList;
7193
		for(auto itr = globals.begin(); itr != globals.end(); itr++)
7190
		for(auto itr = globals.begin(); itr != globals.end(); itr++)
7194
			writeList.pushBack((*itr)->str + L";" + (*itr)->data + L";");
7191
			writeList.pushBack((*itr)->str + L";" + (*itr)->data + L";");
7195
		
7192
		
7196
		// finally, write the file
7193
		// finally, write the file
7197
		writeList.pushFront(Utils::WString::Number(writeList.size()) + L"; /globals amount", L"");
7194
		writeList.pushFront(Utils::WString::Number(writeList.size()) + L"; /globals amount", L"");
7198
		writeList.pushFront(L"// Globals file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2), L"");
7195
		writeList.pushFront(L"// Globals file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2), L"");
7199
 
7196
 
7200
		CFileIO WriteFile(m_sTempDir + L"/Globals.txt");
7197
		CFileIO WriteFile(m_sTempDir + L"/Globals.txt");
7201
		if ( WriteFile.writeFile(&writeList) )
7198
		if ( WriteFile.writeFile(&writeList) )
7202
		{
7199
		{
7203
			this->packFile(&WriteFile, L"types/Globals.pck");
7200
			this->packFile(&WriteFile, L"types/Globals.pck");
7204
			WriteFile.remove();
7201
			WriteFile.remove();
7205
		}
7202
		}
7206
	}
7203
	}
7207
}
7204
}
7208
 
7205
 
7209
void CPackages::CreateTShips()
7206
void CPackages::CreateTShips()
7210
{
7207
{
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 7301... Line 7298...
7301
							tshipsList.push_back(line);
7298
							tshipsList.push_back(line);
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
7315
			if ( !m_iShipBuffer )
7309
			if ( !m_iShipBuffer )
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 7398... Line 7391...
7398
{
7391
{
7399
	// compress the file
7392
	// compress the file
7400
	CFileIO File(filename);
7393
	CFileIO File(filename);
7401
	size_t fileSize;
7394
	size_t fileSize;
7402
	char *fileData = File.ReadToData(&fileSize);
7395
	char *fileData = File.ReadToData(&fileSize);
7403
 
7396
 
7404
	if ( fileData && fileSize)
7397
	if ( fileData && fileSize)
7405
	{
7398
	{
7406
		size_t newFileSize;
7399
		size_t newFileSize;
7407
		unsigned char *pckData = UnPCKData((unsigned char *)fileData, fileSize, &newFileSize, false);
7400
		unsigned char *pckData = UnPCKData((unsigned char *)fileData, fileSize, &newFileSize, false);
7408
		if ( !pckData )
7401
		if ( !pckData )
Line 7450... Line 7443...
7450
				if ( pckFile.isOpened() )
7443
				if ( pckFile.isOpened() )
7451
					pckFile.close();
7444
					pckFile.close();
7452
 
7445
 
7453
				if ( isxml )
7446
				if ( isxml )
7454
					pckFile.Rename(pckFile.changeFileExtension(L"xml"));
7447
					pckFile.Rename(pckFile.changeFileExtension(L"xml"));
7455
			}
7448
			}
7456
 
7449
 
7457
			return true;
7450
			return true;
7458
		}
7451
		}
7459
	}
7452
	}
7460
 
7453
 
7461
	return false;
7454
	return false;
7462
}
7455
}
7463
 
7456
 
7464
bool CPackages::packFile(CFileIO* File, const Utils::WString &sFilename) const
7457
bool CPackages::packFile(CFileIO* File, const Utils::WString &sFilename) const
7465
{
7458
{
7466
	Utils::WString filename = sFilename.findReplace(L"\\", L"/");
7459
	Utils::WString filename = sFilename.findReplace(L"\\", L"/");
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");