Subversion Repositories spk

Rev

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

Rev 213 Rev 216
Line 56... Line 56...
56
	m_iOrgDesc = 0;
56
	m_iOrgDesc = 0;
57
 
57
 
58
	m_iShipyard = SHIPYARD_NONE;
58
	m_iShipyard = SHIPYARD_NONE;
59
}
59
}
60
 
60
 
61
void CXspFile::AddText ( int id, const Utils::String &name, const Utils::String &desc )
61
void CXspFile::addText(int id, const Utils::WString &name, const Utils::WString &desc)
62
{
62
{
63
	// first check if theres an existing id
63
	// first check if theres an existing id
64
	SText *newtext = NULL;
64
	SText *newtext = NULL;
65
	for ( SText *t = m_lText.First(); t; t = m_lText.Next() )
65
	for ( SText *t = m_lText.First(); t; t = m_lText.Next() )
66
	{
66
	{
Line 95... Line 95...
95
			return;
95
			return;
96
		}
96
		}
97
	}
97
	}
98
}
98
}
99
 
99
 
100
void CXspFile::AddDummy ( const Utils::String &section, const Utils::String &data )
100
void CXspFile::addDummy(const Utils::WString &section, const Utils::WString &data)
101
{
101
{
102
	SDummy *d = new SDummy;
102
	SDummy *d = new SDummy;
103
	d->sData = data;
103
	d->sData = data;
104
	d->sSection = section;
104
	d->sSection = section;
105
 
105
 
106
	if ( d->sData.right(1) != ";" )
106
	if ( d->sData.right(1) != L";" )
107
		d->sData += ";";
107
		d->sData += L";";
108
 
108
 
109
	m_lDummy.push_back ( d );
109
	m_lDummy.push_back ( d );
110
 
110
 
111
	_changed();
111
	_changed();
112
}
112
}
113
 
113
 
114
void CXspFile::AddComponent ( const Utils::String &;section, const Utils::String &section2, const Utils::String &data )
114
void CXspFile::addComponent(const Utils::WString &;section, const Utils::WString &section2, const Utils::WString &data)
115
{
115
{
116
	SComponent *c = new SComponent;
116
	SComponent *c = new SComponent;
117
	c->sData = data;
117
	c->sData = data;
118
	c->sSection = section;
118
	c->sSection = section;
119
	c->sSection2 = section2;
119
	c->sSection2 = section2;
120
 
120
 
121
	if ( c->sData.right(1) != ";" )
121
	if ( c->sData.right(1) != L";" )
122
		c->sData += ";";
122
		c->sData += L";";
123
 
123
 
124
	m_lComponent.push_back ( c );
124
	m_lComponent.push_back ( c );
125
 
125
 
126
	_changed();
126
	_changed();
127
}
127
}
Line 207... Line 207...
207
			values += (long)wNode->Data()->iGame;
207
			values += (long)wNode->Data()->iGame;
208
			values += L":";
208
			values += L":";
209
			values += (long)wNode->Data()->iMask;
209
			values += (long)wNode->Data()->iMask;
210
		}
210
		}
211
		values += L" ";
211
		values += L" ";
212
		values += cockpit->sCockpit.toWString() + L"\n";
212
		values += cockpit->sCockpit + L"\n";
213
	}
213
	}
214
 
214
 
215
	for ( CListNode<SText> *tNode = m_lText.Front(); tNode; tNode = tNode->next() )
215
	for ( CListNode<SText> *tNode = m_lText.Front(); tNode; tNode = tNode->next() )
216
		values += Utils::WString(L"Text: ") + (long)tNode->Data()->iId + L"|" + tNode->Data()->sName.toWString().findReplace(L"|", L"<::PiPe::>") + L"|" + tNode->Data()->sDesc.toWString() + L"\n";
216
		values += Utils::WString(L"Text: ") + (long)tNode->Data()->iId + L"|" + tNode->Data()->sName.findReplace(L"|", L"<::PiPe::>") + L"|" + tNode->Data()->sDesc + L"\n";
217
 
217
 
218
	for ( CListNode<SComponent> *cNode = m_lComponent.Front(); cNode; cNode = cNode->next() )
218
	for ( CListNode<SComponent> *cNode = m_lComponent.Front(); cNode; cNode = cNode->next() )
219
		values += L"Component: " + cNode->Data()->sData.toWString().findReplace(L"|", L"<::PiPe::>") + L"|" + cNode->Data()->sSection.toWString().findReplace(L"|", L"<::PiPe::>") + L";|" + cNode->Data()->sSection2.toWString() + L"\n";
219
		values += L"Component: " + cNode->Data()->sData.findReplace(L"|", L"<::PiPe::>") + L"|" + cNode->Data()->sSection.findReplace(L"|", L";<::PiPe::>") + L"|" + cNode->Data()->sSection2 + L"\n";
220
 
220
 
221
	for ( CListNode<SDummy> *dNode = m_lDummy.Front(); dNode; dNode = dNode->next() )
221
	for ( CListNode<SDummy> *dNode = m_lDummy.Front(); dNode; dNode = dNode->next() )
222
		values += L"Dummy: " + dNode->Data()->sData.toWString().findReplace(L"|", L"<::PiPe::>") + L"|" + dNode->Data()->sSection.toWString() + L"\n";
222
		values += L"Dummy: " + dNode->Data()->sData.findReplace(L"|", L"<::PiPe::>") + L"|" + dNode->Data()->sSection + L"\n";
223
 
223
 
224
	for ( CListNode<SWeaponMask> *wNode = m_lWeaponMasks.Front(); wNode; wNode = wNode->next() )
224
	for ( CListNode<SWeaponMask> *wNode = m_lWeaponMasks.Front(); wNode; wNode = wNode->next() )
225
		values += Utils::WString(L"WeaponMask: ") + (long)wNode->Data()->iGame + L" " + (long)wNode->Data()->iMask + L"\n";
225
		values += Utils::WString(L"WeaponMask: ") + (long)wNode->Data()->iGame + L" " + (long)wNode->Data()->iMask + L"\n";
226
	for ( CListNode<SWeaponMask> *mNode = m_lMissileMasks.Front(); mNode; mNode = mNode->next() )
226
	for ( CListNode<SWeaponMask> *mNode = m_lMissileMasks.Front(); mNode; mNode = mNode->next() )
227
		values += Utils::WString(L"MissileMask: ") + (long)mNode->Data()->iGame + L" " + (long)mNode->Data()->iMask + L"\n";
227
		values += Utils::WString(L"MissileMask: ") + (long)mNode->Data()->iGame + L" " + (long)mNode->Data()->iMask + L"\n";
228
	for (auto itr = _lCutData.begin(); itr != _lCutData.end(); itr++)
228
	for (auto itr = _lCutData.begin(); itr != _lCutData.end(); itr++)
229
		values += L"CutData: " + (*itr)->str.toWString() + L"\n";
229
		values += L"CutData: " + (*itr)->str + L"\n";
230
	for (auto itr = _lBodies.begin(); itr != _lBodies.end(); itr++)
230
	for (auto itr = _lBodies.begin(); itr != _lBodies.end(); itr++)
231
		values += L"Bodies: " + (*itr)->str.toWString() + L"\n";
231
		values += L"Bodies: " + (*itr)->str + L"\n";
232
	for (auto itr = _lAnimations.begin(); itr != _lAnimations.end(); itr++)
232
	for (auto itr = _lAnimations.begin(); itr != _lAnimations.end(); itr++)
233
		values += L"Animations: " + (*itr)->str.toWString() + L"\n";
233
		values += L"Animations: " + (*itr)->str + L"\n";
234
 
234
 
235
	return values;
235
	return values;
236
}
236
}
237
 
237
 
238
bool CXspFile::parseValueLine(const Utils::WString &sLine)
238
bool CXspFile::parseValueLine(const Utils::WString &sLine)
Line 251... Line 251...
251
	else if ( first.Compare(L"OrgDesc") || first.Compare(L"OriginalDesc") )
251
	else if ( first.Compare(L"OrgDesc") || first.Compare(L"OriginalDesc") )
252
		m_iOrgDesc = rest;
252
		m_iOrgDesc = rest;
253
	else if ( first.Compare(L"Shipyard") )
