// ------------------------------------------------------------------------------------------------- // gamesnd_parse_soundstbl() will parse the sounds.tbl file, and load the specified sounds. // // void gamesnd_parse_soundstbl() { int rval; int num_game_sounds = 0; int num_iface_sounds = 0; // open localization lcl_ext_open(); gamesnd_init_sounds(); if ((rval = setjmp(parse_abort)) != 0) { Error(LOCATION, "Unable to parse sounds.tbl! Code = %i.\n", rval); } else { read_file_text("sounds.tbl"); reset_parse(); } // Parse the gameplay sounds section required_string("#Game Sounds Start"); while (required_string_either("#Game Sounds End","$Name:")) { Assert( num_game_sounds < MAX_GAME_SOUNDS); gamesnd_parse_line( &Snds[num_game_sounds], "$Name:" ); num_game_sounds++; } required_string("#Game Sounds End"); // Parse the interface sounds section required_string("#Interface Sounds Start"); while (required_string_either("#Interface Sounds End","$Name:")) { Assert( num_iface_sounds < MAX_INTERFACE_SOUNDS); gamesnd_parse_line(&Snds_iface[num_iface_sounds], "$Name:"); num_iface_sounds++; } required_string("#Interface Sounds End"); // parse flyby sound section required_string("#Flyby Sounds Start"); // read 2 terran sounds gamesnd_parse_line(&Snds_flyby[SPECIES_TERRAN][0], "$Terran:"); gamesnd_parse_line(&Snds_flyby[SPECIES_TERRAN][1], "$Terran:"); // 2 vasudan sounds gamesnd_parse_line(&Snds_flyby[SPECIES_VASUDAN][0], "$Vasudan:"); gamesnd_parse_line(&Snds_flyby[SPECIES_VASUDAN][1], "$Vasudan:"); gamesnd_parse_line(&Snds_flyby[SPECIES_SHIVAN][0], "$Shivan:"); gamesnd_parse_line(&Snds_flyby[SPECIES_SHIVAN][1], "$Shivan:"); required_string("#Flyby Sounds End"); // close localization lcl_ext_close(); }
void parse_sound_table(const char* filename) { try { read_file_text(filename, CF_TYPE_TABLES); reset_parse(); // Parse the gameplay sounds section if (optional_string("#Game Sounds Start")) { while (!check_for_string("#Game Sounds End")) { game_snd tempSound; if (gamesnd_parse_line(&tempSound, "$Name:", &Snds)) { Snds.push_back(game_snd(tempSound)); } } required_string("#Game Sounds End"); } // Parse the interface sounds section if (optional_string("#Interface Sounds Start")) { while (!check_for_string("#Interface Sounds End")) { game_snd tempSound; if (gamesnd_parse_line(&tempSound, "$Name:", &Snds_iface)) { Snds_iface.push_back(game_snd(tempSound)); Snds_iface_handle.push_back(-1); } } required_string("#Interface Sounds End"); } // parse flyby sound section if (optional_string("#Flyby Sounds Start")) { char species_name_tag[NAME_LENGTH + 2]; int sanity_check = 0; size_t i; while (!check_for_string("#Flyby Sounds End") && (sanity_check <= (int)Species_info.size())) { for (i = 0; i < Species_info.size(); i++) { species_info *species = &Species_info[i]; sprintf(species_name_tag, "$%s:", species->species_name); if (check_for_string(species_name_tag)) { gamesnd_parse_line(&species->snd_flyby_fighter, species_name_tag); gamesnd_parse_line(&species->snd_flyby_bomber, species_name_tag); sanity_check--; } else { sanity_check++; } } } required_string("#Flyby Sounds End"); } if (optional_string("#Sound Environments Start")) { parse_sound_environments(); } } catch (const parse::ParseException& e) { mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", filename, e.what())); return; } gamesnd_add_retail_default_enhanced_sound_data(); }
// ------------------------------------------------------------------------------------------------- // gamesnd_parse_soundstbl() will parse the sounds.tbl file, and load the specified sounds. // // void gamesnd_parse_soundstbl() { int rval; int num_game_sounds = 0; int num_iface_sounds = 0; int i; char cstrtemp[NAME_LENGTH+3]; char* missing_species_names = NULL; ubyte* missing_species = NULL; int sanity_check = 0; gamesnd_init_sounds(); // open localization lcl_ext_open(); if ((rval = setjmp(parse_abort)) != 0) { mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "sounds.tbl", rval)); lcl_ext_close(); return; } read_file_text("sounds.tbl", CF_TYPE_TABLES); reset_parse(); // Parse the gameplay sounds section required_string("#Game Sounds Start"); while (required_string_either("#Game Sounds End", "$Name:")) { Assert(num_game_sounds < Num_game_sounds); gamesnd_parse_line(&Snds[num_game_sounds], "$Name:"); num_game_sounds++; gamesnd_add_sound_slot(GAME_SND, num_game_sounds); } required_string("#Game Sounds End"); // Parse the interface sounds section required_string("#Interface Sounds Start"); while (required_string_either("#Interface Sounds End", "$Name:")) { Assert(num_iface_sounds < Num_iface_sounds); gamesnd_parse_line(&Snds_iface[num_iface_sounds], "$Name:"); num_iface_sounds++; gamesnd_add_sound_slot(IFACE_SND, num_iface_sounds); } required_string("#Interface Sounds End"); // parse flyby sound section required_string("#Flyby Sounds Start"); missing_species_names = new char[Species_info.size() * (NAME_LENGTH + 2)]; missing_species = new ubyte[Species_info.size()]; memset(missing_species_names, 0, Species_info.size() * (NAME_LENGTH + 2)); memset(missing_species, 1, Species_info.size()); // assume they are all missing while (!check_for_string("#Flyby Sounds End") && (sanity_check <= (int)Species_info.size())) { for (i = 0; i < (int)Species_info.size(); i++) { species_info* species = &Species_info[i]; sprintf(cstrtemp, "$%s:", species->species_name); if (check_for_string(cstrtemp)) { gamesnd_parse_line(&species->snd_flyby_fighter, cstrtemp); gamesnd_parse_line(&species->snd_flyby_bomber, cstrtemp); missing_species[i] = 0; sanity_check--; } else { sanity_check++; } } } // if we are missing any species then report it for (i = 0; i < (int)Species_info.size(); i++) { if (missing_species[i]) { strcat(missing_species_names, Species_info[i].species_name); strcat(missing_species_names, "\n"); } } if (strlen(missing_species_names)) { Error(LOCATION, "The following species are missing flyby sounds in sounds.tbl:\n%s", missing_species_names); } delete[] missing_species_names; delete[] missing_species; required_string("#Flyby Sounds End"); // close localization lcl_ext_close(); }
// ------------------------------------------------------------------------------------------------- // gamesnd_parse_soundstbl() will parse the sounds.tbl file, and load the specified sounds. // // void gamesnd_parse_soundstbl() { int rval; int num_game_sounds = 0; int num_iface_sounds = 0; // open localization lcl_ext_open(); gamesnd_init_sounds(); if ((rval = setjmp(parse_abort)) != 0) { Error(LOCATION, "Unable to parse sounds.tbl! Code = %i.\n", rval); } else { read_file_text("sounds.tbl"); reset_parse(); } // Parse the gameplay sounds section required_string("#Game Sounds Start"); while (required_string_either("#Game Sounds End","$Name:")) { Assert( num_game_sounds < MAX_GAME_SOUNDS); gamesnd_parse_line( &Snds[num_game_sounds], "$Name:" ); num_game_sounds++; } required_string("#Game Sounds End"); // Parse the interface sounds section required_string("#Interface Sounds Start"); while (required_string_either("#Interface Sounds End","$Name:")) { Assert( num_iface_sounds < MAX_INTERFACE_SOUNDS); gamesnd_parse_line(&Snds_iface[num_iface_sounds], "$Name:"); num_iface_sounds++; } required_string("#Interface Sounds End"); // parse flyby sound section // flyby sounds are now read from the craft data in ships.tbl /*required_string("#Flyby Sounds Start"); #if defined(MORE_SPECIES) char cstrtemp[SPECIES_NAME_MAXLEN+3]; for (int i = 0; i < True_NumSpecies; i++) { sprintf(cstrtemp, "$%s:", Species_names[i]); gamesnd_parse_line(&Snds_flyby[i][0], cstrtemp); gamesnd_parse_line(&Snds_flyby[i][1], cstrtemp); } #else // read 2 terran sounds gamesnd_parse_line(&Snds_flyby[SPECIES_TERRAN][0], "$Terran:"); gamesnd_parse_line(&Snds_flyby[SPECIES_TERRAN][1], "$Terran:"); // 2 vasudan sounds gamesnd_parse_line(&Snds_flyby[SPECIES_VASUDAN][0], "$Vasudan:"); gamesnd_parse_line(&Snds_flyby[SPECIES_VASUDAN][1], "$Vasudan:"); gamesnd_parse_line(&Snds_flyby[SPECIES_SHIVAN][0], "$Shivan:"); gamesnd_parse_line(&Snds_flyby[SPECIES_SHIVAN][1], "$Shivan:"); #endif required_string("#Flyby Sounds End");*/ // close localization lcl_ext_close(); }