Files
fs2open.github.com/code/mod_table/mod_table.cpp
T
karajorma dc9de13d85 Get the default chance of a pilot praising his own kills from mod.tbl rather than the hardcoded magic number it currently uses.
Switch mod.tbl to automatically read the default table first, then look for the one the mod uses. This guarantees that variables are initialised to something and simplifies the logic for mod.tbl a lot.
2012-03-07 00:45:28 +00:00

91 lines
2.4 KiB
C++

/*
* Created by Hassan "Karajorma" Kazmi for the FreeSpace2 Source Code Project.
* You may not sell or otherwise commercially exploit the source or things you
* create based on the source.
*/
#include "globalincs/pstypes.h"
#include "globalincs/def_files.h"
#include "mission/missioncampaign.h"
#include "mission/missionmessage.h"
#include "mod_table/mod_table.h"
#include "localization/localize.h"
#include "parse/parselo.h"
int Directive_wait_time;
bool True_loop_argument_sexps;
void parse_mod_table(char *filename)
{
int rval;
// SCP_vector<SCP_string> lines;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0)
{
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", (filename) ? filename : "<default game_settings.tbl>", rval));
lcl_ext_close();
return;
}
if (filename == NULL)
read_file_text_from_array(defaults_get_file("game_settings.tbl"));
else
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
// start parsing
optional_string("#CAMPAIGN SETTINGS");
if (optional_string("$Default Campaign File Name:")) {
stuff_string(Default_campaign_file_name, F_NAME, (MAX_FILENAME_LEN - 4) );
}
optional_string("#HUD SETTINGS");
// how long should the game wait before displaying a directive?
if (optional_string("$Directive Wait Time:")) {
stuff_int(&Directive_wait_time);
}
optional_string("#SEXP SETTINGS");
if (optional_string("$Loop SEXPs Then Arguments:")) {
stuff_boolean(&True_loop_argument_sexps);
if (True_loop_argument_sexps){
mprintf(("Game Settings Table : Using Reversed Loops For SEXP Arguments"));
}
else {
mprintf(("Game Settings Table : Using Standard Loops For SEXP Arguments"));
}
}
optional_string("#OTHER SETTINGS");
if (optional_string("$Self Praise Percentage:")) {
stuff_int(&Praise_self_percentage);
if (Praise_self_percentage < 0 || Praise_self_percentage > 100) {
Warning(LOCATION, "Game_settings.tbl - $Self Praise Percentage must be between 0 and 100. Setting to 100");
Praise_self_percentage = 100;
}
}
required_string("#END");
// close localization
lcl_ext_close();
}
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);
}