Subversion Repositories spk

Rev

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

Rev 102 Rev 108
Line 780... Line 780...
780
 
780
 
781
	if ( !m_sID.empty() )
781
	if ( !m_sID.empty() )
782
	{
782
	{
783
		list->PushBack("# Ship ID, the ship id to identify the ship as");
783
		list->PushBack("# Ship ID, the ship id to identify the ship as");
784
		list->PushBack(CyString("ShipID: ") + m_sID);
784
		list->PushBack(CyString("ShipID: ") + m_sID);
-
 
785
	}
-
 
786
 
-
 
787
	if ( m_bExistingShip )
-
 
788
	{
-
 
789
		list->PushBack("# Existing Ship, replaces an existing ship in the game with ship package instead of creating a new entry");
-
 
790
		list->PushBack("ExistingShip");
-
 
791
		list->PushBack("");
785
	}
792
	}
786
 
793
 
787
	if ( !m_sData.empty() )
794
	if ( !m_sData.empty() )
788
	{
795
	{
789
		list->PushBack("# Ship Data, the TShip data entry to add to the game (parts of this are adjusted and auto generated by the installer)");
796
		list->PushBack("# Ship Data, the TShip data entry to add to the game (parts of this are adjusted and auto generated by the installer)");
790
		list->PushBack(CyString("ShipData: ") + m_sData);
797
		list->PushBack(CyString("ShipData: ") + m_sData);
791
		list->PushBack("");
798
		list->PushBack("");
792
	}
799
	}
793
 
800
 
794
	if ( m_bExistingShip )
