// --------------------------------------------------------------------- // mission_hotkey_set_defaults() // // Set up the hotkey lists for the player based on the mission designer // defaults. // void mission_hotkey_set_defaults() { int i,j; wing *wp; ship *sp; object *A; for ( i = 0; i < MAX_KEYED_TARGETS; i++ ) { hud_target_hotkey_clear(i); } // set the variable letting us know that we should save the hotkey sets Hotkey_sets_saved = 0; Mission_hotkey_save_timestamp = timestamp(HOTKEY_SAVE_TIME); // if we have hotkeys saved from the previous run of this mission, then simply keep the cleared // sets, and let the restore code take care of it! This works because this function is currently // only called from one place -- after the mission loads. if ( Num_hotkeys_saved > 0 ) { mission_hotkey_maybe_restore(); return; } // Check for ships with a hotkey assigned obj_merge_created_list(); for ( A = GET_FIRST(&obj_used_list); A !=END_OF_LIST(&obj_used_list); A = GET_NEXT(A) ) { if ( (A == &obj_used_list) || (A->type != OBJ_SHIP) || ((Game_mode & GM_NORMAL) && (A == Player_obj)) ) { continue; } Assert(A->instance >= 0 && A->instance < MAX_SHIPS); sp = &Ships[A->instance]; if ( sp->hotkey == -1 ) continue; // if the hotkey is the last hotkey in the list, then don't add it either since this hotkey is a special // marker to indicate that this ship should remain invisible in the hotkey screen until after mission // starts if ( sp->hotkey == MAX_KEYED_TARGETS ) continue; Assert(sp->objnum >= 0); hud_target_hotkey_add_remove( sp->hotkey, &Objects[sp->objnum], HOTKEY_MISSION_FILE_ADDED ); } // Check for wings with a hotkey assigned for ( i = 0; i < Num_wings; i++ ) { wp = &Wings[i]; if ( wp->hotkey == -1 ) continue; // like ships, skip this wing if the hotkey is the last hotkey item if ( wp->hotkey == MAX_KEYED_TARGETS ) continue; for ( j = 0; j < wp->current_count; j++ ) { if ( wp->ship_index[j] == -1 ) continue; sp = &Ships[wp->ship_index[j]]; hud_target_hotkey_add_remove( wp->hotkey, &Objects[sp->objnum], HOTKEY_MISSION_FILE_ADDED ); } } }
// 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 briefing_editor_dlg::OnMakeIcon() { char *name; int z, len, team, ship, waypoint, count = -1; int cargo = 0, cargo_count = 0, freighter_count = 0; object *ptr; vec3d min, max, pos; brief_icon *iconp; if (Briefing->stages[m_cur_stage].num_icons >= MAX_STAGE_ICONS) return; m_cur_icon = Briefing->stages[m_cur_stage].num_icons++; iconp = &Briefing->stages[m_cur_stage].icons[m_cur_icon]; ship = waypoint = -1; team = 0; jump_node *jnp = NULL; vm_vec_make(&min, 9e19f, 9e19f, 9e19f); vm_vec_make(&max, -9e19f, -9e19f, -9e19f); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_MARKED) { if (ptr->pos.xyz.x < min.xyz.x) min.xyz.x = ptr->pos.xyz.x; if (ptr->pos.xyz.x > max.xyz.x) max.xyz.x = ptr->pos.xyz.x; if (ptr->pos.xyz.y < min.xyz.y) min.xyz.y = ptr->pos.xyz.y; if (ptr->pos.xyz.y > max.xyz.y) max.xyz.y = ptr->pos.xyz.y; if (ptr->pos.xyz.z < min.xyz.z) min.xyz.z = ptr->pos.xyz.z; if (ptr->pos.xyz.z > max.xyz.z) max.xyz.z = ptr->pos.xyz.z; switch (ptr->type) { case OBJ_SHIP: case OBJ_START: ship = ptr->instance; break; case OBJ_WAYPOINT: waypoint = ptr->instance; break; case OBJ_JUMP_NODE: jnp = ptr->jnp; break; default: Int3(); } if (ship >= 0) { team = Ships[ship].team; z = ship_query_general_type(ship); if (Ship_info[Ships[ship].ship_info_index].flags & SIF_CARGO) cargo_count++; if (Ship_info[Ships[ship].ship_info_index].flags & SIF_FREIGHTER) { // direct docked with any marked cargo? for (dock_instance *dock_ptr = ptr->dock_list; dock_ptr != NULL; dock_ptr = dock_ptr->next) { if (dock_ptr->docked_objp->flags & OF_MARKED) { if (Ship_info[Ships[dock_ptr->docked_objp->instance].ship_info_index].flags & SIF_CARGO) freighter_count++; } } } } count++; } ptr = GET_NEXT(ptr); } if (cargo_count && cargo_count == freighter_count) cargo = 1; vm_vec_avg(&pos, &min, &max); if (ship >= 0) name = Ships[ship].ship_name; else if (waypoint >= 0) name = Waypoint_lists[waypoint / 65536].name; else if (jnp != NULL) name = jnp->get_name_ptr(); else return; len = strlen(name); if (len >= MAX_LABEL_LEN - 1) len = MAX_LABEL_LEN - 1; strncpy(iconp->label, name, len); iconp->label[len] = 0; // iconp->text[0] = 0; iconp->type = 0; iconp->team = team; iconp->pos = pos; iconp->flags = 0; iconp->id = Cur_brief_id++; if (ship >= 0) { iconp->ship_class = Ships[ship].ship_info_index; switch (Ship_info[Ships[ship].ship_info_index].flags & SIF_ALL_SHIP_TYPES) { case SIF_KNOSSOS_DEVICE: iconp->type = ICON_KNOSSOS_DEVICE; break; case SIF_CORVETTE: iconp->type = ICON_CORVETTE; break; case SIF_GAS_MINER: iconp->type = ICON_GAS_MINER; break; case SIF_SUPERCAP: iconp->type = ICON_SUPERCAP; break; case SIF_SENTRYGUN: iconp->type = ICON_SENTRYGUN; break; case SIF_AWACS: iconp->type = ICON_AWACS; break; case SIF_CARGO: if (cargo) iconp->type = (count == 1) ? ICON_FREIGHTER_WITH_CARGO : ICON_FREIGHTER_WING_WITH_CARGO; else iconp->type = count ? ICON_CARGO_WING : ICON_CARGO; break; case SIF_SUPPORT: iconp->type = ICON_SUPPORT_SHIP; break; case SIF_FIGHTER: iconp->type = count ? ICON_FIGHTER_WING : ICON_FIGHTER; break; case SIF_BOMBER: iconp->type = count ? ICON_BOMBER_WING : ICON_BOMBER; break; case SIF_FREIGHTER: if (cargo) iconp->type = (count == 1) ? ICON_FREIGHTER_WITH_CARGO : ICON_FREIGHTER_WING_WITH_CARGO; else iconp->type = count ? ICON_FREIGHTER_WING_NO_CARGO : ICON_FREIGHTER_NO_CARGO; break; case SIF_CRUISER: iconp->type = count ? ICON_CRUISER_WING : ICON_CRUISER; break; case SIF_TRANSPORT: iconp->type = count ? ICON_TRANSPORT_WING : ICON_TRANSPORT; break; case SIF_CAPITAL: case SIF_DRYDOCK: iconp->type = ICON_CAPITAL; break; case SIF_NAVBUOY: iconp->type = ICON_WAYPOINT; break; default: iconp->type = ICON_ASTEROID_FIELD; break; } } // jumpnodes else if(jnp != NULL){ // find the first navbuoy iconp->ship_class = -1; for (int i = 0; i < Num_ship_classes; i++) { if (Ship_info[i].flags & SIF_NAVBUOY) { iconp->ship_class = i; break; } } iconp->type = ICON_JUMP_NODE; } // everything else else { // find the first navbuoy iconp->ship_class = -1; for (int i = 0; i < Num_ship_classes; i++) { if (Ship_info[i].flags & SIF_NAVBUOY) { iconp->ship_class = i; break; } } iconp->type = ICON_WAYPOINT; } if (!m_change_local){ propagate_icon(m_cur_icon); } icon_obj[m_cur_icon] = obj_create(OBJ_POINT, -1, m_cur_icon, NULL, &pos, 0.0f, OF_RENDERS); Assert(icon_obj[m_cur_icon] >= 0); obj_merge_created_list(); unmark_all(); set_cur_object_index(icon_obj[m_cur_icon]); GetDlgItem(IDC_MAKE_ICON) -> EnableWindow(FALSE); GetDlgItem(IDC_PROPAGATE_ICONS) -> EnableWindow(TRUE); update_data(1); }
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; }
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; }