void ShipSpecialHitpoints::OnOk() 
{
	float temp_initial_hull_strength;

	UpdateData(TRUE);

	// TODO: Add extra validation here
	if (m_special_hitpoints_enabled) {

		int start;

		if (Ships[m_ship_num].special_hitpoint_index == -1) {
			// get free sexp_variables
			start = sexp_variable_allocate_block(Ships[m_ship_num].ship_name, SEXP_VARIABLE_BLOCK | SEXP_VARIABLE_BLOCK_HIT);
			if (start == -1) {
				MessageBox("Unable to allocate storage, try deleting Sexp variables");
				return;
			} else {
				Ships[m_ship_num].special_hitpoint_index = start;
			}
		} else {
			start = Ships[m_ship_num].special_hitpoint_index;
		}
		// set to update
		set_modified();

		// set em
		sprintf(Sexp_variables[start+SHIELD_STRENGTH].text, "%d", m_shields);
		sprintf(Sexp_variables[start+HULL_STRENGTH].text, "%d", m_hull);

	} else {
		if (Ships[m_ship_num].special_hitpoint_index != -1) {
			// set to update
			set_modified();

			// free block
			sexp_variable_block_free(Ships[m_ship_num].ship_name, Ships[m_ship_num].special_hitpoint_index, SEXP_VARIABLE_BLOCK | SEXP_VARIABLE_BLOCK_HIT);

			// set index to no hit block
			Ships[m_ship_num].special_hitpoint_index = -1;
		}
	}

	// calc kamikaze stuff
	if (Ships[m_ship_num].special_hitpoint_index != -1)
	{
		temp_initial_hull_strength = (float) atoi(Sexp_variables[Ships[m_ship_num].special_hitpoint_index+HULL_STRENGTH].text);
	}
	else
	{
		temp_initial_hull_strength = Ship_info[Ships[m_ship_num].ship_info_index].initial_hull_strength;
	}

	Ai_info[Ships[m_ship_num].ai_index].kamikaze_damage = min(1000.0f, 200.0f + (temp_initial_hull_strength / 4.0f));


	CDialog::OnOK();
}
예제 #2
0
void ShipSpecialDamage::OnOK() 
{
	UpdateData(TRUE);

	// TODO: Add extra validation here
	if (m_special_exp_enabled) {

		int start;

		if (m_inner_rad > m_outer_rad) {
			MessageBox("Inner radius must be less than outer radius");
			return;
		}

		if (Ships[m_ship_num].special_exp_index == -1) {
			// get free sexp_variables
			start = sexp_variable_allocate_block(Ships[m_ship_num].ship_name, SEXP_VARIABLE_BLOCK | SEXP_VARIABLE_BLOCK_EXP);
			if (start == -1) {
				MessageBox("Unable to allocate storage, try deleting Sexp variables");
				return;
			} else {
				Ships[m_ship_num].special_exp_index = start;
			}
		} else {
			start = Ships[m_ship_num].special_exp_index;
		}
		// set to update
		set_modified();

		// set em
		sprintf(Sexp_variables[start+INNER_RAD].text, "%d", m_inner_rad);
		sprintf(Sexp_variables[start+OUTER_RAD].text, "%d", m_outer_rad);
		sprintf(Sexp_variables[start+DAMAGE].text, "%d", m_damage);
		sprintf(Sexp_variables[start+BLAST].text, "%d", m_blast);
		sprintf(Sexp_variables[start+PROPAGATE].text, "%d", m_shock_enabled);
		sprintf(Sexp_variables[start+SHOCK_SPEED].text, "%d", m_shock_speed);

	} else {
		if (Ships[m_ship_num].special_exp_index != -1) {
			// set to update
			set_modified();

			// free block
			sexp_variable_block_free(Ships[m_ship_num].ship_name, Ships[m_ship_num].special_exp_index, SEXP_VARIABLE_BLOCK |SEXP_VARIABLE_BLOCK_EXP);

			// set index to no exp block
			Ships[m_ship_num].special_exp_index = -1;
		}
	}

	CDialog::OnOK();
}
예제 #3
0
파일: cut.c 프로젝트: kaniini/quinn
/* Copy text from the cutbuffer into the current filestruct. */
void do_uncut_text(void)
{
    assert(openfile->current != NULL && openfile->current->data != NULL);

    /* If the cutbuffer is empty, get out. */
    if (cutbuffer == NULL)
	return;

    add_undo(PASTE);

    /* Add a copy of the text in the cutbuffer to the current filestruct
     * at the current cursor position. */
    copy_from_filestruct(cutbuffer);

    update_undo(PASTE);

    /* Set the current place we want to where the text from the
     * cutbuffer ends. */
    openfile->placewewant = xplustabs();

    /* Mark the file as modified. */
    set_modified();

    /* Update the screen. */
    edit_refresh_needed = TRUE;

#ifndef DISABLE_COLOR
    reset_multis(openfile->current, FALSE);
#endif

#ifdef DEBUG
    dump_filestruct_reverse();
#endif
}
예제 #4
0
// delete a whole wing, leaving ships intact but wingless.
void remove_wing(int wing_num)
{
	int i, total;
	object *ptr;

	if (check_wing_dependencies(wing_num))
		return;

	Ship_editor_dialog.bypass_errors = Wing_editor_dialog.bypass_errors = 1;
	Ship_editor_dialog.update_data(0);
	total = Wings[wing_num].wave_count;
	for (i=0; i<total; i++) {
		ptr = &Objects[wing_objects[wing_num][i]];
		if (ptr->type == OBJ_SHIP)
			remove_ship_from_wing(ptr->instance);
		else if (ptr->type == OBJ_START)
			remove_player_from_wing(ptr->instance);
	}

	Assert(!Wings[wing_num].wave_count);
	Ship_editor_dialog.initialize_data(1);
	Ship_editor_dialog.bypass_errors = Wing_editor_dialog.bypass_errors = 0;

	if (cur_wing == wing_num) {
		set_cur_wing(cur_wing = -1);  // yes, one '=' is correct.
	}

	set_modified();
}
예제 #5
0
// Goober5000
void CFREDDoc::OnFileImportFSM() 
{
	CString fs1_mission_mfc;
	char fs1_mission[MAX_PATH_LEN];
	char *ch;
	char temp[MAX_PATH_LEN];

	// if mission has been modified, offer to save before continuing.
	if (!SaveModified())
		return;

	// set up import dialog
	CFileDialog dlg(TRUE, "fsm", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "FreeSpace Missions (*.fsm)|*.fsm|All files (*.*)|*.*||");
	dlg.m_ofn.lpstrTitle = "Select a mission to import";

	// set initial path
	strcpy(temp, Fred_exe_dir);
	if ((ch = stristr(temp, "FreeSpace2")) >= 0)
	{
		strcpy(ch, "FreeSpace\\Data\\Missions");
		dlg.m_ofn.lpstrInitialDir = temp;
	}

	// get FSM file
	if (dlg.DoModal() != IDOK)
		return;

	fs1_mission_mfc = dlg.GetPathName();

	if (strlen(fs1_mission_mfc) > MAX_PATH_LEN - 1)
	{
		MessageBox(NULL, "Path name is too long", "Error", MB_OK);
		return;
	}

	if (!strlen(fs1_mission_mfc))
	{
		return;
	}

	strcpy(fs1_mission, fs1_mission_mfc);

	// load mission into memory
	if (Briefing_dialog)
		Briefing_dialog->icon_select(-1);  // clean things up first
	if (load_mission(fs1_mission, 1))
		return;

	// ugh - change the file name
	FREDDoc_ptr->SetPathName("Untitled");

	// we haven't saved it yet
	set_modified(TRUE);

	// error check and notify
	if (!Fred_view_wnd->global_error_check())
	{
		Fred_view_wnd->MessageBox("Mission successfully imported with no errors.", "Woohoo!");
	}
}
예제 #6
0
void orient_editor::OnOK()
{
	vec3d delta, pos;
	object *ptr;

	UpdateData(TRUE);
	pos.xyz.x = convert(m_position_x);
	pos.xyz.y = convert(m_position_y);
	pos.xyz.z = convert(m_position_z);

	if ((((CButton *) GetDlgItem(IDC_POINT_TO_OBJECT))->GetCheck() == 1) ||
		(((CButton *) GetDlgItem(IDC_POINT_TO_LOCATION))->GetCheck() == 1))
			set_modified();

	vm_vec_sub(&delta, &pos, &Objects[cur_object_index].pos);
	if (delta.xyz.x || delta.xyz.y || delta.xyz.z)
		set_modified();

	ptr = GET_FIRST(&obj_used_list);
	while (ptr != END_OF_LIST(&obj_used_list)) {
		if (ptr->flags & OF_MARKED) {
			vm_vec_add2(&ptr->pos, &delta);
			update_object(ptr);
		}

		ptr = GET_NEXT(ptr);
	}

	ptr = GET_FIRST(&obj_used_list);
	while (ptr != END_OF_LIST(&obj_used_list)) {
		if (ptr->flags & OF_MARKED)
			object_moved(ptr);

		ptr = GET_NEXT(ptr);
	}

	theApp.record_window_data(&Object_wnd_data, this);
	CDialog::OnOK();
}
void CMissionGoalsDlg::OnOk()
{
	char buf[256], names[2][MAX_GOALS][NAME_LENGTH];
	int i, count;

	for (i=0; i<Num_goals; i++)
		free_sexp2(Mission_goals[i].formula);

	UpdateData(TRUE);
	if (query_modified())
		set_modified();

	count = 0;
	for (i=0; i<Num_goals; i++)
		Mission_goals[i].satisfied = 0;  // use this as a processed flag
	
	// rename all sexp references to old events
	for (i=0; i<m_num_goals; i++)
		if (m_sig[i] >= 0) {
			strcpy(names[0][count], Mission_goals[m_sig[i]].name);
			strcpy(names[1][count], m_goals[i].name);
			count++;
			Mission_goals[m_sig[i]].satisfied = 1;
		}

	// invalidate all sexp references to deleted events.
	for (i=0; i<Num_goals; i++)
		if (!Mission_goals[i].satisfied) {
			sprintf(buf, "<%s>", Mission_goals[i].name);
			strcpy(buf + NAME_LENGTH - 2, ">");  // force it to be not too long
			strcpy(names[0][count], Mission_goals[i].name);
			strcpy(names[1][count], buf);
			count++;
		}

	Num_goals = m_num_goals;
	for (i=0; i<Num_goals; i++) {
		Mission_goals[i] = m_goals[i];
		Mission_goals[i].formula = m_goals_tree.save_tree(Mission_goals[i].formula);
		if ( The_mission.game_type & MISSION_TYPE_MULTI_TEAMS ) {
			Assert( Mission_goals[i].team != -1 );
		}
	}

	// now update all sexp references
	while (count--)
		update_sexp_references(names[0][count], names[1][count], OPF_GOAL_NAME);

	theApp.record_window_data(&Mission_goals_wnd_data, this);
	CDialog::OnOK();
}
BOOL debriefing_editor_dlg::OnInitDialog()
{
	int i, n;

	CDialog::OnInitDialog();
	m_play_bm.LoadBitmap(IDB_PLAY);
	((CButton *) GetDlgItem(IDC_PLAY)) -> SetBitmap(m_play_bm);

	m_current_debriefing = 0;
	UpdateData(FALSE);

	Debriefing = &Debriefings[m_current_debriefing];

	m_tree.link_modified(&modified);  // provide way to indicate trees are modified in dialog
	n = m_tree.select_sexp_node = select_sexp_node;
	select_sexp_node = -1;
	if (n != -1) {
		for (i=0; i<Debriefing->num_stages; i++)
			if (query_node_in_sexp(n, Debriefing->stages[i].formula))
				break;

		if (i < Debriefing->num_stages) {
			m_cur_stage = i;
			update_data();
			GetDlgItem(IDC_TREE) -> SetFocus();
			m_tree.hilite_item(m_tree.select_sexp_node);
			set_modified();
			return FALSE;
		}
	}

	update_data();
	set_modified();

	// hard coded stuff to deal with the multiple briefings per mission.

	return TRUE;
}
예제 #9
0
// Takes a ship out of a wing, deleting wing if that was the only ship in it.
void remove_ship_from_wing(int ship, int min)
{
	char buf[256];
	int i, wing, end, obj;

	wing = Ships[ship].wingnum;
	if (wing != -1) {
		if (Wings[wing].wave_count == min)
		{
			Wings[wing].wave_count = 0;
			Wings[wing].wing_squad_filename[0] = '\0';
			Wings[wing].wing_insignia_texture = -1;
			delete_wing(wing);
		}
		else
		{
			i = Wings[wing].wave_count;
			end = i - 1;
			while (i--)
				if (wing_objects[wing][i] == Ships[ship].objnum)
					break;

			Assert(i != -1);  // Error, object should be in wing.
			if (Wings[wing].special_ship == i)
				Wings[wing].special_ship = 0;

			// if not last element, move last element to position to fill gap
			if (i != end) {
				obj = wing_objects[wing][i] = wing_objects[wing][end];
				Wings[wing].ship_index[i] = Wings[wing].ship_index[end];
				if (Objects[obj].type == OBJ_SHIP) {
					wing_bash_ship_name(buf, Wings[wing].name, i + 1);
					rename_ship(Wings[wing].ship_index[i], buf);
				}
			}

			Wings[wing].wave_count--;
			if (Wings[wing].wave_count && (Wings[wing].threshold >= Wings[wing].wave_count))
				Wings[wing].threshold = Wings[wing].wave_count - 1;
		}

		Ships[ship].wingnum = -1;
	}

	set_modified();
	// reset ship name to non-wing default ship name
	sprintf(buf, "%s %d", Ship_info[Ships[ship].ship_info_index].name, ship);
	rename_ship(ship, buf);
}
예제 #10
0
// delete a whole wing, also deleting its ships if necessary.
int delete_wing(int wing_num, int bypass)
{
	int i, r, total;

	if (already_deleting_wing)
		return 0;

	r = check_wing_dependencies(wing_num);
	if (r)
		return r;

	already_deleting_wing = 1;
	for (i=0; i<Num_reinforcements; i++)
		if (!stricmp(Wings[wing_num].name, Reinforcements[i].name)) {
			delete_reinforcement(i);
			break;
		}

	invalidate_references(Wings[wing_num].name, REF_TYPE_WING);
	if (!bypass) {
		total = Wings[wing_num].wave_count;
		for (i=0; i<total; i++)
			delete_object(wing_objects[wing_num][i]);
	}

	Wings[wing_num].wave_count = 0;
	Wings[wing_num].wing_squad_filename[0] = '\0';
	Wings[wing_num].wing_insignia_texture = -1;

	if (cur_wing == wing_num)
		set_cur_wing(cur_wing = -1);  // yes, one '=' is correct.

	free_sexp2(Wings[wing_num].arrival_cue);
	free_sexp2(Wings[wing_num].departure_cue);

	Num_wings--;
	set_modified();

	update_custom_wing_indexes();

	already_deleting_wing = 0;
	return 0;
}
예제 #11
0
// delete a whole wing, leaving ships intact but wingless.
void remove_wing(int wing_num)
{
	int i, total;
	object *ptr;

	if (check_wing_dependencies(wing_num))
		return;

	Ship_editor_dialog.bypass_errors = Wing_editor_dialog.bypass_errors = 1;
	Ship_editor_dialog.update_data(0);
	total = Wings[wing_num].wave_count;
	for (i=0; i<total; i++) {
		ptr = &Objects[wing_objects[wing_num][i]];
		if (ptr->type == OBJ_SHIP)
			remove_ship_from_wing(ptr->instance, 0);
		else if (ptr->type == OBJ_START)
			remove_player_from_wing(ptr->instance, 0);
	}

	Assert(!Wings[wing_num].wave_count);

	Wings[wing_num].wave_count = 0;
	Wings[wing_num].wing_squad_filename[0] = '\0';
	Wings[wing_num].wing_insignia_texture = -1;

	Ship_editor_dialog.initialize_data(1);
	Ship_editor_dialog.bypass_errors = Wing_editor_dialog.bypass_errors = 0;

	if (cur_wing == wing_num) {
		set_cur_wing(cur_wing = -1);  // yes, one '=' is correct.
	}

	free_sexp2(Wings[wing_num].arrival_cue);
	free_sexp2(Wings[wing_num].departure_cue);

	Num_wings--;

	update_custom_wing_indexes();

	set_modified();
}
void ShipSpecialDamage::update_ship(int shipnum)
{
	ship *shipp = &Ships[shipnum];
	
	// set to update
	set_modified();

	if (m_special_exp_enabled) {
		// set em
		shipp->use_special_explosion = true;
		shipp->special_exp_inner = m_inner_rad;
		shipp->special_exp_outer = m_outer_rad;
		shipp->special_exp_damage = m_damage;
		shipp->special_exp_blast = m_blast;
		shipp->use_shockwave = (m_shock_enabled ? 1:0) ;
		if (m_shock_speed) {
			if (m_shock_speed < 1) {
				m_shock_speed = 1;
				MessageBox("Shockwave speed must be defined! Setting this to 1 now");
			}
			shipp->special_exp_shockwave_speed = m_shock_speed;
		}
		if (m_duration) {
			if (m_duration < 2) {
				m_duration = 2;
				MessageBox("Death roll time must be at least 2 milliseconds!");
			}
			shipp->special_exp_deathroll_time = m_duration;
		}
	} else {
		shipp->use_special_explosion = false;
		shipp->special_exp_inner = -1;
		shipp->special_exp_outer = -1;
		shipp->special_exp_damage = -1;
		shipp->special_exp_blast = -1;
		shipp->use_shockwave = false;
		shipp->special_exp_shockwave_speed = -1;
		shipp->special_exp_deathroll_time = 0;
	}
}
예제 #13
0
void ship_flags_dlg::update_ship(int shipnum)
{
	ship *shipp = &Ships[shipnum];
	object *objp = &Objects[shipp->objnum];

	if (m_reinforcement.GetCheck() != 2)
	{
		//Check if we're trying to add more and we've got too many.
		if( (Num_reinforcements >= MAX_REINFORCEMENTS) && (m_reinforcement.GetCheck() == 1))
		{
			char error_message[256];
			sprintf(error_message, "Too many reinforcements; could not add ship '%s' to reinforcement list!", shipp->ship_name); 
			MessageBox(error_message);
		}
		//Otherwise, just update as normal.
		else
		{
			set_reinforcement(shipp->ship_name, m_reinforcement.GetCheck());	
		}
	}

	switch (m_cargo_known.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_CARGO_REVEALED) )
				set_modified();

			shipp->flags |= SF_CARGO_REVEALED;
			break;

		case 0:
			if ( shipp->flags & SF_CARGO_REVEALED )
				set_modified();

			shipp->flags &= ~SF_CARGO_REVEALED;
			break;
	}

	// update the flags for IGNORE_COUNT and PROTECT_SHIP
	switch (m_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_PROTECTED) )
				set_modified();

			objp->flags |= OF_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_PROTECTED )
				set_modified();

			objp->flags &= ~OF_PROTECTED;
			break;
	}

	switch (m_beam_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_BEAM_PROTECTED) )
				set_modified();

			objp->flags |= OF_BEAM_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_BEAM_PROTECTED )
				set_modified();

			objp->flags &= ~OF_BEAM_PROTECTED;
			break;
	}

	switch (m_flak_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_FLAK_PROTECTED) )
				set_modified();

			objp->flags |= OF_FLAK_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_FLAK_PROTECTED )
				set_modified();

			objp->flags &= ~OF_FLAK_PROTECTED;
			break;
	}

	switch (m_laser_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_LASER_PROTECTED) )
				set_modified();

			objp->flags |= OF_LASER_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_LASER_PROTECTED )
				set_modified();

			objp->flags &= ~OF_LASER_PROTECTED;
			break;
	}

	switch (m_missile_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_MISSILE_PROTECTED) )
				set_modified();

			objp->flags |= OF_MISSILE_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_MISSILE_PROTECTED )
				set_modified();

			objp->flags &= ~OF_MISSILE_PROTECTED;
			break;
	}

	switch (m_invulnerable.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_INVULNERABLE) )
				set_modified();

			objp->flags |= OF_INVULNERABLE;
			break;

		case 0:
			if ( objp->flags & OF_INVULNERABLE )
				set_modified();

			objp->flags &= ~OF_INVULNERABLE;
			break;
	}

	switch (m_targetable_as_bomb.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_TARGETABLE_AS_BOMB) )
				set_modified();

			objp->flags |= OF_TARGETABLE_AS_BOMB;
			break;

		case 0:
			if ( objp->flags & OF_TARGETABLE_AS_BOMB )
				set_modified();

			objp->flags &= ~OF_TARGETABLE_AS_BOMB;
			break;
	}

	switch (m_immobile.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_IMMOBILE) )
				set_modified();

			objp->flags |= OF_IMMOBILE;
			break;

		case 0:
			if ( objp->flags & OF_IMMOBILE )
				set_modified();

			objp->flags &= ~OF_IMMOBILE;
			break;
	}

	switch (m_hidden.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_HIDDEN_FROM_SENSORS) )
				set_modified();

			shipp->flags |= SF_HIDDEN_FROM_SENSORS;
			break;

		case 0:
			if ( shipp->flags & SF_HIDDEN_FROM_SENSORS )
				set_modified();

			shipp->flags &= ~SF_HIDDEN_FROM_SENSORS;
			break;
	}

	switch (m_primitive_sensors.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_PRIMITIVE_SENSORS) )
				set_modified();

			shipp->flags2 |= SF2_PRIMITIVE_SENSORS;
			break;

		case 0:
			if ( shipp->flags2 & SF2_PRIMITIVE_SENSORS )
				set_modified();

			shipp->flags2 &= ~SF2_PRIMITIVE_SENSORS;
			break;
	}

	switch (m_no_subspace_drive.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_SUBSPACE_DRIVE) )
				set_modified();

			shipp->flags2 |= SF2_NO_SUBSPACE_DRIVE;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_SUBSPACE_DRIVE )
				set_modified();

			shipp->flags2 &= ~SF2_NO_SUBSPACE_DRIVE;
			break;
	}

	switch (m_affected_by_gravity.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_AFFECTED_BY_GRAVITY) )
				set_modified();

			shipp->flags2 |= SF2_AFFECTED_BY_GRAVITY;
			break;

		case 0:
			if ( shipp->flags2 & SF2_AFFECTED_BY_GRAVITY )
				set_modified();

			shipp->flags2 &= ~SF2_AFFECTED_BY_GRAVITY;
			break;
	}

	switch (m_toggle_subsystem_scanning.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_TOGGLE_SUBSYSTEM_SCANNING) )
				set_modified();

			shipp->flags2 |= SF2_TOGGLE_SUBSYSTEM_SCANNING;
			break;

		case 0:
			if ( shipp->flags2 & SF2_TOGGLE_SUBSYSTEM_SCANNING )
				set_modified();

			shipp->flags2 &= ~SF2_TOGGLE_SUBSYSTEM_SCANNING;
			break;
	}

	switch (m_ignore_count.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_IGNORE_COUNT) )
				set_modified();

			shipp->flags |= SF_IGNORE_COUNT;
			break;

		case 0:
			if (shipp->flags & SF_IGNORE_COUNT)
				set_modified();

			shipp->flags &= ~SF_IGNORE_COUNT;
			break;
	}

	switch (m_escort.GetCheck()) {
		case 1:
			if (!(shipp->flags & SF_ESCORT))
				set_modified();

			shipp->flags |= SF_ESCORT;
			m_escort_value.save(&shipp->escort_priority);
			break;

		case 0:
			if (shipp->flags & SF_ESCORT)
				set_modified();

			shipp->flags &= ~SF_ESCORT;
			break;
	}

	// deal with updating the "destroy before the mission" stuff
	switch (m_destroy.GetCheck()) {
		case 0:  // this means no check in checkbox
			if ( shipp->flags & SF_KILL_BEFORE_MISSION )
				set_modified();

			shipp->flags &= ~SF_KILL_BEFORE_MISSION;
			break;

		case 1:  // this means checkbox is checked
			if ( !(shipp->flags & SF_KILL_BEFORE_MISSION) )
				set_modified();

			shipp->flags |= SF_KILL_BEFORE_MISSION;
			m_destroy_value.save(&shipp->final_death_time);
			break;
	}  // a mixed state is 2, and since it's not handled, it doesn't change

	switch (m_no_arrival_music.GetCheck()) {
		case 0:
			if (shipp->flags & SF_NO_ARRIVAL_MUSIC)
				set_modified();

			shipp->flags &= ~SF_NO_ARRIVAL_MUSIC;
			break;

		case 1:
			if (!(shipp->flags & SF_NO_ARRIVAL_MUSIC))
				set_modified();

			shipp->flags |= SF_NO_ARRIVAL_MUSIC;
			break;
	}

	switch (m_scannable.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_SCANNABLE) )
				set_modified();

			shipp->flags |= SF_SCANNABLE;
			break;

		case 0:
			if ( shipp->flags & SF_SCANNABLE )
				set_modified();

			shipp->flags &= ~SF_SCANNABLE;
			break;
	}

	switch (m_red_alert_carry.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_RED_ALERT_STORE_STATUS) )
				set_modified();

			shipp->flags |= SF_RED_ALERT_STORE_STATUS;
			break;

		case 0:
			if ( shipp->flags & SF_RED_ALERT_STORE_STATUS )
				set_modified();

			shipp->flags &= ~SF_RED_ALERT_STORE_STATUS;
			break;
	}

	switch (m_special_warpin.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_SPECIAL_WARPIN) )
				set_modified();

			objp->flags |= OF_SPECIAL_WARPIN;
			break;

		case 0:
			if ( (objp->flags & OF_SPECIAL_WARPIN) )
				set_modified();

			objp->flags &= (~OF_SPECIAL_WARPIN);
			break;
	}

	switch (m_no_dynamic.GetCheck()) {
		case 1:
			if ( !(Ai_info[shipp->ai_index].ai_flags & AIF_NO_DYNAMIC) )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags |= AIF_NO_DYNAMIC;
			break;

		case 0:
			if ( Ai_info[shipp->ai_index].ai_flags & AIF_NO_DYNAMIC )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags &= ~AIF_NO_DYNAMIC;
			break;
	}

	switch (m_kamikaze.GetCheck()) {
		case 1: {
			int damage;

			if ( !(Ai_info[shipp->ai_index].ai_flags & AIF_KAMIKAZE) )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags |= AIF_KAMIKAZE;
			m_kdamage.save(&damage);
			Ai_info[shipp->ai_index].kamikaze_damage = damage;
			break;
		}

		case 0:
			if ( Ai_info[shipp->ai_index].ai_flags & AIF_KAMIKAZE )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags &= ~AIF_KAMIKAZE;
			Ai_info[shipp->ai_index].kamikaze_damage = 0;
			break;
	}

	switch (m_disable_messages.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_BUILTIN_MESSAGES) )
				set_modified();

			shipp->flags2 |= SF2_NO_BUILTIN_MESSAGES;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_BUILTIN_MESSAGES )
				set_modified();

			shipp->flags2 &= ~SF2_NO_BUILTIN_MESSAGES;
			break;
	}

	switch (m_set_class_dynamically.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_SET_CLASS_DYNAMICALLY) )
				set_modified();

			shipp->flags2 |= SF2_SET_CLASS_DYNAMICALLY;
			break;

		case 0:
			if ( shipp->flags2 & SF2_SET_CLASS_DYNAMICALLY )
				set_modified();

			shipp->flags2 &= ~SF2_SET_CLASS_DYNAMICALLY;
			break;
	}

	switch (m_no_death_scream.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_DEATH_SCREAM) )
				set_modified();

			shipp->flags2 |= SF2_NO_DEATH_SCREAM;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_DEATH_SCREAM )
				set_modified();

			shipp->flags2 &= ~SF2_NO_DEATH_SCREAM;
			break;
	}

	switch (m_always_death_scream.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_ALWAYS_DEATH_SCREAM) )
				set_modified();

			shipp->flags2 |= SF2_ALWAYS_DEATH_SCREAM;
			break;

		case 0:
			if ( shipp->flags2 & SF2_ALWAYS_DEATH_SCREAM )
				set_modified();

			shipp->flags2 &= ~SF2_ALWAYS_DEATH_SCREAM;
			break;
	}

	switch (m_nav_carry.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NAVPOINT_CARRY) )
				set_modified();

			shipp->flags2 |= SF2_NAVPOINT_CARRY;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NAVPOINT_CARRY )
				set_modified();

			shipp->flags2 &= ~SF2_NAVPOINT_CARRY;
			break;
	}

	switch (m_nav_needslink.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NAVPOINT_NEEDSLINK) )
				set_modified();

			shipp->flags2 |= SF2_NAVPOINT_NEEDSLINK;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NAVPOINT_NEEDSLINK )
				set_modified();

			shipp->flags2 &= ~SF2_NAVPOINT_NEEDSLINK;
			break;
	}

	switch (m_hide_ship_name.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_HIDE_SHIP_NAME) )
				set_modified();

			shipp->flags2 |= SF2_HIDE_SHIP_NAME;
			break;

		case 0:
			if ( shipp->flags2 & SF2_HIDE_SHIP_NAME )
				set_modified();

			shipp->flags2 &= ~SF2_HIDE_SHIP_NAME;
			break;
	}

	switch (m_disable_ets.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_ETS) )
				set_modified();

			shipp->flags2 |= SF2_NO_ETS;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_ETS )
				set_modified();

			shipp->flags2 &= ~SF2_NO_ETS;
			break;
	}

	switch (m_cloaked.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_CLOAKED) )
				set_modified();

			shipp->flags2 |= SF2_CLOAKED;
			break;

		case 0:
			if ( shipp->flags2 & SF2_CLOAKED )
				set_modified();

			shipp->flags2 &= ~SF2_CLOAKED;
			break;
	}

	switch (m_guardian.GetCheck()) {
		case 1:
			if ( !(shipp->ship_guardian_threshold) )
				set_modified();

			shipp->ship_guardian_threshold = SHIP_GUARDIAN_THRESHOLD_DEFAULT;
			break;

		case 0:
			if ( shipp->ship_guardian_threshold )
				set_modified();

			shipp->ship_guardian_threshold = 0;
			break;
	}

	switch (m_vaporize.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_VAPORIZE) )
				set_modified();

			shipp->flags |= SF_VAPORIZE;
			break;

		case 0:
			if ( shipp->flags & SF_VAPORIZE )
				set_modified();

			shipp->flags &= ~SF_VAPORIZE;
			break;
	}

	switch (m_stealth.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_STEALTH) )
				set_modified();

			shipp->flags2 |= SF2_STEALTH;
			break;

		case 0:
			if ( shipp->flags2 & SF2_STEALTH )
				set_modified();

			shipp->flags2 &= ~SF2_STEALTH;
			break;
	}

	switch (m_friendly_stealth_invisible.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_FRIENDLY_STEALTH_INVIS) )
				set_modified();

			shipp->flags2 |= SF2_FRIENDLY_STEALTH_INVIS;
			break;

		case 0:
			if ( shipp->flags2 & SF2_FRIENDLY_STEALTH_INVIS )
				set_modified();

			shipp->flags2 &= ~SF2_FRIENDLY_STEALTH_INVIS;
			break;
	}

	switch (m_scramble_messages.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_SCRAMBLE_MESSAGES) )
				set_modified();

			shipp->flags2 |= SF2_SCRAMBLE_MESSAGES;
			break;

		case 0:
			if ( shipp->flags2 & SF2_SCRAMBLE_MESSAGES )
				set_modified();

			shipp->flags2 &= ~SF2_SCRAMBLE_MESSAGES;
			break;
	}

	switch (m_no_collide.GetCheck()) {
		case 1:
			if (objp->flags & OF_COLLIDES)
				set_modified();

			objp->flags &= ~OF_COLLIDES;
			break;

		case 0:
			if (!(objp->flags & OF_COLLIDES))
				set_modified();

			objp->flags |= OF_COLLIDES;
			break;
	}

	switch (m_no_disabled_self_destruct.GetCheck()) {
		case 1:
			if (!(shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT))
				set_modified();

			shipp->flags2 |= SF2_NO_DISABLED_SELF_DESTRUCT;
			break;

		case 0:
			if (shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT)
				set_modified();

			shipp->flags2 &= ~SF2_NO_DISABLED_SELF_DESTRUCT;
			break;
	}


	shipp->respawn_priority = 0;
	if(The_mission.game_type & MISSION_TYPE_MULTI) {
		m_respawn_priority.save(&shipp->respawn_priority);
	}
}
예제 #14
0
파일: cut.c 프로젝트: ris21/yoda
/* Move text from the current linestruct into the cutbuffer.  If
 * copy_text is TRUE, copy the text back into the linestruct afterward.
 * If cut_till_eof is TRUE, move all text from the current cursor
 * position to the end of the file into the cutbuffer. */
