Subversion Repositories spk

Rev

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

Rev 216 Rev 217
Line 187... Line 187...
187
 
187
 
188
Utils::WString CXspFile::createValuesLine() const
188
Utils::WString CXspFile::createValuesLine() const
189
{
189
{
190
	Utils::WString values = CBaseFile::createValuesLine ();
190
	Utils::WString values = CBaseFile::createValuesLine ();
191
 
191
 
192
	values += L"Data: " + m_sData.toWString() + L"\n";
192
	values += L"Data: " + m_sData + L"\n";
193
	values += L"ID: " + m_sID.toWString() + L"\n";
193
	values += L"ID: " + m_sID + L"\n";
194
 
194
 
195
	if ( m_bLanguageText )
195
	if ( m_bLanguageText )
196
		values += L"LanguageText\n";
196
		values += L"LanguageText\n";
197
	if ( m_bExistingShip )
197
	if ( m_bExistingShip )
198
		values += L"ExistingShip\n";
198
		values += L"ExistingShip\n";
Line 239... Line 239...
239
{
239
{
240
	Utils::WString first = sLine.token(L":", 1);
240
	Utils::WString first = sLine.token(L":", 1);
241
	Utils::WString rest  = sLine.tokens(L":", 2).removeFirstSpace();
241
	Utils::WString rest  = sLine.tokens(L":", 2).removeFirstSpace();
242
 
242
 
243
	if ( first.Compare(L"Data") )
243
	if ( first.Compare(L"Data") )
244
		m_sData = rest.toString();
244
		m_sData = rest;
245
	else if ( first.Compare(L"ID") )
245
	else if ( first.Compare(L"ID") )
246
		m_sID = rest.toString();
246
		m_sID = rest;
247
	else if ( sLine.Compare(L"LanguageText") )
247
	else if ( sLine.Compare(L"LanguageText") )
248
		m_bLanguageText = true;
248
		m_bLanguageText = true;
249
	else if ( sLine.Compare(L"ExistingShip") )
249
	else if ( sLine.Compare(L"ExistingShip") )
250
		m_bExistingShip = true;
250
		m_bExistingShip = true;
251
	else if ( first.Compare(L"OrgDesc") || first.Compare(L"OriginalDesc") )
251
	else if ( first.Compare(L"OrgDesc") || first.Compare(L"OriginalDesc") )
Line 398... Line 398...
398
			CLEANSPLIT(strs, max)
398
			CLEANSPLIT(strs, max)
399
		}
399
		}
400
		else if ( first.Compare("ScreenShot") )
400
		else if ( first.Compare("ScreenShot") )
401
		{
401
		{
402
			int size = rest.token(" ", 1);
402
			int size = rest.token(" ", 1);
403
			Utils::String ext = rest.token(" ", 2);
403
			Utils::WString ext = rest.token(" ", 2);
404
 
404
 
405
			C_File *newFile = this->addFile(m_sID + "_" + (long)(this->countFiles(FILETYPE_SCREEN) + 1) + "." + ext, L"", FILETYPE_SCREEN);
405
			C_File *newFile = this->addFile(m_sID + L"_" + (long)(this->countFiles(FILETYPE_SCREEN) + 1) + L"." + ext, L"", FILETYPE_SCREEN);
406
			newFile->ReadFromData((char *)(compr + pos), size); 
406
			newFile->ReadFromData((char *)(compr + pos), size); 
407
 
407
 
408
			start += (size + 1);
408
			start += (size + 1);
409
		}
409
		}
410
		else if ( first.Compare("SceneFile") )
410
		else if ( first.Compare("SceneFile") )
411
		{
411
		{
412
			Utils::String file = rest.tokens(" ", 3);
412
			Utils::WString file = rest.tokens(" ", 3);
413
			m_pSceneFile = this->addFile(CFileIO(file).filenameStr(), CFileIO(file).dir().toString(), FILETYPE_SHIPSCENE);
413
			m_pSceneFile = this->addFile(CFileIO(file).filename(), CFileIO(file).dir(), FILETYPE_SHIPSCENE);
414
			m_pSceneFile->SetCreationTime((long)rest.token(" ", 1));
414
			m_pSceneFile->SetCreationTime((long)rest.token(" ", 1));
415
			m_pSceneFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
415
			m_pSceneFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
416
 
416
 
417
			start += m_pSceneFile->GetDataSize();
417
			start += m_pSceneFile->GetDataSize();
418
		}
418
		}
419
		else if ( first.Compare("CockpitFile") )
419
		else if ( first.Compare("CockpitFile") )
420
		{
420
		{
421
			Utils::String file = rest.tokens(" ", 3);
421
			Utils::WString file = rest.tokens(" ", 3);
422
			m_pCockpitFile = this->addFile(CFileIO(file).filenameStr(), CFileIO(file).dir().toString(), FILETYPE_COCKPITSCENE);
422
			m_pCockpitFile = this->addFile(CFileIO(file).filename(), CFileIO(file).dir(), FILETYPE_COCKPITSCENE);
423
			m_pCockpitFile->SetCreationTime((long)rest.token(" ", 1));
423
			m_pCockpitFile->SetCreationTime((long)rest.token(" ", 1));
424
			m_pCockpitFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
424
			m_pCockpitFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
425
 
425
 
426
			start += m_pCockpitFile->GetDataSize();
426
			start += m_pCockpitFile->GetDataSize();
427
		}
427
		}
428
		else if ( first.Compare("Model") )
428
		else if ( first.Compare("Model") )
429
		{
429
		{
430
			Utils::String file = rest.tokens(" ", 3);
430
			Utils::WString file = rest.tokens(" ", 3);
431
			C_File *newFile= this->addFile(CFileIO(file).filenameStr(), CFileIO(file).dir().toString(), FILETYPE_SHIPMODEL);
431
			C_File *newFile= this->addFile(CFileIO(file).filename(), CFileIO(file).dir(), FILETYPE_SHIPMODEL);
432
			newFile->SetCreationTime((long)rest.token(" ", 1));
432
			newFile->SetCreationTime((long)rest.token(" ", 1));
433
			newFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
433
			newFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
434
 
434
 
435
			start += (newFile->GetDataSize() + 1);
435
			start += (newFile->GetDataSize() + 1);
436
		}
436
		}
437
		else if ( first.Compare("Files") )
437
		else if ( first.Compare("Files") )
438
		{
438
		{
439
			Utils::String file = rest.tokens(" ", 3);
439
			Utils::WString file = rest.tokens(" ", 3);
440
 
440
 
441
			C_File *newFile = NULL;
441
			C_File *newFile = NULL;
442
			int special = 0;
442
			int special = 0;
443
			if ( file.Compare("types/CutData.txt") || file.Compare("types/CutData.pck") )
443
			if ( file.Compare(L"types/CutData.txt") || file.Compare(L"types/CutData.pck") )
444
			{
444
			{
445
				newFile = new C_File(file);
445
				newFile = new C_File(file);
446
				special = 1;
446
				special = 1;
447
			}
447
			}
448
			else if ( file.Compare("types/Bodies.txt") || file.Compare("types/Bodies.pck") )
448
			else if ( file.Compare(L"types/Bodies.txt") || file.Compare(L"types/Bodies.pck") )
449
			{
449
			{
450
				newFile = new C_File(file);
450
				newFile = new C_File(file);
451
				special = 2;
451
				special = 2;
452
			}
452
			}
453
			else if ( file.Compare("types/Animations.txt") || file.Compare("types/Animations.pck") )
453
			else if ( file.Compare(L"types/Animations.txt") || file.Compare(L"types/Animations.pck") )
454
			{
454
			{
455
				newFile = new C_File(file);
455
				newFile = new C_File(file);
456
				special = 3;
456
				special = 3;
457
			}
457
			}
458
			else
458
			else
459
			{
459
			{
460
				newFile = this->addFile(CFileIO(file).filenameStr(), CFileIO(file).dir().toString(), FILETYPE_SHIPOTHER);
460
				newFile = this->addFile(CFileIO(file).filename(), CFileIO(file).dir(), FILETYPE_SHIPOTHER);
461
				newFile->SetCreationTime((long)rest.token(" ", 1));
461
				newFile->SetCreationTime((long)rest.token(" ", 1));
462
			}
462
			}
463
			newFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
463
			newFile->ReadFromData((char *)(compr + pos), rest.token(" ", 2));
464
			start += (newFile->GetDataSize() + 1);
464
			start += (newFile->GetDataSize() + 1);
465
 
465
 
Line 646... Line 646...
646
	}
646
	}
647
 
647
 
648
	// assume all old ones are for X3
648
	// assume all old ones are for X3
649
	if ( !m_sData.empty() )
649
	if ( !m_sData.empty() )
650
	{
650
	{
651
		this->AddWeaponMask(GAME_X3 - 1, m_sData.token(";", 19));
651
		this->AddWeaponMask(GAME_X3 - 1, m_sData.token(L";", 19));
652
		this->AddMissileMask(GAME_X3 - 1, m_sData.token(";", 25));
652
		this->AddMissileMask(GAME_X3 - 1, m_sData.token(L";", 25));
653
	}
653
	}
654
 
654
 
655
	return true;
655
	return true;
656
}
656
}
657
 
