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

Function ChangePlayerShipIndex

Descent3/DllWrappers.cpp:204–237  ·  view source on GitHub ↗

Changes the ship_index for a given player

Source from the content-addressed store, hash-verified

202
203// Changes the ship_index for a given player
204void ChangePlayerShipIndex(int pnum, int ship_index) {
205 int ObjInitTypeSpecific(object * objp, bool reinitializing);
206
207 if (pnum < 0 || pnum >= MAX_PLAYERS)
208 return;
209 if (Players[pnum].start_roomnum == -1)
210 return; // this player doesn't exist
211 if (ship_index < 0 || ship_index >= MAX_SHIPS)
212 return;
213 if (!Ships[ship_index].used)
214 return;
215
216 bool isme = (pnum == Player_num) ? true : false;
217
218 if (isme) {
219 FreeCockpit();
220 CloseShipHUD();
221 }
222
223 PlayerChangeShip(pnum, ship_index);
224
225 // reset physics, model, etc.
226 ObjInitTypeSpecific(&Objects[Players[pnum].objnum], 0);
227
228 if (isme) {
229 InitShipHUD(Players[pnum].ship_index);
230 InitCockpit(Players[pnum].ship_index);
231
232 if (GetHUDMode() == HUD_COCKPIT)
233 SetHUDMode(HUD_COCKPIT);
234 else if (GetHUDMode() == HUD_FULLSCREEN)
235 SetHUDMode(HUD_FULLSCREEN);
236 }
237}
238
239///////////////////////////////////////////////////////////////////
240// adds a type/id item to the inventory (returns true on success)

Callers

nothing calls this directly

Calls 8

FreeCockpitFunction · 0.85
CloseShipHUDFunction · 0.85
PlayerChangeShipFunction · 0.85
ObjInitTypeSpecificFunction · 0.85
InitShipHUDFunction · 0.85
InitCockpitFunction · 0.85
GetHUDModeFunction · 0.85
SetHUDModeFunction · 0.85

Tested by

no test coverage detected