801
	if ( m_lText.size() ) {
-
 
802
		list->PushBack("# Ship Texts, the name/description of the ship in each language: <LANGID> <NAME>|<DESCRIPTION>");
-
 
803
		for(CListNode<SText> *node = m_lText.Front(); node; node = node->next()) {
-
 
804
			list->PushBack(CyString("ShipText: ") + (long)node->Data()->iId + " " + node->Data()->sName + "|" + node->Data()->sDesc);
-
 
805
		}
-
 
806
 
-
 
807
		list->PushBack("");
795
	{
808
	}
-
 
809
 
-
 
810
	if ( this->m_lWeaponMasks.size() ) {
-
 
811
		list->PushBack("# Weapon Masks, the weapons for each game: <GAME> <MASK>");
-
 
812
		for(CListNode<SWeaponMask> *node = m_lWeaponMasks.Front(); node; node = node->next()) {
-
 
813
			list->PushBack(CyString("WeaponMask: ") + (long)node->Data()->iGame + " " + (long)node->Data()->iMask);
-
 
814
		}
-
 
815
 
-
 
816
		list->PushBack("");
-
 
817
	}
-
 
818
 
-
 
819
	if ( this->m_lMissileMasks.size() ) {
-
 
820
		list->PushBack("# Missile Masks, the missiles for each game: <GAME> <MASK>");
-
 
821
		for(CListNode<SWeaponMask> *node = m_lMissileMasks.Front(); node; node = node->next()) {
-
 
822
			list->PushBack(CyString("WeaponMask: ") + (long)node->Data()->iGame + " " + (long)node->Data()->iMask);
-
 
823
		}
-
 
824
 
-
 
825
		list->PushBack("");
-
 
826
	}
-
 
827
 
-
 
828
	if ( this->m_lComponent.size() ) {
796
		list->PushBack("# Existing Ship, replaces an existing ship in the game with ship package instead of creating a new entry");
829
		list->PushBack("# Ship Components, each component used in the ships scene: <SECTION> <MODELENTRY> <VALUES>");
-
 
830
		for(CListNode<SComponent> *node = m_lComponent.Front(); node; node = node->next()) {
-
 
831
			list->PushBack(CyString("Component: ") + node->Data()->sSection + " " + node->Data()->sSection2 + " " + node->Data()->sData);
-
 
832
		}
-
 
833
		list->PushBack("");
-
 
834
	}
-
 
835
 
-
 
836
	if ( this->m_lDummy.size() ) {
-
 
837
		list->PushBack("# Ship Dummies, each dummy entry used in the ships scene: <SECTION> <VALUE>");
-
 
838
		for(CListNode<SDummy> *node = m_lDummy.Front(); node; node = node->next()) {
-
 
839
			list->PushBack(CyString("Dummy: ") + node->Data()->sSection + " " + node->Data()->sData);
-
 
840
		}
-
 
841
		list->PushBack("");
-
 
842
	}
-
 
843
 
-
 
844
	if ( this->m_lCockpit.size() ) {
-
 
845
		list->PushBack("# Cockpit entries, each cockpit value with thier weapons mask");
-
 
846
		for(CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next()) {
-
 
847
			list->PushBack(CyString("Cockpit: ") + node->Data()->sCockpit.token(";", 19) + " " + node->Data()->sCockpit);
-
 
848
			for(SWeaponMask *mask = node->Data()->lWeaponMask.First(); mask; mask = node->Data()->lWeaponMask.Next()) {
-
 
849
				list->PushBack(CyString("CockpitWeapon: ") + node->Data()->sCockpit.token(";", 19) + " " + (long)mask->iGame + " " + (long)mask->iMask);
-
 
850
			}
-
 
851
		}
-
 
852
 
-
 
853
		list->PushBack("");
-
 
854
	}
-
 
855
 
-
 
856
	if ( !this->m_lCutData.Empty() ) {
-
 
857
		list->PushBack("# Ship Cut Data");
-
 
858
		for(SStringList *str = m_lCutData.Head(); str; str = str->next) {
-
 
859
			list->PushBack(CyString("CutData: ") + str->str);
-
 
860
		}
-
 
861
		list->PushBack("");
-
 
862
	}
-
 
863
 
-
 
864
	if ( !this->m_lBodies.Empty() ) {
797
		list->PushBack("ExistingShip");
865
		list->PushBack("# Ship Bodies");
-
 
866
		for(SStringList *str = m_lBodies.Head(); str; str = str->next) {
-
 
867
			list->PushBack(CyString("Bodies: ") + str->str);
-
 
868
		}
-
 
869
		list->PushBack("");
-
 
870
	}
-
 
871
 
-
 
872
	if ( !this->m_lAnimations.Empty() ) {
-
 
873
		list->PushBack("# Ship Animations");
-
 
874
		for(SStringList *str = m_lAnimations.Head(); str; str = str->next) {
-
 
875
			list->PushBack(CyString("Animation: ") + str->str);
-
 
876
		}
798
		list->PushBack("");
877
		list->PushBack("");
799
	}
878
	}
800
 
879
 
801
	if ( !datafile )
880
	if ( !datafile )
802
	{
881
	{
Line 831... Line 910...
831
	}
910
	}
832
	else if ( sFirst.Compare("ExistingShip") )
911
	else if ( sFirst.Compare("ExistingShip") )
833
		m_bExistingShip = true;
912
		m_bExistingShip = true;
834
	else if ( sFirst.Compare("ShipID") )
913
	else if ( sFirst.Compare("ShipID") )
835
		m_sID = sRest;
914
		m_sID = sRest;
-
 
915
	else if ( sFirst.Compare("ShipText") )
-
 
916
		this->AddText(sRest.token(" ", 1).toLong(), sRest.tokens(" ", 2).token("|", 1), sRest.tokens(" ", 2).tokens("|", 2));
-
 
917
	else if ( sFirst.Compare("Component") )
-
 
918
		this->AddComponent(sRest.token(" ", 1), sRest.token(" ", 2), sRest.tokens(" ", 3));
-
 
919
	else if ( sFirst.Compare("Cockpit") )
-
 
920
		this->AddCockpit(sRest.tokens(" ", 2).replaceToken(";", 19, sRest.token(" ", 1)), 0);