657
 
Line 771... Line 771...
771
void CXspFile::clearBodies()
771
void CXspFile::clearBodies()
772
{
772
{
773
	_lBodies.clear();
773
	_lBodies.clear();
774
}
774
}
775
 
775
 
776
Utils::String CXspFile::GetShipClass()
776
Utils::WString CXspFile::shipClass() const
777
{
777
{
778
	if ( !m_sData.empty() )
778
	if ( !m_sData.empty() )
779
		return m_sData.token(";", TSHIPPOS_CLASS);
779
		return m_sData.token(L";", TSHIPPOS_CLASS);
780
	return "OBJ_SHIP_M5";
780
	return L"OBJ_SHIP_M5";
781
}
781
}
782
 
782
 
783
bool CXspFile::GeneratePackagerScript(bool wildcard, Utils::WStringList *list, int game, const Utils::WStringList &gameAddons, bool datafile)
783
bool CXspFile::GeneratePackagerScript(bool wildcard, Utils::WStringList *list, int game, const Utils::WStringList &gameAddons, bool datafile)
784
{
784
{
785
	if ( !CBaseFile::GeneratePackagerScript(wildcard, list, game, gameAddons, datafile) )
785
	if ( !CBaseFile::GeneratePackagerScript(wildcard, list, game, gameAddons, datafile) )
Line 808... Line 808...
808
	}
808
	}