253
	else if ( first.Compare(L"Shipyard") )
254
		m_iShipyard = rest;
254
		m_iShipyard = rest;
255
	else if ( first.Compare(L"CutData") )
255
	else if ( first.Compare(L"CutData") )
256
		this->addCutData(rest.toString());
256
		this->addCutData(rest);
257
	else if ( first.Compare(L"Bodies") )
257
	else if ( first.Compare(L"Bodies") )
258
		this->addBodies(rest.toString());
258
		this->addBodies(rest);
259
	else if ( first.Compare(L"Animations") )
259
	else if ( first.Compare(L"Animations") )
260
		this->addAnimation(rest.toString());
260
		this->addAnimation(rest);
261
	else if ( first.Compare(L"Cockpit") )
261
	else if ( first.Compare(L"Cockpit") )
262
		this->AddCockpit(rest.toString(), 0);
262
		this->addCockpit(rest, 0);
263
	else if ( first.Compare(L"CockpitNew") )
263
	else if ( first.Compare(L"CockpitNew") )
264
	{
264
	{
265
		Utils::WString cockpit = rest.tokens(L" ", 2);
265
		Utils::WString cockpit = rest.tokens(L" ", 2);
266
		Utils::WString sMasks = rest.token(L" ", 1);
266
		Utils::WString sMasks = rest.token(L" ", 1);
267
		this->AddCockpit(cockpit.toString(), 0, -1);
267
		this->addCockpit(cockpit, 0, -1);
268
		int num = sMasks.token(L":", 1);
268
		int num = sMasks.token(L":", 1);
269
		for ( int i = 0; i < num; i++ )
269
		for ( int i = 0; i < num; i++ )
270
		{
270
		{
271
			int mask = sMasks.token(L":", ((i + 1) * 2) + 1);
271
			int mask = sMasks.token(L":", ((i + 1) * 2) + 1);
272
			int game = sMasks.token(L":", ((i + 1) * 2));
272
			int game = sMasks.token(L":", ((i + 1) * 2));
273
			this->AddCockpit(cockpit.toString(), game, mask);
273
			this->addCockpit(cockpit, game, mask);
274
		}
274
		}
275
	}
275
	}
276
	else if ( first == L"Web" )	this->setWebSite(rest);
276
	else if ( first == L"Web" )	this->setWebSite(rest);
277
	else if ( first.Compare(L"WeaponMask") )
277
	else if ( first.Compare(L"WeaponMask") )
278
		this->AddWeaponMask(rest.token(L" ", 1), rest.token(L" ", 2));
278
		this->AddWeaponMask(rest.token(L" ", 1), rest.token(L" ", 2));
Line 280... Line 280...
280
		this->AddMissileMask(rest.token(L" ", 1), rest.token(L" ", 2));
280
		this->AddMissileMask(rest.token(L" ", 1), rest.token(L" ", 2));
281
	else if ( first == L"Text" )
281
	else if ( first == L"Text" )
282
	{
282
	{
283
		SText *text = new SText;
283
		SText *text = new SText;
284
		text->iId = rest.token(L"|", 1);
284
		text->iId = rest.token(L"|", 1);
285
		text->sName = rest.token(L"|", 2).toString();
285
		text->sName = rest.token(L"|", 2);
286
		text->sName = text->sName.findReplace(L"<::PiPe::>", L"|");
286
		text->sName = text->sName.findReplace(L"<::PiPe::>", L"|");
287
		text->sDesc = rest.tokens(L"|", 3).toString();
287
		text->sDesc = rest.tokens(L"|", 3);
288
		m_lText.push_back ( text );
288
		m_lText.push_back ( text );
289
	}
289
	}
290
	else if ( first == L"Component" )
290
	else if ( first == L"Component" )
291
	{
291
	{
292
		SComponent *c = new SComponent;
292
		SComponent *c = new SComponent;
293
		c->sData = rest.token(L"|", 1).toString();
293
		c->sData = rest.token(L"|", 1);
294
		c->sData = c->sData.findReplace (L"<::PiPe::>", L"|");
294
		c->sData = c->sData.findReplace (L"<::PiPe::>", L"|");
295
		c->sSection = rest.token(L"|", 2).toString();
295
		c->sSection = rest.token(L"|", 2);
296
		c->sSection = c->sSection.findReplace (L"<::PiPe::>", L"|");
296
		c->sSection = c->sSection.findReplace (L"<::PiPe::>", L"|");
297
		c->sSection2 = rest.tokens(L"|", 3).toString();
297
		c->sSection2 = rest.tokens(L"|", 3);
298
		m_lComponent.push_back ( c );
298
		m_lComponent.push_back ( c );
299
	}
299
	}
300
	else if ( first == L"Dummy" )
300
	else if ( first == L"Dummy" )
301
	{
301
	{
302
		SDummy *d = new SDummy;
302
		SDummy *d = new SDummy;
303
		d->sData = rest.token(L"|", 1).toString();
303
		d->sData = rest.token(L"|", 1);
304
		d->sData = d->sData.findReplace (L"<::PiPe::>", L"|");
304
		d->sData = d->sData.findReplace (L"<::PiPe::>", L"|");
305
		d->sSection = rest.tokens(L"|", 2).toString();
305
		d->sSection = rest.tokens(L"|", 2);
306
		m_lDummy.push_back ( d );
306
		m_lDummy.push_back ( d );
307
	}
307
	}
308
	else if ( first == L"Comment" )	this->setDescription(rest.findReplace(L"<newline>", L"<br>"));
308
	else if ( first == L"Comment" )	this->setDescription(rest.findReplace(L"<newline>", L"<br>"));
309
	else
309
	else
310
		return CBaseFile::parseValueLine(sLine);
310
		return CBaseFile::parseValueLine(sLine);
Line 319... Line 319...
319
	{
319
	{
320
		for ( SText *text = m_lText.First(); text; text = m_lText.Next() )
320
		for ( SText *text = m_lText.First(); text; text = m_lText.Next() )
321
		{
321
		{
322
			if ( text->iId == lang )
322
			if ( text->iId == lang )
323
			{
323
			{
324
				name = text->sName.toWString();
324
				name = text->sName;
325
				break;
325
				break;
326
			}
326
			}
327
		}
327
		}
328
	}
328
	}
329
 
329
 
Line 625... Line 625...
625
			newFile->ReadFromData((char *)(compr + pos), rest.word(2));
625
			newFile->ReadFromData((char *)(compr + pos), rest.word(2));
626
 
626
 
627
			start += (newFile->GetDataSize() + 1);
627
			start += (newFile->GetDataSize() + 1);
628
		}
628
		}
629
		else if ( first.Compare("Text") )
629
		else if ( first.Compare("Text") )
630
			this->AddText(rest.token(":", 1), rest.token(":", 2), rest.tokens(":", 3));
630
			this->addText(rest.token(":", 1), rest.token(":", 2), rest.tokens(":", 3));
631
		else if ( first.Compare("Component") )
631
		else if ( first.Compare("Component") )
632
			this->AddComponent(rest.token(";", 1), rest.token(";", 2), rest.tokens(";", 3));
632
			this->addComponent(rest.token(";", 1), rest.token(";", 2), rest.tokens(";", 3));
633
		else if ( first.Compare("Dummy") )
633
		else if ( first.Compare("Dummy") )
634
		{
634
		{
635
			SDummy *d = new SDummy;
635
			SDummy *d = new SDummy;
636
			d->sData = rest.tokens(";", 2);
636
			d->sData = rest.tokens(";", 2).toWString();
637
			d->sSection = rest.token(";", 1);
637
			d->sSection = rest.token(";", 1).toWString();
638
			m_lDummy.push_back ( d );
638
			m_lDummy.push_back ( d );
639
		}
639
		}
640
		else if ( !this->parseValueLine(line) )
640
		else if ( !this->parseValueLine(line) )
641
		{
641
		{
642
		//	printf ( "Command: %s, Rest: %s\n", first.c_str(), rest.c_str());
642
		//	printf ( "Command: %s, Rest: %s\n", first.c_str(), rest.c_str());
Line 656... Line 656...
656
}
656
}
657
 
657
 
658
 
658
 
