Allocs a ship for use, returns -1 if error, else index on success
| 138 | |
| 139 | // Allocs a ship for use, returns -1 if error, else index on success |
| 140 | int AllocShip() { |
| 141 | for (int i = 0; i < MAX_SHIPS; i++) { |
| 142 | if (Ships[i].used == 0) { |
| 143 | memset(&Ships[i], 0, sizeof(ship)); |
| 144 | Ships[i].used = 1; |
| 145 | Ships[i].size = DEFAULT_SHIP_SIZE; |
| 146 | Ships[i].dying_model_handle = -1; |
| 147 | Ships[i].med_render_handle = -1; |
| 148 | Ships[i].lo_render_handle = -1; |
| 149 | Ships[i].med_lod_distance = DEFAULT_MED_LOD_DISTANCE; |
| 150 | Ships[i].lo_lod_distance = DEFAULT_LO_LOD_DISTANCE; |
| 151 | Ships[i].model_handle = -1; |
| 152 | Ships[i].armor_scalar = 1.0; |
| 153 | Ships[i].flags = 0; |
| 154 | |
| 155 | Ships[i].phys_info.hit_die_dot = -1; //-1 mean doesn't apply |
| 156 | |
| 157 | // Make sure the weapon battery info is cleared for a new object |
| 158 | WBClearInfo(Ships[i].static_wb); |
| 159 | |
| 160 | for (int w = 0; w < MAX_PLAYER_WEAPONS; w++) { |
| 161 | Ships[i].firing_sound[w] = -1; |
| 162 | // Ships[i].release_sound[w] = -1; |
| 163 | } |
| 164 | |
| 165 | Num_ships++; |
| 166 | return i; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | Int3(); // No ships free! |
| 171 | return -1; |
| 172 | } |
| 173 | |
| 174 | // Frees ship index n |
| 175 | void FreeShip(int n) { |
no test coverage detected