809
 
809
 
810
	if ( !m_sID.empty() )
810
	if ( !m_sID.empty() )
811
	{
811
	{
812
		list->pushBack(L"# Ship ID, the ship id to identify the ship as");
812
		list->pushBack(L"# Ship ID, the ship id to identify the ship as");
813
		list->pushBack(L"ShipID: " + m_sID.toWString());
813
		list->pushBack(L"ShipID: " + m_sID);
814
	}
814
	}
815
 
815
 
816
	if ( m_bExistingShip )
816
	if ( m_bExistingShip )
817
	{
817
	{
818
		list->pushBack(L"# Existing Ship, replaces an existing ship in the game with ship package instead of creating a new entry");
818
		list->pushBack(L"# Existing Ship, replaces an existing ship in the game with ship package instead of creating a new entry");
Line 821... Line 821...
821
	}
821
	}
822
 
822
 
823
	if ( !m_sData.empty() )
823
	if ( !m_sData.empty() )
824
	{
824
	{
825
		list->pushBack(L"# Ship Data, the TShip data entry to add to the game (parts of this are adjusted and auto generated by the installer)");
825
		list->pushBack(L"# Ship Data, the TShip data entry to add to the game (parts of this are adjusted and auto generated by the installer)");
826
		list->pushBack(L"ShipData: " + m_sData.toWString());
826
		list->pushBack(L"ShipData: " + m_sData);
827
		list->pushBack(L"");
827
		list->pushBack(L"");
828
	}
828
	}
829
 
829
 