659
int GetMaxShipyards() { return (int)SHIPYARD_MAX; }
659
int GetMaxShipyards() { return (int)SHIPYARD_MAX; }
660
 
660
 
661
Utils::String GetShipyardName (int s)
661
Utils::WString GetShipyardName (int s)
662
{
662
{
663
	switch (s)
663
	switch (s)
664
	{
664
	{
665
		case SHIPYARD_ARGON:
665
		case SHIPYARD_ARGON:
666
			return "Argon";
666
			return L"Argon";
667
		case SHIPYARD_BORON:
667
		case SHIPYARD_BORON:
668
			return "Boron";
668
			return L"Boron";
669
		case SHIPYARD_PARANID:
669
		case SHIPYARD_PARANID:
670
			return "Paranid";
670
			return L"Paranid";
671
		case SHIPYARD_SPLIT:
671
		case SHIPYARD_SPLIT:
672
			return "Split";
672
			return L"Split";
673
		case SHIPYARD_TELADI:
673
		case SHIPYARD_TELADI:
674
			return "Teladi";
674
			return L"Teladi";
675
		case SHIPYARD_PIRATES:
675
		case SHIPYARD_PIRATES:
676
			return "Pirates";
676
			return L"Pirates";
677
		case SHIPYARD_FRIEND:
677
		case SHIPYARD_FRIEND:
678
			return "Friendly";
678
			return L"Friendly";
679
		case SHIPYARD_XENON:
679
		case SHIPYARD_XENON:
680
			return "Xenon";
680
			return L"Xenon";
681
		case SHIPYARD_TERRAN:
681
		case SHIPYARD_TERRAN:
682
			return "Terran";
682
			return L"Terran";
683
	}
683
	}
684
 
684
 
685
	return "Unknown";
685
	return L"Unknown";
686
}
686
}
687
 
687
 
688
bool CXspFile::writeHeader(CFileIO &file, int valueheader, int valueComprLen) const
688
bool CXspFile::writeHeader(CFileIO &file, int valueheader, int valueComprLen) const
689
{
689
{
690
	return file.write("XSPCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen);
690
	return file.write("XSPCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen);
Line 793... Line 793...
793
	{
793
	{
794
		list->pushBack(L"# Shipyards, Set which shipyards to add ships for sale to");
794
		list->pushBack(L"# Shipyards, Set which shipyards to add ships for sale to");
795
		for ( int i = SHIPYARD_ARGON; i <= SHIPYARD_MAX; i *= 2 )
795
		for ( int i = SHIPYARD_ARGON; i <= SHIPYARD_MAX; i *= 2 )
796
		{
796
		{
797
			if ( this->IsShipyard(i) )
797
			if ( this->IsShipyard(i) )
798
				list->pushBack(L"Shipyard: " + GetShipyardName(i).toWString());
798
				list->pushBack(L"Shipyard: " + GetShipyardName(i));
799
		}
799
		}
800
		list->pushBack(L"");
800
		list->pushBack(L"");
801
	}
801
	}
802
 
802
 
803
	if ( m_iOrgDesc > 0 )
803
	if ( m_iOrgDesc > 0 )
Line 828... Line 828...
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>");
832
		for(CListNode<SText> *node = m_lText.Front(); node; node = node->next()) {
832
		for(CListNode<SText> *node = m_lText.Front(); node; node = node->next()) {
833
			list->pushBack(Utils::WString(L"ShipText: ") + (long)node->Data()->iId + L" " + node->Data()->sName.toWString() + L"|" + node-&gt;Data()->sDesc.toWString());
833
			list->pushBack(Utils::WString(L"ShipText: ") + (long)node->Data()->iId + L" " + node->Data()->sName + L"|" + node-&gt;Data()->sDesc);
834
		}
834
		}
835
 
835
 
836
		list->pushBack(L"");
836
		list->pushBack(L"");
837
	}
837
	}
838
 
838
 
Line 855... Line 855...
855
	}
855
	}
856
 
856
 
857
	if ( this->m_lComponent.size() ) {
857
	if ( this->m_lComponent.size() ) {
858
		list->pushBack(L"# Ship Components, each component used in the ships scene: <SECTION> <MODELENTRY> <VALUES>");
858
		list->pushBack(L"# Ship Components, each component used in the ships scene: <SECTION> <MODELENTRY> <VALUES>");
859
		for(CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next()) {
859
		for(CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next()) {
860
			list->pushBack(Utils::WString(L"Component: ") + node->Data()->sSection.toWString() + L" " + node->Data()->sSection2.toWString() + L" " + node-&gt;Data()->sData.toWString());
860
			list->pushBack(Utils::WString(L"Component: ") + node->Data()->sSection + L" " + node->Data()->sSection2 + L&quot; " + node->;Data()->sData);
861
		}
861
		}
862
		list->pushBack(L"");
862
		list->pushBack(L"");
863
	}
863
	}
864
 
864
 
865
	if ( this->m_lDummy.size() ) {
865
	if ( this->m_lDummy.size() ) {
866
		list->pushBack(L"# Ship Dummies, each dummy entry used in the ships scene: <SECTION> <VALUE>");
866
		list->pushBack(L"# Ship Dummies, each dummy entry used in the ships scene: <SECTION> <VALUE>");
867
		for(CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next()) {
867
		for(CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next()) {
868
			list->pushBack(L"Dummy: " + node->Data()->sSection.toWString() + L"; " + node-&gt;Data()->sData.toWString());
868
			list->pushBack(L"Dummy: " + node->Data()->sSection + L"; " + node-&gt;Data()->sData);
869
		}
869
		}
870
		list->pushBack(L"");
870
		list->pushBack(L"");
871
	}
871
	}
872
 
872
 
873
	if ( this->m_lCockpit.size() ) {
873
	if ( this->m_lCockpit.size() ) {
874
		list->pushBack(L"# Cockpit entries, each cockpit value with thier weapons mask");
874
		list->pushBack(L"# Cockpit entries, each cockpit value with thier weapons mask");
875
		for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
875
		for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
876
			list->pushBack(L"Cockpit: " + node->Data()->sCockpit.toWString().token(L";", 19) + L" " + node-&gt;Data()->sCockpit.toWString());
876
			list->pushBack(L"Cockpit: " + node->Data()->sCockpit.token(L";", 19) + L" " + node-&gt;Data()->sCockpit);
877
			for(SWeaponMask *mask = node->Data()->lWeaponMask.First(); mask; mask = node->Data()->lWeaponMask.Next()) {
877
			for(SWeaponMask *mask = node->Data()->lWeaponMask.First(); mask; mask = node->Data()->lWeaponMask.Next()) {
878
				list->pushBack(L"CockpitWeapon: " + node->Data()->sCockpit.toWString().token(L";", 19) + L" " + (long)mask->iGame + L" " + (long)mask->iMask);
878
				list->pushBack(L"CockpitWeapon: " + node->Data()->sCockpit.token(L";", 19) + L" " + (long)mask->iGame + L" " + (long)mask->iMask);
879
			}
879
			}
880
		}
880
		}
881
 
881
 
882
		list->pushBack(L"");
882
		list->pushBack(L"");
883
	}
883
	}
884
 
884
 
885
	if (!this->_lCutData.empty())
885
	if (!this->_lCutData.empty())
886
	{
886
	{
887
		list->pushBack(L"# Ship Cut Data");
887
		list->pushBack(L"# Ship Cut Data");
888
		for(auto itr = _lCutData.begin(); itr != _lCutData.end(); itr++)
888
		for(auto itr = _lCutData.begin(); itr != _lCutData.end(); itr++)
889
			list->pushBack(L"CutData: " + (*itr)->str.toWString());
889
			list->pushBack(L"CutData: " + (*itr)->str);
890
		list->pushBack(L"");
890
		list->pushBack(L"");
891
	}
891
	}
892
 
892
 
893
	if (!this->_lBodies.empty())
893
	if (!this->_lBodies.empty())
