| 6421 | } |
| 6422 | |
| 6423 | int AIMakeNextRoomList(int roomnum, int *next_rooms, int max_rooms) { |
| 6424 | int num_next_rooms = 0; |
| 6425 | int i, j; |
| 6426 | int croom; |
| 6427 | |
| 6428 | if (!ROOMNUM_OUTSIDE(roomnum) && roomnum <= Highest_room_index) { |
| 6429 | for (i = 0; i < Rooms[roomnum].num_portals; i++) { |
| 6430 | bool f_found = false; |
| 6431 | |
| 6432 | if (Rooms[roomnum].portals[i].croom >= 0) { |
| 6433 | if (Rooms[Rooms[roomnum].portals[i].croom].flags & RF_EXTERNAL) { |
| 6434 | croom = Highest_room_index + |
| 6435 | TERRAIN_REGION(GetTerrainRoomFromPos( |
| 6436 | &Rooms[Rooms[roomnum].portals[i].croom].portals[Rooms[roomnum].portals[i].cportal].path_pnt)) + |
| 6437 | 1; |
| 6438 | } else { |
| 6439 | croom = Rooms[roomnum].portals[i].croom; |
| 6440 | } |
| 6441 | |
| 6442 | for (j = 0; j < num_next_rooms; j++) { |
| 6443 | if (next_rooms[j] == croom) { |
| 6444 | f_found = true; |
| 6445 | break; |
| 6446 | } |
| 6447 | } |
| 6448 | |
| 6449 | if (!f_found) { |
| 6450 | // If you hit assert, get chris -- make constant larger |
| 6451 | ASSERT(num_next_rooms < max_rooms); |
| 6452 | |
| 6453 | ASSERT((croom >= 0 && croom <= Highest_room_index + 8) || |
| 6454 | (ROOMNUM_OUTSIDE(croom) && CELLNUM(roomnum) > 0 && CELLNUM(roomnum) < TERRAIN_WIDTH * TERRAIN_DEPTH)); |
| 6455 | |
| 6456 | next_rooms[num_next_rooms] = croom; |
| 6457 | num_next_rooms++; |
| 6458 | } |
| 6459 | } |
| 6460 | } |
| 6461 | } else { |
| 6462 | int t_index; |
| 6463 | |
| 6464 | if (BOA_num_terrain_regions == 0) { |
| 6465 | return 0; |
| 6466 | } |
| 6467 | |
| 6468 | if (roomnum > Highest_room_index && roomnum <= Highest_room_index + 8) { |
| 6469 | t_index = roomnum - Highest_room_index - 1; |
| 6470 | } else { |
| 6471 | t_index = TERRAIN_REGION(roomnum); |
| 6472 | } |
| 6473 | |
| 6474 | ASSERT(t_index >= 0 && t_index < BOA_num_terrain_regions); |
| 6475 | |
| 6476 | for (i = 0; i < BOA_num_connect[t_index]; i++) { |
| 6477 | bool f_found = false; |
| 6478 | croom = BOA_connect[t_index][i].roomnum; |
| 6479 | |
| 6480 | for (j = 0; j < num_next_rooms; j++) { |
no test coverage detected