MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / InitCockpit

Function InitCockpit

Descent3/cockpit.cpp:252–299  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////// Initializes the cockpit by loading it in and initializing all it's gauges. initialization of cockpit.

Source from the content-addressed store, hash-verified

250// Initializes the cockpit by loading it in and initializing all it's gauges.
251// initialization of cockpit.
252void InitCockpit(int ship_index) {
253 tCockpitCfgInfo cfginfo;
254 int i;
255 mprintf(0, "Initializing cockpit.\n");
256 LoadCockpitInfo(Ships[ship_index].cockpit_name, &cfginfo);
257 // initialize special hud/cockpit images unique to this ship
258 for (i = 0; i < NUM_SHIELD_GAUGE_FRAMES; i++) {
259 if (cfginfo.shieldrings[i][0])
260 HUD_resources.shield_bmp[i] = bm_AllocLoadFileBitmap(IGNORE_TABLE(cfginfo.shieldrings[i]), 0);
261 }
262 HUD_resources.ship_bmp = bm_AllocLoadFileBitmap(IGNORE_TABLE(cfginfo.shipimg), 0);
263 HUD_resources.energy_bmp = bm_AllocLoadFileBitmap(IGNORE_TABLE(cfginfo.energyimg), 0);
264 HUD_resources.afterburn_bmp = bm_AllocLoadFileBitmap(IGNORE_TABLE(cfginfo.burnimg), 0);
265 HUD_resources.invpulse_bmp = bm_AllocLoadFileBitmap(IGNORE_TABLE(cfginfo.invpulseimg), 0);
266 if (cfginfo.modelname[0] == 0) {
267 Cockpit_info.model_num = -1;
268 mprintf(0, "No cockpit found for ship.\n");
269 return;
270 }
271 // initialize cockpit.
272 Cockpit_info.ship_index = ship_index;
273 Cockpit_info.model_num = LoadPolyModel(IGNORE_TABLE(cfginfo.modelname), 0);
274 Cockpit_info.model = GetPolymodelPointer(Cockpit_info.model_num);
275 Cockpit_info.frame_time = 0.0f;
276 Cockpit_info.state = COCKPIT_STATE_DORMANT;
277 Cockpit_info.this_keyframe = COCKPIT_DORMANT_FRAME;
278 Cockpit_info.next_keyframe = COCKPIT_DORMANT_FRAME;
279 Cockpit_info.resized = false;
280 Cockpit_info.buffet_amp = 0.0f;
281 Cockpit_info.snd_open = SOUND_COCKPIT;
282 vm_MakeZero(&Cockpit_info.buffet_vec);
283 // find layered submodel mask
284 Cockpit_info.layered_mask = 0x00000000;
285 Cockpit_info.nonlayered_mask = 0x00000000;
286 for (i = 0; i < Cockpit_info.model->n_models; i++) {
287 if ((Cockpit_info.model->submodel[i].flags & SOF_VIEWER) ||
288 (Cockpit_info.model->submodel[i].flags & SOF_MONITOR_MASK))
289 continue;
290 if (Cockpit_info.model->submodel[i].flags & SOF_LAYER)
291 Cockpit_info.layered_mask |= (1 << i);
292 else
293 Cockpit_info.nonlayered_mask |= (1 << i);
294 }
295 InitGauges(STAT_SHIELDS | STAT_SHIP | STAT_ENERGY | STAT_PRIMARYLOAD | STAT_SECONDARYLOAD | STAT_AFTERBURN);
296 // initialize reticle
297 FreeReticle();
298 InitReticle(-1, -1);
299}
300// Forces freeing of cockpit
301void FreeCockpit() {
302 int i;

Callers 6

StartLevelFunction · 0.85
ProcessTestKeysFunction · 0.85
LGSPlayersFunction · 0.85
MultiDoBashPlayerShipFunction · 0.85
ChangePlayerShipIndexFunction · 0.85
DemoReadHeaderFunction · 0.85

Calls 8

LoadCockpitInfoFunction · 0.85
bm_AllocLoadFileBitmapFunction · 0.85
LoadPolyModelFunction · 0.85
GetPolymodelPointerFunction · 0.85
vm_MakeZeroFunction · 0.85
InitGaugesFunction · 0.85
FreeReticleFunction · 0.85
InitReticleFunction · 0.85

Tested by

no test coverage detected