-
 
921
	else if ( sFirst.Compare("CockpitWeapon") )
-
 
922
		this->AddCockpitWeapon(sRest.token(" ", 1), sRest.token(" ", 2), sRest.token(" ", 3));
-
 
923
	else if ( sFirst.Compare("WeaponMask") )
-
 
924
		this->AddWeaponMask(sRest.token(" ", 1), sRest.token(" ", 2));
-
 
925
	else if ( sFirst.Compare("MissileMask") )
-
 
926
		this->AddMissileMask(sRest.token(" ", 1), sRest.token(" ", 2));
-
 
927
	else if ( sFirst.Compare("Dummy") )
-
 
928
		this->AddDummy(sRest.token(" ", 1), sRest.token(" ", 2));
-
 
929
	else if ( sFirst.Compare("CutData") )
-
 
930
		this->AddCutData(sRest);
-
 
931
	else if ( sFirst.Compare("Animation") )
-
 
932
		this->AddAnimation(sRest);
-
 
933
	else if ( sFirst.Compare("Bodies") )
-
 
934
		this->AddBodies(sRest);
836
	else if ( !CBaseFile::LoadPackageData(sFirst, sRest, sMainGame, otherGames) )
935
	else if ( !CBaseFile::LoadPackageData(sFirst, sRest, sMainGame, otherGames) )
837
	{
936
	{
838
		return false;
937
		return false;
839
	}
938
	}
840
 
939
 
Line 860... Line 959...
860
			if ( sClass.Compare(CShipData::ConvertShipClass(CShipData::GetShipClassFromNum(i))) )
959
			if ( sClass.Compare(CShipData::ConvertShipClass(CShipData::GetShipClassFromNum(i))) )
861
			{
960
			{
862
				num = i;
961
				num = i;
863
				break;
962
				break;
864
			}
963
			}
865
		}
964
		}
866
 
965
 
867
		data = data.replaceToken(";", TSHIPPOS_CLASS, (long)num);
966
		data = data.replaceToken(";", TSHIPPOS_CLASS, (long)num);
868
	}
967
	}
869
 
968
 
870
	return data;
969
	return data;
871
}
970
}
872
 
971
 
873
Utils::String CXspFile::GetTCShipData()
972
Utils::String CXspFile::GetTCShipData()
874
{
973
{
875
	Utils::String data = m_sData;
974
	Utils::String data = m_sData;
876
 
975
 
877
	Utils::String sSubType = data.token(";", 6);
976
	Utils::String sSubType = data.token(";", 6);
878
	if ( ((long)sSubType) || sSubType == "0" )
977
	if ( ((long)sSubType) || sSubType == "0" )
879
		data = data.replaceToken(";", 6, CShipData::ConvertShipSubType((long)sSubType).ToString());
978
		data = data.replaceToken(";", 6, CShipData::ConvertShipSubType((long)sSubType).ToString());
880
 
979
 
881
	Utils::String sClass = data.token(";", TSHIPPOS_CLASS);
980
	Utils::String sClass = data.token(";", TSHIPPOS_CLASS);
882
	if ( ((long)sClass) || sClass == "0" )
981
	if ( ((long)sClass) || sClass == "0" )
883
		data = data.replaceToken(";", TSHIPPOS_CLASS, CShipData::ConvertShipClass((long)sClass));
982
		data = data.replaceToken(";", TSHIPPOS_CLASS, CShipData::ConvertShipClass((long)sClass));
884
 
983
 
885
	return data;
984
	return data;
886
}
985
}
887
 
986
 
