| 1 | cycrow | 1 |   | 
        
           |  |  | 2 | #include "ShipData.h"
 | 
        
           |  |  | 3 | #include "spkdef.h"
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 | CShipData::CShipData(void)
 | 
        
           |  |  | 6 | {
 | 
        
           |  |  | 7 | 	this->CreateDefault();
 | 
        
           |  |  | 8 | }
 | 
        
           |  |  | 9 |   | 
        
           |  |  | 10 | CShipData::~CShipData(void)
 | 
        
           |  |  | 11 | {
 | 
        
           |  |  | 12 | 	this->ClearLists();
 | 
        
           |  |  | 13 | }
 | 
        
           |  |  | 14 |   | 
        
           |  |  | 15 |   | 
        
           | 211 | cycrow | 16 | Utils::WString CShipData::createData() const
 | 
        
           | 1 | cycrow | 17 | {
 | 
        
           | 211 | cycrow | 18 | 	Utils::WString data = this->sModel;
 | 
        
           |  |  | 19 | 	data.addToken(L";", Utils::WString::Number(this->iPictureID));
 | 
        
           |  |  | 20 | 	data.addToken(L";", Utils::WString::FromFloat(this->fRotX, -1));
 | 
        
           |  |  | 21 | 	data.addToken(L";", Utils::WString::FromFloat(this->fRotY, -1));
 | 
        
           |  |  | 22 | 	data.addToken(L";", Utils::WString::FromFloat(this->fRotZ, -1));
 | 
        
           |  |  | 23 | 	data.addToken(L";", CShipData::ConvertShipSubType(this->iSubType));
 | 
        
           |  |  | 24 | 	data.addToken(L";", Utils::WString::Number(this->iDesc));
 | 
        
           |  |  | 25 | 	data.addToken(L";", Utils::WString::Number(this->iSpeed));
 | 
        
           |  |  | 26 | 	data.addToken(L";", Utils::WString::Number(this->iAccel));
 | 
        
           |  |  | 27 | 	data.addToken(L";", Utils::WString::Number(this->iEngineSound));
 | 
        
           |  |  | 28 | 	data.addToken(L";", Utils::WString::Number(this->iReactionDelay));
 | 
        
           |  |  | 29 | 	data.addToken(L";", Utils::WString::Number(this->iEngineEffect));
 | 
        
           |  |  | 30 | 	data.addToken(L";", Utils::WString::Number(this->iEngineGlow));
 | 
        
           |  |  | 31 | 	data.addToken(L";", Utils::WString::Number(this->iPower));
 | 
        
           |  |  | 32 | 	data.addToken(L";", Utils::WString::Number(this->iSoundMin));
 | 
        
           |  |  | 33 | 	data.addToken(L";", Utils::WString::Number(this->iSoundMax));
 | 
        
           |  |  | 34 | 	data.addToken(L";", this->sModelScene);
 | 
        
           |  |  | 35 | 	data.addToken(L";", this->sCockpitScene);
 | 
        
           |  |  | 36 | 	data.addToken(L";", Utils::WString::Number(this->iLaserMask));
 | 
        
           |  |  | 37 | 	data.addToken(L";", Utils::WString::Number(this->iGunCount));
 | 
        
           |  |  | 38 | 	data.addToken(L";", Utils::WString::Number(this->iLaserEnergy));
 | 
        
           |  |  | 39 | 	data.addToken(L";", Utils::WString::FromFloat(this->fLaserRecharge, -1));
 | 
        
           |  |  | 40 | 	data.addToken(L";", Utils::WString::Number(this->iShieldType));
 | 
        
           |  |  | 41 | 	data.addToken(L";", Utils::WString::Number(this->iMaxShields));
 | 
        
           |  |  | 42 | 	data.addToken(L";", Utils::WString::Number(this->iMissileMask));
 | 
        
           |  |  | 43 | 	data.addToken(L";", Utils::WString::Number(this->iMissileCount));
 | 
        
           |  |  | 44 | 	data.addToken(L";", Utils::WString::Number(this->iSpeedExtension));
 | 
        
           |  |  | 45 | 	data.addToken(L";", Utils::WString::Number(this->iSteeringExtension));
 | 
        
           |  |  | 46 | 	data.addToken(L";", Utils::WString::Number(this->iCargoMin));
 | 
        
           |  |  | 47 | 	data.addToken(L";", Utils::WString::Number(this->iCargoMax));
 | 
        
           |  |  | 48 | 	data.addToken(L";", Utils::WString::Number(this->iWareListID));
 | 
        
           | 1 | cycrow | 49 |   | 
        
           |  |  | 50 | 	// 6 turrets next
 | 
        
           |  |  | 51 | 	for ( int i = 0; i < 6; i++ )
 | 
        
           |  |  | 52 | 	{
 | 
        
           | 170 | cycrow | 53 | 		if ( this->cockpits[i].sCockpit.empty() )
 | 
        
           | 211 | cycrow | 54 | 			data.addToken(L";", Utils::WString::Number(this->cockpits[i].iCockpit));
 | 
        
           | 1 | cycrow | 55 | 		else
 | 
        
           |  |  | 56 | 		{
 | 
        
           |  |  | 57 | 			if ( this->cockpits[i].iCockpit > -1 )
 | 
        
           | 211 | cycrow | 58 | 				data.addToken(L";", this->cockpits[i].sCockpit + L"(" + (long)this->cockpits[i].iCockpit + L")");
 | 
        
           | 1 | cycrow | 59 | 			else
 | 
        
           | 211 | cycrow | 60 | 				data.addToken(L";", this->cockpits[i].sCockpit);
 | 
        
           | 1 | cycrow | 61 | 		}
 | 
        
           | 211 | cycrow | 62 | 		data.addToken(L";", Utils::WString::Number(this->cockpits[i].iPos));
 | 
        
           | 1 | cycrow | 63 | 	}
 | 
        
           |  |  | 64 |   | 
        
           | 211 | cycrow | 65 | 	data.addToken(L";", Utils::WString::Number(this->iDocking));
 | 
        
           |  |  | 66 | 	data.addToken(L";", Utils::WString::Number(this->iCargoClass));
 | 
        
           |  |  | 67 | 	data.addToken(L";", Utils::WString::Number(this->iRace));
 | 
        
           |  |  | 68 | 	data.addToken(L";", Utils::WString::Number(this->iHull));
 | 
        
           |  |  | 69 | 	data.addToken(L";", Utils::WString::Number(this->iExplosionDef));
 | 
        
           |  |  | 70 | 	data.addToken(L";", Utils::WString::Number(this->iExplosionBody));
 | 
        
           |  |  | 71 | 	data.addToken(L";", Utils::WString::Number(this->iParticle));
 | 
        
           |  |  | 72 | 	data.addToken(L";", Utils::WString::Number(this->iVariation));
 | 
        
           |  |  | 73 | 	data.addToken(L";", Utils::WString::Number(this->iRotationAccel));
 | 
        
           |  |  | 74 | 	data.addToken(L";", Utils::WString::Number(this->iClass));
 | 
        
           |  |  | 75 | 	data.addToken(L";", Utils::WString::Number(this->iTurretCount));
 | 
        
           | 1 | cycrow | 76 |   | 
        
           |  |  | 77 | 	// now do the turrets
 | 
        
           |  |  | 78 | 	for ( int i = 0; i < this->iTurretCount; i++ )
 | 
        
           |  |  | 79 | 	{
 | 
        
           |  |  | 80 | 		STurretEntry *t = this->lTurrets[i];
 | 
        
           | 211 | cycrow | 81 | 		data.addToken(L";", Utils::WString::Number(t->iIndex));
 | 
        
           |  |  | 82 | 		data.addToken(L";", Utils::WString::Number(t->iTurret));
 | 
        
           |  |  | 83 | 		data.addToken(L";", t->sModel);
 | 
        
           |  |  | 84 | 		data.addToken(L";", Utils::WString::Number(t->iSceneNode));
 | 
        
           | 1 | cycrow | 85 | 	}
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 | 	// the gun entries next
 | 
        
           | 211 | cycrow | 88 | 	data.addToken(L";", Utils::WString::Number(this->iGunsCount));
 | 
        
           | 1 | cycrow | 89 | 	for ( int i = 0; i < this->iGunsCount; i++ )
 | 
        
           |  |  | 90 | 	{
 | 
        
           |  |  | 91 | 		SGunGroup *g = this->lGuns[i];
 | 
        
           | 211 | cycrow | 92 | 		data.addToken(L";", Utils::WString::Number(g->iGunIndex));
 | 
        
           |  |  | 93 | 		data.addToken(L";", Utils::WString::Number(g->iLaserCount));
 | 
        
           |  |  | 94 | 		data.addToken(L";", Utils::WString::Number(g->iIndex));
 | 
        
           |  |  | 95 | 		data.addToken(L";", Utils::WString::Number(g->iWeaponCount));
 | 
        
           | 1 | cycrow | 96 | 		for ( int j = 0; j < g->iWeaponCount; j++ )
 | 
        
           |  |  | 97 | 		{
 | 
        
           |  |  | 98 | 			SWeaponGroup *w = g->lWeapons[j];
 | 
        
           | 211 | cycrow | 99 | 			data.addToken(L";", Utils::WString::Number(w->iGunIndex));
 | 
        
           |  |  | 100 | 			data.addToken(L";", Utils::WString::Number(w->iLaser));
 | 
        
           |  |  | 101 | 			data.addToken(L";", w->sModel1);
 | 
        
           |  |  | 102 | 			data.addToken(L";", Utils::WString::Number(w->iNode1));
 | 
        
           |  |  | 103 | 			data.addToken(L";", w->sModel2);
 | 
        
           |  |  | 104 | 			data.addToken(L";", Utils::WString::Number(w->iNode2));
 | 
        
           | 1 | cycrow | 105 | 		}
 | 
        
           |  |  | 106 | 	}
 | 
        
           |  |  | 107 |   | 
        
           |  |  | 108 | 	// now the rest of the data
 | 
        
           | 211 | cycrow | 109 | 	data.addToken(L";", Utils::WString::Number(this->iVolumn));
 | 
        
           |  |  | 110 | 	data.addToken(L";", Utils::WString::Number(this->iRelVal));
 | 
        
           |  |  | 111 | 	data.addToken(L";", Utils::WString::Number(this->iPriceMod1));
 | 
        
           |  |  | 112 | 	data.addToken(L";", Utils::WString::Number(this->iPriceMod2));
 | 
        
           |  |  | 113 | 	data.addToken(L";", Utils::WString::Number(this->iSize));
 | 
        
           |  |  | 114 | 	data.addToken(L";", Utils::WString::Number(this->iRelValPlayer));
 | 
        
           |  |  | 115 | 	data.addToken(L";", Utils::WString::Number(this->iMinNoto));
 | 
        
           |  |  | 116 | 	data.addToken(L";", Utils::WString::Number(this->iVideoID));
 | 
        
           |  |  | 117 | 	data.addToken(L";", Utils::WString::Number(this->iSkin));
 | 
        
           |  |  | 118 | 	data.addToken(L";", this->sID);
 | 
        
           |  |  | 119 | 	data += L";"; // add the end ;
 | 
        
           | 1 | cycrow | 120 |   | 
        
           |  |  | 121 | 	return data;
 | 
        
           |  |  | 122 | }
 | 
        
           |  |  | 123 |   | 
        
           |  |  | 124 | void CShipData::CreateDefault()
 | 
        
           |  |  | 125 | {
 | 
        
           | 211 | cycrow | 126 | 	this->sModel = L"0";
 | 
        
           | 1 | cycrow | 127 | 	this->iPictureID = 0;
 | 
        
           |  |  | 128 | 	this->fRotX = 0.00f;
 | 
        
           |  |  | 129 | 	this->fRotY = 0.00f;
 | 
        
           |  |  | 130 | 	this->fRotZ = 0.00f;
 | 
        
           |  |  | 131 | 	this->iSubType = 0;
 | 
        
           |  |  | 132 | 	this->iDesc = 0;
 | 
        
           |  |  | 133 | 	this->iSpeed = 0;
 | 
        
           |  |  | 134 | 	this->iAccel = 0;
 | 
        
           |  |  | 135 | 	this->iEngineSound = 106;
 | 
        
           |  |  | 136 | 	this->iReactionDelay = 1;
 | 
        
           |  |  | 137 | 	this->iEngineEffect = 5;
 | 
        
           |  |  | 138 | 	this->iEngineGlow = 37;
 | 
        
           |  |  | 139 | 	this->iPower = 0;
 | 
        
           |  |  | 140 | 	this->iSoundMin = 112;
 | 
        
           |  |  | 141 | 	this->iSoundMax = 202;
 | 
        
           | 211 | cycrow | 142 | 	this->sModelScene = L"";
 | 
        
           |  |  | 143 | 	this->sCockpitScene = L"";
 | 
        
           | 1 | cycrow | 144 | 	this->iLaserMask = 0;
 | 
        
           |  |  | 145 | 	this->iGunCount = 0;
 | 
        
           |  |  | 146 | 	this->iLaserEnergy = 0;
 | 
        
           |  |  | 147 | 	this->fLaserRecharge = 0.00f;
 | 
        
           |  |  | 148 | 	this->iShieldType = 0;
 | 
        
           |  |  | 149 | 	this->iMaxShields = 0;
 | 
        
           |  |  | 150 | 	this->iMissileMask = 0;
 | 
        
           |  |  | 151 | 	this->iMissileCount = 0;
 | 
        
           |  |  | 152 | 	this->iSpeedExtension = 0;
 | 
        
           |  |  | 153 | 	this->iSteeringExtension = 0;
 | 
        
           |  |  | 154 | 	this->iCargoMin = 0;
 | 
        
           |  |  | 155 | 	this->iCargoMax = 0;
 | 
        
           |  |  | 156 | 	this->iWareListID = 0;
 | 
        
           |  |  | 157 | 	this->iDocking = 0;
 | 
        
           |  |  | 158 | 	this->iCargoClass = 0;
 | 
        
           |  |  | 159 | 	this->iRace = 1;
 | 
        
           |  |  | 160 | 	this->iHull = 0;
 | 
        
           |  |  | 161 | 	this->iExplosionDef = 35;
 | 
        
           |  |  | 162 | 	this->iExplosionBody = 36;
 | 
        
           |  |  | 163 | 	this->iParticle = 1;
 | 
        
           |  |  | 164 | 	this->iVariation = 0;
 | 
        
           |  |  | 165 | 	this->iRotationAccel = 0;
 | 
        
           |  |  | 166 | 	this->iClass = 0;
 | 
        
           |  |  | 167 | 	this->iTurretCount = 0;
 | 
        
           |  |  | 168 | 	this->iGunsCount = 0;
 | 
        
           |  |  | 169 | 	this->iVolumn = 1;
 | 
        
           |  |  | 170 | 	this->iRelVal = 0;
 | 
        
           |  |  | 171 | 	this->iPriceMod1 = 25;
 | 
        
           |  |  | 172 | 	this->iPriceMod2 = 1;
 | 
        
           |  |  | 173 | 	this->iSize = 0;
 | 
        
           |  |  | 174 | 	this->iRelValPlayer = 0;
 | 
        
           |  |  | 175 | 	this->iMinNoto = 0;
 | 
        
           |  |  | 176 | 	this->iVideoID = 0;
 | 
        
           |  |  | 177 | 	this->iSkin = 0;
 | 
        
           | 197 | cycrow | 178 | 	this->sID = L"SC_NEW_SHIP";
 | 
        
           | 1 | cycrow | 179 |   | 
        
           |  |  | 180 | 	// make sure the lists are clear
 | 
        
           |  |  | 181 | 	this->ClearLists();
 | 
        
           |  |  | 182 | }
 | 
        
           |  |  | 183 |   | 
        
           |  |  | 184 | void CShipData::ClearLists() 
 | 
        
           |  |  | 185 | {
 | 
        
           |  |  | 186 | 	this->lTurrets.MemoryClear();
 | 
        
           |  |  | 187 | 	for ( SGunGroup *g = this->lGuns.First(); g; g = this->lGuns.Next() )
 | 
        
           |  |  | 188 | 		g->lWeapons.MemoryClear();
 | 
        
           |  |  | 189 | 	this->lGuns.MemoryClear();
 | 
        
           |  |  | 190 | }
 | 
        
           |  |  | 191 |   | 
        
           | 211 | cycrow | 192 | bool CShipData::readShipData(const Utils::WString &a_data)
 | 
        
           | 1 | cycrow | 193 | {
 | 
        
           | 211 | cycrow | 194 | 	std::vector<Utils::WString> entries;
 | 
        
           |  |  | 195 | 	a_data.tokenise(L";", entries);
 | 
        
           |  |  | 196 |   | 
        
           |  |  | 197 | 	if (entries.size() >= 60)
 | 
        
           | 1 | cycrow | 198 | 	{
 | 
        
           |  |  | 199 | 		this->sModel = entries[0];
 | 
        
           | 170 | cycrow | 200 | 		this->iPictureID = entries[1].toInt();
 | 
        
           |  |  | 201 | 		this->fRotX = entries[2].toFloat();
 | 
        
           |  |  | 202 | 		this->fRotY = entries[3].toFloat();
 | 
        
           |  |  | 203 | 		this->fRotZ = entries[4].toFloat();
 | 
        
           |  |  | 204 | 		if ( entries[5].isNumber() )
 | 
        
           |  |  | 205 | 			this->iSubType = entries[5].toInt();
 | 
        
           | 1 | cycrow | 206 | 		else
 | 
        
           |  |  | 207 | 			this->iSubType = CShipData::ConvertShipSubType(entries[5]);
 | 
        
           | 170 | cycrow | 208 | 		this->iDesc = entries[6].toInt();
 | 
        
           |  |  | 209 | 		this->iSpeed = entries[7].toInt();
 | 
        
           |  |  | 210 | 		this->iAccel = entries[8].toInt();
 | 
        
           |  |  | 211 | 		this->iEngineSound = entries[9].toInt();
 | 
        
           |  |  | 212 | 		this->iReactionDelay = entries[10].toInt();
 | 
        
           |  |  | 213 | 		this->iEngineEffect = entries[11].toInt();
 | 
        
           |  |  | 214 | 		this->iEngineGlow = entries[12].toInt();
 | 
        
           |  |  | 215 | 		this->iPower = entries[13].toInt();
 | 
        
           |  |  | 216 | 		this->iSoundMin = entries[14].toInt();
 | 
        
           |  |  | 217 | 		this->iSoundMax = entries[15].toInt();
 | 
        
           | 1 | cycrow | 218 | 		this->sModelScene = entries[16];
 | 
        
           |  |  | 219 | 		this->sCockpitScene = entries[17];
 | 
        
           | 170 | cycrow | 220 | 		this->iLaserMask = entries[18].toInt();
 | 
        
           |  |  | 221 | 		this->iGunCount = entries[19].toInt();
 | 
        
           |  |  | 222 | 		this->iLaserEnergy = entries[20].toInt();
 | 
        
           |  |  | 223 | 		this->fLaserRecharge = entries[21].toFloat();
 | 
        
           |  |  | 224 | 		this->iShieldType = entries[22].toInt();
 | 
        
           |  |  | 225 | 		this->iMaxShields = entries[23].toInt();
 | 
        
           |  |  | 226 | 		this->iMissileMask = entries[24].toInt();
 | 
        
           |  |  | 227 | 		this->iMissileCount = entries[25].toInt();
 | 
        
           |  |  | 228 | 		this->iSpeedExtension = entries[26].toInt();
 | 
        
           |  |  | 229 | 		this->iSteeringExtension = entries[27].toInt();
 | 
        
           |  |  | 230 | 		this->iCargoMin = entries[28].toInt();
 | 
        
           |  |  | 231 | 		this->iCargoMax = entries[29].toInt();
 | 
        
           |  |  | 232 | 		this->iWareListID = entries[30].toInt();
 | 
        
           | 1 | cycrow | 233 |   | 
        
           |  |  | 234 | 		for ( int i = 0; i < 6; i++ )
 | 
        
           |  |  | 235 | 		{
 | 
        
           | 170 | cycrow | 236 | 			this->cockpits[i].iPos = entries[(i * 2) + 32].toInt();
 | 
        
           |  |  | 237 | 			if ( entries[(i * 2) + 31].isNumber() )
 | 
        
           |  |  | 238 | 				this->cockpits[i].iCockpit = entries[(i * 2) + 31].toInt();
 | 
        
           | 1 | cycrow | 239 | 			else
 | 
        
           |  |  | 240 | 			{
 | 
        
           |  |  | 241 | 				this->cockpits[i].sCockpit = entries[(i * 2) + 31];
 | 
        
           |  |  | 242 | 				this->cockpits[i].iCockpit = -1; // custom cockpit
 | 
        
           | 211 | cycrow | 243 | 				if ( this->cockpits[i].sCockpit.contains(L"(") ) {
 | 
        
           |  |  | 244 | 					this->cockpits[i].iCockpit = this->cockpits[i].sCockpit.tokens(L"(", 2).token(L")", 1).toInt();
 | 
        
           |  |  | 245 | 					this->cockpits[i].sCockpit = this->cockpits[i].sCockpit.token(L"(", 1);
 | 
        
           | 39 | cycrow | 246 | 				}
 | 
        
           | 1 | cycrow | 247 | 			}
 | 
        
           |  |  | 248 | 		}
 | 
        
           |  |  | 249 |   | 
        
           | 170 | cycrow | 250 | 		this->iDocking = entries[43].toInt();
 | 
        
           |  |  | 251 | 		this->iCargoClass = entries[44].toInt();
 | 
        
           |  |  | 252 | 		this->iRace = entries[45].toInt();
 | 
        
           |  |  | 253 | 		this->iHull = entries[46].toInt();
 | 
        
           |  |  | 254 | 		this->iExplosionDef = entries[47].toInt();
 | 
        
           |  |  | 255 | 		this->iExplosionBody = entries[48].toInt();
 | 
        
           |  |  | 256 | 		this->iParticle = entries[49].toInt();
 | 
        
           |  |  | 257 | 		this->iVariation = entries[50].toInt();
 | 
        
           |  |  | 258 | 		this->iRotationAccel = entries[51].toInt();
 | 
        
           |  |  | 259 | 		if ( entries[52].isNumber() )
 | 
        
           |  |  | 260 | 			this->iClass = entries[52].toInt();
 | 
        
           | 1 | cycrow | 261 | 		else
 | 
        
           | 170 | cycrow | 262 | 			this->iClass = CShipData::ConvertShipClass(entries[52]);
 | 
        
           |  |  | 263 | 		this->iTurretCount = entries[53].toInt();
 | 
        
           | 1 | cycrow | 264 |   | 
        
           |  |  | 265 | 		// now read in the turret data
 | 
        
           |  |  | 266 | 		int pos = 54;
 | 
        
           |  |  | 267 | 		for ( int i = 0; i < this->iTurretCount; i++ )
 | 
        
           |  |  | 268 | 		{
 | 
        
           |  |  | 269 | 			STurretEntry *t = new STurretEntry;
 | 
        
           | 170 | cycrow | 270 | 			t->iIndex = entries[pos].toInt();
 | 
        
           |  |  | 271 | 			t->iTurret = entries[pos + 1].toInt();
 | 
        
           | 1 | cycrow | 272 | 			t->sModel = entries[pos + 2];
 | 
        
           | 170 | cycrow | 273 | 			t->iSceneNode = entries[pos + 3].toInt();
 | 
        
           | 1 | cycrow | 274 | 			this->lTurrets.push_back(t);
 | 
        
           |  |  | 275 | 			pos += 4;
 | 
        
           |  |  | 276 | 		}
 | 
        
           |  |  | 277 |   | 
        
           |  |  | 278 | 		if ( this->iTurretCount == 0 )
 | 
        
           |  |  | 279 | 		{
 | 
        
           |  |  | 280 | 			this->iTurretCount = 1;
 | 
        
           |  |  | 281 | 			STurretEntry *t = this->lTurrets.push_back(new STurretEntry);
 | 
        
           |  |  | 282 | 			t->iIndex = 0;
 | 
        
           |  |  | 283 | 			t->iTurret = 1;
 | 
        
           |  |  | 284 | 			t->iSceneNode = 0;
 | 
        
           | 211 | cycrow | 285 | 			t->sModel = L"0";
 | 
        
           | 1 | cycrow | 286 | 		}
 | 
        
           |  |  | 287 |   | 
        
           |  |  | 288 | 		// next pos should be gun count
 | 
        
           | 170 | cycrow | 289 | 		this->iGunsCount = entries[pos].toInt();
 | 
        
           | 1 | cycrow | 290 | 		++pos;
 | 
        
           |  |  | 291 | 		for ( int i = 0; i < this->iGunsCount; i++ )
 | 
        
           |  |  | 292 | 		{
 | 
        
           |  |  | 293 | 			SGunGroup *gun = new SGunGroup;
 | 
        
           | 170 | cycrow | 294 | 			gun->iGunIndex = entries[pos].toInt();
 | 
        
           |  |  | 295 | 			gun->iLaserCount = entries[pos + 1].toInt();
 | 
        
           |  |  | 296 | 			gun->iIndex = entries[pos + 2].toInt();
 | 
        
           |  |  | 297 | 			gun->iWeaponCount = entries[pos + 3].toInt();
 | 
        
           | 1 | cycrow | 298 | 			pos += 4;
 | 
        
           |  |  | 299 |   | 
        
           |  |  | 300 | 			for ( int j = 0; j < gun->iWeaponCount; j++ )
 | 
        
           |  |  | 301 | 			{
 | 
        
           |  |  | 302 | 				SWeaponGroup *weapon = new SWeaponGroup;
 | 
        
           | 170 | cycrow | 303 | 				weapon->iGunIndex = entries[pos].toInt();
 | 
        
           |  |  | 304 | 				weapon->iLaser = entries[pos + 1].toInt();
 | 
        
           | 1 | cycrow | 305 | 				weapon->sModel1 = entries[pos + 2];
 | 
        
           | 170 | cycrow | 306 | 				weapon->iNode1 = entries[pos + 3].toInt();
 | 
        
           | 1 | cycrow | 307 | 				weapon->sModel2 = entries[pos + 4];
 | 
        
           | 170 | cycrow | 308 | 				weapon->iNode2 = entries[pos + 5].toInt();
 | 
        
           | 1 | cycrow | 309 |   | 
        
           |  |  | 310 | 				pos += 6;
 | 
        
           |  |  | 311 | 				gun->lWeapons.push_back(weapon);
 | 
        
           |  |  | 312 | 			}
 | 
        
           |  |  | 313 |   | 
        
           |  |  | 314 | 			this->lGuns.push_back(gun);
 | 
        
           |  |  | 315 | 		}
 | 
        
           |  |  | 316 |   | 
        
           |  |  | 317 | 		if ( !this->iGunsCount )
 | 
        
           |  |  | 318 | 		{
 | 
        
           |  |  | 319 | 			this->iGunCount = 1;
 | 
        
           |  |  | 320 | 			SGunGroup *gun = this->lGuns.push_back(new SGunGroup);
 | 
        
           |  |  | 321 | 			gun->iGunIndex = 0;
 | 
        
           |  |  | 322 | 			gun->iIndex = 0;
 | 
        
           |  |  | 323 | 			gun->iLaserCount = 0;
 | 
        
           |  |  | 324 | 			gun->iWeaponCount = 0;
 | 
        
           |  |  | 325 | 		}
 | 
        
           |  |  | 326 |   | 
        
           | 170 | cycrow | 327 | 		this->iVolumn = entries[pos].toInt();
 | 
        
           |  |  | 328 | 		this->iRelVal = entries[pos + 1].toInt();
 | 
        
           |  |  | 329 | 		this->iPriceMod1 = entries[pos + 2].toInt();
 | 
        
           |  |  | 330 | 		this->iPriceMod2 = entries[pos + 3].toInt();
 | 
        
           |  |  | 331 | 		this->iSize = entries[pos + 4].toInt();
 | 
        
           |  |  | 332 | 		this->iRelValPlayer = entries[pos + 5].toInt();
 | 
        
           |  |  | 333 | 		this->iMinNoto = entries[pos + 6].toInt();
 | 
        
           |  |  | 334 | 		this->iVideoID = entries[pos + 7].toInt();
 | 
        
           |  |  | 335 | 		this->iSkin = entries[pos + 8].toInt();
 | 
        
           | 211 | cycrow | 336 | 		this->sID = entries[pos + 9];
 | 
        
           | 1 | cycrow | 337 |   | 
        
           |  |  | 338 | 		this->UpdateGunEntries();
 | 
        
           |  |  | 339 |   | 
        
           | 59 | cycrow | 340 | 		this->_capValues();
 | 
        
           |  |  | 341 |   | 
        
           | 1 | cycrow | 342 | 		return true;
 | 
        
           |  |  | 343 | 	}
 | 
        
           |  |  | 344 |   | 
        
           |  |  | 345 | 	return false;
 | 
        
           |  |  | 346 | }
 | 
        
           |  |  | 347 |   | 
        
           | 59 | cycrow | 348 | void CShipData::_capValues()
 | 
        
           |  |  | 349 | {
 | 
        
           |  |  | 350 | 	if ( this->iRelVal > 25000000 ) this->iRelVal = 25000000;
 | 
        
           |  |  | 351 | 	if ( this->iRelValPlayer > 25000000 ) this->iRelValPlayer = 25000000;
 | 
        
           |  |  | 352 | }
 | 
        
           |  |  | 353 |   | 
        
           |  |  | 354 |   | 
        
           | 1 | cycrow | 355 | int CShipData::GetShipClassFromNum(int shipclass)
 | 
        
           |  |  | 356 | {
 | 
        
           |  |  | 357 | 	int classes[OBJ_SHIP_MAX];
 | 
        
           |  |  | 358 | 	classes[0] = OBJ_SHIP_TL;
 | 
        
           |  |  | 359 | 	classes[1] = OBJ_SHIP_TS;
 | 
        
           |  |  | 360 | 	classes[2] = OBJ_SHIP_TP;
 | 
        
           |  |  | 361 | 	classes[3] = OBJ_SHIP_TM;
 | 
        
           |  |  | 362 | 	classes[4] = OBJ_SHIP_TL_PIRATE;
 | 
        
           |  |  | 363 | 	classes[5] = OBJ_SHIP_TS_PIRATE;
 | 
        
           |  |  | 364 | 	classes[6] = OBJ_SHIP_GONER;
 | 
        
           |  |  | 365 | 	classes[7] = OBJ_SHIP_M0;
 | 
        
           |  |  | 366 | 	classes[8] = OBJ_SHIP_M1;
 | 
        
           |  |  | 367 | 	classes[9] = OBJ_SHIP_M2;
 | 
        
           |  |  | 368 | 	classes[10] = OBJ_SHIP_M3;
 | 
        
           |  |  | 369 | 	classes[11] = OBJ_SHIP_M4;
 | 
        
           |  |  | 370 | 	classes[12] = OBJ_SHIP_M5;
 | 
        
           |  |  | 371 | 	classes[13] = OBJ_SHIP_M6;
 | 
        
           |  |  | 372 | 	classes[14] = OBJ_SHIP_M7;
 | 
        
           |  |  | 373 | 	classes[15] = OBJ_SHIP_M8;
 | 
        
           |  |  | 374 |   | 
        
           |  |  | 375 | 	return classes[shipclass];
 | 
        
           |  |  | 376 | }
 | 
        
           |  |  | 377 |   | 
        
           |  |  | 378 | int CShipData::ConvertShipClassToNum(int shipclass)
 | 
        
           |  |  | 379 | {
 | 
        
           |  |  | 380 | 	int classes[OBJ_SHIP_MAX];
 | 
        
           |  |  | 381 | 	classes[0] = OBJ_SHIP_TL;
 | 
        
           |  |  | 382 | 	classes[1] = OBJ_SHIP_TS;
 | 
        
           |  |  | 383 | 	classes[2] = OBJ_SHIP_TP;
 | 
        
           |  |  | 384 | 	classes[3] = OBJ_SHIP_TM;
 | 
        
           |  |  | 385 | 	classes[4] = OBJ_SHIP_TL_PIRATE;
 | 
        
           |  |  | 386 | 	classes[5] = OBJ_SHIP_TS_PIRATE;
 | 
        
           |  |  | 387 | 	classes[6] = OBJ_SHIP_GONER;
 | 
        
           |  |  | 388 | 	classes[7] = OBJ_SHIP_M0;
 | 
        
           |  |  | 389 | 	classes[8] = OBJ_SHIP_M1;
 | 
        
           |  |  | 390 | 	classes[9] = OBJ_SHIP_M2;
 | 
        
           |  |  | 391 | 	classes[10] = OBJ_SHIP_M3;
 | 
        
           |  |  | 392 | 	classes[11] = OBJ_SHIP_M4;
 | 
        
           |  |  | 393 | 	classes[12] = OBJ_SHIP_M5;
 | 
        
           |  |  | 394 | 	classes[13] = OBJ_SHIP_M6;
 | 
        
           |  |  | 395 | 	classes[14] = OBJ_SHIP_M7;
 | 
        
           |  |  | 396 | 	classes[15] = OBJ_SHIP_M8;
 | 
        
           |  |  | 397 |   | 
        
           |  |  | 398 | 	for ( int i = 0; i < OBJ_SHIP_MAX; i++ )
 | 
        
           |  |  | 399 | 	{
 | 
        
           |  |  | 400 | 		if ( classes[i] == shipclass )
 | 
        
           |  |  | 401 | 			return i;
 | 
        
           |  |  | 402 | 	}
 | 
        
           |  |  | 403 |   | 
        
           |  |  | 404 | 	return 0;
 | 
        
           |  |  | 405 | }
 | 
        
           |  |  | 406 |   | 
        
           | 211 | cycrow | 407 | int CShipData::ConvertShipClass(const Utils::WString &shipclass)
 | 
        
           | 1 | cycrow | 408 | {
 | 
        
           |  |  | 409 | 	for ( int i = 0; i < OBJ_SHIP_MAX; i++ )
 | 
        
           |  |  | 410 | 	{
 | 
        
           |  |  | 411 | 		int c = CShipData::GetShipClassFromNum(i);
 | 
        
           |  |  | 412 | 		if ( CShipData::ConvertShipClass(c).Compare(shipclass) )
 | 
        
           |  |  | 413 | 			return c;
 | 
        
           |  |  | 414 | 	}
 | 
        
           |  |  | 415 |   | 
        
           |  |  | 416 | 	return OBJ_SHIP_TL;
 | 
        
           |  |  | 417 | }
 | 
        
           |  |  | 418 |   | 
        
           | 211 | cycrow | 419 | Utils::WString CShipData::ConvertShipClass(int shipclass)
 | 
        
           | 1 | cycrow | 420 | {
 | 
        
           |  |  | 421 | 	switch ( shipclass )
 | 
        
           |  |  | 422 | 	{
 | 
        
           |  |  | 423 | 		case OBJ_SHIP_TL:
 | 
        
           | 211 | cycrow | 424 | 			return L"OBJ_SHIP_TL";
 | 
        
           | 1 | cycrow | 425 | 		case OBJ_SHIP_TS:
 | 
        
           | 211 | cycrow | 426 | 			return L"OBJ_SHIP_TS";
 | 
        
           | 1 | cycrow | 427 | 		case OBJ_SHIP_TP:
 | 
        
           | 211 | cycrow | 428 | 			return L"OBJ_SHIP_TP";
 | 
        
           | 1 | cycrow | 429 | 		case OBJ_SHIP_TM:
 | 
        
           | 211 | cycrow | 430 | 			return L"OBJ_SHIP_TS";
 | 
        
           | 1 | cycrow | 431 | 		case OBJ_SHIP_TL_PIRATE:
 | 
        
           | 211 | cycrow | 432 | 			return L"OBJ_SHIP_TL_PIRATE";
 | 
        
           | 1 | cycrow | 433 | 		case OBJ_SHIP_TS_PIRATE:
 | 
        
           | 211 | cycrow | 434 | 			return L"OBJ_SHIP_TS_PIRATE";
 | 
        
           | 1 | cycrow | 435 | 		case OBJ_SHIP_GONER:
 | 
        
           | 211 | cycrow | 436 | 			return L"OBJ_SHIP_GONER";
 | 
        
           | 1 | cycrow | 437 | 		case OBJ_SHIP_M0:
 | 
        
           | 211 | cycrow | 438 | 			return L"OBJ_SHIP_M0";
 | 
        
           | 1 | cycrow | 439 | 		case OBJ_SHIP_M1:
 | 
        
           | 211 | cycrow | 440 | 			return L"OBJ_SHIP_M1";
 | 
        
           | 1 | cycrow | 441 | 		case OBJ_SHIP_M2:
 | 
        
           | 211 | cycrow | 442 | 			return L"OBJ_SHIP_M2";
 | 
        
           | 1 | cycrow | 443 | 		case OBJ_SHIP_M3:
 | 
        
           | 211 | cycrow | 444 | 			return L"OBJ_SHIP_M3";
 | 
        
           | 1 | cycrow | 445 | 		case OBJ_SHIP_M4:
 | 
        
           | 211 | cycrow | 446 | 			return L"OBJ_SHIP_M4";
 | 
        
           | 1 | cycrow | 447 | 		case OBJ_SHIP_M5:
 | 
        
           | 211 | cycrow | 448 | 			return L"OBJ_SHIP_M5";
 | 
        
           | 1 | cycrow | 449 | 		case OBJ_SHIP_M6:
 | 
        
           | 211 | cycrow | 450 | 			return L"OBJ_SHIP_M6";
 | 
        
           | 1 | cycrow | 451 | 		case OBJ_SHIP_M7:
 | 
        
           | 211 | cycrow | 452 | 			return L"OBJ_SHIP_M7";
 | 
        
           | 1 | cycrow | 453 | 		case OBJ_SHIP_M8:
 | 
        
           | 211 | cycrow | 454 | 			return L"OBJ_SHIP_M8";
 | 
        
           | 1 | cycrow | 455 | 	}
 | 
        
           |  |  | 456 |   | 
        
           | 211 | cycrow | 457 | 	return L"OBJ_SHIP_TL";
 | 
        
           | 1 | cycrow | 458 | }
 | 
        
           |  |  | 459 |   | 
        
           | 211 | cycrow | 460 | Utils::WString CShipData::ConvertShipSubType(int subtype)
 | 
        
           | 1 | cycrow | 461 | {
 | 
        
           |  |  | 462 | 	switch ( subtype )
 | 
        
           |  |  | 463 | 	{
 | 
        
           |  |  | 464 | 		case SG_SH_TL:
 | 
        
           | 211 | cycrow | 465 | 			return L"SG_SH_TL";
 | 
        
           | 1 | cycrow | 466 | 		case SG_SH_TS:
 | 
        
           | 211 | cycrow | 467 | 			return L"SG_SH_TS";
 | 
        
           | 1 | cycrow | 468 | 		case SG_SH_M0:
 | 
        
           | 211 | cycrow | 469 | 			return L"SG_SH_M0";
 | 
        
           | 1 | cycrow | 470 | 		case SG_SH_M1:
 | 
        
           | 211 | cycrow | 471 | 			return L"SG_SH_M1";
 | 
        
           | 1 | cycrow | 472 | 		case SG_SH_M2:
 | 
        
           | 211 | cycrow | 473 | 			return L"SG_SH_M2";
 | 
        
           | 1 | cycrow | 474 | 		case SG_SH_M3:
 | 
        
           | 211 | cycrow | 475 | 			return L"SG_SH_M3";
 | 
        
           | 1 | cycrow | 476 | 		case SG_SH_M4:
 | 
        
           | 211 | cycrow | 477 | 			return L"SG_SH_M4";
 | 
        
           | 1 | cycrow | 478 | 		case SG_SH_M5:
 | 
        
           | 211 | cycrow | 479 | 			return L"SG_SH_M5";
 | 
        
           | 1 | cycrow | 480 | 		case SG_SH_TL_P:
 | 
        
           | 211 | cycrow | 481 | 			return L"SG_SH_TL_P";
 | 
        
           | 1 | cycrow | 482 | 		case SG_SH_TS_P:
 | 
        
           | 211 | cycrow | 483 | 			return L"SG_SH_TS_P";
 | 
        
           | 1 | cycrow | 484 | 		case SG_SH_GO:
 | 
        
           | 211 | cycrow | 485 | 			return L"SG_SH_GO";
 | 
        
           | 1 | cycrow | 486 | 		case SG_SH_M6:
 | 
        
           | 211 | cycrow | 487 | 			return L"SG_SH_M6";
 | 
        
           | 1 | cycrow | 488 | 		case SG_SH_TP:
 | 
        
           | 211 | cycrow | 489 | 			return L"SG_SH_TP";
 | 
        
           | 1 | cycrow | 490 | 		case SG_SH_M7:
 | 
        
           | 211 | cycrow | 491 | 			return L"SG_SH_M7";
 | 
        
           | 1 | cycrow | 492 | 		case SG_SH_TM:
 | 
        
           | 211 | cycrow | 493 | 			return L"SG_SH_TM";
 | 
        
           | 1 | cycrow | 494 | 		case SG_SH_M8:
 | 
        
           | 211 | cycrow | 495 | 			return L"SG_SH_M8";
 | 
        
           | 1 | cycrow | 496 | 	}
 | 
        
           |  |  | 497 |   | 
        
           | 211 | cycrow | 498 | 	return L"SG_SH_TL";
 | 
        
           | 1 | cycrow | 499 | }
 | 
        
           |  |  | 500 |   | 
        
           | 211 | cycrow | 501 | int CShipData::ConvertShipSubType(const Utils::WString &subtype)
 | 
        
           | 1 | cycrow | 502 | {
 | 
        
           |  |  | 503 | 	int num = 0;
 | 
        
           |  |  | 504 | 	for ( int i = 0; i < SG_SH_MAX; i++ )
 | 
        
           |  |  | 505 | 	{
 | 
        
           |  |  | 506 | 		if ( subtype.Compare(CShipData::ConvertShipSubType(i)) )
 | 
        
           |  |  | 507 | 			return i;
 | 
        
           |  |  | 508 | 	}
 | 
        
           |  |  | 509 |   | 
        
           |  |  | 510 | 	return 0;
 | 
        
           |  |  | 511 | }
 | 
        
           |  |  | 512 |   | 
        
           |  |  | 513 | void CShipData::RemoveTurret(int t)
 | 
        
           |  |  | 514 | {
 | 
        
           |  |  | 515 | 	if ( t >= 1 && t <= 6 )
 | 
        
           |  |  | 516 | 	{
 | 
        
           |  |  | 517 | 		if ( t >= this->lTurrets.size() )
 | 
        
           |  |  | 518 | 			return;
 | 
        
           |  |  | 519 |   | 
        
           |  |  | 520 | 		// remove the turret entry
 | 
        
           |  |  | 521 | 		this->lTurrets.erase(t, true);
 | 
        
           |  |  | 522 | 		int index = 0;
 | 
        
           |  |  | 523 | 		for ( CListNode<STurretEntry> *node = this->lTurrets.Front(); node; node = node->next() )
 | 
        
           |  |  | 524 | 		{
 | 
        
           |  |  | 525 | 			node->Data()->iTurret = index;
 | 
        
           |  |  | 526 | 			++index;
 | 
        
           |  |  | 527 | 			node->Data()->iIndex = index;
 | 
        
           |  |  | 528 | 		}
 | 
        
           |  |  | 529 | 		--this->iTurretCount;
 | 
        
           |  |  | 530 |   | 
        
           |  |  | 531 | 		// shuffle the other entries
 | 
        
           |  |  | 532 | 		for ( int i = (t - 1); i < 5; i++ )
 | 
        
           |  |  | 533 | 		{
 | 
        
           |  |  | 534 | 			this->cockpits[i].iCockpit = this->cockpits[i + 1].iCockpit;
 | 
        
           |  |  | 535 | 			this->cockpits[i].iPos  = this->cockpits[i + 1].iPos;
 | 
        
           |  |  | 536 | 			this->cockpits[i].sCockpit = this->cockpits[i + 1].sCockpit;
 | 
        
           |  |  | 537 | 		}
 | 
        
           |  |  | 538 |   | 
        
           |  |  | 539 | 		// zero out the remaining
 | 
        
           |  |  | 540 | 		this->cockpits[5].iCockpit = 0;
 | 
        
           |  |  | 541 | 		this->cockpits[5].iPos = 0;
 | 
        
           | 211 | cycrow | 542 | 		this->cockpits[5].sCockpit = L"";
 | 
        
           | 1 | cycrow | 543 |   | 
        
           |  |  | 544 | 		// now remove the gun entries connected to the turret
 | 
        
           |  |  | 545 | 		SGunGroup *g = this->lGuns.Get(t);
 | 
        
           |  |  | 546 | 		if ( g )
 | 
        
           |  |  | 547 | 		{
 | 
        
           |  |  | 548 | 			g->lWeapons.MemoryClear();
 | 
        
           |  |  | 549 | 			this->lGuns.remove(g, true);
 | 
        
           |  |  | 550 | 			--this->iGunsCount;
 | 
        
           |  |  | 551 | 		}
 | 
        
           |  |  | 552 |   | 
        
           |  |  | 553 | 		// now we need to readjust the gun entrys
 | 
        
           |  |  | 554 | 		this->UpdateGunEntries();
 | 
        
           |  |  | 555 | 	}
 | 
        
           |  |  | 556 | }
 | 
        
           |  |  | 557 |   | 
        
           |  |  | 558 | void CShipData::UpdateGunEntries()
 | 
        
           |  |  | 559 | {
 | 
        
           |  |  | 560 | 	int index = 1;
 | 
        
           |  |  | 561 | 	int count = 1;
 | 
        
           |  |  | 562 | 	int gunindex = 1;
 | 
        
           |  |  | 563 | 	this->iGunCount = 0;
 | 
        
           |  |  | 564 | 	for ( CListNode<SGunGroup> *node = this->lGuns.Front(); node; node = node->next() )
 | 
        
           |  |  | 565 | 	{
 | 
        
           |  |  | 566 | 		SGunGroup *g = node->Data();
 | 
        
           |  |  | 567 |   | 
        
           |  |  | 568 | 		g->iLaserCount = 0;
 | 
        
           |  |  | 569 | 		for ( CListNode<SWeaponGroup> *wNode = g->lWeapons.Front(); wNode; wNode = wNode->next() )
 | 
        
           |  |  | 570 | 		{
 | 
        
           |  |  | 571 | 			SWeaponGroup *w = wNode->Data();
 | 
        
           |  |  | 572 |   | 
        
           | 211 | cycrow | 573 | 			if ( (w->iNode1 > 0 || (w->iNode1 == 0 && w->sModel1 != L"0")) && !w->sModel1.empty() )
 | 
        
           | 1 | cycrow | 574 | 			{
 | 
        
           |  |  | 575 | 				w->iLaser = 1;
 | 
        
           | 211 | cycrow | 576 | 				if ( (w->iNode2 > 0 || (w->iNode2 == 0 && w->sModel2 != L"0")) && !w->sModel2.empty() )
 | 
        
           | 1 | cycrow | 577 | 					w->iLaser = 2;
 | 
        
           |  |  | 578 | 			}
 | 
        
           |  |  | 579 | 			else
 | 
        
           |  |  | 580 | 			{
 | 
        
           |  |  | 581 | 				w->iLaser = 0;
 | 
        
           |  |  | 582 | 				w->iNode2 = -1;
 | 
        
           | 211 | cycrow | 583 | 				w->sModel2 = L"";
 | 
        
           | 1 | cycrow | 584 | 			}
 | 
        
           |  |  | 585 |   | 
        
           |  |  | 586 | 			w->iGunIndex = gunindex;
 | 
        
           |  |  | 587 | 			gunindex += w->iLaser;
 | 
        
           |  |  | 588 | 			g->iLaserCount += w->iLaser;
 | 
        
           |  |  | 589 | 		}
 | 
        
           |  |  | 590 |   | 
        
           |  |  | 591 | 		g->iWeaponCount = g->lWeapons.size();
 | 
        
           |  |  | 592 |   | 
        
           |  |  | 593 | 		g->iGunIndex = index;
 | 
        
           |  |  | 594 | 		index += g->iLaserCount;
 | 
        
           |  |  | 595 | 		this->iGunCount += g->iLaserCount;
 | 
        
           |  |  | 596 | 		g->iIndex = count;
 | 
        
           |  |  | 597 | 		++count;
 | 
        
           |  |  | 598 | 	}
 | 
        
           |  |  | 599 |   | 
        
           |  |  | 600 | 	this->iTurretCount = this->lTurrets.size();
 | 
        
           |  |  | 601 | 	this->iGunsCount = this->lGuns.size();
 | 
        
           |  |  | 602 | }
 | 
        
           |  |  | 603 |   | 
        
           |  |  | 604 | void CShipData::ClearTurrets()
 | 
        
           |  |  | 605 | {
 | 
        
           |  |  | 606 | 	for ( int i = 0; i < 6; i++ )
 | 
        
           |  |  | 607 | 	{
 | 
        
           |  |  | 608 | 		this->cockpits[i].iCockpit = 0;
 | 
        
           |  |  | 609 | 		this->cockpits[i].iPos = 0;
 | 
        
           | 211 | cycrow | 610 | 		this->cockpits[i].sCockpit = L"";
 | 
        
           | 1 | cycrow | 611 | 	}
 | 
        
           |  |  | 612 |   | 
        
           |  |  | 613 | 	while ( this->lTurrets.size() > 1 )
 | 
        
           |  |  | 614 | 		this->lTurrets.erase(1, true);
 | 
        
           |  |  | 615 | 	while ( this->lGuns.size() > 1 )
 | 
        
           |  |  | 616 | 		this->lGuns.erase(1, true);
 | 
        
           |  |  | 617 | 	this->iTurretCount = 1;
 | 
        
           |  |  | 618 | 	this->iGunsCount = 1;
 | 
        
           |  |  | 619 | }
 | 
        
           |  |  | 620 |   | 
        
           |  |  | 621 | void CShipData::AddNewTurret(int dir)
 | 
        
           |  |  | 622 | {
 | 
        
           |  |  | 623 | 	if ( this->iTurretCount >= 7 )
 | 
        
           |  |  | 624 | 		return;
 | 
        
           |  |  | 625 |   | 
        
           |  |  | 626 | 	STurretEntry *t = new STurretEntry;
 | 
        
           |  |  | 627 | 	SGunGroup *g = new SGunGroup;
 | 
        
           |  |  | 628 |   | 
        
           |  |  | 629 | 	t->iSceneNode = 0;
 | 
        
           |  |  | 630 | 	t->iIndex = this->iTurretCount + 1;
 | 
        
           |  |  | 631 | 	t->iTurret = this->iTurretCount;
 | 
        
           |  |  | 632 |   | 
        
           |  |  | 633 | 	this->cockpits[(this->iTurretCount - 1)].iCockpit = 0;
 | 
        
           |  |  | 634 | 	this->cockpits[(this->iTurretCount - 1)].iPos = dir;
 | 
        
           |  |  | 635 |   | 
        
           |  |  | 636 | 	g->iWeaponCount = 1;
 | 
        
           |  |  | 637 | 	g->iLaserCount = 0;
 | 
        
           |  |  | 638 | 	SWeaponGroup *w = new SWeaponGroup;
 | 
        
           |  |  | 639 | 	w->iLaser = 0;
 | 
        
           |  |  | 640 | 	w->iNode1 = 0;
 | 
        
           |  |  | 641 | 	w->iNode2 = -1;
 | 
        
           | 211 | cycrow | 642 | 	w->sModel1 = L"0";
 | 
        
           | 1 | cycrow | 643 | 	g->lWeapons.push_back(w);
 | 
        
           |  |  | 644 |   | 
        
           |  |  | 645 | 	this->lTurrets.push_back(t);
 | 
        
           |  |  | 646 | 	this->lGuns.push_back(g);
 | 
        
           |  |  | 647 |   | 
        
           |  |  | 648 | 	++this->iTurretCount;
 | 
        
           |  |  | 649 | 	++this->iGunsCount;
 | 
        
           |  |  | 650 |   | 
        
           |  |  | 651 | 	this->UpdateGunEntries();
 | 
        
           |  |  | 652 | }
 | 
        
           |  |  | 653 |   | 
        
           | 211 | cycrow | 654 | Utils::WString CShipData::ConvertMissileGroup(int type)
 | 
        
           | 1 | cycrow | 655 | {
 | 
        
           |  |  | 656 | 	switch ( type )
 | 
        
           |  |  | 657 | 	{
 | 
        
           |  |  | 658 | 		case SG_MISSILE_LIGHT:
 | 
        
           | 211 | cycrow | 659 | 			return L"SG_MISSILE_LIGHT";
 | 
        
           | 1 | cycrow | 660 | 		case SG_MISSILE_MEDIUM:
 | 
        
           | 211 | cycrow | 661 | 			return L"SG_MISSILE_MEDIUM";
 | 
        
           | 1 | cycrow | 662 | 		case SG_MISSILE_HEAVY:
 | 
        
           | 211 | cycrow | 663 | 			return L"SG_MISSILE_HEAVY";
 | 
        
           | 1 | cycrow | 664 | 		case SG_MISSILE_TR_LIGHT:
 | 
        
           | 211 | cycrow | 665 | 			return L"SG_MISSILE_TR_LIGHT";
 | 
        
           | 1 | cycrow | 666 | 		case SG_MISSILE_TR_MEDIUM:
 | 
        
           | 211 | cycrow | 667 | 			return L"SG_MISSILE_TR_MEDIUM";
 | 
        
           | 1 | cycrow | 668 | 		case SG_MISSILE_TR_HEAVY:
 | 
        
           | 211 | cycrow | 669 | 			return L"SG_MISSILE_TR_HEAVY";
 | 
        
           | 1 | cycrow | 670 | 		case SG_MISSILE_KHAAK:
 | 
        
           | 211 | cycrow | 671 | 			return L"SG_MISSILE_KHAAK";
 | 
        
           | 1 | cycrow | 672 | 		case SG_MISSILE_BOMBER:
 | 
        
           | 211 | cycrow | 673 | 			return L"SG_MISSILE_BOMBOER";
 | 
        
           | 1 | cycrow | 674 | 		case SG_MISSILE_TORP_CAPTIAL:
 | 
        
           | 211 | cycrow | 675 | 			return L"SG_MISSILE_TORP_CAPTIAL";
 | 
        
           | 1 | cycrow | 676 | 		case SG_MISSILE_AF_CAPTIAL:
 | 
        
           | 211 | cycrow | 677 | 			return L"SG_MISSILE_AF_CAPTIAL";
 | 
        
           | 1 | cycrow | 678 | 		case SG_MISSILE_TR_BOMBER:
 | 
        
           | 211 | cycrow | 679 | 			return L"SG_MISSILE_TR_BOMBER";
 | 
        
           | 1 | cycrow | 680 | 		case SG_MISSILE_TR_TORP_CAPTIAL:
 | 
        
           | 211 | cycrow | 681 | 			return L"SG_MISSILE_TR_TORP_CAPTIAL";
 | 
        
           | 1 | cycrow | 682 | 		case SG_MISSILE_TR_AF_CAPTIAL:
 | 
        
           | 211 | cycrow | 683 | 			return L"SG_MISSILE_TR_AF_CAPTIAL";
 | 
        
           | 1 | cycrow | 684 | 		case SG_MISSILE_BOARDINGPOD:
 | 
        
           | 211 | cycrow | 685 | 			return L"SG_MISSILE_BOARDINGPOD";
 | 
        
           | 1 | cycrow | 686 | 		case SG_MISSILE_DMBF:
 | 
        
           | 211 | cycrow | 687 | 			return L"SG_MISSILE_DMBF";
 | 
        
           | 1 | cycrow | 688 | 	}
 | 
        
           |  |  | 689 |   | 
        
           | 211 | cycrow | 690 | 	return L"";
 | 
        
           | 1 | cycrow | 691 | }
 | 
        
           |  |  | 692 |   | 
        
           |  |  | 693 | int CShipData::ConvertMissileGroupToID(int type)
 | 
        
           |  |  | 694 | {
 | 
        
           |  |  | 695 | 	int arr[] = {SG_MISSILE_LIGHT, SG_MISSILE_MEDIUM, SG_MISSILE_HEAVY, SG_MISSILE_TR_LIGHT, SG_MISSILE_TR_MEDIUM, SG_MISSILE_TR_HEAVY, SG_MISSILE_KHAAK, SG_MISSILE_BOMBER, SG_MISSILE_TORP_CAPTIAL, 
 | 
        
           |  |  | 696 | 		SG_MISSILE_AF_CAPTIAL, SG_MISSILE_TR_BOMBER, SG_MISSILE_TR_TORP_CAPTIAL, SG_MISSILE_AF_CAPTIAL, SG_MISSILE_BOARDINGPOD, SG_MISSILE_DMBF};
 | 
        
           |  |  | 697 | 	for ( int i = 0; i < SG_MISSILE_MAX; i++ )
 | 
        
           |  |  | 698 | 	{
 | 
        
           |  |  | 699 | 		if ( arr[i] == type )
 | 
        
           |  |  | 700 | 			return i;
 | 
        
           |  |  | 701 | 	}
 | 
        
           |  |  | 702 |   | 
        
           |  |  | 703 | 	return 0; 
 | 
        
           |  |  | 704 | }
 | 
        
           |  |  | 705 |   | 
        
           | 211 | cycrow | 706 | int CShipData::ConvertMissileGroupToID(const Utils::WString &type)
 | 
        
           | 1 | cycrow | 707 | {
 | 
        
           |  |  | 708 | 	return CShipData::ConvertMissileGroupToID(CShipData::ConvertMissileGroup(type));
 | 
        
           |  |  | 709 | }
 | 
        
           |  |  | 710 |   | 
        
           | 211 | cycrow | 711 | int CShipData::ConvertMissileGroup(const Utils::WString &type)
 | 
        
           | 1 | cycrow | 712 | {
 | 
        
           | 211 | cycrow | 713 | 	if ( type.Compare(L"SG_MISSILE_LIGHT") )
 | 
        
           | 1 | cycrow | 714 | 		return SG_MISSILE_LIGHT;
 | 
        
           | 211 | cycrow | 715 | 	if ( type.Compare(L"SG_MISSILE_MEDIUM") )
 | 
        
           | 1 | cycrow | 716 | 		return SG_MISSILE_MEDIUM;
 | 
        
           | 211 | cycrow | 717 | 	if ( type.Compare(L"SG_MISSILE_HEAVY") )
 | 
        
           | 1 | cycrow | 718 | 		return SG_MISSILE_HEAVY;
 | 
        
           | 211 | cycrow | 719 | 	if ( type.Compare(L"SG_MISSILE_TR_LIGHT") )
 | 
        
           | 1 | cycrow | 720 | 		return SG_MISSILE_TR_LIGHT;
 | 
        
           | 211 | cycrow | 721 | 	if ( type.Compare(L"SG_MISSILE_TR_MEDIUM") )
 | 
        
           | 1 | cycrow | 722 | 		return SG_MISSILE_TR_MEDIUM;
 | 
        
           | 211 | cycrow | 723 | 	if ( type.Compare(L"SG_MISSILE_TR_HEAVY") )
 | 
        
           | 1 | cycrow | 724 | 		return SG_MISSILE_TR_HEAVY;
 | 
        
           | 211 | cycrow | 725 | 	if ( type.Compare(L"SG_MISSILE_KHAAK") )
 | 
        
           | 1 | cycrow | 726 | 		return SG_MISSILE_KHAAK;
 | 
        
           | 211 | cycrow | 727 | 	if ( type.Compare(L"SG_MISSILE_BOMBER") )
 | 
        
           | 1 | cycrow | 728 | 		return SG_MISSILE_BOMBER;
 | 
        
           | 211 | cycrow | 729 | 	if ( type.Compare(L"SG_MISSILE_TORP_CAPTIAL") )
 | 
        
           | 1 | cycrow | 730 | 		return SG_MISSILE_TORP_CAPTIAL;
 | 
        
           | 211 | cycrow | 731 | 	if ( type.Compare(L"SG_MISSILE_AF_CAPTIAL") )
 | 
        
           | 1 | cycrow | 732 | 		return SG_MISSILE_AF_CAPTIAL;
 | 
        
           | 211 | cycrow | 733 | 	if ( type.Compare(L"SG_MISSILE_TR_BOMBER") )
 | 
        
           | 1 | cycrow | 734 | 		return SG_MISSILE_TR_BOMBER;
 | 
        
           | 211 | cycrow | 735 | 	if ( type.Compare(L"SG_MISSILE_TR_TORP_CAPTIAL") )
 | 
        
           | 1 | cycrow | 736 | 		return SG_MISSILE_TR_TORP_CAPTIAL;
 | 
        
           | 211 | cycrow | 737 | 	if ( type.Compare(L"SG_MISSILE_TR_AF_CAPTIAL") )
 | 
        
           | 1 | cycrow | 738 | 		return SG_MISSILE_TR_AF_CAPTIAL;
 | 
        
           | 211 | cycrow | 739 | 	if ( type.Compare(L"SG_MISSILE_BOARDINGPOD") )
 | 
        
           | 1 | cycrow | 740 | 		return SG_MISSILE_BOARDINGPOD;
 | 
        
           | 211 | cycrow | 741 | 	if ( type.Compare(L"SG_MISSILE_DMBF") )
 | 
        
           | 1 | cycrow | 742 | 		return SG_MISSILE_DMBF;
 | 
        
           |  |  | 743 |   | 
        
           |  |  | 744 | 	return 0;
 | 
        
           |  |  | 745 | }
 |