| 953 | // int m_active_secondaries[MAX_LEVEL_GOALS]; |
| 954 | |
| 955 | int levelgoals::GetNumActivePrimaryGoals() { |
| 956 | int x; |
| 957 | m_num_active_primaries = 0; |
| 958 | |
| 959 | int i; |
| 960 | int bestp[4]; |
| 961 | int cp; // Current priority |
| 962 | char cl; // Current list |
| 963 | int temp_p[MAX_GOAL_LISTS][MAX_LEVEL_GOALS]; |
| 964 | char temp_g[MAX_GOAL_LISTS][MAX_LEVEL_GOALS]; |
| 965 | |
| 966 | int temp_count[MAX_GOAL_LISTS]; |
| 967 | |
| 968 | for (i = 0; i < MAX_GOAL_LISTS; i++) { |
| 969 | bestp[i] = -1; |
| 970 | temp_count[i] = 0; |
| 971 | } |
| 972 | |
| 973 | // Determine the active number for the current list |
| 974 | for (i = 0; i < m_num_goals; i++) { |
| 975 | int flags; |
| 976 | m_goal[i].GetStatus(i, LO_GET_SPECIFIED, &flags); |
| 977 | |
| 978 | if (!(flags & (LGF_COMPLETED | LGF_FAILED | LGF_SECONDARY_GOAL))) { |
| 979 | if (flags & LGF_ENABLED) { |
| 980 | m_goal[i].GoalList(LO_GET_SPECIFIED, &cl); |
| 981 | m_goal[i].Priority(i, LO_GET_SPECIFIED, &cp); |
| 982 | |
| 983 | if (bestp[cl] == -1 || cp <= bestp[cl]) { |
| 984 | bestp[cl] = cp; |
| 985 | temp_p[cl][temp_count[cl]] = cp; |
| 986 | temp_g[cl][(temp_count[cl])++] = i; |
| 987 | } |
| 988 | } |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | for (x = 0; x < MAX_GOAL_LISTS; x++) { |
| 993 | for (i = 0; i < temp_count[x]; i++) { |
| 994 | if (temp_p[x][i] == bestp[x]) { |
| 995 | m_active_primaries[m_num_active_primaries++] = temp_g[x][i]; |
| 996 | } |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | return m_num_active_primaries; |
| 1001 | } |
| 1002 | |
| 1003 | int levelgoals::GetActivePrimaryGoal(int p_index) { |
| 1004 | if (p_index < 0 || p_index >= m_num_active_primaries) |
no test coverage detected