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 758... Line 758...
758
		if ( !mask && !getOnly )
758
		if ( !mask && !getOnly )
759
			mask = m->iMask;
759
			mask = m->iMask;
760
	}
760
	}
761
 
761
 
762
	return mask;
762
	return mask;
-
 
763
}
-
 
764
 
-
 
765
void CXspFile::clearCutData()
-
 
766
{
-
 
767
	_lCutData.clear();
763
}
768
}
764
 
769
 
765
Utils::String CXspFile::GetShipClass()
770
Utils::String CXspFile::GetShipClass()
766
{
771
{
767
	if ( !m_sData.empty() )
772
	if ( !m_sData.empty() )
Line 798... Line 803...
798
 
803
 
799
	if ( !m_sID.empty() )
804
	if ( !m_sID.empty() )
800
	{
805
	{
801
		list->pushBack("# Ship ID, the ship id to identify the ship as");
806
		list->pushBack("# Ship ID, the ship id to identify the ship as");
802
		list->pushBack("ShipID: " + m_sID);
807
		list->pushBack("ShipID: " + m_sID);
803
	}
808
	}
804
 
809
 
805
	if ( m_bExistingShip )
810
	if ( m_bExistingShip )
806
	{
811
	{
807
		list->pushBack("# Existing Ship, replaces an existing ship in the game with ship package instead of creating a new entry");
812
		list->pushBack("# Existing Ship, replaces an existing ship in the game with ship package instead of creating a new entry");
808
		list->pushBack("ExistingShip");
813
		list->pushBack("ExistingShip");
Line 818... Line 823...
818
 
823
 
819
	if ( m_lText.size() ) {
824
	if ( m_lText.size() ) {
820
		list->pushBack("# Ship Texts, the name/description of the ship in each language: <LANGID> <NAME>|<DESCRIPTION>");
825
		list->pushBack("# Ship Texts, the name/description of the ship in each language: <LANGID> <NAME>|<DESCRIPTION>");
821
		for(CListNode<SText> *node = m_lText.Front(); node; node = node->next()) {
826
		for(CListNode<SText> *node = m_lText.Front(); node; node = node->next()) {
822
			list->pushBack(Utils::String("ShipText: ") + (long)node->Data()->iId + " " + node->Data()->sName + "|" + node->Data()->sDesc);
827
			list->pushBack(Utils::String("ShipText: ") + (long)node->Data()->iId + " " + node->Data()->sName + "|" + node->Data()->sDesc);
823
		}
828
		}
824
 
829
 
825
		list->pushBack("");
830
		list->pushBack("");
826
	}
831
	}
827
 
832
 
828
	if ( this->m_lWeaponMasks.size() ) {
833
	if ( this->m_lWeaponMasks.size() ) {
829
		list->pushBack("# Weapon Masks, the weapons for each game: <GAME> <MASK>");
834
		list->pushBack("# Weapon Masks, the weapons for each game: <GAME> <MASK>");
830
		for(CListNode<SWeaponMask> *node = m_lWeaponMasks.Front(); node; node = node->next()) {
835
		for(CListNode<SWeaponMask> *node = m_lWeaponMasks.Front(); node; node = node->next()) {
831
			list->pushBack(Utils::String("WeaponMask: ") + (long)node->Data()->iGame + " " + (long)node->Data()->iMask);
836
			list->pushBack(Utils::String("WeaponMask: ") + (long)node->Data()->iGame + " " + (long)node->Data()->iMask);
832
		}
837
		}
833
 
838
 
834
		list->pushBack("");
839
		list->pushBack("");
835
	}
840
	}
836
 
841
 
837
	if ( this->m_lMissileMasks.size() ) {
842
	if ( this->m_lMissileMasks.size() ) {
838
		list->pushBack("# Missile Masks, the missiles for each game: <GAME> <MASK>");
843
		list->pushBack("# Missile Masks, the missiles for each game: <GAME> <MASK>");
839
		for(CListNode<SWeaponMask> *node = m_lMissileMasks.Front(); node; node = node->next()) {
844
		for(CListNode<SWeaponMask> *node = m_lMissileMasks.Front(); node; node = node->next()) {
840
			list->pushBack(Utils::String("WeaponMask: ") + (long)node->Data()->iGame + " " + (long)node->Data()->iMask);
845
			list->pushBack(Utils::String("WeaponMask: ") + (long)node->Data()->iGame + " " + (long)node->Data()->iMask);
841
		}
846
		}
842
 
847
 
843
		list->pushBack("");
848
		list->pushBack("");
844
	}
849
	}
845
 
850
 
846
	if ( this->m_lComponent.size() ) {
851
	if ( this->m_lComponent.size() ) {
847
		list->pushBack("# Ship Components, each component used in the ships scene: <SECTION> <MODELENTRY> <VALUES>");
852
		list->pushBack("# Ship Components, each component used in the ships scene: <SECTION> <MODELENTRY> <VALUES>");
848
		for(CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next()) {
853
		for(CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next()) {
849
			list->pushBack(Utils::String("Component: ") + node->Data()->sSection + " " + node->Data()->sSection2 + " " + node->Data()->sData);
854
			list->pushBack(Utils::String("Component: ") + node->Data()->sSection + " " + node->Data()->sSection2 + " " + node->Data()->sData);
850
		}
855
		}
851
		list->pushBack("");
856
		list->pushBack("");
852
	}
857
	}
853
 
858
 
854
	if ( this->m_lDummy.size() ) {
859
	if ( this->m_lDummy.size() ) {
855
		list->pushBack("# Ship Dummies, each dummy entry used in the ships scene: <SECTION> <VALUE>");
860
		list->pushBack("# Ship Dummies, each dummy entry used in the ships scene: <SECTION> <VALUE>");
856
		for(CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next()) {
861
		for(CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next()) {
857
			list->pushBack("Dummy: " + node->Data()->sSection + " " + node->Data()->sData);
862
			list->pushBack("Dummy: " + node->Data()->sSection + " " + node->Data()->sData);
858
		}
863
		}
859
		list->pushBack("");
864
		list->pushBack("");
860
	}
865
	}
861
 
866
 
862
	if ( this->m_lCockpit.size() ) {
867
	if ( this->m_lCockpit.size() ) {
863
		list->pushBack("# Cockpit entries, each cockpit value with thier weapons mask");
868
		list->pushBack("# Cockpit entries, each cockpit value with thier weapons mask");
864
		for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
869
		for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
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&lt;STypesSection> &sectionList, bool bUseFirst)
930
void CXspFile::_addDataSection(CyStringList&; list, Utils::CList&lt;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());
-
 
939
		}
-
 
940
	}
-
 
941
}
-
 
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);
935
		}
