/** * 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 parse_fonts_tbl(char *only_parse_first_font, size_t only_parse_first_font_size) { int rval; char *filename; // choose file name // (this can be done within the function, as opposed to being passed as a parameter, // because fonts.tbl doesn't have a modular counterpart) if ( cf_exists_full("fonts.tbl", CF_TYPE_TABLES) ) { filename = "fonts.tbl"; } else { filename = NULL; } if ((rval = setjmp(parse_abort)) != 0) { mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", (filename) ? filename : NOX("<default fonts.tbl>"), rval)); return; } if (filename != NULL) { read_file_text(filename, CF_TYPE_TABLES); } else { read_file_text_from_array(defaults_get_file("fonts.tbl")); } reset_parse(); // start parsing required_string("#Fonts"); // read fonts while (required_string_either("#End","$Font:")) { char font_filename[MAX_FILENAME_LEN]; // grab font required_string("$Font:"); stuff_string(font_filename, F_NAME, MAX_FILENAME_LEN); // if we only need the first font, copy it and bail if (only_parse_first_font != NULL) { strcpy_s(only_parse_first_font, only_parse_first_font_size, font_filename); return; } // create font int font_id = gr_create_font(font_filename); if (font_id < 0) { Warning(LOCATION, "Could not create font from typeface '%s'!", font_filename); } } // done parsing required_string("#End"); // double check if (Num_fonts < 3) { Error(LOCATION, "There must be at least three fonts in %s!", (filename) ? filename : NOX("<default fonts.tbl>")); } }
// 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); }
// ------------------------------------------------------------------------------------ // shockwave_init() // // Call once at the start of each level (mission) // void shockwave_level_init() { int i; if ( !Default_shockwave_loaded ) { i = -1; // try and load in a 3d shockwave first // Goober5000 - check for existence of file before trying to load it if ( cf_exists_full("shockwave.pof", CF_TYPE_MODELS) ) { mprintf(("SHOCKWAVE => Loading default shockwave model... \n")); i = shockwave_load( Default_shockwave_3D_filename, true ); if (i >= 0) mprintf(("SHOCKWAVE => Default model load: SUCCEEDED!!\n")); else mprintf(("SHOCKWAVE => Default model load: FAILED!! Falling back to 2D effect...\n")); } // next, try the 2d shockwave effect, unless the 3d effect was loaded if (i < 0) i = shockwave_load( Default_shockwave_2D_filename ); if (i < 0) Error(LOCATION, "ERROR: Unable to open neither 3D nor 2D default shockwaves!!"); Default_shockwave_loaded = 1; } else { // have to make sure that the default 3D model is still valid and usable // the 2D shockwave shouldn't need anything like this if (Shockwave_info[0].model_id >= 0) Shockwave_info[0].model_id = model_load( Default_shockwave_3D_filename, 0, NULL ); } Assert( ((Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0)) ); list_init(&Shockwave_list); for ( i = 0; i < MAX_SHOCKWAVES; i++ ) { Shockwaves[i].flags = 0; Shockwaves[i].objnum = -1; Shockwaves[i].model_id = -1; } Shockwave_inited = 1; }
// ******************************************************************************************** // Inits the Nav System void NavSystem_Init() { for (int i = 0; i < MAX_NAVPOINTS; i++) Navs[i].clear(); AutoPilotEngaged = false; CurrentNav = -1; audio_handle = -1; CinematicStarted = false; UseCutsceneBars = true; // defaults... can be tabled or bound to mission later if (cf_exists_full("autopilot.tbl", CF_TYPE_TABLES)) parse_autopilot_table("autopilot.tbl"); else parse_autopilot_table(NULL); }
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; }
/** * Call once at the start of each level (mission) */ void shockwave_level_init() { int i; if ( !Default_shockwave_loaded ) { i = -1; // try and load in a 3d shockwave first if enabled // Goober5000 - check for existence of file before trying to load it // chief1983 - Spicious added this check for the command line option. I've modified the hardcoded "shockwave.pof" that existed in the check // to use the static name instead, and added a check to override the command line if a 2d default filename is not found // Note - The 3d shockwave flag is forced on by TBP's flag as of rev 4983 if ( Cmdline_enable_3d_shockwave && cf_exists_full(Default_shockwave_3D_filename, CF_TYPE_MODELS) ) { mprintf(("SHOCKWAVE => Loading default shockwave model... \n")); i = shockwave_load( Default_shockwave_3D_filename, true ); if (i >= 0) mprintf(("SHOCKWAVE => Default model load: SUCCEEDED!!\n")); else mprintf(("SHOCKWAVE => Default model load: FAILED!! Falling back to 2D effect...\n")); } // next, try the 2d shockwave effect, unless the 3d effect was loaded // chief1983 - added some messages similar to those for the 3d shockwave if (i < 0 || Cmdline_fb_explosions) { mprintf(("SHOCKWAVE => Loading default shockwave animation... \n")); i = shockwave_load( Default_shockwave_2D_filename ); if (i >= 0) mprintf(("SHOCKWAVE => Default animation load: SUCCEEDED!!\n")); else mprintf(("SHOCKWAVE => Default animation load: FAILED!! Checking if 3d effect was already tried...\n")); } // chief1983 - The first patch broke mods that don't provide a 2d shockwave or define a specific shockwave for each model/weapon (shame on them) // The next patch involved a direct copy of the attempt above, with an i < 0 check in place of the command line check. I've taken that and modified it to // spit out a more meaningful message. Might as well not bother trying again if the command line option was checked as it should have tried the first time through if ( i < 0 && !Cmdline_enable_3d_shockwave && cf_exists_full(Default_shockwave_3D_filename, CF_TYPE_MODELS) ) { mprintf(("SHOCKWAVE => Loading default shockwave model as last resort... \n")); i = shockwave_load( Default_shockwave_3D_filename, true ); if (i >= 0) mprintf(("SHOCKWAVE => Default model load: SUCCEEDED!!\n")); else mprintf(("SHOCKWAVE => Default model load: FAILED!! No effect loaded...\n")); } if (i < 0) Error(LOCATION, "ERROR: Unable to open neither 3D nor 2D default shockwaves!!"); Default_shockwave_loaded = 1; } else { // have to make sure that the default 3D model is still valid and usable // the 2D shockwave shouldn't need anything like this if (Shockwave_info[0].model_id >= 0) Shockwave_info[0].model_id = model_load( Default_shockwave_3D_filename, 0, NULL ); } Assert( ((Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0)) ); list_init(&Shockwave_list); for ( i = 0; i < MAX_SHOCKWAVES; i++ ) { Shockwaves[i].flags = 0; Shockwaves[i].objnum = -1; Shockwaves[i].model_id = -1; } Shockwave_inited = 1; }
/** * @brief Parses controlconfigdefault.tbl, and overrides the default control configuration for each valid entry in the .tbl */ void control_config_common_load_overrides() { LoadEnumsIntoMaps(); try { if (cf_exists_full("controlconfigdefaults.tbl", CF_TYPE_TABLES)) { read_file_text("controlconfigdefaults.tbl", CF_TYPE_TABLES); } else { read_file_text_from_default(defaults_get_file("controlconfigdefaults.tbl")); } reset_parse(); // start parsing // TODO: Split this out into more helps. Too many tabs! while(optional_string("#ControlConfigOverride")) { config_item *cfg_preset = new config_item[CCFG_MAX + 1]; std::copy(Control_config, Control_config + CCFG_MAX + 1, cfg_preset); Control_config_presets.push_back(cfg_preset); SCP_string preset_name; if (optional_string("$Name:")) { stuff_string_line(preset_name); } else { preset_name = "<unnamed preset>"; } Control_config_preset_names.push_back(preset_name); while (required_string_either("#End","$Bind Name:")) { const int iBufferLength = 64; char szTempBuffer[iBufferLength]; required_string("$Bind Name:"); stuff_string(szTempBuffer, F_NAME, iBufferLength); const size_t cCntrlAryLength = sizeof(Control_config) / sizeof(Control_config[0]); for (size_t i = 0; i < cCntrlAryLength; ++i) { config_item& r_ccConfig = cfg_preset[i]; if (!strcmp(szTempBuffer, r_ccConfig.text)) { /** * short key_default; * short joy_default; * char tab; * bool hasXSTR; * char type; */ int iTemp; if (optional_string("$Key Default:")) { if (optional_string("NONE")) { r_ccConfig.key_default = (short)-1; } else { stuff_string(szTempBuffer, F_NAME, iBufferLength); r_ccConfig.key_default = (short)mKeyNameToVal[szTempBuffer]; } } if (optional_string("$Joy Default:")) { stuff_int(&iTemp); r_ccConfig.joy_default = (short)iTemp; } if (optional_string("$Key Mod Shift:")) { stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_SHIFTED : 0; } if (optional_string("$Key Mod Alt:")) { stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_ALTED : 0; } if (optional_string("$Key Mod Ctrl:")) { stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_CTRLED : 0; } if (optional_string("$Category:")) { stuff_string(szTempBuffer, F_NAME, iBufferLength); r_ccConfig.tab = (char)mCCTabNameToVal[szTempBuffer]; } if (optional_string("$Has XStr:")) { stuff_int(&iTemp); r_ccConfig.hasXSTR = (iTemp == 1); } if (optional_string("$Type:")) { stuff_string(szTempBuffer, F_NAME, iBufferLength); r_ccConfig.type = (char)mCCTypeNameToVal[szTempBuffer]; } if (optional_string("+Disable")) { r_ccConfig.disabled = true; } if (optional_string("$Disable:")) { stuff_boolean(&r_ccConfig.disabled); } // Nerf the buffer now. szTempBuffer[0] = '\0'; } else if ((i + 1) == cCntrlAryLength) { error_display(1, "Bind Name not found: %s\n", szTempBuffer); advance_to_eoln(NULL); ignore_white_space(); return; } } } required_string("#End"); } } catch (const parse::ParseException& e) { mprintf(("TABLES: Unable to parse 'controlconfigdefaults.tbl'! Error message = %s.\n", e.what())); return; } // Overwrite the control config with the first preset that was found if (!Control_config_presets.empty()) { std::copy(Control_config_presets[0], Control_config_presets[0] + CCFG_MAX + 1, Control_config); } }
bool pilotfile::load_savefile(const char *campaign) { char base[_MAX_FNAME] = { '\0' }; std::ostringstream buf; if (Game_mode & GM_MULTIPLAYER) { return false; } if ( (campaign == NULL) || !strlen(campaign) ) { return false; } // set player ptr first thing Assert( (Player_num >= 0) && (Player_num < MAX_PLAYERS) ); p = &Players[Player_num]; // build up filename for the savefile... _splitpath((char*)campaign, NULL, NULL, base, NULL); buf << p->callsign << "." << base << ".csg"; filename = buf.str().c_str(); // if campaign file doesn't exist, abort so we don't load irrelevant data buf.str(std::string()); buf << base << FS_CAMPAIGN_FILE_EXT; if ( !cf_exists_full((char*)buf.str().c_str(), CF_TYPE_MISSIONS) ) { mprintf(("CSG => Unable to find campaign file '%s'!\n", buf.str().c_str())); return false; } // we need to reset this early, in case open fails and we need to create m_data_invalid = false; // open it, hopefully... cfp = cfopen((char*)filename.c_str(), "rb", CFILE_NORMAL, CF_TYPE_PLAYERS); if ( !cfp ) { mprintf(("CSG => Unable to open '%s' for reading!\n", filename.c_str())); return false; } unsigned int csg_id = cfread_uint(cfp); if (csg_id != CSG_FILE_ID) { mprintf(("CSG => Invalid header id for '%s'!\n", filename.c_str())); csg_close(); return false; } // version, now used csg_ver = cfread_ubyte(cfp); mprintf(("CSG => Loading '%s' with version %d...\n", filename.c_str(), (int)csg_ver)); csg_reset_data(); // the point of all this: read in the CSG contents while ( !cfeof(cfp) ) { ushort section_id = cfread_ushort(cfp); uint section_size = cfread_uint(cfp); size_t start_pos = cftell(cfp); // safety, to help protect against long reads cf_set_max_read_len(cfp, section_size); try { switch (section_id) { case Section::Flags: mprintf(("CSG => Parsing: Flags...\n")); m_have_flags = true; csg_read_flags(); break; case Section::Info: mprintf(("CSG => Parsing: Info...\n")); m_have_info = true; csg_read_info(); break; case Section::Variables: mprintf(("CSG => Parsing: Variables...\n")); csg_read_variables(); break; case Section::HUD: mprintf(("CSG => Parsing: HUD...\n")); csg_read_hud(); break; case Section::RedAlert: mprintf(("CSG => Parsing: RedAlert...\n")); csg_read_redalert(); break; case Section::Scoring: mprintf(("CSG => Parsing: Scoring...\n")); csg_read_stats(); break; case Section::Loadout: mprintf(("CSG => Parsing: Loadout...\n")); csg_read_loadout(); break; case Section::Techroom: mprintf(("CSG => Parsing: Techroom...\n")); csg_read_techroom(); break; case Section::Missions: mprintf(("CSG => Parsing: Missions...\n")); csg_read_missions(); break; case Section::Settings: mprintf(("CSG => Parsing: Settings...\n")); csg_read_settings(); break; case Section::Controls: mprintf(("CSG => Parsing: Controls...\n")); csg_read_controls(); break; case Section::Cutscenes: mprintf(("CSG => Parsing: Cutscenes...\n")); csg_read_cutscenes(); break; case Section::LastMissions: mprintf(("CSG => Parsing: Last Missions...\n")); csg_read_lastmissions(); break; default: mprintf(("CSG => Skipping unknown section 0x%04x!\n", section_id)); break; } } catch (cfile::max_read_length &msg) { // read to max section size, move to next section, discarding // extra/unknown data mprintf(("CSG => Warning: (0x%04x) %s\n", section_id, msg.what())); } catch (const char *err) { mprintf(("CSG => ERROR: %s\n", err)); csg_close(); return false; } // reset safety catch cf_set_max_read_len(cfp, 0); // skip to next section (if not already there) size_t offset_pos = (start_pos + section_size) - cftell(cfp); if (offset_pos) { mprintf(("CSG => Warning: (0x%04x) Short read, information may have been lost!\n", section_id)); cfseek(cfp, (int)offset_pos, CF_SEEK_CUR); } } // if the campaign (for whatever reason) doesn't have a squad image, use the multi one if (p->s_squad_filename[0] == '\0') { strcpy_s(p->s_squad_filename, p->m_squad_filename); } player_set_squad_bitmap(p, p->s_squad_filename, false); mprintf(("CSG => Loading complete!\n")); // cleanup and return csg_close(); return true; }
/** * Parse the table */ void iff_init() { char traitor_name[NAME_LENGTH]; char attack_names[MAX_IFFS][MAX_IFFS][NAME_LENGTH]; struct { char iff_name[NAME_LENGTH]; int color_index; } observed_color_table[MAX_IFFS][MAX_IFFS]; int num_attack_names[MAX_IFFS]; int num_observed_colors[MAX_IFFS]; int i, j, k; int string_idx; try { // Goober5000 - if table doesn't exist, use the default table if (cf_exists_full("iff_defs.tbl", CF_TYPE_TABLES)) read_file_text("iff_defs.tbl", CF_TYPE_TABLES); else read_file_text_from_array(defaults_get_file("iff_defs.tbl")); reset_parse(); // parse the table -------------------------------------------------------- required_string("#IFFs"); // get the traitor required_string("$Traitor IFF:"); stuff_string(traitor_name, F_NAME, NAME_LENGTH); int rgb[3]; // check if alternate colours are wanted to be used for these // Marks various stuff... like asteroids if ((optional_string("$Selection Color:")) || (optional_string("$Selection Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); iff_init_color(rgb[0], rgb[1], rgb[2]); } else iff_init_color(0xff, 0xff, 0xff); // Marks the ship currently saying something if ((optional_string("$Message Color:")) || (optional_string("$Message Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); iff_init_color(rgb[0], rgb[1], rgb[2]); } else iff_init_color(0x7f, 0x7f, 0x7f); // Marks the tagged ships if ((optional_string("$Tagged Color:")) || (optional_string("$Tagged Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); iff_init_color(rgb[0], rgb[1], rgb[2]); } else iff_init_color(0xff, 0xff, 0x00); // init radar blips colour table int a_bright, a_dim; bool alternate_blip_color = false; for (i = 0; i < 5; i++) { for (j = 0; j < 2; j++) { for (k = 0; k < 3; k++) { radar_iff_color[i][j][k] = -1; } } } // if the bright/dim scaling is wanted to be changed if (optional_string("$Dimmed IFF brightness:")) { int dim_iff_brightness; stuff_int(&dim_iff_brightness); Assert(dim_iff_brightness >= 0 && dim_iff_brightness <= HUD_COLOR_ALPHA_MAX); *iff_color_brightness = dim_iff_brightness; } else *iff_color_brightness = 4; // alternate = use same method as with ship blips // retail = use 1/2 intensities if (optional_string("$Use Alternate Blip Coloring:") || optional_string("$Use Alternate Blip Colouring:")) { stuff_boolean(&alternate_blip_color); } // Parse blip colours, their order is hardcoded. if ((optional_string("$Missile Blip Color:")) || (optional_string("$Missile Blip Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); for (i = 0; i < 3; i++) { Assert(rgb[i] >= 0 && rgb[i] <= 255); radar_iff_color[0][1][i] = rgb[i]; radar_iff_color[0][0][i] = rgb[i] / 2; } } if ((optional_string("$Navbuoy Blip Color:")) || (optional_string("$Navbuoy Blip Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); for (i = 0; i < 3; i++) { Assert(rgb[i] >= 0 && rgb[i] <= 255); radar_iff_color[1][1][i] = rgb[i]; radar_iff_color[1][0][i] = rgb[i] / 2; } } if ((optional_string("$Warping Blip Color:")) || (optional_string("$Warping Blip Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); for (i = 0; i < 3; i++) { Assert(rgb[i] >= 0 && rgb[i] <= 255); radar_iff_color[2][1][i] = rgb[i]; radar_iff_color[2][0][i] = rgb[i] / 2; } } if ((optional_string("$Node Blip Color:")) || (optional_string("$Node Blip Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); for (i = 0; i < 3; i++) { Assert(rgb[i] >= 0 && rgb[i] <= 255); radar_iff_color[3][1][i] = rgb[i]; radar_iff_color[3][0][i] = rgb[i] / 2; } } if ((optional_string("$Tagged Blip Color:")) || (optional_string("$Tagged Blip Colour:"))) { stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); for (i = 0; i < 3; i++) { Assert(rgb[i] >= 0 && rgb[i] <= 255); radar_iff_color[4][1][i] = rgb[i]; radar_iff_color[4][0][i] = rgb[i] / 2; } } if (alternate_blip_color == true) { a_bright = iff_get_alpha_value(true); a_dim = iff_get_alpha_value(false); for (i = 0; i < 5; i++) { if (radar_iff_color[i][0][0] >= 0) { for (j = 0; j < 3; j++) { radar_iff_color[i][0][j] = radar_iff_color[i][1][j]; } radar_iff_color[i][1][3] = a_bright; radar_iff_color[i][0][3] = a_dim; } } } else { for (i = 0; i < 5; i++) { if (radar_iff_color[i][0][0] >= 0) { radar_iff_color[i][0][3] = 255; radar_iff_color[i][1][3] = 255; } } } if (optional_string("$Radar Target ID Flags:")) { parse_string_flag_list((int*)&radar_target_id_flags, rti_flags, Num_rti_flags); if (optional_string("+reset")) radar_target_id_flags = 0; } // begin reading data Num_iffs = 0; while (required_string_either("#End", "$IFF Name:")) { iff_info *iff; int cur_iff; // make sure we're under the limit if (Num_iffs >= MAX_IFFS) { Warning(LOCATION, "Too many iffs in iffs_defs.tbl! Max is %d.\n", MAX_IFFS); skip_to_start_of_string("#End", NULL); break; } // add new IFF iff = &Iff_info[Num_iffs]; cur_iff = Num_iffs; Num_iffs++; // get required IFF info ---------------------------------------------- // get the iff name required_string("$IFF Name:"); stuff_string(iff->iff_name, F_NAME, NAME_LENGTH); // get the iff color if (check_for_string("$Colour:")) required_string("$Colour:"); else required_string("$Color:"); stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); iff->color_index = iff_init_color(rgb[0], rgb[1], rgb[2]); // get relationships between IFFs ------------------------------------- // get the list of iffs attacked if (optional_string("$Attacks:")) num_attack_names[cur_iff] = stuff_string_list(attack_names[cur_iff], MAX_IFFS); else num_attack_names[cur_iff] = 0; // get the list of observed colors num_observed_colors[cur_iff] = 0; while (optional_string("+Sees")) { // get iff observed stuff_string_until(observed_color_table[cur_iff][num_observed_colors[cur_iff]].iff_name, "As:", NAME_LENGTH); required_string("As:"); // get color observed stuff_int_list(rgb, 3, RAW_INTEGER_TYPE); observed_color_table[cur_iff][num_observed_colors[cur_iff]].color_index = iff_init_color(rgb[0], rgb[1], rgb[2]); // increment num_observed_colors[cur_iff]++; } // get flags ---------------------------------------------------------- // get iff flags iff->flags = 0; if (optional_string("$Flags:")) { char flag_strings[MAX_IFF_FLAGS][NAME_LENGTH]; int num_strings = stuff_string_list(flag_strings, MAX_IFF_FLAGS); for (string_idx = 0; string_idx < num_strings; string_idx++) { if (!stricmp(NOX("support allowed"), flag_strings[string_idx])) iff->flags |= IFFF_SUPPORT_ALLOWED; else if (!stricmp(NOX("exempt from all teams at war"), flag_strings[string_idx])) iff->flags |= IFFF_EXEMPT_FROM_ALL_TEAMS_AT_WAR; else if (!stricmp(NOX("orders hidden"), flag_strings[string_idx])) iff->flags |= IFFF_ORDERS_HIDDEN; else if (!stricmp(NOX("orders shown"), flag_strings[string_idx])) iff->flags |= IFFF_ORDERS_SHOWN; else if (!stricmp(NOX("wing name hidden"), flag_strings[string_idx])) iff->flags |= IFFF_WING_NAME_HIDDEN; else Warning(LOCATION, "Bogus string in iff flags: %s\n", flag_strings[string_idx]); } } // get default ship flags iff->default_parse_flags = 0; if (optional_string("$Default Ship Flags:")) { i = 0; j = 0; char flag_strings[MAX_PARSE_OBJECT_FLAGS][NAME_LENGTH]; int num_strings = stuff_string_list(flag_strings, MAX_PARSE_OBJECT_FLAGS); for (i = 0; i < num_strings; i++) { for (j = 0; j < MAX_PARSE_OBJECT_FLAGS; j++) { if (!stricmp(flag_strings[i], Parse_object_flags[j])) { iff->default_parse_flags |= (1 << j); break; } } } if (j == MAX_PARSE_OBJECT_FLAGS) Warning(LOCATION, "Bogus string in iff default ship flags: %s\n", flag_strings[i]); } // again iff->default_parse_flags2 = 0; if (optional_string("$Default Ship Flags2:")) { i = 0; j = 0; char flag_strings[MAX_PARSE_OBJECT_FLAGS_2][NAME_LENGTH]; int num_strings = stuff_string_list(flag_strings, MAX_PARSE_OBJECT_FLAGS_2); for (i = 0; i < num_strings; i++) { for (j = 0; j < MAX_PARSE_OBJECT_FLAGS_2; j++) { if (!stricmp(flag_strings[i], Parse_object_flags_2[j])) { iff->default_parse_flags2 |= (1 << j); break; } } } if (j == MAX_PARSE_OBJECT_FLAGS_2) Warning(LOCATION, "Bogus string in iff default ship flags2: %s\n", flag_strings[i]); } // this is cleared between each level but let's just set it here for thoroughness iff->ai_rearm_timestamp = timestamp(-1); } required_string("#End"); // now resolve the relationships ------------------------------------------ // first get the traitor Iff_traitor = iff_lookup(traitor_name); if (Iff_traitor < 0) { Iff_traitor = 0; Warning(LOCATION, "Traitor IFF %s not found in iff_defs.tbl! Defaulting to %s.\n", traitor_name, Iff_info[Iff_traitor].iff_name); } // next get the attackees and colors for (int cur_iff = 0; cur_iff < Num_iffs; cur_iff++) { iff_info *iff = &Iff_info[cur_iff]; // clear the iffs to be attacked iff->attackee_bitmask = 0; iff->attackee_bitmask_all_teams_at_war = 0; // clear the observed colors for (j = 0; j < MAX_IFFS; j++) iff->observed_color_index[j] = -1; // resolve the list names for (int list_index = 0; list_index < MAX_IFFS; list_index++) { // are we within the number of attackees listed? if (list_index < num_attack_names[cur_iff]) { // find out who int target_iff = iff_lookup(attack_names[cur_iff][list_index]); // valid? if (target_iff >= 0) iff->attackee_bitmask |= iff_get_mask(target_iff); else Warning(LOCATION, "Attack target IFF %s not found for IFF %s in iff_defs.tbl!\n", attack_names[cur_iff][list_index], iff->iff_name); } // are we within the number of colors listed? if (list_index < num_observed_colors[cur_iff]) { // find out who int target_iff = iff_lookup(observed_color_table[cur_iff][list_index].iff_name); // valid? if (target_iff >= 0) iff->observed_color_index[target_iff] = observed_color_table[cur_iff][list_index].color_index; else Warning(LOCATION, "Observed color IFF %s not found for IFF %s in iff_defs.tbl!\n", observed_color_table[cur_iff][list_index].iff_name, iff->iff_name); } } // resolve the all teams at war relationships if (iff->flags & IFFF_EXEMPT_FROM_ALL_TEAMS_AT_WAR) { // exempt, so use standard attacks iff->attackee_bitmask_all_teams_at_war = iff->attackee_bitmask; } else { // nonexempt, so build bitmask of all other nonexempt teams for (int other_iff = 0; other_iff < Num_iffs; other_iff++) { // skip myself (unless I attack myself normally) if ((other_iff == cur_iff) && !iff_x_attacks_y(cur_iff, cur_iff)) continue; // skip anyone exempt if (Iff_info[other_iff].flags & IFFF_EXEMPT_FROM_ALL_TEAMS_AT_WAR) continue; // add everyone else iff->attackee_bitmask_all_teams_at_war |= iff_get_mask(other_iff); } } } // add tbl/tbm to multiplayer validation list extern void fs2netd_add_table_validation(const char *tblname); fs2netd_add_table_validation("iff_defs.tbl"); } catch (const parse::ParseException& e) { mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", "iff_defs.tbl", e.what())); return; } }
static bool opengl_post_init_table() { bool warned = false; try { if (cf_exists_full("post_processing.tbl", CF_TYPE_TABLES)) read_file_text("post_processing.tbl", CF_TYPE_TABLES); else read_file_text_from_default(defaults_get_file("post_processing.tbl")); reset_parse(); if (optional_string("#Effects")) { while (!required_string_one_of(3, "$Name:", "#Ship Effects", "#End")) { char tbuf[NAME_LENGTH + 1] = { 0 }; post_effect_t eff; required_string("$Name:"); stuff_string(tbuf, F_NAME, NAME_LENGTH); eff.name = tbuf; required_string("$Uniform:"); stuff_string(tbuf, F_NAME, NAME_LENGTH); eff.uniform_name = tbuf; required_string("$Define:"); stuff_string(tbuf, F_NAME, NAME_LENGTH); eff.define_name = tbuf; required_string("$AlwaysOn:"); stuff_boolean(&eff.always_on); required_string("$Default:"); stuff_float(&eff.default_intensity); eff.intensity = eff.default_intensity; required_string("$Div:"); stuff_float(&eff.div); required_string("$Add:"); stuff_float(&eff.add); // Post_effects index is used for flag checks, so we can't have more than 32 if (Post_effects.size() < 32) { Post_effects.push_back(eff); } else if (!warned) { mprintf(("WARNING: post_processing.tbl can only have a max of 32 effects! Ignoring extra...\n")); warned = true; } } } //Built-in per-ship effects ship_effect se1; strcpy_s(se1.name, "FS1 Ship select"); se1.shader_effect = 0; se1.disables_rendering = false; se1.invert_timer = false; Ship_effects.push_back(se1); if (optional_string("#Ship Effects")) { while (!required_string_one_of(3, "$Name:", "#Light Shafts", "#End")) { ship_effect se; char tbuf[NAME_LENGTH] = { 0 }; required_string("$Name:"); stuff_string(tbuf, F_NAME, NAME_LENGTH); strcpy_s(se.name, tbuf); required_string("$Shader Effect:"); stuff_int(&se.shader_effect); required_string("$Disables Rendering:"); stuff_boolean(&se.disables_rendering); required_string("$Invert timer:"); stuff_boolean(&se.invert_timer); Ship_effects.push_back(se); } } if (optional_string("#Light Shafts")) { required_string("$AlwaysOn:"); stuff_boolean(&ls_on); required_string("$Density:"); stuff_float(&ls_density); required_string("$Falloff:"); stuff_float(&ls_falloff); required_string("$Weight:"); stuff_float(&ls_weight); required_string("$Intensity:"); stuff_float(&ls_intensity); required_string("$Sample Number:"); stuff_int(&ls_samplenum); ls_cpintensity = ls_weight; for (int i = 1; i < ls_samplenum; i++) ls_cpintensity += ls_weight * pow(ls_falloff, i); ls_cpintensity *= ls_intensity; } required_string("#End"); return true; } catch (const parse::ParseException& e) { mprintf(("Unable to parse 'post_processing.tbl'! Error message = %s.\n", e.what())); return false; } }