888
bool CXspFile::RemoveCockpit(const Utils::String &sCockpitId)
987
bool CXspFile::RemoveCockpit(const Utils::String &sCockpitId)
889
{
988
{
Line 899... Line 998...
899
	bool ret = false;
998
	bool ret = false;
900
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
999
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
901
	{
1000
	{
902
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1001
		Utils::String id = node->Data()->sCockpit.token(";", 19);
903
		if ( id.Compare(cockpitid) )
1002
		if ( id.Compare(cockpitid) )
904
		{
1003
		{
905
			node->DeleteData();
1004
			node->DeleteData();
906
			ret = true;
1005
			ret = true;
907
			break;
1006
			break;
908
		}
1007
		}
909
	}
1008
	}
910
 
1009
 
Line 969... Line 1068...
969
 
1068
 
970
	return NULL;
1069
	return NULL;
971
}
1070
}
972
 
1071
 
973
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &cockpit)
1072
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &cockpit)
974
{
1073
{
975
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1074
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
976
	{
1075
	{
977
		Utils::String id = node->Data()->sCockpit.token(";", 19);
1076
		Utils::String id = node->Data()->sCockpit.token(";", 19);
978
		if ( id.Compare(cid) )
1077
		if ( id.Compare(cid) )
979
		{
1078
		{
980
			node->Data()->sCockpit = cockpit;
1079
			node->Data()->sCockpit = cockpit;
981
			break;
1080
			break;
982
		}
1081
		}
983
	}
1082
	}
984
}
1083
}
985
 
1084
 
986
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &scene, int mask)
1085
void CXspFile::EditCockpit(const Utils::String &cid, const Utils::String &scene, int mask)
987
{
1086
{
988
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
1087
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
Line 1012... Line 1111...
1012
{
1111
{
1013
	bool ret = false;
1112
	bool ret = false;
1014
	for ( SStringList *str = m_lCutData.Head(); str; str = str->next )
1113
	for ( SStringList *str = m_lCutData.Head(); str; str = str->next )
1015
	{
1114
	{
1016
		if ( str->str.GetToken(";", 1, 1).Compare(CyString(cut.token(";", 1))) )
1115
		if ( str->str.GetToken(";", 1, 1).Compare(CyString(cut.token(";", 1))) )
1017
		{
1116
		{
1018
			ret = true;
1117
			ret = true;
1019
			str->remove = true;
1118
			str->remove = true;
1020
			break;
1119
			break;
1021
		}
1120
		}
1022
	}
1121
	}
1023
 
1122
 
1024
	m_lCutData.RemoveMarked();
1123
	m_lCutData.RemoveMarked();
1025
 
1124
 
1026
	return ret;
1125
	return ret;
1027
}
1126
}
1028
 
1127
 
1029
bool CXspFile::RemoveBodies(const Utils::String &cut)
1128
bool CXspFile::RemoveBodies(const Utils::String &cut)
1030
{
1129
{
1031
	bool ret = false;
1130
	bool ret = false;
1032
	for ( SStringList *str = m_lBodies.Head(); str; str = str->next )
1131
	for ( SStringList *str = m_lBodies.Head(); str; str = str->next )
1033
	{
1132
	{
1034
		if ( str->str.Remove(' ').Compare(CyString(cut.remove(' '))) )
1133
		if ( str->str.Remove(' ').Compare(CyString(cut.remove(' '))) )
1035
		{
1134
		{
1036
			ret = true;
1135
			ret = true;
1037
			str->remove = true;
1136
			str->remove = true;
1038
			break;
1137
			break;
1039
		}
1138
		}
1040
	}
1139
	}
1041
 
1140
 
1042
	m_lBodies.RemoveMarked();
1141
	m_lBodies.RemoveMarked();
-
 
1142
 
-
 
1143
	return ret;
-
 
1144
}
-
 
1145
 
-
 
1146
bool CXspFile::RemoveAnimation(const Utils::String &cut)
-
 
1147
{
-
 
1148
	bool ret = false;
-
 
1149
	for ( SStringList *str = m_lAnimations.Head(); str; str = str->next )
-
 
1150
	{
-
 
1151
		if ( str->str.Remove(' ').Remove('\n').Compare(CyString(cut.remove(' ').remove('\n'))) )
-
 
1152
		{
-
 
1153
			ret = true;
-
 
1154
			str->remove = true;
-
 
1155
			break;
-
 
1156
		}
-
 
1157
	}
-
 
1158
 
-
 
1159
	m_lAnimations.RemoveMarked();
1043
 
1160
 
1044
	return ret;
1161
	return ret;
1045
}
1162
}
1046
 
1163
 
1047
bool CXspFile::RemoveAnimation(const Utils::String &cut)
1164
SCockpit *CXspFile::_findCockpit(const Utils::String &sID)
-
 
1165
{
-
 
1166
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() ) {
-
 
1167
		Utils::String id = node->Data()->sCockpit.token(";", 19);
-
 
1168
		if ( id.Compare(sID) )
-
 
1169
			return node->Data();
-
 
1170
	}
-
 
1171
 
-
 
1172
	return NULL;
-
 
1173
}
-
 
1174
 
-
 
1175
void CXspFile::AddCockpitWeapon(const Utils::String &cockpit, int game, int mask)
1048
{
1176
{
-
 
1177
	SCockpit *pCockpit = _findCockpit(cockpit);
-
 
1178
 
-
 
1179
	// search if the game mask already exists
1049
	bool ret = false;
1180
	SWeaponMask *wm = NULL;
1050
	for ( SStringList *str = m_lAnimations.Head(); str; str = str->next )
1181
	for ( CListNode<SWeaponMask> *node = pCockpit->lWeaponMask.Front(); node; node = node->next() )
1051
	{
1182
	{
1052
		if ( str->str.Remove(&apos; ').Remove('\n').Compare(CyString(cut.remove(' ').remove('\n&apos;))) )
1183
		if ( node->Data()-&gt;iGame == game )
1053
		{
1184
		{
1054
			ret = true;
-
 
1055
			str->remove = true;
1185
			wm = node->Data();
1056
			break;
1186
			break;
1057
		}
1187
		}
1058
	}
1188
	}
1059
 
1189
 
-
 
1190
	if ( !wm )
-
 
1191
	{
-
 
1192
		wm = new SWeaponMask;
1060
	m_lAnimations.RemoveMarked();
1193
		pCockpit->lWeaponMask.push_back(wm);
-
 
1194
	}
1061
 
1195
 
-
 
1196
	wm->iGame = game;
-
 
1197
	if ( mask == -1 )
-
 
1198
		wm->iMask = pCockpit->sCockpit.token(";", 9);
-
 
1199
	else
-
 
1200
		wm->iMask = mask;
1062
	return ret;
1201
	_changed();
1063
}
1202
}
1064
 