953
		}
936
	}
954
	}
937
}
955
}
938
 
956
 
939
void CXspFile::addDummiesToList(Utils::CList<STypesSection> &list)
957
void CXspFile::addDummiesToList(Utils::CList<STypesSection> &list)
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 1153... Line 1171...
1153
	bool ret = false;
1171
	bool ret = false;
1154
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1172
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1155
	{
1173
	{
1156
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1174
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1157
		if ( id.Compare(cockpitid) )
1175
		if ( id.Compare(cockpitid) )
1158
		{
1176
		{
1159
			node->DeleteData();
1177
			node->DeleteData();
1160
			ret = true;
1178
			ret = true;
1161
			break;
1179
			break;
1162
		}
1180
		}
1163
	}
1181
	}
1164
 
1182
 
1165
	m_lCockpit.RemoveEmpty();
1183
	m_lCockpit.RemoveEmpty();
1166
 
1184
 
1167
	return ret;
1185
	return ret;
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-&gt;next )
1286
	for(size_t i = 0; i &lt; _lCutData.size(); i++)
1269
	{
1287
	{
-
 
1288
		Utils::String str = _lCutData[i]->str;
1270
		if ( str-&gt;str.GetToken(";", 1, 1).Compare(CyString(cut.token(";", 1))) )
1289
		if (str.token(&quot;;", 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
 
-
 
1278
	m_lCutData.RemoveMarked();
-
 
1279
 
1296
 
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)
Line 1395... Line 1412...
1395
			data += ";";
1412
			data += ";";
1396
	}
1413
	}
1397
	m_lBodies.PushBack(CyString(data), true);
1414
	m_lBodies.PushBack(CyString(data), true);
1398
	_changed();
1415
	_changed();
1399
}
1416
}
-
 
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
 
1400
 
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;
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
						}