894
	{
894
	{
895
		list->pushBack(L"# Ship Bodies");
895
		list->pushBack(L"# Ship Bodies");
896
		for(auto itr = _lBodies.begin(); itr != _lBodies.end(); itr++)
896
		for(auto itr = _lBodies.begin(); itr != _lBodies.end(); itr++)
897
			list->pushBack(L"Bodies: " + (*itr)->str.toWString());
897
			list->pushBack(L"Bodies: " + (*itr)->str);
898
		list->pushBack(L"");
898
		list->pushBack(L"");
899
	}
899
	}
900
 
900
 
901
	if (!this->_lAnimations.empty())
901
	if (!this->_lAnimations.empty())
902
	{
902
	{
903
		list->pushBack(L"# Ship Animations");
903
		list->pushBack(L"# Ship Animations");
904
		for (auto itr = _lAnimations.begin(); itr != _lAnimations.end(); itr++)
904
		for (auto itr = _lAnimations.begin(); itr != _lAnimations.end(); itr++)
905
			list->pushBack(L"Animation: " + (*itr)->str.toWString());	
905
			list->pushBack(L"Animation: " + (*itr)->str);	
906
		list->pushBack(L"");
906
		list->pushBack(L"");
907
	}
907
	}
908
 
908
 
909
	if ( !datafile )
909
	if ( !datafile )
910
	{
910
	{
Line 913... Line 913...
913
	}
913
	}
914
 
914
 
915
	return true;
915
	return true;
916
}
916
}
917
 
917
 
918
void CXspFile::_addSection(Utils::CList<STypesSection> &list, const Utils::String &section, const Utils::String &data)
918
void CXspFile::_addSection(Utils::CList<STypesSection> &list, const Utils::WString &section, const Utils::WString &data)
919
{
919
{
920
	STypesSection *currentSubSection = NULL;
920
	STypesSection *currentSubSection = NULL;
921
	for(Utils::CList<STypesSection>::iterator itr = list.begin(); itr != list.end(); itr++) {
921
	for(Utils::CList<STypesSection>::iterator itr = list.begin(); itr != list.end(); itr++) {
922
		if ( (*itr)->sSection.Compare(section) ) {
922
		if ( (*itr)->sSection.Compare(section) ) {
923
			currentSubSection = *itr;
923
			currentSubSection = *itr;
Line 929... Line 929...
929
		currentSubSection = new STypesSection;
929
		currentSubSection = new STypesSection;
930
		currentSubSection->sSection = section;
930
		currentSubSection->sSection = section;
931
		list.push_back(currentSubSection);
931
		list.push_back(currentSubSection);
932
	}
932
	}
933
 
933
 
934
	currentSubSection->lEntries.pushBack(data, "");
934
	currentSubSection->lEntries.pushBack(data, L"");
935
}
935
}
936
 
936
 
937
void CXspFile::_addDataSection(Utils::CStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst)
937
void CXspFile::_addDataSection(Utils::WStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst)
938
{
938
{
939
	for(auto itr = list.begin(); itr != list.end(); itr++)
939
	for(auto itr = list.begin(); itr != list.end(); itr++)
940
	{
940
	{
941
		if (bUseFirst) {
941
		if (bUseFirst) {
942
			Utils::String data = (*itr)->str;
942
			Utils::WString data = (*itr)->str;
943
			_addSection(sectionList, data.token(";", 1), data.tokens(";", 2));
943
			_addSection(sectionList, data.token(L";", 1), data.tokens(L";", 2));
944
		}
944
		}
945
		else {
945
		else {
946
			_addSection(sectionList, (*itr)->str, (*itr)->data);
946
			_addSection(sectionList, (*itr)->str, (*itr)->data);
947
		}
947
		}
948
	}
948
	}
Line 990... Line 990...
990
}
990
}
991
 
991
 
992
 
992
 
993
void CXspFile::addGeneratedFiles(HZIP &hz)
993
void CXspFile::addGeneratedFiles(HZIP &hz)
994
{
994
{
995
	TCHAR buf[5000];
-
 
996
 
-
 
997
	CFileIO tmpFile(CPackages::tempDirectory() + "/temp.tmp");
995
	CFileIO tmpFile(CPackages::tempDirectory() + L"/temp.tmp");
998
 
996
 
999
	for(int i = 0; i < 5; i++) {
997
	for(int i = 0; i < 5; i++) {
1000
		Utils::String type;
998
		Utils::WString type;
1001
		Utils::String data;
999
		Utils::WString data;
1002
		switch(i) {
1000
		switch(i) {
1003
			case 0:
1001
			case 0:
1004
				data = "50;1\r\n" + this->m_sData;
1002
				data = L"50;1\r\n" + this->m_sData.toWString();
1005
				type = "TShips";
1003
				type = L"TShips";
1006
				break;
1004
				break;
1007
			case 1:
1005
			case 1:
1008
				if ( !this->m_lCockpit.empty() ) {
1006
				if ( !this->m_lCockpit.empty() ) {
1009
					data = Utils::String("51;") + (long)this->m_lCockpit.size() + ";\r\n";
1007
					data = Utils::WString("51;") + (long)this->m_lCockpit.size() + L";\r\n";
1010
					for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
1008
					for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
1011
						data += node->Data()->sCockpit + "\r\n";
1009
						data += node->Data()->sCockpit + L"\r\n";
1012
					}
1010
					}
1013
					type = "TCockpits";
1011
					type = L"TCockpits";
1014
				}
1012
				}
1015
				break;
1013
				break;
1016
			case 2:
1014
			case 2:
1017
				if ( !this->m_lComponent.empty() ) {
1015
				if ( !this->m_lComponent.empty() ) {
1018
					type = "Components";
1016
					type = L"Components";
1019
					CLinkList<SComponentEntry> componentList;
1017
					CLinkList<SComponentEntry> componentList;
1020
					this->addComponentsToList(componentList);
1018
					this->addComponentsToList(componentList);
1021
					for(CListNode<SComponentEntry> *node = componentList.Front(); node; node = node->next()) {
1019
					for(CListNode<SComponentEntry> *node = componentList.Front(); node; node = node->next()) {
1022
						data += node->Data()->sSection + "; " + (long)node->Data()->lEntries.size() + ";\r\n";
1020
						data += node->Data()->sSection + L"; " + (long)node->Data()->lEntries.size() + L";\r\n";
1023
						data += CXspFile::TypesListToString(node->Data()->lEntries, true);
1021
						data += CXspFile::TypesListToString(node->Data()->lEntries, true);
1024
					}
1022
					}
1025
				}
1023
				}
1026
				break;
1024
				break;
1027
			case 3:
1025
			case 3:
1028
				GENERATESECTION("Dummies", SDummy, this->m_lDummy);
1026
				GENERATESECTION(L"Dummies", SDummy, this->m_lDummy);
1029
				break;
1027
				break;
1030
			case 4:
1028
			case 4:
1031
				GENERATESTRINGSECTION("Bodies", this->_lBodies, true);
1029
				GENERATESTRINGSECTION(L"Bodies", this->_lBodies, true);
1032
				break;
1030
				break;
1033
		}
1031
		}
1034
 
1032
 
1035
		if ( type.empty() ) continue;
1033
		if ( type.empty() ) continue;
1036
 
1034
 
1037
		Utils::String fname = "GENERATED/types/" + type + ".txt";
1035
		Utils::WString fname = L"GENERATED/types/" + type + L".txt";
1038
		
1036
		
1039
		Utils::String fileData = "// Exported " + type + " file, Generated by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2) + "\r\n" + data;
1037
		Utils::WString fileData = L"// Exported " + type + L" file, Generated by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2) + L"\r\n" + data;
-
 
1038
		/*
1040
		if ( tmpFile.startWrite() ) {
1039
		if ( tmpFile.startWrite() ) {
1041
			tmpFile.write(fileData.c_str(), fileData.length());
1040
			tmpFile.write(fileData.c_str(), fileData.length());
1042
			tmpFile.close();
1041
			tmpFile.close();
1043
		}
1042
		}
1044
 
1043
 
1045
		// tships files
1044
		// tships files
1046
		wsprintf(buf, L"%hs", fname.c_str());
1045
		wsprintf(buf, L"%hs", fname.c_str());
1047
			
-
 
1048
		if ( tmpFile.startRead() ) {
1046
		if ( tmpFile.startRead() ) {
1049
			size_t dataSize = 0;
1047
			*/
1050
			unsigned char *data = tmpFile.readAll(&dataSize);
1048
		ZipAdd(hz, fname.c_str(), (void *)fileData.c_str(), fileData.length() * sizeof(wchar_t));
1051
			ZipAdd(hz, buf, data, dataSize);
-
 
1052
		}
1049
		//}
1053
	}
1050
	}
1054
}
1051
}
1055
 
