void stuff_link_with_formula(int *link_idx, int formula, int mission_num) { int j, node, node2, node3; if (formula >= 0) { if (!stricmp(CTEXT(formula), "cond")) { // sexp is valid node = CDR(formula); free_one_sexp(formula); while (node != -1) { node2 = CAR(node); Links[*link_idx].from = mission_num; Links[*link_idx].sexp = CAR(node2); Links[*link_idx].mission_loop_txt = NULL; Links[*link_idx].mission_loop_brief_anim = NULL; Links[*link_idx].mission_loop_brief_sound = NULL; sexp_mark_persistent(CAR(node2)); free_one_sexp(node2); node3 = CADR(node2); if ( !stricmp( CTEXT(node3), "next-mission") ) { node3 = CDR(node3); for (j=0; j<Campaign.num_missions; j++) if (!stricmp(CTEXT(node3), Campaign.missions[j].name)) break; if (j < Campaign.num_missions) { // mission is in campaign (you never know..) Links[(*link_idx)++].to = j; Elements[mission_num].from_links++; Elements[j].to_links++; } } else if ( !stricmp( CTEXT(node3), "end-of-campaign") ) { Links[(*link_idx)++].to = -1; Elements[mission_num].from_links++; } else Int3(); // bogus operator in campaign file free_sexp(CDR(node2)); free_one_sexp(node); node = CDR(node); } } } }
void campaign_editor::save_tree(int clear) { int i; if (m_last_mission < 0){ return; // nothing to save } for (i=0; i<Total_links; i++){ if (Links[i].from == m_last_mission) { sexp_unmark_persistent(Links[i].sexp); free_sexp2(Links[i].sexp); Links[i].sexp = m_tree.save_tree(Links[i].node); sexp_mark_persistent(Links[i].sexp); } } if (clear){ m_last_mission = -1; } }