void do_cut_text(
#ifndef NANO_TINY
	bool copy_text, bool cut_till_eof, bool undoing
#else
	void
#endif
	)
{
#ifndef NANO_TINY
    linestruct *cb_save = NULL;
	/* The current end of the cutbuffer, before we add text to
	 * it. */
    size_t cb_save_len = 0;
	/* The length of the string at the current end of the cutbuffer,
	 * before we add text to it. */
    bool old_no_newlines = ISSET(NO_NEWLINES);
#endif

    assert(openfile->current != NULL && openfile->current->data != NULL);

    /* If keep_cutbuffer is FALSE and the cutbuffer isn't empty, blow
     * away the text in the cutbuffer. */
    if (!keep_cutbuffer && cutbuffer != NULL) {
	free_filestruct(cutbuffer);
	cutbuffer = NULL;
#ifdef DEBUG
	fprintf(stderr, "Blew away cutbuffer =)\n");
#endif
    }

#ifndef NANO_TINY
    if (copy_text) {
	if (cutbuffer != NULL) {
	    /* If the cutbuffer isn't empty, save where it currently
	     * ends.  This is where we'll add the new text. */
	    cb_save = cutbottom;
	    cb_save_len = strlen(cutbottom->data);
	}

	/* Set NO_NEWLINES to TRUE, so that we don't disturb the last
	 * line of the file when moving text to the cutbuffer. */
	SET(NO_NEWLINES);
    }
#endif

    /* Set keep_cutbuffer to TRUE, so that the text we're going to move
     * into the cutbuffer will be added to the text already in the
     * cutbuffer instead of replacing it. */
    keep_cutbuffer = TRUE;

#ifndef NANO_TINY
    if (cut_till_eof) {
	/* If cut_till_eof is TRUE, move all text up to the end of the
	 * file into the cutbuffer. */
	cut_to_eof();
    } else if (openfile->mark_set) {
	/* If the mark is on, move the marked text to the cutbuffer, and
	 * turn the mark off. */
	cut_marked();
	openfile->mark_set = FALSE;
    } else if (ISSET(CUT_TO_END))
	/* If the CUT_TO_END flag is set, move all text up to the end of
	 * the line into the cutbuffer. */
	cut_to_eol();
    else
#endif
	/* Move the entire line into the cutbuffer. */
	cut_line();

#ifndef NANO_TINY
    if (copy_text) {
	/* Copy the text in the cutbuffer, starting at its saved end if
	 * there is one, back into the linestruct.  This effectively
	 * uncuts the text we just cut without marking the file as
	 * modified. */
	if (cutbuffer != NULL) {
	    if (cb_save != NULL) {
		cb_save->data += cb_save_len;
		copy_from_filestruct(cb_save);
		cb_save->data -= cb_save_len;
	    } else
		copy_from_filestruct(cutbuffer);

	    /* Set the current place we want to where the text from the
	     * cutbuffer ends. */
	    openfile->placewewant = xplustabs();
	}

	/* Set NO_NEWLINES back to what it was before, since we're done
	 * disturbing the text. */
	if (!old_no_newlines)
	    UNSET(NO_NEWLINES);
    } else if (!undoing)
	update_undo(cut_till_eof ? CUT_EOF : CUT);

    /* Leave the text in the cutbuffer, and mark the file as
     * modified. */
    if (!copy_text)
#endif /* !NANO_TINY */
	set_modified();

    /* Update the screen. */
    edit_refresh_needed = TRUE;

#ifndef DISABLE_COLOR
    reset_multis(openfile->current, FALSE);
#endif

#ifdef DEBUG
    dump_filestruct(cutbuffer);
#endif
}
예제 #15
0
void ShipGoalsDlg::update_item(int item, int multi)
{
	char *docker, *dockee, *subsys;
	int mode;
	char buf[512], save[80];
	waypoint_list *wp_list;

	if (item >= MAX_AI_GOALS)
		return;

	if (!multi || m_priority[item] >= 0)
		goalp[item].priority = m_priority[item];

	if (m_behavior[item] < 0) {
		if (multi)
			return;
		else
			m_behavior[item] = 0;
	}

	mode = (int)m_behavior_box[item] -> GetItemData(m_behavior[item]);
	switch (mode) {
		case AI_GOAL_NONE:
		case AI_GOAL_CHASE_ANY:
		case AI_GOAL_UNDOCK:
		case AI_GOAL_KEEP_SAFE_DISTANCE:
		case AI_GOAL_PLAY_DEAD:
		case AI_GOAL_PLAY_DEAD_PERSISTENT:
		case AI_GOAL_WARP:
			// these goals do not have a target in the dialog box, so let's set the goal and return immediately
			// so that we don't run afoul of the "doesn't have a valid target" code at the bottom of the function
			MODIFY(goalp[item].ai_mode, mode);
			return;

		case AI_GOAL_WAYPOINTS:
		case AI_GOAL_WAYPOINTS_ONCE:
		case AI_GOAL_DISABLE_SHIP:
		case AI_GOAL_DISARM_SHIP:
		case AI_GOAL_IGNORE:
		case AI_GOAL_IGNORE_NEW:
		case AI_GOAL_EVADE_SHIP:
		case AI_GOAL_STAY_NEAR_SHIP:
		case AI_GOAL_STAY_STILL:
		case AI_GOAL_CHASE_SHIP_CLASS:
			break;

		case AI_GOAL_DESTROY_SUBSYSTEM:
			subsys = NULL;
			if (!multi || (m_data[item] && (m_subsys[item] >= 0)))
				subsys = (char *) m_subsys_box[item]->GetItemDataPtr(m_subsys[item]);
				//MODIFY(goalp[item].ai_submode, m_subsys[item] + 1);

			if (!subsys) {
				sprintf(buf, "Order #%d doesn't have valid subsystem name.  Order will be removed", item + 1);
				MessageBox(buf, "Notice");
				MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
				return;

			} else {
				if (!goalp[item].docker.name || (goalp[item].docker.name && !stricmp(goalp[item].docker.name, subsys)))
					set_modified();

				goalp[item].docker.name = subsys;
			}

			break;

		case AI_GOAL_CHASE | AI_GOAL_CHASE_WING:
			switch (m_data[item] & TYPE_MASK) {
				case TYPE_SHIP:
				case TYPE_PLAYER:
					mode = AI_GOAL_CHASE;
					break;

				case TYPE_WING:
					mode = AI_GOAL_CHASE_WING;
					break;
			}

			break;

		case AI_GOAL_DOCK:
			docker = NULL;
			if (!multi || (m_data[item] && (m_subsys[item] >= 0)))
				docker = (char *) m_subsys_box[item] -> GetItemDataPtr(m_subsys[item]);

			dockee = NULL;
			if (!multi || (m_data[item] && (m_dock2[item] >= 0)))
				dockee = (char *) m_dock2_box[item] -> GetItemDataPtr(m_dock2[item]);

			if (docker == (char *) SIZE_T_MAX)
				docker = NULL;
			if (dockee == (char *) SIZE_T_MAX)
				dockee = NULL;

			if (!docker || !dockee) {
				sprintf(buf, "Order #%d doesn't have valid docking points.  Order will be removed", item + 1);
				MessageBox(buf, "Notice");
				MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
				return;

			} else {
				if (!goalp[item].docker.name)
					set_modified();
				else if (!stricmp(goalp[item].docker.name, docker))
					set_modified();

				if (!goalp[item].dockee.name)
					set_modified();
				else if (!stricmp(goalp[item].dockee.name, dockee))
					set_modified();

				goalp[item].docker.name = docker;
				goalp[item].dockee.name = dockee;
			}

			break;

		case AI_GOAL_GUARD | AI_GOAL_GUARD_WING:
			switch (m_data[item] & TYPE_MASK) {
				case TYPE_SHIP:
				case TYPE_PLAYER:
					mode = AI_GOAL_GUARD;
					break;

				case TYPE_WING:
					mode = AI_GOAL_GUARD_WING;
					break;
			}

			break;

		default:
			Warning(LOCATION, "Unknown AI_GOAL type 0x%x", mode);
			MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
			return;
	}

	MODIFY(goalp[item].ai_mode, mode);

	*save = 0;
	if (goalp[item].target_name)
		strcpy_s(save, goalp[item].target_name);

	switch (m_data[item] & TYPE_MASK) {
		int not_used;

		case TYPE_SHIP:
		case TYPE_PLAYER:
			goalp[item].target_name = ai_get_goal_target_name(Ships[m_data[item] & DATA_MASK].ship_name, &not_used);
			break;

		case TYPE_WING:
			goalp[item].target_name = ai_get_goal_target_name(Wings[m_data[item] & DATA_MASK].name, &not_used);
			break;

		case TYPE_PATH:
			wp_list = find_waypoint_list_at_index(m_data[item] & DATA_MASK);
			Assert(wp_list != NULL);
			goalp[item].target_name = ai_get_goal_target_name(wp_list->get_name(), &not_used);
			break;

		case TYPE_WAYPOINT:
			goalp[item].target_name = ai_get_goal_target_name(object_name(m_data[item] & DATA_MASK), &not_used);
			break;

		case TYPE_SHIP_CLASS:
			goalp[item].target_name = ai_get_goal_target_name(Ship_info[m_data[item] & DATA_MASK].name, &not_used);
			break;

		case 0:
		case -1:
		case (-1 & TYPE_MASK):
			if (multi)
				return;

			sprintf(buf, "Order #%d doesn't have a valid target.  Order will be removed", item + 1);
			MessageBox(buf, "Notice");
			MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
			return;

		default:
			Error(LOCATION, "Unhandled TYPE_X #define %d in ship goals dialog box", m_data[item] & TYPE_MASK);
	}

	if (stricmp(save, goalp[item].target_name))
		set_modified();
}
예제 #16
0
void asteroid_editor::update_init()
{
	int num_asteroids, idx, cur_choice;

	UpdateData(TRUE);
	if (last_field >= 0) {
		// store into temp asteroid field
		num_asteroids = a_field[last_field].num_initial_asteroids;
		a_field[last_field].num_initial_asteroids = m_enable_asteroids ? m_density : 0;
		if (a_field[last_field].num_initial_asteroids < 0)
			a_field[last_field].num_initial_asteroids = 0;

		if (a_field[last_field].num_initial_asteroids > MAX_ASTEROIDS)
			a_field[last_field].num_initial_asteroids = MAX_ASTEROIDS;

		if (num_asteroids != a_field[last_field].num_initial_asteroids)
			set_modified();

		vector	vel_vec = {1.0f, 0.0f, 0.0f};
		vm_vec_scale(&vel_vec, (float) m_avg_speed);

		MODIFY(a_field[last_field].vel.x, vel_vec.x);
		MODIFY(a_field[last_field].vel.y, vel_vec.y);
		MODIFY(a_field[last_field].vel.z, vel_vec.z);

		MODIFY(a_field[last_field].min_bound.x, (float) atof(m_min_x));
		MODIFY(a_field[last_field].min_bound.y, (float) atof(m_min_y));
		MODIFY(a_field[last_field].min_bound.z, (float) atof(m_min_z));
		MODIFY(a_field[last_field].max_bound.x, (float) atof(m_max_x));
		MODIFY(a_field[last_field].max_bound.y, (float) atof(m_max_y));
		MODIFY(a_field[last_field].max_bound.z, (float) atof(m_max_z));

		// type of field
		MODIFY(a_field[last_field].field_type, m_field_type);
		MODIFY(a_field[last_field].debris_genre, m_debris_genre);
		if ( (m_field_type == FT_PASSIVE) && (m_debris_genre == DG_SHIP) ) {
			// we should have ship debris
			for (idx=0; idx<3; idx++) {
				// loop over combo boxes, store the item data of the cur selection, -1 in no cur selection
				int cur_sel = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetCurSel();
				if (cur_sel != CB_ERR) {
					cur_choice = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetItemData(cur_sel);
				} else {
					cur_choice = -1;
				}
				MODIFY(a_field[cur_field].field_debris_type[idx], cur_choice);
			}
		}

		if ( m_debris_genre == DG_ASTEROID ) {
			if ( ((CButton *)GetDlgItem(IDC_SUBTYPE1))->GetCheck() == 1) {
				cur_choice = 1;
			} else {
				cur_choice = -1;
			}
			MODIFY(a_field[cur_field].field_debris_type[0], cur_choice);


			if ( ((CButton *)GetDlgItem(IDC_SUBTYPE2))->GetCheck() == 1) {
				cur_choice = 1;
			} else {
				cur_choice = -1;
			}
			MODIFY(a_field[cur_field].field_debris_type[1], cur_choice);


			if ( ((CButton *)GetDlgItem(IDC_SUBTYPE3))->GetCheck() == 1) {
				cur_choice = 1;
			} else {
				cur_choice = -1;
			}
			MODIFY(a_field[cur_field].field_debris_type[2], cur_choice);
		}

		MODIFY(a_field[last_field].has_inner_bound, m_enable_inner_bounds);

		MODIFY(a_field[last_field].inner_min_bound.x, (float) atof(m_box_min_x));
		MODIFY(a_field[last_field].inner_min_bound.y, (float) atof(m_box_min_y));
		MODIFY(a_field[last_field].inner_min_bound.z, (float) atof(m_box_min_z));
		MODIFY(a_field[last_field].inner_max_bound.x, (float) atof(m_box_max_x));
		MODIFY(a_field[last_field].inner_max_bound.y, (float) atof(m_box_max_y));
		MODIFY(a_field[last_field].inner_max_bound.z, (float) atof(m_box_max_z));
	}

	Assert(cur_field >= 0);
	// get from temp asteroid field into class
	m_enable_asteroids = a_field[cur_field].num_initial_asteroids ? TRUE : FALSE;
	m_enable_inner_bounds = a_field[cur_field].has_inner_bound ? TRUE : FALSE;
	m_density = a_field[cur_field].num_initial_asteroids;
	if (!m_enable_asteroids)
		m_density = 10;

	// set field type
	m_field_type = a_field[cur_field].field_type;
	m_debris_genre = a_field[cur_field].debris_genre;
//	m_debris_species = a_field[cur_field].debris_species;

	m_avg_speed = (int) vm_vec_mag(&a_field[cur_field].vel);
	m_min_x.Format("%.1f", a_field[cur_field].min_bound.x);
	m_min_y.Format("%.1f", a_field[cur_field].min_bound.y);
	m_min_z.Format("%.1f", a_field[cur_field].min_bound.z);
	m_max_x.Format("%.1f", a_field[cur_field].max_bound.x);
	m_max_y.Format("%.1f", a_field[cur_field].max_bound.y);
	m_max_z.Format("%.1f", a_field[cur_field].max_bound.z);

	m_box_min_x.Format("%.1f", a_field[cur_field].inner_min_bound.x);
	m_box_min_y.Format("%.1f", a_field[cur_field].inner_min_bound.y);
	m_box_min_z.Format("%.1f", a_field[cur_field].inner_min_bound.z);
	m_box_max_x.Format("%.1f", a_field[cur_field].inner_max_bound.x);
	m_box_max_y.Format("%.1f", a_field[cur_field].inner_max_bound.y);
	m_box_max_z.Format("%.1f", a_field[cur_field].inner_max_bound.z);

	// set up combo boxes
	int box_index;
	int num_field_debris_info = MAX_DEBRIS_TYPES + 1;

	for (idx=0; idx<num_field_debris_info; idx++) {
		box_index = ((CComboBox*)GetDlgItem(IDC_SHIP_DEBRIS1))->AddString(Field_debris_info[idx].name);
		((CComboBox*)GetDlgItem(IDC_SHIP_DEBRIS1))->SetItemData(box_index, Field_debris_info[idx].index);

		box_index = ((CComboBox*)GetDlgItem(IDC_SHIP_DEBRIS2))->AddString(Field_debris_info[idx].name);
		((CComboBox*)GetDlgItem(IDC_SHIP_DEBRIS2))->SetItemData(box_index, Field_debris_info[idx].index);

		box_index = ((CComboBox*)GetDlgItem(IDC_SHIP_DEBRIS3))->AddString(Field_debris_info[idx].name);
		((CComboBox*)GetDlgItem(IDC_SHIP_DEBRIS3))->SetItemData(box_index, Field_debris_info[idx].index);
	}

	// now delete asteroid data
	// search by string Field_debris_info[1-3].name

	for (idx=0; idx<3; idx++) {
		box_index = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->FindStringExact(0, Field_debris_info[1].name);	// "Asteroid Small"
		if (box_index > 0) {
			((CComboBox*)GetDlgItem(Dlg_id[idx]))->DeleteString(box_index);
		}

		box_index = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->FindStringExact(0, Field_debris_info[2].name);	// "Asteroid Medium"
		if (box_index > 0) {
			((CComboBox*)GetDlgItem(Dlg_id[idx]))->DeleteString(box_index);
		}

		box_index = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->FindStringExact(0, Field_debris_info[3].name);	// "Asteroid Big"
		if (box_index > 0) {
			((CComboBox*)GetDlgItem(Dlg_id[idx]))->DeleteString(box_index);
		}
	}

	// set active debris type for each combo box
	int box_count, cur_box_data;
	for (idx=0;idx<3; idx++) {
		// Only set selection if not "None"
		if (a_field[cur_field].field_debris_type[idx] != -1) {
			box_count = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetCount();
			for (box_index=0; box_index<box_count; box_index++) {
				cur_box_data = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetItemData(box_index);
				if (cur_box_data == a_field[cur_field].field_debris_type[idx]) {
					// set cur sel
					((CComboBox*)GetDlgItem(Dlg_id[idx]))->SetCurSel(box_index);
					break;
				}
			}
		}
	}

	// set up asteroid subtype checkboxes
	((CButton*)GetDlgItem(IDC_SUBTYPE1))->SetCheck(a_field[cur_field].field_debris_type[0] == 1);
	((CButton*)GetDlgItem(IDC_SUBTYPE2))->SetCheck(a_field[cur_field].field_debris_type[1] == 1);
	((CButton*)GetDlgItem(IDC_SUBTYPE3))->SetCheck(a_field[cur_field].field_debris_type[2] == 1);


	UpdateData(FALSE);
	OnEnableAsteroids();

	last_field = cur_field;
}
void ShipSpecialHitpoints::OnOk() 
{
	float temp_max_hull_strength;
	int new_shield_strength, new_hull_strength;
	int i;

	UpdateData(TRUE);

	// TODO: Add extra validation here
	if (m_special_hitpoints_enabled) {

		// Don't update anything if the hull strength is invalid
		if (m_hull < 1) {
			return;
		}

		// set to update
		set_modified();

		new_hull_strength = m_hull;
		//Ships[m_ship_num].special_hitpoints = m_hull;

	} 
	else {
		// set to update
		set_modified();

		new_hull_strength = 0;
	}

	if (m_special_shield_enabled) {

		// Don't update anything if the hull strength is invalid
		if (m_shields < 0) 	{
			return;
		}

		// set to update
		set_modified();

		new_shield_strength = m_shields;
		//Ships[m_ship_num].special_shield = m_shields;

	} 
	else {
		// set to update
		set_modified();

		new_shield_strength = -1;
	}

	for ( i=0; i<num_selected_ships; i++) {
		// set the special hitpoints/shield
		Ships[m_selected_ships[i]].special_hitpoints = new_hull_strength;
		Ships[m_selected_ships[i]].special_shield = new_shield_strength;

		// calc kamikaze stuff
		if (Ships[m_selected_ships[i]].special_hitpoints)
		{
			temp_max_hull_strength = (float)Ships[m_selected_ships[i]].special_hitpoints;
		}
		else
		{
			temp_max_hull_strength = Ship_info[Ships[m_selected_ships[i]].ship_info_index].max_hull_strength;
		}

		Ai_info[Ships[m_selected_ships[i]].ai_index].kamikaze_damage = min(1000, 200 + (int)(temp_max_hull_strength / 4.0f));
	}

	
	CDialog::OnOK();
}
예제 #18
0
// read in a new mission file from disk
int CFREDDoc::load_mission(char *pathname)
{
	char name[512], *old_name;
	int i, j, k, ob;
	int used_pool[MAX_WEAPON_TYPES];
	waypoint_list *wptr;
	object *objp;

	Parse_viewer_pos = view_pos;
	Parse_viewer_orient = view_orient;

	// activate the localizer hash table
	fhash_flush();	

	clear_mission();
	Fred_found_unknown_ship_during_parsing = 0;
	if (parse_main(pathname)) {
		sprintf(name, "Unable to load the file \"%s\"", pathname);
		Fred_view_wnd->MessageBox(name);
		create_new_mission();		
		return -1;
	}

	if(Fred_found_unknown_ship_during_parsing){
		Fred_view_wnd->MessageBox("Fred encountered unknown ship/weapon classes when parsing the mission file. This may be due to mission disk data you do not have");
	}
	Fred_found_unknown_ship_during_parsing = 0;

	for (i=0; i<Num_waypoint_lists; i++) {
		wptr = &Waypoint_lists[i];
		for (j=0; j<wptr->count; j++){
			ob = obj_create(OBJ_WAYPOINT, -1, i * 65536 + j, NULL, &wptr->waypoints[j], 0.0f, OF_RENDERS);
		}
	}

	obj_merge_created_list();
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags & OF_PLAYER_SHIP) {
			Assert(objp->type == OBJ_SHIP);
			objp->type = OBJ_START;
//			Player_starts++;
		}

		objp = GET_NEXT(objp);
	}

	for (i=0; i<num_wings; i++) {
		for (j=0; j<Wings[i].wave_count; j++) {
			ob = Ships[Wings[i].ship_index[j]].objnum;
			wing_objects[i][j] = ob;
			Ships[Wings[i].ship_index[j]].wingnum = i;
			Ships[Wings[i].ship_index[j]].arrival_cue = Locked_sexp_false;
		}

		// fix old ship names for ships in wings if needed
		while (j--) {
			if ( (Objects[wing_objects[i][j]].type == OBJ_SHIP) || (Objects[wing_objects[i][j]].type == OBJ_START) ) {  // don't change player ship names
				sprintf(name, "%s %d", Wings[i].name, j + 1);
				old_name = Ships[Wings[i].ship_index[j]].ship_name;
				if (stricmp(name, old_name)) {  // need to fix name
					update_sexp_references(old_name, name);
					ai_update_goal_references(REF_TYPE_SHIP, old_name, name);
					for (k=0; k<Num_reinforcements; k++)
						if (!stricmp(old_name, Reinforcements[k].name)) {
							Assert(strlen(name) < NAME_LENGTH);
							strcpy(Reinforcements[k].name, name);
						}

					strcpy(Ships[Wings[i].ship_index[j]].ship_name, name);
				}
			}
		}
	}

	generate_weaponry_usage_list(used_pool);
	for ( j = 0; j < Num_teams; j++ ) {
		for (i=0; i<Num_weapon_types; i++) {
			Team_data[j].weaponry_pool[i] -= used_pool[i];  // convert weaponry_pool to be extras available beyond the current ships weapons
			if (Team_data[j].weaponry_pool[i] < 0)
				Team_data[j].weaponry_pool[i] = 0;
		}
	}

	Assert(Mission_palette >= 0);
	Assert(Mission_palette <= 98);

	if (The_mission.flags & MISSION_FLAG_SUBSPACE) {
		strcpy(name, NOX("gamepalette-subspace"));
	} else {
		strcpy(name, "gamepalette1-01");
		// sprintf(name, NOX("gamepalette1-%02d"), Mission_palette + 1);
	}

	palette_load_table(name);

	// go through all ships and translate their alternate name indices	
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		// if this is a ship, check it, and mark its possible alternate name down in the auxiliary array
		if(((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) && (objp->instance >= 0) && (Ships[objp->instance].alt_type_index >= 0)){
			mission_parse_lookup_alt_index(Ships[objp->instance].alt_type_index, Fred_alt_names[objp->instance]);

			// also zero it
			Ships[objp->instance].alt_type_index = -1;
		}

		objp = GET_NEXT(objp);
	}


	view_pos = Parse_viewer_pos;
	view_orient = Parse_viewer_orient;
	set_modified(0);	

	return 0;
}
void asteroid_editor::update_init()
{
	int num_asteroids, idx, cur_choice;

	UpdateData(TRUE);
	if (last_field >= 0) {
		// store into temp asteroid field
		num_asteroids = a_field[last_field].num_initial_asteroids;
		a_field[last_field].num_initial_asteroids = m_enable_asteroids ? m_density : 0;
		if (a_field[last_field].num_initial_asteroids < 0)
			a_field[last_field].num_initial_asteroids = 0;

		if (a_field[last_field].num_initial_asteroids > MAX_ASTEROIDS)
			a_field[last_field].num_initial_asteroids = MAX_ASTEROIDS;

		if (num_asteroids != a_field[last_field].num_initial_asteroids)
			set_modified();

		vec3d	vel_vec = {1.0f, 0.0f, 0.0f};
		vm_vec_scale(&vel_vec, (float) m_avg_speed);

		MODIFY(a_field[last_field].vel.xyz.x, vel_vec.xyz.x);
		MODIFY(a_field[last_field].vel.xyz.y, vel_vec.xyz.y);
		MODIFY(a_field[last_field].vel.xyz.z, vel_vec.xyz.z);

		MODIFY(a_field[last_field].min_bound.xyz.x, (float) atof(m_min_x));
		MODIFY(a_field[last_field].min_bound.xyz.y, (float) atof(m_min_y));
		MODIFY(a_field[last_field].min_bound.xyz.z, (float) atof(m_min_z));
		MODIFY(a_field[last_field].max_bound.xyz.x, (float) atof(m_max_x));
		MODIFY(a_field[last_field].max_bound.xyz.y, (float) atof(m_max_y));
		MODIFY(a_field[last_field].max_bound.xyz.z, (float) atof(m_max_z));

		// type of field
		MODIFY(a_field[last_field].field_type, m_field_type);
		MODIFY(a_field[last_field].debris_genre, m_debris_genre);
		if ( (m_field_type == FT_PASSIVE) && (m_debris_genre == DG_SHIP) ) {
			// we should have ship debris
			for (idx=0; idx<MAX_ACTIVE_DEBRIS_TYPES; idx++) {
				// loop over combo boxes, store the item data of the cur selection, -1 in no cur selection
				int cur_sel = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetCurSel();
				if (cur_sel != CB_ERR) {
					cur_choice = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetItemData(cur_sel);
				} else {
					cur_choice = -1;
				}
				MODIFY(a_field[cur_field].field_debris_type[idx], cur_choice);
			}
		}

		if ( m_debris_genre == DG_ASTEROID ) {
			if ( ((CButton *)GetDlgItem(IDC_SUBTYPE1))->GetCheck() == 1) {
				cur_choice = 1;
			} else {
				cur_choice = -1;
			}
			MODIFY(a_field[cur_field].field_debris_type[0], cur_choice);


			if ( ((CButton *)GetDlgItem(IDC_SUBTYPE2))->GetCheck() == 1) {
				cur_choice = 1;
			} else {
				cur_choice = -1;
			}
			MODIFY(a_field[cur_field].field_debris_type[1], cur_choice);


			if ( ((CButton *)GetDlgItem(IDC_SUBTYPE3))->GetCheck() == 1) {
				cur_choice = 1;
			} else {
				cur_choice = -1;
			}
			MODIFY(a_field[cur_field].field_debris_type[2], cur_choice);
		}

		MODIFY(a_field[last_field].has_inner_bound, m_enable_inner_bounds);

		MODIFY(a_field[last_field].inner_min_bound.xyz.x, (float) atof(m_box_min_x));
		MODIFY(a_field[last_field].inner_min_bound.xyz.y, (float) atof(m_box_min_y));
		MODIFY(a_field[last_field].inner_min_bound.xyz.z, (float) atof(m_box_min_z));
		MODIFY(a_field[last_field].inner_max_bound.xyz.x, (float) atof(m_box_max_x));
		MODIFY(a_field[last_field].inner_max_bound.xyz.y, (float) atof(m_box_max_y));
		MODIFY(a_field[last_field].inner_max_bound.xyz.z, (float) atof(m_box_max_z));
	}

	Assert(cur_field >= 0);
	// get from temp asteroid field into class
	m_enable_asteroids = a_field[cur_field].num_initial_asteroids ? TRUE : FALSE;
	m_enable_inner_bounds = a_field[cur_field].has_inner_bound ? TRUE : FALSE;
	m_density = a_field[cur_field].num_initial_asteroids;
	if (!m_enable_asteroids)
		m_density = 10;

	// set field type
	m_field_type = a_field[cur_field].field_type;
	m_debris_genre = a_field[cur_field].debris_genre;
//	m_debris_species = a_field[cur_field].debris_species;

	m_avg_speed = (int) vm_vec_mag(&a_field[cur_field].vel);
	m_min_x.Format("%.1f", a_field[cur_field].min_bound.xyz.x);
	m_min_y.Format("%.1f", a_field[cur_field].min_bound.xyz.y);
	m_min_z.Format("%.1f", a_field[cur_field].min_bound.xyz.z);
	m_max_x.Format("%.1f", a_field[cur_field].max_bound.xyz.x);
	m_max_y.Format("%.1f", a_field[cur_field].max_bound.xyz.y);
	m_max_z.Format("%.1f", a_field[cur_field].max_bound.xyz.z);

	m_box_min_x.Format("%.1f", a_field[cur_field].inner_min_bound.xyz.x);
	m_box_min_y.Format("%.1f", a_field[cur_field].inner_min_bound.xyz.y);
	m_box_min_z.Format("%.1f", a_field[cur_field].inner_min_bound.xyz.z);
	m_box_max_x.Format("%.1f", a_field[cur_field].inner_max_bound.xyz.x);
	m_box_max_y.Format("%.1f", a_field[cur_field].inner_max_bound.xyz.y);
	m_box_max_z.Format("%.1f", a_field[cur_field].inner_max_bound.xyz.z);

	// set up combo boxes
	uint i;
	int j, k, index, box_index;

	// add "None" to each box
	for (k = 0; k < MAX_ACTIVE_DEBRIS_TYPES; k++)
	{
		box_index = ((CComboBox*)GetDlgItem(Dlg_id[k]))->AddString("None");
		((CComboBox*)GetDlgItem(Dlg_id[k]))->SetItemData(box_index, -1);
	}

	// now add each kind of debris to each box
	CString name;
	char *debris_size[NUM_DEBRIS_SIZES] = { "Small", "Medium", "Large" };

	// each species
	for (i = 0; i < Species_info.size(); i++)
	{
		// each size
		for (j = 0; j < NUM_DEBRIS_SIZES; j++)
		{
			name = CString(Species_info[i].species_name) + " " + debris_size[j];
			index = NUM_DEBRIS_SIZES + ((i * NUM_DEBRIS_SIZES) + j);

			// each box
			for (k = 0; k < MAX_ACTIVE_DEBRIS_TYPES; k++)
			{
				box_index = ((CComboBox*)GetDlgItem(Dlg_id[k]))->AddString(name);
				((CComboBox*)GetDlgItem(Dlg_id[k]))->SetItemData(box_index, index);
			}
		}
	}

	// set active debris type for each combo box
	int box_count, cur_box_data;
	for (idx=0;idx<MAX_ACTIVE_DEBRIS_TYPES; idx++) {
		// Only set selection if not "None"
		if (a_field[cur_field].field_debris_type[idx] != -1) {
			box_count = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetCount();
			for (box_index=0; box_index<box_count; box_index++) {
				cur_box_data = ((CComboBox*)GetDlgItem(Dlg_id[idx]))->GetItemData(box_index);
				if (cur_box_data == a_field[cur_field].field_debris_type[idx]) {
					// set cur sel
					((CComboBox*)GetDlgItem(Dlg_id[idx]))->SetCurSel(box_index);
					break;
				}
			}
		}
	}

	// set up asteroid subtype checkboxes
	((CButton*)GetDlgItem(IDC_SUBTYPE1))->SetCheck(a_field[cur_field].field_debris_type[0] == 1);
	((CButton*)GetDlgItem(IDC_SUBTYPE2))->SetCheck(a_field[cur_field].field_debris_type[1] == 1);
	((CButton*)GetDlgItem(IDC_SUBTYPE3))->SetCheck(a_field[cur_field].field_debris_type[2] == 1);


	UpdateData(FALSE);
	OnEnableAsteroids();

	last_field = cur_field;
}
예제 #20
0
void ship_flags_dlg::update_ship(int ship)
{
	if (m_reinforcement.GetCheck() != 2)
		set_reinforcement(Ships[ship].ship_name, m_reinforcement.GetCheck());

	switch (m_cargo_known.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags & SF_CARGO_REVEALED) )
				set_modified();
   
			Ships[ship].flags |= SF_CARGO_REVEALED;
			break;

		case 0:
			if ( Ships[ship].flags & SF_CARGO_REVEALED )
				set_modified();

			Ships[ship].flags &= ~SF_CARGO_REVEALED;
			break;
	}

	// update the flags for IGNORE_COUNT and PROTECT_SHIP
	switch (m_protect_ship.GetCheck()) {
		case 1:
			if (!(Objects[Ships[ship].objnum].flags & OF_PROTECTED) )
				set_modified();

			Objects[Ships[ship].objnum].flags |= OF_PROTECTED;
			break;

		case 0:
			if ( Objects[Ships[ship].objnum].flags & OF_PROTECTED )
				set_modified();

			Objects[Ships[ship].objnum].flags &= ~OF_PROTECTED;
			break;
	}

	switch (m_beam_protect_ship.GetCheck()) {
		case 1:
			if (!(Objects[Ships[ship].objnum].flags & OF_BEAM_PROTECTED) )
				set_modified();

			Objects[Ships[ship].objnum].flags |= OF_BEAM_PROTECTED;
			break;

		case 0:
			if ( Objects[Ships[ship].objnum].flags & OF_BEAM_PROTECTED )
				set_modified();

			Objects[Ships[ship].objnum].flags &= ~OF_BEAM_PROTECTED;
			break;
	}

	switch (m_invulnerable.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags & SF_INVULNERABLE) )
				set_modified();

			Ships[ship].flags |= SF_INVULNERABLE;
			break;

		case 0:
			if ( Ships[ship].flags & SF_INVULNERABLE )
				set_modified();

			Ships[ship].flags &= ~SF_INVULNERABLE;
			break;
	}

	switch (m_hidden.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags & SF_HIDDEN_FROM_SENSORS) )
				set_modified();

			Ships[ship].flags |= SF_HIDDEN_FROM_SENSORS;
			break;

		case 0:
			if ( Ships[ship].flags & SF_HIDDEN_FROM_SENSORS )
				set_modified();

			Ships[ship].flags &= ~SF_HIDDEN_FROM_SENSORS;
			break;
	}

	switch (m_primitive_sensors.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags2 & SF2_PRIMITIVE_SENSORS) )
				set_modified();

			Ships[ship].flags2 |= SF2_PRIMITIVE_SENSORS;
			break;

		case 0:
			if ( Ships[ship].flags2 & SF2_PRIMITIVE_SENSORS )
				set_modified();

			Ships[ship].flags2 &= ~SF2_PRIMITIVE_SENSORS;
			break;
	}

	switch (m_no_subspace_drive.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags2 & SF2_NO_SUBSPACE_DRIVE) )
				set_modified();

			Ships[ship].flags2 |= SF2_NO_SUBSPACE_DRIVE;
			break;

		case 0:
			if ( Ships[ship].flags2 & SF2_NO_SUBSPACE_DRIVE )
				set_modified();

			Ships[ship].flags2 &= ~SF2_NO_SUBSPACE_DRIVE;
			break;
	}

	switch (m_weapon_jam.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags2 & SF2_JAMMER_ON) )
				set_modified();

			Ships[ship].flags2 |= SF2_JAMMER_ON;
			break;

		case 0:
			if ( Ships[ship].flags2 & SF2_JAMMER_ON )
				set_modified();

			Ships[ship].flags2 &= ~SF2_JAMMER_ON;
			break;
	}

	switch (m_ignore_count.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags & SF_IGNORE_COUNT) )
				set_modified();

			Ships[ship].flags |= SF_IGNORE_COUNT;
			break;

		case 0:
			if (Ships[ship].flags & SF_IGNORE_COUNT)
				set_modified();

			Ships[ship].flags &= ~SF_IGNORE_COUNT;
			break;
	}

	switch (m_escort.GetCheck()) {
		case 1:
			if (!(Ships[ship].flags & SF_ESCORT))
				set_modified();

			Ships[ship].flags |= SF_ESCORT;
			m_escort_value.save(&Ships[ship].escort_priority);
			break;

		case 0:
			if (Ships[ship].flags & SF_ESCORT)
				set_modified();

			Ships[ship].flags &= ~SF_ESCORT;
			break;
	}

	// deal with updating the "destroy before the mission" stuff
	switch (m_destroy.GetCheck()) {
		case 0:  // this means no check in checkbox
			if ( Ships[ship].flags & SF_KILL_BEFORE_MISSION )
				set_modified();

			Ships[ship].flags &= ~SF_KILL_BEFORE_MISSION;
			break;

		case 1:  // this means checkbox is checked
			if ( !(Ships[ship].flags & SF_KILL_BEFORE_MISSION) )
				set_modified();

			Ships[ship].flags |= SF_KILL_BEFORE_MISSION;
			m_destroy_value.save(&Ships[ship].final_death_time);
			break;
	}  // a mixed state is 2, and since it's not handled, it doesn't change

	switch (m_no_arrival_music.GetCheck()) {
		case 0:
			if (Ships[ship].flags & SF_NO_ARRIVAL_MUSIC)
				set_modified();

			Ships[ship].flags &= ~SF_NO_ARRIVAL_MUSIC;
			break;

		case 1:
			if (!(Ships[ship].flags & SF_NO_ARRIVAL_MUSIC))
				set_modified();

			Ships[ship].flags |= SF_NO_ARRIVAL_MUSIC;
			break;
	}

	switch (m_scannable.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags & SF_SCANNABLE) )
				set_modified();

			Ships[ship].flags |= SF_SCANNABLE;
			break;

		case 0:
			if ( Ships[ship].flags & SF_SCANNABLE )
				set_modified();

			Ships[ship].flags &= ~SF_SCANNABLE;
			break;
	}

	switch (m_red_alert_carry.GetCheck()) {
		case 1:
			if ( !(Ships[ship].flags & SF_RED_ALERT_STORE_STATUS) )
				set_modified();

			Ships[ship].flags |= SF_RED_ALERT_STORE_STATUS;
			break;

		case 0:
			if ( Ships[ship].flags & SF_RED_ALERT_STORE_STATUS )
				set_modified();

			Ships[ship].flags &= ~SF_RED_ALERT_STORE_STATUS;
			break;
	}

	switch (m_special_warp.GetCheck()) {
		case 1:
			if ( !(Objects[Ships[ship].objnum].flags & OF_SPECIAL_WARP) )
				set_modified();

			Objects[Ships[ship].objnum].flags |= OF_SPECIAL_WARP;
			break;

		case 0:
			if ( (Objects[Ships[ship].objnum].flags & OF_SPECIAL_WARP) )
				set_modified();

			Objects[Ships[ship].objnum].flags &= (~OF_SPECIAL_WARP);
			break;
	}

	switch (m_no_dynamic.GetCheck()) {
		case 1:
			if ( !(Ai_info[Ships[ship].ai_index].ai_flags & AIF_NO_DYNAMIC) )
				set_modified();

			Ai_info[Ships[ship].ai_index].ai_flags |= AIF_NO_DYNAMIC;
			break;

		case 0:
			if ( Ai_info[Ships[ship].ai_index].ai_flags & AIF_NO_DYNAMIC )
				set_modified();

			Ai_info[Ships[ship].ai_index].ai_flags &= ~AIF_NO_DYNAMIC;
			break;
	}

	switch (m_kamikaze.GetCheck()) {
		case 1: {
			int damage;

			if ( !(Ai_info[Ships[ship].ai_index].ai_flags & AIF_KAMIKAZE) )
				set_modified();

			Ai_info[Ships[ship].ai_index].ai_flags |= AIF_KAMIKAZE;
			m_kdamage.save(&damage);
			Ai_info[Ships[ship].ai_index].kamikaze_damage = i2fl(damage);
			break;
		}

		case 0:
			if ( Ai_info[Ships[ship].ai_index].ai_flags & AIF_KAMIKAZE )
				set_modified();

			Ai_info[Ships[ship].ai_index].ai_flags &= ~AIF_KAMIKAZE;
			Ai_info[Ships[ship].ai_index].kamikaze_damage = 0.0f;
			break;
	}

	Ships[ship].respawn_priority = 0;
	if(The_mission.game_type & MISSION_TYPE_MULTI){
		m_respawn_priority.save(&Ships[ship].respawn_priority);
	}
}
void initial_status::change_subsys()
{
	int z, cargo_index, enable = FALSE, enable_cargo_name = FALSE;
	int ship_has_scannable_subsystems;
	ship_subsys *ptr;

	// Goober5000
	ship_has_scannable_subsystems = Ship_info[Ships[m_ship].ship_info_index].is_huge_ship();
	if (Ships[m_ship].flags[Ship::Ship_Flags::Toggle_subsystem_scanning])
		ship_has_scannable_subsystems = !ship_has_scannable_subsystems;

	if (cur_subsys != LB_ERR) {
		ptr = GET_FIRST(&Ships[m_ship].subsys_list);
		while (cur_subsys--) {
			Assert(ptr != END_OF_LIST(&Ships[m_ship].subsys_list));
			ptr = GET_NEXT(ptr);
		}

		MODIFY(ptr -> current_hits, 100.0f - (float) m_damage);

		// update cargo name
		if (strlen(m_cargo_name) > 0) { //-V805
			cargo_index = string_lookup(m_cargo_name, Cargo_names, Num_cargo);
			if (cargo_index == -1) {
				if (Num_cargo < MAX_CARGO);
				cargo_index = Num_cargo++;
				strcpy(Cargo_names[cargo_index], m_cargo_name);
				ptr->subsys_cargo_name = cargo_index;
			} else {
				ptr->subsys_cargo_name = cargo_index;
			}
		} else {
			ptr->subsys_cargo_name = 0;
		}
		set_modified();
	}

	cur_subsys = z = ((CListBox *) GetDlgItem(IDC_SUBSYS)) -> GetCurSel();
	if (z == LB_ERR) {
		m_damage = 100;

	} else {
		ptr = GET_FIRST(&Ships[m_ship].subsys_list);
		while (z--) {
			Assert(ptr != END_OF_LIST(&Ships[m_ship].subsys_list));
			ptr = GET_NEXT(ptr);
		}

		m_damage = 100 - (int) ptr -> current_hits;
		if ( ship_has_scannable_subsystems ) {
			enable_cargo_name = TRUE;
			if (ptr->subsys_cargo_name > 0) {
				m_cargo_name = Cargo_names[ptr->subsys_cargo_name];
			} else {
				m_cargo_name = _T("");
			}
		} else {
			m_cargo_name = _T("");
		}
		enable = TRUE;
	}

	GetDlgItem(IDC_DAMAGE) -> EnableWindow(enable);
	GetDlgItem(IDC_DAMAGE_SPIN) -> EnableWindow(enable);
	GetDlgItem(IDC_CARGO_NAME)->EnableWindow(enable && enable_cargo_name);
}
int CMessageEditorDlg::update(int num)
{
	char *ptr, buf[4096];
	int i, node, fnode;
	CListBox *list;

	UpdateData(TRUE);
	if (num >= 0)
	{
		ptr = (char *) (LPCTSTR) m_message_name;
		for (i=0; i<Num_messages; i++)
			if ((i != num) && (!stricmp(m_message_name, Messages[i].name)))
				break;

		if (i == Num_messages) {  // update name if no conflicts, otherwise keep old name
			update_sexp_references(Messages[num].name, ptr, OPF_MESSAGE);
			string_copy(Messages[num].name, m_message_name, NAME_LENGTH - 1);

			list = (CListBox *) GetDlgItem(IDC_MESSAGE_LIST);
			list->DeleteString(num);
			list->InsertString(num, m_message_name);
		}

		string_copy(Messages[num].message, m_message_text, MESSAGE_LENGTH - 1);
		if (Messages[num].avi_info.name)
			free(Messages[num].avi_info.name);

		ptr = (char *) (LPCTSTR) m_avi_filename;
		if (!ptr || !strlen(ptr))
			Messages[num].avi_info.name = NULL;
		else
			Messages[num].avi_info.name = strdup(ptr);

		if (Messages[num].wave_info.name)
			free(Messages[num].wave_info.name);

		ptr = (char *) (LPCTSTR) m_wave_filename;
		if (!ptr || !strlen(ptr))
			Messages[num].wave_info.name = NULL;
		else
			Messages[num].wave_info.name = strdup(ptr);

		// update the persona to the message.  We subtract 1 for the "None" at the beginning of the combo
		// box list.
		Messages[num].persona_index = m_persona - 1;

		if (m_tree.query_false()) {
			if (m_event_num >= 0) {  // need to delete event
				i = m_event_num;
				free_sexp2(Mission_events[i].formula);
				Assert(i < Num_mission_events);
				while (i < Num_mission_events - 1) {
					Mission_events[i] = Mission_events[i + 1];
					i++;
				}

				Num_mission_events--;
				m_event_num = -1;
			}

		} else {
			if (m_event_num >= 0)
				free_sexp2(Mission_events[m_event_num].formula);
			
			else {
				if (Num_mission_events == MAX_MISSION_EVENTS) {
					MessageBox("You have reached the limit on mission events.\n"
						"Can't add an event to send this message.");

					goto exit;
				}

				Assert(Num_mission_events < MAX_MISSION_EVENTS);
				m_event_num = Num_mission_events++;
				string_copy(Mission_events[m_event_num].name, m_message_name, NAME_LENGTH - 1);
				Mission_events[m_event_num].repeat_count = 1;
				Mission_events[m_event_num].interval = 1;
				Mission_events[m_event_num].score = 0;
				Mission_events[m_event_num].chain_delay = -1;
				Mission_events[m_event_num].objective_text = NULL;
				Mission_events[m_event_num].objective_key_text = NULL;
			}

			fnode = m_tree.save_tree();
			ptr = (char *) (LPCTSTR) m_message_name;
			node = alloc_sexp(ptr, SEXP_ATOM, SEXP_ATOM_STRING, -1, -1);
			((CComboBox *) GetDlgItem(IDC_PRIORITY))->GetLBText(m_priority, buf);
			node = alloc_sexp(buf, SEXP_ATOM, SEXP_ATOM_STRING, -1, node);
			((CComboBox *) GetDlgItem(IDC_SENDER))->GetLBText(m_sender, buf);
			node = alloc_sexp(buf, SEXP_ATOM, SEXP_ATOM_STRING, -1, node);
			node = alloc_sexp("send-message", SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, node);
			node = alloc_sexp("", SEXP_LIST, SEXP_ATOM_LIST, node, -1);
			node = alloc_sexp("", SEXP_LIST, SEXP_ATOM_LIST, fnode, node);
			node = alloc_sexp("when", SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, node);
			Mission_events[m_event_num].formula = node;
		}
	}

exit:
	if (query_modified())
		set_modified();

	modified = 0;
	return 0;
}
예제 #23
0
// update parts of wing that can't fail.  This is useful if for when you need to change
// something in a wing that this updates elsewhere in Fred.  Normally when auto-update
// kicks in, the changes you make will be wiped out by the auto=update, so instead you
// would call this function to update the wing, make your changes, and then call the
// initialize_data_safe() function to show your changes in the dialog
void wing_editor::update_data_safe()
{
	char buf[512];
	int i, d, hotkey = -1;

	nprintf(("Fred routing", "Wing dialog save safe\n"));
	if (!GetSafeHwnd())
		return;

	UpdateData(TRUE);
	UpdateData(TRUE);

	if (cur_wing < 0)
		return;

	if (m_threshold >= Wings[cur_wing].wave_count) {
		m_threshold = Wings[cur_wing].wave_count - 1;
		if (!bypass_errors)
			sprintf(buf, "Wave threshold is set too high.  Value has been lowered to %d", (int) m_threshold);

		MessageBox(buf);
	}

	if (m_threshold + Wings[cur_wing].wave_count > MAX_SHIPS_PER_WING) {
		m_threshold = MAX_SHIPS_PER_WING - Wings[cur_wing].wave_count;
		if (!bypass_errors)
			sprintf(buf, "Wave threshold is set too high.  Value has been lowered to %d", (int) m_threshold);

		MessageBox(buf);
	}

	if (m_waves < 1) {
		m_waves = 1;
		if (!bypass_errors)
			sprintf(buf, "Number of waves illegal.  Has been set to 1.", (int) m_waves);

		MessageBox(buf);
	}

	MODIFY(Wings[cur_wing].special_ship, m_special_ship);
	MODIFY(Wings[cur_wing].num_waves, m_waves);
	MODIFY(Wings[cur_wing].threshold, m_threshold);
	MODIFY(Wings[cur_wing].arrival_location, m_arrival_location);
	MODIFY(Wings[cur_wing].departure_location, m_departure_location);
	MODIFY(Wings[cur_wing].arrival_delay, m_arrival_delay);
	if (m_arrival_delay_min > m_arrival_delay_max) {
		if (!bypass_errors)
			sprintf(buf, "Arrival delay minimum greater than maximum.  Value lowered to %d", m_arrival_delay_max);

		MessageBox(buf);
		m_arrival_delay_min = m_arrival_delay_max;
	}

	MODIFY(Wings[cur_wing].wave_delay_min, m_arrival_delay_min);
	MODIFY(Wings[cur_wing].wave_delay_max, m_arrival_delay_max);
	MODIFY(Wings[cur_wing].arrival_distance, m_arrival_dist);
	if (m_arrival_target >= 0) {
		i = ((CComboBox *) GetDlgItem(IDC_ARRIVAL_TARGET)) -> GetItemData(m_arrival_target);
		MODIFY(Wings[cur_wing].arrival_anchor, i);

		// when arriving near or in front of a ship, be sure that we are far enough away from it!!!
		if (((m_arrival_location != ARRIVE_AT_LOCATION) && (m_arrival_location != ARRIVE_FROM_DOCK_BAY)) && (i >= 0) && (i < SPECIAL_ARRIVAL_ANCHORS_OFFSET)) {
			d = int(min(500, 2.0f * Objects[Ships[i].objnum].radius));
			if ((Wings[cur_wing].arrival_distance < d) && (Wings[cur_wing].arrival_distance > -d)) {
				if (!bypass_errors)
					sprintf(buf, "Ship must arrive at least %d meters away from target.\n"
						"Value has been reset to this.  Use with caution!\r\n"
						"Reccomended distance is %d meters.\r\n", d, (int)(2.0f * Objects[Ships[i].objnum].radius) );

				MessageBox(buf);
				if (Wings[cur_wing].arrival_distance < 0)
					Wings[cur_wing].arrival_distance = -d;
				else
					Wings[cur_wing].arrival_distance = d;

				m_arrival_dist = Wings[cur_wing].arrival_distance;
			}
		}
	}

	i = ((CComboBox*)GetDlgItem(IDC_DEPARTURE_TARGET))->GetItemData(m_departure_target);
	
	if (m_departure_location == DEPART_AT_DOCK_BAY) 
		MODIFY(Wings[cur_wing].departure_anchor,  i);
	else
		MODIFY(Wings[cur_wing].jump_anchor, m_departure_target);

	MODIFY(Wings[cur_wing].departure_delay, m_departure_delay);
	hotkey = m_hotkey - 1;
	MODIFY(Wings[cur_wing].hotkey, hotkey);
	if ( m_ignore_count ) {
		if ( !(Wings[cur_wing].flags & WF_IGNORE_COUNT) )
			set_modified();
		Wings[cur_wing].flags |= WF_IGNORE_COUNT;

	} else {
		if ( Wings[cur_wing].flags & WF_IGNORE_COUNT )
			set_modified();
		Wings[cur_wing].flags &= ~WF_IGNORE_COUNT;
	}

	if ( m_no_arrival_music ) {
		if ( !(Wings[cur_wing].flags & WF_NO_ARRIVAL_MUSIC) )
			set_modified();
		Wings[cur_wing].flags |= WF_NO_ARRIVAL_MUSIC;

	} else {
		if ( Wings[cur_wing].flags & WF_NO_ARRIVAL_MUSIC )
			set_modified();
		Wings[cur_wing].flags &= ~WF_NO_ARRIVAL_MUSIC;
	}

	// check the no message flag
	if ( m_no_arrival_message ) {
		if ( !(Wings[cur_wing].flags & WF_NO_ARRIVAL_MESSAGE) )
			set_modified();
		Wings[cur_wing].flags |= WF_NO_ARRIVAL_MESSAGE;

	} else {
		if ( Wings[cur_wing].flags & WF_NO_ARRIVAL_MESSAGE )
			set_modified();
		Wings[cur_wing].flags &= ~WF_NO_ARRIVAL_MESSAGE;
	}

	// set the no warp effect for wings flag
	if ( m_no_arrival_warp ) {
		if ( !(Wings[cur_wing].flags & WF_NO_ARRIVAL_WARP) )
			set_modified();
		Wings[cur_wing].flags |= WF_NO_ARRIVAL_WARP;
	} else {
		if ( Wings[cur_wing].flags & WF_NO_ARRIVAL_WARP )
			set_modified();
		Wings[cur_wing].flags &= ~WF_NO_ARRIVAL_WARP;
	}
	// set the no warp effect for wings flag
	if ( m_no_departure_warp ) {
		if ( !(Wings[cur_wing].flags & WF_NO_DEPARTURE_WARP) )
			set_modified();
		Wings[cur_wing].flags |= WF_NO_DEPARTURE_WARP;
	} else {
		if ( Wings[cur_wing].flags & WF_NO_DEPARTURE_WARP )
			set_modified();
		Wings[cur_wing].flags &= ~WF_NO_DEPARTURE_WARP;
	}

	if ( m_no_dynamic ) {
		if ( !(Wings[cur_wing].flags & WF_NO_DYNAMIC) )
			set_modified();
		Wings[cur_wing].flags |= WF_NO_DYNAMIC;
	} else {
		if ( Wings[cur_wing].flags & WF_NO_DYNAMIC )
			set_modified();
		Wings[cur_wing].flags &= ~WF_NO_DYNAMIC;
	}

	if (Wings[cur_wing].arrival_cue >= 0)
		free_sexp2(Wings[cur_wing].arrival_cue);
	Wings[cur_wing].arrival_cue = m_arrival_tree.save_tree();

	if (Wings[cur_wing].departure_cue >= 0)
		free_sexp2(Wings[cur_wing].departure_cue);
	Wings[cur_wing].departure_cue = m_departure_tree.save_tree();

	// copy squad stuff
	if(stricmp(m_wing_squad_filename, Wings[cur_wing].wing_squad_filename))
	{
		string_copy(Wings[cur_wing].wing_squad_filename, m_wing_squad_filename, MAX_FILENAME_LEN);
		set_modified();
	}

	if (modified)
		set_modified();
}
예제 #24
0
int CFREDDoc::load_mission(char *pathname, int flags) {
	// make sure we're in the correct working directory!!!!!!
	chdir(Fred_base_dir);

	char name[512], *old_name;
	int i, j, k, ob;
	int used_pool[MAX_WEAPON_TYPES];
	object *objp;

	Parse_viewer_pos = view_pos;
	Parse_viewer_orient = view_orient;

	// activate the localizer hash table
	fhash_flush();

	clear_mission();

	if (parse_main(pathname, flags)) {
		if (flags & MPF_IMPORT_FSM) {
			sprintf(name, "Unable to import the file \"%s\".", pathname);
			Fred_view_wnd->MessageBox(name);
		} else {
			sprintf(name, "Unable to load the file \"%s\".", pathname);
			Fred_view_wnd->MessageBox(name);
		}
		create_new_mission();
		return -1;
	}

	if ((Num_unknown_ship_classes > 0) || (Num_unknown_weapon_classes > 0) || (Num_unknown_loadout_classes > 0)) {
		if (flags & MPF_IMPORT_FSM) {
			char msg[256];
			sprintf(msg, "Fred encountered unknown ship/weapon classes when importing \"%s\" (path \"%s\"). You will have to manually edit the converted mission to correct this.", The_mission.name, pathname);
			Fred_view_wnd->MessageBox(msg);
		} else {
			Fred_view_wnd->MessageBox("Fred encountered unknown ship/weapon classes when parsing the mission file. This may be due to mission disk data you do not have.");
		}
	}

	obj_merge_created_list();
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags[Object::Object_Flags::Player_ship]) {
			Assert(objp->type == OBJ_SHIP);
			objp->type = OBJ_START;
			//			Player_starts++;
		}

		objp = GET_NEXT(objp);
	}

	for (i = 0; i < Num_wings; i++) {
		for (j = 0; j < Wings[i].wave_count; j++) {
			ob = Ships[Wings[i].ship_index[j]].objnum;
			wing_objects[i][j] = ob;
			Ships[Wings[i].ship_index[j]].wingnum = i;
			Ships[Wings[i].ship_index[j]].arrival_cue = Locked_sexp_false;
		}

		// fix old ship names for ships in wings if needed
		while (j--) {
			if ((Objects[wing_objects[i][j]].type == OBJ_SHIP) || (Objects[wing_objects[i][j]].type == OBJ_START)) {  // don't change player ship names
				wing_bash_ship_name(name, Wings[i].name, j + 1);
				old_name = Ships[Wings[i].ship_index[j]].ship_name;
				if (stricmp(name, old_name)) {  // need to fix name
					update_sexp_references(old_name, name);
					ai_update_goal_references(REF_TYPE_SHIP, old_name, name);
					update_texture_replacements(old_name, name);
					for (k = 0; k < Num_reinforcements; k++)
						if (!strcmp(old_name, Reinforcements[k].name)) {
							Assert(strlen(name) < NAME_LENGTH);
							strcpy_s(Reinforcements[k].name, name);
						}

					strcpy_s(Ships[Wings[i].ship_index[j]].ship_name, name);
				}
			}
		}
	}

	for (i = 0; i < Num_teams; i++) {
		generate_weaponry_usage_list(i, used_pool);
		for (j = 0; j < Team_data[i].num_weapon_choices; j++) {
			// The amount used in wings is always set by a static loadout entry so skip any that were set by Sexp variables
			if ((!strlen(Team_data[i].weaponry_pool_variable[j])) && (!strlen(Team_data[i].weaponry_amount_variable[j]))) {
				// convert weaponry_pool to be extras available beyond the current ships weapons
				Team_data[i].weaponry_count[j] -= used_pool[Team_data[i].weaponry_pool[j]];
				if (Team_data[i].weaponry_count[j] < 0) {
					Team_data[i].weaponry_count[j] = 0;
				}

				// zero the used pool entry
				used_pool[Team_data[i].weaponry_pool[j]] = 0;
			}
		}
		// double check the used pool is empty
		for (j = 0; j < MAX_WEAPON_TYPES; j++) {
			if (used_pool[j] != 0) {
				Warning(LOCATION, "%s is used in wings of team %d but was not in the loadout. Fixing now", Weapon_info[j].name, i + 1);

				// add the weapon as a new entry
				Team_data[i].weaponry_pool[Team_data[i].num_weapon_choices] = j;
				Team_data[i].weaponry_count[Team_data[i].num_weapon_choices] = used_pool[j];
				strcpy_s(Team_data[i].weaponry_amount_variable[Team_data[i].num_weapon_choices], "");
				strcpy_s(Team_data[i].weaponry_pool_variable[Team_data[i].num_weapon_choices++], "");
			}
		}
	}

	Assert(Mission_palette >= 0);
	Assert(Mission_palette <= 98);

	// RT, don't need this anymore
