void techroom_intel_init()
{
	int rval, temp;
	static int inited = 0;

	if (inited)
		return;

	// open localization
	lcl_ext_open();

	if ((rval = setjmp(parse_abort)) != 0) {
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", "species.tbl", rval));
		lcl_ext_close();
		return;
	}
	
	read_file_text("species.tbl", CF_TYPE_TABLES);
	reset_parse();

	Intel_info_size = 0;
	while (optional_string("$Entry:")) {
		Assert(Intel_info_size < MAX_INTEL_ENTRIES);
		if (Intel_info_size >= MAX_INTEL_ENTRIES) {
			mprintf(("TECHMENU: Too many intel entries!\n"));
			break;
		}

		Intel_info[Intel_info_size].flags = IIF_DEFAULT_VALUE;

		required_string("$Name:");
		stuff_string(Intel_info[Intel_info_size].name, F_NAME, NAME_LENGTH);

		required_string("$Anim:");
		stuff_string(Intel_info[Intel_info_size].anim_filename, F_NAME, NAME_LENGTH);

		required_string("$AlwaysInTechRoom:");
		stuff_int(&temp);
		if (temp) {
			// set default to align with what we read - Goober5000
			Intel_info[Intel_info_size].flags |= IIF_IN_TECH_DATABASE;
			Intel_info[Intel_info_size].flags |= IIF_DEFAULT_IN_TECH_DATABASE;
		}

		required_string("$Description:");
		stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, TECH_INTEL_DESC_LEN);

		Intel_info_size++;
	}

	inited = 1;

	// 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	
	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();
}
Exemple #3
0
// initialization stuff for cutscenes
void cutscene_init()
{
	char buf[MULTITEXT_LENGTH];
	int rval;

	if ((rval = setjmp(parse_abort)) != 0) {
		Error(LOCATION, "Error parsing 'rank.tbl'\r\nError code = %i.\r\n", rval);
	} 

	// open localization
	lcl_ext_open();

	read_file_text("cutscenes.tbl");
	reset_parse();

	// parse in all the rank names
	Num_cutscenes = 0;
	skip_to_string("#Cutscenes");
	ignore_white_space();
	while ( required_string_either("#End", "$Filename:") ) {
		Assert ( Num_cutscenes < MAX_CUTSCENES );
		required_string("$Filename:");
		stuff_string( Cutscenes[Num_cutscenes].filename, F_PATHNAME, NULL );
		required_string("$Name:");
		stuff_string( Cutscenes[Num_cutscenes].name, F_NAME, NULL );
		required_string("$Description:");
		stuff_string(buf, F_MULTITEXT, NULL);
		drop_white_space(buf);
		compact_multitext_string(buf);
		Cutscenes[Num_cutscenes].description = strdup(buf);
		required_string("$cd:");
		stuff_int( &Cutscenes[Num_cutscenes].cd );

		Num_cutscenes++;
	}

	required_string("#End");

	Cutscenes_viewable = INTRO_CUTSCENE_FLAG;

	// close localization
	lcl_ext_close();
}
Exemple #4
0
void credits_init()
{
	int i, w, h;
	credits_screen_buttons *b;
	char line[512] = "";	
	char *linep1, *linep2;	

	int credits_spooled_music_index = event_music_get_spooled_music_index("Cinema");	
	if(credits_spooled_music_index != -1){
		char *credits_wavfile_name = Spooled_music[credits_spooled_music_index].filename;		
		if(credits_wavfile_name != NULL){
			credits_load_music(credits_wavfile_name);
		}
	}

	// Use this id to trigger the start of music playing on the briefing screen
	Credits_music_begin_timestamp = timestamp(CREDITS_MUSIC_DELAY);

	Credits_frametime = 0;
	Credits_last_time = timer_get_milliseconds();

	Credit_text = NULL;
	Credit_text_malloced = 0;

	// allocate enough space for credits text
	CFILE *fp = cfopen( NOX("credits.tbl"), "rb" );
	if(fp != NULL){
		int rval, size;
		size = cfilelength(fp);
		Credit_text = (char *) vm_malloc(size + 200 + strlen(fs2_open_credit_text) + strlen(unmodified_credits));
		if (Credit_text == NULL) {
			return;
		} else {
			Credit_text_malloced = 1;
		}
		cfclose(fp);

		// open localization
		lcl_ext_open();

		if ((rval = setjmp(parse_abort)) != 0) {
			mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", "credits.tbl", rval));
			lcl_ext_close();
			return;
		}
		
		read_file_text("credits.tbl");
		reset_parse();

		// keep reading everything in
		strcpy(Credit_text, fs2_open_credit_text); 
	   
		bool first_run = true;
		while(!check_for_string_raw("#end")){ 
			
			stuff_string_line(line, sizeof(line));

			// This is a bit odd but it means if a total conversion uses different credits the 
			// Volition credit won't happen
			if(first_run == true)
			{
				if(strcmp(line, mod_check) == 0)
				{
					strcat(Credit_text,	unmodified_credits);	
				}

				first_run = false;
			}

			linep1 = line;

			do {
				linep2 = split_str_once(linep1, Credits_text_coords[gr_screen.res][2]);
				Assert( linep2 != linep1 );
				strcat(Credit_text, linep1);
				strcat(Credit_text, "\n");			
				linep1 = linep2;
			} while (linep2 != NULL);
		}		

		// close localization
		lcl_ext_close();	
	} else {
		Credit_text = NOX("No credits available.\n");
	}	

	int ch;
	for ( i = 0; Credit_text[i]; i++ ) {
			ch = Credit_text[i];
			switch (ch) {
			case -4:
				ch = 129;
				break;

			case -28:
				ch = 132;
				break;

			case -10:
				ch = 148;
				break;

			case -23:
				ch = 130;
				break;

			case -30:
				ch = 131;
				break;

			case -25:
				ch = 135;
				break;

			case -21:
				ch = 137;
				break;

			case -24:
				ch = 138;
				break;

			case -17:
				ch = 139;
				break;

			case -18:
				ch = 140;
				break;

			case -60:
				ch = 142;
				break;

			case -55:
				ch = 144;
				break;

			case -12:
				ch = 147;
				break;

			case -14:
				ch = 149;
				break;

			case -5:
				ch = 150;
				break;

			case -7:
				ch = 151;
				break;

			case -42:
				ch = 153;
				break;

			case -36:
				ch = 154;
				break;

			case -31:
				ch = 160;
				break;

			case -19:
				ch = 161;
				break;

			case -13:
				ch = 162;
				break;

			case -6:
				ch = 163;
				break;

			case -32:
				ch = 133;
				break;

			case -22:
				ch = 136;
				break;

			case -20:
				ch = 141;
				break;
			}
			Credit_text[i] = (char)ch;
	}

	gr_get_string_size(&w, &h, Credit_text);

	Credit_start_pos = i2fl(Credits_text_coords[gr_screen.res][CREDITS_H_COORD]);
	Credit_stop_pos = -i2fl(h);
	Credit_position = Credit_start_pos;

	Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0);
	Ui_window.set_mask_bmap(Credits_bitmap_mask_fname[gr_screen.res]);
	common_set_interface_palette("InterfacePalette");  // set the interface palette

	for (i=0; i<NUM_BUTTONS; i++) {
		b = &Buttons[i][gr_screen.res];

		b->button.create(&Ui_window, "", b->x, b->y, 60, 30, (i < 2), 1);
		// set up callback for when a mouse first goes over a button
		b->button.set_highlight_action(common_play_highlight_sound);
		b->button.set_bmaps(b->filename);
		b->button.link_hotspot(b->hotspot);
	}

	// add some text
	Ui_window.add_XSTR("Technical Database", 1055, Buttons[TECH_DATABASE_BUTTON][gr_screen.res].xt,  Buttons[TECH_DATABASE_BUTTON][gr_screen.res].yt, &Buttons[TECH_DATABASE_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
	Ui_window.add_XSTR("Mission Simulator", 1056, Buttons[SIMULATOR_BUTTON][gr_screen.res].xt,  Buttons[SIMULATOR_BUTTON][gr_screen.res].yt, &Buttons[SIMULATOR_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
	Ui_window.add_XSTR("Cutscenes", 1057, Buttons[CUTSCENES_BUTTON][gr_screen.res].xt,  Buttons[CUTSCENES_BUTTON][gr_screen.res].yt, &Buttons[CUTSCENES_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
	Ui_window.add_XSTR("Credits", 1058, Buttons[CREDITS_BUTTON][gr_screen.res].xt,  Buttons[CREDITS_BUTTON][gr_screen.res].yt, &Buttons[CREDITS_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
	Ui_window.add_XSTR("Exit", 1420, Buttons[EXIT_BUTTON][gr_screen.res].xt,  Buttons[EXIT_BUTTON][gr_screen.res].yt, &Buttons[EXIT_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_PINK);

	if (Player->flags & PLAYER_FLAGS_IS_MULTI) {
		Buttons[SIMULATOR_BUTTON][gr_screen.res].button.disable();
		Buttons[CUTSCENES_BUTTON][gr_screen.res].button.disable();
	}

	Buttons[EXIT_BUTTON][gr_screen.res].button.set_hotkey(KEY_CTRLED | KEY_ENTER);

	Background_bitmap = bm_load(Credits_bitmap_fname[gr_screen.res]);
	Credits_artwork_index = rand() % NUM_IMAGES;
	for (i=0; i<NUM_IMAGES; i++){
		Credits_bmps[i] = -1;
	}

	// CreditsWin01 = bm_load(NOX("CreditsWin01"));
	// CreditsWin02 = bm_load(NOX("CreditsWin02"));
	// CreditsWin03 = bm_load(NOX("CreditsWin03"));
	// CreditsWin04 = bm_load(NOX("CreditsWin04"));
}
void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MENU_REGION* regions, int* num_regions, int play_sound)
{
	CFILE* fp;
	int state=0;
	char* p1, *p2, *p3;
	//char music_filename[128];

	char seps[]   = NOX(" ,\t");
	char *token;
	char tmp_line[132];

	*num_regions=0;

	// open localization
	lcl_ext_open();

	fp = cfopen( NOX("menu.tbl"), "rt" );
	if (fp == NULL) {
		Error(LOCATION, "menu.tbl could not be opened\n");

		// close localization
		lcl_ext_close();

		return;
	}


	while (cfgets(tmp_line, 132, fp)) {
		p1 = strchr(tmp_line,'\n'); if (p1) *p1 = '\0';
		p1 = strchr(tmp_line,';'); if (p1) *p1 = '\0';
		p1 = p3 = strchr( tmp_line, '[' );

		if (p3 && state == 1) {	
			// close localization
			lcl_ext_close();

			cfclose(fp);
			return;
		}
		
		if ( p1 || p3)	{
			if (!state)	{
				p2 = strchr( tmp_line, ']' );
				if (p2) *p2 = 0;
				if (!stricmp( ++p1, menu_name )) state = 1;
			} else {
				cfclose(fp);
				break;
			}
		} else if (state) {
			
		
			// parse a region line
			p1 = strchr( tmp_line, '\"' );
			if (p1) {
				p2 = strchr( tmp_line+1, '\"' );
				if (!p2) {
					nprintf(("Warning","Error parsing menu file\n"));

					// close localization
					lcl_ext_close();

					return;
				}
				*p2 = 0;
				strcpy(regions[*num_regions].text,++p1);
				p2++;

				// get the tokens mask number
				token = strtok( p2, seps );
				regions[*num_regions].mask = atoi(token);
				
				// get the hot key character
				token = strtok( NULL, seps );
				regions[*num_regions].key = token[0];

				// stuff default click sound (not in menu.tbl)
				if ( play_sound ) {
					regions[*num_regions].click_sound = SND_IFACE_MOUSE_CLICK;
				} else {
					regions[*num_regions].click_sound = -1;
				}

				*num_regions = *num_regions + 1;

			}
				else {
				// get the menu filenames

				// Establish string and get the first token
				token = strtok( tmp_line, seps );
				if ( token != NULL )
				{
					// store the background filename
					strcpy(bkg_filename, token);

					// get the mask filename
					token = strtok( NULL, seps );
					strcpy(mask_filename, token);
				}
			}
		}
	}	
	cfclose(fp);
	
	// close localization
	lcl_ext_close();
}
void parse_mod_table(const 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:")) {
		char temp[MAX_FILENAME_LEN];
		stuff_string(temp, F_NAME, MAX_FILENAME_LEN);

		// remove extension?
		if (drop_extension(temp)) {
			mprintf(("Game Settings Table: Removed extension on default campaign file name %s\n", temp));
		}

		// check length
		int maxlen = (MAX_FILENAME_LEN - 4);
		int len = strlen(temp);
		if (len > maxlen) {
			Warning(LOCATION, "Token too long: [%s].  Length = %i.  Max is %i.\n", temp, len, maxlen);
			temp[maxlen] = 0;
		}

		strcpy_s(Default_campaign_file_name, temp);
	}

	if (optional_string("#Ignored Campaign File Names")) {
		SCP_string campaign_name; 

		while (optional_string("$Campaign File Name:")) {
			stuff_string(campaign_name, F_NAME); 

			// remove extension?
			if (drop_extension(campaign_name)) {
				mprintf(("Game Settings Table: Removed extension on ignored campaign file name %s\n", campaign_name.c_str()));
			}

			Ignored_campaigns.push_back(campaign_name); 
		}
	}

	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);
	}

	if (optional_string("$Cutscene camera displays HUD:")) {
		stuff_boolean(&Cutscene_camera_displays_hud);
	}
	// compatibility
	if (optional_string("$Cutscene camera disables HUD:")) {
		mprintf(("Game Settings Table: \"$$Cutscene camera disables HUD\" is deprecated in favor of \"$Cutscene camera displays HUD\"\n"));
		bool temp;
		stuff_boolean(&temp);
		Cutscene_camera_displays_hud = !temp;
	}
	
	if (optional_string("$Full color head animations:")) {
		stuff_boolean(&Full_color_head_anis);
	}
	// compatibility
	if (optional_string("$Color head animations with hud colors:")) {
		mprintf(("Game Settings Table: \"$Color head animations with hud colors\" is deprecated in favor of \"$Full color head animations\"\n"));
		bool temp;
		stuff_boolean(&temp);
		Full_color_head_anis = !temp;
	}

	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\n"));
		} else {
			mprintf(("Game Settings Table: Using Standard Loops For SEXP Arguments\n"));
		}
	}

	if (optional_string("$Use Alternate Chaining Behavior:")) {
		stuff_boolean(&Alternate_chaining_behavior);
		if (Alternate_chaining_behavior) {
			mprintf(("Game Settings Table: Using alternate event chaining behavior\n"));
		} else {
			mprintf(("Game Settings Table: Using standard event chaining behavior\n"));
		}
	}

	optional_string("#GRAPHICS SETTINGS");

	if (optional_string("$Enable External Shaders:")) {
		stuff_boolean(&Enable_external_shaders);
		if (Enable_external_shaders)
			mprintf(("Game Settings Table: External shaders are enabled\n"));
		else
			mprintf(("Game Settings Table: External shaders are DISABLED\n"));
	}

	if (optional_string("$Default Detail Level:")) {
		int detail_level;

		stuff_int(&detail_level);

		mprintf(("Game Settings Table: Setting default detail level to %i of %i-%i\n", detail_level, 0, NUM_DEFAULT_DETAIL_LEVELS-1));

		if (detail_level < 0 || detail_level > NUM_DEFAULT_DETAIL_LEVELS-1) {
			Warning(LOCATION, "Invalid detail level: %i, setting to %i\n", detail_level, Default_detail_level);
		} else {
			Default_detail_level = detail_level;
		}
	}
	
	optional_string("#NETWORK SETTINGS"); 

	if (optional_string("$FS2NetD port:")) {
		stuff_int(&FS2NetD_port);
		if (FS2NetD_port)
			mprintf(("Game Settings Table: FS2NetD connecting to port %i\n", FS2NetD_port));
	}

	optional_string("#OTHER SETTINGS"); 

	if (optional_string("$Fixed Turret Collisions:")) { 
		stuff_boolean(&Fixed_turret_collisions);
	}

	if (optional_string("$Damage Impacted Subsystem First:")) { 
		stuff_boolean(&Damage_impacted_subsystem_first);
	}

	if (optional_string("$Default ship select effect:")) {
		char effect[NAME_LENGTH];
		stuff_string(effect, F_NAME, NAME_LENGTH);
		if (!stricmp(effect, "FS2"))
			Default_ship_select_effect = 2;
		else if (!stricmp(effect, "FS1"))
			Default_ship_select_effect = 1;
		else if (!stricmp(effect, "off"))
			Default_ship_select_effect = 0;
	}

	if (optional_string("$Default weapon select effect:")) {
		char effect[NAME_LENGTH];
		stuff_string(effect, F_NAME, NAME_LENGTH);
		if (!stricmp(effect, "FS2"))
			Default_weapon_select_effect = 2;
		else if (!stricmp(effect, "FS1"))
			Default_weapon_select_effect = 1;
		else if (!stricmp(effect, "off"))
			Default_weapon_select_effect = 0;
	}

	if (optional_string("$Weapons inherit parent collision group:")) {
		stuff_boolean(&Weapons_inherit_parent_collision_group);
		if (Weapons_inherit_parent_collision_group)
			mprintf(("Game Settings Table: Weapons inherit parent collision group\n"));
	}

	if (optional_string("$Flight controls follow eyepoint orientation:")) {
		stuff_boolean(&Flight_controls_follow_eyepoint_orientation);
		if (Flight_controls_follow_eyepoint_orientation)
			mprintf(("Game Settings Table: Flight controls follow eyepoint orientation\n"));
	}

	required_string("#END");

	// close localization
	lcl_ext_close();
}
// initialize the xstr table
void lcl_xstr_init()
{
	char chr, buf[4096];
	char language_tag[512];	
	int i, z, index, rval;
	char *p_offset = NULL;
	int offset_lo = 0, offset_hi = 0;

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

	if ((rval = setjmp(parse_abort)) != 0) {
		mprintf(("Error parsing 'strings.tbl'\nError code = %i.\n", rval));
	} else {
		// make sure localization is NOT running
		lcl_ext_close();

		read_file_text("strings.tbl");
		reset_parse();

		// move down to the proper section		
		memset(language_tag, 0, 512);
		strcpy(language_tag, "#");
		strcat(language_tag, Lcl_languages[Lcl_current_lang].lang_name);
		if(skip_to_string(language_tag) != 1){
			Error(LOCATION, NOX("Strings.tbl is corrupt"));
		}		

		// parse all the strings in this section of the table
		while (!check_for_string("#")) {
			int num_offsets_on_this_line = 0;

			stuff_int(&index);
			stuff_string(buf, F_NAME, NULL, 4096);
			i = strlen(buf);
			while (i--) {
				if (!isspace(buf[i])) {
					break;
				}
			}

			// trim unneccesary end of string
			if (i >= 0) {
				// Assert(buf[i] == '"');
				if (buf[i] != '"') {
					// probably an offset on this entry
					buf[i+1] = 0;						// drop down a null terminator (prolly unnecessary)
					while(!is_white_space(buf[i])) i--;	// back up over the potential offset
					while(is_white_space(buf[i])) i--;	// now back up over intervening spaces
					num_offsets_on_this_line = 1;
					if (buf[i] != '"') {
						// could have a 2nd offset value (one for 640, one for 1024)
						// so back up again
						while(!is_white_space(buf[i])) i--;	// back up over the 2nd offset
						while(is_white_space(buf[i])) i--;	// now back up over intervening spaces
						num_offsets_on_this_line = 2;
					}

					p_offset = &buf[i+1];			// get ptr to string section with offset in it
					if (buf[i] != '"') {
						Error(LOCATION, NOX("Strings.tbl is corrupt"));		// now its an error
					}
				}

				buf[i] = 0;
			}

			// copy string into buf
			z = 0;
			for (i=1; buf[i]; i++) {
				chr = buf[i];
				if (chr == '\\') {
					chr = buf[++i];
					if (chr == 'n') {
						chr = '\n';
					} else if (chr == 'r') {
						chr = '\r';
					}

				}

				buf[z++] = chr;
			}

			// null terminator on buf
			buf[z] = 0;

			// write into Xstr_table
			if (index >= 0 && index < XSTR_SIZE) {
				if (Xstr_table[index].str != NULL) {
					Warning(LOCATION, "Strings table index %d used more than once", index);
				}
				Xstr_table[index].str = strdup(buf);
			}

			// read offset information, assume 0 if nonexistant
			if (p_offset != NULL) {
				if (sscanf(p_offset, "%d%d", &offset_lo, &offset_hi) < num_offsets_on_this_line) {
					// whatever is in the file ain't a proper offset
					Error(LOCATION, NOX("Strings.tbl is corrupt"));
				}
			}
			Xstr_table[index].offset_x = offset_lo;
			if (num_offsets_on_this_line == 2) {
				Xstr_table[index].offset_x_hi = offset_hi;
			} else {
				Xstr_table[index].offset_x_hi = offset_lo;						
			}

			// clear out our vars
			p_offset = NULL;
			offset_lo = 0;
			offset_hi = 0;
			num_offsets_on_this_line = 0;
		}
	}

	Xstr_inited = 1;
}
// initialize the pointer array into tstrings.tbl (call from lcl_ext_open() ONLY)
void lcl_ext_setup_pointers()
{
	char language_string[128];
	char line[1024];
	char *tok;	
	int string_count;
	int ret;
	int found_start = 0;

	// open the localization file
	lcl_ext_open();
	if(Lcl_ext_file == NULL){
		error_display(0, "Error opening externalization file! File likely does not exist or could not be found");
		return;
	}

	// seek to the currently active language
	memset(language_string, 0, 128);
	strcpy(language_string, "#");
	if(!stricmp(DEFAULT_LANGUAGE, Lcl_languages[Lcl_current_lang].lang_name)){
		strcat(language_string, "default");
	} else {
		strcat(language_string, Lcl_languages[Lcl_current_lang].lang_name);
	}
	memset(line, 0, 1024);

	// reset seek variables and begin		
	Lcl_pointer_count = 0;
	while(cfgets(line, 1024, Lcl_ext_file)){
		tok = strtok(line, " \n");
		if(tok == NULL){
			continue;			
		}
		
		// if the language matches, we're good to start parsing strings
		if(!stricmp(language_string, tok)){
			found_start = 1;			
			break;
		}		
	}

	// if we didn't find the language specified, error
	if(found_start <= 0){
		error_display(0, "Could not find specified langauge in tstrings.tbl!\n");
		lcl_ext_close();
		return;
	}

	string_count = 0;	
	while(cfgets(line, 1024, Lcl_ext_file)){
		ret = lcl_ext_lookup_sub(line, NULL, -1);

		// do stuff
		switch(ret & 0x0fffffff){
		// error
		case 0 :
			lcl_ext_close();
			return;		

		// end of language found
		case 3 :
			// mark one final pointer
			Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1;
			lcl_ext_close();
			return;
		}

		// the only other case we care about is the beginning of a new id#
		if(ret & (1<<31)){		
			if((string_count % LCL_GRANULARITY) == 0){
				// mark the pointer down
				Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1;

				// if we're out of pointer slots
				if(Lcl_pointer_count >= LCL_MAX_POINTERS){
					error_display(0, "Out of pointer for tstrings.tbl lookup. Please increment LCL_MAX_POINTERS in localize.cpp");
					lcl_ext_close();
					return;
				}
			}
			// increment string count
			string_count++;			
		}
	}

	// should never get here. we should always be exiting through case 3 (end of language section) of the above switch
	// statement
	Int3();
	lcl_ext_close();
}
void parse_autopilot_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 autopilot.tbl>", rval));
		lcl_ext_close();
		return;
	}

	if (filename == NULL)
		read_file_text_from_array(defaults_get_file("autopilot.tbl"));
	else
		read_file_text(filename, CF_TYPE_TABLES);

	reset_parse();		

	
	required_string("#Autopilot");

	// autopilot link distance
	required_string("$Link Distance:");
	stuff_int(&NavLinkDistance);

	if (optional_string("$Interrupt autopilot if enemy within distance:"))
		stuff_int(&AutopilotMinEnemyDistance);
	else
		AutopilotMinEnemyDistance = 5000;

	if (optional_string("$Interrupt autopilot if asteroid within distance:"))
		stuff_int(&AutopilotMinAsteroidDistance);
	else
		AutopilotMinAsteroidDistance = 1000;

	if (optional_string("$Lock Weapons During Autopilot:"))
		stuff_boolean(&LockWeaponsDuringAutopilot);
	else
		LockWeaponsDuringAutopilot = false;

	// optional no cutscene bars
	if (optional_string("+No_Cutscene_Bars"))
		UseCutsceneBars = false;
	// optional no cutscene bars
	if (optional_string("+No_Autopilot_Interrupt"))
		Cmdline_autopilot_interruptable = 0;

	// No Nav selected message
	char *msg_tags[] = { "$No Nav Selected:", "$Gliding:",
		"$Too Close:", "$Hostiles:", "$Linked:", "$Hazard:",
		"$Support Present:", "$Support Working:" };
	for (int i = 0; i < NP_NUM_MESSAGES; i++)
	{
		required_string(msg_tags[i]);
		
		required_string("+Msg:");
		stuff_string(NavMsgs[i].message, F_MESSAGE, 256);

		required_string("+Snd File:");
		stuff_string(NavMsgs[i].filename, F_NAME, 256);
	}


	required_string("#END");

	// close localization
	lcl_ext_close();
}
Exemple #10
0
// -------------------------------------------------------------------------------------------------
// 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();
}
Exemple #11
0
void parse_medal_tbl()
{
	int rval, i;
	int num_badges = 0;

	// open localization
	lcl_ext_open();

	if ((rval = setjmp(parse_abort)) != 0)
	{
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", "medals.tbl", rval));
		lcl_ext_close();
		return;
	}

	read_file_text("medals.tbl", CF_TYPE_TABLES);
	reset_parse();

	// parse in all the rank names
	Num_medals = 0;
	required_string("#Medals");
	while (required_string_either("#End", "$Name:"))
	{
		medal_stuff temp_medal;

		required_string("$Name:");
		stuff_string(temp_medal.name, F_NAME, NAME_LENGTH);

		required_string("$Bitmap:");
		stuff_string(temp_medal.bitmap, F_NAME, MAX_FILENAME_LEN);

		required_string("$Num mods:");
		stuff_int(&temp_medal.num_versions);

		// some medals are based on kill counts.  When string +Num Kills: is present, we know that
		// this medal is a badge and should be treated specially
		if (optional_string("+Num Kills:"))
		{
			char buf[MULTITEXT_LENGTH];

			stuff_int(&temp_medal.kills_needed);

			if (optional_string("$Wavefile 1:"))
				stuff_string(temp_medal.voice_base, F_NAME, MAX_FILENAME_LEN);
			if (optional_string("$Wavefile 2:"))
				stuff_string(temp_medal.voice_base, F_NAME, MAX_FILENAME_LEN);
			//stuff_string(Badge_info[bi].wave2, F_NAME, NULL, MAX_FILENAME_LEN);

			if (optional_string("$Wavefile Base:"))
				stuff_string(temp_medal.voice_base, F_NAME, MAX_FILENAME_LEN);

			//required_string("$Wavefile 2:");
			//stuff_string(Badge_info[bi].wave2, F_NAME, NULL, MAX_FILENAME_LEN);

			required_string("$Promotion Text:");
			stuff_string(buf, F_MULTITEXT, sizeof(buf));
			temp_medal.promotion_text = vm_strdup(buf);

			// since badges (ace ranks) are handled a little differently we need to know
			// which we are in the list of badges.
			temp_medal.badge_num = num_badges++;
		}

		Medals.push_back(temp_medal);
	}

	required_string("#End");

	Num_medals = Medals.size();
	Assert(Num_medals == MAX_MEDALS);

	// be sure that the badges kill numbers show up in order
	//WMC - I don't think this is needed anymore due to my changes to post-mission functions
	//but I'm keeping it here to be sure.
	int prev_badge_kills = 0;
	for (i = 0; i < Num_medals; i++)
	{
		if (Medals[i].kills_needed < prev_badge_kills && Medals[i].kills_needed != 0)
			Error(LOCATION,
				"Badges must appear sorted by lowest kill # first in medals.tbl\nFind Allender for most information.");

		if (Medals[i].kills_needed > 0)
			prev_badge_kills = Medals[i].kills_needed;
	}

	// close localization
	lcl_ext_close();
}
Exemple #12
0
void parse_species_tbl(char* filename)
{
	int i, rval;
	char species_name[NAME_LENGTH];

	// open localization
	lcl_ext_open();

	if ((rval = setjmp(parse_abort)) != 0)
	{
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", (filename) ? filename :
				 NOX("<default species_defs.tbl>"), rval));
		lcl_ext_close();
		return;
	}

	if (filename == NULL)
		read_file_text_from_array(defaults_get_file("species_defs.tbl"));
	else
		read_file_text(filename, CF_TYPE_TABLES);

	reset_parse();


	// start parsing
	required_string("#SPECIES DEFS");

	// no longer required: counted automatically
	if (optional_string("$NumSpecies:"))
	{
		int temp;
		stuff_int(&temp);
	}

	// begin reading data
	while (required_string_either("#END", "$Species_Name:"))
	{
		bool no_create = false;
		species_info* species, new_species;

		species = &new_species;

		// Start Species - Get its name
		required_string("$Species_Name:");
		stuff_string(species_name, F_NAME, NAME_LENGTH);

		if (optional_string("+nocreate"))
		{
			no_create = true;

			for (i = 0; i < (int)Species_info.size(); i++)
			{
				if (!stricmp(Species_info[i].species_name, species_name))
				{
					species = &Species_info[i];
					break;
				}
			}
		}
		else
		{
			strcpy_s(species->species_name, species_name);
		}

		// Goober5000 - IFF
		if (optional_string("$Default IFF:"))
		{
			bool iff_found = false;
			char temp_name[NAME_LENGTH];
			stuff_string(temp_name, F_NAME, NAME_LENGTH);

			// search for it in iffs
			for (int iLoop = 0; iLoop < Num_iffs; iLoop++)
			{
				if (!stricmp(Iff_info[iLoop].iff_name, temp_name))
				{
					species->default_iff = iLoop;
					iff_found = true;
				}
			}

			if (!iff_found)
			{
				species->default_iff = 0;
				Warning(LOCATION, "Species %s default IFF %s not found in iff_defs.tbl!  Defaulting to %s.\n",
					species->species_name, temp_name, Iff_info[species->default_iff].iff_name);
			}
		}
		else if (!no_create)
		{
			// we have no idea which it could be, so default to 0
			species->default_iff = 0;

			// let them know
			Warning(LOCATION, "$Default IFF not specified for species %s in species_defs.tbl!  Defaulting to %s.\n",
				species->species_name, Iff_info[species->default_iff].iff_name);
		}

		// Goober5000 - FRED color
		if (optional_string("$FRED Color:") || optional_string("$FRED Colour:"))
		{
			stuff_int_list(species->fred_color.a1d, 3, RAW_INTEGER_TYPE);
		}
		else if (!no_create)
		{
			// set defaults to Volition's originals
			if (!stricmp(species->species_name, "Terran"))
			{
				species->fred_color.rgb.r = 0;
				species->fred_color.rgb.g = 0;
				species->fred_color.rgb.b = 192;
			}
			else if (!stricmp(species->species_name, "Vasudan"))
			{
				species->fred_color.rgb.r = 0;
				species->fred_color.rgb.g = 128;
				species->fred_color.rgb.b = 0;
			}
			else if (!stricmp(species->species_name, "Shivan"))
			{
				species->fred_color.rgb.r = 192;
				species->fred_color.rgb.g = 0;
				species->fred_color.rgb.b = 0;
			}
			else if (!stricmp(species->species_name, "Ancients") || !stricmp(species->species_name, "Ancient"))
			{
				species->fred_color.rgb.r = 192;
				species->fred_color.rgb.g = 0;
				species->fred_color.rgb.b = 192;
			}
			else
			{
				species->fred_color.rgb.r = 0;
				species->fred_color.rgb.g = 0;
				species->fred_color.rgb.b = 0;
			}

			// let them know
			Warning(LOCATION,
				"$FRED Color not specified for species %s in species_defs.tbl!  Defaulting to (%d, %d, %d).\n",
				species->species_name, species->fred_color.rgb.r, species->fred_color.rgb.g,
				species->fred_color.rgb.b);
		}

		// stuff
		optional_string("$MiscAnims:");

		// Get its Debris Texture
		if ((!no_create && required_string("+Debris_Texture:")) || optional_string("+Debris_Texture:"))
		{
			generic_bitmap_init(&species->debris_texture, NULL);
			stuff_string(species->debris_texture.filename, F_NAME, MAX_FILENAME_LEN);
		}


		// Shield Hit Animation
		if ((!no_create && required_string("+Shield_Hit_ani:")) || optional_string("+Shield_Hit_ani:"))
		{
			generic_anim_init(&species->shield_anim, NULL);
			stuff_string(species->shield_anim.filename, F_NAME, MAX_FILENAME_LEN);
		}


		// Thruster Anims
		parse_thrust_anims(species, no_create);

		// Thruster Glow Anims
		parse_thrust_glows(species, no_create);


		// Goober5000 - AWACS multiplier
		if (optional_string("$AwacsMultiplier:"))
		{
			stuff_float(&species->awacs_multiplier);
		}
		else if (!no_create)
		{
			// set defaults to Volition's originals
			if (!stricmp(species->species_name, "Vasudan"))
				species->awacs_multiplier = 1.25f;
			else if (!stricmp(species->species_name, "Shivan"))
				species->awacs_multiplier = 1.50f;
			else
				species->awacs_multiplier = 1.0f;

			// let them know
			Warning(LOCATION,
				"$AwacsMultiplier not specified for species %s in species_defs.tbl!  Defaulting to %.2d.\n",
				species->species_name, species->awacs_multiplier);
		}

		// don't add new entry if this is just a modified one
		if (!no_create)
			Species_info.push_back(new_species);
	}

	required_string("#END");

	// add tbl/tbm to multiplayer validation list
	extern void fs2netd_add_table_validation(char* tblname);
	fs2netd_add_table_validation(filename);

	// close localization
	lcl_ext_close();
}
void parse_medal_tbl()
{
	int rval, i;

	// open localization
	lcl_ext_open();

	if ((rval = setjmp(parse_abort)) != 0) {
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", "medals.tbl", rval));
		lcl_ext_close();
		return;
	}

	read_file_text("medals.tbl", CF_TYPE_TABLES);
	reset_parse();

	required_string("#Medals");

	// special background information
	if (optional_string("+Background Bitmap:")) {
		stuff_string(Medals_background_filename, F_NAME, NAME_LENGTH);
	} else {
		strcpy_s(Medals_background_filename, Default_medals_background_filename);
	}

	// special mask information
	if (optional_string("+Mask Bitmap:")) {
		stuff_string(Medals_mask_filename, F_NAME, NAME_LENGTH);
	} else {
		strcpy_s(Medals_mask_filename, Default_medals_mask_filename);
	}

	// special positioning for player callsign
	if (optional_string("+Callsign Position 640:")) {
		stuff_int(&Medals_callsign_coords[GR_640].x);
		stuff_int(&Medals_callsign_coords[GR_640].y);
	} else {
		Medals_callsign_coords[GR_640].x = Default_medals_callsign_coords[GR_640][0];
		Medals_callsign_coords[GR_640].y = Default_medals_callsign_coords[GR_640][1];
	}
	if (optional_string("+Callsign Position 1024:")) {
		stuff_int(&Medals_callsign_coords[GR_1024].x);
		stuff_int(&Medals_callsign_coords[GR_1024].y);
	} else {
		Medals_callsign_coords[GR_1024].x = Default_medals_callsign_coords[GR_1024][0];
		Medals_callsign_coords[GR_1024].y = Default_medals_callsign_coords[GR_1024][1];
	}

	// special positioning for medal label
	if (optional_string("+Label Position 640:")) {
		stuff_int(&Medals_label_coords[GR_640].x);
		stuff_int(&Medals_label_coords[GR_640].y);
		stuff_int(&Medals_label_coords[GR_640].w);
	} else {
		Medals_label_coords[GR_640].x = Default_medals_label_coords[GR_640][0];
		Medals_label_coords[GR_640].y = Default_medals_label_coords[GR_640][1];
		Medals_label_coords[GR_640].w = Default_medals_label_coords[GR_640][2];
	}
	if (optional_string("+Label Position 1024:")) {
		stuff_int(&Medals_label_coords[GR_1024].x);
		stuff_int(&Medals_label_coords[GR_1024].y);
		stuff_int(&Medals_label_coords[GR_1024].w);
	} else {
		Medals_label_coords[GR_1024].x = Default_medals_label_coords[GR_1024][0];
		Medals_label_coords[GR_1024].y = Default_medals_label_coords[GR_1024][1];
		Medals_label_coords[GR_1024].w = Default_medals_label_coords[GR_1024][2];
	}

	// parse in all the medal names
	Num_medals = 0;
	while ( required_string_either("#End", "$Name:") )
	{
		medal_stuff temp_medal;
		medal_display_info temp_display;

		required_string("$Name:");
		stuff_string( temp_medal.name, F_NAME, NAME_LENGTH );

		// is this rank?  if so, save it
		if (!stricmp(temp_medal.name, "Rank"))
			Rank_medal_index = Num_medals;

		required_string("$Bitmap:");
		stuff_string( temp_medal.bitmap, F_NAME, MAX_FILENAME_LEN );

		if (optional_string("+Position 640:")) {
			stuff_int(&temp_display.coords[GR_640].x);
			stuff_int(&temp_display.coords[GR_640].y);
		} else if (Num_medals < NUM_MEDALS_FS2) {
			temp_display.coords[GR_640].x = Default_medal_coords[GR_640][Num_medals][0];
			temp_display.coords[GR_640].y = Default_medal_coords[GR_640][Num_medals][1];
		} else {
			Warning(LOCATION, "No default GR_640 position for medal '%s'!", temp_medal.name);
			temp_display.coords[GR_640].x = 0;
			temp_display.coords[GR_640].y = 0;
		}
		if (optional_string("+Position 1024:")) {
			stuff_int(&temp_display.coords[GR_1024].x);
			stuff_int(&temp_display.coords[GR_1024].y);
		} else if (Num_medals < NUM_MEDALS_FS2) {
			temp_display.coords[GR_1024].x = Default_medal_coords[GR_1024][Num_medals][0];
			temp_display.coords[GR_1024].y = Default_medal_coords[GR_1024][Num_medals][1];
		} else {
			Warning(LOCATION, "No default GR_1024 position for medal '%s'!", temp_medal.name);
			temp_display.coords[GR_1024].x = 0;
			temp_display.coords[GR_1024].y = 0;
		}

		if (optional_string("+Debriefing Bitmap:")) {
			stuff_string( temp_medal.debrief_bitmap, F_NAME, MAX_FILENAME_LEN );
		} else if (Num_medals < NUM_MEDALS_FS2) {
			strcpy_s(temp_medal.debrief_bitmap, Default_debriefing_bitmaps[Num_medals]);
		} else {
			Warning(LOCATION, "No default debriefing bitmap for medal '%s'!", temp_medal.name);
			strcpy_s(temp_medal.debrief_bitmap, "");
		}

		required_string("$Num mods:");
		stuff_int( &temp_medal.num_versions );

		// this is dumb
		temp_medal.version_starts_at_1 = (Num_medals == Rank_medal_index);
		if (optional_string("+Version starts at 1:")) {
			stuff_boolean( &temp_medal.version_starts_at_1 );
		}

		// some medals are based on kill counts.  When string +Num Kills: is present, we know that
		// this medal is a badge and should be treated specially
		if ( optional_string("+Num Kills:") ) {
			char buf[MULTITEXT_LENGTH];
			int persona;
			stuff_int( &temp_medal.kills_needed );

			if (optional_string("$Wavefile 1:"))
				stuff_string(temp_medal.voice_base, F_NAME, MAX_FILENAME_LEN);

			if (optional_string("$Wavefile 2:"))
				stuff_string(temp_medal.voice_base, F_NAME, MAX_FILENAME_LEN);

			if (optional_string("$Wavefile Base:"))
				stuff_string(temp_medal.voice_base, F_NAME, MAX_FILENAME_LEN);

			while (check_for_string("$Promotion Text:")) {
				required_string("$Promotion Text:");
				stuff_string(buf, F_MULTITEXT, sizeof(buf));
				persona = -1;
				if (optional_string("+Persona:")) {
					stuff_int(&persona);
					if (persona < 0) {
						Warning(LOCATION, "Debriefing text for %s is assigned to an invalid persona: %i (must be 0 or greater).\n", temp_medal.name, persona);
						continue;
					}
				}
				temp_medal.promotion_text[persona] = vm_strdup(buf);
			}
			if (temp_medal.promotion_text.find(-1) == temp_medal.promotion_text.end()) {
				Warning(LOCATION, "%s medal is missing default debriefing text.\n", temp_medal.name);
				temp_medal.promotion_text[-1] = "";
			}
		}

		Medals.push_back(temp_medal);
		Medal_display_info.push_back(temp_display);
		Num_medals++;
	}

	required_string("#End");

	// be sure that we know where the rank is
	if (Rank_medal_index < 0)
	{
		Warning(LOCATION, "Could not find the 'Rank' medal!");
		Rank_medal_index = 0;
	}

	// be sure that the badges kill numbers show up in order
	//WMC - I don't think this is needed anymore due to my changes to post-mission functions
	//but I'm keeping it here to be sure.
	int prev_badge_kills = 0;
	for (i = 0; i < Num_medals; i++ )
	{
		if ( Medals[i].kills_needed < prev_badge_kills && Medals[i].kills_needed != 0)
			Error(LOCATION, "Badges must appear sorted by lowest kill # first in medals.tbl\nFind Allender for most information.");

		if (Medals[i].kills_needed > 0)
			prev_badge_kills = Medals[i].kills_needed;
	}

	// close localization
	lcl_ext_close();
}
// initialization stuff for cutscenes
void cutscene_init()
{
	atexit(cutscene_close);
	char buf[MULTITEXT_LENGTH];
	int rval;
    cutscene_info cutinfo;

	// open localization
	lcl_ext_open();

	if ((rval = setjmp(parse_abort)) != 0) {
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", "cutscenes.tbl", rval));
		lcl_ext_close();
		return;
	}

	read_file_text("cutscenes.tbl", CF_TYPE_TABLES);
	reset_parse();

	// parse in all the cutscenes
	Cutscenes.clear();
	skip_to_string("#Cutscenes");
	ignore_white_space();

	bool isFirstCutscene = true;

	while ( required_string_either("#End", "$Filename:") ) 
    {
        memset(&cutinfo, 0, sizeof(cutscene_info));

		required_string("$Filename:");
		stuff_string( cutinfo.filename, F_PATHNAME, MAX_FILENAME_LEN );

		required_string("$Name:");
		stuff_string( cutinfo.name, F_NAME, NAME_LENGTH );

		required_string("$Description:");
		stuff_string(buf, F_MULTITEXT, sizeof(buf));
		drop_white_space(buf);
		compact_multitext_string(buf);
		cutinfo.description = vm_strdup(buf);

		required_string("$cd:");
		stuff_int( &cutinfo.cd );

		if (isFirstCutscene) {
			isFirstCutscene = false;
			// The original code assumes the first movie is the intro, so always viewable
			cutinfo.viewable = true;
		}

		if (optional_string("$Always Viewable:")) {
			stuff_boolean(&cutinfo.viewable);
		}


        Cutscenes.push_back(cutinfo);
	}

	required_string("#End");

	// close localization
	lcl_ext_close();
}
// parses help.tbl and populates help_overlaylist[]
void parse_helptbl(const char *filename)
{
	int overlay_id, currcount, vtxcount;
	char name[HELP_MAX_NAME_LENGTH];
	char buf[HELP_MAX_STRING_LENGTH + 1];
	int i, j, rval;

	SCP_vector<help_pline> pline_temp;
	help_pline pline_temp2;
	SCP_vector<help_text> text_temp;
	help_text text_temp2;
	SCP_vector<help_right_bracket> rbracket_temp;
	help_right_bracket rbracket_temp2;
	SCP_vector<help_left_bracket> lbracket_temp;
	help_left_bracket lbracket_temp2;
	vec3d vec3d_temp;

	// open localization
	lcl_ext_open();
	
	if ((rval = setjmp(parse_abort)) != 0) {
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", filename, rval));
		lcl_ext_close();
		return;
	} 

	read_file_text(filename, CF_TYPE_TABLES);
	reset_parse();

	// for each overlay...
	while (optional_string("$")) {

		stuff_string(name, F_NAME, HELP_MAX_NAME_LENGTH);

		overlay_id = help_overlay_get_index(name);

		if (overlay_id < 0) {
			if (num_help_overlays >= MAX_HELP_OVERLAYS) {
				Warning(LOCATION, "Could not load help overlay after '%s' as maximum number of help overlays was reached (Max is %d)", help_overlaylist[overlay_id - 1].name, MAX_HELP_OVERLAYS);

				if (!skip_to_string("$end")) {
					Error(LOCATION, "Couldn't find $end. Help.tbl or -hlp.tbm is invalid.\n");
				}

				continue;
			} else {
				overlay_id = num_help_overlays;
				strcpy_s(help_overlaylist[overlay_id].name, name);
				num_help_overlays++;
			}
		}

		// clear out counters in the overlay struct
		help_overlaylist[overlay_id].plinecount = 0;
		help_overlaylist[overlay_id].textcount = 0;
		help_overlaylist[overlay_id].rbracketcount = 0;
		help_overlaylist[overlay_id].lbracketcount = 0;

		help_overlaylist[overlay_id].fontlist.clear();
		help_overlaylist[overlay_id].plinelist.clear();
		help_overlaylist[overlay_id].textlist.clear();
		help_overlaylist[overlay_id].rbracketlist.clear();
		help_overlaylist[overlay_id].lbracketlist.clear();

		if (optional_string("+resolutions")) {
			stuff_int(&help_overlaylist[overlay_id].num_resolutions);
		} else {
			help_overlaylist[overlay_id].num_resolutions = 2;
		}

		if (help_overlaylist[overlay_id].num_resolutions < 1) {
			Error(LOCATION, "+resolutions in %s is %d. (Must be 1 or greater)", filename, help_overlaylist[overlay_id].num_resolutions);
		}

		if (optional_string("+font")) {
			int font;
			for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
				stuff_int(&font);
				help_overlaylist[overlay_id].fontlist.push_back(font);
			}
		} else {
			for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
				help_overlaylist[overlay_id].fontlist.push_back(FONT1);
			}
		}

		for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
			help_overlaylist[overlay_id].plinelist.push_back(pline_temp);
			help_overlaylist[overlay_id].textlist.push_back(text_temp);
			help_overlaylist[overlay_id].rbracketlist.push_back(rbracket_temp);
			help_overlaylist[overlay_id].lbracketlist.push_back(lbracket_temp);
		}
		
		// read in all elements for this overlay
		while (!(optional_string("$end")))  {

			if (optional_string("+pline")) {

				currcount = help_overlaylist[overlay_id].plinecount;
				int a, b;		// temp vars to read in int before cast to float;

				// read number of pline vertices
				stuff_int(&vtxcount);
				// get vertex coordinates for each resolution
				for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
					help_overlaylist[overlay_id].plinelist.at(i).push_back(pline_temp2);
					for (j=0; j<vtxcount; j++) {
						help_overlaylist[overlay_id].plinelist.at(i).at(currcount).vtx.push_back(vec3d_temp);
						help_overlaylist[overlay_id].plinelist.at(i).at(currcount).vtxcount = vtxcount;
						stuff_int(&a);
						stuff_int(&b);
						help_overlaylist[overlay_id].plinelist.at(i).at(currcount).vtx.at(j).xyz.x = (float)a;
						help_overlaylist[overlay_id].plinelist.at(i).at(currcount).vtx.at(j).xyz.y = (float)b;
						help_overlaylist[overlay_id].plinelist.at(i).at(currcount).vtx.at(j).xyz.z = 0.0f;
					}
				}

				help_overlaylist[overlay_id].plinecount++;

			} else if (optional_string("+text")) {

				currcount = help_overlaylist[overlay_id].textcount;

				// get coordinates for each resolution
				for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
					help_overlaylist[overlay_id].textlist.at(i).push_back(text_temp2);
					stuff_int(&(help_overlaylist[overlay_id].textlist.at(i).at(currcount).x_coord));
					stuff_int(&(help_overlaylist[overlay_id].textlist.at(i).at(currcount).y_coord));
				}

				// get string (always use the first resolution)
				stuff_string(buf, F_MESSAGE, sizeof(buf));
				help_overlaylist[overlay_id].textlist.at(0).at(currcount).string = vm_strdup(buf);

				help_overlaylist[overlay_id].textcount++;

			} else if (optional_string("+right_bracket")) {

				currcount = help_overlaylist[overlay_id].rbracketcount;

				// get coordinates for each resolution
				for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
					help_overlaylist[overlay_id].rbracketlist.at(i).push_back(rbracket_temp2);
					stuff_int(&(help_overlaylist[overlay_id].rbracketlist.at(i).at(currcount).x_coord));
					stuff_int(&(help_overlaylist[overlay_id].rbracketlist.at(i).at(currcount).y_coord));
				}

				help_overlaylist[overlay_id].rbracketcount++;

			} else if (optional_string("+left_bracket")) {

				currcount = help_overlaylist[overlay_id].lbracketcount;

				// get coordinates for each resolution
				for (i=0; i<help_overlaylist[overlay_id].num_resolutions; i++) {
					help_overlaylist[overlay_id].lbracketlist.at(i).push_back(lbracket_temp2);
					stuff_int(&(help_overlaylist[overlay_id].lbracketlist.at(i).at(currcount).x_coord));
					stuff_int(&(help_overlaylist[overlay_id].lbracketlist.at(i).at(currcount).y_coord));
				}

				help_overlaylist[overlay_id].lbracketcount++;

			} else {
				// help.tbl is corrupt
				Assert(0);

			}		// end if

		}		// end while
	}		// end while

	// close localization
	lcl_ext_close();
}
Exemple #16
0
// parses help.tbl and populates help_overlaylist[]
void parse_helptbl()
{
	int overlay_id, currcount;
	char buf[HELP_MAX_STRING_LENGTH + 1];
	int i, rval;

	// open localization
	lcl_ext_open();

	if ((rval = setjmp(parse_abort)) != 0)
	{
		mprintf(("TABLES: Unable to parse '%s'!  Error code = %i.\n", HELP_OVERLAY_FILENAME, rval));
		lcl_ext_close();
		return;
	}

	read_file_text(HELP_OVERLAY_FILENAME, CF_TYPE_TABLES);

	// for each overlay...
	for (overlay_id = 0; overlay_id < MAX_HELP_OVERLAYS; overlay_id++)
	{

		reset_parse();
		skip_to_string(help_overlay_section_names[overlay_id]);

		// clear out counters in the overlay struct
		help_overlaylist[overlay_id].plinecount = 0;
		help_overlaylist[overlay_id].textcount = 0;
		help_overlaylist[overlay_id].rbracketcount = 0;
		help_overlaylist[overlay_id].lbracketcount = 0;

		// read in all elements for this overlay
		while (!(check_for_string("$end")))
		{

			if (optional_string("+pline"))
			{

				currcount = help_overlaylist[overlay_id].plinecount;
				int a, b;		// temp vars to read in int before cast to float;

				if (currcount < HELP_MAX_ITEM)
				{
					// read number of pline vertices
					stuff_int(&help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount);		// note that it is read into GR_640
					// help_overlaylist[overlay_id].plinelist[GR_1024][currcount].vtxcount = help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount;			// set equal to 1024 version vertex count to prevent bugs
					Assert(help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount <=
						HELP_MAX_PLINE_VERTICES);
					// get 640x480 vertex coordinates
					for (i = 0; i < help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount; i++)
					{
						stuff_int(&a);
						stuff_int(&b);
						help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[i].xyz.x = (float)a;
						help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[i].xyz.y = (float)b;
						help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[i].xyz.z = 0.0f;
						help_overlaylist[overlay_id].plinelist[GR_640][currcount].pvtx[i] = &help_overlaylist[
							overlay_id].plinelist[GR_640][currcount].vtx[i];
					}
					// get 1024x768 vertex coordinates
					for (i = 0; i < help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount; i++)
					{
						stuff_int(&a);
						stuff_int(&b);
						help_overlaylist[overlay_id].plinelist[GR_1024][currcount].vtx[i].xyz.x = (float)a;
						help_overlaylist[overlay_id].plinelist[GR_1024][currcount].vtx[i].xyz.y = (float)b;
						help_overlaylist[overlay_id].plinelist[GR_1024][currcount].vtx[i].xyz.z = 0.0f;
						help_overlaylist[overlay_id].plinelist[GR_1024][currcount].pvtx[i] = &help_overlaylist[
							overlay_id].plinelist[GR_1024][currcount].vtx[i];
					}
				}

				//mprintf(("Found pline - start location (%f,%f), end location (%f,%f)\n", help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[0].xyz.x, help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[0].xyz.y, help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[2].xyz.x, help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtx[2].xyz.y));
				help_overlaylist[overlay_id].plinecount++;

			}
			else if (optional_string("+text"))
			{

				currcount = help_overlaylist[overlay_id].textcount;

				if (currcount < HELP_MAX_ITEM)
				{
					// get 640x480 coordinates
					stuff_int(&(help_overlaylist[overlay_id].textlist[GR_640][currcount].x_coord));
					stuff_int(&(help_overlaylist[overlay_id].textlist[GR_640][currcount].y_coord));
					// get 1024x768 coordinates
					stuff_int(&(help_overlaylist[overlay_id].textlist[GR_1024][currcount].x_coord));
					stuff_int(&(help_overlaylist[overlay_id].textlist[GR_1024][currcount].y_coord));

					// get string (always use the GR_640 one)
					stuff_string(buf, F_MESSAGE, sizeof(buf));
					help_overlaylist[overlay_id].textlist[GR_640][currcount].string = vm_strdup(buf);

					//mprintf(("Found text %d on overlay %d - location (%d,%d) @ 640x480 :: location (%d,%d) @ 1024x768\n", currcount, overlay_id, help_overlaylist[overlay_id].textlist[GR_640][currcount].x_coord, help_overlaylist[overlay_id].textlist[GR_640][currcount].y_coord, help_overlaylist[overlay_id].textlist[GR_1024][currcount].x_coord, help_overlaylist[overlay_id].textlist[GR_1024][currcount].x_coord));
					help_overlaylist[overlay_id].textcount++;
				}

			}
			else if (optional_string("+right_bracket"))
			{

				currcount = help_overlaylist[overlay_id].rbracketcount;

				if (currcount < HELP_MAX_ITEM)
				{
					// get 640x480 coordinates
					stuff_int(&(help_overlaylist[overlay_id].rbracketlist[GR_640][currcount].x_coord));
					stuff_int(&(help_overlaylist[overlay_id].rbracketlist[GR_640][currcount].y_coord));
					// get 1024x768 coordinates
					stuff_int(&(help_overlaylist[overlay_id].rbracketlist[GR_1024][currcount].x_coord));
					stuff_int(&(help_overlaylist[overlay_id].rbracketlist[GR_1024][currcount].y_coord));

					//mprintf(("Found rbracket %d on overlay %d - location (%d,%d) @ 640x480 :: location (%d,%d) @ 1024x768\n", currcount, overlay_id, help_overlaylist[overlay_id].rbracketlist[GR_640][currcount].x_coord, help_overlaylist[overlay_id].rbracketlist[GR_640][currcount].y_coord, help_overlaylist[overlay_id].rbracketlist[GR_1024][currcount].x_coord, help_overlaylist[overlay_id].rbracketlist[GR_1024][currcount].y_coord));
					help_overlaylist[overlay_id].rbracketcount++;
				}

			}
			else if (optional_string("+left_bracket"))
			{

				currcount = help_overlaylist[overlay_id].lbracketcount;

				if (currcount < HELP_MAX_ITEM)
				{
					// get 640x480 coordinates
					stuff_int(&(help_overlaylist[overlay_id].lbracketlist[GR_640][currcount].x_coord));
					stuff_int(&(help_overlaylist[overlay_id].lbracketlist[GR_640][currcount].y_coord));
					// get 1024x768 coordinates
					stuff_int(&(help_overlaylist[overlay_id].lbracketlist[GR_1024][currcount].x_coord));
					stuff_int(&(help_overlaylist[overlay_id].lbracketlist[GR_1024][currcount].y_coord));

					//mprintf(("Found lbracket %d on overlay %d - location (%d,%d) @ 640x480 :: location (%d,%d) @ 1024x768\n", currcount, overlay_id, help_overlaylist[overlay_id].lbracketlist[GR_640][currcount].x_coord, help_overlaylist[overlay_id].lbracketlist[GR_640][currcount].y_coord, help_overlaylist[overlay_id].lbracketlist[GR_1024][currcount].x_coord, help_overlaylist[overlay_id].lbracketlist[GR_1024][currcount].y_coord));
					help_overlaylist[overlay_id].lbracketcount++;
				}

			}
			else
			{
				// help.tbl is corrupt
				Assert(0);

			}		// end if

		}		// end while
	}		// end for

	// 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();
}