| 830 | #define SCRIPTBADFORMISSION -1 |
| 831 | |
| 832 | int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams) { |
| 833 | char mod_keys[MAX_KEYWORDLEN]; |
| 834 | if (!GetDLLRequirements(script, mod_keys, MAX_KEYWORDLEN)) { |
| 835 | return SCRIPTBADFORMISSION; |
| 836 | } |
| 837 | int teams = MissionGetKeywords(mission, mod_keys); |
| 838 | // Bad match! |
| 839 | if (teams == -1) { |
| 840 | if (!Dedicated_server) { |
| 841 | DoMessageBox(script, TXT_MSNNOTCOMPATIBLE, MSGBOX_OK); |
| 842 | return SCRIPTBADFORMISSION; |
| 843 | } else { |
| 844 | PrintDedicatedMessage(TXT_MSNNOTCOMPATIBLE); |
| 845 | PrintDedicatedMessage("\n"); |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | // See how many teams this dll will allow. |
| 850 | int desired_teams = 1; |
| 851 | int max_teams, min_teams; |
| 852 | |
| 853 | GetDLLNumTeamInfo(script, &min_teams, &max_teams); |
| 854 | |
| 855 | if (min_teams > teams) { |
| 856 | mprintf(0, "This multiplayer game requires more teams than the mission supports!\n"); |
| 857 | return SCRIPTBADFORMISSION; |
| 858 | } |
| 859 | // Use whatever is smaller, the dll's max teams, or what the missions supports |
| 860 | if (max_teams > teams) |
| 861 | max_teams = teams; |
| 862 | |
| 863 | if (Dedicated_server) { |
| 864 | teams = min_teams; |
| 865 | |
| 866 | if (min_teams != max_teams) { |
| 867 | // they can set the number of teams for this game |
| 868 | // make sure it's valid |
| 869 | if (dedicated_server_num_teams >= min_teams && dedicated_server_num_teams <= max_teams) { |
| 870 | teams = dedicated_server_num_teams; |
| 871 | } else { |
| 872 | // invalid num teams |
| 873 | PrintDedicatedMessage(TXT_INVALIDNUMTEAMS, teams); |
| 874 | PrintDedicatedMessage("\n"); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | } else { |
| 879 | if (min_teams != max_teams) { |
| 880 | char a_num_teams[5]; |
| 881 | char team_count_msg[300]; |
| 882 | snprintf(a_num_teams, sizeof(a_num_teams), "%d", min_teams); |
| 883 | snprintf(team_count_msg, sizeof(team_count_msg), "%s %s (%d - %d)", TXT_TEAMCOUNTPROMPT, script, min_teams, |
| 884 | max_teams); |
| 885 | retry_team_count: |
| 886 | int res = DoEditDialog(team_count_msg, a_num_teams, 4); |
| 887 | if (res) { |
| 888 | desired_teams = atoi(a_num_teams); |
| 889 | if ((desired_teams > max_teams) || (desired_teams < min_teams)) { |
no test coverage detected