#if 0

	if (The_mission.flags[Mission::Mission_Flags::Subspace]) {
		strcpy_s(name, NOX("gamepalette-subspace"));
	} else {
		strcpy_s(name, "gamepalette1-01");
		// sprintf(name, NOX("gamepalette1-%02d"), Mission_palette + 1);
	}

	palette_load_table(name);
#endif

	// go through all ships and translate their callsign and alternate name indices	
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		// if this is a ship, check it, and mark its possible alternate name down in the auxiliary array
		if (((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) && (objp->instance >= 0)) {
			if (Ships[objp->instance].alt_type_index >= 0) {
				mission_parse_lookup_alt_index(Ships[objp->instance].alt_type_index, Fred_alt_names[objp->instance]);

				// also zero it
				Ships[objp->instance].alt_type_index = -1;
			}

			if (Ships[objp->instance].callsign_index >= 0) {
				mission_parse_lookup_callsign_index(Ships[objp->instance].callsign_index, Fred_callsigns[objp->instance]);

				// also zero it
				Ships[objp->instance].callsign_index = -1;
			}
		}

		objp = GET_NEXT(objp);
	}


	view_pos = Parse_viewer_pos;
	view_orient = Parse_viewer_orient;
	set_modified(0);
	stars_post_level_init();

	recreate_dialogs();

	return 0;
}
예제 #25
0
파일: search.c 프로젝트: ris21/yoda
/* Step through each replace word and prompt user before replacing.
 * Parameters real_current and real_current_x are needed in order to
 * allow the cursor position to be updated when a word before the cursor
 * is replaced by a shorter word.
 *
 * needle is the string to seek.  We replace it with answer.  Return -1
 * if needle isn't found, else the number of replacements performed.  If
 * canceled isn't NULL, set it to TRUE if we canceled. */
