/** * Set jump node name * * @param new_name New name to set */ void CJumpNode::SetName(const char *new_name) { Assert(new_name != NULL); #ifndef NDEBUG CJumpNode* check = jumpnode_get_by_name(new_name); Assert((check == this || !check)); #endif strcpy_s(m_name, new_name); }
// update wing structure(s) with dialog data. The data is first checked for errors. If // no errors occur, returns 0. If an error occurs, returns -1. If the update is bypassed, // returns 1. Bypass is necessary to avoid an infinite loop, and it doesn't actually // update the data. Bypass only occurs if bypass mode is active and we still get an error. // Once the error no longer occurs, bypass mode is cleared and data is updated. int wing_editor::update_data(int redraw) { char *str, old_name[255], buf[512]; int i, z; object *ptr; nprintf(("Fred routing", "Wing dialog save\n")); if (!GetSafeHwnd()) return 0; UpdateData(TRUE); UpdateData(TRUE); if (cur_wing >= 0) { for (i=0; i<MAX_WINGS; i++) if (Wings[i].wave_count && !stricmp(Wings[i].name, m_wing_name) && (i != cur_wing)) { if (bypass_errors) return 1; bypass_errors = 1; z = MessageBox("This wing name is already being used by another wing\n" "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); if (z == IDCANCEL) return -1; m_wing_name = _T(Wings[cur_wing].name); UpdateData(FALSE); } ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->type == OBJ_SHIP) { if (!stricmp(m_wing_name, Ships[ptr->instance].ship_name)) { if (bypass_errors) return 1; bypass_errors = 1; z = MessageBox("This wing name is already being used by a ship\n" "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); if (z == IDCANCEL) return -1; m_wing_name = _T(Wings[cur_wing].name); UpdateData(FALSE); } } ptr = GET_NEXT(ptr); } for (i=0; i<MAX_WAYPOINT_LISTS; i++) if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_wing_name)) { if (bypass_errors) return 1; bypass_errors = 1; z = MessageBox("This wing name is already being used by a waypoint path\n" "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); if (z == IDCANCEL) return -1; m_wing_name = _T(Wings[cur_wing].name); UpdateData(FALSE); } if(jumpnode_get_by_name(m_wing_name) != NULL) { if (bypass_errors) return 1; bypass_errors = 1; z = MessageBox("This wing name is already being used by a jump node\n" "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); if (z == IDCANCEL) return -1; m_wing_name = _T(Wings[cur_wing].name); UpdateData(FALSE); } strcpy(old_name, Wings[cur_wing].name); string_copy(Wings[cur_wing].name, m_wing_name, NAME_LENGTH, 1); update_data_safe(); update_custom_wing_indexes(); bypass_errors = 0; modified = 0; str = Wings[cur_wing].name; if (stricmp(old_name, str)) { update_sexp_references(old_name, str); ai_update_goal_references(REF_TYPE_WING, old_name, str); for (i=0; i<Num_reinforcements; i++) if (!stricmp(old_name, Reinforcements[i].name)) { Assert(strlen(str) < NAME_LENGTH); strcpy(Reinforcements[i].name, str); } for (i=0; i<Wings[cur_wing].wave_count; i++) { if ((Objects[wing_objects[cur_wing][i]].type == OBJ_SHIP) || (Objects[wing_objects[cur_wing][i]].type == OBJ_START)) { sprintf(buf, "%s %d", str, i + 1); rename_ship(Wings[cur_wing].ship_index[i], buf); } } Update_window = 1; } if (set_reinforcement(str, m_reinforcement) == 1) { free_sexp2(Wings[cur_wing].arrival_cue); Wings[cur_wing].arrival_cue = Locked_sexp_false; } } if (redraw) update_map_window(); return 0; }