MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / GetNumActivePrimaryGoals

Method GetNumActivePrimaryGoals

Descent3/levelgoal.cpp:955–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

953// int m_active_secondaries[MAX_LEVEL_GOALS];
954
955int 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
1003int levelgoals::GetActivePrimaryGoal(int p_index) {
1004 if (p_index < 0 || p_index >= m_num_active_primaries)

Callers 2

osipf_LGoalValueFunction · 0.80
TCGoalsBuildLineDataFunction · 0.80

Calls 3

GoalListMethod · 0.80
PriorityMethod · 0.80
GetStatusMethod · 0.45

Tested by

no test coverage detected