830
	if ( m_lText.size() ) {
830
	if ( m_lText.size() ) {
831
		list->pushBack(L"# Ship Texts, the name/description of the ship in each language: <LANGID> <NAME>|<DESCRIPTION>");
831
		list->pushBack(L"# Ship Texts, the name/description of the ship in each language: <LANGID> <NAME>|<DESCRIPTION>");
Line 997... Line 997...
997
	for(int i = 0; i < 5; i++) {
997
	for(int i = 0; i < 5; i++) {
998
		Utils::WString type;
998
		Utils::WString type;
999
		Utils::WString data;
999
		Utils::WString data;
1000
		switch(i) {
1000
		switch(i) {
1001
			case 0:
1001
			case 0:
1002
				data = L"50;1\r\n" + this->m_sData.toWString();
1002
				data = L"50;1\r\n" + this->m_sData;
1003
				type = L"TShips";
1003
				type = L"TShips";
1004
				break;
1004
				break;
1005
			case 1:
1005
			case 1:
1006
				if ( !this->m_lCockpit.empty() ) {
1006
				if ( !this->m_lCockpit.empty() ) {
1007
					data = Utils::WString("51;") + (long)this->m_lCockpit.size() + L";\r\n";
1007
					data = Utils::WString("51;") + (long)this->m_lCockpit.size() + L";\r\n";
Line 1064... Line 1064...
1064
		}
1064
		}
1065
	}
1065
	}
1066
	else if ( sFirst.Compare(L"OriginalDescription") )
1066
	else if ( sFirst.Compare(L"OriginalDescription") )
1067
		m_iOrgDesc = sRest;
1067
		m_iOrgDesc = sRest;
1068
	else if ( sFirst.Compare(L"ShipData") )
1068
	else if ( sFirst.Compare(L"ShipData") )
1069
		m_sData = sRest.toString();
1069
		m_sData = sRest;
1070
	else if ( sFirst.Compare(L"ReadData") ) // read data from a tships file
1070
	else if ( sFirst.Compare(L"ReadData") ) // read data from a tships file
1071
	{
1071
	{
1072
		CPackages p;
1072
		CPackages p;
1073
		m_sData = p.readShipData(sRest.tokens(L" ", 2).toString(), sRest.token(L" ", 1).toString());
1073
		m_sData = p.readShipData(sRest.tokens(L" ", 2), sRest.token(L" ", 1));
1074
	}
1074
	}
1075
	else if ( sFirst.Compare(L"ExistingShip") )
1075
	else if ( sFirst.Compare(L"ExistingShip") )
1076
		m_bExistingShip = true;
1076
		m_bExistingShip = true;
1077
	else if ( sFirst.Compare(L"ShipID") )
1077
	else if ( sFirst.Compare(L"ShipID") )
1078
		m_sID = sRest.toString();
1078
		m_sID = sRest;
1079
	else if ( sFirst.Compare(L"ShipText") )
1079
	else if ( sFirst.Compare(L"ShipText") )
1080
		this->addText(sRest.token(L" ", 1).toLong(), sRest.tokens(L" ", 2).token(L"|", 1), sRest.tokens(L" ", 2).tokens(L"|", 2));
1080
		this->addText(sRest.token(L" ", 1).toLong(), sRest.tokens(L" ", 2).token(L"|", 1), sRest.tokens(L" ", 2).tokens(L"|", 2));
1081
	else if ( sFirst.Compare(L"Component") )
1081
	else if ( sFirst.Compare(L"Component") )
1082
		this->addComponent(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.tokens(L" ", 3));
1082
		this->addComponent(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.tokens(L" ", 3));
1083
	else if ( sFirst.Compare(L"Cockpit") )
1083
	else if ( sFirst.Compare(L"Cockpit") )
Line 1103... Line 1103...
1103
 
1103
 
1104
	return true;
1104
	return true;
1105
}
1105
}
1106
 
1106
 
1107
 
1107
 
1108
Utils::String CXspFile::GetX3ShipData()
1108
Utils::WString CXspFile::getX3ShipData() const
1109
{
1109
{
1110
	Utils::String data = m_sData;
1110
	Utils::WString data = m_sData;
1111
 
1111
 
1112
	// change the ship subtype, Reunion uses number, TC uses a define
1112
	// change the ship subtype, Reunion uses number, TC uses a define
1113
	Utils::WString sSubType = data.token(";", 6);
1113
	Utils::WString sSubType = data.token(L";", 6);
1114
	if ( !((long)sSubType) && sSubType != L"0" )
1114
	if ( !((long)sSubType) && sSubType != L"0" )
1115
		data = data.replaceToken(";", 6, (long)CShipData::ConvertShipSubType(sSubType));
1115
		data = data.replaceToken(L";", 6, (long)CShipData::ConvertShipSubType(sSubType));
1116
 
1116
 
1117
	Utils::String sClass = data.token(";", TSHIPPOS_CLASS);
1117
	Utils::WString sClass = data.token(L";", TSHIPPOS_CLASS);
1118
	if ( !((long)sClass) && sClass != "0" )
1118
	if ( !((long)sClass) && sClass != L"0" )
1119
	{
1119
	{
1120
		int num = 0;
1120
		int num = 0;
1121
		for ( int i = 0; i < OBJ_SHIP_MAX; i++ )
1121
		for ( int i = 0; i < OBJ_SHIP_MAX; i++ )
1122
		{
1122
		{
1123
			if ( sClass.Compare(CShipData::ConvertShipClass(CShipData::GetShipClassFromNum(i)).toString()) )
1123
			if ( sClass.Compare(CShipData::ConvertShipClass(CShipData::GetShipClassFromNum(i))) )
1124
			{
1124
			{
1125
				num = i;
1125
				num = i;
1126
				break;
1126
				break;
1127
			}
1127
			}
1128
		}
1128
		}
1129
 
1129
 
1130
		data = data.replaceToken(";", TSHIPPOS_CLASS, (long)num);
1130
		data = data.replaceToken(L";", TSHIPPOS_CLASS, (long)num);
1131
	}
1131
	}
1132
 
1132
 
1133
	return data;
1133
	return data;
1134
}
1134
}
1135
 
1135
 
1136
Utils::String CXspFile::GetTCShipData()
1136
Utils::WString CXspFile::getTCShipData() const
1137
{
1137
{
1138
	Utils::String data = m_sData;
1138
	Utils::WString data = m_sData;
1139
 
1139
 
1140
	Utils::WString sSubType = data.token(";", 6);
1140
	Utils::WString sSubType = data.token(L";", 6);
1141
	if ( ((long)sSubType) || sSubType == L"0" )
1141
	if ( ((long)sSubType) || sSubType == L"0" )
1142
		data = data.replaceToken(";", 6, CShipData::ConvertShipSubType((long)sSubType).toString());
1142
		data = data.replaceToken(L";", 6, CShipData::ConvertShipSubType((long)sSubType));
1143
 
1143
 
1144
	Utils::String sClass = data.token(";", TSHIPPOS_CLASS);
1144
	Utils::WString sClass = data.token(L";", TSHIPPOS_CLASS);
1145
	if ( ((long)sClass) || sClass == "0" )
1145
	if ( ((long)sClass) || sClass == L"0" )
1146
		data = data.replaceToken(";", TSHIPPOS_CLASS, CShipData::ConvertShipClass((long)sClass).toString());
1146
		data = data.replaceToken(L";", TSHIPPOS_CLASS, CShipData::ConvertShipClass((long)sClass));
1147
 
1147
 
1148
	return data;
1148
	return data;
1149
}
1149
}
1150
 
1150
 
1151
bool CXspFile::removeCockpit(const Utils::WString &sCockpitId)
1151
bool CXspFile::removeCockpit(const Utils::WString &sCockpitId)
Line 1801... Line 1801...
1801
	return this->shipName(lang);
1801
	return this->shipName(lang);
1802
}
1802
}
1803
 
