Subversion Repositories spk

Rev

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

Rev 160 Rev 165
Line 40... Line 40...
40
 
40
 
41
	for ( CListNode<SCockpit> *n = m_lCockpit.Front(); n; n = n->next() )
41
	for ( CListNode<SCockpit> *n = m_lCockpit.Front(); n; n = n->next() )
42
		n->Data()->lWeaponMask.MemoryClear();
42
		n->Data()->lWeaponMask.MemoryClear();
43
	m_lCockpit.MemoryClear();
43
	m_lCockpit.MemoryClear();
44
	m_lCockpit.destroy();
44
	m_lCockpit.destroy();
45
	m_lCutData.Clear();
45
	_lCutData.clear();
46
	m_lBodies.Clear();
46
	m_lBodies.Clear();
47
}
47
}
48
 
48
 
49
void CXspFile::SetDefaults ()
49
void CXspFile::SetDefaults ()
50
{
50
{
Line 222... Line 222...
222
 
222
 
223
	for ( CListNode<SWeaponMask> *wNode = m_lWeaponMasks.Front(); wNode; wNode = wNode->next() )
223
	for ( CListNode<SWeaponMask> *wNode = m_lWeaponMasks.Front(); wNode; wNode = wNode->next() )
224
		values += Utils::String("WeaponMask: ") + (long)wNode->Data()->iGame + " " + (long)wNode->Data()->iMask + "\n";
224
		values += Utils::String("WeaponMask: ") + (long)wNode->Data()->iGame + " " + (long)wNode->Data()->iMask + "\n";
225
	for ( CListNode<SWeaponMask> *mNode = m_lMissileMasks.Front(); mNode; mNode = mNode->next() )
225
	for ( CListNode<SWeaponMask> *mNode = m_lMissileMasks.Front(); mNode; mNode = mNode->next() )
226
		values += Utils::String("MissileMask: ") + (long)mNode->Data()->iGame + " " + (long)mNode->Data()->iMask + "\n";
226
		values += Utils::String("MissileMask: ") + (long)mNode->Data()->iGame + " " + (long)mNode->Data()->iMask + "\n";
227
	for ( SStringList *cut = m_lCutData.Head(); cut; cut = cut->next )
227
	for(auto itr = _lCutData.begin(); itr != _lCutData.end(); itr++)
228
		values += Utils::String("CutData: ") + cut->str.ToString() + "\n";
228
		values += "CutData: " + (*itr)->str + "\n";
229
	for ( SStringList *body = m_lBodies.Head(); body; body = body->next )
229
	for ( SStringList *body = m_lBodies.Head(); body; body = body->next )
230
		values += Utils::String("Bodies: ") + body->str.ToString() + "\n";
230
		values += Utils::String("Bodies: ") + body->str.ToString() + "\n";
231
	for ( SStringList *ani = m_lAnimations.Head(); ani; ani = ani->next )
231
	for ( SStringList *ani = m_lAnimations.Head(); ani; ani = ani->next )
232
		values += Utils::String("Animations: ") + ani->str.ToString() + "\n";
232
		values += Utils::String("Animations: ") + ani->str.ToString() + "\n";
233
 
233
 
Line 250... Line 250...
250
	else if ( first.Compare("OrgDesc") || first.Compare("OriginalDesc") )
250
	else if ( first.Compare("OrgDesc") || first.Compare("OriginalDesc") )
251
		m_iOrgDesc = rest;
251
		m_iOrgDesc = rest;
252
	else if ( first.Compare("Shipyard") )
252
	else if ( first.Compare("Shipyard") )
253
		m_iShipyard = rest;
253
		m_iShipyard = rest;
254
	else if ( first.Compare("CutData") )
254
	else if ( first.Compare("CutData") )
255
		this->AddCutData(rest);
255
		this->addCutData(rest);
256
	else if ( first.Compare("Bodies") )
256
	else if ( first.Compare("Bodies") )
257
		this->AddBodies(rest);
257
		this->AddBodies(rest);
258
	else if ( first.Compare("Animations") )
258
	else if ( first.Compare("Animations") )
259
		this->AddAnimation(rest);
259
		this->AddAnimation(rest);
260
	else if ( first.Compare("Cockpit") )
260
	else if ( first.Compare("Cockpit") )
Line 528... Line 528...
528
									break;
528
									break;
529
							}
529
							}
530
						}
530
						}
531
 
531
 
532
						for ( SStringList *strNode = newLines.Head(); strNode; strNode = strNode->next )
532
						for ( SStringList *strNode = newLines.Head(); strNode; strNode = strNode->next )
533
							this->AddCutData(strNode->str.ToString());
533
							this->addCutData(strNode->str.ToString());
534
					}
534
					}
535
					// bodies
535
					// bodies
536
					else if ( special == 2 )
536
					else if ( special == 2 )
537
					{
537
					{
538
						entries = 0;
538
						entries = 0;
Line 760... Line 760...
760
	}
760
	}
761
 
761
 
762
	return mask;
762
	return mask;
763
}
763
}
764
 
764
 
-
 
765
void CXspFile::clearCutData()
-
 