1052
 
1056
bool CXspFile::loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
1053
bool CXspFile::loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
1057
{
1054
{
Line 1078... Line 1075...
1078
	else if ( sFirst.Compare(L"ExistingShip") )
1075
	else if ( sFirst.Compare(L"ExistingShip") )
1079
		m_bExistingShip = true;
1076
		m_bExistingShip = true;
1080
	else if ( sFirst.Compare(L"ShipID") )
1077
	else if ( sFirst.Compare(L"ShipID") )
1081
		m_sID = sRest.toString();
1078
		m_sID = sRest.toString();
1082
	else if ( sFirst.Compare(L"ShipText") )
1079
	else if ( sFirst.Compare(L"ShipText") )
1083
		this->AddText(sRest.token(L" ", 1).toLong(), sRest.tokens(L" ", 2).token(L"|", 1).toString(), sRest.tokens(L" ", 2).tokens(L"|", 2).toString());
1080
		this->addText(sRest.token(L" ", 1).toLong(), sRest.tokens(L" ", 2).token(L"|", 1), sRest.tokens(L" ", 2).tokens(L"|", 2));
1084
	else if ( sFirst.Compare(L"Component") )
1081
	else if ( sFirst.Compare(L"Component") )
1085
		this->AddComponent(sRest.token(L" ", 1).toString(), sRest.token(L" ", 2).toString(), sRest.tokens(L" ", 3).toString());
1082
		this->addComponent(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.tokens(L" ", 3));
1086
	else if ( sFirst.Compare(L"Cockpit") )
1083
	else if ( sFirst.Compare(L"Cockpit") )
1087
		this->AddCockpit(sRest.tokens(L" ", 2).replaceToken(L";", 19, sRest.token(L" ", 1)).toString(), 0);
1084
		this->addCockpit(sRest.tokens(L" ", 2).replaceToken(L";", 19, sRest.token(L" ", 1)), 0);
1088
	else if ( sFirst.Compare(L"CockpitWeapon") )
1085
	else if ( sFirst.Compare(L"CockpitWeapon") )
1089
		this->AddCockpitWeapon(sRest.token(L" ", 1).toString(), sRest.token(L" ", 2), sRest.token(L" ", 3));
1086
		this->addCockpitWeapon(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.token(L" ", 3));
1090
	else if ( sFirst.Compare(L"WeaponMask") )
1087
	else if ( sFirst.Compare(L"WeaponMask") )
1091
		this->AddWeaponMask(sRest.token(L" ", 1), sRest.token(L" ", 2));
1088
		this->AddWeaponMask(sRest.token(L" ", 1), sRest.token(L" ", 2));
1092
	else if ( sFirst.Compare(L"MissileMask") )
1089
	else if ( sFirst.Compare(L"MissileMask") )
1093
		this->AddMissileMask(sRest.token(L" ", 1), sRest.token(L" ", 2));
1090
		this->AddMissileMask(sRest.token(L" ", 1), sRest.token(L" ", 2));
1094
	else if ( sFirst.Compare(L"Dummy") )
1091
	else if ( sFirst.Compare(L"Dummy") )
1095
		this->AddDummy(sRest.token(L" ", 1).toString(), sRest.token(L" ", 2).toString());
1092
		this->addDummy(sRest.token(L" ", 1), sRest.token(L" ", 2));
1096
	else if ( sFirst.Compare(L"CutData") )
1093
	else if ( sFirst.Compare(L"CutData") )
1097
		this->addCutData(sRest.toString());
1094
		this->addCutData(sRest);
1098
	else if ( sFirst.Compare(L"Animation") )
1095
	else if ( sFirst.Compare(L"Animation") )
1099
		this->addAnimation(sRest.toString());
1096
		this->addAnimation(sRest);
1100
	else if ( sFirst.Compare(L"Bodies") )
1097
	else if ( sFirst.Compare(L"Bodies") )
1101
		this->addBodies(sRest.toString());
1098
		this->addBodies(sRest);
1102
	else if ( !CBaseFile::loadPackageData(sFirst, sRest, sMainGame, otherGames, gameAddons, progress) )
1099
	else if ( !CBaseFile::loadPackageData(sFirst, sRest, sMainGame, otherGames, gameAddons, progress) )
1103
	{
1100
	{
1104
		return false;
1101
		return false;
1105
	}
1102
	}
1106
 
1103
 
1107
	return true;
1104
	return true;
1108
}
1105
}
Line 1149... Line 1146...
1149
		data = data.replaceToken(";", TSHIPPOS_CLASS, CShipData::ConvertShipClass((long)sClass).toString());
1146
		data = data.replaceToken(";", TSHIPPOS_CLASS, CShipData::ConvertShipClass((long)sClass).toString());
1150
 
1147
 
1151
	return data;
1148
	return data;
1152
}
1149
}
1153
 
1150
 