1803
 
1804
bool CXspFile::startExtractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *pProgress)
1804
bool CXspFile::startExtractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *pProgress)
1805
{
1805
{
1806
	m_sID = sId.remove('\r');
1806
	m_sID = sId.toWString().remove('\r');
1807
	while ( m_sID.right(1) == ";" )
1807
	while ( m_sID.right(1) == L";" )
1808
		m_sID.truncate(-1);
1808
		m_sID.truncate(-1);
1809
 
1809
 
1810
	m_sData = pVfs->getTShipsEntry(m_sID).toString();
1810
	m_sData = pVfs->getTShipsEntry(m_sID);
1811
 
1811
 
1812
	// get scene files
1812
	// get scene files
1813
	if ( pProgress ) pProgress->UpdateStatus(IMPORTSHIP_SCENE);
1813
	if ( pProgress ) pProgress->UpdateStatus(IMPORTSHIP_SCENE);
1814
	if ( !this->extractSceneFiles(pVfs) )
1814
	if ( !this->extractSceneFiles(pVfs) )
1815
		return false;
1815
		return false;
Line 1832... Line 1832...
1832
	return true;
1832
	return true;
1833
}
1833
}
1834
 
1834
 
1835
bool CXspFile::extractSceneFiles(CVirtualFileSystem *pVfs)
1835
bool CXspFile::extractSceneFiles(CVirtualFileSystem *pVfs)
1836
{
1836
{
1837
	m_pSceneFile = pVfs->extractGameFileToPackage(this, "objects\\" + m_sData.token(";", 17) + ".pbd", FILETYPE_SHIPSCENE, "objects\\" + m_sData.token(";", 17) + ".bod");
1837
	m_pSceneFile = pVfs->extractGameFileToPackage(this, L"objects\\" + m_sData.token(L";", 17) + L".pbd", FILETYPE_SHIPSCENE, L"objects\\" + m_sData.token(L";", 17) + L".bod");
1838
	if ( !m_pSceneFile ) return false;
1838
	if ( !m_pSceneFile ) return false;
1839
	m_pCockpitFile = pVfs->extractGameFileToPackage(this, "objects\\" + m_sData.token(";", 18) + ".pbd", FILETYPE_COCKPITSCENE, "objects\\" + m_sData.token(";", 18) + ".bod");
1839
	m_pCockpitFile = pVfs->extractGameFileToPackage(this, L"objects\\" + m_sData.token(L";", 18) + L".pbd", FILETYPE_COCKPITSCENE, L"objects\\" + m_sData.token(L";", 18) + L".bod");
1840
 
1840
 
1841
	return true;
1841
	return true;
1842
}
1842
}
1843
 
1843
 