ssize_t do_replace_loop(
#ifndef DISABLE_SPELLER
	bool whole_word_only,
#endif
	bool *canceled, const linestruct *real_current, size_t
	*real_current_x, const char *needle)
{
    ssize_t numreplaced = -1;
    size_t match_len;
    bool replaceall = FALSE;
#ifndef NANO_TINY
    bool old_mark_set = openfile->mark_set;
    linestruct *top, *bot;
    size_t top_x, bot_x;
    bool right_side_up = FALSE;
	/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
	 * FALSE if (current, current_x) is. */

    if (old_mark_set) {
	/* If the mark is on, frame the region, and turn the mark off. */
	mark_order((const linestruct **)&top, &top_x,
	    (const linestruct **)&bot, &bot_x, &right_side_up);
	openfile->mark_set = FALSE;

	/* Start either at the top or the bottom of the marked region. */
	if (!ISSET(BACKWARDS_SEARCH)) {
	    openfile->current = top;
	    openfile->current_x = (top_x == 0 ? 0 : top_x - 1);
	} else {
	    openfile->current = bot;
	    openfile->current_x = bot_x;
	}
    }
#endif /* !NANO_TINY */

    if (canceled != NULL)
	*canceled = FALSE;

    findnextstr_wrap_reset();
    while (findnextstr(
#ifndef DISABLE_SPELLER
	whole_word_only,
#endif
	real_current, *real_current_x, needle, &match_len)) {
	int i = 0;

#ifndef NANO_TINY
	if (old_mark_set) {
	    /* When we've found an occurrence outside of the marked region,
	     * stop the fanfare. */
	    if (openfile->current->lineno > bot->lineno ||
		openfile->current->lineno < top->lineno ||
		(openfile->current == bot && openfile->current_x > bot_x) ||
		(openfile->current == top && openfile->current_x < top_x))
		break;
	}
#endif

	/* Indicate that we found the search string. */
	if (numreplaced == -1)
	    numreplaced = 0;

	if (!replaceall) {
	    size_t xpt = xplustabs();
	    char *exp_word = display_string(openfile->current->data,
		xpt, strnlenpt(openfile->current->data,
		openfile->current_x + match_len) - xpt, FALSE);

	    edit_refresh();

	    curs_set(0);

	    do_replace_highlight(TRUE, exp_word);

	    /* TRANSLATORS: This is a prompt. */
	    i = do_yesno_prompt(TRUE, _("Replace this instance?"));

	    do_replace_highlight(FALSE, exp_word);

	    free(exp_word);

	    curs_set(1);

	    if (i == -1) {	/* We canceled the replace. */
		if (canceled != NULL)
		    *canceled = TRUE;
		break;
	    }
	}

	if (i > 0 || replaceall) {	/* Yes, replace it!!!! */
	    char *copy;
	    size_t length_change;

#ifndef NANO_TINY
	    add_undo(REPLACE);
#endif
	    if (i == 2)
		replaceall = TRUE;

	    copy = replace_line(needle);

	    length_change = strlen(copy) - strlen(openfile->current->data);

#ifndef NANO_TINY
	    /* If the mark was on and (mark_begin, mark_begin_x) was the
	     * top of it, don't change mark_begin_x. */
	    if (!old_mark_set || !right_side_up) {
		/* Keep mark_begin_x in sync with the text changes. */
		if (openfile->current == openfile->mark_begin &&
			openfile->mark_begin_x > openfile->current_x) {
		    if (openfile->mark_begin_x < openfile->current_x +
			match_len)
			openfile->mark_begin_x = openfile->current_x;
		    else
			openfile->mark_begin_x += length_change;
		    bot_x = openfile->mark_begin_x;
		}
	    }

	    /* If the mark was on and (current, current_x) was the top
	     * of it, don't change real_current_x. */
	    if (!old_mark_set || right_side_up) {
#endif
		/* Keep real_current_x in sync with the text changes. */
		if (openfile->current == real_current &&
			openfile->current_x <= *real_current_x) {
		    if (*real_current_x < openfile->current_x + match_len)
			*real_current_x = openfile->current_x + match_len;
		    *real_current_x += length_change;
#ifndef NANO_TINY
		    bot_x = *real_current_x;
		}
#endif
	    }

	    /* Set the cursor at the last character of the replacement
	     * text, so searching will resume after the replacement
	     * text.  Note that current_x might be set to (size_t)-1
	     * here. */
#ifndef NANO_TINY
	    if (!ISSET(BACKWARDS_SEARCH))
#endif
		openfile->current_x += match_len + length_change - 1;

	    /* Clean up. */
	    openfile->totsize += mbstrlen(copy) -
		mbstrlen(openfile->current->data);
	    free(openfile->current->data);
	    openfile->current->data = copy;

#ifndef DISABLE_COLOR
	    /* Reset the precalculated multiline-regex hints only when
	     * the first replacement has been made. */
	    if (numreplaced == 0)
		reset_multis(openfile->current, TRUE);
#endif

	    if (!replaceall) {
#ifndef DISABLE_COLOR
		/* If color syntaxes are available and turned on, we
		 * need to call edit_refresh(). */
		if (openfile->colorstrings != NULL &&
			!ISSET(NO_COLOR_SYNTAX))
		    edit_refresh();
		else
#endif
		    update_line(openfile->current, openfile->current_x);
	    }

	    set_modified();
	    numreplaced++;
	}
    }

    if (numreplaced == -1)
	not_found_msg(needle);

#ifndef NANO_TINY
    if (old_mark_set)
	openfile->mark_set = TRUE;
#endif

    /* If the NO_NEWLINES flag isn't set, and text has been added to the
     * magicline, make a new magicline. */
    if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
	new_magicline();

    return numreplaced;
}
예제 #26
0
void briefing_editor_dlg::update_data(int update)
{
	char buf[MAX_LABEL_LEN], buf2[MAX_ICON_TEXT_LEN], buf3[MAX_BRIEF_LEN];
	int i, j, l, lines, count, enable = TRUE, valid = 0, invalid = 0;
	object *objp;
	brief_stage *ptr = NULL;

	if (update)
		UpdateData(TRUE);

	// save off current data before we update over it with new briefing stage/team stuff
	Briefing = save_briefing;

	Mission_music[SCORE_BRIEFING] = m_briefing_music - 1;
	strcpy(The_mission.substitute_briefing_music_name, m_substitute_briefing_music);
	if (m_last_stage >= 0) {
		ptr = &Briefing->stages[m_last_stage];
		deconvert_multiline_string(buf3, m_text, MAX_BRIEF_LEN);
		if (stricmp(ptr->new_text, buf3))
			set_modified();

		strcpy(ptr->new_text, buf3);
		MODIFY(ptr->camera_time, atoi(m_time));
		string_copy(ptr->voice, m_voice, MAX_FILENAME_LEN, 1);
		i = ptr->flags;
		if (m_cut_prev)
			i |= BS_BACKWARD_CUT;
		else
			i &= ~BS_BACKWARD_CUT;

		if (m_cut_next)
			i |= BS_FORWARD_CUT;
		else
			i &= ~BS_FORWARD_CUT;

		MODIFY(ptr->flags, i);
		ptr->formula = m_tree.save_tree();
		switch (m_lines.GetCheck()) {
			case 1:
				// add lines between every pair of 2 marked icons if there isn't one already.
				for (i=0; i<ptr->num_icons - 1; i++)
					for (j=i+1; j<ptr->num_icons; j++) {
						if ( icon_marked[i] && icon_marked[j] ) {
							for (l=0; l<ptr->num_lines; l++)
								if ( ((ptr->lines[l].start_icon == i) && (ptr->lines[l].end_icon == j)) || ((ptr->lines[l].start_icon == j) && (ptr->lines[l].end_icon == i)) )
									break;

							if ((l == ptr->num_lines) && (l < MAX_BRIEF_STAGE_LINES)) {
								ptr->lines[l].start_icon = i;
								ptr->lines[l].end_icon = j;
								ptr->num_lines++;
							}
						}
					}

				break;

			case 0:
				// remove all existing lines between any 2 marked icons
				i = ptr->num_lines;
				while (i--)
					if ( icon_marked[ptr->lines[i].start_icon] && icon_marked[ptr->lines[i].end_icon] ) {
						ptr->num_lines--;
						for (l=i; l<ptr->num_lines; l++)
							ptr->lines[l] = ptr->lines[l + 1];
					}

				break;
		}

		if (m_last_icon >= 0) {
			valid = (m_id != ptr->icons[m_last_icon].id);
			if (m_id >= 0) {
				if (valid && !m_change_local) {
					for (i=m_last_stage+1; i<Briefing->num_stages; i++) {
						if (find_icon(m_id, i) >= 0) {
							char msg[1024];

							valid = 0;
							sprintf(msg, "Icon ID #%d is already used in a later stage.  You can only\n"
								"change to that ID locally.  Icon ID has been reset back to %d", m_id, ptr->icons[m_last_icon].id);

							m_id = ptr->icons[m_last_icon].id;
							MessageBox(msg);
							break;
						}
					}
				}

				for (i=0; i<ptr->num_icons; i++)
					if ((i != m_last_icon) && (ptr->icons[i].id == m_id)) {
						char msg[1024];

						sprintf(msg, "Icon ID #%d is already used in this stage.  Icon ID has been reset back to %d",
							m_id, ptr->icons[m_last_icon].id);

						m_id = ptr->icons[m_last_icon].id;
						MessageBox(msg);
						break;
					}

				if (valid && !m_change_local) {
					set_modified();
					reset_icon_loop(m_last_stage);
					while (get_next_icon(ptr->icons[m_last_icon].id))
						iconp->id = m_id;
				}
			}

			ptr->icons[m_last_icon].id = m_id;
			string_copy(buf, m_icon_label, MAX_LABEL_LEN);
			if (stricmp(ptr->icons[m_last_icon].label, buf) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					strcpy(iconp->label, buf);
			}

			strcpy(ptr->icons[m_last_icon].label, buf);
			if ( m_hilight )
				ptr->icons[m_last_icon].flags |= BI_HIGHLIGHT;
			else
				ptr->icons[m_last_icon].flags &= ~BI_HIGHLIGHT;

			if (m_flipicon)
				ptr->icons[m_last_icon].flags |= BI_MIRROR_ICON;
			else
				ptr->icons[m_last_icon].flags &= ~BI_MIRROR_ICON;

			if ((ptr->icons[m_last_icon].type != m_icon_image) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					iconp->type = m_icon_image;
			}

			ptr->icons[m_last_icon].type = m_icon_image;
			if ((ptr->icons[m_last_icon].team != m_icon_team) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					iconp->team = m_icon_team;
			}

			ptr->icons[m_last_icon].team = m_icon_team;
			if ((ptr->icons[m_last_icon].ship_class != m_ship_type) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					iconp->ship_class = m_ship_type;
			}

			MODIFY(ptr->icons[m_last_icon].ship_class, m_ship_type);
			deconvert_multiline_string(buf2, m_icon_text, MAX_ICON_TEXT_LEN);
/*
			if (stricmp(ptr->icons[m_last_icon].text, buf2) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					strcpy(iconp->text, buf2);
			}

			strcpy(ptr->icons[m_last_icon].text, buf2);
*/
		}
	}

	if (!::IsWindow(m_hWnd))
		return;

	// set briefing pointer to correct team
	Briefing = &Briefings[m_current_briefing];

	if ((m_cur_stage >= 0) && (m_cur_stage < Briefing->num_stages)) {
		ptr = &Briefing->stages[m_cur_stage];
		m_stage_title.Format("Stage %d of %d", m_cur_stage + 1, Briefing->num_stages);
		m_text = convert_multiline_string(ptr->new_text);
		m_time.Format("%d", ptr->camera_time);
		m_voice = ptr->voice;
		m_cut_prev = (ptr->flags & BS_BACKWARD_CUT) ? 1 : 0;
		m_cut_next = (ptr->flags & BS_FORWARD_CUT) ? 1 : 0;
		m_tree.load_tree(ptr->formula);

	} else {
		m_stage_title = _T("No stages");
		m_text = _T("");
		m_time = _T("");
		m_voice = _T("");
		m_cut_prev = m_cut_next = 0;
		m_tree.clear_tree();
		enable = FALSE;
		m_cur_stage = -1;
	}

	if (m_cur_stage == Briefing->num_stages - 1)
		GetDlgItem(IDC_NEXT) -> EnableWindow(FALSE);
	else
		GetDlgItem(IDC_NEXT) -> EnableWindow(enable);

	if (m_cur_stage)
		GetDlgItem(IDC_PREV) -> EnableWindow(enable);
	else
		GetDlgItem(IDC_PREV) -> EnableWindow(FALSE);

	if (Briefing->num_stages >= MAX_BRIEF_STAGES)
		GetDlgItem(IDC_ADD_STAGE) -> EnableWindow(FALSE);
	else
		GetDlgItem(IDC_ADD_STAGE) -> EnableWindow(TRUE);

	if (Briefing->num_stages) {
		GetDlgItem(IDC_DELETE_STAGE) -> EnableWindow(enable);
		GetDlgItem(IDC_INSERT_STAGE) -> EnableWindow(enable);
	} else {
		GetDlgItem(IDC_DELETE_STAGE) -> EnableWindow(FALSE);
		GetDlgItem(IDC_INSERT_STAGE) -> EnableWindow(FALSE);
	}

	GetDlgItem(IDC_TIME) -> EnableWindow(enable);
	GetDlgItem(IDC_VOICE) -> EnableWindow(enable);
	GetDlgItem(IDC_BROWSE) -> EnableWindow(enable);
	GetDlgItem(IDC_TEXT) -> EnableWindow(enable);
	GetDlgItem(IDC_SAVE_VIEW) -> EnableWindow(enable);
	GetDlgItem(IDC_GOTO_VIEW) -> EnableWindow(enable);
	GetDlgItem(IDC_CUT_PREV) -> EnableWindow(enable);
	GetDlgItem(IDC_CUT_NEXT) -> EnableWindow(enable);
	GetDlgItem(IDC_TREE) -> EnableWindow(enable);
	GetDlgItem(IDC_PLAY) -> EnableWindow(enable);

	if ((m_cur_stage >= 0) && (m_cur_icon >= 0) && (m_cur_icon < ptr->num_icons)) {
		m_hilight = (ptr->icons[m_cur_icon].flags & BI_HIGHLIGHT)?1:0;
		m_flipicon = (ptr->icons[m_cur_icon].flags & BI_MIRROR_ICON)?1:0;
		m_icon_image = ptr->icons[m_cur_icon].type;
		m_icon_team = ptr->icons[m_cur_icon].team;
		m_icon_label = ptr->icons[m_cur_icon].label;
		m_ship_type = ptr->icons[m_cur_icon].ship_class;
//		m_icon_text = convert_multiline_string(ptr->icons[m_cur_icon].text);
		m_id = ptr->icons[m_cur_icon].id;
		enable = TRUE;

	} else {
		m_flipicon = FALSE;
		m_hilight = FALSE;
		m_icon_image = -1;
		m_icon_team = -1;
		m_ship_type = -1;
		m_icon_label = _T("");
		m_cur_icon = -1;
		m_id = 0;
		enable = FALSE;
	}

	GetDlgItem(IDC_ICON_TEXT) -> EnableWindow(enable);
	GetDlgItem(IDC_ICON_LABEL) -> EnableWindow(enable);
	GetDlgItem(IDC_ICON_IMAGE) -> EnableWindow(enable);
	GetDlgItem(IDC_SHIP_TYPE) -> EnableWindow(enable);
	GetDlgItem(IDC_HILIGHT) -> EnableWindow(enable);
	GetDlgItem(IDC_FLIP_ICON) -> EnableWindow(enable);
	GetDlgItem(IDC_LOCAL) -> EnableWindow(enable);
	GetDlgItem(IDC_TEAM) -> EnableWindow(enable);
	GetDlgItem(IDC_ID) -> EnableWindow(enable);
	GetDlgItem(IDC_DELETE_ICON) -> EnableWindow(enable);

	valid = invalid = 0;
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags & OF_MARKED) {
			if ((objp->type == OBJ_SHIP) || (objp->type == OBJ_START) || (objp->type == OBJ_WAYPOINT) || (objp->type == OBJ_JUMP_NODE))
				valid = 1;
			else
				invalid = 1;
		}

		objp = GET_NEXT(objp);
	}

	if (m_cur_stage >= 0)
		ptr = &Briefing->stages[m_cur_stage];

	if (valid && !invalid && (m_cur_stage >= 0) && (ptr->num_icons < MAX_STAGE_ICONS))
		GetDlgItem(IDC_MAKE_ICON) -> EnableWindow(TRUE);
	else
		GetDlgItem(IDC_MAKE_ICON) -> EnableWindow(FALSE);

	if (m_cur_stage >= 0)
		for (i=0; i<ptr->num_icons; i++)
			icon_marked[i] = 0;

	valid = invalid = 0;
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags & OF_MARKED) {
			if (objp->type == OBJ_POINT) {
				valid++;
				icon_marked[objp->instance] = 1;

			} else
				invalid++;
		}

		objp = GET_NEXT(objp);
	}

	if (valid && !invalid && (m_cur_stage >= 0))
		GetDlgItem(IDC_PROPAGATE_ICONS) -> EnableWindow(TRUE);
	else
		GetDlgItem(IDC_PROPAGATE_ICONS) -> EnableWindow(FALSE);

	count = 0;
	lines = 1;  // default lines checkbox to checked
	
	if (m_cur_stage >= 0) {
		for (i=0; i<ptr->num_lines; i++)
			line_marked[i] = 0;

		// go through and locate all lines between marked icons
		for (i=0; i<ptr->num_icons - 1; i++)
			for (j=i+1; j<ptr->num_icons; j++) {
				if ( icon_marked[i] && icon_marked[j] ) {
					for (l=0; l<ptr->num_lines; l++)
						if ( ((ptr->lines[l].start_icon == i) && (ptr->lines[l].end_icon == j)) || ((ptr->lines[l].start_icon == j) && (ptr->lines[l].end_icon == i)) ) {
							line_marked[l] = 1;
							count++;  // track number of marked lines (lines between 2 icons that are both marked)
							break;
						}

					// at least 1 line missing between 2 marked icons, so use mixed state
					if (l == ptr->num_lines)
						lines = 2;
				}
			}
	}

	// not even 1 line between any 2 marked icons?  Set checkbox to unchecked.
	if (!count)
		lines = 0;

	i = 0;
	if (m_cur_stage >= 0){
		i = calc_num_lines_for_icons(valid) + ptr->num_lines - count;
	}

	if ((valid > 1) && !invalid && (m_cur_stage >= 0) && (i <= MAX_BRIEF_STAGE_LINES))
		GetDlgItem(IDC_LINES) -> EnableWindow(TRUE);
	else
		GetDlgItem(IDC_LINES) -> EnableWindow(FALSE);

	m_lines.SetCheck(lines);

	UpdateData(FALSE);
	if ((m_last_stage != m_cur_stage) || (Briefing != save_briefing)) {
		if (m_last_stage >= 0) {
			for (i=0; i<save_briefing->stages[m_last_stage].num_icons; i++) {
				// save positions of all icons, in case they have moved
				save_briefing->stages[m_last_stage].icons[i].pos = Objects[icon_obj[i]].pos;
				// release objects being used by last stage
				obj_delete(icon_obj[i]);
			}
		}

		if (m_cur_stage >= 0) {
			for (i=0; i<ptr->num_icons; i++) {
				// create an object for each icon for display/manipulation purposes
				icon_obj[i] = obj_create(OBJ_POINT, -1, i, NULL, &ptr->icons[i].pos, 0.0f, OF_RENDERS);
			}

			obj_merge_created_list();
		}

		m_last_stage = m_cur_stage;
	}

	m_last_icon = m_cur_icon;
	Update_window = 1;
	save_briefing = Briefing;
}
예제 #27
0
void CFREDDoc::OnFileImportWeapons() 
{
	CString ships_tbl_mfc;
	char ships_tbl[MAX_PATH_LEN];
	char *ships_tbl_text;
	char *ships_tbl_text_raw;
	char *ch;
	char temp[MAX_PATH_LEN];

	// set up import dialog
	CFileDialog dlg(TRUE, "tbl", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "Imperial Alliance Tables (*.tbl)|*.tbl|All files (*.*)|*.*||");
	dlg.m_ofn.lpstrTitle = "Specify the ships.tbl with the required loadouts";

	// set initial path
	strcpy(temp, Fred_exe_dir);
	if ((ch = stristr(temp, "ImperialAlliance")) >= 0)
	{
		strcpy(ch, "ImperialAlliance\\Data\\Tables");
		dlg.m_ofn.lpstrInitialDir = temp;
	}

	// get ships.tbl
	if (dlg.DoModal() != IDOK)
		return;

	ships_tbl_mfc = dlg.GetPathName();

	if (strlen(ships_tbl_mfc) > MAX_PATH_LEN - 1)
	{
		MessageBox(NULL, "Path name is too long", "Error", MB_OK);
		return;
	}

	if (!strlen(ships_tbl_mfc))
	{
		return;
	}

	strcpy(ships_tbl, ships_tbl_mfc);

	// allocate junk
	ships_tbl_text = (char *) malloc(sizeof(char) * MISSION_TEXT_SIZE);
	ships_tbl_text_raw = (char *) malloc(sizeof(char) * MISSION_TEXT_SIZE);
	if (!ships_tbl_text || !ships_tbl_text_raw)
	{
		free(ships_tbl_text);
		free(ships_tbl_text_raw);

		Error(LOCATION, "Not enough memory to import weapons.");
		return;
	}

	// load the other table and convert, freeing memory after use
	read_file_text(ships_tbl, CF_TYPE_ANY, ships_tbl_text, ships_tbl_text_raw);
	free(ships_tbl_text_raw);
	restore_default_weapons(ships_tbl_text);
	free(ships_tbl_text);

	// we haven't saved it yet
	set_modified(TRUE);

	// error check and notify
	if (!Fred_view_wnd->global_error_check())
	{
		Fred_view_wnd->MessageBox("Weapon loadouts successfully imported with no errors.", "Woohoo!");
	}
}
예제 #28
0
void ship_flags_dlg::update_ship(int shipnum)
{
	ship *shipp = &Ships[shipnum];
	object *objp = &Objects[shipp->objnum];

	if (m_reinforcement.GetCheck() != 2)
		set_reinforcement(shipp->ship_name, m_reinforcement.GetCheck());

	switch (m_cargo_known.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_CARGO_REVEALED) )
				set_modified();

			shipp->flags |= SF_CARGO_REVEALED;
			break;

		case 0:
			if ( shipp->flags & SF_CARGO_REVEALED )
				set_modified();

			shipp->flags &= ~SF_CARGO_REVEALED;
			break;
	}

	// update the flags for IGNORE_COUNT and PROTECT_SHIP
	switch (m_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_PROTECTED) )
				set_modified();

			objp->flags |= OF_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_PROTECTED )
				set_modified();

			objp->flags &= ~OF_PROTECTED;
			break;
	}

	switch (m_beam_protect_ship.GetCheck()) {
		case 1:
			if (!(objp->flags & OF_BEAM_PROTECTED) )
				set_modified();

			objp->flags |= OF_BEAM_PROTECTED;
			break;

		case 0:
			if ( objp->flags & OF_BEAM_PROTECTED )
				set_modified();

			objp->flags &= ~OF_BEAM_PROTECTED;
			break;
	}

	switch (m_invulnerable.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_INVULNERABLE) )
				set_modified();

			objp->flags |= OF_INVULNERABLE;
			break;

		case 0:
			if ( objp->flags & OF_INVULNERABLE )
				set_modified();

			objp->flags &= ~OF_INVULNERABLE;
			break;
	}

	switch (m_targetable_as_bomb.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_TARGETABLE_AS_BOMB) )
				set_modified();

			objp->flags |= OF_TARGETABLE_AS_BOMB;
			break;

		case 0:
			if ( objp->flags & OF_TARGETABLE_AS_BOMB )
				set_modified();

			objp->flags &= ~OF_TARGETABLE_AS_BOMB;
			break;
	}

	switch (m_hidden.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_HIDDEN_FROM_SENSORS) )
				set_modified();

			shipp->flags |= SF_HIDDEN_FROM_SENSORS;
			break;

		case 0:
			if ( shipp->flags & SF_HIDDEN_FROM_SENSORS )
				set_modified();

			shipp->flags &= ~SF_HIDDEN_FROM_SENSORS;
			break;
	}

	switch (m_primitive_sensors.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_PRIMITIVE_SENSORS) )
				set_modified();

			shipp->flags2 |= SF2_PRIMITIVE_SENSORS;
			break;

		case 0:
			if ( shipp->flags2 & SF2_PRIMITIVE_SENSORS )
				set_modified();

			shipp->flags2 &= ~SF2_PRIMITIVE_SENSORS;
			break;
	}

	switch (m_no_subspace_drive.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_SUBSPACE_DRIVE) )
				set_modified();

			shipp->flags2 |= SF2_NO_SUBSPACE_DRIVE;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_SUBSPACE_DRIVE )
				set_modified();

			shipp->flags2 &= ~SF2_NO_SUBSPACE_DRIVE;
			break;
	}

	switch (m_affected_by_gravity.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_AFFECTED_BY_GRAVITY) )
				set_modified();

			shipp->flags2 |= SF2_AFFECTED_BY_GRAVITY;
			break;

		case 0:
			if ( shipp->flags2 & SF2_AFFECTED_BY_GRAVITY )
				set_modified();

			shipp->flags2 &= ~SF2_AFFECTED_BY_GRAVITY;
			break;
	}

	switch (m_toggle_subsystem_scanning.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_TOGGLE_SUBSYSTEM_SCANNING) )
				set_modified();

			shipp->flags2 |= SF2_TOGGLE_SUBSYSTEM_SCANNING;
			break;

		case 0:
			if ( shipp->flags2 & SF2_TOGGLE_SUBSYSTEM_SCANNING )
				set_modified();

			shipp->flags2 &= ~SF2_TOGGLE_SUBSYSTEM_SCANNING;
			break;
	}

	switch (m_ignore_count.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_IGNORE_COUNT) )
				set_modified();

			shipp->flags |= SF_IGNORE_COUNT;
			break;

		case 0:
			if (shipp->flags & SF_IGNORE_COUNT)
				set_modified();

			shipp->flags &= ~SF_IGNORE_COUNT;
			break;
	}

	switch (m_escort.GetCheck()) {
		case 1:
			if (!(shipp->flags & SF_ESCORT))
				set_modified();

			shipp->flags |= SF_ESCORT;
			m_escort_value.save(&shipp->escort_priority);
			break;

		case 0:
			if (shipp->flags & SF_ESCORT)
				set_modified();

			shipp->flags &= ~SF_ESCORT;
			break;
	}

	// deal with updating the "destroy before the mission" stuff
	switch (m_destroy.GetCheck()) {
		case 0:  // this means no check in checkbox
			if ( shipp->flags & SF_KILL_BEFORE_MISSION )
				set_modified();

			shipp->flags &= ~SF_KILL_BEFORE_MISSION;
			break;

		case 1:  // this means checkbox is checked
			if ( !(shipp->flags & SF_KILL_BEFORE_MISSION) )
				set_modified();

			shipp->flags |= SF_KILL_BEFORE_MISSION;
			m_destroy_value.save(&shipp->final_death_time);
			break;
	}  // a mixed state is 2, and since it's not handled, it doesn't change

	switch (m_no_arrival_music.GetCheck()) {
		case 0:
			if (shipp->flags & SF_NO_ARRIVAL_MUSIC)
				set_modified();

			shipp->flags &= ~SF_NO_ARRIVAL_MUSIC;
			break;

		case 1:
			if (!(shipp->flags & SF_NO_ARRIVAL_MUSIC))
				set_modified();

			shipp->flags |= SF_NO_ARRIVAL_MUSIC;
			break;
	}

	switch (m_scannable.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_SCANNABLE) )
				set_modified();

			shipp->flags |= SF_SCANNABLE;
			break;

		case 0:
			if ( shipp->flags & SF_SCANNABLE )
				set_modified();

			shipp->flags &= ~SF_SCANNABLE;
			break;
	}

	switch (m_red_alert_carry.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_RED_ALERT_STORE_STATUS) )
				set_modified();

			shipp->flags |= SF_RED_ALERT_STORE_STATUS;
			break;

		case 0:
			if ( shipp->flags & SF_RED_ALERT_STORE_STATUS )
				set_modified();

			shipp->flags &= ~SF_RED_ALERT_STORE_STATUS;
			break;
	}

	switch (m_special_warpin.GetCheck()) {
		case 1:
			if ( !(objp->flags & OF_SPECIAL_WARPIN) )
				set_modified();

			objp->flags |= OF_SPECIAL_WARPIN;
			break;

		case 0:
			if ( (objp->flags & OF_SPECIAL_WARPIN) )
				set_modified();

			objp->flags &= (~OF_SPECIAL_WARPIN);
			break;
	}

	switch (m_no_dynamic.GetCheck()) {
		case 1:
			if ( !(Ai_info[shipp->ai_index].ai_flags & AIF_NO_DYNAMIC) )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags |= AIF_NO_DYNAMIC;
			break;

		case 0:
			if ( Ai_info[shipp->ai_index].ai_flags & AIF_NO_DYNAMIC )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags &= ~AIF_NO_DYNAMIC;
			break;
	}

	switch (m_kamikaze.GetCheck()) {
		case 1: {
			int damage;

			if ( !(Ai_info[shipp->ai_index].ai_flags & AIF_KAMIKAZE) )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags |= AIF_KAMIKAZE;
			m_kdamage.save(&damage);
			Ai_info[shipp->ai_index].kamikaze_damage = i2fl(damage);
			break;
		}

		case 0:
			if ( Ai_info[shipp->ai_index].ai_flags & AIF_KAMIKAZE )
				set_modified();

			Ai_info[shipp->ai_index].ai_flags &= ~AIF_KAMIKAZE;
			Ai_info[shipp->ai_index].kamikaze_damage = 0.0f;
			break;
	}

	switch (m_disable_messages.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_BUILTIN_MESSAGES) )
				set_modified();

			shipp->flags2 |= SF2_NO_BUILTIN_MESSAGES;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_BUILTIN_MESSAGES )
				set_modified();

			shipp->flags2 &= ~SF2_NO_BUILTIN_MESSAGES;
			break;
	}

	switch (m_set_class_dynamically.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_SET_CLASS_DYNAMICALLY) )
				set_modified();

			shipp->flags2 |= SF2_SET_CLASS_DYNAMICALLY;
			break;

		case 0:
			if ( shipp->flags2 & SF2_SET_CLASS_DYNAMICALLY )
				set_modified();

			shipp->flags2 &= ~SF2_SET_CLASS_DYNAMICALLY;
			break;
	}

	switch (m_no_death_scream.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NO_DEATH_SCREAM) )
				set_modified();

			shipp->flags2 |= SF2_NO_DEATH_SCREAM;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NO_DEATH_SCREAM )
				set_modified();

			shipp->flags2 &= ~SF2_NO_DEATH_SCREAM;
			break;
	}

	switch (m_always_death_scream.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_ALWAYS_DEATH_SCREAM) )
				set_modified();

			shipp->flags2 |= SF2_ALWAYS_DEATH_SCREAM;
			break;

		case 0:
			if ( shipp->flags2 & SF2_ALWAYS_DEATH_SCREAM )
				set_modified();

			shipp->flags2 &= ~SF2_ALWAYS_DEATH_SCREAM;
			break;
	}

	switch (m_nav_carry.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NAVPOINT_CARRY) )
				set_modified();

			shipp->flags2 |= SF2_NAVPOINT_CARRY;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NAVPOINT_CARRY )
				set_modified();

			shipp->flags2 &= ~SF2_NAVPOINT_CARRY;
			break;
	}

	switch (m_nav_needslink.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_NAVPOINT_NEEDSLINK) )
				set_modified();

			shipp->flags2 |= SF2_NAVPOINT_NEEDSLINK;
			break;

		case 0:
			if ( shipp->flags2 & SF2_NAVPOINT_NEEDSLINK )
				set_modified();

			shipp->flags2 &= ~SF2_NAVPOINT_NEEDSLINK;
			break;
	}

	switch (m_hide_ship_name.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_HIDE_SHIP_NAME) )
				set_modified();

			shipp->flags2 |= SF2_HIDE_SHIP_NAME;
			break;

		case 0:
			if ( shipp->flags2 & SF2_HIDE_SHIP_NAME )
				set_modified();

			shipp->flags2 &= ~SF2_HIDE_SHIP_NAME;
			break;
	}

	switch (m_is_harmless.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_IS_HARMLESS) )
				set_modified();

			shipp->flags2 |= SF2_IS_HARMLESS;
			break;

		case 0:
			if ( shipp->flags2 & SF2_IS_HARMLESS )
				set_modified();

			shipp->flags2 &= ~SF2_IS_HARMLESS;
			break;
	}

	switch (m_hide_log_entries.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_HIDE_LOG_ENTRIES) )
				set_modified();

			shipp->flags2 |= SF2_HIDE_LOG_ENTRIES;
			break;

		case 0:
			if ( shipp->flags2 & SF2_HIDE_LOG_ENTRIES )
				set_modified();

			shipp->flags2 &= ~SF2_HIDE_LOG_ENTRIES;
			break;
	}

	switch (m_guardian.GetCheck()) {
		case 1:
			if ( !(shipp->ship_guardian_threshold) )
				set_modified();

			shipp->ship_guardian_threshold = SHIP_GUARDIAN_THRESHOLD_DEFAULT;
			break;

		case 0:
			if ( shipp->ship_guardian_threshold )
				set_modified();

			shipp->ship_guardian_threshold = 0;
			break;
	}

	switch (m_vaporize.GetCheck()) {
		case 1:
			if ( !(shipp->flags & SF_VAPORIZE) )
				set_modified();

			shipp->flags |= SF_VAPORIZE;
			break;

		case 0:
			if ( shipp->flags & SF_VAPORIZE )
				set_modified();

			shipp->flags &= ~SF_VAPORIZE;
			break;
	}

	switch (m_stealth.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_STEALTH) )
				set_modified();

			shipp->flags2 |= SF2_STEALTH;
			break;

		case 0:
			if ( shipp->flags2 & SF2_STEALTH )
				set_modified();

			shipp->flags2 &= ~SF2_STEALTH;
			break;
	}

	switch (m_friendly_stealth_invisible.GetCheck()) {
		case 1:
			if ( !(shipp->flags2 & SF2_FRIENDLY_STEALTH_INVIS) )
				set_modified();

			shipp->flags2 |= SF2_FRIENDLY_STEALTH_INVIS;
			break;

		case 0:
			if ( shipp->flags2 & SF2_FRIENDLY_STEALTH_INVIS )
				set_modified();

			shipp->flags2 &= ~SF2_FRIENDLY_STEALTH_INVIS;
			break;
	}

	shipp->respawn_priority = 0;
	if(The_mission.game_type & MISSION_TYPE_MULTI) {
		m_respawn_priority.save(&shipp->respawn_priority);
	}
}
예제 #29
0
void event_editor::OnOk()
{
	char buf[256], names[2][MAX_MISSION_EVENTS][NAME_LENGTH];
	int i, count;

	audiostream_close_file(m_wave_id, 0);
	m_wave_id = -1;

	save();
	if (query_modified())
		set_modified();

	for (i=0; i<Num_mission_events; i++) {
		free_sexp2(Mission_events[i].formula);
		if (Mission_events[i].objective_text)
			free(Mission_events[i].objective_text);
		if (Mission_events[i].objective_key_text)
			free(Mission_events[i].objective_key_text);
	}

	count = 0;
	for (i=0; i<Num_mission_events; i++)
		Mission_events[i].result = 0;  // use this as a processed flag
	
	// rename all sexp references to old events
	for (i=0; i<m_num_events; i++)
		if (m_sig[i] >= 0) {
			strcpy_s(names[0][count], Mission_events[m_sig[i]].name);
			strcpy_s(names[1][count], m_events[i].name);
			count++;
			Mission_events[m_sig[i]].result = 1;
		}

	// invalidate all sexp references to deleted events.
	for (i=0; i<Num_mission_events; i++)
		if (!Mission_events[i].result) {
			sprintf(buf, "<%s>", Mission_events[i].name);
			strcpy(buf + NAME_LENGTH - 2, ">");  // force it to be not too long
			strcpy_s(names[0][count], Mission_events[i].name);
			strcpy_s(names[1][count], buf);
			count++;
		}

	Num_mission_events = m_num_events;
	for (i=0; i<m_num_events; i++) {
		Mission_events[i] = m_events[i];
		Mission_events[i].formula = m_event_tree.save_tree(m_events[i].formula);
		Mission_events[i].objective_text = m_events[i].objective_text;
		Mission_events[i].objective_key_text = m_events[i].objective_key_text;
		Mission_events[i].mission_log_flags = m_events[i].mission_log_flags;
	}

	// now update all sexp references
	while (count--)
		update_sexp_references(names[0][count], names[1][count], OPF_EVENT_NAME);

	for (i=Num_builtin_messages; i<Num_messages; i++) {
		if (Messages[i].avi_info.name)
			free(Messages[i].avi_info.name);

		if (Messages[i].wave_info.name)
			free(Messages[i].wave_info.name);
	}

	Num_messages = m_num_messages + Num_builtin_messages;
	for (i=0; i<m_num_messages; i++)
		Messages[i + Num_builtin_messages] = m_messages[i];

	theApp.record_window_data(&Events_wnd_data, this);
	delete Event_editor_dlg;
	Event_editor_dlg = NULL;
}
예제 #30
0
파일: update_query.cpp 프로젝트: ryjen/db
 update_query &update_query::table(const string &value)
 {
     tableName_ = value;
     set_modified();
     return *this;
 }