Ok to use Highest_room_index offset stuff
| 62 | |
| 63 | // Ok to use Highest_room_index offset stuff |
| 64 | bool AIFindAltPath(object *obj, int i, int j, float *dist) { |
| 65 | i = BOA_INDEX(i); |
| 66 | j = BOA_INDEX(j); |
| 67 | |
| 68 | pq PQPath; |
| 69 | int counter; |
| 70 | q_item *start_node = new q_item(i, -1, 0.0f); |
| 71 | q_item *cur_node; |
| 72 | bool f_found = false; |
| 73 | |
| 74 | q_item *node_list[MAX_ROOMS + 8]; |
| 75 | |
| 76 | // mprintf(0, "AI: Finding an alternate path from %d to %d\n", i, j); |
| 77 | |
| 78 | if (i == -1 || j == -1) { |
| 79 | delete start_node; |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | memset(node_list, 0, sizeof(q_item *) * (MAX_ROOMS + 8)); |
| 84 | |
| 85 | PQPath.push(start_node); |
| 86 | |
| 87 | while ((cur_node = PQPath.pop())) { |
| 88 | node_list[BOA_INDEX(cur_node->roomnum)] = cur_node; |
| 89 | ASSERT(BOA_INDEX(cur_node->roomnum) >= 0 && BOA_INDEX(cur_node->roomnum) <= Highest_room_index + 8); |
| 90 | |
| 91 | if (cur_node->roomnum == j) { |
| 92 | AIUpdatePathInfo(node_list, i, j); |
| 93 | f_found = true; |
| 94 | goto done; |
| 95 | } |
| 96 | |
| 97 | int num_portals; |
| 98 | bool f_room = true; |
| 99 | int t_index; |
| 100 | |
| 101 | if (cur_node->roomnum <= Highest_room_index) { |
| 102 | num_portals = Rooms[cur_node->roomnum].num_portals; |
| 103 | } else { |
| 104 | t_index = cur_node->roomnum - Highest_room_index - 1; |
| 105 | num_portals = BOA_num_connect[t_index]; |
| 106 | f_room = false; |
| 107 | } |
| 108 | |
| 109 | for (counter = 0; counter < num_portals; counter++) { |
| 110 | int next_room; |
| 111 | q_item *list_item; |
| 112 | float new_cost; |
| 113 | |
| 114 | if (!BOA_PassablePortal(cur_node->roomnum, counter, false, false)) |
| 115 | continue; |
| 116 | |
| 117 | if (f_room) |
| 118 | next_room = Rooms[cur_node->roomnum].portals[counter].croom; |
| 119 | else |
| 120 | next_room = BOA_connect[t_index][counter].roomnum; |
| 121 |
no test coverage detected