1154
bool CXspFile::removeCockpit(const Utils::String &sCockpitId)
1151
bool CXspFile::removeCockpit(const Utils::WString &sCockpitId)
1155
{
1152
{
1156
	Utils::String cockpitid = sCockpitId;
1153
	Utils::WString cockpitid = sCockpitId;
1157
	// if its a whole line, just get the end
1154
	// if its a whole line, just get the end
1158
	if ( cockpitid.isin(";") )
1155
	if ( cockpitid.contains(L";") )
1159
	{
1156
	{
1160
		cockpitid = cockpitid.tokens(";", -2);
1157
		cockpitid = cockpitid.tokens(L";", -2);
1161
		while ( cockpitid.right(1) == ";" )
1158
		while ( cockpitid.right(1) == L";" )
1162
			cockpitid.truncate(-1);
1159
			cockpitid.truncate(-1);
1163
	}
1160
	}
1164
 
1161
 
1165
	bool ret = false;
1162
	bool ret = false;
1166
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1163
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1167
	{
1164
	{
1168
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1165
		Utils::WString id = node->Data()->sCockpit.token(L";", 19);
1169
		if ( id.Compare(cockpitid) )
1166
		if ( id.Compare(cockpitid) )
1170
		{
1167
		{
1171
			node->DeleteData();
1168
			node->DeleteData();
1172
			ret = true;
1169
			ret = true;
1173
			break;
1170
			break;
Line 1177... Line 1174...
1177
	m_lCockpit.RemoveEmpty();
1174
	m_lCockpit.RemoveEmpty();
1178
 
1175
 
1179
	return ret;
1176
	return ret;
1180
}
1177
}
1181
 
1178
 
1182
bool CXspFile::removeComponent(const Utils::String &section1, const Utils::String &section2, const Utils::String &data)
1179
bool CXspFile::removeComponent(const Utils::WString &section1, const Utils::WString &section2, const Utils::WString &data)
1183
{
1180
{
1184
	bool ret = false;
1181
	bool ret = false;
1185
	for ( CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next() )
1182
	for ( CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next() )
1186
	{
1183
	{
1187
		if ( node->Data()->sSection.Compare(section1) && node->Data()->sSection2.Compare(section2) && node->Data()->sData.Compare(data) )
1184
		if ( node->Data()->sSection.Compare(section1) && node->Data()->sSection2.Compare(section2) && node->Data()->sData.Compare(data) )
1188
		{
1185
		{
1189
			ret = true;
1186
			ret = true;
1190
			node->DeleteData();
1187
			node->DeleteData();
1191
			break;
1188
			break;
1192
		}
1189
		}
1193
	}
1190
	}
1194
	m_lComponent.RemoveEmpty();
1191
	m_lComponent.RemoveEmpty();
1195
	return ret;
1192
	return ret;
1196
}
1193
}
1197
 
1194
 
1198
bool CXspFile::removeDummy(const Utils::String &section, const Utils::String &data)
1195
bool CXspFile::removeDummy(const Utils::WString &section, const Utils::WString &data)
1199
{
1196
{
1200
	bool ret = false;
1197
	bool ret = false;
1201
	for ( CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next() )
1198
	for ( CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next() )
1202
	{
1199
	{
1203
		if ( node->Data()->sSection.Compare(section) && node->Data()->sData.Compare(data) )
1200
		if ( node->Data()->sSection.Compare(section) && node->Data()->sData.Compare(data) )
Line 1214... Line 1211...
1214
 
1211
 
1215
Utils::String CXspFile::GetCockpitData(const Utils::String &cid)
1212
Utils::String CXspFile::GetCockpitData(const Utils::String &cid)
1216
{
1213
{
1217
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1214
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1218
	{
1215
	{
1219
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1216
		Utils::WString id = node->Data()->sCockpit.token(L";", 19);
1220
		if ( id.Compare(cid) )
1217
		if ( id.Compare(cid) )
1221
			return node->Data()->sCockpit;
1218
			return node->Data()->sCockpit.toString();
1222
	}
1219
	}
1223
 
1220
 
1224
	return "";
1221
	return "";
1225
}
1222
}
1226
 
1223
 
1227
SCockpit *CXspFile::FindCockpit(const Utils::String &cid)
1224
SCockpit *CXspFile::FindCockpit(const Utils::String &cid)
1228
{
1225
{
1229
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1226
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1230
	{
1227
	{
1231
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1228
		Utils::WString id = node->Data()->sCockpit.token(L";", 19);
1232
		if ( id.Compare(cid) )
1229
		if ( id.Compare(cid) )
1233
			return node->Data();
1230
			return node->Data();
1234
	}
1231
	}
1235
 
1232
 
1236
	return NULL;
1233
	return NULL;
Line 1238... Line 1235...
1238
 
1235
 
1239
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &cockpit)
1236
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &cockpit)
1240
{
1237
{
1241
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1238
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1242
	{
1239
	{
1243
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1240
		Utils::WString id = node->Data()->sCockpit.token(L";", 19);
1244
		if ( id.Compare(cid) )
1241
		if ( id.Compare(cid) )
1245
		{
1242
		{
1246
			node->Data()->sCockpit = cockpit;
1243
			node->Data()->sCockpit = cockpit.toWString();
1247
			break;
1244
			break;
1248
		}
1245
		}
1249
	}
1246
	}
1250
}
1247
}
1251
 
1248
 
1252
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &scene, int mask)
1249
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &scene, int mask)
1253
{
1250
{
1254
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1251
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1255
	{
1252
	{
1256
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1253
		Utils::WString id = node->Data()->sCockpit.token(L";", 19);
1257
		if ( id.Compare(cid) )
1254
		if ( id.Compare(cid) )
1258
		{
1255
		{
1259
			Utils::String cockpit = node->Data()->sCockpit;
1256
			Utils::WString cockpit = node->Data()->sCockpit;
1260
			cockpit = cockpit.replaceToken(";", 8, scene);
1257
			cockpit = cockpit.replaceToken(L";", 8, scene);
1261
			cockpit = cockpit.replaceToken(";", 9, (long)mask);
1258
			cockpit = cockpit.replaceToken(L";", 9, (long)mask);
1262
			node->Data()->sCockpit = cockpit;
1259
			node->Data()->sCockpit = cockpit;
1263
			break;
1260
			break;
1264
		}
1261
		}
1265
	}
1262
	}
1266
}
1263
}
1267
void CXspFile::NewCockpit(const Utils::String &id, const Utils::String &scene, int mask)
1264
void CXspFile::NewCockpit(const Utils::String &id, const Utils::String &scene, int mask)
1268
{
1265
{
1269
	Utils::String cockpit = "0;0;0;0;0;0;0;";
1266
	Utils::WString cockpit = L"0;0;0;0;0;0;0;";
1270
	cockpit += scene + ";";
1267
	cockpit += scene.toWString() + L";";
1271
	cockpit += (long)mask;
1268
	cockpit += (long)mask;
1272
	cockpit += ";0;0;0;0;0;0;-100000;0;0;";
1269
	cockpit += L";0;0;0;0;0;0;-100000;0;0;";
1273
	cockpit += id + ";";
1270
	cockpit += id.toWString() + L";";
1274
	this->AddCockpit(cockpit, -1);
1271
	this->addCockpit(cockpit, -1);
1275
}
1272
}
1276
 
1273
 
1277
bool CXspFile::removeCutData(const Utils::String &cut)
1274
bool CXspFile::removeCutData(const Utils::WString &cut)
1278
{
1275
{
1279
	bool ret = false;
1276
	bool ret = false;
1280
	for(size_t i = 0; i < _lCutData.size(); i++)
1277
	for(size_t i = 0; i < _lCutData.size(); i++)
1281
	{
1278
	{
1282
		Utils::String str = _lCutData[i]->str;
1279
		Utils::WString str = _lCutData[i]->str;
1283
		if (str.token(";", 1).Compare(cut.token(";", 1)))
1280
		if (str.token(L";", 1).Compare(cut.token(L";", 1)))
1284
		{
1281
		{
1285
			ret = true;
1282
			ret = true;
1286
			_lCutData.remove(str);
1283
			_lCutData.remove(str);
1287
			break;
1284
			break;
1288
		}
1285
		}
1289
	}
1286
	}
1290
 
1287
 
1291
	return ret;
1288
	return ret;
1292
}
1289
}
1293
 
1290
 
1294
bool CXspFile::removeBodies(const Utils::String &cut)
1291
bool CXspFile::removeBodies(const Utils::WString &cut)
1295
{
1292
{
1296
	bool ret = false;
1293
	bool ret = false;
1297
	for (auto itr = _lBodies.begin(); itr != _lBodies.end(); itr++)
1294
	for (auto itr = _lBodies.begin(); itr != _lBodies.end(); itr++)
1298
	{
1295
	{
1299
		if ((*itr)->str.remove(' ').Compare(cut.remove(' ')))
1296
		if ((*itr)->str.remove(' ').Compare(cut.remove(' ')))
Line 1304... Line 1301...
1304
	}
1301
	}
1305
 
1302
 
1306
	return false;
1303
	return false;
1307
}
1304
}
1308
 
1305
 
1309
bool CXspFile::removeAnimation(const Utils::String &cut)
1306
bool CXspFile::removeAnimation(const Utils::WString &cut)
1310
{
1307
{
1311
	for(auto itr = _lAnimations.begin(); itr != _lAnimations.end(); itr++)
1308
	for(auto itr = _lAnimations.begin(); itr != _lAnimations.end(); itr++)
1312
	{
1309
	{
1313
		if ((*itr)->str.remove(' ').remove('\n').Compare(cut.remove(' ').remove('\n')))
1310
		if ((*itr)->str.remove(' ').remove('\n').Compare(cut.remove(' ').remove('\n')))
1314
		{
1311
		{
Line 1318... Line 1315...
1318
	}
1315
	}
1319
 
1316
 
1320
	return false;
1317
	return false;
1321
}
1318
}
1322
 
1319
 
1323
SCockpit *CXspFile::_findCockpit(const Utils::String &sID)
1320
SCockpit *CXspFile::_findCockpit(const Utils::WString &sID)
1324
{
1321
{
1325
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() ) {
1322
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() ) {
1326
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1323
		Utils::WString id = node->Data()->sCockpit.token(L";", 19);
1327
		if ( id.Compare(sID) )
1324
		if ( id.Compare(sID) )
1328
			return node->Data();
1325
			return node->Data();
1329
	}
1326
	}
1330
 
1327
 
1331
	return NULL;
1328
	return NULL;
1332
}
1329
}
1333
 
1330
 
1334
void CXspFile::AddCockpitWeapon(const Utils::String &cockpit, int game, int mask)
1331
void CXspFile::addCockpitWeapon(const Utils::WString &cockpit, int game, int mask)
1335
{
1332
{
1336
	SCockpit *pCockpit = _findCockpit(cockpit);
1333
	SCockpit *pCockpit = _findCockpit(cockpit);
1337
 
1334
 
1338
	// search if the game mask already exists
1335
	// search if the game mask already exists
1339
	SWeaponMask *wm = NULL;
1336
	SWeaponMask *wm = NULL;
Line 1352... Line 1349...
1352
		pCockpit->lWeaponMask.push_back(wm);
1349
		pCockpit->lWeaponMask.push_back(wm);
1353
	}
1350
	}
1354
 
1351
 
1355
	wm->iGame = game;
1352
	wm->iGame = game;
1356
	if ( mask == -1 )
1353
	if ( mask == -1 )
1357
		wm->iMask = pCockpit->sCockpit.token(";", 9);
1354
		wm->iMask = pCockpit->sCockpit.token(L";", 9);
1358
	else
1355
	else
1359
		wm->iMask = mask;
1356
		wm->iMask = mask;
1360
	_changed();
1357
	_changed();
1361
}
1358
}
1362
 
1359
 
1363
void CXspFile::AddCockpit(const Utils::String &cockpit, int game, int mask, int index)
1360
void CXspFile::addCockpit(const Utils::WString &cockpit, int game, int mask, int index)
1364
{
1361
{
1365
	Utils::String cid = cockpit.token(";", 19);
1362
	Utils::WString cid = cockpit.token(L";", 19);
1366
	SCockpit *pCockpit = _findCockpit(cid);
1363
	SCockpit *pCockpit = _findCockpit(cid);
1367
 
1364
 
1368
	if ( !pCockpit )
1365
	if ( !pCockpit )
1369
	{
1366
	{
1370
		pCockpit = new SCockpit;
1367
		pCockpit = new SCockpit;
Line 1375... Line 1372...
1375
	if ( index != -1 )
1372
	if ( index != -1 )
1376
		pCockpit->iIndex = index;
1373
		pCockpit->iIndex = index;
1377
 
1374
 
1378
	// now add the game mask
1375
	// now add the game mask
1379
	if ( game > 0 )
1376
	if ( game > 0 )
1380
		AddCockpitWeapon(cid, game, mask);
1377
		addCockpitWeapon(cid, game, mask);
1381
	_changed();
1378
	_changed();
1382
}
1379
}
1383
 
1380
 
1384
void CXspFile::addBody(const Utils::String &section, const Utils::String &data)
1381
void CXspFile::addBody(const Utils::WString &section, const Utils::WString &data)
1385
{
1382
{
1386
	this->addBodies(section + ";" + data);
1383
	this->addBodies(section + L";" + data);
1387
	_changed();
1384
	_changed();
1388
}
1385
}
1389
void CXspFile::addBodies(const Utils::String &sData)
1386
void CXspFile::addBodies(const Utils::WString &sData)
1390
{
1387
{
1391
	Utils::String data = sData;
1388
	Utils::WString data = sData;
1392
	if ( !data.isNumber() )
1389
	if ( !data.isNumber() )
1393
	{
1390
	{
1394
		if ( data[(int)(data.length() - 5)] == '.' )
1391
		if ( data[(int)(data.length() - 5)] == '.' )
1395
			data = data.left(-5);
1392
			data = data.left(-5);
1396
		else if ( data[(int)(data.length() - 4)] == '.' )
1393
		else if ( data[(int)(data.length() - 4)] == '.' )
1397
			data = data.left(-4);
1394
			data = data.left(-4);
1398
		if ( data.right(1) != ";" )
1395
		if ( data.right(1) != L";" )
1399
			data += ";";
1396
			data += L";";
1400
	}
1397
	}
1401
	if(!_lBodies.contains(data))
1398
	if(!_lBodies.contains(data))
1402
		_lBodies.pushBack(data);
1399
		_lBodies.pushBack(data);
1403
	_changed();
1400
	_changed();
1404
}
1401
}
1405
 
1402
 
1406
void CXspFile::addCutData(const Utils::String& data)
1403
void CXspFile::addCutData(const Utils::WString& data)
1407
{ 
1404
{ 
1408
	if (!_lCutData.contains(data))
1405
	if (!_lCutData.contains(data))
1409
	{
1406
	{
1410
		_lCutData.pushBack(data);
1407
		_lCutData.pushBack(data);
1411
		_changed();
1408
		_changed();
Line 1424... Line 1421...
1424
		return TAT_3;
1421
		return TAT_3;
1425
 
1422
 
1426
	return TAT_NONE;
1423
	return TAT_NONE;
1427
}
1424
}
1428
 
1425
 
1429
Utils::String CXspFile::TypesListToString(Utils::CList<STypesSection> &list, bool deleteAfter)
1426
Utils::WString CXspFile::TypesListToString(Utils::CList<STypesSection> &list, bool deleteAfter)
1430
{
1427
{
1431
	Utils::String data;
1428
	Utils::WString data;
1432
 
1429
 
1433
	for(Utils::CList<STypesSection>::iterator itr = list.begin(); itr != list.end(); itr++) {
1430
	for(Utils::CList<STypesSection>::iterator itr = list.begin(); itr != list.end(); itr++) {
1434
		data += (*itr)->sSection + "; " + (long)(*itr)->lEntries.size() + ";\r\n";
1431
		data += (*itr)->sSection + L"; " + (long)(*itr)->lEntries.size() + L";\r\n";
1435
		for(Utils::SStringList *str = (*itr)->lEntries.first(); str; str = (*itr)->lEntries.next()) {
1432
		for(Utils::WStringNode *str = (*itr)->lEntries.first(); str; str = (*itr)->lEntries.next()) {
1436
			data += str->str + "\r\n";
1433
			data += str->str + L"\r\n";
1437
		}
1434
		}
1438
 
1435
 
1439
		if ( deleteAfter ) {
1436
		if ( deleteAfter ) {
1440
			(*itr)->lEntries.clear();
1437
			(*itr)->lEntries.clear();
1441
		}
1438
		}
Line 1716... Line 1713...
1716
	for(auto itr = list.begin(); itr != list.end(); itr++)
1713
	for(auto itr = list.begin(); itr != list.end(); itr++)
1717
		this->addAnimation((*itr)->str);
1714
		this->addAnimation((*itr)->str);
1718
	_changed();
1715
	_changed();
1719
}
1716
}
1720
 
1717
 
1721
void CXspFile::addAnimation(const Utils::String& data) 
1718
void CXspFile::addAnimation(const Utils::WString& data) 
1722
{ 
1719
{ 
1723
	if (!_lAnimations.contains(data))
1720
	if (!_lAnimations.contains(data))
1724
	{
1721
	{
1725
		_lAnimations.pushBack(data);
1722
		_lAnimations.pushBack(data);
1726
		_changed();
1723
		_changed();
Line 1933... Line 1930...
1933
void CXspFile::extractCutData(CVirtualFileSystem *pVfs, Utils::CStringList &sceneModels, bool add)
1930
void CXspFile::extractCutData(CVirtualFileSystem *pVfs, Utils::CStringList &sceneModels, bool add)
1934
{
1931
{
1935
	std::vector<int> cuts;
1932
	std::vector<int> cuts;
1936
	for ( CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next() )
1933
	for ( CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next() )
1937
	{
1934
	{
1938
		Utils::String data = node->Data()->sData;
1935
		Utils::WString data = node->Data()->sData;
1939
		int states = data.token(";", 3);
1936
		int states = data.token(L";", 3);
1940
		for ( int i = 0; i < states; i++ ) {
1937
		for ( int i = 0; i < states; i++ ) {
1941
			int cutid = data.token(";", (i * 2) + 5);
1938
			int cutid = data.token(L";", (i * 2) + 5);
1942
			if ( !cutid ) continue;
1939
			if ( !cutid ) continue;
1943
			cuts.push_back(cutid);
1940
			cuts.push_back(cutid);
1944
		}
1941
		}
1945
	}
1942
	}
1946
 
1943
 
Line 2016... Line 2013...
2016
					else
2013
					else
2017
					{
2014
					{
2018
						Utils::String first = str.token(";", 1);
2015
						Utils::String first = str.token(";", 1);
2019
						if (sceneModels.contains(first))
2016
						if (sceneModels.contains(first))
2020
						{
2017
						{
2021
							this->AddDummy(section, str);
2018
							this->addDummy(section, str);
2022
 
2019
 
2023
							if (add)
2020
							if (add)
2024
							{
2021
							{
2025
								int pos = 4;
2022
								int pos = 4;
2026
								int scene = str.token(";", 3).toInt();
2023
								int scene = str.token(";", 3).toInt();
Line 2072... Line 2069...
2072
 
2069
 
2073
					// not in a section yet
2070
					// not in a section yet
2074
					if (secCount2)
2071
					if (secCount2)
2075
					{
2072
					{
2076
						if (sceneModels.contains(file))
2073
						if (sceneModels.contains(file))
2077
							this->AddComponent(section, file, str);
2074
							this->addComponent(section, file, str);
2078
						--secCount2;
2075
						--secCount2;
2079
					}
2076
					}
2080
					else if (secCount <= 0)
2077
					else if (secCount <= 0)
2081
					{
2078
					{
2082
						section = str.token(";", 1);
2079
						section = str.token(";", 1);
Line 2395... Line 2392...
2395
			for (int i = 0; i < 6; i++)
2392
			for (int i = 0; i < 6; i++)
2396
			{
2393
			{
2397
				int idx = m_sData.token(";", 32 + (i * 2));
2394
				int idx = m_sData.token(";", 32 + (i * 2));
2398
				if (static_cast<size_t>(idx) < lines.size() && idx)
2395
				if (static_cast<size_t>(idx) < lines.size() && idx)
2399
				{
2396
				{
2400
					Utils::String turret = lines[idx];
2397
					Utils::WString turret = lines[idx];
2401
					int pos = -1;
2398
					int pos = -1;
2402
					Utils::String id;
2399
					Utils::WString id;
2403
					while (id.empty() && pos > -100) id = turret.token(";", pos--);
2400
					while (id.empty() && pos > -100) id = turret.token(L";", pos--);
2404
					m_sData = m_sData.replaceToken(";", 32 + (i * 2), id + "(" + (long)idx + ")");
2401
					m_sData = m_sData.replaceToken(";", 32 + (i * 2), id.toString() + "(" + (long)idx + ")");
2405
 
2402
 
2406
					this->AddCockpit(turret, 0);
2403
					this->addCockpit(turret, 0);
2407
				}
2404
				}
2408
			}
2405
			}
2409
		}
2406
		}
2410
		return true;
2407
		return true;
2411
	}
2408
	}
Line 2559... Line 2556...
2559
		if ( lang == 44 || this->name().empty())
2556
		if ( lang == 44 || this->name().empty())
2560
		{
2557
		{
2561
			this->setName(shipName);
2558
			this->setName(shipName);
2562
			this->setDescription(shipDesc.findReplace("&amp", "&"));
2559
			this->setDescription(shipDesc.findReplace("&amp", "&"));
2563
		}
2560
		}
2564
		this->AddText(lang, shipName, shipDesc);
2561
		this->addText(lang, shipName, shipDesc);
2565
		return true;	
2562
		return true;	
2566
	}
2563
	}
2567
 
2564
 
2568
	return false;
2565
	return false;
2569
}
2566
}
Line 2712... Line 2709...
2712
	{
2709
	{
2713
		SCockpit *c = node->Data();
2710
		SCockpit *c = node->Data();
2714
		if ( c->iIndex < 0 )
2711
		if ( c->iIndex < 0 )
2715
			continue;
2712
			continue;
2716
 
2713
 
2717
		Utils::String id = c->sCockpit.token(";", 19);
2714
		Utils::WString id = c->sCockpit.token(L";", 19);
2718
 
2715
 
2719
		for ( int i = 0; i < 6; i++ )
2716
		for ( int i = 0; i < 6; i++ )
2720
		{
2717
		{
2721
			Utils::String tId = m_sData.token(";", 32 + (i * 2));
2718
			Utils::String tId = m_sData.token(";", 32 + (i * 2));
2722
			if ( tId.isNumber() && ((int)tId) == c->iIndex )
2719
			if ( tId.isNumber() && ((int)tId) == c->iIndex )
2723
				m_sData = m_sData.replaceToken(";", 32 + (i * 2), (id + "(" + Utils::String::Number(c->iIndex) + ")").c_str());
2720
				m_sData = m_sData.replaceToken(";", 32 + (i * 2), id.toString() + "(" + Utils::String::Number(c->iIndex) + ")");
2724
		}
2721
		}
2725
	}
2722
	}
2726
}
2723
}
2727
 
2724
 
2728
Utils::String CXspFile::formatShipData(const Utils::CStringList &cockpits, int *text, int game)
2725
Utils::WString CXspFile::formatShipData(const Utils::WStringList &cockpits, int *text, int game)
2729
{
2726
{
2730
	Utils::String data = (game == GAME_X3) ? this->GetX3ShipData() : this->GetTCShipData();
2727
	Utils::WString data = (game == GAME_X3) ? this->GetX3ShipData() : this->GetTCShipData();
2731
	// do turrets
2728
	// do turrets
2732
	for ( int t = 0; t < 6; t++ )
2729
	for ( int t = 0; t < 6; t++ )
2733
	{
2730
	{
2734
		int oldPos = 0;
2731
		int oldPos = 0;
2735
		Utils::String turret = data.token(";", 32 + (t * 2));
2732
		Utils::WString turret = data.token(L";", 32 + (t * 2));
2736
		if ( !turret.isNumber() )
2733
		if ( !turret.isNumber() )
2737
		{
2734
		{
2738
			if ( turret.isin("(") )
2735
			if ( turret.contains(L"(") )
2739
			{
2736
			{
2740
				oldPos = turret.tokens("(", 2).token(")", 1);
2737
				oldPos = turret.tokens(L"(", 2).token(L")", 1);
2741
				turret = turret.token("(", 1);
2738
				turret = turret.token(L"(", 1);
2742
			}
2739
			}
2743
			int pos = cockpits.findPos(turret);
2740
			int pos = cockpits.findPos(turret);
2744
			if ( pos < 0 )	pos = oldPos;
2741
			if ( pos < 0 )	pos = oldPos;
2745
			if (static_cast<size_t>(pos) >= cockpits.size()) pos = 0;
2742
			if (static_cast<size_t>(pos) >= cockpits.size()) pos = 0;
2746
			data = data.replaceToken(";", 32 + (t * 2), (long)pos);
2743
			data = data.replaceToken(L";", 32 + (t * 2), (long)pos);
2747
		}
2744
		}
2748
	}
2745
	}
2749
	// adjust the weapons
2746
	// adjust the weapons
2750
	int mask = this->GetLaserMask(game - 1);
2747
	int mask = this->GetLaserMask(game - 1);
2751
	if ( mask != -1 )
2748
	if ( mask != -1 )
2752
		data = data.replaceToken(";", 19, (long)mask);
2749
		data = data.replaceToken(L";", 19, (long)mask);
2753
	mask = this->GetMissileMask(game - 1);
2750
	mask = this->GetMissileMask(game - 1);
2754
	if ( mask != -1 )
2751
	if ( mask != -1 )
2755
		data = data.replaceToken(";", 25, (long)mask);
2752
		data = data.replaceToken(L";", 25, (long)mask);
2756
 
2753
 
2757
	// fix the ship text
2754
	// fix the ship text
2758
	if ( m_iOrgDesc > 0 )
2755
	if ( m_iOrgDesc > 0 )
2759
		(*text) = m_iOrgDesc;
2756
		(*text) = m_iOrgDesc;
2760
	data = data.replaceToken(";", 7, (long)*text);
2757
	data = data.replaceToken(L";", 7, (long)*text);
2761
 
2758
 
2762
	// add the ware id
2759
	// add the ware id
2763
	data.removeChar(9);
2760
	data.removeChar(9);
2764
	data.removeEndSpace();
2761
	data.removeEndSpace();
2765
	// remove the end ;
2762
	// remove the end ;
2766
	while ( data.right(1) == ";" ) data.truncate(-1);
2763
	while ( data.right(1) == L";" ) data.truncate(-1);
2767
	data = data.replaceToken(";", data.countToken(";"), this->GetShipID());
2764
	data = data.replaceToken(L";", data.countToken(L";"), this->GetShipID());
2768
	if ( data.right(1) != ";" )
2765
	if ( data.right(1) != L";" )
2769
		data += ";";
2766
		data += L";";
2770
 
2767
 
2771
	return data;
2768
	return data;
2772
}
2769
}
2773
 
2770