Sorts our texture states using the quicksort algorithm
| 3606 | } |
| 3607 | // Sorts our texture states using the quicksort algorithm |
| 3608 | void SortStates(state_limited_element *state_array, int cellcount) { |
| 3609 | state_limited_element v, t; |
| 3610 | int pop_val; |
| 3611 | int i, j; |
| 3612 | int l, r; |
| 3613 | l = 0; |
| 3614 | r = cellcount - 1; |
| 3615 | uint16_t state_stack_counter = 0; |
| 3616 | uint16_t state_stack[2000]; |
| 3617 | |
| 3618 | while (1) { |
| 3619 | while (r > l) { |
| 3620 | i = l - 1; |
| 3621 | j = r; |
| 3622 | v = state_array[r]; |
| 3623 | while (1) { |
| 3624 | while (state_array[++i].sort_key < v.sort_key) |
| 3625 | ; |
| 3626 | while (state_array[--j].sort_key > v.sort_key) |
| 3627 | ; |
| 3628 | if (i >= j) |
| 3629 | break; |
| 3630 | t = state_array[i]; |
| 3631 | state_array[i] = state_array[j]; |
| 3632 | state_array[j] = t; |
| 3633 | } |
| 3634 | t = state_array[i]; |
| 3635 | state_array[i] = state_array[r]; |
| 3636 | state_array[r] = t; |
| 3637 | |
| 3638 | if (i - l > r - i) { |
| 3639 | STATE_PUSH(l); |
| 3640 | STATE_PUSH(i - 1); |
| 3641 | l = i + 1; |
| 3642 | } else { |
| 3643 | STATE_PUSH(i + 1); |
| 3644 | STATE_PUSH(r); |
| 3645 | r = i - 1; |
| 3646 | } |
| 3647 | } |
| 3648 | if (!state_stack_counter) |
| 3649 | break; |
| 3650 | STATE_POP(); |
| 3651 | r = pop_val; |
| 3652 | STATE_POP(); |
| 3653 | l = pop_val; |
| 3654 | } |
| 3655 | } |
| 3656 | // Builds a list of mirror faces for each room and allocs memory accordingly |
| 3657 | void ConsolidateMineMirrors() { |
| 3658 | int i, t; |
no outgoing calls
no test coverage detected