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