1844
bool CXspFile::readSceneModels(Utils::CStringList& out)
1844
bool CXspFile::readSceneModels(Utils::CStringList& out)
Line 2364... Line 2364...
2364
bool CXspFile::ImportCockpits(const Utils::String &filename)
2364
bool CXspFile::ImportCockpits(const Utils::String &filename)
2365
{
2365
{
2366
	CFileIO File(filename);
2366
	CFileIO File(filename);
2367
	if ( File.exists() )
2367
	if ( File.exists() )
2368
	{
2368
	{
2369
		std::vector<Utils::String> lines;
2369
		std::vector<Utils::WString> lines;
2370
		if (File.readLines(lines))
2370
		if (File.readLines(lines))
2371
		{
2371
		{
2372
			int entries = 0;
2372
			int entries = 0;
2373
			auto itr = lines.begin();
2373
			auto itr = lines.begin();
2374
			while(itr != lines.end())
2374
			while(itr != lines.end())
2375
			{
2375
			{
2376
				Utils::String str = itr->remove(9).remove('\r');
2376
				Utils::WString str = itr->remove(9).remove('\r');
2377
				str.removeFirstSpace();
2377
				str.removeFirstSpace();
2378
				if (str.empty())
2378
				if (str.empty())
2379
					itr = lines.erase(itr);
2379
					itr = lines.erase(itr);
2380
				else if (str[0] == '/')
2380
				else if (str[0] == '/')
2381
					itr = lines.erase(itr);
2381
					itr = lines.erase(itr);
2382
				else if (!entries)
2382
				else if (!entries)
2383
				{
2383
				{
2384
					entries = str.token(";", 2).toInt();
2384
					entries = str.token(L";", 2).toInt();
2385
					itr = lines.erase(itr);
2385
					itr = lines.erase(itr);
2386
				}
2386
				}
2387
				else
2387
				else
2388
					itr++;
2388
					itr++;
2389
			}
2389
			}
2390
 
2390
 
2391
			// now get all the entries from TShips
2391
			// now get all the entries from TShips
2392
			for (int i = 0; i < 6; i++)
2392
			for (int i = 0; i < 6; i++)
2393
			{
2393
			{
2394
				int idx = m_sData.token(";", 32 + (i * 2));
2394
				int idx = m_sData.token(L";", 32 + (i * 2));
2395
				if (static_cast<size_t>(idx) < lines.size() && idx)
2395
				if (static_cast<size_t>(idx) < lines.size() && idx)
2396
				{
2396
				{
2397
					Utils::WString turret = lines[idx];
2397
					Utils::WString turret = lines[idx];
2398
					int pos = -1;
2398
					int pos = -1;
2399
					Utils::WString id;
2399
					Utils::WString id;
2400
					while (id.empty() && pos > -100) id = turret.token(L";", pos--);
2400
					while (id.empty() && pos > -100) id = turret.token(L";", pos--);
2401
					m_sData = m_sData.replaceToken(";", 32 + (i * 2), id.toString() + "(" + (long)idx + ")");
2401
					m_sData = m_sData.replaceToken(L";", 32 + (i * 2), id + L"(" + (long)idx + L")");
2402
 
2402
 
2403
					this->addCockpit(turret, 0);
2403
					this->addCockpit(turret, 0);
2404
				}
2404
				}
2405
			}
2405
			}
2406
		}
2406
		}
Line 2436... Line 2436...
2436
}
2436
}
2437
 
2437
 
2438
bool CXspFile::_addTextFromFile(CFileIO &F, int textId)
2438
bool CXspFile::_addTextFromFile(CFileIO &F, int textId)
2439
{
2439
{
2440
	if ( textId == -1 && !m_sData.empty() )
2440
	if ( textId == -1 && !m_sData.empty() )
2441
		textId = m_sData.token(";", 7);
2441
		textId = m_sData.token(L";", 7);
2442
 
2442
 
2443
	if ( textId <= 0 )
2443
	if ( textId <= 0 )
2444
		return false;
2444
		return false;
2445
 
2445
 
2446
	if ( !F.isOpened() )
2446
	if ( !F.isOpened() )
2447
		return false;
2447
		return false;
2448
 
2448
 
2449
	bool added = false;
2449
	bool added = false;
2450
 
2450
 
2451
	Utils::String shipName;
2451
	Utils::WString shipName;
2452
	Utils::String shipDesc;
2452
	Utils::WString shipDesc;
2453
 
2453
 
2454
	int lastAddedGameID = 0;
2454
	int lastAddedGameID = 0;
2455
	int currentGameID = 0;
2455
	int currentGameID = 0;
2456
	int lang = 0;
2456
	int lang = 0;
2457
	bool inpage = false;
2457
	bool inpage = false;
Line 2461... Line 2461...
2461
		{
2461
		{
2462
			added = true;
2462
			added = true;
2463
			break;
2463
			break;
2464
		}
2464
		}
2465
 
2465
 
2466
		Utils::String line = F.readEndOfLineStr();
2466
		Utils::WString line = F.readEndOfLine();
2467
		line.removeChar(9);
2467
		line.removeChar(9);
2468
		line.removeChar('\r');
2468
		line.removeChar('\r');
2469
		line.removeFirstSpace();
2469
		line.removeFirstSpace();
2470
	
2470
	
2471
		if ( inpage )
2471
		if ( inpage )
2472
		{
2472
		{
2473
			if ( line.left(6).Compare("</page") ) {
2473
			if ( line.left(6).Compare(L"</page") ) {
2474
				inpage = false;
2474
				inpage = false;
2475
				continue;
2475
				continue;
2476
			}
2476
			}
2477
 
2477
 
2478
			// find matching id
2478
			// find matching id
2479
			if ( line.left(6).Compare("<t id=") )
2479
			if ( line.left(6).Compare(L"<t id=") )
2480
			{
2480
			{
2481
				int pos = line.findPos("id=\"", 0);
2481
				int pos = line.findPos(L"id=\"", 0);
2482
				if ( pos != -1 )
2482
				if ( pos != -1 )
2483
				{
2483
				{
2484
					pos += 4;
2484
					pos += 4;
2485
					int endpos = line.findPos("\"", pos);
2485
					int endpos = line.findPos(L"\"", pos);
2486
					if ( endpos != -1 )
2486
					if ( endpos != -1 )
2487
					{
2487
					{
2488
						int id = line.mid(pos, endpos);
2488
						int id = line.mid(pos, endpos);
2489
						if ( id == textId || id == (textId + 1) )
2489
						if ( id == textId || id == (textId + 1) )
2490
						{
2490
						{
2491
							pos = line.findPos(">", endpos);
2491
							pos = line.findPos(L">", endpos);
2492
							if ( pos != -1 )
2492
							if ( pos != -1 )
2493
							{
2493
							{
2494
								endpos = line.findPos("</t>", pos);
2494
								endpos = line.findPos("L</t>", pos);
2495
								if ( endpos != -1 )
2495
								if ( endpos != -1 )
2496
								{
2496
								{
2497
									if ( id == textId )
2497
									if ( id == textId )
2498
										shipName = line.mid(pos + 1, endpos);
2498
										shipName = line.mid(pos + 1, endpos);
2499
									else
2499
									else
Line 2506... Line 2506...
2506
				}
2506
				}
2507
			}
2507
			}
2508
		}
2508
		}
2509
		else if ( lang ) // search for page 17
2509
		else if ( lang ) // search for page 17
2510
		{
2510
		{
2511
			if ( line.left(8).Compare("<page id") )
2511
			if ( line.left(8).Compare(L"<page id") )
2512
			{
2512
			{
2513
				int pos = line.findPos("id=\"");
2513
				int pos = line.findPos(L"id=\"");
2514
				if ( pos != -1 )
2514
				if ( pos != -1 )
2515
				{
2515
				{
2516
					pos += 4;
2516
					pos += 4;
2517
					int endpos = line.findPos("\"", pos);
2517
					int endpos = line.findPos(L"\"", pos);
2518
					if ( endpos != -1 )
2518
					if ( endpos != -1 )
2519
					{
2519
					{
2520
						Utils::String sId = line.mid(pos, endpos);
2520
						Utils::WString sId = line.mid(pos, endpos);
2521
						int id = sId;
2521
						int id = sId;
2522
						if ( sId.length() > 4 ) {
2522
						if ( sId.length() > 4 ) {
2523
							id = sId.right(4);
2523
							id = sId.right(4);
2524
							currentGameID = sId.left(sId.length() - 4);
2524
							currentGameID = sId.left(sId.length() - 4);
2525
						}
2525
						}
Line 2528... Line 2528...
2528
							inpage = true;
2528
							inpage = true;
2529
					}
2529
					}
2530
				}
2530
				}
2531
			}
2531
			}
2532
		}
2532
		}
2533
		else if ( line.left(12).Compare("<language id") )
2533
		else if ( line.left(12).Compare(L"<language id") )
2534
		{
2534
		{
2535
			int pos = line.findPos("id=\"");
2535
			int pos = line.findPos(L"id=\"");
2536
			if ( pos != -1 )
2536
			if ( pos != -1 )
2537
			{
2537
			{
2538
				// move past the id=
2538
				// move past the id=
2539
				pos += 4;
2539
				pos += 4;
2540
 
2540
 
2541
				Utils::String s = line.right(-pos);
2541
				Utils::WString s = line.right(-pos);
2542
				Utils::String s2 = line.mid(pos, -1);
2542
				Utils::WString s2 = line.mid(pos, -1);
2543
				int endpos = line.findPos("\"", pos);
2543
				int endpos = line.findPos(L"\"", pos);
2544
				if ( endpos != -1 )
2544
				if ( endpos != -1 )
2545
					lang = line.mid(pos, endpos);
2545
					lang = line.mid(pos, endpos);
2546
			}
2546
			}
2547
		}
2547
		}
2548
	}
2548
	}
Line 2554... Line 2554...
2554
	if ( added )
2554
	if ( added )
2555
	{
2555
	{
2556
		if ( lang == 44 || this->name().empty())
2556
		if ( lang == 44 || this->name().empty())
2557
		{
2557
		{
2558
			this->setName(shipName);
2558
			this->setName(shipName);
2559
			this->setDescription(shipDesc.findReplace("&amp", "&"));
2559
			this->setDescription(shipDesc.findReplace(L"&amp", L"&"));
2560
		}
2560
		}
2561
		this->addText(lang, shipName, shipDesc);
2561
		this->addText(lang, shipName, shipDesc);
2562
		return true;	
2562
		return true;	
2563
	}
2563
	}
2564
 
2564
 
Line 2620... Line 2620...
2620
			this->extractTextures(pVfs);
2620
			this->extractTextures(pVfs);
2621
			break;
2621
			break;
2622
 
2622
 
2623
		case IMPORTSHIP_TEXTS:
2623
		case IMPORTSHIP_TEXTS:
2624
			// extract the text file entries
2624
			// extract the text file entries
2625
			pVfs->extractTexts(this, m_sData.token(";", 7));
2625
			pVfs->extractTexts(this, m_sData.token(L";", 7));
2626
			break;
2626
			break;
2627
 
2627
 
2628
		case IMPORTSHIP_BODIES:
2628
		case IMPORTSHIP_BODIES:
2629
			// extract the bodies entries
2629
			// extract the bodies entries
2630
			if (lModels.empty()) return false;
2630
			if (lModels.empty()) return false;
Line 2713... Line 2713...
2713
 
2713
 
2714
		Utils::WString id = c->sCockpit.token(L";", 19);
2714
		Utils::WString id = c->sCockpit.token(L";", 19);
2715
 
2715
 
2716
		for ( int i = 0; i < 6; i++ )
2716
		for ( int i = 0; i < 6; i++ )
2717
		{
2717
		{
2718
			Utils::String tId = m_sData.token(";", 32 + (i * 2));
2718
			Utils::WString tId = m_sData.token(L";", 32 + (i * 2));
2719
			if ( tId.isNumber() && ((int)tId) == c->iIndex )
2719
			if ( tId.isNumber() && ((int)tId) == c->iIndex )
2720
				m_sData = m_sData.replaceToken(";", 32 + (i * 2), id.toString() + "(" + Utils::String::Number(c->iIndex) + ")");
2720
				m_sData = m_sData.replaceToken(L";", 32 + (i * 2), id + L"(" + Utils::WString::Number(c->iIndex) + L")");
2721
		}
2721
		}
2722
	}
2722
	}
2723
}
2723
}
2724
 
2724
 
2725
Utils::WString CXspFile::formatShipData(const Utils::WStringList &cockpits, int *text, int game)
2725
Utils::WString CXspFile::formatShipData(const Utils::WStringList &cockpits, int *text, int game)
2726
{
2726
{
2727
	Utils::WString data = (game == GAME_X3) ? this->GetX3ShipData() : this->GetTCShipData();
2727
	Utils::WString data = (game == GAME_X3) ? this->getX3ShipData() : this->getTCShipData();
2728
	// do turrets
2728
	// do turrets
2729
	for ( int t = 0; t < 6; t++ )
2729
	for ( int t = 0; t < 6; t++ )
2730
	{
2730
	{
2731
		int oldPos = 0;
2731
		int oldPos = 0;
2732
		Utils::WString turret = data.token(L";", 32 + (t * 2));
2732
		Utils::WString turret = data.token(L";", 32 + (t * 2));
Line 2759... Line 2759...
2759
	// add the ware id
2759
	// add the ware id
2760
	data.removeChar(9);
2760
	data.removeChar(9);
2761
	data.removeEndSpace();
2761
	data.removeEndSpace();
2762
	// remove the end ;
2762
	// remove the end ;
2763
	while ( data.right(1) == L";" ) data.truncate(-1);
2763
	while ( data.right(1) == L";" ) data.truncate(-1);
2764
	data = data.replaceToken(L";", data.countToken(L";"), this->GetShipID());
2764
	data = data.replaceToken(L";", data.countToken(L";"), this->shipID());
2765
	if ( data.right(1) != L";" )
2765
	if ( data.right(1) != L";" )
2766
		data += L";";
2766
		data += L";";
2767
 
2767
 
2768
	return data;
2768
	return data;
2769
}
2769
}