Returns the max number of teams this mission can support for this mod, or -1 if this level shouldn't be played with this mission Return values: -1 Bad match -- this level and this mod shouldn't be played together! MAX_NET_PLAYERS -- This is playable with any number of teams the mod wants
| 1893 | // -1 Bad match -- this level and this mod shouldn't be played together! |
| 1894 | // MAX_NET_PLAYERS -- This is playable with any number of teams the mod wants |
| 1895 | int MissionGetKeywords(const char *mission, char *keywords) { |
| 1896 | ASSERT(mission); |
| 1897 | ASSERT(keywords); |
| 1898 | |
| 1899 | char msn_keywords[NUM_KEYWORDS][KEYWORD_LEN]; |
| 1900 | char mod_keywords[NUM_KEYWORDS][KEYWORD_LEN]; |
| 1901 | int i; |
| 1902 | char *parse_keys = mem_strdup(keywords); |
| 1903 | char seps[] = ","; |
| 1904 | int teams = MAX_NET_PLAYERS; |
| 1905 | int goals = 0; |
| 1906 | int goalsneeded = 0; |
| 1907 | int mod_key_count = 0; |
| 1908 | int msn_key_count = 0; |
| 1909 | bool goal_per_team = false; |
| 1910 | tMissionInfo msn_info; |
| 1911 | |
| 1912 | memset(msn_keywords, 0, sizeof(msn_keywords)); |
| 1913 | memset(mod_keywords, 0, sizeof(mod_keywords)); |
| 1914 | mprintf(0, "MissionGetKeywords(%s,%s)\n", mission, keywords); |
| 1915 | if (!GetMissionInfo(mission, &msn_info)) { |
| 1916 | return -1; |
| 1917 | } |
| 1918 | |
| 1919 | if (!*parse_keys) { |
| 1920 | return MAX_NET_PLAYERS; |
| 1921 | } |
| 1922 | // Break up the mod keywords into an array |
| 1923 | char *tokp = strtok(parse_keys, seps); |
| 1924 | if (tokp) { |
| 1925 | do { |
| 1926 | strcpy(mod_keywords[mod_key_count], tokp); |
| 1927 | mod_key_count++; |
| 1928 | tokp = strtok(NULL, seps); |
| 1929 | } while ((tokp) && (mod_key_count < NUM_KEYWORDS)); |
| 1930 | } |
| 1931 | // Break up the msn keywords into an array |
| 1932 | tokp = strtok(msn_info.keywords, seps); |
| 1933 | if (tokp) { |
| 1934 | do { |
| 1935 | strcpy(msn_keywords[msn_key_count], tokp); |
| 1936 | msn_key_count++; |
| 1937 | tokp = strtok(NULL, seps); |
| 1938 | } while ((tokp) && (msn_key_count < NUM_KEYWORDS)); |
| 1939 | } |
| 1940 | |
| 1941 | for (i = 0; i < NUM_KEYWORDS; i++) { |
| 1942 | if (msn_keywords[i][0] == 0) { |
| 1943 | continue; |
| 1944 | } |
| 1945 | if (strnicmp(GOALSTEXT, msn_keywords[i], GOALSTEXTLEN) == 0) { |
| 1946 | // Get the number of goals this game has |
| 1947 | goals = atoi(msn_keywords[i] + GOALSTEXTLEN); |
| 1948 | } |
| 1949 | } |
| 1950 | mem_free(parse_keys); |
| 1951 | |
| 1952 | // Loop through looking for matches |
no test coverage detected