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