/************************************************************************** Initialize audio system and autoselect a plugin **************************************************************************/ void audio_real_init(const char *const spec_name, const char *const prefered_plugin_name) { const char *filename; const char *file_capstr; char us_capstr[] = "+soundspec"; if (strcmp(prefered_plugin_name, "none") == 0) { /* We explicitly choose none plugin, silently skip the code below */ log_verbose("Proceeding with sound support disabled."); tagfile = NULL; return; } if (num_plugins_used == 1) { /* We only have the dummy plugin, skip the code but issue an advertise */ log_normal(_("No real audio plugin present.")); log_normal(_("Proceeding with sound support disabled.")); log_normal(_("For sound support, install SDL_mixer")); log_normal("http://www.libsdl.org/projects/SDL_mixer/index.html"); tagfile = NULL; return; } if (!spec_name) { log_fatal("No sound spec-file given!"); exit(EXIT_FAILURE); } log_verbose("Initializing sound using %s...", spec_name); filename = soundspec_fullname(spec_name); if (!filename) { log_error("Cannot find sound spec-file \"%s\".", spec_name); log_normal(_("To get sound you need to download a sound set!")); log_normal(_("Get sound sets from <%s>."), "http://www.freeciv.org/wiki/Sounds"); log_normal(_("Proceeding with sound support disabled.")); tagfile = NULL; return; } if (!(tagfile = secfile_load(filename, TRUE))) { log_fatal(_("Could not load sound spec-file '%s':\n%s"), filename, secfile_error()); exit(EXIT_FAILURE); } file_capstr = secfile_lookup_str(tagfile, "soundspec.options"); if (NULL == file_capstr) { log_fatal("Audio spec-file \"%s\" doesn't have capability string.", filename); exit(EXIT_FAILURE); } if (!has_capabilities(us_capstr, file_capstr)) { log_fatal("sound spec-file appears incompatible:"); log_fatal(" file: \"%s\"", filename); log_fatal(" file options: %s", file_capstr); log_fatal(" supported options: %s", us_capstr); exit(EXIT_FAILURE); } if (!has_capabilities(file_capstr, us_capstr)) { log_fatal("sound spec-file claims required option(s) " "which we don't support:"); log_fatal(" file: \"%s\"", filename); log_fatal(" file options: %s", file_capstr); log_fatal(" supported options: %s", us_capstr); exit(EXIT_FAILURE); } free((void *) filename); atexit(audio_shutdown); if (prefered_plugin_name[0] != '\0') { if (!audio_select_plugin(prefered_plugin_name)) log_normal(_("Proceeding with sound support disabled.")); return; } #ifdef AUDIO_SDL if (audio_select_plugin("sdl")) return; #endif log_normal(_("No real audio subsystem managed to initialize!")); log_normal(_("Perhaps there is some misconfiguration or bad permissions.")); log_normal(_("Proceeding with sound support disabled.")); }
/********************************************************************** Finds and reads the toplevel themespec file based on given name. Sets global variables, including tile sizes and full names for intro files. ***********************************************************************/ struct theme *theme_read_toplevel(const char *theme_name) { struct section_file *file; char *fname; int i; size_t num_spec_files; const char **spec_filenames; const char *file_capstr; bool duplicates_ok; struct theme *t = theme_new(); const char *langname; const char *filename, *c; fname = themespec_fullname(theme_name); if (!fname) { log_error("Can't find theme \"%s\".", theme_name); theme_free(t); return NULL; } log_verbose("themespec file is \"%s\".", fname); if (!(file = secfile_load(fname, TRUE))) { log_error("Could not open '%s':\n%s", fname, secfile_error()); FC_FREE(fname); theme_free(t); return NULL; } if (!check_themespec_capabilities(file, "themespec", THEMESPEC_CAPSTR, fname)) { secfile_destroy(file); FC_FREE(fname); theme_free(t); return NULL; } file_capstr = secfile_lookup_str(file, "themespec.options"); duplicates_ok = has_capabilities("+duplicates_ok", file_capstr); (void) secfile_entry_by_path(file, "themespec.name"); /* currently unused */ sz_strlcpy(t->name, theme_name); t->priority = secfile_lookup_int_default(file, 0, "themespec.priority"); langname = get_langname(); if (langname) { if (strstr(langname, "zh_CN") != NULL) { c = secfile_lookup_str(file, "themespec.font_file_zh_CN"); } else if (strstr(langname, "ja") != NULL) { c = secfile_lookup_str(file, "themespec.font_file_ja"); } else if (strstr(langname, "ko") != NULL) { c = secfile_lookup_str(file, "themespec.font_file_ko"); } else { c = secfile_lookup_str(file, "themespec.font_file"); } } else { c = secfile_lookup_str(file, "themespec.font_file"); } if ((filename = fileinfoname(get_data_dirs(), c))) { t->font_filename = fc_strdup(filename); } else { log_fatal("Could not open font: %s", c); secfile_destroy(file); FC_FREE(fname); theme_free(t); return NULL; } log_debug("theme font file %s", t->font_filename); t->default_font_size = secfile_lookup_int_default(file, 10, "themespec.default_font_size"); log_debug("theme default font size %d", t->default_font_size); spec_filenames = secfile_lookup_str_vec(file, &num_spec_files, "themespec.files"); if (NULL == spec_filenames || 0 == num_spec_files) { log_error("No theme graphics files specified in \"%s\"", fname); secfile_destroy(file); FC_FREE(fname); theme_free(t); return NULL; } fc_assert(t->sprite_hash == NULL); t->sprite_hash = small_sprite_hash_new(); for (i = 0; i < num_spec_files; i++) { struct specfile *sf = fc_malloc(sizeof(*sf)); log_debug("spec file %s", spec_filenames[i]); sf->big_sprite = NULL; filename = fileinfoname(get_data_dirs(), spec_filenames[i]); if (!filename) { log_error("Can't find spec file \"%s\".", spec_filenames[i]); secfile_destroy(file); FC_FREE(fname); theme_free(t); return NULL; } sf->file_name = fc_strdup(filename); scan_specfile(t, sf, duplicates_ok); specfile_list_prepend(t->specfiles, sf); } FC_FREE(spec_filenames); t->background_system = theme_background_system_read(file); t->color_system = theme_color_system_read(file); secfile_check_unused(file); secfile_destroy(file); log_verbose("finished reading \"%s\".", fname); FC_FREE(fname); return t; }