/**
* CommanderDJ: initialise alpha colors based on colors.tbl
* Made modular and given a wider range of features by MageKing17
*/
void alpha_colors_init()
{
	// Set our default colors.
	int i;
	for (i = 0; i < TOTAL_COLORS; i++) {
		gr_init_alphacolor(COLOR_LIST[i], rgba_defaults[i][0], rgba_defaults[i][1], rgba_defaults[i][2], rgba_defaults[i][3]);
	}

	if (cf_exists_full("colors.tbl", CF_TYPE_TABLES)) {
		mprintf(("TABLES => Starting parse of 'colors.tbl' (checking '#Start Colors' section only)...\n"));
		parse_colors("colors.tbl");
	}
	parse_modular_table(NOX("*-clr.tbm"), parse_colors);

	// Set defaults for interface colors and color tags (must be done after the above because they're generally just copies of above-defined colors).
	for (i = 0; i < INTERFACE_COLORS; i++) {
		memcpy(interface_colors[i], COLOR_LIST[interface_defaults[i]], sizeof(color));
	}

	for (i = 0; i < DEFAULT_TAGS; i++) {
		Tagged_Colors[DEFAULT_TAG_LIST[i]] = DEFAULT_TAG_COLORS[i];
		Color_Tags.push_back(DEFAULT_TAG_LIST[i]);
	}

	if (cf_exists_full("colors.tbl", CF_TYPE_TABLES)) {
		mprintf(("TABLES => Starting parse of 'colors.tbl' (skipping '#Start Colors' section)...\n"));
		parse_everything_else("colors.tbl");
	}
	parse_modular_table(NOX("*-clr.tbm"), parse_everything_else);
}
void ai_profiles_init()
{
	int temp;

	if (Ai_profiles_initted)
		return;

	Num_ai_profiles = 0;
	Default_ai_profile = 0;
	Default_profile_name[0] = '\0';

	// init retail entry first
	parse_ai_profiles_tbl(NULL);

	// now parse the supplied table (if any)
	if (cf_exists_full("ai_profiles.tbl", CF_TYPE_TABLES))
		parse_ai_profiles_tbl("ai_profiles.tbl");

	// parse any modular tables
	parse_modular_table("*-aip.tbm", parse_ai_profiles_tbl);

	// set default if specified
	temp = ai_profile_lookup(Default_profile_name);
	if (temp >= 0)
		Default_ai_profile = temp;

	Ai_profiles_initted = 1;
}
void credits_parse()
{
	// Parse main table
	credits_parse_table("credits.tbl");

	// Parse modular tables
	parse_modular_table("*-crd.tbm", credits_parse_table);
}
// game init
void ssm_init()
{
	if (cf_exists_full("ssm.tbl", CF_TYPE_TABLES)) {
		mprintf(("TABLES => Starting parse of 'ssm.tbl'...\n"));
		parse_ssm("ssm.tbl");
	}
	parse_modular_table(NOX("*-ssm.tbm"), parse_ssm);

	// Now that we've populated Ssm_info, let's validate weapon $SSM: entries.
	validate_SSM_entries();
}
void mod_table_init()
{	
	// first parse the default table
	parse_mod_table(NULL);

	// if a mod.tbl exists read it
	if (cf_exists_full("game_settings.tbl", CF_TYPE_TABLES)) {
		parse_mod_table("game_settings.tbl");
	}

	// parse any modular tables
	parse_modular_table("*-mod.tbm", parse_mod_table);
}
// initialize the xstr table
void lcl_xstr_init()
{
	int i;


	for (i = 0; i < XSTR_SIZE; i++)
		Xstr_table[i].str = NULL;

	for (i = 0; i < LCL_MAX_STRINGS; i++)
		Lcl_ext_str[i] = NULL;


	try
	{
		parse_stringstbl("strings.tbl");
	}
	catch (const parse::ParseException& e)
	{
		mprintf(("TABLES: Unable to parse '%s'!  Error message = %s.\n", "strings.tbl", e.what()));
	}

	parse_modular_table(NOX("*-lcl.tbm"), parse_stringstbl);


	try
	{
		parse_tstringstbl("tstrings.tbl");
	}
	catch (const parse::ParseException& e)
	{
		mprintf(("TABLES: Unable to parse '%s'!  Error message = %s.\n", "tstrings.tbl", e.what()));
	}

	parse_modular_table(NOX("*-tlc.tbm"), parse_tstringstbl);


	Xstr_inited = 1;
}
void species_init()
{
	if (Species_initted)
		return;

	Species_info.clear();


	if (cf_exists_full("species_defs.tbl", CF_TYPE_TABLES))
		parse_species_tbl("species_defs.tbl");
	else
		parse_species_tbl(NULL);

	parse_modular_table("*-sdf.tbm", parse_species_tbl);


	Species_initted = 1;
}
/**
 * Parse the sounds.tbl file, and load the specified sounds.
 */
