| 1776 | } |
| 1777 | |
| 1778 | bool PhysValidateGroundPath(object *obj, vector *s, int sroom, vector *e, int eroom, float rad, float min_vert_dot) { |
| 1779 | if (ROOMNUM_OUTSIDE(sroom)) { |
| 1780 | int x1, x2, y1, y2, x, y, delta_y, delta_x, change_x, change_y, length, cur_node, error_term, i; |
| 1781 | |
| 1782 | int new_x, new_y; |
| 1783 | int counter; |
| 1784 | int delta_ter_check = rad / TERRAIN_SIZE + 1; |
| 1785 | |
| 1786 | // Determine the start end end nodes |
| 1787 | x1 = CELLNUM(sroom) % TERRAIN_WIDTH; |
| 1788 | y1 = CELLNUM(sroom) / TERRAIN_WIDTH; |
| 1789 | |
| 1790 | x2 = CELLNUM(eroom) % TERRAIN_WIDTH; |
| 1791 | y2 = CELLNUM(eroom) / TERRAIN_WIDTH; |
| 1792 | |
| 1793 | x = x1; |
| 1794 | y = y1; |
| 1795 | |
| 1796 | // How many nodes did I move? |
| 1797 | delta_x = x2 - x1; |
| 1798 | delta_y = y2 - y1; |
| 1799 | |
| 1800 | // Check the current node |
| 1801 | if (!IsNodeValid(CELLNUM(sroom), min_vert_dot)) { |
| 1802 | return false; |
| 1803 | } |
| 1804 | |
| 1805 | if (delta_x == 0 && delta_y == 0) |
| 1806 | return true; |
| 1807 | |
| 1808 | // check the end node |
| 1809 | cur_node = y1 * TERRAIN_DEPTH + x2; |
| 1810 | if (!IsNodeValid(cur_node, min_vert_dot)) { |
| 1811 | return false; |
| 1812 | } |
| 1813 | |
| 1814 | // Do a Breshenham line algorithm |
| 1815 | if (delta_x < 0) { |
| 1816 | change_x = -1; |
| 1817 | delta_x = -delta_x; |
| 1818 | } else { |
| 1819 | change_x = 1; |
| 1820 | } |
| 1821 | |
| 1822 | if (delta_y < 0) { |
| 1823 | change_y = -1; |
| 1824 | delta_y = -delta_y; |
| 1825 | } else { |
| 1826 | change_y = 1; |
| 1827 | } |
| 1828 | |
| 1829 | error_term = 0; |
| 1830 | i = 1; |
| 1831 | |
| 1832 | if (delta_x < delta_y) { |
| 1833 | length = delta_y + 1; |
| 1834 | |
| 1835 | while (i < length) { |
no test coverage detected