Gets next ship from n that has actually been alloced
| 182 | |
| 183 | // Gets next ship from n that has actually been alloced |
| 184 | int GetNextShip(int n) { |
| 185 | int i; |
| 186 | |
| 187 | if (Num_ships == 0) |
| 188 | return -1; |
| 189 | |
| 190 | if ((n < 0) || (n >= MAX_SHIPS)) |
| 191 | n = -1; |
| 192 | |
| 193 | for (i = n + 1; i < MAX_SHIPS; i++) |
| 194 | if (Ships[i].used) |
| 195 | return i; |
| 196 | for (i = 0; i < n; i++) |
| 197 | if (Ships[i].used) |
| 198 | return i; |
| 199 | |
| 200 | // this is the only one |
| 201 | |
| 202 | return n; |
| 203 | } |
| 204 | |
| 205 | // Gets previous ship from n that has actually been alloced |
| 206 | int GetPrevShip(int n) { |
no outgoing calls
no test coverage detected