766
{
-
 
767
	_lCutData.clear();
-
 
768
}
-
 
769
 
765
Utils::String CXspFile::GetShipClass()
770
Utils::String CXspFile::GetShipClass()
766
{
771
{
767
	if ( !m_sData.empty() )
772
	if ( !m_sData.empty() )
768
		return m_sData.token(";", TSHIPPOS_CLASS);
773
		return m_sData.token(";", TSHIPPOS_CLASS);
769
	return "OBJ_SHIP_M5";
774
	return "OBJ_SHIP_M5";
Line 869... Line 874...
869
		}
874
		}
870
 
875
 
871
		list->pushBack("");
876
		list->pushBack("");
872
	}
877
	}
873
 
878
 
874
	if ( !this->m_lCutData.Empty() ) {
879
	if ( !this->_lCutData.empty() ) {
875
		list->pushBack("# Ship Cut Data");
880
		list->pushBack("# Ship Cut Data");
876
		for(SStringList *str = m_lCutData.Head(); str; str = str->next) {
881
		for(auto itr = _lCutData.begin(); itr != _lCutData.end(); itr++)
877
			list->pushBack(Utils::String("CutData: ") + str->str.ToString());
882
			list->pushBack("CutData: " + (*itr)->str);
878
		}
-
 
879
		list->pushBack("");
883
		list->pushBack("");
880
	}
884
	}
881
 
885
 
882
	if ( !this->m_lBodies.Empty() ) {
886
	if ( !this->m_lBodies.Empty() ) {
883
		list->pushBack("# Ship Bodies");
887
		list->pushBack("# Ship Bodies");
Line 921... Line 925...
921
	}
925
	}
922
 
926
 
923
	currentSubSection->lEntries.pushBack(data, "");
927
	currentSubSection->lEntries.pushBack(data, "");
924
}
928
}
925
 
929
 
926
void CXspFile::_addDataSection(CyStringList &list, Utils::CList<STypesSection> &sectionList, bool bUseFirst)
930
void CXspFile::_addDataSection(CyStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst)
927
{
931
{
928
	for(SStringList *str = list.Head(); str; str = str->next) {
932
	for (SStringList* str = list.Head(); str; str = str->next) {
929
		if ( bUseFirst ) {
933
		if (bUseFirst) {
930
			Utils::String data = str->str.ToString();
934
			Utils::String data = str->str.ToString();
931
			_addSection(sectionList, data.token(";", 1), data.tokens(";", 2));
935
			_addSection(sectionList, data.token(";", 1), data.tokens(";", 2));
932
		}
936
		}
933
		else {
937
		else {
934
			_addSection(sectionList, str->str.ToString(), str->data.ToString());
938
			_addSection(sectionList, str->str.ToString(), str->data.ToString());
935
		}
939
		}
936
	}
940
	}
937
}
941
}
938
 
942
 
-
 
943
void CXspFile::_addDataSection(Utils::CStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst)
-
 
944
{
-
 
945
	for(auto itr = list.begin(); itr != list.end(); itr++)
-
 
946
	{
-
 
947
		if (bUseFirst) {
-
 
948
			Utils::String data = (*itr)->str;
-
 
949
			_addSection(sectionList, data.token(";", 1), data.tokens(";", 2));
-
 
950
		}
-
 
951
		else {
-
 
952
			_addSection(sectionList, (*itr)->str, (*itr)->data);
-
 
953
		}
-
 
954
	}
-
 
955
}
-
 
956
 
939
void CXspFile::addDummiesToList(Utils::CList<STypesSection> &list)
957
void CXspFile::addDummiesToList(Utils::CList<STypesSection> &list)
940
{
958
{
941
	ADDSECTIONLIST(SDummy, m_lDummy);
959
	ADDSECTIONLIST(SDummy, m_lDummy);
942
}
960
}
943
 
961
 
Line 962... Line 980...
962
	}
980
	}
963
}
981
}
964
 
982
 
965
void CXspFile::addCutDataToList(Utils::CList<STypesSection> &list)
983
void CXspFile::addCutDataToList(Utils::CList<STypesSection> &list)
966
{
984
{
967
	_addDataSection(this->m_lCutData, list, false);
985
	_addDataSection(this->_lCutData, list, false);
968
}
986
}
969
 
987
 
