Changes the ship_index for a given player
| 202 | |
| 203 | // Changes the ship_index for a given player |
| 204 | void 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) |
nothing calls this directly
no test coverage detected