/* then read in global config file */ void initialize_options(void) { /* Initialize MathCards backend for math questions: */ local_game = (MC_MathGame*) malloc(sizeof(MC_MathGame)); if (local_game == NULL) { fprintf(stderr, "\nUnable to allocate MC_MathGame\n"); exit(1); } local_game->math_opts = NULL; if (!MC_Initialize(local_game)) { fprintf(stderr, "\nUnable to initialize MathCards\n"); exit(1); } lan_game_settings = (MC_MathGame*) malloc(sizeof(MC_MathGame)); if (lan_game_settings == NULL) { fprintf(stderr, "\nUnable to allocate MC_MathGame\n"); exit(1); } lan_game_settings->math_opts = NULL; if (!MC_Initialize(lan_game_settings)) { fprintf(stderr, "\nUnable to initialize MathCards\n"); exit(1); } /* initialize game_options struct with defaults DSB */ if (!Opts_Initialize()) { fprintf(stderr, "\nUnable to initialize game_options\n"); cleanup_on_error(); exit(1); } /* Now that MathCards and game_options initialized using */ /* hard-coded defaults, read options from disk and mofify */ /* as needed. First read in installation-wide settings: */ if (!read_global_config_file(local_game)) { fprintf(stderr, "\nCould not find global config file.\n"); /* can still proceed using hard-coded defaults. */ } }
int initMP() { int i; int success = 1; char nrstr[HIGH_SCORE_NAME_LENGTH * 3]; int nplayers = params[PLAYERS]; const char* config_files[5] = { "multiplay/space_cadet", "multiplay/scout", "multiplay/ranger", "multiplay/ace", "multiplay/commando" }; DEBUGMSG(debug_multiplayer, "Reading in difficulty settings...\n"); success *= read_global_config_file(local_game); success *= read_named_config_file(local_game, "multiplay/mpoptions"); success *= read_named_config_file(local_game, config_files[params[DIFFICULTY]]); if (!success) { fprintf(stderr, "Couldn't read in settings for %s\n", config_files[params[DIFFICULTY]] ); return 1; } pscores[0] = pscores[1] = pscores[2] = pscores[3] = 0; pnames[0] = pnames[1] = pnames[2] = pnames[3] = NULL; //allocate and enter player names for (i = 0; i < nplayers; ++i) pnames[i] = malloc((1 + 3 * HIGH_SCORE_NAME_LENGTH) * sizeof(char) ); for (i = 0; i < nplayers; ++i) { if (pnames[i]) { if (i == 0) //First player NameEntry(pnames[i], N_("Who is playing first?"), N_("Enter your name:"), NULL); else //subsequent players NameEntry(pnames[i], N_("Who is playing next?"), N_("Enter your name:"), NULL); } else { fprintf(stderr, "Can't allocate name %d!\n", i); return 1; } } //enter how many rounds if (params[MODE] == SCORE_SWEEP) { while (params[ROUNDS] <= 0) { NameEntry(nrstr, N_("How many rounds will you play?"), N_("Enter a number"), NULL); params[ROUNDS] = atoi(nrstr); } } inprogress = 1; //now we can start the game return 0; }