970
void CXspFile::addBodiesToList(Utils::CList<STypesSection> &list)
988
void CXspFile::addBodiesToList(Utils::CList<STypesSection> &list)
971
{
989
{
972
	_addDataSection(this->m_lBodies, list, true);
990
	_addDataSection(this->m_lBodies, list, true);
Line 1080... Line 1098...
1080
	else if ( sFirst.Compare("MissileMask") )
1098
	else if ( sFirst.Compare("MissileMask") )
1081
		this->AddMissileMask(sRest.token(" ", 1), sRest.token(" ", 2));
1099
		this->AddMissileMask(sRest.token(" ", 1), sRest.token(" ", 2));
1082
	else if ( sFirst.Compare("Dummy") )
1100
	else if ( sFirst.Compare("Dummy") )
1083
		this->AddDummy(sRest.token(" ", 1), sRest.token(" ", 2));
1101
		this->AddDummy(sRest.token(" ", 1), sRest.token(" ", 2));
1084
	else if ( sFirst.Compare("CutData") )
1102
	else if ( sFirst.Compare("CutData") )
1085
		this->AddCutData(sRest);
1103
		this->addCutData(sRest);
1086
	else if ( sFirst.Compare("Animation") )
1104
	else if ( sFirst.Compare("Animation") )
1087
		this->AddAnimation(sRest);
1105
		this->AddAnimation(sRest);
1088
	else if ( sFirst.Compare("Bodies") )
1106
	else if ( sFirst.Compare("Bodies") )
1089
		this->AddBodies(sRest);
1107
		this->AddBodies(sRest);
1090
	else if ( !CBaseFile::LoadPackageData(sFirst, sRest, sMainGame, otherGames, gameAddons, progress) )
1108
	else if ( !CBaseFile::LoadPackageData(sFirst, sRest, sMainGame, otherGames, gameAddons, progress) )
Line 1260... Line 1278...
1260
	cockpit += ";0;0;0;0;0;0;-100000;0;0;";
1278
	cockpit += ";0;0;0;0;0;0;-100000;0;0;";
1261
	cockpit += id + ";";
1279
	cockpit += id + ";";
1262
	this->AddCockpit(cockpit, -1);
1280
	this->AddCockpit(cockpit, -1);
1263
}
1281
}
1264
 
1282
 
1265
bool CXspFile::RemoveCutData(const Utils::String &cut)
1283
bool CXspFile::removeCutData(const Utils::String &cut)
1266
{
1284
{
1267
	bool ret = false;
1285
	bool ret = false;
1268
	for ( SStringList *str = m_lCutData.Head(); str; str = str->next )
1286
	for(size_t i = 0; i < _lCutData.size(); i++)
1269
	{
1287
	{
-
 
1288
		Utils::String str = _lCutData[i]->str;
1270
		if ( str->str.GetToken(";", 1, 1).Compare(CyString(cut.token(";", 1))) )
1289
		if (str.token(";", 1).Compare(cut.token(";", 1)))
1271
		{
1290
		{
1272
			ret = true;
1291
			ret = true;
1273
			str->remove = true;
1292
			_lCutData.remove(str);
1274
			break;
1293
			break;
1275
		}
1294
		}
1276
	}
1295
	}
1277
 
1296
 
1278
	m_lCutData.RemoveMarked();
-
 
1279
 
-
 
1280
	return ret;
1297
	return ret;
1281
}
1298
}
1282
 
1299
 
1283
bool CXspFile::RemoveBodies(const Utils::String &cut)
1300
bool CXspFile::RemoveBodies(const Utils::String &cut)
1284
{
1301
{
Line 1396... Line 1413...
1396
	}
1413
	}
1397
	m_lBodies.PushBack(CyString(data), true);
1414
	m_lBodies.PushBack(CyString(data), true);
1398
	_changed();
1415
	_changed();
1399
}
1416
}
1400
 
1417
 
-
 
1418
void CXspFile::addCutData(const Utils::String& data)
-
 
1419
{ 
-
 
1420
	if (!_lCutData.contains(data))
-
 
1421
	{
-
 
1422
		_lCutData.pushBack(data);
-
 
1423
		_changed();
-
 
1424
	}
-
 
1425
}
-
 
1426
 
-
 
1427
 
1401
int CXspFile::GetAnimationType(const Utils::String &type)
1428
int CXspFile::GetAnimationType(const Utils::String &type)
1402
{
1429
{
1403
	if ( type.Compare("TAT_TAGSINGLESTEP") )
1430
	if ( type.Compare("TAT_TAGSINGLESTEP") )
1404
		return TAT_SINGLE;
1431
		return TAT_SINGLE;
1405
	else if ( type.Compare("TAT_TAGONESHOT") 
1432
	else if ( type.Compare("TAT_TAGONESHOT") 
Line 1810... Line 1837...
1810
				for ( int i = 0; i < max; i += 2 ) {
1837
				for ( int i = 0; i < max; i += 2 ) {
1811
					int cutid = words[i];
1838
					int cutid = words[i];
1812
					if ( !cutid ) continue;
1839
					if ( !cutid ) continue;
1813
					for ( std::vector<int>::iterator itr = cuts.begin(); itr != cuts.end(); itr++ ) {
1840
					for ( std::vector<int>::iterator itr = cuts.begin(); itr != cuts.end(); itr++ ) {
1814
						if ( (*itr) == cutid ) {
1841
						if ( (*itr) == cutid ) {
1815
							this->AddCutData(words[i] + ";" + words[i + 1] + ";");
1842
							this->addCutData(words[i] + ";" + words[i + 1] + ";");
1816
							if ( add ) {
1843
							if ( add ) {
1817
								sceneModels->PushBack(CyString(words[i + 1]));
1844
								sceneModels->PushBack(CyString(words[i + 1]));
1818
							}
1845
							}
1819
							break;
1846
							break;
1820
						}
1847
						}