| 1892 | // Bot class begin |
| 1893 | |
| 1894 | bool CBot::FindWaypoint() |
| 1895 | { |
| 1896 | waypoint_s *wp, *wpselect; |
| 1897 | int index; |
| 1898 | float distance, min_distance[3]; |
| 1899 | waypoint_s *min_wp[3]; |
| 1900 | |
| 1901 | for (index=0; index < 3; index++) |
| 1902 | { |
| 1903 | min_distance[index] = 9999.0; |
| 1904 | min_wp[index] = NULL; |
| 1905 | } |
| 1906 | |
| 1907 | TLinkedList<node_s *>::node_s *pNode = m_pCurrentWaypoint->pNode->ConnectedWPs.GetFirst(); |
| 1908 | |
| 1909 | while (pNode) |
| 1910 | { |
| 1911 | if ((pNode->Entry->iFlags & W_FL_INTAG) && |
| 1912 | SOLID(S((int)pNode->Entry->v_origin.x, (int)pNode->Entry->v_origin.y))) |
| 1913 | { |
| 1914 | pNode = pNode->next; |
| 1915 | continue; |
| 1916 | } |
| 1917 | |
| 1918 | wp = GetWPFromNode(pNode->Entry); |
| 1919 | if (!wp) |
| 1920 | { |
| 1921 | pNode = pNode->next; |
| 1922 | continue; |
| 1923 | } |
| 1924 | |
| 1925 | // if index is not a current or recent previous waypoint... |
| 1926 | if ((wp != m_pCurrentWaypoint) && |
| 1927 | (wp != m_pPrevWaypoints[0]) && |
| 1928 | (wp != m_pPrevWaypoints[1]) && |
| 1929 | (wp != m_pPrevWaypoints[2]) && |
| 1930 | (wp != m_pPrevWaypoints[3]) && |
| 1931 | (wp != m_pPrevWaypoints[4])) |
| 1932 | { |
| 1933 | // find the distance from the bot to this waypoint |
| 1934 | distance = GetDistance(wp->pNode->v_origin); |
| 1935 | |
| 1936 | if (distance < min_distance[0]) |
| 1937 | { |
| 1938 | min_distance[2] = min_distance[1]; |
| 1939 | min_wp[2] = min_wp[1]; |
| 1940 | |
| 1941 | min_distance[1] = min_distance[0]; |
| 1942 | min_wp[1] = min_wp[0]; |
| 1943 | |
| 1944 | min_distance[0] = distance; |
| 1945 | min_wp[0] = wp; |
| 1946 | } |
| 1947 | else if (distance < min_distance [1]) |
| 1948 | { |
| 1949 | min_distance[2] = min_distance[1]; |
| 1950 | min_wp[2] = min_wp[1]; |
| 1951 |
nothing calls this directly
no test coverage detected