void gamesnd_parse_soundstbl()
{
	parse_sound_table("sounds.tbl");

	parse_modular_table("*-snd.tbm", parse_sound_table);

	// if we are missing any species then report
	if (!missingFlybySounds.empty())
	{
		SCP_string errorString;
		for (size_t i = 0; i < missingFlybySounds.size(); i++)
		{
			errorString.append(missingFlybySounds[i].species_name);
			errorString.append("\n");
		}

		Error(LOCATION, "The following species are missing flyby sounds in sounds.tbl:\n%s", errorString.c_str());
	}

	missingFlybySounds.clear();
}
// Called once at the beginning of the game to load help bitmaps & data
void help_overlay_init() 
{
	// load right_bracket bitmap
	help_right_bracket_bitmap = bm_load("right_bracket");
	// we failed to load the bitmap - this is very bad
	Assertion( help_right_bracket_bitmap >= 0, "Failed to load bitmap right_bracket for help overlay\n");

	// load left_bracket bitmap
	help_left_bracket_bitmap = bm_load("left_bracket");
	// we failed to load the bitmap - this is very bad
	Assertion( help_left_bracket_bitmap >= 0, "Failed to load bitmap left_bracket for help overlay\n");

	atexit(close_help);

	num_help_overlays = 0;

	// parse help.tbl
	parse_helptbl(HELP_OVERLAY_FILENAME);

	// look for any modular tables
	parse_modular_table(NOX("*-hlp.tbm"), parse_helptbl);
}
Exemple #10
0
//Initializes the (global) scripting system, as well as any subsystems.
//script_close is handled by destructors
void script_init(void)
{
	mprintf(("SCRIPTING: Beginning initialization sequence...\n"));

	mprintf(("SCRIPTING: Beginning Lua initialization...\n"));
	Script_system.CreateLuaState();

	if (Output_scripting_meta)
	{
		mprintf(("SCRIPTING: Outputting scripting metadata...\n"));
		char cmdname[MAX_PATH_LEN];
		memset(cmdname, 0, sizeof(cmdname));
		snprintf(cmdname, MAX_PATH_LEN - 1, "%s%s%s%s%s%s%s", detect_home(), DIR_SEPARATOR_STR, Osreg_company_name,
			DIR_SEPARATOR_STR, Osreg_user_dir, DIR_SEPARATOR_STR, "scripting.html");

		Script_system.OutputMeta(cmdname);
	}
	mprintf(("SCRIPTING: Beginning main hook parse sequence....\n"));
	script_parse_table("scripting.tbl");
	parse_modular_table(NOX("*-sct.tbm"), script_parse_table);
	mprintf(("SCRIPTING: Inititialization complete.\n"));
}
//Initializes the (global) scripting system, as well as any subsystems.
//script_close is handled by destructors
void script_init()
{
	mprintf(("SCRIPTING: Beginning initialization sequence...\n"));

	// first things first: init all script hooks, since they are PODs now, not classes...
	script_hook_init(&Script_splashhook);
	script_hook_init(&Script_simulationhook);
	script_hook_init(&Script_hudhook);
	script_hook_init(&Script_globalhook);
	script_hook_init(&Script_gameinithook);

	mprintf(("SCRIPTING: Beginning Lua initialization...\n"));
	Script_system.CreateLuaState();

	if(Output_scripting_meta)
	{
		mprintf(("SCRIPTING: Outputting scripting metadata...\n"));
		Script_system.OutputMeta("scripting.html");
	}
	mprintf(("SCRIPTING: Beginning main hook parse sequence....\n"));
	script_parse_table("scripting.tbl");
	parse_modular_table(NOX("*-sct.tbm"), script_parse_table);
	mprintf(("SCRIPTING: Inititialization complete.\n"));
}
// initialize localization, if no language is passed - use the language specified in the registry
void lcl_init(int lang_init)
{
	char lang_string[128];
	const char *ret;
	int lang, idx, i;

	// initialize encryption
	encrypt_init();

	// setup English
	Lcl_languages.push_back(Lcl_builtin_languages[FS2_OPEN_DEFAULT_LANGUAGE]);

	// check string.tbl to see which languages we support
	try
	{
		parse_stringstbl_quick("strings.tbl");
	}
	catch (const parse::ParseException& e)
	{
		mprintf(("TABLES: Unable to parse '%s'!  Error message = %s.\n", "strings.tbl", e.what()));
	}

	parse_modular_table(NOX("*-lcl.tbm"), parse_stringstbl_quick);

	// if the only language we have at this point is English, we need to setup the builtin languages as we might be dealing with an old style strings.tbl
	// which doesn't support anything beyond the builtin languages. Note, we start at i = 1 because we added English above.
	if ((int)Lcl_languages.size() == 1) {
		for (i=1; i<NUM_BUILTIN_LANGUAGES; i++) {
			Lcl_languages.push_back(Lcl_builtin_languages[i]);
		}
	}

	// read the language from the registry
	if(lang_init < 0){
		memset(lang_string, 0, 128);
		// default to DEFAULT_LANGUAGE (which should be English so we don't have to put German text 
		// in tstrings in the #default section)
		ret = os_config_read_string(NULL, "Language", Lcl_languages[FS2_OPEN_DEFAULT_LANGUAGE].lang_name);

		if(ret == NULL){
			Error(LOCATION, "Default language not found."); 
		}

		strcpy_s(lang_string, ret);
		

		// look it up
		lang = -1;
		for(idx = 0; idx < (int)Lcl_languages.size(); idx++){
			if(!stricmp(Lcl_languages[idx].lang_name, lang_string)){
				lang = idx;
				break;
			}
		}
		if(lang < 0){
			lang = 0;
		}	
	} else {
		Assert((lang_init >= 0) && (lang_init < (int)Lcl_languages.size()));
		lang = lang_init;
	}

	// set the language (this function takes care of setting up file pointers)
	lcl_set_language(lang);
}