1203
 
1065
void CXspFile::AddCockpit(const Utils::String &cockpit, int game, int mask, int index)
1204
void CXspFile::AddCockpit(const Utils::String &cockpit, int game, int mask, int index)
1066
{
1205
{
1067
	SCockpit *pCockpit = NULL;
-
 
1068
 
-
 
1069
	// first search for the cockpit entry
-
 
1070
	Utils::String cid = cockpit.token(";", 19);
1206
	Utils::String cid = cockpit.token(";", 19);
1071
	for ( CListNode<SCockpit> *node = m_lCockpit.Front(); node; node = node->next() )
-
 
1072
	{
-
 
1073
		Utils::String id = node->Data()->sCockpit.token(";", 19);
-
 
1074
		if ( id.Compare(cid) )
-
 
1075
		{
-
 
1076
			pCockpit = node->Data();
1207
	SCockpit *pCockpit = _findCockpit(cid);
1077
			break;
-
 
1078
		}
-
 
1079
	}
-
 
1080
 
1208
 
1081
	if ( !pCockpit )
1209
	if ( !pCockpit )
1082
	{
1210
	{
1083
		pCockpit = new SCockpit;
1211
		pCockpit = new SCockpit;
1084
		pCockpit->sCockpit = cockpit;
1212
		pCockpit->sCockpit = cockpit;
1085
		pCockpit->iIndex = index;
1213
		pCockpit->iIndex = index;
Line 1088... Line 1216...
1088
	if ( index != -1 )
1216
	if ( index != -1 )
1089
		pCockpit->iIndex = index;
1217
		pCockpit->iIndex = index;
1090
 
1218
 
1091
	// now add the game mask
1219
	// now add the game mask
1092
	if ( game > 0 )
1220
	if ( game > 0 )
1093
	{
-
 
1094
		// search if the game mask already exists
-
 
1095
		SWeaponMask *wm = NULL;
-
 
1096
		for ( CListNode<SWeaponMask> *node = pCockpit->lWeaponMask.Front(); node; node = node->next() )
-
 
1097
		{
-
 
1098
			if ( node->Data()->iGame == game )
-
 
1099
			{
-
 
1100
				wm = node->Data();
-
 
1101
				break;
-
 
1102
			}
-
 
1103
		}
-
 
1104
 
-
 
1105
		if ( !wm )
-
 
1106
		{
-
 
1107
			wm = new SWeaponMask;
-
 
1108
			pCockpit->lWeaponMask.push_back(wm);
1221
		AddCockpitWeapon(cid, game, mask);
1109
		}
-
 
1110
 
-
 
1111
		wm->iGame = game;
-
 
1112
		if ( mask == -1 )
-
 
1113
			wm->iMask = cockpit.token(";", 9);
-
 
1114
		else
-
 
1115
			wm->iMask = mask;
-
 
1116
	}
-
 
1117
	_changed();
1222
	_changed();
1118
}
1223
}
1119
 
1224
 
1120
void CXspFile::AddBody(const Utils::String &section, const Utils::String &data)
1225
void CXspFile::AddBody(const Utils::String &section, const Utils::String &data)
1121
{
1226
{
Line 2062... Line 2167...
2062
		SInCatFile *f = node->Data();
2167
		SInCatFile *f = node->Data();
2063
		if ( !f->sFile.Left(2).Compare("t\\") && !f->sFile.Left(2).Compare("t/") )
2168
		if ( !f->sFile.Left(2).Compare("t\\") && !f->sFile.Left(2).Compare("t/") )
2064
			continue;
2169
			continue;
2065
 
2170
 
2066
		// extract the text file and read in the data
2171
		// extract the text file and read in the data
2067
		bool extracted = catFile->ExtractFile(f->sFile, CPackages::GetTempDirectory() + "tmp.dat");
2172
		bool extracted = catFile->ExtractFile(f->sFile, CPackages::GetTempDirectory() + "/tmp.dat");
2068
		if ( !extracted && secondCatFile ) extracted = secondCatFile->ExtractFile(f->sFile, CPackages::GetTempDirectory() + "tmp.dat");
2173
		if ( !extracted && secondCatFile ) extracted = secondCatFile->ExtractFile(f->sFile, CPackages::GetTempDirectory() + "/tmp.dat");
2069
		if ( extracted ) {
2174
		if ( extracted ) {
2070
			this->AddTextFromFile(CPackages::tempDirectory() + "tmp.dat", textId);
2175
			this->AddTextFromFile(CPackages::tempDirectory() + "/tmp.dat", textId);
2071
			CFileIO::Remove(CPackages::tempDirectory() + "tmp.dat");
2176
			CFileIO::Remove(CPackages::tempDirectory() + "/tmp.dat");
2072
		}
2177
		}
2073
	}
2178
	}
2074
}
2179
}
2075
 
2180
 
2076
bool CXspFile::processSceneFileSection(int section, CVirtualFileSystem *pVfs, CyStringList *lModels, CProgressInfo *progress)
2181
bool CXspFile::processSceneFileSection(int section, CVirtualFileSystem *pVfs, CyStringList *lModels, CProgressInfo *progress)